summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChi Yo Tsai <chiyotsai@google.com>2019-01-23 17:43:44 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-01-23 17:43:44 +0000
commitc9e2befce5c3b240a33c6c14c6e2aeadad148948 (patch)
tree2e429cf2f5ffeae5996ebf70ac2885efb578ffc7
parentcc6d6a3b3f0f802ae0d5458b42e8ef7c896c9538 (diff)
parent2082077001e7f657d42de9fc734f8eb2ed5e6609 (diff)
downloadlibvpx-c9e2befce5c3b240a33c6c14c6e2aeadad148948.tar
libvpx-c9e2befce5c3b240a33c6c14c6e2aeadad148948.tar.gz
libvpx-c9e2befce5c3b240a33c6c14c6e2aeadad148948.tar.bz2
libvpx-c9e2befce5c3b240a33c6c14c6e2aeadad148948.zip
Merge "Clean up code for yuv_temporal filter_test.cc"
-rw-r--r--test/yuv_temporal_filter_test.cc77
1 files changed, 38 insertions, 39 deletions
diff --git a/test/yuv_temporal_filter_test.cc b/test/yuv_temporal_filter_test.cc
index 7550ef168..db2faecbb 100644
--- a/test/yuv_temporal_filter_test.cc
+++ b/test/yuv_temporal_filter_test.cc
@@ -8,8 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <limits>
-
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vp9_rtcd.h"
@@ -32,10 +30,9 @@ typedef void (*YUVTemporalFilterFunc)(
uint32_t *y_accumulator, uint16_t *y_count, uint32_t *u_accumulator,
uint16_t *u_count, uint32_t *v_accumulator, uint16_t *v_count);
-static INLINE int get_filter_weight(unsigned int row, unsigned int col,
- unsigned int block_height,
- unsigned int block_width,
- const int *const blk_fw, int use_32x32) {
+int GetFilterWeight(unsigned int row, unsigned int col,
+ unsigned int block_height, unsigned int block_width,
+ const int *const blk_fw, int use_32x32) {
if (use_32x32) {
return blk_fw[0];
}
@@ -43,8 +40,8 @@ static INLINE int get_filter_weight(unsigned int row, unsigned int col,
return blk_fw[2 * (row >= block_height / 2) + (col >= block_width / 2)];
}
-static INLINE int mod_index(int sum_dist, int index, int rounding, int strength,
- int filter_weight) {
+int GetModIndex(int sum_dist, int index, int rounding, int strength,
+ int filter_weight) {
int mod = (sum_dist * 3) / index;
mod += rounding;
mod >>= strength;
@@ -57,7 +54,7 @@ static INLINE int mod_index(int sum_dist, int index, int rounding, int strength,
return mod;
}
-void reference_filter(
+void ApplyReferenceFilter(
const Buffer<uint8_t> &y_src, const Buffer<uint8_t> &y_pre,
const Buffer<uint8_t> &u_src, const Buffer<uint8_t> &v_src,
const Buffer<uint8_t> &u_pre, const Buffer<uint8_t> &v_pre,
@@ -80,7 +77,7 @@ void reference_filter(
u_dif.Set(0);
v_dif.Set(0);
- // How many bits to we want round
+ // How many bits to we want to round
ASSERT_GE(strength, 0);
ASSERT_LE(strength, 6);
int rounding = 0;
@@ -100,32 +97,32 @@ void reference_filter(
ASSERT_TRUE(v_dif.TopLeftPixel() != NULL);
// Get the square diffs
- for (int row = 0; row < (int)block_height; row++) {
- for (int col = 0; col < (int)block_width; col++) {
- int diff = y_src.TopLeftPixel()[row * y_src.stride() + col] -
- y_pre.TopLeftPixel()[row * y_pre.stride() + col];
+ for (int row = 0; row < static_cast<int>(block_height); row++) {
+ for (int col = 0; col < static_cast<int>(block_width); col++) {
+ const int diff = y_src.TopLeftPixel()[row * y_src.stride() + col] -
+ y_pre.TopLeftPixel()[row * y_pre.stride() + col];
y_dif.TopLeftPixel()[row * y_dif.stride() + col] = diff * diff;
}
}
for (int row = 0; row < uv_block_height; row++) {
for (int col = 0; col < uv_block_width; col++) {
- int u_diff = u_src.TopLeftPixel()[row * u_src.stride() + col] -
- u_pre.TopLeftPixel()[row * u_pre.stride() + col];
- int v_diff = v_src.TopLeftPixel()[row * v_src.stride() + col] -
- v_pre.TopLeftPixel()[row * v_pre.stride() + col];
+ const int u_diff = u_src.TopLeftPixel()[row * u_src.stride() + col] -
+ u_pre.TopLeftPixel()[row * u_pre.stride() + col];
+ const int v_diff = v_src.TopLeftPixel()[row * v_src.stride() + col] -
+ v_pre.TopLeftPixel()[row * v_pre.stride() + col];
u_dif.TopLeftPixel()[row * u_dif.stride() + col] = u_diff * u_diff;
v_dif.TopLeftPixel()[row * v_dif.stride() + col] = v_diff * v_diff;
}
}
// Apply the filter
- for (int row = 0; row < (int)block_height; row++) {
- for (int col = 0; col < (int)block_width; col++) {
+ for (int row = 0; row < static_cast<int>(block_height); row++) {
+ for (int col = 0; col < static_cast<int>(block_width); col++) {
const int uv_r = row >> ss_y;
const int uv_c = col >> ss_x;
- int filter_weight = get_filter_weight(row, col, block_height, block_width,
- blk_fw, use_32x32);
+ const int filter_weight = GetFilterWeight(row, col, block_height,
+ block_width, blk_fw, use_32x32);
// First we get the modifier for the current y pixel
const int y_pixel = y_pre.TopLeftPixel()[row * y_pre.stride() + col];
@@ -138,8 +135,8 @@ void reference_filter(
const int sub_row = row + row_step;
const int sub_col = col + col_step;
- if (sub_row >= 0 && sub_row < (int)block_height && sub_col >= 0 &&
- sub_col < (int)block_width) {
+ if (sub_row >= 0 && sub_row < static_cast<int>(block_height) &&
+ sub_col >= 0 && sub_col < static_cast<int>(block_width)) {
y_mod += y_dif.TopLeftPixel()[sub_row * y_dif.stride() + sub_col];
y_num_used++;
}
@@ -156,7 +153,7 @@ void reference_filter(
y_num_used += 2;
// Set the modifier
- y_mod = mod_index(y_mod, y_num_used, rounding, strength, filter_weight);
+ y_mod = GetModIndex(y_mod, y_num_used, rounding, strength, filter_weight);
// Accumulate the result
y_count->TopLeftPixel()[row * y_count->stride() + col] += y_mod;
@@ -186,7 +183,7 @@ void reference_filter(
}
}
- assert(uv_num_used > 0);
+ ASSERT_GT(uv_num_used, 0);
// Sum all the luma pixels associated with the current luma pixel
for (int row_step = 0; row_step < 1 + ss_y; row_step++) {
@@ -204,11 +201,11 @@ void reference_filter(
// Set the modifier
u_mod =
- mod_index(u_mod, uv_num_used, rounding, strength, filter_weight);
+ GetModIndex(u_mod, uv_num_used, rounding, strength, filter_weight);
v_mod =
- mod_index(v_mod, uv_num_used, rounding, strength, filter_weight);
+ GetModIndex(v_mod, uv_num_used, rounding, strength, filter_weight);
- // Accumuate the result
+ // Accumulate the result
u_count->TopLeftPixel()[uv_r * u_count->stride() + uv_c] += u_mod;
u_accumulator->TopLeftPixel()[uv_r * u_accumulator->stride() + uv_c] +=
u_mod * u_pixel;
@@ -233,7 +230,7 @@ class YUVTemporalFilterTest
ACMRandom rnd_;
};
-TEST_P(YUVTemporalFilterTest, USE_32X32) {
+TEST_P(YUVTemporalFilterTest, Use_32X32) {
const int width = 32, height = 32;
Buffer<uint8_t> y_src = Buffer<uint8_t>(width, height, 8);
Buffer<uint8_t> y_pre = Buffer<uint8_t>(width, height, 0);
@@ -311,10 +308,11 @@ TEST_P(YUVTemporalFilterTest, USE_32X32) {
v_count_ref.Set(rnd_.Rand8());
v_count_tst.CopyFrom(v_count_ref);
- reference_filter(y_src, y_pre, u_src, v_src, u_pre, v_pre, width,
- height, ss_x, ss_y, filter_strength, &filter_weight,
- use_32x32, &y_accum_ref, &y_count_ref, &u_accum_ref,
- &u_count_ref, &v_accum_ref, &v_count_ref);
+ ApplyReferenceFilter(y_src, y_pre, u_src, v_src, u_pre, v_pre, width,
+ height, ss_x, ss_y, filter_strength,
+ &filter_weight, use_32x32, &y_accum_ref,
+ &y_count_ref, &u_accum_ref, &u_count_ref,
+ &v_accum_ref, &v_count_ref);
ASM_REGISTER_STATE_CHECK(filter_func_(
y_src.TopLeftPixel(), y_src.stride(), y_pre.TopLeftPixel(),
y_pre.stride(), u_src.TopLeftPixel(), v_src.TopLeftPixel(),
@@ -349,7 +347,7 @@ TEST_P(YUVTemporalFilterTest, USE_32X32) {
}
}
-TEST_P(YUVTemporalFilterTest, USE_16X16) {
+TEST_P(YUVTemporalFilterTest, Use_16X16) {
const int width = 32, height = 32;
Buffer<uint8_t> y_src = Buffer<uint8_t>(width, height, 8);
Buffer<uint8_t> y_pre = Buffer<uint8_t>(width, height, 0);
@@ -436,10 +434,11 @@ TEST_P(YUVTemporalFilterTest, USE_16X16) {
v_count_ref.Set(rnd_.Rand8());
v_count_tst.CopyFrom(v_count_ref);
- reference_filter(y_src, y_pre, u_src, v_src, u_pre, v_pre, width,
- height, ss_x, ss_y, filter_strength, filter_weight,
- use_32x32, &y_accum_ref, &y_count_ref, &u_accum_ref,
- &u_count_ref, &v_accum_ref, &v_count_ref);
+ ApplyReferenceFilter(y_src, y_pre, u_src, v_src, u_pre, v_pre, width,
+ height, ss_x, ss_y, filter_strength,
+ filter_weight, use_32x32, &y_accum_ref,
+ &y_count_ref, &u_accum_ref, &u_count_ref,
+ &v_accum_ref, &v_count_ref);
ASM_REGISTER_STATE_CHECK(filter_func_(
y_src.TopLeftPixel(), y_src.stride(), y_pre.TopLeftPixel(),
y_pre.stride(), u_src.TopLeftPixel(), v_src.TopLeftPixel(),