Mercurial > mplayer.hg
changeset 30378:8339bca8e4b4
Move the resync-related code into more consistent places instead of having it
scattered all over the place with half of it forgotten in some places.
author | reimar |
---|---|
date | Sun, 24 Jan 2010 15:16:39 +0000 |
parents | 2eea1f09e2c5 |
children | 0140d505dd91 |
files | libmpcodecs/dec_audio.c libmpcodecs/dec_video.c libmpdemux/demuxer.c mencoder.c mplayer.c |
diffstat | 5 files changed, 28 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/dec_audio.c Sun Jan 24 12:55:05 2010 +0000 +++ b/libmpcodecs/dec_audio.c Sun Jan 24 15:16:39 2010 +0000 @@ -455,6 +455,8 @@ void resync_audio_stream(sh_audio_t *sh_audio) { + sh_audio->a_buffer_len = 0; + sh_audio->a_out_buffer_len = 0; sh_audio->a_in_buffer_len = 0; // clear audio input buffer if (!sh_audio->initialized) return;
--- a/libmpcodecs/dec_video.c Sun Jan 24 12:55:05 2010 +0000 +++ b/libmpcodecs/dec_video.c Sun Jan 24 15:16:39 2010 +0000 @@ -133,6 +133,10 @@ void resync_video_stream(sh_video_t *sh_video) { + sh_video->timer = 0; + sh_video->next_frame_time = 0; + sh_video->num_buffered_pts = 0; + sh_video->last_pts = MP_NOPTS_VALUE; if(mpvdec) mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL); }
--- a/libmpdemux/demuxer.c Sun Jan 24 12:55:05 2010 +0000 +++ b/libmpdemux/demuxer.c Sun Jan 24 15:16:39 2010 +0000 @@ -1183,6 +1183,20 @@ return res; } +static void demux_resync(demuxer_t *demuxer) +{ + sh_video_t *sh_video = demuxer->video->sh; + sh_audio_t *sh_audio = demuxer->audio->sh; + demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); + if (sh_video) { + ds_fill_buffer(demuxer->video); + resync_video_stream(sh_video); + } + if (sh_audio) { + ds_fill_buffer(demuxer->audio); + resync_audio_stream(sh_audio); + } +} void demux_flush(demuxer_t *demuxer) { @@ -1196,8 +1210,6 @@ { demux_stream_t *d_audio = demuxer->audio; demux_stream_t *d_video = demuxer->video; - sh_audio_t *sh_audio = d_audio->sh; - sh_video_t *sh_video = d_video->sh; double tmp = 0; double pts; @@ -1214,17 +1226,11 @@ } demux_flush(demuxer); - // clear demux buffers: - if (sh_audio) - sh_audio->a_buffer_len = 0; demuxer->stream->eof = 0; demuxer->video->eof = 0; demuxer->audio->eof = 0; - if (sh_video) - sh_video->timer = 0; // !!!!!! - if (flags & SEEK_ABSOLUTE) pts = 0.0f; else { @@ -1243,7 +1249,7 @@ if (stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_TIME, &pts) != STREAM_UNSUPPORTED) { - demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); + demux_resync(demuxer); return 1; } @@ -1251,8 +1257,7 @@ if (demuxer->desc->seek) demuxer->desc->seek(demuxer, rel_seek_secs, audio_delay, flags); - if (sh_audio) - resync_audio_stream(sh_audio); + demux_resync(demuxer); return 1; } @@ -1475,8 +1480,6 @@ { int ris; int current, total; - sh_video_t *sh_video = demuxer->video->sh; - sh_audio_t *sh_audio = demuxer->audio->sh; if (!demuxer->num_chapters || !demuxer->chapters) { if (!mode) { @@ -1491,17 +1494,9 @@ ris = stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_CHAPTER, &chapter); - if (ris != STREAM_UNSUPPORTED) - demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); - if (sh_video) { - ds_fill_buffer(demuxer->video); - resync_video_stream(sh_video); - } - if (sh_audio) { - ds_fill_buffer(demuxer->audio); - resync_audio_stream(sh_audio); - } + demux_resync(demuxer); + // exit status may be ok, but main() doesn't have to seek itself // (because e.g. dvds depend on sectors, not on pts) *seek_pts = -1.0; @@ -1525,6 +1520,9 @@ return ris != STREAM_UNSUPPORTED ? chapter : -1; } else { // chapters structure is set in the demuxer + sh_video_t *sh_video = demuxer->video->sh; + sh_audio_t *sh_audio = demuxer->audio->sh; + total = demuxer->num_chapters; if (mode == 1) //absolute seeking @@ -1659,8 +1657,6 @@ int demuxer_set_angle(demuxer_t *demuxer, int angle) { int ris, angles = -1; - sh_video_t *sh_video = demuxer->video->sh; - sh_audio_t *sh_audio = demuxer->audio->sh; angles = demuxer_angles_count(demuxer); if ((angles < 1) || (angle > angles)) @@ -1672,16 +1668,7 @@ if (ris == STREAM_UNSUPPORTED) return -1; - demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL); - if (sh_video) { - ds_fill_buffer(demuxer->video); - resync_video_stream(sh_video); - } - - if (sh_audio) { - ds_fill_buffer(demuxer->audio); - resync_audio_stream(sh_audio); - } + demux_resync(demuxer); return angle; }
--- a/mencoder.c Sun Jan 24 12:55:05 2010 +0000 +++ b/mencoder.c Sun Jan 24 15:16:39 2010 +0000 @@ -1708,7 +1708,6 @@ if(demux_seek(demuxer, next_edl_record->stop_sec - sh_video->pts, audio_delay, 0)){ sh_video->pts = demuxer->video->pts; //if (vo_vobsub) vobsub_seek(vo_vobsub,sh_video->pts); - resync_video_stream(sh_video); //if(vo_spudec) spudec_reset(vo_spudec); if (audio_delay != 0.0) fixdelay(demuxer->video, d_audio, mux_a, frame_data, framecopy); return 1;
--- a/mplayer.c Sun Jan 24 12:55:05 2010 +0000 +++ b/mplayer.c Sun Jan 24 15:16:39 2010 +0000 @@ -2543,12 +2543,8 @@ mpctx->startup_decode_retry = DEFAULT_STARTUP_DECODE_RETRY; if (mpctx->sh_video) { current_module = "seek_video_reset"; - resync_video_stream(mpctx->sh_video); if (vo_config_count) mpctx->video_out->control(VOCTRL_RESET, NULL); - mpctx->sh_video->next_frame_time = 0; - mpctx->sh_video->num_buffered_pts = 0; - mpctx->sh_video->last_pts = MP_NOPTS_VALUE; mpctx->num_buffered_frames = 0; mpctx->delay = 0; mpctx->time_frame = 0; @@ -2563,8 +2559,6 @@ if (mpctx->sh_audio) { current_module = "seek_audio_reset"; mpctx->audio_out->reset(); // stop audio, throwing away buffered data - mpctx->sh_audio->a_buffer_len = 0; - mpctx->sh_audio->a_out_buffer_len = 0; if (!mpctx->sh_video) update_subtitles(NULL, mpctx->sh_audio->pts, mpctx->d_sub, 1); }