diff options
author | lorenm <lorenm@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-12-01 20:32:05 +0000 |
---|---|---|
committer | lorenm <lorenm@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-12-01 20:32:05 +0000 |
commit | 95329dd3cde5723404204a66b3cdf5b0540bd1da (patch) | |
tree | a5f1a3a68e7418c94bc81619ef2aa32449ea0151 /libmpcodecs | |
parent | aa4f0eb5685172b39cd92f6fe7215abc3feebdb4 (diff) |
suppress dummy frames due to B-frame delay.
flush delayed frames.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14081 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/ve_lavc.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/libmpcodecs/ve_lavc.c b/libmpcodecs/ve_lavc.c index 3f12d31b26..efcd9dc580 100644 --- a/libmpcodecs/ve_lavc.c +++ b/libmpcodecs/ve_lavc.c @@ -324,6 +324,8 @@ struct vf_priv_s { #define FF_QP2LAMBDA 1 #endif +static int encode_frame(struct vf_instance_s* vf, AVFrame *pic); + static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ @@ -740,7 +742,14 @@ static int config(struct vf_instance_s* vf, static int control(struct vf_instance_s* vf, int request, void* data){ - return CONTROL_UNKNOWN; + switch(request){ + case VFCTRL_FLUSH_FRAMES: + if(vf->priv->codec->capabilities & CODEC_CAP_DELAY) + while(encode_frame(vf, NULL) > 0); + return CONTROL_TRUE; + default: + return CONTROL_UNKNOWN; + } } static int query_format(struct vf_instance_s* vf, unsigned int fmt){ @@ -781,8 +790,6 @@ static double psnr(double d){ } static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ - const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; - int out_size; AVFrame *pic= vf->priv->pic; pic->data[0]=mpi->planes[0]; @@ -804,9 +811,18 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ } #endif + return (encode_frame(vf, pic) >= 0); +} + +static int encode_frame(struct vf_instance_s* vf, AVFrame *pic){ + const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'}; + int out_size; + out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size, pic); + if(out_size == 0) + return 0; muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0); @@ -835,7 +851,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ perror("fopen"); lavc_param_psnr=0; // disable block mp_msg(MSGT_MENCODER,MSGL_ERR,"Can't open %s for writing. Check its permissions.\n",filename); - return 0; + return -1; /*exit(1);*/ } } @@ -870,7 +886,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ /* store stats if there are any */ if(lavc_venc_context->stats_out && stats_file) fprintf(stats_file, "%s", lavc_venc_context->stats_out); - return 1; + return out_size; } static void uninit(struct vf_instance_s* vf){ |