Update of /cvsroot/pure-data/externals/pidip/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22342
Modified Files: pdp_theonice~.c pdp_imgloader.c Log Message: PiDiP 0.12.21
Index: pdp_imgloader.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_imgloader.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pdp_imgloader.c 10 May 2007 23:01:30 -0000 1.6 --- pdp_imgloader.c 8 Aug 2007 19:03:08 -0000 1.7 *************** *** 84,88 **** Imlib_Load_Error imliberr;
! post( "pdp_imgloader : loading : %s", filename->s_name );
if ( x->x_image != NULL ) --- 84,88 ---- Imlib_Load_Error imliberr;
! // post( "pdp_imgloader : loading : %s", filename->s_name );
if ( x->x_image != NULL ) *************** *** 102,106 **** x->x_iwidth = imlib_image_get_width(); x->x_iheight = imlib_image_get_height(); ! post( "pdp_imgloader : loaded : %s (%dx%d)", filename->s_name, x->x_iwidth, x->x_iheight ); x->x_xoffset = (int) fx; x->x_yoffset = (int) fy; --- 102,106 ---- x->x_iwidth = imlib_image_get_width(); x->x_iheight = imlib_image_get_height(); ! // post( "pdp_imgloader : loaded : %s (%dx%d)", filename->s_name, x->x_iwidth, x->x_iheight ); x->x_xoffset = (int) fx; x->x_yoffset = (int) fy; *************** *** 336,341 **** ( (int)fy3 >= 0 ) && ( (int)fy3 < x->x_vheight ) ) { ! post( "pdp_imgloader : hide : coordinates : %d %d %d %d %d %d", ! (int)fx1, (int)fy1, (int)fx2, (int)fy2, (int)fx3, (int)fy3 ); for ( ti=0; ti<MAX_ZONES; ti++ ) { --- 336,341 ---- ( (int)fy3 >= 0 ) && ( (int)fy3 < x->x_vheight ) ) { ! // post( "pdp_imgloader : hide : coordinates : %d %d %d %d %d %d", ! // (int)fx1, (int)fy1, (int)fx2, (int)fy2, (int)fx3, (int)fy3 ); for ( ti=0; ti<MAX_ZONES; ti++ ) { *************** *** 409,416 **** } } ! post( "pdp_imgloader : hiding : [%d,%d]/[%d,%d]/[%d,%d], ", ! x->x_hiddenzones[ti].x1, x->x_hiddenzones[ti].y1, ! x->x_hiddenzones[ti].x2, x->x_hiddenzones[ti].y2, ! x->x_hiddenzones[ti].x3, x->x_hiddenzones[ti].y3 ); if ( (x->x_hiddenzones[ti].x2-x->x_hiddenzones[ti].x1) != 0 ) { --- 409,416 ---- } } ! // post( "pdp_imgloader : hiding : [%d,%d]/[%d,%d]/[%d,%d], ", ! // x->x_hiddenzones[ti].x1, x->x_hiddenzones[ti].y1, ! // x->x_hiddenzones[ti].x2, x->x_hiddenzones[ti].y2, ! // x->x_hiddenzones[ti].x3, x->x_hiddenzones[ti].y3 ); if ( (x->x_hiddenzones[ti].x2-x->x_hiddenzones[ti].x1) != 0 ) { *************** *** 443,452 **** ( ( (float) x->x_hiddenzones[ti].x3 ) - ( (float) x->x_hiddenzones[ti].x1 ) ); } ! post( "pdp_imgloader : hiding : a1=%f b1=%f", ! x->x_hiddenzones[ti].a1, x->x_hiddenzones[ti].b1 ); ! post( "pdp_imgloader : hiding : a2=%f b2=%f", ! x->x_hiddenzones[ti].a2, x->x_hiddenzones[ti].b2 ); ! post( "pdp_imgloader : hiding : a3=%f b3=%f", ! x->x_hiddenzones[ti].a3, x->x_hiddenzones[ti].b3 ); pdp_imgloader_update_mask( x ); return; --- 443,452 ---- ( ( (float) x->x_hiddenzones[ti].x3 ) - ( (float) x->x_hiddenzones[ti].x1 ) ); } ! // post( "pdp_imgloader : hiding : a1=%f b1=%f", ! // x->x_hiddenzones[ti].a1, x->x_hiddenzones[ti].b1 ); ! // post( "pdp_imgloader : hiding : a2=%f b2=%f", ! // x->x_hiddenzones[ti].a2, x->x_hiddenzones[ti].b2 ); ! // post( "pdp_imgloader : hiding : a3=%f b3=%f", ! // x->x_hiddenzones[ti].a3, x->x_hiddenzones[ti].b3 ); pdp_imgloader_update_mask( x ); return; *************** *** 482,489 **** argv[5].a_w.w_float *= x->x_vheight;
! post( "pdp_imgloader : rawhide : coordinates : %f %f %f %f %f %f (width=%d) (height=%d)", ! argv[0].a_w.w_float, argv[1].a_w.w_float, argv[2].a_w.w_float, ! argv[3].a_w.w_float, argv[4].a_w.w_float, argv[5].a_w.w_float, ! x->x_vwidth, x->x_vheight );
pdp_imgloader_hide( x, s, argc, argv ); --- 482,489 ---- argv[5].a_w.w_float *= x->x_vheight;
! // post( "pdp_imgloader : rawhide : coordinates : %f %f %f %f %f %f (width=%d) (height=%d)", ! // argv[0].a_w.w_float, argv[1].a_w.w_float, argv[2].a_w.w_float, ! // argv[3].a_w.w_float, argv[4].a_w.w_float, argv[5].a_w.w_float, ! // x->x_vwidth, x->x_vheight );
pdp_imgloader_hide( x, s, argc, argv ); *************** *** 782,786 **** class_addmethod(pdp_imgloader_class, (t_method)pdp_imgloader_fit, gensym("fit"), A_DEFFLOAT, A_NULL);
- }
--- 782,785 ----
Index: pdp_theonice~.c =================================================================== RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_theonice~.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pdp_theonice~.c 10 May 2007 23:01:30 -0000 1.5 --- pdp_theonice~.c 8 Aug 2007 19:03:08 -0000 1.6 *************** *** 143,154 **** vorbis_comment x_vorbis_comment; // vorbis comment yuv_buffer x_yuvbuffer; // yuv buffer ! int x_eos; // end of stream
! int x_akbps; // audio bit rate ! int x_vkbps; // video bit rate t_float x_aquality; // audio quality ! int x_vquality; // video quality ! int x_abytesout; // audio bytes written ! int x_vbytesout; // video bytes written double x_audiotime; // audio stream time double x_paudiotime; // previous value --- 143,154 ---- vorbis_comment x_vorbis_comment; // vorbis comment yuv_buffer x_yuvbuffer; // yuv buffer ! int x_eos; // end of stream
! int x_akbps; // audio bit rate ! int x_vkbps; // video bit rate t_float x_aquality; // audio quality ! int x_vquality; // video quality ! int x_abytesout; // audio bytes written ! int x_vbytesout; // video bytes written double x_audiotime; // audio stream time double x_paudiotime; // previous value *************** *** 907,910 **** --- 907,913 ---- }
+ static void pdp_theonice_send_video(t_pdp_theonice *x); + static void pdp_theonice_send_audio(t_pdp_theonice *x); + /* store audio data in PCM format in a buffer for now */ static t_int *pdp_theonice_perform(t_int *w) *************** *** 933,937 **** if ( x->x_audioin_position >= MAX_AUDIO_PACKET_SIZE-1 ) { ! post( "pdp_theonice~ : reaching end of audio buffer" ); } } --- 936,940 ---- if ( x->x_audioin_position >= MAX_AUDIO_PACKET_SIZE-1 ) { ! post( "pdp_theonice~ : audio x-run" ); } } *************** *** 969,972 **** --- 972,977 ---- }
+ pdp_theonice_send_audio(x); + return (w+5); } *************** *** 981,1013 **** t_pdp *header = pdp_packet_header(x->x_packet0); unsigned char *data = (unsigned char *)pdp_packet_data(x->x_packet0); ! int i, ret; int px, py; unsigned char *pY, *pU, *pV; - struct timeval tstream; - struct timeval etime; - int nbaudiosamples, nbusecs, nbsamples; t_float fframerate=0.0; - int ttime, atime;
! if ( ( (int)(header->info.image.width) != x->x_vwidth ) || ! ( (int)(header->info.image.height) != x->x_vheight ) ) ! { ! post( "pdp_theonice~: reallocating ressources" ); ! pdp_theonice_free_ressources( x ); ! pdp_theonice_shutdown_encoder( x ); ! x->x_vwidth = header->info.image.width; ! x->x_vheight = header->info.image.height; ! x->x_vsize = x->x_vwidth*x->x_vheight; ! x->x_tvwidth=((x->x_vwidth + 15) >>4)<<4; ! x->x_tvheight=((x->x_vheight + 15) >>4)<<4; ! pdp_theonice_allocate( x ); ! if ( x->x_tzero.tv_sec != 0 ) ! { ! pdp_theonice_init_encoder( x ); ! pdp_theonice_write_headers( x ); ! } ! }
! x->x_frames++;
if ( x->x_frameswritten == 0 ) --- 986,1030 ---- t_pdp *header = pdp_packet_header(x->x_packet0); unsigned char *data = (unsigned char *)pdp_packet_data(x->x_packet0); ! int i; int px, py; unsigned char *pY, *pU, *pV; t_float fframerate=0.0;
! if ( ( (int)(header->info.image.width) != x->x_vwidth ) || ! ( (int)(header->info.image.height) != x->x_vheight ) ) ! { ! post( "pdp_theonice~: reallocating ressources" ); ! pdp_theonice_free_ressources( x ); ! pdp_theonice_shutdown_encoder( x ); ! x->x_vwidth = header->info.image.width; ! x->x_vheight = header->info.image.height; ! x->x_vsize = x->x_vwidth*x->x_vheight; ! x->x_tvwidth=((x->x_vwidth + 15) >>4)<<4; ! x->x_tvheight=((x->x_vheight + 15) >>4)<<4; ! pdp_theonice_allocate( x ); ! if ( x->x_tzero.tv_sec != 0 ) ! { ! pdp_theonice_init_encoder( x ); ! pdp_theonice_write_headers( x ); ! } ! }
! pY = x->x_yuvbuffer.y; ! memcpy( (void*)pY, (void*)&data[0], x->x_vsize ); ! pV = x->x_yuvbuffer.v; ! memcpy( (void*)pV, (void*)&data[x->x_vsize], (x->x_vsize>>2) ); ! pU = x->x_yuvbuffer.u; ! memcpy( (void*)pU, (void*)&data[x->x_vsize+(x->x_vsize>>2)], (x->x_vsize>>2) ); ! ! x->x_frames++; ! ! pdp_theonice_send_video(x); ! } ! ! static void pdp_theonice_send_video(t_pdp_theonice *x) ! { ! struct timeval etime; ! int ttime, atime, ret; ! struct timeval tstream;
if ( x->x_frameswritten == 0 ) *************** *** 1043,1076 **** }
- pY = x->x_yuvbuffer.y; - memcpy( (void*)pY, (void*)&data[0], x->x_vsize ); - pV = x->x_yuvbuffer.v; - memcpy( (void*)pV, (void*)&data[x->x_vsize], (x->x_vsize>>2) ); - pU = x->x_yuvbuffer.u; - memcpy( (void*)pU, (void*)&data[x->x_vsize+(x->x_vsize>>2)], (x->x_vsize>>2) ); - if ( x->x_socketfd > 0 && x->x_streaming ) { - // calculate the number of audio samples to output - if ( gettimeofday(&tstream, NULL) == -1) - { - post("pdp_theonice~ : could set stop time" ); - } - // calculate time diff in micro seconds - nbusecs = ( tstream.tv_usec - x->x_tprevstream.tv_usec ) + - ( tstream.tv_sec - x->x_tprevstream.tv_sec )*1000000; - nbaudiosamples = (sys_getsr()*1000000)/nbusecs; - memcpy( &x->x_tprevstream, &tstream, sizeof( struct timeval) ); - - if ( x->x_audioin_position > nbaudiosamples ) - { - nbsamples = nbaudiosamples; - } - else - { - nbsamples = x->x_audioin_position; - } - // if ( x->x_audiotime > x->x_videotime ) nbsamples = -1; - if ( ( ret = theora_encode_YUVin( &x->x_theora_state, &x->x_yuvbuffer ) ) != 0 ) { --- 1060,1065 ---- *************** *** 1110,1116 **** }
! // audio is ahead, don't send no audio ! if ( nbsamples < 0 ) return;
x->x_vbuffer=vorbis_analysis_buffer( &x->x_dsp_state, nbsamples ); if ( !x->x_vbuffer ) return; --- 1099,1134 ---- }
! } ! } ! ! static void pdp_theonice_send_audio(t_pdp_theonice *x) ! { ! int nbaudiosamples, nbusecs, nbsamples, ret; ! struct timeval tstream;
+ // calculate the number of audio samples to output + if ( gettimeofday(&tstream, NULL) == -1) + { + post("pdp_theonice~ : could set stop time" ); + } + // calculate time diff in micro seconds + nbusecs = ( tstream.tv_usec - x->x_tprevstream.tv_usec ) + + ( tstream.tv_sec - x->x_tprevstream.tv_sec )*1000000; + nbaudiosamples = (sys_getsr()*1000000)/nbusecs; + memcpy( &x->x_tprevstream, &tstream, sizeof( struct timeval) ); + + if ( x->x_audioin_position > nbaudiosamples ) + { + nbsamples = nbaudiosamples; + } + else + { + nbsamples = x->x_audioin_position; + } + // audio is ahead of video, do not send audio + if ( x->x_audiotime > x->x_videotime ) return; + + if ( x->x_socketfd > 0 && x->x_streaming ) + { x->x_vbuffer=vorbis_analysis_buffer( &x->x_dsp_state, nbsamples ); if ( !x->x_vbuffer ) return; *************** *** 1331,1335 **** class_addmethod(pdp_theonice_class, (t_method)pdp_theonice_genre, gensym("genre"), A_GIMME, A_NULL);
- }
--- 1349,1352 ----