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_cfl.h"
16
17 #include <algorithm>
18 #include <cassert>
19 #include <cstddef>
20 #include <cstdint>
21 #include <cstdlib>
22 #include <cstring>
23
24 #include "src/dsp/constants.h"
25 #include "src/dsp/dsp.h"
26 #include "src/utils/common.h"
27 #include "src/utils/constants.h"
28
29 namespace libgav1 {
30 namespace dsp {
31 namespace {
32
33 constexpr TransformSize kTransformSizesLargerThan32x32[] = {
34 kTransformSize16x64, kTransformSize32x64, kTransformSize64x16,
35 kTransformSize64x32, kTransformSize64x64};
36
37 //------------------------------------------------------------------------------
38 // CflIntraPredictor_C
39
40 // |luma| can be within +/-(((1 << bitdepth) - 1) << 3), inclusive.
41 // |alpha| can be -16 to 16 (inclusive).
42 template <int block_width, int block_height, int bitdepth, typename Pixel>
CflIntraPredictor_C(void * const dest,ptrdiff_t stride,const int16_t luma[kCflLumaBufferStride][kCflLumaBufferStride],const int alpha)43 void CflIntraPredictor_C(
44 void* const dest, ptrdiff_t stride,
45 const int16_t luma[kCflLumaBufferStride][kCflLumaBufferStride],
46 const int alpha) {
47 auto* dst = static_cast<Pixel*>(dest);
48 const int dc = dst[0];
49 stride /= sizeof(Pixel);
50 const int max_value = (1 << bitdepth) - 1;
51 for (int y = 0; y < block_height; ++y) {
52 for (int x = 0; x < block_width; ++x) {
53 assert(luma[y][x] >= -(((1 << bitdepth) - 1) << 3));
54 assert(luma[y][x] <= ((1 << bitdepth) - 1) << 3);
55 dst[x] = Clip3(dc + RightShiftWithRoundingSigned(alpha * luma[y][x], 6),
56 0, max_value);
57 }
58 dst += stride;
59 }
60 }
61
62 //------------------------------------------------------------------------------
63 // CflSubsampler_C
64
65 template <int block_width, int block_height, int bitdepth, typename Pixel,
66 int subsampling_x, int subsampling_y>
CflSubsampler_C(int16_t luma[kCflLumaBufferStride][kCflLumaBufferStride],const int max_luma_width,const int max_luma_height,const void * const source,ptrdiff_t stride)67 void CflSubsampler_C(int16_t luma[kCflLumaBufferStride][kCflLumaBufferStride],
68 const int max_luma_width, const int max_luma_height,
69 const void* const source, ptrdiff_t stride) {
70 assert(max_luma_width >= 4);
71 assert(max_luma_height >= 4);
72 const auto* src = static_cast<const Pixel*>(source);
73 stride /= sizeof(Pixel);
74 int sum = 0;
75 for (int y = 0; y < block_height; ++y) {
76 for (int x = 0; x < block_width; ++x) {
77 const ptrdiff_t luma_x =
78 std::min(x << subsampling_x, max_luma_width - (1 << subsampling_x));
79 const ptrdiff_t luma_x_next = luma_x + stride;
80 luma[y][x] =
81 (src[luma_x] + ((subsampling_x != 0) ? src[luma_x + 1] : 0) +
82 ((subsampling_y != 0) ? (src[luma_x_next] + src[luma_x_next + 1])
83 : 0))
84 << (3 - subsampling_x - subsampling_y);
85 sum += luma[y][x];
86 }
87 if ((y << subsampling_y) < (max_luma_height - (1 << subsampling_y))) {
88 src += stride << subsampling_y;
89 }
90 }
91 const int average = RightShiftWithRounding(
92 sum, FloorLog2(block_width) + FloorLog2(block_height));
93 for (int y = 0; y < block_height; ++y) {
94 for (int x = 0; x < block_width; ++x) {
95 luma[y][x] -= average;
96 }
97 }
98 }
99
100 //------------------------------------------------------------------------------
101
102 // Initializes dsp entries for kTransformSize|W|x|H|.
103 #define INIT_CFL_INTRAPREDICTOR_WxH(W, H, BITDEPTH, PIXEL) \
104 dsp->cfl_intra_predictors[kTransformSize##W##x##H] = \
105 CflIntraPredictor_C<W, H, BITDEPTH, PIXEL>; \
106 dsp->cfl_subsamplers[kTransformSize##W##x##H][kSubsamplingType444] = \
107 CflSubsampler_C<W, H, BITDEPTH, PIXEL, 0, 0>; \
108 dsp->cfl_subsamplers[kTransformSize##W##x##H][kSubsamplingType422] = \
109 CflSubsampler_C<W, H, BITDEPTH, PIXEL, 1, 0>; \
110 dsp->cfl_subsamplers[kTransformSize##W##x##H][kSubsamplingType420] = \
111 CflSubsampler_C<W, H, BITDEPTH, PIXEL, 1, 1>
112
113 #define INIT_CFL_INTRAPREDICTORS(BITDEPTH, PIXEL) \
114 INIT_CFL_INTRAPREDICTOR_WxH(4, 4, BITDEPTH, PIXEL); \
115 INIT_CFL_INTRAPREDICTOR_WxH(4, 8, BITDEPTH, PIXEL); \
116 INIT_CFL_INTRAPREDICTOR_WxH(4, 16, BITDEPTH, PIXEL); \
117 INIT_CFL_INTRAPREDICTOR_WxH(8, 4, BITDEPTH, PIXEL); \
118 INIT_CFL_INTRAPREDICTOR_WxH(8, 8, BITDEPTH, PIXEL); \
119 INIT_CFL_INTRAPREDICTOR_WxH(8, 16, BITDEPTH, PIXEL); \
120 INIT_CFL_INTRAPREDICTOR_WxH(8, 32, BITDEPTH, PIXEL); \
121 INIT_CFL_INTRAPREDICTOR_WxH(16, 4, BITDEPTH, PIXEL); \
122 INIT_CFL_INTRAPREDICTOR_WxH(16, 8, BITDEPTH, PIXEL); \
123 INIT_CFL_INTRAPREDICTOR_WxH(16, 16, BITDEPTH, PIXEL); \
124 INIT_CFL_INTRAPREDICTOR_WxH(16, 32, BITDEPTH, PIXEL); \
125 INIT_CFL_INTRAPREDICTOR_WxH(32, 8, BITDEPTH, PIXEL); \
126 INIT_CFL_INTRAPREDICTOR_WxH(32, 16, BITDEPTH, PIXEL); \
127 INIT_CFL_INTRAPREDICTOR_WxH(32, 32, BITDEPTH, PIXEL)
128
Init8bpp()129 void Init8bpp() {
130 Dsp* const dsp = dsp_internal::GetWritableDspTable(8);
131 assert(dsp != nullptr);
132 #if LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
133 INIT_CFL_INTRAPREDICTORS(8, uint8_t);
134 #else // !LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
135 static_cast<void>(dsp);
136 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x4_CflIntraPredictor
137 dsp->cfl_intra_predictors[kTransformSize4x4] =
138 CflIntraPredictor_C<4, 4, 8, uint8_t>;
139 #endif
140 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x4_CflSubsampler444
141 dsp->cfl_subsamplers[kTransformSize4x4][kSubsamplingType444] =
142 CflSubsampler_C<4, 4, 8, uint8_t, 0, 0>;
143 #endif
144 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x4_CflSubsampler422
145 dsp->cfl_subsamplers[kTransformSize4x4][kSubsamplingType422] =
146 CflSubsampler_C<4, 4, 8, uint8_t, 1, 0>;
147 #endif
148 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x4_CflSubsampler420
149 dsp->cfl_subsamplers[kTransformSize4x4][kSubsamplingType420] =
150 CflSubsampler_C<4, 4, 8, uint8_t, 1, 1>;
151 #endif
152
153 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x8_CflIntraPredictor
154 dsp->cfl_intra_predictors[kTransformSize4x8] =
155 CflIntraPredictor_C<4, 8, 8, uint8_t>;
156 #endif
157 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x8_CflSubsampler444
158 dsp->cfl_subsamplers[kTransformSize4x8][kSubsamplingType444] =
159 CflSubsampler_C<4, 8, 8, uint8_t, 0, 0>;
160 #endif
161 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x8_CflSubsampler422
162 dsp->cfl_subsamplers[kTransformSize4x8][kSubsamplingType422] =
163 CflSubsampler_C<4, 8, 8, uint8_t, 1, 0>;
164 #endif
165 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x8_CflSubsampler420
166 dsp->cfl_subsamplers[kTransformSize4x8][kSubsamplingType420] =
167 CflSubsampler_C<4, 8, 8, uint8_t, 1, 1>;
168 #endif
169
170 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x16_CflIntraPredictor
171 dsp->cfl_intra_predictors[kTransformSize4x16] =
172 CflIntraPredictor_C<4, 16, 8, uint8_t>;
173 #endif
174 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x16_CflSubsampler444
175 dsp->cfl_subsamplers[kTransformSize4x16][kSubsamplingType444] =
176 CflSubsampler_C<4, 16, 8, uint8_t, 0, 0>;
177 #endif
178 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x16_CflSubsampler422
179 dsp->cfl_subsamplers[kTransformSize4x16][kSubsamplingType422] =
180 CflSubsampler_C<4, 16, 8, uint8_t, 1, 0>;
181 #endif
182 #ifndef LIBGAV1_Dsp8bpp_TransformSize4x16_CflSubsampler420
183 dsp->cfl_subsamplers[kTransformSize4x16][kSubsamplingType420] =
184 CflSubsampler_C<4, 16, 8, uint8_t, 1, 1>;
185 #endif
186
187 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x4_CflIntraPredictor
188 dsp->cfl_intra_predictors[kTransformSize8x4] =
189 CflIntraPredictor_C<8, 4, 8, uint8_t>;
190 #endif
191 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x4_CflSubsampler444
192 dsp->cfl_subsamplers[kTransformSize8x4][kSubsamplingType444] =
193 CflSubsampler_C<8, 4, 8, uint8_t, 0, 0>;
194 #endif
195 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x4_CflSubsampler422
196 dsp->cfl_subsamplers[kTransformSize8x4][kSubsamplingType422] =
197 CflSubsampler_C<8, 4, 8, uint8_t, 1, 0>;
198 #endif
199 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x4_CflSubsampler420
200 dsp->cfl_subsamplers[kTransformSize8x4][kSubsamplingType420] =
201 CflSubsampler_C<8, 4, 8, uint8_t, 1, 1>;
202 #endif
203
204 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x8_CflIntraPredictor
205 dsp->cfl_intra_predictors[kTransformSize8x8] =
206 CflIntraPredictor_C<8, 8, 8, uint8_t>;
207 #endif
208 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x8_CflSubsampler444
209 dsp->cfl_subsamplers[kTransformSize8x8][kSubsamplingType444] =
210 CflSubsampler_C<8, 8, 8, uint8_t, 0, 0>;
211 #endif
212 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x8_CflSubsampler422
213 dsp->cfl_subsamplers[kTransformSize8x8][kSubsamplingType422] =
214 CflSubsampler_C<8, 8, 8, uint8_t, 1, 0>;
215 #endif
216 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x8_CflSubsampler420
217 dsp->cfl_subsamplers[kTransformSize8x8][kSubsamplingType420] =
218 CflSubsampler_C<8, 8, 8, uint8_t, 1, 1>;
219 #endif
220
221 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x16_CflIntraPredictor
222 dsp->cfl_intra_predictors[kTransformSize8x16] =
223 CflIntraPredictor_C<8, 16, 8, uint8_t>;
224 #endif
225 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x16_CflSubsampler444
226 dsp->cfl_subsamplers[kTransformSize8x16][kSubsamplingType444] =
227 CflSubsampler_C<8, 16, 8, uint8_t, 0, 0>;
228 #endif
229 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x16_CflSubsampler422
230 dsp->cfl_subsamplers[kTransformSize8x16][kSubsamplingType422] =
231 CflSubsampler_C<8, 16, 8, uint8_t, 1, 0>;
232 #endif
233 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x16_CflSubsampler420
234 dsp->cfl_subsamplers[kTransformSize8x16][kSubsamplingType420] =
235 CflSubsampler_C<8, 16, 8, uint8_t, 1, 1>;
236 #endif
237
238 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x32_CflIntraPredictor
239 dsp->cfl_intra_predictors[kTransformSize8x32] =
240 CflIntraPredictor_C<8, 32, 8, uint8_t>;
241 #endif
242 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x32_CflSubsampler444
243 dsp->cfl_subsamplers[kTransformSize8x32][kSubsamplingType444] =
244 CflSubsampler_C<8, 32, 8, uint8_t, 0, 0>;
245 #endif
246 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x32_CflSubsampler422
247 dsp->cfl_subsamplers[kTransformSize8x32][kSubsamplingType422] =
248 CflSubsampler_C<8, 32, 8, uint8_t, 1, 0>;
249 #endif
250 #ifndef LIBGAV1_Dsp8bpp_TransformSize8x32_CflSubsampler420
251 dsp->cfl_subsamplers[kTransformSize8x32][kSubsamplingType420] =
252 CflSubsampler_C<8, 32, 8, uint8_t, 1, 1>;
253 #endif
254
255 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x4_CflIntraPredictor
256 dsp->cfl_intra_predictors[kTransformSize16x4] =
257 CflIntraPredictor_C<16, 4, 8, uint8_t>;
258 #endif
259 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x4_CflSubsampler444
260 dsp->cfl_subsamplers[kTransformSize16x4][kSubsamplingType444] =
261 CflSubsampler_C<16, 4, 8, uint8_t, 0, 0>;
262 #endif
263 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x4_CflSubsampler422
264 dsp->cfl_subsamplers[kTransformSize16x4][kSubsamplingType422] =
265 CflSubsampler_C<16, 4, 8, uint8_t, 1, 0>;
266 #endif
267 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x4_CflSubsampler420
268 dsp->cfl_subsamplers[kTransformSize16x4][kSubsamplingType420] =
269 CflSubsampler_C<16, 4, 8, uint8_t, 1, 1>;
270 #endif
271
272 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x8_CflIntraPredictor
273 dsp->cfl_intra_predictors[kTransformSize16x8] =
274 CflIntraPredictor_C<16, 8, 8, uint8_t>;
275 #endif
276 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x8_CflSubsampler444
277 dsp->cfl_subsamplers[kTransformSize16x8][kSubsamplingType444] =
278 CflSubsampler_C<16, 8, 8, uint8_t, 0, 0>;
279 #endif
280 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x8_CflSubsampler422
281 dsp->cfl_subsamplers[kTransformSize16x8][kSubsamplingType422] =
282 CflSubsampler_C<16, 8, 8, uint8_t, 1, 0>;
283 #endif
284 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x8_CflSubsampler420
285 dsp->cfl_subsamplers[kTransformSize16x8][kSubsamplingType420] =
286 CflSubsampler_C<16, 8, 8, uint8_t, 1, 1>;
287 #endif
288
289 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x16_CflIntraPredictor
290 dsp->cfl_intra_predictors[kTransformSize16x16] =
291 CflIntraPredictor_C<16, 16, 8, uint8_t>;
292 #endif
293 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x16_CflSubsampler444
294 dsp->cfl_subsamplers[kTransformSize16x16][kSubsamplingType444] =
295 CflSubsampler_C<16, 16, 8, uint8_t, 0, 0>;
296 #endif
297 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x16_CflSubsampler422
298 dsp->cfl_subsamplers[kTransformSize16x16][kSubsamplingType422] =
299 CflSubsampler_C<16, 16, 8, uint8_t, 1, 0>;
300 #endif
301 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x16_CflSubsampler420
302 dsp->cfl_subsamplers[kTransformSize16x16][kSubsamplingType420] =
303 CflSubsampler_C<16, 16, 8, uint8_t, 1, 1>;
304 #endif
305
306 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x32_CflIntraPredictor
307 dsp->cfl_intra_predictors[kTransformSize16x32] =
308 CflIntraPredictor_C<16, 32, 8, uint8_t>;
309 #endif
310 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x32_CflSubsampler444
311 dsp->cfl_subsamplers[kTransformSize16x32][kSubsamplingType444] =
312 CflSubsampler_C<16, 32, 8, uint8_t, 0, 0>;
313 #endif
314 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x32_CflSubsampler422
315 dsp->cfl_subsamplers[kTransformSize16x32][kSubsamplingType422] =
316 CflSubsampler_C<16, 32, 8, uint8_t, 1, 0>;
317 #endif
318 #ifndef LIBGAV1_Dsp8bpp_TransformSize16x32_CflSubsampler420
319 dsp->cfl_subsamplers[kTransformSize16x32][kSubsamplingType420] =
320 CflSubsampler_C<16, 32, 8, uint8_t, 1, 1>;
321 #endif
322
323 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x8_CflIntraPredictor
324 dsp->cfl_intra_predictors[kTransformSize32x8] =
325 CflIntraPredictor_C<32, 8, 8, uint8_t>;
326 #endif
327 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x8_CflSubsampler444
328 dsp->cfl_subsamplers[kTransformSize32x8][kSubsamplingType444] =
329 CflSubsampler_C<32, 8, 8, uint8_t, 0, 0>;
330 #endif
331 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x8_CflSubsampler422
332 dsp->cfl_subsamplers[kTransformSize32x8][kSubsamplingType422] =
333 CflSubsampler_C<32, 8, 8, uint8_t, 1, 0>;
334 #endif
335 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x8_CflSubsampler420
336 dsp->cfl_subsamplers[kTransformSize32x8][kSubsamplingType420] =
337 CflSubsampler_C<32, 8, 8, uint8_t, 1, 1>;
338 #endif
339
340 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x16_CflIntraPredictor
341 dsp->cfl_intra_predictors[kTransformSize32x16] =
342 CflIntraPredictor_C<32, 16, 8, uint8_t>;
343 #endif
344 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x16_CflSubsampler444
345 dsp->cfl_subsamplers[kTransformSize32x16][kSubsamplingType444] =
346 CflSubsampler_C<32, 16, 8, uint8_t, 0, 0>;
347 #endif
348 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x16_CflSubsampler422
349 dsp->cfl_subsamplers[kTransformSize32x16][kSubsamplingType422] =
350 CflSubsampler_C<32, 16, 8, uint8_t, 1, 0>;
351 #endif
352 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x16_CflSubsampler420
353 dsp->cfl_subsamplers[kTransformSize32x16][kSubsamplingType420] =
354 CflSubsampler_C<32, 16, 8, uint8_t, 1, 1>;
355 #endif
356
357 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x32_CflIntraPredictor
358 dsp->cfl_intra_predictors[kTransformSize32x32] =
359 CflIntraPredictor_C<32, 32, 8, uint8_t>;
360 #endif
361 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x32_CflSubsampler444
362 dsp->cfl_subsamplers[kTransformSize32x32][kSubsamplingType444] =
363 CflSubsampler_C<32, 32, 8, uint8_t, 0, 0>;
364 #endif
365 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x32_CflSubsampler422
366 dsp->cfl_subsamplers[kTransformSize32x32][kSubsamplingType422] =
367 CflSubsampler_C<32, 32, 8, uint8_t, 1, 0>;
368 #endif
369 #ifndef LIBGAV1_Dsp8bpp_TransformSize32x32_CflSubsampler420
370 dsp->cfl_subsamplers[kTransformSize32x32][kSubsamplingType420] =
371 CflSubsampler_C<32, 32, 8, uint8_t, 1, 1>;
372 #endif
373 #endif // LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
374 // Cfl predictors are available only for transform sizes with max(width,
375 // height) <= 32. Set all others to nullptr.
376 for (const auto i : kTransformSizesLargerThan32x32) {
377 dsp->cfl_intra_predictors[i] = nullptr;
378 for (int j = 0; j < kNumSubsamplingTypes; ++j) {
379 dsp->cfl_subsamplers[i][j] = nullptr;
380 }
381 }
382 } // NOLINT(readability/fn_size)
383
384 #if LIBGAV1_MAX_BITDEPTH >= 10
Init10bpp()385 void Init10bpp() {
386 Dsp* const dsp = dsp_internal::GetWritableDspTable(10);
387 assert(dsp != nullptr);
388 #if LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
389 INIT_CFL_INTRAPREDICTORS(10, uint16_t);
390 #else // !LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
391 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x4_CflIntraPredictor
392 dsp->cfl_intra_predictors[kTransformSize4x4] =
393 CflIntraPredictor_C<4, 4, 10, uint16_t>;
394 #endif
395 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x4_CflSubsampler444
396 dsp->cfl_subsamplers[kTransformSize4x4][kSubsamplingType444] =
397 CflSubsampler_C<4, 4, 10, uint16_t, 0, 0>;
398 #endif
399 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x4_CflSubsampler422
400 dsp->cfl_subsamplers[kTransformSize4x4][kSubsamplingType422] =
401 CflSubsampler_C<4, 4, 10, uint16_t, 1, 0>;
402 #endif
403 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x4_CflSubsampler420
404 dsp->cfl_subsamplers[kTransformSize4x4][kSubsamplingType420] =
405 CflSubsampler_C<4, 4, 10, uint16_t, 1, 1>;
406 #endif
407
408 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x8_CflIntraPredictor
409 dsp->cfl_intra_predictors[kTransformSize4x8] =
410 CflIntraPredictor_C<4, 8, 10, uint16_t>;
411 #endif
412 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x8_CflSubsampler444
413 dsp->cfl_subsamplers[kTransformSize4x8][kSubsamplingType444] =
414 CflSubsampler_C<4, 8, 10, uint16_t, 0, 0>;
415 #endif
416 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x8_CflSubsampler422
417 dsp->cfl_subsamplers[kTransformSize4x8][kSubsamplingType422] =
418 CflSubsampler_C<4, 8, 10, uint16_t, 1, 0>;
419 #endif
420 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x8_CflSubsampler420
421 dsp->cfl_subsamplers[kTransformSize4x8][kSubsamplingType420] =
422 CflSubsampler_C<4, 8, 10, uint16_t, 1, 1>;
423 #endif
424
425 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x16_CflIntraPredictor
426 dsp->cfl_intra_predictors[kTransformSize4x16] =
427 CflIntraPredictor_C<4, 16, 10, uint16_t>;
428 #endif
429 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x16_CflSubsampler444
430 dsp->cfl_subsamplers[kTransformSize4x16][kSubsamplingType444] =
431 CflSubsampler_C<4, 16, 10, uint16_t, 0, 0>;
432 #endif
433 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x16_CflSubsampler422
434 dsp->cfl_subsamplers[kTransformSize4x16][kSubsamplingType422] =
435 CflSubsampler_C<4, 16, 10, uint16_t, 1, 0>;
436 #endif
437 #ifndef LIBGAV1_Dsp10bpp_TransformSize4x16_CflSubsampler420
438 dsp->cfl_subsamplers[kTransformSize4x16][kSubsamplingType420] =
439 CflSubsampler_C<4, 16, 10, uint16_t, 1, 1>;
440 #endif
441
442 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x4_CflIntraPredictor
443 dsp->cfl_intra_predictors[kTransformSize8x4] =
444 CflIntraPredictor_C<8, 4, 10, uint16_t>;
445 #endif
446 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x4_CflSubsampler444
447 dsp->cfl_subsamplers[kTransformSize8x4][kSubsamplingType444] =
448 CflSubsampler_C<8, 4, 10, uint16_t, 0, 0>;
449 #endif
450 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x4_CflSubsampler422
451 dsp->cfl_subsamplers[kTransformSize8x4][kSubsamplingType422] =
452 CflSubsampler_C<8, 4, 10, uint16_t, 1, 0>;
453 #endif
454 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x4_CflSubsampler420
455 dsp->cfl_subsamplers[kTransformSize8x4][kSubsamplingType420] =
456 CflSubsampler_C<8, 4, 10, uint16_t, 1, 1>;
457 #endif
458
459 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x8_CflIntraPredictor
460 dsp->cfl_intra_predictors[kTransformSize8x8] =
461 CflIntraPredictor_C<8, 8, 10, uint16_t>;
462 #endif
463 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x8_CflSubsampler444
464 dsp->cfl_subsamplers[kTransformSize8x8][kSubsamplingType444] =
465 CflSubsampler_C<8, 8, 10, uint16_t, 0, 0>;
466 #endif
467 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x8_CflSubsampler422
468 dsp->cfl_subsamplers[kTransformSize8x8][kSubsamplingType422] =
469 CflSubsampler_C<8, 8, 10, uint16_t, 1, 0>;
470 #endif
471 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x8_CflSubsampler420
472 dsp->cfl_subsamplers[kTransformSize8x8][kSubsamplingType420] =
473 CflSubsampler_C<8, 8, 10, uint16_t, 1, 1>;
474 #endif
475
476 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x16_CflIntraPredictor
477 dsp->cfl_intra_predictors[kTransformSize8x16] =
478 CflIntraPredictor_C<8, 16, 10, uint16_t>;
479 #endif
480 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x16_CflSubsampler444
481 dsp->cfl_subsamplers[kTransformSize8x16][kSubsamplingType444] =
482 CflSubsampler_C<8, 16, 10, uint16_t, 0, 0>;
483 #endif
484 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x16_CflSubsampler422
485 dsp->cfl_subsamplers[kTransformSize8x16][kSubsamplingType422] =
486 CflSubsampler_C<8, 16, 10, uint16_t, 1, 0>;
487 #endif
488 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x16_CflSubsampler420
489 dsp->cfl_subsamplers[kTransformSize8x16][kSubsamplingType420] =
490 CflSubsampler_C<8, 16, 10, uint16_t, 1, 1>;
491 #endif
492
493 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x32_CflIntraPredictor
494 dsp->cfl_intra_predictors[kTransformSize8x32] =
495 CflIntraPredictor_C<8, 32, 10, uint16_t>;
496 #endif
497 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x32_CflSubsampler444
498 dsp->cfl_subsamplers[kTransformSize8x32][kSubsamplingType444] =
499 CflSubsampler_C<8, 32, 10, uint16_t, 0, 0>;
500 #endif
501 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x32_CflSubsampler422
502 dsp->cfl_subsamplers[kTransformSize8x32][kSubsamplingType422] =
503 CflSubsampler_C<8, 32, 10, uint16_t, 1, 0>;
504 #endif
505 #ifndef LIBGAV1_Dsp10bpp_TransformSize8x32_CflSubsampler420
506 dsp->cfl_subsamplers[kTransformSize8x32][kSubsamplingType420] =
507 CflSubsampler_C<8, 32, 10, uint16_t, 1, 1>;
508 #endif
509
510 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x4_CflIntraPredictor
511 dsp->cfl_intra_predictors[kTransformSize16x4] =
512 CflIntraPredictor_C<16, 4, 10, uint16_t>;
513 #endif
514 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x4_CflSubsampler444
515 dsp->cfl_subsamplers[kTransformSize16x4][kSubsamplingType444] =
516 CflSubsampler_C<16, 4, 10, uint16_t, 0, 0>;
517 #endif
518 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x4_CflSubsampler422
519 dsp->cfl_subsamplers[kTransformSize16x4][kSubsamplingType422] =
520 CflSubsampler_C<16, 4, 10, uint16_t, 1, 0>;
521 #endif
522 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x4_CflSubsampler420
523 dsp->cfl_subsamplers[kTransformSize16x4][kSubsamplingType420] =
524 CflSubsampler_C<16, 4, 10, uint16_t, 1, 1>;
525 #endif
526
527 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x8_CflIntraPredictor
528 dsp->cfl_intra_predictors[kTransformSize16x8] =
529 CflIntraPredictor_C<16, 8, 10, uint16_t>;
530 #endif
531 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x8_CflSubsampler444
532 dsp->cfl_subsamplers[kTransformSize16x8][kSubsamplingType444] =
533 CflSubsampler_C<16, 8, 10, uint16_t, 0, 0>;
534 #endif
535 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x8_CflSubsampler422
536 dsp->cfl_subsamplers[kTransformSize16x8][kSubsamplingType422] =
537 CflSubsampler_C<16, 8, 10, uint16_t, 1, 0>;
538 #endif
539 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x8_CflSubsampler420
540 dsp->cfl_subsamplers[kTransformSize16x8][kSubsamplingType420] =
541 CflSubsampler_C<16, 8, 10, uint16_t, 1, 1>;
542 #endif
543
544 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x16_CflIntraPredictor
545 dsp->cfl_intra_predictors[kTransformSize16x16] =
546 CflIntraPredictor_C<16, 16, 10, uint16_t>;
547 #endif
548 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x16_CflSubsampler444
549 dsp->cfl_subsamplers[kTransformSize16x16][kSubsamplingType444] =
550 CflSubsampler_C<16, 16, 10, uint16_t, 0, 0>;
551 #endif
552 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x16_CflSubsampler422
553 dsp->cfl_subsamplers[kTransformSize16x16][kSubsamplingType422] =
554 CflSubsampler_C<16, 16, 10, uint16_t, 1, 0>;
555 #endif
556 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x16_CflSubsampler420
557 dsp->cfl_subsamplers[kTransformSize16x16][kSubsamplingType420] =
558 CflSubsampler_C<16, 16, 10, uint16_t, 1, 1>;
559 #endif
560
561 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x32_CflIntraPredictor
562 dsp->cfl_intra_predictors[kTransformSize16x32] =
563 CflIntraPredictor_C<16, 32, 10, uint16_t>;
564 #endif
565 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x32_CflSubsampler444
566 dsp->cfl_subsamplers[kTransformSize16x32][kSubsamplingType444] =
567 CflSubsampler_C<16, 32, 10, uint16_t, 0, 0>;
568 #endif
569 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x32_CflSubsampler422
570 dsp->cfl_subsamplers[kTransformSize16x32][kSubsamplingType422] =
571 CflSubsampler_C<16, 32, 10, uint16_t, 1, 0>;
572 #endif
573 #ifndef LIBGAV1_Dsp10bpp_TransformSize16x32_CflSubsampler420
574 dsp->cfl_subsamplers[kTransformSize16x32][kSubsamplingType420] =
575 CflSubsampler_C<16, 32, 10, uint16_t, 1, 1>;
576 #endif
577
578 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x8_CflIntraPredictor
579 dsp->cfl_intra_predictors[kTransformSize32x8] =
580 CflIntraPredictor_C<32, 8, 10, uint16_t>;
581 #endif
582 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x8_CflSubsampler444
583 dsp->cfl_subsamplers[kTransformSize32x8][kSubsamplingType444] =
584 CflSubsampler_C<32, 8, 10, uint16_t, 0, 0>;
585 #endif
586 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x8_CflSubsampler422
587 dsp->cfl_subsamplers[kTransformSize32x8][kSubsamplingType422] =
588 CflSubsampler_C<32, 8, 10, uint16_t, 1, 0>;
589 #endif
590 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x8_CflSubsampler420
591 dsp->cfl_subsamplers[kTransformSize32x8][kSubsamplingType420] =
592 CflSubsampler_C<32, 8, 10, uint16_t, 1, 1>;
593 #endif
594
595 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x16_CflIntraPredictor
596 dsp->cfl_intra_predictors[kTransformSize32x16] =
597 CflIntraPredictor_C<32, 16, 10, uint16_t>;
598 #endif
599 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x16_CflSubsampler444
600 dsp->cfl_subsamplers[kTransformSize32x16][kSubsamplingType444] =
601 CflSubsampler_C<32, 16, 10, uint16_t, 0, 0>;
602 #endif
603 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x16_CflSubsampler422
604 dsp->cfl_subsamplers[kTransformSize32x16][kSubsamplingType422] =
605 CflSubsampler_C<32, 16, 10, uint16_t, 1, 0>;
606 #endif
607 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x16_CflSubsampler420
608 dsp->cfl_subsamplers[kTransformSize32x16][kSubsamplingType420] =
609 CflSubsampler_C<32, 16, 10, uint16_t, 1, 1>;
610 #endif
611
612 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x32_CflIntraPredictor
613 dsp->cfl_intra_predictors[kTransformSize32x32] =
614 CflIntraPredictor_C<32, 32, 10, uint16_t>;
615 #endif
616 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x32_CflSubsampler444
617 dsp->cfl_subsamplers[kTransformSize32x32][kSubsamplingType444] =
618 CflSubsampler_C<32, 32, 10, uint16_t, 0, 0>;
619 #endif
620 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x32_CflSubsampler422
621 dsp->cfl_subsamplers[kTransformSize32x32][kSubsamplingType422] =
622 CflSubsampler_C<32, 32, 10, uint16_t, 1, 0>;
623 #endif
624 #ifndef LIBGAV1_Dsp10bpp_TransformSize32x32_CflSubsampler420
625 dsp->cfl_subsamplers[kTransformSize32x32][kSubsamplingType420] =
626 CflSubsampler_C<32, 32, 10, uint16_t, 1, 1>;
627 #endif
628
629 #endif // LIBGAV1_ENABLE_ALL_DSP_FUNCTIONS
630 // Cfl predictors are available only for transform sizes with max(width,
631 // height) <= 32. Set all others to nullptr.
632 for (const auto i : kTransformSizesLargerThan32x32) {
633 dsp->cfl_intra_predictors[i] = nullptr;
634 for (int j = 0; j < kNumSubsamplingTypes; ++j) {
635 dsp->cfl_subsamplers[i][j] = nullptr;
636 }
637 }
638 } // NOLINT(readability/fn_size)
639 #endif // LIBGAV1_MAX_BITDEPTH >= 10
640
641 #undef INIT_CFL_INTRAPREDICTOR_WxH
642 #undef INIT_CFL_INTRAPREDICTORS
643
644 } // namespace
645
IntraPredCflInit_C()646 void IntraPredCflInit_C() {
647 Init8bpp();
648 #if LIBGAV1_MAX_BITDEPTH >= 10
649 Init10bpp();
650 #endif
651 }
652
653 } // namespace dsp
654 } // namespace libgav1
655