FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vvc/intra.c
Date: 2025-04-25 22:50:00
Exec Total Coverage
Lines: 428 431 99.3%
Functions: 26 26 100.0%
Branches: 271 286 94.8%

Line Branch Exec Source
1 /*
2 * VVC intra prediction
3 *
4 * Copyright (C) 2021 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 #include "libavutil/frame.h"
23 #include "libavutil/imgutils.h"
24
25 #include "data.h"
26 #include "inter.h"
27 #include "intra.h"
28 #include "itx_1d.h"
29
30 395164 static int is_cclm(enum IntraPredMode mode)
31 {
32
6/6
✓ Branch 0 taken 334981 times.
✓ Branch 1 taken 60183 times.
✓ Branch 2 taken 312026 times.
✓ Branch 3 taken 22955 times.
✓ Branch 4 taken 25032 times.
✓ Branch 5 taken 286994 times.
395164 return mode == INTRA_LT_CCLM || mode == INTRA_L_CCLM || mode == INTRA_T_CCLM;
33 }
34
35 171081 static int derive_ilfnst_pred_mode_intra(const VVCLocalContext *lc, const TransformBlock *tb)
36 {
37 171081 const VVCFrameContext *fc = lc->fc;
38 171081 const VVCSPS *sps = fc->ps.sps;
39 171081 const CodingUnit *cu = lc->cu;
40 171081 const int x_tb = tb->x0 >> fc->ps.sps->min_cb_log2_size_y;
41 171081 const int y_tb = tb->y0 >> fc->ps.sps->min_cb_log2_size_y;
42 171081 const int x_c = (tb->x0 + (tb->tb_width << sps->hshift[1] >> 1) ) >> fc->ps.sps->min_cb_log2_size_y;
43 171081 const int y_c = (tb->y0 + (tb->tb_height << sps->vshift[1] >> 1)) >> fc->ps.sps->min_cb_log2_size_y;
44 171081 const int min_cb_width = fc->ps.pps->min_cb_width;
45 171081 const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_tb, y_tb);
46
2/2
✓ Branch 0 taken 120399 times.
✓ Branch 1 taken 50682 times.
171081 int pred_mode_intra = tb->c_idx == 0 ? cu->intra_pred_mode_y : cu->intra_pred_mode_c;
47
4/4
✓ Branch 0 taken 19883 times.
✓ Branch 1 taken 151198 times.
✓ Branch 2 taken 5088 times.
✓ Branch 3 taken 14795 times.
171081 if (intra_mip_flag && !tb->c_idx) {
48 5088 pred_mode_intra = INTRA_PLANAR;
49
2/2
✓ Branch 1 taken 15840 times.
✓ Branch 2 taken 150153 times.
165993 } else if (is_cclm(pred_mode_intra)) {
50 15840 int intra_mip_flag_c = SAMPLE_CTB(fc->tab.imf, x_c, y_c);
51 15840 int cu_pred_mode = SAMPLE_CTB(fc->tab.cpm[0], x_c, y_c);
52
2/2
✓ Branch 0 taken 4442 times.
✓ Branch 1 taken 11398 times.
15840 if (intra_mip_flag_c) {
53 4442 pred_mode_intra = INTRA_PLANAR;
54
3/4
✓ Branch 0 taken 10426 times.
✓ Branch 1 taken 972 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10426 times.
11398 } else if (cu_pred_mode == MODE_IBC || cu_pred_mode == MODE_PLT) {
55 972 pred_mode_intra = INTRA_DC;
56 } else {
57 10426 pred_mode_intra = SAMPLE_CTB(fc->tab.ipm, x_c, y_c);
58 }
59 }
60 171081 pred_mode_intra = ff_vvc_wide_angle_mode_mapping(cu, tb->tb_width, tb->tb_height, tb->c_idx, pred_mode_intra);
61
62 171081 return pred_mode_intra;
63 }
64
65 //8.7.4 Transformation process for scaled transform coefficients
66 171081 static void ilfnst_transform(const VVCLocalContext *lc, TransformBlock *tb)
67 {
68 171081 const VVCSPS *sps = lc->fc->ps.sps;
69 171081 const CodingUnit *cu = lc->cu;
70 171081 const int w = tb->tb_width;
71 171081 const int h = tb->tb_height;
72
4/4
✓ Branch 0 taken 99497 times.
✓ Branch 1 taken 71584 times.
✓ Branch 2 taken 68322 times.
✓ Branch 3 taken 31175 times.
171081 const int n_lfnst_out_size = (w >= 8 && h >= 8) ? 48 : 16; ///< nLfnstOutSize
73
4/4
✓ Branch 0 taken 99497 times.
✓ Branch 1 taken 71584 times.
✓ Branch 2 taken 68322 times.
✓ Branch 3 taken 31175 times.
171081 const int log2_lfnst_size = (w >= 8 && h >= 8) ? 3 : 2; ///< log2LfnstSize
74 171081 const int n_lfnst_size = 1 << log2_lfnst_size; ///< nLfnstSize
75
8/8
✓ Branch 0 taken 39632 times.
✓ Branch 1 taken 131449 times.
✓ Branch 2 taken 27202 times.
✓ Branch 3 taken 12430 times.
✓ Branch 4 taken 71584 times.
✓ Branch 5 taken 87067 times.
✓ Branch 6 taken 49283 times.
✓ Branch 7 taken 22301 times.
171081 const int non_zero_size = ((w == 8 && h == 8) || (w == 4 && h == 4)) ? 8 : 16; ///< nonZeroSize
76 171081 const int pred_mode_intra = derive_ilfnst_pred_mode_intra(lc, tb);
77 171081 const int transpose = pred_mode_intra > 34;
78 int u[16], v[48];
79
80
2/2
✓ Branch 0 taken 2243592 times.
✓ Branch 1 taken 171081 times.
2414673 for (int x = 0; x < non_zero_size; x++) {
81 2243592 int xc = ff_vvc_diag_scan_x[2][2][x];
82 2243592 int yc = ff_vvc_diag_scan_y[2][2][x];
83 2243592 u[x] = tb->coeffs[w * yc + xc];
84 }
85 171081 ff_vvc_inv_lfnst_1d(v, u, non_zero_size, n_lfnst_out_size, pred_mode_intra,
86 171081 cu->lfnst_idx, sps->log2_transform_range);
87
2/2
✓ Branch 0 taken 49682 times.
✓ Branch 1 taken 121399 times.
171081 if (transpose) {
88 49682 int *dst = tb->coeffs;
89 49682 const int *src = v;
90
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 15122 times.
49682 if (n_lfnst_size == 4) {
91
2/2
✓ Branch 0 taken 138240 times.
✓ Branch 1 taken 34560 times.
172800 for (int y = 0; y < 4; y++) {
92 138240 dst[0] = src[0];
93 138240 dst[1] = src[4];
94 138240 dst[2] = src[8];
95 138240 dst[3] = src[12];
96 138240 src++;
97 138240 dst += w;
98 }
99 } else {
100
2/2
✓ Branch 0 taken 120976 times.
✓ Branch 1 taken 15122 times.
136098 for (int y = 0; y < 8; y++) {
101 120976 dst[0] = src[0];
102 120976 dst[1] = src[8];
103 120976 dst[2] = src[16];
104 120976 dst[3] = src[24];
105
2/2
✓ Branch 0 taken 60488 times.
✓ Branch 1 taken 60488 times.
120976 if (y < 4) {
106 60488 dst[4] = src[32];
107 60488 dst[5] = src[36];
108 60488 dst[6] = src[40];
109 60488 dst[7] = src[44];
110 }
111 120976 src++;
112 120976 dst += w;
113 }
114 }
115
116 } else {
117 121399 int *dst = tb->coeffs;
118 121399 const int *src = v;
119
2/2
✓ Branch 0 taken 698396 times.
✓ Branch 1 taken 121399 times.
819795 for (int y = 0; y < n_lfnst_size; y++) {
120
2/2
✓ Branch 0 taken 485596 times.
✓ Branch 1 taken 212800 times.
698396 int size = (y < 4) ? n_lfnst_size : 4;
121 698396 memcpy(dst, src, size * sizeof(int));
122 698396 src += size;
123 698396 dst += w;
124 }
125 }
126 171081 tb->max_scan_x = n_lfnst_size - 1;
127 171081 tb->max_scan_y = n_lfnst_size - 1;
128 171081 }
129
130 //part of 8.7.4 Transformation process for scaled transform coefficients
131 923289 static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalContext *lc, const TransformBlock *tb, enum VVCTxType *trh, enum VVCTxType *trv)
132 {
133 923289 const CodingUnit *cu = lc->cu;
134 static const enum VVCTxType mts_to_trh[] = { VVC_DCT2, VVC_DST7, VVC_DCT8, VVC_DST7, VVC_DCT8 };
135 static const enum VVCTxType mts_to_trv[] = { VVC_DCT2, VVC_DST7, VVC_DST7, VVC_DCT8, VVC_DCT8 };
136 923289 const VVCSPS *sps = fc->ps.sps;
137 923289 int implicit_mts_enabled = 0;
138
6/6
✓ Branch 0 taken 671986 times.
✓ Branch 1 taken 251303 times.
✓ Branch 2 taken 137942 times.
✓ Branch 3 taken 534044 times.
✓ Branch 4 taken 32201 times.
✓ Branch 5 taken 105741 times.
923289 if (tb->c_idx || (cu->isp_split_type != ISP_NO_SPLIT && cu->lfnst_idx)) {
139 283504 *trh = *trv = VVC_DCT2;
140 283504 return;
141 }
142
143
2/2
✓ Branch 0 taken 635891 times.
✓ Branch 1 taken 3894 times.
639785 if (sps->r->sps_mts_enabled_flag) {
144
2/2
✓ Branch 0 taken 530150 times.
✓ Branch 1 taken 105741 times.
635891 if (cu->isp_split_type != ISP_NO_SPLIT ||
145
4/4
✓ Branch 0 taken 34142 times.
✓ Branch 1 taken 496008 times.
✓ Branch 2 taken 465 times.
✓ Branch 3 taken 33677 times.
530150 (cu->sbt_flag && FFMAX(tb->tb_width, tb->tb_height) <= 32) ||
146
4/4
✓ Branch 0 taken 45019 times.
✓ Branch 1 taken 451454 times.
✓ Branch 2 taken 28412 times.
✓ Branch 3 taken 16607 times.
496473 (!sps->r->sps_explicit_mts_intra_enabled_flag && cu->pred_mode == MODE_INTRA &&
147
4/4
✓ Branch 0 taken 18449 times.
✓ Branch 1 taken 9963 times.
✓ Branch 2 taken 14592 times.
✓ Branch 3 taken 3857 times.
28412 !cu->lfnst_idx && !cu->intra_mip_flag)) {
148 154010 implicit_mts_enabled = 1;
149 }
150 }
151
2/2
✓ Branch 0 taken 154010 times.
✓ Branch 1 taken 485775 times.
639785 if (implicit_mts_enabled) {
152 154010 const int w = tb->tb_width;
153 154010 const int h = tb->tb_height;
154
2/2
✓ Branch 0 taken 33677 times.
✓ Branch 1 taken 120333 times.
154010 if (cu->sbt_flag) {
155
4/4
✓ Branch 0 taken 17823 times.
✓ Branch 1 taken 15854 times.
✓ Branch 2 taken 8393 times.
✓ Branch 3 taken 9430 times.
33677 *trh = (cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? VVC_DST7 : VVC_DCT8;
156
4/4
✓ Branch 0 taken 15854 times.
✓ Branch 1 taken 17823 times.
✓ Branch 2 taken 7657 times.
✓ Branch 3 taken 8197 times.
33677 *trv = (!cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? VVC_DST7 : VVC_DCT8;
157 } else {
158
4/4
✓ Branch 0 taken 101947 times.
✓ Branch 1 taken 18386 times.
✓ Branch 2 taken 81961 times.
✓ Branch 3 taken 19986 times.
120333 *trh = (w >= 4 && w <= 16) ? VVC_DST7 : VVC_DCT2;
159
4/4
✓ Branch 0 taken 77159 times.
✓ Branch 1 taken 43174 times.
✓ Branch 2 taken 74254 times.
✓ Branch 3 taken 2905 times.
120333 *trv = (h >= 4 && h <= 16) ? VVC_DST7 : VVC_DCT2;
160 }
161 154010 return;
162 }
163 485775 *trh = mts_to_trh[cu->mts_idx];
164 485775 *trv = mts_to_trv[cu->mts_idx];
165 }
166
167 52268 static void add_residual_for_joint_coding_chroma(VVCLocalContext *lc,
168 const TransformUnit *tu, TransformBlock *tb, const int chroma_scale)
169 {
170 52268 const VVCFrameContext *fc = lc->fc;
171 52268 const CodingUnit *cu = lc->cu;
172 52268 const int c_sign = 1 - 2 * fc->ps.ph.r->ph_joint_cbcr_sign_flag;
173 52268 const int shift = tu->coded_flag[1] ^ tu->coded_flag[2];
174 52268 const int c_idx = 1 + tu->coded_flag[1];
175 52268 const ptrdiff_t stride = fc->frame->linesize[c_idx];
176 52268 const int hs = fc->ps.sps->hshift[c_idx];
177 52268 const int vs = fc->ps.sps->vshift[c_idx];
178 52268 uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride +
179 52268 ((tb->x0 >> hs) << fc->ps.sps->pixel_shift)];
180
2/2
✓ Branch 0 taken 25317 times.
✓ Branch 1 taken 26951 times.
52268 if (chroma_scale) {
181 25317 fc->vvcdsp.itx.pred_residual_joint(tb->coeffs, tb->tb_width, tb->tb_height, c_sign, shift);
182 25317 fc->vvcdsp.intra.lmcs_scale_chroma(lc, tb->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, cu->x0, cu->y0);
183 25317 fc->vvcdsp.itx.add_residual(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride);
184 } else {
185 26951 fc->vvcdsp.itx.add_residual_joint(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride, c_sign, shift);
186 }
187 52268 }
188
189 1918572 static int add_reconstructed_area(VVCLocalContext *lc, const int ch_type, const int x0, const int y0, const int w, const int h)
190 {
191 1918572 const VVCSPS *sps = lc->fc->ps.sps;
192 1918572 const int hs = sps->hshift[ch_type];
193 1918572 const int vs = sps->vshift[ch_type];
194 ReconstructedArea *a;
195
196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1918572 times.
1918572 if (lc->num_ras[ch_type] >= FF_ARRAY_ELEMS(lc->ras[ch_type]))
197 return AVERROR_INVALIDDATA;
198
199 1918572 a = &lc->ras[ch_type][lc->num_ras[ch_type]];
200 1918572 a->x = x0 >> hs;
201 1918572 a->y = y0 >> vs;
202 1918572 a->w = w >> hs;
203 1918572 a->h = h >> vs;
204 1918572 lc->num_ras[ch_type]++;
205
206 1918572 return 0;
207 }
208
209 963998 static void add_tu_area(const TransformUnit *tu, int *x0, int *y0, int *w, int *h)
210 {
211 963998 *x0 = tu->x0;
212 963998 *y0 = tu->y0;
213 963998 *w = tu->width;
214 963998 *h = tu->height;
215 963998 }
216
217 #define MIN_ISP_PRED_WIDTH 4
218 740018 static int get_luma_predict_unit(const CodingUnit *cu, const TransformUnit *tu, const int idx, int *x0, int *y0, int *w, int *h)
219 {
220 740018 int has_luma = 1;
221 740018 add_tu_area(tu, x0, y0, w, h);
222
4/4
✓ Branch 0 taken 74180 times.
✓ Branch 1 taken 665838 times.
✓ Branch 2 taken 26318 times.
✓ Branch 3 taken 47862 times.
740018 if (cu->isp_split_type == ISP_VER_SPLIT && tu->width < MIN_ISP_PRED_WIDTH) {
223 26318 *w = MIN_ISP_PRED_WIDTH;
224 26318 has_luma = !(idx % (MIN_ISP_PRED_WIDTH / tu->width));
225 }
226 740018 return has_luma;
227 }
228
229 244690 static int get_chroma_predict_unit(const CodingUnit *cu, const TransformUnit *tu, const int idx, int *x0, int *y0, int *w, int *h)
230 {
231
2/2
✓ Branch 0 taken 223980 times.
✓ Branch 1 taken 20710 times.
244690 if (cu->isp_split_type == ISP_NO_SPLIT) {
232 223980 add_tu_area(tu, x0, y0, w, h);
233 223980 return 1;
234 }
235
2/2
✓ Branch 0 taken 5191 times.
✓ Branch 1 taken 15519 times.
20710 if (idx == cu->num_intra_subpartitions - 1) {
236 5191 *x0 = cu->x0;
237 5191 *y0 = cu->y0;
238 5191 *w = cu->cb_width;
239 5191 *h = cu->cb_height;
240 5191 return 1;
241 }
242 15519 return 0;
243 }
244
245 //8.4.5.1 General decoding process for intra blocks
246 1400823 static void predict_intra(VVCLocalContext *lc, const TransformUnit *tu, const int idx, const int target_ch_type)
247 {
248 1400823 const VVCFrameContext *fc = lc->fc;
249 1400823 const CodingUnit *cu = lc->cu;
250 1400823 const VVCTreeType tree_type = cu->tree_type;
251 int x0, y0, w, h;
252
2/2
✓ Branch 0 taken 416115 times.
✓ Branch 1 taken 984708 times.
1400823 if (cu->pred_mode != MODE_INTRA) {
253 416115 add_reconstructed_area(lc, target_ch_type, tu->x0, tu->y0, tu->width, tu->height);
254 416115 return;
255 }
256
3/4
✓ Branch 0 taken 740018 times.
✓ Branch 1 taken 244690 times.
✓ Branch 2 taken 740018 times.
✗ Branch 3 not taken.
984708 if (!target_ch_type && tree_type != DUAL_TREE_CHROMA) {
257
2/2
✓ Branch 1 taken 725823 times.
✓ Branch 2 taken 14195 times.
740018 if (get_luma_predict_unit(cu, tu, idx, &x0, &y0, &w, &h)) {
258 725823 ff_vvc_set_neighbour_available(lc, x0, y0, w, h);
259 725823 fc->vvcdsp.intra.intra_pred(lc, x0, y0, w, h, 0);
260 725823 add_reconstructed_area(lc, 0, x0, y0, w, h);
261 }
262 }
263
3/4
✓ Branch 0 taken 244690 times.
✓ Branch 1 taken 740018 times.
✓ Branch 2 taken 244690 times.
✗ Branch 3 not taken.
984708 if (target_ch_type && tree_type != DUAL_TREE_LUMA) {
264
2/2
✓ Branch 1 taken 229171 times.
✓ Branch 2 taken 15519 times.
244690 if (get_chroma_predict_unit(cu, tu, idx, &x0, &y0, &w, &h)){
265 229171 ff_vvc_set_neighbour_available(lc, x0, y0, w, h);
266
2/2
✓ Branch 1 taken 92330 times.
✓ Branch 2 taken 136841 times.
229171 if (is_cclm(cu->intra_pred_mode_c)) {
267 92330 fc->vvcdsp.intra.intra_cclm_pred(lc, x0, y0, w, h);
268 } else {
269 136841 fc->vvcdsp.intra.intra_pred(lc, x0, y0, w, h, 1);
270 136841 fc->vvcdsp.intra.intra_pred(lc, x0, y0, w, h, 2);
271 }
272 229171 add_reconstructed_area(lc, 1, x0, y0, w, h);
273 }
274 }
275 }
276
277 863387 static void scale_clip(int *coeff, const int nzw, const int w, const int h,
278 const int shift, const int log2_transform_range)
279 {
280 863387 const int add = 1 << (shift - 1);
281
2/2
✓ Branch 0 taken 8934880 times.
✓ Branch 1 taken 863387 times.
9798267 for (int y = 0; y < h; y++) {
282 8934880 int *p = coeff + y * w;
283
2/2
✓ Branch 0 taken 48301112 times.
✓ Branch 1 taken 8934880 times.
57235992 for (int x = 0; x < nzw; x++) {
284 48301112 *p = av_clip_intp2((*p + add) >> shift, log2_transform_range);
285 48301112 p++;
286 }
287 8934880 memset(p, 0, sizeof(*p) * (w - nzw));
288 }
289 863387 }
290
291 876208 static void scale(int *out, const int *in, const int w, const int h, const int shift)
292 {
293 876208 const int add = 1 << (shift - 1);
294
2/2
✓ Branch 0 taken 8989514 times.
✓ Branch 1 taken 876208 times.
9865722 for (int y = 0; y < h; y++) {
295
2/2
✓ Branch 0 taken 150691500 times.
✓ Branch 1 taken 8989514 times.
159681014 for (int x = 0; x < w; x++) {
296 150691500 int *o = out + y * w + x;
297 150691500 const int *i = in + y * w + x;
298 150691500 *o = (*i + add) >> shift;
299 }
300 }
301 876208 }
302
303 // part of 8.7.3 Scaling process for transform coefficients
304 952114 static void derive_qp(const VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
305 {
306 952114 const VVCSPS *sps = lc->fc->ps.sps;
307 952114 const H266RawSliceHeader *rsh = lc->sc->sh.r;
308 952114 const CodingUnit *cu = lc->cu;
309 int qp, qp_act_offset;
310
311
2/2
✓ Branch 0 taken 697419 times.
✓ Branch 1 taken 254695 times.
952114 if (tb->c_idx == 0) {
312 //fix me
313 697419 qp = cu->qp[LUMA] + sps->qp_bd_offset;
314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 697419 times.
697419 qp_act_offset = cu->act_enabled_flag ? -5 : 0;
315 } else {
316
6/6
✓ Branch 0 taken 52268 times.
✓ Branch 1 taken 202427 times.
✓ Branch 2 taken 44548 times.
✓ Branch 3 taken 7720 times.
✓ Branch 4 taken 29773 times.
✓ Branch 5 taken 14775 times.
254695 const int is_jcbcr = tu->joint_cbcr_residual_flag && tu->coded_flag[CB] && tu->coded_flag[CR];
317
2/2
✓ Branch 0 taken 224922 times.
✓ Branch 1 taken 29773 times.
254695 const int idx = is_jcbcr ? JCBCR : tb->c_idx;
318 254695 qp = cu->qp[idx];
319 254695 qp_act_offset = cu->act_enabled_flag ? 1 : 0;
320 }
321
2/2
✓ Branch 0 taken 28825 times.
✓ Branch 1 taken 923289 times.
952114 if (tb->ts) {
322 28825 const int qp_prime_ts_min = 4 + 6 * sps->r->sps_min_qp_prime_ts;
323
324 28825 tb->qp = av_clip(qp + qp_act_offset, qp_prime_ts_min, 63 + sps->qp_bd_offset);
325 28825 tb->rect_non_ts_flag = 0;
326 28825 tb->bd_shift = 10;
327 } else {
328 923289 const int log_sum = tb->log2_tb_width + tb->log2_tb_height;
329 923289 const int rect_non_ts_flag = log_sum & 1;
330
331 923289 tb->qp = av_clip(qp + qp_act_offset, 0, 63 + sps->qp_bd_offset);
332 923289 tb->rect_non_ts_flag = rect_non_ts_flag;
333 923289 tb->bd_shift = sps->bit_depth + rect_non_ts_flag + (log_sum / 2)
334 923289 + 10 - sps->log2_transform_range + rsh->sh_dep_quant_used_flag;
335 }
336 952114 tb->bd_offset = (1 << tb->bd_shift) >> 1;
337 952114 }
338
339 //8.7.3 Scaling process for transform coefficients
340 952114 static av_always_inline int derive_scale(const TransformBlock *tb, const int sh_dep_quant_used_flag)
341 {
342 static const uint8_t rem6[63 + 8 * 6 + 1] = {
343 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
344 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
345 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
346 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5,
347 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3,
348 };
349
350 static const uint8_t div6[63 + 8 * 6 + 1] = {
351 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
352 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
353 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
354 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
355 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18,
356 };
357
358 const static int level_scale[2][6] = {
359 { 40, 45, 51, 57, 64, 72 },
360 { 57, 64, 72, 80, 90, 102 }
361 };
362
4/4
✓ Branch 0 taken 884800 times.
✓ Branch 1 taken 67314 times.
✓ Branch 2 taken 855975 times.
✓ Branch 3 taken 28825 times.
952114 const int addin = sh_dep_quant_used_flag && !tb->ts;
363 952114 const int qp = tb->qp + addin;
364
365 952114 return level_scale[tb->rect_non_ts_flag][rem6[qp]] << div6[qp];
366 }
367
368 //8.7.3 Scaling process for transform coefficients
369 952114 static const uint8_t* derive_scale_m(const VVCLocalContext *lc, const TransformBlock *tb, uint8_t *scale_m)
370 {
371 //Table 38 – Specification of the scaling matrix identifier variable id according to predMode, cIdx, nTbW, and nTbH
372 952114 const int ids[2][3][6] = {
373 {
374 { 0, 2, 8, 14, 20, 26 },
375 { 0, 3, 9, 15, 21, 21 },
376 { 0, 4, 10, 16, 22, 22 }
377 },
378 {
379 { 0, 5, 11, 17, 23, 27 },
380 { 0, 6, 12, 18, 24, 24 },
381 { 1, 7, 13, 19, 25, 25 },
382 }
383 };
384 952114 const VVCFrameParamSets *ps = &lc->fc->ps;
385 952114 const VVCSPS *sps = ps->sps;
386 952114 const H266RawSliceHeader *rsh = lc->sc->sh.r;
387 952114 const CodingUnit *cu = lc->cu;
388 952114 const VVCScalingList *sl = ps->sl;
389 952114 const int id = ids[cu->pred_mode != MODE_INTRA][tb->c_idx][FFMAX(tb->log2_tb_height, tb->log2_tb_width) - 1];
390
4/4
✓ Branch 0 taken 949263 times.
✓ Branch 1 taken 2851 times.
✓ Branch 2 taken 166682 times.
✓ Branch 3 taken 782581 times.
952114 const int log2_matrix_size = (id < 2) ? 1 : (id < 8) ? 2 : 3;
391 952114 uint8_t *p = scale_m;
392
393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952114 times.
952114 av_assert0(!sps->r->sps_scaling_matrix_for_alternative_colour_space_disabled_flag);
394
395
4/4
✓ Branch 0 taken 99612 times.
✓ Branch 1 taken 852502 times.
✓ Branch 2 taken 97122 times.
✓ Branch 3 taken 2490 times.
952114 if (!rsh->sh_explicit_scaling_list_used_flag || tb->ts ||
396
3/4
✓ Branch 0 taken 97122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31396 times.
✓ Branch 3 taken 65726 times.
97122 sps->r->sps_scaling_matrix_for_lfnst_disabled_flag && cu->apply_lfnst_flag[tb->c_idx])
397 886388 return ff_vvc_default_scale_m;
398
399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65726 times.
65726 if (!sl) {
400 av_log(lc->fc->log_ctx, AV_LOG_WARNING, "bug: no scaling list aps, id = %d", ps->ph.r->ph_scaling_list_aps_id);
401 return ff_vvc_default_scale_m;
402 }
403
404
2/2
✓ Branch 0 taken 326806 times.
✓ Branch 1 taken 65726 times.
392532 for (int y = tb->min_scan_y; y <= tb->max_scan_y; y++) {
405 326806 const int off = y << log2_matrix_size >> tb->log2_tb_height << log2_matrix_size;
406 326806 const uint8_t *m = &sl->scaling_matrix_rec[id][off];
407
408
2/2
✓ Branch 0 taken 1859082 times.
✓ Branch 1 taken 326806 times.
2185888 for (int x = tb->min_scan_x; x <= tb->max_scan_x; x++)
409 1859082 *p++ = m[x << log2_matrix_size >> tb->log2_tb_width];
410 }
411
4/6
✓ Branch 0 taken 27312 times.
✓ Branch 1 taken 38414 times.
✓ Branch 2 taken 27312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27312 times.
✗ Branch 5 not taken.
65726 if (id >= SL_START_16x16 && !tb->min_scan_x && !tb->min_scan_y)
412 27312 *scale_m = sl->scaling_matrix_dc_rec[id - SL_START_16x16];
413
414 65726 return scale_m;
415 }
416
417 //8.7.3 Scaling process for transform coefficients
418 11473467 static av_always_inline int scale_coeff(const TransformBlock *tb, int coeff,
419 const int scale, const int scale_m, const int log2_transform_range)
420 {
421 11473467 coeff = ((int64_t) coeff * scale * scale_m + tb->bd_offset) >> tb->bd_shift;
422 11473467 coeff = av_clip_intp2(coeff, log2_transform_range);
423 11473467 return coeff;
424 }
425
426 952114 static void dequant(const VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
427 {
428 uint8_t tmp[MAX_TB_SIZE * MAX_TB_SIZE];
429 952114 const H266RawSliceHeader *rsh = lc->sc->sh.r;
430 952114 const VVCSPS *sps = lc->fc->ps.sps;
431 952114 const uint8_t *scale_m = derive_scale_m(lc, tb, tmp);
432 int scale;
433
434 952114 derive_qp(lc, tu, tb);
435 952114 scale = derive_scale(tb, rsh->sh_dep_quant_used_flag);
436
437
2/2
✓ Branch 0 taken 3738175 times.
✓ Branch 1 taken 952114 times.
4690289 for (int y = tb->min_scan_y; y <= tb->max_scan_y; y++) {
438
2/2
✓ Branch 0 taken 22650915 times.
✓ Branch 1 taken 3738175 times.
26389090 for (int x = tb->min_scan_x; x <= tb->max_scan_x; x++) {
439 22650915 int *coeff = tb->coeffs + y * tb->tb_width + x;
440
441
2/2
✓ Branch 0 taken 11473467 times.
✓ Branch 1 taken 11177448 times.
22650915 if (*coeff)
442 11473467 *coeff = scale_coeff(tb, *coeff, scale, *scale_m, sps->log2_transform_range);
443 22650915 scale_m++;
444 }
445 }
446 952114 }
447
448 //transmatrix[0][0]
449 #define DCT_A 64
450 907442 static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
451 {
452 907442 const VVCSPS *sps = fc->ps.sps;
453 907442 const int w = tb->tb_width;
454 907442 const int h = tb->tb_height;
455 907442 const size_t nzw = tb->max_scan_x + 1;
456 907442 const size_t nzh = tb->max_scan_y + 1;
457 907442 const int shift[] = { 7, 5 + sps->log2_transform_range - sps->bit_depth };
458
459
9/10
✓ Branch 0 taken 338493 times.
✓ Branch 1 taken 568949 times.
✓ Branch 2 taken 73143 times.
✓ Branch 3 taken 265350 times.
✓ Branch 4 taken 50513 times.
✓ Branch 5 taken 22630 times.
✓ Branch 6 taken 44055 times.
✓ Branch 7 taken 6458 times.
✓ Branch 8 taken 44055 times.
✗ Branch 9 not taken.
907442 if (w == h && nzw == 1 && nzh == 1 && trh == VVC_DCT2 && trv == VVC_DCT2) {
460 44055 const int add[] = { 1 << (shift[0] - 1), 1 << (shift[1] - 1) };
461 44055 const int t = (tb->coeffs[0] * DCT_A + add[0]) >> shift[0];
462 44055 const int dc = (t * DCT_A + add[1]) >> shift[1];
463
464
2/2
✓ Branch 0 taken 15444624 times.
✓ Branch 1 taken 44055 times.
15488679 for (int i = 0; i < w * h; i++)
465 15444624 tb->coeffs[i] = dc;
466
467 44055 return;
468 }
469
470
2/2
✓ Branch 0 taken 4133006 times.
✓ Branch 1 taken 863387 times.
4996393 for (int x = 0; x < nzw; x++)
471 4133006 fc->vvcdsp.itx.itx[trv][tb->log2_tb_height - 1](tb->coeffs + x, w, nzh);
472 863387 scale_clip(tb->coeffs, nzw, w, h, shift[0], sps->log2_transform_range);
473
474
2/2
✓ Branch 0 taken 8934880 times.
✓ Branch 1 taken 863387 times.
9798267 for (int y = 0; y < h; y++)
475 8934880 fc->vvcdsp.itx.itx[trh][tb->log2_tb_width - 1](tb->coeffs + y * w, 1, nzw);
476 863387 scale(tb->coeffs, tb->coeffs, w, h, shift[1]);
477 }
478
479 15847 static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum VVCTxType trh, const enum VVCTxType trv)
480 {
481 15847 const VVCSPS *sps = fc->ps.sps;
482 15847 const int w = tb->tb_width;
483 15847 const int h = tb->tb_height;
484 15847 const size_t nzw = tb->max_scan_x + 1;
485 15847 const size_t nzh = tb->max_scan_y + 1;
486
487
12/12
✓ Branch 0 taken 13087 times.
✓ Branch 1 taken 2760 times.
✓ Branch 2 taken 4804 times.
✓ Branch 3 taken 8283 times.
✓ Branch 4 taken 1935 times.
✓ Branch 5 taken 2869 times.
✓ Branch 6 taken 2760 times.
✓ Branch 7 taken 10218 times.
✓ Branch 8 taken 738 times.
✓ Branch 9 taken 2022 times.
✓ Branch 10 taken 157 times.
✓ Branch 11 taken 581 times.
15847 if ((w > 1 && nzw == 1 && trh == VVC_DCT2) || (h > 1 && nzh == 1 && trv == VVC_DCT2)) {
488 3026 const int shift = 6 + sps->log2_transform_range - sps->bit_depth;
489 3026 const int add = 1 << (shift - 1);
490 3026 const int dc = (tb->coeffs[0] * DCT_A + add) >> shift;
491
492
2/2
✓ Branch 0 taken 97184 times.
✓ Branch 1 taken 3026 times.
100210 for (int i = 0; i < w * h; i++)
493 97184 tb->coeffs[i] = dc;
494
495 3026 return;
496 }
497
498
2/2
✓ Branch 0 taken 10218 times.
✓ Branch 1 taken 2603 times.
12821 if (w > 1)
499 10218 fc->vvcdsp.itx.itx[trh][tb->log2_tb_width - 1](tb->coeffs, 1, nzw);
500 else
501 2603 fc->vvcdsp.itx.itx[trv][tb->log2_tb_height - 1](tb->coeffs, 1, nzh);
502 12821 scale(tb->coeffs, tb->coeffs, w, h, 6 + sps->log2_transform_range - sps->bit_depth);
503 }
504
505 10 static void transform_bdpcm(TransformBlock *tb, const VVCLocalContext *lc, const CodingUnit *cu)
506 {
507 10 const VVCSPS *sps = lc->fc->ps.sps;
508
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 const IntraPredMode mode = tb->c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y;
509 10 const int vertical = mode == INTRA_VERT;
510 10 lc->fc->vvcdsp.itx.transform_bdpcm(tb->coeffs, tb->tb_width, tb->tb_height,
511 10 vertical, sps->log2_transform_range);
512
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if (vertical)
513 4 tb->max_scan_y = tb->tb_height - 1;
514 else
515 6 tb->max_scan_x = tb->tb_width - 1;
516 10 }
517
518 1400823 static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx, const int target_ch_type)
519 {
520 1400823 const VVCFrameContext *fc = lc->fc;
521 1400823 const VVCSPS *sps = fc->ps.sps;
522 1400823 const VVCSH *sh = &lc->sc->sh;
523 1400823 const CodingUnit *cu = lc->cu;
524 1400823 const int ps = fc->ps.sps->pixel_shift;
525 DECLARE_ALIGNED(32, int, temp)[MAX_TB_SIZE * MAX_TB_SIZE];
526
527
2/2
✓ Branch 0 taken 2582084 times.
✓ Branch 1 taken 1400823 times.
3982907 for (int i = 0; i < tu->nb_tbs; i++) {
528 2582084 TransformBlock *tb = &tu->tbs[i];
529 2582084 const int c_idx = tb->c_idx;
530 2582084 const int ch_type = c_idx > 0;
531
532
4/4
✓ Branch 0 taken 1817129 times.
✓ Branch 1 taken 764955 times.
✓ Branch 2 taken 952114 times.
✓ Branch 3 taken 865015 times.
2582084 if (ch_type == target_ch_type && tb->has_coeffs) {
533 952114 const int w = tb->tb_width;
534 952114 const int h = tb->tb_height;
535
7/8
✓ Branch 0 taken 254695 times.
✓ Branch 1 taken 697419 times.
✓ Branch 2 taken 120118 times.
✓ Branch 3 taken 134577 times.
✓ Branch 4 taken 120118 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 118045 times.
✓ Branch 7 taken 2073 times.
952114 const int chroma_scale = ch_type && sh->r->sh_lmcs_used_flag && fc->ps.ph.r->ph_chroma_residual_scale_flag && (w * h > 4);
536 952114 const ptrdiff_t stride = fc->frame->linesize[c_idx];
537 952114 const int hs = sps->hshift[c_idx];
538 952114 const int vs = sps->vshift[c_idx];
539 952114 uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride + ((tb->x0 >> hs) << ps)];
540
541
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 952104 times.
952114 if (cu->bdpcm_flag[tb->c_idx])
542 10 transform_bdpcm(tb, lc, cu);
543 952114 dequant(lc, tu, tb);
544
2/2
✓ Branch 0 taken 923289 times.
✓ Branch 1 taken 28825 times.
952114 if (!tb->ts) {
545 enum VVCTxType trh, trv;
546
547
2/2
✓ Branch 0 taken 171081 times.
✓ Branch 1 taken 752208 times.
923289 if (cu->apply_lfnst_flag[c_idx])
548 171081 ilfnst_transform(lc, tb);
549 923289 derive_transform_type(fc, lc, tb, &trh, &trv);
550
4/4
✓ Branch 0 taken 920529 times.
✓ Branch 1 taken 2760 times.
✓ Branch 2 taken 907442 times.
✓ Branch 3 taken 13087 times.
923289 if (w > 1 && h > 1)
551 907442 itx_2d(fc, tb, trh, trv);
552 else
553 15847 itx_1d(fc, tb, trh, trv);
554 }
555
556
2/2
✓ Branch 0 taken 118045 times.
✓ Branch 1 taken 834069 times.
952114 if (chroma_scale)
557 118045 fc->vvcdsp.intra.lmcs_scale_chroma(lc, temp, tb->coeffs, w, h, cu->x0, cu->y0);
558 // TODO: Address performance issue here by combining transform, lmcs_scale_chroma, and add_residual into one function.
559 // Complete this task before implementing ASM code.
560
2/2
✓ Branch 0 taken 118045 times.
✓ Branch 1 taken 834069 times.
952114 fc->vvcdsp.itx.add_residual(dst, chroma_scale ? temp : tb->coeffs, w, h, stride);
561
562
4/4
✓ Branch 0 taken 64933 times.
✓ Branch 1 taken 887181 times.
✓ Branch 2 taken 52268 times.
✓ Branch 3 taken 12665 times.
952114 if (tu->joint_cbcr_residual_flag && tb->c_idx)
563 52268 add_residual_for_joint_coding_chroma(lc, tu, tb, chroma_scale);
564 }
565 }
566 1400823 }
567
568 938287 static int reconstruct(VVCLocalContext *lc)
569 {
570 938287 VVCFrameContext *fc = lc->fc;
571 938287 CodingUnit *cu = lc->cu;
572 938287 const int start = cu->tree_type == DUAL_TREE_CHROMA;
573
4/4
✓ Branch 0 taken 919159 times.
✓ Branch 1 taken 19128 times.
✓ Branch 2 taken 378348 times.
✓ Branch 3 taken 540811 times.
938287 const int end = fc->ps.sps->r->sps_chroma_format_idc && (cu->tree_type != DUAL_TREE_LUMA);
574
575
2/2
✓ Branch 0 taken 1135478 times.
✓ Branch 1 taken 938287 times.
2073765 for (int ch_type = start; ch_type <= end; ch_type++) {
576 1135478 TransformUnit *tu = cu->tus.head;
577
2/2
✓ Branch 0 taken 1400823 times.
✓ Branch 1 taken 1135478 times.
2536301 for (int i = 0; tu; i++) {
578 1400823 predict_intra(lc, tu, i, ch_type);
579 1400823 itransform(lc, tu, i, ch_type);
580 1400823 tu = tu->next;
581 }
582 }
583 938287 return 0;
584 }
585
586 #define POS(c_idx, x, y) \
587 &fc->frame->data[c_idx][((y) >> fc->ps.sps->vshift[c_idx]) * fc->frame->linesize[c_idx] + \
588 (((x) >> fc->ps.sps->hshift[c_idx]) << fc->ps.sps->pixel_shift)]
589
590 #define IBC_POS(c_idx, x, y) \
591 (fc->tab.ibc_vir_buf[c_idx] + \
592 (x << ps) + (y + ((cu->y0 & ~(sps->ctb_size_y - 1)) >> vs)) * ibc_stride)
593 #define IBC_X(x) ((x) & ((fc->tab.sz.ibc_buffer_width >> hs) - 1))
594 #define IBC_Y(y) ((y) & ((1 << sps->ctb_log2_size_y >> vs) - 1))
595
596 31272 static void intra_block_copy(const VVCLocalContext *lc, const int c_idx)
597 {
598 31272 const CodingUnit *cu = lc->cu;
599 31272 const PredictionUnit *pu = &cu->pu;
600 31272 const VVCFrameContext *fc = lc->fc;
601 31272 const VVCSPS *sps = fc->ps.sps;
602 31272 const Mv *bv = &pu->mi.mv[L0][0];
603 31272 const int hs = sps->hshift[c_idx];
604 31272 const int vs = sps->vshift[c_idx];
605 31272 const int ps = sps->pixel_shift;
606 31272 const int ref_x = IBC_X((cu->x0 >> hs) + (bv->x >> (4 + hs)));
607 31272 const int ref_y = IBC_Y((cu->y0 >> vs) + (bv->y >> (4 + vs)));
608 31272 const int w = cu->cb_width >> hs;
609 31272 const int h = cu->cb_height >> vs;
610 31272 const int ibc_buf_width = fc->tab.sz.ibc_buffer_width >> hs; ///< IbcBufWidthY and IbcBufWidthC
611 31272 const int rw = FFMIN(w, ibc_buf_width - ref_x);
612 31272 const int ibc_stride = ibc_buf_width << ps;
613 31272 const int dst_stride = fc->frame->linesize[c_idx];
614 31272 const uint8_t *ibc_buf = IBC_POS(c_idx, ref_x, ref_y);
615 31272 uint8_t *dst = POS(c_idx, cu->x0, cu->y0);
616
617 31272 av_image_copy_plane(dst, dst_stride, ibc_buf, ibc_stride, rw << ps, h);
618
619
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 31241 times.
31272 if (w > rw) {
620 //wrap around, left part
621 31 ibc_buf = IBC_POS(c_idx, 0, ref_y);
622 31 dst += rw << ps;
623 31 av_image_copy_plane(dst, dst_stride, ibc_buf, ibc_stride, (w - rw) << ps, h);
624 }
625 31272 }
626
627 31182 static void vvc_predict_ibc(const VVCLocalContext *lc)
628 {
629 31182 const H266RawSPS *rsps = lc->fc->ps.sps->r;
630
631 31182 intra_block_copy(lc, LUMA);
632
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 31137 times.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
31182 if (lc->cu->tree_type == SINGLE_TREE && rsps->sps_chroma_format_idc) {
633 45 intra_block_copy(lc, CB);
634 45 intra_block_copy(lc, CR);
635 }
636 31182 }
637
638 127411 static void ibc_fill_vir_buf(const VVCLocalContext *lc, const CodingUnit *cu)
639 {
640 127411 const VVCFrameContext *fc = lc->fc;
641 127411 const VVCSPS *sps = fc->ps.sps;
642
3/4
✓ Branch 0 taken 127411 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44943 times.
✓ Branch 3 taken 82468 times.
127411 const int has_chroma = sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA;
643 127411 const int start = cu->tree_type == DUAL_TREE_CHROMA;
644
2/2
✓ Branch 0 taken 44943 times.
✓ Branch 1 taken 82468 times.
127411 const int end = has_chroma ? CR : LUMA;
645
646
2/2
✓ Branch 0 taken 195820 times.
✓ Branch 1 taken 127411 times.
323231 for (int c_idx = start; c_idx <= end; c_idx++) {
647 195820 const int hs = sps->hshift[c_idx];
648 195820 const int vs = sps->vshift[c_idx];
649 195820 const int ps = sps->pixel_shift;
650 195820 const int x = IBC_X(cu->x0 >> hs);
651 195820 const int y = IBC_Y(cu->y0 >> vs);
652 195820 const int src_stride = fc->frame->linesize[c_idx];
653 195820 const int ibc_stride = fc->tab.sz.ibc_buffer_width >> hs << ps;
654 195820 const uint8_t *src = POS(c_idx, cu->x0, cu->y0);
655 195820 uint8_t *ibc_buf = IBC_POS(c_idx, x, y);
656
657 195820 av_image_copy_plane(ibc_buf, ibc_stride, src, src_stride, cu->cb_width >> hs << ps , cu->cb_height >> vs);
658 }
659 127411 }
660
661 46713 int ff_vvc_reconstruct(VVCLocalContext *lc, const int rs, const int rx, const int ry)
662 {
663 46713 const VVCFrameContext *fc = lc->fc;
664 46713 const VVCSPS *sps = fc->ps.sps;
665 46713 const int x_ctb = rx << sps->ctb_log2_size_y;
666 46713 const int y_ctb = ry << sps->ctb_log2_size_y;
667 46713 CodingUnit *cu = fc->tab.cus[rs];
668 46713 int ret = 0;
669
670 46713 lc->num_ras[0] = lc->num_ras[1] = 0;
671 46713 lc->lmcs.x_vpdu = -1;
672 46713 lc->lmcs.y_vpdu = -1;
673 46713 ff_vvc_decode_neighbour(lc, x_ctb, y_ctb, rx, ry, rs);
674
2/2
✓ Branch 0 taken 1233121 times.
✓ Branch 1 taken 46713 times.
1279834 while (cu) {
675 1233121 lc->cu = cu;
676
677
2/2
✓ Branch 0 taken 15686 times.
✓ Branch 1 taken 1217435 times.
1233121 if (cu->ciip_flag)
678 15686 ff_vvc_predict_ciip(lc);
679
2/2
✓ Branch 0 taken 31182 times.
✓ Branch 1 taken 1186253 times.
1217435 else if (cu->pred_mode == MODE_IBC)
680 31182 vvc_predict_ibc(lc);
681
2/2
✓ Branch 0 taken 938287 times.
✓ Branch 1 taken 294834 times.
1233121 if (cu->coded_flag) {
682 938287 ret = reconstruct(lc);
683 } else {
684
1/2
✓ Branch 0 taken 294834 times.
✗ Branch 1 not taken.
294834 if (cu->tree_type != DUAL_TREE_CHROMA)
685 294834 add_reconstructed_area(lc, LUMA, cu->x0, cu->y0, cu->cb_width, cu->cb_height);
686
4/4
✓ Branch 0 taken 278323 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 252629 times.
✓ Branch 3 taken 25694 times.
294834 if (sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA)
687 252629 add_reconstructed_area(lc, CHROMA, cu->x0, cu->y0, cu->cb_width, cu->cb_height);
688 }
689
2/2
✓ Branch 0 taken 127411 times.
✓ Branch 1 taken 1105710 times.
1233121 if (sps->r->sps_ibc_enabled_flag)
690 127411 ibc_fill_vir_buf(lc, cu);
691 1233121 cu = cu->next;
692 }
693 46713 ff_vvc_ctu_free_cus(fc->tab.cus + rs);
694 46713 return ret;
695 }
696
697