FFmpeg
Loading...
Searching...
No Matches
intra_template.c
Go to the documentation of this file.
1/*
2 * VVC intra prediction DSP
3 *
4 * Copyright (C) 2021-2023 Nuomi
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
23#include "libavutil/avassert.h"
25
26#include "intra.h"
27
28#define POS(x, y) src[(x) + stride * (y)]
29
30static av_always_inline void FUNC(cclm_linear_pred)(VVCFrameContext *fc, const int x0, const int y0,
31 const int w, const int h, const pixel* pdsy, const int *a, const int *b, const int *k)
32{
33 const VVCSPS *sps = fc->ps.sps;
34 for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) {
35 const int c_idx = i + 1;
36 const int x = x0 >> sps->hshift[c_idx];
37 const int y = y0 >> sps->vshift[c_idx];
38 const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
39 pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
40 for (int y = 0; y < h; y++) {
41 for (int x = 0; x < w; x++) {
42 const int dsy = pdsy[y * w + x];
43 const int pred = ((dsy * a[i]) >> k[i]) + b[i];
44 POS(x, y) = CLIP(pred);
45 }
46 }
47 }
48}
49
50#define MAX_PICK_POS 4
51#define TOP 0
52#define LEFT 1
53
54static av_always_inline void FUNC(cclm_get_params_default)(int *a, int *b, int *k)
55{
56 for (int i = 0; i < 2; i++) {
57 a[i] = k[i] = 0;
58 b[i] = 1 << (BIT_DEPTH - 1);
59 }
60}
61
63 const int x, const int y, const int w, const int h, const int avail_t, const int avail_l,
64 int cnt[2], int pos[2][MAX_PICK_POS])
65{
66 const enum IntraPredMode mode = lc->cu->intra_pred_mode_c;
67 const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM;
68 int num_samp[2];
69
70 if (mode == INTRA_LT_CCLM) {
71 num_samp[TOP] = avail_t ? w : 0;
72 num_samp[LEFT] = avail_l ? h : 0;
73 } else {
74 num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc, x, y, w + FFMIN(w, h), 1) : 0;
75 num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMIN(w, h), 1) : 0;
76 }
77 if (!num_samp[TOP] && !num_samp[LEFT]) {
78 return 0;
79 }
80 for (int i = TOP; i <= LEFT; i++) {
81 const int start = num_samp[i] >> (2 + num_is4);
82 const int step = FFMAX(1, num_samp[i] >> (1 + num_is4)) ;
83 cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1);
84 for (int c = 0; c < cnt[i]; c++)
85 pos[i][c] = start + c * step;
86 }
87 return 1;
88}
89
90static av_always_inline void FUNC(cclm_select_luma_444)(const pixel *src, const int step,
91 const int cnt, const int pos[MAX_PICK_POS], pixel *sel_luma)
92{
93 for (int i = 0; i < cnt; i++)
94 sel_luma[i] = src[pos[i] * step];
95}
96
98 const int x0, const int y0, const int avail_t, const int avail_l, const int cnt[2], const int pos[2][MAX_PICK_POS],
99 pixel *sel_luma)
100{
101 const VVCSPS *sps = fc->ps.sps;
102
103 const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y);
104 const int hs = sps->hshift[1];
105 const int vs = sps->vshift[1];
106 const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel);
107
108 if (!hs && !vs) {
109 const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
110 FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma);
111 FUNC(cclm_select_luma_444)(src - avail_l, stride, cnt[LEFT], pos[LEFT], sel_luma + cnt[TOP]);
112 } else {
113 // top
114 if (vs && !b_ctu_boundary) {
115 const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride;
116 for (int i = 0; i < cnt[TOP]; i++) {
117 const int x = pos[TOP][i] << hs;
118 const pixel *src = source + x;
119 const int has_left = x || avail_l;
120 const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
121 if (sps->r->sps_chroma_vertical_collocated_flag) {
122 sel_luma[i] = (POS(0, -1) + l + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
123 } else {
124 const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1);
125 sel_luma[i] = (l + l1 + 2 * (POS(0, 0) + POS(0, 1)) + POS(1, 0) + POS(1, 1) + 4) >> 3;
126 }
127 }
128 } else {
129 const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride;
130 for (int i = 0; i < cnt[TOP]; i++) {
131 const int x = pos[TOP][i] << hs;
132 const pixel *src = source + x;
133 const int has_left = x || avail_l;
134 const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
135 sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
136 }
137 }
138
139 // left
140 {
141 const pixel *left;
142 const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l;
143 left = source - avail_l;
144
145 for (int i = 0; i < cnt[LEFT]; i++) {
146 const int y = pos[LEFT][i] << vs;
147 const int offset = y * stride;
148 const pixel *l = left + offset;
149 const pixel *src = source + offset;
150 pixel pred;
151 if (!vs) {
152 pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
153 } else {
154 if (sps->r->sps_chroma_vertical_collocated_flag) {
155 const int has_top = y || avail_t;
156 const pixel t = has_top ? POS(0, -1) : POS(0, 0);
157 pred = (*l + t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
158 } else {
159 pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
160 }
161 }
162 sel_luma[i + cnt[TOP]] = pred;
163 }
164 }
165 }
166}
167
169 const int x, const int y, const int cnt[2], const int pos[2][MAX_PICK_POS],
170 pixel sel[][MAX_PICK_POS * 2])
171{
172 for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
173 const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
174
175 //top
176 const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride;
177 for (int i = 0; i < cnt[TOP]; i++) {
178 sel[c_idx][i] = src[pos[TOP][i]];
179 }
180
181 //left
182 src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride;
183 for (int i = 0; i < cnt[LEFT]; i++) {
184 sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride];
185 }
186 }
187}
188
190 const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l,
191 pixel sel[][MAX_PICK_POS * 2])
192{
193 const VVCFrameContext *fc = lc->fc;
194 const VVCSPS *sps = fc->ps.sps;
195 const int x = x0 >> sps->hshift[1];
196 const int y = y0 >> sps->vshift[1];
197 int cnt[2], pos[2][MAX_PICK_POS];
198
199 if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos))
200 return 0;
201
202 FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]);
203 FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel);
204
205 if (cnt[TOP] + cnt[LEFT] == 2) {
206 for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
207 sel[c_idx][3] = sel[c_idx][0];
208 sel[c_idx][2] = sel[c_idx][1];
209 sel[c_idx][0] = sel[c_idx][1];
210 sel[c_idx][1] = sel[c_idx][3];
211 }
212 }
213 return 1;
214}
215
217 const pixel sel[][MAX_PICK_POS * 2], int *min, int *max)
218{
219 int min_grp_idx[] = { 0, 2 };
220 int max_grp_idx[] = { 1, 3 };
221
222 if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]])
223 FFSWAP(int, min_grp_idx[0], min_grp_idx[1]);
224 if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]])
225 FFSWAP(int, max_grp_idx[0], max_grp_idx[1]);
226 if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) {
227 FFSWAP(int, min_grp_idx[0], max_grp_idx[0]);
228 FFSWAP(int, min_grp_idx[1], max_grp_idx[1]);
229 }
230 if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]])
231 FFSWAP(int, min_grp_idx[1], max_grp_idx[0]);
232 for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
233 max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1;
234 min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1;
235 }
236}
237
239 const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l,
240 int *a, int *b, int *k)
241{
244 int diff;
245
246 if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) {
248 return;
249 }
250
252
253 diff = max[LUMA] - min[LUMA];
254 if (diff == 0) {
255 for (int i = 0; i < 2; i++) {
256 a[i] = k[i] = 0;
257 b[i] = min[i + 1];
258 }
259 return;
260 }
261 for (int i = 0; i < 2; i++) {
262 const static int div_sig_table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0};
263 const int diffc = max[i + 1] - min[i + 1];
264 int x = av_log2(diff);
265 int y, v, sign, add;
266 const int norm_diff = ((diff << 4) >> x) & 15;
267 x += (norm_diff) ? 1 : 0;
268 y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0;
269 v = div_sig_table[norm_diff] | 8;
270 add = (1 << y >> 1);
271 a[i] = (diffc * v + add) >> y;
272 k[i] = FFMAX(1, 3 + x -y);
273 sign = a[i] < 0 ? -1 : (a[i] > 0);
274 a[i] = ((3 + x - y) < 1) ? sign * 15 : a[i];
275 b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]);
276 }
277
278}
279
280#undef TOP
281#undef LEFT
282
284 const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l,
285 pixel *pdsy)
286{
287 const int hs = fc->ps.sps->hshift[1];
288 const int vs = fc->ps.sps->vshift[1];
289 const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel);
290 const pixel *source = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
291 const pixel *left = source - avail_l;
292 const pixel *top = source - avail_t * stride;
293
294 const VVCSPS *sps = fc->ps.sps;
295 if (!hs && !vs) {
296 for (int i = 0; i < h; i++)
297 memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel));
298 return;
299 }
300 for (int i = 0; i < h; i++) {
301 const pixel *src = source;
302 const pixel *l = left;
303 const pixel *t = top;
304 if (!vs) {
305 for (int j = 0; j < w; j++) {
306 pixel pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
307 pdsy[i * w + j] = pred;
308 src += 2;
309 l = src - 1;
310 }
311
312 } else {
313 if (sps->r->sps_chroma_vertical_collocated_flag) {
314 for (int j = 0; j < w; j++) {
315 pixel pred = (*l + *t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
316 pdsy[i * w + j] = pred;
317 src += 2;
318 t += 2;
319 l = src - 1;
320 }
321 } else {
322 for (int j = 0; j < w; j++) {
323 pixel pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
324
325 pdsy[i * w + j] = pred;
326 src += 2;
327 l = src - 1;
328 }
329 }
330 }
331 source += (stride << vs);
332 left += (stride << vs);
333 top = source - stride;
334 }
335}
336
338 const int x, const int y, const int w, const int h, const int avail_t, const int avail_l)
339{
340 for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
341 const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
342 pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride;
343 for (int i = 0; i < h; i++) {
344 for (int j = 0; j < w; j++) {
345 dst[j] = 1 << (BIT_DEPTH - 1);
346 }
347 dst += stride;
348 }
349 }
350}
351
352//8.4.5.2.14 Specification of INTRA_LT_CCLM, INTRA_L_CCLM and INTRA_T_CCLM intra prediction mode
353static void FUNC(intra_cclm_pred)(const VVCLocalContext *lc, const int x0, const int y0,
354 const int width, const int height)
355{
356 VVCFrameContext *fc = lc->fc;
357 const VVCSPS *sps = fc->ps.sps;
358 const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0);
359 const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0);
360 const int hs = sps->hshift[1];
361 const int vs = sps->vshift[1];
362 const int x = x0 >> hs;
363 const int y = y0 >> vs;
364 const int w = width >> hs;
365 const int h = height >> vs;
366 int a[2], b[2], k[2];
367
369 if (!avail_t && !avail_l) {
370 FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l);
371 return;
372 }
373 FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy);
374 FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k);
375 FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k);
376}
377
378static int FUNC(lmcs_sum_samples)(const pixel *start, ptrdiff_t stride, const int avail, const int target_size)
379{
380 const int size = FFMIN(avail, target_size);
381 int sum = 0;
382 for (int i = 0; i < size; i++) {
383 sum += *start;
384 start += stride;
385 }
386 sum += *(start - stride) * (target_size - size);
387 return sum;
388}
389
390// 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples
391static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, const int y0)
392{
393 VVCFrameContext *fc = lc->fc;
394 const VVCLMCS *lmcs = &fc->ps.lmcs;
395 const int size_y = FFMIN(fc->ps.sps->ctb_size_y, 64);
396
397 const int x = x0 & ~(size_y - 1);
398 const int y = y0 & ~(size_y - 1);
399 if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) {
400 int cnt = 0, luma = 0, i;
401 const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift));
402 const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel);
403 const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0);
404 const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0);
405 if (avail_l) {
406 luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y);
407 cnt = size_y;
408 }
409 if (avail_t) {
410 luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y);
411 cnt += size_y;
412 }
413 if (cnt)
414 luma = (luma + (cnt >> 1)) >> av_log2(cnt);
415 else
416 luma = 1 << (BIT_DEPTH - 1);
417
418 for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) {
419 if (luma < lmcs->pivot[i + 1])
420 break;
421 }
422 i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1);
423
424 lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i];
425 lc->lmcs.x_vpdu = x;
426 lc->lmcs.y_vpdu = y;
427 }
428 return lc->lmcs.chroma_scale;
429}
430
431// 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples
432static void FUNC(lmcs_scale_chroma)(VVCLocalContext *lc, int *coeff,
433 const int width, const int height, const int x0_cu, const int y0_cu)
434{
435 const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu);
436
437 for (int y = 0; y < height; y++) {
438 for (int x = 0; x < width; x++) {
439 const int c = av_clip_intp2(*coeff, BIT_DEPTH);
440
441 if (c > 0)
442 *coeff = (c * chroma_scale + (1 << 10)) >> 11;
443 else
444 *coeff = -((-c * chroma_scale + (1 << 10)) >> 11);
445 coeff++;
446 }
447 }
448}
449
450static av_always_inline void FUNC(ref_filter)(const pixel *left, const pixel *top,
451 pixel *filtered_left, pixel *filtered_top, const int left_size, const int top_size,
452 const int unfilter_last_one)
453{
454 filtered_left[-1] = filtered_top[-1] = (left[0] + 2 * left[-1] + top[0] + 2 ) >> 2;
455 for (int i = 0; i < left_size - unfilter_last_one; i++) {
456 filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2;
457 }
458 for (int i = 0; i < top_size - unfilter_last_one; i++) {
459 filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2;
460 }
461 if (unfilter_last_one) {
462 filtered_top[top_size - 1] = top[top_size - 1];
463 filtered_left[left_size - 1] = left[left_size - 1];
464 }
465}
466
468 IntraEdgeParams* edge, const pixel *src, const ptrdiff_t stride,
469 const int x, int y, int w, int h, int c_idx, const int is_intra_mip,
470 const int mode, const int ref_idx, const int need_pdpc)
471{
472#define EXTEND(ptr, val, len) \
473do { \
474 for (i = 0; i < (len); i++) \
475 *(ptr + i) = val; \
476} while (0)
477 const CodingUnit *cu = lc->cu;
478 const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode);
479 const int filter_flag = !ref_idx && w * h > 32 && !c_idx &&
480 cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag;
481 int cand_up_left = lc->na.cand_up_left;
482 pixel *left = (pixel*)edge->left_array + MAX_TB_SIZE + 3;
483 pixel *top = (pixel*)edge->top_array + MAX_TB_SIZE + 3;
484 pixel *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3;
485 pixel *filtered_top = (pixel*)edge->filtered_top_array + MAX_TB_SIZE + 3;
486 const int ref_line = ref_idx == 3 ? -4 : (-1 - ref_idx);
487 int left_size, top_size, unfilter_left_size, unfilter_top_size;
488 int left_available, top_available;
489 int refw, refh;
490 int intra_pred_angle, inv_angle;
491 int i;
492
493 if (is_intra_mip || mode == INTRA_PLANAR) {
494 left_size = h + 1;
495 top_size = w + 1;
496 unfilter_left_size = left_size + filter_flag;
497 unfilter_top_size = top_size + filter_flag;
498 } else if (mode == INTRA_DC) {
499 unfilter_left_size = left_size = h;
500 unfilter_top_size = top_size = w;
501 } else if (mode == INTRA_VERT) {
502 //we may need 1 pixel to predict the top left.
503 unfilter_left_size = left_size = need_pdpc ? h : 1;
504 unfilter_top_size = top_size = w;
505 } else if (mode == INTRA_HORZ) {
506 unfilter_left_size = left_size = h;
507 //even need_pdpc == 0, we may need 1 pixel to predict the top left.
508 unfilter_top_size = top_size = need_pdpc ? w : 1;
509 } else {
510 if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) {
511 refw = w * 2;
512 refh = h * 2;
513 } else {
514 refw = cu->cb_width + w;
515 refh = cu->cb_height + h;
516 }
517 intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
518 inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
519 unfilter_top_size = top_size = refw;
520 unfilter_left_size = left_size = refh;
521 }
522
523 left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx);
524 for (i = 0; i < left_available; i++)
525 left[i] = POS(ref_line, i);
526
527 top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx);
528 memcpy(top, src + ref_line * stride, top_available * sizeof(pixel));
529
530 av_assume(ref_line >= -4);
531
532 for (int i = -1; i >= ref_line; i--) {
533 if (cand_up_left) {
534 left[i] = POS(ref_line, i);
535 top[i] = POS(i, ref_line);
536 } else if (left_available) {
537 left[i] = top[i] = left[0];
538 } else if (top_available) {
539 left[i] = top[i] = top[0];
540 } else {
541 left[i] = top[i] = 1 << (BIT_DEPTH - 1);
542 }
543 }
544
545 EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available);
546 EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available);
547
548 if (ref_filter_flag) {
549 if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) {
550 const int unfilter_last_one = left_size == unfilter_left_size;
551 FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one);
552 left = filtered_left;
553 top = filtered_top;
554 }
555 }
556 if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) {
557 if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) {
558 edge->filter_flag = 0;
559 } else {
560 const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18));
561 const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0};
562 const int ntbs = (av_log2(w) + av_log2(h)) >> 1;
563 edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2];
564 }
565
566 if (mode != INTRA_VERT && mode != INTRA_HORZ) {
567 if (mode >= INTRA_DIAG) {
568 if (intra_pred_angle < 0) {
569 pixel *p = top - (ref_idx + 1);
570 for (int x = -h; x < 0; x++) {
571 const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h);
572 p[x] = left[idx];
573 }
574 } else {
575 for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++)
576 top[i] = top[refw - 1];
577 }
578 } else {
579 if (intra_pred_angle < 0) {
580 pixel *p = left - (ref_idx + 1);
581 for (int x = -w; x < 0; x++) {
582 const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w);
583 p[x] = top[idx];
584 }
585 } else {
586 for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++)
587 left[i] = left[refh - 1];
588 }
589 }
590 }
591 }
592 edge->left = (uint8_t*)left;
593 edge->top = (uint8_t*)top;
594}
595
596//8.4.1 General decoding process for coding units coded in intra prediction mode
597static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0,
598 const int width, const int height, int c_idx)
599{
600 VVCFrameContext *fc = lc->fc;
601 const VVCSPS *sps = fc->ps.sps;
602 const VVCPPS *pps = fc->ps.pps;
603 const CodingUnit *cu = lc->cu;
604 const int log2_min_cb_size = sps->min_cb_log2_size_y;
605 const int min_cb_width = pps->min_cb_width;
606 const int x_cb = x0 >> log2_min_cb_size;
607 const int y_cb = y0 >> log2_min_cb_size;
608
609 const int hshift = fc->ps.sps->hshift[c_idx];
610 const int vshift = fc->ps.sps->vshift[c_idx];
611 const int x = x0 >> hshift;
612 const int y = y0 >> vshift;
613 const int w = width >> hshift;
614 const int h = height >> vshift;
615 const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
616
617 const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y;
618 const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode);
619
620 const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb);
621 const int is_intra_mip = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag);
622 const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx;
623 const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx);
624
625
626 pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
627 IntraEdgeParams edge;
628
629 FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc);
630
631 if (is_intra_mip) {
632 int intra_mip_transposed_flag;
633 int intra_mip_mode;
634 unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag);
635
636 fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left,
637 w, h, stride, intra_mip_mode, intra_mip_transposed_flag);
638 } else if (mode == INTRA_PLANAR) {
639 fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride);
640 } else if (mode == INTRA_DC) {
641 fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride);
642 } else if (mode == INTRA_VERT) {
643 fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride);
644 } else if (mode == INTRA_HORZ) {
645 fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride);
646 } else {
647 if (mode >= INTRA_DIAG) {
648 fc->vvcdsp.intra.pred_angular_v((uint8_t *)src, edge.top, edge.left,
649 w, h, stride, c_idx, mode, ref_idx,
650 edge.filter_flag, need_pdpc);
651 } else {
652 fc->vvcdsp.intra.pred_angular_h((uint8_t *)src, edge.top, edge.left,
653 w, h, stride, c_idx, mode, ref_idx,
654 edge.filter_flag, need_pdpc);
655 }
656 }
657 if (need_pdpc) {
658 //8.4.5.2.15 Position-dependent intra prediction sample filtering process
659 if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC ||
660 mode == INTRA_VERT || mode == INTRA_HORZ)) {
661 const int scale = (av_log2(w) + av_log2(h) - 2) >> 2;
662 const pixel *left = (pixel*)edge.left;
663 const pixel *top = (pixel*)edge.top;
664 for (int y = 0; y < h; y++) {
665 for (int x = 0; x < w; x++) {
666 int l, t, wl, wt, pred;
667 pixel val;
668 if (mode == INTRA_PLANAR || mode == INTRA_DC) {
669 l = left[y];
670 t = top[x];
671 wl = 32 >> FFMIN((x << 1) >> scale, 31);
672 wt = 32 >> FFMIN((y << 1) >> scale, 31);
673 } else {
674 l = left[y] - left[-1] + POS(x,y);
675 t = top[x] - top[-1] + POS(x,y);
676 wl = (mode == INTRA_VERT) ? (32 >> FFMIN((x << 1) >> scale, 31)) : 0;
677 wt = (mode == INTRA_HORZ) ? (32 >> FFMIN((y << 1) >> scale, 31)) : 0;
678 }
679 val = POS(x, y);
680 pred = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6);
681 POS(x, y) = CLIP(pred);
682 }
683 }
684 }
685 }
686}
687
688//8.4.5.2.11 Specification of INTRA_PLANAR intra prediction mode
689static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top,
690 const uint8_t *_left, const int w, const int h, const ptrdiff_t stride)
691{
692 int x, y;
693 pixel *src = (pixel *)_src;
694 const pixel *top = (const pixel *)_top;
695 const pixel *left = (const pixel *)_left;
696 const int logw = av_log2(w);
697 const int logh = av_log2(h);
698 const int size = w * h;
699 const int shift = (logw + logh + 1);
700 for (y = 0; y < h; y++) {
701 for (x = 0; x < w; x++) {
702 const int pred_v = ((h - 1 - y) * top[x] + (y + 1) * left[h]) << logw;
703 const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh;
704 const int pred = (pred_v + pred_h + size) >> shift;
705 POS(x, y) = pred;
706 }
707 }
708}
709
710//8.4.5.2.3 MIP boundary sample downsampling process
711static av_always_inline void FUNC(mip_downsampling)(int *reduced, const int boundary_size,
712 const pixel *ref, const int n_tb_s)
713{
714 const int b_dwn = n_tb_s / boundary_size;
715 const int log2 = av_log2(b_dwn);
716
717 if (boundary_size == n_tb_s) {
718 for (int i = 0; i < n_tb_s; i++)
719 reduced[i] = ref[i];
720 return;
721 }
722 for (int i = 0; i < boundary_size; i++) {
723 int r;
724 r = *ref++;
725 for (int j = 1; j < b_dwn; j++)
726 r += *ref++;
727 reduced[i] = (r + (1 << (log2 - 1))) >> log2;
728 }
729}
730
731static av_always_inline void FUNC(mip_reduced_pred)(pixel *src, const ptrdiff_t stride,
732 const int up_hor, const int up_ver, const int pred_size, const int *reduced, const int reduced_size,
733 const int ow, const int temp0, const uint8_t *matrix, int is_transposed)
734{
735 src = &POS(up_hor - 1, up_ver - 1);
736 for (int y = 0; y < pred_size; y++) {
737 for (int x = 0; x < pred_size; x++) {
738 int pred = 0;
739 for (int i = 0; i < reduced_size; i++)
740 pred += reduced[i] * matrix[i];
741 matrix += reduced_size;
742 pred = ((pred + ow) >> 6) + temp0;
743 pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1);
744 if (is_transposed)
745 POS(y * up_hor, x * up_ver) = pred;
746 else
747 POS(x * up_hor, y * up_ver) = pred;
748 }
749 }
750}
751
752static av_always_inline void FUNC(mip_upsampling_1d)(pixel *dst, const int dst_step, const int dst_stride, const int dst_height, const int factor,
753 const pixel *boundary, const int boundary_step, const int pred_size)
754{
755
756 for (int i = 0; i < dst_height; i++) {
757 const pixel *before = boundary;
758 const pixel *after = dst - dst_step;
759 pixel *d = dst;
760 for (int j = 0; j < pred_size; j++) {
761 after += dst_step * factor;
762 for (int k = 1; k < factor; k++) {
763 int mid = (factor - k) * (*before) + k * (*after);
764 *d = (mid + factor / 2) / factor;
765 d += dst_step;
766 }
767 before = after;
768 d += dst_step;
769 }
770 boundary += boundary_step;
771 dst += dst_stride;
772 }
773}
774
775//8.4.5.2.2 Matrix-based intra sample prediction
776static av_always_inline void FUNC(pred_mip)(uint8_t *_src, const uint8_t *_top,
777 const uint8_t *_left, const int w, const int h, const ptrdiff_t stride,
778 int mode_id, int is_transposed)
779{
780 pixel *src = (pixel *)_src;
781 const pixel *top = (const pixel *)_top;
782 const pixel *left = (const pixel *)_left;
783
784 const int size_id = ff_vvc_get_mip_size_id(w, h);
785 static const int boundary_sizes[] = {2, 4, 4};
786 static const int pred_sizes[] = {4, 4, 8};
787 const int boundary_size = boundary_sizes[size_id];
788 const int pred_size = pred_sizes[size_id];
789 const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0);
790 const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id);
791 const int up_hor = w / pred_size;
792 const int up_ver = h / pred_size;
793
794 int reduced[16];
795 int *red_t = reduced;
796 int *red_l = reduced + boundary_size;
797 int off = 1, ow = 0;
798 int temp0;
799
800 if (is_transposed) {
801 FFSWAP(int*, red_t, red_l);
802 }
803 FUNC(mip_downsampling)(red_t, boundary_size, top, w);
804 FUNC(mip_downsampling)(red_l, boundary_size, left, h);
805
806 temp0 = reduced[0];
807 if (size_id != 2) {
808 off = 0;
809 ow = (1 << (BIT_DEPTH - 1)) - temp0;
810 } else {
811 ow = reduced[1] - temp0;
812 }
813 reduced[0] = ow;
814 for (int i = 1; i < in_size; i++) {
815 reduced[i] = reduced[i + off] - temp0;
816 ow += reduced[i];
817 }
818 ow = 32 - 32 * ow;
819
820 FUNC(mip_reduced_pred)(src, stride, up_hor, up_ver, pred_size, reduced, in_size, ow, temp0, matrix, is_transposed);
821 if (up_hor > 1 || up_ver > 1) {
822 if (up_hor > 1)
823 FUNC(mip_upsampling_1d)(&POS(0, up_ver - 1), 1, up_ver * stride, pred_size, up_hor, left + up_ver - 1, up_ver, pred_size);
824 if (up_ver > 1)
825 FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size);
826 }
827}
828
830 const int w, const int h)
831{
832 pixel dc_val;
833 int sum = 0;
834 unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h);
835 const int shift = av_log2(offset);
836 offset >>= 1;
837 if (w >= h) {
838 for (int i = 0; i < w; i++)
839 sum += top[i];
840 }
841 if (w <= h) {
842 for (int i = 0; i < h; i++)
843 sum += left[i];
844 }
845 dc_val = (sum + offset) >> shift;
846 return dc_val;
847}
848
849//8.4.5.2.12 Specification of INTRA_DC intra prediction mode
850static av_always_inline void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
851 const uint8_t *_left, const int w, const int h, const ptrdiff_t stride)
852{
853 int x, y;
854 pixel *src = (pixel *)_src;
855 const pixel *top = (const pixel *)_top;
856 const pixel *left = (const pixel *)_left;
857 const pixel dc = FUNC(pred_dc_val)(top, left, w, h);
858 const pixel4 a = PIXEL_SPLAT_X4(dc);
859 for (y = 0; y < h; y++) {
860 pixel *s = src;
861 for (x = 0; x < w; x += 4) {
862 AV_WN4P(s, a);
863 s += 4;
864 }
865 src += stride;
866 }
867}
868
869static av_always_inline void FUNC(pred_v)(uint8_t *_src, const uint8_t *_top,
870 const int w, const int h, const ptrdiff_t stride)
871{
872 pixel *src = (pixel *)_src;
873 const pixel *top = (const pixel *)_top;
874 for (int y = 0; y < h; y++) {
875 memcpy(src, top, sizeof(pixel) * w);
876 src += stride;
877 }
878}
879
880static void FUNC(pred_h)(uint8_t *_src, const uint8_t *_left, const int w, const int h,
881 const ptrdiff_t stride)
882{
883 pixel *src = (pixel *)_src;
884 const pixel *left = (const pixel *)_left;
885 for (int y = 0; y < h; y++) {
886 const pixel4 a = PIXEL_SPLAT_X4(left[y]);
887 for (int x = 0; x < w; x += 4) {
888 AV_WN4P(&POS(x, y), a);
889 }
890 }
891}
892
893#define INTRA_LUMA_FILTER(p) CLIP((p[0] * f[0] + p[1] * f[1] + p[2] * f[2] + p[3] * f[3] + 32) >> 6)
894#define INTRA_CHROMA_FILTER(p) (((32 - fact) * p[1] + fact * p[2] + 16) >> 5)
895
896//8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes
897static void FUNC(pred_angular_v)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left,
898 const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode,
899 const int ref_idx, const int filter_flag, const int need_pdpc)
900{
901 pixel *src = (pixel *)_src;
902 const pixel *left = (const pixel *)_left;
903 const pixel *top = (const pixel *)_top - (1 + ref_idx);
904 const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
905 int pos = (1 + ref_idx) * intra_pred_angle;
906 const int dp = intra_pred_angle;
907 const int is_luma = !c_idx;
908 int nscale, inv_angle;
909
910 if (need_pdpc) {
911 inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
912 nscale = ff_vvc_nscale_derive(w, h, mode);
913 }
914
915 for (int y = 0; y < h; y++) {
916 const int idx = (pos >> 5) + ref_idx;
917 const int fact = pos & 31;
918 if (!fact && (!is_luma || !filter_flag)) {
919 for (int x = 0; x < w; x++) {
920 const pixel *p = top + x + idx + 1;
921 POS(x, y) = *p;
922 }
923 } else {
924 if (!c_idx) {
925 const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
926 for (int x = 0; x < w; x++) {
927 const pixel *p = top + x + idx;
928 POS(x, y) = INTRA_LUMA_FILTER(p);
929 }
930 } else {
931 for (int x = 0; x < w; x++) {
932 const pixel *p = top + x + idx;
933 POS(x, y) = INTRA_CHROMA_FILTER(p);
934 }
935 }
936 }
937 if (need_pdpc) {
938 int inv_angle_sum = 256 + inv_angle;
939 for (int x = 0; x < FFMIN(w, 3 << nscale); x++) {
940 const pixel l = left[y + (inv_angle_sum >> 9)];
941 const pixel val = POS(x, y);
942 const int wl = 32 >> ((x << 1) >> nscale);
943 const int pred = val + (((l - val) * wl + 32) >> 6);
944 POS(x, y) = CLIP(pred);
945 inv_angle_sum += inv_angle;
946 }
947 }
948 pos += dp;
949 }
950}
951
952//8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes
953static void FUNC(pred_angular_h)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left,
954 const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode,
955 const int ref_idx, const int filter_flag, const int need_pdpc)
956{
957 pixel *src = (pixel *)_src;
958 const pixel *left = (const pixel *)_left - (1 + ref_idx);
959 const pixel *top = (const pixel *)_top;
960 const int is_luma = !c_idx;
961 const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
962 const int dp = intra_pred_angle;
963 int nscale = 0, inv_angle, inv_angle_sum;
964
965 if (need_pdpc) {
966 inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
967 inv_angle_sum = 256 + inv_angle;
968 nscale = ff_vvc_nscale_derive(w, h, mode);
969 }
970
971 for (int y = 0; y < h; y++) {
972 int pos = (1 + ref_idx) * intra_pred_angle;
973 int wt;
974 if (need_pdpc)
975 wt = (32 >> FFMIN(31, (y * 2) >> nscale));
976
977 for (int x = 0; x < w; x++) {
978 const int idx = (pos >> 5) + ref_idx;
979 const int fact = pos & 31;
980 const pixel *p = left + y + idx;
981 int pred;
982 if (!fact && (!is_luma || !filter_flag)) {
983 pred = p[1];
984 } else {
985 if (!c_idx) {
986 const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
988 } else {
990 }
991 }
992 if (need_pdpc) {
993 if (y < (3 << nscale)) {
994 const pixel t = top[x + (inv_angle_sum >> 9)];
995 pred = CLIP(pred + (((t - pred) * wt + 32) >> 6));
996 }
997 }
998 POS(x, y) = pred;
999 pos += dp;
1000 }
1001 if (need_pdpc)
1002 inv_angle_sum += inv_angle;
1003 }
1004}
1005
1007{
1008 intra->lmcs_scale_chroma = FUNC(lmcs_scale_chroma);
1009 intra->intra_cclm_pred = FUNC(intra_cclm_pred);
1010 intra->intra_pred = FUNC(intra_pred);
1011 intra->pred_planar = FUNC(pred_planar);
1012 intra->pred_mip = FUNC(pred_mip);
1013 intra->pred_dc = FUNC(pred_dc);
1014 intra->pred_v = FUNC(pred_v);
1015 intra->pred_h = FUNC(pred_h);
1016 intra->pred_angular_v = FUNC(pred_angular_v);
1017 intra->pred_angular_h = FUNC(pred_angular_h);
1018}
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 double val(void *priv, double ch)
Definition aeval.c:77
static double fact(double i)
Definition af_aiir.c:936
#define log2(x)
Definition math.h:26
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assume(cond)
Definition avassert.h:119
#define CLIP(a)
#define FUNC(a)
#define pixel4
#define PIXEL_SPLAT_X4(x)
#define AV_WN4P
#define pixel
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define f(width, name)
Definition cbs_vp8.c:236
#define s(width, name)
Definition cbs_vp9.c:198
#define LEFT
Definition cdgraphics.c:168
#define av_clip_intp2
Definition common.h:121
#define av_clip
Definition common.h:100
#define av_zero_extend
Definition common.h:151
@ ISP_NO_SPLIT
Definition ctu.h:122
@ INTRA_HORZ
Definition ctu.h:237
@ INTRA_DIAG
Definition ctu.h:238
@ INTRA_L_CCLM
Definition ctu.h:242
@ INTRA_LT_CCLM
Definition ctu.h:241
@ INTRA_T_CCLM
Definition ctu.h:243
@ INTRA_VERT
Definition ctu.h:239
#define abs(x)
#define min(a, b)
#define max(a, b)
static const uint16_t fc[]
Definition dcaenc.h:43
uint64_t pps
Definition dovi_rpuenc.c:36
int a
#define LUMA
Definition filter.c:31
IntraPredMode
Definition hevcdec.h:125
@ INTRA_DC
Definition hevcdec.h:127
@ INTRA_PLANAR
Definition hevcdec.h:126
#define MAX_TB_SIZE
Definition hevcdec.h:47
#define SAMPLE_CTB(tab, x, y)
Definition hevcdec.h:72
static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2], const int shift)
#define r
Definition input.c:42
#define b
Definition input.c:43
#define av_log2
Definition intmath.h:84
static void lmcs_scale_chroma(VVCLocalContext *lc, TransformUnit *tu, TransformBlock *tb, const int target_ch_type)
Definition intra.c:500
int ff_vvc_intra_pred_angle_derive(int pred_mode)
int ff_vvc_nscale_derive(int w, int h, int mode)
Definition intra_utils.c:42
int ff_vvc_get_top_available(const VVCLocalContext *lc, int x0, int y0, int target_size, int c_idx)
Definition intra_utils.c:95
int ff_vvc_wide_angle_mode_mapping(const CodingUnit *cu, int tb_width, int tb_height, int c_idx, int pred_mode_intra)
int ff_vvc_get_left_available(const VVCLocalContext *lc, int x0, int y0, int target_size, int c_idx)
int ff_vvc_need_pdpc(int w, int h, uint8_t bdpcm_flag, int mode, int ref_idx)
Definition intra_utils.c:61
int ff_vvc_ref_filter_flag_derive(int mode)
int ff_vvc_get_mip_size_id(int w, int h)
Definition intra_utils.c:33
int ff_vvc_intra_inv_angle_derive(int pred_mode)
static av_always_inline void FUNC ref_filter(const pixel *left, const pixel *top, pixel *filtered_left, pixel *filtered_top, const int left_size, const int top_size, const int unfilter_last_one)
static void FUNC pred_angular_v(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode, const int ref_idx, const int filter_flag, const int need_pdpc)
static av_always_inline void FUNC cclm_get_params_default(int *a, int *b, int *k)
static av_always_inline void FUNC mip_upsampling_1d(pixel *dst, const int dst_step, const int dst_stride, const int dst_height, const int factor, const pixel *boundary, const int boundary_step, const int pred_size)
static av_always_inline void FUNC cclm_pred_default(VVCFrameContext *fc, const int x, const int y, const int w, const int h, const int avail_t, const int avail_l)
static av_always_inline pixel FUNC pred_dc_val(const pixel *top, const pixel *left, const int w, const int h)
#define EXTEND(ptr, val, len)
static av_always_inline void FUNC mip_reduced_pred(pixel *src, const ptrdiff_t stride, const int up_hor, const int up_ver, const int pred_size, const int *reduced, const int reduced_size, const int ow, const int temp0, const uint8_t *matrix, int is_transposed)
#define MAX_PICK_POS
static av_always_inline void FUNC cclm_select_chroma(const VVCFrameContext *fc, const int x, const int y, const int cnt[2], const int pos[2][MAX_PICK_POS], pixel sel[][MAX_PICK_POS *2])
static av_always_inline void FUNC cclm_select_luma_444(const pixel *src, const int step, const int cnt, const int pos[MAX_PICK_POS], pixel *sel_luma)
static void FUNC pred_h(uint8_t *_src, const uint8_t *_left, const int w, const int h, const ptrdiff_t stride)
static av_always_inline int FUNC cclm_get_select_pos(const VVCLocalContext *lc, const int x, const int y, const int w, const int h, const int avail_t, const int avail_l, int cnt[2], int pos[2][MAX_PICK_POS])
static int FUNC lmcs_derive_chroma_scale(VVCLocalContext *lc, const int x0, const int y0)
static av_always_inline void FUNC mip_downsampling(int *reduced, const int boundary_size, const pixel *ref, const int n_tb_s)
static void FUNC pred_angular_h(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode, const int ref_idx, const int filter_flag, const int need_pdpc)
#define POS(x, y)
static void FUNC intra_cclm_pred(const VVCLocalContext *lc, const int x0, const int y0, const int width, const int height)
static av_always_inline int FUNC cclm_select_samples(const VVCLocalContext *lc, const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l, pixel sel[][MAX_PICK_POS *2])
static av_always_inline void FUNC cclm_linear_pred(VVCFrameContext *fc, const int x0, const int y0, const int w, const int h, const pixel *pdsy, const int *a, const int *b, const int *k)
static av_always_inline void FUNC cclm_select_luma(const VVCFrameContext *fc, const int x0, const int y0, const int avail_t, const int avail_l, const int cnt[2], const int pos[2][MAX_PICK_POS], pixel *sel_luma)
static av_always_inline void FUNC cclm_get_min_max(const pixel sel[][MAX_PICK_POS *2], int *min, int *max)
static void FUNC ff_vvc_intra_dsp_init(VVCIntraDSPContext *const intra)
static av_always_inline void FUNC pred_mip(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, const int w, const int h, const ptrdiff_t stride, int mode_id, int is_transposed)
static av_always_inline void FUNC pred_v(uint8_t *_src, const uint8_t *_top, const int w, const int h, const ptrdiff_t stride)
static int FUNC lmcs_sum_samples(const pixel *start, ptrdiff_t stride, const int avail, const int target_size)
#define INTRA_CHROMA_FILTER(p)
static av_always_inline void FUNC prepare_intra_edge_params(const VVCLocalContext *lc, IntraEdgeParams *edge, const pixel *src, const ptrdiff_t stride, const int x, int y, int w, int h, int c_idx, const int is_intra_mip, const int mode, const int ref_idx, const int need_pdpc)
#define INTRA_LUMA_FILTER(p)
static av_always_inline void FUNC cclm_get_params(const VVCLocalContext *lc, const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l, int *a, int *b, int *k)
static av_always_inline void FUNC cclm_get_luma_rec_pixels(const VVCFrameContext *fc, const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l, pixel *pdsy)
unsigned offset
Definition libaomenc.c:812
static int shift(int a, int b)
Definition bonk.c:261
@ VVC_MAX_SAMPLE_ARRAYS
Definition vvc.h:77
static const int factor[16]
Definition vf_pp7.c:98
#define av_always_inline
Definition attributes.h:72
uint8_t w
Definition llvidencdsp.c:39
#define FFSWAP(type, a, b)
Definition macros.h:52
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
static av_always_inline void FUNC intra_pred(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int log2_size, int c_idx)
static void FUNC pred_dc(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, ptrdiff_t stride, int log2_size, int c_idx)
static av_always_inline void FUNC pred_planar(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, ptrdiff_t stride, int trafo_size)
#define TOP
Definition scpr.c:33
static const float pred[4]
Definition siprdata.h:259
unsigned int pos
Definition spdifenc.c:431
int mip_chroma_direct_flag
MipChromaDirectFlag.
Definition ctu.h:325
int bdpcm_flag[VVC_MAX_SAMPLE_ARRAYS]
BdpcmFlag.
Definition ctu.h:327
enum IspType isp_split_type
IntraSubPartitionsSplitType.
Definition ctu.h:317
int cb_width
Definition ctu.h:293
IntraPredMode intra_pred_mode_y
IntraPredModeY.
Definition ctu.h:323
int cb_height
Definition ctu.h:294
uint8_t intra_luma_ref_idx
IntraLumaRefLineIdx[][].
Definition ctu.h:309
IntraPredMode intra_pred_mode_c
IntraPredModeC.
Definition ctu.h:324
uint8_t * top
Definition dsp.c:57
int filter_flag
Definition dsp.c:59
uint8_t * left
Definition dsp.c:58
Definition ps.h:201
uint16_t chroma_scale_coeff[LMCS_MAX_BIN_SIZE]
Definition ps.h:211
uint8_t min_bin_idx
Definition ps.h:202
Definition ps.h:92
Definition ps.h:58
Definition swscale.c:85
#define stride
#define src
Definition vp8dsp.c:248
static int ref[MAX_W *MAX_W]
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
int size
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
static double c[64]
const int8_t ff_vvc_intra_luma_filter[VVC_INTRA_LUMA_TYPES][VVC_INTRA_LUMA_FACTS][VVC_INTRA_LUMA_TAPS]
Definition data.c:2006
const uint8_t * ff_vvc_get_mip_matrix(const int size_id, const int mode_id)
Definition data.c:1147
static av_always_inline void unpack_mip_info(int *intra_mip_transposed_flag, int *intra_mip_mode, const uint8_t mip_info)
Definition dsp.c:47
#define LMCS_MAX_BIN_SIZE
Definition ps.h:48