ref: 191dfa8dc7bc82cbdddfb04cf6adf05a3151c0c7
parent: c27bdb9bc1d8313daee99e46955361544109192f
author: Dmitry Kovalev <dkovalev@google.com>
date: Tue Apr 8 11:43:51 EDT 2014
Cleaning up get_sby_perpixel_{, diff_}variance(). Change-Id: Icbfeb04647d654253866d290abd4775a877b4f61
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -103,27 +103,24 @@
};
static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi,
- MACROBLOCK *x,
+ const struct buf_2d *ref,
BLOCK_SIZE bs) {
- unsigned int var, sse;
- var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride,
- VP9_VAR_OFFS, 0, &sse);
+ unsigned int sse;
+ const unsigned int var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride,
+ VP9_VAR_OFFS, 0, &sse);
return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]);
}
static unsigned int get_sby_perpixel_diff_variance(VP9_COMP *cpi,
- MACROBLOCK *x,
- int mi_row,
- int mi_col,
+ const struct buf_2d *ref,
+ int mi_row, int mi_col,
BLOCK_SIZE bs) {
- const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, LAST_FRAME);
- int offset = (mi_row * MI_SIZE) * yv12->y_stride + (mi_col * MI_SIZE);
- unsigned int var, sse;
- var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
- x->plane[0].src.stride,
- yv12->y_buffer + offset,
- yv12->y_stride,
- &sse);
+ const YV12_BUFFER_CONFIG *last = get_ref_frame_buffer(cpi, LAST_FRAME);
+ const uint8_t* last_y = &last->y_buffer[mi_row * MI_SIZE * last->y_stride +
+ mi_col * MI_SIZE];
+ unsigned int sse;
+ const unsigned int var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride,
+ last_y, last->y_stride, &sse);
return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]);
}
@@ -130,7 +127,7 @@
static BLOCK_SIZE get_rd_var_based_fixed_partition(VP9_COMP *cpi,
int mi_row,
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,
BLOCK_64X64);
if (var < 8)
@@ -146,7 +143,7 @@
static BLOCK_SIZE get_nonrd_var_based_fixed_partition(VP9_COMP *cpi,
int mi_row,
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,
BLOCK_64X64);
if (var < 4)
@@ -1013,7 +1010,7 @@
// Set to zero to make sure we do not use the previous encoded frame stats
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) {
const int energy = bsize <= BLOCK_16X16 ? x->mb_energy
@@ -2115,7 +2112,7 @@
if (cpi->sf.disable_split_var_thresh && partition_none_allowed) {
unsigned int source_variancey;
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) {
do_split = 0;
if (source_variancey < cpi->sf.disable_split_var_thresh / 2)
--
⑨