From: Fiona Glaser Date: Fri, 23 Oct 2009 05:38:32 +0000 (-0700) Subject: Fix two warnings + some minor optimizations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7d3ceb4871dbe46c8437be014ac45d550602f9e;p=libx264 Fix two warnings + some minor optimizations --- diff --git a/common/common.h b/common/common.h index 12e1c267..ec61e144 100644 --- a/common/common.h +++ b/common/common.h @@ -619,8 +619,8 @@ struct x264_t int16_t dist_scale_factor[16][2]; int16_t bipred_weight[32][4]; /* maps fref1[0]'s ref indices into the current list0 */ - int8_t map_col_to_list0_buf[2]; // for negative indices - int8_t map_col_to_list0[16]; +#define map_col_to_list0(col) h->mb.map_col_to_list0[col+2] + int8_t map_col_to_list0[18]; } mb; /* rate control encoding only */ diff --git a/common/macroblock.c b/common/macroblock.c index 972417ed..50867b03 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -173,7 +173,7 @@ static int x264_mb_predict_mv_direct16x16_temporal( x264_t *h ) int i_mb_4x4 = 16 * h->mb.i_mb_stride * h->mb.i_mb_y + 4 * h->mb.i_mb_x; int i_mb_8x8 = 4 * h->mb.i_mb_stride * h->mb.i_mb_y + 2 * h->mb.i_mb_x; int i8; - const int type_col = h->fref1[0]->mb_type[ h->mb.i_mb_xy ]; + const int type_col = h->fref1[0]->mb_type[h->mb.i_mb_xy]; x264_macroblock_cache_ref( h, 0, 0, 4, 4, 1, 0 ); @@ -190,7 +190,7 @@ static int x264_mb_predict_mv_direct16x16_temporal( x264_t *h ) const int x8 = i8%2; const int y8 = i8/2; const int i_part_8x8 = i_mb_8x8 + x8 + y8 * h->mb.i_b8_stride; - const int i_ref = h->mb.map_col_to_list0[ h->fref1[0]->ref[0][ i_part_8x8 ] ]; + const int i_ref = map_col_to_list0(h->fref1[0]->ref[0][i_part_8x8]); if( i_ref >= 0 ) { @@ -793,16 +793,16 @@ void x264_macroblock_slice_init( x264_t *h ) for( i = 0; i < h->i_ref1; i++ ) h->fdec->ref_poc[1][i] = h->fref1[i]->i_poc; - h->mb.map_col_to_list0[-1] = -1; - h->mb.map_col_to_list0[-2] = -2; + map_col_to_list0(-1) = -1; + map_col_to_list0(-2) = -2; for( i = 0; i < h->fref1[0]->i_ref[0]; i++ ) { int poc = h->fref1[0]->ref_poc[0][i]; - h->mb.map_col_to_list0[i] = -2; + map_col_to_list0(i) = -2; for( j = 0; j < h->i_ref0; j++ ) if( h->fref0[j]->i_poc == poc ) { - h->mb.map_col_to_list0[i] = j; + map_col_to_list0(i) = j; break; } } diff --git a/encoder/analyse.c b/encoder/analyse.c index d137c1af..f3fd473f 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -819,8 +819,9 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_ else h->predict_8x8[i_mode]( p_dst_by, edge ); - i_satd = sa8d( p_dst_by, FDEC_STRIDE, p_src_by, FENC_STRIDE ) - + a->i_lambda * (i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) ? 1 : 4); + i_satd = sa8d( p_dst_by, FDEC_STRIDE, p_src_by, FENC_STRIDE ) + a->i_lambda * 4; + if( i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) ) + i_satd -= a->i_lambda * 3; COPY2_IF_LT( i_best, i_satd, a->i_predict8x8[idx], i_mode ); a->i_satd_i8x8_dir[i_mode][idx] = i_satd; @@ -895,8 +896,7 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_ h->pixf.intra_mbcmp_x3_4x4( p_src_by, p_dst_by, satd ); satd[i_pred_mode] -= 3 * a->i_lambda; for( i=2; i>=0; i-- ) - COPY2_IF_LT( i_best, satd[i] + 4 * a->i_lambda, - a->i_predict4x4[idx], i ); + COPY2_IF_LT( i_best, satd[i], a->i_predict4x4[idx], i ); i = 3; } else @@ -911,13 +911,13 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_ else h->predict_4x4[i_mode]( p_dst_by ); - i_satd = h->pixf.mbcmp[PIXEL_4x4]( p_dst_by, FDEC_STRIDE, - p_src_by, FENC_STRIDE ) - + a->i_lambda * (i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) ? 1 : 4); + i_satd = h->pixf.mbcmp[PIXEL_4x4]( p_dst_by, FDEC_STRIDE, p_src_by, FENC_STRIDE ); + if( i_pred_mode == x264_mb_pred_mode4x4_fix(i_mode) ) + i_satd -= a->i_lambda * 3; COPY2_IF_LT( i_best, i_satd, a->i_predict4x4[idx], i_mode ); } - i_cost += i_best; + i_cost += i_best + 4 * a->i_lambda; if( i_cost > i_satd_thresh || idx == 15 ) break;