FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vvc/intra.c
Date: 2024-05-04 02:01:39
Exec Total Coverage
Lines: 424 432 98.1%
Functions: 26 26 100.0%
Branches: 261 286 91.3%

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 271491 static int is_cclm(enum IntraPredMode mode)
31 {
32
6/6
✓ Branch 0 taken 229110 times.
✓ Branch 1 taken 42381 times.
✓ Branch 2 taken 215756 times.
✓ Branch 3 taken 13354 times.
✓ Branch 4 taken 15114 times.
✓ Branch 5 taken 200642 times.
271491 return mode == INTRA_LT_CCLM || mode == INTRA_L_CCLM || mode == INTRA_T_CCLM;
33 }
34
35 119963 static int derive_ilfnst_pred_mode_intra(const VVCLocalContext *lc, const TransformBlock *tb)
36 {
37 119963 const VVCFrameContext *fc = lc->fc;
38 119963 const VVCSPS *sps = fc->ps.sps;
39 119963 const CodingUnit *cu = lc->cu;
40 119963 const int x_tb = tb->x0 >> fc->ps.sps->min_cb_log2_size_y;
41 119963 const int y_tb = tb->y0 >> fc->ps.sps->min_cb_log2_size_y;
42 119963 const int x_c = (tb->x0 + (tb->tb_width << sps->hshift[1] >> 1) ) >> fc->ps.sps->min_cb_log2_size_y;
43 119963 const int y_c = (tb->y0 + (tb->tb_height << sps->vshift[1] >> 1)) >> fc->ps.sps->min_cb_log2_size_y;
44 119963 const int min_cb_width = fc->ps.pps->min_cb_width;
45 119963 const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_tb, y_tb);
46
2/2
✓ Branch 0 taken 89100 times.
✓ Branch 1 taken 30863 times.
119963 int pred_mode_intra = tb->c_idx == 0 ? cu->intra_pred_mode_y : cu->intra_pred_mode_c;
47
4/4
✓ Branch 0 taken 13695 times.
✓ Branch 1 taken 106268 times.
✓ Branch 2 taken 4170 times.
✓ Branch 3 taken 9525 times.
119963 if (intra_mip_flag && !tb->c_idx) {
48 4170 pred_mode_intra = INTRA_PLANAR;
49
2/2
✓ Branch 1 taken 9586 times.
✓ Branch 2 taken 106207 times.
115793 } else if (is_cclm(pred_mode_intra)) {
50 9586 int intra_mip_flag_c = SAMPLE_CTB(fc->tab.imf, x_c, y_c);
51 9586 int cu_pred_mode = SAMPLE_CTB(fc->tab.cpm[0], x_c, y_c);
52
2/2
✓ Branch 0 taken 2936 times.
✓ Branch 1 taken 6650 times.
9586 if (intra_mip_flag_c) {
53 2936 pred_mode_intra = INTRA_PLANAR;
54
2/4
✓ Branch 0 taken 6650 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6650 times.
6650 } else if (cu_pred_mode == MODE_IBC || cu_pred_mode == MODE_PLT) {
55 pred_mode_intra = INTRA_DC;
56 } else {
57 6650 pred_mode_intra = SAMPLE_CTB(fc->tab.ipm, x_c, y_c);
58 }
59 }
60 119963 pred_mode_intra = ff_vvc_wide_angle_mode_mapping(cu, tb->tb_width, tb->tb_height, tb->c_idx, pred_mode_intra);
61
62 119963 return pred_mode_intra;
63 }
64
65 //8.7.4 Transformation process for scaled transform coefficients
66 119963 static void ilfnst_transform(const VVCLocalContext *lc, TransformBlock *tb)
67 {
68 119963 const VVCSPS *sps = lc->fc->ps.sps;
69 119963 const CodingUnit *cu = lc->cu;
70 119963 const int w = tb->tb_width;
71 119963 const int h = tb->tb_height;
72
4/4
✓ Branch 0 taken 76302 times.
✓ Branch 1 taken 43661 times.
✓ Branch 2 taken 53298 times.
✓ Branch 3 taken 23004 times.
119963 const int n_lfnst_out_size = (w >= 8 && h >= 8) ? 48 : 16; ///< nLfnstOutSize
73
4/4
✓ Branch 0 taken 76302 times.
✓ Branch 1 taken 43661 times.
✓ Branch 2 taken 53298 times.
✓ Branch 3 taken 23004 times.
119963 const int log2_lfnst_size = (w >= 8 && h >= 8) ? 3 : 2; ///< log2LfnstSize
74 119963 const int n_lfnst_size = 1 << log2_lfnst_size; ///< nLfnstSize
75
8/8
✓ Branch 0 taken 28249 times.
✓ Branch 1 taken 91714 times.
✓ Branch 2 taken 19673 times.
✓ Branch 3 taken 8576 times.
✓ Branch 4 taken 43661 times.
✓ Branch 5 taken 67726 times.
✓ Branch 6 taken 27823 times.
✓ Branch 7 taken 15838 times.
119963 const int non_zero_size = ((w == 8 && h == 8) || (w == 4 && h == 4)) ? 8 : 16; ///< nonZeroSize
76 119963 const int pred_mode_intra = derive_ilfnst_pred_mode_intra(lc, tb);
77 119963 const int transpose = pred_mode_intra > 34;
78 int u[16], v[48];
79
80
2/2
✓ Branch 0 taken 1628216 times.
✓ Branch 1 taken 119963 times.
1748179 for (int x = 0; x < non_zero_size; x++) {
81 1628216 int xc = ff_vvc_diag_scan_x[2][2][x];
82 1628216 int yc = ff_vvc_diag_scan_y[2][2][x];
83 1628216 u[x] = tb->coeffs[w * yc + xc];
84 }
85 119963 ff_vvc_inv_lfnst_1d(v, u, non_zero_size, n_lfnst_out_size, pred_mode_intra,
86 119963 cu->lfnst_idx, sps->log2_transform_range);
87
2/2
✓ Branch 0 taken 33011 times.
✓ Branch 1 taken 86952 times.
119963 if (transpose) {
88 33011 int *dst = tb->coeffs;
89 33011 const int *src = v;
90
2/2
✓ Branch 0 taken 21381 times.
✓ Branch 1 taken 11630 times.
33011 if (n_lfnst_size == 4) {
91
2/2
✓ Branch 0 taken 85524 times.
✓ Branch 1 taken 21381 times.
106905 for (int y = 0; y < 4; y++) {
92 85524 dst[0] = src[0];
93 85524 dst[1] = src[4];
94 85524 dst[2] = src[8];
95 85524 dst[3] = src[12];
96 85524 src++;
97 85524 dst += w;
98 }
99 } else {
100
2/2
✓ Branch 0 taken 93040 times.
✓ Branch 1 taken 11630 times.
104670 for (int y = 0; y < 8; y++) {
101 93040 dst[0] = src[0];
102 93040 dst[1] = src[8];
103 93040 dst[2] = src[16];
104 93040 dst[3] = src[24];
105
2/2
✓ Branch 0 taken 46520 times.
✓ Branch 1 taken 46520 times.
93040 if (y < 4) {
106 46520 dst[4] = src[32];
107 46520 dst[5] = src[36];
108 46520 dst[6] = src[40];
109 46520 dst[7] = src[44];
110 }
111 93040 src++;
112 93040 dst += w;
113 }
114 }
115
116 } else {
117 86952 int *dst = tb->coeffs;
118 86952 const int *src = v;
119
2/2
✓ Branch 0 taken 514480 times.
✓ Branch 1 taken 86952 times.
601432 for (int y = 0; y < n_lfnst_size; y++) {
120
2/2
✓ Branch 0 taken 347808 times.
✓ Branch 1 taken 166672 times.
514480 int size = (y < 4) ? n_lfnst_size : 4;
121 514480 memcpy(dst, src, size * sizeof(int));
122 514480 src += size;
123 514480 dst += w;
124 }
125 }
126 119963 tb->max_scan_x = n_lfnst_size - 1;
127 119963 tb->max_scan_y = n_lfnst_size - 1;
128 119963 }
129
130 //part of 8.7.4 Transformation process for scaled transform coefficients
131 649936 static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalContext *lc, const TransformBlock *tb, enum TxType *trh, enum TxType *trv)
132 {
133 649936 const CodingUnit *cu = lc->cu;
134 static const enum TxType mts_to_trh[] = {DCT2, DST7, DCT8, DST7, DCT8};
135 static const enum TxType mts_to_trv[] = {DCT2, DST7, DST7, DCT8, DCT8};
136 649936 const VVCSPS *sps = fc->ps.sps;
137 649936 int implicit_mts_enabled = 0;
138
6/6
✓ Branch 0 taken 499904 times.
✓ Branch 1 taken 150032 times.
✓ Branch 2 taken 106271 times.
✓ Branch 3 taken 393633 times.
✓ Branch 4 taken 25777 times.
✓ Branch 5 taken 80494 times.
649936 if (tb->c_idx || (cu->isp_split_type != ISP_NO_SPLIT && cu->lfnst_idx)) {
139 175809 *trh = *trv = DCT2;
140 175809 return;
141 }
142
143
2/2
✓ Branch 0 taken 471540 times.
✓ Branch 1 taken 2587 times.
474127 if (sps->r->sps_mts_enabled_flag) {
144
2/2
✓ Branch 0 taken 391046 times.
✓ Branch 1 taken 80494 times.
471540 if (cu->isp_split_type != ISP_NO_SPLIT ||
145
4/4
✓ Branch 0 taken 30600 times.
✓ Branch 1 taken 360446 times.
✓ Branch 2 taken 465 times.
✓ Branch 3 taken 30135 times.
391046 (cu->sbt_flag && FFMAX(tb->tb_width, tb->tb_height) <= 32) ||
146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 360911 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
360911 (!sps->r->sps_explicit_mts_intra_enabled_flag && cu->pred_mode == MODE_INTRA &&
147 !cu->lfnst_idx && !cu->intra_mip_flag)) {
148 110629 implicit_mts_enabled = 1;
149 }
150 }
151
2/2
✓ Branch 0 taken 110629 times.
✓ Branch 1 taken 363498 times.
474127 if (implicit_mts_enabled) {
152 110629 const int w = tb->tb_width;
153 110629 const int h = tb->tb_height;
154
2/2
✓ Branch 0 taken 30135 times.
✓ Branch 1 taken 80494 times.
110629 if (cu->sbt_flag) {
155
4/4
✓ Branch 0 taken 15734 times.
✓ Branch 1 taken 14401 times.
✓ Branch 2 taken 7341 times.
✓ Branch 3 taken 8393 times.
30135 *trh = (cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? DST7 : DCT8;
156
4/4
✓ Branch 0 taken 14401 times.
✓ Branch 1 taken 15734 times.
✓ Branch 2 taken 6930 times.
✓ Branch 3 taken 7471 times.
30135 *trv = (!cu->sbt_horizontal_flag || cu->sbt_pos_flag) ? DST7 : DCT8;
157 } else {
158
4/4
✓ Branch 0 taken 66546 times.
✓ Branch 1 taken 13948 times.
✓ Branch 2 taken 50615 times.
✓ Branch 3 taken 15931 times.
80494 *trh = (w >= 4 && w <= 16) ? DST7 : DCT2;
159
4/4
✓ Branch 0 taken 47416 times.
✓ Branch 1 taken 33078 times.
✓ Branch 2 taken 45598 times.
✓ Branch 3 taken 1818 times.
80494 *trv = (h >= 4 && h <= 16) ? DST7 : DCT2;
160 }
161 110629 return;
162 }
163 363498 *trh = mts_to_trh[cu->mts_idx];
164 363498 *trv = mts_to_trv[cu->mts_idx];
165 }
166
167 25858 static void add_residual_for_joint_coding_chroma(VVCLocalContext *lc,
168 const TransformUnit *tu, TransformBlock *tb, const int chroma_scale)
169 {
170 25858 const VVCFrameContext *fc = lc->fc;
171 25858 const CodingUnit *cu = lc->cu;
172 25858 const int c_sign = 1 - 2 * fc->ps.ph.r->ph_joint_cbcr_sign_flag;
173 25858 const int shift = tu->coded_flag[1] ^ tu->coded_flag[2];
174 25858 const int c_idx = 1 + tu->coded_flag[1];
175 25858 const ptrdiff_t stride = fc->frame->linesize[c_idx];
176 25858 const int hs = fc->ps.sps->hshift[c_idx];
177 25858 const int vs = fc->ps.sps->vshift[c_idx];
178 25858 uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride +
179 25858 ((tb->x0 >> hs) << fc->ps.sps->pixel_shift)];
180
2/2
✓ Branch 0 taken 11146 times.
✓ Branch 1 taken 14712 times.
25858 if (chroma_scale) {
181 11146 fc->vvcdsp.itx.pred_residual_joint(tb->coeffs, tb->tb_width, tb->tb_height, c_sign, shift);
182 11146 fc->vvcdsp.intra.lmcs_scale_chroma(lc, tb->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, cu->x0, cu->y0);
183 11146 fc->vvcdsp.itx.add_residual(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride);
184 } else {
185 14712 fc->vvcdsp.itx.add_residual_joint(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride, c_sign, shift);
186 }
187 25858 }
188
189 1503928 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 1503928 const VVCSPS *sps = lc->fc->ps.sps;
192 1503928 const int hs = sps->hshift[ch_type];
193 1503928 const int vs = sps->vshift[ch_type];
194 ReconstructedArea *a;
195
196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1503928 times.
1503928 if (lc->num_ras[ch_type] >= FF_ARRAY_ELEMS(lc->ras[ch_type]))
197 return AVERROR_INVALIDDATA;
198
199 1503928 a = &lc->ras[ch_type][lc->num_ras[ch_type]];
200 1503928 a->x = x0 >> hs;
201 1503928 a->y = y0 >> vs;
202 1503928 a->w = w >> hs;
203 1503928 a->h = h >> vs;
204 1503928 lc->num_ras[ch_type]++;
205
206 1503928 return 0;
207 }
208
209 663984 static void add_tu_area(const TransformUnit *tu, int *x0, int *y0, int *w, int *h)
210 {
211 663984 *x0 = tu->x0;
212 663984 *y0 = tu->y0;
213 663984 *w = tu->width;
214 663984 *h = tu->height;
215 663984 }
216
217 #define MIN_ISP_PRED_WIDTH 4
218 513371 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 513371 int has_luma = 1;
221 513371 add_tu_area(tu, x0, y0, w, h);
222
4/4
✓ Branch 0 taken 56702 times.
✓ Branch 1 taken 456669 times.
✓ Branch 2 taken 20028 times.
✓ Branch 3 taken 36674 times.
513371 if (cu->isp_split_type == ISP_VER_SPLIT && tu->width < MIN_ISP_PRED_WIDTH) {
223 20028 *w = MIN_ISP_PRED_WIDTH;
224 20028 has_luma = !(idx % (MIN_ISP_PRED_WIDTH / tu->width));
225 }
226 513371 return has_luma;
227 }
228
229 170899 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 150613 times.
✓ Branch 1 taken 20286 times.
170899 if (cu->isp_split_type == ISP_NO_SPLIT) {
232 150613 add_tu_area(tu, x0, y0, w, h);
233 150613 return 1;
234 }
235
2/2
✓ Branch 0 taken 5085 times.
✓ Branch 1 taken 15201 times.
20286 if (idx == cu->num_intra_subpartitions - 1) {
236 5085 *x0 = cu->x0;
237 5085 *y0 = cu->y0;
238 5085 *w = cu->cb_width;
239 5085 *h = cu->cb_height;
240 5085 return 1;
241 }
242 15201 return 0;
243 }
244
245 //8.4.5.1 General decoding process for intra blocks
246 1027373 static void predict_intra(VVCLocalContext *lc, const TransformUnit *tu, const int idx, const int target_ch_type)
247 {
248 1027373 const VVCFrameContext *fc = lc->fc;
249 1027373 const CodingUnit *cu = lc->cu;
250 1027373 const VVCTreeType tree_type = cu->tree_type;
251 int x0, y0, w, h;
252
2/2
✓ Branch 0 taken 343103 times.
✓ Branch 1 taken 684270 times.
1027373 if (cu->pred_mode != MODE_INTRA) {
253 343103 add_reconstructed_area(lc, target_ch_type, tu->x0, tu->y0, tu->width, tu->height);
254 343103 return;
255 }
256
3/4
✓ Branch 0 taken 513371 times.
✓ Branch 1 taken 170899 times.
✓ Branch 2 taken 513371 times.
✗ Branch 3 not taken.
684270 if (!target_ch_type && tree_type != DUAL_TREE_CHROMA) {
257
2/2
✓ Branch 1 taken 502574 times.
✓ Branch 2 taken 10797 times.
513371 if (get_luma_predict_unit(cu, tu, idx, &x0, &y0, &w, &h)) {
258 502574 ff_vvc_set_neighbour_available(lc, x0, y0, w, h);
259 502574 fc->vvcdsp.intra.intra_pred(lc, x0, y0, w, h, 0);
260 502574 add_reconstructed_area(lc, 0, x0, y0, w, h);
261 }
262 }
263
3/4
✓ Branch 0 taken 170899 times.
✓ Branch 1 taken 513371 times.
✓ Branch 2 taken 170899 times.
✗ Branch 3 not taken.
684270 if (target_ch_type && tree_type != DUAL_TREE_LUMA) {
264
2/2
✓ Branch 1 taken 155698 times.
✓ Branch 2 taken 15201 times.
170899 if (get_chroma_predict_unit(cu, tu, idx, &x0, &y0, &w, &h)){
265 155698 ff_vvc_set_neighbour_available(lc, x0, y0, w, h);
266
2/2
✓ Branch 1 taken 61263 times.
✓ Branch 2 taken 94435 times.
155698 if (is_cclm(cu->intra_pred_mode_c)) {
267 61263 fc->vvcdsp.intra.intra_cclm_pred(lc, x0, y0, w, h);
268 } else {
269 94435 fc->vvcdsp.intra.intra_pred(lc, x0, y0, w, h, 1);
270 94435 fc->vvcdsp.intra.intra_pred(lc, x0, y0, w, h, 2);
271 }
272 155698 add_reconstructed_area(lc, 1, x0, y0, w, h);
273 }
274 }
275 }
276
277 610624 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 610624 const int add = 1 << (shift - 1);
281
2/2
✓ Branch 0 taken 6749576 times.
✓ Branch 1 taken 610624 times.
7360200 for (int y = 0; y < h; y++) {
282 6749576 int *p = coeff + y * w;
283
2/2
✓ Branch 0 taken 36569506 times.
✓ Branch 1 taken 6749576 times.
43319082 for (int x = 0; x < nzw; x++) {
284 36569506 *p = av_clip_intp2((*p + add) >> shift, log2_transform_range);
285 36569506 p++;
286 }
287 6749576 memset(p, 0, sizeof(*p) * (w - nzw));
288 }
289 610624 }
290
291 620560 static void scale(int *out, const int *in, const int w, const int h, const int shift)
292 {
293 620560 const int add = 1 << (shift - 1);
294
2/2
✓ Branch 0 taken 6791178 times.
✓ Branch 1 taken 620560 times.
7411738 for (int y = 0; y < h; y++) {
295
2/2
✓ Branch 0 taken 118179952 times.
✓ Branch 1 taken 6791178 times.
124971130 for (int x = 0; x < w; x++) {
296 118179952 int *o = out + y * w + x;
297 118179952 const int *i = in + y * w + x;
298 118179952 *o = (*i + add) >> shift;
299 }
300 }
301 620560 }
302
303 // part of 8.7.3 Scaling process for transform coefficients
304 672930 static void derive_qp(const VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
305 {
306 672930 const VVCSPS *sps = lc->fc->ps.sps;
307 672930 const H266RawSliceHeader *rsh = lc->sc->sh.r;
308 672930 const CodingUnit *cu = lc->cu;
309 int qp, qp_act_offset;
310
311
2/2
✓ Branch 0 taken 520246 times.
✓ Branch 1 taken 152684 times.
672930 if (tb->c_idx == 0) {
312 //fix me
313 520246 qp = cu->qp[LUMA] + sps->qp_bd_offset;
314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520246 times.
520246 qp_act_offset = cu->act_enabled_flag ? -5 : 0;
315 } else {
316
6/6
✓ Branch 0 taken 25858 times.
✓ Branch 1 taken 126826 times.
✓ Branch 2 taken 20550 times.
✓ Branch 3 taken 5308 times.
✓ Branch 4 taken 9917 times.
✓ Branch 5 taken 10633 times.
152684 const int is_jcbcr = tu->joint_cbcr_residual_flag && tu->coded_flag[CB] && tu->coded_flag[CR];
317
2/2
✓ Branch 0 taken 142767 times.
✓ Branch 1 taken 9917 times.
152684 const int idx = is_jcbcr ? JCBCR : tb->c_idx;
318 152684 qp = cu->qp[idx];
319 152684 qp_act_offset = cu->act_enabled_flag ? 1 : 0;
320 }
321
2/2
✓ Branch 0 taken 22994 times.
✓ Branch 1 taken 649936 times.
672930 if (tb->ts) {
322 22994 const int qp_prime_ts_min = 4 + 6 * sps->r->sps_min_qp_prime_ts;
323
324 22994 tb->qp = av_clip(qp + qp_act_offset, qp_prime_ts_min, 63 + sps->qp_bd_offset);
325 22994 tb->rect_non_ts_flag = 0;
326 22994 tb->bd_shift = 10;
327 } else {
328 649936 const int log_sum = tb->log2_tb_width + tb->log2_tb_height;
329 649936 const int rect_non_ts_flag = log_sum & 1;
330
331 649936 tb->qp = av_clip(qp + qp_act_offset, 0, 63 + sps->qp_bd_offset);
332 649936 tb->rect_non_ts_flag = rect_non_ts_flag;
333 649936 tb->bd_shift = sps->bit_depth + rect_non_ts_flag + (log_sum / 2)
334 649936 + 10 - sps->log2_transform_range + rsh->sh_dep_quant_used_flag;
335 }
336 672930 tb->bd_offset = (1 << tb->bd_shift) >> 1;
337 672930 }
338
339 //8.7.3 Scaling process for transform coefficients
340 672930 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
3/4
✓ Branch 0 taken 672930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 649936 times.
✓ Branch 3 taken 22994 times.
672930 const int addin = sh_dep_quant_used_flag && !tb->ts;
363 672930 const int qp = tb->qp + addin;
364
365 672930 return level_scale[tb->rect_non_ts_flag][rem6[qp]] << div6[qp];
366 }
367
368 //8.7.3 Scaling process for transform coefficients
369 672930 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 672930 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 672930 const VVCFrameParamSets *ps = &lc->fc->ps;
385 672930 const VVCSPS *sps = ps->sps;
386 672930 const H266RawSliceHeader *rsh = lc->sc->sh.r;
387 672930 const CodingUnit *cu = lc->cu;
388 672930 const VVCScalingList *sl = ps->sl;
389 672930 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 672668 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 90690 times.
✓ Branch 3 taken 581978 times.
672930 const int log2_matrix_size = (id < 2) ? 1 : (id < 8) ? 2 : 3;
391 672930 uint8_t *p = scale_m;
392
393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 672930 times.
672930 av_assert0(!sps->r->sps_scaling_matrix_for_alternative_colour_space_disabled_flag);
394
395
4/4
✓ Branch 0 taken 28021 times.
✓ Branch 1 taken 644909 times.
✓ Branch 2 taken 25822 times.
✓ Branch 3 taken 2199 times.
672930 if (!rsh->sh_explicit_scaling_list_used_flag || tb->ts ||
396
3/4
✓ Branch 0 taken 25822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13008 times.
✓ Branch 3 taken 12814 times.
25822 sps->r->sps_scaling_matrix_for_lfnst_disabled_flag && cu->apply_lfnst_flag[tb->c_idx])
397 660116 return ff_vvc_default_scale_m;
398
399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12814 times.
12814 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 36051 times.
✓ Branch 1 taken 12814 times.
48865 for (int y = tb->min_scan_y; y <= tb->max_scan_y; y++) {
405 36051 const int off = y << log2_matrix_size >> tb->log2_tb_height << log2_matrix_size;
406 36051 const uint8_t *m = &sl->scaling_matrix_rec[id][off];
407
408
2/2
✓ Branch 0 taken 131310 times.
✓ Branch 1 taken 36051 times.
167361 for (int x = tb->min_scan_x; x <= tb->max_scan_x; x++)
409 131310 *p++ = m[x << log2_matrix_size >> tb->log2_tb_width];
410 }
411
4/6
✓ Branch 0 taken 5189 times.
✓ Branch 1 taken 7625 times.
✓ Branch 2 taken 5189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5189 times.
✗ Branch 5 not taken.
12814 if (id >= SL_START_16x16 && !tb->min_scan_x && !tb->min_scan_y)
412 5189 *scale_m = sl->scaling_matrix_dc_rec[id - SL_START_16x16];
413
414 12814 return scale_m;
415 }
416
417 //8.7.3 Scaling process for transform coefficients
418 7875554 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 7875554 coeff = ((int64_t) coeff * scale * scale_m + tb->bd_offset) >> tb->bd_shift;
422 7875554 coeff = av_clip_intp2(coeff, log2_transform_range);
423 7875554 return coeff;
424 }
425
426 672930 static void dequant(const VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
427 {
428 uint8_t tmp[MAX_TB_SIZE * MAX_TB_SIZE];
429 672930 const H266RawSliceHeader *rsh = lc->sc->sh.r;
430 672930 const VVCSPS *sps = lc->fc->ps.sps;
431 672930 const uint8_t *scale_m = derive_scale_m(lc, tb, tmp);
432 int scale;
433
434 672930 derive_qp(lc, tu, tb);
435 672930 scale = derive_scale(tb, rsh->sh_dep_quant_used_flag);
436
437
2/2
✓ Branch 0 taken 2554887 times.
✓ Branch 1 taken 672930 times.
3227817 for (int y = tb->min_scan_y; y <= tb->max_scan_y; y++) {
438
2/2
✓ Branch 0 taken 15626673 times.
✓ Branch 1 taken 2554887 times.
18181560 for (int x = tb->min_scan_x; x <= tb->max_scan_x; x++) {
439 15626673 int *coeff = tb->coeffs + y * tb->tb_width + x;
440
441
2/2
✓ Branch 0 taken 7875554 times.
✓ Branch 1 taken 7751119 times.
15626673 if (*coeff)
442 7875554 *coeff = scale_coeff(tb, *coeff, scale, *scale_m, sps->log2_transform_range);
443 15626673 scale_m++;
444 }
445 }
446 672930 }
447
448 //transmatrix[0][0]
449 #define DCT_A 64
450 637516 static void itx_2d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxType trh, const enum TxType trv)
451 {
452 637516 const VVCSPS *sps = fc->ps.sps;
453 637516 const int w = tb->tb_width;
454 637516 const int h = tb->tb_height;
455 637516 const size_t nzw = tb->max_scan_x + 1;
456 637516 const size_t nzh = tb->max_scan_y + 1;
457 637516 const int shift[] = { 7, 5 + sps->log2_transform_range - sps->bit_depth };
458
459
9/10
✓ Branch 0 taken 209234 times.
✓ Branch 1 taken 428282 times.
✓ Branch 2 taken 42968 times.
✓ Branch 3 taken 166266 times.
✓ Branch 4 taken 31162 times.
✓ Branch 5 taken 11806 times.
✓ Branch 6 taken 26892 times.
✓ Branch 7 taken 4270 times.
✓ Branch 8 taken 26892 times.
✗ Branch 9 not taken.
637516 if (w == h && nzw == 1 && nzh == 1 && trh == DCT2 && trv == DCT2) {
460 26892 const int add[] = { 1 << (shift[0] - 1), 1 << (shift[1] - 1) };
461 26892 const int t = (tb->coeffs[0] * DCT_A + add[0]) >> shift[0];
462 26892 const int dc = (t * DCT_A + add[1]) >> shift[1];
463
464
2/2
✓ Branch 0 taken 12054768 times.
✓ Branch 1 taken 26892 times.
12081660 for (int i = 0; i < w * h; i++)
465 12054768 tb->coeffs[i] = dc;
466
467 26892 return;
468 }
469
470
2/2
✓ Branch 0 taken 2968659 times.
✓ Branch 1 taken 610624 times.
3579283 for (int x = 0; x < nzw; x++)
471 2968659 fc->vvcdsp.itx.itx[trv][tb->log2_tb_height - 1](tb->coeffs + x, w, nzh);
472 610624 scale_clip(tb->coeffs, nzw, w, h, shift[0], sps->log2_transform_range);
473
474
2/2
✓ Branch 0 taken 6749576 times.
✓ Branch 1 taken 610624 times.
7360200 for (int y = 0; y < h; y++)
475 6749576 fc->vvcdsp.itx.itx[trh][tb->log2_tb_width - 1](tb->coeffs + y * w, 1, nzw);
476 610624 scale(tb->coeffs, tb->coeffs, w, h, shift[1]);
477 }
478
479 12420 static void itx_1d(const VVCFrameContext *fc, TransformBlock *tb, const enum TxType trh, const enum TxType trv)
480 {
481 12420 const VVCSPS *sps = fc->ps.sps;
482 12420 const int w = tb->tb_width;
483 12420 const int h = tb->tb_height;
484 12420 const size_t nzw = tb->max_scan_x + 1;
485 12420 const size_t nzh = tb->max_scan_y + 1;
486
487
12/12
✓ Branch 0 taken 10339 times.
✓ Branch 1 taken 2081 times.
✓ Branch 2 taken 3930 times.
✓ Branch 3 taken 6409 times.
✓ Branch 4 taken 1561 times.
✓ Branch 5 taken 2369 times.
✓ Branch 6 taken 2081 times.
✓ Branch 7 taken 7970 times.
✓ Branch 8 taken 559 times.
✓ Branch 9 taken 1522 times.
✓ Branch 10 taken 115 times.
✓ Branch 11 taken 444 times.
12420 if ((w > 1 && nzw == 1 && trh == DCT2) || (h > 1 && nzh == 1 && trv == DCT2)) {
488 2484 const int shift = 6 + sps->log2_transform_range - sps->bit_depth;
489 2484 const int add = 1 << (shift - 1);
490 2484 const int dc = (tb->coeffs[0] * DCT_A + add) >> shift;
491
492
2/2
✓ Branch 0 taken 79840 times.
✓ Branch 1 taken 2484 times.
82324 for (int i = 0; i < w * h; i++)
493 79840 tb->coeffs[i] = dc;
494
495 2484 return;
496 }
497
498
2/2
✓ Branch 0 taken 7970 times.
✓ Branch 1 taken 1966 times.
9936 if (w > 1)
499 7970 fc->vvcdsp.itx.itx[trh][tb->log2_tb_width - 1](tb->coeffs, 1, nzw);
500 else
501 1966 fc->vvcdsp.itx.itx[trv][tb->log2_tb_height - 1](tb->coeffs, 1, nzh);
502 9936 scale(tb->coeffs, tb->coeffs, w, h, 6 + sps->log2_transform_range - sps->bit_depth);
503 }
504
505 9 static void transform_bdpcm(TransformBlock *tb, const VVCLocalContext *lc, const CodingUnit *cu)
506 {
507 9 const VVCSPS *sps = lc->fc->ps.sps;
508
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 const IntraPredMode mode = tb->c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y;
509 9 const int vertical = mode == INTRA_VERT;
510 9 lc->fc->vvcdsp.itx.transform_bdpcm(tb->coeffs, tb->tb_width, tb->tb_height,
511 9 vertical, sps->log2_transform_range);
512
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if (vertical)
513 3 tb->max_scan_y = tb->tb_height - 1;
514 else
515 6 tb->max_scan_x = tb->tb_width - 1;
516 9 }
517
518 1027373 static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx, const int target_ch_type)
519 {
520 1027373 const VVCFrameContext *fc = lc->fc;
521 1027373 const VVCSPS *sps = fc->ps.sps;
522 1027373 const VVCSH *sh = &lc->sc->sh;
523 1027373 const CodingUnit *cu = lc->cu;
524 1027373 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 1974709 times.
✓ Branch 1 taken 1027373 times.
3002082 for (int i = 0; i < tu->nb_tbs; i++) {
528 1974709 TransformBlock *tb = &tu->tbs[i];
529 1974709 const int c_idx = tb->c_idx;
530 1974709 const int ch_type = c_idx > 0;
531
532
4/4
✓ Branch 0 taken 1336399 times.
✓ Branch 1 taken 638310 times.
✓ Branch 2 taken 672930 times.
✓ Branch 3 taken 663469 times.
1974709 if (ch_type == target_ch_type && tb->has_coeffs) {
533 672930 const int w = tb->tb_width;
534 672930 const int h = tb->tb_height;
535
7/8
✓ Branch 0 taken 152684 times.
✓ Branch 1 taken 520246 times.
✓ Branch 2 taken 74173 times.
✓ Branch 3 taken 78511 times.
✓ Branch 4 taken 74173 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74002 times.
✓ Branch 7 taken 171 times.
672930 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 672930 const ptrdiff_t stride = fc->frame->linesize[c_idx];
537 672930 const int hs = sps->hshift[c_idx];
538 672930 const int vs = sps->vshift[c_idx];
539 672930 uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride + ((tb->x0 >> hs) << ps)];
540
541
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 672921 times.
672930 if (cu->bdpcm_flag[tb->c_idx])
542 9 transform_bdpcm(tb, lc, cu);
543 672930 dequant(lc, tu, tb);
544
2/2
✓ Branch 0 taken 649936 times.
✓ Branch 1 taken 22994 times.
672930 if (!tb->ts) {
545 enum TxType trh, trv;
546
547
2/2
✓ Branch 0 taken 119963 times.
✓ Branch 1 taken 529973 times.
649936 if (cu->apply_lfnst_flag[c_idx])
548 119963 ilfnst_transform(lc, tb);
549 649936 derive_transform_type(fc, lc, tb, &trh, &trv);
550
4/4
✓ Branch 0 taken 647855 times.
✓ Branch 1 taken 2081 times.
✓ Branch 2 taken 637516 times.
✓ Branch 3 taken 10339 times.
649936 if (w > 1 && h > 1)
551 637516 itx_2d(fc, tb, trh, trv);
552 else
553 12420 itx_1d(fc, tb, trh, trv);
554 }
555
556
2/2
✓ Branch 0 taken 74002 times.
✓ Branch 1 taken 598928 times.
672930 if (chroma_scale)
557 74002 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 74002 times.
✓ Branch 1 taken 598928 times.
672930 fc->vvcdsp.itx.add_residual(dst, chroma_scale ? temp : tb->coeffs, w, h, stride);
561
562
4/4
✓ Branch 0 taken 30032 times.
✓ Branch 1 taken 642898 times.
✓ Branch 2 taken 25858 times.
✓ Branch 3 taken 4174 times.
672930 if (tu->joint_cbcr_residual_flag && tb->c_idx)
563 25858 add_residual_for_joint_coding_chroma(lc, tu, tb, chroma_scale);
564 }
565 }
566 1027373 }
567
568 655498 static int reconstruct(VVCLocalContext *lc)
569 {
570 655498 VVCFrameContext *fc = lc->fc;
571 655498 CodingUnit *cu = lc->cu;
572 655498 const int start = cu->tree_type == DUAL_TREE_CHROMA;
573
4/4
✓ Branch 0 taken 638462 times.
✓ Branch 1 taken 17036 times.
✓ Branch 2 taken 286665 times.
✓ Branch 3 taken 351797 times.
655498 const int end = fc->ps.sps->r->sps_chroma_format_idc && (cu->tree_type != DUAL_TREE_LUMA);
574
575
2/2
✓ Branch 0 taken 825639 times.
✓ Branch 1 taken 655498 times.
1481137 for (int ch_type = start; ch_type <= end; ch_type++) {
576 825639 TransformUnit *tu = cu->tus.head;
577
2/2
✓ Branch 0 taken 1027373 times.
✓ Branch 1 taken 825639 times.
1853012 for (int i = 0; tu; i++) {
578 1027373 predict_intra(lc, tu, i, ch_type);
579 1027373 itransform(lc, tu, i, ch_type);
580 1027373 tu = tu->next;
581 }
582 }
583 655498 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 1660 static void intra_block_copy(const VVCLocalContext *lc, const int c_idx)
597 {
598 1660 const CodingUnit *cu = lc->cu;
599 1660 const PredictionUnit *pu = &cu->pu;
600 1660 const VVCFrameContext *fc = lc->fc;
601 1660 const VVCSPS *sps = fc->ps.sps;
602 1660 const Mv *bv = &pu->mi.mv[L0][0];
603 1660 const int hs = sps->hshift[c_idx];
604 1660 const int vs = sps->vshift[c_idx];
605 1660 const int ps = sps->pixel_shift;
606 1660 const int ref_x = IBC_X((cu->x0 >> hs) + (bv->x >> (4 + hs)));
607 1660 const int ref_y = IBC_Y((cu->y0 >> vs) + (bv->y >> (4 + vs)));
608 1660 const int w = cu->cb_width >> hs;
609 1660 const int h = cu->cb_height >> vs;
610 1660 const int ibc_buf_width = fc->tab.sz.ibc_buffer_width >> hs; ///< IbcBufWidthY and IbcBufWidthC
611 1660 const int rw = FFMIN(w, ibc_buf_width - ref_x);
612 1660 const int ibc_stride = ibc_buf_width << ps;
613 1660 const int dst_stride = fc->frame->linesize[c_idx];
614 1660 const uint8_t *ibc_buf = IBC_POS(c_idx, ref_x, ref_y);
615 1660 uint8_t *dst = POS(c_idx, cu->x0, cu->y0);
616
617 1660 av_image_copy_plane(dst, dst_stride, ibc_buf, ibc_stride, rw << ps, h);
618
619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1660 times.
1660 if (w > rw) {
620 //wrap around, left part
621 ibc_buf = IBC_POS(c_idx, 0, ref_y);
622 dst += rw << ps;
623 av_image_copy_plane(dst, dst_stride, ibc_buf, ibc_stride, (w - rw) << ps, h);
624 }
625 1660 }
626
627 1582 static void vvc_predict_ibc(const VVCLocalContext *lc)
628 {
629 1582 const H266RawSPS *rsps = lc->fc->ps.sps->r;
630
631 1582 intra_block_copy(lc, LUMA);
632
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1543 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
1582 if (lc->cu->tree_type == SINGLE_TREE && rsps->sps_chroma_format_idc) {
633 39 intra_block_copy(lc, CB);
634 39 intra_block_copy(lc, CR);
635 }
636 1582 }
637
638 3578 static void ibc_fill_vir_buf(const VVCLocalContext *lc, const CodingUnit *cu)
639 {
640 3578 const VVCFrameContext *fc = lc->fc;
641 3578 const VVCSPS *sps = fc->ps.sps;
642
3/4
✓ Branch 0 taken 3578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1190 times.
✓ Branch 3 taken 2388 times.
3578 const int has_chroma = sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA;
643 3578 const int start = cu->tree_type == DUAL_TREE_CHROMA;
644
2/2
✓ Branch 0 taken 1190 times.
✓ Branch 1 taken 2388 times.
3578 const int end = has_chroma ? CR : LUMA;
645
646
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 3578 times.
9329 for (int c_idx = start; c_idx <= end; c_idx++) {
647 5751 const int hs = sps->hshift[c_idx];
648 5751 const int vs = sps->vshift[c_idx];
649 5751 const int ps = sps->pixel_shift;
650 5751 const int x = IBC_X(cu->x0 >> hs);
651 5751 const int y = IBC_Y(cu->y0 >> vs);
652 5751 const int src_stride = fc->frame->linesize[c_idx];
653 5751 const int ibc_stride = fc->tab.sz.ibc_buffer_width >> hs << ps;
654 5751 const uint8_t *src = POS(c_idx, cu->x0, cu->y0);
655 5751 uint8_t *ibc_buf = IBC_POS(c_idx, x, y);
656
657 5751 av_image_copy_plane(ibc_buf, ibc_stride, src, src_stride, cu->cb_width >> hs << ps , cu->cb_height >> vs);
658 }
659 3578 }
660
661 42891 int ff_vvc_reconstruct(VVCLocalContext *lc, const int rs, const int rx, const int ry)
662 {
663 42891 const VVCFrameContext *fc = lc->fc;
664 42891 const VVCSPS *sps = fc->ps.sps;
665 42891 const int x_ctb = rx << sps->ctb_log2_size_y;
666 42891 const int y_ctb = ry << sps->ctb_log2_size_y;
667 42891 CTU *ctu = fc->tab.ctus + rs;
668 42891 CodingUnit *cu = ctu->cus;
669 42891 int ret = 0;
670
671 42891 lc->num_ras[0] = lc->num_ras[1] = 0;
672 42891 lc->lmcs.x_vpdu = -1;
673 42891 lc->lmcs.y_vpdu = -1;
674 42891 ff_vvc_decode_neighbour(lc, x_ctb, y_ctb, rx, ry, rs);
675
2/2
✓ Branch 0 taken 915428 times.
✓ Branch 1 taken 42891 times.
958319 while (cu) {
676 915428 lc->cu = cu;
677
678
2/2
✓ Branch 0 taken 15407 times.
✓ Branch 1 taken 900021 times.
915428 if (cu->ciip_flag)
679 15407 ff_vvc_predict_ciip(lc);
680
2/2
✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 898439 times.
900021 else if (cu->pred_mode == MODE_IBC)
681 1582 vvc_predict_ibc(lc);
682
2/2
✓ Branch 0 taken 655498 times.
✓ Branch 1 taken 259930 times.
915428 if (cu->coded_flag) {
683 655498 ret = reconstruct(lc);
684 } else {
685
1/2
✓ Branch 0 taken 259930 times.
✗ Branch 1 not taken.
259930 if (cu->tree_type != DUAL_TREE_CHROMA)
686 259930 add_reconstructed_area(lc, LUMA, cu->x0, cu->y0, cu->cb_width, cu->cb_height);
687
4/4
✓ Branch 0 taken 243419 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 242623 times.
✓ Branch 3 taken 796 times.
259930 if (sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA)
688 242623 add_reconstructed_area(lc, CHROMA, cu->x0, cu->y0, cu->cb_width, cu->cb_height);
689 }
690
2/2
✓ Branch 0 taken 3578 times.
✓ Branch 1 taken 911850 times.
915428 if (sps->r->sps_ibc_enabled_flag)
691 3578 ibc_fill_vir_buf(lc, cu);
692 915428 cu = cu->next;
693 }
694 42891 ff_vvc_ctu_free_cus(ctu);
695 42891 return ret;
696 }
697
698