diff options
author | corey <corey@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-02-21 09:39:22 +0000 |
---|---|---|
committer | corey <corey@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-02-21 09:39:22 +0000 |
commit | 960b978a037702e3c684b66b6ab2cdd4d62c5162 (patch) | |
tree | ca292bc48860e8d135f9e1ef3bc1c10acf52e633 /libmpcodecs | |
parent | 14d023a2ee8ccc35d0c0e46a8a9dc3da41328c9d (diff) |
Fix video delay when encoding with B-frames.
Encoding delay is adjusted for on-the-fly during encoding.
Decoding delay is compensated for by setting an appropriate dwStart on
the audio stream (only in muxer_avi at this point).
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17660 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/ve_lavc.c | 6 | ||||
-rw-r--r-- | libmpcodecs/ve_x264.c | 7 | ||||
-rw-r--r-- | libmpcodecs/ve_xvid.c | 7 | ||||
-rw-r--r-- | libmpcodecs/ve_xvid4.c | 7 |
4 files changed, 25 insertions, 2 deletions
diff --git a/libmpcodecs/ve_lavc.c b/libmpcodecs/ve_lavc.c index afc5f787a7..8e8f2ff793 100644 --- a/libmpcodecs/ve_lavc.c +++ b/libmpcodecs/ve_lavc.c @@ -770,6 +770,8 @@ static int config(struct vf_instance_s* vf, mux_v->bih->biSize= sizeof(BITMAPINFOHEADER) + lavc_venc_context->extradata_size; } + mux_v->decoder_delay = lavc_venc_context->max_b_frames ? 1 : 0; + return 1; } @@ -854,8 +856,10 @@ static int encode_frame(struct vf_instance_s* vf, AVFrame *pic){ out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size, pic); - if(out_size == 0) + if(out_size == 0) { + ++mux_v->encoder_delay; return 0; + } muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE); diff --git a/libmpcodecs/ve_x264.c b/libmpcodecs/ve_x264.c index 9015e9e4fb..51a57c3799 100644 --- a/libmpcodecs/ve_x264.c +++ b/libmpcodecs/ve_x264.c @@ -435,6 +435,11 @@ static int config(struct vf_instance_s* vf, int width, int height, int d_width, return 0; } + if (mod->param.i_bframe > 1 && mod->param.b_bframe_pyramid) + mod->mux->decoder_delay = 2; + else + mod->mux->decoder_delay = mod->param.i_bframe ? 1 : 0; + return 1; } @@ -511,6 +516,8 @@ static int encode_frame(struct vf_instance_s *vf, x264_picture_t *pic_in) && frame_ref == 1 && !bframe); muxer_write_chunk(mod->mux, i_size, keyframe?0x10:0, MP_NOPTS_VALUE, MP_NOPTS_VALUE); } + else + ++mod->mux->encoder_delay; return i_size; } diff --git a/libmpcodecs/ve_xvid.c b/libmpcodecs/ve_xvid.c index bfb08b70fb..881d9508a5 100644 --- a/libmpcodecs/ve_xvid.c +++ b/libmpcodecs/ve_xvid.c @@ -378,6 +378,10 @@ config(struct vf_instance_s* vf, vbrInit(&fp->vbr_state); +#ifdef XVID_API_UNSTABLE + fp->mux->decoder_delay = enc_param.max_bframes ? 1 : 0; +#endif + return 1; } @@ -523,7 +527,10 @@ put_image(struct vf_instance_s* vf, mp_image_t *mpi) #endif // write output + if (fp->enc_frame.length > 0) muxer_write_chunk(fp->mux, fp->enc_frame.length, fp->enc_frame.intra==1 ? 0x10 : 0, MP_NOPTS_VALUE, MP_NOPTS_VALUE); + else + ++fp->mux->encoder_delay; // update the VBR engine vbrUpdate(&fp->vbr_state, enc_stats.quant, fp->enc_frame.intra, diff --git a/libmpcodecs/ve_xvid4.c b/libmpcodecs/ve_xvid4.c index 3789b8dc67..201aec6acc 100644 --- a/libmpcodecs/ve_xvid4.c +++ b/libmpcodecs/ve_xvid4.c @@ -504,6 +504,8 @@ config(struct vf_instance_s* vf, /* Store the encoder instance into the private data */ mod->instance = mod->create.handle; + mod->mux->decoder_delay = mod->create.max_bframes ? 1 : 0; + return(FINE); } @@ -620,7 +622,10 @@ put_image(struct vf_instance_s* vf, mp_image_t *mpi) } /* If size is == 0, we're done with that frame */ - if(size == 0) return(FINE); + if(size == 0) { + ++mod->mux->encoder_delay; + return(FINE); + } /* xvidcore returns stats about encoded frame in an asynchronous way * accumulate these stats */ |