xref: /aosp_15_r20/external/libaom/test/av1_scale_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  *  Copyright (c) 2017 The WebM project authors. All Rights Reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *  Copyright (c) 2024, Alliance for Open Media. All rights reserved.
4*77c1e3ccSAndroid Build Coastguard Worker  *
5*77c1e3ccSAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
6*77c1e3ccSAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
7*77c1e3ccSAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
8*77c1e3ccSAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
9*77c1e3ccSAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #include <assert.h>
13*77c1e3ccSAndroid Build Coastguard Worker #include <string.h>
14*77c1e3ccSAndroid Build Coastguard Worker 
15*77c1e3ccSAndroid Build Coastguard Worker #include <tuple>
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
18*77c1e3ccSAndroid Build Coastguard Worker 
19*77c1e3ccSAndroid Build Coastguard Worker #include "common/av1_config.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
21*77c1e3ccSAndroid Build Coastguard Worker 
22*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
23*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
24*77c1e3ccSAndroid Build Coastguard Worker 
25*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/aom_dsp_common.h"
26*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/aom_filter.h"
27*77c1e3ccSAndroid Build Coastguard Worker #include "aom_mem/aom_mem.h"
28*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/aom_timer.h"
29*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/mem.h"
30*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/filter.h"
31*77c1e3ccSAndroid Build Coastguard Worker #include "test/acm_random.h"
32*77c1e3ccSAndroid Build Coastguard Worker #include "test/register_state_check.h"
33*77c1e3ccSAndroid Build Coastguard Worker #include "test/util.h"
34*77c1e3ccSAndroid Build Coastguard Worker 
35*77c1e3ccSAndroid Build Coastguard Worker namespace {
36*77c1e3ccSAndroid Build Coastguard Worker 
37*77c1e3ccSAndroid Build Coastguard Worker using ResizeFrameFunc = void (*)(const YV12_BUFFER_CONFIG *src,
38*77c1e3ccSAndroid Build Coastguard Worker                                  YV12_BUFFER_CONFIG *dst,
39*77c1e3ccSAndroid Build Coastguard Worker                                  const InterpFilter filter, const int phase,
40*77c1e3ccSAndroid Build Coastguard Worker                                  const int num_planes);
41*77c1e3ccSAndroid Build Coastguard Worker 
42*77c1e3ccSAndroid Build Coastguard Worker class ResizeAndExtendTest : public ::testing::TestWithParam<ResizeFrameFunc> {
43*77c1e3ccSAndroid Build Coastguard Worker  public:
ResizeAndExtendTest()44*77c1e3ccSAndroid Build Coastguard Worker   ResizeAndExtendTest() { resize_fn_ = GetParam(); }
45*77c1e3ccSAndroid Build Coastguard Worker   ~ResizeAndExtendTest() override = default;
46*77c1e3ccSAndroid Build Coastguard Worker 
47*77c1e3ccSAndroid Build Coastguard Worker  protected:
48*77c1e3ccSAndroid Build Coastguard Worker   const int kBufFiller = 123;
49*77c1e3ccSAndroid Build Coastguard Worker   const int kBufMax = kBufFiller - 1;
50*77c1e3ccSAndroid Build Coastguard Worker 
FillPlane(uint8_t * const buf,const int width,const int height,const int stride)51*77c1e3ccSAndroid Build Coastguard Worker   void FillPlane(uint8_t *const buf, const int width, const int height,
52*77c1e3ccSAndroid Build Coastguard Worker                  const int stride) {
53*77c1e3ccSAndroid Build Coastguard Worker     for (int y = 0; y < height; ++y) {
54*77c1e3ccSAndroid Build Coastguard Worker       for (int x = 0; x < width; ++x) {
55*77c1e3ccSAndroid Build Coastguard Worker         buf[x + (y * stride)] = (x + (width * y)) % kBufMax;
56*77c1e3ccSAndroid Build Coastguard Worker       }
57*77c1e3ccSAndroid Build Coastguard Worker     }
58*77c1e3ccSAndroid Build Coastguard Worker   }
59*77c1e3ccSAndroid Build Coastguard Worker 
ResetResizeImage(YV12_BUFFER_CONFIG * const img,const int width,const int height,const int border)60*77c1e3ccSAndroid Build Coastguard Worker   void ResetResizeImage(YV12_BUFFER_CONFIG *const img, const int width,
61*77c1e3ccSAndroid Build Coastguard Worker                         const int height, const int border) {
62*77c1e3ccSAndroid Build Coastguard Worker     memset(img, 0, sizeof(*img));
63*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_EQ(0, aom_alloc_frame_buffer(img, width, height, 1, 1, 0, border, 16,
64*77c1e3ccSAndroid Build Coastguard Worker                                         false, 0));
65*77c1e3ccSAndroid Build Coastguard Worker     memset(img->buffer_alloc, kBufFiller, img->frame_size);
66*77c1e3ccSAndroid Build Coastguard Worker   }
67*77c1e3ccSAndroid Build Coastguard Worker 
ResetResizeImages(const int src_width,const int src_height,const int dst_width,const int dst_height,const int dst_border)68*77c1e3ccSAndroid Build Coastguard Worker   void ResetResizeImages(const int src_width, const int src_height,
69*77c1e3ccSAndroid Build Coastguard Worker                          const int dst_width, const int dst_height,
70*77c1e3ccSAndroid Build Coastguard Worker                          const int dst_border) {
71*77c1e3ccSAndroid Build Coastguard Worker     ResetResizeImage(&img_, src_width, src_height, AOM_BORDER_IN_PIXELS);
72*77c1e3ccSAndroid Build Coastguard Worker     ResetResizeImage(&ref_img_, dst_width, dst_height, dst_border);
73*77c1e3ccSAndroid Build Coastguard Worker     ResetResizeImage(&dst_img_, dst_width, dst_height, dst_border);
74*77c1e3ccSAndroid Build Coastguard Worker     FillPlane(img_.y_buffer, img_.y_crop_width, img_.y_crop_height,
75*77c1e3ccSAndroid Build Coastguard Worker               img_.y_stride);
76*77c1e3ccSAndroid Build Coastguard Worker     FillPlane(img_.u_buffer, img_.uv_crop_width, img_.uv_crop_height,
77*77c1e3ccSAndroid Build Coastguard Worker               img_.uv_stride);
78*77c1e3ccSAndroid Build Coastguard Worker     FillPlane(img_.v_buffer, img_.uv_crop_width, img_.uv_crop_height,
79*77c1e3ccSAndroid Build Coastguard Worker               img_.uv_stride);
80*77c1e3ccSAndroid Build Coastguard Worker   }
81*77c1e3ccSAndroid Build Coastguard Worker 
DeallocResizeImages()82*77c1e3ccSAndroid Build Coastguard Worker   void DeallocResizeImages() {
83*77c1e3ccSAndroid Build Coastguard Worker     aom_free_frame_buffer(&img_);
84*77c1e3ccSAndroid Build Coastguard Worker     aom_free_frame_buffer(&ref_img_);
85*77c1e3ccSAndroid Build Coastguard Worker     aom_free_frame_buffer(&dst_img_);
86*77c1e3ccSAndroid Build Coastguard Worker   }
87*77c1e3ccSAndroid Build Coastguard Worker 
RunTest(InterpFilter filter_type)88*77c1e3ccSAndroid Build Coastguard Worker   void RunTest(InterpFilter filter_type) {
89*77c1e3ccSAndroid Build Coastguard Worker     static const int kNumSizesToTest = 22;
90*77c1e3ccSAndroid Build Coastguard Worker     static const int kNumScaleFactorsToTest = 4;
91*77c1e3ccSAndroid Build Coastguard Worker     static const int kNumDstBordersToTest = 2;
92*77c1e3ccSAndroid Build Coastguard Worker     static const int kSizesToTest[] = { 1,  2,  3,  4,  6,   8,  10, 12,
93*77c1e3ccSAndroid Build Coastguard Worker                                         14, 16, 18, 20, 22,  24, 26, 28,
94*77c1e3ccSAndroid Build Coastguard Worker                                         30, 32, 34, 68, 128, 134 };
95*77c1e3ccSAndroid Build Coastguard Worker     static const int kScaleFactors[] = { 1, 2, 3, 4 };
96*77c1e3ccSAndroid Build Coastguard Worker     static const int kDstBorders[] = { 0, AOM_BORDER_IN_PIXELS };
97*77c1e3ccSAndroid Build Coastguard Worker     for (int border = 0; border < kNumDstBordersToTest; ++border) {
98*77c1e3ccSAndroid Build Coastguard Worker       const int dst_border = kDstBorders[border];
99*77c1e3ccSAndroid Build Coastguard Worker       for (int phase_scaler = 0; phase_scaler < 16; ++phase_scaler) {
100*77c1e3ccSAndroid Build Coastguard Worker         for (int h = 0; h < kNumSizesToTest; ++h) {
101*77c1e3ccSAndroid Build Coastguard Worker           const int src_height = kSizesToTest[h];
102*77c1e3ccSAndroid Build Coastguard Worker           for (int w = 0; w < kNumSizesToTest; ++w) {
103*77c1e3ccSAndroid Build Coastguard Worker             const int src_width = kSizesToTest[w];
104*77c1e3ccSAndroid Build Coastguard Worker             for (int sf_up_idx = 0; sf_up_idx < kNumScaleFactorsToTest;
105*77c1e3ccSAndroid Build Coastguard Worker                  ++sf_up_idx) {
106*77c1e3ccSAndroid Build Coastguard Worker               const int sf_up = kScaleFactors[sf_up_idx];
107*77c1e3ccSAndroid Build Coastguard Worker               for (int sf_down_idx = 0; sf_down_idx < kNumScaleFactorsToTest;
108*77c1e3ccSAndroid Build Coastguard Worker                    ++sf_down_idx) {
109*77c1e3ccSAndroid Build Coastguard Worker                 const int sf_down = kScaleFactors[sf_down_idx];
110*77c1e3ccSAndroid Build Coastguard Worker                 const int dst_width = src_width * sf_up / sf_down;
111*77c1e3ccSAndroid Build Coastguard Worker                 const int dst_height = src_height * sf_up / sf_down;
112*77c1e3ccSAndroid Build Coastguard Worker                 // TODO: bug aomedia:363916152 - Enable unit tests for 4 to 3
113*77c1e3ccSAndroid Build Coastguard Worker                 // scaling when Neon and SSSE3 implementation of
114*77c1e3ccSAndroid Build Coastguard Worker                 // av1_resize_and_extend_frame do not differ from scalar version
115*77c1e3ccSAndroid Build Coastguard Worker                 if (sf_down == 4 && sf_up == 3) {
116*77c1e3ccSAndroid Build Coastguard Worker                   continue;
117*77c1e3ccSAndroid Build Coastguard Worker                 }
118*77c1e3ccSAndroid Build Coastguard Worker 
119*77c1e3ccSAndroid Build Coastguard Worker                 if (sf_up == sf_down && sf_up != 1) {
120*77c1e3ccSAndroid Build Coastguard Worker                   continue;
121*77c1e3ccSAndroid Build Coastguard Worker                 }
122*77c1e3ccSAndroid Build Coastguard Worker                 // I420 frame width and height must be even.
123*77c1e3ccSAndroid Build Coastguard Worker                 if (!dst_width || !dst_height || dst_width & 1 ||
124*77c1e3ccSAndroid Build Coastguard Worker                     dst_height & 1) {
125*77c1e3ccSAndroid Build Coastguard Worker                   continue;
126*77c1e3ccSAndroid Build Coastguard Worker                 }
127*77c1e3ccSAndroid Build Coastguard Worker                 // aom_convolve8_c() has restriction on the step which cannot
128*77c1e3ccSAndroid Build Coastguard Worker                 // exceed 64 (ratio 1 to 4).
129*77c1e3ccSAndroid Build Coastguard Worker                 if (src_width > 4 * dst_width || src_height > 4 * dst_height) {
130*77c1e3ccSAndroid Build Coastguard Worker                   continue;
131*77c1e3ccSAndroid Build Coastguard Worker                 }
132*77c1e3ccSAndroid Build Coastguard Worker                 ASSERT_NO_FATAL_FAILURE(ResetResizeImages(
133*77c1e3ccSAndroid Build Coastguard Worker                     src_width, src_height, dst_width, dst_height, dst_border));
134*77c1e3ccSAndroid Build Coastguard Worker 
135*77c1e3ccSAndroid Build Coastguard Worker                 av1_resize_and_extend_frame_c(&img_, &ref_img_, filter_type,
136*77c1e3ccSAndroid Build Coastguard Worker                                               phase_scaler, 1);
137*77c1e3ccSAndroid Build Coastguard Worker                 resize_fn_(&img_, &dst_img_, filter_type, phase_scaler, 1);
138*77c1e3ccSAndroid Build Coastguard Worker 
139*77c1e3ccSAndroid Build Coastguard Worker                 if (memcmp(dst_img_.buffer_alloc, ref_img_.buffer_alloc,
140*77c1e3ccSAndroid Build Coastguard Worker                            ref_img_.frame_size)) {
141*77c1e3ccSAndroid Build Coastguard Worker                   printf(
142*77c1e3ccSAndroid Build Coastguard Worker                       "filter_type = %d, phase_scaler = %d, src_width = %4d, "
143*77c1e3ccSAndroid Build Coastguard Worker                       "src_height = %4d, dst_width = %4d, dst_height = %4d, "
144*77c1e3ccSAndroid Build Coastguard Worker                       "scale factor = %d:%d\n",
145*77c1e3ccSAndroid Build Coastguard Worker                       filter_type, phase_scaler, src_width, src_height,
146*77c1e3ccSAndroid Build Coastguard Worker                       dst_width, dst_height, sf_down, sf_up);
147*77c1e3ccSAndroid Build Coastguard Worker                   PrintDiff();
148*77c1e3ccSAndroid Build Coastguard Worker                 }
149*77c1e3ccSAndroid Build Coastguard Worker 
150*77c1e3ccSAndroid Build Coastguard Worker                 EXPECT_EQ(ref_img_.frame_size, dst_img_.frame_size);
151*77c1e3ccSAndroid Build Coastguard Worker                 EXPECT_EQ(0,
152*77c1e3ccSAndroid Build Coastguard Worker                           memcmp(ref_img_.buffer_alloc, dst_img_.buffer_alloc,
153*77c1e3ccSAndroid Build Coastguard Worker                                  ref_img_.frame_size));
154*77c1e3ccSAndroid Build Coastguard Worker 
155*77c1e3ccSAndroid Build Coastguard Worker                 DeallocResizeImages();
156*77c1e3ccSAndroid Build Coastguard Worker               }
157*77c1e3ccSAndroid Build Coastguard Worker             }
158*77c1e3ccSAndroid Build Coastguard Worker           }
159*77c1e3ccSAndroid Build Coastguard Worker         }
160*77c1e3ccSAndroid Build Coastguard Worker       }
161*77c1e3ccSAndroid Build Coastguard Worker     }
162*77c1e3ccSAndroid Build Coastguard Worker   }
163*77c1e3ccSAndroid Build Coastguard Worker 
PrintDiffComponent(const uint8_t * const ref,const uint8_t * const opt,const int stride,const int width,const int height,const int plane_idx) const164*77c1e3ccSAndroid Build Coastguard Worker   void PrintDiffComponent(const uint8_t *const ref, const uint8_t *const opt,
165*77c1e3ccSAndroid Build Coastguard Worker                           const int stride, const int width, const int height,
166*77c1e3ccSAndroid Build Coastguard Worker                           const int plane_idx) const {
167*77c1e3ccSAndroid Build Coastguard Worker     for (int y = 0; y < height; y++) {
168*77c1e3ccSAndroid Build Coastguard Worker       for (int x = 0; x < width; x++) {
169*77c1e3ccSAndroid Build Coastguard Worker         if (ref[y * stride + x] != opt[y * stride + x]) {
170*77c1e3ccSAndroid Build Coastguard Worker           printf("Plane %d pixel[%d][%d] diff:%6d (ref),%6d (opt)\n", plane_idx,
171*77c1e3ccSAndroid Build Coastguard Worker                  y, x, ref[y * stride + x], opt[y * stride + x]);
172*77c1e3ccSAndroid Build Coastguard Worker           break;
173*77c1e3ccSAndroid Build Coastguard Worker         }
174*77c1e3ccSAndroid Build Coastguard Worker       }
175*77c1e3ccSAndroid Build Coastguard Worker     }
176*77c1e3ccSAndroid Build Coastguard Worker   }
177*77c1e3ccSAndroid Build Coastguard Worker 
PrintDiff() const178*77c1e3ccSAndroid Build Coastguard Worker   void PrintDiff() const {
179*77c1e3ccSAndroid Build Coastguard Worker     assert(ref_img_.y_stride == dst_img_.y_stride);
180*77c1e3ccSAndroid Build Coastguard Worker     assert(ref_img_.y_width == dst_img_.y_width);
181*77c1e3ccSAndroid Build Coastguard Worker     assert(ref_img_.y_height == dst_img_.y_height);
182*77c1e3ccSAndroid Build Coastguard Worker     assert(ref_img_.uv_stride == dst_img_.uv_stride);
183*77c1e3ccSAndroid Build Coastguard Worker     assert(ref_img_.uv_width == dst_img_.uv_width);
184*77c1e3ccSAndroid Build Coastguard Worker     assert(ref_img_.uv_height == dst_img_.uv_height);
185*77c1e3ccSAndroid Build Coastguard Worker 
186*77c1e3ccSAndroid Build Coastguard Worker     if (memcmp(dst_img_.buffer_alloc, ref_img_.buffer_alloc,
187*77c1e3ccSAndroid Build Coastguard Worker                ref_img_.frame_size)) {
188*77c1e3ccSAndroid Build Coastguard Worker       PrintDiffComponent(ref_img_.y_buffer, dst_img_.y_buffer,
189*77c1e3ccSAndroid Build Coastguard Worker                          ref_img_.y_stride, ref_img_.y_width, ref_img_.y_height,
190*77c1e3ccSAndroid Build Coastguard Worker                          0);
191*77c1e3ccSAndroid Build Coastguard Worker       PrintDiffComponent(ref_img_.u_buffer, dst_img_.u_buffer,
192*77c1e3ccSAndroid Build Coastguard Worker                          ref_img_.uv_stride, ref_img_.uv_width,
193*77c1e3ccSAndroid Build Coastguard Worker                          ref_img_.uv_height, 1);
194*77c1e3ccSAndroid Build Coastguard Worker       PrintDiffComponent(ref_img_.v_buffer, dst_img_.v_buffer,
195*77c1e3ccSAndroid Build Coastguard Worker                          ref_img_.uv_stride, ref_img_.uv_width,
196*77c1e3ccSAndroid Build Coastguard Worker                          ref_img_.uv_height, 2);
197*77c1e3ccSAndroid Build Coastguard Worker     }
198*77c1e3ccSAndroid Build Coastguard Worker   }
199*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTest()200*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
201*77c1e3ccSAndroid Build Coastguard Worker     static const int kCountSpeedTestBlock = 100;
202*77c1e3ccSAndroid Build Coastguard Worker     static const int kNumScaleFactorsToTest = 4;
203*77c1e3ccSAndroid Build Coastguard Worker     static const int kNumInterpFiltersToTest = 3;
204*77c1e3ccSAndroid Build Coastguard Worker     static const int kScaleFactors[] = { 1, 2, 3, 4 };
205*77c1e3ccSAndroid Build Coastguard Worker     static const int kInterpFilters[] = { 0, 1, 3 };
206*77c1e3ccSAndroid Build Coastguard Worker     const int src_width = 1280;
207*77c1e3ccSAndroid Build Coastguard Worker     const int src_height = 720;
208*77c1e3ccSAndroid Build Coastguard Worker     for (int filter = 0; filter < kNumInterpFiltersToTest; ++filter) {
209*77c1e3ccSAndroid Build Coastguard Worker       const InterpFilter filter_type =
210*77c1e3ccSAndroid Build Coastguard Worker           static_cast<InterpFilter>(kInterpFilters[filter]);
211*77c1e3ccSAndroid Build Coastguard Worker       for (int phase_scaler = 0; phase_scaler < 2; ++phase_scaler) {
212*77c1e3ccSAndroid Build Coastguard Worker         for (int sf_up_idx = 0; sf_up_idx < kNumScaleFactorsToTest;
213*77c1e3ccSAndroid Build Coastguard Worker              ++sf_up_idx) {
214*77c1e3ccSAndroid Build Coastguard Worker           const int sf_up = kScaleFactors[sf_up_idx];
215*77c1e3ccSAndroid Build Coastguard Worker           for (int sf_down_idx = 0; sf_down_idx < kNumScaleFactorsToTest;
216*77c1e3ccSAndroid Build Coastguard Worker                ++sf_down_idx) {
217*77c1e3ccSAndroid Build Coastguard Worker             const int sf_down = kScaleFactors[sf_down_idx];
218*77c1e3ccSAndroid Build Coastguard Worker             const int dst_width = src_width * sf_up / sf_down;
219*77c1e3ccSAndroid Build Coastguard Worker             const int dst_height = src_height * sf_up / sf_down;
220*77c1e3ccSAndroid Build Coastguard Worker             // TODO: bug aomedia:363916152 - Enable unit tests for 4 to 3
221*77c1e3ccSAndroid Build Coastguard Worker             // scaling when Neon and SSSE3 implementation of
222*77c1e3ccSAndroid Build Coastguard Worker             // av1_resize_and_extend_frame do not differ from scalar version
223*77c1e3ccSAndroid Build Coastguard Worker             if (sf_down == 4 && sf_up == 3) {
224*77c1e3ccSAndroid Build Coastguard Worker               continue;
225*77c1e3ccSAndroid Build Coastguard Worker             }
226*77c1e3ccSAndroid Build Coastguard Worker 
227*77c1e3ccSAndroid Build Coastguard Worker             if (sf_up == sf_down && sf_up != 1) {
228*77c1e3ccSAndroid Build Coastguard Worker               continue;
229*77c1e3ccSAndroid Build Coastguard Worker             }
230*77c1e3ccSAndroid Build Coastguard Worker             // I420 frame width and height must be even.
231*77c1e3ccSAndroid Build Coastguard Worker             if (dst_width & 1 || dst_height & 1) {
232*77c1e3ccSAndroid Build Coastguard Worker               continue;
233*77c1e3ccSAndroid Build Coastguard Worker             }
234*77c1e3ccSAndroid Build Coastguard Worker             ASSERT_NO_FATAL_FAILURE(ResetResizeImages(src_width, src_height,
235*77c1e3ccSAndroid Build Coastguard Worker                                                       dst_width, dst_height,
236*77c1e3ccSAndroid Build Coastguard Worker                                                       AOM_BORDER_IN_PIXELS));
237*77c1e3ccSAndroid Build Coastguard Worker 
238*77c1e3ccSAndroid Build Coastguard Worker             aom_usec_timer ref_timer;
239*77c1e3ccSAndroid Build Coastguard Worker             aom_usec_timer_start(&ref_timer);
240*77c1e3ccSAndroid Build Coastguard Worker             for (int i = 0; i < kCountSpeedTestBlock; ++i)
241*77c1e3ccSAndroid Build Coastguard Worker               av1_resize_and_extend_frame_c(&img_, &ref_img_, filter_type,
242*77c1e3ccSAndroid Build Coastguard Worker                                             phase_scaler, 1);
243*77c1e3ccSAndroid Build Coastguard Worker             aom_usec_timer_mark(&ref_timer);
244*77c1e3ccSAndroid Build Coastguard Worker             const int64_t ref_time = aom_usec_timer_elapsed(&ref_timer);
245*77c1e3ccSAndroid Build Coastguard Worker 
246*77c1e3ccSAndroid Build Coastguard Worker             aom_usec_timer tst_timer;
247*77c1e3ccSAndroid Build Coastguard Worker             aom_usec_timer_start(&tst_timer);
248*77c1e3ccSAndroid Build Coastguard Worker             for (int i = 0; i < kCountSpeedTestBlock; ++i)
249*77c1e3ccSAndroid Build Coastguard Worker               resize_fn_(&img_, &dst_img_, filter_type, phase_scaler, 1);
250*77c1e3ccSAndroid Build Coastguard Worker             aom_usec_timer_mark(&tst_timer);
251*77c1e3ccSAndroid Build Coastguard Worker             const int64_t tst_time = aom_usec_timer_elapsed(&tst_timer);
252*77c1e3ccSAndroid Build Coastguard Worker             DeallocResizeImages();
253*77c1e3ccSAndroid Build Coastguard Worker 
254*77c1e3ccSAndroid Build Coastguard Worker             std::cout << "[          ] C time = " << ref_time / 1000
255*77c1e3ccSAndroid Build Coastguard Worker                       << " ms, SIMD time = " << tst_time / 1000 << " ms\n";
256*77c1e3ccSAndroid Build Coastguard Worker           }
257*77c1e3ccSAndroid Build Coastguard Worker         }
258*77c1e3ccSAndroid Build Coastguard Worker       }
259*77c1e3ccSAndroid Build Coastguard Worker     }
260*77c1e3ccSAndroid Build Coastguard Worker   }
261*77c1e3ccSAndroid Build Coastguard Worker 
262*77c1e3ccSAndroid Build Coastguard Worker   YV12_BUFFER_CONFIG img_;
263*77c1e3ccSAndroid Build Coastguard Worker   YV12_BUFFER_CONFIG ref_img_;
264*77c1e3ccSAndroid Build Coastguard Worker   YV12_BUFFER_CONFIG dst_img_;
265*77c1e3ccSAndroid Build Coastguard Worker   ResizeFrameFunc resize_fn_;
266*77c1e3ccSAndroid Build Coastguard Worker };
267*77c1e3ccSAndroid Build Coastguard Worker 
268*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ResizeAndExtendTest);
269*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(ResizeAndExtendTest,ResizeFrame_EightTap)270*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ResizeAndExtendTest, ResizeFrame_EightTap) { RunTest(EIGHTTAP_REGULAR); }
TEST_P(ResizeAndExtendTest,ResizeFrame_EightTapSmooth)271*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ResizeAndExtendTest, ResizeFrame_EightTapSmooth) {
272*77c1e3ccSAndroid Build Coastguard Worker   RunTest(EIGHTTAP_SMOOTH);
273*77c1e3ccSAndroid Build Coastguard Worker }
TEST_P(ResizeAndExtendTest,ResizeFrame_Bilinear)274*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ResizeAndExtendTest, ResizeFrame_Bilinear) { RunTest(BILINEAR); }
TEST_P(ResizeAndExtendTest,DISABLED_Speed)275*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ResizeAndExtendTest, DISABLED_Speed) { SpeedTest(); }
276*77c1e3ccSAndroid Build Coastguard Worker 
277*77c1e3ccSAndroid Build Coastguard Worker // TODO: bug aomedia:363916152 - Enable SSSE3 unit tests when implementation of
278*77c1e3ccSAndroid Build Coastguard Worker // av1_resize_and_extend_frame does not differ from scalar version
279*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
280*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(DISABLED_SSSE3, ResizeAndExtendTest,
281*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::Values(av1_resize_and_extend_frame_ssse3));
282*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_SSSE3
283*77c1e3ccSAndroid Build Coastguard Worker 
284*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
285*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, ResizeAndExtendTest,
286*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::Values(av1_resize_and_extend_frame_neon));
287*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_NEON
288*77c1e3ccSAndroid Build Coastguard Worker 
289*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_DOTPROD
290*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
291*77c1e3ccSAndroid Build Coastguard Worker     NEON_DOTPROD, ResizeAndExtendTest,
292*77c1e3ccSAndroid Build Coastguard Worker     ::testing::Values(av1_resize_and_extend_frame_neon_dotprod));
293*77c1e3ccSAndroid Build Coastguard Worker 
294*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_NEON_DOTPROD
295*77c1e3ccSAndroid Build Coastguard Worker 
296*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_I8MM
297*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
298*77c1e3ccSAndroid Build Coastguard Worker     NEON_I8MM, ResizeAndExtendTest,
299*77c1e3ccSAndroid Build Coastguard Worker     ::testing::Values(av1_resize_and_extend_frame_neon_i8mm));
300*77c1e3ccSAndroid Build Coastguard Worker 
301*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_NEON_I8MM
302*77c1e3ccSAndroid Build Coastguard Worker 
303*77c1e3ccSAndroid Build Coastguard Worker }  // namespace
304