From: Kieran Kunhya Date: Tue, 27 Mar 2012 16:38:56 +0000 (+0100) Subject: Fix intra-refresh + hrd X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52f7a149ef6c39eb0d7eec7884362ba31a4b05ba;p=libx264 Fix intra-refresh + hrd --- diff --git a/common/common.h b/common/common.h index fab453e3..a3149c02 100644 --- a/common/common.h +++ b/common/common.h @@ -513,6 +513,7 @@ struct x264_t int64_t i_cpb_delay_lookahead; int64_t i_cpb_delay_pir_offset; + int64_t i_cpb_delay_pir_offset_next; int b_queued_intra_refresh; int64_t i_last_idr_pts; diff --git a/encoder/encoder.c b/encoder/encoder.c index 88897ef4..e193e559 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -2735,6 +2735,7 @@ int x264_encoder_encode( x264_t *h, if( h->param.cpu&X264_CPU_SSE_MISALIGN ) x264_cpu_mask_misalign_sse(); #endif + h->i_cpb_delay_pir_offset = h->i_cpb_delay_pir_offset_next; /* no data out */ *pi_nal = 0; @@ -3125,7 +3126,7 @@ int x264_encoder_encode( x264_t *h, } if( h->fenc->b_keyframe && h->param.b_intra_refresh ) - h->i_cpb_delay_pir_offset = h->fenc->i_cpb_delay; + h->i_cpb_delay_pir_offset_next = h->fenc->i_cpb_delay; /* Init the rate control */ /* FIXME: Include slice header bit cost. */ diff --git a/encoder/slicetype.c b/encoder/slicetype.c index af08184e..0b20f66a 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -1067,7 +1067,8 @@ static void x264_calculate_durations( x264_t *h, x264_frame_t *cur_frame, x264_f prev_frame->i_cpb_duration += cur_frame->i_dpb_output_delay; } - if( cur_frame->b_keyframe ) + // don't reset cpb delay for IDR frames when using intra-refresh + if( cur_frame->b_keyframe && !h->param.b_intra_refresh ) *i_cpb_delay = 0; *i_cpb_delay += cur_frame->i_duration;