From: Jason Garrett-Glaser Date: Fri, 11 Dec 2009 00:52:39 +0000 (-0800) Subject: Fix regression in direct=auto/temporal in r1364 X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=65b3d0fd9f8167a6d0772a29e8fcf1a66ee7f8af;p=x264.git 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. --- diff --git a/common/macroblock.c b/common/macroblock.c index c8ffe2b3..76d2b218 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 252371f4..51997369 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 a64c8a3e..3511c106 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 ) {