diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 11 | ||||
-rw-r--r-- | src/xine-engine/audio_decoder.c | 14 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 14 | ||||
-rw-r--r-- | src/xine-engine/metronom.c | 98 | ||||
-rw-r--r-- | src/xine-engine/metronom.h | 11 | ||||
-rw-r--r-- | src/xine-engine/video_decoder.c | 11 |
6 files changed, 125 insertions, 34 deletions
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index 65c4e141a..b1085c5be 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpeg_block.c,v 1.42 2001/09/08 15:41:20 guenter Exp $ + * $Id: demux_mpeg_block.c,v 1.43 2001/09/12 22:18:47 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -125,7 +125,16 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m /* If this is not a block for the demuxer, pass it * straight through. */ if(buf->type != BUF_DEMUX_BLOCK) { + buf_element_t *cbuf; + this->video_fifo->put (this->video_fifo, buf); + + /* duplicate goes to audio fifo */ + + cbuf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + cbuf->type = buf->type; + this->audio_fifo->put (this->audio_fifo, cbuf); + return; } diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index eeb542619..74a88c2df 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_decoder.c,v 1.38 2001/09/12 17:33:34 guenter Exp $ + * $Id: audio_decoder.c,v 1.39 2001/09/12 22:18:47 guenter Exp $ * * * functions that implement audio decoding @@ -124,7 +124,17 @@ void *audio_decoder_loop (void *this_gen) { } running = 0; break; - + + case BUF_VIDEO_FILL: + break; + + case BUF_CONTROL_NOP: + break; + + case BUF_CONTROL_DISCONTINUITY: + this->metronom->expect_audio_discontinuity (this->metronom); + break; + default: while (this->audio_mute==2) { diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 85f99e585..d8cd73690 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.h,v 1.12 2001/09/10 03:04:48 guenter Exp $ + * $Id: buffer.h,v 1.13 2001/09/12 22:18:47 guenter Exp $ * * * contents: @@ -60,10 +60,14 @@ extern "C" { /* control buffer types */ -#define BUF_CONTROL_BASE 0x01000000 -#define BUF_CONTROL_START 0x01000000 -#define BUF_CONTROL_END 0x01010000 -#define BUF_CONTROL_QUIT 0x01020000 +#define BUF_CONTROL_BASE 0x01000000 +#define BUF_CONTROL_START 0x01000000 +#define BUF_CONTROL_END 0x01010000 +#define BUF_CONTROL_QUIT 0x01020000 +#define BUF_CONTROL_DISCONTINUITY 0x01030000 +#define BUF_CONTROL_NOP 0x01040000 +#define BUF_CONTROL_AUDIO_CHANNEL 0x01050000 +#define BUF_CONTROL_SPU_CHANNEL 0x01060000 /* video buffer types: */ diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index 48644548a..8069552ea 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: metronom.c,v 1.25 2001/09/10 21:52:59 guenter Exp $ + * $Id: metronom.c,v 1.26 2001/09/12 22:18:47 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -398,6 +398,20 @@ static uint32_t metronom_got_spu_packet (metronom_t *this, uint32_t pts,uint32_t return pts + this->video_wrap_offset; } +static void metronom_expect_audio_discontinuity (metronom_t *this) { + + printf ("metronom: expecting audio discontinuity\n"); + + this->audio_discontinuity = 1; +} + +static void metronom_expect_video_discontinuity (metronom_t *this) { + + printf ("metronom: expecting video discontinuity\n"); + + this->video_discontinuity = 1; +} + static uint32_t metronom_got_video_frame (metronom_t *this, uint32_t pts) { uint32_t vpts; @@ -430,8 +444,10 @@ static uint32_t metronom_got_video_frame (metronom_t *this, uint32_t pts) { */ if ( ( (pts + WRAP_TRESHOLD) <this->last_video_pts) - && (pts<WRAP_START_TIME) ) { + && (this->video_discontinuity || (pts<WRAP_START_TIME)) ) { + this->video_discontinuity = 0; + this->video_wrap_offset += this->last_video_pts - pts + this->num_video_vpts_guessed *(this->pts_per_frame + this->video_pts_delta); @@ -467,6 +483,22 @@ static uint32_t metronom_got_video_frame (metronom_t *this, uint32_t pts) { vpts = pts + this->video_wrap_offset; /* + * jump into the future? + */ + if (this->video_discontinuity + && (vpts > (this->video_vpts + 10000))) { + + printf ("metronom: video jump into the future\n"); + + this->video_discontinuity = 0; + + this->video_wrap_offset += this->last_video_pts - pts + + this->num_video_vpts_guessed *(this->pts_per_frame + this->video_pts_delta); + + vpts = pts + this->video_wrap_offset; + } + + /* * calc delta to compensate wrong framerates */ @@ -531,7 +563,9 @@ static uint32_t metronom_got_audio_samples (metronom_t *this, uint32_t pts, uint * did a wrap-around occur? */ if ( ( (pts + WRAP_TRESHOLD) < this->last_audio_pts ) - && (pts<WRAP_START_TIME) ) { + && (this->audio_discontinuity || (pts<WRAP_START_TIME)) ) { + + this->audio_discontinuity = 0; this->audio_wrap_offset += this->last_audio_pts - pts + this->num_audio_samples_guessed *(this->audio_pts_delta + this->pts_per_smpls) / AUDIO_SAMPLE_NUM ; @@ -568,6 +602,22 @@ static uint32_t metronom_got_audio_samples (metronom_t *this, uint32_t pts, uint vpts = pts + this->audio_wrap_offset; /* + * jump into the future? + */ + if (this->audio_discontinuity + && (vpts > (this->audio_vpts + 10000))) { + + printf ("metronom: video jump into the future\n"); + + this->audio_discontinuity = 0; + + this->audio_wrap_offset += this->last_audio_pts - pts + + this->num_audio_samples_guessed *(this->audio_pts_delta + this->pts_per_smpls) / AUDIO_SAMPLE_NUM ; + + vpts = pts + this->audio_wrap_offset; + } + + /* * calc delta to compensate wrong samplerates */ @@ -681,26 +731,28 @@ metronom_t * metronom_init (int have_audio) { metronom_t *this = xmalloc (sizeof (metronom_t)); - this->audio_stream_start= metronom_audio_stream_start; - this->audio_stream_end = metronom_audio_stream_end ; - this->video_stream_start= metronom_video_stream_start; - this->video_stream_end = metronom_video_stream_end ; - this->set_video_rate = metronom_set_video_rate; - this->get_video_rate = metronom_get_video_rate; - this->set_audio_rate = metronom_set_audio_rate; - this->got_video_frame = metronom_got_video_frame; - this->got_audio_samples = metronom_got_audio_samples; - this->got_spu_packet = metronom_got_spu_packet; - this->set_av_offset = metronom_set_av_offset; - this->get_av_offset = metronom_get_av_offset; - this->start_clock = metronom_start_clock; - this->stop_clock = metronom_stop_clock; - this->resume_clock = metronom_resume_clock; - this->get_current_time = metronom_get_current_time; - this->adjust_clock = metronom_adjust_clock; - this->register_scr = metronom_register_scr; - this->unregister_scr = metronom_unregister_scr; - this->set_speed = metronom_set_speed; + this->audio_stream_start = metronom_audio_stream_start; + this->audio_stream_end = metronom_audio_stream_end ; + this->video_stream_start = metronom_video_stream_start; + this->video_stream_end = metronom_video_stream_end ; + this->set_video_rate = metronom_set_video_rate; + this->get_video_rate = metronom_get_video_rate; + this->set_audio_rate = metronom_set_audio_rate; + this->got_video_frame = metronom_got_video_frame; + this->got_audio_samples = metronom_got_audio_samples; + this->got_spu_packet = metronom_got_spu_packet; + this->set_av_offset = metronom_set_av_offset; + this->get_av_offset = metronom_get_av_offset; + this->expect_video_discontinuity = metronom_expect_video_discontinuity; + this->expect_audio_discontinuity = metronom_expect_audio_discontinuity; + this->start_clock = metronom_start_clock; + this->stop_clock = metronom_stop_clock; + this->resume_clock = metronom_resume_clock; + this->get_current_time = metronom_get_current_time; + this->adjust_clock = metronom_adjust_clock; + this->register_scr = metronom_register_scr; + this->unregister_scr = metronom_unregister_scr; + this->set_speed = metronom_set_speed; this->scr_list = calloc(MAX_SCR_PROVIDERS, sizeof(void*)); this->register_scr(this, unixscr_init()); diff --git a/src/xine-engine/metronom.h b/src/xine-engine/metronom.h index 368bed25e..4b436bdce 100644 --- a/src/xine-engine/metronom.h +++ b/src/xine-engine/metronom.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: metronom.h,v 1.10 2001/08/25 07:12:16 guenter Exp $ + * $Id: metronom.h,v 1.11 2001/09/12 22:18:47 guenter Exp $ * * metronom: general pts => virtual calculation/assoc * @@ -121,6 +121,13 @@ struct metronom_s { int32_t (*get_av_offset) (metronom_t *this); /* + * tell metronom to expect a pts discontinuity + */ + + void (*expect_audio_discontinuity) (metronom_t *this); + void (*expect_video_discontinuity) (metronom_t *this); + + /* * system clock reference (SCR) functions */ @@ -205,6 +212,8 @@ struct metronom_s { int video_stream_running; int audio_stream_starting; int audio_stream_running; + int video_discontinuity; + int audio_discontinuity; pthread_cond_t video_started; pthread_cond_t audio_started; pthread_cond_t video_ended; diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index ab86afa0b..d88f1656c 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_decoder.c,v 1.49 2001/09/11 09:03:51 jkeil Exp $ + * $Id: video_decoder.c,v 1.50 2001/09/12 22:18:47 guenter Exp $ * */ @@ -91,7 +91,7 @@ void *video_decoder_loop (void *this_gen) { pthread_mutex_lock (&this->xine_lock); this->video_finished = 0; this->spu_finished = 0; -/* FIXME: I don't think we need spu_track_map. */ + /* FIXME: I don't think we need spu_track_map. */ for (i=0 ; i<50; i++) this->spu_track_map[0] = 0; @@ -172,6 +172,13 @@ void *video_decoder_loop (void *this_gen) { running = 0; break; + case BUF_CONTROL_DISCONTINUITY: + this->metronom->expect_video_discontinuity (this->metronom); + break; + + case BUF_CONTROL_NOP: + break; + default: profiler_start_count (prof_video_decode); |