• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The libgav1 Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/dsp/intrapred_smooth.h"
16 
17 #include <algorithm>
18 #include <cassert>
19 #include <cstddef>
20 #include <cstdlib>
21 #include <cstring>
22 
23 #include "src/dsp/constants.h"
24 #include "src/dsp/dsp.h"
25 #include "src/utils/common.h"
26 #include "src/utils/constants.h"
27 
28 namespace libgav1 {
29 namespace dsp {
30 namespace {
31 
32 template <int block_width, int block_height, typename Pixel>
33 struct SmoothFuncs_C {
34   SmoothFuncs_C() = delete;
35 
36   static void Smooth(void* dest, ptrdiff_t stride, const void* top_row,
37                      const void* left_column);
38   static void SmoothVertical(void* dest, ptrdiff_t stride, const void* top_row,
39                              const void* left_column);
40   static void SmoothHorizontal(void* dest, ptrdiff_t stride,
41                                const void* top_row, const void* left_column);
42 };
43 
44 constexpr uint8_t kSmoothWeights[] = {
45     // block dimension = 4
46     255, 149, 85, 64,
47     // block dimension = 8
48     255, 197, 146, 105, 73, 50, 37, 32,
49     // block dimension = 16
50     255, 225, 196, 170, 145, 123, 102, 84, 68, 54, 43, 33, 26, 20, 17, 16,
51     // block dimension = 32
52     255, 240, 225, 210, 196, 182, 169, 157, 145, 133, 122, 111, 101, 92, 83, 74,
53     66, 59, 52, 45, 39, 34, 29, 25, 21, 17, 14, 12, 10, 9, 8, 8,
54     // block dimension = 64
55     255, 248, 240, 233, 225, 218, 210, 203, 196, 189, 182, 176, 169, 163, 156,
56     150, 144, 138, 133, 127, 121, 116, 111, 106, 101, 96, 91, 86, 82, 77, 73,
57     69, 65, 61, 57, 54, 50, 47, 44, 41, 38, 35, 32, 29, 27, 25, 22, 20, 18, 16,
58     15, 13, 12, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 4};
59 
60 // SmoothFuncs_C::Smooth
61 template <int block_width, int block_height, typename Pixel>
Smooth(void * const dest,ptrdiff_t stride,const void * const top_row,const void * const left_column)62 void SmoothFuncs_C<block_width, block_height, Pixel>::Smooth(
63     void* const dest, ptrdiff_t stride, const void* const top_row,
64     const void* const left_column) {
65   const auto* const top = static_cast<const Pixel*>(top_row);
66   const auto* const left = static_cast<const Pixel*>(left_column);
67   const Pixel top_right = top[block_width - 1];
68   const Pixel bottom_left = left[block_height - 1];
69   static_assert(
70       block_width >= 4 && block_height >= 4,
71       "Weights for smooth predictor undefined for block width/height < 4");
72   const uint8_t* const weights_x = kSmoothWeights + block_width - 4;
73   const uint8_t* const weights_y = kSmoothWeights + block_height - 4;
74   const uint16_t scale_value = (1 << kSmoothWeightScale);
75   auto* dst = static_cast<Pixel*>(dest);
76   stride /= sizeof(Pixel);
77 
78   for (int y = 0; y < block_height; ++y) {
79     for (int x = 0; x < block_width; ++x) {
80       assert(scale_value >= weights_y[y] && scale_value >= weights_x[x]);
81       uint32_t pred = weights_y[y] * top[x];
82       pred += weights_x[x] * left[y];
83       pred += static_cast<uint8_t>(scale_value - weights_y[y]) * bottom_left;
84       pred += static_cast<uint8_t>(scale_value - weights_x[x]) * top_right;
85       // The maximum value of pred with the rounder is 2^9 * (2^bitdepth - 1)
86       // + 256. With the descale there's no need for saturation.
87       dst[x] = static_cast<Pixel>(
88           RightShiftWithRounding(pred, kSmoothWeightScale + 1));
89     }
90     dst += stride;
91   }
92 }
93 
94 // SmoothFuncs_C::SmoothVertical
95 template <int block_width, int block_height, typename Pixel>
SmoothVertical(void * const dest,ptrdiff_t stride,const void * const top_row,const void * const left_column)96 void SmoothFuncs_C<block_width, block_height, Pixel>::SmoothVertical(
97     void* const dest, ptrdiff_t stride, const void* const top_row,
98     const void* const left_column) {
99   const auto* const top = static_cast<const Pixel*>(top_row);
100   const auto* const left = static_cast<const Pixel*>(left_column);
101   const Pixel bottom_left = left[block_height - 1];
102   static_assert(block_height >= 4,
103                 "Weights for smooth predictor undefined for block height < 4");
104   const uint8_t* const weights_y = kSmoothWeights + block_height - 4;
105   const uint16_t scale_value = (1 << kSmoothWeightScale);
106   auto* dst = static_cast<Pixel*>(dest);
107   stride /= sizeof(Pixel);
108 
109   for (int y = 0; y < block_height; ++y) {
110     for (int x = 0; x < block_width; ++x) {
111       assert(scale_value >= weights_y[y]);
112       uint32_t pred = weights_y[y] * top[x];
113       pred += static_cast<uint8_t>(scale_value - weights_y[y]) * bottom_left;
114       dst[x] =
115           static_cast<Pixel>(RightShiftWithRounding(pred, kSmoothWeightScale));
116     }
117     dst += stride;
118   }
119 }
120 
121 // SmoothFuncs_C::SmoothHorizontal
122 template <int block_width, int block_height, typename Pixel>
SmoothHorizontal(void * const dest,ptrdiff_t stride,const void * const top_row,const void * const left_column)123 void SmoothFuncs_C<block_width, block_height, Pixel>::SmoothHorizontal(
124     void* const dest, ptrdiff_t stride, const void* const top_row,
125     const void* const left_column) {
126   const auto* const top = static_cast<const Pixel*>(top_row);
127   const auto* const left = static_cast<const Pixel*>(left_column);
128   const Pixel top_right = top[block_width - 1];
129   static_assert(block_width >= 4,
130                 "Weights for smooth predictor undefined for block width < 4");
131   const uint8_t* const weights_x = kSmoothWeights + block_width - 4;
132   const uint16_t scale_value = (1 << kSmoothWeightScale);
133   auto* dst = static_cast<Pixel*>(dest);
134   stride /= sizeof(Pixel);
135 
136   for (int y = 0; y < block_height; ++y) {
137     for (int x = 0; x < block_width; ++x) {
138       assert(scale_value >= weights_x[x]);
139       uint32_t pred = weights_x[x] * left[y];
140       pred += static_cast<uint8_t>(scale_value - weights_x[x]) * top_right;
141       dst[x] =
142           static_cast<Pixel>(RightShiftWithRounding(pred, kSmoothWeightScale));
143     }
144     dst += stride;
145   }
146 }
147 
148 // -----------------------------------------------------------------------------
149 
150 template <typename Pixel>
151 struct SmoothDefs {
152   SmoothDefs() = delete;
153 
154   using _4x4 = SmoothFuncs_C<4, 4, Pixel>;
155   using _4x8 = SmoothFuncs_C<4, 8, Pixel>;
156   using _4x16 = SmoothFuncs_C<4, 16, Pixel>;
157   using _8x4 = SmoothFuncs_C<8, 4, Pixel>;
158   using _8x8 = SmoothFuncs_C<8, 8, Pixel>;
159   using _8x16 = SmoothFuncs_C<8, 16, Pixel>;
160   using _8x32 = SmoothFuncs_C<8, 32, Pixel>;
161   using _16x4 = SmoothFuncs_C<16, 4, Pixel>;
162   using _16x8 = SmoothFuncs_C<16, 8, Pixel>;
163   using _16x16 = SmoothFuncs_C<16, 16, Pixel>;
164   using _16x32 = SmoothFuncs_C<16, 32, Pixel>;
165   using _16x64 = SmoothFuncs_C<16, 64, Pixel>;
166   using _32x8 = SmoothFuncs_C<32, 8, Pixel>;
167   using _32x16 = SmoothFuncs_C<32, 16, Pixel>;
168   using _32x32 = SmoothFuncs_C<32, 32, Pixel>;
169   using _32x64 = SmoothFuncs_C<32, 64, Pixel>;
170   using _64x16 = SmoothFuncs_C<64, 16, Pixel>;
171   using _64x32 = SmoothFuncs_C<64, 32, Pixel>;
172   using _64x64 = SmoothFuncs_C<64, 64, Pixel>;
173 };
174 
175 using Defs = SmoothDefs<uint8_t>;
176 
177 // Initializes dsp entries for kTransformSize|W|x|H| from |DEFS| of
178 // the same size.
179 #define INIT_SMOOTH_WxH(DEFS, W, H)                                       \
180   dsp->intra_predictors[kTransformSize##W##x##H][kIntraPredictorSmooth] = \
181       DEFS::_##W##x##H::Smooth;                                           \
182   dsp->intra_predictors[kTransformSize##W##x##H]                          \
183                        [kIntraPredictorSmoothVertical] =                  \
184       DEFS::_##W##x##H::SmoothVertical;                                   \
185   dsp->intra_predictors[kTransformSize##W##x##H]                          \
186                        [kIntraPredictorSmoothHorizontal] =                \
187       DEFS::_##W##x##H::SmoothHorizontal
188 
189 #define INIT_SMOOTH(DEFS)        \
190   INIT_SMOOTH_WxH(DEFS, 4, 4);   \
191   INIT_SMOOTH_WxH(DEFS, 4, 8);   \
192   INIT_SMOOTH_WxH(DEFS, 4, 16);  \
193   INIT_SMOOTH_WxH(DEFS, 8, 4);   \
194   INIT_SMOOTH_WxH(DEFS, 8, 8);   \
195   INIT_SMOOTH_WxH(DEFS, 8, 16);  \
196   INIT_SMOOTH_WxH(DEFS, 8, 32);  \
197   INIT_SMOOTH_WxH(DEFS, 16, 4);  \
198   INIT_SMOOTH_WxH(DEFS, 16, 8);  \
199   INIT_SMOOTH_WxH(DEFS, 16, 16); \
200   INIT_SMOOTH_WxH(DEFS, 16, 32); \
201   INIT_SMOOTH_WxH(DEFS, 16, 64); \
202   INIT_SMOOTH_WxH(DEFS, 32, 8);  \
203   INIT_SMOOTH_WxH(DEFS, 32, 16); \
204   INIT_SMOOTH_WxH(DEFS, 32, 32); \
205   INIT_SMOOTH_WxH(DEFS, 32, 64); \
206   INIT_SMOOTH_WxH(DEFS, 64, 16); \
207   INIT_SMOOTH_WxH(DEFS, 64, 32); \
208   INIT_SMOOTH_WxH(DEFS, 64, 64)
209 
Init8bpp()210 void Init8bpp() {
211   Dsp* const dsp = dsp_internal::GetWritableDspTable(8);
212   assert(dsp != nullptr);
213 #if LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
214   INIT_SMOOTH(Defs);
215 #else  // !LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
216   static_cast<void>(dsp);
217 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x4_IntraPredictorSmooth
218   dsp->intra_predictors[kTransformSize4x4][kIntraPredictorSmooth] =
219       Defs::_4x4::Smooth;
220 #endif
221 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x4_IntraPredictorSmoothVertical
222   dsp->intra_predictors[kTransformSize4x4][kIntraPredictorSmoothVertical] =
223       Defs::_4x4::SmoothVertical;
224 #endif
225 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x4_IntraPredictorSmoothHorizontal
226   dsp->intra_predictors[kTransformSize4x4][kIntraPredictorSmoothHorizontal] =
227       Defs::_4x4::SmoothHorizontal;
228 #endif
229 
230 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x8_IntraPredictorSmooth
231   dsp->intra_predictors[kTransformSize4x8][kIntraPredictorSmooth] =
232       Defs::_4x8::Smooth;
233 #endif
234 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x8_IntraPredictorSmoothVertical
235   dsp->intra_predictors[kTransformSize4x8][kIntraPredictorSmoothVertical] =
236       Defs::_4x8::SmoothVertical;
237 #endif
238 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x8_IntraPredictorSmoothHorizontal
239   dsp->intra_predictors[kTransformSize4x8][kIntraPredictorSmoothHorizontal] =
240       Defs::_4x8::SmoothHorizontal;
241 #endif
242 
243 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x16_IntraPredictorSmooth
244   dsp->intra_predictors[kTransformSize4x16][kIntraPredictorSmooth] =
245       Defs::_4x16::Smooth;
246 #endif
247 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x16_IntraPredictorSmoothVertical
248   dsp->intra_predictors[kTransformSize4x16][kIntraPredictorSmoothVertical] =
249       Defs::_4x16::SmoothVertical;
250 #endif
251 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x16_IntraPredictorSmoothHorizontal
252   dsp->intra_predictors[kTransformSize4x16][kIntraPredictorSmoothHorizontal] =
253       Defs::_4x16::SmoothHorizontal;
254 #endif
255 
256 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x4_IntraPredictorSmooth
257   dsp->intra_predictors[kTransformSize8x4][kIntraPredictorSmooth] =
258       Defs::_8x4::Smooth;
259 #endif
260 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x4_IntraPredictorSmoothVertical
261   dsp->intra_predictors[kTransformSize8x4][kIntraPredictorSmoothVertical] =
262       Defs::_8x4::SmoothVertical;
263 #endif
264 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x4_IntraPredictorSmoothHorizontal
265   dsp->intra_predictors[kTransformSize8x4][kIntraPredictorSmoothHorizontal] =
266       Defs::_8x4::SmoothHorizontal;
267 #endif
268 
269 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x8_IntraPredictorSmooth
270   dsp->intra_predictors[kTransformSize8x8][kIntraPredictorSmooth] =
271       Defs::_8x8::Smooth;
272 #endif
273 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x8_IntraPredictorSmoothVertical
274   dsp->intra_predictors[kTransformSize8x8][kIntraPredictorSmoothVertical] =
275       Defs::_8x8::SmoothVertical;
276 #endif
277 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x8_IntraPredictorSmoothHorizontal
278   dsp->intra_predictors[kTransformSize8x8][kIntraPredictorSmoothHorizontal] =
279       Defs::_8x8::SmoothHorizontal;
280 #endif
281 
282 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x16_IntraPredictorSmooth
283   dsp->intra_predictors[kTransformSize8x16][kIntraPredictorSmooth] =
284       Defs::_8x16::Smooth;
285 #endif
286 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x16_IntraPredictorSmoothVertical
287   dsp->intra_predictors[kTransformSize8x16][kIntraPredictorSmoothVertical] =
288       Defs::_8x16::SmoothVertical;
289 #endif
290 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x16_IntraPredictorSmoothHorizontal
291   dsp->intra_predictors[kTransformSize8x16][kIntraPredictorSmoothHorizontal] =
292       Defs::_8x16::SmoothHorizontal;
293 #endif
294 
295 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x32_IntraPredictorSmooth
296   dsp->intra_predictors[kTransformSize8x32][kIntraPredictorSmooth] =
297       Defs::_8x32::Smooth;
298 #endif
299 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x32_IntraPredictorSmoothVertical
300   dsp->intra_predictors[kTransformSize8x32][kIntraPredictorSmoothVertical] =
301       Defs::_8x32::SmoothVertical;
302 #endif
303 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x32_IntraPredictorSmoothHorizontal
304   dsp->intra_predictors[kTransformSize8x32][kIntraPredictorSmoothHorizontal] =
305       Defs::_8x32::SmoothHorizontal;
306 #endif
307 
308 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x4_IntraPredictorSmooth
309   dsp->intra_predictors[kTransformSize16x4][kIntraPredictorSmooth] =
310       Defs::_16x4::Smooth;
311 #endif
312 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x4_IntraPredictorSmoothVertical
313   dsp->intra_predictors[kTransformSize16x4][kIntraPredictorSmoothVertical] =
314       Defs::_16x4::SmoothVertical;
315 #endif
316 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x4_IntraPredictorSmoothHorizontal
317   dsp->intra_predictors[kTransformSize16x4][kIntraPredictorSmoothHorizontal] =
318       Defs::_16x4::SmoothHorizontal;
319 #endif
320 
321 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x8_IntraPredictorSmooth
322   dsp->intra_predictors[kTransformSize16x8][kIntraPredictorSmooth] =
323       Defs::_16x8::Smooth;
324 #endif
325 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x8_IntraPredictorSmoothVertical
326   dsp->intra_predictors[kTransformSize16x8][kIntraPredictorSmoothVertical] =
327       Defs::_16x8::SmoothVertical;
328 #endif
329 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x8_IntraPredictorSmoothHorizontal
330   dsp->intra_predictors[kTransformSize16x8][kIntraPredictorSmoothHorizontal] =
331       Defs::_16x8::SmoothHorizontal;
332 #endif
333 
334 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x16_IntraPredictorSmooth
335   dsp->intra_predictors[kTransformSize16x16][kIntraPredictorSmooth] =
336       Defs::_16x16::Smooth;
337 #endif
338 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x16_IntraPredictorSmoothVertical
339   dsp->intra_predictors[kTransformSize16x16][kIntraPredictorSmoothVertical] =
340       Defs::_16x16::SmoothVertical;
341 #endif
342 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x16_IntraPredictorSmoothHorizontal
343   dsp->intra_predictors[kTransformSize16x16][kIntraPredictorSmoothHorizontal] =
344       Defs::_16x16::SmoothHorizontal;
345 #endif
346 
347 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x32_IntraPredictorSmooth
348   dsp->intra_predictors[kTransformSize16x32][kIntraPredictorSmooth] =
349       Defs::_16x32::Smooth;
350 #endif
351 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x32_IntraPredictorSmoothVertical
352   dsp->intra_predictors[kTransformSize16x32][kIntraPredictorSmoothVertical] =
353       Defs::_16x32::SmoothVertical;
354 #endif
355 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x32_IntraPredictorSmoothHorizontal
356   dsp->intra_predictors[kTransformSize16x32][kIntraPredictorSmoothHorizontal] =
357       Defs::_16x32::SmoothHorizontal;
358 #endif
359 
360 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x64_IntraPredictorSmooth
361   dsp->intra_predictors[kTransformSize16x64][kIntraPredictorSmooth] =
362       Defs::_16x64::Smooth;
363 #endif
364 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x64_IntraPredictorSmoothVertical
365   dsp->intra_predictors[kTransformSize16x64][kIntraPredictorSmoothVertical] =
366       Defs::_16x64::SmoothVertical;
367 #endif
368 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x64_IntraPredictorSmoothHorizontal
369   dsp->intra_predictors[kTransformSize16x64][kIntraPredictorSmoothHorizontal] =
370       Defs::_16x64::SmoothHorizontal;
371 #endif
372 
373 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x8_IntraPredictorSmooth
374   dsp->intra_predictors[kTransformSize32x8][kIntraPredictorSmooth] =
375       Defs::_32x8::Smooth;
376 #endif
377 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x8_IntraPredictorSmoothVertical
378   dsp->intra_predictors[kTransformSize32x8][kIntraPredictorSmoothVertical] =
379       Defs::_32x8::SmoothVertical;
380 #endif
381 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x8_IntraPredictorSmoothHorizontal
382   dsp->intra_predictors[kTransformSize32x8][kIntraPredictorSmoothHorizontal] =
383       Defs::_32x8::SmoothHorizontal;
384 #endif
385 
386 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x16_IntraPredictorSmooth
387   dsp->intra_predictors[kTransformSize32x16][kIntraPredictorSmooth] =
388       Defs::_32x16::Smooth;
389 #endif
390 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x16_IntraPredictorSmoothVertical
391   dsp->intra_predictors[kTransformSize32x16][kIntraPredictorSmoothVertical] =
392       Defs::_32x16::SmoothVertical;
393 #endif
394 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x16_IntraPredictorSmoothHorizontal
395   dsp->intra_predictors[kTransformSize32x16][kIntraPredictorSmoothHorizontal] =
396       Defs::_32x16::SmoothHorizontal;
397 #endif
398 
399 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x32_IntraPredictorSmooth
400   dsp->intra_predictors[kTransformSize32x32][kIntraPredictorSmooth] =
401       Defs::_32x32::Smooth;
402 #endif
403 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x32_IntraPredictorSmoothVertical
404   dsp->intra_predictors[kTransformSize32x32][kIntraPredictorSmoothVertical] =
405       Defs::_32x32::SmoothVertical;
406 #endif
407 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x32_IntraPredictorSmoothHorizontal
408   dsp->intra_predictors[kTransformSize32x32][kIntraPredictorSmoothHorizontal] =
409       Defs::_32x32::SmoothHorizontal;
410 #endif
411 
412 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x64_IntraPredictorSmooth
413   dsp->intra_predictors[kTransformSize32x64][kIntraPredictorSmooth] =
414       Defs::_32x64::Smooth;
415 #endif
416 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x64_IntraPredictorSmoothVertical
417   dsp->intra_predictors[kTransformSize32x64][kIntraPredictorSmoothVertical] =
418       Defs::_32x64::SmoothVertical;
419 #endif
420 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x64_IntraPredictorSmoothHorizontal
421   dsp->intra_predictors[kTransformSize32x64][kIntraPredictorSmoothHorizontal] =
422       Defs::_32x64::SmoothHorizontal;
423 #endif
424 
425 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x16_IntraPredictorSmooth
426   dsp->intra_predictors[kTransformSize64x16][kIntraPredictorSmooth] =
427       Defs::_64x16::Smooth;
428 #endif
429 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x16_IntraPredictorSmoothVertical
430   dsp->intra_predictors[kTransformSize64x16][kIntraPredictorSmoothVertical] =
431       Defs::_64x16::SmoothVertical;
432 #endif
433 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x16_IntraPredictorSmoothHorizontal
434   dsp->intra_predictors[kTransformSize64x16][kIntraPredictorSmoothHorizontal] =
435       Defs::_64x16::SmoothHorizontal;
436 #endif
437 
438 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x32_IntraPredictorSmooth
439   dsp->intra_predictors[kTransformSize64x32][kIntraPredictorSmooth] =
440       Defs::_64x32::Smooth;
441 #endif
442 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x32_IntraPredictorSmoothVertical
443   dsp->intra_predictors[kTransformSize64x32][kIntraPredictorSmoothVertical] =
444       Defs::_64x32::SmoothVertical;
445 #endif
446 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x32_IntraPredictorSmoothHorizontal
447   dsp->intra_predictors[kTransformSize64x32][kIntraPredictorSmoothHorizontal] =
448       Defs::_64x32::SmoothHorizontal;
449 #endif
450 
451 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x64_IntraPredictorSmooth
452   dsp->intra_predictors[kTransformSize64x64][kIntraPredictorSmooth] =
453       Defs::_64x64::Smooth;
454 #endif
455 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x64_IntraPredictorSmoothVertical
456   dsp->intra_predictors[kTransformSize64x64][kIntraPredictorSmoothVertical] =
457       Defs::_64x64::SmoothVertical;
458 #endif
459 #ifndef LIBGAV1_Dsp8bpp_TransformSize64x64_IntraPredictorSmoothHorizontal
460   dsp->intra_predictors[kTransformSize64x64][kIntraPredictorSmoothHorizontal] =
461       Defs::_64x64::SmoothHorizontal;
462 #endif
463 #endif  // LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
464 }  // NOLINT(readability/fn_size)
465 
466 #if LIBGAV1_MAX_BITDEPTH >= 10
467 using DefsHbd = SmoothDefs<uint16_t>;
468 
Init10bpp()469 void Init10bpp() {
470   Dsp* const dsp = dsp_internal::GetWritableDspTable(10);
471   assert(dsp != nullptr);
472 #if LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
473   INIT_SMOOTH(DefsHbd);
474 #else  // !LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
475   static_cast<void>(dsp);
476 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x4_IntraPredictorSmooth
477   dsp->intra_predictors[kTransformSize4x4][kIntraPredictorSmooth] =
478       DefsHbd::_4x4::Smooth;
479 #endif
480 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x4_IntraPredictorSmoothVertical
481   dsp->intra_predictors[kTransformSize4x4][kIntraPredictorSmoothVertical] =
482       DefsHbd::_4x4::SmoothVertical;
483 #endif
484 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x4_IntraPredictorSmoothHorizontal
485   dsp->intra_predictors[kTransformSize4x4][kIntraPredictorSmoothHorizontal] =
486       DefsHbd::_4x4::SmoothHorizontal;
487 #endif
488 
489 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x8_IntraPredictorSmooth
490   dsp->intra_predictors[kTransformSize4x8][kIntraPredictorSmooth] =
491       DefsHbd::_4x8::Smooth;
492 #endif
493 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x8_IntraPredictorSmoothVertical
494   dsp->intra_predictors[kTransformSize4x8][kIntraPredictorSmoothVertical] =
495       DefsHbd::_4x8::SmoothVertical;
496 #endif
497 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x8_IntraPredictorSmoothHorizontal
498   dsp->intra_predictors[kTransformSize4x8][kIntraPredictorSmoothHorizontal] =
499       DefsHbd::_4x8::SmoothHorizontal;
500 #endif
501 
502 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x16_IntraPredictorSmooth
503   dsp->intra_predictors[kTransformSize4x16][kIntraPredictorSmooth] =
504       DefsHbd::_4x16::Smooth;
505 #endif
506 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x16_IntraPredictorSmoothVertical
507   dsp->intra_predictors[kTransformSize4x16][kIntraPredictorSmoothVertical] =
508       DefsHbd::_4x16::SmoothVertical;
509 #endif
510 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x16_IntraPredictorSmoothHorizontal
511   dsp->intra_predictors[kTransformSize4x16][kIntraPredictorSmoothHorizontal] =
512       DefsHbd::_4x16::SmoothHorizontal;
513 #endif
514 
515 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x4_IntraPredictorSmooth
516   dsp->intra_predictors[kTransformSize8x4][kIntraPredictorSmooth] =
517       DefsHbd::_8x4::Smooth;
518 #endif
519 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x4_IntraPredictorSmoothVertical
520   dsp->intra_predictors[kTransformSize8x4][kIntraPredictorSmoothVertical] =
521       DefsHbd::_8x4::SmoothVertical;
522 #endif
523 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x4_IntraPredictorSmoothHorizontal
524   dsp->intra_predictors[kTransformSize8x4][kIntraPredictorSmoothHorizontal] =
525       DefsHbd::_8x4::SmoothHorizontal;
526 #endif
527 
528 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x8_IntraPredictorSmooth
529   dsp->intra_predictors[kTransformSize8x8][kIntraPredictorSmooth] =
530       DefsHbd::_8x8::Smooth;
531 #endif
532 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x8_IntraPredictorSmoothVertical
533   dsp->intra_predictors[kTransformSize8x8][kIntraPredictorSmoothVertical] =
534       DefsHbd::_8x8::SmoothVertical;
535 #endif
536 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x8_IntraPredictorSmoothHorizontal
537   dsp->intra_predictors[kTransformSize8x8][kIntraPredictorSmoothHorizontal] =
538       DefsHbd::_8x8::SmoothHorizontal;
539 #endif
540 
541 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x16_IntraPredictorSmooth
542   dsp->intra_predictors[kTransformSize8x16][kIntraPredictorSmooth] =
543       DefsHbd::_8x16::Smooth;
544 #endif
545 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x16_IntraPredictorSmoothVertical
546   dsp->intra_predictors[kTransformSize8x16][kIntraPredictorSmoothVertical] =
547       DefsHbd::_8x16::SmoothVertical;
548 #endif
549 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x16_IntraPredictorSmoothHorizontal
550   dsp->intra_predictors[kTransformSize8x16][kIntraPredictorSmoothHorizontal] =
551       DefsHbd::_8x16::SmoothHorizontal;
552 #endif
553 
554 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x32_IntraPredictorSmooth
555   dsp->intra_predictors[kTransformSize8x32][kIntraPredictorSmooth] =
556       DefsHbd::_8x32::Smooth;
557 #endif
558 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x32_IntraPredictorSmoothVertical
559   dsp->intra_predictors[kTransformSize8x32][kIntraPredictorSmoothVertical] =
560       DefsHbd::_8x32::SmoothVertical;
561 #endif
562 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x32_IntraPredictorSmoothHorizontal
563   dsp->intra_predictors[kTransformSize8x32][kIntraPredictorSmoothHorizontal] =
564       DefsHbd::_8x32::SmoothHorizontal;
565 #endif
566 
567 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x4_IntraPredictorSmooth
568   dsp->intra_predictors[kTransformSize16x4][kIntraPredictorSmooth] =
569       DefsHbd::_16x4::Smooth;
570 #endif
571 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x4_IntraPredictorSmoothVertical
572   dsp->intra_predictors[kTransformSize16x4][kIntraPredictorSmoothVertical] =
573       DefsHbd::_16x4::SmoothVertical;
574 #endif
575 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x4_IntraPredictorSmoothHorizontal
576   dsp->intra_predictors[kTransformSize16x4][kIntraPredictorSmoothHorizontal] =
577       DefsHbd::_16x4::SmoothHorizontal;
578 #endif
579 
580 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x8_IntraPredictorSmooth
581   dsp->intra_predictors[kTransformSize16x8][kIntraPredictorSmooth] =
582       DefsHbd::_16x8::Smooth;
583 #endif
584 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x8_IntraPredictorSmoothVertical
585   dsp->intra_predictors[kTransformSize16x8][kIntraPredictorSmoothVertical] =
586       DefsHbd::_16x8::SmoothVertical;
587 #endif
588 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x8_IntraPredictorSmoothHorizontal
589   dsp->intra_predictors[kTransformSize16x8][kIntraPredictorSmoothHorizontal] =
590       DefsHbd::_16x8::SmoothHorizontal;
591 #endif
592 
593 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x16_IntraPredictorSmooth
594   dsp->intra_predictors[kTransformSize16x16][kIntraPredictorSmooth] =
595       DefsHbd::_16x16::Smooth;
596 #endif
597 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x16_IntraPredictorSmoothVertical
598   dsp->intra_predictors[kTransformSize16x16][kIntraPredictorSmoothVertical] =
599       DefsHbd::_16x16::SmoothVertical;
600 #endif
601 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x16_IntraPredictorSmoothHorizontal
602   dsp->intra_predictors[kTransformSize16x16][kIntraPredictorSmoothHorizontal] =
603       DefsHbd::_16x16::SmoothHorizontal;
604 #endif
605 
606 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x32_IntraPredictorSmooth
607   dsp->intra_predictors[kTransformSize16x32][kIntraPredictorSmooth] =
608       DefsHbd::_16x32::Smooth;
609 #endif
610 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x32_IntraPredictorSmoothVertical
611   dsp->intra_predictors[kTransformSize16x32][kIntraPredictorSmoothVertical] =
612       DefsHbd::_16x32::SmoothVertical;
613 #endif
614 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x32_IntraPredictorSmoothHorizontal
615   dsp->intra_predictors[kTransformSize16x32][kIntraPredictorSmoothHorizontal] =
616       DefsHbd::_16x32::SmoothHorizontal;
617 #endif
618 
619 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x64_IntraPredictorSmooth
620   dsp->intra_predictors[kTransformSize16x64][kIntraPredictorSmooth] =
621       DefsHbd::_16x64::Smooth;
622 #endif
623 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x64_IntraPredictorSmoothVertical
624   dsp->intra_predictors[kTransformSize16x64][kIntraPredictorSmoothVertical] =
625       DefsHbd::_16x64::SmoothVertical;
626 #endif
627 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x64_IntraPredictorSmoothHorizontal
628   dsp->intra_predictors[kTransformSize16x64][kIntraPredictorSmoothHorizontal] =
629       DefsHbd::_16x64::SmoothHorizontal;
630 #endif
631 
632 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x8_IntraPredictorSmooth
633   dsp->intra_predictors[kTransformSize32x8][kIntraPredictorSmooth] =
634       DefsHbd::_32x8::Smooth;
635 #endif
636 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x8_IntraPredictorSmoothVertical
637   dsp->intra_predictors[kTransformSize32x8][kIntraPredictorSmoothVertical] =
638       DefsHbd::_32x8::SmoothVertical;
639 #endif
640 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x8_IntraPredictorSmoothHorizontal
641   dsp->intra_predictors[kTransformSize32x8][kIntraPredictorSmoothHorizontal] =
642       DefsHbd::_32x8::SmoothHorizontal;
643 #endif
644 
645 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x16_IntraPredictorSmooth
646   dsp->intra_predictors[kTransformSize32x16][kIntraPredictorSmooth] =
647       DefsHbd::_32x16::Smooth;
648 #endif
649 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x16_IntraPredictorSmoothVertical
650   dsp->intra_predictors[kTransformSize32x16][kIntraPredictorSmoothVertical] =
651       DefsHbd::_32x16::SmoothVertical;
652 #endif
653 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x16_IntraPredictorSmoothHorizontal
654   dsp->intra_predictors[kTransformSize32x16][kIntraPredictorSmoothHorizontal] =
655       DefsHbd::_32x16::SmoothHorizontal;
656 #endif
657 
658 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x32_IntraPredictorSmooth
659   dsp->intra_predictors[kTransformSize32x32][kIntraPredictorSmooth] =
660       DefsHbd::_32x32::Smooth;
661 #endif
662 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x32_IntraPredictorSmoothVertical
663   dsp->intra_predictors[kTransformSize32x32][kIntraPredictorSmoothVertical] =
664       DefsHbd::_32x32::SmoothVertical;
665 #endif
666 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x32_IntraPredictorSmoothHorizontal
667   dsp->intra_predictors[kTransformSize32x32][kIntraPredictorSmoothHorizontal] =
668       DefsHbd::_32x32::SmoothHorizontal;
669 #endif
670 
671 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x64_IntraPredictorSmooth
672   dsp->intra_predictors[kTransformSize32x64][kIntraPredictorSmooth] =
673       DefsHbd::_32x64::Smooth;
674 #endif
675 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x64_IntraPredictorSmoothVertical
676   dsp->intra_predictors[kTransformSize32x64][kIntraPredictorSmoothVertical] =
677       DefsHbd::_32x64::SmoothVertical;
678 #endif
679 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x64_IntraPredictorSmoothHorizontal
680   dsp->intra_predictors[kTransformSize32x64][kIntraPredictorSmoothHorizontal] =
681       DefsHbd::_32x64::SmoothHorizontal;
682 #endif
683 
684 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x16_IntraPredictorSmooth
685   dsp->intra_predictors[kTransformSize64x16][kIntraPredictorSmooth] =
686       DefsHbd::_64x16::Smooth;
687 #endif
688 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x16_IntraPredictorSmoothVertical
689   dsp->intra_predictors[kTransformSize64x16][kIntraPredictorSmoothVertical] =
690       DefsHbd::_64x16::SmoothVertical;
691 #endif
692 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x16_IntraPredictorSmoothHorizontal
693   dsp->intra_predictors[kTransformSize64x16][kIntraPredictorSmoothHorizontal] =
694       DefsHbd::_64x16::SmoothHorizontal;
695 #endif
696 
697 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x32_IntraPredictorSmooth
698   dsp->intra_predictors[kTransformSize64x32][kIntraPredictorSmooth] =
699       DefsHbd::_64x32::Smooth;
700 #endif
701 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x32_IntraPredictorSmoothVertical
702   dsp->intra_predictors[kTransformSize64x32][kIntraPredictorSmoothVertical] =
703       DefsHbd::_64x32::SmoothVertical;
704 #endif
705 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x32_IntraPredictorSmoothHorizontal
706   dsp->intra_predictors[kTransformSize64x32][kIntraPredictorSmoothHorizontal] =
707       DefsHbd::_64x32::SmoothHorizontal;
708 #endif
709 
710 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x64_IntraPredictorSmooth
711   dsp->intra_predictors[kTransformSize64x64][kIntraPredictorSmooth] =
712       DefsHbd::_64x64::Smooth;
713 #endif
714 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x64_IntraPredictorSmoothVertical
715   dsp->intra_predictors[kTransformSize64x64][kIntraPredictorSmoothVertical] =
716       DefsHbd::_64x64::SmoothVertical;
717 #endif
718 #ifndef LIBGAV1_Dsp10bpp_TransformSize64x64_IntraPredictorSmoothHorizontal
719   dsp->intra_predictors[kTransformSize64x64][kIntraPredictorSmoothHorizontal] =
720       DefsHbd::_64x64::SmoothHorizontal;
721 #endif
722 #endif  // LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
723 }  // NOLINT(readability/fn_size)
724 #endif  // LIBGAV1_MAX_BITDEPTH >= 10
725 
726 #undef INIT_SMOOTH_WxH
727 #undef INIT_SMOOTH
728 }  // namespace
729 
IntraPredSmoothInit_C()730 void IntraPredSmoothInit_C() {
731   Init8bpp();
732 #if LIBGAV1_MAX_BITDEPTH >= 10
733   Init10bpp();
734 #endif
735 }
736 
737 }  // namespace dsp
738 }  // namespace libgav1
739