}
else
{
- static const uint8_t i_mb_bits[9*3][6] =
+ static const uint8_t i_mb_bits[9*3] =
{
- { 1,0,0,0,1,2 }, { 1,0,0,1,0,2 }, { 0,0,2,2,2,2 }, /* L0 L0 */
- { 1,0,1,0,1,2 }, { 1,0,1,1,0,2 }, {0}, /* L0 L1 */
- { 1,1,0,0,0,0 }, { 1,1,0,0,0,1 }, {0}, /* L0 BI */
- { 1,0,1,1,1,2 }, { 1,1,1,1,0,2 }, {0}, /* L1 L0 */
- { 1,0,0,1,1,2 }, { 1,0,1,0,0,2 }, { 0,1,2,2,2,2 }, /* L1 L1 */
- { 1,1,0,0,1,0 }, { 1,1,0,0,1,1 }, {0}, /* L1 BI */
- { 1,1,0,1,0,0 }, { 1,1,0,1,0,1 }, {0}, /* BI L0 */
- { 1,1,0,1,1,0 }, { 1,1,0,1,1,1 }, {0}, /* BI L1 */
- { 1,1,1,0,0,0 }, { 1,1,1,0,0,1 }, { 1,0,0,0,0,2 }, /* BI BI */
+ 0x31, 0x29, 0x4, /* L0 L0 */
+ 0x35, 0x2d, 0, /* L0 L1 */
+ 0x43, 0x63, 0, /* L0 BI */
+ 0x3d, 0x2f, 0, /* L1 L0 */
+ 0x39, 0x25, 0x6, /* L1 L1 */
+ 0x53, 0x73, 0, /* L1 BI */
+ 0x4b, 0x6b, 0, /* BI L0 */
+ 0x5b, 0x7b, 0, /* BI L1 */
+ 0x47, 0x67, 0x21 /* BI BI */
};
const int idx = (i_mb_type - B_L0_L0) * 3 + (h->mb.i_partition - D_16x8);
+ int bits = i_mb_bits[idx];
- x264_cabac_encode_decision_noup( cb, 27+3, i_mb_bits[idx][0] );
- x264_cabac_encode_decision( cb, 27+5-i_mb_bits[idx][0], i_mb_bits[idx][1] );
- if( i_mb_bits[idx][2] != 2 )
+ x264_cabac_encode_decision_noup( cb, 27+3, bits&1 );
+ x264_cabac_encode_decision( cb, 27+5-(bits&1), (bits>>1)&1 ); bits >>= 2;
+ if( bits != 1 )
{
- x264_cabac_encode_decision( cb, 27+5, i_mb_bits[idx][2] );
- x264_cabac_encode_decision( cb, 27+5, i_mb_bits[idx][3] );
- x264_cabac_encode_decision( cb, 27+5, i_mb_bits[idx][4] );
- if( i_mb_bits[idx][5] != 2 )
- x264_cabac_encode_decision_noup( cb, 27+5, i_mb_bits[idx][5] );
+ x264_cabac_encode_decision( cb, 27+5, bits&1 ); bits >>= 1;
+ x264_cabac_encode_decision( cb, 27+5, bits&1 ); bits >>= 1;
+ x264_cabac_encode_decision( cb, 27+5, bits&1 ); bits >>= 1;
+ if( bits != 1 )
+ x264_cabac_encode_decision_noup( cb, 27+5, bits&1 );
}
}
}
}
}
-static inline void x264_cabac_mb_sub_b_partition( x264_cabac_t *cb, int i_sub )
+static ALWAYS_INLINE void x264_cabac_mb_sub_b_partition( x264_cabac_t *cb, int i_sub )
{
if( i_sub == D_DIRECT_8x8 )
{
x264_cabac_encode_decision( cb, 39, i_sub == D_L1_8x8 );
}
-static inline void x264_cabac_mb_transform_size( x264_t *h, x264_cabac_t *cb )
+static ALWAYS_INLINE void x264_cabac_mb_transform_size( x264_t *h, x264_cabac_t *cb )
{
int ctx = 399 + h->mb.cache.i_neighbour_transform_size;
x264_cabac_encode_decision_noup( cb, ctx, h->mb.b_transform_8x8 );
x264_cabac_encode_decision( cb, 54 + ctx, 0 );
}
-static inline void x264_cabac_mb_mvd_cpn( x264_t *h, x264_cabac_t *cb, int i_list, int idx, int l, int mvd, int ctx )
+static ALWAYS_INLINE int x264_cabac_mb_mvd_cpn( x264_t *h, x264_cabac_t *cb, int i_list, int idx, int l, int mvd, int ctx )
{
const int i_abs = abs( mvd );
const int ctxbase = l ? 47 : 40;
x264_cabac_encode_bypass( cb, mvd < 0 );
}
#endif
+ /* Since we don't need to keep track of MVDs larger than 33, just cap the value.
+ * This lets us store MVDs as 8-bit values instead of 16-bit. */
+ return X264_MIN( i_abs, 33 );
}
-static NOINLINE uint32_t x264_cabac_mb_mvd( x264_t *h, x264_cabac_t *cb, int i_list, int idx, int width )
+static NOINLINE uint16_t x264_cabac_mb_mvd( x264_t *h, x264_cabac_t *cb, int i_list, int idx, int width )
{
ALIGNED_4( int16_t mvp[2] );
- uint32_t amvd;
int mdx, mdy;
/* Calculate mvd */
x264_mb_predict_mv( h, i_list, idx, width, mvp );
mdx = h->mb.cache.mv[i_list][x264_scan8[idx]][0] - mvp[0];
mdy = h->mb.cache.mv[i_list][x264_scan8[idx]][1] - mvp[1];
- amvd = x264_cabac_amvd_sum(h->mb.cache.mvd[i_list][x264_scan8[idx] - 1],
- h->mb.cache.mvd[i_list][x264_scan8[idx] - 8]);
+ uint16_t amvd = x264_cabac_mvd_sum(h->mb.cache.mvd[i_list][x264_scan8[idx] - 1],
+ h->mb.cache.mvd[i_list][x264_scan8[idx] - 8]);
/* encode */
- x264_cabac_mb_mvd_cpn( h, cb, i_list, idx, 0, mdx, amvd&0xFFFF );
- x264_cabac_mb_mvd_cpn( h, cb, i_list, idx, 1, mdy, amvd>>16 );
+ mdx = x264_cabac_mb_mvd_cpn( h, cb, i_list, idx, 0, mdx, amvd&0xFF );
+ mdy = x264_cabac_mb_mvd_cpn( h, cb, i_list, idx, 1, mdy, amvd>>8 );
- return pack16to32_mask(mdx,mdy);
+ return pack8to16(mdx,mdy);
}
#define x264_cabac_mb_mvd(h,cb,i_list,idx,width,height)\
do\
{\
- uint32_t mvd = x264_cabac_mb_mvd(h,cb,i_list,idx,width);\
+ uint16_t mvd = x264_cabac_mb_mvd(h,cb,i_list,idx,width);\
x264_macroblock_cache_mvd( h, block_idx_x[idx], block_idx_y[idx], width, height, i_list, mvd );\
} while(0)
cb->i_queue = -1;
cb->i_bytes_outstanding = 0;
- /* if PCM is chosen, we need to store reconstructed frame data */
- h->mc.copy[PIXEL_16x16]( h->mb.pic.p_fdec[0], FDEC_STRIDE, h->mb.pic.p_fenc[0], FENC_STRIDE, 16 );
- h->mc.copy[PIXEL_8x8] ( h->mb.pic.p_fdec[1], FDEC_STRIDE, h->mb.pic.p_fenc[1], FENC_STRIDE, 8 );
- h->mc.copy[PIXEL_8x8] ( h->mb.pic.p_fdec[2], FDEC_STRIDE, h->mb.pic.p_fenc[2], FENC_STRIDE, 8 );
-
h->stat.frame.i_tex_bits += x264_cabac_pos( cb ) - i_mb_pos_tex;
return;
}