xref: /aosp_15_r20/external/libgav1/src/dsp/average_blend_test.cc (revision 095378508e87ed692bf8dfeb34008b65b3735891)
1*09537850SAkhilesh Sanikop // Copyright 2020 The libgav1 Authors
2*09537850SAkhilesh Sanikop //
3*09537850SAkhilesh Sanikop // Licensed under the Apache License, Version 2.0 (the "License");
4*09537850SAkhilesh Sanikop // you may not use this file except in compliance with the License.
5*09537850SAkhilesh Sanikop // You may obtain a copy of the License at
6*09537850SAkhilesh Sanikop //
7*09537850SAkhilesh Sanikop //      http://www.apache.org/licenses/LICENSE-2.0
8*09537850SAkhilesh Sanikop //
9*09537850SAkhilesh Sanikop // Unless required by applicable law or agreed to in writing, software
10*09537850SAkhilesh Sanikop // distributed under the License is distributed on an "AS IS" BASIS,
11*09537850SAkhilesh Sanikop // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*09537850SAkhilesh Sanikop // See the License for the specific language governing permissions and
13*09537850SAkhilesh Sanikop // limitations under the License.
14*09537850SAkhilesh Sanikop 
15*09537850SAkhilesh Sanikop #include "src/dsp/average_blend.h"
16*09537850SAkhilesh Sanikop 
17*09537850SAkhilesh Sanikop #include <cassert>
18*09537850SAkhilesh Sanikop #include <cstdint>
19*09537850SAkhilesh Sanikop #include <ostream>
20*09537850SAkhilesh Sanikop #include <string>
21*09537850SAkhilesh Sanikop #include <type_traits>
22*09537850SAkhilesh Sanikop 
23*09537850SAkhilesh Sanikop #include "absl/strings/match.h"
24*09537850SAkhilesh Sanikop #include "absl/strings/string_view.h"
25*09537850SAkhilesh Sanikop #include "absl/time/clock.h"
26*09537850SAkhilesh Sanikop #include "absl/time/time.h"
27*09537850SAkhilesh Sanikop #include "gtest/gtest.h"
28*09537850SAkhilesh Sanikop #include "src/dsp/constants.h"
29*09537850SAkhilesh Sanikop #include "src/dsp/distance_weighted_blend.h"
30*09537850SAkhilesh Sanikop #include "src/dsp/dsp.h"
31*09537850SAkhilesh Sanikop #include "src/utils/common.h"
32*09537850SAkhilesh Sanikop #include "src/utils/constants.h"
33*09537850SAkhilesh Sanikop #include "src/utils/cpu.h"
34*09537850SAkhilesh Sanikop #include "src/utils/memory.h"
35*09537850SAkhilesh Sanikop #include "tests/block_utils.h"
36*09537850SAkhilesh Sanikop #include "tests/third_party/libvpx/acm_random.h"
37*09537850SAkhilesh Sanikop #include "tests/utils.h"
38*09537850SAkhilesh Sanikop 
39*09537850SAkhilesh Sanikop namespace libgav1 {
40*09537850SAkhilesh Sanikop namespace dsp {
41*09537850SAkhilesh Sanikop namespace {
42*09537850SAkhilesh Sanikop 
43*09537850SAkhilesh Sanikop constexpr int kNumSpeedTests = 5e8;
44*09537850SAkhilesh Sanikop constexpr char kAverageBlend[] = "AverageBlend";
45*09537850SAkhilesh Sanikop // average_blend is applied to compound prediction values. This implies a range
46*09537850SAkhilesh Sanikop // far exceeding that of pixel values.
47*09537850SAkhilesh Sanikop // The ranges include kCompoundOffset in 10bpp and 12bpp.
48*09537850SAkhilesh Sanikop // see: src/dsp/convolve.cc & src/dsp/warp.cc.
49*09537850SAkhilesh Sanikop constexpr int kCompoundPredictionRange[3][2] = {
50*09537850SAkhilesh Sanikop     // 8bpp
51*09537850SAkhilesh Sanikop     {-5132, 9212},
52*09537850SAkhilesh Sanikop     // 10bpp
53*09537850SAkhilesh Sanikop     {3988, 61532},
54*09537850SAkhilesh Sanikop     // 12bpp
55*09537850SAkhilesh Sanikop     {3974, 61559},
56*09537850SAkhilesh Sanikop };
57*09537850SAkhilesh Sanikop 
58*09537850SAkhilesh Sanikop template <int bitdepth, typename Pixel>
59*09537850SAkhilesh Sanikop class AverageBlendTest : public testing::TestWithParam<BlockSize>,
60*09537850SAkhilesh Sanikop                          public test_utils::MaxAlignedAllocable {
61*09537850SAkhilesh Sanikop  public:
62*09537850SAkhilesh Sanikop   static_assert(bitdepth >= kBitdepth8 && bitdepth <= LIBGAV1_MAX_BITDEPTH, "");
63*09537850SAkhilesh Sanikop   AverageBlendTest() = default;
64*09537850SAkhilesh Sanikop   ~AverageBlendTest() override = default;
65*09537850SAkhilesh Sanikop 
SetUp()66*09537850SAkhilesh Sanikop   void SetUp() override {
67*09537850SAkhilesh Sanikop     test_utils::ResetDspTable(bitdepth);
68*09537850SAkhilesh Sanikop     AverageBlendInit_C();
69*09537850SAkhilesh Sanikop     DistanceWeightedBlendInit_C();
70*09537850SAkhilesh Sanikop     const dsp::Dsp* const dsp = dsp::GetDspTable(bitdepth);
71*09537850SAkhilesh Sanikop     ASSERT_NE(dsp, nullptr);
72*09537850SAkhilesh Sanikop     base_func_ = dsp->average_blend;
73*09537850SAkhilesh Sanikop     const testing::TestInfo* const test_info =
74*09537850SAkhilesh Sanikop         testing::UnitTest::GetInstance()->current_test_info();
75*09537850SAkhilesh Sanikop     const absl::string_view test_case = test_info->test_suite_name();
76*09537850SAkhilesh Sanikop     if (absl::StartsWith(test_case, "C/")) {
77*09537850SAkhilesh Sanikop       base_func_ = nullptr;
78*09537850SAkhilesh Sanikop     } else if (absl::StartsWith(test_case, "SSE41/")) {
79*09537850SAkhilesh Sanikop       if ((GetCpuInfo() & kSSE4_1) == 0) GTEST_SKIP() << "No SSE4.1 support!";
80*09537850SAkhilesh Sanikop       AverageBlendInit_SSE4_1();
81*09537850SAkhilesh Sanikop     } else if (absl::StartsWith(test_case, "NEON/")) {
82*09537850SAkhilesh Sanikop       AverageBlendInit_NEON();
83*09537850SAkhilesh Sanikop     } else {
84*09537850SAkhilesh Sanikop       FAIL() << "Unrecognized architecture prefix in test case name: "
85*09537850SAkhilesh Sanikop              << test_case;
86*09537850SAkhilesh Sanikop     }
87*09537850SAkhilesh Sanikop     func_ = dsp->average_blend;
88*09537850SAkhilesh Sanikop     dist_blend_func_ = dsp->distance_weighted_blend;
89*09537850SAkhilesh Sanikop   }
90*09537850SAkhilesh Sanikop 
91*09537850SAkhilesh Sanikop  protected:
92*09537850SAkhilesh Sanikop   void Test(const char* digest, int num_tests, bool debug);
93*09537850SAkhilesh Sanikop 
94*09537850SAkhilesh Sanikop  private:
95*09537850SAkhilesh Sanikop   using PredType =
96*09537850SAkhilesh Sanikop       typename std::conditional<bitdepth == 8, int16_t, uint16_t>::type;
97*09537850SAkhilesh Sanikop   static constexpr int kDestStride = kMaxSuperBlockSizeInPixels;
98*09537850SAkhilesh Sanikop   const int width_ = kBlockWidthPixels[GetParam()];
99*09537850SAkhilesh Sanikop   const int height_ = kBlockHeightPixels[GetParam()];
100*09537850SAkhilesh Sanikop   alignas(kMaxAlignment) PredType
101*09537850SAkhilesh Sanikop       source1_[kMaxSuperBlockSizeInPixels * kMaxSuperBlockSizeInPixels];
102*09537850SAkhilesh Sanikop   alignas(kMaxAlignment) PredType
103*09537850SAkhilesh Sanikop       source2_[kMaxSuperBlockSizeInPixels * kMaxSuperBlockSizeInPixels];
104*09537850SAkhilesh Sanikop   Pixel dest_[kMaxSuperBlockSizeInPixels * kMaxSuperBlockSizeInPixels] = {};
105*09537850SAkhilesh Sanikop   Pixel reference_[kMaxSuperBlockSizeInPixels * kMaxSuperBlockSizeInPixels] =
106*09537850SAkhilesh Sanikop       {};
107*09537850SAkhilesh Sanikop   dsp::AverageBlendFunc base_func_;
108*09537850SAkhilesh Sanikop   dsp::AverageBlendFunc func_;
109*09537850SAkhilesh Sanikop   dsp::DistanceWeightedBlendFunc dist_blend_func_;
110*09537850SAkhilesh Sanikop };
111*09537850SAkhilesh Sanikop 
112*09537850SAkhilesh Sanikop template <int bitdepth, typename Pixel>
Test(const char * digest,int num_tests,bool debug)113*09537850SAkhilesh Sanikop void AverageBlendTest<bitdepth, Pixel>::Test(const char* digest, int num_tests,
114*09537850SAkhilesh Sanikop                                              bool debug) {
115*09537850SAkhilesh Sanikop   if (func_ == nullptr) return;
116*09537850SAkhilesh Sanikop   libvpx_test::ACMRandom rnd(libvpx_test::ACMRandom::DeterministicSeed());
117*09537850SAkhilesh Sanikop   PredType* src_1 = source1_;
118*09537850SAkhilesh Sanikop   PredType* src_2 = source2_;
119*09537850SAkhilesh Sanikop   for (int y = 0; y < height_; ++y) {
120*09537850SAkhilesh Sanikop     for (int x = 0; x < width_; ++x) {
121*09537850SAkhilesh Sanikop       constexpr int bitdepth_index = (bitdepth - 8) >> 1;
122*09537850SAkhilesh Sanikop       const int min_val = kCompoundPredictionRange[bitdepth_index][0];
123*09537850SAkhilesh Sanikop       const int max_val = kCompoundPredictionRange[bitdepth_index][1];
124*09537850SAkhilesh Sanikop       src_1[x] = static_cast<PredType>(rnd(max_val - min_val) + min_val);
125*09537850SAkhilesh Sanikop       src_2[x] = static_cast<PredType>(rnd(max_val - min_val) + min_val);
126*09537850SAkhilesh Sanikop     }
127*09537850SAkhilesh Sanikop     src_1 += width_;
128*09537850SAkhilesh Sanikop     src_2 += width_;
129*09537850SAkhilesh Sanikop   }
130*09537850SAkhilesh Sanikop   absl::Duration elapsed_time;
131*09537850SAkhilesh Sanikop   for (int i = 0; i < num_tests; ++i) {
132*09537850SAkhilesh Sanikop     const absl::Time start = absl::Now();
133*09537850SAkhilesh Sanikop     func_(source1_, source2_, width_, height_, dest_,
134*09537850SAkhilesh Sanikop           sizeof(dest_[0]) * kDestStride);
135*09537850SAkhilesh Sanikop     elapsed_time += absl::Now() - start;
136*09537850SAkhilesh Sanikop   }
137*09537850SAkhilesh Sanikop   if (debug) {
138*09537850SAkhilesh Sanikop     if (base_func_ != nullptr) {
139*09537850SAkhilesh Sanikop       base_func_(source1_, source2_, width_, height_, reference_,
140*09537850SAkhilesh Sanikop                  sizeof(reference_[0]) * kDestStride);
141*09537850SAkhilesh Sanikop     } else {
142*09537850SAkhilesh Sanikop       // Use dist_blend_func_ as the base for C tests.
143*09537850SAkhilesh Sanikop       const int8_t weight = 8;
144*09537850SAkhilesh Sanikop       dist_blend_func_(source1_, source2_, weight, weight, width_, height_,
145*09537850SAkhilesh Sanikop                        reference_, sizeof(reference_[0]) * kDestStride);
146*09537850SAkhilesh Sanikop     }
147*09537850SAkhilesh Sanikop     EXPECT_TRUE(test_utils::CompareBlocks(dest_, reference_, width_, height_,
148*09537850SAkhilesh Sanikop                                           kDestStride, kDestStride, false));
149*09537850SAkhilesh Sanikop   }
150*09537850SAkhilesh Sanikop 
151*09537850SAkhilesh Sanikop   test_utils::CheckMd5Digest(kAverageBlend, ToString(GetParam()), digest, dest_,
152*09537850SAkhilesh Sanikop                              sizeof(dest_[0]) * kDestStride * height_,
153*09537850SAkhilesh Sanikop                              elapsed_time);
154*09537850SAkhilesh Sanikop }
155*09537850SAkhilesh Sanikop 
156*09537850SAkhilesh Sanikop const BlockSize kTestParam[] = {
157*09537850SAkhilesh Sanikop     kBlock4x4,    kBlock4x8,     kBlock4x16,  kBlock8x4,   kBlock8x8,
158*09537850SAkhilesh Sanikop     kBlock8x16,   kBlock8x32,    kBlock16x4,  kBlock16x8,  kBlock16x16,
159*09537850SAkhilesh Sanikop     kBlock16x32,  kBlock16x64,   kBlock32x8,  kBlock32x16, kBlock32x32,
160*09537850SAkhilesh Sanikop     kBlock32x64,  kBlock64x16,   kBlock64x32, kBlock64x64, kBlock64x128,
161*09537850SAkhilesh Sanikop     kBlock128x64, kBlock128x128,
162*09537850SAkhilesh Sanikop };
163*09537850SAkhilesh Sanikop 
164*09537850SAkhilesh Sanikop using AverageBlendTest8bpp = AverageBlendTest<8, uint8_t>;
165*09537850SAkhilesh Sanikop 
GetAverageBlendDigest8bpp(const BlockSize block_size)166*09537850SAkhilesh Sanikop const char* GetAverageBlendDigest8bpp(const BlockSize block_size) {
167*09537850SAkhilesh Sanikop   static const char* const kDigests[kMaxBlockSizes] = {
168*09537850SAkhilesh Sanikop       // 4xN
169*09537850SAkhilesh Sanikop       "152bcc35946900b1ed16369b3e7a81b7",
170*09537850SAkhilesh Sanikop       "c23e9b5698f7384eaae30a3908118b77",
171*09537850SAkhilesh Sanikop       "f2da31d940f62490c368c03d32d3ede8",
172*09537850SAkhilesh Sanikop       // 8xN
173*09537850SAkhilesh Sanikop       "73c95485ef956e1d9ab914e88e6a202b",
174*09537850SAkhilesh Sanikop       "d90d3abd368e58c513070a88b34649ba",
175*09537850SAkhilesh Sanikop       "77f7d53d0edeffb3537afffd9ff33a4a",
176*09537850SAkhilesh Sanikop       "460b9b1e6b83f65f013cfcaf67ec0122",
177*09537850SAkhilesh Sanikop       // 16xN
178*09537850SAkhilesh Sanikop       "96454a56de940174ff92e9bb686d6d38",
179*09537850SAkhilesh Sanikop       "a50e268e93b48ae39cc2a47d377410e2",
180*09537850SAkhilesh Sanikop       "65c8502ff6d78065d466f9911ed6bb3e",
181*09537850SAkhilesh Sanikop       "bc2c873b9f5d74b396e1df705e87f699",
182*09537850SAkhilesh Sanikop       "b4dae656484b2d255d1e09b7f34e12c1",
183*09537850SAkhilesh Sanikop       // 32xN
184*09537850SAkhilesh Sanikop       "7e1e5db92b22a96e5226a23de883d766",
185*09537850SAkhilesh Sanikop       "ca40d46d89773e7f858b15fcecd43cc0",
186*09537850SAkhilesh Sanikop       "bfdc894707323f4dc43d1326309f8368",
187*09537850SAkhilesh Sanikop       "f4733417621719b7feba3166ec0da5b9",
188*09537850SAkhilesh Sanikop       // 64xN
189*09537850SAkhilesh Sanikop       "378fa0594d22f01c8e8931c2a908d7c4",
190*09537850SAkhilesh Sanikop       "db38fe2e082bd4a09acb3bb1d52ee11e",
191*09537850SAkhilesh Sanikop       "3ad44401cc731215c46c9b7d96f7e4ae",
192*09537850SAkhilesh Sanikop       "6c43267be5ed03d204a05fe36090f870",
193*09537850SAkhilesh Sanikop       // 128xN
194*09537850SAkhilesh Sanikop       "c8cfe46ebf166c1cbf08e8804206aadb",
195*09537850SAkhilesh Sanikop       "b0557b5156d2334c8ce4a7ee12f9d6b4",
196*09537850SAkhilesh Sanikop   };
197*09537850SAkhilesh Sanikop   assert(block_size < kMaxBlockSizes);
198*09537850SAkhilesh Sanikop   return kDigests[block_size];
199*09537850SAkhilesh Sanikop }
200*09537850SAkhilesh Sanikop 
TEST_P(AverageBlendTest8bpp,Blending)201*09537850SAkhilesh Sanikop TEST_P(AverageBlendTest8bpp, Blending) {
202*09537850SAkhilesh Sanikop   Test(GetAverageBlendDigest8bpp(GetParam()), 1, false);
203*09537850SAkhilesh Sanikop }
204*09537850SAkhilesh Sanikop 
TEST_P(AverageBlendTest8bpp,DISABLED_Speed)205*09537850SAkhilesh Sanikop TEST_P(AverageBlendTest8bpp, DISABLED_Speed) {
206*09537850SAkhilesh Sanikop   Test(GetAverageBlendDigest8bpp(GetParam()),
207*09537850SAkhilesh Sanikop        kNumSpeedTests /
208*09537850SAkhilesh Sanikop            (kBlockHeightPixels[GetParam()] * kBlockWidthPixels[GetParam()]),
209*09537850SAkhilesh Sanikop        false);
210*09537850SAkhilesh Sanikop }
211*09537850SAkhilesh Sanikop 
212*09537850SAkhilesh Sanikop INSTANTIATE_TEST_SUITE_P(C, AverageBlendTest8bpp,
213*09537850SAkhilesh Sanikop                          testing::ValuesIn(kTestParam));
214*09537850SAkhilesh Sanikop #if LIBGAV1_ENABLE_SSE4_1
215*09537850SAkhilesh Sanikop INSTANTIATE_TEST_SUITE_P(SSE41, AverageBlendTest8bpp,
216*09537850SAkhilesh Sanikop                          testing::ValuesIn(kTestParam));
217*09537850SAkhilesh Sanikop #endif
218*09537850SAkhilesh Sanikop #if LIBGAV1_ENABLE_NEON
219*09537850SAkhilesh Sanikop INSTANTIATE_TEST_SUITE_P(NEON, AverageBlendTest8bpp,
220*09537850SAkhilesh Sanikop                          testing::ValuesIn(kTestParam));
221*09537850SAkhilesh Sanikop #endif
222*09537850SAkhilesh Sanikop 
223*09537850SAkhilesh Sanikop #if LIBGAV1_MAX_BITDEPTH >= 10
224*09537850SAkhilesh Sanikop using AverageBlendTest10bpp = AverageBlendTest<10, uint16_t>;
225*09537850SAkhilesh Sanikop 
GetAverageBlendDigest10bpp(const BlockSize block_size)226*09537850SAkhilesh Sanikop const char* GetAverageBlendDigest10bpp(const BlockSize block_size) {
227*09537850SAkhilesh Sanikop   static const char* const kDigests[kMaxBlockSizes] = {
228*09537850SAkhilesh Sanikop       // 4xN
229*09537850SAkhilesh Sanikop       "98c0671c092b4288adcaaa17362cc4a3",
230*09537850SAkhilesh Sanikop       "7083f3def8bfb63ab3a985ef5616a923",
231*09537850SAkhilesh Sanikop       "a7211ee2eaa6f88e08875b377d17b0f1",
232*09537850SAkhilesh Sanikop       // 8xN
233*09537850SAkhilesh Sanikop       "11f9ab881700f2ef0f82d8d4662868c6",
234*09537850SAkhilesh Sanikop       "3bee144b9ea6f4288b860c24f88a22f3",
235*09537850SAkhilesh Sanikop       "27113bd17bf95034f100e9046c7b59d2",
236*09537850SAkhilesh Sanikop       "c42886a5e16e23a81e43833d34467558",
237*09537850SAkhilesh Sanikop       // 16xN
238*09537850SAkhilesh Sanikop       "b0ac2eb0a7a6596d6d1339074c7f8771",
239*09537850SAkhilesh Sanikop       "24c9e079b9a8647a6ee03f5441f2cdd9",
240*09537850SAkhilesh Sanikop       "dd05777751ccdb4356856c90e1176e53",
241*09537850SAkhilesh Sanikop       "27b1d69d035b1525c013b7373cfe3875",
242*09537850SAkhilesh Sanikop       "08c46403afe19e6b008ccc8f56633da9",
243*09537850SAkhilesh Sanikop       // 32xN
244*09537850SAkhilesh Sanikop       "36d434db11298aba76166df06e9b8125",
245*09537850SAkhilesh Sanikop       "efd24dd7b555786bff1a482e51170ea3",
246*09537850SAkhilesh Sanikop       "3b37ddac87de443cd18784f02c2d1dd5",
247*09537850SAkhilesh Sanikop       "80d8070939a743a20689a65bf5dc0a68",
248*09537850SAkhilesh Sanikop       // 64xN
249*09537850SAkhilesh Sanikop       "88e747246237c6408d0bd4cc3ecc8396",
250*09537850SAkhilesh Sanikop       "af1fe8c52487c9f2951c3ea516828abb",
251*09537850SAkhilesh Sanikop       "ea6f18ff56b053748c18032b7e048e83",
252*09537850SAkhilesh Sanikop       "af0cb87fe27d24c2e0afd2c90a8533a6",
253*09537850SAkhilesh Sanikop       // 128xN
254*09537850SAkhilesh Sanikop       "16a83b19911d6dc7278a694b8baa9901",
255*09537850SAkhilesh Sanikop       "bd22e77ce6fa727267ff63eeb4dcb19c",
256*09537850SAkhilesh Sanikop   };
257*09537850SAkhilesh Sanikop   assert(block_size < kMaxBlockSizes);
258*09537850SAkhilesh Sanikop   return kDigests[block_size];
259*09537850SAkhilesh Sanikop }
260*09537850SAkhilesh Sanikop 
TEST_P(AverageBlendTest10bpp,Blending)261*09537850SAkhilesh Sanikop TEST_P(AverageBlendTest10bpp, Blending) {
262*09537850SAkhilesh Sanikop   Test(GetAverageBlendDigest10bpp(GetParam()), 1, false);
263*09537850SAkhilesh Sanikop }
264*09537850SAkhilesh Sanikop 
TEST_P(AverageBlendTest10bpp,DISABLED_Speed)265*09537850SAkhilesh Sanikop TEST_P(AverageBlendTest10bpp, DISABLED_Speed) {
266*09537850SAkhilesh Sanikop   Test(GetAverageBlendDigest10bpp(GetParam()),
267*09537850SAkhilesh Sanikop        kNumSpeedTests /
268*09537850SAkhilesh Sanikop            (kBlockHeightPixels[GetParam()] * kBlockHeightPixels[GetParam()]) /
269*09537850SAkhilesh Sanikop            2,
270*09537850SAkhilesh Sanikop        false);
271*09537850SAkhilesh Sanikop }
272*09537850SAkhilesh Sanikop 
273*09537850SAkhilesh Sanikop INSTANTIATE_TEST_SUITE_P(C, AverageBlendTest10bpp,
274*09537850SAkhilesh Sanikop                          testing::ValuesIn(kTestParam));
275*09537850SAkhilesh Sanikop #if LIBGAV1_ENABLE_SSE4_1
276*09537850SAkhilesh Sanikop INSTANTIATE_TEST_SUITE_P(SSE41, AverageBlendTest10bpp,
277*09537850SAkhilesh Sanikop                          testing::ValuesIn(kTestParam));
278*09537850SAkhilesh Sanikop #endif
279*09537850SAkhilesh Sanikop #if LIBGAV1_ENABLE_NEON
280*09537850SAkhilesh Sanikop INSTANTIATE_TEST_SUITE_P(NEON, AverageBlendTest10bpp,
281*09537850SAkhilesh Sanikop                          testing::ValuesIn(kTestParam));
282*09537850SAkhilesh Sanikop #endif
283*09537850SAkhilesh Sanikop #endif  // LIBGAV1_MAX_BITDEPTH >= 10
284*09537850SAkhilesh Sanikop 
285*09537850SAkhilesh Sanikop #if LIBGAV1_MAX_BITDEPTH == 12
286*09537850SAkhilesh Sanikop using AverageBlendTest12bpp = AverageBlendTest<12, uint16_t>;
287*09537850SAkhilesh Sanikop 
GetAverageBlendDigest12bpp(const BlockSize block_size)288*09537850SAkhilesh Sanikop const char* GetAverageBlendDigest12bpp(const BlockSize block_size) {
289*09537850SAkhilesh Sanikop   static const char* const kDigests[kMaxBlockSizes] = {
290*09537850SAkhilesh Sanikop       // 4xN
291*09537850SAkhilesh Sanikop       "8f5ad8fba61a0f1cb6b77f5460c241be",
292*09537850SAkhilesh Sanikop       "3a9d017848fdb4162315c689b4449ac6",
293*09537850SAkhilesh Sanikop       "bb97029fff021b168b98b209dcee5123",
294*09537850SAkhilesh Sanikop       // 8xN
295*09537850SAkhilesh Sanikop       "a7ff1b199965b8856499ae3f1b2c48eb",
296*09537850SAkhilesh Sanikop       "05220c72835fc4662d261183df0a57cf",
297*09537850SAkhilesh Sanikop       "97de8c325f1475c44e1afc44183e55ad",
298*09537850SAkhilesh Sanikop       "60d820c46cad14d9d934da238bb79707",
299*09537850SAkhilesh Sanikop       // 16xN
300*09537850SAkhilesh Sanikop       "f3e4863121819bc28f7c1f453898650c",
301*09537850SAkhilesh Sanikop       "5f5f68d21269d7df546c848921e8f2cd",
302*09537850SAkhilesh Sanikop       "17efe0b0fce1f8d4c7bc6eacf769063e",
303*09537850SAkhilesh Sanikop       "3da591e201f44511cdd6c465692ace1e",
304*09537850SAkhilesh Sanikop       "5a0ca6c88664d2e918a032b5fcf66070",
305*09537850SAkhilesh Sanikop       // 32xN
306*09537850SAkhilesh Sanikop       "efe236bee8a9fef90b99d8012006f985",
307*09537850SAkhilesh Sanikop       "d6ff3aacbbbadff6d0ccb0873fb9fa2a",
308*09537850SAkhilesh Sanikop       "38801f7361052873423d57b574aabddc",
309*09537850SAkhilesh Sanikop       "55c76772ecdc1721e92ca04d2fc7c089",
310*09537850SAkhilesh Sanikop       // 64xN
311*09537850SAkhilesh Sanikop       "4261ecdde34eedc4e5066a93e0f64881",
312*09537850SAkhilesh Sanikop       "fe82e012efab872672193316d670fd82",
313*09537850SAkhilesh Sanikop       "6c698bc2d4acf4444a64ac55ae9641de",
314*09537850SAkhilesh Sanikop       "98626e25101cff69019d1b7e6e439404",
315*09537850SAkhilesh Sanikop       // 128xN
316*09537850SAkhilesh Sanikop       "fe0f3c89dd39786df1c952a2470d680d",
317*09537850SAkhilesh Sanikop       "af7e166fc3d8c9ce85789acf3467ed9d",
318*09537850SAkhilesh Sanikop   };
319*09537850SAkhilesh Sanikop   assert(block_size < kMaxBlockSizes);
320*09537850SAkhilesh Sanikop   return kDigests[block_size];
321*09537850SAkhilesh Sanikop }
322*09537850SAkhilesh Sanikop 
TEST_P(AverageBlendTest12bpp,Blending)323*09537850SAkhilesh Sanikop TEST_P(AverageBlendTest12bpp, Blending) {
324*09537850SAkhilesh Sanikop   Test(GetAverageBlendDigest12bpp(GetParam()), 1, false);
325*09537850SAkhilesh Sanikop }
326*09537850SAkhilesh Sanikop 
TEST_P(AverageBlendTest12bpp,DISABLED_Speed)327*09537850SAkhilesh Sanikop TEST_P(AverageBlendTest12bpp, DISABLED_Speed) {
328*09537850SAkhilesh Sanikop   Test(GetAverageBlendDigest12bpp(GetParam()),
329*09537850SAkhilesh Sanikop        kNumSpeedTests /
330*09537850SAkhilesh Sanikop            (kBlockHeightPixels[GetParam()] * kBlockHeightPixels[GetParam()]) /
331*09537850SAkhilesh Sanikop            2,
332*09537850SAkhilesh Sanikop        false);
333*09537850SAkhilesh Sanikop }
334*09537850SAkhilesh Sanikop 
335*09537850SAkhilesh Sanikop INSTANTIATE_TEST_SUITE_P(C, AverageBlendTest12bpp,
336*09537850SAkhilesh Sanikop                          testing::ValuesIn(kTestParam));
337*09537850SAkhilesh Sanikop #endif  // LIBGAV1_MAX_BITDEPTH == 12
338*09537850SAkhilesh Sanikop 
339*09537850SAkhilesh Sanikop }  // namespace
340*09537850SAkhilesh Sanikop }  // namespace dsp
341*09537850SAkhilesh Sanikop 
operator <<(std::ostream & os,const BlockSize param)342*09537850SAkhilesh Sanikop static std::ostream& operator<<(std::ostream& os, const BlockSize param) {
343*09537850SAkhilesh Sanikop   return os << ToString(param);
344*09537850SAkhilesh Sanikop }
345*09537850SAkhilesh Sanikop 
346*09537850SAkhilesh Sanikop }  // namespace libgav1
347