From 14c5a7c333253a479c42760f7d86d698989fddd9 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 18 Feb 2004 15:23:41 +0000 Subject: [PATCH] flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11978 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/ad_ffmpeg.c | 10 ++++++++-- libmpcodecs/dec_video.c | 5 +++++ libmpcodecs/dec_video.h | 1 + libmpcodecs/vd.h | 1 + libmpcodecs/vd_ffmpeg.c | 6 +++++- mplayer.c | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 481026d38c..a4d894ad09 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -126,8 +126,13 @@ static void uninit(sh_audio_t *sh) 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 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m 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(yds->buffer_pos+=y-x; // put back data (HACK!) if(len2>0){ diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c index cb5e458dad..c9185a6170 100644 --- a/libmpcodecs/dec_video.c +++ b/libmpcodecs/dec_video.c @@ -132,6 +132,11 @@ int set_rectangle(sh_video_t *sh_video,int param,int value) 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); diff --git a/libmpcodecs/dec_video.h b/libmpcodecs/dec_video.h index 34a8e0b3b4..09f955d05c 100644 --- a/libmpcodecs/dec_video.h +++ b/libmpcodecs/dec_video.h @@ -18,5 +18,6 @@ extern void set_video_quality(sh_video_t *sh_video,int quality); 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; diff --git a/libmpcodecs/vd.h b/libmpcodecs/vd.h index 37f323b96f..769a6c3a9b 100644 --- a/libmpcodecs/vd.h +++ b/libmpcodecs/vd.h @@ -23,6 +23,7 @@ extern int vd_use_slices; #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); diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index 08f8964372..023b036a15 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -137,7 +137,11 @@ static int control(sh_video_t *sh,int cmd,void* arg,...){ #endif } return CONTROL_FALSE; - } + } + break; + case VDCTRL_RESYNC_STREAM: + avcodec_flush_buffers(avctx); + return CONTROL_TRUE; } return CONTROL_UNKNOWN; } diff --git a/mplayer.c b/mplayer.c index 5c2eb0ea20..918bd16115 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3407,6 +3407,7 @@ if(rel_seek_secs || abs_seek_pos){ if(sh_video){ current_module="seek_video_reset"; + resync_video_stream(sh_video); if(vo_config_count) video_out->control(VOCTRL_RESET,NULL); }