[Gridflow-cvs] [svn] commit: r3577 - in /trunk/format: mpeg3.c quicktimehw.c videodev.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Wed Apr 16 19:40:07 EDT 2008


Author: matju
Date: Wed Apr 16 19:40:07 2008
New Revision: 3577

Log:
use \constructor

Modified:
    trunk/format/mpeg3.c
    trunk/format/quicktimehw.c
    trunk/format/videodev.c

Modified: trunk/format/mpeg3.c
==============================================================================
--- trunk/format/mpeg3.c (original)
+++ trunk/format/mpeg3.c Wed Apr 16 19:40:07 2008
@@ -30,9 +30,21 @@
 \class FormatMPEG3 : Format {
 	mpeg3_t *mpeg;
 	int track;
-	FormatMPEG3 () : track(0) {}
 	~FormatMPEG3 () {if (mpeg) {mpeg3_close(mpeg); mpeg=0;}}
-	\decl void initialize (t_symbol *mode, string filename);
+	\constructor (t_symbol *mode, string filename) {
+		track=0;
+	// libmpeg3 may be nice, but it won't take a filehandle, only filename
+		if (mode!=gensym("in")) RAISE("read-only, sorry");
+		filename = gf_find_file(filename);
+	#ifdef MPEG3_UNDEFINED_ERROR
+		int err;
+		mpeg = mpeg3_open((char *)filename.data(),&err);
+		post("mpeg error code = %d",err);
+	#else
+		mpeg = mpeg3_open((char *)filename.data());
+	#endif
+		if (!mpeg) RAISE("IO Error: can't open file `%s': %s", filename.data(), strerror(errno));
+	}
 	\decl 0 seek (int frame);
 	\decl 0 bang ();
 };
@@ -60,23 +72,6 @@
 //	return INT2NUM(nframe);
 }
 
-// libmpeg3 may be nice, but it won't take a filehandle, only filename
-\def void initialize (t_symbol *mode, string filename) {
-	SUPER;
-	if (mode!=gensym("in")) RAISE("read-only, sorry");
-	filename = gf_find_file(filename);
-#ifdef MPEG3_UNDEFINED_ERROR
-	{
-		int err;
-		mpeg = mpeg3_open((char *)filename.data(),&err);
-		post("mpeg error code = %d",err);
-	}
-#else
-	mpeg = mpeg3_open((char *)filename.data());
-#endif
-	if (!mpeg) RAISE("IO Error: can't open file `%s': %s", filename.data(), strerror(errno));
-}
-
 \classinfo {install_format("#io.mpeg",4,"mpg mpeg");}
 \end class FormatMPEG3
 void startup_mpeg3 () {

Modified: trunk/format/quicktimehw.c
==============================================================================
--- trunk/format/quicktimehw.c (original)
+++ trunk/format/quicktimehw.c Wed Apr 16 19:40:07 2008
@@ -45,10 +45,33 @@
 	float64 framerate;
 	P<BitPacking> bit_packing;
 	int jpeg_quality; // in theory we shouldn't need this, but...
-	FormatQuickTimeHW() : track(0), dim(0), codec(QUICKTIME_RAW), 
-		started(false), force(0), framerate(29.97), bit_packing(0), jpeg_quality(75) {}
 	~FormatQuickTimeHW() {if (anim) quicktime_close(anim);}
-	\decl void initialize (t_symbol *mode, string filename);
+	\constructor (t_symbol *mode, string filename) {
+		track=0; dim=0; codec=QUICKTIME_RAW; started=false; force=0; framerate=29.97; bit_packing=0; jpeg_quality=75;
+// libquicktime may be nice, but it won't take a filehandle, only filename
+		filename = gf_find_file(filename);
+		anim = quicktime_open((char *)filename.data(),mode==gensym("in"),mode==gensym("out"));
+		if (!anim) RAISE("can't open file `%s': %s (or some other reason that libquicktime won't tell us)",
+			filename.data(), strerror(errno));
+		if (mode==gensym("in")) {
+			length = quicktime_video_length(anim,track);
+			post("quicktime: codec=%s height=%d width=%d depth=%d framerate=%f",
+				quicktime_video_compressor(anim,track),
+				quicktime_video_height(anim,track),
+				quicktime_video_width(anim,track),
+				quicktime_video_depth(anim,track),
+				quicktime_frame_rate(anim,track));
+	/* This doesn't really work: (is it just for encoding?)
+			if (!quicktime_supported_video(anim,track))
+				RAISE("quicktime: unsupported codec: %s",
+				      quicktime_video_compressor(anim,track));
+	*/
+		}
+		_0_colorspace(0,0,string("rgb"));
+		quicktime_set_cpus(anim,1);
+		uint32 mask[3] = {0x0000ff,0x00ff00,0xff0000};
+		bit_packing = new BitPacking(is_le(),3,3,mask);
+	}
 	\decl 0 bang ();
 	\decl 0 seek (int frame);
 	\decl 0 force_size (int32 height, int32 width);
@@ -180,33 +203,6 @@
 	//SUPER;
 }
 
