summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder/vp9_encoder.c')
-rw-r--r--vp9/encoder/vp9_encoder.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 08d9e29e6..868ec3a87 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4732,7 +4732,7 @@ static void set_mb_wiener_variance(VP9_COMP *cpi) {
DECLARE_ALIGNED(16, int16_t, src_diff[32 * 32]);
DECLARE_ALIGNED(16, tran_low_t, coeff[32 * 32]);
- int mb_row, mb_col;
+ int mb_row, mb_col, count = 0;
// Hard coded operating block size
const int block_size = 16;
const int coeff_count = block_size * block_size;
@@ -4749,6 +4749,8 @@ static void set_mb_wiener_variance(VP9_COMP *cpi) {
memset(zero_pred, 0, sizeof(*zero_pred) * coeff_count);
+ cpi->norm_wiener_variance = 0;
+
for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) {
for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
int idx, hist_count = 0;
@@ -4789,18 +4791,21 @@ static void set_mb_wiener_variance(VP9_COMP *cpi) {
// Wiener filter
for (idx = 1; idx < coeff_count; ++idx) {
- int sign = coeff[idx] < 0;
int64_t sqr_coeff = (int64_t)coeff[idx] * coeff[idx];
coeff[idx] = (int16_t)((sqr_coeff * coeff[idx]) /
(sqr_coeff + (int64_t)median_val * median_val));
- if (sign) coeff[idx] = -coeff[idx];
-
wiener_variance += (int64_t)coeff[idx] * coeff[idx];
}
cpi->mb_wiener_variance[mb_row * cm->mb_cols + mb_col] =
wiener_variance / coeff_count;
+ cpi->norm_wiener_variance +=
+ cpi->mb_wiener_variance[mb_row * cm->mb_cols + mb_col];
+ ++count;
}
}
+
+ if (count) cpi->norm_wiener_variance /= count;
+ cpi->norm_wiener_variance = VPXMAX(1, cpi->norm_wiener_variance);
}
static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,