1
mirror of https://github.com/mpv-player/mpv synced 2024-07-15 22:21:38 +02:00

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
This commit is contained in:
michael 2004-02-18 15:23:41 +00:00
parent 6f0edb4574
commit 14c5a7c333
6 changed files with 21 additions and 3 deletions

View File

@ -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(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
if(len2>0){

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}