diff options
Diffstat (limited to 'src/dsp/obmc_test.cc')
-rw-r--r-- | src/dsp/obmc_test.cc | 80 |
1 files changed, 76 insertions, 4 deletions
diff --git a/src/dsp/obmc_test.cc b/src/dsp/obmc_test.cc index 3672e12..a10feb2 100644 --- a/src/dsp/obmc_test.cc +++ b/src/dsp/obmc_test.cc @@ -15,6 +15,7 @@ #include "src/dsp/obmc.h" #include <algorithm> +#include <cassert> #include <cstddef> #include <cstdint> #include <cstring> @@ -58,6 +59,8 @@ const char* GetDigest8bpp(int id) { "98a9be6245720d4e0da18115c1a1dbd7", "7e7afe3136ad681b5ea05664fe916548", "33971753243f09106173199b7bae1ef5", "65413f33c19a42c112d395121aa4b3b4", }; + assert(id >= 0); + assert(id < sizeof(kDigest) / sizeof(kDigest[0])); return kDigest[id]; } @@ -75,6 +78,8 @@ const char* GetDigestSpeed8bpp(int id) { "29f8a6fc2a650f3945a4ea6d3b975b6d", "8f300a257e913a42666b4921b2b0b5c5", "a526265c4b3c8593736a82ddc1fd1603", "76e248f6756ac96343204b0e48d72a9e", }; + assert(id >= 0); + assert(id < sizeof(kDigest) / sizeof(kDigest[0])); return kDigest[id]; } @@ -93,6 +98,8 @@ const char* GetDigest10bpp(int id) { "e4a01e492ddc0398b5c5b60c81468242", "f1b4f7ab5c8b949e51db104f2e33565a", "b1fb9ecc6a552e2b23ee92e2f3e4122a", "a683d20129a91bb20b904aa20c0499b1", }; + assert(id >= 0); + assert(id < sizeof(kDigest) / sizeof(kDigest[0])); return kDigest[id]; } @@ -110,10 +117,52 @@ const char* GetDigestSpeed10bpp(int id) { "b543855cbe384b88861c881853c28192", "5faaafc124e94eedc69dc0f5d33dacac", "13ca4d01bd20085459e6126555e1f7b5", "46d46fae3c8a7d9e4725154d8d2b76d8", }; + assert(id >= 0); + assert(id < sizeof(kDigest) / sizeof(kDigest[0])); return kDigest[id]; } #endif // LIBGAV1_MAX_BITDEPTH >= 10 +#if LIBGAV1_MAX_BITDEPTH == 12 +const char* GetDigest12bpp(int id) { + static const char* const kDigest[] = { + "eb18c776d7b56280f01cca40b04a9c44", "058d4a6ed025eac5dcf7aec3203c0882", + "8355884d7470e9c6af9309ab23bee859", "2ba330551ac58d1d034b947d7ab9b59f", + "0d25cd773c81e4c57f82513e3b031f01", "b9075f7c3b9a240dbb015a24454eeb71", + "563ed8683723d1e4f2746280bca3db0a", "d7125306bd8c952d0f85fe1515ca16a7", + "5bf99c7e4a918c9b6a7e251484ea6527", "38ac9c685e8d2bd2771b6f2b38268301", + "abc39dbde7470e08b15417ee97c704b2", "37e12753d23b7a8df92b1d32f3170d9f", + "9a609776cfa31f64826225d0a6b7afdd", "ccdd89e70e94f751fd891b124c1c3210", + "2bbf7b095e26ed4f27e7d05e20117084", "9a1b403c3a7c00da5686bcb87f1270e8", + "701d651e391043ab8ebbd0023a430980", "0047f10bdd8321494e8e82597fe2f969", + "f97e662d139b2811e3d3227de95135a2", "852933b90d4a70f9254157381ed641e0", + "cfcda707ec8e4361ef741dc716888348", "95e34eab83b3159f61685db248c6a881", + }; + assert(id >= 0); + assert(id < sizeof(kDigest) / sizeof(kDigest[0])); + return kDigest[id]; +} + +const char* GetDigestSpeed12bpp(int id) { + static const char* const kDigest[] = { + "6c0f37c41d72ce40d95545ac0f08d88a", "8a8efeb7d8b2f852d76d0176b6c6878f", + "5757c88d1cdc0cd29c47c346474161f0", "fef8cf06d16ba7357bfc061e43080cd3", + "6bd11582448532bce8b91cc8807ab6a0", "1e6dd42eada2d636e210f4e20a771102", + "377a0472f45fcb42f1712243ea845530", "e3760f2b6e69c1b40e71ecde711d227c", + "6721638d1a5dadb96ddd0ca067c737ca", "3d3a23210a8496a76991bcec5045808b", + "2cbd26ecf7d4e927ab569083d3ddb4ca", "7d61af2d7841d1a39a2e930bac166804", + "dd929506442fb1f2e67130fe8cdf487b", "c0e57f8d2546d5bcb646a24d09d83d7c", + "2989c6487456c92eb003c8e17e904f45", "5cfb60a3be6ee5c41e0f655a3020f687", + "28f37d47cb07aa382659ff556a55a4c6", "b6478ab317b11f592deb60d02ce62f2f", + "bc78e7250c101f82e794d4fa0ee55025", "24304ed23d336a46f205206d3c5d48ef", + "dc1e71d95d06c1086bb7f9e05e38bf39", "32606ef72985e7de608df2e8760784b7", + }; + assert(id >= 0); + assert(id < sizeof(kDigest) / sizeof(kDigest[0])); + return kDigest[id]; +} +#endif // LIBGAV1_MAX_BITDEPTH == 12 + struct ObmcTestParam { ObmcTestParam(int width, int height, ObmcDirection blending_direction) : width(width), height(height), blending_direction(blending_direction) {} @@ -130,6 +179,7 @@ std::ostream& operator<<(std::ostream& os, const ObmcTestParam& param) { template <int bitdepth, typename Pixel> class ObmcBlendTest : public testing::TestWithParam<ObmcTestParam> { public: + static_assert(bitdepth >= kBitdepth8 && bitdepth <= LIBGAV1_MAX_BITDEPTH, ""); ObmcBlendTest() = default; ~ObmcBlendTest() override = default; @@ -206,11 +256,12 @@ void ObmcBlendTest<bitdepth, Pixel>::Test(const char* const digest, src_2[x] = rnd.Rand16() & mask; } src_1 += kMaxBlendingBlockSize; - src_2 += kMaxBlendingBlockSize; + src_2 += width_; } } const ptrdiff_t stride = kMaxBlendingBlockSize * sizeof(Pixel); - func_(source1_, stride, width_, height_, source2_, stride); + func_(source1_, stride, width_, height_, source2_, + width_ * sizeof(source2_[0])); if (use_fixed_values) { const bool success = test_utils::CompareBlocks( source1_, source2_, width_, height_, kMaxBlendingBlockSize, @@ -238,7 +289,7 @@ void ObmcBlendTest<bitdepth, Pixel>::TestSpeed(const char* const digest, src_2[x] = rnd.Rand16() & mask; } src_1 += kMaxBlendingBlockSize; - src_2 += kMaxBlendingBlockSize; + src_2 += width_; } const ptrdiff_t stride = kMaxBlendingBlockSize * sizeof(Pixel); uint8_t dest[sizeof(Pixel) * kMaxBlendingBlockSize * kMaxBlendingBlockSize]; @@ -247,7 +298,8 @@ void ObmcBlendTest<bitdepth, Pixel>::TestSpeed(const char* const digest, memcpy(dest, source1_, sizeof(Pixel) * kMaxBlendingBlockSize * kMaxBlendingBlockSize); const absl::Time start = absl::Now(); - func_(dest, stride, width_, height_, source2_, stride); + func_(dest, stride, width_, height_, source2_, + width_ * sizeof(source2_[0])); elapsed_time += absl::Now() - start; } memcpy(source1_, dest, @@ -338,6 +390,26 @@ INSTANTIATE_TEST_SUITE_P(NEON, ObmcBlendTest10bpp, #endif #endif // LIBGAV1_MAX_BITDEPTH >= 10 +#if LIBGAV1_MAX_BITDEPTH == 12 +using ObmcBlendTest12bpp = ObmcBlendTest<12, uint16_t>; + +TEST_P(ObmcBlendTest12bpp, Blending) { + Test(/*digest=*/nullptr, /*use_fixed_values=*/true, 0); + Test(/*digest=*/nullptr, /*use_fixed_values=*/true, 1); + Test(/*digest=*/nullptr, /*use_fixed_values=*/true, 128); + Test(/*digest=*/nullptr, /*use_fixed_values=*/true, (1 << 12) - 1); + Test(GetDigest12bpp(GetDigestId()), /*use_fixed_values=*/false, -1); +} + +TEST_P(ObmcBlendTest12bpp, DISABLED_Speed) { + TestSpeed(GetDigestSpeed12bpp(GetDigestId()), + kNumSpeedTests / (GetParam().height * GetParam().width)); +} + +INSTANTIATE_TEST_SUITE_P(C, ObmcBlendTest12bpp, + testing::ValuesIn(kObmcTestParam)); +#endif // LIBGAV1_MAX_BITDEPTH == 12 + } // namespace } // namespace dsp } // namespace libgav1 |