-// libquicktime may be nice, but it won't take a filehandle, only filename
-\def void initialize (t_symbol *mode, string filename) {
-	SUPER;
-	filename = gf_find_file(filename);
-	anim = quicktime_open((char *)filename.data(),mode==gensym("in"),mode==gensym("out"));
-	if (!anim) RAISE("can't open file `%s': %s (or some other reason that libquicktime won't tell us)",
-		filename.data(), strerror(errno));
-	if (mode==gensym("in")) {
-		length = quicktime_video_length(anim,track);
-		post("quicktime: codec=%s height=%d width=%d depth=%d framerate=%f",
-			quicktime_video_compressor(anim,track),
-			quicktime_video_height(anim,track),
-			quicktime_video_width(anim,track),
-			quicktime_video_depth(anim,track),
-			quicktime_frame_rate(anim,track));
-/* This doesn't really work: (is it just for encoding?)
-		if (!quicktime_supported_video(anim,track))
-			RAISE("quicktime: unsupported codec: %s",
-			      quicktime_video_compressor(anim,track));
-*/
-	}
-	_0_colorspace(0,0,string("rgb"));
-	quicktime_set_cpus(anim,1);
-	uint32 mask[3] = {0x0000ff,0x00ff00,0xff0000};
-	bit_packing = new BitPacking(is_le(),3,3,mask);
-}
-
 \classinfo {install_format("#io.quicktime",6,"mov");
 //  def self.info; %[codecs: #{@codecs.keys.join' '}] end
 //#define L fprintf(stderr,"%s:%d in %s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__);

Modified: trunk/format/videodev.c
==============================================================================
--- trunk/format/videodev.c (original)
+++ trunk/format/videodev.c Wed Apr 16 19:40:07 2008
@@ -237,7 +237,13 @@
 	string colorspace;
 	int palettes; /* bitfield */
 
-	FormatVideoDev () : queuesize(0), queuemax(2), next_frame(0), use_mmap(true), use_pwc(false), bit_packing(0), dim(0) {}
+	\constructor (string mode, string filename) {
+		queuesize=0; queuemax=2; next_frame=0; use_mmap=true; use_pwc=false; bit_packing=0; dim=0;
+		image=0;
+		f = fopen(filename.data(),"r+");
+		fd = fileno(f);
+		initialize2(); // name conflict...
+	}
 	void frame_finished (uint8 * buf);
 
 	void alloc_image ();
@@ -741,14 +747,6 @@
 	_0_channel(0,0,0);
 }
 
-\def void initialize (string mode, string filename) {
-	SUPER;
-	image=0;
-	f = fopen(filename.data(),"r+");
-	fd = fileno(f);
-	initialize2(); // name conflict...
-}
-
 \end class FormatVideoDev {install_format("#io.videodev",4,"");}
 void startup_videodev () {
 	\startall



More information about the Gridflow-cvs mailing list