[x264-devel] Fix intra-refresh + hrd
Kieran Kunhya
git at videolan.org
Wed Apr 25 00:17:09 CEST 2012
x264 | branch: master | Kieran Kunhya <kierank at ob-encoder.com> | Tue Mar 27 17:38:56 2012 +0100| [259a6e57ae25c71acc1669e0aefde7ffe7e235ec] | committer: Jason Garrett-Glaser
Fix intra-refresh + hrd
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=259a6e57ae25c71acc1669e0aefde7ffe7e235ec
---
common/common.h | 1 +
encoder/encoder.c | 3 ++-
encoder/slicetype.c | 3 ++-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/common/common.h b/common/common.h
index fab453e..a3149c0 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 2539b3f..e9ea971 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 e77ba1d..9bd862d 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;
More information about the x264-devel
mailing list