]> git.sesse.net Git - x264/commitdiff
Fix intra-refresh + hrd
authorKieran Kunhya <kierank@ob-encoder.com>
Tue, 27 Mar 2012 16:38:56 +0000 (17:38 +0100)
committerFiona Glaser <fiona@x264.com>
Tue, 27 Mar 2012 16:43:57 +0000 (09:43 -0700)
common/common.h
encoder/encoder.c
encoder/slicetype.c

index fab453e3da66a3ce500be867d99d4e67d4e50ae5..a3149c02c7f963ac4bd04630ecfdda12359d5b6f 100644 (file)
@@ -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;
index 88897ef4f3f058ce40cb4edd04ac9a0a95efef22..e193e559bbde972c41302d6c7ebe84dc39b02c6b 100644 (file)
@@ -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. */
index af08184e8eb39b1b03d4482256388ae0d14094f8..0b20f66a09b56c803b004da2c0b7571a0666c63a 100644 (file)
@@ -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;