Cleaning up get_sby_perpixel_{, diff_}variance().

Change-Id: Icbfeb04647d654253866d290abd4775a877b4f61
This commit is contained in:
Dmitry Kovalev 2014-04-08 15:43:51 -07:00
Родитель c27bdb9bc1
Коммит 191dfa8dc7
1 изменённых файлов: 16 добавлений и 19 удалений

Просмотреть файл

@ -103,34 +103,31 @@ static const uint8_t VP9_VAR_OFFS[64] = {
}; };
static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi, static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi,
MACROBLOCK *x, const struct buf_2d *ref,
BLOCK_SIZE bs) { BLOCK_SIZE bs) {
unsigned int var, sse; unsigned int sse;
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride, const unsigned int var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride,
VP9_VAR_OFFS, 0, &sse); VP9_VAR_OFFS, 0, &sse);
return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]);
} }
static unsigned int get_sby_perpixel_diff_variance(VP9_COMP *cpi, static unsigned int get_sby_perpixel_diff_variance(VP9_COMP *cpi,
MACROBLOCK *x, const struct buf_2d *ref,
int mi_row, int mi_row, int mi_col,
int mi_col,
BLOCK_SIZE bs) { BLOCK_SIZE bs) {
const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, LAST_FRAME); const YV12_BUFFER_CONFIG *last = get_ref_frame_buffer(cpi, LAST_FRAME);
int offset = (mi_row * MI_SIZE) * yv12->y_stride + (mi_col * MI_SIZE); const uint8_t* last_y = &last->y_buffer[mi_row * MI_SIZE * last->y_stride +
unsigned int var, sse; mi_col * MI_SIZE];
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, unsigned int sse;
x->plane[0].src.stride, const unsigned int var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride,
yv12->y_buffer + offset, last_y, last->y_stride, &sse);
yv12->y_stride,
&sse);
return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]);
} }
static BLOCK_SIZE get_rd_var_based_fixed_partition(VP9_COMP *cpi, static BLOCK_SIZE get_rd_var_based_fixed_partition(VP9_COMP *cpi,
int mi_row, int mi_row,
int mi_col) { int mi_col) {
unsigned int var = get_sby_perpixel_diff_variance(cpi, &cpi->mb, unsigned int var = get_sby_perpixel_diff_variance(cpi, &cpi->mb.plane[0].src,
mi_row, mi_col, mi_row, mi_col,
BLOCK_64X64); BLOCK_64X64);
if (var < 8) if (var < 8)
@ -146,7 +143,7 @@ static BLOCK_SIZE get_rd_var_based_fixed_partition(VP9_COMP *cpi,
static BLOCK_SIZE get_nonrd_var_based_fixed_partition(VP9_COMP *cpi, static BLOCK_SIZE get_nonrd_var_based_fixed_partition(VP9_COMP *cpi,
int mi_row, int mi_row,
int mi_col) { int mi_col) {
unsigned int var = get_sby_perpixel_diff_variance(cpi, &cpi->mb, unsigned int var = get_sby_perpixel_diff_variance(cpi, &cpi->mb.plane[0].src,
mi_row, mi_col, mi_row, mi_col,
BLOCK_64X64); BLOCK_64X64);
if (var < 4) if (var < 4)
@ -1013,7 +1010,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile,
// Set to zero to make sure we do not use the previous encoded frame stats // Set to zero to make sure we do not use the previous encoded frame stats
mbmi->skip = 0; mbmi->skip = 0;
x->source_variance = get_sby_perpixel_variance(cpi, x, bsize); x->source_variance = get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize);
if (aq_mode == VARIANCE_AQ) { if (aq_mode == VARIANCE_AQ) {
const int energy = bsize <= BLOCK_16X16 ? x->mb_energy const int energy = bsize <= BLOCK_16X16 ? x->mb_energy
@ -2115,7 +2112,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
if (cpi->sf.disable_split_var_thresh && partition_none_allowed) { if (cpi->sf.disable_split_var_thresh && partition_none_allowed) {
unsigned int source_variancey; unsigned int source_variancey;
vp9_setup_src_planes(x, cpi->Source, mi_row, mi_col); vp9_setup_src_planes(x, cpi->Source, mi_row, mi_col);
source_variancey = get_sby_perpixel_variance(cpi, x, bsize); source_variancey = get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize);
if (source_variancey < cpi->sf.disable_split_var_thresh) { if (source_variancey < cpi->sf.disable_split_var_thresh) {
do_split = 0; do_split = 0;
if (source_variancey < cpi->sf.disable_split_var_thresh / 2) if (source_variancey < cpi->sf.disable_split_var_thresh / 2)