FFmpeg
Loading...
Searching...
No Matches
filter_template.c
Go to the documentation of this file.
1/*
2 * VVC filters DSP
3 *
4 * Copyright (C) 2022 Nuo Mi
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
24
25static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const void *_lut)
26{
27 const pixel *lut = _lut;
28 pixel *dst = (pixel*)_dst;
29 dst_stride /= sizeof(pixel);
30
31 for (int y = 0; y < height; y++) {
32 for (int x = 0; x < width; x++)
33 dst[x] = lut[dst[x]];
34 dst += dst_stride;
35 }
36}
37
39{
40 return av_clip(v0 - curr, -clip, clip) + av_clip(v1 - curr, -clip, clip);
41}
42
43static void FUNC(alf_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const uint8_t *_src, ptrdiff_t src_stride,
44 const int width, const int height, const int16_t *filter, const int16_t *_clip, const int vb_pos)
45{
46 const pixel *src = (pixel *)_src;
47 const tpixel *clip = (const tpixel *)_clip;
48 const int shift = 7;
49 const int offset = 1 << ( shift - 1 );
50 const int vb_above = vb_pos - 4;
51 const int vb_below = vb_pos + 3;
52
53 dst_stride /= sizeof(pixel);
54 src_stride /= sizeof(pixel);
55
56 for (int y = 0; y < height; y += ALF_BLOCK_SIZE) {
57 for (int x = 0; x < width; x += ALF_BLOCK_SIZE) {
58 const pixel *s0 = src + y * src_stride + x;
59 const pixel *s1 = s0 + src_stride;
60 const pixel *s2 = s0 - src_stride;
61 const pixel *s3 = s1 + src_stride;
62 const pixel *s4 = s2 - src_stride;
63 const pixel *s5 = s3 + src_stride;
64 const pixel *s6 = s4 - src_stride;
65
66 for (int i = 0; i < ALF_BLOCK_SIZE; i++) {
67 pixel *dst = (pixel *)_dst + (y + i) * dst_stride + x;
68
69 const pixel *p0 = s0 + i * src_stride;
70 const pixel *p1 = s1 + i * src_stride;
71 const pixel *p2 = s2 + i * src_stride;
72 const pixel *p3 = s3 + i * src_stride;
73 const pixel *p4 = s4 + i * src_stride;
74 const pixel *p5 = s5 + i * src_stride;
75 const pixel *p6 = s6 + i * src_stride;
76
77 const int is_near_vb_above = (y + i < vb_pos) && (y + i >= vb_pos - 1);
78 const int is_near_vb_below = (y + i >= vb_pos) && (y + i <= vb_pos);
79 const int is_near_vb = is_near_vb_above || is_near_vb_below;
80
81 if ((y + i < vb_pos) && ((y + i) > vb_above)) {
82 p1 = (y + i == vb_pos - 1) ? p0 : p1;
83 p3 = (y + i >= vb_pos - 2) ? p1 : p3;
84 p5 = (y + i >= vb_pos - 3) ? p3 : p5;
85
86 p2 = (y + i == vb_pos - 1) ? p0 : p2;
87 p4 = (y + i >= vb_pos - 2) ? p2 : p4;
88 p6 = (y + i >= vb_pos - 3) ? p4 : p6;
89 } else if ((y + i >= vb_pos) && ((y + i) < vb_below)) {
90 p2 = (y + i == vb_pos ) ? p0 : p2;
91 p4 = (y + i <= vb_pos + 1) ? p2 : p4;
92 p6 = (y + i <= vb_pos + 2) ? p4 : p6;
93
94 p1 = (y + i == vb_pos ) ? p0 : p1;
95 p3 = (y + i <= vb_pos + 1) ? p1 : p3;
96 p5 = (y + i <= vb_pos + 2) ? p3 : p5;
97 }
98
99 for (int j = 0; j < ALF_BLOCK_SIZE; j++) {
100 int sum = 0;
101 const pixel curr = *p0;
102
103 sum += filter[0] * FUNC(alf_clip)(curr, p5[+0], p6[+0], clip[0]);
104 sum += filter[1] * FUNC(alf_clip)(curr, p3[+1], p4[-1], clip[1]);
105 sum += filter[2] * FUNC(alf_clip)(curr, p3[+0], p4[+0], clip[2]);
106 sum += filter[3] * FUNC(alf_clip)(curr, p3[-1], p4[+1], clip[3]);
107 sum += filter[4] * FUNC(alf_clip)(curr, p1[+2], p2[-2], clip[4]);
108 sum += filter[5] * FUNC(alf_clip)(curr, p1[+1], p2[-1], clip[5]);
109 sum += filter[6] * FUNC(alf_clip)(curr, p1[+0], p2[+0], clip[6]);
110 sum += filter[7] * FUNC(alf_clip)(curr, p1[-1], p2[+1], clip[7]);
111 sum += filter[8] * FUNC(alf_clip)(curr, p1[-2], p2[+2], clip[8]);
112 sum += filter[9] * FUNC(alf_clip)(curr, p0[+3], p0[-3], clip[9]);
113 sum += filter[10] * FUNC(alf_clip)(curr, p0[+2], p0[-2], clip[10]);
114 sum += filter[11] * FUNC(alf_clip)(curr, p0[+1], p0[-1], clip[11]);
115
116 if (!is_near_vb)
117 sum = (sum + offset) >> shift;
118 else
119 sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3);
120 sum += curr;
121 dst[j] = CLIP(sum);
122
123 p0++;
124 p1++;
125 p2++;
126 p3++;
127 p4++;
128 p5++;
129 p6++;
130 }
131 }
134 }
135 }
136}
137
138static void FUNC(alf_filter_chroma)(uint8_t* _dst, ptrdiff_t dst_stride, const uint8_t* _src, ptrdiff_t src_stride,
139 const int width, const int height, const int16_t *filter, const int16_t *_clip, const int vb_pos)
140{
141 const pixel *src = (pixel *)_src;
142 const tpixel *clip = (const tpixel *)_clip;
143 const int shift = 7;
144 const int offset = 1 << ( shift - 1 );
145 const int vb_above = vb_pos - 2;
146 const int vb_below = vb_pos + 1;
147
148 dst_stride /= sizeof(pixel);
149 src_stride /= sizeof(pixel);
150
151 for (int y = 0; y < height; y += ALF_BLOCK_SIZE) {
152 for (int x = 0; x < width; x += ALF_BLOCK_SIZE) {
153 const pixel *s0 = src + y * src_stride + x;
154 const pixel *s1 = s0 + src_stride;
155 const pixel *s2 = s0 - src_stride;
156 const pixel *s3 = s1 + src_stride;
157 const pixel *s4 = s2 - src_stride;
158
159 for (int i = 0; i < ALF_BLOCK_SIZE; i++) {
160 pixel *dst = (pixel *)_dst + (y + i) * dst_stride + x;
161
162 const pixel *p0 = s0 + i * src_stride;
163 const pixel *p1 = s1 + i * src_stride;
164 const pixel *p2 = s2 + i * src_stride;
165 const pixel *p3 = s3 + i * src_stride;
166 const pixel *p4 = s4 + i * src_stride;
167
168 const int is_near_vb_above = (y + i < vb_pos) && (y + i >= vb_pos - 1);
169 const int is_near_vb_below = (y + i >= vb_pos) && (y + i <= vb_pos);
170 const int is_near_vb = is_near_vb_above || is_near_vb_below;
171
172 if ((y + i < vb_pos) && ((y + i) >= vb_above)) {
173 p1 = (y + i == vb_pos - 1) ? p0 : p1;
174 p3 = (y + i >= vb_pos - 2) ? p1 : p3;
175
176 p2 = (y + i == vb_pos - 1) ? p0 : p2;
177 p4 = (y + i >= vb_pos - 2) ? p2 : p4;
178 } else if ((y + i >= vb_pos) && ((y + i) <= vb_below)) {
179 p2 = (y + i == vb_pos ) ? p0 : p2;
180 p4 = (y + i <= vb_pos + 1) ? p2 : p4;
181
182 p1 = (y + i == vb_pos ) ? p0 : p1;
183 p3 = (y + i <= vb_pos + 1) ? p1 : p3;
184 }
185
186 for (int j = 0; j < ALF_BLOCK_SIZE; j++) {
187 int sum = 0;
188 const pixel curr = *p0;
189
190 sum += filter[0] * FUNC(alf_clip)(curr, p3[+0], p4[+0], clip[0]);
191 sum += filter[1] * FUNC(alf_clip)(curr, p1[+1], p2[-1], clip[1]);
192 sum += filter[2] * FUNC(alf_clip)(curr, p1[+0], p2[+0], clip[2]);
193 sum += filter[3] * FUNC(alf_clip)(curr, p1[-1], p2[+1], clip[3]);
194 sum += filter[4] * FUNC(alf_clip)(curr, p0[+2], p0[-2], clip[4]);
195 sum += filter[5] * FUNC(alf_clip)(curr, p0[+1], p0[-1], clip[5]);
196
197 if (!is_near_vb)
198 sum = (sum + offset) >> shift;
199 else
200 sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3);
201 sum += curr;
202 dst[j] = CLIP(sum);
203
204 p0++;
205 p1++;
206 p2++;
207 p3++;
208 p4++;
209 }
210 }
211 }
212 }
213}
214
215static void FUNC(alf_filter_cc)(uint8_t *_dst, ptrdiff_t dst_stride, const uint8_t *_luma, const ptrdiff_t luma_stride,
216 const int width, const int height, const int hs, const int vs, const int16_t *filter, const int vb_pos)
217{
218 const ptrdiff_t stride = luma_stride / sizeof(pixel);
219
220 dst_stride /= sizeof(pixel);
221
222 for (int y = 0; y < height; y++) {
223 for (int x = 0; x < width; x++) {
224 int sum = 0;
225 pixel *dst = (pixel *)_dst + y * dst_stride + x;
226 const pixel *src = (pixel *)_luma + (y << vs) * stride + (x << hs);
227
228 const pixel *s0 = src - stride;
229 const pixel *s1 = src;
230 const pixel *s2 = src + stride;
231 const pixel *s3 = src + 2 * stride;
232
233 const int pos = y << vs;
234 if (!vs && (pos == vb_pos || pos == vb_pos + 1))
235 continue;
236
237 if (pos == (vb_pos - 2) || pos == (vb_pos + 1))
238 s3 = s2;
239 else if (pos == (vb_pos - 1) || pos == vb_pos)
240 s3 = s2 = s0 = s1;
241
242
243 sum += filter[0] * (*s0 - *src);
244 sum += filter[1] * (*(s1 - 1) - *src);
245 sum += filter[2] * (*(s1 + 1) - *src);
246 sum += filter[3] * (*(s2 - 1) - *src);
247 sum += filter[4] * (*s2 - *src);
248 sum += filter[5] * (*(s2 + 1) - *src);
249 sum += filter[6] * (*s3 - *src);
250 sum = av_clip((sum + 64) >> 7, -(1 << (BIT_DEPTH - 1)), (1 << (BIT_DEPTH - 1)) - 1);
251 sum += *dst;
252 *dst = av_clip_pixel(sum);
253 }
254 }
255}
256
257#define ALF_DIR_VERT 0
258#define ALF_DIR_HORZ 1
259#define ALF_DIR_DIGA0 2
260#define ALF_DIR_DIGA1 3
261
262static void FUNC(alf_get_idx)(int *class_idx, int *transpose_idx, const int *sum, const int ac)
263{
264 static const int arg_var[] = {0, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4 };
265
266 int hv0, hv1, dir_hv, d0, d1, dir_d, hvd1, hvd0, sum_hv, dir1;
267
268 dir_hv = sum[ALF_DIR_VERT] <= sum[ALF_DIR_HORZ];
269 hv1 = FFMAX(sum[ALF_DIR_VERT], sum[ALF_DIR_HORZ]);
270 hv0 = FFMIN(sum[ALF_DIR_VERT], sum[ALF_DIR_HORZ]);
271
272 dir_d = sum[ALF_DIR_DIGA0] <= sum[ALF_DIR_DIGA1];
273 d1 = FFMAX(sum[ALF_DIR_DIGA0], sum[ALF_DIR_DIGA1]);
274 d0 = FFMIN(sum[ALF_DIR_DIGA0], sum[ALF_DIR_DIGA1]);
275
276 //promote to avoid overflow
277 dir1 = (uint64_t)d1 * hv0 <= (uint64_t)hv1 * d0;
278 hvd1 = dir1 ? hv1 : d1;
279 hvd0 = dir1 ? hv0 : d0;
280
281 sum_hv = sum[ALF_DIR_HORZ] + sum[ALF_DIR_VERT];
282 *class_idx = arg_var[av_clip_uintp2(sum_hv * ac >> (BIT_DEPTH - 1), 4)];
283 if (hvd1 * 2 > 9 * hvd0)
284 *class_idx += ((dir1 << 1) + 2) * 5;
285 else if (hvd1 > 2 * hvd0)
286 *class_idx += ((dir1 << 1) + 1) * 5;
287
288 *transpose_idx = dir_d * 2 + dir_hv;
289}
290
291static void FUNC(alf_classify)(int *class_idx, int *transpose_idx,
292 const uint8_t *_src, const ptrdiff_t _src_stride, const int width, const int height,
293 const int vb_pos, int *gradient_tmp)
294{
295 int *grad;
296
297 const int h = height + ALF_GRADIENT_BORDER * 2;
298 const int w = width + ALF_GRADIENT_BORDER * 2;
300 const int gstride = (w / ALF_GRADIENT_STEP) * ALF_NUM_DIR;
301
302 const pixel *src = (const pixel *)_src;
303 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
304 src -= (ALF_GRADIENT_BORDER + 1) * src_stride + ALF_GRADIENT_BORDER;
305
306 grad = gradient_tmp;
307 for (int y = 0; y < h; y += ALF_GRADIENT_STEP) {
308 const pixel *s0 = src + y * src_stride;
309 const pixel *s1 = s0 + src_stride;
310 const pixel *s2 = s1 + src_stride;
311 const pixel *s3 = s2 + src_stride;
312
313 if (y == vb_pos) //above
314 s3 = s2;
315 else if (y == vb_pos + ALF_GRADIENT_BORDER)
316 s0 = s1;
317
318 for (int x = 0; x < w; x += ALF_GRADIENT_STEP) {
319 //two points a time
320 const pixel *a0 = s0 + x;
321 const pixel *p0 = s1 + x;
322 const pixel *b0 = s2 + x;
323 const int val0 = (*p0) << 1;
324
325 const pixel *a1 = s1 + x + 1;
326 const pixel *p1 = s2 + x + 1;
327 const pixel *b1 = s3 + x + 1;
328 const int val1 = (*p1) << 1;
329
330 grad[ALF_DIR_VERT] = FFABS(val0 - *a0 - *b0) + FFABS(val1 - *a1 - *b1);
331 grad[ALF_DIR_HORZ] = FFABS(val0 - *(p0 - 1) - *(p0 + 1)) + FFABS(val1 - *(p1 - 1) - *(p1 + 1));
332 grad[ALF_DIR_DIGA0] = FFABS(val0 - *(a0 - 1) - *(b0 + 1)) + FFABS(val1 - *(a1 - 1) - *(b1 + 1));
333 grad[ALF_DIR_DIGA1] = FFABS(val0 - *(a0 + 1) - *(b0 - 1)) + FFABS(val1 - *(a1 + 1) - *(b1 - 1));
334 grad += ALF_NUM_DIR;
335 }
336 }
337
338 for (int y = 0; y < height ; y += ALF_BLOCK_SIZE ) {
339 int start = 0;
341 int ac = 2;
342 if (y + ALF_BLOCK_SIZE == vb_pos) {
344 ac = 3;
345 } else if (y == vb_pos) {
347 ac = 3;
348 }
349 for (int x = 0; x < width; x += ALF_BLOCK_SIZE) {
350 const int xg = x / ALF_GRADIENT_STEP;
351 const int yg = y / ALF_GRADIENT_STEP;
352 int sum[ALF_NUM_DIR] = { 0 };
353
354 grad = gradient_tmp + (yg + start) * gstride + xg * ALF_NUM_DIR;
355 //todo: optimize this loop
356 for (int i = start; i < end; i++) {
357 for (int j = 0; j < size; j++) {
362 grad += ALF_NUM_DIR;
363 }
364 grad += gstride - size * ALF_NUM_DIR;
365 }
366 FUNC(alf_get_idx)(class_idx, transpose_idx, sum, ac);
367
368 class_idx++;
369 transpose_idx++;
370 }
371 }
372
373}
374
375static void FUNC(alf_recon_coeff_and_clip)(int16_t *coeff, int16_t *_clip,
376 const int *class_idx, const int *transpose_idx, const int size,
377 const int16_t *coeff_set, const uint8_t *clip_idx_set, const uint8_t *class_to_filt)
378{
379 const static int index[][ALF_NUM_COEFF_LUMA] = {
380 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },
381 { 9, 4, 10, 8, 1, 5, 11, 7, 3, 0, 2, 6 },
382 { 0, 3, 2, 1, 8, 7, 6, 5, 4, 9, 10, 11 },
383 { 9, 8, 10, 4, 3, 7, 11, 5, 1, 0, 2, 6 },
384 };
385
386 const tpixel clip_set[] = {
387 1 << BIT_DEPTH, 1 << (BIT_DEPTH - 3), 1 << (BIT_DEPTH - 5), 1 << (BIT_DEPTH - 7)
388 };
389
390 tpixel *clip = (tpixel *)_clip;
391
392 for (int i = 0; i < size; i++) {
393 const int16_t *src_coeff = coeff_set + class_to_filt[class_idx[i]] * ALF_NUM_COEFF_LUMA;
394 const uint8_t *clip_idx = clip_idx_set + class_idx[i] * ALF_NUM_COEFF_LUMA;
395
396 for (int j = 0; j < ALF_NUM_COEFF_LUMA; j++) {
397 const int idx = index[transpose_idx[i]][j];
398 *coeff++ = src_coeff[idx];
399 *clip++ = clip_set[clip_idx[idx]];
400 }
401 }
402}
403
404static void FUNC(alf_get_clip_from_idx)(int16_t *_clip, const uint8_t *clip_idx)
405{
406 tpixel *clip = (tpixel *)_clip;
407 const int offset[] = { 0, 3, 5, 7 };
408
409 for (int i = 0; i < ALF_NUM_COEFF_CHROMA; i++) {
410 clip[i] = 1 << (BIT_DEPTH - offset[clip_idx[i]]);
411 }
412}
413
414#undef ALF_DIR_HORZ
415#undef ALF_DIR_VERT
416#undef ALF_DIR_DIGA0
417#undef ALF_DIR_DIGA1
418
419// line zero
420#define P7 pix[-8 * xstride]
421#define P6 pix[-7 * xstride]
422#define P5 pix[-6 * xstride]
423#define P4 pix[-5 * xstride]
424#define P3 pix[-4 * xstride]
425#define P2 pix[-3 * xstride]
426#define P1 pix[-2 * xstride]
427#define P0 pix[-1 * xstride]
428#define Q0 pix[0 * xstride]
429#define Q1 pix[1 * xstride]
430#define Q2 pix[2 * xstride]
431#define Q3 pix[3 * xstride]
432#define Q4 pix[4 * xstride]
433#define Q5 pix[5 * xstride]
434#define Q6 pix[6 * xstride]
435#define Q7 pix[7 * xstride]
436#define P(x) pix[(-(x)-1) * xstride]
437#define Q(x) pix[(x) * xstride]
438
439// line three. used only for deblocking decision
440#define TP7 pix[-8 * xstride + 3 * ystride]
441#define TP6 pix[-7 * xstride + 3 * ystride]
442#define TP5 pix[-6 * xstride + 3 * ystride]
443#define TP4 pix[-5 * xstride + 3 * ystride]
444#define TP3 pix[-4 * xstride + 3 * ystride]
445#define TP2 pix[-3 * xstride + 3 * ystride]
446#define TP1 pix[-2 * xstride + 3 * ystride]
447#define TP0 pix[-1 * xstride + 3 * ystride]
448#define TQ0 pix[0 * xstride + 3 * ystride]
449#define TQ1 pix[1 * xstride + 3 * ystride]
450#define TQ2 pix[2 * xstride + 3 * ystride]
451#define TQ3 pix[3 * xstride + 3 * ystride]
452#define TQ4 pix[4 * xstride + 3 * ystride]
453#define TQ5 pix[5 * xstride + 3 * ystride]
454#define TQ6 pix[6 * xstride + 3 * ystride]
455#define TQ7 pix[7 * xstride + 3 * ystride]
456#define TP(x) pix[(-(x)-1) * xstride + 3 * ystride]
457#define TQ(x) pix[(x) * xstride + 3 * ystride]
458
459#define FP3 pix[-4 * xstride + 1 * ystride]
460#define FP2 pix[-3 * xstride + 1 * ystride]
461#define FP1 pix[-2 * xstride + 1 * ystride]
462#define FP0 pix[-1 * xstride + 1 * ystride]
463#define FQ0 pix[0 * xstride + 1 * ystride]
464#define FQ1 pix[1 * xstride + 1 * ystride]
465#define FQ2 pix[2 * xstride + 1 * ystride]
466#define FQ3 pix[3 * xstride + 1 * ystride]
467
469
470static void FUNC(loop_filter_luma_large)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int32_t tc,
471 const uint8_t no_p, const uint8_t no_q, const uint8_t max_len_p, const uint8_t max_len_q)
472{
473 for (int d = 0; d < 4; d++) {
474 const int p6 = P6;
475 const int p5 = P5;
476 const int p4 = P4;
477 const int p3 = P3;
478 const int p2 = P2;
479 const int p1 = P1;
480 const int p0 = P0;
481 const int q0 = Q0;
482 const int q1 = Q1;
483 const int q2 = Q2;
484 const int q3 = Q3;
485 const int q4 = Q4;
486 const int q5 = Q5;
487 const int q6 = Q6;
488 int m;
489 if (max_len_p == 5 && max_len_q == 5)
490 m = (p4 + p3 + 2 * (p2 + p1 + p0 + q0 + q1 + q2) + q3 + q4 + 8) >> 4;
491 else if (max_len_p == max_len_q)
492 m = (p6 + p5 + p4 + p3 + p2 + p1 + 2 * (p0 + q0) + q1 + q2 + q3 + q4 + q5 + q6 + 8) >> 4;
493 else if (max_len_p + max_len_q == 12)
494 m = (p5 + p4 + p3 + p2 + 2 * (p1 + p0 + q0 + q1) + q2 + q3 + q4 + q5 + 8) >> 4;
495 else if (max_len_p + max_len_q == 8)
496 m = (p3 + p2 + p1 + p0 + q0 + q1 + q2 + q3 + 4) >> 3;
497 else if (max_len_q == 7)
498 m = (2 * (p2 + p1 + p0 + q0) + p0 + p1 + q1 + q2 + q3 + q4 + q5 + q6 + 8) >> 4;
499 else
500 m = (p6 + p5 + p4 + p3 + p2 + p1 + 2 * (q2 + q1 + q0 + p0) + q0 + q1 + 8) >> 4;
501 if (!no_p) {
502 const int refp = (P(max_len_p) + P(max_len_p - 1) + 1) >> 1;
503 if (max_len_p == 3) {
504 P0 = p0 + av_clip(((m * 53 + refp * 11 + 32) >> 6) - p0, -(tc * 6 >> 1), (tc * 6 >> 1));
505 P1 = p1 + av_clip(((m * 32 + refp * 32 + 32) >> 6) - p1, -(tc * 4 >> 1), (tc * 4 >> 1));
506 P2 = p2 + av_clip(((m * 11 + refp * 53 + 32) >> 6) - p2, -(tc * 2 >> 1), (tc * 2 >> 1));
507 } else if (max_len_p == 5) {
508 P0 = p0 + av_clip(((m * 58 + refp * 6 + 32) >> 6) - p0, -(tc * 6 >> 1), (tc * 6 >> 1));
509 P1 = p1 + av_clip(((m * 45 + refp * 19 + 32) >> 6) - p1, -(tc * 5 >> 1), (tc * 5 >> 1));
510 P2 = p2 + av_clip(((m * 32 + refp * 32 + 32) >> 6) - p2, -(tc * 4 >> 1), (tc * 4 >> 1));
511 P3 = p3 + av_clip(((m * 19 + refp * 45 + 32) >> 6) - p3, -(tc * 3 >> 1), (tc * 3 >> 1));
512 P4 = p4 + av_clip(((m * 6 + refp * 58 + 32) >> 6) - p4, -(tc * 2 >> 1), (tc * 2 >> 1));
513 } else {
514 P0 = p0 + av_clip(((m * 59 + refp * 5 + 32) >> 6) - p0, -(tc * 6 >> 1), (tc * 6 >> 1));
515 P1 = p1 + av_clip(((m * 50 + refp * 14 + 32) >> 6) - p1, -(tc * 5 >> 1), (tc * 5 >> 1));
516 P2 = p2 + av_clip(((m * 41 + refp * 23 + 32) >> 6) - p2, -(tc * 4 >> 1), (tc * 4 >> 1));
517 P3 = p3 + av_clip(((m * 32 + refp * 32 + 32) >> 6) - p3, -(tc * 3 >> 1), (tc * 3 >> 1));
518 P4 = p4 + av_clip(((m * 23 + refp * 41 + 32) >> 6) - p4, -(tc * 2 >> 1), (tc * 2 >> 1));
519 P5 = p5 + av_clip(((m * 14 + refp * 50 + 32) >> 6) - p5, -(tc * 1 >> 1), (tc * 1 >> 1));
520 P6 = p6 + av_clip(((m * 5 + refp * 59 + 32) >> 6) - p6, -(tc * 1 >> 1), (tc * 1 >> 1));
521 }
522 }
523 if (!no_q) {
524 const int refq = (Q(max_len_q) + Q(max_len_q - 1) + 1) >> 1;
525 if (max_len_q == 3) {
526 Q0 = q0 + av_clip(((m * 53 + refq * 11 + 32) >> 6) - q0, -(tc * 6 >> 1), (tc * 6 >> 1));
527 Q1 = q1 + av_clip(((m * 32 + refq * 32 + 32) >> 6) - q1, -(tc * 4 >> 1), (tc * 4 >> 1));
528 Q2 = q2 + av_clip(((m * 11 + refq * 53 + 32) >> 6) - q2, -(tc * 2 >> 1), (tc * 2 >> 1));
529 } else if (max_len_q == 5) {
530 Q0 = q0 + av_clip(((m * 58 + refq * 6 + 32) >> 6) - q0, -(tc * 6 >> 1), (tc * 6 >> 1));
531 Q1 = q1 + av_clip(((m * 45 + refq * 19 + 32) >> 6) - q1, -(tc * 5 >> 1), (tc * 5 >> 1));
532 Q2 = q2 + av_clip(((m * 32 + refq * 32 + 32) >> 6) - q2, -(tc * 4 >> 1), (tc * 4 >> 1));
533 Q3 = q3 + av_clip(((m * 19 + refq * 45 + 32) >> 6) - q3, -(tc * 3 >> 1), (tc * 3 >> 1));
534 Q4 = q4 + av_clip(((m * 6 + refq * 58 + 32) >> 6) - q4, -(tc * 2 >> 1), (tc * 2 >> 1));
535 } else {
536 Q0 = q0 + av_clip(((m * 59 + refq * 5 + 32) >> 6) - q0, -(tc * 6 >> 1), (tc * 6 >> 1));
537 Q1 = q1 + av_clip(((m * 50 + refq * 14 + 32) >> 6) - q1, -(tc * 5 >> 1), (tc * 5 >> 1));
538 Q2 = q2 + av_clip(((m * 41 + refq * 23 + 32) >> 6) - q2, -(tc * 4 >> 1), (tc * 4 >> 1));
539 Q3 = q3 + av_clip(((m * 32 + refq * 32 + 32) >> 6) - q3, -(tc * 3 >> 1), (tc * 3 >> 1));
540 Q4 = q4 + av_clip(((m * 23 + refq * 41 + 32) >> 6) - q4, -(tc * 2 >> 1), (tc * 2 >> 1));
541 Q5 = q5 + av_clip(((m * 14 + refq * 50 + 32) >> 6) - q5, -(tc * 1 >> 1), (tc * 1 >> 1));
542 Q6 = q6 + av_clip(((m * 5 + refq * 59 + 32) >> 6) - q6, -(tc * 1 >> 1), (tc * 1 >> 1));
543 }
544
545 }
546 pix += ystride;
547 }
548}
549
550static void FUNC(vvc_loop_filter_luma)(uint8_t* _pix, ptrdiff_t _xstride, ptrdiff_t _ystride,
551 const int32_t *_beta, const int32_t *_tc, const uint8_t *_no_p, const uint8_t *_no_q,
552 const uint8_t *_max_len_p, const uint8_t *_max_len_q, const int hor_ctu_edge)
553{
554 const ptrdiff_t xstride = _xstride / sizeof(pixel);
555 const ptrdiff_t ystride = _ystride / sizeof(pixel);
556
557 for (int i = 0; i < 2; i++) {
558#if BIT_DEPTH < 10
559 const int tc = (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - BIT_DEPTH);
560#else
561 const int tc = _tc[i] << (BIT_DEPTH - 10);
562#endif
563 if (tc) {
564 pixel* pix = (pixel*)_pix + i * 4 * ystride;
565 const int dp0 = abs(P2 - 2 * P1 + P0);
566 const int dq0 = abs(Q2 - 2 * Q1 + Q0);
567 const int dp3 = abs(TP2 - 2 * TP1 + TP0);
568 const int dq3 = abs(TQ2 - 2 * TQ1 + TQ0);
569 const int d0 = dp0 + dq0;
570 const int d3 = dp3 + dq3;
571 const int tc25 = ((tc * 5 + 1) >> 1);
572
573 const int no_p = _no_p[i];
574 const int no_q = _no_q[i];
575
576 int max_len_p = _max_len_p[i];
577 int max_len_q = _max_len_q[i];
578
579 const int large_p = (max_len_p > 3 && !hor_ctu_edge);
580 const int large_q = max_len_q > 3;
581
582 const int beta = _beta[i] << BIT_DEPTH - 8;
583 const int beta_3 = beta >> 3;
584 const int beta_2 = beta >> 2;
585
586 if (large_p || large_q) {
587 const int dp0l = large_p ? ((dp0 + abs(P5 - 2 * P4 + P3) + 1) >> 1) : dp0;
588 const int dq0l = large_q ? ((dq0 + abs(Q5 - 2 * Q4 + Q3) + 1) >> 1) : dq0;
589 const int dp3l = large_p ? ((dp3 + abs(TP5 - 2 * TP4 + TP3) + 1) >> 1) : dp3;
590 const int dq3l = large_q ? ((dq3 + abs(TQ5 - 2 * TQ4 + TQ3) + 1) >> 1) : dq3;
591 const int d0l = dp0l + dq0l;
592 const int d3l = dp3l + dq3l;
593 const int beta53 = beta * 3 >> 5;
594 const int beta_4 = beta >> 4;
595 max_len_p = large_p ? max_len_p : 3;
596 max_len_q = large_q ? max_len_q : 3;
597
598 if (d0l + d3l < beta) {
599 const int sp0l = abs(P3 - P0) + (max_len_p == 7 ? abs(P7 - P6 - P5 + P4) : 0);
600 const int sq0l = abs(Q0 - Q3) + (max_len_q == 7 ? abs(Q4 - Q5 - Q6 + Q7) : 0);
601 const int sp3l = abs(TP3 - TP0) + (max_len_p == 7 ? abs(TP7 - TP6 - TP5 + TP4) : 0);
602 const int sq3l = abs(TQ0 - TQ3) + (max_len_q == 7 ? abs(TQ4 - TQ5 - TQ6 + TQ7) : 0);
603 const int sp0 = large_p ? ((sp0l + abs(P3 - P(max_len_p)) + 1) >> 1) : sp0l;
604 const int sp3 = large_p ? ((sp3l + abs(TP3 - TP(max_len_p)) + 1) >> 1) : sp3l;
605 const int sq0 = large_q ? ((sq0l + abs(Q3 - Q(max_len_q)) + 1) >> 1) : sq0l;
606 const int sq3 = large_q ? ((sq3l + abs(TQ3 - TQ(max_len_q)) + 1) >> 1) : sq3l;
607 if (sp0 + sq0 < beta53 && abs(P0 - Q0) < tc25 &&
608 sp3 + sq3 < beta53 && abs(TP0 - TQ0) < tc25 &&
609 (d0l << 1) < beta_4 && (d3l << 1) < beta_4) {
610 FUNC(loop_filter_luma_large)(pix, xstride, ystride, tc, no_p, no_q, max_len_p, max_len_q);
611 continue;
612 }
613 }
614 }
615 if (d0 + d3 < beta) {
616 if (max_len_p > 2 && max_len_q > 2 &&
617 abs(P3 - P0) + abs(Q3 - Q0) < beta_3 && abs(P0 - Q0) < tc25 &&
618 abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 &&
619 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
620 FUNC(loop_filter_luma_strong)(pix, xstride, ystride, tc, tc << 1, tc * 3, no_p, no_q);
621 } else {
622 int nd_p = 1;
623 int nd_q = 1;
624 if (max_len_p > 1 && max_len_q > 1) {
625 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
626 nd_p = 2;
627 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
628 nd_q = 2;
629 }
630 FUNC(loop_filter_luma_weak)(pix, xstride, ystride, tc, beta, no_p, no_q, nd_p, nd_q);
631 }
632 }
633 }
634 }
635}
636
637static void FUNC(loop_filter_chroma_strong)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride,
638 const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q)
639{
640 for (int d = 0; d < size; d++) {
641 const int p3 = P3;
642 const int p2 = P2;
643 const int p1 = P1;
644 const int p0 = P0;
645 const int q0 = Q0;
646 const int q1 = Q1;
647 const int q2 = Q2;
648 const int q3 = Q3;
649 if (!no_p) {
650 P0 = av_clip((p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2 + 4) >> 3, p0 - tc, p0 + tc);
651 P1 = av_clip((2 * p3 + p2 + 2 * p1 + p0 + q0 + q1 + 4) >> 3, p1 - tc, p1 + tc);
652 P2 = av_clip((3 * p3 + 2 * p2 + p1 + p0 + q0 + 4) >> 3, p2 - tc, p2 + tc );
653 }
654 if (!no_q) {
655 Q0 = av_clip((p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3 + 4) >> 3, q0 - tc, q0 + tc);
656 Q1 = av_clip((p1 + p0 + q0 + 2 * q1 + q2 + 2 * q3 + 4) >> 3, q1 - tc, q1 + tc);
657 Q2 = av_clip((p0 + q0 + q1 + 2 * q2 + 3 * q3 + 4) >> 3, q2 - tc, q2 + tc);
658 }
659 pix += ystride;
660 }
661}
662
663static void FUNC(loop_filter_chroma_strong_one_side)(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride,
664 const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q)
665{
666 for (int d = 0; d < size; d++) {
667 const int p1 = P1;
668 const int p0 = P0;
669 const int q0 = Q0;
670 const int q1 = Q1;
671 const int q2 = Q2;
672 const int q3 = Q3;
673 if (!no_p) {
674 P0 = av_clip((3 * p1 + 2 * p0 + q0 + q1 + q2 + 4) >> 3, p0 - tc, p0 + tc);
675 }
676 if (!no_q) {
677 Q0 = av_clip((2 * p1 + p0 + 2 * q0 + q1 + q2 + q3 + 4) >> 3, q0 - tc, q0 + tc);
678 Q1 = av_clip((p1 + p0 + q0 + 2 * q1 + q2 + 2 * q3 + 4) >> 3, q1 - tc, q1 + tc);
679 Q2 = av_clip((p0 + q0 + q1 + 2 * q2 + 3 * q3 + 4) >> 3, q2 - tc, q2 + tc);
680 }
681 pix += ystride;
682 }
683}
684
685static void FUNC(vvc_loop_filter_chroma)(uint8_t *_pix, const ptrdiff_t _xstride, const ptrdiff_t _ystride,
686 const int32_t *_beta, const int32_t *_tc, const uint8_t *_no_p, const uint8_t *_no_q,
687 const uint8_t *_max_len_p, const uint8_t *_max_len_q, const int shift)
688{
689 const ptrdiff_t xstride = _xstride / sizeof(pixel);
690 const ptrdiff_t ystride = _ystride / sizeof(pixel);
691 const int size = shift ? 2 : 4;
692 const int end = 8 / size; // 8 samples a loop
693
694 for (int i = 0; i < end; i++) {
695#if BIT_DEPTH < 10
696 const int tc = (_tc[i] + (1 << (9 - BIT_DEPTH))) >> (10 - BIT_DEPTH);
697#else
698 const int tc = _tc[i] << (BIT_DEPTH - 10);
699#endif
700 if (tc) {
701 pixel *pix = (pixel *)_pix + i * size * ystride;
702 const uint8_t no_p = _no_p[i];
703 const uint8_t no_q = _no_q[i];
704
705 const int beta = _beta[i] << (BIT_DEPTH - 8);
706 const int beta_3 = beta >> 3;
707 const int beta_2 = beta >> 2;
708
709 const int tc25 = ((tc * 5 + 1) >> 1);
710
711 uint8_t max_len_p = _max_len_p[i];
712 uint8_t max_len_q = _max_len_q[i];
713
714 if (!max_len_p || !max_len_q)
715 continue;
716
717 if (max_len_q == 3){
718 const int p1n = shift ? FP1 : TP1;
719 const int p2n = max_len_p == 1 ? p1n : (shift ? FP2 : TP2);
720 const int p0n = shift ? FP0 : TP0;
721 const int q0n = shift ? FQ0 : TQ0;
722 const int q1n = shift ? FQ1 : TQ1;
723 const int q2n = shift ? FQ2 : TQ2;
724 const int p3 = max_len_p == 1 ? P1 : P3;
725 const int p2 = max_len_p == 1 ? P1 : P2;
726 const int p1 = P1;
727 const int p0 = P0;
728 const int dp0 = abs(p2 - 2 * p1 + p0);
729 const int dq0 = abs(Q2 - 2 * Q1 + Q0);
730
731 const int dp1 = abs(p2n - 2 * p1n + p0n);
732 const int dq1 = abs(q2n - 2 * q1n + q0n);
733 const int d0 = dp0 + dq0;
734 const int d1 = dp1 + dq1;
735
736 if (d0 + d1 < beta) {
737 const int p3n = max_len_p == 1 ? p1n : (shift ? FP3 : TP3);
738 const int q3n = shift ? FQ3 : TQ3;
739 const int dsam0 = (d0 << 1) < beta_2 && (abs(p3 - p0) + abs(Q0 - Q3) < beta_3) &&
740 abs(p0 - Q0) < tc25;
741 const int dsam1 = (d1 << 1) < beta_2 && (abs(p3n - p0n) + abs(q0n - q3n) < beta_3) &&
742 abs(p0n - q0n) < tc25;
743 if (!dsam0 || !dsam1)
744 max_len_p = max_len_q = 1;
745 } else {
746 max_len_p = max_len_q = 1;
747 }
748 }
749
750 if (max_len_p == 3 && max_len_q == 3)
751 FUNC(loop_filter_chroma_strong)(pix, xstride, ystride, size, tc, no_p, no_q);
752 else if (max_len_q == 3)
753 FUNC(loop_filter_chroma_strong_one_side)(pix, xstride, ystride, size, tc, no_p, no_q);
754 else
755 FUNC(loop_filter_chroma_weak)(pix, xstride, ystride, size, tc, no_p, no_q);
756 }
757 }
758}
759
760static void FUNC(vvc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
761 const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q,
762 const uint8_t *max_len_p, const uint8_t *max_len_q, int shift)
763{
764 FUNC(vvc_loop_filter_chroma)(pix, stride, sizeof(pixel), beta, tc,
765 no_p, no_q, max_len_p, max_len_q, shift);
766}
767
768static void FUNC(vvc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
769 const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q,
770 const uint8_t *max_len_p, const uint8_t *max_len_q, int shift)
771{
772 FUNC(vvc_loop_filter_chroma)(pix, sizeof(pixel), stride, beta, tc,
773 no_p, no_q, max_len_p, max_len_q, shift);
774}
775
776static void FUNC(vvc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
777 const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q,
778 const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge)
779{
780 FUNC(vvc_loop_filter_luma)(pix, stride, sizeof(pixel), beta, tc,
781 no_p, no_q, max_len_p, max_len_q, hor_ctu_edge);
782}
783
784static void FUNC(vvc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
785 const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q,
786 const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge)
787{
788 FUNC(vvc_loop_filter_luma)(pix, sizeof(pixel), stride, beta, tc,
789 no_p, no_q, max_len_p, max_len_q, hor_ctu_edge);
790}
791
792static int FUNC(vvc_loop_ladf_level)(const uint8_t *_pix, const ptrdiff_t _xstride, const ptrdiff_t _ystride)
793{
794 const pixel *pix = (pixel *)_pix;
795 const ptrdiff_t xstride = _xstride / sizeof(pixel);
796 const ptrdiff_t ystride = _ystride / sizeof(pixel);
797 return (P0 + TP0 + Q0 + TQ0) >> 2;
798}
799
800static int FUNC(vvc_h_loop_ladf_level)(const uint8_t *pix, ptrdiff_t stride)
801{
802 return FUNC(vvc_loop_ladf_level)(pix, stride, sizeof(pixel));
803}
804
805static int FUNC(vvc_v_loop_ladf_level)(const uint8_t *pix, ptrdiff_t stride)
806{
807 return FUNC(vvc_loop_ladf_level)(pix, sizeof(pixel), stride);
808}
809
810#undef P7
811#undef P6
812#undef P5
813#undef P4
814#undef P3
815#undef P2
816#undef P1
817#undef P0
818#undef Q0
819#undef Q1
820#undef Q2
821#undef Q3
822#undef Q4
823#undef Q5
824#undef Q6
825#undef Q7
826
827#undef TP7
828#undef TP6
829#undef TP5
830#undef TP4
831#undef TP3
832#undef TP2
833#undef TP1
834#undef TP0
835#undef TQ0
836#undef TQ1
837#undef TQ2
838#undef TQ3
839#undef TQ4
840#undef TQ5
841#undef TQ6
842#undef TQ7
843
845{
846 lmcs->filter = FUNC(lmcs_filter_luma);
847}
848
850{
851 lf->ladf_level[0] = FUNC(vvc_h_loop_ladf_level);
852 lf->ladf_level[1] = FUNC(vvc_v_loop_ladf_level);
853 lf->filter_luma[0] = FUNC(vvc_h_loop_filter_luma);
854 lf->filter_luma[1] = FUNC(vvc_v_loop_filter_luma);
855 lf->filter_chroma[0] = FUNC(vvc_h_loop_filter_chroma);
856 lf->filter_chroma[1] = FUNC(vvc_v_loop_filter_chroma);
857}
858
860{
861 for (int i = 0; i < FF_ARRAY_ELEMS(sao->band_filter); i++)
862 sao->band_filter[i] = FUNC(sao_band_filter);
863 for (int i = 0; i < FF_ARRAY_ELEMS(sao->edge_filter); i++)
864 sao->edge_filter[i] = FUNC(sao_edge_filter);
865 sao->edge_restore[0] = FUNC(sao_edge_restore_0);
866 sao->edge_restore[1] = FUNC(sao_edge_restore_1);
867}
868
870{
871 alf->filter[LUMA] = FUNC(alf_filter_luma);
872 alf->filter[CHROMA] = FUNC(alf_filter_chroma);
873 alf->filter_cc = FUNC(alf_filter_cc);
874 alf->classify = FUNC(alf_classify);
875 alf->recon_coeff_and_clip = FUNC(alf_recon_coeff_and_clip);
876 alf->get_clip_from_idx = FUNC(alf_get_clip_from_idx);
877}
uint8_t * _dst
Definition dsp.h:66
uint8_t ptrdiff_t const uint8_t * _src
Definition dsp.h:66
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
#define BIT_DEPTH
Definition dsp_init.c:121
static void FUNC alf_get_idx(int *class_idx, int *transpose_idx, const int *sum, const int ac)
static void FUNC alf_classify(int *class_idx, int *transpose_idx, const uint8_t *_src, const ptrdiff_t _src_stride, const int width, const int height, const int vb_pos, int16_t *gradient_tmp)
#define ALF_DIR_DIGA1
#define ALF_DIR_VERT
#define ALF_DIR_DIGA0
#define ALF_DIR_HORZ
int32_t
#define CLIP(a)
#define av_clip_pixel(a)
#define FUNC(a)
#define pixel
#define tpixel
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define av_clip
Definition common.h:100
#define av_clip_uintp2
Definition common.h:124
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition common.h:74
#define ALF_BLOCK_SIZE
Definition ctu.h:77
#define ALF_GRADIENT_STEP
Definition ctu.h:85
#define ALF_GRADIENT_BORDER
Definition ctu.h:86
#define ALF_NUM_DIR
Definition ctu.h:88
#define abs(x)
#define P7
static void FUNC vvc_loop_filter_luma(uint8_t *_pix, ptrdiff_t _xstride, ptrdiff_t _ystride, const int32_t *_beta, const int32_t *_tc, const uint8_t *_no_p, const uint8_t *_no_q, const uint8_t *_max_len_p, const uint8_t *_max_len_q, const int hor_ctu_edge)
#define FP2
#define P(x)
static av_always_inline tpixel FUNC alf_clip(pixel curr, pixel v0, pixel v1, tpixel clip)
#define TQ4
#define Q(x)
#define Q6
#define FP3
#define Q7
static void FUNC vvc_h_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, const uint8_t *max_len_p, const uint8_t *max_len_q, int shift)
#define P5
#define FQ2
static void FUNC vvc_v_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge)
static void FUNC alf_get_clip_from_idx(int16_t *_clip, const uint8_t *clip_idx)
static int FUNC vvc_loop_ladf_level(const uint8_t *_pix, const ptrdiff_t _xstride, const ptrdiff_t _ystride)
static void FUNC alf_recon_coeff_and_clip(int16_t *coeff, int16_t *_clip, const int *class_idx, const int *transpose_idx, const int size, const int16_t *coeff_set, const uint8_t *clip_idx_set, const uint8_t *class_to_filt)
static void FUNC ff_vvc_alf_dsp_init(VVCALFDSPContext *const alf)
static void FUNC vvc_v_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, const uint8_t *max_len_p, const uint8_t *max_len_q, int shift)
#define TP(x)
#define FQ0
static int FUNC vvc_h_loop_ladf_level(const uint8_t *pix, ptrdiff_t stride)
#define TQ6
static void FUNC ff_vvc_sao_dsp_init(VVCSAODSPContext *const sao)
static void FUNC ff_vvc_lf_dsp_init(VVCLFDSPContext *const lf)
#define FP0
#define FQ3
static void FUNC vvc_loop_filter_chroma(uint8_t *_pix, const ptrdiff_t _xstride, const ptrdiff_t _ystride, const int32_t *_beta, const int32_t *_tc, const uint8_t *_no_p, const uint8_t *_no_q, const uint8_t *_max_len_p, const uint8_t *_max_len_q, const int shift)
static int FUNC vvc_v_loop_ladf_level(const uint8_t *pix, ptrdiff_t stride)
static void FUNC loop_filter_luma_large(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int32_t tc, const uint8_t no_p, const uint8_t no_q, const uint8_t max_len_p, const uint8_t max_len_q)
#define TP4
static void FUNC loop_filter_chroma_strong(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q)
#define TQ(x)
static void FUNC lmcs_filter_luma(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const void *_lut)
#define P6
static void FUNC vvc_h_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, const int32_t *beta, const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q, const uint8_t *max_len_p, const uint8_t *max_len_q, const int hor_ctu_edge)
#define TQ7
#define TP5
#define P4
#define Q5
#define TP7
#define TP6
#define FP1
static void FUNC ff_vvc_lmcs_dsp_init(VVCLMCSDSPContext *const lmcs)
#define Q4
#define FQ1
static void FUNC loop_filter_chroma_strong_one_side(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q)
#define TQ5
int index
Definition gxfenc.c:90
#define CHROMA(h)
Definition h264dec.h:88
static void FUNC loop_filter_chroma_weak(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int size, const int32_t tc, const uint8_t no_p, const uint8_t no_q)
static void FUNC loop_filter_luma_strong(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int32_t tc, const int32_t tc2, const int tc3, const uint8_t no_p, const uint8_t no_q)
static void FUNC loop_filter_luma_weak(pixel *pix, const ptrdiff_t xstride, const ptrdiff_t ystride, const int32_t tc, const int32_t beta, const uint8_t no_p, const uint8_t no_q, const int nd_p, const int nd_q)
static void FUNC sao_edge_restore_0(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao, const int *borders, int _width, int _height, int c_idx, const uint8_t *vert_edge, const uint8_t *horiz_edge, const uint8_t *diag_edge)
static void FUNC sao_band_filter(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, ptrdiff_t stride_src, const int16_t *sao_offset_val, int sao_left_class, int width, int height)
static void FUNC sao_edge_filter(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, const int16_t *sao_offset_val, int eo, int width, int height)
static void FUNC sao_edge_restore_1(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao, const int *borders, int _width, int _height, int c_idx, const uint8_t *vert_edge, const uint8_t *horiz_edge, const uint8_t *diag_edge)
#define P3
#define Q3
#define TQ2
#define TQ3
#define TP2
#define TQ0
#define TP0
#define TQ1
#define TP1
#define TP3
#define LUMA
Definition filter.c:31
unsigned offset
Definition libaomenc.c:812
static int shift(int a, int b)
Definition bonk.c:261
#define Q1
Definition cavsdsp.c:40
#define P0
Definition cavsdsp.c:38
#define P1
Definition cavsdsp.c:37
#define Q0
Definition cavsdsp.c:39
#define P2
Definition cavsdsp.c:36
#define Q2
Definition cavsdsp.c:41
#define av_always_inline
Definition attributes.h:72
uint8_t w
Definition llvidencdsp.c:39
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
enum AVPixelFormat pix
Definition ohcodec.c:55
static double grad(int hash, double x, double y, double z)
Definition perlin.c:42
#define FF_ARRAY_ELEMS(a)
unsigned int pos
Definition spdifenc.c:431
#define stride
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
int size
static const uint8_t q1[256]
Definition twofish.c:100
static const uint8_t q0[256]
Definition twofish.c:81
static double b1(void *priv, double x, double y)
Definition vf_xfade.c:2041
static double a0(void *priv, double x, double y)
Definition vf_xfade.c:2035
static double b0(void *priv, double x, double y)
Definition vf_xfade.c:2040
static double a1(void *priv, double x, double y)
Definition vf_xfade.c:2036
static void alf_filter_chroma(VVCLocalContext *lc, uint8_t *dst, const uint8_t *src, const ptrdiff_t dst_stride, const ptrdiff_t src_stride, const int c_idx, const int width, const int height, const int vb_pos, const ALFParams *alf)
Definition filter.c:1039
static void alf_filter_luma(VVCLocalContext *lc, uint8_t *dst, const uint8_t *src, const ptrdiff_t dst_stride, const ptrdiff_t src_stride, const int x0, const int y0, const int width, const int height, const int _vb_pos, const ALFParams *alf)
Definition filter.c:1021
static void alf_filter_cc(VVCLocalContext *lc, uint8_t *dst, const uint8_t *luma, const ptrdiff_t dst_stride, const ptrdiff_t luma_stride, const int c_idx, const int width, const int height, const int hs, const int vs, const int vb_pos, const ALFParams *alf)
Definition filter.c:1058
#define ALF_NUM_COEFF_LUMA
Definition ps.h:167
#define ALF_NUM_COEFF_CHROMA
Definition ps.h:168