[Gridflow-cvs] [svn] commit: r3290 - in /trunk/format: mpeg3.c netpbm.c opengl.c quicktimeapple.c quicktimehw.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Tue Mar 25 17:08:05 EDT 2008


Author: matju
Date: Tue Mar 25 17:08:05 2008
New Revision: 3290

Log:
adapt to new source_filter and use inlet 0 for all format methods

Modified:
    trunk/format/mpeg3.c
    trunk/format/netpbm.c
    trunk/format/opengl.c
    trunk/format/quicktimeapple.c
    trunk/format/quicktimehw.c

Modified: trunk/format/mpeg3.c
==============================================================================
--- trunk/format/mpeg3.c (original)
+++ trunk/format/mpeg3.c Tue Mar 25 17:08:05 2008
@@ -27,22 +27,23 @@
 #include <string.h>
 #include <errno.h>
 
-\class FormatMPEG3 < Format
-struct FormatMPEG3 : Format {
+\class FormatMPEG3 : Format {
 	mpeg3_t *mpeg;
 	int track;
 	FormatMPEG3 () : track(0) {}
 	\decl void initialize (Symbol mode, Symbol source, String filename);
-	\decl void seek (int frame);
-	\decl Ruby frame ();
-	\decl void close ();
+	\decl 0 seek (int frame);
+	\decl 0 bang ();
+	\decl 0 close ();
 };
 
-\def void seek (int frame) { mpeg3_set_frame(mpeg,frame,track); }
+\def 0 seek (int frame) { mpeg3_set_frame(mpeg,frame,track); }
 
-\def Ruby frame () {
+\def 0 bang () {
 	int nframe = mpeg3_get_frame(mpeg,track);
-	if (nframe >= mpeg3_video_frames(mpeg,track)) return Qfalse;
+	int nframes = mpeg3_video_frames(mpeg,track);
+	post("track=%d; nframe=%d; nframes=%d",track,nframe,nframes);
+	if (nframe >= nframes) {outlet_bang(bself->out[1]); return;}
 	int sx = mpeg3_video_width(mpeg,track);
 	int sy = mpeg3_video_height(mpeg,track);
 	int channels = 3;
@@ -60,10 +61,10 @@
 		out.send(bs,row);
 	}
 	delete[] (uint8 *)buf;
-	return INT2NUM(nframe);
+//	return INT2NUM(nframe);
 }
 
-\def void close () {
+\def 0 close () {
 //	fprintf(stderr, "begin mpeg3_close...\n");
 	if (mpeg) { mpeg3_close(mpeg); mpeg=0; }
 	rb_call_super(argc,argv);
@@ -89,11 +90,7 @@
 	if (!mpeg) RAISE("IO Error: can't open file `%s': %s", filename, strerror(errno));
 }
 
-\classinfo {
-	IEVAL(rself,"install '#io:mpeg',1,1;@flags=4;"
-	"@comment='Motion Picture Expert Group Format"
-	" (using HeroineWarrior\\'s)';suffixes_are'mpg,mpeg'");
-}
+\classinfo {install_format("#io:mpeg",1,1,4,"mpg mpeg");}
 \end class FormatMPEG3
 void startup_mpeg3 () {
 	\startall

Modified: trunk/format/netpbm.c
==============================================================================
--- trunk/format/netpbm.c (original)
+++ trunk/format/netpbm.c Tue Mar 25 17:08:05 2008
@@ -26,13 +26,13 @@
 #include <pam.h>
 };
 
-\class FormatNetPBM < Format {
+\class FormatNetPBM : Format {
 	struct pam inpam, outpam;
 	int fd;
 	FILE *f;
 	\grin 0
 	\decl void initialize(Symbol mode, Symbol source, String filename);
-	\decl void frame ();
+	\decl 0 bang ();
 };
 \def void initialize(Symbol mode, Symbol source, String filename) {
 	rb_call_super(argc,argv);
@@ -44,7 +44,7 @@
 	memset(& inpam,sizeof(pam),0);
 	memset(&outpam,sizeof(pam),0);
 }
-\def void frame () {
+\def 0 bang () {
 	//inpam.allocation_depth = 3;
 	pnm_readpaminit(f, &inpam, /*PAM_STRUCT_SIZE(tuple_type)*/ sizeof(struct pam));
 	tuple *tuplerow = pnm_allocpamrow(&inpam);
@@ -94,10 +94,10 @@
 	fflush(f);
 } GRID_END
 
-\classinfo { IEVAL(rself,"install('#io:netpbm',1,1);@mode=6; suffixes_are 'ppm','pgm','pnm','pam'"); }
+\classinfo {install_format("#io:netpbm",1,1,6,"ppm pgm pnm pam");}
 \end class FormatNetPBM
 
 void startup_netpbm () {
-	pm_init(0, 0);
+	pm_init(0,0);
 	\startall
 }

Modified: trunk/format/opengl.c
==============================================================================
--- trunk/format/opengl.c (original)
+++ trunk/format/opengl.c Tue Mar 25 17:08:05 2008
@@ -41,17 +41,16 @@
 
 static bool in_use = false;
 
-\class FormatOpenGL < Format
-struct FormatOpenGL : Format {
+\class FormatOpenGL : Format {
 	int window;
 	GLuint gltex;
 	P<BitPacking> bit_packing;
 	P<Dim> dim;
-	uint8 * buf;
+	uint8 *buf;
 	\decl void call ();
 	\decl void initialize (Symbol mode);
-	\decl void close ();
-	\decl void resize_window (int sx, int sy);
+	\decl 0 close ();
+	\decl 0 resize_window (int sx, int sy);
 	\grin 0
 };
 
@@ -83,7 +82,7 @@
 	IEVAL(rself,"@clock.delay 100");
 }
 
-\def void resize_window (int sx, int sy) {
+\def 0 resize_window (int sx, int sy) {
 	dim = new Dim(sy,sx,3);
 	char foo[666];
 	sprintf(foo,"GridFlow/GL (%d,%d,3)",sy,sx);
@@ -133,7 +132,7 @@
 	} GRID_FINISH {
 } GRID_END
 
-\def void close () {
+\def 0 close () {
 	IEVAL(rself,"@clock.unset");
 	if (gltex) glDeleteTextures(1, (GLuint*)&gltex);
 	if (buf) delete buf;
@@ -172,9 +171,7 @@
 	gfpost("@clock = Clock.new self");
 }
 
-\classinfo {
-	IEVAL(rself,"install '#io:opengl',1,1;@comment='Silicon Graphics OpenGL'");
-}
+\classinfo {install_format("#io:opengl",1,1,2,"");}
 \end class FormatOpenGL
 void startup_opengl () {
 	\startall

Modified: trunk/format/quicktimeapple.c
==============================================================================
--- trunk/format/quicktimeapple.c (original)
+++ trunk/format/quicktimeapple.c Tue Mar 25 17:08:05 2008
@@ -175,8 +175,7 @@
 */
 #endif
 
-\class FormatQuickTimeCamera < Format
-struct FormatQuickTimeCamera : Format {
+\class FormatQuickTimeCamera : Format {
   P<Dim> dim;
   uint8 *buf;
   VDC vdc;
@@ -193,8 +192,8 @@
 //int m_colorspace;
   FormatQuickTimeCamera() : vdc(0) {}
   \decl void initialize (Symbol mode, Symbol source, String filename);
-  \decl void frame ();
-  \decl void close ();
+  \decl 0 frame ();
+  \decl 0 close ();
   \grin 0 int
 };
 
@@ -303,12 +302,12 @@
 }
 */
 
-\def void frame () {
+\def 0 frame () {
     GridOutlet out(this,0,dim);
     out.send(dim->prod(),buf);
 }
 
-\def void close () {
+\def 0 close () {
   if (m_vc) {
     if (::SGDisposeChannel(m_sg, m_vc)) RAISE("SGDisposeChannel");
     m_vc=0;
@@ -336,19 +335,9 @@
 } GRID_FLOW {
 } GRID_FINISH {
 } GRID_END
-
-\classinfo {
-	IEVAL(rself,
-\ruby
-    install '#io:quicktimecamera',1,1
-    @comment="Apple Quicktime (CAMERA MODULE)"
-    @flags=4
-\end ruby
-);}
-\end class FormatQuickTimeCamera
-
-\class FormatQuickTimeApple < Format
-struct FormatQuickTimeApple : Format {
+\end class FormatQuickTimeCamera {install_format("#io:quicktimecamera",1,1,4,"");}
+
+\class FormatQuickTimeApple : Format {
 	Movie movie;
 	TimeValue time;
 	short movie_file;
@@ -356,23 +345,20 @@
 	uint8 *buffer;
 	P<Dim> dim;
 	int nframe, nframes;
-
 	FormatQuickTimeApple() : movie(0), time(0), movie_file(0), gw(0),
 		buffer(), dim(0), nframe(0), nframes(0) {}
 	\decl void initialize (Symbol mode, Symbol source, String filename);
-	\decl void close ();
-	\decl void codec_m (String c);
-	\decl void colorspace_m (Symbol c);
-	\decl Ruby frame ();
-	\decl void seek (int frame);
+	\decl 0 close ();
+	\decl 0 codec_m (String c);
+	\decl 0 colorspace_m (Symbol c);
+	\decl 0 bang ();
+	\decl 0 seek (int frame);
 	\grin 0
 };
 
-\def void seek (int frame) {
-	nframe=frame;
-}
-
-\def Ruby frame () {
+\def 0 seek (int frame) {nframe=frame;}
+
+\def 0 bang () {
 	CGrafPtr savedPort;
 	GDHandle savedDevice;
 	SetMovieGWorld(movie,gw,GetGWorldDevice(gw));
@@ -425,10 +411,10 @@
 } GRID_FINISH {
 } GRID_END
 
-\def void codec_m      (String c) { RAISE("Unimplemented. Sorry."); }
-\def void colorspace_m (Symbol c) { RAISE("Unimplemented. Sorry."); }
-
-\def void close () {
+\def 0 codec_m      (String c) { RAISE("Unimplemented. Sorry."); }
+\def 0 colorspace_m (Symbol c) { RAISE("Unimplemented. Sorry."); }
+
+\def 0 close () {
 //!@#$
 	if (movie) {
 		DisposeMovie(movie);
@@ -483,12 +469,9 @@
 
 \classinfo {
 	EnterMovies();
+	install_format("#io:quicktime",1,1,4,"mov");
 IEVAL(rself,
 \ruby
-  install '#io:quicktime',1,1
-  @comment="Apple Quicktime (using Apple's)"
-  @flags=4
-  suffixes_are'mov'
   def self.new(mode,source,filename)
     if source==:camera then FormatQuickTimeCamera.new(mode,source,filename) else super end
   end

Modified: trunk/format/quicktimehw.c
==============================================================================
--- trunk/format/quicktimehw.c (original)
+++ trunk/format/quicktimehw.c Tue Mar 25 17:08:05 2008
@@ -2,7 +2,7 @@
 	$Id$
 
 	GridFlow
-	Copyright (c) 2001-2006 by Mathieu Bouchard
+	Copyright (c) 2001-2008 by Mathieu Bouchard
 
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
@@ -27,8 +27,7 @@
 #include <string.h>
 #include <errno.h>
 
-\class FormatQuickTimeHW < Format
-struct FormatQuickTimeHW : Format {
+\class FormatQuickTimeHW : Format {
 	quicktime_t *anim;
 	int track;
 	P<Dim> dim;
@@ -41,33 +40,28 @@
 	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) {}
 	\decl void initialize (Symbol mode, Symbol source, String filename);
-	\decl void close ();
-	\decl Ruby frame ();
-	\decl void seek (int frame);
-
-	\decl void _0_force_size (int32 height, int32 width);
-	\decl void _0_codec (String c);
-	\decl void _0_colorspace (Symbol c);
-	\decl void _0_parameter (Symbol name, int32 value);
-	\decl void _0_framerate (float64 f);
-	\decl void _0_size (int32 height, int32 width);
-	\decl void _0_get ();
+	\decl 0 close ();
+	\decl 0 bang ();
+	\decl 0 seek (int frame);
+	\decl 0 force_size (int32 height, int32 width);
+	\decl 0 codec (String c);
+	\decl 0 colorspace (Symbol c);
+	\decl 0 parameter (Symbol name, int32 value);
+	\decl 0 framerate (float64 f);
+	\decl 0 size (int32 height, int32 width);
+	\decl 0 get ();
 	\grin 0 int
 };
 
-\def void _0_force_size (int32 height, int32 width) { force = new Dim(height, width); }
-\def void seek (int frame) {quicktime_set_video_position(anim,frame,track);}
-
-\def Ruby frame () {
+\def 0 force_size (int32 height, int32 width) { force = new Dim(height, width); }
+\def 0 seek (int frame) {quicktime_set_video_position(anim,frame,track);}
+
+\def 0 bang () {
 	int nframe = quicktime_video_position(anim,track);
-	if (nframe >= length) {
-//		post("nframe=%d length=%d",nframe,length);
-		return Qfalse;
-	}
+	if (nframe >= length) {outlet_bang(bself->out[1]); return;}
 	/* if it works, only do it once, to avoid silly stderr messages forgotten in LQT */
 	if (!quicktime_reads_cmodel(anim,colorspace,0) && !started) {
 		RAISE("LQT says this video cannot be decoded into the chosen colorspace");
@@ -92,23 +86,23 @@
 	NumberTypeE_find(rb_ivar_get(rself,SI(@cast))));
 	out.give(sy*sx*channels,buf);
 	started=true;
-	return INT2NUM(nframe);
+//	return INT2NUM(nframe);
 }
 
 //!@#$ should also support symbol values (how?)
-\def void _0_parameter (Symbol name, int32 value) {
+\def 0 parameter (Symbol name, int32 value) {
 	int val = value;
 	//post("quicktime_set_parameter %s %d",(char*)rb_sym_name(name), val);
 	quicktime_set_parameter(anim, (char*)rb_sym_name(name), &val);
 	if (name==SYM(jpeg_quality)) jpeg_quality=value;
 }
 
-\def void _0_framerate (float64 f) {
+\def 0 framerate (float64 f) {
 	framerate=f;
 	quicktime_set_framerate(anim, f);
 }
 
-\def void _0_size (int32 height, int32 width) {
+\def 0 size (int32 height, int32 width) {
 	if (dim) RAISE("video size already set!");
 	// first frame: have to do setup
 	dim = new Dim(height, width, 3);
@@ -147,7 +141,7 @@
 } GRID_FINISH {
 } GRID_END
 
-\def void _0_codec (String c) {
+\def 0 codec (String c) {
 	//fprintf(stderr,"codec = %s\n",rb_str_ptr(rb_inspect(c)));
 #ifdef LQT_VERSION
 	char buf[5];
@@ -162,7 +156,7 @@
 	codec = strdup(buf);
 }
 
-\def void _0_colorspace (Symbol c) {
+\def 0 colorspace (Symbol c) {
 	if (0) {
 	} else if (c==SYM(rgb))     { channels=3; colorspace=BC_RGB888; 
 	} else if (c==SYM(rgba))    { channels=4; colorspace=BC_RGBA8888;
@@ -174,14 +168,13 @@
 	} else RAISE("unknown colorspace '%s' (supported: rgb, rgba, bgr, bgrn, yuv, yuva)",rb_sym_name(c));
 }
 
-\def void close () {
+\def 0 close () {
 	if (anim) { quicktime_close(anim); anim=0; }
 	rb_call_super(argc,argv);
 }
 
-\def void _0_get () {
-/*
-	t_atom a[1];
+\def 0 get () {
+/*	t_atom a[1];
 	SETFLOAT(a,(float)length);
 	outlet_anything(bself->out[1],gensym("frames"),1,a);
 */
@@ -219,19 +212,9 @@
 	bit_packing = new BitPacking(is_le(),3,3,mask);
 }
 
-\classinfo {
-	IEVAL(rself,
-\ruby
-  install '#io:quicktime',1,2
-  @comment=%[Burkhard Plaum's (or HeroineWarrior's) libquicktime]
-  suffixes_are 'mov'
-  @flags=6
-  def self.info; %[codecs: #{@codecs.keys.join' '}] end
-\end ruby
-);
-
+\classinfo {install_format("#io:quicktime",1,2,6,"mov");
+//  def self.info; %[codecs: #{@codecs.keys.join' '}] end
 //#define L fprintf(stderr,"%s:%d in %s\n",__FILE__,__LINE__,__PRETTY_FUNCTION__);
-
 #ifdef LQT_VERSION
 	lqt_registry_init();
 	int n = lqt_get_num_video_codecs();



More information about the Gridflow-cvs mailing list