changeset 11977:efb37725d616

flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12)
author michael
date Wed, 18 Feb 2004 15:23:41 +0000
parents 4e70e9ea29c4
children b1cb4a217e6a
files libmpcodecs/ad_ffmpeg.c libmpcodecs/dec_video.c libmpcodecs/dec_video.h libmpcodecs/vd.h libmpcodecs/vd_ffmpeg.c mplayer.c
diffstat 6 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ad_ffmpeg.c	Wed Feb 18 13:34:41 2004 +0000
+++ b/libmpcodecs/ad_ffmpeg.c	Wed Feb 18 15:23:41 2004 +0000
@@ -126,8 +126,13 @@
 
 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
 {
-    // TODO ???
-  return CONTROL_UNKNOWN;
+    AVCodecContext *lavc_context = sh->context;
+    switch(cmd){
+    case ADCTRL_RESYNC_STREAM:
+        avcodec_flush_buffers(lavc_context);
+    return CONTROL_TRUE;
+    }
+    return CONTROL_UNKNOWN;
 }
 
 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
@@ -139,6 +144,7 @@
 	int x=ds_get_packet(sh_audio->ds,&start);
 	if(x<=0) break; // error
 	y=avcodec_decode_audio(sh_audio->context,(INT16*)buf,&len2,start,x);
+//printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout);
 	if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
 	if(y<x) sh_audio->ds->buffer_pos+=y-x;  // put back data (HACK!)
 	if(len2>0){
--- a/libmpcodecs/dec_video.c	Wed Feb 18 13:34:41 2004 +0000
+++ b/libmpcodecs/dec_video.c	Wed Feb 18 15:23:41 2004 +0000
@@ -132,6 +132,11 @@
     return 0;
 }
 
+void resync_video_stream(sh_video_t *sh_video)
+{
+    if(mpvdec) mpvdec->control(sh_video, VDCTRL_RESYNC_STREAM, NULL);
+}
+
 void uninit_video(sh_video_t *sh_video){
     if(!sh_video->inited) return;
     mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_UninitVideoStr,sh_video->codec->drv);
--- a/libmpcodecs/dec_video.h	Wed Feb 18 13:34:41 2004 +0000
+++ b/libmpcodecs/dec_video.h	Wed Feb 18 15:23:41 2004 +0000
@@ -18,5 +18,6 @@
 extern int get_video_colors(sh_video_t *sh_video,char *item,int *value);
 extern int set_video_colors(sh_video_t *sh_video,char *item,int value);
 extern int set_rectangle(sh_video_t *sh_video,int param,int value);
+extern void resync_video_stream(sh_video_t *sh_video);
 
 extern int divx_quality;
--- a/libmpcodecs/vd.h	Wed Feb 18 13:34:41 2004 +0000
+++ b/libmpcodecs/vd.h	Wed Feb 18 15:23:41 2004 +0000
@@ -23,6 +23,7 @@
 #define VDCTRL_SET_PP_LEVEL 5 /* set postprocessing level */
 #define VDCTRL_SET_EQUALIZER 6 /* set color options (brightness,contrast etc) */
 #define VDCTRL_GET_EQUALIZER 7 /* get color options (brightness,contrast etc) */
+#define VDCTRL_RESYNC_STREAM 8 /* seeking */
 
 // callbacks:
 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt);
--- a/libmpcodecs/vd_ffmpeg.c	Wed Feb 18 13:34:41 2004 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Wed Feb 18 15:23:41 2004 +0000
@@ -137,7 +137,11 @@
 #endif
 	}
         return CONTROL_FALSE;
-    }
+        }
+    break;
+    case VDCTRL_RESYNC_STREAM:
+        avcodec_flush_buffers(avctx);
+    return CONTROL_TRUE;
     }
     return CONTROL_UNKNOWN;
 }
--- a/mplayer.c	Wed Feb 18 13:34:41 2004 +0000
+++ b/mplayer.c	Wed Feb 18 15:23:41 2004 +0000
@@ -3407,6 +3407,7 @@
 
       if(sh_video){
 	 current_module="seek_video_reset";
+         resync_video_stream(sh_video);
          if(vo_config_count) video_out->control(VOCTRL_RESET,NULL);
       }