[x264-devel] commit: Fix regression in direct=auto/temporal in r1364 ( Jason Garrett-Glaser )

git version control git at videolan.org
Fri Dec 11 02:11:20 CET 2009


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu Dec 10 16:52:39 2009 -0800| [65b3d0fd9f8167a6d0772a29e8fcf1a66ee7f8af] | committer: Jason Garrett-Glaser 

Fix regression in direct=auto/temporal in r1364
Bug caused rare race condition in frame reference handling.
This resulted in invalid bitstreams in some B-frames and, very rarely, crashes.

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

 common/macroblock.c |   25 ++++++++++++++-----------
 common/macroblock.h |    1 +
 encoder/encoder.c   |    4 +++-
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/common/macroblock.c b/common/macroblock.c
index c8ffe2b..76d2b21 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -835,6 +835,20 @@ void x264_macroblock_slice_init( x264_t *h )
 
     setup_inverse_delta_pocs( h );
 
+    h->mb.i_neighbour4[6] =
+    h->mb.i_neighbour4[9] =
+    h->mb.i_neighbour4[12] =
+    h->mb.i_neighbour4[14] = MB_LEFT|MB_TOP|MB_TOPLEFT|MB_TOPRIGHT;
+    h->mb.i_neighbour4[3] =
+    h->mb.i_neighbour4[7] =
+    h->mb.i_neighbour4[11] =
+    h->mb.i_neighbour4[13] =
+    h->mb.i_neighbour4[15] =
+    h->mb.i_neighbour8[3] = MB_LEFT|MB_TOP|MB_TOPLEFT;
+}
+
+void x264_macroblock_thread_init( x264_t *h )
+{
     /* fdec:      fenc:
      * yyyyyyy
      * yYYYY      YYYY
@@ -851,17 +865,6 @@ void x264_macroblock_slice_init( x264_t *h )
     h->mb.pic.p_fdec[0] = h->mb.pic.fdec_buf + 2*FDEC_STRIDE;
     h->mb.pic.p_fdec[1] = h->mb.pic.fdec_buf + 19*FDEC_STRIDE;
     h->mb.pic.p_fdec[2] = h->mb.pic.fdec_buf + 19*FDEC_STRIDE + 16;
-
-    h->mb.i_neighbour4[6] =
-    h->mb.i_neighbour4[9] =
-    h->mb.i_neighbour4[12] =
-    h->mb.i_neighbour4[14] = MB_LEFT|MB_TOP|MB_TOPLEFT|MB_TOPRIGHT;
-    h->mb.i_neighbour4[3] =
-    h->mb.i_neighbour4[7] =
-    h->mb.i_neighbour4[11] =
-    h->mb.i_neighbour4[13] =
-    h->mb.i_neighbour4[15] =
-    h->mb.i_neighbour8[3] = MB_LEFT|MB_TOP|MB_TOPLEFT;
 }
 
 void x264_prefetch_fenc( x264_t *h, x264_frame_t *fenc, int i_mb_x, int i_mb_y )
diff --git a/common/macroblock.h b/common/macroblock.h
index 252371f..5199736 100644
--- a/common/macroblock.h
+++ b/common/macroblock.h
@@ -263,6 +263,7 @@ enum cabac_ctx_block_cat_e
 
 int  x264_macroblock_cache_init( x264_t *h );
 void x264_macroblock_slice_init( x264_t *h );
+void x264_macroblock_thread_init( x264_t *h );
 void x264_macroblock_cache_load( x264_t *h, int i_mb_x, int i_mb_y );
 void x264_macroblock_cache_save( x264_t *h );
 void x264_macroblock_cache_end( x264_t *h );
diff --git a/encoder/encoder.c b/encoder/encoder.c
index a64c8a3..3511c10 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1602,6 +1602,8 @@ static inline void x264_slice_init( x264_t *h, int i_nal_type, int i_global_qp )
     {
         /* Nothing to do ? */
     }
+
+    x264_macroblock_slice_init( h );
 }
 
 static int x264_slice_write( x264_t *h )
@@ -1620,7 +1622,7 @@ static int x264_slice_write( x264_t *h )
     x264_nal_start( h, h->i_nal_type, h->i_nal_ref_idc );
 
     /* Slice header */
-    x264_macroblock_slice_init( h );
+    x264_macroblock_thread_init( h );
     x264_slice_header_write( &h->out.bs, &h->sh, h->i_nal_ref_idc );
     if( h->param.b_cabac )
     {



More information about the x264-devel mailing list