Mercurial > mplayer.hg
changeset 14080:b4532e84bb4d
suppress dummy frames due to B-frame delay.
flush delayed frames.
author | lorenm |
---|---|
date | Wed, 01 Dec 2004 20:32:05 +0000 |
parents | f60d6dee476b |
children | 866623c7ec87 |
files | libmpcodecs/ve_lavc.c |
diffstat | 1 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/ve_lavc.c Wed Dec 01 18:03:16 2004 +0000 +++ b/libmpcodecs/ve_lavc.c Wed Dec 01 20:32:05 2004 +0000 @@ -324,6 +324,8 @@ #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 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 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 @@ } #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 @@ 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 @@ /* 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){