Index: encoder/analyse.c =================================================================== --- encoder/analyse.c (revision 263) +++ encoder/analyse.c (working copy) @@ -202,6 +202,7 @@ && h->mb.i_subpel_refine >= 5; h->mb.b_transform_8x8 = 0; + h->mb.cache.b_transform_8x8_allowed = h->param.analyse.b_transform_8x8; /* I: Intra part */ a->i_sad_i16x16 = @@ -1443,6 +1444,22 @@ a->i_cost8x16bi += a->i_lambda * i_mb_b16x8_cost_table[a->i_mb_type8x16]; } +static inline void x264_mb_guess_transform( x264_t *h ) +{ + int bias = 0; + if( h->mb.i_mb_type_top >= 0 && !IS_SKIP( h->mb.i_mb_type_top ) ) + bias += h->mb.mb_transform_size[ -h->mb.i_mb_stride ] ? 3 : -3; + if( h->mb.i_mb_type_left >= 0 && !IS_SKIP( h->mb.i_mb_type_left ) ) + bias += h->mb.mb_transform_size[ -1 ] ? 3 : -3; + if( h->mb.i_mb_type_topleft >= 0 && !IS_SKIP( h->mb.i_mb_type_topleft ) ) + bias += h->mb.mb_transform_size[ -h->mb.i_mb_stride-1 ] ? 2 : -2; + if( h->mb.i_mb_type_topright >= 0 && !IS_SKIP( h->mb.i_mb_type_topright ) ) + bias += h->mb.mb_transform_size[ -h->mb.i_mb_stride+1 ] ? 2 : -2; + + h->mb.b_transform_8x8 = bias > 0 ? 1 : bias < 0 ? 0 + : h->stat.frame.i_mb_count_8x8dct[1]*2 > h->stat.frame.i_mb_count_8x8dct[0]; +} + static inline void x264_mb_analyse_transform( x264_t *h ) { h->mb.cache.b_transform_8x8_allowed = @@ -1548,6 +1565,9 @@ x264_mb_analyse_load_costs( h, &analysis ); + if( analysis.b_mbrd && h->param.analyse.b_transform_8x8 ) + x264_mb_guess_transform( h ); + x264_mb_analyse_inter_p16x16( h, &analysis ); if( flags & X264_ANALYSE_PSUB16x16 ) x264_mb_analyse_inter_p8x8( h, &analysis ); @@ -2023,15 +2043,16 @@ { int mvp[2]; x264_mb_predict_mv_pskip( h, mvp ); - /* */ - h->mb.i_partition = D_16x16; x264_macroblock_cache_ref( h, 0, 0, 4, 4, 0, 0 ); x264_macroblock_cache_mv ( h, 0, 0, 4, 4, 0, mvp[0], mvp[1] ); + h->mb.i_partition = D_16x16; + h->mb.b_transform_8x8 = 0; break; } case B_SKIP: /* nothing has changed since x264_macroblock_probe_bskip */ + h->mb.b_transform_8x8 = 0; break; case B_DIRECT: x264_mb_load_mv_direct8x8( h, 0 );