/* CABAC: not exactly the same. x264_cabac_size_decision() keeps track of
* fractional bits, but only finite precision. */
#define x264_cabac_encode_decision(c,x,v) x264_cabac_size_decision(c,x,v)
-#define x264_cabac_encode_terminal(c,v) x264_cabac_size_decision(c,276,v)
+#define x264_cabac_encode_terminal(c) x264_cabac_size_decision(c,276,0)
#define x264_cabac_encode_bypass(c,v) ((c)->f8_bits_encoded += 256)
-#define x264_cabac_encode_flush(c)
+#define x264_cabac_encode_flush(h,c)
#define x264_macroblock_write_cabac x264_macroblock_size_cabac
#define x264_cabac_mb_skip x264_cabac_mb_size_skip_unused
#include "cabac.c"
}
else if( h->param.b_cabac )
{
- x264_cabac_t cabac_tmp = h->cabac;
- cabac_tmp.f8_bits_encoded = 0;
+ x264_cabac_t cabac_tmp;
+ h->mc.memcpy_aligned( &cabac_tmp, &h->cabac, offsetof(x264_cabac_t,i_low) );
x264_macroblock_size_cabac( h, &cabac_tmp );
i_bits = ( cabac_tmp.f8_bits_encoded * i_lambda2 + 128 ) >> 8;
}
if( h->param.b_cabac )
{
- x264_cabac_t cabac_tmp = h->cabac;
- cabac_tmp.f8_bits_encoded = 0;
+ x264_cabac_t cabac_tmp;
+ h->mc.memcpy_aligned( &cabac_tmp, &h->cabac, offsetof(x264_cabac_t,i_low) );
x264_partition_size_cabac( h, &cabac_tmp, i8, i_pixel );
i_bits = ( cabac_tmp.f8_bits_encoded * i_lambda2 + 128 ) >> 8;
}
if( h->param.b_cabac )
{
- x264_cabac_t cabac_tmp = h->cabac;
- cabac_tmp.f8_bits_encoded = 0;
+ x264_cabac_t cabac_tmp;
+ h->mc.memcpy_aligned( &cabac_tmp, &h->cabac, offsetof(x264_cabac_t,i_low) );
x264_partition_i8x8_size_cabac( h, &cabac_tmp, i8, i_mode );
i_bits = ( cabac_tmp.f8_bits_encoded * i_lambda2 + 128 ) >> 8;
}
if( h->param.b_cabac )
{
- x264_cabac_t cabac_tmp = h->cabac;
- cabac_tmp.f8_bits_encoded = 0;
+ x264_cabac_t cabac_tmp;
+ h->mc.memcpy_aligned( &cabac_tmp, &h->cabac, offsetof(x264_cabac_t,i_low) );
+
x264_partition_i4x4_size_cabac( h, &cabac_tmp, i4, i_mode );
i_bits = ( cabac_tmp.f8_bits_encoded * i_lambda2 + 128 ) >> 8;
}
if( h->param.b_cabac )
{
- x264_cabac_t cabac_tmp = h->cabac;
- cabac_tmp.f8_bits_encoded = 0;
+ x264_cabac_t cabac_tmp;
+ h->mc.memcpy_aligned( &cabac_tmp, &h->cabac, offsetof(x264_cabac_t,i_low) );
x264_i8x8_chroma_size_cabac( h, &cabac_tmp );
i_bits = ( cabac_tmp.f8_bits_encoded * i_lambda2 + 128 ) >> 8;
}
static void quant_trellis_cabac( x264_t *h, int16_t *dct,
const uint16_t *quant_mf, const int *unquant_mf,
- const int *coef_weight, const int *zigzag,
+ const int *coef_weight, const uint8_t *zigzag,
int i_ctxBlockCat, int i_lambda2, int b_ac, int i_coefs )
{
int abs_coefs[64], signs[64];
{
// no need to calculate ssd of 0s: it's the same in all nodes.
// no need to modify level_tree for ctx=0: it starts with an infinite loop of 0s.
- const int cost_sig0 = x264_cabac_size_decision_noup( &cabac_state_sig[i], 0 )
- * i_lambda2 >> ( CABAC_SIZE_BITS - LAMBDA_BITS );
+ const uint32_t cost_sig0 = x264_cabac_size_decision_noup( &cabac_state_sig[i], 0 )
+ * (uint64_t)i_lambda2 >> ( CABAC_SIZE_BITS - LAMBDA_BITS );
for( j = 1; j < 8; j++ )
{
if( nodes_cur[j].score != TRELLIS_SCORE_MAX )