return i_suffix_length;
}
-static void block_residual_write_cavlc( x264_t *h, bs_t *s, int i_ctxBlockCat, int i_idx, int16_t *l, int i_count )
+static void block_residual_write_cavlc( x264_t *h, bs_t *s, int i_ctxBlockCat, int i_idx, int16_t *l, int i_count, int nC )
{
- static const uint8_t ct_index[17] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,3};
static const uint8_t ctz_index[8] = {3,0,1,0,2,0,1,0};
x264_run_level_t runlevel;
int i_trailing, i_total_zero, i_suffix_length, i;
int i_total = 0;
unsigned int i_sign;
- /* x264_mb_predict_non_zero_code return 0 <-> (16+16+1)>>1 = 16 */
- int nC = i_idx >= 25 ? 4 : ct_index[x264_mb_predict_non_zero_code( h, i_idx == 24 ? 0 : i_idx )];
if( !h->mb.cache.non_zero_count[x264_scan8[i_idx]] )
{
}
}
+static const uint8_t ct_index[17] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,3};
+
+#define block_residual_write_cavlc(h,s,cat,idx,l,count)\
+{\
+ int nC = cat == DCT_CHROMA_DC ? 4 : ct_index[x264_mb_predict_non_zero_code( h, cat == DCT_LUMA_DC ? 0 : idx )];\
+ block_residual_write_cavlc(h,s,cat,idx,l,count,nC);\
+}
+
static void cavlc_qp_delta( x264_t *h, bs_t *s )
{
int i_dqp = h->mb.i_qp - h->mb.i_last_qp;
}
#if !RDO_SKIP_BS
- if( i_mb_type == I_PCM)
+ if( i_mb_type == I_PCM )
{
bs_write_ue( s, i_mb_i_offset + 25 );
i_mb_pos_tex = bs_pos( s );
if( h->mb.i_partition == D_16x16 )
{
- bs_write_ue( s, 0 );
+ bs_write1( s, 1 );
if( h->mb.pic.i_fref[0] > 1 )
bs_write_te( s, h->mb.pic.i_fref[0] - 1, h->mb.cache.ref[0][x264_scan8[0]] );
else
{
bs_write_ue( s, 3 );
- b_sub_ref = h->mb.pic.i_fref[0] > 1;
+ b_sub_ref = 1;
}
/* sub mb type */
bs_write_ue( s, sub_mb_type_b_to_golomb[ h->mb.i_sub_partition[i] ] );
/* ref */
- for( i = 0; i < 4; i++ )
- if( x264_mb_partition_listX_table[0][ h->mb.i_sub_partition[i] ] )
- bs_write_te( s, h->mb.pic.i_fref[0] - 1, h->mb.cache.ref[0][x264_scan8[i*4]] );
- for( i = 0; i < 4; i++ )
- if( x264_mb_partition_listX_table[1][ h->mb.i_sub_partition[i] ] )
- bs_write_te( s, h->mb.pic.i_fref[1] - 1, h->mb.cache.ref[1][x264_scan8[i*4]] );
+ if( h->mb.pic.i_fref[0] > 1 )
+ for( i = 0; i < 4; i++ )
+ if( x264_mb_partition_listX_table[0][ h->mb.i_sub_partition[i] ] )
+ bs_write_te( s, h->mb.pic.i_fref[0] - 1, h->mb.cache.ref[0][x264_scan8[i*4]] );
+ if( h->mb.pic.i_fref[1] > 1 )
+ for( i = 0; i < 4; i++ )
+ if( x264_mb_partition_listX_table[1][ h->mb.i_sub_partition[i] ] )
+ bs_write_te( s, h->mb.pic.i_fref[1] - 1, h->mb.cache.ref[1][x264_scan8[i*4]] );
/* mvd */
for( i = 0; i < 4; i++ )
}
}
else if( i_mb_type == B_DIRECT )
- bs_write_ue( s, 0 );
+ bs_write1( s, 1 );
else
{
x264_log(h, X264_LOG_ERROR, "invalid/unhandled mb_type\n" );