/* 8x8 */
int i_cost8x8;
/* [ref][0] is 16x16 mv, [ref][1..4] are 8x8 mv from partition [0..3] */
- DECLARE_ALIGNED( int, mvc[32][5][2], 8 );
+ DECLARE_ALIGNED_8( int mvc[32][5][2] );
x264_me_t me8x8[4];
/* Sub 4x4 */
40,45,51,57,64,72,81,91 /* 44-51 */
};
-/* pow(lambda,2) * .9 */
+/* lambda2 = pow(lambda,2) * .9 * 256 */
static const int i_qp0_cost2_table[52] = {
- 1, 1, 1, 1, 1, 1, /* 0-5 */
- 1, 1, 1, 1, 1, 1, /* 6-11 */
- 1, 1, 1, 2, 2, 3, /* 12-17 */
- 4, 5, 6, 7, 9, 11, /* 18-23 */
- 14, 18, 23, 29, 36, 46, /* 24-29 */
- 58, 73, 91, 115, 145, 183, /* 30-35 */
- 230, 290, 366, 461, 581, 731, /* 36-41 */
- 922,1161,1463,1843,2322,2926, /* 42-47 */
-3686,4645,5852,7373
+ 14, 18, 22, 28, 36, 45, 57, 72, /* 0 - 7 */
+ 91, 115, 145, 182, 230, 290, 365, 460, /* 8 - 15 */
+ 580, 731, 921, 1161, 1462, 1843, 2322, 2925, /* 16 - 23 */
+ 3686, 4644, 5851, 7372, 9289, 11703, 14745, 18578, /* 24 - 31 */
+ 23407, 29491, 37156, 46814, 58982, 74313, 93628, 117964, /* 32 - 39 */
+148626, 187257, 235929, 297252, 374514, 471859, 594505, 749029, /* 40 - 47 */
+943718, 1189010, 1498059, 1887436 /* 48 - 51 */
};
/* TODO: calculate CABAC costs */
static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
{
- memset( a, 0, sizeof( x264_mb_analysis_t ) );
-
/* conduct the analysis using this lamda and QP */
a->i_qp = h->mb.i_qp = i_qp;
h->mb.i_chroma_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )];
/* 8x8 prediction selection */
if( flags & X264_ANALYSE_I8x8 )
{
- DECLARE_ALIGNED( uint8_t, edge[33], 16 );
+ DECLARE_ALIGNED_16( uint8_t edge[33] );
x264_pixel_cmp_t sa8d = (*h->pixf.mbcmp == *h->pixf.sad) ? h->pixf.sad[PIXEL_8x8] : h->pixf.sa8d[PIXEL_8x8];
int i_satd_thresh = a->b_mbrd ? COST_MAX : X264_MIN( i_satd_inter, a->i_satd_i16x16 );
int i_cost = 0;
{
h->mc.copy[PIXEL_16x16]( h->mb.pic.i4x4_fdec_buf, 16, p_dst, FDEC_STRIDE, 16 );
if( h->mb.i_skip_intra == 2 )
- h->mc.memcpy_aligned( h->mb.pic.i4x4_dct_buf, h->dct.block, sizeof(h->mb.pic.i4x4_dct_buf) );
+ h->mc.memcpy_aligned( h->mb.pic.i4x4_dct_buf, h->dct.luma4x4, sizeof(h->mb.pic.i4x4_dct_buf) );
}
}
else
}
else if( h->mb.i_type == I_8x8 )
{
- DECLARE_ALIGNED( uint8_t, edge[33], 16 );
+ DECLARE_ALIGNED_16( uint8_t edge[33] );
for( idx = 0; idx < 4; idx++ )
{
uint64_t pels_h = 0;
assert( a->l0.me16x16.mv[1] <= h->mb.mv_max_spel[1] || h->param.i_threads == 1 );
h->mb.i_type = P_L0;
- if( a->b_mbrd && a->l0.i_ref == 0
+ if( a->b_mbrd && a->l0.me16x16.i_ref == 0
&& a->l0.me16x16.mv[0] == h->mb.cache.pskip_mv[0]
&& a->l0.me16x16.mv[1] == h->mb.cache.pskip_mv[1] )
{
{
x264_me_t m;
uint8_t **p_fenc = h->mb.pic.p_fenc;
- DECLARE_ALIGNED( int, mvc[3][2], 8 );
+ DECLARE_ALIGNED_8( int mvc[3][2] );
int i, j;
/* XXX Needed for x264_mb_predict_mv */
{
x264_me_t m;
uint8_t **p_fenc = h->mb.pic.p_fenc;
- DECLARE_ALIGNED( int, mvc[3][2], 8 );
+ DECLARE_ALIGNED_8( int mvc[3][2] );
int i, j;
/* XXX Needed for x264_mb_predict_mv */
static int x264_mb_analyse_inter_p4x4_chroma( x264_t *h, x264_mb_analysis_t *a, uint8_t **p_fref, int i8x8, int pixel )
{
- DECLARE_ALIGNED( uint8_t, pix1[16*8], 8 );
+ DECLARE_ALIGNED_8( uint8_t pix1[16*8] );
uint8_t *pix2 = pix1+8;
const int i_stride = h->mb.pic.i_stride[1];
const int or = 4*(i8x8&1) + 2*(i8x8&2)*i_stride;
static void x264_mb_analyse_inter_b16x16( x264_t *h, x264_mb_analysis_t *a )
{
- DECLARE_ALIGNED( uint8_t, pix1[16*16], 16 );
- DECLARE_ALIGNED( uint8_t, pix2[16*16], 16 );
+ DECLARE_ALIGNED_16( uint8_t pix1[16*16] );
+ DECLARE_ALIGNED_16( uint8_t pix2[16*16] );
uint8_t *src2;
int stride2 = 16;
int weight;
uint8_t **p_fref[2] =
{ h->mb.pic.p_fref[0][a->l0.i_ref],
h->mb.pic.p_fref[1][a->l1.i_ref] };
- DECLARE_ALIGNED( uint8_t, pix[2][8*8], 8 );
+ DECLARE_ALIGNED_8( uint8_t pix[2][8*8] );
int i, l;
/* XXX Needed for x264_mb_predict_mv */
uint8_t **p_fref[2] =
{ h->mb.pic.p_fref[0][a->l0.i_ref],
h->mb.pic.p_fref[1][a->l1.i_ref] };
- DECLARE_ALIGNED( uint8_t, pix[2][16*8], 16 );
- DECLARE_ALIGNED( int, mvc[2][2], 8 );
+ DECLARE_ALIGNED_16( uint8_t pix[2][16*8] );
+ DECLARE_ALIGNED_8( int mvc[2][2] );
int i, l;
h->mb.i_partition = D_16x8;
uint8_t **p_fref[2] =
{ h->mb.pic.p_fref[0][a->l0.i_ref],
h->mb.pic.p_fref[1][a->l1.i_ref] };
- DECLARE_ALIGNED( uint8_t, pix[2][8*16], 8 );
- DECLARE_ALIGNED( int, mvc[2][2], 8 );
+ DECLARE_ALIGNED_8( uint8_t pix[2][8*16] );
+ DECLARE_ALIGNED_8( int mvc[2][2] );
int i, l;
h->mb.i_partition = D_8x16;
int i_cost = COST_MAX;
int i;
- /* init analysis */
- x264_mb_analyse_init( h, &analysis, x264_ratecontrol_qp( h ) );
+ h->mb.i_qp = x264_ratecontrol_qp( h );
+ if( h->param.rc.i_aq_mode )
+ x264_adaptive_quant( h );
+
+ x264_mb_analyse_init( h, &analysis, h->mb.i_qp );
/*--------------------------- Do the analysis ---------------------------*/
if( h->sh.i_type == SLICE_TYPE_I )
i_bskip_cost = ssd_mb( h );
/* 6 = minimum cavlc cost of a non-skipped MB */
- if( i_bskip_cost <= 6 * analysis.i_lambda2 )
+ if( i_bskip_cost <= ((6 * analysis.i_lambda2 + 128) >> 8) )
{
h->mb.i_type = B_SKIP;
x264_analyse_update_cache( h, &analysis );