ref: 83dd9b36f424d2531d61e979ad0d23a6b7c77d25
parent: c099d6be1c2066cfb50c215d420b728eaa178439
author: Johann <johannkoenig@google.com>
date: Wed Mar 22 07:04:20 EDT 2017
vp9 temporal filter: additional test Change tests to reflect use. Input sizes will be 8 or 16 (but not necessarily square). filter_weight is capped at 2 and filter_strength at 6 Speed test, disabled by default. Change-Id: Idfde9d6c4b7d93aaf0e641b0f4862c15e2a2af7a
--- a/test/temporal_filter_test.cc
+++ b/test/temporal_filter_test.cc
@@ -11,10 +11,10 @@
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vp9_rtcd.h"
-
#include "test/acm_random.h"
#include "test/buffer.h"
#include "test/register_state_check.h"
+#include "vpx_ports/vpx_timer.h"
namespace {
@@ -115,9 +115,50 @@
ACMRandom rnd_;
};
+TEST_P(TemporalFilterTest, SizeCombinations) {
+ // Depending on subsampling this function may be called with values of 8 or 16
+ // for width and height, in any combination.
+ Buffer<uint8_t> a = Buffer<uint8_t>(16, 16, 8);
+
+ const int filter_weight = 2;
+ const int filter_strength = 6;
+
+ for (int width = 8; width <= 16; width += 8) {
+ for (int height = 8; height <= 16; height += 8) {
+ // The second buffer must not have any border.
+ Buffer<uint8_t> b = Buffer<uint8_t>(width, height, 0);
+ Buffer<unsigned int> accum_ref = Buffer<unsigned int>(width, height, 0);
+ Buffer<unsigned int> accum_chk = Buffer<unsigned int>(width, height, 0);
+ Buffer<uint16_t> count_ref = Buffer<uint16_t>(width, height, 0);
+ Buffer<uint16_t> count_chk = Buffer<uint16_t>(width, height, 0);
+
+ a.Set(&rnd_, &ACMRandom::Rand8);
+ b.Set(&rnd_, &ACMRandom::Rand8);
+
+ accum_ref.Set(rnd_.Rand8());
+ accum_chk.CopyFrom(accum_ref);
+ count_ref.Set(rnd_.Rand8());
+ count_chk.CopyFrom(count_ref);
+ reference_filter(a, b, width, height, filter_strength, filter_weight,
+ &accum_ref, &count_ref);
+ filter_func_(a.TopLeftPixel(), a.stride(), b.TopLeftPixel(), width,
+ height, filter_strength, filter_weight,
+ accum_chk.TopLeftPixel(), count_chk.TopLeftPixel());
+ EXPECT_TRUE(accum_chk.CheckValues(accum_ref));
+ EXPECT_TRUE(count_chk.CheckValues(count_ref));
+ if (HasFailure()) {
+ printf("Width: %d Height: %d\n", width, height);
+ count_chk.PrintDifference(count_ref);
+ accum_chk.PrintDifference(accum_ref);
+ ASSERT_TRUE(false);
+ }
+ }
+ }
+}
+
TEST_P(TemporalFilterTest, CompareReferenceRandom) {
- const int width = 24;
- const int height = 32;
+ const int width = 16;
+ const int height = 16;
Buffer<uint8_t> a = Buffer<uint8_t>(width, height, 8);
// The second buffer must not have any border.
Buffer<uint8_t> b = Buffer<uint8_t>(width, height, 0);
@@ -129,8 +170,8 @@
a.Set(&rnd_, &ACMRandom::Rand8);
b.Set(&rnd_, &ACMRandom::Rand8);
- for (int filter_strength = 0; filter_strength < 10; ++filter_strength) {
- for (int filter_weight = 0; filter_weight < 10; ++filter_weight) {
+ for (int filter_strength = 0; filter_strength <= 6; ++filter_strength) {
+ for (int filter_weight = 0; filter_weight <= 2; ++filter_weight) {
accum_ref.Set(rnd_.Rand8());
accum_chk.CopyFrom(accum_ref);
count_ref.Set(rnd_.Rand8());
@@ -140,19 +181,62 @@
filter_func_(a.TopLeftPixel(), a.stride(), b.TopLeftPixel(), width,
height, filter_strength, filter_weight,
accum_chk.TopLeftPixel(), count_chk.TopLeftPixel());
- ASSERT_TRUE(accum_chk.CheckValues(accum_ref));
- ASSERT_TRUE(count_chk.CheckValues(count_ref));
+ EXPECT_TRUE(accum_chk.CheckValues(accum_ref));
+ EXPECT_TRUE(count_chk.CheckValues(count_ref));
+ if (HasFailure()) {
+ printf("Weight: %d Strength: %d\n", filter_weight, filter_strength);
+ count_chk.PrintDifference(count_ref);
+ accum_chk.PrintDifference(accum_ref);
+ ASSERT_TRUE(false);
+ }
}
}
}
+TEST_P(TemporalFilterTest, DISABLED_Speed) {
+ Buffer<uint8_t> a = Buffer<uint8_t>(16, 16, 8);
+
+ const int filter_weight = 2;
+ const int filter_strength = 6;
+
+ for (int width = 8; width <= 16; width += 8) {
+ for (int height = 8; height <= 16; height += 8) {
+ // The second buffer must not have any border.
+ Buffer<uint8_t> b = Buffer<uint8_t>(width, height, 0);
+ Buffer<unsigned int> accum_ref = Buffer<unsigned int>(width, height, 0);
+ Buffer<unsigned int> accum_chk = Buffer<unsigned int>(width, height, 0);
+ Buffer<uint16_t> count_ref = Buffer<uint16_t>(width, height, 0);
+ Buffer<uint16_t> count_chk = Buffer<uint16_t>(width, height, 0);
+
+ a.Set(&rnd_, &ACMRandom::Rand8);
+ b.Set(&rnd_, &ACMRandom::Rand8);
+
+ accum_chk.Set(0);
+ count_chk.Set(0);
+
+ vpx_usec_timer timer;
+ vpx_usec_timer_start(&timer);
+ for (int i = 0; i < 10000; ++i) {
+ filter_func_(a.TopLeftPixel(), a.stride(), b.TopLeftPixel(), width,
+ height, filter_strength, filter_weight,
+ accum_chk.TopLeftPixel(), count_chk.TopLeftPixel());
+ }
+ vpx_usec_timer_mark(&timer);
+ const int elapsed_time =
+ static_cast<int>(vpx_usec_timer_elapsed(&timer) / 1000);
+ printf("Temporal filter %dx%d time: %5d ms\n", width, height,
+ elapsed_time);
+ }
+ }
+}
+
INSTANTIATE_TEST_CASE_P(C, TemporalFilterTest,
::testing::Values(&vp9_temporal_filter_apply_c));
/* TODO(johannkoenig): https://bugs.chromium.org/p/webm/issues/detail?id=1378
-#if HAVE_SSE2
-INSTANTIATE_TEST_CASE_P(SSE2, TemporalFilterTest,
- ::testing::Values(&vp9_temporal_filter_apply_sse2));
-#endif // HAVE_SSE2
+#if HAVE_SSE4_1
+INSTANTIATE_TEST_CASE_P(SSE4_1, TemporalFilterTest,
+ ::testing::Values(&vp9_temporal_filter_apply_sse4_1));
+#endif // HAVE_SSE4_1
*/
} // namespace