diff options
author | Johann <johannkoenig@google.com> | 2017-03-22 11:04:20 -0700 |
---|---|---|
committer | Johann Koenig <johannkoenig@google.com> | 2017-03-22 19:37:04 +0000 |
commit | 83dd9b36f424d2531d61e979ad0d23a6b7c77d25 (patch) | |
tree | ae8d81b52c614c50581fc2087262f774962495f5 /test | |
parent | c099d6be1c2066cfb50c215d420b728eaa178439 (diff) | |
download | libvpx-83dd9b36f424d2531d61e979ad0d23a6b7c77d25.tar libvpx-83dd9b36f424d2531d61e979ad0d23a6b7c77d25.tar.gz libvpx-83dd9b36f424d2531d61e979ad0d23a6b7c77d25.tar.bz2 libvpx-83dd9b36f424d2531d61e979ad0d23a6b7c77d25.zip |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/temporal_filter_test.cc | 106 |
1 files changed, 95 insertions, 11 deletions
diff --git a/test/temporal_filter_test.cc b/test/temporal_filter_test.cc index c92ee72d2..7804d34d8 100644 --- 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 @@ class TemporalFilterTest : public ::testing::TestWithParam<TemporalFilterFunc> { 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 @@ TEST_P(TemporalFilterTest, CompareReferenceRandom) { 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,8 +181,51 @@ TEST_P(TemporalFilterTest, CompareReferenceRandom) { 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); } } } @@ -150,9 +234,9 @@ 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 |