[MPlayer-cvslog] r30420 - in trunk: libmpcodecs/dec_audio.c libmpcodecs/dec_video.c libmpdemux/demuxer.c mencoder.c mplayer.c

reimar subversion at mplayerhq.hu
Sun Jan 24 16:16:39 CET 2010


Author: reimar
Date: Sun Jan 24 16:16:39 2010
New Revision: 30420

Log:
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.

Modified:
   trunk/libmpcodecs/dec_audio.c
   trunk/libmpcodecs/dec_video.c
   trunk/libmpdemux/demuxer.c
   trunk/mencoder.c
   trunk/mplayer.c

Modified: trunk/libmpcodecs/dec_audio.c
==============================================================================
--- trunk/libmpcodecs/dec_audio.c	Sun Jan 24 13:55:05 2010	(r30419)
+++ trunk/libmpcodecs/dec_audio.c	Sun Jan 24 16:16:39 2010	(r30420)
@@ -455,6 +455,8 @@ int decode_audio(sh_audio_t *sh_audio, i
 
 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;

Modified: trunk/libmpcodecs/dec_video.c
==============================================================================
--- trunk/libmpcodecs/dec_video.c	Sun Jan 24 13:55:05 2010	(r30419)
+++ trunk/libmpcodecs/dec_video.c	Sun Jan 24 16:16:39 2010	(r30420)
@@ -133,6 +133,10 @@ int set_rectangle(sh_video_t *sh_video,i
 
 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);
 }
 

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	Sun Jan 24 13:55:05 2010	(r30419)
+++ trunk/libmpdemux/demuxer.c	Sun Jan 24 16:16:39 2010	(r30420)
@@ -1183,6 +1183,20 @@ demuxer_t *demux_open(stream_t *vs, int 
     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 @@ int demux_seek(demuxer_t *demuxer, float
 {
     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 @@ int demux_seek(demuxer_t *demuxer, float
     }
 
     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 @@ int demux_seek(demuxer_t *demuxer, float
 
     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 @@ int demux_seek(demuxer_t *demuxer, float
     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 demuxer_seek_chapter(demuxer_t *demu
 {
     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 @@ int demuxer_seek_chapter(demuxer_t *demu
 
         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 @@ int demuxer_seek_chapter(demuxer_t *demu
 
         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_get_current_angle(demuxer_t 
 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 @@ int demuxer_set_angle(demuxer_t *demuxer
     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;
 }

Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c	Sun Jan 24 13:55:05 2010	(r30419)
+++ trunk/mencoder.c	Sun Jan 24 16:16:39 2010	(r30420)
@@ -1708,7 +1708,6 @@ static int edl_seek(edl_record_ptr next_
         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;

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Sun Jan 24 13:55:05 2010	(r30419)
+++ trunk/mplayer.c	Sun Jan 24 16:16:39 2010	(r30420)
@@ -2543,12 +2543,8 @@ static int seek(MPContext *mpctx, double
     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 @@ static int seek(MPContext *mpctx, double
     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);
     }


More information about the MPlayer-cvslog mailing list