Update of /cvsroot/pure-data/externals/pidip/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21582/modules
Modified Files: Makefile Makefile.in pdp_ascii.c pdp_compose.c pdp_ctrack.c pdp_ffmpeg~.c pdp_form.c pdp_i.c pdp_live~.c pdp_o.c pdp_ocanvas.c pdp_pen.c pdp_rec~.c pdp_shape.c pdp_text.c pdp_underwatch.c pdp_yqt.c Log Message: PiDiP v 0.12.17
Index: Makefile.in =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/Makefile.in,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile.in 18 May 2004 00:44:08 -0000 1.12 --- Makefile.in 14 Nov 2004 22:52:21 -0000 1.13 *************** *** 16,21 **** 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_fcqt.o \ ! pdp_ocanvas.o pdp_spotlight.o pdp_colorgrid.o @PDP_STREAMING_OBJECTS@ ! # pdp_xcanvas.o pdp_aa.o
all_modules: $(OBJECTS) --- 16,24 ---- 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_fcqt.o \ ! pdp_ocanvas.o pdp_spotlight.o pdp_colorgrid.o \ ! pdp_binary.o pdp_erode.o pdp_dilate.o pdp_hitandmiss.o \ ! pdp_disintegration.o pdp_distance.o pdp_theorin~.o \ ! pdp_theorout~.o pdp_cropper.o pdp_background.o \ ! @PDP_STREAMING_OBJECTS@ # pdp_xcanvas.o pdp_aa.o
all_modules: $(OBJECTS)
Index: pdp_ctrack.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_ctrack.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_ctrack.c 30 Mar 2004 01:56:16 -0000 1.3 --- pdp_ctrack.c 14 Nov 2004 22:52:21 -0000 1.4 *************** *** 87,92 **** t_outlet *x_y2; // output y2 coordinate of block which has been detected t_outlet *x_R; // output R component of selected color ! t_outlet *x_G; // output R component of selected color ! t_outlet *x_B; // output R component of selected color
t_canvas *x_canvas; --- 87,92 ---- t_outlet *x_y2; // output y2 coordinate of block which has been detected t_outlet *x_R; // output R component of selected color ! t_outlet *x_G; // output G component of selected color ! t_outlet *x_B; // output B component of selected color
t_canvas *x_canvas;
Index: pdp_live~.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_live~.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_live~.c 30 Mar 2004 01:56:16 -0000 1.3 --- pdp_live~.c 14 Nov 2004 22:52:21 -0000 1.4 *************** *** 36,39 **** --- 36,41 ---- #include <sys/resource.h> #include <avformat.h> + #include <sys/types.h> + #include <signal.h>
#define VIDEO_BUFFER_SIZE (1024*1024) *************** *** 47,52 **** #define DEFAULT_FRAME_RATE 25 #define END_OF_STREAM 20 ! #define MIN_PRIORITY -20 ! #define DEFAULT_PRIORITY 0 #define MAX_PRIORITY 20
--- 49,54 ---- #define DEFAULT_FRAME_RATE 25 #define END_OF_STREAM 20 ! #define MIN_PRIORITY 0 ! #define DEFAULT_PRIORITY 1 #define MAX_PRIORITY 20
*************** *** 67,71 ****
t_pdp *x_header; ! short int *x_data; t_int x_vwidth; t_int x_vheight; --- 69,73 ----
t_pdp *x_header; ! unsigned char *x_data; t_int x_vwidth; t_int x_vheight; *************** *** 83,90 **** --- 85,96 ---- pthread_t x_decodechild; // stream decoding thread t_int x_usethread; // flag to activate decoding in a thread + t_int x_autoplay; // flag to autoplay the file ( default = true ) + t_int x_nextimage; // flag to play next image in manual mode t_int x_priority; // priority of decoding thread
char *x_url; t_int x_streaming; // streaming flag + t_int x_decoding; // decoding flag + t_int x_loop; // looping flag ( default = on ) t_int x_nopackets; // no packet to decode t_int x_endofstream; // end of the stream reached *************** *** 109,112 **** --- 115,119 ---- long long int x_pts; // presentation time stamp long long int x_previouspts; // previous presentation time stamp + long long int x_firstpts; // first presentation time stamp ( time origin ) t_int x_newpicture;
*************** *** 138,142 **** static void pdp_live_audio(t_pdp_live *x, t_floatarg faudio ) { ! if ( ( faudio == 0.0 ) || ( faudio == 1 ) ) { x->x_audio = (int)faudio; --- 145,149 ---- static void pdp_live_audio(t_pdp_live *x, t_floatarg faudio ) { ! if ( ( faudio == 0. ) || ( faudio == 1. ) ) { x->x_audio = (int)faudio; *************** *** 144,154 **** }
static t_int pdp_live_decode_packet(t_pdp_live *x) { ! t_int chunksize=0, length; t_int audiosize, sizeout, imagesize, pictureok; AVFrame frame; uint8_t *pcktptr; ! struct timeval etime; struct timespec mwait;
--- 151,222 ---- }
+ static void pdp_live_autoplay(t_pdp_live *x, t_floatarg fautoplay ) + { + if ( ( fautoplay == 0. ) || ( fautoplay == 1. ) ) + { + x->x_autoplay = (int)fautoplay; + } + } + + static void pdp_live_loop(t_pdp_live *x, t_floatarg floop ) + { + if ( ( floop == 0. ) || ( floop == 1. ) ) + { + x->x_loop = (int)floop; + } + } + + static void pdp_live_bang(t_pdp_live *x) + { + if ( x->x_nextimage == 1 ) + { + // post( "pdp_live~ : banging too fast, previous image is not decoded yet... ignored" ); + return; + } + x->x_nextimage = 1; + } + + static void pdp_live_frame_cold(t_pdp_live *x, t_floatarg frameindex) + { + int frame = (int)frameindex; + int ret; + uint64_t newpts; + + if (!(x->x_streaming)) return; + + #if FFMPEG_VERSION_INT >= 0x000409 + if ( ( ( x->x_avcontext->iformat->flags & AVFMT_NOFILE ) == 0 ) && ( x->x_videoindex != -1 ) ) + { + if ( x->x_framerate != 0 ) + { + newpts = x->x_firstpts + ( frame * 1000000 ) / x->x_framerate; + } + else + { + post( "pdp_live~ : couldn't seek requested frame ( framerate = %d )", x->x_framerate ); + return; + } + if ( ( ret = av_seek_frame(x->x_avcontext, x->x_videoindex, newpts) ) < 0 ) + { + post( "pdp_live~ : couldn't seek the requested frame (ret=%d)", ret ); + } + } + #else + post( "pdp_live~ : no seek function with ffmpeg < 4.0.9"); + #endif + } + static t_int pdp_live_decode_packet(t_pdp_live *x) { ! t_int chunksize=0, length, err, ret; t_int audiosize, sizeout, imagesize, pictureok; AVFrame frame; uint8_t *pcktptr; ! unsigned char *pY, *pU, *pV; ! uint8_t *psY, *psU, *psV; ! t_int px, py; ! long long tplaying; ! long long ttheoretical; ! struct timeval ctime; struct timespec mwait;
*************** *** 160,164 **** // post( "pdp_live~ : trying to read packet" ); // read new packet on the stream ! if (av_read_packet(x->x_avcontext, &x->x_pkt) < 0) { x->x_nopackets++; --- 228,232 ---- // post( "pdp_live~ : trying to read packet" ); // read new packet on the stream ! if ( x->x_streaming && av_read_packet(x->x_avcontext, &x->x_pkt) < 0) { x->x_nopackets++; *************** *** 167,170 **** --- 235,260 ---- { x->x_endofstream = 1; + if ( x->x_loop ) + { + + #if FFMPEG_VERSION_INT >= 0x000409 + + if ( ( x->x_avcontext->iformat->flags & AVFMT_NOFILE ) == 0 ) + { + post( "pdp_live~ : looping file reading..." ); + if ( ( ret = av_seek_frame(x->x_avcontext, x->x_videoindex, 0) ) < 0 ) + { + post( "pdp_live~ : couldn't seek the requested frame (ret=%d)", ret ); + } + else + { + x->x_endofstream = 0; + } + } + + #else + post( "pdp_live~ : no seek function with ffmpeg < 4.0.9"); + #endif + } } return -1; *************** *** 183,186 **** --- 273,277 ---- while (length > 0) { + if ( !x->x_streaming ) break; switch(x->x_avcontext->streams[x->x_pkt.stream_index]->codec.codec_type) { *************** *** 241,245 **** x->x_audioin_position = 0; } ! if ( ( x->x_audioin_position > x->x_blocksize ) && (!x->x_audioon) ) { x->x_audioon = 1; --- 332,336 ---- x->x_audioin_position = 0; } ! if ( ( x->x_audioin_position > 4*x->x_blocksize ) && (!x->x_audioon) ) { x->x_audioon = 1; *************** *** 254,271 ****
x->x_framerate = x->x_avcontext->streams[x->x_pkt.stream_index]->codec.frame_rate / 10000; x->x_videoindex = x->x_pkt.stream_index;
- // calculate actual frame rate - // if ( gettimeofday(&etime, NULL) == -1) - // { - // post("pdp_live~ : could not read time" ); - // } - // if ( ( etime.tv_sec - x->x_starttime.tv_sec ) > 0 ) - // { - // x->x_framerate = x->x_nbframes / ( etime.tv_sec - x->x_starttime.tv_sec ); - // } - // if ( x->x_framerate == 0 ) x->x_framerate = 1; - // post ("pdp_live~ : frame rate is %d", x->x_framerate ); - chunksize = avcodec_decode_video( &x->x_avcontext->streams[x->x_pkt.stream_index]->codec, --- 345,351 ----
x->x_framerate = x->x_avcontext->streams[x->x_pkt.stream_index]->codec.frame_rate / 10000; + if ( x->x_framerate == 0 ) x->x_framerate = DEFAULT_FRAME_RATE; x->x_videoindex = x->x_pkt.stream_index;
chunksize = avcodec_decode_video( &x->x_avcontext->streams[x->x_pkt.stream_index]->codec, *************** *** 305,333 **** { x->x_newpicture=1; - x->x_previouspts = x->x_pts; - x->x_pts = frame.pts; - // post( "pdp_live : frame pts : %ld", x->x_pts ); x->x_vwidth = x->x_avcontext->streams[x->x_pkt.stream_index]->codec.width; x->x_vheight = x->x_avcontext->streams[x->x_pkt.stream_index]->codec.height; x->x_vsize = x->x_vwidth*x->x_vheight;
! if ( x->x_previouspts != -1 ) ! { ! mwait.tv_sec = 0; ! mwait.tv_nsec = (x->x_pts - x->x_previouspts)*1000;
! if ( ( x->x_pts == 0 ) ) ! { ! // post("pdp_live~ : no presentation time stamp, using framerate :%d", ! // x->x_framerate ); ! mwait.tv_sec = 0; ! mwait.tv_nsec = 1000000000/((x->x_framerate+5)); // the +5 is experimental ! // it comes from the time used in decoding ! }
! nanosleep( &mwait, NULL ); // wait between the two successive frames ! // i know, cheap flow control }
} break; --- 385,451 ---- { x->x_newpicture=1; x->x_vwidth = x->x_avcontext->streams[x->x_pkt.stream_index]->codec.width; x->x_vheight = x->x_avcontext->streams[x->x_pkt.stream_index]->codec.height; x->x_vsize = x->x_vwidth*x->x_vheight;
! // create a new pdp packet from BITMAP YV12 image format ! x->x_packet0 = pdp_packet_new_bitmap_yv12( x->x_vwidth, x->x_vheight ); ! x->x_header = pdp_packet_header(x->x_packet0); ! x->x_data = (unsigned char *)pdp_packet_data(x->x_packet0);
! pY = x->x_data; ! pV = x->x_data+x->x_vsize; ! pU = x->x_data+x->x_vsize+(x->x_vsize>>2);
! psY = x->x_picture_decoded.data[0]; ! psU = x->x_picture_decoded.data[1]; ! psV = x->x_picture_decoded.data[2]; ! ! for ( py=0; py<x->x_vheight; py++) ! { ! memcpy( (void*)pY, (void*)psY, x->x_vwidth ); ! pY += x->x_vwidth; ! psY += x->x_picture_decoded.linesize[0]; ! if ( py%2==0 ) ! { ! memcpy( (void*)pU, (void*)psU, (x->x_vwidth>>1) ); ! memcpy( (void*)pV, (void*)psV, (x->x_vwidth>>1) ); ! pU += (x->x_vwidth>>1); ! pV += (x->x_vwidth>>1); ! psU += x->x_picture_decoded.linesize[1]; ! psV += x->x_picture_decoded.linesize[2]; ! } ! } ! ! if ( x->x_firstpts == -1 ) ! { ! x->x_firstpts = x->x_pts; } + x->x_previouspts = x->x_pts; + x->x_pts = frame.pts; + // post( "pdp_live : frame pts : %ld", x->x_pts );
+ if ( x->x_nbframes > 0 ) + { + if ( gettimeofday(&ctime, NULL) == -1) + { + post("pdp_theorin~ : could not read time" ); + } + + tplaying = ( ctime.tv_sec-x->x_starttime.tv_sec )*1000 + + ( ctime.tv_usec-x->x_starttime.tv_usec )/1000; + ttheoretical = ((x->x_nbframes)*1000 )/x->x_framerate; + // post( "pdp-theorin~ : %d playing since : %lldms ( theory : %lldms )", + // x->x_nbframes, tplaying, ttheoretical ); + + if ( tplaying < ttheoretical ) + { + mwait.tv_sec = 0; + mwait.tv_nsec = (ttheoretical - tplaying)*1000000; + + // wait between the two successive frames + if ( x->x_autoplay ) nanosleep( &mwait, NULL ); + } + } } break; *************** *** 335,339 **** pcktptr += chunksize; length -= chunksize; - if ( !x->x_streaming ) break; } av_free_packet(&x->x_pkt); --- 453,456 ---- *************** *** 354,369 **** twait.tv_nsec = 10000000; // 10 ms
! schedprio.sched_priority = 0; ! if ( sched_setscheduler(0,SCHED_OTHER,&schedprio) == -1) ! { ! post("pdp_live~ : couldn't set scheduler for decoding thread.\n"); ! } ! if ( setpriority( PRIO_PROCESS, 0, x->x_priority ) < 0 ) ! { ! post("pdp_live~ : couldn't set priority to %d for decoding thread.\n", x->x_priority ); ! } ! else { ! post("pdp_live~ : priority set to %d for thread %d.\n", x->x_priority, x->x_decodechild ); }
--- 471,478 ---- twait.tv_nsec = 10000000; // 10 ms
! schedprio.sched_priority = sched_get_priority_min(SCHED_FIFO) + x->x_priority; ! if ( sched_setscheduler(0,SCHED_FIFO,&schedprio) == -1) { ! post("pdp_theorin~ : couldn't set priority for decoding thread."); }
*************** *** 377,393 **** }
! while ( x->x_streaming ) { ! while ( x->x_newpicture ) nanosleep( &twait, NULL );
! // decode incoming packets ! if ( pdp_live_decode_packet( x ) < 0 ) { ! nanosleep( &twait, NULL ); // nothing to read, just wait } - }
- post( "pdp_live~ : decoding thread %d exiting....", x->x_decodechild ); x->x_decodechild = 0; pthread_exit(NULL); --- 486,510 ---- }
! while ( x->x_decodechild ) { ! if ( ( x->x_streaming ) && ( ( x->x_autoplay ) || ( x->x_nextimage == 1 ) ) ) ! { ! x->x_decoding = 1; ! while ( x->x_newpicture ) nanosleep( &twait, NULL );
! // decode incoming packets ! if ( ( x->x_streaming ) && ( pdp_live_decode_packet( x ) < 0 ) ) ! { ! nanosleep( &twait, NULL ); // nothing to read, just wait ! } ! x->x_nextimage = -1; ! } ! else { ! x->x_decoding = 0; ! nanosleep( &twait, NULL ); // nothing to do, just wait } }
x->x_decodechild = 0; pthread_exit(NULL); *************** *** 420,424 **** if ( err == -6 ) post( "pdp_live~ : unknown format ( stream not found? )" ); x->x_connectchild = 0; - x->x_avcontext = av_mallocz(sizeof(AVFormatContext)); pthread_exit(NULL); } --- 537,540 ---- *************** *** 508,516 **** x->x_endofstream = 0; x->x_nbframes = 0;
! x->x_connectchild = 0; ! ! if ( x->x_usethread ) { // launch decoding thread if ( pthread_attr_init( &decode_child_attr ) < 0 ) --- 624,634 ---- x->x_endofstream = 0; x->x_nbframes = 0; + x->x_pts = -1; + x->x_previouspts = -1; + x->x_firstpts = -1;
! if ( x->x_usethread && ( x->x_decodechild == 0 )) { + x->x_decodechild = 1; // trick & treets // launch decoding thread if ( pthread_attr_init( &decode_child_attr ) < 0 ) *************** *** 557,569 **** x->x_streaming = 0; x->x_newpicture = 0; ! post("pdp_live~ : waiting for the end of decoding thread..." ); ! while ( x->x_decodechild && ( count < 100 ) ) ! { ! count++; ! sleep( 1 ); ! } ! if ( x->x_decodechild ) { ! post("pdp_live~ : zombie thread, i guess" ); } post("pdp_live~ : closing input file..." ); --- 675,687 ---- x->x_streaming = 0; x->x_newpicture = 0; ! post("pdp_live~ : waiting end of decoding..." ); ! while ( x->x_decoding ) nanosleep( &twait, NULL ); ! /* close each decoder */ ! for(i=0;i<x->x_avcontext->nb_streams;i++) { ! if (avcodec_close(&x->x_avcontext->streams[i]->codec) < 0) ! { ! post("pdp_live~ : error while closing codec for stream #%d", i); ! } } post("pdp_live~ : closing input file..." ); *************** *** 632,638 **** t_pdp_live *x = (t_pdp_live *)(w[3]); int n = (int)(w[4]); // number of samples - short int *pY, *pU, *pV; - uint8_t *psY, *psU, *psV; - t_int pixRGB, px, py; short sampleL, sampleR; struct timeval etime; --- 750,753 ---- *************** *** 651,655 **** { sn=0; - n=n*DEFAULT_CHANNELS; while (n--) { --- 766,769 ---- *************** *** 671,675 **** x->x_audioin_position-=sn; // post( "pdp_live~ : audio in position : %d", x->x_audioin_position ); ! if ( x->x_audioin_position <= sn ) { x->x_audioon = 0; --- 785,789 ---- x->x_audioin_position-=sn; // post( "pdp_live~ : audio in position : %d", x->x_audioin_position ); ! if ( x->x_audioin_position <= 0 ) { x->x_audioon = 0; *************** *** 695,699 **** { x->x_cursec = etime.tv_sec; ! if (x->x_streaming) outlet_float( x->x_outlet_framerate, x->x_framerate ); x->x_secondcount = 0; } --- 809,813 ---- { x->x_cursec = etime.tv_sec; ! if (x->x_streaming) outlet_float( x->x_outlet_framerate, x->x_secondcount ); x->x_secondcount = 0; } *************** *** 706,741 **** if ( x->x_newpicture ) { - // create a new pdp packet from PIX_FMT_YUV420P image format - x->x_packet0 = pdp_packet_new_image_YCrCb( x->x_vwidth, x->x_vheight ); - x->x_header = pdp_packet_header(x->x_packet0); - x->x_data = (short int *)pdp_packet_data(x->x_packet0); - - pY = x->x_data; - pV = x->x_data+x->x_vsize; - pU = x->x_data+x->x_vsize+(x->x_vsize>>2); - - psY = x->x_picture_decoded.data[0]; - psU = x->x_picture_decoded.data[1]; - psV = x->x_picture_decoded.data[2]; - - for ( py=0; py<x->x_vheight; py++) - { - for ( px=0; px<x->x_vwidth; px++) - { - *(pY) = ( *(psY+px) << 7 ); - *(pV) = ( ((*(psV+(px>>1)))-128) << 8 ); - *(pU) = ( ((*(psU+(px>>1)))-128) << 8 ); - pY++; - if ( (px%2==0) && (py%2==0) ) - { - pV++; pU++; - } - } - psY += x->x_picture_decoded.linesize[0]; - if ( py%2==0 ) psU += x->x_picture_decoded.linesize[1]; - if ( py%2==0 ) psV += x->x_picture_decoded.linesize[2]; - } - pdp_packet_pass_if_valid(x->x_pdp_out, &x->x_packet0);
// update streaming status --- 820,825 ---- if ( x->x_newpicture ) { pdp_packet_pass_if_valid(x->x_pdp_out, &x->x_packet0); + x->x_newpicture = 0;
// update streaming status *************** *** 743,748 **** x->x_secondcount++; outlet_float( x->x_outlet_nbframes, x->x_nbframes ); - - x->x_newpicture = 0; } outlet_float( x->x_outlet_streaming, x->x_streaming ); --- 827,830 ---- *************** *** 761,776 **** int i;
if ( x->x_streaming ) { pdp_live_disconnect(x); - sleep(3); } post( "pdp_live~ : freeing object" ); pdp_packet_mark_unused(x->x_packet0); - if (x->x_audio_resample_ctx) - { - audio_resample_close(x->x_audio_resample_ctx); - x->x_audio_resample_ctx = NULL; - } av_free_static(); } --- 843,859 ---- int i;
+ if ( x->x_decodechild ) + { + x->x_decodechild = 0; + x->x_decoding = 0; + sleep( 5 ); // let the decoding thread exiting + } + if ( x->x_streaming ) { pdp_live_disconnect(x); } post( "pdp_live~ : freeing object" ); pdp_packet_mark_unused(x->x_packet0); av_free_static(); } *************** *** 784,787 **** --- 867,872 ---- t_pdp_live *x = (t_pdp_live *)pd_new(pdp_live_class);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("frame_cold")); + x->x_pdp_out = outlet_new(&x->x_obj, &s_anything);
*************** *** 797,800 **** --- 882,886 ---- x->x_connectchild = 0; x->x_decodechild = 0; + x->x_decoding = 0; x->x_usethread = 1; x->x_priority = DEFAULT_PRIORITY; *************** *** 808,812 **** x->x_audio_resample_ctx = NULL; x->x_nbvideostreams = 0; ! x->x_videoindex = 0; x->x_audioin_position = 0; x->x_newpicture = 0; --- 894,898 ---- x->x_audio_resample_ctx = NULL; x->x_nbvideostreams = 0; ! x->x_videoindex = -1; x->x_audioin_position = 0; x->x_newpicture = 0; *************** *** 814,820 **** --- 900,910 ---- x->x_nopackets = 0; x->x_blocksize = MIN_AUDIO_SIZE; + x->x_autoplay = 1; + x->x_loop = 1; + x->x_nextimage = 0;
x->x_pts = -1; x->x_previouspts = -1; + x->x_firstpts = -1;
x->x_avcontext = av_mallocz(sizeof(AVFormatContext)); *************** *** 852,856 **** --- 942,950 ---- class_addmethod(pdp_live_class, (t_method)pdp_live_priority, gensym("priority"), A_FLOAT, A_NULL); class_addmethod(pdp_live_class, (t_method)pdp_live_audio, gensym("audio"), A_FLOAT, A_NULL); + class_addmethod(pdp_live_class, (t_method)pdp_live_autoplay, gensym("autoplay"), A_FLOAT, A_NULL); + class_addmethod(pdp_live_class, (t_method)pdp_live_loop, gensym("loop"), A_FLOAT, A_NULL); class_addmethod(pdp_live_class, (t_method)pdp_live_threadify, gensym("thread"), A_FLOAT, A_NULL); + class_addmethod(pdp_live_class, (t_method)pdp_live_bang, gensym("bang"), A_NULL); + class_addmethod(pdp_live_class, (t_method)pdp_live_frame_cold, gensym("frame_cold"), A_FLOAT, A_NULL); class_sethelpsymbol( pdp_live_class, gensym("pdp_live~.pd") );
Index: pdp_o.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_o.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdp_o.c 17 Sep 2003 20:07:00 -0000 1.2 --- pdp_o.c 14 Nov 2004 22:52:21 -0000 1.3 *************** *** 183,187 **** { t_int i; ! char value = source[0]; char count = 0; t_int tcount=0; --- 183,187 ---- { t_int i; ! int value = source[0]; char count = 0; t_int tcount=0; *************** *** 199,210 **** else { - value=source[i]; *(pcount)=count; *(pvalue) = value; tcount+=count; - count=1; pcount+=2; pvalue+=2; *(csize)+=2; } } --- 199,210 ---- else { *(pcount)=count; *(pvalue) = value; tcount+=count; pcount+=2; pvalue+=2; *(csize)+=2; + value=source[i]; + count=1; } } *************** *** 222,226 **** { // post( "pdp_o : huffman : compression ratio %d/%d : %f (total count=%d)", size, (*csize), ! // (t_float)size/(t_float)(*csize), tcount ); return HUFFMAN; } --- 222,226 ---- { // post( "pdp_o : huffman : compression ratio %d/%d : %f (total count=%d)", size, (*csize), ! // (t_float)size/(t_float)(*csize), tcount ); return HUFFMAN; } *************** *** 350,354 **** // post( "pdp_o : y value out of range : %d", downvalue ); } ! if ( data[i] != x->x_previous_frame[i] ) { x->x_diff_frame[i] = (char)downvalue; --- 350,355 ---- // post( "pdp_o : y value out of range : %d", downvalue ); } ! if ( ( data[i] != x->x_previous_frame[i] ) || ! ( !strcmp( x->x_hpacket.tag, PDP_PACKET_TAG ) ) ) { x->x_diff_frame[i] = (char)downvalue; *************** *** 369,373 **** // post( "pdp_o : y value out of range : %d", downvalue ); } ! if ( data[i] != x->x_previous_frame[i] ) { x->x_diff_frame[i] = (char)downvalue; --- 370,375 ---- // post( "pdp_o : y value out of range : %d", downvalue ); } ! if ( ( data[i] != x->x_previous_frame[i] ) || ! ( !strcmp( x->x_hpacket.tag, PDP_PACKET_TAG ) ) ) { x->x_diff_frame[i] = (char)downvalue; *************** *** 379,384 **** }
! x->x_hpacket.width = x->x_vwidth; ! x->x_hpacket.height = x->x_vheight; if ( gettimeofday(&x->x_hpacket.etime, NULL) == -1) { --- 381,386 ---- }
! x->x_hpacket.width = htonl(x->x_vwidth); ! x->x_hpacket.height = htonl(x->x_vheight); if ( gettimeofday(&x->x_hpacket.etime, NULL) == -1) { *************** *** 392,395 **** --- 394,400 ---- }
+ x->x_hpacket.etime.tv_sec = htonl( x->x_hpacket.etime.tv_sec ); + x->x_hpacket.etime.tv_usec = htonl( x->x_hpacket.etime.tv_usec ); + // do not send the frame if too many frames // have been sent in the current second *************** *** 398,402 ****
// try a huffman coding ! x->x_hpacket.encoding = pdp_o_huffman(x, x->x_diff_frame, x->x_hdata, x->x_vsize+(x->x_vsize>>1), &x->x_hsize );
x->x_hpacket.clength = (x->x_vsize+(x->x_vsize>>1))*1.01+600; --- 403,407 ----
// try a huffman coding ! x->x_hpacket.encoding = htonl( pdp_o_huffman(x, x->x_diff_frame, x->x_hdata, x->x_vsize+(x->x_vsize>>1), &x->x_hsize ) );
x->x_hpacket.clength = (x->x_vsize+(x->x_vsize>>1))*1.01+600; *************** *** 416,419 **** --- 421,425 ----
// send header + x->x_hpacket.clength = htonl( x->x_hpacket.clength ); count = send(x->x_fd, &x->x_hpacket, sizeof(x->x_hpacket), MSG_NOSIGNAL); if(count < 0) *************** *** 431,434 **** --- 437,441 ---- x->x_bandwidthcount += count/1024; } + x->x_hpacket.clength = ntohl( x->x_hpacket.clength );
// send data
Index: pdp_text.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_text.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_text.c 29 Oct 2003 22:43:08 -0000 1.3 --- pdp_text.c 14 Nov 2004 22:52:22 -0000 1.4 *************** *** 61,64 **** --- 61,65 ---- t_int *x_b; t_float *x_angle; + t_float x_alpha; t_int *x_scroll;
*************** *** 155,159 **** x->x_angle[x->x_nbtexts] = argv[6].a_w.w_float; } ! if ( (argc>=8) && (argv[7].a_type == A_FLOAT) ) { x->x_scroll[x->x_nbtexts] = (int)argv[7].a_w.w_float; --- 156,160 ---- x->x_angle[x->x_nbtexts] = argv[6].a_w.w_float; } ! if ( (argc>=8) && (argv[7].a_type == A_FLOAT) ) { x->x_scroll[x->x_nbtexts] = (int)argv[7].a_w.w_float; *************** *** 225,228 **** --- 226,237 ---- }
+ static void pdp_text_alpha(t_pdp_text *x, t_floatarg falpha ) + { + if ( ( falpha >= 0. ) && ( falpha <= 1. ) ) + { + x->x_alpha = falpha; + } + } + static void pdp_text_scroll(t_pdp_text *x, t_floatarg fscroll ) { *************** *** 457,465 **** v = yuv_RGBtoV(imdata[py*x->x_vwidth+px]);
! *(pY) = y<<7; if ( (px%2==0) && (py%2==0) ) { ! *(pV) = (v-128)<<8; ! *(pU) = (u-128)<<8; } } --- 466,474 ---- v = yuv_RGBtoV(imdata[py*x->x_vwidth+px]);
! *(pY) = ((y)<<7)*x->x_alpha + (*pY)*(1-x->x_alpha); if ( (px%2==0) && (py%2==0) ) { ! *(pV) = ((v-128)<<8)*x->x_alpha + *(pV)*(1-x->x_alpha); ! *(pU) = ((u-128)<<8)*x->x_alpha + *(pU)*(1-x->x_alpha); } } *************** *** 558,561 **** --- 567,571 ---- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("angle")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("scroll")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("alpha"));
x->x_outlet0 = outlet_new(&x->x_obj, &s_anything); *************** *** 586,589 **** --- 596,600 ---- x->x_nbtexts = 0; x->x_current = -1; + x->x_alpha = 1.;
return (void *)x; *************** *** 619,622 **** --- 630,634 ---- class_addmethod(pdp_text_class, (t_method)pdp_text_font, gensym("font"), A_SYMBOL, A_NULL); class_addmethod(pdp_text_class, (t_method)pdp_text_angle, gensym("angle"), A_DEFFLOAT, A_NULL); + class_addmethod(pdp_text_class, (t_method)pdp_text_alpha, gensym("alpha"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_text_class, (t_method)pdp_text_scroll, gensym("scroll"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_text_class, (t_method)pdp_text_dither, gensym("dither"), A_DEFFLOAT, A_NULL);
Index: pdp_compose.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_compose.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_compose.c 30 Mar 2004 01:56:16 -0000 1.3 --- pdp_compose.c 14 Nov 2004 22:52:21 -0000 1.4 *************** *** 62,66 **** --- 62,68 ----
t_int x_packet0; + t_int x_packet1; t_int x_dropped; + t_int x_queue_id;
t_int x_vwidth; *************** *** 229,232 **** --- 231,236 ---- t_pdp *header = pdp_packet_header(x->x_packet0); short int *data = (short int *)pdp_packet_data(x->x_packet0); + t_pdp *newheader = pdp_packet_header(x->x_packet1); + short int *newdata = (short int *)pdp_packet_data(x->x_packet1); t_int i, cf; t_int px=0, py=0, ppx=0, ppy=0, found=0, xcell=0, ycell=0; *************** *** 286,292 **** pfV = x->x_frame+x->x_vsize; pfU = x->x_frame+x->x_vsize+(x->x_vsize>>2); ! pdY = data; ! pdV = data+x->x_vsize; ! pdU = data+x->x_vsize+(x->x_vsize>>2); prY = x->x_right_frame; prV = x->x_right_frame+x->x_vsize; --- 290,296 ---- pfV = x->x_frame+x->x_vsize; pfU = x->x_frame+x->x_vsize+(x->x_vsize>>2); ! pdY = newdata; ! pdV = newdata+x->x_vsize; ! pdU = newdata+x->x_vsize+(x->x_vsize>>2); prY = x->x_right_frame; prV = x->x_right_frame+x->x_vsize; *************** *** 327,335 **** }
- pdp_packet_pass_if_valid(x->x_pdp_output, &x->x_packet0); - return; }
static void pdp_compose_process(t_pdp_compose *x) { --- 331,346 ---- }
return; }
+ static void pdp_compose_sendpacket(t_pdp_compose *x) + { + pdp_packet_mark_unused(x->x_packet0); + x->x_packet0=-1; + + /* unregister and propagate if valid dest packet */ + pdp_packet_pass_if_valid(x->x_pdp_output, &x->x_packet1); + } + static void pdp_compose_process(t_pdp_compose *x) { *************** *** 345,349 ****
case PDP_IMAGE_YV12: ! pdp_compose_process_yv12(x); break;
--- 356,361 ----
case PDP_IMAGE_YV12: ! x->x_packet1 = pdp_packet_clone_rw(x->x_packet0); ! pdp_queue_add(x, pdp_compose_process_yv12, pdp_compose_sendpacket, &x->x_queue_id); break;
*************** *** 366,383 **** short int *rightdata = (short int *)pdp_packet_data((int)f);
! if (s== gensym("register_rw")) memcpy(x->x_right_frame, rightdata, (x->x_vsize + (x->x_vsize>>1))<<1 ); }
static void pdp_compose_input_0(t_pdp_compose *x, t_symbol *s, t_floatarg f) { ! /* if this is a register_ro message or register_rw message, register with packet factory */ ! ! if (s== gensym("register_rw")) x->x_dropped = pdp_packet_convert_ro_or_drop(&x->x_packet0, (int)f, pdp_gensym("image/YCrCb/*") );
! if ((s == gensym("process")) && (-1 != x->x_packet0) && (!x->x_dropped)){ ! pdp_compose_process(x); - } } --- 378,399 ---- short int *rightdata = (short int *)pdp_packet_data((int)f);
! if ( s== gensym("register_rw") ) ! { ! memcpy(x->x_right_frame, rightdata, (x->x_vsize + (x->x_vsize>>1))<<1 ); ! } ! ! pdp_packet_mark_unused( (int)f ); }
static void pdp_compose_input_0(t_pdp_compose *x, t_symbol *s, t_floatarg f) { ! if ( s== gensym("register_rw") ) ! { x->x_dropped = pdp_packet_convert_ro_or_drop(&x->x_packet0, (int)f, pdp_gensym("image/YCrCb/*") ); + }
! if ((s == gensym("process")) && (-1 != x->x_packet0) && (!x->x_dropped)) ! { pdp_compose_process(x); } } *************** *** 387,391 **** int i;
! pdp_packet_mark_unused(x->x_packet0); pdp_compose_free_ressources( x ); } --- 403,408 ---- int i;
! pdp_queue_finish(x->x_queue_id); ! pdp_packet_mark_unused(x->x_packet1); pdp_compose_free_ressources( x ); } *************** *** 417,420 **** --- 434,439 ----
x->x_packet0 = -1; + x->x_packet1 = -1; + x->x_queue_id = -1;
x->x_cursX = -1;
Index: pdp_rec~.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_rec~.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdp_rec~.c 17 Sep 2003 20:07:41 -0000 1.2 --- pdp_rec~.c 14 Nov 2004 22:52:22 -0000 1.3 *************** *** 446,451 **** isample=(short) (32767.0 * fsample); x->x_audio_buf[1][x->x_audioin_position]=isample; ! x->x_audioin_position=(x->x_audioin_position+1)%(2*MAX_AUDIO_PACKET_SIZE); ! if ( x->x_audioin_position == 2*MAX_AUDIO_PACKET_SIZE-1 ) { post( "pdp_rec~ : reaching end of audio buffer" ); --- 446,451 ---- isample=(short) (32767.0 * fsample); x->x_audio_buf[1][x->x_audioin_position]=isample; ! x->x_audioin_position=(x->x_audioin_position+1)%(MAX_AUDIO_PACKET_SIZE); ! if ( x->x_audioin_position == MAX_AUDIO_PACKET_SIZE-1 ) { post( "pdp_rec~ : reaching end of audio buffer" ); *************** *** 625,628 **** --- 625,629 ---- // close video file if existing pdp_rec_close(x); + pdp_rec_free_ressources(x); for ( i=0; i<x->x_channels; i++) {
Index: pdp_shape.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_shape.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_shape.c 30 Mar 2004 01:56:16 -0000 1.3 --- pdp_shape.c 14 Nov 2004 22:52:22 -0000 1.4 *************** *** 27,31 **** #include <math.h>
! static char *pdp_shape_version = "pdp_shape: version 0.1, shape recongnition object written by Yves Degoyon (ydegoyon@free.fr)";
typedef struct pdp_shape_struct --- 27,31 ---- #include <math.h>
! static char *pdp_shape_version = "pdp_shape: version 0.1, shape recognition object written by Yves Degoyon (ydegoyon@free.fr)";
typedef struct pdp_shape_struct *************** *** 80,92 **** int i;
! if ( x->x_bdata ) freebytes( x->x_bdata, (( x->x_vsize + (x->x_vsize>>1))<<1)); ! if ( x->x_bbdata ) freebytes( x->x_bbdata, (( x->x_vsize + (x->x_vsize>>1))<<1)); ! if ( x->x_checked ) freebytes( x->x_checked, x->x_vsize );
x->x_vsize = newsize;
! x->x_bdata = (short int *)getbytes((( x->x_vsize + (x->x_vsize>>1))<<1)); ! x->x_bbdata = (short int *)getbytes((( x->x_vsize + (x->x_vsize>>1))<<1)); ! x->x_checked = (char *)getbytes( x->x_vsize ); }
--- 80,92 ---- int i;
! if ( x->x_bdata ) free( x->x_bdata ); ! if ( x->x_bbdata ) free( x->x_bbdata ); ! if ( x->x_checked ) free( x->x_checked );
x->x_vsize = newsize;
! x->x_bdata = (short int *)malloc((( x->x_vsize + (x->x_vsize>>1))<<1)); ! x->x_bbdata = (short int *)malloc((( x->x_vsize + (x->x_vsize>>1))<<1)); ! x->x_checked = (char *)malloc( x->x_vsize ); }
*************** *** 452,461 ****
// paint cursor in red for debug purpose ! pbbY = x->x_bbdata; ! pbbU = (x->x_bbdata+x->x_vsize); ! pbbV = (x->x_bbdata+x->x_vsize+(x->x_vsize>>2)); ! *(pbbY+x->x_cursY*x->x_vwidth+x->x_cursX) = (yuv_RGBtoY( 0xff ))<<7; ! *(pbbU+(x->x_cursY>>1)*(x->x_vwidth>>1)+(x->x_cursX>>1)) = ((yuv_RGBtoU( 0xff )-128)<<8); ! *(pbbV+(x->x_cursY>>1)*(x->x_vwidth>>1)+(x->x_cursX>>1)) = ((yuv_RGBtoV( 0xff )-128)<<8);
memcpy( newdata, x->x_bbdata, (x->x_vsize+(x->x_vsize>>1))<<1 ); --- 452,464 ----
// paint cursor in red for debug purpose ! if ( x->x_cursX != -1 ) ! { ! pbbY = x->x_bbdata; ! pbbU = (x->x_bbdata+x->x_vsize); ! pbbV = (x->x_bbdata+x->x_vsize+(x->x_vsize>>2)); ! *(pbbY+x->x_cursY*x->x_vwidth+x->x_cursX) = (yuv_RGBtoY( 0xff ))<<7; ! *(pbbU+(x->x_cursY>>1)*(x->x_vwidth>>1)+(x->x_cursX>>1)) = ((yuv_RGBtoU( 0xff )-128)<<8); ! *(pbbV+(x->x_cursY>>1)*(x->x_vwidth>>1)+(x->x_cursX>>1)) = ((yuv_RGBtoV( 0xff )-128)<<8); ! }
memcpy( newdata, x->x_bbdata, (x->x_vsize+(x->x_vsize>>1))<<1 );
Index: pdp_i.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_i.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_i.c 18 May 2004 00:44:08 -0000 1.3 --- pdp_i.c 14 Nov 2004 22:52:21 -0000 1.4 *************** *** 179,183 ****
if ( ( ret = recv(x->x_socket, (void*) (x->x_inbuffer + x->x_inwriteposition), ! (size_t)((x->x_inbuffersize-x->x_inwriteposition)), MSG_NOSIGNAL) ) < 0 ) { --- 179,183 ----
if ( ( ret = recv(x->x_socket, (void*) (x->x_inbuffer + x->x_inwriteposition), ! (size_t)((x->x_inbuffersize-x->x_inwriteposition-1)), MSG_NOSIGNAL) ) < 0 ) { *************** *** 190,194 **** // post( "pdp_i : received %d bytes at %d on %d ( up to %d)", // ret, x->x_inwriteposition, x->x_socket, ! // x->x_inbuffersize-x->x_inwriteposition*sizeof( unsigned long) );
if ( ret == 0 ) --- 190,194 ---- // post( "pdp_i : received %d bytes at %d on %d ( up to %d)", // ret, x->x_inwriteposition, x->x_socket, ! // x->x_inbuffersize-x->x_inwriteposition );
if ( ret == 0 ) *************** *** 198,201 **** --- 198,202 ---- pdp_i_closesocket( x->x_socket ); sys_rmpollfn(x->x_socket); + post( "pdp_i : lost the connection." ); x->x_socket = -1; } *************** *** 203,224 **** { // check we don't overflow input buffer ! if ( x->x_inwriteposition+ret >= x->x_inbuffersize ) { post( "pdp_i : too much input...resetting" ); x->x_inwriteposition=0; return; } x->x_inwriteposition += ret; ! if ( pheader = (t_hpacket*) strstr( (char*) x->x_inbuffer, PDP_PACKET_START ) ) { // check if a full packet is present ! if ( x->x_inwriteposition >= (int)((char*)pheader - (char*)(x->x_inbuffer)) + (int)sizeof(t_hpacket) + (int)pheader->clength ) { ! if ( ( x->x_vwidth != pheader->width ) || ! ( x->x_vheight != pheader->height ) ) { pdp_i_free_ressources(x); ! x->x_vheight = pheader->height; ! x->x_vwidth = pheader->width; x->x_vsize = x->x_vheight*x->x_vwidth; pdp_i_allocate(x); --- 204,229 ---- { // check we don't overflow input buffer ! if ( x->x_inwriteposition+ret >= x->x_inbuffersize/2 ) { post( "pdp_i : too much input...resetting" ); x->x_inwriteposition=0; + memset( (char*) x->x_inbuffer, 0x00, x->x_inbuffersize ); return; } x->x_inwriteposition += ret; ! if ( ( ( pheader = (t_hpacket*) strstr( (char*) x->x_inbuffer, PDP_PACKET_START ) ) != NULL ) || ! ( ( pheader = (t_hpacket*) strstr( (char*) x->x_inbuffer, PDP_PACKET_DIFF ) ) != NULL ) ) { // check if a full packet is present ! if ( x->x_inwriteposition >= ! (int)((char*)pheader - (char*)(x->x_inbuffer)) + ! (int)sizeof(t_hpacket) + (int)ntohl(pheader->clength) ) { ! if ( ( x->x_vwidth != (t_int)ntohl(pheader->width) ) || ! ( x->x_vheight != (t_int)ntohl(pheader->height) ) ) { pdp_i_free_ressources(x); ! x->x_vheight = ntohl(pheader->height); ! x->x_vwidth = ntohl(pheader->width); x->x_vsize = x->x_vheight*x->x_vwidth; pdp_i_allocate(x); *************** *** 231,235 **** memcpy( x->x_data, x->x_bdata, x->x_bsize );
! // post( "pdp_i : decompress %d in %d bytes", pheader->clength, x->x_hsize ); x->x_bzsize = x->x_hsize;
--- 236,240 ---- memcpy( x->x_data, x->x_bdata, x->x_bsize );
! // post( "pdp_i : decompress %d in %d bytes", ntohl(pheader->clength), x->x_hsize ); x->x_bzsize = x->x_hsize;
*************** *** 237,246 **** &x->x_bzsize, (char *) pheader+sizeof(t_hpacket), ! pheader->clength, 0, 0 ) ) == BZ_OK ) { ! // post( "pdp_i : bz2 decompression (%d)->(%d)", pheader->clength, x->x_bzsize );
! switch( pheader->encoding ) { case REGULAR : --- 242,251 ---- &x->x_bzsize, (char *) pheader+sizeof(t_hpacket), ! ntohl(pheader->clength), 0, 0 ) ) == BZ_OK ) { ! // post( "pdp_i : bz2 decompression (%d)->(%d)", ntohl(pheader->clength), x->x_bzsize );
! switch( ntohl(pheader->encoding) ) { case REGULAR : *************** *** 286,291 **** x->x_header->info.image.height = x->x_vheight;
- pdp_packet_pass_if_valid(x->x_pdp_output, &x->x_packet); // post( "pdp_i : propagate packet : %d", x->x_packet ); outlet_float( x->x_frames, ++x->x_framesreceived ); } --- 291,296 ---- x->x_header->info.image.height = x->x_vheight;
// post( "pdp_i : propagate packet : %d", x->x_packet ); + pdp_packet_pass_if_valid(x->x_pdp_output, &x->x_packet); outlet_float( x->x_frames, ++x->x_framesreceived ); } *************** *** 298,303 ****
// roll buffer ! x->x_inwriteposition -= (int)((char*)pheader-(char*)(x->x_inbuffer)) + sizeof(t_hpacket) + pheader->clength; ! memcpy( x->x_inbuffer, pheader+sizeof(t_hpacket) + pheader->clength, x->x_inwriteposition ); } } --- 303,320 ----
// roll buffer ! x->x_inwriteposition -= (int)((char*)pheader-(char*)(x->x_inbuffer)) + sizeof(t_hpacket) + ntohl(pheader->clength); ! if ( x->x_inwriteposition > 0 ) ! { ! memcpy( x->x_inbuffer, pheader+sizeof(t_hpacket) + ntohl(pheader->clength), x->x_inwriteposition ); ! } ! else ! { ! x->x_inwriteposition = 0; ! memset( (char*) x->x_inbuffer, 0x00, x->x_inbuffersize ); ! } ! } ! else ! { ! // post( "pdp_i : not a full frame" ); } }
Index: pdp_ascii.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_ascii.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_ascii.c 18 May 2004 00:44:08 -0000 1.3 --- pdp_ascii.c 14 Nov 2004 22:52:21 -0000 1.4 *************** *** 28,31 **** --- 28,32 ---- #include "default.map" #include <math.h> + #include <stdio.h>
#define LINE_MAX_LENGTH 1024
Index: pdp_yqt.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_yqt.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pdp_yqt.c 30 Mar 2004 01:56:16 -0000 1.5 --- pdp_yqt.c 14 Nov 2004 22:52:22 -0000 1.6 *************** *** 238,242 **** if ( gettimeofday(&etime, NULL) == -1) { ! post("pdp_fcqt : could not get time" ); } if ( etime.tv_sec != x->x_cursec ) --- 238,242 ---- if ( gettimeofday(&etime, NULL) == -1) { ! post("pdp_yqt : could not get time" ); } if ( etime.tv_sec != x->x_cursec ) *************** *** 249,253 ****
outlet_float(x->x_curframe, (float)pos); - pdp_packet_pass_if_valid(x->x_outlet0, &object);
// fills in the audio buffer with a chunk if necessary --- 249,252 ---- *************** *** 286,289 **** --- 285,290 ---- }
+ pdp_packet_pass_if_valid(x->x_outlet0, &object); + }
Index: pdp_ffmpeg~.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_ffmpeg~.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pdp_ffmpeg~.c 18 May 2004 00:44:08 -0000 1.4 --- pdp_ffmpeg~.c 14 Nov 2004 22:52:21 -0000 1.5 *************** *** 442,448 **** --- 442,457 ----
if (x->x_img_resample_ctx) img_resample_close(x->x_img_resample_ctx); + + #if LIBAVCODEC_BUILD > 4715 + x->x_img_resample_ctx = img_resample_full_init( + owidth, oheight, + x->x_vwidth, x->x_vheight, + 0, 0, 0, 0, + 0, 0, 0, 0); + #else x->x_img_resample_ctx = img_resample_full_init( owidth, oheight, x->x_vwidth, x->x_vheight, 0, 0, 0, 0); + #endif
size = avpicture_get_size(x->x_avcontext->streams[i]->codec.pix_fmt, *************** *** 473,476 **** --- 482,488 ---- { AVFrame aframe; + #if LIBAVCODEC_BUILD > 4715 + AVPacket vpkt; + #endif t_int fsize, ret;
*************** *** 483,487 **** --- 495,513 ---- x->x_video_buffer, VIDEO_BUFFER_SIZE, &aframe); + + #if LIBAVCODEC_BUILD > 4715 + av_init_packet(&vpkt); + + vpkt.pts = aframe.pts; + if((&x->x_avcontext->streams[i]->codec)->coded_frame->key_frame) + vpkt.flags |= PKT_FLAG_KEY; + vpkt.stream_index= i; + vpkt.data= (uint8_t *)x->x_video_buffer; + vpkt.size= fsize; + + if ( ( ret = av_write_frame( x->x_avcontext, &vpkt) ) < 0 ) + #else if ( ( ret = av_write_frame( x->x_avcontext, i, x->x_video_buffer, fsize) ) < 0 ) + #endif { post ("pdp_ffmpeg~ : error : could not send frame : (ret=%d)", ret ); *************** *** 550,557 **** --- 576,599 ---- &x->x_audio_fifo[saudioindex].rptr) == 0) { + #if LIBAVCODEC_BUILD > 4715 + AVPacket apkt; + #endif encsize = avcodec_encode_audio(&x->x_avcontext->streams[i]->codec, (uint8_t*)&x->x_audio_out, sizeof(x->x_audio_out), (short *)pencbuf); + #if LIBAVCODEC_BUILD > 4715 + av_init_packet(&apkt); + + apkt.pts = etime.tv_sec*1000000 + etime.tv_usec; + if((&x->x_avcontext->streams[i]->codec)->coded_frame->key_frame) + apkt.flags |= PKT_FLAG_KEY; + apkt.stream_index= i; + apkt.data= (uint8_t *)x->x_audio_out; + apkt.size= encsize; + + av_write_frame(x->x_avcontext, &apkt); + #else av_write_frame(x->x_avcontext, i, x->x_audio_out, encsize); + #endif } saudioindex++;
Index: Makefile =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/Makefile,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile 18 May 2004 00:44:08 -0000 1.12 --- Makefile 14 Nov 2004 22:52:21 -0000 1.13 *************** *** 16,21 **** 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_fcqt.o \ ! pdp_ocanvas.o pdp_spotlight.o pdp_colorgrid.o pdp_live~.o pdp_ffmpeg~.o ! # pdp_xcanvas.o pdp_aa.o
all_modules: $(OBJECTS) --- 16,24 ---- 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_fcqt.o \ ! pdp_ocanvas.o pdp_spotlight.o pdp_colorgrid.o \ ! pdp_binary.o pdp_erode.o pdp_dilate.o pdp_hitandmiss.o \ ! pdp_disintegration.o pdp_distance.o pdp_theorin~.o \ ! pdp_theorout~.o pdp_cropper.o pdp_background.o \ ! pdp_live~.o pdp_ffmpeg~.o # pdp_xcanvas.o pdp_aa.o
all_modules: $(OBJECTS)
Index: pdp_underwatch.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_underwatch.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdp_underwatch.c 17 Sep 2003 20:09:42 -0000 1.2 --- pdp_underwatch.c 14 Nov 2004 22:52:22 -0000 1.3 *************** *** 74,80 **** int i;
- unsigned int u_offset; - unsigned int v_offset; - unsigned int totnbpixels; int px, py, pd, t;
--- 74,77 ---- *************** *** 83,90 **** x->x_vsize = x->x_vwidth*x->x_vheight;
- u_offset = x->x_vsize; - v_offset = x->x_vsize + (x->x_vsize>>2); - totnbpixels = x->x_vsize + (x->x_vsize>>1); - newheader->info.image.encoding = header->info.image.encoding; newheader->info.image.width = x->x_vwidth; --- 80,83 ----
Index: pdp_form.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_form.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdp_form.c 17 Sep 2003 20:04:38 -0000 1.2 --- pdp_form.c 14 Nov 2004 22:52:21 -0000 1.3 *************** *** 75,78 **** --- 75,79 ---- t_int x_current; t_int x_capacity; + t_float x_alpha;
/* imlib data */ *************** *** 313,316 **** --- 314,325 ---- }
+ static void pdp_form_alpha(t_pdp_form *x, t_floatarg falpha ) + { + if ( ( falpha >= 0. ) && ( falpha <= 1. ) ) + { + x->x_alpha = falpha; + } + } + static void pdp_form_resize(t_pdp_form *x, t_floatarg fnewsize ) { *************** *** 449,457 **** v = yuv_RGBtoV(imdata[py*x->x_vwidth+px]);
! *(pY) = y<<7; if ( (px%2==0) && (py%2==0) ) { ! *(pV) = (v-128)<<8; ! *(pU) = (u-128)<<8; } } --- 458,466 ---- v = yuv_RGBtoV(imdata[py*x->x_vwidth+px]);
! *(pY) = (y<<7)*x->x_alpha + (*pY)*(1-x->x_alpha); if ( (px%2==0) && (py%2==0) ) { ! *(pV) = ((v-128)<<8)*x->x_alpha + (*pV)*(1-x->x_alpha); ! *(pU) = ((u-128)<<8)*x->x_alpha + (*pU)*(1-x->x_alpha); } } *************** *** 550,553 **** --- 559,563 ---- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("g")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("b")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("alpha"));
x->x_outlet0 = outlet_new(&x->x_obj, &s_anything); *************** *** 568,571 **** --- 578,582 ---- x->x_nbforms = 0; x->x_current = -1; + x->x_alpha = 1.;
return (void *)x; *************** *** 602,605 **** --- 613,617 ---- class_addmethod(pdp_form_class, (t_method)pdp_form_delete, gensym("delete"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_form_class, (t_method)pdp_form_resize, gensym("resize"), A_DEFFLOAT, A_NULL); + class_addmethod(pdp_form_class, (t_method)pdp_form_alpha, gensym("alpha"), A_DEFFLOAT, A_NULL); class_sethelpsymbol( pdp_form_class, gensym("pdp_form.pd") );
Index: pdp_ocanvas.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_ocanvas.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pdp_ocanvas.c 18 May 2004 00:44:09 -0000 1.2 --- pdp_ocanvas.c 14 Nov 2004 22:52:21 -0000 1.3 *************** *** 54,57 **** --- 54,58 ---- t_float *x_xoffsets; t_float *x_yoffsets; + t_float *x_alphas; t_int *x_sizes;
*************** *** 106,110 **** ppx = px-(int)x->x_xoffsets[ii]; ppy = py-(int)x->x_yoffsets[ii]; ! *(pY+py*x->x_owidth+px) += *(piY+ppy*x->x_widths[ii]+ppx); if ( (px%2==0) && (py%2==0) ) { --- 107,111 ---- ppx = px-(int)x->x_xoffsets[ii]; ppy = py-(int)x->x_yoffsets[ii]; ! *(pY+py*x->x_owidth+px) += *(piY+ppy*x->x_widths[ii]+ppx)*x->x_alphas[ii]; if ( (px%2==0) && (py%2==0) ) { *************** *** 176,179 **** --- 177,195 ---- }
+ static void pdp_ocanvas_alpha(t_pdp_ocanvas *x, t_floatarg ni, t_floatarg xalpha) + { + if ( ( ni < 1 ) || ( ni > x->x_nbinputs ) ) + { + post( "pdp_ocanvas : alpha : wrong source : %d : must be between 1 and %d", ni, x->x_nbinputs ); + return; + } + if ( ( xalpha < .0 ) || ( xalpha > 1.0 ) ) + { + post( "pdp_ocanvas : alpha : wrong alpha value : %f : must be between 0 and 1", xalpha ); + return; + } + x->x_alphas[(int)ni-1] = xalpha; + } + static void pdp_ocanvas_select(t_pdp_ocanvas *x, t_floatarg X, t_floatarg Y) { *************** *** 325,328 **** --- 341,345 ---- if ( x->x_xoffsets ) freebytes( x->x_xoffsets, x->x_nbinputs*sizeof(t_float) ); if ( x->x_yoffsets ) freebytes( x->x_yoffsets, x->x_nbinputs*sizeof(t_float) ); + if ( x->x_alphas ) freebytes( x->x_alphas, x->x_nbinputs*sizeof(t_float) ); }
*************** *** 382,385 **** --- 399,403 ---- x->x_xoffsets = ( t_float* ) getbytes( x->x_nbinputs*sizeof(t_float) ); x->x_yoffsets = ( t_float* ) getbytes( x->x_nbinputs*sizeof(t_float) ); + x->x_alphas = ( t_float* ) getbytes( x->x_nbinputs*sizeof(t_float) );
x->x_opacket = pdp_packet_new_image_YCrCb( x->x_owidth, x->x_oheight ); *************** *** 392,395 **** --- 410,414 ---- x->x_xoffsets[ii] = 0.; x->x_yoffsets[ii] = 0.; + x->x_alphas[ii] = 1.; } x->x_current = -1; *************** *** 427,430 **** --- 446,450 ---- class_addmethod(pdp_ocanvas_class, (t_method)pdp_ocanvas_input9, gensym("pdp9"), A_SYMBOL, A_DEFFLOAT, A_NULL); class_addmethod(pdp_ocanvas_class, (t_method)pdp_ocanvas_offset, gensym("offset"), A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_NULL); + class_addmethod(pdp_ocanvas_class, (t_method)pdp_ocanvas_alpha, gensym("alpha"), A_DEFFLOAT, A_DEFFLOAT, A_NULL); class_addmethod(pdp_ocanvas_class, (t_method)pdp_ocanvas_select, gensym("select"), A_DEFFLOAT, A_DEFFLOAT, A_NULL); class_addmethod(pdp_ocanvas_class, (t_method)pdp_ocanvas_drag, gensym("drag"), A_DEFFLOAT, A_DEFFLOAT, A_NULL);
Index: pdp_pen.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_pen.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_pen.c 8 Dec 2003 22:45:54 -0000 1.3 --- pdp_pen.c 14 Nov 2004 22:52:21 -0000 1.4 *************** *** 53,56 **** --- 53,57 ---- t_int x_xoffset; t_int x_yoffset; + t_float x_alpha;
t_int x_pwidth; *************** *** 318,321 **** --- 319,330 ---- }
+ static void pdp_pen_alpha(t_pdp_pen *x, t_floatarg falpha) + { + if ( falpha >= 0. && falpha <= 1. ) + { + x->x_alpha = falpha; + } + } + static void pdp_pen_mode(t_pdp_pen *x, t_floatarg mode) { *************** *** 395,403 **** if ( *(pbY+(py-x->x_yoffset)*x->x_vwidth+(px-x->x_xoffset)) != 0 ) { ! *(pnY+py*x->x_vwidth+px) = *(pbY+(py-x->x_yoffset)*x->x_vwidth+(px-x->x_xoffset)); *(pnU+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = ! *(pbU+((py-x->x_yoffset)>>1)*(x->x_vwidth>>1)+((px-x->x_xoffset)>>1)); *(pnV+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = ! *(pbV+((py-x->x_yoffset)>>1)*(x->x_vwidth>>1)+((px-x->x_xoffset)>>1)); } } --- 404,416 ---- if ( *(pbY+(py-x->x_yoffset)*x->x_vwidth+(px-x->x_xoffset)) != 0 ) { ! *(pnY+py*x->x_vwidth+px) = ! (*(pbY+(py-x->x_yoffset)*x->x_vwidth+(px-x->x_xoffset))*x->x_alpha) + ! (*(pnY+py*x->x_vwidth+px)*(1-x->x_alpha)); *(pnU+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = ! (*(pbU+((py-x->x_yoffset)>>1)*(x->x_vwidth>>1)+((px-x->x_xoffset)>>1))*x->x_alpha) + ! (*(pnU+(py>>1)*(x->x_vwidth>>1)+(px>>1))*(1-x->x_alpha)); *(pnV+(py>>1)*(x->x_vwidth>>1)+(px>>1)) = ! (*(pbV+((py-x->x_yoffset)>>1)*(x->x_vwidth>>1)+((px-x->x_xoffset)>>1))*x->x_alpha) + ! (*(pnV+(py>>1)*(x->x_vwidth>>1)+(px>>1))*(1-x->x_alpha)); } } *************** *** 483,486 **** --- 496,500 ---- inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("xoffset")); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("yoffset")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("alpha"));
x->x_packet0 = -1; *************** *** 499,502 **** --- 513,517 ---- x->x_pwidth = 3; x->x_mode = 0; + x->x_alpha = 1.;
return (void *)x; *************** *** 526,529 **** --- 541,545 ---- class_addmethod(pdp_pen_class, (t_method)pdp_pen_xoffset, gensym("xoffset"), A_DEFFLOAT, A_NULL); class_addmethod(pdp_pen_class, (t_method)pdp_pen_yoffset, gensym("yoffset"), A_DEFFLOAT, A_NULL); + class_addmethod(pdp_pen_class, (t_method)pdp_pen_alpha, gensym("alpha"), A_DEFFLOAT, A_NULL);
}