[x264-devel] Fix nalu_process callback with HRD

Kieran Kunhya git at videolan.org
Sat Jul 23 02:38:51 CEST 2011


x264 | branch: master | Kieran Kunhya <kieran at kunhya.com> | Wed Jul 13 20:25:40 2011 +0100| [f23a615354397e3f5256a831b75e149186d4ac91] | committer: Jason Garrett-Glaser

Fix nalu_process callback with HRD

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=f23a615354397e3f5256a831b75e149186d4ac91
---

 encoder/encoder.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 85ad046..633da2a 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -2835,7 +2835,16 @@ int     x264_encoder_encode( x264_t *h,
             overhead += h->out.nal[h->out.i_nal-1].i_payload + NALU_OVERHEAD;
         }
 
-        /* buffering period sei is written in x264_encoder_frame_end */
+        /* when frame threading is used, buffering period sei is written in x264_encoder_frame_end */
+        if( h->i_thread_frames == 1 && h->sps->vui.b_nal_hrd_parameters_present )
+        {
+            x264_hrd_fullness( h );
+            x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
+            x264_sei_buffering_period_write( h, &h->out.bs );
+            if( x264_nal_end( h ) )
+               return -1;
+            overhead += h->out.nal[h->out.i_nal-1].i_payload + NALU_OVERHEAD;
+        }
     }
 
     /* write extra sei */
@@ -2979,8 +2988,8 @@ static int x264_encoder_frame_end( x264_t *h, x264_t *thread_current,
     }
 
     x264_emms();
-    /* generate sei buffering period and insert it into place */
-    if( h->fenc->b_keyframe && h->sps->vui.b_nal_hrd_parameters_present )
+    /* generate buffering period sei and insert it into place */
+    if( h->i_thread_frames > 1 && h->fenc->b_keyframe && h->sps->vui.b_nal_hrd_parameters_present )
     {
         x264_hrd_fullness( h );
         x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );



More information about the x264-devel mailing list