Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * VVC CTU(Coding Tree Unit) parser | ||
3 | * | ||
4 | * Copyright (C) 2022 Nuo Mi | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #include "libavcodec/refstruct.h" | ||
24 | |||
25 | #include "cabac.h" | ||
26 | #include "ctu.h" | ||
27 | #include "inter.h" | ||
28 | #include "mvs.h" | ||
29 | |||
30 | #define PROF_TEMP_SIZE (PROF_BLOCK_SIZE) * sizeof(int16_t) | ||
31 | |||
32 | #define TAB_MSM(fc, depth, x, y) fc->tab.msm[(depth)][((y) >> 5) * fc->ps.pps->width32 + ((x) >> 5)] | ||
33 | #define TAB_ISPMF(fc, x, y) fc->tab.ispmf[((y) >> 6) * fc->ps.pps->width64 + ((x) >> 6)] | ||
34 | |||
35 | typedef enum VVCModeType { | ||
36 | MODE_TYPE_ALL, | ||
37 | MODE_TYPE_INTER, | ||
38 | MODE_TYPE_INTRA, | ||
39 | } VVCModeType; | ||
40 | |||
41 | 1877088 | static void set_tb_size(const VVCFrameContext *fc, const TransformBlock *tb) | |
42 | { | ||
43 | 1877088 | const int x_tb = tb->x0 >> MIN_TU_LOG2; | |
44 | 1877088 | const int y_tb = tb->y0 >> MIN_TU_LOG2; | |
45 | 1877088 | const int hs = fc->ps.sps->hshift[tb->c_idx]; | |
46 | 1877088 | const int vs = fc->ps.sps->vshift[tb->c_idx]; | |
47 | 1877088 | const int is_chroma = tb->c_idx != 0; | |
48 | 1877088 | const int width = FFMAX(1, tb->tb_width >> (MIN_TU_LOG2 - hs)); | |
49 | 1877088 | const int end = y_tb + FFMAX(1, tb->tb_height >> (MIN_TU_LOG2 - vs)); | |
50 | |||
51 |
2/2✓ Branch 0 taken 9241724 times.
✓ Branch 1 taken 1877088 times.
|
11118812 | for (int y = y_tb; y < end; y++) { |
52 | 9241724 | const int off = y * fc->ps.pps->min_tu_width + x_tb; | |
53 | 9241724 | memset(fc->tab.tb_width [is_chroma] + off, tb->tb_width, width); | |
54 | 9241724 | memset(fc->tab.tb_height[is_chroma] + off, tb->tb_height, width); | |
55 | } | ||
56 | 1877088 | } | |
57 | |||
58 | 2613252 | static void set_tb_tab(uint8_t *tab, uint8_t v, const VVCFrameContext *fc, | |
59 | const TransformBlock *tb) | ||
60 | { | ||
61 | 2613252 | const int width = tb->tb_width << fc->ps.sps->hshift[tb->c_idx]; | |
62 | 2613252 | const int height = tb->tb_height << fc->ps.sps->vshift[tb->c_idx]; | |
63 | |||
64 |
2/2✓ Branch 0 taken 12568830 times.
✓ Branch 1 taken 2613252 times.
|
15182082 | for (int h = 0; h < height; h += MIN_TU_SIZE) { |
65 | 12568830 | const int y = (tb->y0 + h) >> MIN_TU_LOG2; | |
66 | 12568830 | const int off = y * fc->ps.pps->min_tu_width + (tb->x0 >> MIN_TU_LOG2); | |
67 | 12568830 | const int w = FFMAX(1, width >> MIN_TU_LOG2); | |
68 | 12568830 | memset(tab + off, v, w); | |
69 | } | ||
70 | 2613252 | } | |
71 | |||
72 | // 8.7.1 Derivation process for quantization parameters | ||
73 | 1736 | static int get_qp_y_pred(const VVCLocalContext *lc) | |
74 | { | ||
75 | 1736 | const VVCFrameContext *fc = lc->fc; | |
76 | 1736 | const VVCSPS *sps = fc->ps.sps; | |
77 | 1736 | const VVCPPS *pps = fc->ps.pps; | |
78 | 1736 | const CodingUnit *cu = lc->cu; | |
79 | 1736 | const int ctb_log2_size = sps->ctb_log2_size_y; | |
80 | 1736 | const int ctb_size_mask = (1 << ctb_log2_size) - 1; | |
81 | 1736 | const int xQg = lc->parse.cu_qg_top_left_x; | |
82 | 1736 | const int yQg = lc->parse.cu_qg_top_left_y; | |
83 | 1736 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
84 | 1736 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
85 | 1736 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
86 | 1736 | const int rx = cu->x0 >> ctb_log2_size; | |
87 | 1736 | const int ry = cu->y0 >> ctb_log2_size; | |
88 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1736 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1736 | const int in_same_ctb_a = ((xQg - 1) >> ctb_log2_size) == rx && (yQg >> ctb_log2_size) == ry; |
89 |
2/4✓ Branch 0 taken 1736 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1736 times.
|
1736 | const int in_same_ctb_b = (xQg >> ctb_log2_size) == rx && ((yQg - 1) >> ctb_log2_size) == ry; |
90 | int qPy_pred, qPy_a, qPy_b; | ||
91 | |||
92 |
2/2✓ Branch 0 taken 1240 times.
✓ Branch 1 taken 496 times.
|
1736 | if (lc->na.cand_up) { |
93 |
2/4✓ Branch 0 taken 1240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1240 times.
✗ Branch 3 not taken.
|
1240 | const int first_qg_in_ctu = !(xQg & ctb_size_mask) && !(yQg & ctb_size_mask); |
94 | 1240 | const int qPy_up = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
95 |
3/4✓ Branch 0 taken 1240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 1054 times.
|
1240 | if (first_qg_in_ctu && pps->ctb_to_col_bd[xQg >> ctb_log2_size] == xQg >> ctb_log2_size) |
96 | 186 | return qPy_up; | |
97 | } | ||
98 | |||
99 | // qPy_pred | ||
100 |
2/2✓ Branch 0 taken 93 times.
✓ Branch 1 taken 1457 times.
|
1550 | qPy_pred = lc->ep->is_first_qg ? lc->sc->sh.slice_qp_y : lc->ep->qp_y; |
101 | |||
102 | // qPy_b | ||
103 |
3/4✓ Branch 0 taken 1054 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 1054 times.
✗ Branch 3 not taken.
|
1550 | if (!lc->na.cand_up || !in_same_ctb_b) |
104 | 1550 | qPy_b = qPy_pred; | |
105 | else | ||
106 | ✗ | qPy_b = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
107 | |||
108 | // qPy_a | ||
109 |
3/4✓ Branch 0 taken 1457 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 1457 times.
✗ Branch 3 not taken.
|
1550 | if (!lc->na.cand_left || !in_same_ctb_a) |
110 | 1550 | qPy_a = qPy_pred; | |
111 | else | ||
112 | ✗ | qPy_a = fc->tab.qp[LUMA][(x_cb - 1) + y_cb * min_cb_width]; | |
113 | |||
114 | av_assert2(qPy_a >= -fc->ps.sps->qp_bd_offset && qPy_a <= 63); | ||
115 | av_assert2(qPy_b >= -fc->ps.sps->qp_bd_offset && qPy_b <= 63); | ||
116 | |||
117 | 1550 | return (qPy_a + qPy_b + 1) >> 1; | |
118 | } | ||
119 | |||
120 | 8004377 | static void set_cb_tab(const VVCLocalContext *lc, uint8_t *tab, const uint8_t v) | |
121 | { | ||
122 | 8004377 | const VVCFrameContext *fc = lc->fc; | |
123 | 8004377 | const VVCPPS *pps = fc->ps.pps; | |
124 | 8004377 | const CodingUnit *cu = lc->cu; | |
125 | 8004377 | const int log2_min_cb_size = fc->ps.sps->min_cb_log2_size_y; | |
126 | 8004377 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
127 | 8004377 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
128 | 8004377 | const int cb_width = cu->cb_width; | |
129 | 8004377 | const int cb_height = cu->cb_height; | |
130 | 8004377 | int x = y_cb * pps->min_cb_width + x_cb; | |
131 | |||
132 |
2/2✓ Branch 0 taken 35690812 times.
✓ Branch 1 taken 8004377 times.
|
43695189 | for (int y = 0; y < (cb_height >> log2_min_cb_size); y++) { |
133 | 35690812 | const int width = cb_width >> log2_min_cb_size; | |
134 | |||
135 | 35690812 | memset(&tab[x], v, width); | |
136 | 35690812 | x += pps->min_cb_width; | |
137 | } | ||
138 | 8004377 | } | |
139 | |||
140 | 1128012 | static int set_qp_y(VVCLocalContext *lc, const int x0, const int y0, const int has_qp_delta) | |
141 | { | ||
142 | 1128012 | const VVCSPS *sps = lc->fc->ps.sps; | |
143 | 1128012 | EntryPoint *ep = lc->ep; | |
144 | 1128012 | CodingUnit *cu = lc->cu; | |
145 | 1128012 | int cu_qp_delta = 0; | |
146 | |||
147 |
2/2✓ Branch 0 taken 1079795 times.
✓ Branch 1 taken 48217 times.
|
1128012 | if (!lc->fc->ps.pps->r->pps_cu_qp_delta_enabled_flag) { |
148 | 1079795 | ep->qp_y = lc->sc->sh.slice_qp_y; | |
149 |
6/6✓ Branch 0 taken 48124 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 6338 times.
✓ Branch 3 taken 41786 times.
✓ Branch 4 taken 1643 times.
✓ Branch 5 taken 4695 times.
|
48217 | } else if (ep->is_first_qg || (lc->parse.cu_qg_top_left_x == x0 && lc->parse.cu_qg_top_left_y == y0)) { |
150 | 1736 | ep->qp_y = get_qp_y_pred(lc); | |
151 | 1736 | ep->is_first_qg = 0; | |
152 | } | ||
153 | |||
154 |
2/2✓ Branch 0 taken 859 times.
✓ Branch 1 taken 1127153 times.
|
1128012 | if (has_qp_delta) { |
155 | 859 | const int cu_qp_delta_abs = ff_vvc_cu_qp_delta_abs(lc); | |
156 | |||
157 |
2/2✓ Branch 0 taken 190 times.
✓ Branch 1 taken 669 times.
|
859 | if (cu_qp_delta_abs) |
158 |
2/2✓ Branch 1 taken 96 times.
✓ Branch 2 taken 94 times.
|
190 | cu_qp_delta = ff_vvc_cu_qp_delta_sign_flag(lc) ? -cu_qp_delta_abs : cu_qp_delta_abs; |
159 |
2/4✓ Branch 0 taken 859 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 859 times.
|
859 | if (cu_qp_delta > (31 + sps->qp_bd_offset / 2) || cu_qp_delta < -(32 + sps->qp_bd_offset / 2)) |
160 | ✗ | return AVERROR_INVALIDDATA; | |
161 | 859 | lc->parse.is_cu_qp_delta_coded = 1; | |
162 | |||
163 |
2/2✓ Branch 0 taken 190 times.
✓ Branch 1 taken 669 times.
|
859 | if (cu_qp_delta) { |
164 | 190 | int off = sps->qp_bd_offset; | |
165 |
1/2✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
|
190 | ep->qp_y = FFUMOD(ep->qp_y + cu_qp_delta + 64 + 2 * off, 64 + off) - off; |
166 | } | ||
167 | } | ||
168 | |||
169 | 1128012 | set_cb_tab(lc, lc->fc->tab.qp[LUMA], ep->qp_y); | |
170 | 1128012 | cu->qp[LUMA] = ep->qp_y; | |
171 | |||
172 | 1128012 | return 0; | |
173 | } | ||
174 | |||
175 | 1373942 | static void set_qp_c_tab(const VVCLocalContext *lc, const TransformUnit *tu, const TransformBlock *tb) | |
176 | { | ||
177 |
6/6✓ Branch 0 taken 66654 times.
✓ Branch 1 taken 1307288 times.
✓ Branch 2 taken 52920 times.
✓ Branch 3 taken 13734 times.
✓ Branch 4 taken 24580 times.
✓ Branch 5 taken 28340 times.
|
1373942 | const int is_jcbcr = tu->joint_cbcr_residual_flag && tu->coded_flag[CB] && tu->coded_flag[CR]; |
178 |
2/2✓ Branch 0 taken 1349362 times.
✓ Branch 1 taken 24580 times.
|
1373942 | const int idx = is_jcbcr ? JCBCR : tb->c_idx; |
179 | |||
180 | 1373942 | set_tb_tab(lc->fc->tab.qp[tb->c_idx], lc->cu->qp[idx], lc->fc, tb); | |
181 | 1373942 | } | |
182 | |||
183 | 1090570 | static void set_qp_c(VVCLocalContext *lc) | |
184 | { | ||
185 | 1090570 | const VVCFrameContext *fc = lc->fc; | |
186 | 1090570 | const VVCSPS *sps = fc->ps.sps; | |
187 | 1090570 | const VVCPPS *pps = fc->ps.pps; | |
188 | 1090570 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
189 | 1090570 | CodingUnit *cu = lc->cu; | |
190 | 1090570 | const int x_center = cu->x0 + cu->cb_width / 2; | |
191 | 1090570 | const int y_center = cu->y0 + cu->cb_height / 2; | |
192 | 1090570 | const int single_tree = cu->tree_type == SINGLE_TREE; | |
193 |
2/2✓ Branch 0 taken 446926 times.
✓ Branch 1 taken 643644 times.
|
1090570 | const int qp_luma = (single_tree ? lc->ep->qp_y : ff_vvc_get_qPy(fc, x_center, y_center)) + sps->qp_bd_offset; |
194 | 1090570 | const int qp_chroma = av_clip(qp_luma, 0, MAX_QP + sps->qp_bd_offset); | |
195 | 1090570 | const int sh_chroma_qp_offset[] = { | |
196 | 1090570 | rsh->sh_cb_qp_offset, | |
197 | 1090570 | rsh->sh_cr_qp_offset, | |
198 | 1090570 | rsh->sh_joint_cbcr_qp_offset, | |
199 | }; | ||
200 | int qp; | ||
201 | |||
202 |
2/2✓ Branch 0 taken 3228815 times.
✓ Branch 1 taken 1090570 times.
|
4319385 | for (int i = CB - 1; i < CR + sps->r->sps_joint_cbcr_enabled_flag; i++) { |
203 | 3228815 | qp = sps->chroma_qp_table[i][qp_chroma]; | |
204 | 3228815 | qp = qp + pps->chroma_qp_offset[i] + sh_chroma_qp_offset[i] + lc->parse.chroma_qp_offset[i]; | |
205 | 3228815 | qp = av_clip(qp, -sps->qp_bd_offset, MAX_QP) + sps->qp_bd_offset; | |
206 | 3228815 | cu->qp[i + 1] = qp; | |
207 | } | ||
208 | 1090570 | } | |
209 | |||
210 | 1349398 | static TransformUnit* alloc_tu(VVCFrameContext *fc, CodingUnit *cu) | |
211 | { | ||
212 | 1349398 | TransformUnit *tu = ff_refstruct_pool_get(fc->tu_pool); | |
213 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1349398 times.
|
1349398 | if (!tu) |
214 | ✗ | return NULL; | |
215 | |||
216 | 1349398 | tu->next = NULL; | |
217 | |||
218 |
2/2✓ Branch 0 taken 241521 times.
✓ Branch 1 taken 1107877 times.
|
1349398 | if (cu->tus.tail) |
219 | 241521 | cu->tus.tail->next = tu; | |
220 | else | ||
221 | 1107877 | cu->tus.head = tu; | |
222 | 1349398 | cu->tus.tail = tu; | |
223 | |||
224 | 1349398 | return tu; | |
225 | } | ||
226 | |||
227 | 1349398 | static TransformUnit* add_tu(VVCFrameContext *fc, CodingUnit *cu, const int x0, const int y0, const int tu_width, const int tu_height) | |
228 | { | ||
229 | 1349398 | TransformUnit *tu = alloc_tu(fc, cu); | |
230 | |||
231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1349398 times.
|
1349398 | if (!tu) |
232 | ✗ | return NULL; | |
233 | |||
234 | 1349398 | tu->x0 = x0; | |
235 | 1349398 | tu->y0 = y0; | |
236 | 1349398 | tu->width = tu_width; | |
237 | 1349398 | tu->height = tu_height; | |
238 | 1349398 | tu->joint_cbcr_residual_flag = 0; | |
239 | 1349398 | memset(tu->coded_flag, 0, sizeof(tu->coded_flag)); | |
240 | 1349398 | tu->avail[LUMA] = tu->avail[CHROMA] = 0; | |
241 | 1349398 | tu->nb_tbs = 0; | |
242 | |||
243 | 1349398 | return tu; | |
244 | } | ||
245 | |||
246 | 2564059 | static TransformBlock* add_tb(TransformUnit *tu, VVCLocalContext *lc, | |
247 | const int x0, const int y0, const int tb_width, const int tb_height, const int c_idx) | ||
248 | { | ||
249 | TransformBlock *tb; | ||
250 | |||
251 | 2564059 | tb = &tu->tbs[tu->nb_tbs++]; | |
252 | 2564059 | tb->has_coeffs = 0; | |
253 | 2564059 | tb->x0 = x0; | |
254 | 2564059 | tb->y0 = y0; | |
255 | 2564059 | tb->tb_width = tb_width; | |
256 | 2564059 | tb->tb_height = tb_height; | |
257 | 2564059 | tb->log2_tb_width = av_log2(tb_width); | |
258 | 2564059 | tb->log2_tb_height = av_log2(tb_height); | |
259 | |||
260 | 2564059 | tb->max_scan_x = tb->max_scan_y = 0; | |
261 | 2564059 | tb->min_scan_x = tb->min_scan_y = 0; | |
262 | |||
263 | 2564059 | tb->c_idx = c_idx; | |
264 | 2564059 | tb->ts = 0; | |
265 | 2564059 | tb->coeffs = lc->coeffs; | |
266 | 2564059 | lc->coeffs += tb_width * tb_height; | |
267 | 2564059 | tu->avail[!!c_idx] = true; | |
268 | 2564059 | return tb; | |
269 | } | ||
270 | |||
271 | 861930 | static uint8_t tu_y_coded_flag_decode(VVCLocalContext *lc, const int is_sbt_not_coded, | |
272 | const int sub_tu_index, const int is_isp, const int is_chroma_coded) | ||
273 | { | ||
274 | 861930 | uint8_t tu_y_coded_flag = 0; | |
275 | 861930 | const VVCSPS *sps = lc->fc->ps.sps; | |
276 | 861930 | CodingUnit *cu = lc->cu; | |
277 | |||
278 |
2/2✓ Branch 0 taken 824624 times.
✓ Branch 1 taken 37306 times.
|
861930 | if (!is_sbt_not_coded) { |
279 |
4/4✓ Branch 0 taken 684287 times.
✓ Branch 1 taken 140337 times.
✓ Branch 2 taken 49921 times.
✓ Branch 3 taken 634366 times.
|
824624 | int has_y_coded_flag = sub_tu_index < cu->num_intra_subpartitions - 1 || !lc->parse.infer_tu_cbf_luma; |
280 |
2/2✓ Branch 0 taken 622678 times.
✓ Branch 1 taken 201946 times.
|
824624 | if (!is_isp) { |
281 |
4/4✓ Branch 0 taken 620466 times.
✓ Branch 1 taken 2212 times.
✓ Branch 2 taken 486 times.
✓ Branch 3 taken 619980 times.
|
622678 | const int is_large = cu->cb_width > sps->max_tb_size_y || cu->cb_height > sps->max_tb_size_y; |
282 |
7/8✓ Branch 0 taken 481429 times.
✓ Branch 1 taken 141249 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 481429 times.
✓ Branch 4 taken 102129 times.
✓ Branch 5 taken 39120 times.
✓ Branch 6 taken 2298 times.
✓ Branch 7 taken 99831 times.
|
622678 | has_y_coded_flag = (cu->pred_mode == MODE_INTRA && !cu->act_enabled_flag) || is_chroma_coded || is_large; |
283 | } | ||
284 |
2/2✓ Branch 0 taken 713105 times.
✓ Branch 1 taken 111519 times.
|
824624 | tu_y_coded_flag = has_y_coded_flag ? ff_vvc_tu_y_coded_flag(lc) : 1; |
285 | } | ||
286 |
2/2✓ Branch 0 taken 201946 times.
✓ Branch 1 taken 659984 times.
|
861930 | if (is_isp) |
287 |
4/4✓ Branch 0 taken 100512 times.
✓ Branch 1 taken 101434 times.
✓ Branch 2 taken 38903 times.
✓ Branch 3 taken 61609 times.
|
201946 | lc->parse.infer_tu_cbf_luma = lc->parse.infer_tu_cbf_luma && !tu_y_coded_flag; |
288 | 861930 | return tu_y_coded_flag; | |
289 | } | ||
290 | |||
291 | 414968 | static void chroma_qp_offset_decode(VVCLocalContext *lc, const int is_128, const int is_chroma_coded) | |
292 | { | ||
293 | 414968 | const VVCPPS *pps = lc->fc->ps.pps; | |
294 | 414968 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
295 | |||
296 |
4/4✓ Branch 0 taken 412270 times.
✓ Branch 1 taken 2698 times.
✓ Branch 2 taken 152317 times.
✓ Branch 3 taken 259953 times.
|
414968 | if ((is_128 || is_chroma_coded) && |
297 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 155015 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
155015 | rsh->sh_cu_chroma_qp_offset_enabled_flag && !lc->parse.is_cu_chroma_qp_offset_coded) { |
298 | ✗ | const int cu_chroma_qp_offset_flag = ff_vvc_cu_chroma_qp_offset_flag(lc); | |
299 | ✗ | if (cu_chroma_qp_offset_flag) { | |
300 | ✗ | int cu_chroma_qp_offset_idx = 0; | |
301 | ✗ | if (pps->r->pps_chroma_qp_offset_list_len_minus1 > 0) | |
302 | ✗ | cu_chroma_qp_offset_idx = ff_vvc_cu_chroma_qp_offset_idx(lc); | |
303 | ✗ | for (int i = CB - 1; i < JCBCR; i++) | |
304 | ✗ | lc->parse.chroma_qp_offset[i] = pps->chroma_qp_offset_list[cu_chroma_qp_offset_idx][i]; | |
305 | } else { | ||
306 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
307 | } | ||
308 | ✗ | lc->parse.is_cu_chroma_qp_offset_coded = 1; | |
309 | } | ||
310 | 414968 | } | |
311 | |||
312 | 1021211 | static int hls_transform_unit(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int sub_tu_index, int ch_type) | |
313 | { | ||
314 | 1021211 | VVCFrameContext *fc = lc->fc; | |
315 | 1021211 | const VVCSPS *sps = fc->ps.sps; | |
316 | 1021211 | const VVCPPS *pps = fc->ps.pps; | |
317 | 1021211 | CodingUnit *cu = lc->cu; | |
318 | 1021211 | TransformUnit *tu = add_tu(fc, cu, x0, y0, tu_width, tu_height); | |
319 | 1021211 | const int min_cb_width = pps->min_cb_width; | |
320 | 1021211 | const VVCTreeType tree_type = cu->tree_type; | |
321 |
4/4✓ Branch 0 taken 1018999 times.
✓ Branch 1 taken 2212 times.
✓ Branch 2 taken 486 times.
✓ Branch 3 taken 1018513 times.
|
1021211 | const int is_128 = cu->cb_width > 64 || cu->cb_height > 64; |
322 | 1021211 | const int is_isp = cu->isp_split_type != ISP_NO_SPLIT; | |
323 |
4/4✓ Branch 0 taken 201946 times.
✓ Branch 1 taken 819265 times.
✓ Branch 2 taken 61609 times.
✓ Branch 3 taken 140337 times.
|
1021211 | const int is_isp_last_tu = is_isp && (sub_tu_index == cu->num_intra_subpartitions - 1); |
324 |
4/4✓ Branch 0 taken 74612 times.
✓ Branch 1 taken 946599 times.
✓ Branch 2 taken 37306 times.
✓ Branch 3 taken 37306 times.
|
1095823 | const int is_sbt_not_coded = cu->sbt_flag && |
325 |
6/6✓ Branch 0 taken 19540 times.
✓ Branch 1 taken 17766 times.
✓ Branch 2 taken 37306 times.
✓ Branch 3 taken 19540 times.
✓ Branch 4 taken 19540 times.
✓ Branch 5 taken 17766 times.
|
74612 | ((sub_tu_index == 0 && cu->sbt_pos_flag) || (sub_tu_index == 1 && !cu->sbt_pos_flag)); |
326 |
6/6✓ Branch 0 taken 414968 times.
✓ Branch 1 taken 606243 times.
✓ Branch 2 taken 391496 times.
✓ Branch 3 taken 23472 times.
✓ Branch 4 taken 20558 times.
✓ Branch 5 taken 370938 times.
|
1041769 | const int chroma_available = tree_type != DUAL_TREE_LUMA && sps->r->sps_chroma_format_idc && |
327 |
2/2✓ Branch 0 taken 5153 times.
✓ Branch 1 taken 15405 times.
|
20558 | (!is_isp || is_isp_last_tu); |
328 | int ret, xc, yc, wc, hc, is_chroma_coded; | ||
329 | |||
330 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1021211 times.
|
1021211 | if (!tu) |
331 | ✗ | return AVERROR_INVALIDDATA; | |
332 | |||
333 |
4/4✓ Branch 0 taken 255687 times.
✓ Branch 1 taken 765524 times.
✓ Branch 2 taken 6935 times.
✓ Branch 3 taken 248752 times.
|
1021211 | if (tree_type == SINGLE_TREE && is_isp_last_tu) { |
334 | 6935 | const int x_cu = x0 >> fc->ps.sps->min_cb_log2_size_y; | |
335 | 6935 | const int y_cu = y0 >> fc->ps.sps->min_cb_log2_size_y; | |
336 | 6935 | xc = SAMPLE_CTB(fc->tab.cb_pos_x[ch_type], x_cu, y_cu); | |
337 | 6935 | yc = SAMPLE_CTB(fc->tab.cb_pos_y[ch_type], x_cu, y_cu); | |
338 | 6935 | wc = SAMPLE_CTB(fc->tab.cb_width[ch_type], x_cu, y_cu); | |
339 | 6935 | hc = SAMPLE_CTB(fc->tab.cb_height[ch_type], x_cu, y_cu); | |
340 | } else { | ||
341 | 1014276 | xc = x0, yc = y0, wc = tu_width, hc = tu_height; | |
342 | } | ||
343 | |||
344 |
4/4✓ Branch 0 taken 376091 times.
✓ Branch 1 taken 645120 times.
✓ Branch 2 taken 340077 times.
✓ Branch 3 taken 36014 times.
|
1021211 | if (chroma_available && !is_sbt_not_coded) { |
345 | 340077 | tu->coded_flag[CB] = ff_vvc_tu_cb_coded_flag(lc); | |
346 | 340077 | tu->coded_flag[CR] = ff_vvc_tu_cr_coded_flag(lc, tu->coded_flag[CB]); | |
347 | } | ||
348 | |||
349 |
6/6✓ Branch 0 taken 376091 times.
✓ Branch 1 taken 645120 times.
✓ Branch 2 taken 246041 times.
✓ Branch 3 taken 130050 times.
✓ Branch 4 taken 22667 times.
✓ Branch 5 taken 223374 times.
|
1021211 | is_chroma_coded = chroma_available && (tu->coded_flag[CB] || tu->coded_flag[CR]); |
350 | |||
351 |
2/2✓ Branch 0 taken 861930 times.
✓ Branch 1 taken 159281 times.
|
1021211 | if (tree_type != DUAL_TREE_CHROMA) { |
352 | int has_qp_delta; | ||
353 | 861930 | tu->coded_flag[LUMA] = tu_y_coded_flag_decode(lc, is_sbt_not_coded, sub_tu_index, is_isp, is_chroma_coded); | |
354 |
4/4✓ Branch 0 taken 199311 times.
✓ Branch 1 taken 659921 times.
✓ Branch 2 taken 24211 times.
✓ Branch 3 taken 175100 times.
|
859232 | has_qp_delta = (is_128 || tu->coded_flag[LUMA] || is_chroma_coded) && |
355 |
6/6✓ Branch 0 taken 859232 times.
✓ Branch 1 taken 2698 times.
✓ Branch 2 taken 31507 times.
✓ Branch 3 taken 655323 times.
✓ Branch 4 taken 859 times.
✓ Branch 5 taken 30648 times.
|
1721162 | pps->r->pps_cu_qp_delta_enabled_flag && !lc->parse.is_cu_qp_delta_coded; |
356 | 861930 | ret = set_qp_y(lc, x0, y0, has_qp_delta); | |
357 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 861930 times.
|
861930 | if (ret < 0) |
358 | ✗ | return ret; | |
359 | 861930 | add_tb(tu, lc, x0, y0, tu_width, tu_height, LUMA); | |
360 | } | ||
361 |
2/2✓ Branch 0 taken 414968 times.
✓ Branch 1 taken 606243 times.
|
1021211 | if (tree_type != DUAL_TREE_LUMA) { |
362 | 414968 | chroma_qp_offset_decode(lc, is_128, is_chroma_coded); | |
363 |
2/2✓ Branch 0 taken 376091 times.
✓ Branch 1 taken 38877 times.
|
414968 | if (chroma_available) { |
364 | 376091 | const int hs = sps->hshift[CHROMA]; | |
365 | 376091 | const int vs = sps->vshift[CHROMA]; | |
366 | 376091 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CB); | |
367 | 376091 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CR); | |
368 | } | ||
369 | } | ||
370 |
4/4✓ Branch 0 taken 978007 times.
✓ Branch 1 taken 43204 times.
✓ Branch 2 taken 807773 times.
✓ Branch 3 taken 170234 times.
|
1021211 | if (sps->r->sps_joint_cbcr_enabled_flag && ((cu->pred_mode == MODE_INTRA && |
371 |
4/4✓ Branch 0 taken 718278 times.
✓ Branch 1 taken 89495 times.
✓ Branch 2 taken 699712 times.
✓ Branch 3 taken 18566 times.
|
807773 | (tu->coded_flag[CB] || tu->coded_flag[CR])) || |
372 |
5/6✓ Branch 0 taken 35165 times.
✓ Branch 1 taken 834781 times.
✓ Branch 2 taken 4217 times.
✓ Branch 3 taken 30948 times.
✓ Branch 4 taken 112278 times.
✗ Branch 5 not taken.
|
978007 | (tu->coded_flag[CB] && tu->coded_flag[CR])) && |
373 | chroma_available) { | ||
374 | 112278 | tu->joint_cbcr_residual_flag = ff_vvc_tu_joint_cbcr_residual_flag(lc, tu->coded_flag[1], tu->coded_flag[2]); | |
375 | } | ||
376 | |||
377 |
2/2✓ Branch 0 taken 1614112 times.
✓ Branch 1 taken 1021211 times.
|
2635323 | for (int i = 0; i < tu->nb_tbs; i++) { |
378 | 1614112 | TransformBlock *tb = &tu->tbs[i]; | |
379 | 1614112 | const int is_chroma = tb->c_idx != LUMA; | |
380 | 1614112 | tb->has_coeffs = tu->coded_flag[tb->c_idx]; | |
381 |
4/4✓ Branch 0 taken 875509 times.
✓ Branch 1 taken 738603 times.
✓ Branch 2 taken 213683 times.
✓ Branch 3 taken 661826 times.
|
1614112 | if (tb->has_coeffs && is_chroma) |
382 |
6/6✓ Branch 0 taken 83633 times.
✓ Branch 1 taken 130050 times.
✓ Branch 2 taken 60966 times.
✓ Branch 3 taken 22667 times.
✓ Branch 4 taken 48676 times.
✓ Branch 5 taken 12290 times.
|
213683 | tb->has_coeffs = tb->c_idx == CB ? 1 : !(tu->coded_flag[CB] && tu->joint_cbcr_residual_flag); |
383 |
2/2✓ Branch 0 taken 863219 times.
✓ Branch 1 taken 750893 times.
|
1614112 | if (tb->has_coeffs) { |
384 | 863219 | tb->ts = cu->bdpcm_flag[tb->c_idx]; | |
385 |
4/4✓ Branch 0 taken 833175 times.
✓ Branch 1 taken 30044 times.
✓ Branch 2 taken 833165 times.
✓ Branch 3 taken 10 times.
|
863219 | if (sps->r->sps_transform_skip_enabled_flag && !cu->bdpcm_flag[tb->c_idx] && |
386 |
4/4✓ Branch 0 taken 816774 times.
✓ Branch 1 taken 16391 times.
✓ Branch 2 taken 809604 times.
✓ Branch 3 taken 7170 times.
|
833165 | tb->tb_width <= sps->max_ts_size && tb->tb_height <= sps->max_ts_size && |
387 |
6/6✓ Branch 0 taken 769958 times.
✓ Branch 1 taken 39646 times.
✓ Branch 2 taken 594055 times.
✓ Branch 3 taken 175903 times.
✓ Branch 4 taken 460979 times.
✓ Branch 5 taken 133076 times.
|
809604 | !cu->sbt_flag && (is_chroma || !is_isp)) { |
388 | 636882 | tb->ts = ff_vvc_transform_skip_flag(lc, is_chroma); | |
389 | } | ||
390 | 863219 | ret = ff_vvc_residual_coding(lc, tb); | |
391 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 863219 times.
|
863219 | if (ret < 0) |
392 | ✗ | return ret; | |
393 | 863219 | set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], tu->coded_flag[tb->c_idx], fc, tb); | |
394 | } | ||
395 |
2/2✓ Branch 0 taken 1238021 times.
✓ Branch 1 taken 376091 times.
|
1614112 | if (tb->c_idx != CR) |
396 | 1238021 | set_tb_size(fc, tb); | |
397 |
2/2✓ Branch 0 taken 376091 times.
✓ Branch 1 taken 1238021 times.
|
1614112 | if (tb->c_idx == CB) |
398 | 376091 | set_tb_tab(fc->tab.tu_joint_cbcr_residual_flag, tu->joint_cbcr_residual_flag, fc, tb); | |
399 | } | ||
400 | |||
401 | 1021211 | return 0; | |
402 | } | ||
403 | |||
404 | 845341 | static int hls_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int ch_type) | |
405 | { | ||
406 | 845341 | const CodingUnit *cu = lc->cu; | |
407 | 845341 | const VVCSPS *sps = lc->fc->ps.sps; | |
408 | int ret; | ||
409 | |||
410 | 845341 | lc->parse.infer_tu_cbf_luma = 1; | |
411 |
4/4✓ Branch 0 taken 783732 times.
✓ Branch 1 taken 61609 times.
✓ Branch 2 taken 746426 times.
✓ Branch 3 taken 37306 times.
|
845341 | if (cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag) { |
412 |
4/4✓ Branch 0 taken 744896 times.
✓ Branch 1 taken 1530 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 744653 times.
|
748199 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
413 |
4/4✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 1106 times.
✓ Branch 3 taken 424 times.
|
1773 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
414 |
2/2✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 667 times.
|
1773 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
415 |
2/2✓ Branch 0 taken 667 times.
✓ Branch 1 taken 1106 times.
|
1773 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
416 | |||
417 | #define TRANSFORM_TREE(x, y) do { \ | ||
418 | ret = hls_transform_tree(lc, x, y, trafo_width, trafo_height, ch_type); \ | ||
419 | if (ret < 0) \ | ||
420 | return ret; \ | ||
421 | } while (0) | ||
422 | |||
423 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1773 times.
|
1773 | TRANSFORM_TREE(x0, y0); |
424 |
2/2✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 667 times.
|
1773 | if (ver_split_first) |
425 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1106 times.
|
1106 | TRANSFORM_TREE(x0 + trafo_width, y0); |
426 | else | ||
427 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 667 times.
|
667 | TRANSFORM_TREE(x0, y0 + trafo_height); |
428 | |||
429 | } else { | ||
430 | 744653 | ret = hls_transform_unit(lc, x0, y0, tu_width, tu_height, 0, ch_type); | |
431 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 744653 times.
|
744653 | if (ret < 0) |
432 | ✗ | return ret; | |
433 | |||
434 | } | ||
435 |
2/2✓ Branch 0 taken 37306 times.
✓ Branch 1 taken 61609 times.
|
98915 | } else if (cu->sbt_flag) { |
436 |
2/2✓ Branch 0 taken 19479 times.
✓ Branch 1 taken 17827 times.
|
37306 | if (!cu->sbt_horizontal_flag) { |
437 | #define TRANSFORM_UNIT(x, width, idx) do { \ | ||
438 | ret = hls_transform_unit(lc, x, y0, width, tu_height, idx, ch_type); \ | ||
439 | if (ret < 0) \ | ||
440 | return ret; \ | ||
441 | } while (0) | ||
442 | |||
443 | 19479 | const int trafo_width = tu_width * lc->parse.sbt_num_fourths_tb0 / 4; | |
444 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19479 times.
|
19479 | TRANSFORM_UNIT(x0, trafo_width, 0); |
445 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19479 times.
|
19479 | TRANSFORM_UNIT(x0 + trafo_width, tu_width - trafo_width, 1); |
446 | |||
447 | #undef TRANSFORM_UNIT | ||
448 | } else { | ||
449 | #define TRANSFORM_UNIT(y, height, idx) do { \ | ||
450 | ret = hls_transform_unit(lc, x0, y, tu_width, height, idx, ch_type); \ | ||
451 | if (ret < 0) \ | ||
452 | return ret; \ | ||
453 | } while (0) | ||
454 | |||
455 | 17827 | const int trafo_height = tu_height * lc->parse.sbt_num_fourths_tb0 / 4; | |
456 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 17827 times.
|
17827 | TRANSFORM_UNIT(y0, trafo_height, 0); |
457 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 17827 times.
|
17827 | TRANSFORM_UNIT(y0 + trafo_height, tu_height - trafo_height, 1); |
458 | |||
459 | #undef TRANSFORM_UNIT | ||
460 | } | ||
461 |
2/2✓ Branch 0 taken 38154 times.
✓ Branch 1 taken 23455 times.
|
61609 | } else if (cu->isp_split_type == ISP_HOR_SPLIT) { |
462 | 38154 | const int trafo_height = tu_height / cu->num_intra_subpartitions; | |
463 |
2/2✓ Branch 0 taken 128776 times.
✓ Branch 1 taken 38154 times.
|
166930 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
464 | 128776 | ret = hls_transform_unit(lc, x0, y0 + trafo_height * i, tu_width, trafo_height, i, 0); | |
465 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 128776 times.
|
128776 | if (ret < 0) |
466 | ✗ | return ret; | |
467 | } | ||
468 |
1/2✓ Branch 0 taken 23455 times.
✗ Branch 1 not taken.
|
23455 | } else if (cu->isp_split_type == ISP_VER_SPLIT) { |
469 | 23455 | const int trafo_width = tu_width / cu->num_intra_subpartitions; | |
470 |
2/2✓ Branch 0 taken 73170 times.
✓ Branch 1 taken 23455 times.
|
96625 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
471 | 73170 | ret = hls_transform_unit(lc, x0 + trafo_width * i , y0, trafo_width, tu_height, i, 0); | |
472 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 73170 times.
|
73170 | if (ret < 0) |
473 | ✗ | return ret; | |
474 | } | ||
475 | } | ||
476 | |||
477 | 845341 | return 0; | |
478 | } | ||
479 | |||
480 | 390292 | static int skipped_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height) | |
481 | { | ||
482 | 390292 | VVCFrameContext *fc = lc->fc; | |
483 | 390292 | const CodingUnit *cu = lc->cu; | |
484 | 390292 | const VVCSPS *sps = fc->ps.sps; | |
485 | |||
486 |
4/4✓ Branch 0 taken 330097 times.
✓ Branch 1 taken 60195 times.
✓ Branch 2 taken 1910 times.
✓ Branch 3 taken 328187 times.
|
452397 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
487 |
4/4✓ Branch 0 taken 60195 times.
✓ Branch 1 taken 1910 times.
✓ Branch 2 taken 40745 times.
✓ Branch 3 taken 19450 times.
|
62105 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
488 |
2/2✓ Branch 0 taken 40745 times.
✓ Branch 1 taken 21360 times.
|
62105 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
489 |
2/2✓ Branch 0 taken 21360 times.
✓ Branch 1 taken 40745 times.
|
62105 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
490 | |||
491 | #define SKIPPED_TRANSFORM_TREE(x, y) do { \ | ||
492 | int ret = skipped_transform_tree(lc, x, y, trafo_width, trafo_height); \ | ||
493 | if (ret < 0) \ | ||
494 | return ret; \ | ||
495 | } while (0) | ||
496 | |||
497 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 62105 times.
|
62105 | SKIPPED_TRANSFORM_TREE(x0, y0); |
498 |
2/2✓ Branch 0 taken 40745 times.
✓ Branch 1 taken 21360 times.
|
62105 | if (ver_split_first) |
499 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 40745 times.
|
40745 | SKIPPED_TRANSFORM_TREE(x0 + trafo_width, y0); |
500 | else | ||
501 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21360 times.
|
21360 | SKIPPED_TRANSFORM_TREE(x0, y0 + trafo_height); |
502 | } else { | ||
503 | 328187 | TransformUnit *tu = add_tu(fc, lc->cu, x0, y0, tu_width, tu_height); | |
504 |
4/4✓ Branch 0 taken 311676 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 310880 times.
✓ Branch 3 taken 796 times.
|
328187 | const int has_chroma = sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA; |
505 | 328187 | const int c_start = cu->tree_type == DUAL_TREE_CHROMA ? CB : LUMA; | |
506 |
2/2✓ Branch 0 taken 310880 times.
✓ Branch 1 taken 17307 times.
|
328187 | const int c_end = has_chroma ? VVC_MAX_SAMPLE_ARRAYS : CB; |
507 | |||
508 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 328187 times.
|
328187 | if (!tu) |
509 | ✗ | return AVERROR_INVALIDDATA; | |
510 |
2/2✓ Branch 0 taken 949947 times.
✓ Branch 1 taken 328187 times.
|
1278134 | for (int i = c_start; i < c_end; i++) { |
511 | 949947 | TransformBlock *tb = add_tb(tu, lc, x0, y0, tu_width >> sps->hshift[i], tu_height >> sps->vshift[i], i); | |
512 |
2/2✓ Branch 0 taken 639067 times.
✓ Branch 1 taken 310880 times.
|
949947 | if (i != CR) |
513 | 639067 | set_tb_size(fc, tb); | |
514 | } | ||
515 | } | ||
516 | |||
517 | 390292 | return 0; | |
518 | } | ||
519 | |||
520 | //6.4.1 Allowed quad split process | ||
521 | //6.4.2 Allowed binary split process | ||
522 | //6.4.3 Allowed ternary split process | ||
523 | 1823471 | static void can_split(const VVCLocalContext *lc, int x0, int y0,int cb_width, int cb_height, | |
524 | int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, | ||
525 | VVCTreeType tree_type, VVCModeType mode_type, VVCAllowedSplit* split) | ||
526 | { | ||
527 | int min_qt_size, max_bt_size, max_tt_size, max_mtt_depth; | ||
528 | 1823471 | const VVCFrameContext *fc = lc->fc; | |
529 | 1823471 | const VVCSH *sh = &lc->sc->sh; | |
530 | 1823471 | const VVCSPS *sps = fc->ps.sps; | |
531 | 1823471 | const VVCPPS *pps = fc->ps.pps; | |
532 | 1823471 | const int chroma = tree_type == DUAL_TREE_CHROMA; | |
533 | 1823471 | int min_cb_size_y = sps->min_cb_size_y; | |
534 | 1823471 | int *qt = &split->qt; | |
535 | 1823471 | int *btv = &split->btv; | |
536 | 1823471 | int *bth = &split->bth; | |
537 | 1823471 | int *ttv = &split->ttv; | |
538 | 1823471 | int *tth = &split->tth; | |
539 | |||
540 | 1823471 | *qt = *bth = *btv = *tth = *ttv = 1; | |
541 | |||
542 |
2/2✓ Branch 0 taken 1361501 times.
✓ Branch 1 taken 461970 times.
|
1823471 | if (mtt_depth) |
543 | 1361501 | *qt = 0; | |
544 | |||
545 | 1823471 | min_qt_size = sh->min_qt_size[chroma]; | |
546 |
2/2✓ Branch 0 taken 678543 times.
✓ Branch 1 taken 1144928 times.
|
1823471 | if (cb_width <= min_qt_size) |
547 | 678543 | *qt = 0; | |
548 | |||
549 |
2/2✓ Branch 0 taken 255856 times.
✓ Branch 1 taken 1567615 times.
|
1823471 | if (chroma) { |
550 | 255856 | int chroma_area = (cb_width >> sps->hshift[1]) * (cb_height >> sps->vshift[1]); | |
551 | 255856 | int chroma_width = cb_width >> sps->hshift[1]; | |
552 | |||
553 |
2/2✓ Branch 0 taken 75596 times.
✓ Branch 1 taken 180260 times.
|
255856 | if (chroma_width == 8) |
554 | 75596 | *ttv = 0; | |
555 |
2/2✓ Branch 0 taken 58702 times.
✓ Branch 1 taken 121558 times.
|
180260 | else if (chroma_width <= 4) { |
556 |
1/2✓ Branch 0 taken 58702 times.
✗ Branch 1 not taken.
|
58702 | if (chroma_width == 4) |
557 | 58702 | *btv = 0; | |
558 | 58702 | *qt = 0; | |
559 | } | ||
560 |
2/2✓ Branch 0 taken 10647 times.
✓ Branch 1 taken 245209 times.
|
255856 | if (mode_type == MODE_TYPE_INTRA) |
561 | 10647 | *qt = *btv = *bth = *ttv = *tth = 0; | |
562 |
2/2✓ Branch 0 taken 83064 times.
✓ Branch 1 taken 172792 times.
|
255856 | if (chroma_area <= 32) { |
563 | 83064 | *ttv = *tth = 0; | |
564 |
2/2✓ Branch 0 taken 34523 times.
✓ Branch 1 taken 48541 times.
|
83064 | if (chroma_area <= 16) |
565 | 34523 | *btv = *bth = 0; | |
566 | } | ||
567 | } | ||
568 | 1823471 | max_bt_size = sh->max_bt_size[chroma]; | |
569 | 1823471 | max_tt_size = sh->max_tt_size[chroma]; | |
570 | 1823471 | max_mtt_depth = sh->max_mtt_depth[chroma] + depth_offset; | |
571 | |||
572 |
2/2✓ Branch 0 taken 59865 times.
✓ Branch 1 taken 1763606 times.
|
1823471 | if (mode_type == MODE_TYPE_INTER) { |
573 | 59865 | int area = cb_width * cb_height; | |
574 |
2/2✓ Branch 0 taken 22852 times.
✓ Branch 1 taken 37013 times.
|
59865 | if (area == 32) |
575 | 22852 | *btv = *bth = 0; | |
576 |
2/2✓ Branch 0 taken 21705 times.
✓ Branch 1 taken 15308 times.
|
37013 | else if (area == 64) |
577 | 21705 | *ttv = *tth = 0; | |
578 | } | ||
579 |
2/2✓ Branch 0 taken 700515 times.
✓ Branch 1 taken 1122956 times.
|
1823471 | if (cb_width <= 2 * min_cb_size_y) { |
580 | 700515 | *ttv = 0; | |
581 |
2/2✓ Branch 0 taken 238550 times.
✓ Branch 1 taken 461965 times.
|
700515 | if (cb_width <= min_cb_size_y) |
582 | 238550 | *btv = 0; | |
583 | } | ||
584 |
2/2✓ Branch 0 taken 766236 times.
✓ Branch 1 taken 1057235 times.
|
1823471 | if (cb_height <= 2 * min_cb_size_y) { |
585 | 766236 | *tth = 0; | |
586 |
2/2✓ Branch 0 taken 275907 times.
✓ Branch 1 taken 490329 times.
|
766236 | if (cb_height <= min_cb_size_y) |
587 | 275907 | *bth = 0; | |
588 | } | ||
589 |
4/4✓ Branch 0 taken 1773642 times.
✓ Branch 1 taken 49829 times.
✓ Branch 2 taken 590 times.
✓ Branch 3 taken 1773052 times.
|
1823471 | if (cb_width > max_bt_size || cb_height > max_bt_size) |
590 | 50419 | *btv = *bth = 0; | |
591 | 1823471 | max_tt_size = FFMIN(64, max_tt_size); | |
592 |
4/4✓ Branch 0 taken 1704547 times.
✓ Branch 1 taken 118924 times.
✓ Branch 2 taken 8126 times.
✓ Branch 3 taken 1696421 times.
|
1823471 | if (cb_width > max_tt_size || cb_height > max_tt_size) |
593 | 127050 | *ttv = *tth = 0; | |
594 |
2/2✓ Branch 0 taken 407471 times.
✓ Branch 1 taken 1416000 times.
|
1823471 | if (mtt_depth >= max_mtt_depth) |
595 | 407471 | *btv = *bth = *ttv = *tth = 0; | |
596 |
2/2✓ Branch 0 taken 4205 times.
✓ Branch 1 taken 1819266 times.
|
1823471 | if (x0 + cb_width > pps->width) { |
597 | 4205 | *ttv = *tth = 0; | |
598 |
2/2✓ Branch 0 taken 1320 times.
✓ Branch 1 taken 2885 times.
|
4205 | if (cb_height > 64) |
599 | 1320 | *btv = 0; | |
600 |
2/2✓ Branch 0 taken 3062 times.
✓ Branch 1 taken 1143 times.
|
4205 | if (y0 + cb_height <= pps->height) |
601 | 3062 | *bth = 0; | |
602 |
1/2✓ Branch 0 taken 1143 times.
✗ Branch 1 not taken.
|
1143 | else if (cb_width > min_qt_size) |
603 | 1143 | *btv = *bth = 0; | |
604 | } | ||
605 |
2/2✓ Branch 0 taken 48253 times.
✓ Branch 1 taken 1775218 times.
|
1823471 | if (y0 + cb_height > pps->height) { |
606 | 48253 | *btv = *ttv = *tth = 0; | |
607 |
2/2✓ Branch 0 taken 6171 times.
✓ Branch 1 taken 42082 times.
|
48253 | if (cb_width > 64) |
608 | 6171 | *bth = 0; | |
609 | } | ||
610 |
4/4✓ Branch 0 taken 1361501 times.
✓ Branch 1 taken 461970 times.
✓ Branch 2 taken 598696 times.
✓ Branch 3 taken 762805 times.
|
1823471 | if (mtt_depth > 0 && part_idx == 1) { |
611 |
2/2✓ Branch 0 taken 67604 times.
✓ Branch 1 taken 531092 times.
|
598696 | if (last_split_mode == SPLIT_TT_VER) |
612 | 67604 | *btv = 0; | |
613 |
2/2✓ Branch 0 taken 71930 times.
✓ Branch 1 taken 459162 times.
|
531092 | else if (last_split_mode == SPLIT_TT_HOR) |
614 | 71930 | *bth = 0; | |
615 | } | ||
616 |
4/4✓ Branch 0 taken 1781555 times.
✓ Branch 1 taken 41916 times.
✓ Branch 2 taken 2994 times.
✓ Branch 3 taken 1778561 times.
|
1823471 | if (cb_width <= 64 && cb_height > 64) |
617 | 2994 | *btv = 0; | |
618 |
4/4✓ Branch 0 taken 41916 times.
✓ Branch 1 taken 1781555 times.
✓ Branch 2 taken 2954 times.
✓ Branch 3 taken 38962 times.
|
1823471 | if (cb_width > 64 && cb_height <= 64) |
619 | 2954 | *bth = 0; | |
620 | 1823471 | } | |
621 | |||
622 | 445017 | static int get_num_intra_subpartitions(enum IspType isp_split_type, int cb_width, int cb_height) | |
623 | { | ||
624 |
2/2✓ Branch 0 taken 383408 times.
✓ Branch 1 taken 61609 times.
|
445017 | if (isp_split_type == ISP_NO_SPLIT) |
625 | 383408 | return 1; | |
626 |
8/8✓ Branch 0 taken 14568 times.
✓ Branch 1 taken 47041 times.
✓ Branch 2 taken 4140 times.
✓ Branch 3 taken 10428 times.
✓ Branch 4 taken 21929 times.
✓ Branch 5 taken 29252 times.
✓ Branch 6 taken 11817 times.
✓ Branch 7 taken 10112 times.
|
61609 | if ((cb_width == 4 && cb_height == 8) || (cb_width == 8 && cb_height == 4)) |
627 | 22245 | return 2; | |
628 | 39364 | return 4; | |
629 | } | ||
630 | |||
631 | 203578 | static int get_cclm_enabled(const VVCLocalContext *lc, const int x0, const int y0) | |
632 | { | ||
633 | 203578 | const VVCFrameContext *fc = lc->fc; | |
634 | 203578 | const VVCSPS *sps = fc->ps.sps; | |
635 | 203578 | int enabled = 0; | |
636 | |||
637 |
2/2✓ Branch 0 taken 449 times.
✓ Branch 1 taken 203129 times.
|
203578 | if (!sps->r->sps_cclm_enabled_flag) |
638 | 449 | return 0; | |
639 |
6/6✓ Branch 0 taken 196492 times.
✓ Branch 1 taken 6637 times.
✓ Branch 2 taken 148631 times.
✓ Branch 3 taken 47861 times.
✓ Branch 4 taken 1163 times.
✓ Branch 5 taken 147468 times.
|
203129 | if (!sps->r->sps_qtbtt_dual_tree_intra_flag || !IS_I(lc->sc->sh.r) || sps->ctb_log2_size_y < 6) |
640 | 55661 | return 1; | |
641 | else { | ||
642 | 147468 | const int x64 = x0 >> 6 << 6; | |
643 | 147468 | const int y64 = y0 >> 6 << 6; | |
644 | 147468 | const int y32 = y0 >> 5 << 5; | |
645 | 147468 | const int x64_cu = x64 >> fc->ps.sps->min_cb_log2_size_y; | |
646 | 147468 | const int y64_cu = y64 >> fc->ps.sps->min_cb_log2_size_y; | |
647 | 147468 | const int y32_cu = y32 >> fc->ps.sps->min_cb_log2_size_y; | |
648 | 147468 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
649 | 147468 | const int depth = SAMPLE_CTB(fc->tab.cqt_depth[1], x64_cu, y64_cu); | |
650 | 147468 | const int min_depth = fc->ps.sps->ctb_log2_size_y - 6; | |
651 | 147468 | const VVCSplitMode msm64 = (VVCSplitMode)TAB_MSM(fc, 0, x64, y64); | |
652 | 147468 | const VVCSplitMode msm32 = (VVCSplitMode)TAB_MSM(fc, 1, x64, y32); | |
653 | |||
654 |
2/2✓ Branch 0 taken 18431 times.
✓ Branch 1 taken 129037 times.
|
165899 | enabled = SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y64_cu) == 64 && |
655 |
2/2✓ Branch 0 taken 6475 times.
✓ Branch 1 taken 11956 times.
|
18431 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y64_cu) == 64; |
656 |
2/2✓ Branch 0 taken 20278 times.
✓ Branch 1 taken 11757 times.
|
32035 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && |
657 |
4/4✓ Branch 0 taken 32035 times.
✓ Branch 1 taken 115433 times.
✓ Branch 2 taken 11900 times.
✓ Branch 3 taken 8378 times.
|
191403 | SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y32_cu) == 64 && |
658 |
2/2✓ Branch 0 taken 4694 times.
✓ Branch 1 taken 7206 times.
|
11900 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y32_cu) == 32; |
659 | 147468 | enabled |= depth > min_depth; | |
660 |
6/6✓ Branch 0 taken 32035 times.
✓ Branch 1 taken 115433 times.
✓ Branch 2 taken 20278 times.
✓ Branch 3 taken 11757 times.
✓ Branch 4 taken 7430 times.
✓ Branch 5 taken 12848 times.
|
147468 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && msm32 == SPLIT_BT_VER; |
661 | |||
662 |
2/2✓ Branch 0 taken 133581 times.
✓ Branch 1 taken 13887 times.
|
147468 | if (enabled) { |
663 | 133581 | const int w = SAMPLE_CTB(fc->tab.cb_width[0], x64_cu, y64_cu); | |
664 | 133581 | const int h = SAMPLE_CTB(fc->tab.cb_height[0], x64_cu, y64_cu); | |
665 | 133581 | const int depth0 = SAMPLE_CTB(fc->tab.cqt_depth[0], x64_cu, y64_cu); | |
666 |
7/8✓ Branch 0 taken 5054 times.
✓ Branch 1 taken 128527 times.
✓ Branch 2 taken 5054 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4462 times.
✓ Branch 5 taken 592 times.
✓ Branch 6 taken 4462 times.
✓ Branch 7 taken 128527 times.
|
133581 | if ((w == 64 && h == 64 && TAB_ISPMF(fc, x64, y64)) || |
667 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 4462 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 128527 times.
|
132989 | ((w < 64 || h < 64) && depth0 == min_depth)) |
668 | 592 | return 0; | |
669 | } | ||
670 | |||
671 | } | ||
672 | |||
673 | 146876 | return enabled; | |
674 | } | ||
675 | |||
676 | 725660 | static int less(const void *a, const void *b) | |
677 | { | ||
678 | 725660 | return *(const int*)a - *(const int*)b; | |
679 | } | ||
680 | |||
681 | //8.4.2 Derivation process for luma intra prediction mode | ||
682 | 445017 | static enum IntraPredMode luma_intra_pred_mode(VVCLocalContext* lc, const int intra_subpartitions_mode_flag) | |
683 | { | ||
684 | 445017 | VVCFrameContext *fc = lc->fc; | |
685 | 445017 | CodingUnit *cu = lc->cu; | |
686 | 445017 | const int x0 = cu->x0; | |
687 | 445017 | const int y0 = cu->y0; | |
688 | enum IntraPredMode pred; | ||
689 | 445017 | int intra_luma_not_planar_flag = 1; | |
690 | 445017 | int intra_luma_mpm_remainder = 0; | |
691 | 445017 | int intra_luma_mpm_flag = 1; | |
692 | 445017 | int intra_luma_mpm_idx = 0; | |
693 | |||
694 |
2/2✓ Branch 0 taken 414871 times.
✓ Branch 1 taken 30146 times.
|
445017 | if (!cu->intra_luma_ref_idx) |
695 | 414871 | intra_luma_mpm_flag = ff_vvc_intra_luma_mpm_flag(lc); | |
696 |
2/2✓ Branch 0 taken 341602 times.
✓ Branch 1 taken 103415 times.
|
445017 | if (intra_luma_mpm_flag) { |
697 |
2/2✓ Branch 0 taken 311456 times.
✓ Branch 1 taken 30146 times.
|
341602 | if (!cu->intra_luma_ref_idx) |
698 | 311456 | intra_luma_not_planar_flag = ff_vvc_intra_luma_not_planar_flag(lc, intra_subpartitions_mode_flag); | |
699 |
2/2✓ Branch 0 taken 171532 times.
✓ Branch 1 taken 170070 times.
|
341602 | if (intra_luma_not_planar_flag) |
700 | 171532 | intra_luma_mpm_idx = ff_vvc_intra_luma_mpm_idx(lc); | |
701 | } else { | ||
702 | 103415 | intra_luma_mpm_remainder = ff_vvc_intra_luma_mpm_remainder(lc); | |
703 | } | ||
704 | |||
705 |
2/2✓ Branch 0 taken 170070 times.
✓ Branch 1 taken 274947 times.
|
445017 | if (!intra_luma_not_planar_flag) { |
706 | 170070 | pred = INTRA_PLANAR; | |
707 | } else { | ||
708 | 274947 | const VVCSPS *sps = fc->ps.sps; | |
709 | 274947 | const int x_a = (x0 - 1) >> sps->min_cb_log2_size_y; | |
710 | 274947 | const int y_a = (y0 + cu->cb_height - 1) >> sps->min_cb_log2_size_y; | |
711 | 274947 | const int x_b = (x0 + cu->cb_width - 1) >> sps->min_cb_log2_size_y; | |
712 | 274947 | const int y_b = (y0 - 1) >> sps->min_cb_log2_size_y; | |
713 | 274947 | int min_cb_width = fc->ps.pps->min_cb_width; | |
714 | 274947 | int x0b = av_zero_extend(x0, sps->ctb_log2_size_y); | |
715 | 274947 | int y0b = av_zero_extend(y0, sps->ctb_log2_size_y); | |
716 |
4/4✓ Branch 0 taken 48724 times.
✓ Branch 1 taken 226223 times.
✓ Branch 2 taken 44479 times.
✓ Branch 3 taken 4245 times.
|
274947 | const int available_l = lc->ctb_left_flag || x0b; |
717 |
4/4✓ Branch 0 taken 87963 times.
✓ Branch 1 taken 186984 times.
✓ Branch 2 taken 83123 times.
✓ Branch 3 taken 4840 times.
|
274947 | const int available_u = lc->ctb_up_flag || y0b; |
718 | |||
719 | int a, b, cand[5]; | ||
720 | |||
721 |
4/4✓ Branch 0 taken 270702 times.
✓ Branch 1 taken 4245 times.
✓ Branch 2 taken 258279 times.
✓ Branch 3 taken 12423 times.
|
274947 | if (!available_l || (SAMPLE_CTB(fc->tab.cpm[0], x_a, y_a) != MODE_INTRA) || |
722 |
2/2✓ Branch 0 taken 34605 times.
✓ Branch 1 taken 223674 times.
|
258279 | SAMPLE_CTB(fc->tab.imf, x_a, y_a)) { |
723 | 51273 | a = INTRA_PLANAR; | |
724 | } else { | ||
725 | 223674 | a = SAMPLE_CTB(fc->tab.ipm, x_a, y_a); | |
726 | } | ||
727 | |||
728 |
4/4✓ Branch 0 taken 270107 times.
✓ Branch 1 taken 4840 times.
✓ Branch 2 taken 257746 times.
✓ Branch 3 taken 12361 times.
|
274947 | if (!available_u || (SAMPLE_CTB(fc->tab.cpm[0], x_b, y_b) != MODE_INTRA) || |
729 |
4/4✓ Branch 0 taken 222809 times.
✓ Branch 1 taken 34937 times.
✓ Branch 2 taken 13806 times.
✓ Branch 3 taken 209003 times.
|
257746 | SAMPLE_CTB(fc->tab.imf, x_b, y_b) || !y0b) { |
730 | 65944 | b = INTRA_PLANAR; | |
731 | } else { | ||
732 | 209003 | b = SAMPLE_CTB(fc->tab.ipm, x_b, y_b); | |
733 | } | ||
734 | |||
735 |
4/4✓ Branch 0 taken 82254 times.
✓ Branch 1 taken 192693 times.
✓ Branch 2 taken 18080 times.
✓ Branch 3 taken 64174 times.
|
274947 | if (a == b && a > INTRA_DC) { |
736 | 18080 | cand[0] = a; | |
737 | 18080 | cand[1] = 2 + ((a + 61) % 64); | |
738 | 18080 | cand[2] = 2 + ((a - 1) % 64); | |
739 | 18080 | cand[3] = 2 + ((a + 60) % 64); | |
740 | 18080 | cand[4] = 2 + (a % 64); | |
741 | } else { | ||
742 | 256867 | const int minab = FFMIN(a, b); | |
743 | 256867 | const int maxab = FFMAX(a, b); | |
744 |
4/4✓ Branch 0 taken 128060 times.
✓ Branch 1 taken 128807 times.
✓ Branch 2 taken 65780 times.
✓ Branch 3 taken 62280 times.
|
322647 | if (a > INTRA_DC && b > INTRA_DC) { |
745 | 65780 | const int diff = maxab - minab; | |
746 | 65780 | cand[0] = a; | |
747 | 65780 | cand[1] = b; | |
748 |
2/2✓ Branch 0 taken 13548 times.
✓ Branch 1 taken 52232 times.
|
65780 | if (diff == 1) { |
749 | 13548 | cand[2] = 2 + ((minab + 61) % 64); | |
750 | 13548 | cand[3] = 2 + ((maxab - 1) % 64); | |
751 | 13548 | cand[4] = 2 + ((minab + 60) % 64); | |
752 |
2/2✓ Branch 0 taken 556 times.
✓ Branch 1 taken 51676 times.
|
52232 | } else if (diff >= 62) { |
753 | 556 | cand[2] = 2 + ((minab - 1) % 64); | |
754 | 556 | cand[3] = 2 + ((maxab + 61) % 64); | |
755 | 556 | cand[4] = 2 + (minab % 64); | |
756 |
2/2✓ Branch 0 taken 6310 times.
✓ Branch 1 taken 45366 times.
|
51676 | } else if (diff == 2) { |
757 | 6310 | cand[2] = 2 + ((minab - 1) % 64); | |
758 | 6310 | cand[3] = 2 + ((minab + 61) % 64); | |
759 | 6310 | cand[4] = 2 + ((maxab - 1) % 64); | |
760 | } else { | ||
761 | 45366 | cand[2] = 2 + ((minab + 61) % 64); | |
762 | 45366 | cand[3] = 2 + ((minab - 1) % 64); | |
763 | 45366 | cand[4] = 2 + ((maxab + 61) % 64); | |
764 | } | ||
765 |
4/4✓ Branch 0 taken 128807 times.
✓ Branch 1 taken 62280 times.
✓ Branch 2 taken 51320 times.
✓ Branch 3 taken 77487 times.
|
191087 | } else if (a > INTRA_DC || b > INTRA_DC) { |
766 | 113600 | cand[0] = maxab; | |
767 | 113600 | cand[1] = 2 + ((maxab + 61 ) % 64); | |
768 | 113600 | cand[2] = 2 + ((maxab - 1) % 64); | |
769 | 113600 | cand[3] = 2 + ((maxab + 60 ) % 64); | |
770 | 113600 | cand[4] = 2 + (maxab % 64); | |
771 | } else { | ||
772 | 77487 | cand[0] = INTRA_DC; | |
773 | 77487 | cand[1] = INTRA_VERT; | |
774 | 77487 | cand[2] = INTRA_HORZ; | |
775 | 77487 | cand[3] = INTRA_VERT - 4; | |
776 | 77487 | cand[4] = INTRA_VERT + 4; | |
777 | } | ||
778 | } | ||
779 |
2/2✓ Branch 0 taken 171532 times.
✓ Branch 1 taken 103415 times.
|
274947 | if (intra_luma_mpm_flag) { |
780 | 171532 | pred = cand[intra_luma_mpm_idx]; | |
781 | } else { | ||
782 | 103415 | qsort(cand, FF_ARRAY_ELEMS(cand), sizeof(cand[0]), less); | |
783 | 103415 | pred = intra_luma_mpm_remainder + 1; | |
784 |
2/2✓ Branch 0 taken 517075 times.
✓ Branch 1 taken 103415 times.
|
620490 | for (int i = 0; i < FF_ARRAY_ELEMS(cand); i++) { |
785 |
2/2✓ Branch 0 taken 253991 times.
✓ Branch 1 taken 263084 times.
|
517075 | if (pred >= cand[i]) |
786 | 253991 | pred++; | |
787 | } | ||
788 | } | ||
789 | } | ||
790 | 445017 | return pred; | |
791 | } | ||
792 | |||
793 | 841795 | static int lfnst_idx_decode(VVCLocalContext *lc) | |
794 | { | ||
795 | 841795 | CodingUnit *cu = lc->cu; | |
796 | 841795 | const VVCTreeType tree_type = cu->tree_type; | |
797 | 841795 | const VVCSPS *sps = lc->fc->ps.sps; | |
798 | 841795 | const int cb_width = cu->cb_width; | |
799 | 841795 | const int cb_height = cu->cb_height; | |
800 | 841795 | const TransformUnit *tu = cu->tus.head; | |
801 | int lfnst_width, lfnst_height, min_lfnst; | ||
802 | 841795 | int lfnst_idx = 0; | |
803 | |||
804 | 841795 | memset(cu->apply_lfnst_flag, 0, sizeof(cu->apply_lfnst_flag)); | |
805 | |||
806 |
5/6✓ Branch 0 taken 619048 times.
✓ Branch 1 taken 222747 times.
✓ Branch 2 taken 523975 times.
✓ Branch 3 taken 95073 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 523975 times.
|
841795 | if (!sps->r->sps_lfnst_enabled_flag || cu->pred_mode != MODE_INTRA || FFMAX(cb_width, cb_height) > sps->max_tb_size_y) |
807 | 317820 | return 0; | |
808 | |||
809 |
2/2✓ Branch 0 taken 630629 times.
✓ Branch 1 taken 510117 times.
|
1140746 | while (tu) { |
810 |
2/2✓ Branch 0 taken 816487 times.
✓ Branch 1 taken 616771 times.
|
1433258 | for (int j = 0; j < tu->nb_tbs; j++) { |
811 | 816487 | const TransformBlock *tb = tu->tbs + j; | |
812 |
4/4✓ Branch 0 taken 552604 times.
✓ Branch 1 taken 263883 times.
✓ Branch 2 taken 13858 times.
✓ Branch 3 taken 538746 times.
|
816487 | if (tu->coded_flag[tb->c_idx] && tb->ts) |
813 | 13858 | return 0; | |
814 | } | ||
815 | 616771 | tu = tu->next; | |
816 | } | ||
817 | |||
818 |
2/2✓ Branch 0 taken 120767 times.
✓ Branch 1 taken 389350 times.
|
510117 | if (tree_type == DUAL_TREE_CHROMA) { |
819 | 120767 | lfnst_width = cb_width >> sps->hshift[1]; | |
820 | 120767 | lfnst_height = cb_height >> sps->vshift[1]; | |
821 | } else { | ||
822 | 389350 | const int vs = cu->isp_split_type == ISP_VER_SPLIT; | |
823 | 389350 | const int hs = cu->isp_split_type == ISP_HOR_SPLIT; | |
824 |
2/2✓ Branch 0 taken 17044 times.
✓ Branch 1 taken 372306 times.
|
389350 | lfnst_width = vs ? cb_width / cu->num_intra_subpartitions : cb_width; |
825 |
2/2✓ Branch 0 taken 29922 times.
✓ Branch 1 taken 359428 times.
|
389350 | lfnst_height = hs ? cb_height / cu->num_intra_subpartitions : cb_height; |
826 | } | ||
827 | 510117 | min_lfnst = FFMIN(lfnst_width, lfnst_height); | |
828 |
6/6✓ Branch 0 taken 389350 times.
✓ Branch 1 taken 120767 times.
✓ Branch 2 taken 94493 times.
✓ Branch 3 taken 294857 times.
✓ Branch 4 taken 74841 times.
✓ Branch 5 taken 19652 times.
|
510117 | if (tree_type != DUAL_TREE_CHROMA && cu->intra_mip_flag && min_lfnst < 16) |
829 | 74841 | return 0; | |
830 | |||
831 |
2/2✓ Branch 0 taken 405293 times.
✓ Branch 1 taken 29983 times.
|
435276 | if (min_lfnst >= 4) { |
832 |
6/6✓ Branch 0 taken 378404 times.
✓ Branch 1 taken 26889 times.
✓ Branch 2 taken 168565 times.
✓ Branch 3 taken 209839 times.
✓ Branch 4 taken 164626 times.
✓ Branch 5 taken 30828 times.
|
405293 | if ((cu->isp_split_type != ISP_NO_SPLIT || !lc->parse.lfnst_dc_only) && lc->parse.lfnst_zero_out_sig_coeff_flag) |
833 | 164626 | lfnst_idx = ff_vvc_lfnst_idx(lc, tree_type != SINGLE_TREE); | |
834 | } | ||
835 | |||
836 |
2/2✓ Branch 0 taken 122033 times.
✓ Branch 1 taken 313243 times.
|
435276 | if (lfnst_idx) { |
837 | 122033 | cu->apply_lfnst_flag[LUMA] = tree_type != DUAL_TREE_CHROMA; | |
838 | 122033 | cu->apply_lfnst_flag[CB] = cu->apply_lfnst_flag[CR] = tree_type == DUAL_TREE_CHROMA; | |
839 | } | ||
840 | |||
841 | 435276 | return lfnst_idx; | |
842 | } | ||
843 | |||
844 | 841795 | static MtsIdx mts_idx_decode(VVCLocalContext *lc) | |
845 | { | ||
846 | 841795 | const CodingUnit *cu = lc->cu; | |
847 | 841795 | const VVCSPS *sps = lc->fc->ps.sps; | |
848 | 841795 | const int cb_width = cu->cb_width; | |
849 | 841795 | const int cb_height = cu->cb_height; | |
850 | 841795 | const uint8_t transform_skip_flag = cu->tus.head->tbs[0].ts; //fix me | |
851 | 841795 | int mts_idx = MTS_DCT2_DCT2; | |
852 |
6/6✓ Branch 0 taken 682514 times.
✓ Branch 1 taken 159281 times.
✓ Branch 2 taken 588799 times.
✓ Branch 3 taken 93715 times.
✓ Branch 4 taken 563548 times.
✓ Branch 5 taken 25251 times.
|
841795 | if (cu->tree_type != DUAL_TREE_CHROMA && !cu->lfnst_idx && |
853 |
2/2✓ Branch 0 taken 545004 times.
✓ Branch 1 taken 18544 times.
|
563548 | !transform_skip_flag && FFMAX(cb_width, cb_height) <= 32 && |
854 |
4/4✓ Branch 0 taken 499765 times.
✓ Branch 1 taken 45239 times.
✓ Branch 2 taken 463996 times.
✓ Branch 3 taken 35769 times.
|
545004 | cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag && |
855 |
4/4✓ Branch 0 taken 455325 times.
✓ Branch 1 taken 8671 times.
✓ Branch 2 taken 313261 times.
✓ Branch 3 taken 142064 times.
|
463996 | lc->parse.mts_zero_out_sig_coeff_flag && !lc->parse.mts_dc_only) { |
856 |
3/4✓ Branch 0 taken 54689 times.
✓ Branch 1 taken 258572 times.
✓ Branch 2 taken 54689 times.
✗ Branch 3 not taken.
|
313261 | if ((cu->pred_mode == MODE_INTER && sps->r->sps_explicit_mts_inter_enabled_flag) || |
857 |
4/4✓ Branch 0 taken 258527 times.
✓ Branch 1 taken 54734 times.
✓ Branch 2 taken 244197 times.
✓ Branch 3 taken 14330 times.
|
313261 | (cu->pred_mode == MODE_INTRA && sps->r->sps_explicit_mts_intra_enabled_flag)) { |
858 | 244197 | mts_idx = ff_vvc_mts_idx(lc); | |
859 | } | ||
860 | } | ||
861 | |||
862 | 841795 | return mts_idx; | |
863 | } | ||
864 | |||
865 | 203434 | static enum IntraPredMode derive_center_luma_intra_pred_mode(const VVCFrameContext *fc, const VVCSPS *sps, const VVCPPS *pps, const CodingUnit *cu) | |
866 | { | ||
867 | 203434 | const int x_center = (cu->x0 + cu->cb_width / 2) >> sps->min_cb_log2_size_y; | |
868 | 203434 | const int y_center = (cu->y0 + cu->cb_height / 2) >> sps->min_cb_log2_size_y; | |
869 | 203434 | const int min_cb_width = pps->min_cb_width; | |
870 | 203434 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_center, y_center); | |
871 | 203434 | const int cu_pred_mode = SAMPLE_CTB(fc->tab.cpm[0], x_center, y_center); | |
872 | 203434 | const int intra_pred_mode_y = SAMPLE_CTB(fc->tab.ipm, x_center, y_center); | |
873 | |||
874 |
2/2✓ Branch 0 taken 41927 times.
✓ Branch 1 taken 161507 times.
|
203434 | if (intra_mip_flag) { |
875 |
4/4✓ Branch 0 taken 8686 times.
✓ Branch 1 taken 33241 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 8442 times.
|
41927 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
876 | 244 | return INTRA_INVALID; | |
877 | 41683 | return INTRA_PLANAR; | |
878 | } | ||
879 |
3/4✓ Branch 0 taken 161401 times.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161401 times.
|
161507 | if (cu_pred_mode == MODE_IBC || cu_pred_mode == MODE_PLT) |
880 | 106 | return INTRA_DC; | |
881 | 161401 | return intra_pred_mode_y; | |
882 | } | ||
883 | |||
884 | 203578 | static void derive_chroma_intra_pred_mode(VVCLocalContext *lc, | |
885 | const int cclm_mode_flag, const int cclm_mode_idx, const int intra_chroma_pred_mode) | ||
886 | { | ||
887 | 203578 | const VVCFrameContext *fc = lc->fc; | |
888 | 203578 | CodingUnit *cu = lc->cu; | |
889 | 203578 | const VVCSPS *sps = fc->ps.sps; | |
890 | 203578 | const VVCPPS *pps = fc->ps.pps; | |
891 | 203578 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
892 | 203578 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
893 | 203578 | const int min_cb_width = pps->min_cb_width; | |
894 | 203578 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
895 | 203578 | enum IntraPredMode luma_intra_pred_mode = SAMPLE_CTB(fc->tab.ipm, x_cb, y_cb); | |
896 | |||
897 |
6/6✓ Branch 0 taken 44300 times.
✓ Branch 1 taken 159278 times.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 42175 times.
✓ Branch 4 taken 679 times.
✓ Branch 5 taken 1446 times.
|
203578 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && |
898 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 535 times.
|
679 | intra_chroma_pred_mode == 4 && intra_mip_flag) { |
899 | 144 | cu->mip_chroma_direct_flag = 1; | |
900 | 144 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
901 | 144 | return; | |
902 | } | ||
903 | 203434 | luma_intra_pred_mode = derive_center_luma_intra_pred_mode(fc, sps, pps, cu); | |
904 | |||
905 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 203434 times.
|
203434 | if (cu->act_enabled_flag) { |
906 | ✗ | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
907 | ✗ | return; | |
908 | } | ||
909 |
2/2✓ Branch 0 taken 82776 times.
✓ Branch 1 taken 120658 times.
|
203434 | if (cclm_mode_flag) { |
910 | 82776 | cu->intra_pred_mode_c = INTRA_LT_CCLM + cclm_mode_idx; | |
911 |
2/2✓ Branch 0 taken 89500 times.
✓ Branch 1 taken 31158 times.
|
120658 | } else if (intra_chroma_pred_mode == 4){ |
912 | 89500 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
913 | } else { | ||
914 | const static IntraPredMode pred_mode_c[][4 + 1] = { | ||
915 | {INTRA_VDIAG, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR}, | ||
916 | {INTRA_VERT, INTRA_VDIAG, INTRA_VERT, INTRA_VERT, INTRA_VERT}, | ||
917 | {INTRA_HORZ, INTRA_HORZ, INTRA_VDIAG, INTRA_HORZ, INTRA_HORZ}, | ||
918 | {INTRA_DC, INTRA_DC, INTRA_DC, INTRA_VDIAG, INTRA_DC}, | ||
919 | }; | ||
920 | 31158 | const int modes[4] = {INTRA_PLANAR, INTRA_VERT, INTRA_HORZ, INTRA_DC}; | |
921 | int idx; | ||
922 | |||
923 | // This workaround is necessary to have 4:4:4 video decode correctly | ||
924 | // See VVC ticket https://jvet.hhi.fraunhofer.de/trac/vvc/ticket/1602 | ||
925 | // and VTM source https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM/-/blob/master/source/Lib/CommonLib/UnitTools.cpp#L736 | ||
926 |
6/6✓ Branch 0 taken 2515 times.
✓ Branch 1 taken 28643 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 2272 times.
✓ Branch 4 taken 43 times.
✓ Branch 5 taken 200 times.
|
31158 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && intra_mip_flag) { |
927 | 43 | idx = 4; | |
928 | } else { | ||
929 |
2/2✓ Branch 0 taken 69679 times.
✓ Branch 1 taken 10510 times.
|
80189 | for (idx = 0; idx < FF_ARRAY_ELEMS(modes); idx++) { |
930 |
2/2✓ Branch 0 taken 20605 times.
✓ Branch 1 taken 49074 times.
|
69679 | if (modes[idx] == luma_intra_pred_mode) |
931 | 20605 | break; | |
932 | } | ||
933 | } | ||
934 | |||
935 | 31158 | cu->intra_pred_mode_c = pred_mode_c[intra_chroma_pred_mode][idx]; | |
936 | } | ||
937 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 203434 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
203434 | if (sps->r->sps_chroma_format_idc == CHROMA_FORMAT_422 && cu->intra_pred_mode_c <= INTRA_VDIAG) { |
938 | const static int mode_map_422[INTRA_VDIAG + 1] = { | ||
939 | 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 5, 6, 8, 10, 12, 13, | ||
940 | 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 31, 33, 34, 35, 36, 37, | ||
941 | 38, 39, 40, 41, 41, 42, 43, 43, 44, 44, 45, 45, 46, 47, 48, 48, | ||
942 | 49, 49, 50, 51, 51, 52, 52, 53, 54, 55, 55, 56, 56, 57, 57, 58, | ||
943 | 59, 59, 60, | ||
944 | }; | ||
945 | ✗ | cu->intra_pred_mode_c = mode_map_422[cu->intra_pred_mode_c]; | |
946 | } | ||
947 | } | ||
948 | |||
949 | 543038 | static void intra_luma_pred_modes(VVCLocalContext *lc) | |
950 | { | ||
951 | 543038 | VVCFrameContext *fc = lc->fc; | |
952 | 543038 | const VVCSPS *sps = fc->ps.sps; | |
953 | 543038 | const VVCPPS *pps = fc->ps.pps; | |
954 | 543038 | CodingUnit *cu = lc->cu; | |
955 | 543038 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
956 | 543038 | const int x0 = cu->x0; | |
957 | 543038 | const int y0 = cu->y0; | |
958 | 543038 | const int x_cb = x0 >> log2_min_cb_size; | |
959 | 543038 | const int y_cb = y0 >> log2_min_cb_size; | |
960 | 543038 | const int cb_width = cu->cb_width; | |
961 | 543038 | const int cb_height = cu->cb_height; | |
962 | |||
963 | 543038 | cu->intra_luma_ref_idx = 0; | |
964 |
6/6✓ Branch 0 taken 28688 times.
✓ Branch 1 taken 514350 times.
✓ Branch 2 taken 27889 times.
✓ Branch 3 taken 799 times.
✓ Branch 4 taken 27878 times.
✓ Branch 5 taken 11 times.
|
543038 | if (sps->r->sps_bdpcm_enabled_flag && cb_width <= sps->max_ts_size && cb_height <= sps->max_ts_size) |
965 | 27878 | cu->bdpcm_flag[LUMA] = ff_vvc_intra_bdpcm_luma_flag(lc); | |
966 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 543000 times.
|
543038 | if (cu->bdpcm_flag[LUMA]) { |
967 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 2 taken 18 times.
|
38 | cu->intra_pred_mode_y = ff_vvc_intra_bdpcm_luma_dir_flag(lc) ? INTRA_VERT : INTRA_HORZ; |
968 | } else { | ||
969 |
2/2✓ Branch 0 taken 401168 times.
✓ Branch 1 taken 141832 times.
|
543000 | if (sps->r->sps_mip_enabled_flag) |
970 | 401168 | cu->intra_mip_flag = ff_vvc_intra_mip_flag(lc, fc->tab.imf); | |
971 |
2/2✓ Branch 0 taken 97983 times.
✓ Branch 1 taken 445017 times.
|
543000 | if (cu->intra_mip_flag) { |
972 | 97983 | int intra_mip_transposed_flag = ff_vvc_intra_mip_transposed_flag(lc); | |
973 | 97983 | int intra_mip_mode = ff_vvc_intra_mip_mode(lc); | |
974 | 97983 | int x = y_cb * pps->min_cb_width + x_cb; | |
975 |
2/2✓ Branch 0 taken 268606 times.
✓ Branch 1 taken 97983 times.
|
366589 | for (int y = 0; y < (cb_height>>log2_min_cb_size); y++) { |
976 | 268606 | int width = cb_width>>log2_min_cb_size; | |
977 | 268606 | memset(&fc->tab.imf[x], cu->intra_mip_flag, width); | |
978 | 268606 | fc->tab.imtf[x] = intra_mip_transposed_flag; | |
979 | 268606 | fc->tab.imm[x] = intra_mip_mode; | |
980 | 268606 | x += pps->min_cb_width; | |
981 | } | ||
982 | 97983 | cu->intra_pred_mode_y = intra_mip_mode; | |
983 | } else { | ||
984 | 445017 | int intra_subpartitions_mode_flag = 0; | |
985 |
4/4✓ Branch 0 taken 426093 times.
✓ Branch 1 taken 18924 times.
✓ Branch 2 taken 389011 times.
✓ Branch 3 taken 37082 times.
|
445017 | if (sps->r->sps_mrl_enabled_flag && ((y0 % sps->ctb_size_y) > 0)) |
986 | 389011 | cu->intra_luma_ref_idx = ff_vvc_intra_luma_ref_idx(lc); | |
987 |
4/4✓ Branch 0 taken 426093 times.
✓ Branch 1 taken 18924 times.
✓ Branch 2 taken 395947 times.
✓ Branch 3 taken 30146 times.
|
445017 | if (sps->r->sps_isp_enabled_flag && !cu->intra_luma_ref_idx && |
988 |
2/4✓ Branch 0 taken 395947 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 395947 times.
✗ Branch 3 not taken.
|
395947 | (cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) && |
989 |
2/2✓ Branch 0 taken 349125 times.
✓ Branch 1 taken 46822 times.
|
395947 | (cb_width * cb_height > MIN_TU_SIZE * MIN_TU_SIZE) && |
990 |
1/2✓ Branch 0 taken 349125 times.
✗ Branch 1 not taken.
|
349125 | !cu->act_enabled_flag) |
991 | 349125 | intra_subpartitions_mode_flag = ff_vvc_intra_subpartitions_mode_flag(lc); | |
992 |
4/4✓ Branch 0 taken 90472 times.
✓ Branch 1 taken 354545 times.
✓ Branch 2 taken 20051 times.
✓ Branch 3 taken 70421 times.
|
445017 | if (!(x0 & 63) && !(y0 & 63)) |
993 | 20051 | TAB_ISPMF(fc, x0, y0) = intra_subpartitions_mode_flag; | |
994 | 445017 | cu->isp_split_type = ff_vvc_isp_split_type(lc, intra_subpartitions_mode_flag); | |
995 | 445017 | cu->num_intra_subpartitions = get_num_intra_subpartitions(cu->isp_split_type, cb_width, cb_height); | |
996 | 445017 | cu->intra_pred_mode_y = luma_intra_pred_mode(lc, intra_subpartitions_mode_flag); | |
997 | } | ||
998 | } | ||
999 | 543038 | set_cb_tab(lc, fc->tab.ipm, cu->intra_pred_mode_y); | |
1000 | 543038 | } | |
1001 | |||
1002 | 203581 | static void intra_chroma_pred_modes(VVCLocalContext *lc) | |
1003 | { | ||
1004 | 203581 | const VVCSPS *sps = lc->fc->ps.sps; | |
1005 | 203581 | CodingUnit *cu = lc->cu; | |
1006 | 203581 | const int hs = sps->hshift[CHROMA]; | |
1007 | 203581 | const int vs = sps->vshift[CHROMA]; | |
1008 | |||
1009 | 203581 | cu->mip_chroma_direct_flag = 0; | |
1010 |
2/2✓ Branch 0 taken 25937 times.
✓ Branch 1 taken 177644 times.
|
203581 | if (sps->r->sps_bdpcm_enabled_flag && |
1011 |
2/2✓ Branch 0 taken 24636 times.
✓ Branch 1 taken 1301 times.
|
25937 | (cu->cb_width >> hs) <= sps->max_ts_size && |
1012 |
2/2✓ Branch 0 taken 24174 times.
✓ Branch 1 taken 462 times.
|
24636 | (cu->cb_height >> vs) <= sps->max_ts_size) { |
1013 | 24174 | cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = ff_vvc_intra_bdpcm_chroma_flag(lc); | |
1014 | } | ||
1015 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 203578 times.
|
203581 | if (cu->bdpcm_flag[CHROMA]) { |
1016 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
|
3 | cu->intra_pred_mode_c = ff_vvc_intra_bdpcm_chroma_dir_flag(lc) ? INTRA_VERT : INTRA_HORZ; |
1017 | } else { | ||
1018 | 203578 | const int cclm_enabled = get_cclm_enabled(lc, cu->x0, cu->y0); | |
1019 | 203578 | int cclm_mode_flag = 0; | |
1020 | 203578 | int cclm_mode_idx = 0; | |
1021 | 203578 | int intra_chroma_pred_mode = 0; | |
1022 | |||
1023 |
2/2✓ Branch 0 taken 188650 times.
✓ Branch 1 taken 14928 times.
|
203578 | if (cclm_enabled) |
1024 | 188650 | cclm_mode_flag = ff_vvc_cclm_mode_flag(lc); | |
1025 | |||
1026 |
2/2✓ Branch 0 taken 82776 times.
✓ Branch 1 taken 120802 times.
|
203578 | if (cclm_mode_flag) |
1027 | 82776 | cclm_mode_idx = ff_vvc_cclm_mode_idx(lc); | |
1028 | else | ||
1029 | 120802 | intra_chroma_pred_mode = ff_vvc_intra_chroma_pred_mode(lc); | |
1030 | 203578 | derive_chroma_intra_pred_mode(lc, cclm_mode_flag, cclm_mode_idx, intra_chroma_pred_mode); | |
1031 | } | ||
1032 | 203581 | } | |
1033 | |||
1034 | 1107877 | static PredMode pred_mode_decode(VVCLocalContext *lc, | |
1035 | const VVCTreeType tree_type, | ||
1036 | const VVCModeType mode_type) | ||
1037 | { | ||
1038 | 1107877 | const VVCFrameContext *fc = lc->fc; | |
1039 | 1107877 | CodingUnit *cu = lc->cu; | |
1040 | 1107877 | const VVCSPS *sps = fc->ps.sps; | |
1041 | 1107877 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1042 | 1107877 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
1043 |
4/4✓ Branch 0 taken 209927 times.
✓ Branch 1 taken 897950 times.
✓ Branch 2 taken 72354 times.
✓ Branch 3 taken 137573 times.
|
1107877 | const int is_4x4 = cu->cb_width == 4 && cu->cb_height == 4; |
1044 | int pred_mode_flag; | ||
1045 | int pred_mode_ibc_flag; | ||
1046 | PredMode pred_mode; | ||
1047 | |||
1048 | 1107877 | cu->skip_flag = 0; | |
1049 |
4/4✓ Branch 0 taken 622702 times.
✓ Branch 1 taken 485175 times.
✓ Branch 2 taken 2408 times.
✓ Branch 3 taken 620294 times.
|
1595460 | if (!IS_I(rsh) || sps->r->sps_ibc_enabled_flag) { |
1050 |
4/4✓ Branch 0 taken 465606 times.
✓ Branch 1 taken 21977 times.
✓ Branch 2 taken 2153 times.
✓ Branch 3 taken 463453 times.
|
487583 | const int is_128 = cu->cb_width == 128 || cu->cb_height == 128; |
1051 |
4/4✓ Branch 0 taken 478938 times.
✓ Branch 1 taken 8645 times.
✓ Branch 2 taken 469574 times.
✓ Branch 3 taken 9364 times.
|
487583 | if (tree_type != DUAL_TREE_CHROMA && |
1052 |
2/2✓ Branch 0 taken 18718 times.
✓ Branch 1 taken 450856 times.
|
469574 | ((!is_4x4 && mode_type != MODE_TYPE_INTRA) || |
1053 |
3/4✓ Branch 0 taken 436 times.
✓ Branch 1 taken 27646 times.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
|
28082 | (sps->r->sps_ibc_enabled_flag && !is_128))) { |
1054 | 451292 | cu->skip_flag = ff_vvc_cu_skip_flag(lc, fc->tab.skip); | |
1055 | } | ||
1056 | |||
1057 |
6/6✓ Branch 0 taken 478219 times.
✓ Branch 1 taken 9364 times.
✓ Branch 2 taken 451016 times.
✓ Branch 3 taken 27203 times.
✓ Branch 4 taken 2112 times.
✓ Branch 5 taken 448904 times.
|
487583 | if (is_4x4 || mode_type == MODE_TYPE_INTRA || IS_I(rsh)) { |
1058 | 38679 | pred_mode_flag = 1; | |
1059 |
4/4✓ Branch 0 taken 393264 times.
✓ Branch 1 taken 55640 times.
✓ Branch 2 taken 208527 times.
✓ Branch 3 taken 184737 times.
|
448904 | } else if (mode_type == MODE_TYPE_INTER || cu->skip_flag) { |
1060 | 264167 | pred_mode_flag = 0; | |
1061 | } else { | ||
1062 | 184737 | pred_mode_flag = ff_vvc_pred_mode_flag(lc, ch_type); | |
1063 | } | ||
1064 | 487583 | pred_mode = pred_mode_flag ? MODE_INTRA : MODE_INTER; | |
1065 | |||
1066 |
4/4✓ Branch 0 taken 2408 times.
✓ Branch 1 taken 485175 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 2312 times.
|
487583 | if (((IS_I(rsh) && !cu->skip_flag) || |
1067 |
6/6✓ Branch 0 taken 485175 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 81160 times.
✓ Branch 3 taken 404015 times.
✓ Branch 4 taken 72092 times.
✓ Branch 5 taken 9068 times.
|
485271 | (!IS_I(rsh) && (pred_mode != MODE_INTRA || |
1068 |
6/6✓ Branch 0 taken 27203 times.
✓ Branch 1 taken 44889 times.
✓ Branch 2 taken 36247 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 418444 times.
✓ Branch 5 taken 24130 times.
|
487487 | ((is_4x4 || mode_type == MODE_TYPE_INTRA) && !cu->skip_flag)))) && |
1069 |
6/6✓ Branch 0 taken 362804 times.
✓ Branch 1 taken 55640 times.
✓ Branch 2 taken 3239 times.
✓ Branch 3 taken 359565 times.
✓ Branch 4 taken 3032 times.
✓ Branch 5 taken 207 times.
|
418444 | !is_128 && mode_type != MODE_TYPE_INTER && sps->r->sps_ibc_enabled_flag && |
1070 | tree_type != DUAL_TREE_CHROMA) { | ||
1071 | 3032 | pred_mode_ibc_flag = ff_vvc_pred_mode_ibc_flag(lc, ch_type); | |
1072 |
6/6✓ Branch 0 taken 233277 times.
✓ Branch 1 taken 251274 times.
✓ Branch 2 taken 233250 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 233235 times.
|
484551 | } else if (cu->skip_flag && (is_4x4 || mode_type == MODE_TYPE_INTRA)) { |
1073 | 42 | pred_mode_ibc_flag = 1; | |
1074 |
6/6✓ Branch 0 taken 460379 times.
✓ Branch 1 taken 24130 times.
✓ Branch 2 taken 404739 times.
✓ Branch 3 taken 55640 times.
✓ Branch 4 taken 8645 times.
✓ Branch 5 taken 396094 times.
|
484509 | } else if (is_128 || mode_type == MODE_TYPE_INTER || tree_type == DUAL_TREE_CHROMA) { |
1075 | 88415 | pred_mode_ibc_flag = 0; | |
1076 | } else { | ||
1077 |
2/2✓ Branch 0 taken 78 times.
✓ Branch 1 taken 396016 times.
|
396094 | pred_mode_ibc_flag = (IS_I(rsh)) ? sps->r->sps_ibc_enabled_flag : 0; |
1078 | } | ||
1079 |
2/2✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 486001 times.
|
487583 | if (pred_mode_ibc_flag) |
1080 | 1582 | pred_mode = MODE_IBC; | |
1081 | } else { | ||
1082 | 620294 | pred_mode = MODE_INTRA; | |
1083 | } | ||
1084 | |||
1085 | 1107877 | set_cb_tab(lc, fc->tab.cpm[cu->ch_type], pred_mode); | |
1086 |
2/2✓ Branch 0 taken 463437 times.
✓ Branch 1 taken 644440 times.
|
1107877 | if (tree_type == SINGLE_TREE) |
1087 | 463437 | set_cb_tab(lc, fc->tab.cpm[CHROMA], pred_mode); | |
1088 | |||
1089 | 1107877 | return pred_mode; | |
1090 | } | ||
1091 | |||
1092 | 841795 | static void sbt_info(VVCLocalContext *lc, const VVCSPS *sps) | |
1093 | { | ||
1094 | 841795 | CodingUnit *cu = lc->cu; | |
1095 | 841795 | const int cb_width = cu->cb_width; | |
1096 | 841795 | const int cb_height = cu->cb_height; | |
1097 | |||
1098 |
6/6✓ Branch 0 taken 138712 times.
✓ Branch 1 taken 703083 times.
✓ Branch 2 taken 132984 times.
✓ Branch 3 taken 5728 times.
✓ Branch 4 taken 117891 times.
✓ Branch 5 taken 15093 times.
|
841795 | if (cu->pred_mode == MODE_INTER && sps->r->sps_sbt_enabled_flag && !cu->ciip_flag |
1099 |
4/4✓ Branch 0 taken 117209 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 116966 times.
✓ Branch 3 taken 243 times.
|
117891 | && cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) { |
1100 | 116966 | const int sbt_ver_h = cb_width >= 8; | |
1101 | 116966 | const int sbt_hor_h = cb_height >= 8; | |
1102 | 116966 | cu->sbt_flag = 0; | |
1103 |
3/4✓ Branch 0 taken 16948 times.
✓ Branch 1 taken 100018 times.
✓ Branch 2 taken 16948 times.
✗ Branch 3 not taken.
|
116966 | if (sbt_ver_h || sbt_hor_h) |
1104 | 116966 | cu->sbt_flag = ff_vvc_sbt_flag(lc); | |
1105 |
2/2✓ Branch 0 taken 37306 times.
✓ Branch 1 taken 79660 times.
|
116966 | if (cu->sbt_flag) { |
1106 | 37306 | const int sbt_ver_q = cb_width >= 16; | |
1107 | 37306 | const int sbt_hor_q = cb_height >= 16; | |
1108 | 37306 | int cu_sbt_quad_flag = 0; | |
1109 | |||
1110 |
7/8✓ Branch 0 taken 5966 times.
✓ Branch 1 taken 31340 times.
✓ Branch 2 taken 5966 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20658 times.
✓ Branch 5 taken 16648 times.
✓ Branch 6 taken 10919 times.
✓ Branch 7 taken 9739 times.
|
37306 | if ((sbt_ver_h || sbt_hor_h) && (sbt_ver_q || sbt_hor_q)) |
1111 | 27567 | cu_sbt_quad_flag = ff_vvc_sbt_quad_flag(lc); | |
1112 |
2/2✓ Branch 0 taken 9645 times.
✓ Branch 1 taken 27661 times.
|
37306 | if (cu_sbt_quad_flag) { |
1113 | 9645 | cu->sbt_horizontal_flag = sbt_hor_q; | |
1114 |
4/4✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 3539 times.
✓ Branch 2 taken 3101 times.
✓ Branch 3 taken 3005 times.
|
9645 | if (sbt_ver_q && sbt_hor_q) |
1115 | 3101 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
1116 | } else { | ||
1117 | 27661 | cu->sbt_horizontal_flag = sbt_hor_h; | |
1118 |
4/4✓ Branch 0 taken 23046 times.
✓ Branch 1 taken 4615 times.
✓ Branch 2 taken 19107 times.
✓ Branch 3 taken 3939 times.
|
27661 | if (sbt_ver_h && sbt_hor_h) |
1119 | 19107 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
1120 | } | ||
1121 | 37306 | cu->sbt_pos_flag = ff_vvc_sbt_pos_flag(lc); | |
1122 | |||
1123 | { | ||
1124 |
2/2✓ Branch 0 taken 9645 times.
✓ Branch 1 taken 27661 times.
|
37306 | const int sbt_min = cu_sbt_quad_flag ? 1 : 2; |
1125 |
2/2✓ Branch 0 taken 17766 times.
✓ Branch 1 taken 19540 times.
|
37306 | lc->parse.sbt_num_fourths_tb0 = cu->sbt_pos_flag ? (4 - sbt_min) : sbt_min; |
1126 | } | ||
1127 | } | ||
1128 | } | ||
1129 | 841795 | } | |
1130 | |||
1131 | 266082 | static int skipped_transform_tree_unit(VVCLocalContext *lc) | |
1132 | { | ||
1133 | 266082 | const H266RawSPS *rsps = lc->fc->ps.sps->r; | |
1134 | 266082 | const CodingUnit *cu = lc->cu; | |
1135 | int ret; | ||
1136 | |||
1137 |
1/2✓ Branch 0 taken 266082 times.
✗ Branch 1 not taken.
|
266082 | if (cu->tree_type != DUAL_TREE_CHROMA) |
1138 | 266082 | set_qp_y(lc, cu->x0, cu->y0, 0); | |
1139 |
4/4✓ Branch 0 taken 249571 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 248775 times.
✓ Branch 3 taken 796 times.
|
266082 | if (rsps->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA) |
1140 | 248775 | set_qp_c(lc); | |
1141 | 266082 | ret = skipped_transform_tree(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
1142 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 266082 times.
|
266082 | if (ret < 0) |
1143 | ✗ | return ret; | |
1144 | 266082 | return 0; | |
1145 | } | ||
1146 | |||
1147 | 1107877 | static void set_cb_pos(const VVCFrameContext *fc, const CodingUnit *cu) | |
1148 | { | ||
1149 | 1107877 | const VVCSPS *sps = fc->ps.sps; | |
1150 | 1107877 | const VVCPPS *pps = fc->ps.pps; | |
1151 | 1107877 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
1152 | 1107877 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
1153 | 1107877 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
1154 | 1107877 | const int ch_type = cu->ch_type; | |
1155 | int x, y; | ||
1156 | |||
1157 | 1107877 | x = y_cb * pps->min_cb_width + x_cb; | |
1158 |
2/2✓ Branch 0 taken 4823410 times.
✓ Branch 1 taken 1107877 times.
|
5931287 | for (y = 0; y < (cu->cb_height >> log2_min_cb_size); y++) { |
1159 | 4823410 | const int width = cu->cb_width >> log2_min_cb_size; | |
1160 | |||
1161 |
2/2✓ Branch 0 taken 46662748 times.
✓ Branch 1 taken 4823410 times.
|
51486158 | for (int i = 0; i < width; i++) { |
1162 | 46662748 | fc->tab.cb_pos_x[ch_type][x + i] = cu->x0; | |
1163 | 46662748 | fc->tab.cb_pos_y[ch_type][x + i] = cu->y0; | |
1164 | } | ||
1165 | 4823410 | memset(&fc->tab.cb_width[ch_type][x], cu->cb_width, width); | |
1166 | 4823410 | memset(&fc->tab.cb_height[ch_type][x], cu->cb_height, width); | |
1167 | 4823410 | memset(&fc->tab.cqt_depth[ch_type][x], cu->cqt_depth, width); | |
1168 | |||
1169 | 4823410 | x += pps->min_cb_width; | |
1170 | } | ||
1171 | 1107877 | } | |
1172 | |||
1173 | 1107877 | static CodingUnit* alloc_cu(VVCLocalContext *lc, const int x0, const int y0) | |
1174 | { | ||
1175 | 1107877 | VVCFrameContext *fc = lc->fc; | |
1176 | 1107877 | const VVCSPS *sps = fc->ps.sps; | |
1177 | 1107877 | const VVCPPS *pps = fc->ps.pps; | |
1178 | 1107877 | const int rx = x0 >> sps->ctb_log2_size_y; | |
1179 | 1107877 | const int ry = y0 >> sps->ctb_log2_size_y; | |
1180 | 1107877 | CodingUnit **cus = fc->tab.cus + ry * pps->ctb_width + rx; | |
1181 | 1107877 | CodingUnit *cu = ff_refstruct_pool_get(fc->cu_pool); | |
1182 | |||
1183 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1107877 times.
|
1107877 | if (!cu) |
1184 | ✗ | return NULL; | |
1185 | 1107877 | cu->next = NULL; | |
1186 | |||
1187 |
2/2✓ Branch 0 taken 1062085 times.
✓ Branch 1 taken 45792 times.
|
1107877 | if (lc->cu) |
1188 | 1062085 | lc->cu->next = cu; | |
1189 | else | ||
1190 | 45792 | *cus = cu; | |
1191 | 1107877 | lc->cu = cu; | |
1192 | |||
1193 | 1107877 | return cu; | |
1194 | } | ||
1195 | |||
1196 | 1107877 | static CodingUnit* add_cu(VVCLocalContext *lc, const int x0, const int y0, | |
1197 | const int cb_width, const int cb_height, const int cqt_depth, const VVCTreeType tree_type) | ||
1198 | { | ||
1199 | 1107877 | VVCFrameContext *fc = lc->fc; | |
1200 | 1107877 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
1201 | 1107877 | CodingUnit *cu = alloc_cu(lc, x0, y0); | |
1202 | |||
1203 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1107877 times.
|
1107877 | if (!cu) |
1204 | ✗ | return NULL; | |
1205 | |||
1206 | 1107877 | memset(&cu->pu, 0, sizeof(cu->pu)); | |
1207 | |||
1208 | 1107877 | lc->parse.prev_tu_cbf_y = 0; | |
1209 | |||
1210 | 1107877 | cu->sbt_flag = 0; | |
1211 | 1107877 | cu->act_enabled_flag = 0; | |
1212 | |||
1213 | 1107877 | cu->tree_type = tree_type; | |
1214 | 1107877 | cu->x0 = x0; | |
1215 | 1107877 | cu->y0 = y0; | |
1216 | 1107877 | cu->cb_width = cb_width; | |
1217 | 1107877 | cu->cb_height = cb_height; | |
1218 | 1107877 | cu->ch_type = ch_type; | |
1219 | 1107877 | cu->cqt_depth = cqt_depth; | |
1220 | 1107877 | cu->tus.head = cu->tus.tail = NULL; | |
1221 | 1107877 | cu->bdpcm_flag[LUMA] = cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = 0; | |
1222 | 1107877 | cu->isp_split_type = ISP_NO_SPLIT; | |
1223 | 1107877 | cu->intra_mip_flag = 0; | |
1224 | 1107877 | cu->ciip_flag = 0; | |
1225 | 1107877 | cu->coded_flag = 1; | |
1226 | 1107877 | cu->num_intra_subpartitions = 1; | |
1227 | 1107877 | cu->pu.dmvr_flag = 0; | |
1228 | |||
1229 | 1107877 | set_cb_pos(fc, cu); | |
1230 | 1107877 | return cu; | |
1231 | } | ||
1232 | |||
1233 | 1107877 | static void set_cu_tabs(const VVCLocalContext *lc, const CodingUnit *cu) | |
1234 | { | ||
1235 | 1107877 | const VVCFrameContext *fc = lc->fc; | |
1236 | 1107877 | const PredictionUnit *pu = &cu->pu; | |
1237 | 1107877 | const TransformUnit *tu = cu->tus.head; | |
1238 | |||
1239 | 1107877 | set_cb_tab(lc, fc->tab.mmi, pu->mi.motion_model_idc); | |
1240 | 1107877 | set_cb_tab(lc, fc->tab.msf, pu->merge_subblock_flag); | |
1241 |
2/2✓ Branch 0 taken 948596 times.
✓ Branch 1 taken 159281 times.
|
1107877 | if (cu->tree_type != DUAL_TREE_CHROMA) { |
1242 | 948596 | set_cb_tab(lc, fc->tab.skip, cu->skip_flag); | |
1243 | 948596 | set_cb_tab(lc, fc->tab.pcmf[LUMA], cu->bdpcm_flag[LUMA]); | |
1244 | } | ||
1245 |
2/2✓ Branch 0 taken 622718 times.
✓ Branch 1 taken 485159 times.
|
1107877 | if (cu->tree_type != DUAL_TREE_LUMA) |
1246 | 622718 | set_cb_tab(lc, fc->tab.pcmf[CHROMA], cu->bdpcm_flag[CHROMA]); | |
1247 | |||
1248 |
2/2✓ Branch 0 taken 1349398 times.
✓ Branch 1 taken 1107877 times.
|
2457275 | while (tu) { |
1249 |
2/2✓ Branch 0 taken 2564059 times.
✓ Branch 1 taken 1349398 times.
|
3913457 | for (int j = 0; j < tu->nb_tbs; j++) { |
1250 | 2564059 | const TransformBlock *tb = tu->tbs + j; | |
1251 |
2/2✓ Branch 0 taken 1373942 times.
✓ Branch 1 taken 1190117 times.
|
2564059 | if (tb->c_idx != LUMA) |
1252 | 1373942 | set_qp_c_tab(lc, tu, tb); | |
1253 | } | ||
1254 | 1349398 | tu = tu->next; | |
1255 | } | ||
1256 | 1107877 | } | |
1257 | |||
1258 | //8.5.2.7 Derivation process for merge motion vector difference | ||
1259 | 54381 | static void derive_mmvd(const VVCLocalContext *lc, MvField *mvf, const Mv *mmvd_offset) | |
1260 | { | ||
1261 | 54381 | const SliceContext *sc = lc->sc; | |
1262 | Mv mmvd[2]; | ||
1263 | |||
1264 |
2/2✓ Branch 0 taken 22866 times.
✓ Branch 1 taken 31515 times.
|
54381 | if (mvf->pred_flag == PF_BI) { |
1265 | 22866 | const RefPicList *rpl = sc->rpl; | |
1266 | 22866 | const int poc = lc->fc->ps.ph.poc; | |
1267 | 22866 | const int diff[] = { | |
1268 | 22866 | poc - rpl[L0].refs[mvf->ref_idx[L0]].poc, | |
1269 | 22866 | poc - rpl[L1].refs[mvf->ref_idx[L1]].poc | |
1270 | }; | ||
1271 |
4/4✓ Branch 0 taken 21698 times.
✓ Branch 1 taken 1168 times.
✓ Branch 2 taken 8539 times.
✓ Branch 3 taken 14327 times.
|
22866 | const int sign = FFSIGN(diff[0]) != FFSIGN(diff[1]); |
1272 | |||
1273 |
2/2✓ Branch 0 taken 7861 times.
✓ Branch 1 taken 15005 times.
|
22866 | if (diff[0] == diff[1]) { |
1274 | 7861 | mmvd[1] = mmvd[0] = *mmvd_offset; | |
1275 | } | ||
1276 | else { | ||
1277 | 15005 | const int i = FFABS(diff[0]) < FFABS(diff[1]); | |
1278 | 15005 | const int o = !i; | |
1279 | 15005 | mmvd[i] = *mmvd_offset; | |
1280 |
2/4✓ Branch 0 taken 15005 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15005 times.
✗ Branch 3 not taken.
|
15005 | if (!rpl[L0].refs[mvf->ref_idx[L0]].is_lt && !rpl[L1].refs[mvf->ref_idx[L1]].is_lt) { |
1281 | 15005 | ff_vvc_mv_scale(&mmvd[o], mmvd_offset, diff[i], diff[o]); | |
1282 | } | ||
1283 | else { | ||
1284 | ✗ | mmvd[o].x = sign ? -mmvd[i].x : mmvd[i].x; | |
1285 | ✗ | mmvd[o].y = sign ? -mmvd[i].y : mmvd[i].y; | |
1286 | } | ||
1287 | } | ||
1288 | 22866 | mvf->mv[0].x += mmvd[0].x; | |
1289 | 22866 | mvf->mv[0].y += mmvd[0].y; | |
1290 | 22866 | mvf->mv[1].x += mmvd[1].x; | |
1291 | 22866 | mvf->mv[1].y += mmvd[1].y; | |
1292 | } else { | ||
1293 | 31515 | const int idx = mvf->pred_flag - PF_L0; | |
1294 | 31515 | mvf->mv[idx].x += mmvd_offset->x; | |
1295 | 31515 | mvf->mv[idx].y += mmvd_offset->y; | |
1296 | } | ||
1297 | |||
1298 | 54381 | } | |
1299 | |||
1300 | 270839 | static void mvf_to_mi(const MvField *mvf, MotionInfo *mi) | |
1301 | { | ||
1302 | 270839 | mi->pred_flag = mvf->pred_flag; | |
1303 | 270839 | mi->bcw_idx = mvf->bcw_idx; | |
1304 | 270839 | mi->hpel_if_idx = mvf->hpel_if_idx; | |
1305 |
2/2✓ Branch 0 taken 541678 times.
✓ Branch 1 taken 270839 times.
|
812517 | for (int i = 0; i < 2; i++) { |
1306 | 541678 | const PredFlag mask = i + 1; | |
1307 |
2/2✓ Branch 0 taken 427582 times.
✓ Branch 1 taken 114096 times.
|
541678 | if (mvf->pred_flag & mask) { |
1308 | 427582 | mi->mv[i][0] = mvf->mv[i]; | |
1309 | 427582 | mi->ref_idx[i] = mvf->ref_idx[i]; | |
1310 | } | ||
1311 | } | ||
1312 | 270839 | } | |
1313 | |||
1314 | 270839 | static void mv_merge_refine_pred_flag(MvField *mvf, const int width, const int height) | |
1315 | { | ||
1316 |
4/4✓ Branch 0 taken 161512 times.
✓ Branch 1 taken 109327 times.
✓ Branch 2 taken 4769 times.
✓ Branch 3 taken 156743 times.
|
270839 | if (mvf->pred_flag == PF_BI && (width + height) == 12) { |
1317 | 4769 | mvf->pred_flag = PF_L0; | |
1318 | 4769 | mvf->bcw_idx = 0; | |
1319 | } | ||
1320 | 270839 | } | |
1321 | |||
1322 | // subblock-based inter prediction data | ||
1323 | 48822 | static void merge_data_subblock(VVCLocalContext *lc) | |
1324 | { | ||
1325 | 48822 | const VVCFrameContext *fc = lc->fc; | |
1326 | 48822 | const VVCPH *ph = &fc->ps.ph; | |
1327 | 48822 | CodingUnit* cu = lc->cu; | |
1328 | 48822 | PredictionUnit *pu = &cu->pu; | |
1329 | 48822 | int merge_subblock_idx = 0; | |
1330 | |||
1331 |
1/2✓ Branch 0 taken 48822 times.
✗ Branch 1 not taken.
|
48822 | if (ph->max_num_subblock_merge_cand > 1) { |
1332 | 48822 | merge_subblock_idx = ff_vvc_merge_subblock_idx(lc, ph->max_num_subblock_merge_cand); | |
1333 | } | ||
1334 | 48822 | ff_vvc_sb_mv_merge_mode(lc, merge_subblock_idx, pu); | |
1335 | 48822 | } | |
1336 | |||
1337 | 255322 | static void merge_data_regular(VVCLocalContext *lc) | |
1338 | { | ||
1339 | 255322 | const VVCFrameContext *fc = lc->fc; | |
1340 | 255322 | const VVCSPS *sps = fc->ps.sps; | |
1341 | 255322 | const VVCPH *ph = &fc->ps.ph; | |
1342 | 255322 | const CodingUnit* cu = lc->cu; | |
1343 | 255322 | PredictionUnit *pu = &lc->cu->pu; | |
1344 | 255322 | int merge_idx = 0; | |
1345 | Mv mmvd_offset; | ||
1346 | MvField mvf; | ||
1347 | |||
1348 |
2/2✓ Branch 0 taken 250158 times.
✓ Branch 1 taken 5164 times.
|
255322 | if (sps->r->sps_mmvd_enabled_flag) |
1349 | 250158 | pu->mmvd_merge_flag = ff_vvc_mmvd_merge_flag(lc); | |
1350 |
2/2✓ Branch 0 taken 54381 times.
✓ Branch 1 taken 200941 times.
|
255322 | if (pu->mmvd_merge_flag) { |
1351 | 54381 | int mmvd_cand_flag = 0; | |
1352 |
1/2✓ Branch 0 taken 54381 times.
✗ Branch 1 not taken.
|
54381 | if (sps->max_num_merge_cand > 1) |
1353 | 54381 | mmvd_cand_flag = ff_vvc_mmvd_cand_flag(lc); | |
1354 | 54381 | ff_vvc_mmvd_offset_coding(lc, &mmvd_offset, ph->r->ph_mmvd_fullpel_only_flag); | |
1355 | 54381 | merge_idx = mmvd_cand_flag; | |
1356 |
1/2✓ Branch 0 taken 200941 times.
✗ Branch 1 not taken.
|
200941 | } else if (sps->max_num_merge_cand > 1) { |
1357 | 200941 | merge_idx = ff_vvc_merge_idx(lc); | |
1358 | } | ||
1359 | 255322 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 0, &mvf); | |
1360 |
2/2✓ Branch 0 taken 54381 times.
✓ Branch 1 taken 200941 times.
|
255322 | if (pu->mmvd_merge_flag) |
1361 | 54381 | derive_mmvd(lc, &mvf, &mmvd_offset); | |
1362 | 255322 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
1363 | 255322 | ff_vvc_store_mvf(lc, &mvf); | |
1364 | 255322 | mvf_to_mi(&mvf, &pu->mi); | |
1365 | 255322 | } | |
1366 | |||
1367 | 40254 | static int ciip_flag_decode(VVCLocalContext *lc, const int ciip_avaiable, const int gpm_avaiable, const int is_128) | |
1368 | { | ||
1369 | 40254 | const VVCFrameContext *fc = lc->fc; | |
1370 | 40254 | const VVCSPS *sps = fc->ps.sps; | |
1371 | 40254 | const CodingUnit *cu = lc->cu; | |
1372 | |||
1373 |
4/4✓ Branch 0 taken 25226 times.
✓ Branch 1 taken 15028 times.
✓ Branch 2 taken 18681 times.
✓ Branch 3 taken 6545 times.
|
40254 | if (ciip_avaiable && gpm_avaiable) |
1374 | 18681 | return ff_vvc_ciip_flag(lc); | |
1375 |
3/4✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 15028 times.
✓ Branch 2 taken 6545 times.
✗ Branch 3 not taken.
|
21573 | return sps->r->sps_ciip_enabled_flag && !cu->skip_flag && |
1376 |
2/4✓ Branch 0 taken 21573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6545 times.
✗ Branch 3 not taken.
|
43146 | !is_128 && (cu->cb_width * cu->cb_height >= 64); |
1377 | } | ||
1378 | |||
1379 | 24737 | static void merge_data_gpm(VVCLocalContext *lc) | |
1380 | { | ||
1381 | 24737 | const VVCFrameContext *fc = lc->fc; | |
1382 | 24737 | const VVCSPS *sps = fc->ps.sps; | |
1383 | 24737 | PredictionUnit *pu = &lc->cu->pu; | |
1384 | int merge_gpm_idx[2]; | ||
1385 | |||
1386 | 24737 | pu->merge_gpm_flag = 1; | |
1387 | 24737 | pu->gpm_partition_idx = ff_vvc_merge_gpm_partition_idx(lc); | |
1388 | 24737 | merge_gpm_idx[0] = ff_vvc_merge_gpm_idx(lc, 0); | |
1389 | 24737 | merge_gpm_idx[1] = 0; | |
1390 |
1/2✓ Branch 0 taken 24737 times.
✗ Branch 1 not taken.
|
24737 | if (sps->max_num_gpm_merge_cand > 2) |
1391 | 24737 | merge_gpm_idx[1] = ff_vvc_merge_gpm_idx(lc, 1); | |
1392 | |||
1393 | 24737 | ff_vvc_luma_mv_merge_gpm(lc, merge_gpm_idx, pu->gpm_mv); | |
1394 | 24737 | ff_vvc_store_gpm_mvf(lc, pu); | |
1395 | 24737 | } | |
1396 | |||
1397 | 15517 | static void merge_data_ciip(VVCLocalContext *lc) | |
1398 | { | ||
1399 | 15517 | const VVCFrameContext* fc = lc->fc; | |
1400 | 15517 | const VVCSPS* sps = fc->ps.sps; | |
1401 | 15517 | CodingUnit *cu = lc->cu; | |
1402 | 15517 | MotionInfo *mi = &cu->pu.mi; | |
1403 | 15517 | int merge_idx = 0; | |
1404 | MvField mvf; | ||
1405 | |||
1406 |
1/2✓ Branch 0 taken 15517 times.
✗ Branch 1 not taken.
|
15517 | if (sps->max_num_merge_cand > 1) |
1407 | 15517 | merge_idx = ff_vvc_merge_idx(lc); | |
1408 | 15517 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 1, &mvf); | |
1409 | 15517 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
1410 | 15517 | ff_vvc_store_mvf(lc, &mvf); | |
1411 | 15517 | mvf_to_mi(&mvf, mi); | |
1412 | 15517 | cu->intra_pred_mode_y = cu->intra_pred_mode_c = INTRA_PLANAR; | |
1413 | 15517 | cu->intra_luma_ref_idx = 0; | |
1414 | 15517 | cu->intra_mip_flag = 0; | |
1415 | 15517 | } | |
1416 | |||
1417 | // block-based inter prediction data | ||
1418 | 295576 | static void merge_data_block(VVCLocalContext *lc) | |
1419 | { | ||
1420 | 295576 | const VVCFrameContext* fc = lc->fc; | |
1421 | 295576 | const VVCSPS *sps = fc->ps.sps; | |
1422 | 295576 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1423 | 295576 | CodingUnit *cu = lc->cu; | |
1424 | 295576 | const int cb_width = cu->cb_width; | |
1425 | 295576 | const int cb_height = cu->cb_height; | |
1426 |
4/4✓ Branch 0 taken 278307 times.
✓ Branch 1 taken 17269 times.
✓ Branch 2 taken 1327 times.
✓ Branch 3 taken 276980 times.
|
295576 | const int is_128 = cb_width == 128 || cb_height == 128; |
1427 | 881564 | const int ciip_avaiable = sps->r->sps_ciip_enabled_flag && | |
1428 |
6/6✓ Branch 0 taken 290412 times.
✓ Branch 1 taken 5164 times.
✓ Branch 2 taken 96788 times.
✓ Branch 3 taken 193624 times.
✓ Branch 4 taken 86785 times.
✓ Branch 5 taken 10003 times.
|
295576 | !cu->skip_flag && (cb_width * cb_height >= 64); |
1429 |
3/4✓ Branch 0 taken 276144 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241923 times.
✓ Branch 3 taken 34221 times.
|
276144 | const int gpm_avaiable = sps->r->sps_gpm_enabled_flag && IS_B(rsh) && |
1430 |
2/2✓ Branch 0 taken 216496 times.
✓ Branch 1 taken 25427 times.
|
241923 | (cb_width >= 8) && (cb_height >=8) && |
1431 |
6/6✓ Branch 0 taken 276144 times.
✓ Branch 1 taken 19432 times.
✓ Branch 2 taken 210430 times.
✓ Branch 3 taken 6066 times.
✓ Branch 4 taken 208603 times.
✓ Branch 5 taken 1827 times.
|
571720 | (cb_width < 8 * cb_height) && (cb_height < 8 *cb_width); |
1432 | |||
1433 | 295576 | int regular_merge_flag = 1; | |
1434 | |||
1435 |
6/6✓ Branch 0 taken 276980 times.
✓ Branch 1 taken 18596 times.
✓ Branch 2 taken 190491 times.
✓ Branch 3 taken 86489 times.
✓ Branch 4 taken 129209 times.
✓ Branch 5 taken 61282 times.
|
295576 | if (!is_128 && (ciip_avaiable || gpm_avaiable)) |
1436 | 215698 | regular_merge_flag = ff_vvc_regular_merge_flag(lc, cu->skip_flag); | |
1437 |
2/2✓ Branch 0 taken 255322 times.
✓ Branch 1 taken 40254 times.
|
295576 | if (regular_merge_flag) { |
1438 | 255322 | merge_data_regular(lc); | |
1439 | } else { | ||
1440 | 40254 | cu->ciip_flag = ciip_flag_decode(lc, ciip_avaiable, gpm_avaiable, is_128); | |
1441 |
2/2✓ Branch 0 taken 15517 times.
✓ Branch 1 taken 24737 times.
|
40254 | if (cu->ciip_flag) |
1442 | 15517 | merge_data_ciip(lc); | |
1443 | else | ||
1444 | 24737 | merge_data_gpm(lc); | |
1445 | } | ||
1446 | 295576 | } | |
1447 | |||
1448 | 240 | static int merge_data_ibc(VVCLocalContext *lc) | |
1449 | { | ||
1450 | 240 | const VVCFrameContext* fc = lc->fc; | |
1451 | 240 | const VVCSPS* sps = fc->ps.sps; | |
1452 | 240 | MotionInfo *mi = &lc->cu->pu.mi; | |
1453 | 240 | int merge_idx = 0; | |
1454 | int ret; | ||
1455 | |||
1456 | 240 | mi->pred_flag = PF_IBC; | |
1457 | |||
1458 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
|
240 | if (sps->max_num_ibc_merge_cand > 1) |
1459 | ✗ | merge_idx = ff_vvc_merge_idx(lc); | |
1460 | |||
1461 | 240 | ret = ff_vvc_luma_mv_merge_ibc(lc, merge_idx, &mi->mv[L0][0]); | |
1462 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
|
240 | if (ret) |
1463 | ✗ | return ret; | |
1464 | 240 | ff_vvc_store_mv(lc, mi); | |
1465 | |||
1466 | 240 | return 0; | |
1467 | } | ||
1468 | |||
1469 | 344638 | static int hls_merge_data(VVCLocalContext *lc) | |
1470 | { | ||
1471 | 344638 | const VVCFrameContext *fc = lc->fc; | |
1472 | 344638 | const VVCPH *ph = &fc->ps.ph; | |
1473 | 344638 | const CodingUnit *cu = lc->cu; | |
1474 | 344638 | PredictionUnit *pu = &lc->cu->pu; | |
1475 | int ret; | ||
1476 | |||
1477 | 344638 | pu->merge_gpm_flag = 0; | |
1478 | 344638 | pu->mi.num_sb_x = pu->mi.num_sb_y = 1; | |
1479 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 344398 times.
|
344638 | if (cu->pred_mode == MODE_IBC) { |
1480 | 240 | ret = merge_data_ibc(lc); | |
1481 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
|
240 | if (ret) |
1482 | ✗ | return ret; | |
1483 | } else { | ||
1484 |
5/6✓ Branch 0 taken 344398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 308525 times.
✓ Branch 3 taken 35873 times.
✓ Branch 4 taken 281484 times.
✓ Branch 5 taken 27041 times.
|
344398 | if (ph->max_num_subblock_merge_cand > 0 && cu->cb_width >= 8 && cu->cb_height >= 8) |
1485 | 281484 | pu->merge_subblock_flag = ff_vvc_merge_subblock_flag(lc); | |
1486 |
2/2✓ Branch 0 taken 48822 times.
✓ Branch 1 taken 295576 times.
|
344398 | if (pu->merge_subblock_flag) |
1487 | 48822 | merge_data_subblock(lc); | |
1488 | else | ||
1489 | 295576 | merge_data_block(lc); | |
1490 | } | ||
1491 | 344638 | return 0; | |
1492 | } | ||
1493 | |||
1494 | 83565 | static void hls_mvd_coding(VVCLocalContext *lc, Mv* mvd) | |
1495 | { | ||
1496 | int16_t mv[2]; | ||
1497 | |||
1498 |
2/2✓ Branch 0 taken 167130 times.
✓ Branch 1 taken 83565 times.
|
250695 | for (int i = 0; i < 2; i++) { |
1499 | 167130 | mv[i] = ff_vvc_abs_mvd_greater0_flag(lc); | |
1500 | } | ||
1501 | |||
1502 |
2/2✓ Branch 0 taken 167130 times.
✓ Branch 1 taken 83565 times.
|
250695 | for (int i = 0; i < 2; i++) { |
1503 |
2/2✓ Branch 0 taken 116621 times.
✓ Branch 1 taken 50509 times.
|
167130 | if (mv[i]) |
1504 | 116621 | mv[i] += ff_vvc_abs_mvd_greater1_flag(lc); | |
1505 | } | ||
1506 | |||
1507 |
2/2✓ Branch 0 taken 167130 times.
✓ Branch 1 taken 83565 times.
|
250695 | for (int i = 0; i < 2; i++) { |
1508 |
2/2✓ Branch 0 taken 116621 times.
✓ Branch 1 taken 50509 times.
|
167130 | if (mv[i] > 0) { |
1509 |
2/2✓ Branch 0 taken 68543 times.
✓ Branch 1 taken 48078 times.
|
116621 | if (mv[i] == 2) |
1510 | 68543 | mv[i] += ff_vvc_abs_mvd_minus2(lc); | |
1511 | 116621 | mv[i] = (1 - 2 * ff_vvc_mvd_sign_flag(lc)) * mv[i]; | |
1512 | } | ||
1513 | } | ||
1514 | 83565 | mvd->x = mv[0]; | |
1515 | 83565 | mvd->y = mv[1]; | |
1516 | 83565 | } | |
1517 | |||
1518 | 59578 | static int bcw_idx_decode(VVCLocalContext *lc, const MotionInfo *mi, const int cb_width, const int cb_height) | |
1519 | { | ||
1520 | 59578 | const VVCFrameContext *fc = lc->fc; | |
1521 | 59578 | const VVCSPS *sps = fc->ps.sps; | |
1522 | 59578 | const VVCPPS *pps = fc->ps.pps; | |
1523 | 59578 | const VVCPH *ph = &fc->ps.ph; | |
1524 | 59578 | const VVCSH *sh = &lc->sc->sh; | |
1525 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59578 times.
|
59578 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &ph->pwt : &sh->pwt; |
1526 | 59578 | int bcw_idx = 0; | |
1527 | |||
1528 |
4/4✓ Branch 0 taken 55847 times.
✓ Branch 1 taken 3731 times.
✓ Branch 2 taken 17075 times.
✓ Branch 3 taken 38772 times.
|
59578 | if (sps->r->sps_bcw_enabled_flag && mi->pred_flag == PF_BI && |
1529 |
2/2✓ Branch 0 taken 16887 times.
✓ Branch 1 taken 188 times.
|
17075 | !w->weight_flag[L0][LUMA][mi->ref_idx[0]] && |
1530 |
1/2✓ Branch 0 taken 16887 times.
✗ Branch 1 not taken.
|
16887 | !w->weight_flag[L1][LUMA][mi->ref_idx[1]] && |
1531 |
1/2✓ Branch 0 taken 16887 times.
✗ Branch 1 not taken.
|
16887 | !w->weight_flag[L0][CHROMA][mi->ref_idx[0]] && |
1532 |
1/2✓ Branch 0 taken 16887 times.
✗ Branch 1 not taken.
|
16887 | !w->weight_flag[L1][CHROMA][mi->ref_idx[1]] && |
1533 |
2/2✓ Branch 0 taken 11078 times.
✓ Branch 1 taken 5809 times.
|
16887 | cb_width * cb_height >= 256) { |
1534 | 11078 | bcw_idx = ff_vvc_bcw_idx(lc, ff_vvc_no_backward_pred_flag(lc)); | |
1535 | } | ||
1536 | 59578 | return bcw_idx; | |
1537 | } | ||
1538 | |||
1539 | 77489 | static int8_t ref_idx_decode(VVCLocalContext *lc, const VVCSH *sh, const int sym_mvd_flag, const int lx) | |
1540 | { | ||
1541 | 77489 | const H266RawSliceHeader *rsh = sh->r; | |
1542 | 77489 | int ref_idx = 0; | |
1543 | |||
1544 |
4/4✓ Branch 0 taken 60858 times.
✓ Branch 1 taken 16631 times.
✓ Branch 2 taken 49376 times.
✓ Branch 3 taken 11482 times.
|
77489 | if (rsh->num_ref_idx_active[lx] > 1 && !sym_mvd_flag) |
1545 | 49376 | ref_idx = ff_vvc_ref_idx_lx(lc, rsh->num_ref_idx_active[lx]); | |
1546 |
2/2✓ Branch 0 taken 11482 times.
✓ Branch 1 taken 16631 times.
|
28113 | else if (sym_mvd_flag) |
1547 | 11482 | ref_idx = sh->ref_idx_sym[lx]; | |
1548 | 77489 | return ref_idx; | |
1549 | } | ||
1550 | |||
1551 | 77489 | static int mvds_decode(VVCLocalContext *lc, Mv mvds[2][MAX_CONTROL_POINTS], | |
1552 | const int num_cp_mv, const int lx) | ||
1553 | { | ||
1554 | 77489 | const VVCFrameContext *fc = lc->fc; | |
1555 | 77489 | const VVCPH *ph = &fc->ps.ph; | |
1556 | 77489 | const PredictionUnit *pu = &lc->cu->pu; | |
1557 | 77489 | const MotionInfo *mi = &pu->mi; | |
1558 | 77489 | int has_no_zero_mvd = 0; | |
1559 | |||
1560 |
6/6✓ Branch 0 taken 26053 times.
✓ Branch 1 taken 51436 times.
✓ Branch 2 taken 4768 times.
✓ Branch 3 taken 21285 times.
✓ Branch 4 taken 4754 times.
✓ Branch 5 taken 14 times.
|
77489 | if (lx == L1 && ph->r->ph_mvd_l1_zero_flag && mi->pred_flag == PF_BI) { |
1561 |
2/2✓ Branch 0 taken 6065 times.
✓ Branch 1 taken 4754 times.
|
10819 | for (int j = 0; j < num_cp_mv; j++) |
1562 | 6065 | AV_ZERO64(&mvds[lx][j]); | |
1563 | } else { | ||
1564 | 72735 | Mv *mvd0 = &mvds[lx][0]; | |
1565 |
4/4✓ Branch 0 taken 21299 times.
✓ Branch 1 taken 51436 times.
✓ Branch 2 taken 5741 times.
✓ Branch 3 taken 15558 times.
|
72735 | if (lx == L1 && pu->sym_mvd_flag) { |
1566 | 5741 | mvd0->x = -mvds[L0][0].x; | |
1567 | 5741 | mvd0->y = -mvds[L0][0].y; | |
1568 | } else { | ||
1569 | 66994 | hls_mvd_coding(lc, mvd0); | |
1570 | } | ||
1571 |
4/4✓ Branch 0 taken 21557 times.
✓ Branch 1 taken 51178 times.
✓ Branch 2 taken 13721 times.
✓ Branch 3 taken 7836 times.
|
72735 | has_no_zero_mvd |= (mvd0->x || mvd0->y); |
1572 |
2/2✓ Branch 0 taken 15229 times.
✓ Branch 1 taken 72735 times.
|
87964 | for (int j = 1; j < num_cp_mv; j++) { |
1573 | 15229 | Mv *mvd = &mvds[lx][j]; | |
1574 | 15229 | hls_mvd_coding(lc, mvd); | |
1575 | 15229 | mvd->x += mvd0->x; | |
1576 | 15229 | mvd->y += mvd0->y; | |
1577 |
4/4✓ Branch 0 taken 2926 times.
✓ Branch 1 taken 12303 times.
✓ Branch 2 taken 2000 times.
✓ Branch 3 taken 926 times.
|
15229 | has_no_zero_mvd |= (mvd->x || mvd->y); |
1578 | } | ||
1579 | } | ||
1580 | 77489 | return has_no_zero_mvd; | |
1581 | } | ||
1582 | |||
1583 | 59578 | static void mvp_add_difference(MotionInfo *mi, const int num_cp_mv, | |
1584 | const Mv mvds[2][MAX_CONTROL_POINTS], const int amvr_shift) | ||
1585 | { | ||
1586 |
2/2✓ Branch 0 taken 119156 times.
✓ Branch 1 taken 59578 times.
|
178734 | for (int i = 0; i < 2; i++) { |
1587 | 119156 | const PredFlag mask = i + PF_L0; | |
1588 |
2/2✓ Branch 0 taken 77489 times.
✓ Branch 1 taken 41667 times.
|
119156 | if (mi->pred_flag & mask) { |
1589 |
2/2✓ Branch 0 taken 94029 times.
✓ Branch 1 taken 77489 times.
|
171518 | for (int j = 0; j < num_cp_mv; j++) { |
1590 | 94029 | const Mv *mvd = &mvds[i][j]; | |
1591 | 94029 | mi->mv[i][j].x += mvd->x * (1 << amvr_shift); | |
1592 | 94029 | mi->mv[i][j].y += mvd->y * (1 << amvr_shift); | |
1593 | } | ||
1594 | } | ||
1595 | } | ||
1596 | 59578 | } | |
1597 | |||
1598 | 1342 | static int mvp_data_ibc(VVCLocalContext *lc) | |
1599 | { | ||
1600 | 1342 | const VVCFrameContext *fc = lc->fc; | |
1601 | 1342 | const CodingUnit *cu = lc->cu; | |
1602 | 1342 | const PredictionUnit *pu = &lc->cu->pu; | |
1603 | 1342 | const VVCSPS *sps = fc->ps.sps; | |
1604 | 1342 | MotionInfo *mi = &lc->cu->pu.mi; | |
1605 | 1342 | int mvp_l0_flag = 0; | |
1606 | 1342 | int amvr_shift = 4; | |
1607 | 1342 | Mv *mv = &mi->mv[L0][0]; | |
1608 | int ret; | ||
1609 | |||
1610 | 1342 | mi->pred_flag = PF_IBC; | |
1611 | 1342 | mi->num_sb_x = 1; | |
1612 | 1342 | mi->num_sb_y = 1; | |
1613 | |||
1614 | 1342 | hls_mvd_coding(lc, mv); | |
1615 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1342 times.
|
1342 | if (sps->max_num_ibc_merge_cand > 1) |
1616 | ✗ | mvp_l0_flag = ff_vvc_mvp_lx_flag(lc); | |
1617 |
5/6✓ Branch 0 taken 1342 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 1025 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 264 times.
|
1342 | if (sps->r->sps_amvr_enabled_flag && (mv->x || mv->y)) |
1618 | 1078 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, 1); | |
1619 | |||
1620 | 1342 | ret = ff_vvc_mvp_ibc(lc, mvp_l0_flag, amvr_shift, mv); | |
1621 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1342 times.
|
1342 | if (ret) |
1622 | ✗ | return ret; | |
1623 | 1342 | ff_vvc_store_mv(lc, mi); | |
1624 | |||
1625 | 1342 | return 0; | |
1626 | } | ||
1627 | |||
1628 | 59578 | static int mvp_data(VVCLocalContext *lc) | |
1629 | { | ||
1630 | 59578 | const VVCFrameContext *fc = lc->fc; | |
1631 | 59578 | const CodingUnit *cu = lc->cu; | |
1632 | 59578 | PredictionUnit *pu = &lc->cu->pu; | |
1633 | 59578 | const VVCSPS *sps = fc->ps.sps; | |
1634 | 59578 | const VVCPH *ph = &fc->ps.ph; | |
1635 | 59578 | const VVCSH *sh = &lc->sc->sh; | |
1636 | 59578 | const H266RawSliceHeader *rsh = sh->r; | |
1637 | 59578 | MotionInfo *mi = &pu->mi; | |
1638 | 59578 | const int cb_width = cu->cb_width; | |
1639 | 59578 | const int cb_height = cu->cb_height; | |
1640 | |||
1641 | 59578 | int mvp_lx_flag[2] = {0}; | |
1642 | 59578 | int cu_affine_type_flag = 0; | |
1643 | int num_cp_mv; | ||
1644 | 59578 | int amvr_enabled, has_no_zero_mvd = 0, amvr_shift; | |
1645 | Mv mvds[2][MAX_CONTROL_POINTS]; | ||
1646 | |||
1647 | 59578 | mi->pred_flag = ff_vvc_pred_flag(lc, IS_B(rsh)); | |
1648 |
5/6✓ Branch 0 taken 59578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33915 times.
✓ Branch 3 taken 25663 times.
✓ Branch 4 taken 26349 times.
✓ Branch 5 taken 7566 times.
|
59578 | if (sps->r->sps_affine_enabled_flag && cb_width >= 16 && cb_height >= 16) { |
1649 | 26349 | pu->inter_affine_flag = ff_vvc_inter_affine_flag(lc); | |
1650 | 26349 | set_cb_tab(lc, fc->tab.iaf, pu->inter_affine_flag); | |
1651 |
3/4✓ Branch 0 taken 26349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9109 times.
✓ Branch 3 taken 17240 times.
|
26349 | if (sps->r->sps_6param_affine_enabled_flag && pu->inter_affine_flag) |
1652 | 9109 | cu_affine_type_flag = ff_vvc_cu_affine_type_flag(lc); | |
1653 | } | ||
1654 | 59578 | mi->motion_model_idc = pu->inter_affine_flag + cu_affine_type_flag; | |
1655 | 59578 | num_cp_mv = mi->motion_model_idc + 1; | |
1656 | |||
1657 |
4/4✓ Branch 0 taken 47609 times.
✓ Branch 1 taken 11969 times.
✓ Branch 2 taken 37569 times.
✓ Branch 3 taken 10040 times.
|
59578 | if (sps->r->sps_smvd_enabled_flag && !ph->r->ph_mvd_l1_zero_flag && |
1658 |
4/4✓ Branch 0 taken 12561 times.
✓ Branch 1 taken 25008 times.
✓ Branch 2 taken 11430 times.
✓ Branch 3 taken 1131 times.
|
37569 | mi->pred_flag == PF_BI && !pu->inter_affine_flag && |
1659 |
2/4✓ Branch 0 taken 11430 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11430 times.
✗ Branch 3 not taken.
|
11430 | sh->ref_idx_sym[0] > -1 && sh->ref_idx_sym[1] > -1) |
1660 | 11430 | pu->sym_mvd_flag = ff_vvc_sym_mvd_flag(lc); | |
1661 | |||
1662 |
2/2✓ Branch 0 taken 119156 times.
✓ Branch 1 taken 59578 times.
|
178734 | for (int i = L0; i <= L1; i++) { |
1663 |
2/2✓ Branch 0 taken 59578 times.
✓ Branch 1 taken 59578 times.
|
119156 | const PredFlag pred_flag = PF_L0 + !i; |
1664 |
2/2✓ Branch 0 taken 77489 times.
✓ Branch 1 taken 41667 times.
|
119156 | if (mi->pred_flag != pred_flag) { |
1665 | 77489 | mi->ref_idx[i] = ref_idx_decode(lc, sh, pu->sym_mvd_flag, i); | |
1666 | 77489 | has_no_zero_mvd |= mvds_decode(lc, mvds, num_cp_mv, i); | |
1667 | 77489 | mvp_lx_flag[i] = ff_vvc_mvp_lx_flag(lc); | |
1668 | } | ||
1669 | } | ||
1670 | |||
1671 | 119156 | amvr_enabled = mi->motion_model_idc == MOTION_TRANSLATION ? | |
1672 |
2/2✓ Branch 0 taken 50469 times.
✓ Branch 1 taken 9109 times.
|
59578 | sps->r->sps_amvr_enabled_flag : sps->r->sps_affine_amvr_enabled_flag; |
1673 | 59578 | amvr_enabled &= has_no_zero_mvd; | |
1674 | |||
1675 | 59578 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, amvr_enabled); | |
1676 | |||
1677 | 59578 | mi->hpel_if_idx = amvr_shift == 3; | |
1678 | 59578 | mi->bcw_idx = bcw_idx_decode(lc, mi, cb_width, cb_height); | |
1679 | |||
1680 |
2/2✓ Branch 0 taken 9109 times.
✓ Branch 1 taken 50469 times.
|
59578 | if (mi->motion_model_idc) |
1681 | 9109 | ff_vvc_affine_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
1682 | else | ||
1683 | 50469 | ff_vvc_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
1684 | |||
1685 | 59578 | mvp_add_difference(mi, num_cp_mv, mvds, amvr_shift); | |
1686 | |||
1687 |
2/2✓ Branch 0 taken 9109 times.
✓ Branch 1 taken 50469 times.
|
59578 | if (mi->motion_model_idc) |
1688 | 9109 | ff_vvc_store_sb_mvs(lc, pu); | |
1689 | else | ||
1690 | 50469 | ff_vvc_store_mv(lc, &pu->mi); | |
1691 | |||
1692 | 59578 | return 0; | |
1693 | } | ||
1694 | |||
1695 | // derive bdofFlag from 8.5.6 Decoding process for inter blocks | ||
1696 | // derive dmvr from 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
1697 | 321308 | static void derive_dmvr_bdof_flag(const VVCLocalContext *lc, PredictionUnit *pu) | |
1698 | { | ||
1699 | 321308 | const VVCFrameContext *fc = lc->fc; | |
1700 | 321308 | const VVCPPS *pps = fc->ps.pps; | |
1701 | 321308 | const VVCPH *ph = &fc->ps.ph; | |
1702 | 321308 | const VVCSH *sh = &lc->sc->sh; | |
1703 | 321308 | const int poc = ph->poc; | |
1704 | 321308 | const MotionInfo *mi = &pu->mi; | |
1705 | 321308 | const int8_t *ref_idx = mi->ref_idx; | |
1706 | 321308 | const VVCRefPic *rp0 = &lc->sc->rpl[L0].refs[ref_idx[L0]]; | |
1707 | 321308 | const VVCRefPic *rp1 = &lc->sc->rpl[L1].refs[ref_idx[L1]]; | |
1708 | 321308 | const CodingUnit *cu = lc->cu; | |
1709 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 321308 times.
|
321308 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt; |
1710 | |||
1711 | 321308 | pu->bdof_flag = 0; | |
1712 | |||
1713 |
2/2✓ Branch 0 taken 172607 times.
✓ Branch 1 taken 148701 times.
|
321308 | if (mi->pred_flag == PF_BI && |
1714 |
2/2✓ Branch 0 taken 117712 times.
✓ Branch 1 taken 54895 times.
|
172607 | (poc - rp0->poc == rp1->poc - poc) && |
1715 |
2/4✓ Branch 0 taken 117712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117712 times.
✗ Branch 3 not taken.
|
117712 | !rp0->is_lt && !rp1->is_lt && |
1716 |
2/2✓ Branch 0 taken 114992 times.
✓ Branch 1 taken 2720 times.
|
117712 | !cu->ciip_flag && |
1717 |
2/2✓ Branch 0 taken 101496 times.
✓ Branch 1 taken 13496 times.
|
114992 | !mi->bcw_idx && |
1718 |
3/4✓ Branch 0 taken 100526 times.
✓ Branch 1 taken 970 times.
✓ Branch 2 taken 100526 times.
✗ Branch 3 not taken.
|
101496 | !w->weight_flag[L0][LUMA][ref_idx[L0]] && !w->weight_flag[L1][LUMA][ref_idx[L1]] && |
1719 |
2/4✓ Branch 0 taken 100526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100526 times.
✗ Branch 3 not taken.
|
100526 | !w->weight_flag[L0][CHROMA][ref_idx[L0]] && !w->weight_flag[L1][CHROMA][ref_idx[L1]] && |
1720 |
4/4✓ Branch 0 taken 94774 times.
✓ Branch 1 taken 5752 times.
✓ Branch 2 taken 91187 times.
✓ Branch 3 taken 3587 times.
|
100526 | cu->cb_width >= 8 && cu->cb_height >= 8 && |
1721 |
2/2✓ Branch 0 taken 85289 times.
✓ Branch 1 taken 5898 times.
|
91187 | (cu->cb_width * cu->cb_height >= 128) && |
1722 |
2/4✓ Branch 0 taken 85289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85289 times.
✗ Branch 3 not taken.
|
85289 | !rp0->is_scaled && !rp1->is_scaled) { |
1723 |
2/2✓ Branch 0 taken 83260 times.
✓ Branch 1 taken 2029 times.
|
85289 | if (!ph->r->ph_bdof_disabled_flag && |
1724 |
1/2✓ Branch 0 taken 83260 times.
✗ Branch 1 not taken.
|
83260 | mi->motion_model_idc == MOTION_TRANSLATION && |
1725 |
1/2✓ Branch 0 taken 83260 times.
✗ Branch 1 not taken.
|
83260 | !pu->merge_subblock_flag && |
1726 |
2/2✓ Branch 0 taken 80450 times.
✓ Branch 1 taken 2810 times.
|
83260 | !pu->sym_mvd_flag) |
1727 | 80450 | pu->bdof_flag = 1; | |
1728 |
2/2✓ Branch 0 taken 80803 times.
✓ Branch 1 taken 4486 times.
|
85289 | if (!ph->r->ph_dmvr_disabled_flag && |
1729 |
2/2✓ Branch 0 taken 75478 times.
✓ Branch 1 taken 5325 times.
|
80803 | pu->general_merge_flag && |
1730 |
2/2✓ Branch 0 taken 68451 times.
✓ Branch 1 taken 7027 times.
|
75478 | !pu->mmvd_merge_flag) |
1731 | 68451 | pu->dmvr_flag = 1; | |
1732 | } | ||
1733 | 321308 | } | |
1734 | |||
1735 | // part of 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
1736 | 321308 | static void refine_regular_subblock(const VVCLocalContext *lc) | |
1737 | { | ||
1738 | 321308 | const CodingUnit *cu = lc->cu; | |
1739 | 321308 | PredictionUnit *pu = &lc->cu->pu; | |
1740 | |||
1741 | 321308 | derive_dmvr_bdof_flag(lc, pu); | |
1742 |
4/4✓ Branch 0 taken 252857 times.
✓ Branch 1 taken 68451 times.
✓ Branch 2 taken 11999 times.
✓ Branch 3 taken 240858 times.
|
321308 | if (pu->dmvr_flag || pu->bdof_flag) { |
1743 |
2/2✓ Branch 0 taken 47628 times.
✓ Branch 1 taken 32822 times.
|
80450 | pu->mi.num_sb_x = (cu->cb_width > 16) ? (cu->cb_width >> 4) : 1; |
1744 |
2/2✓ Branch 0 taken 45500 times.
✓ Branch 1 taken 34950 times.
|
80450 | pu->mi.num_sb_y = (cu->cb_height > 16) ? (cu->cb_height >> 4) : 1; |
1745 | } | ||
1746 | 321308 | } | |
1747 | |||
1748 | 337107 | static void fill_dmvr_info(const VVCLocalContext *lc) | |
1749 | { | ||
1750 | 337107 | const VVCFrameContext *fc = lc->fc; | |
1751 | 337107 | const CodingUnit *cu = lc->cu; | |
1752 | |||
1753 |
2/2✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 335525 times.
|
337107 | if (cu->pred_mode == MODE_IBC) { |
1754 | 1582 | ff_vvc_set_intra_mvf(lc, 1); | |
1755 | } else { | ||
1756 | 335525 | const VVCPPS *pps = fc->ps.pps; | |
1757 | 335525 | const int w = cu->cb_width >> MIN_PU_LOG2; | |
1758 | |||
1759 |
2/2✓ Branch 0 taken 1922701 times.
✓ Branch 1 taken 335525 times.
|
2258226 | for (int y = cu->y0 >> MIN_PU_LOG2; y < (cu->y0 + cu->cb_height) >> MIN_PU_LOG2; y++) { |
1760 | 1922701 | const int idx = pps->min_pu_width * y + (cu->x0 >> MIN_PU_LOG2); | |
1761 | 1922701 | const MvField *mvf = fc->tab.mvf + idx; | |
1762 | 1922701 | MvField *dmvr_mvf = fc->ref->tab_dmvr_mvf + idx; | |
1763 | |||
1764 | 1922701 | memcpy(dmvr_mvf, mvf, sizeof(MvField) * w); | |
1765 | } | ||
1766 | } | ||
1767 | 337107 | } | |
1768 | |||
1769 | 405558 | static int inter_data(VVCLocalContext *lc) | |
1770 | { | ||
1771 | 405558 | const CodingUnit *cu = lc->cu; | |
1772 | 405558 | PredictionUnit *pu = &lc->cu->pu; | |
1773 | 405558 | const MotionInfo *mi = &pu->mi; | |
1774 | 405558 | int ret = 0; | |
1775 | |||
1776 | 405558 | pu->general_merge_flag = 1; | |
1777 |
2/2✓ Branch 0 taken 171688 times.
✓ Branch 1 taken 233870 times.
|
405558 | if (!cu->skip_flag) |
1778 | 171688 | pu->general_merge_flag = ff_vvc_general_merge_flag(lc); | |
1779 | |||
1780 |
2/2✓ Branch 0 taken 344638 times.
✓ Branch 1 taken 60920 times.
|
405558 | if (pu->general_merge_flag) { |
1781 | 344638 | hls_merge_data(lc); | |
1782 |
2/2✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 59578 times.
|
60920 | } else if (cu->pred_mode == MODE_IBC){ |
1783 | 1342 | ret = mvp_data_ibc(lc); | |
1784 | } else { | ||
1785 | 59578 | ret = mvp_data(lc); | |
1786 | } | ||
1787 | |||
1788 |
2/2✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 403976 times.
|
405558 | if (cu->pred_mode == MODE_IBC) |
1789 | { | ||
1790 | 1582 | ff_vvc_update_hmvp(lc, mi); | |
1791 |
6/6✓ Branch 0 taken 379239 times.
✓ Branch 1 taken 24737 times.
✓ Branch 2 taken 346662 times.
✓ Branch 3 taken 32577 times.
✓ Branch 4 taken 321308 times.
✓ Branch 5 taken 25354 times.
|
403976 | } else if (!pu->merge_gpm_flag && !pu->inter_affine_flag && !pu->merge_subblock_flag) { |
1792 | 321308 | refine_regular_subblock(lc); | |
1793 | 321308 | ff_vvc_update_hmvp(lc, mi); | |
1794 | } | ||
1795 | |||
1796 |
2/2✓ Branch 0 taken 337107 times.
✓ Branch 1 taken 68451 times.
|
405558 | if (!pu->dmvr_flag) |
1797 | 337107 | fill_dmvr_info(lc); | |
1798 | 405558 | return ret; | |
1799 | } | ||
1800 | |||
1801 | 1107877 | static int hls_coding_unit(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, | |
1802 | int cqt_depth, const VVCTreeType tree_type, VVCModeType mode_type) | ||
1803 | { | ||
1804 | 1107877 | const VVCFrameContext *fc = lc->fc; | |
1805 | 1107877 | const VVCSPS *sps = fc->ps.sps; | |
1806 | 1107877 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1807 | 1107877 | const int hs = sps->hshift[CHROMA]; | |
1808 | 1107877 | const int vs = sps->vshift[CHROMA]; | |
1809 |
4/4✓ Branch 0 taken 1085900 times.
✓ Branch 1 taken 21977 times.
✓ Branch 2 taken 2153 times.
✓ Branch 3 taken 1083747 times.
|
1107877 | const int is_128 = cb_width > 64 || cb_height > 64; |
1810 | 1107877 | int pred_mode_plt_flag = 0; | |
1811 | int ret; | ||
1812 | |||
1813 | 1107877 | CodingUnit *cu = add_cu(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type); | |
1814 | |||
1815 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1107877 times.
|
1107877 | if (!cu) |
1816 | ✗ | return AVERROR(ENOMEM); | |
1817 | |||
1818 | 1107877 | ff_vvc_set_neighbour_available(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
1819 | |||
1820 |
3/4✓ Branch 0 taken 622702 times.
✓ Branch 1 taken 485175 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 622702 times.
|
1107877 | if (IS_I(rsh) && is_128) |
1821 | ✗ | mode_type = MODE_TYPE_INTRA; | |
1822 | 1107877 | cu->pred_mode = pred_mode_decode(lc, tree_type, mode_type); | |
1823 | |||
1824 |
3/10✓ Branch 0 taken 702319 times.
✓ Branch 1 taken 405558 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 702319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
1107877 | if (cu->pred_mode == MODE_INTRA && sps->r->sps_palette_enabled_flag && !is_128 && !cu->skip_flag && |
1825 | ✗ | mode_type != MODE_TYPE_INTER && ((cb_width * cb_height) > | |
1826 | ✗ | (tree_type != DUAL_TREE_CHROMA ? 16 : (16 << hs << vs))) && | |
1827 | ✗ | (mode_type != MODE_TYPE_INTRA || tree_type != DUAL_TREE_CHROMA)) { | |
1828 | ✗ | pred_mode_plt_flag = ff_vvc_pred_mode_plt_flag(lc); | |
1829 | ✗ | if (pred_mode_plt_flag) { | |
1830 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1831 | ✗ | return AVERROR_PATCHWELCOME; | |
1832 | } | ||
1833 | } | ||
1834 |
3/6✓ Branch 0 taken 702319 times.
✓ Branch 1 taken 405558 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 702319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1107877 | if (cu->pred_mode == MODE_INTRA && sps->r->sps_act_enabled_flag && tree_type == SINGLE_TREE) { |
1835 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Adaptive Color Transform"); | |
1836 | ✗ | return AVERROR_PATCHWELCOME; | |
1837 | } | ||
1838 |
3/4✓ Branch 0 taken 405558 times.
✓ Branch 1 taken 702319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 405558 times.
|
1107877 | if (cu->pred_mode == MODE_INTRA || cu->pred_mode == MODE_PLT) { |
1839 |
4/4✓ Branch 0 taken 642897 times.
✓ Branch 1 taken 59422 times.
✓ Branch 2 taken 483616 times.
✓ Branch 3 taken 159281 times.
|
702319 | if (tree_type == SINGLE_TREE || tree_type == DUAL_TREE_LUMA) { |
1840 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 543038 times.
|
543038 | if (pred_mode_plt_flag) { |
1841 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1842 | ✗ | return AVERROR_PATCHWELCOME; | |
1843 | } else { | ||
1844 | 543038 | intra_luma_pred_modes(lc); | |
1845 | } | ||
1846 | 543038 | ff_vvc_set_intra_mvf(lc, 0); | |
1847 | } | ||
1848 |
6/6✓ Branch 0 taken 642897 times.
✓ Branch 1 taken 59422 times.
✓ Branch 2 taken 159281 times.
✓ Branch 3 taken 483616 times.
✓ Branch 4 taken 203581 times.
✓ Branch 5 taken 15122 times.
|
702319 | if ((tree_type == SINGLE_TREE || tree_type == DUAL_TREE_CHROMA) && sps->r->sps_chroma_format_idc) { |
1849 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 203581 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
203581 | if (pred_mode_plt_flag && tree_type == DUAL_TREE_CHROMA) { |
1850 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1851 | ✗ | return AVERROR_PATCHWELCOME; | |
1852 |
1/2✓ Branch 0 taken 203581 times.
✗ Branch 1 not taken.
|
203581 | } else if (!pred_mode_plt_flag) { |
1853 |
1/2✓ Branch 0 taken 203581 times.
✗ Branch 1 not taken.
|
203581 | if (!cu->act_enabled_flag) |
1854 | 203581 | intra_chroma_pred_modes(lc); | |
1855 | } | ||
1856 | } | ||
1857 |
1/2✓ Branch 0 taken 405558 times.
✗ Branch 1 not taken.
|
405558 | } else if (tree_type != DUAL_TREE_CHROMA) { /* MODE_INTER or MODE_IBC */ |
1858 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 405558 times.
|
405558 | if ((ret = inter_data(lc)) < 0) |
1859 | ✗ | return ret; | |
1860 | } | ||
1861 |
5/6✓ Branch 0 taken 405558 times.
✓ Branch 1 taken 702319 times.
✓ Branch 2 taken 405558 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60920 times.
✓ Branch 5 taken 344638 times.
|
1107877 | if (cu->pred_mode != MODE_INTRA && !pred_mode_plt_flag && !lc->cu->pu.general_merge_flag) |
1862 | 60920 | cu->coded_flag = ff_vvc_cu_coded_flag(lc); | |
1863 | else | ||
1864 |
3/4✓ Branch 0 taken 813087 times.
✓ Branch 1 taken 233870 times.
✓ Branch 2 taken 813087 times.
✗ Branch 3 not taken.
|
1046957 | cu->coded_flag = !(cu->skip_flag || pred_mode_plt_flag); |
1865 | |||
1866 |
2/2✓ Branch 0 taken 841795 times.
✓ Branch 1 taken 266082 times.
|
1107877 | if (cu->coded_flag) { |
1867 | 841795 | sbt_info(lc, sps); | |
1868 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 841795 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
841795 | if (sps->r->sps_act_enabled_flag && cu->pred_mode != MODE_INTRA && tree_type == SINGLE_TREE) { |
1869 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Adaptive Color Transform"); | |
1870 | ✗ | return AVERROR_PATCHWELCOME; | |
1871 | } | ||
1872 | 841795 | lc->parse.lfnst_dc_only = 1; | |
1873 | 841795 | lc->parse.lfnst_zero_out_sig_coeff_flag = 1; | |
1874 | 841795 | lc->parse.mts_dc_only = 1; | |
1875 | 841795 | lc->parse.mts_zero_out_sig_coeff_flag = 1; | |
1876 | 841795 | ret = hls_transform_tree(lc, x0, y0, cb_width, cb_height, cu->ch_type); | |
1877 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 841795 times.
|
841795 | if (ret < 0) |
1878 | ✗ | return ret; | |
1879 | 841795 | cu->lfnst_idx = lfnst_idx_decode(lc); | |
1880 | 841795 | cu->mts_idx = mts_idx_decode(lc); | |
1881 | 841795 | set_qp_c(lc); | |
1882 | } else { | ||
1883 | 266082 | ret = skipped_transform_tree_unit(lc); | |
1884 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 266082 times.
|
266082 | if (ret < 0) |
1885 | ✗ | return ret; | |
1886 | } | ||
1887 | 1107877 | set_cu_tabs(lc, cu); | |
1888 | |||
1889 | 1107877 | return 0; | |
1890 | } | ||
1891 | |||
1892 | 715594 | static int derive_mode_type_condition(const VVCLocalContext *lc, | |
1893 | const VVCSplitMode split, const int cb_width, const int cb_height, const VVCModeType mode_type_curr) | ||
1894 | { | ||
1895 | 715594 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1896 | 715594 | const VVCSPS *sps = lc->fc->ps.sps; | |
1897 | 715594 | const int area = cb_width * cb_height; | |
1898 | |||
1899 |
6/6✓ Branch 0 taken 415675 times.
✓ Branch 1 taken 299919 times.
✓ Branch 2 taken 10978 times.
✓ Branch 3 taken 404697 times.
✓ Branch 4 taken 301902 times.
✓ Branch 5 taken 8995 times.
|
715594 | if ((IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) || |
1900 |
2/2✓ Branch 0 taken 277723 times.
✓ Branch 1 taken 24179 times.
|
301902 | mode_type_curr != MODE_TYPE_ALL || !sps->r->sps_chroma_format_idc || |
1901 |
2/2✓ Branch 0 taken 41943 times.
✓ Branch 1 taken 235780 times.
|
277723 | sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
1902 | 479814 | return 0; | |
1903 |
8/10✓ Branch 0 taken 11787 times.
✓ Branch 1 taken 223993 times.
✓ Branch 2 taken 9504 times.
✓ Branch 3 taken 2283 times.
✓ Branch 4 taken 9504 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8918 times.
✓ Branch 7 taken 586 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 232911 times.
|
235780 | if ((area == 64 && (split == SPLIT_QT || split == SPLIT_TT_HOR || split == SPLIT_TT_VER)) || |
1904 | ✗ | (area == 32 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER))) | |
1905 | 2869 | return 1; | |
1906 |
8/10✓ Branch 0 taken 8918 times.
✓ Branch 1 taken 223993 times.
✓ Branch 2 taken 5572 times.
✓ Branch 3 taken 3346 times.
✓ Branch 4 taken 5572 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 8918 times.
✓ Branch 8 taken 21318 times.
✓ Branch 9 taken 202675 times.
|
232911 | if ((area == 64 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
1907 |
7/8✓ Branch 0 taken 18977 times.
✓ Branch 1 taken 2341 times.
✓ Branch 2 taken 2755 times.
✓ Branch 3 taken 16222 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5096 times.
✓ Branch 6 taken 17347 times.
✓ Branch 7 taken 201550 times.
|
223993 | (area == 128 && (split == SPLIT_TT_HOR || split == SPLIT_TT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
1908 |
6/6✓ Branch 0 taken 12017 times.
✓ Branch 1 taken 5330 times.
✓ Branch 2 taken 61676 times.
✓ Branch 3 taken 151891 times.
✓ Branch 4 taken 8299 times.
✓ Branch 5 taken 53377 times.
|
218897 | (cb_width == 8 && split == SPLIT_BT_VER) || (cb_width == 16 && split == SPLIT_TT_VER)) |
1909 |
2/2✓ Branch 0 taken 27488 times.
✓ Branch 1 taken 155 times.
|
27643 | return 1 + !IS_I(rsh); |
1910 | |||
1911 | 205268 | return 0; | |
1912 | } | ||
1913 | |||
1914 | 715594 | static VVCModeType mode_type_decode(VVCLocalContext *lc, const int x0, const int y0, | |
1915 | const int cb_width, const int cb_height, const VVCSplitMode split, const int ch_type, | ||
1916 | const VVCModeType mode_type_curr) | ||
1917 | { | ||
1918 | VVCModeType mode_type; | ||
1919 | 715594 | const int mode_type_condition = derive_mode_type_condition(lc, split, cb_width, cb_height, mode_type_curr); | |
1920 | |||
1921 |
2/2✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 712570 times.
|
715594 | if (mode_type_condition == 1) |
1922 | 3024 | mode_type = MODE_TYPE_INTRA; | |
1923 |
2/2✓ Branch 0 taken 27488 times.
✓ Branch 1 taken 685082 times.
|
712570 | else if (mode_type_condition == 2) { |
1924 |
2/2✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 19865 times.
|
27488 | mode_type = ff_vvc_non_inter_flag(lc, x0, y0, ch_type) ? MODE_TYPE_INTRA : MODE_TYPE_INTER; |
1925 | } else { | ||
1926 | 685082 | mode_type = mode_type_curr; | |
1927 | } | ||
1928 | |||
1929 | 715594 | return mode_type; | |
1930 | } | ||
1931 | |||
1932 | static int hls_coding_tree(VVCLocalContext *lc, | ||
1933 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1934 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
1935 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr); | ||
1936 | |||
1937 | 212191 | static int coding_tree_btv(VVCLocalContext *lc, | |
1938 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1939 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1940 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1941 | { | ||
1942 | #define CODING_TREE(x, idx) do { \ | ||
1943 | ret = hls_coding_tree(lc, x, y0, cb_width / 2, cb_height, \ | ||
1944 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
1945 | depth_offset, idx, SPLIT_BT_VER, tree_type, mode_type); \ | ||
1946 | if (ret < 0) \ | ||
1947 | return ret; \ | ||
1948 | } while (0); | ||
1949 | |||
1950 | 212191 | const VVCPPS *pps = lc->fc->ps.pps; | |
1951 | 212191 | const int x1 = x0 + cb_width / 2; | |
1952 | 212191 | int ret = 0; | |
1953 | |||
1954 | 212191 | depth_offset += (x0 + cb_width > pps->width) ? 1 : 0; | |
1955 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 212191 times.
|
212191 | CODING_TREE(x0, 0); |
1956 |
2/2✓ Branch 0 taken 211019 times.
✓ Branch 1 taken 1172 times.
|
212191 | if (x1 < pps->width) |
1957 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 211019 times.
|
211019 | CODING_TREE(x1, 1); |
1958 | |||
1959 | 212191 | return 0; | |
1960 | |||
1961 | #undef CODING_TREE | ||
1962 | } | ||
1963 | |||
1964 | 265185 | static int coding_tree_bth(VVCLocalContext *lc, | |
1965 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1966 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1967 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1968 | { | ||
1969 | #define CODING_TREE(y, idx) do { \ | ||
1970 | ret = hls_coding_tree(lc, x0, y, cb_width , cb_height / 2, \ | ||
1971 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
1972 | depth_offset, idx, SPLIT_BT_HOR, tree_type, mode_type); \ | ||
1973 | if (ret < 0) \ | ||
1974 | return ret; \ | ||
1975 | } while (0); | ||
1976 | |||
1977 | 265185 | const VVCPPS *pps = lc->fc->ps.pps; | |
1978 | 265185 | const int y1 = y0 + (cb_height / 2); | |
1979 | 265185 | int ret = 0; | |
1980 | |||
1981 | 265185 | depth_offset += (y0 + cb_height > pps->height) ? 1 : 0; | |
1982 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 265185 times.
|
265185 | CODING_TREE(y0, 0); |
1983 |
2/2✓ Branch 0 taken 248143 times.
✓ Branch 1 taken 17042 times.
|
265185 | if (y1 < pps->height) |
1984 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 248143 times.
|
248143 | CODING_TREE(y1, 1); |
1985 | |||
1986 | 265185 | return 0; | |
1987 | |||
1988 | #undef CODING_TREE | ||
1989 | } | ||
1990 | |||
1991 | 67604 | static int coding_tree_ttv(VVCLocalContext *lc, | |
1992 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1993 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1994 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1995 | { | ||
1996 | #define CODING_TREE(x, w, sub_div, idx) do { \ | ||
1997 | ret = hls_coding_tree(lc, x, y0, w, cb_height, \ | ||
1998 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
1999 | depth_offset, idx, SPLIT_TT_VER, tree_type, mode_type); \ | ||
2000 | if (ret < 0) \ | ||
2001 | return ret; \ | ||
2002 | } while (0); | ||
2003 | |||
2004 | 67604 | const VVCSH *sh = &lc->sc->sh; | |
2005 | 67604 | const int x1 = x0 + cb_width / 4; | |
2006 | 67604 | const int x2 = x0 + cb_width * 3 / 4; | |
2007 | int ret; | ||
2008 | |||
2009 |
3/4✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 22548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45056 times.
|
67604 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
2010 |
3/4✓ Branch 0 taken 31955 times.
✓ Branch 1 taken 35649 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31955 times.
|
67604 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
2011 | |||
2012 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 67604 times.
|
67604 | CODING_TREE(x0, cb_width / 4, cb_sub_div + 2, 0); |
2013 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 67604 times.
|
67604 | CODING_TREE(x1, cb_width / 2, cb_sub_div + 1, 1); |
2014 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 67604 times.
|
67604 | CODING_TREE(x2, cb_width / 4, cb_sub_div + 2, 2); |
2015 | |||
2016 | 67604 | return 0; | |
2017 | |||
2018 | #undef CODING_TREE | ||
2019 | } | ||
2020 | |||
2021 | 71930 | static int coding_tree_tth(VVCLocalContext *lc, | |
2022 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2023 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2024 | VVCTreeType tree_type, VVCModeType mode_type) | ||
2025 | { | ||
2026 | #define CODING_TREE(y, h, sub_div, idx) do { \ | ||
2027 | ret = hls_coding_tree(lc, x0, y, cb_width, h, \ | ||
2028 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
2029 | depth_offset, idx, SPLIT_TT_HOR, tree_type, mode_type); \ | ||
2030 | if (ret < 0) \ | ||
2031 | return ret; \ | ||
2032 | } while (0); | ||
2033 | |||
2034 | 71930 | const VVCSH *sh = &lc->sc->sh; | |
2035 | 71930 | const int y1 = y0 + (cb_height / 4); | |
2036 | 71930 | const int y2 = y0 + (3 * cb_height / 4); | |
2037 | int ret; | ||
2038 | |||
2039 |
3/4✓ Branch 0 taken 45670 times.
✓ Branch 1 taken 26260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45670 times.
|
71930 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
2040 |
3/4✓ Branch 0 taken 28201 times.
✓ Branch 1 taken 43729 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28201 times.
|
71930 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
2041 | |||
2042 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 71930 times.
|
71930 | CODING_TREE(y0, cb_height / 4, cb_sub_div + 2, 0); |
2043 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 71930 times.
|
71930 | CODING_TREE(y1, cb_height / 2, cb_sub_div + 1, 1); |
2044 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 71930 times.
|
71930 | CODING_TREE(y2, cb_height / 4, cb_sub_div + 2, 2); |
2045 | |||
2046 | 71930 | return 0; | |
2047 | |||
2048 | #undef CODING_TREE | ||
2049 | } | ||
2050 | |||
2051 | 98684 | static int coding_tree_qt(VVCLocalContext *lc, | |
2052 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2053 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2054 | VVCTreeType tree_type, VVCModeType mode_type) | ||
2055 | { | ||
2056 | #define CODING_TREE(x, y, idx) do { \ | ||
2057 | ret = hls_coding_tree(lc, x, y, cb_width / 2, cb_height / 2, \ | ||
2058 | qg_on_y, qg_on_c, cb_sub_div + 2, cqt_depth + 1, 0, 0, \ | ||
2059 | idx, SPLIT_QT, tree_type, mode_type); \ | ||
2060 | if (ret < 0) \ | ||
2061 | return ret; \ | ||
2062 | } while (0); | ||
2063 | |||
2064 | 98684 | const VVCPPS *pps = lc->fc->ps.pps; | |
2065 | 98684 | const int x1 = x0 + cb_width / 2; | |
2066 | 98684 | const int y1 = y0 + cb_height / 2; | |
2067 | 98684 | int ret = 0; | |
2068 | |||
2069 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 98684 times.
|
98684 | CODING_TREE(x0, y0, 0); |
2070 |
2/2✓ Branch 0 taken 95651 times.
✓ Branch 1 taken 3033 times.
|
98684 | if (x1 < pps->width) |
2071 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 95651 times.
|
95651 | CODING_TREE(x1, y0, 1); |
2072 |
2/2✓ Branch 0 taken 93253 times.
✓ Branch 1 taken 5431 times.
|
98684 | if (y1 < pps->height) |
2073 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 93253 times.
|
93253 | CODING_TREE(x0, y1, 2); |
2074 |
2/2✓ Branch 0 taken 95651 times.
✓ Branch 1 taken 3033 times.
|
98684 | if (x1 < pps->width && |
2075 |
2/2✓ Branch 0 taken 90228 times.
✓ Branch 1 taken 5423 times.
|
95651 | y1 < pps->height) |
2076 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 90228 times.
|
90228 | CODING_TREE(x1, y1, 3); |
2077 | |||
2078 | 98684 | return 0; | |
2079 | |||
2080 | #undef CODING_TREE | ||
2081 | } | ||
2082 | |||
2083 | typedef int (*coding_tree_fn)(VVCLocalContext *lc, | ||
2084 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2085 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2086 | VVCTreeType tree_type, VVCModeType mode_type); | ||
2087 | |||
2088 | const static coding_tree_fn coding_tree[] = { | ||
2089 | coding_tree_tth, | ||
2090 | coding_tree_bth, | ||
2091 | coding_tree_ttv, | ||
2092 | coding_tree_btv, | ||
2093 | coding_tree_qt, | ||
2094 | }; | ||
2095 | |||
2096 | 1823471 | static int hls_coding_tree(VVCLocalContext *lc, | |
2097 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2098 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
2099 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr) | ||
2100 | { | ||
2101 | 1823471 | VVCFrameContext *fc = lc->fc; | |
2102 | 1823471 | const VVCPPS *pps = fc->ps.pps; | |
2103 | 1823471 | const VVCSH *sh = &lc->sc->sh; | |
2104 | 1823471 | const H266RawSliceHeader *rsh = sh->r; | |
2105 | 1823471 | const int ch_type = tree_type_curr == DUAL_TREE_CHROMA; | |
2106 | int ret; | ||
2107 | VVCAllowedSplit allowed; | ||
2108 | |||
2109 |
6/6✓ Branch 0 taken 74221 times.
✓ Branch 1 taken 1749250 times.
✓ Branch 2 taken 52598 times.
✓ Branch 3 taken 21623 times.
✓ Branch 4 taken 1704 times.
✓ Branch 5 taken 50894 times.
|
1823471 | if (pps->r->pps_cu_qp_delta_enabled_flag && qg_on_y && cb_sub_div <= sh->cu_qp_delta_subdiv) { |
2110 | 1704 | lc->parse.is_cu_qp_delta_coded = 0; | |
2111 | 1704 | lc->parse.cu_qg_top_left_x = x0; | |
2112 | 1704 | lc->parse.cu_qg_top_left_y = y0; | |
2113 | } | ||
2114 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1823471 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1823471 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && qg_on_c && |
2115 | ✗ | cb_sub_div <= sh->cu_chroma_qp_offset_subdiv) { | |
2116 | ✗ | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
2117 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2118 | } | ||
2119 | |||
2120 | 1823471 | can_split(lc, x0, y0, cb_width, cb_height, mtt_depth, depth_offset, part_idx, | |
2121 | last_split_mode, tree_type_curr, mode_type_curr, &allowed); | ||
2122 |
2/2✓ Branch 1 taken 715594 times.
✓ Branch 2 taken 1107877 times.
|
1823471 | if (ff_vvc_split_cu_flag(lc, x0, y0, cb_width, cb_height, ch_type, &allowed)) { |
2123 | 715594 | VVCSplitMode split = ff_vvc_split_mode(lc, x0, y0, cb_width, cb_height, cqt_depth, mtt_depth, ch_type, &allowed); | |
2124 | 715594 | VVCModeType mode_type = mode_type_decode(lc, x0, y0, cb_width, cb_height, split, ch_type, mode_type_curr); | |
2125 | |||
2126 |
2/2✓ Branch 0 taken 700177 times.
✓ Branch 1 taken 15417 times.
|
715594 | VVCTreeType tree_type = (mode_type == MODE_TYPE_INTRA) ? DUAL_TREE_LUMA : tree_type_curr; |
2127 | |||
2128 |
2/2✓ Branch 0 taken 616910 times.
✓ Branch 1 taken 98684 times.
|
715594 | if (split != SPLIT_QT) { |
2129 |
6/6✓ Branch 0 taken 393567 times.
✓ Branch 1 taken 223343 times.
✓ Branch 2 taken 263210 times.
✓ Branch 3 taken 130357 times.
✓ Branch 4 taken 228433 times.
✓ Branch 5 taken 34777 times.
|
616910 | if (!(x0 & 31) && !(y0 & 31) && mtt_depth <= 1) |
2130 | 228433 | TAB_MSM(fc, mtt_depth, x0, y0) = split; | |
2131 | } | ||
2132 | 715594 | ret = coding_tree[split - 1](lc, x0, y0, cb_width, cb_height, qg_on_y, qg_on_c, | |
2133 | cb_sub_div, cqt_depth, mtt_depth, depth_offset, tree_type, mode_type); | ||
2134 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 715594 times.
|
715594 | if (ret < 0) |
2135 | ✗ | return ret; | |
2136 |
4/4✓ Branch 0 taken 706599 times.
✓ Branch 1 taken 8995 times.
✓ Branch 2 taken 10647 times.
✓ Branch 3 taken 695952 times.
|
715594 | if (mode_type_curr == MODE_TYPE_ALL && mode_type == MODE_TYPE_INTRA) { |
2137 | 10647 | ret = hls_coding_tree(lc, x0, y0, cb_width, cb_height, 0, qg_on_c, cb_sub_div, | |
2138 | cqt_depth, mtt_depth, 0, 0, split, DUAL_TREE_CHROMA, mode_type); | ||
2139 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10647 times.
|
10647 | if (ret < 0) |
2140 | ✗ | return ret; | |
2141 | } | ||
2142 | } else { | ||
2143 | 1107877 | ret = hls_coding_unit(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type_curr, mode_type_curr); | |
2144 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1107877 times.
|
1107877 | if (ret < 0) |
2145 | ✗ | return ret; | |
2146 | } | ||
2147 | |||
2148 | 1823471 | return 0; | |
2149 | } | ||
2150 | |||
2151 | 25007 | static int dual_tree_implicit_qt_split(VVCLocalContext *lc, | |
2152 | const int x0, const int y0, const int cb_size, const int cqt_depth) | ||
2153 | { | ||
2154 | 25007 | const VVCSH *sh = &lc->sc->sh; | |
2155 | 25007 | const H266RawSliceHeader *rsh = sh->r; | |
2156 | 25007 | const VVCPPS *pps = lc->fc->ps.pps; | |
2157 | 25007 | const int cb_subdiv = 2 * cqt_depth; | |
2158 | int ret; | ||
2159 | |||
2160 |
2/2✓ Branch 0 taken 5174 times.
✓ Branch 1 taken 19833 times.
|
25007 | if (cb_size > 64) { |
2161 | #define DUAL_TREE(x, y) do { \ | ||
2162 | ret = dual_tree_implicit_qt_split(lc, x, y, cb_size / 2, cqt_depth + 1); \ | ||
2163 | if (ret < 0) \ | ||
2164 | return ret; \ | ||
2165 | } while (0) | ||
2166 | |||
2167 | 5174 | const int x1 = x0 + (cb_size / 2); | |
2168 | 5174 | const int y1 = y0 + (cb_size / 2); | |
2169 |
3/4✓ Branch 0 taken 32 times.
✓ Branch 1 taken 5142 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
5174 | if (pps->r->pps_cu_qp_delta_enabled_flag && cb_subdiv <= sh->cu_qp_delta_subdiv) { |
2170 | 32 | lc->parse.is_cu_qp_delta_coded = 0; | |
2171 | 32 | lc->parse.cu_qg_top_left_x = x0; | |
2172 | 32 | lc->parse.cu_qg_top_left_y = y0; | |
2173 | } | ||
2174 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5174 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && cb_subdiv <= sh->cu_chroma_qp_offset_subdiv) { |
2175 | ✗ | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
2176 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2177 | } | ||
2178 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5174 times.
|
5174 | DUAL_TREE(x0, y0); |
2179 |
2/2✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 149 times.
|
5174 | if (x1 < pps->width) |
2180 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5025 times.
|
5025 | DUAL_TREE(x1, y0); |
2181 |
2/2✓ Branch 0 taken 4682 times.
✓ Branch 1 taken 492 times.
|
5174 | if (y1 < pps->height) |
2182 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4682 times.
|
4682 | DUAL_TREE(x0, y1); |
2183 |
4/4✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 4536 times.
✓ Branch 3 taken 489 times.
|
5174 | if (x1 < pps->width && y1 < pps->height) |
2184 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4536 times.
|
4536 | DUAL_TREE(x1, y1); |
2185 | #undef DUAL_TREE | ||
2186 | } else { | ||
2187 | #define CODING_TREE(tree_type) do { \ | ||
2188 | const int qg_on_y = tree_type == DUAL_TREE_LUMA; \ | ||
2189 | ret = hls_coding_tree(lc, x0, y0, cb_size, cb_size, qg_on_y, !qg_on_y, \ | ||
2190 | cb_subdiv, cqt_depth, 0, 0, 0, SPLIT_NONE, tree_type, MODE_TYPE_ALL); \ | ||
2191 | if (ret < 0) \ | ||
2192 | return ret; \ | ||
2193 | } while (0) | ||
2194 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19833 times.
|
19833 | CODING_TREE(DUAL_TREE_LUMA); |
2195 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19833 times.
|
19833 | CODING_TREE(DUAL_TREE_CHROMA); |
2196 | #undef CODING_TREE | ||
2197 | } | ||
2198 | 25007 | return 0; | |
2199 | } | ||
2200 | |||
2201 | #define SET_SAO(elem, value) \ | ||
2202 | do { \ | ||
2203 | if (!sao_merge_up_flag && !sao_merge_left_flag) \ | ||
2204 | sao->elem = value; \ | ||
2205 | else if (sao_merge_left_flag) \ | ||
2206 | sao->elem = CTB(fc->tab.sao, rx-1, ry).elem; \ | ||
2207 | else if (sao_merge_up_flag) \ | ||
2208 | sao->elem = CTB(fc->tab.sao, rx, ry-1).elem; \ | ||
2209 | else \ | ||
2210 | sao->elem = 0; \ | ||
2211 | } while (0) | ||
2212 | |||
2213 | 45792 | static void hls_sao(VVCLocalContext *lc, const int rx, const int ry) | |
2214 | { | ||
2215 | 45792 | VVCFrameContext *fc = lc->fc; | |
2216 | 45792 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
2217 | 45792 | int sao_merge_left_flag = 0; | |
2218 | 45792 | int sao_merge_up_flag = 0; | |
2219 | 45792 | SAOParams *sao = &CTB(fc->tab.sao, rx, ry); | |
2220 | int c_idx, i; | ||
2221 | |||
2222 |
3/4✓ Branch 0 taken 28125 times.
✓ Branch 1 taken 17667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28125 times.
|
45792 | if (rsh->sh_sao_luma_used_flag || rsh->sh_sao_chroma_used_flag) { |
2223 |
2/2✓ Branch 0 taken 15954 times.
✓ Branch 1 taken 1713 times.
|
17667 | if (rx > 0) { |
2224 |
2/2✓ Branch 0 taken 15402 times.
✓ Branch 1 taken 552 times.
|
15954 | if (lc->ctb_left_flag) |
2225 | 15402 | sao_merge_left_flag = ff_vvc_sao_merge_flag_decode(lc); | |
2226 | } | ||
2227 |
4/4✓ Branch 0 taken 14643 times.
✓ Branch 1 taken 3024 times.
✓ Branch 2 taken 7891 times.
✓ Branch 3 taken 6752 times.
|
17667 | if (ry > 0 && !sao_merge_left_flag) { |
2228 |
2/2✓ Branch 0 taken 7285 times.
✓ Branch 1 taken 606 times.
|
7891 | if (lc->ctb_up_flag) |
2229 | 7285 | sao_merge_up_flag = ff_vvc_sao_merge_flag_decode(lc); | |
2230 | } | ||
2231 | } | ||
2232 | |||
2233 |
4/4✓ Branch 0 taken 181056 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 136320 times.
✓ Branch 3 taken 45792 times.
|
182112 | for (c_idx = 0; c_idx < (fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) { |
2234 |
2/2✓ Branch 0 taken 45792 times.
✓ Branch 1 taken 90528 times.
|
136320 | const int sao_used_flag = !c_idx ? rsh->sh_sao_luma_used_flag : rsh->sh_sao_chroma_used_flag; |
2235 |
2/2✓ Branch 0 taken 98047 times.
✓ Branch 1 taken 38273 times.
|
136320 | if (!sao_used_flag) { |
2236 | 98047 | sao->type_idx[c_idx] = SAO_NOT_APPLIED; | |
2237 | 98047 | continue; | |
2238 | } | ||
2239 | |||
2240 |
2/2✓ Branch 0 taken 10303 times.
✓ Branch 1 taken 27970 times.
|
38273 | if (c_idx == 2) { |
2241 | 10303 | sao->type_idx[2] = sao->type_idx[1]; | |
2242 | 10303 | sao->eo_class[2] = sao->eo_class[1]; | |
2243 | } else { | ||
2244 |
7/8✓ Branch 0 taken 24483 times.
✓ Branch 1 taken 3487 times.
✓ Branch 2 taken 12433 times.
✓ Branch 3 taken 12050 times.
✓ Branch 5 taken 12050 times.
✓ Branch 6 taken 3487 times.
✓ Branch 7 taken 3487 times.
✗ Branch 8 not taken.
|
27970 | SET_SAO(type_idx[c_idx], ff_vvc_sao_type_idx_decode(lc)); |
2245 | } | ||
2246 | |||
2247 |
2/2✓ Branch 0 taken 25065 times.
✓ Branch 1 taken 13208 times.
|
38273 | if (sao->type_idx[c_idx] == SAO_NOT_APPLIED) |
2248 | 25065 | continue; | |
2249 | |||
2250 |
2/2✓ Branch 0 taken 52832 times.
✓ Branch 1 taken 13208 times.
|
66040 | for (i = 0; i < 4; i++) |
2251 |
7/8✓ Branch 0 taken 43780 times.
✓ Branch 1 taken 9052 times.
✓ Branch 2 taken 18364 times.
✓ Branch 3 taken 25416 times.
✓ Branch 5 taken 25416 times.
✓ Branch 6 taken 9052 times.
✓ Branch 7 taken 9052 times.
✗ Branch 8 not taken.
|
52832 | SET_SAO(offset_abs[c_idx][i], ff_vvc_sao_offset_abs_decode(lc)); |
2252 | |||
2253 |
2/2✓ Branch 0 taken 4914 times.
✓ Branch 1 taken 8294 times.
|
13208 | if (sao->type_idx[c_idx] == SAO_BAND) { |
2254 |
2/2✓ Branch 0 taken 19656 times.
✓ Branch 1 taken 4914 times.
|
24570 | for (i = 0; i < 4; i++) { |
2255 |
2/2✓ Branch 0 taken 6040 times.
✓ Branch 1 taken 13616 times.
|
19656 | if (sao->offset_abs[c_idx][i]) { |
2256 |
7/8✓ Branch 0 taken 5292 times.
✓ Branch 1 taken 748 times.
✓ Branch 2 taken 1723 times.
✓ Branch 3 taken 3569 times.
✓ Branch 5 taken 3569 times.
✓ Branch 6 taken 748 times.
✓ Branch 7 taken 748 times.
✗ Branch 8 not taken.
|
6040 | SET_SAO(offset_sign[c_idx][i], |
2257 | ff_vvc_sao_offset_sign_decode(lc)); | ||
2258 | } else { | ||
2259 | 13616 | sao->offset_sign[c_idx][i] = 0; | |
2260 | } | ||
2261 | } | ||
2262 |
7/8✓ Branch 0 taken 4302 times.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 1163 times.
✓ Branch 3 taken 3139 times.
✓ Branch 5 taken 3139 times.
✓ Branch 6 taken 612 times.
✓ Branch 7 taken 612 times.
✗ Branch 8 not taken.
|
4914 | SET_SAO(band_position[c_idx], ff_vvc_sao_band_position_decode(lc)); |
2263 |
2/2✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 1610 times.
|
8294 | } else if (c_idx != 2) { |
2264 |
7/8✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 1341 times.
✓ Branch 2 taken 2610 times.
✓ Branch 3 taken 2733 times.
✓ Branch 5 taken 2733 times.
✓ Branch 6 taken 1341 times.
✓ Branch 7 taken 1341 times.
✗ Branch 8 not taken.
|
6684 | SET_SAO(eo_class[c_idx], ff_vvc_sao_eo_class_decode(lc)); |
2265 | } | ||
2266 | |||
2267 | // Inferred parameters | ||
2268 | 13208 | sao->offset_val[c_idx][0] = 0; | |
2269 |
2/2✓ Branch 0 taken 52832 times.
✓ Branch 1 taken 13208 times.
|
66040 | for (i = 0; i < 4; i++) { |
2270 | 52832 | sao->offset_val[c_idx][i + 1] = sao->offset_abs[c_idx][i]; | |
2271 |
2/2✓ Branch 0 taken 33176 times.
✓ Branch 1 taken 19656 times.
|
52832 | if (sao->type_idx[c_idx] == SAO_EDGE) { |
2272 |
2/2✓ Branch 0 taken 16588 times.
✓ Branch 1 taken 16588 times.
|
33176 | if (i > 1) |
2273 | 16588 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
2274 |
2/2✓ Branch 0 taken 5100 times.
✓ Branch 1 taken 14556 times.
|
19656 | } else if (sao->offset_sign[c_idx][i]) { |
2275 | 5100 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
2276 | } | ||
2277 | 52832 | sao->offset_val[c_idx][i + 1] *= 1 << (fc->ps.sps->bit_depth - FFMIN(10, fc->ps.sps->bit_depth)); | |
2278 | } | ||
2279 | } | ||
2280 | 45792 | } | |
2281 | |||
2282 | 45792 | static void alf_params(VVCLocalContext *lc, const int rx, const int ry) | |
2283 | { | ||
2284 | 45792 | const VVCFrameContext *fc = lc->fc; | |
2285 | 45792 | const H266RawSliceHeader *sh = lc->sc->sh.r; | |
2286 | 45792 | ALFParams *alf = &CTB(fc->tab.alf, rx, ry); | |
2287 | |||
2288 | 45792 | alf->ctb_flag[LUMA] = alf->ctb_flag[CB] = alf->ctb_flag[CR] = 0; | |
2289 |
2/2✓ Branch 0 taken 26288 times.
✓ Branch 1 taken 19504 times.
|
45792 | if (sh->sh_alf_enabled_flag) { |
2290 | 26288 | alf->ctb_flag[LUMA] = ff_vvc_alf_ctb_flag(lc, rx, ry, LUMA); | |
2291 |
2/2✓ Branch 0 taken 18836 times.
✓ Branch 1 taken 7452 times.
|
26288 | if (alf->ctb_flag[LUMA]) { |
2292 | 18836 | uint8_t alf_use_aps_flag = 0; | |
2293 |
2/2✓ Branch 0 taken 18110 times.
✓ Branch 1 taken 726 times.
|
18836 | if (sh->sh_num_alf_aps_ids_luma > 0) |
2294 | 18110 | alf_use_aps_flag = ff_vvc_alf_use_aps_flag(lc); | |
2295 |
2/2✓ Branch 0 taken 16340 times.
✓ Branch 1 taken 2496 times.
|
18836 | if (alf_use_aps_flag) { |
2296 | 16340 | alf->ctb_filt_set_idx_y = 16; | |
2297 |
2/2✓ Branch 0 taken 4492 times.
✓ Branch 1 taken 11848 times.
|
16340 | if (sh->sh_num_alf_aps_ids_luma > 1) |
2298 | 4492 | alf->ctb_filt_set_idx_y += ff_vvc_alf_luma_prev_filter_idx(lc); | |
2299 | } else { | ||
2300 | 2496 | alf->ctb_filt_set_idx_y = ff_vvc_alf_luma_fixed_filter_idx(lc); | |
2301 | } | ||
2302 | } | ||
2303 |
2/2✓ Branch 0 taken 52576 times.
✓ Branch 1 taken 26288 times.
|
78864 | for (int c_idx = CB; c_idx <= CR; c_idx++) { |
2304 |
2/2✓ Branch 0 taken 26288 times.
✓ Branch 1 taken 26288 times.
|
52576 | const uint8_t alf_enabled_flag = |
2305 | c_idx == CB ? sh->sh_alf_cb_enabled_flag : sh->sh_alf_cr_enabled_flag; | ||
2306 |
2/2✓ Branch 0 taken 31037 times.
✓ Branch 1 taken 21539 times.
|
52576 | if (alf_enabled_flag) { |
2307 | 31037 | const VVCALF *aps = fc->ps.alf_list[sh->sh_alf_aps_id_chroma]; | |
2308 | 31037 | alf->ctb_flag[c_idx] = ff_vvc_alf_ctb_flag(lc, rx, ry, c_idx); | |
2309 | 31037 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = 0; | |
2310 |
4/4✓ Branch 0 taken 23232 times.
✓ Branch 1 taken 7805 times.
✓ Branch 2 taken 15333 times.
✓ Branch 3 taken 7899 times.
|
31037 | if (alf->ctb_flag[c_idx] && aps->num_chroma_filters > 1) |
2311 | 15333 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = ff_vvc_alf_ctb_filter_alt_idx(lc, c_idx, aps->num_chroma_filters); | |
2312 | } | ||
2313 | } | ||
2314 | } | ||
2315 |
2/2✓ Branch 0 taken 35226 times.
✓ Branch 1 taken 10566 times.
|
45792 | if (fc->ps.sps->r->sps_ccalf_enabled_flag) { |
2316 | 35226 | const uint8_t cc_enabled[] = { sh->sh_alf_cc_cb_enabled_flag, sh->sh_alf_cc_cr_enabled_flag }; | |
2317 | 35226 | const uint8_t cc_aps_id[] = { sh->sh_alf_cc_cb_aps_id, sh->sh_alf_cc_cr_aps_id }; | |
2318 |
2/2✓ Branch 0 taken 70452 times.
✓ Branch 1 taken 35226 times.
|
105678 | for (int i = 0; i < 2; i++) { |
2319 | 70452 | alf->ctb_cc_idc[i] = 0; | |
2320 |
2/2✓ Branch 0 taken 21273 times.
✓ Branch 1 taken 49179 times.
|
70452 | if (cc_enabled[i]) { |
2321 | 21273 | const VVCALF *aps = fc->ps.alf_list[cc_aps_id[i]]; | |
2322 | 21273 | alf->ctb_cc_idc[i] = ff_vvc_alf_ctb_cc_idc(lc, rx, ry, i, aps->num_cc_filters[i]); | |
2323 | } | ||
2324 | } | ||
2325 | } | ||
2326 | 45792 | } | |
2327 | |||
2328 | 45792 | static void deblock_params(VVCLocalContext *lc, const int rx, const int ry) | |
2329 | { | ||
2330 | 45792 | VVCFrameContext *fc = lc->fc; | |
2331 | 45792 | const VVCSH *sh = &lc->sc->sh; | |
2332 | 45792 | CTB(fc->tab.deblock, rx, ry) = sh->deblock; | |
2333 | 45792 | } | |
2334 | |||
2335 | 45792 | static int hls_coding_tree_unit(VVCLocalContext *lc, | |
2336 | const int x0, const int y0, const int ctu_idx, const int rx, const int ry) | ||
2337 | { | ||
2338 | 45792 | const VVCFrameContext *fc = lc->fc; | |
2339 | 45792 | const VVCSPS *sps = fc->ps.sps; | |
2340 | 45792 | const VVCPPS *pps = fc->ps.pps; | |
2341 | 45792 | const VVCSH *sh = &lc->sc->sh; | |
2342 | 45792 | const H266RawSliceHeader *rsh = sh->r; | |
2343 | 45792 | const unsigned int ctb_size = sps->ctb_size_y; | |
2344 | 45792 | int ret = 0; | |
2345 | |||
2346 | 45792 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2347 | |||
2348 | 45792 | hls_sao(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2349 | 45792 | alf_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2350 | 45792 | deblock_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2351 | |||
2352 |
4/4✓ Branch 0 taken 5786 times.
✓ Branch 1 taken 40006 times.
✓ Branch 2 taken 5590 times.
✓ Branch 3 taken 196 times.
|
45792 | if (IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) |
2353 | 5590 | ret = dual_tree_implicit_qt_split(lc, x0, y0, ctb_size, 0); | |
2354 | else | ||
2355 | 40202 | ret = hls_coding_tree(lc, x0, y0, ctb_size, ctb_size, | |
2356 | 1, 1, 0, 0, 0, 0, 0, SPLIT_NONE, SINGLE_TREE, MODE_TYPE_ALL); | ||
2357 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 45792 times.
|
45792 | if (ret < 0) |
2358 | ✗ | return ret; | |
2359 | |||
2360 |
2/2✓ Branch 0 taken 5265 times.
✓ Branch 1 taken 40527 times.
|
45792 | if (rx == pps->ctb_to_col_bd[rx + 1] - 1) { |
2361 |
2/2✓ Branch 0 taken 1659 times.
✓ Branch 1 taken 3606 times.
|
5265 | if (ctu_idx == sh->num_ctus_in_curr_slice - 1) { |
2362 | 1659 | const int end_of_slice_one_bit = ff_vvc_end_of_slice_flag_decode(lc); | |
2363 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1659 times.
|
1659 | if (!end_of_slice_one_bit) |
2364 | ✗ | return AVERROR_INVALIDDATA; | |
2365 | } else { | ||
2366 |
2/2✓ Branch 0 taken 214 times.
✓ Branch 1 taken 3392 times.
|
3606 | if (ry == pps->ctb_to_row_bd[ry + 1] - 1) { |
2367 | 214 | const int end_of_tile_one_bit = ff_vvc_end_of_tile_one_bit(lc); | |
2368 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
|
214 | if (!end_of_tile_one_bit) |
2369 | ✗ | return AVERROR_INVALIDDATA; | |
2370 | } else { | ||
2371 |
2/2✓ Branch 0 taken 153 times.
✓ Branch 1 taken 3239 times.
|
3392 | if (fc->ps.sps->r->sps_entropy_coding_sync_enabled_flag) { |
2372 | 153 | const int end_of_subset_one_bit = ff_vvc_end_of_subset_one_bit(lc); | |
2373 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
|
153 | if (!end_of_subset_one_bit) |
2374 | ✗ | return AVERROR_INVALIDDATA; | |
2375 | } | ||
2376 | } | ||
2377 | } | ||
2378 | } | ||
2379 | |||
2380 | 45792 | return 0; | |
2381 | } | ||
2382 | |||
2383 | 485175 | static int has_inter_luma(const CodingUnit *cu) | |
2384 | { | ||
2385 |
4/6✓ Branch 0 taken 404130 times.
✓ Branch 1 taken 81045 times.
✓ Branch 2 taken 404130 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 404130 times.
✗ Branch 5 not taken.
|
485175 | return cu->pred_mode != MODE_INTRA && cu->pred_mode != MODE_PLT && cu->tree_type != DUAL_TREE_CHROMA; |
2386 | } | ||
2387 | |||
2388 | 7741141 | static int pred_get_y(const int y0, const Mv *mv, const int height) | |
2389 | { | ||
2390 | 7741141 | return FFMAX(0, y0 + (mv->y >> 4) + height); | |
2391 | } | ||
2392 | |||
2393 | 404130 | static void cu_get_max_y(const CodingUnit *cu, int max_y[2][VVC_MAX_REF_ENTRIES], const VVCFrameContext *fc) | |
2394 | { | ||
2395 | 404130 | const PredictionUnit *pu = &cu->pu; | |
2396 | |||
2397 |
2/2✓ Branch 0 taken 24737 times.
✓ Branch 1 taken 379393 times.
|
404130 | if (pu->merge_gpm_flag) { |
2398 |
2/2✓ Branch 0 taken 49474 times.
✓ Branch 1 taken 24737 times.
|
74211 | for (int i = 0; i < FF_ARRAY_ELEMS(pu->gpm_mv); i++) { |
2399 | 49474 | const MvField *mvf = pu->gpm_mv + i; | |
2400 | 49474 | const int lx = mvf->pred_flag - PF_L0; | |
2401 | 49474 | const int idx = mvf->ref_idx[lx]; | |
2402 | 49474 | const int y = pred_get_y(cu->y0, mvf->mv + lx, cu->cb_height); | |
2403 | |||
2404 | 49474 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y); | |
2405 | } | ||
2406 | } else { | ||
2407 | 379393 | const MotionInfo *mi = &pu->mi; | |
2408 |
4/4✓ Branch 0 taken 346816 times.
✓ Branch 1 taken 32577 times.
✓ Branch 2 taken 68451 times.
✓ Branch 3 taken 278365 times.
|
379393 | const int max_dmvr_off = (!pu->inter_affine_flag && pu->dmvr_flag) ? 2 : 0; |
2409 | 379393 | const int sbw = cu->cb_width / mi->num_sb_x; | |
2410 | 379393 | const int sbh = cu->cb_height / mi->num_sb_y; | |
2411 |
2/2✓ Branch 0 taken 831190 times.
✓ Branch 1 taken 379393 times.
|
1210583 | for (int sby = 0; sby < mi->num_sb_y; sby++) { |
2412 |
2/2✓ Branch 0 taken 5305709 times.
✓ Branch 1 taken 831190 times.
|
6136899 | for (int sbx = 0; sbx < mi->num_sb_x; sbx++) { |
2413 | 5305709 | const int x0 = cu->x0 + sbx * sbw; | |
2414 | 5305709 | const int y0 = cu->y0 + sby * sbh; | |
2415 | 5305709 | const MvField *mvf = ff_vvc_get_mvf(fc, x0, y0); | |
2416 |
2/2✓ Branch 0 taken 10611418 times.
✓ Branch 1 taken 5305709 times.
|
15917127 | for (int lx = 0; lx < 2; lx++) { |
2417 | 10611418 | const PredFlag mask = 1 << lx; | |
2418 |
2/2✓ Branch 0 taken 7691667 times.
✓ Branch 1 taken 2919751 times.
|
10611418 | if (mvf->pred_flag & mask) { |
2419 | 7691667 | const int idx = mvf->ref_idx[lx]; | |
2420 | 7691667 | const int y = pred_get_y(y0, mvf->mv + lx, sbh); | |
2421 | |||
2422 | 7691667 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y + max_dmvr_off); | |
2423 | } | ||
2424 | } | ||
2425 | } | ||
2426 | } | ||
2427 | } | ||
2428 | 404130 | } | |
2429 | |||
2430 | 45792 | static void ctu_get_pred(VVCLocalContext *lc, const int rs) | |
2431 | { | ||
2432 | 45792 | const VVCFrameContext *fc = lc->fc; | |
2433 | 45792 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
2434 | 45792 | CTU *ctu = fc->tab.ctus + rs; | |
2435 | 45792 | const CodingUnit *cu = fc->tab.cus[rs]; | |
2436 | |||
2437 | 45792 | ctu->has_dmvr = 0; | |
2438 | |||
2439 |
2/2✓ Branch 0 taken 5786 times.
✓ Branch 1 taken 40006 times.
|
45792 | if (IS_I(rsh)) |
2440 | 5786 | return; | |
2441 | |||
2442 |
2/2✓ Branch 0 taken 80012 times.
✓ Branch 1 taken 40006 times.
|
120018 | for (int lx = 0; lx < 2; lx++) |
2443 | 80012 | memset(ctu->max_y[lx], -1, sizeof(ctu->max_y[0][0]) * rsh->num_ref_idx_active[lx]); | |
2444 | |||
2445 |
2/2✓ Branch 0 taken 485175 times.
✓ Branch 1 taken 40006 times.
|
525181 | while (cu) { |
2446 |
2/2✓ Branch 1 taken 404130 times.
✓ Branch 2 taken 81045 times.
|
485175 | if (has_inter_luma(cu)) { |
2447 | 404130 | cu_get_max_y(cu, ctu->max_y, fc); | |
2448 | 404130 | ctu->has_dmvr |= cu->pu.dmvr_flag; | |
2449 | } | ||
2450 | 485175 | cu = cu->next; | |
2451 | } | ||
2452 | 40006 | ctu->max_y_idx[0] = ctu->max_y_idx[1] = 0; | |
2453 | } | ||
2454 | |||
2455 | 45792 | int ff_vvc_coding_tree_unit(VVCLocalContext *lc, | |
2456 | const int ctu_idx, const int rs, const int rx, const int ry) | ||
2457 | { | ||
2458 | 45792 | const VVCFrameContext *fc = lc->fc; | |
2459 | 45792 | const VVCSPS *sps = fc->ps.sps; | |
2460 | 45792 | const VVCPPS *pps = fc->ps.pps; | |
2461 | 45792 | const int x_ctb = rx << sps->ctb_log2_size_y; | |
2462 | 45792 | const int y_ctb = ry << sps->ctb_log2_size_y; | |
2463 | 45792 | const int ctb_size = 1 << sps->ctb_log2_size_y << sps->ctb_log2_size_y; | |
2464 | 45792 | EntryPoint* ep = lc->ep; | |
2465 | int ret; | ||
2466 | |||
2467 |
2/2✓ Branch 0 taken 5265 times.
✓ Branch 1 taken 40527 times.
|
45792 | if (rx == pps->ctb_to_col_bd[rx]) { |
2468 | 5265 | ep->num_hmvp = 0; | |
2469 | 5265 | ep->num_hmvp_ibc = 0; | |
2470 |
4/4✓ Branch 0 taken 3504 times.
✓ Branch 1 taken 1761 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 3392 times.
|
5265 | ep->is_first_qg = ry == pps->ctb_to_row_bd[ry] || !ctu_idx; |
2471 | } | ||
2472 | |||
2473 | 45792 | lc->coeffs = fc->tab.coeffs + rs * ctb_size * VVC_MAX_SAMPLE_ARRAYS; | |
2474 | 45792 | lc->cu = NULL; | |
2475 | |||
2476 | 45792 | ff_vvc_cabac_init(lc, ctu_idx, rx, ry); | |
2477 | 45792 | ff_vvc_decode_neighbour(lc, x_ctb, y_ctb, rx, ry, rs); | |
2478 | 45792 | ret = hls_coding_tree_unit(lc, x_ctb, y_ctb, ctu_idx, rx, ry); | |
2479 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 45792 times.
|
45792 | if (ret < 0) |
2480 | ✗ | return ret; | |
2481 | 45792 | ctu_get_pred(lc, rs); | |
2482 | |||
2483 | 45792 | return 0; | |
2484 | } | ||
2485 | |||
2486 | 310074 | void ff_vvc_decode_neighbour(VVCLocalContext *lc, const int x_ctb, const int y_ctb, | |
2487 | const int rx, const int ry, const int rs) | ||
2488 | { | ||
2489 | 310074 | VVCFrameContext *fc = lc->fc; | |
2490 | 310074 | const int ctb_size = fc->ps.sps->ctb_size_y; | |
2491 | |||
2492 | 310074 | lc->end_of_tiles_x = fc->ps.pps->width; | |
2493 | 310074 | lc->end_of_tiles_y = fc->ps.pps->height; | |
2494 |
2/2✓ Branch 0 taken 36066 times.
✓ Branch 1 taken 274008 times.
|
310074 | if (fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx + 1]) |
2495 | 36066 | lc->end_of_tiles_x = FFMIN(x_ctb + ctb_size, lc->end_of_tiles_x); | |
2496 |
2/2✓ Branch 0 taken 60850 times.
✓ Branch 1 taken 249224 times.
|
310074 | if (fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry + 1]) |
2497 | 60850 | lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, lc->end_of_tiles_y); | |
2498 | |||
2499 | 310074 | lc->boundary_flags = 0; | |
2500 |
4/4✓ Branch 0 taken 282072 times.
✓ Branch 1 taken 28002 times.
✓ Branch 2 taken 8064 times.
✓ Branch 3 taken 274008 times.
|
310074 | if (rx > 0 && fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx - 1]) |
2501 | 8064 | lc->boundary_flags |= BOUNDARY_LEFT_TILE; | |
2502 |
4/4✓ Branch 0 taken 282072 times.
✓ Branch 1 taken 28002 times.
✓ Branch 2 taken 5278 times.
✓ Branch 3 taken 276794 times.
|
310074 | if (rx > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - 1]) |
2503 | 5278 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; | |
2504 |
4/4✓ Branch 0 taken 260648 times.
✓ Branch 1 taken 49426 times.
✓ Branch 2 taken 11424 times.
✓ Branch 3 taken 249224 times.
|
310074 | if (ry > 0 && fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry - 1]) |
2505 | 11424 | lc->boundary_flags |= BOUNDARY_UPPER_TILE; | |
2506 |
4/4✓ Branch 0 taken 260648 times.
✓ Branch 1 taken 49426 times.
✓ Branch 2 taken 11312 times.
✓ Branch 3 taken 249336 times.
|
310074 | if (ry > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - fc->ps.pps->ctb_width]) |
2507 | 11312 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; | |
2508 |
2/2✓ Branch 0 taken 30018 times.
✓ Branch 1 taken 280056 times.
|
310074 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_x[lc->sc->sh.r->curr_subpic_idx] == rx) |
2509 | 30018 | lc->boundary_flags |= BOUNDARY_LEFT_SUBPIC; | |
2510 |
2/2✓ Branch 0 taken 50980 times.
✓ Branch 1 taken 259094 times.
|
310074 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_y[lc->sc->sh.r->curr_subpic_idx] == ry) |
2511 | 50980 | lc->boundary_flags |= BOUNDARY_UPPER_SUBPIC; | |
2512 |
4/4✓ Branch 0 taken 282072 times.
✓ Branch 1 taken 28002 times.
✓ Branch 2 taken 274008 times.
✓ Branch 3 taken 8064 times.
|
310074 | lc->ctb_left_flag = rx > 0 && !(lc->boundary_flags & BOUNDARY_LEFT_TILE); |
2513 |
6/6✓ Branch 0 taken 260648 times.
✓ Branch 1 taken 49426 times.
✓ Branch 2 taken 249224 times.
✓ Branch 3 taken 11424 times.
✓ Branch 4 taken 246872 times.
✓ Branch 5 taken 2352 times.
|
310074 | lc->ctb_up_flag = ry > 0 && !(lc->boundary_flags & BOUNDARY_UPPER_TILE) && !(lc->boundary_flags & BOUNDARY_UPPER_SLICE); |
2514 |
4/4✓ Branch 0 taken 246872 times.
✓ Branch 1 taken 63202 times.
✓ Branch 2 taken 223810 times.
✓ Branch 3 taken 23062 times.
|
533884 | lc->ctb_up_right_flag = lc->ctb_up_flag && (fc->ps.pps->ctb_to_col_bd[rx] == fc->ps.pps->ctb_to_col_bd[rx + 1]) && |
2515 |
1/2✓ Branch 0 taken 223810 times.
✗ Branch 1 not taken.
|
223810 | (fc->ps.pps->ctb_to_row_bd[ry] == fc->ps.pps->ctb_to_row_bd[ry - 1]); |
2516 |
4/4✓ Branch 0 taken 274008 times.
✓ Branch 1 taken 36066 times.
✓ Branch 2 taken 223810 times.
✓ Branch 3 taken 50198 times.
|
310074 | lc->ctb_up_left_flag = lc->ctb_left_flag && lc->ctb_up_flag; |
2517 | 310074 | } | |
2518 | |||
2519 | 2401816 | void ff_vvc_set_neighbour_available(VVCLocalContext *lc, | |
2520 | const int x0, const int y0, const int w, const int h) | ||
2521 | { | ||
2522 | 2401816 | const int log2_ctb_size = lc->fc->ps.sps->ctb_log2_size_y; | |
2523 | 2401816 | const int x0b = av_zero_extend(x0, log2_ctb_size); | |
2524 | 2401816 | const int y0b = av_zero_extend(y0, log2_ctb_size); | |
2525 | |||
2526 |
4/4✓ Branch 0 taken 665118 times.
✓ Branch 1 taken 1736698 times.
✓ Branch 2 taken 589828 times.
✓ Branch 3 taken 75290 times.
|
2401816 | lc->na.cand_up = (lc->ctb_up_flag || y0b); |
2527 |
4/4✓ Branch 0 taken 397472 times.
✓ Branch 1 taken 2004344 times.
✓ Branch 2 taken 341894 times.
✓ Branch 3 taken 55578 times.
|
2401816 | lc->na.cand_left = (lc->ctb_left_flag || x0b); |
2528 |
8/8✓ Branch 0 taken 382275 times.
✓ Branch 1 taken 2019541 times.
✓ Branch 2 taken 277686 times.
✓ Branch 3 taken 104589 times.
✓ Branch 4 taken 2254128 times.
✓ Branch 5 taken 43099 times.
✓ Branch 6 taken 2200510 times.
✓ Branch 7 taken 53618 times.
|
2401816 | lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag; |
2529 | 2401816 | lc->na.cand_up_right_sap = | |
2530 |
6/6✓ Branch 0 taken 356777 times.
✓ Branch 1 taken 2045039 times.
✓ Branch 2 taken 253631 times.
✓ Branch 3 taken 103146 times.
✓ Branch 4 taken 74973 times.
✓ Branch 5 taken 178658 times.
|
2401816 | (x0b + w == 1 << log2_ctb_size) ? lc->ctb_up_right_flag && !y0b : lc->na.cand_up; |
2531 |
4/4✓ Branch 0 taken 2064929 times.
✓ Branch 1 taken 336887 times.
✓ Branch 2 taken 2046783 times.
✓ Branch 3 taken 18146 times.
|
2401816 | lc->na.cand_up_right = lc->na.cand_up_right_sap && (x0 + w) < lc->end_of_tiles_x; |
2532 | 2401816 | } | |
2533 | |||
2534 | 91584 | void ff_vvc_ctu_free_cus(CodingUnit **cus) | |
2535 | { | ||
2536 |
2/2✓ Branch 0 taken 1107877 times.
✓ Branch 1 taken 91584 times.
|
1199461 | while (*cus) { |
2537 | 1107877 | CodingUnit *cu = *cus; | |
2538 | 1107877 | TransformUnit **head = &cu->tus.head; | |
2539 | |||
2540 | 1107877 | *cus = cu->next; | |
2541 | |||
2542 |
2/2✓ Branch 0 taken 1349398 times.
✓ Branch 1 taken 1107877 times.
|
2457275 | while (*head) { |
2543 | 1349398 | TransformUnit *tu = *head; | |
2544 | 1349398 | *head = tu->next; | |
2545 | 1349398 | ff_refstruct_unref(&tu); | |
2546 | } | ||
2547 | 1107877 | cu->tus.tail = NULL; | |
2548 | |||
2549 | 1107877 | ff_refstruct_unref(&cu); | |
2550 | } | ||
2551 | 91584 | } | |
2552 | |||
2553 | 14543790 | int ff_vvc_get_qPy(const VVCFrameContext *fc, const int xc, const int yc) | |
2554 | { | ||
2555 | 14543790 | const int min_cb_log2_size_y = fc->ps.sps->min_cb_log2_size_y; | |
2556 | 14543790 | const int x = xc >> min_cb_log2_size_y; | |
2557 | 14543790 | const int y = yc >> min_cb_log2_size_y; | |
2558 | 14543790 | return fc->tab.qp[LUMA][x + y * fc->ps.pps->min_cb_width]; | |
2559 | } | ||
2560 | |||
2561 | 2026 | void ff_vvc_ep_init_stat_coeff(EntryPoint *ep, | |
2562 | const int bit_depth, const int persistent_rice_adaptation_enabled_flag) | ||
2563 | { | ||
2564 |
2/2✓ Branch 0 taken 6078 times.
✓ Branch 1 taken 2026 times.
|
8104 | for (size_t i = 0; i < FF_ARRAY_ELEMS(ep->stat_coeff); ++i) { |
2565 | 6078 | ep->stat_coeff[i] = | |
2566 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6078 times.
|
6078 | persistent_rice_adaptation_enabled_flag ? 2 * (av_log2(bit_depth - 10)) : 0; |
2567 | } | ||
2568 | 2026 | } | |
2569 |