MUNGE_8x8_NNZ( BACKUP )
for( int p = 0; p < 3; p++ )
- for( int i = 0; i < 4; i++ )
- if( h->mb.i_cbp_luma & ( 1 << i ) )
- x264_cabac_block_residual_8x8_cbf( h, cb, ctx_cat_plane[DCT_LUMA_8x8][p], i*4+p*16, h->dct.luma8x8[i+p*4], b_intra );
+ FOREACH_BIT( i, 0, h->mb.i_cbp_luma )
+ x264_cabac_block_residual_8x8_cbf( h, cb, ctx_cat_plane[DCT_LUMA_8x8][p], i*4+p*16, h->dct.luma8x8[i+p*4], b_intra );
MUNGE_8x8_NNZ( RESTORE )
}
else
{
- for( int i = 0; i < 4; i++ )
- if( h->mb.i_cbp_luma & ( 1 << i ) )
- x264_cabac_block_residual_8x8( h, cb, DCT_LUMA_8x8, h->dct.luma8x8[i] );
+ FOREACH_BIT( i, 0, h->mb.i_cbp_luma )
+ x264_cabac_block_residual_8x8( h, cb, DCT_LUMA_8x8, h->dct.luma8x8[i] );
}
}
else
{
for( int p = 0; p < plane_count; p++ )
- for( int i = 0; i < 16; i++ )
- if( h->mb.i_cbp_luma & ( 1 << ( i >> 2 ) ) )
- x264_cabac_block_residual_cbf( h, cb, ctx_cat_plane[DCT_LUMA_4x4][p], i+p*16, h->dct.luma4x4[i+p*16], b_intra );
+ FOREACH_BIT( i8x8, 0, h->mb.i_cbp_luma )
+ for( int i = 0; i < 4; i++ )
+ x264_cabac_block_residual_cbf( h, cb, ctx_cat_plane[DCT_LUMA_4x4][p], i+i8x8*4+p*16, h->dct.luma4x4[i+i8x8*4+p*16], b_intra );
}
if( chroma && h->mb.i_cbp_chroma ) /* Chroma DC residual present */
}
}
-static inline void x264_cavlc_macroblock_luma_residual( x264_t *h, int i8start, int i8end )
+static ALWAYS_INLINE void x264_cavlc_macroblock_luma_residual( x264_t *h, int plane_count )
{
if( h->mb.b_transform_8x8 )
{
/* shuffle 8x8 dct coeffs into 4x4 lists */
- for( int i8 = i8start; i8 <= i8end; i8++ )
- if( h->mb.cache.non_zero_count[x264_scan8[i8*4]] )
- h->zigzagf.interleave_8x8_cavlc( h->dct.luma4x4[i8*4], h->dct.luma8x8[i8], &h->mb.cache.non_zero_count[x264_scan8[i8*4]] );
+ for( int p = 0; p < plane_count; p++ )
+ for( int i8 = 0; i8 < 4; i8++ )
+ if( h->mb.cache.non_zero_count[x264_scan8[p*16+i8*4]] )
+ h->zigzagf.interleave_8x8_cavlc( h->dct.luma4x4[p*16+i8*4], h->dct.luma8x8[p*4+i8],
+ &h->mb.cache.non_zero_count[x264_scan8[p*16+i8*4]] );
}
- for( int i8 = i8start; i8 <= i8end; i8++ )
- if( h->mb.i_cbp_luma & (1 << (i8&3)) )
+ for( int p = 0; p < plane_count; p++ )
+ FOREACH_BIT( i8, 0, h->mb.i_cbp_luma )
for( int i4 = 0; i4 < 4; i4++ )
- x264_cavlc_block_residual( h, DCT_LUMA_4x4, i4+i8*4, h->dct.luma4x4[i4+i8*4] );
+ x264_cavlc_block_residual( h, DCT_LUMA_4x4, i4+i8*4+p*16, h->dct.luma4x4[i4+i8*4+p*16] );
+}
+
+static ALWAYS_INLINE void x264_cavlc_partition_luma_residual( x264_t *h, int i8, int p )
+{
+ if( h->mb.b_transform_8x8 && h->mb.cache.non_zero_count[x264_scan8[i8*4]] )
+ h->zigzagf.interleave_8x8_cavlc( h->dct.luma4x4[i8*4+p*16], h->dct.luma8x8[i8+p*4],
+ &h->mb.cache.non_zero_count[x264_scan8[i8*4+p*16]] );
+
+ if( h->mb.i_cbp_luma & (1 << i8) )
+ for( int i4 = 0; i4 < 4; i4++ )
+ x264_cavlc_block_residual( h, DCT_LUMA_4x4, i4+i8*4+p*16, h->dct.luma4x4[i4+i8*4+p*16] );
}
static void x264_cavlc_mb_header_i( x264_t *h, int i_mb_type, int i_mb_i_offset, int chroma )
else if( h->mb.i_cbp_luma | h->mb.i_cbp_chroma )
{
x264_cavlc_qp_delta( h );
- x264_cavlc_macroblock_luma_residual( h, 0, plane_count*4-1 );
+ x264_cavlc_macroblock_luma_residual( h, plane_count );
}
if( h->mb.i_cbp_chroma )
{
for( j = (i_pixel < PIXEL_8x8); j >= 0; j-- )
{
for( int p = 0; p < plane_count; p++ )
- x264_cavlc_macroblock_luma_residual( h, p*4+i8, p*4+i8 );
+ x264_cavlc_partition_luma_residual( h, i8, p );
if( h->mb.i_cbp_chroma )
{
if( CHROMA_FORMAT == CHROMA_422 )
h->out.bs.i_bits_encoded = x264_cavlc_intra4x4_pred_size( h, 4*i8, i_mode );
bs_write_ue( &h->out.bs, cbp_to_golomb[!CHROMA444][1][(h->mb.i_cbp_chroma << 4)|h->mb.i_cbp_luma] );
for( int p = 0; p < plane_count; p++ )
- x264_cavlc_macroblock_luma_residual( h, p*4+i8, p*4+i8 );
+ x264_cavlc_partition_luma_residual( h, i8, p );
return h->out.bs.i_bits_encoded;
}