diff options
-rw-r--r-- | CHANGES.LOG | 3 | ||||
-rw-r--r-- | doc/help-pdp_fqt.pd | 53 | ||||
-rw-r--r-- | doc/help-pdp_yqt.pd | 27 | ||||
-rw-r--r-- | modules/Makefile | 2 | ||||
-rw-r--r-- | modules/Makefile.in | 2 | ||||
-rw-r--r-- | modules/pdp_fqt.c | 189 | ||||
-rw-r--r-- | modules/pdp_yqt.c | 31 | ||||
-rw-r--r-- | system/pidip.c | 2 |
8 files changed, 139 insertions, 170 deletions
diff --git a/CHANGES.LOG b/CHANGES.LOG index 319d971..5046876 100644 --- a/CHANGES.LOG +++ b/CHANGES.LOG @@ -1,6 +1,7 @@ 0.12.10 added pdp_fqt : fast quicktime reader ( frames are cached in memory and no audio decoding ) - added help patches for pdp_yqt and pdp_fqt + added pdp_fcqt : fast quicktime reader ( same as pdp_fqt but frames are compressed ) + added help patches for pdp_yqt, pdp_fqt and pdp_fcqt adaptations for newer autoconfs 0.12.9 fixed pdp_ripple diff --git a/doc/help-pdp_fqt.pd b/doc/help-pdp_fqt.pd index 0fe6c1b..0f997a6 100644 --- a/doc/help-pdp_fqt.pd +++ b/doc/help-pdp_fqt.pd @@ -1,10 +1,6 @@ #N canvas 237 21 712 664 10; -#X obj 218 293 pdp_xv; #X obj 268 64 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; -#X msg 123 136 loop \$1; -#X obj 124 114 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 -1; #X msg 370 44 open \$1; #X obj 369 20 openpanel; #X obj 354 3 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 @@ -24,34 +20,33 @@ #X floatatom 295 282 5 0 0 0 - - -; #X text 315 257 Number of frames decoded; #X text 344 281 Total number of frames; -#X text 81 360 pdp_fqt : fast quicktime movie reader -; -#X text 81 377 ( frames are cached in memory and no audio decoding ); -#X obj 225 222 pdp_fqt; +#X text 81 360 pdp_fqt : fast quicktime movie reader; +#X text 81 377 ( frames are cached in memory and no audio decoding +); #X floatatom 317 164 5 0 0 0 - - -; #X text 368 164 Frame command; -#X floatatom 320 209 5 0 0 0 - - -; -#X text 370 209 Gain; #X obj 316 183 t b f; #X text 81 394 written by Yves Degoyon; -#X connect 1 0 10 0; -#X connect 2 0 22 0; +#X obj 218 293 pdp_xv; +#X floatatom 328 304 5 0 0 0 - - -; +#X text 373 304 Frame rate; +#X obj 225 222 pdp_fqt; +#X connect 0 0 7 0; +#X connect 1 0 26 0; +#X connect 2 0 1 0; #X connect 3 0 2 0; -#X connect 4 0 22 0; -#X connect 5 0 4 0; -#X connect 6 0 5 0; -#X connect 7 0 10 1; +#X connect 4 0 7 1; +#X connect 5 0 7 0; +#X connect 6 0 4 0; +#X connect 7 0 26 0; #X connect 8 0 10 0; -#X connect 9 0 7 0; -#X connect 10 0 22 0; -#X connect 11 0 13 0; -#X connect 12 0 15 0; -#X connect 13 0 12 0; -#X connect 15 0 14 0; -#X connect 22 0 0 0; -#X connect 22 1 16 0; -#X connect 22 2 17 0; -#X connect 23 0 27 0; -#X connect 25 0 22 2; -#X connect 27 0 22 0; -#X connect 27 1 22 1; +#X connect 9 0 12 0; +#X connect 10 0 9 0; +#X connect 12 0 11 0; +#X connect 19 0 21 0; +#X connect 21 0 26 0; +#X connect 21 1 26 1; +#X connect 26 0 23 0; +#X connect 26 1 13 0; +#X connect 26 2 14 0; +#X connect 26 3 24 0; diff --git a/doc/help-pdp_yqt.pd b/doc/help-pdp_yqt.pd index fddc611..ab21309 100644 --- a/doc/help-pdp_yqt.pd +++ b/doc/help-pdp_yqt.pd @@ -3,7 +3,7 @@ #X obj 268 64 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; #X msg 123 136 loop \$1; -#X obj 124 114 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 1 +#X obj 124 114 tgl 15 0 empty empty empty 20 8 0 8 -262144 -1 -1 0 1; #X msg 370 44 open \$1; #X obj 369 20 openpanel; @@ -26,8 +26,6 @@ #X text 346 306 Total number of frames; #X floatatom 317 164 5 0 0 0 - - -; #X text 368 164 Frame command; -#X floatatom 320 209 5 0 0 0 - - -; -#X text 370 209 Gain; #X obj 316 183 t b f; #X obj 296 261 dac~; #X obj 225 223 pdp_yqt; @@ -36,25 +34,24 @@ #X text 82 392 with big plundering from pdp_qt ( Tom Schouten ); #X text 81 376 written by Yves Degoyon; #X connect 1 0 10 0; -#X connect 2 0 26 0; +#X connect 2 0 24 0; #X connect 3 0 2 0; -#X connect 4 0 26 0; +#X connect 4 0 24 0; #X connect 5 0 4 0; #X connect 6 0 5 0; #X connect 7 0 10 1; #X connect 8 0 10 0; #X connect 9 0 7 0; -#X connect 10 0 26 0; +#X connect 10 0 24 0; #X connect 11 0 13 0; #X connect 12 0 15 0; #X connect 13 0 12 0; #X connect 15 0 14 0; -#X connect 20 0 24 0; -#X connect 22 0 26 2; -#X connect 24 0 26 0; -#X connect 24 1 26 1; -#X connect 26 0 0 0; -#X connect 26 1 16 0; -#X connect 26 2 17 0; -#X connect 26 3 25 0; -#X connect 26 4 25 1; +#X connect 20 0 22 0; +#X connect 22 0 24 0; +#X connect 22 1 24 1; +#X connect 24 0 0 0; +#X connect 24 1 16 0; +#X connect 24 2 17 0; +#X connect 24 3 23 0; +#X connect 24 4 23 1; diff --git a/modules/Makefile b/modules/Makefile index 4d11bf1..8d6c12f 100644 --- a/modules/Makefile +++ b/modules/Makefile @@ -15,6 +15,6 @@ OBJECTS = pdp_intrusion.o pdp_yqt.o pdp_simura.o pdp_underwatch.o \ pdp_ffmpeg~.o pdp_live~.o pdp_segsnd~.o pdp_noquark.o \ pdp_juxta.o pdp_capture.o pdp_smuck.o pdp_lumafilt.o \ pdp_transition.o pdp_imgloader.o pdp_imgsaver.o pdp_cache.o \ - pdp_canvas.o pdp_pen.o pdp_shape.o pdp_fqt.o + pdp_canvas.o pdp_pen.o pdp_shape.o pdp_fqt.o pdp_fcqt.o all_modules: $(OBJECTS) diff --git a/modules/Makefile.in b/modules/Makefile.in index 3b0faac..e7f9de0 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -14,6 +14,6 @@ OBJECTS = pdp_intrusion.o pdp_yqt.o pdp_simura.o pdp_underwatch.o \ pdp_ffmpeg~.o pdp_live~.o pdp_segsnd~.o pdp_noquark.o \ pdp_juxta.o pdp_capture.o pdp_smuck.o pdp_lumafilt.o \ pdp_transition.o pdp_imgloader.o pdp_imgsaver.o pdp_cache.o \ - pdp_canvas.o pdp_pen.o pdp_shape.o pdp_fqt.o + pdp_canvas.o pdp_pen.o pdp_shape.o pdp_fqt.o pdp_fcqt.o all_modules: $(OBJECTS) diff --git a/modules/pdp_fqt.c b/modules/pdp_fqt.c index c534849..ccbaf57 100644 --- a/modules/pdp_fqt.c +++ b/modules/pdp_fqt.c @@ -22,30 +22,32 @@ #include "pdp.h" #include "pdp_llconv.h" +#include "time.h" +#include "sys/time.h" #include <quicktime/lqt.h> #include <quicktime/colormodels.h> -typedef struct pdp_fqt_data -{ - short int gain[4]; -} t_pdp_fqt_data; - typedef struct pdp_fqt_struct { t_object x_obj; t_float x_f; t_outlet *x_outlet0; - t_outlet *x_outlet1; - t_outlet *x_outlet2; + t_outlet *x_curframe; + t_outlet *x_nbframes; + t_outlet *x_framerate; int packet0; bool initialized; - unsigned int x_vwidth; - unsigned int x_vheight; - - bool loop; + t_int x_vwidth; + t_int x_vheight; + t_int x_size; + t_int x_fsize; // frames size + t_int x_length; + t_int x_current_frame; + t_int x_cursec; + t_int x_framescount; unsigned char * qt_rows[3]; @@ -53,7 +55,8 @@ typedef struct pdp_fqt_struct quicktime_t *qt; int qt_cmodel; - t_pdp_fqt_data *state_data; + unsigned int** x_frames; + t_int* x_fsizes; } t_pdp_fqt; @@ -61,9 +64,16 @@ typedef struct pdp_fqt_struct static void pdp_fqt_close(t_pdp_fqt *x) { + t_int fi; + if (x->initialized){ quicktime_close(x->qt); - free(x->qt_frame); + if ( x->qt_frame ) freebytes(x->qt_frame, x->x_size*3/2); + for ( fi=0; fi<x->x_length; fi++ ) + { + if ( x->x_frames[fi] ) freebytes( x->x_frames[fi], x->x_fsizes[fi] ); + } + if ( x->x_frames ) freebytes( x->x_frames, x->x_length*sizeof(unsigned int*) ); x->initialized = false; } @@ -71,13 +81,13 @@ static void pdp_fqt_close(t_pdp_fqt *x) static void pdp_fqt_open(t_pdp_fqt *x, t_symbol *name) { - unsigned int size; + t_int fi; post("pdp_fqt: opening %s", name->s_name); pdp_fqt_close(x); - x->qt = quicktime_open(name->s_name, 1, 0); + x->qt = quicktime_open(name->s_name, 1, 0); // read=yes, write=no if (!(x->qt)){ post("pdp_fqt: error opening qt file"); @@ -103,86 +113,105 @@ static void pdp_fqt_open(t_pdp_fqt *x, t_symbol *name) x->qt_cmodel = BC_YUV420P; x->x_vwidth = quicktime_video_width(x->qt,0); x->x_vheight = quicktime_video_height(x->qt,0); - x->qt_frame = (unsigned char*)malloc(x->x_vwidth*x->x_vheight*4); - size = x->x_vwidth * x->x_vheight; + x->x_size = x->x_vwidth * x->x_vheight; + x->qt_frame = (unsigned char*)getbytes(x->x_size*3/2); x->qt_rows[0] = &x->qt_frame[0]; - x->qt_rows[2] = &x->qt_frame[size]; - x->qt_rows[1] = &x->qt_frame[size + (size>>2)]; + x->qt_rows[2] = &x->qt_frame[x->x_size]; + x->qt_rows[1] = &x->qt_frame[x->x_size + (x->x_size>>2)]; quicktime_set_cmodel(x->qt, x->qt_cmodel); x->initialized = true; - outlet_float(x->x_outlet2, (float)quicktime_video_length(x->qt,0)); + x->x_length = quicktime_video_length(x->qt,0); + outlet_float(x->x_nbframes, (float)x->x_length); + + } + // read all frames + x->x_current_frame = 0; + x->x_frames = (unsigned int**) getbytes( x->x_length*sizeof(unsigned int*) ); + x->x_fsizes = (t_int*) getbytes( x->x_length*sizeof(t_int) ); + x->x_fsize = 0; + if ( !x->x_frames ) + { + post("pdp_fqt: couldn't allocate memory for frames" ); + quicktime_close(x->qt); + x->initialized = false; + return; } + + for ( fi=0; fi<x->x_length; fi++ ) + { + x->x_fsizes[fi] = ((x->x_size)+(x->x_size>>1))<<1; + x->x_fsize += x->x_fsizes[fi]; + x->x_frames[fi] = (unsigned int*) getbytes( x->x_fsizes[fi] ); + if ( !x->x_frames[fi] ) + { + post("pdp_fqt: couldn't allocate memory for frames" ); + quicktime_close(x->qt); + x->initialized = false; + return; + } + + lqt_decode_video(x->qt, x->qt_rows, 0); + + switch(x->qt_cmodel){ + case BC_YUV420P: + pdp_llconv(x->qt_frame, RIF_YVU__P411_U8, x->x_frames[fi], RIF_YVU__P411_S16, + x->x_vwidth, x->x_vheight); + break; + + default: + post("pdp_fqt : error on decode: unkown colour model"); + break; + } + + } + + post("pdp_fqt: allocated memory for %d frames (size=%db %dM)", + x->x_length, x->x_fsize, x->x_fsize/(1024*1024) ); } static void pdp_fqt_bang(t_pdp_fqt *x) { - unsigned int w, h, nbpixels, packet_size; - int object, length, pos, i, j; + int object; short int* data; t_pdp* header; - - static short int gain[4] = {0x7fff, 0x7fff, 0x7fff, 0x7fff}; + struct timeval etime; if (!(x->initialized)){ //post("pdp_fqt: no qt file opened"); return; } - w = x->x_vwidth; - h = x->x_vheight; - nbpixels = w * h; - packet_size = (nbpixels + (nbpixels >> 1)) << 1; - object = pdp_packet_new_image_YCrCb( x->x_vwidth, x->x_vheight ); header = pdp_packet_header(object); data = (short int *) pdp_packet_data(object); header->info.image.encoding = PDP_IMAGE_YV12; - header->info.image.width = w; - header->info.image.height = h; - - length = quicktime_video_length(x->qt,0); - pos = quicktime_video_position(x->qt,0); - // post("pdp_fqt : video position : %d length =%d", pos, length ); - - if (pos >= length){ - pos = (x->loop) ? 0 : length - 1; - // post("pdp_fqt : setting video position to %d", pos); - quicktime_set_video_position(x->qt, pos, 0); - } - - lqt_decode_video(x->qt, x->qt_rows, 0); + header->info.image.width = x->x_vwidth; + header->info.image.height = x->x_vheight; - switch(x->qt_cmodel){ - case BC_YUV420P: - pdp_llconv(x->qt_frame, RIF_YVU__P411_U8, data, RIF_YVU__P411_S16, x->x_vwidth, x->x_vheight); - break; + x->x_current_frame = ( x->x_current_frame + 1 ) % x->x_length; + // post( "pdp_fqt : current frame : %d", x->x_current_frame ); - case BC_YUV422: - pdp_llconv(x->qt_frame, RIF_YUYV_P____U8, data, RIF_YVU__P411_S16, x->x_vwidth, x->x_vheight); - break; + memcpy( data, x->x_frames[x->x_current_frame], x->x_fsizes[x->x_current_frame] ); - case BC_RGB888: - pdp_llconv(x->qt_frame, RIF_RGB__P____U8, data, RIF_YVU__P411_S16, x->x_vwidth, x->x_vheight); - break; - - default: - post("pdp_fqt : error on decode: unkown colour model"); - break; + if ( gettimeofday(&etime, NULL) == -1) + { + post("pdp_fcqt : could not get time" ); } - - outlet_float(x->x_outlet1, (float)pos); - pdp_packet_pass_if_valid(x->x_outlet0, &object); + if ( etime.tv_sec != x->x_cursec ) + { + x->x_cursec = etime.tv_sec; + outlet_float(x->x_framerate, (float)x->x_framescount); + x->x_framescount = 0; + } + x->x_framescount++; -} + outlet_float(x->x_curframe, (float)x->x_current_frame); + pdp_packet_pass_if_valid(x->x_outlet0, &object); -static void pdp_fqt_loop(t_pdp_fqt *x, t_floatarg loop) -{ - int loopi = (int)loop; - x->loop = !(loopi == 0); } static void pdp_fqt_frame_cold(t_pdp_fqt *x, t_floatarg frameindex) @@ -208,25 +237,8 @@ static void pdp_fqt_frame(t_pdp_fqt *x, t_floatarg frameindex) pdp_fqt_bang(x); } -static void pdp_fqt_gain(t_pdp_fqt *x, t_floatarg f) -{ - int i; - short int g; - float bound = (float)0x7fff; - - f *= (float)0x7fff; - - f = (f>bound) ? bound : f; - f = (f<-bound) ? -bound : f; - - g = (short int)f; - - for (i=0; i<4; i++) x->state_data->gain[i] = g; -} - static void pdp_fqt_free(t_pdp_fqt *x) { - free (x->state_data); pdp_fqt_close(x); } @@ -237,21 +249,16 @@ void *pdp_fqt_new(void) t_pdp_fqt *x = (t_pdp_fqt *)pd_new(pdp_fqt_class); inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("frame_cold")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("gain")); x->x_outlet0 = outlet_new(&x->x_obj, &s_anything); - x->x_outlet1 = outlet_new(&x->x_obj, &s_float); - x->x_outlet2 = outlet_new(&x->x_obj, &s_float); + x->x_curframe = outlet_new(&x->x_obj, &s_float); + x->x_nbframes = outlet_new(&x->x_obj, &s_float); + x->x_framerate = outlet_new(&x->x_obj, &s_float); x->packet0 = -1; x->initialized = false; - x->loop = false; - - x->state_data = (t_pdp_fqt_data *)malloc(sizeof(t_pdp_fqt_data)); - pdp_fqt_gain(x, 1.0f); - return (void *)x; } @@ -269,10 +276,8 @@ void pdp_fqt_setup(void) class_addmethod(pdp_fqt_class, (t_method)pdp_fqt_bang, gensym("bang"), A_NULL); class_addmethod(pdp_fqt_class, (t_method)pdp_fqt_close, gensym("close"), A_NULL); class_addmethod(pdp_fqt_class, (t_method)pdp_fqt_open, gensym("open"), A_SYMBOL, A_NULL); - class_addmethod(pdp_fqt_class, (t_method)pdp_fqt_loop, gensym("loop"), A_DEFFLOAT, A_NULL); class_addfloat (pdp_fqt_class, (t_method)pdp_fqt_frame); class_addmethod(pdp_fqt_class, (t_method)pdp_fqt_frame_cold, gensym("frame_cold"), A_FLOAT, A_NULL); - class_addmethod(pdp_fqt_class, (t_method)pdp_fqt_gain, gensym("gain"), A_FLOAT, A_NULL); class_addmethod(pdp_fqt_class, nullfn, gensym("signal"), 0); class_sethelpsymbol( pdp_fqt_class, gensym("pdp_fqt.pd") ); diff --git a/modules/pdp_yqt.c b/modules/pdp_yqt.c index d91ac8e..26cffa9 100644 --- a/modules/pdp_yqt.c +++ b/modules/pdp_yqt.c @@ -29,11 +29,6 @@ #define OUTPUT_BUFFER_SIZE 128*1024 /* audio output buffer : 128k */ #define DECODE_PACKET_SIZE 16*1024 /* size of audio data decoded in one call */ -typedef struct pdp_yqt_data -{ - short int gain[4]; -} t_pdp_yqt_data; - typedef struct pdp_yqt_struct { t_object x_obj; @@ -73,8 +68,6 @@ typedef struct pdp_yqt_struct t_float *x_outl; t_float *x_outr; - t_pdp_yqt_data *state_data; - } t_pdp_yqt; @@ -183,8 +176,6 @@ static void pdp_yqt_bang(t_pdp_yqt *x) short int* data; t_pdp* header; - static short int gain[4] = {0x7fff, 0x7fff, 0x7fff, 0x7fff}; - if (!(x->initialized)){ //post("pdp_yqt: no qt file opened"); return; @@ -307,26 +298,9 @@ static void pdp_yqt_frame(t_pdp_yqt *x, t_floatarg frameindex) pdp_yqt_bang(x); } -static void pdp_yqt_gain(t_pdp_yqt *x, t_floatarg f) -{ - int i; - short int g; - float bound = (float)0x7fff; - - f *= (float)0x7fff; - - f = (f>bound) ? bound : f; - f = (f<-bound) ? -bound : f; - - g = (short int)f; - - for (i=0; i<4; i++) x->state_data->gain[i] = g; -} - static void pdp_yqt_free(t_pdp_yqt *x) { - free (x->state_data); pdp_yqt_close(x); freebytes(x->x_outbuffer, OUTPUT_BUFFER_SIZE*sizeof(t_float)); @@ -341,7 +315,6 @@ void *pdp_yqt_new(void) t_pdp_yqt *x = (t_pdp_yqt *)pd_new(pdp_yqt_class); inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("frame_cold")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("gain")); x->x_outlet0 = outlet_new(&x->x_obj, &s_anything); x->x_outlet1 = outlet_new(&x->x_obj, &s_float); @@ -356,9 +329,6 @@ void *pdp_yqt_new(void) x->loop = false; - x->state_data = (t_pdp_yqt_data *)malloc(sizeof(t_pdp_yqt_data)); - pdp_yqt_gain(x, 1.0f); - // allocate audio buffers x->x_outbuffersize = OUTPUT_BUFFER_SIZE; x->x_outl = (t_float*) getbytes(DECODE_PACKET_SIZE*sizeof(t_float)); @@ -433,7 +403,6 @@ void pdp_yqt_setup(void) class_addmethod(pdp_yqt_class, (t_method)pdp_yqt_loop, gensym("loop"), A_DEFFLOAT, A_NULL); class_addfloat (pdp_yqt_class, (t_method)pdp_yqt_frame); class_addmethod(pdp_yqt_class, (t_method)pdp_yqt_frame_cold, gensym("frame_cold"), A_FLOAT, A_NULL); - class_addmethod(pdp_yqt_class, (t_method)pdp_yqt_gain, gensym("gain"), A_FLOAT, A_NULL); class_addmethod(pdp_yqt_class, nullfn, gensym("signal"), 0); class_addmethod(pdp_yqt_class, (t_method)pdp_yqt_dsp, gensym("dsp"), 0); class_sethelpsymbol( pdp_yqt_class, gensym("pdp_yqt.pd") ); diff --git a/system/pidip.c b/system/pidip.c index c663093..fb2ba55 100644 --- a/system/pidip.c +++ b/system/pidip.c @@ -15,6 +15,7 @@ extern "C" void pdp_yvu2rgb_setup(void); void pdp_yqt_setup(void); void pdp_fqt_setup(void); + void pdp_fcqt_setup(void); void pdp_lens_setup(void); void pdp_baltan_setup(void); void pdp_aging_setup(void); @@ -70,6 +71,7 @@ void pidip_setup(void){ pdp_intrusion_setup(); pdp_yqt_setup(); pdp_fqt_setup(); + pdp_fcqt_setup(); pdp_simura_setup(); pdp_underwatch_setup(); pdp_vertigo_setup(); |