Misc fixes in hor freq energy computation
Change-Id: I0e7b4a409616fc81f0f699f7ec8c674cdc52e89f
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 99d3c5f..712f4aa 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -266,7 +266,7 @@
}
// Compute the horizontal frequency component energy in a frame
-// by calucluating the 16x4 Horizontal DCT. This will be subsequently
+// by calculuating the 16x4 Horizontal DCT. This will be subsequently
// used to decide the superresolution factors.
void analyze_hor_freq(const AV1_COMP *cpi, double *energy) {
uint64_t freq_energy[16] = { 0 };
@@ -283,15 +283,16 @@
av1_fwd_txfm2d_16x4(src16 + i * buf->y_stride + j, coeff, buf->y_stride,
H_DCT, bd);
for (int k = 4; k < 16; ++k) {
- const int64_t en =
+ const int64_t this_energy =
coeff[k] * coeff[k] + coeff[k + 16] * coeff[k + 16] +
coeff[k + 32] * coeff[k + 32] + coeff[k + 48] * coeff[k + 48];
- freq_energy[k] += ROUND_POWER_OF_TWO(en, 2 * (bd - 8));
+ freq_energy[k] += ROUND_POWER_OF_TWO(this_energy, 2 * (bd - 8));
}
n++;
}
}
} else {
+ assert(bd == 8);
int16_t src16[16 * 4];
for (int i = 0; i < height - 4; i += 4) {
for (int j = 0; j < width - 16; j += 16) {
@@ -301,16 +302,16 @@
buf->y_buffer[(i + ii) * buf->y_stride + (j + jj)];
av1_fwd_txfm2d_16x4(src16, coeff, buf->y_stride, H_DCT, bd);
for (int k = 4; k < 16; ++k) {
- const int64_t en =
+ const int64_t this_energy =
coeff[k] * coeff[k] + coeff[k + 16] * coeff[k + 16] +
coeff[k + 32] * coeff[k + 32] + coeff[k + 48] * coeff[k + 48];
- freq_energy[k] += ROUND_POWER_OF_TWO(en, 2 * (bd - 8));
+ freq_energy[k] += this_energy;
}
n++;
}
}
}
- for (int k = 4; k < 16; ++k) energy[k] = (double)freq_energy[k] / n;
+ for (int k = 4; k < 16; ++k) energy[k] = (double)freq_energy[k] / (4 * n);
}
static void set_high_precision_mv(AV1_COMP *cpi, int allow_high_precision_mv,