# HG changeset patch # User michael # Date 1077117821 0 # Node ID efb37725d61673455d574ab350cef466925dbbda # Parent 4e70e9ea29c47b4f12d608160a6cca1492924c92 flushing stuff after seeking (finally we can view MPEG without thouse blocks after seeking with -vc ffmpeg12) diff -r 4e70e9ea29c4 -r efb37725d616 libmpcodecs/ad_ffmpeg.c --- 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(yds->buffer_pos+=y-x; // put back data (HACK!) if(len2>0){ diff -r 4e70e9ea29c4 -r efb37725d616 libmpcodecs/dec_video.c --- 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); diff -r 4e70e9ea29c4 -r efb37725d616 libmpcodecs/dec_video.h --- 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; diff -r 4e70e9ea29c4 -r efb37725d616 libmpcodecs/vd.h --- 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); diff -r 4e70e9ea29c4 -r efb37725d616 libmpcodecs/vd_ffmpeg.c --- 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; } diff -r 4e70e9ea29c4 -r efb37725d616 mplayer.c --- 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); }