]> git.videolan.org Git - x264.git/commitdiff
Fix regression in direct=auto/temporal in r1364
authorJason Garrett-Glaser <darkshikari@gmail.com>
Fri, 11 Dec 2009 00:52:39 +0000 (16:52 -0800)
committerJason Garrett-Glaser <darkshikari@gmail.com>
Fri, 11 Dec 2009 01:00:56 +0000 (17:00 -0800)
Bug caused rare race condition in frame reference handling.
This resulted in invalid bitstreams in some B-frames and, very rarely, crashes.

common/macroblock.c
common/macroblock.h
encoder/encoder.c

index c8ffe2b3d7d505cca509e911000f2a4896ca1984..76d2b2186f2abd235fe2e4c87bd594b6ca401b58 100644 (file)
@@ -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 )
index 252371f45228f0e3f3f390eac03e6493470ec58a..5199736916fd484643e4886bcf6557050d27ffb5 100644 (file)
@@ -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 );
index a64c8a3ea7be5f3c4c521c67f16f335f30623bff..3511c10684a405c95132ded7432acd665dbf71eb 100644 (file)
@@ -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 )
     {