Update of /cvsroot/pure-data/externals/pidip/modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13994
Modified Files:
Makefile Makefile.in pdp_ascii.c pdp_canvas.c pdp_ffmpeg~.c
pdp_i.c pdp_lumafilt.c pdp_mp4audiosource.cpp
pdp_mp4audiosync.cpp pdp_mp4live~.cpp pdp_mp4player~.cpp
pdp_mp4videosync.cpp pdp_ocanvas.c pdp_vertigo.c
Log Message:
PiDiP 0.12.14
Index: pdp_mp4player~.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_mp4player~.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pdp_mp4player~.cpp 30 Mar 2004 02:59:55 -0000 1.1
--- pdp_mp4player~.cpp 18 May 2004 00:44:09 -0000 1.2
***************
*** 103,110 ****
--- 103,113 ----
x->x_streaming = 0;
+ x->x_newpicture = 0;
outlet_float( x->x_outlet_streaming, x->x_streaming );
x->x_nbframes = 0;
outlet_float( x->x_outlet_nbframes, x->x_nbframes );
+ x->x_framerate = 0;
+ outlet_float( x->x_outlet_framerate, x->x_framerate );
post( "pdp_mp4player~ : deleting session" );
***************
*** 228,236 ****
t_int sn;
// just read the buffer
if ( x->x_audioon )
{
sn=0;
- n=n*DEFAULT_CHANNELS;
while (n--)
{
--- 231,240 ----
t_int sn;
+ x->x_blocksize = n;
+
// just read the buffer
if ( x->x_audioon )
{
sn=0;
while (n--)
{
***************
*** 250,254 ****
}
x->x_audioin_position-=sn;
! memcpy( &x->x_audio_in[0], &x->x_audio_in[sn], 4*MAX_AUDIO_PACKET_SIZE-sn );
// post( "pdp_mp4player~ : audio in position : %d", x->x_audioin_position );
if ( x->x_audioin_position <= sn )
--- 254,258 ----
}
x->x_audioin_position-=sn;
! memcpy( &x->x_audio_in[0], &x->x_audio_in[sn], (4*MAX_AUDIO_PACKET_SIZE-sn-1)*sizeof(short) );
// post( "pdp_mp4player~ : audio in position : %d", x->x_audioin_position );
if ( x->x_audioin_position <= sn )
***************
*** 282,286 ****
if ( x->x_newpicture )
{
! pdp_packet_pass_if_valid(x->x_pdp_out, &x->x_packet0);
// update streaming status
--- 286,293 ----
if ( x->x_newpicture )
{
! x->x_packet = pdp_packet_new_image_YCrCb( x->x_vwidth, x->x_vheight );
! x->x_data = (short int *)pdp_packet_data(x->x_packet);
! memcpy( x->x_data, x->x_datav, (x->x_vsize + (x->x_vsize>>1))<<1 );
! pdp_packet_pass_if_valid(x->x_pdp_out, &x->x_packet);
// update streaming status
***************
*** 289,292 ****
--- 296,300 ----
x->x_secondcount++;
outlet_float( x->x_outlet_nbframes, x->x_nbframes );
+ x->x_newpicture = 0;
}
***************
*** 308,312 ****
}
post( "pdp_mp4player~ : freeing object" );
! pdp_packet_mark_unused(x->x_packet0);
// remove invalid global ports
--- 316,320 ----
}
post( "pdp_mp4player~ : freeing object" );
! pdp_packet_mark_unused(x->x_packet);
// remove invalid global ports
***************
*** 331,344 ****
x->x_outlet_framerate = outlet_new(&x->x_obj, &s_float);
! x->x_packet0 = -1;
x->x_nbframes = 0;
x->x_cursec = 0;
x->x_secondcount = 0;
x->x_audioin_position = 0;
x->x_priority = DEFAULT_PRIORITY;
x->x_decodechild = 0;
x->x_newpicture = 0;
! memset( &x->x_audio_buf[0], 0x0, 4*MAX_AUDIO_PACKET_SIZE*sizeof(short) );
memset( &x->x_audio_in[0], 0x0, 4*MAX_AUDIO_PACKET_SIZE*sizeof(short) );
--- 339,356 ----
x->x_outlet_framerate = outlet_new(&x->x_obj, &s_float);
! x->x_packet = -1;
x->x_nbframes = 0;
x->x_cursec = 0;
x->x_secondcount = 0;
x->x_audioin_position = 0;
+ x->x_blocksize = MIN_AUDIO_SIZE;
x->x_priority = DEFAULT_PRIORITY;
x->x_decodechild = 0;
x->x_newpicture = 0;
! x->x_vwidth = -1;
! x->x_vheight = -1;
! x->x_datav = NULL;
!
memset( &x->x_audio_in[0], 0x0, 4*MAX_AUDIO_PACKET_SIZE*sizeof(short) );
Index: pdp_i.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_i.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pdp_i.c 17 Sep 2003 20:04:48 -0000 1.2
--- pdp_i.c 18 May 2004 00:44:08 -0000 1.3
***************
*** 205,209 ****
if ( x->x_inwriteposition+ret >= x->x_inbuffersize )
{
! // post( "pdp_i : too much input...resetting" );
x->x_inwriteposition=0;
return;
--- 205,209 ----
if ( x->x_inwriteposition+ret >= x->x_inbuffersize )
{
! post( "pdp_i : too much input...resetting" );
x->x_inwriteposition=0;
return;
Index: Makefile.in
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/Makefile.in,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Makefile.in 30 Mar 2004 01:56:16 -0000 1.11
--- Makefile.in 18 May 2004 00:44:08 -0000 1.12
***************
*** 16,20 ****
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_STREAMING_OBJECTS@
# pdp_xcanvas.o pdp_aa.o
--- 16,20 ----
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
Index: pdp_mp4videosync.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_mp4videosync.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pdp_mp4videosync.cpp 30 Mar 2004 02:59:55 -0000 1.1
--- pdp_mp4videosync.cpp 18 May 2004 00:44:09 -0000 1.2
***************
*** 176,182 ****
uint64_t time)
{
! // post( "pdp_mp4videosync : set video frame : %dx%d", m_width, m_height );
m_psptr->wake_sync_thread();
// pass the data to the pdp object
m_father->x_newpicture = 1;
--- 176,220 ----
uint64_t time)
{
! short int *pY, *pU, *pV;
! t_int px, py;
!
m_psptr->wake_sync_thread();
+ if ( !m_father->x_streaming )
+ {
+ return;
+ }
+
+ // transforming into a image for pdp
+ if ( ( (t_int)m_father->x_vheight != (t_int)m_height ) ||
+ ( (t_int)m_father->x_vwidth != (t_int)m_width ) )
+ {
+ m_father->x_vheight = m_height;
+ m_father->x_vwidth = m_width;
+ m_father->x_vsize = m_father->x_vheight*m_father->x_vwidth;
+ post( "pdp_mp4videosync : allocating video data : %dx%d", m_width, m_height );
+
+ // allocate video data
+ m_father->x_datav = ( short int* ) malloc( (m_father->x_vsize+(m_father->x_vsize>>1))<<1 );
+ }
+
+ // post( "pdp_mp4videosync : set video frame : width : y:%d, uv:%d", pixelw_y, pixelw_uv );
+
+ pY = m_father->x_datav;
+ pV = m_father->x_datav+m_father->x_vsize;
+ pU = m_father->x_datav+m_father->x_vsize+(m_father->x_vsize>>2);
+ for(py=0; py<m_father->x_vheight; py++)
+ {
+ for(px=0; px<m_father->x_vwidth; px++)
+ {
+ *(pY+py*m_father->x_vwidth+px) = *(y+py*pixelw_y+px)<<7;
+ if ( ( px%2 == 0 ) && ( py%2 == 0 ) )
+ {
+ *(pU+(py>>1)*(m_father->x_vwidth>>1)+(px>>1)) = ((*(u+(py>>1)*pixelw_uv+(px>>1)))-128)<<8;
+ *(pV+(py>>1)*(m_father->x_vwidth>>1)+(px>>1)) = ((*(v+(py>>1)*pixelw_uv+(px>>1)))-128)<<8;
+ }
+ }
+ }
+
// pass the data to the pdp object
m_father->x_newpicture = 1;
Index: Makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/Makefile,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Makefile 30 Mar 2004 01:56:16 -0000 1.11
--- Makefile 18 May 2004 00:44:08 -0000 1.12
***************
*** 16,20 ****
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_live~.o pdp_ffmpeg~.o
# pdp_xcanvas.o pdp_aa.o
--- 16,20 ----
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
Index: pdp_mp4live~.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_mp4live~.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pdp_mp4live~.cpp 30 Mar 2004 02:59:55 -0000 1.1
--- pdp_mp4live~.cpp 18 May 2004 00:44:09 -0000 1.2
***************
*** 61,65 ****
#define VIDEO_BUFFER_SIZE (1024*1024)
#define MAX_AUDIO_PACKET_SIZE (128 * 1024)
! #define AUDIO_PACKET_SIZE (2*1024) /* using aac encoding */
static char *pdp_mp4live_version = "pdp_mp4live~: version 0.1, an mpeg4ip video streaming object ( ydegoyon(a)free.fr )";
--- 61,65 ----
#define VIDEO_BUFFER_SIZE (1024*1024)
#define MAX_AUDIO_PACKET_SIZE (128 * 1024)
! #define AUDIO_PACKET_SIZE (2*1024*2) /* using aac encoding, 2 channels, 2 bytes per sample */
static char *pdp_mp4live_version = "pdp_mp4live~: version 0.1, an mpeg4ip video streaming object ( ydegoyon(a)free.fr )";
***************
*** 91,96 ****
/* audio structures */
short x_audio_buf[2*MAX_AUDIO_PACKET_SIZE]; /* buffer for incoming audio */
- short x_audio_enc_buf[2*MAX_AUDIO_PACKET_SIZE]; /* buffer for audio to be encoded */
- uint8_t x_audio_out[4*MAX_AUDIO_PACKET_SIZE]; /* buffer for encoded audio */
t_int x_audioin_position; // writing position for incoming audio
t_int x_audio_per_frame; // number of audio samples to transmit for each frame
--- 91,94 ----
***************
*** 426,431 ****
pV = data+x->x_vsize+(x->x_vsize>>2);
- x->x_videosource->ProcessVideo( pY, pV, pU );
-
/* update frames counter */
--- 424,427 ----
***************
*** 443,457 ****
x->x_secondcount++;
! /* send an audio frame */
! if ( x->x_audioin_position > x->x_audio_per_frame )
! {
! x->x_audiosource->ProcessAudio( (u_int8_t*)x->x_audio_buf,
! (u_int32_t)x->x_audio_per_frame*sizeof(short) );
- /* output resampled raw samples */
- memcpy( x->x_audio_buf, x->x_audio_buf+x->x_audio_per_frame,
- x->x_audioin_position-x->x_audio_per_frame );
- x->x_audioin_position-=x->x_audio_per_frame;
- }
}
return;
--- 439,444 ----
x->x_secondcount++;
! x->x_videosource->ProcessVideo( pY, pV, pU );
}
return;
***************
*** 500,503 ****
--- 487,505 ----
}
+ if ( x->x_streaming )
+ {
+ /* send an audio frame */
+ if ( (t_int)(x->x_audioin_position*sizeof(short)) > (t_int)x->x_audio_per_frame )
+ {
+ x->x_audiosource->ProcessAudio( (u_int8_t*)x->x_audio_buf,
+ (u_int32_t)x->x_audio_per_frame );
+
+ /* recopy the buffer and set new pointers */
+ memcpy( x->x_audio_buf, x->x_audio_buf+(x->x_audio_per_frame/sizeof(short)),
+ x->x_audioin_position*sizeof(short)-x->x_audio_per_frame );
+ x->x_audioin_position-=(x->x_audio_per_frame/sizeof(short));
+ }
+ }
+
return (w+5);
}
Index: pdp_ffmpeg~.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_ffmpeg~.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** pdp_ffmpeg~.c 30 Mar 2004 01:56:16 -0000 1.3
--- pdp_ffmpeg~.c 18 May 2004 00:44:08 -0000 1.4
***************
*** 602,606 ****
if ( x->x_audioin_position == 2*MAX_AUDIO_PACKET_SIZE-1 )
{
! post( "pdp_ffmpeg~ : reaching end of audio buffer" );
}
}
--- 602,606 ----
if ( x->x_audioin_position == 2*MAX_AUDIO_PACKET_SIZE-1 )
{
! // post( "pdp_ffmpeg~ : reaching end of audio buffer" );
}
}
Index: pdp_mp4audiosync.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_mp4audiosync.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pdp_mp4audiosync.cpp 30 Mar 2004 02:59:55 -0000 1.1
--- pdp_mp4audiosync.cpp 18 May 2004 00:44:09 -0000 1.2
***************
*** 34,42 ****
#include "m_pd.h"
- #define audio_message(loglevel, fmt...) message(loglevel, "audiosync", fmt)
-
static void pdp_audio_callback (void *userdata, Uint8 *stream, int len)
{
CPDPAudioSync *a = (CPDPAudioSync *)userdata;
a->audio_callback(stream, len);
}
--- 34,41 ----
#include "m_pd.h"
static void pdp_audio_callback (void *userdata, Uint8 *stream, int len)
{
CPDPAudioSync *a = (CPDPAudioSync *)userdata;
+ // post( "pdp_mp4audiosync : audio callback" );
a->audio_callback(stream, len);
}
***************
*** 44,85 ****
CPDPAudioSync::CPDPAudioSync (CPlayerSession *psptr, t_pdp_mp4player *pdp_father) : CAudioSync(psptr)
{
- m_fill_index = m_play_index = 0;
- for (int ix = 0; ix < DECODE_BUFFERS_MAX; ix++) {
- m_buffer_filled[ix] = 0;
- m_sample_buffer[ix] = NULL;
- }
- m_buffer_size = 0;
m_config_set = 0;
! m_audio_initialized = 0;
! m_audio_paused = 1;
m_resync_required = 0;
m_dont_fill = 0;
- m_consec_no_buffers = 0;
- m_audio_waiting_buffer = 0;
- m_skipped_buffers = 0;
- m_didnt_fill_buffers = 0;
m_play_time = 0 ;
m_buffer_latency = 0;
m_first_time = 1;
- m_first_filled = 1;
- m_buffer_offset_on = 0;
- m_buffer_ts = 0;
- m_load_audio_do_next_resync = 0;
m_convert_buffer = NULL;
m_father = pdp_father;
}
CPDPAudioSync::~CPDPAudioSync (void)
{
! for (int ix = 0; ix < DECODE_BUFFERS_MAX; ix++) {
! if (m_sample_buffer[ix] != NULL)
! free(m_sample_buffer[ix]);
! m_sample_buffer[ix] = NULL;
}
CHECK_AND_FREE(m_convert_buffer);
- audio_message(LOG_NOTICE,
- "Audio sync skipped %u buffers",
- m_skipped_buffers);
- audio_message(LOG_NOTICE, "didn't fill %u buffers", m_didnt_fill_buffers);
}
--- 43,67 ----
CPDPAudioSync::CPDPAudioSync (CPlayerSession *psptr, t_pdp_mp4player *pdp_father) : CAudioSync(psptr)
{
m_config_set = 0;
! m_audio_initialized = 1;
! m_audio_paused = 0;
m_resync_required = 0;
m_dont_fill = 0;
m_play_time = 0 ;
m_buffer_latency = 0;
m_first_time = 1;
m_convert_buffer = NULL;
m_father = pdp_father;
+ post( "pdp_mp4audiosync : created audio sync" );
}
CPDPAudioSync::~CPDPAudioSync (void)
{
! if (m_sample_buffer[0] != NULL)
! {
! free(m_sample_buffer[0]);
}
+ m_sample_buffer[0] = NULL;
CHECK_AND_FREE(m_convert_buffer);
}
***************
*** 108,115 ****
m_buffer_size = channels * sample_size * m_bytes_per_sample;
! for (int ix = 0; ix < DECODE_BUFFERS_MAX; ix++) {
! m_buffer_filled[ix] = 0;
! m_sample_buffer[ix] = (uint8_t *)malloc(2 * m_buffer_size);
! }
m_freq = freq;
m_channels = channels;
--- 90,96 ----
m_buffer_size = channels * sample_size * m_bytes_per_sample;
! m_buffer_filled[0] = 0;
! m_sample_buffer[0] = (uint8_t *)malloc(2 * m_buffer_size);
!
m_freq = freq;
m_channels = channels;
***************
*** 122,126 ****
m_config_set = 1;
m_msec_per_frame = (sample_size * 1000) / m_freq;
! audio_message(LOG_DEBUG, "buffer size %d msec per frame %d", m_buffer_size, m_msec_per_frame);
};
--- 103,107 ----
m_config_set = 1;
m_msec_per_frame = (sample_size * 1000) / m_freq;
! post("pdp_mp4audiosync : buffer size %d msec per frame %d", m_buffer_size, m_msec_per_frame);
};
***************
*** 133,158 ****
}
! if (m_audio_initialized != 0) {
! locked = 1;
! }
! ret = m_buffer_filled[m_fill_index];
! if (ret == 1) {
! m_audio_waiting_buffer = 1;
! m_audio_waiting_buffer = 0;
! if (m_dont_fill != 0) {
! return (NULL);
! }
! locked = 0;
! if (m_audio_initialized != 0) {
! locked = 1;
! }
! ret = m_buffer_filled[m_fill_index];
! if (locked)
! if (ret == 1) {
! post("pdp_mp4audiosync : no buffer");
! return (NULL);
! }
}
! return (m_sample_buffer[m_fill_index]);
}
--- 114,125 ----
}
! ret = m_buffer_filled[0];
! if (ret == 1)
! {
! post("pdp_mp4audiosync : no buffer");
! return (NULL);
}
! // post("pdp_mp4audiosync : get_audio_buffer : return %x", m_sample_buffer[0]);
! return (m_sample_buffer[0]);
}
***************
*** 165,221 ****
uint32_t copied;
copied = 0;
- if (m_buffer_offset_on == 0) {
- int64_t diff = ts - m_buffer_ts;
! if (m_buffer_ts != 0 && diff > 1) {
! m_load_audio_do_next_resync = 1;
! audio_message(LOG_DEBUG, "timeslot doesn't match - %llu %llu",
! ts, m_buffer_ts);
! }
! m_buffer_ts = ts;
! } else {
! int64_t check;
! check = ts - m_loaded_next_ts;
! if (check > m_msec_per_frame) {
! audio_message(LOG_DEBUG, "potential resync at ts "U64" should be ts "U64,
! ts, m_loaded_next_ts);
! uint32_t left;
! left = m_buffer_size - m_buffer_offset_on;
! to = get_audio_buffer();
! memset(to + m_buffer_offset_on, 0, left);
! filled_audio_buffer(m_buffer_ts, 0);
! m_buffer_offset_on = 0;
! m_load_audio_do_next_resync = 1;
! m_buffer_ts = ts;
! }
}
! m_loaded_next_ts = bytes * M_64;
! m_loaded_next_ts /= m_bytes_per_sample;
! m_loaded_next_ts /= m_freq;
! m_loaded_next_ts += ts;
! while ( bytes > 0) {
! to = get_audio_buffer();
! if (to == NULL) {
! return;
! }
! int copy;
! uint32_t left;
- left = m_buffer_size - m_buffer_offset_on;
- copy = MIN(left, bytes);
- memcpy(to + m_buffer_offset_on, from, copy);
- bytes -= copy;
- copied += copy;
- from += copy;
- m_buffer_offset_on += copy;
- if (m_buffer_offset_on >= m_buffer_size) {
- m_buffer_offset_on = 0;
- filled_audio_buffer(m_buffer_ts, resync | m_load_audio_do_next_resync);
- m_buffer_ts += m_msec_per_frame;
- resync = 0;
- m_load_audio_do_next_resync = 0;
- }
- }
return;
}
--- 132,149 ----
uint32_t copied;
copied = 0;
! post( "pdp_mp4audiosync : load audio buffer : length=%d", bytes );
!
! to = get_audio_buffer();
! if (to == NULL)
! {
! return;
}
! int copy;
! uint32_t left;
! bytes = MIN(m_buffer_size, bytes);
! memcpy(to, from, bytes);
return;
}
***************
*** 223,316 ****
void CPDPAudioSync::filled_audio_buffer (uint64_t ts, int resync)
{
! uint32_t fill_index;
! int locked;
! // m_dont_fill will be set when we have a pause
! if (m_dont_fill == 1) {
! return;
! }
! // resync = 0;
! fill_index = m_fill_index;
! m_fill_index++;
! m_fill_index %= DECODE_BUFFERS_MAX;
! locked = 0;
! if (m_audio_initialized != 0) {
! locked = 1;
! }
! if (m_first_filled != 0) {
! m_first_filled = 0;
! resync = 0;
! m_resync_required = 0;
! } else {
! int64_t diff;
! diff = ts - m_last_fill_timestamp;
! if (diff - m_msec_per_frame > m_msec_per_frame) {
! // have a hole here - don't want to resync
! if (diff > ((m_msec_per_frame + 1) * 4)) {
! resync = 1;
! } else {
! // try to fill the holes
! m_last_fill_timestamp += m_msec_per_frame + 1; // fill plus extra
! int64_t ts_diff;
! do {
! uint8_t *retbuffer;
! // Get and swap buffers.
! retbuffer = get_audio_buffer();
! if (retbuffer == NULL) {
! return;
! }
! if (retbuffer != m_sample_buffer[m_fill_index]) {
! audio_message(LOG_ERR, "retbuffer not fill index in audio sync");
! return;
! }
! locked = 0;
! if (m_audio_initialized != 0) {
! locked = 1;
! }
! m_sample_buffer[m_fill_index] = m_sample_buffer[fill_index];
! m_sample_buffer[fill_index] = retbuffer;
! memset(retbuffer, m_silence, m_buffer_size);
! m_buffer_time[fill_index] = m_last_fill_timestamp;
! m_buffer_filled[fill_index] = 1;
! m_samples_loaded += m_buffer_size;
! fill_index++;
! fill_index %= DECODE_BUFFERS_MAX;
! m_fill_index++;
! m_fill_index %= DECODE_BUFFERS_MAX;
! audio_message(LOG_NOTICE, "Filling timestamp %llu with silence",
! m_last_fill_timestamp);
! m_last_fill_timestamp += m_msec_per_frame + 1; // fill plus extra
! ts_diff = ts - m_last_fill_timestamp;
! audio_message(LOG_DEBUG, "diff is %lld", ts_diff);
! } while (ts_diff > 0);
! locked = 0;
! if (m_audio_initialized != 0) {
! locked = 1;
! }
! }
! } else {
! if (m_last_fill_timestamp == ts) {
! audio_message(LOG_NOTICE, "Repeat timestamp with audio %llu", ts);
! return;
}
}
}
! m_last_fill_timestamp = ts;
! m_buffer_filled[fill_index] = 1;
! m_samples_loaded += m_buffer_size;
! m_buffer_time[fill_index] = ts;
! if (resync) {
! m_resync_required = 1;
! m_resync_buffer = fill_index;
! #ifdef DEBUG_AUDIO_FILL
! audio_message(LOG_DEBUG, "Resync from filled_audio_buffer");
! #endif
! }
!
! // Check this - we might not want to do this unless we're resyncing
! if (resync) m_psptr->wake_sync_thread();
! #ifdef DEBUG_AUDIO_FILL
! audio_message(LOG_DEBUG, "Filling " LLU " %u %u", ts, fill_index, m_samples_loaded);
! #endif
}
--- 151,181 ----
void CPDPAudioSync::filled_audio_buffer (uint64_t ts, int resync)
{
! // post( "pdp_mp4audiosync : filled audio buffer" );
! // if (resync) m_psptr->wake_sync_thread();
! if ( m_father->x_audio )
! {
! // copy the buffer filled by the codec towards pdp
! if ( (m_father->x_audioin_position*sizeof(short)+m_buffer_size) < (4*MAX_AUDIO_PACKET_SIZE*sizeof(short)) )
! {
! memcpy( m_father->x_audio_in+m_father->x_audioin_position, m_sample_buffer[0], m_buffer_size );
! m_father->x_audioin_position+=(m_buffer_size/sizeof(short));
! // post( "pdp_mp4audiosync : filled_audio_buffer : copied %d PCM samples : audio in : %d : resync : %d",
! // m_buffer_size/sizeof(short), m_father->x_audioin_position, resync );
! if ( ( m_father->x_audioin_position > DEFAULT_CHANNELS*m_father->x_blocksize )
! && (!m_father->x_audioon) )
! {
! m_father->x_audioon = 1;
! // post( "pdp_mp4audiosync : audio on" );
}
}
+ else
+ {
+ post( "pdp_mp4audiosync : filled_audio_buffer : skipped buffer : (in : %d)",
+ m_father->x_audioin_position );
+ }
}
!
! return;
}
***************
*** 318,337 ****
{
uint8_t *to;
! if (m_buffer_offset_on != 0) {
! to = get_audio_buffer();
! if (to != NULL) {
! uint32_t left;
! left = m_buffer_size - m_buffer_offset_on;
! memset(to + m_buffer_offset_on, 0, left);
! m_buffer_offset_on = 0;
! filled_audio_buffer(m_buffer_ts, 0);
! m_buffer_ts += m_msec_per_frame;
! }
! }
CAudioSync::set_eof();
}
! int CPDPAudioSync::initialize_audio (int have_video)
{
return (1);
}
--- 183,194 ----
{
uint8_t *to;
!
! to = get_audio_buffer();
CAudioSync::set_eof();
}
! int CPDPAudioSync::initialize_audio (int have_audio)
{
+ m_audio_initialized = 1;
return (1);
}
***************
*** 339,344 ****
int CPDPAudioSync::is_audio_ready (uint64_t &disptime)
{
! disptime = m_buffer_time[m_play_index];
! return (m_dont_fill == 0 && m_buffer_filled[m_play_index] == 1);
}
--- 196,200 ----
int CPDPAudioSync::is_audio_ready (uint64_t &disptime)
{
! return (1);
}
***************
*** 356,359 ****
--- 212,217 ----
int playtime;
+ post( "pdp_mp4audiosync : audio callback" );
+
}
***************
*** 367,393 ****
void CPDPAudioSync::flush_sync_buffers (void)
{
clear_eof();
- m_dont_fill = 1;
- if (m_audio_waiting_buffer) {
- m_audio_waiting_buffer = 0;
- }
}
void CPDPAudioSync::flush_decode_buffers (void)
{
! int locked = 0;
! if (m_audio_initialized != 0) {
! locked = 1;
! }
! m_dont_fill = 0;
! m_first_filled = 1;
! for (int ix = 0; ix < DECODE_BUFFERS_MAX; ix++) {
! m_buffer_filled[ix] = 0;
! }
! m_buffer_offset_on = 0;
! m_play_index = m_fill_index = 0;
! m_audio_paused = 1;
! m_resync_buffer = 0;
! m_samples_loaded = 0;
}
--- 225,236 ----
void CPDPAudioSync::flush_sync_buffers (void)
{
+ post( "pdp_mp4audiosync : flush sync buffer" );
clear_eof();
}
void CPDPAudioSync::flush_decode_buffers (void)
{
! post( "pdp_mp4audiosync : flush decode buffer" );
! m_buffer_filled[0] = 0;
}
***************
*** 467,471 ****
{
((CPDPAudioSync *)ifptr)->filled_audio_buffer(ts,
! resync_req);
}
--- 310,314 ----
{
((CPDPAudioSync *)ifptr)->filled_audio_buffer(ts,
! resync_req);
}
Index: pdp_mp4audiosource.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_mp4audiosource.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pdp_mp4audiosource.cpp 30 Mar 2004 02:59:55 -0000 1.1
--- pdp_mp4audiosource.cpp 18 May 2004 00:44:08 -0000 1.2
***************
*** 102,107 ****
// for live capture we can match the source to the destination
m_audioSrcSamplesPerFrame = m_audioDstSamplesPerFrame;
! m_pcmFrameSize =
! m_audioSrcSamplesPerFrame * m_audioSrcChannels * sizeof(u_int16_t);
if (m_audioOssMaxBufferSize > 0) {
--- 102,106 ----
// for live capture we can match the source to the destination
m_audioSrcSamplesPerFrame = m_audioDstSamplesPerFrame;
! m_pcmFrameSize = m_audioSrcSamplesPerFrame * m_audioSrcChannels * sizeof(u_int16_t);
if (m_audioOssMaxBufferSize > 0) {
***************
*** 136,140 ****
void CPDPAudioSource::ProcessAudio(u_int8_t* pcmBuffer, u_int32_t pcmBufferSize)
{
- audio_buf_info info;
Timestamp currentTime = GetTimestamp();
Timestamp timestamp;
--- 135,138 ----
***************
*** 157,203 ****
}
! if (info.bytes == m_audioOssMaxBufferSize) {
! // means the audio buffer is full, and not capturing
! // we want to make the timestamp based on the previous one
! // When we hit this case, we start using the m_timestampOverflowArray
! // This will give us a timestamp for when the array is full.
! //
! // In other words, if we have a full audio buffer (ie: it's not loading
! // any more), we start storing the current timestamp into the array.
! // This will let us "catch up", and have a somewhat accurate timestamp
! // when we loop around
! //
! // wmay - I'm not convinced that this actually works - if the buffer
! // cleans up, we'll ignore m_timestampOverflowArray
! if (m_timestampOverflowArray != NULL &&
! m_timestampOverflowArray[m_timestampOverflowArrayIndex] != 0) {
! timestamp = m_timestampOverflowArray[m_timestampOverflowArrayIndex];
! } else {
! timestamp = m_prevTimestamp + SrcSamplesToTicks(m_audioSrcSamplesPerFrame);
! }
!
! if (m_timestampOverflowArray != NULL)
! m_timestampOverflowArray[m_timestampOverflowArrayIndex] = currentTime;
!
! debug_message("pdp_mp4live~ : audio buffer full !");
!
! } else {
! // buffer is not full - so, we make the timestamp based on the number
! // of bytes in the buffer that we read.
! timestamp = currentTime - SrcSamplesToTicks(SrcBytesToSamples(info.bytes));
! if (m_timestampOverflowArray != NULL)
! m_timestampOverflowArray[m_timestampOverflowArrayIndex] = 0;
! }
#ifdef DEBUG_TIMESTAMPS
! debug_message("pdp_mp4live~ : info.bytes=%d t=%llu timestamp=%llu delta=%llu",
! info.bytes, currentTime, timestamp, timestamp - m_prevTimestamp);
#endif
m_prevTimestamp = timestamp;
- if (m_timestampOverflowArray != NULL) {
- m_timestampOverflowArrayIndex = (m_timestampOverflowArrayIndex + 1) %
- m_audioOssMaxBufferFrames;
- }
ProcessAudioFrame(m_pcmFrameBuffer, m_pcmFrameSize, timestamp, false);
--- 155,166 ----
}
! timestamp = currentTime - SrcSamplesToTicks(SrcBytesToSamples(pcmBufferSize));
#ifdef DEBUG_TIMESTAMPS
! debug_message("pdp_mp4live~ : bytes=%d t=%llu timestamp=%llu delta=%llu",
! pcmBufferSize, currentTime, timestamp, timestamp - m_prevTimestamp);
#endif
m_prevTimestamp = timestamp;
ProcessAudioFrame(m_pcmFrameBuffer, m_pcmFrameSize, timestamp, false);
Index: pdp_canvas.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_canvas.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pdp_canvas.c 25 Oct 2003 02:06:30 -0000 1.4
--- pdp_canvas.c 18 May 2004 00:44:08 -0000 1.5
***************
*** 42,45 ****
--- 42,46 ----
t_int x_opacket;
+ t_int x_lastpacket;
t_int x_current;
***************
*** 140,143 ****
--- 141,145 ----
ppV+((py-(t_int)x->x_yoffsets[ii])>>1)*(x->x_widths[ii]>>1)+(mx>>1), dx );
}
+
}
}
***************
*** 242,249 ****
if (s== gensym("register_rw"))
{
- /* release the packet */
if ( x->x_packets[ni] != -1 )
! {
! pdp_packet_mark_unused(x->x_packets[ni]);
x->x_packets[ni] = -1;
}
--- 244,251 ----
if (s== gensym("register_rw"))
{
if ( x->x_packets[ni] != -1 )
! {
! // delete the packet
! pdp_packet_delete(x->x_packets[ni]);
x->x_packets[ni] = -1;
}
Index: pdp_vertigo.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_vertigo.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pdp_vertigo.c 17 Sep 2003 20:09:51 -0000 1.2
--- pdp_vertigo.c 18 May 2004 00:44:09 -0000 1.3
***************
*** 212,216 ****
v = pcy[i] & 0xffff;
v = (v * 3) + ((*poy++) & 0xffff);
! *pny++ = (v>>2);
if ( (((px+1)%2)==0) && (((py+1)%2)==0) )
{
--- 212,216 ----
v = pcy[i] & 0xffff;
v = (v * 3) + ((*poy++) & 0xffff);
! *pny++ = (v>>2)<<7;
if ( (((px+1)%2)==0) && (((py+1)%2)==0) )
{
Index: pdp_lumafilt.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_lumafilt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pdp_lumafilt.c 17 Sep 2003 20:05:59 -0000 1.2
--- pdp_lumafilt.c 18 May 2004 00:44:08 -0000 1.3
***************
*** 135,139 ****
else
{
! post( "pdp_lumafilt : luminosity value out of bounds : %d", luma );
}
pnY++;
--- 135,139 ----
else
{
! // post( "pdp_lumafilt : luminosity value out of bounds : %d", luma );
}
pnY++;
Index: pdp_ascii.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_ascii.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pdp_ascii.c 17 Sep 2003 20:01:29 -0000 1.2
--- pdp_ascii.c 18 May 2004 00:44:08 -0000 1.3
***************
*** 26,32 ****
#include "pdp.h"
#include "yuv.h"
! #include "charmaps.h"
#include <math.h>
static char *pdp_ascii_version = "pdp_ascii: version 0.1, ASCII art output written by ydegoyon(a)free.fr";
--- 26,34 ----
#include "pdp.h"
#include "yuv.h"
! #include "default.map"
#include <math.h>
+ #define LINE_MAX_LENGTH 1024
+
static char *pdp_ascii_version = "pdp_ascii: version 0.1, ASCII art output written by ydegoyon(a)free.fr";
***************
*** 50,53 ****
--- 52,62 ----
t_float x_ratio; // character to pixel ratio
+ t_int x_charwidth; // width of characters
+ t_int x_charheight; // height of characters
+ t_int x_nbchars; // number of characters in the map
+ char* x_charmaps; // the table of characters
+
+ FILE *x_filed; // charmaps file descriptor
+
} t_pdp_ascii;
***************
*** 62,68 ****
static void pdp_ascii_ratio(t_pdp_ascii *x, t_floatarg fratio)
{
! if ( ( fratio > 0) && ( x->x_ratio < x->x_vwidth/2 ) )
{
x->x_ratio = fratio;
}
}
--- 71,80 ----
static void pdp_ascii_ratio(t_pdp_ascii *x, t_floatarg fratio)
{
! if ( ( fratio > 0)
! && ( fratio < x->x_vwidth/x->x_charwidth )
! && ( fratio < x->x_vheight/x->x_charheight ) )
{
x->x_ratio = fratio;
+ // post( "psp_ascii : set ratio : %f", x->x_ratio );
}
}
***************
*** 85,89 ****
t_int px, py, ppx, ppy;
t_int rank, value;
! t_int pwidth, pheight;
x->x_vwidth = header->info.image.width;
--- 97,101 ----
t_int px, py, ppx, ppy;
t_int rank, value;
! t_int pwidth, pheight, offset;
x->x_vwidth = header->info.image.width;
***************
*** 97,108 ****
memset( newdata, 0x00, (x->x_vsize+(x->x_vsize>>1))<<1 );
! pwidth = (int) CHARWIDTH*x->x_ratio;
if (pwidth==0) pwidth=1;
! if (pwidth>x->x_vwidth) return;
! pheight = (int) CHARHEIGHT*x->x_ratio;
if (pheight==0) pheight=1;
! if (pheight>x->x_vheight) return;
! for(py=1; py<x->x_vheight; py+=pheight)
{
for(px=0; px<x->x_vwidth; px+=pwidth)
--- 109,122 ----
memset( newdata, 0x00, (x->x_vsize+(x->x_vsize>>1))<<1 );
! pwidth = (int) x->x_charwidth*x->x_ratio;
if (pwidth==0) pwidth=1;
! // if (pwidth>x->x_vwidth) return;
! pheight = (int) x->x_charheight*x->x_ratio;
if (pheight==0) pheight=1;
! // if (pheight>x->x_vheight) return;
! // post( "psp_ascii : pwidth=%d, pheight=%d", pwidth, pheight );
!
! for(py=0; py<x->x_vheight; py+=pheight)
{
for(px=0; px<x->x_vwidth; px+=pwidth)
***************
*** 113,116 ****
--- 127,135 ----
for ( ppx=0; ppx<pwidth; ppx++ )
{
+ if ( ( px+ppx >= x->x_vwidth ) ||
+ ( py+ppy >= x->x_vheight ) )
+ {
+ break;
+ }
pixsum += (data[(py+ppy)*x->x_vwidth + (px+ppx)]>>7);
}
***************
*** 121,130 ****
for ( ppx=0; ppx<pwidth; ppx++ )
{
! if ( ( px+ppx > x->x_vwidth ) ||
! ( py+ppy > x->x_vheight ) )
{
break;
}
! if ( charmaps[rank][((int)(ppy/x->x_ratio))*CHARWIDTH+((int)(ppx/x->x_ratio))] )
{
value = ( (2*rank+x->x_brightness) > 255 ) ? 255 : (2*rank+x->x_brightness);
--- 140,151 ----
for ( ppx=0; ppx<pwidth; ppx++ )
{
! if ( ( px+ppx >= x->x_vwidth ) ||
! ( py+ppy >= x->x_vheight ) )
{
break;
}
! offset = rank*x->x_charwidth*x->x_charheight
! +((int)(ppy/x->x_ratio))*x->x_charwidth+((int)(ppx/x->x_ratio));
! if ( *(x->x_charmaps+offset) && ( offset < x->x_nbchars*x->x_charwidth*x->x_charheight ) )
{
value = ( (2*rank+x->x_brightness) > 255 ) ? 255 : (2*rank+x->x_brightness);
***************
*** 210,217 ****
--- 231,341 ----
int i;
+ if ( x->x_charmaps ) free( x->x_charmaps );
pdp_queue_finish(x->x_queue_id);
pdp_packet_mark_unused(x->x_packet0);
}
+ /* load a new charmaps file */
+ static void pdp_ascii_load(t_pdp_ascii *x, t_symbol *sfile)
+ {
+ char *lineread = (char*) getbytes( LINE_MAX_LENGTH );
+ char *word1 = (char*) getbytes( LINE_MAX_LENGTH );
+ char *word2 = (char*) getbytes( LINE_MAX_LENGTH );
+ char *word3 = (char*) getbytes( LINE_MAX_LENGTH );
+ t_int charwidth, charheight, nbchars, nblines;
+ t_int nbexpdata;
+ char *pdata;
+ char charread;
+
+ // opening new charmaps file
+ if ( ( x->x_filed = fopen( sfile->s_name, "r" ) ) == NULL )
+ {
+ error( "pdp_ascii : cannot open >%s<", sfile->s_name);
+ return;
+ }
+ post( "pdp_ascii : opened >%s<", sfile->s_name);
+
+ // read the new dimensions of the charmaps
+ charwidth = -1;
+ charheight = -1;
+ nbchars = -1;
+ nblines = 0;
+ while ( lineread[0] != '{' )
+ {
+ if ( fgets( lineread, LINE_MAX_LENGTH, x->x_filed ) == 0 )
+ {
+ post( "pdp_ascii : abnormal end of file encountered..." );
+ goto closeandreturn;
+ }
+
+ if ( strncmp( lineread, "#define", 7 ) == 0 )
+ {
+ sscanf( lineread, "%s %s %s", word1, word2, word3 );
+ // post( "pdp_ascii : definition : %s = %s", word2, word3 );
+ if ( !strcmp( word2, "CHARWIDTH" ) )
+ {
+ charwidth = atoi( word3 );
+ }
+ if ( !strcmp( word2, "CHARHEIGHT" ) )
+ {
+ charheight = atoi( word3 );
+ }
+ if ( !strcmp( word2, "NBCHARS" ) )
+ {
+ nbchars = atoi( word3 );
+ }
+ }
+
+ nblines++;
+ if ( nblines>20 ) break;
+ }
+
+ if ( ( charwidth > 0 ) && ( charheight > 0 ) && ( nbchars > 0 ) )
+ {
+ post( "pdp_ascii : new dimensions : %d %dx%d characters", nbchars, charwidth, charheight );
+ if ( x->x_charmaps ) free( x->x_charmaps );
+ x->x_charwidth = charwidth;
+ x->x_charheight = charheight;
+ x->x_nbchars = nbchars;
+ x->x_charmaps = (char*)malloc(x->x_nbchars*x->x_charwidth*x->x_charheight*sizeof(char));
+ }
+ else
+ {
+ post( "pdp_ascii : wrong file format : couldn't read new dimensions" );
+ goto closeandreturn;
+ }
+
+ nbexpdata = nbchars*charwidth*charheight;
+ pdata = x->x_charmaps;
+
+ while ( ( ( charread = fgetc( x->x_filed ) ) != EOF ) && ( nbexpdata > 0 ) )
+ {
+ switch ( charread )
+ {
+ case '0':
+ case '1':
+ *pdata++ = ( charread == '0' )?0:1;
+ nbexpdata--;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ closeandreturn :
+
+ // closing opened file
+ if ( x->x_filed != NULL )
+ {
+ if(fclose(x->x_filed) < 0)
+ {
+ perror( "pdp_ascii : closing file" );
+ }
+ x->x_filed = NULL;
+ return;
+ }
+ }
+
t_class *pdp_ascii_class;
***************
*** 231,234 ****
--- 355,364 ----
x->x_brightness = 25;
+ x->x_charwidth = CHARWIDTH;
+ x->x_charheight = CHARHEIGHT;
+ x->x_nbchars = NBCHARS;
+ x->x_charmaps = (char*)malloc(x->x_nbchars*x->x_charwidth*x->x_charheight*sizeof(char));
+ memcpy( (void*)x->x_charmaps, (void*)charmaps, x->x_nbchars*x->x_charwidth*x->x_charheight*sizeof(char) );
+
return (void *)x;
}
***************
*** 251,254 ****
--- 381,385 ----
class_addmethod(pdp_ascii_class, (t_method)pdp_ascii_brightness, gensym("brightness"), A_DEFFLOAT, A_NULL);
class_addmethod(pdp_ascii_class, (t_method)pdp_ascii_ratio, gensym("ratio"), A_DEFFLOAT, A_NULL);
+ class_addmethod( pdp_ascii_class, (t_method)pdp_ascii_load, gensym("load"), A_SYMBOL, 0);
class_sethelpsymbol( pdp_ascii_class, gensym("pdp_ascii.pd") );
Index: pdp_ocanvas.c
===================================================================
RCS file: /cvsroot/pure-data/externals/pidip/modules/pdp_ocanvas.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** pdp_ocanvas.c 8 Dec 2003 23:06:15 -0000 1.1
--- pdp_ocanvas.c 18 May 2004 00:44:09 -0000 1.2
***************
*** 239,243 ****
if ( x->x_packets[ni] != -1 )
{
! pdp_packet_mark_unused(x->x_packets[ni]);
x->x_packets[ni] = -1;
}
--- 239,243 ----
if ( x->x_packets[ni] != -1 )
{
! pdp_packet_delete(x->x_packets[ni]);
x->x_packets[ni] = -1;
}