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 | 1638867 | static void set_tb_pos(const VVCFrameContext *fc, const TransformBlock *tb) | |
42 | { | ||
43 | 1638867 | const int x_tb = tb->x0 >> MIN_TU_LOG2; | |
44 | 1638867 | const int y_tb = tb->y0 >> MIN_TU_LOG2; | |
45 | 1638867 | const int hs = fc->ps.sps->hshift[tb->c_idx]; | |
46 | 1638867 | const int vs = fc->ps.sps->vshift[tb->c_idx]; | |
47 | 1638867 | const int is_chroma = tb->c_idx != 0; | |
48 | 1638867 | const int width = FFMAX(1, tb->tb_width >> (MIN_TU_LOG2 - hs)); | |
49 | 1638867 | const int end = y_tb + FFMAX(1, tb->tb_height >> (MIN_TU_LOG2 - vs)); | |
50 | |||
51 |
2/2✓ Branch 0 taken 8560404 times.
✓ Branch 1 taken 1638867 times.
|
10199271 | for (int y = y_tb; y < end; y++) { |
52 | 8560404 | const int off = y * fc->ps.pps->min_tu_width + x_tb; | |
53 |
2/2✓ Branch 0 taken 79634692 times.
✓ Branch 1 taken 8560404 times.
|
88195096 | for (int i = 0; i < width; i++) { |
54 | 79634692 | fc->tab.tb_pos_x0[is_chroma][off + i] = tb->x0; | |
55 | 79634692 | fc->tab.tb_pos_y0[is_chroma][off + i] = tb->y0; | |
56 | } | ||
57 | 8560404 | memset(fc->tab.tb_width [is_chroma] + off, tb->tb_width, width); | |
58 | 8560404 | memset(fc->tab.tb_height[is_chroma] + off, tb->tb_height, width); | |
59 | } | ||
60 | 1638867 | } | |
61 | |||
62 | 2255036 | static void set_tb_tab(uint8_t *tab, uint8_t v, const VVCFrameContext *fc, | |
63 | const TransformBlock *tb) | ||
64 | { | ||
65 | 2255036 | const int width = tb->tb_width << fc->ps.sps->hshift[tb->c_idx]; | |
66 | 2255036 | const int height = tb->tb_height << fc->ps.sps->vshift[tb->c_idx]; | |
67 | |||
68 |
2/2✓ Branch 0 taken 11358121 times.
✓ Branch 1 taken 2255036 times.
|
13613157 | for (int h = 0; h < height; h += MIN_TU_SIZE) { |
69 | 11358121 | const int y = (tb->y0 + h) >> MIN_TU_LOG2; | |
70 | 11358121 | const int off = y * fc->ps.pps->min_tu_width + (tb->x0 >> MIN_TU_LOG2); | |
71 | 11358121 | const int w = FFMAX(1, width >> MIN_TU_LOG2); | |
72 | 11358121 | memset(tab + off, v, w); | |
73 | } | ||
74 | 2255036 | } | |
75 | |||
76 | // 8.7.1 Derivation process for quantization parameters | ||
77 | 488 | static int get_qp_y_pred(const VVCLocalContext *lc) | |
78 | { | ||
79 | 488 | const VVCFrameContext *fc = lc->fc; | |
80 | 488 | const VVCSPS *sps = fc->ps.sps; | |
81 | 488 | const VVCPPS *pps = fc->ps.pps; | |
82 | 488 | const CodingUnit *cu = lc->cu; | |
83 | 488 | const int ctb_log2_size = sps->ctb_log2_size_y; | |
84 | 488 | const int ctb_size_mask = (1 << ctb_log2_size) - 1; | |
85 | 488 | const int xQg = lc->parse.cu_qg_top_left_x; | |
86 | 488 | const int yQg = lc->parse.cu_qg_top_left_y; | |
87 | 488 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
88 | 488 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
89 | 488 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
90 | 488 | const int rx = cu->x0 >> ctb_log2_size; | |
91 | 488 | const int ry = cu->y0 >> ctb_log2_size; | |
92 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
488 | const int in_same_ctb_a = ((xQg - 1) >> ctb_log2_size) == rx && (yQg >> ctb_log2_size) == ry; |
93 |
2/4✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
|
488 | const int in_same_ctb_b = (xQg >> ctb_log2_size) == rx && ((yQg - 1) >> ctb_log2_size) == ry; |
94 | int qPy_pred, qPy_a, qPy_b; | ||
95 | |||
96 |
2/2✓ Branch 0 taken 244 times.
✓ Branch 1 taken 244 times.
|
488 | if (lc->na.cand_up) { |
97 |
2/4✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 244 times.
✗ Branch 3 not taken.
|
244 | const int first_qg_in_ctu = !(xQg & ctb_size_mask) && !(yQg & ctb_size_mask); |
98 | 244 | const int qPy_up = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
99 |
3/4✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 183 times.
|
244 | if (first_qg_in_ctu && pps->ctb_to_col_bd[xQg >> ctb_log2_size] == xQg >> ctb_log2_size) |
100 | 61 | return qPy_up; | |
101 | } | ||
102 | |||
103 | // qPy_pred | ||
104 |
2/2✓ Branch 0 taken 61 times.
✓ Branch 1 taken 366 times.
|
427 | qPy_pred = lc->ep->is_first_qg ? lc->sc->sh.slice_qp_y : lc->ep->qp_y; |
105 | |||
106 | // qPy_b | ||
107 |
3/4✓ Branch 0 taken 183 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 183 times.
✗ Branch 3 not taken.
|
427 | if (!lc->na.cand_up || !in_same_ctb_b) |
108 | 427 | qPy_b = qPy_pred; | |
109 | else | ||
110 | ✗ | qPy_b = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
111 | |||
112 | // qPy_a | ||
113 |
3/4✓ Branch 0 taken 366 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 366 times.
✗ Branch 3 not taken.
|
427 | if (!lc->na.cand_left || !in_same_ctb_a) |
114 | 427 | qPy_a = qPy_pred; | |
115 | else | ||
116 | ✗ | qPy_a = fc->tab.qp[LUMA][(x_cb - 1) + y_cb * min_cb_width]; | |
117 | |||
118 | av_assert2(qPy_a >= -fc->ps.sps->qp_bd_offset && qPy_a < 63); | ||
119 | av_assert2(qPy_b >= -fc->ps.sps->qp_bd_offset && qPy_b < 63); | ||
120 | |||
121 | 427 | return (qPy_a + qPy_b + 1) >> 1; | |
122 | } | ||
123 | |||
124 | 3551944 | static void set_cb_tab(const VVCLocalContext *lc, uint8_t *tab, const uint8_t v) | |
125 | { | ||
126 | 3551944 | const VVCFrameContext *fc = lc->fc; | |
127 | 3551944 | const VVCPPS *pps = fc->ps.pps; | |
128 | 3551944 | const CodingUnit *cu = lc->cu; | |
129 | 3551944 | const int log2_min_cb_size = fc->ps.sps->min_cb_log2_size_y; | |
130 | 3551944 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
131 | 3551944 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
132 | 3551944 | const int cb_width = cu->cb_width; | |
133 | 3551944 | const int cb_height = cu->cb_height; | |
134 | 3551944 | int x = y_cb * pps->min_cb_width + x_cb; | |
135 | |||
136 |
2/2✓ Branch 0 taken 16706056 times.
✓ Branch 1 taken 3551944 times.
|
20258000 | for (int y = 0; y < (cb_height >> log2_min_cb_size); y++) { |
137 | 16706056 | const int width = cb_width >> log2_min_cb_size; | |
138 | |||
139 | 16706056 | memset(&tab[x], v, width); | |
140 | 16706056 | x += pps->min_cb_width; | |
141 | } | ||
142 | 3551944 | } | |
143 | |||
144 | 947875 | static int set_qp_y(VVCLocalContext *lc, const int x0, const int y0, const int has_qp_delta) | |
145 | { | ||
146 | 947875 | const VVCSPS *sps = lc->fc->ps.sps; | |
147 | 947875 | EntryPoint *ep = lc->ep; | |
148 | 947875 | CodingUnit *cu = lc->cu; | |
149 | 947875 | int cu_qp_delta = 0; | |
150 | |||
151 |
2/2✓ Branch 0 taken 922979 times.
✓ Branch 1 taken 24896 times.
|
947875 | if (!lc->fc->ps.pps->r->pps_cu_qp_delta_enabled_flag) { |
152 | 922979 | ep->qp_y = lc->sc->sh.slice_qp_y; | |
153 |
6/6✓ Branch 0 taken 24835 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 2819 times.
✓ Branch 3 taken 22016 times.
✓ Branch 4 taken 427 times.
✓ Branch 5 taken 2392 times.
|
24896 | } else if (ep->is_first_qg || (lc->parse.cu_qg_top_left_x == x0 && lc->parse.cu_qg_top_left_y == y0)) { |
154 | 488 | ep->qp_y = get_qp_y_pred(lc); | |
155 | 488 | ep->is_first_qg = 0; | |
156 | } | ||
157 | |||
158 |
2/2✓ Branch 0 taken 376 times.
✓ Branch 1 taken 947499 times.
|
947875 | if (has_qp_delta) { |
159 | 376 | const int cu_qp_delta_abs = ff_vvc_cu_qp_delta_abs(lc); | |
160 | |||
161 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
|
376 | if (cu_qp_delta_abs) |
162 | ✗ | cu_qp_delta = ff_vvc_cu_qp_delta_sign_flag(lc) ? -cu_qp_delta_abs : cu_qp_delta_abs; | |
163 |
2/4✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 376 times.
|
376 | if (cu_qp_delta > (31 + sps->qp_bd_offset / 2) || cu_qp_delta < -(32 + sps->qp_bd_offset / 2)) |
164 | ✗ | return AVERROR_INVALIDDATA; | |
165 | 376 | lc->parse.is_cu_qp_delta_coded = 1; | |
166 | |||
167 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
|
376 | if (cu_qp_delta) { |
168 | ✗ | int off = sps->qp_bd_offset; | |
169 | ✗ | ep->qp_y = FFUMOD(ep->qp_y + cu_qp_delta + 64 + 2 * off, 64 + off) - off; | |
170 | } | ||
171 | } | ||
172 | |||
173 | 947875 | set_cb_tab(lc, lc->fc->tab.qp[LUMA], ep->qp_y); | |
174 | 947875 | cu->qp[LUMA] = ep->qp_y; | |
175 | |||
176 | 947875 | return 0; | |
177 | } | ||
178 | |||
179 | 1257842 | static void set_qp_c_tab(const VVCLocalContext *lc, const TransformUnit *tu, const TransformBlock *tb) | |
180 | { | ||
181 |
6/6✓ Branch 0 taken 51716 times.
✓ Branch 1 taken 1206126 times.
✓ Branch 2 taken 41100 times.
✓ Branch 3 taken 10616 times.
✓ Branch 4 taken 19834 times.
✓ Branch 5 taken 21266 times.
|
1257842 | const int is_jcbcr = tu->joint_cbcr_residual_flag && tu->coded_flag[CB] && tu->coded_flag[CR]; |
182 |
2/2✓ Branch 0 taken 1238008 times.
✓ Branch 1 taken 19834 times.
|
1257842 | const int idx = is_jcbcr ? JCBCR : tb->c_idx; |
183 | |||
184 | 1257842 | set_tb_tab(lc->fc->tab.qp[tb->c_idx], lc->cu->qp[idx], lc->fc, tb); | |
185 | 1257842 | } | |
186 | |||
187 | 898121 | static void set_qp_c(VVCLocalContext *lc) | |
188 | { | ||
189 | 898121 | const VVCFrameContext *fc = lc->fc; | |
190 | 898121 | const VVCSPS *sps = fc->ps.sps; | |
191 | 898121 | const VVCPPS *pps = fc->ps.pps; | |
192 | 898121 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
193 | 898121 | CodingUnit *cu = lc->cu; | |
194 | 898121 | const int x_center = cu->x0 + cu->cb_width / 2; | |
195 | 898121 | const int y_center = cu->y0 + cu->cb_height / 2; | |
196 | 898121 | const int single_tree = cu->tree_type == SINGLE_TREE; | |
197 |
2/2✓ Branch 0 taken 429800 times.
✓ Branch 1 taken 468321 times.
|
898121 | const int qp_luma = (single_tree ? lc->ep->qp_y : ff_vvc_get_qPy(fc, x_center, y_center)) + sps->qp_bd_offset; |
198 | 898121 | const int qp_chroma = av_clip(qp_luma, 0, MAX_QP + sps->qp_bd_offset); | |
199 | 898121 | const int sh_chroma_qp_offset[] = { | |
200 | 898121 | rsh->sh_cb_qp_offset, | |
201 | 898121 | rsh->sh_cr_qp_offset, | |
202 | 898121 | rsh->sh_joint_cbcr_qp_offset, | |
203 | }; | ||
204 | int qp; | ||
205 | |||
206 |
2/2✓ Branch 0 taken 2677327 times.
✓ Branch 1 taken 898121 times.
|
3575448 | for (int i = CB - 1; i < CR + sps->r->sps_joint_cbcr_enabled_flag; i++) { |
207 | 2677327 | qp = sps->chroma_qp_table[i][qp_chroma]; | |
208 | 2677327 | qp = qp + pps->chroma_qp_offset[i] + sh_chroma_qp_offset[i] + lc->parse.chroma_qp_offset[i]; | |
209 | 2677327 | qp = av_clip(qp, -sps->qp_bd_offset, MAX_QP) + sps->qp_bd_offset; | |
210 | 2677327 | cu->qp[i + 1] = qp; | |
211 | } | ||
212 | 898121 | } | |
213 | |||
214 | 1126470 | static TransformUnit* alloc_tu(VVCFrameContext *fc, CodingUnit *cu) | |
215 | { | ||
216 | 1126470 | TransformUnit *tu = ff_refstruct_pool_get(fc->tu_pool); | |
217 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1126470 times.
|
1126470 | if (!tu) |
218 | ✗ | return NULL; | |
219 | |||
220 | 1126470 | tu->next = NULL; | |
221 | |||
222 |
2/2✓ Branch 0 taken 211042 times.
✓ Branch 1 taken 915428 times.
|
1126470 | if (cu->tus.tail) |
223 | 211042 | cu->tus.tail->next = tu; | |
224 | else | ||
225 | 915428 | cu->tus.head = tu; | |
226 | 1126470 | cu->tus.tail = tu; | |
227 | |||
228 | 1126470 | return tu; | |
229 | } | ||
230 | |||
231 | 1126470 | static TransformUnit* add_tu(VVCFrameContext *fc, CodingUnit *cu, const int x0, const int y0, const int tu_width, const int tu_height) | |
232 | { | ||
233 | 1126470 | TransformUnit *tu = alloc_tu(fc, cu); | |
234 | |||
235 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1126470 times.
|
1126470 | if (!tu) |
236 | ✗ | return NULL; | |
237 | |||
238 | 1126470 | tu->x0 = x0; | |
239 | 1126470 | tu->y0 = y0; | |
240 | 1126470 | tu->width = tu_width; | |
241 | 1126470 | tu->height = tu_height; | |
242 | 1126470 | tu->joint_cbcr_residual_flag = 0; | |
243 | 1126470 | memset(tu->coded_flag, 0, sizeof(tu->coded_flag)); | |
244 | 1126470 | tu->nb_tbs = 0; | |
245 | |||
246 | 1126470 | return tu; | |
247 | } | ||
248 | |||
249 | 2267788 | static TransformBlock* add_tb(TransformUnit *tu, VVCLocalContext *lc, | |
250 | const int x0, const int y0, const int tb_width, const int tb_height, const int c_idx) | ||
251 | { | ||
252 | TransformBlock *tb; | ||
253 | |||
254 | 2267788 | tb = &tu->tbs[tu->nb_tbs++]; | |
255 | 2267788 | tb->has_coeffs = 0; | |
256 | 2267788 | tb->x0 = x0; | |
257 | 2267788 | tb->y0 = y0; | |
258 | 2267788 | tb->tb_width = tb_width; | |
259 | 2267788 | tb->tb_height = tb_height; | |
260 | 2267788 | tb->log2_tb_width = av_log2(tb_width); | |
261 | 2267788 | tb->log2_tb_height = av_log2(tb_height); | |
262 | |||
263 | 2267788 | tb->max_scan_x = tb->max_scan_y = 0; | |
264 | 2267788 | tb->min_scan_x = tb->min_scan_y = 0; | |
265 | |||
266 | 2267788 | tb->c_idx = c_idx; | |
267 | 2267788 | tb->ts = 0; | |
268 | 2267788 | tb->coeffs = lc->coeffs; | |
269 | 2267788 | lc->coeffs += tb_width * tb_height; | |
270 | 2267788 | return tb; | |
271 | } | ||
272 | |||
273 | 687945 | static uint8_t tu_y_coded_flag_decode(VVCLocalContext *lc, const int is_sbt_not_coded, | |
274 | const int sub_tu_index, const int is_isp, const int is_chroma_coded) | ||
275 | { | ||
276 | 687945 | uint8_t tu_y_coded_flag = 0; | |
277 | 687945 | const VVCSPS *sps = lc->fc->ps.sps; | |
278 | 687945 | CodingUnit *cu = lc->cu; | |
279 | |||
280 |
2/2✓ Branch 0 taken 650837 times.
✓ Branch 1 taken 37108 times.
|
687945 | if (!is_sbt_not_coded) { |
281 |
4/4✓ Branch 0 taken 540720 times.
✓ Branch 1 taken 110117 times.
✓ Branch 2 taken 38899 times.
✓ Branch 3 taken 501821 times.
|
650837 | int has_y_coded_flag = sub_tu_index < cu->num_intra_subpartitions - 1 || !lc->parse.infer_tu_cbf_luma; |
282 |
2/2✓ Branch 0 taken 492779 times.
✓ Branch 1 taken 158058 times.
|
650837 | if (!is_isp) { |
283 |
4/4✓ Branch 0 taken 490595 times.
✓ Branch 1 taken 2184 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 490123 times.
|
492779 | const int is_large = cu->cb_width > sps->max_tb_size_y || cu->cb_height > sps->max_tb_size_y; |
284 |
7/8✓ Branch 0 taken 355313 times.
✓ Branch 1 taken 137466 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 355313 times.
✓ Branch 4 taken 99330 times.
✓ Branch 5 taken 38136 times.
✓ Branch 6 taken 2259 times.
✓ Branch 7 taken 97071 times.
|
492779 | has_y_coded_flag = (cu->pred_mode == MODE_INTRA && !cu->act_enabled_flag) || is_chroma_coded || is_large; |
285 | } | ||
286 |
2/2✓ Branch 0 taken 544724 times.
✓ Branch 1 taken 106113 times.
|
650837 | tu_y_coded_flag = has_y_coded_flag ? ff_vvc_tu_y_coded_flag(lc) : 1; |
287 | } | ||
288 |
2/2✓ Branch 0 taken 158058 times.
✓ Branch 1 taken 529887 times.
|
687945 | if (is_isp) |
289 |
4/4✓ Branch 0 taken 78501 times.
✓ Branch 1 taken 79557 times.
✓ Branch 2 taken 30560 times.
✓ Branch 3 taken 47941 times.
|
158058 | lc->parse.infer_tu_cbf_luma = lc->parse.infer_tu_cbf_luma && !tu_y_coded_flag; |
290 | 687945 | return tu_y_coded_flag; | |
291 | } | ||
292 | |||
293 | 360539 | static void chroma_qp_offset_decode(VVCLocalContext *lc, const int is_128, const int is_chroma_coded) | |
294 | { | ||
295 | 360539 | const VVCPPS *pps = lc->fc->ps.pps; | |
296 | 360539 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
297 | |||
298 |
4/4✓ Branch 0 taken 357883 times.
✓ Branch 1 taken 2656 times.
✓ Branch 2 taken 119053 times.
✓ Branch 3 taken 238830 times.
|
360539 | if ((is_128 || is_chroma_coded) && |
299 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 121709 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
121709 | rsh->sh_cu_chroma_qp_offset_enabled_flag && !lc->parse.is_cu_chroma_qp_offset_coded) { |
300 | ✗ | const int cu_chroma_qp_offset_flag = ff_vvc_cu_chroma_qp_offset_flag(lc); | |
301 | ✗ | if (cu_chroma_qp_offset_flag) { | |
302 | ✗ | int cu_chroma_qp_offset_idx = 0; | |
303 | ✗ | if (pps->r->pps_chroma_qp_offset_list_len_minus1 > 0) | |
304 | ✗ | cu_chroma_qp_offset_idx = ff_vvc_cu_chroma_qp_offset_idx(lc); | |
305 | ✗ | for (int i = CB - 1; i < JCBCR; i++) | |
306 | ✗ | lc->parse.chroma_qp_offset[i] = pps->chroma_qp_offset_list[cu_chroma_qp_offset_idx][i]; | |
307 | } else { | ||
308 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
309 | } | ||
310 | ✗ | lc->parse.is_cu_chroma_qp_offset_coded = 1; | |
311 | } | ||
312 | 360539 | } | |
313 | |||
314 | 804469 | static int hls_transform_unit(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int sub_tu_index, int ch_type) | |
315 | { | ||
316 | 804469 | VVCFrameContext *fc = lc->fc; | |
317 | 804469 | const VVCSPS *sps = fc->ps.sps; | |
318 | 804469 | const VVCPPS *pps = fc->ps.pps; | |
319 | 804469 | CodingUnit *cu = lc->cu; | |
320 | 804469 | TransformUnit *tu = add_tu(fc, cu, x0, y0, tu_width, tu_height); | |
321 | 804469 | const int min_cb_width = pps->min_cb_width; | |
322 | 804469 | const VVCTreeType tree_type = cu->tree_type; | |
323 |
4/4✓ Branch 0 taken 802285 times.
✓ Branch 1 taken 2184 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 801813 times.
|
804469 | const int is_128 = cu->cb_width > 64 || cu->cb_height > 64; |
324 | 804469 | const int is_isp = cu->isp_split_type != ISP_NO_SPLIT; | |
325 |
4/4✓ Branch 0 taken 158058 times.
✓ Branch 1 taken 646411 times.
✓ Branch 2 taken 47941 times.
✓ Branch 3 taken 110117 times.
|
804469 | const int is_isp_last_tu = is_isp && (sub_tu_index == cu->num_intra_subpartitions - 1); |
326 |
4/4✓ Branch 0 taken 74216 times.
✓ Branch 1 taken 730253 times.
✓ Branch 2 taken 37108 times.
✓ Branch 3 taken 37108 times.
|
878685 | const int is_sbt_not_coded = cu->sbt_flag && |
327 |
6/6✓ Branch 0 taken 19439 times.
✓ Branch 1 taken 17669 times.
✓ Branch 2 taken 37108 times.
✓ Branch 3 taken 19439 times.
✓ Branch 4 taken 19439 times.
✓ Branch 5 taken 17669 times.
|
74216 | ((sub_tu_index == 0 && cu->sbt_pos_flag) || (sub_tu_index == 1 && !cu->sbt_pos_flag)); |
328 |
6/6✓ Branch 0 taken 360539 times.
✓ Branch 1 taken 443930 times.
✓ Branch 2 taken 339428 times.
✓ Branch 3 taken 21111 times.
✓ Branch 4 taken 20286 times.
✓ Branch 5 taken 319142 times.
|
824755 | const int chroma_available = tree_type != DUAL_TREE_LUMA && sps->r->sps_chroma_format_idc && |
329 |
2/2✓ Branch 0 taken 5085 times.
✓ Branch 1 taken 15201 times.
|
20286 | (!is_isp || is_isp_last_tu); |
330 | int ret, xc, yc, wc, hc, is_chroma_coded; | ||
331 | |||
332 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 804469 times.
|
804469 | if (!tu) |
333 | ✗ | return AVERROR_INVALIDDATA; | |
334 | |||
335 |
4/4✓ Branch 0 taken 244015 times.
✓ Branch 1 taken 560454 times.
✓ Branch 2 taken 6674 times.
✓ Branch 3 taken 237341 times.
|
804469 | if (tree_type == SINGLE_TREE && is_isp_last_tu) { |
336 | 6674 | const int x_cu = x0 >> fc->ps.sps->min_cb_log2_size_y; | |
337 | 6674 | const int y_cu = y0 >> fc->ps.sps->min_cb_log2_size_y; | |
338 | 6674 | xc = SAMPLE_CTB(fc->tab.cb_pos_x[ch_type], x_cu, y_cu); | |
339 | 6674 | yc = SAMPLE_CTB(fc->tab.cb_pos_y[ch_type], x_cu, y_cu); | |
340 | 6674 | wc = SAMPLE_CTB(fc->tab.cb_width[ch_type], x_cu, y_cu); | |
341 | 6674 | hc = SAMPLE_CTB(fc->tab.cb_height[ch_type], x_cu, y_cu); | |
342 | } else { | ||
343 | 797795 | xc = x0, yc = y0, wc = tu_width, hc = tu_height; | |
344 | } | ||
345 | |||
346 |
4/4✓ Branch 0 taken 324227 times.
✓ Branch 1 taken 480242 times.
✓ Branch 2 taken 288411 times.
✓ Branch 3 taken 35816 times.
|
804469 | if (chroma_available && !is_sbt_not_coded) { |
347 | 288411 | tu->coded_flag[CB] = ff_vvc_tu_cb_coded_flag(lc); | |
348 | 288411 | tu->coded_flag[CR] = ff_vvc_tu_cr_coded_flag(lc, tu->coded_flag[CB]); | |
349 | } | ||
350 | |||
351 |
6/6✓ Branch 0 taken 324227 times.
✓ Branch 1 taken 480242 times.
✓ Branch 2 taken 222499 times.
✓ Branch 3 taken 101728 times.
✓ Branch 4 taken 17722 times.
✓ Branch 5 taken 204777 times.
|
804469 | is_chroma_coded = chroma_available && (tu->coded_flag[CB] || tu->coded_flag[CR]); |
352 | |||
353 |
2/2✓ Branch 0 taken 687945 times.
✓ Branch 1 taken 116524 times.
|
804469 | if (tree_type != DUAL_TREE_CHROMA) { |
354 | int has_qp_delta; | ||
355 | 687945 | tu->coded_flag[LUMA] = tu_y_coded_flag_decode(lc, is_sbt_not_coded, sub_tu_index, is_isp, is_chroma_coded); | |
356 |
4/4✓ Branch 0 taken 166916 times.
✓ Branch 1 taken 518373 times.
✓ Branch 2 taken 24006 times.
✓ Branch 3 taken 142910 times.
|
685289 | has_qp_delta = (is_128 || tu->coded_flag[LUMA] || is_chroma_coded) && |
357 |
6/6✓ Branch 0 taken 685289 times.
✓ Branch 1 taken 2656 times.
✓ Branch 2 taken 13787 times.
✓ Branch 3 taken 531248 times.
✓ Branch 4 taken 376 times.
✓ Branch 5 taken 13411 times.
|
1373234 | pps->r->pps_cu_qp_delta_enabled_flag && !lc->parse.is_cu_qp_delta_coded; |
358 | 687945 | ret = set_qp_y(lc, x0, y0, has_qp_delta); | |
359 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 687945 times.
|
687945 | if (ret < 0) |
360 | ✗ | return ret; | |
361 | 687945 | add_tb(tu, lc, x0, y0, tu_width, tu_height, LUMA); | |
362 | } | ||
363 |
2/2✓ Branch 0 taken 360539 times.
✓ Branch 1 taken 443930 times.
|
804469 | if (tree_type != DUAL_TREE_LUMA) { |
364 | 360539 | chroma_qp_offset_decode(lc, is_128, is_chroma_coded); | |
365 |
2/2✓ Branch 0 taken 324227 times.
✓ Branch 1 taken 36312 times.
|
360539 | if (chroma_available) { |
366 | 324227 | const int hs = sps->hshift[CHROMA]; | |
367 | 324227 | const int vs = sps->vshift[CHROMA]; | |
368 | 324227 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CB); | |
369 | 324227 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CR); | |
370 | } | ||
371 | } | ||
372 |
4/4✓ Branch 0 taken 783358 times.
✓ Branch 1 taken 21111 times.
✓ Branch 2 taken 614082 times.
✓ Branch 3 taken 169276 times.
|
804469 | if (sps->r->sps_joint_cbcr_enabled_flag && ((cu->pred_mode == MODE_INTRA && |
373 |
4/4✓ Branch 0 taken 547415 times.
✓ Branch 1 taken 66667 times.
✓ Branch 2 taken 532768 times.
✓ Branch 3 taken 14647 times.
|
614082 | (tu->coded_flag[CB] || tu->coded_flag[CR])) || |
374 |
5/6✓ Branch 0 taken 35061 times.
✓ Branch 1 taken 666983 times.
✓ Branch 2 taken 4165 times.
✓ Branch 3 taken 30896 times.
✓ Branch 4 taken 85479 times.
✗ Branch 5 not taken.
|
783358 | (tu->coded_flag[CB] && tu->coded_flag[CR])) && |
375 | chroma_available) { | ||
376 | 85479 | tu->joint_cbcr_residual_flag = ff_vvc_tu_joint_cbcr_residual_flag(lc, tu->coded_flag[1], tu->coded_flag[2]); | |
377 | } | ||
378 | |||
379 |
2/2✓ Branch 0 taken 1336399 times.
✓ Branch 1 taken 804469 times.
|
2140868 | for (int i = 0; i < tu->nb_tbs; i++) { |
380 | 1336399 | TransformBlock *tb = &tu->tbs[i]; | |
381 | 1336399 | const int is_chroma = tb->c_idx != LUMA; | |
382 | 1336399 | tb->has_coeffs = tu->coded_flag[tb->c_idx]; | |
383 |
4/4✓ Branch 0 taken 682847 times.
✓ Branch 1 taken 653552 times.
✓ Branch 2 taken 162601 times.
✓ Branch 3 taken 520246 times.
|
1336399 | if (tb->has_coeffs && is_chroma) |
384 |
6/6✓ Branch 0 taken 60873 times.
✓ Branch 1 taken 101728 times.
✓ Branch 2 taken 43151 times.
✓ Branch 3 taken 17722 times.
✓ Branch 4 taken 33234 times.
✓ Branch 5 taken 9917 times.
|
162601 | tb->has_coeffs = tb->c_idx == CB ? 1 : !(tu->coded_flag[CB] && tu->joint_cbcr_residual_flag); |
385 |
2/2✓ Branch 0 taken 672930 times.
✓ Branch 1 taken 663469 times.
|
1336399 | if (tb->has_coeffs) { |
386 | 672930 | tb->ts = cu->bdpcm_flag[tb->c_idx]; | |
387 |
4/4✓ Branch 0 taken 669840 times.
✓ Branch 1 taken 3090 times.
✓ Branch 2 taken 669831 times.
✓ Branch 3 taken 9 times.
|
672930 | if (sps->r->sps_transform_skip_enabled_flag && !cu->bdpcm_flag[tb->c_idx] && |
388 |
4/4✓ Branch 0 taken 655002 times.
✓ Branch 1 taken 14829 times.
✓ Branch 2 taken 648295 times.
✓ Branch 3 taken 6707 times.
|
669831 | tb->tb_width <= sps->max_ts_size && tb->tb_height <= sps->max_ts_size && |
389 |
6/6✓ Branch 0 taken 608870 times.
✓ Branch 1 taken 39425 times.
✓ Branch 2 taken 470280 times.
✓ Branch 3 taken 138590 times.
✓ Branch 4 taken 366852 times.
✓ Branch 5 taken 103428 times.
|
648295 | !cu->sbt_flag && (is_chroma || !is_isp)) { |
390 | 505442 | tb->ts = ff_vvc_transform_skip_flag(lc, is_chroma); | |
391 | } | ||
392 | 672930 | ret = ff_vvc_residual_coding(lc, tb); | |
393 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 672930 times.
|
672930 | if (ret < 0) |
394 | ✗ | return ret; | |
395 | 672930 | set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], tu->coded_flag[tb->c_idx], fc, tb); | |
396 | } | ||
397 |
2/2✓ Branch 0 taken 1012172 times.
✓ Branch 1 taken 324227 times.
|
1336399 | if (tb->c_idx != CR) |
398 | 1012172 | set_tb_pos(fc, tb); | |
399 |
2/2✓ Branch 0 taken 324227 times.
✓ Branch 1 taken 1012172 times.
|
1336399 | if (tb->c_idx == CB) |
400 | 324227 | set_tb_tab(fc->tab.tu_joint_cbcr_residual_flag, tu->joint_cbcr_residual_flag, fc, tb); | |
401 | } | ||
402 | |||
403 | 804469 | return 0; | |
404 | } | ||
405 | |||
406 | 658990 | static int hls_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int ch_type) | |
407 | { | ||
408 | 658990 | const CodingUnit *cu = lc->cu; | |
409 | 658990 | const VVCSPS *sps = lc->fc->ps.sps; | |
410 | int ret; | ||
411 | |||
412 | 658990 | lc->parse.infer_tu_cbf_luma = 1; | |
413 |
4/4✓ Branch 0 taken 611049 times.
✓ Branch 1 taken 47941 times.
✓ Branch 2 taken 573941 times.
✓ Branch 3 taken 37108 times.
|
658990 | if (cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag) { |
414 |
4/4✓ Branch 0 taken 572431 times.
✓ Branch 1 taken 1510 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 572195 times.
|
575687 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
415 |
4/4✓ Branch 0 taken 1510 times.
✓ Branch 1 taken 236 times.
✓ Branch 2 taken 1092 times.
✓ Branch 3 taken 418 times.
|
1746 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
416 |
2/2✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 654 times.
|
1746 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
417 |
2/2✓ Branch 0 taken 654 times.
✓ Branch 1 taken 1092 times.
|
1746 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
418 | |||
419 | #define TRANSFORM_TREE(x, y) do { \ | ||
420 | ret = hls_transform_tree(lc, x, y, trafo_width, trafo_height, ch_type); \ | ||
421 | if (ret < 0) \ | ||
422 | return ret; \ | ||
423 | } while (0) | ||
424 | |||
425 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1746 times.
|
1746 | TRANSFORM_TREE(x0, y0); |
426 |
2/2✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 654 times.
|
1746 | if (ver_split_first) |
427 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1092 times.
|
1092 | TRANSFORM_TREE(x0 + trafo_width, y0); |
428 | else | ||
429 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 654 times.
|
654 | TRANSFORM_TREE(x0, y0 + trafo_height); |
430 | |||
431 | } else { | ||
432 | 572195 | ret = hls_transform_unit(lc, x0, y0, tu_width, tu_height, 0, ch_type); | |
433 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 572195 times.
|
572195 | if (ret < 0) |
434 | ✗ | return ret; | |
435 | |||
436 | } | ||
437 |
2/2✓ Branch 0 taken 37108 times.
✓ Branch 1 taken 47941 times.
|
85049 | } else if (cu->sbt_flag) { |
438 |
2/2✓ Branch 0 taken 19353 times.
✓ Branch 1 taken 17755 times.
|
37108 | if (!cu->sbt_horizontal_flag) { |
439 | #define TRANSFORM_UNIT(x, width, idx) do { \ | ||
440 | ret = hls_transform_unit(lc, x, y0, width, tu_height, idx, ch_type); \ | ||
441 | if (ret < 0) \ | ||
442 | return ret; \ | ||
443 | } while (0) | ||
444 | |||
445 | 19353 | const int trafo_width = tu_width * lc->parse.sbt_num_fourths_tb0 / 4; | |
446 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19353 times.
|
19353 | TRANSFORM_UNIT(x0, trafo_width, 0); |
447 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19353 times.
|
19353 | TRANSFORM_UNIT(x0 + trafo_width, tu_width - trafo_width, 1); |
448 | |||
449 | #undef TRANSFORM_UNIT | ||
450 | } else { | ||
451 | #define TRANSFORM_UNIT(y, height, idx) do { \ | ||
452 | ret = hls_transform_unit(lc, x0, y, tu_width, height, idx, ch_type); \ | ||
453 | if (ret < 0) \ | ||
454 | return ret; \ | ||
455 | } while (0) | ||
456 | |||
457 | 17755 | const int trafo_height = tu_height * lc->parse.sbt_num_fourths_tb0 / 4; | |
458 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 17755 times.
|
17755 | TRANSFORM_UNIT(y0, trafo_height, 0); |
459 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 17755 times.
|
17755 | TRANSFORM_UNIT(y0 + trafo_height, tu_height - trafo_height, 1); |
460 | |||
461 | #undef TRANSFORM_UNIT | ||
462 | } | ||
463 |
2/2✓ Branch 0 taken 29819 times.
✓ Branch 1 taken 18122 times.
|
47941 | } else if (cu->isp_split_type == ISP_HOR_SPLIT) { |
464 | 29819 | const int trafo_height = tu_height / cu->num_intra_subpartitions; | |
465 |
2/2✓ Branch 0 taken 101356 times.
✓ Branch 1 taken 29819 times.
|
131175 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
466 | 101356 | ret = hls_transform_unit(lc, x0, y0 + trafo_height * i, tu_width, trafo_height, i, 0); | |
467 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 101356 times.
|
101356 | if (ret < 0) |
468 | ✗ | return ret; | |
469 | } | ||
470 |
1/2✓ Branch 0 taken 18122 times.
✗ Branch 1 not taken.
|
18122 | } else if (cu->isp_split_type == ISP_VER_SPLIT) { |
471 | 18122 | const int trafo_width = tu_width / cu->num_intra_subpartitions; | |
472 |
2/2✓ Branch 0 taken 56702 times.
✓ Branch 1 taken 18122 times.
|
74824 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
473 | 56702 | ret = hls_transform_unit(lc, x0 + trafo_width * i , y0, trafo_width, tu_height, i, 0); | |
474 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56702 times.
|
56702 | if (ret < 0) |
475 | ✗ | return ret; | |
476 | } | ||
477 | } | ||
478 | |||
479 | 658990 | return 0; | |
480 | } | ||
481 | |||
482 | 384072 | static int skipped_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height) | |
483 | { | ||
484 | 384072 | VVCFrameContext *fc = lc->fc; | |
485 | 384072 | const CodingUnit *cu = lc->cu; | |
486 | 384072 | const VVCSPS *sps = fc->ps.sps; | |
487 | |||
488 |
4/4✓ Branch 0 taken 323910 times.
✓ Branch 1 taken 60162 times.
✓ Branch 2 taken 1909 times.
✓ Branch 3 taken 322001 times.
|
446143 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
489 |
4/4✓ Branch 0 taken 60162 times.
✓ Branch 1 taken 1909 times.
✓ Branch 2 taken 40722 times.
✓ Branch 3 taken 19440 times.
|
62071 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
490 |
2/2✓ Branch 0 taken 40722 times.
✓ Branch 1 taken 21349 times.
|
62071 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
491 |
2/2✓ Branch 0 taken 21349 times.
✓ Branch 1 taken 40722 times.
|
62071 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
492 | |||
493 | #define SKIPPED_TRANSFORM_TREE(x, y) do { \ | ||
494 | int ret = skipped_transform_tree(lc, x, y, trafo_width, trafo_height); \ | ||
495 | if (ret < 0) \ | ||
496 | return ret; \ | ||
497 | } while (0) | ||
498 | |||
499 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 62071 times.
|
62071 | SKIPPED_TRANSFORM_TREE(x0, y0); |
500 |
2/2✓ Branch 0 taken 40722 times.
✓ Branch 1 taken 21349 times.
|
62071 | if (ver_split_first) |
501 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 40722 times.
|
40722 | SKIPPED_TRANSFORM_TREE(x0 + trafo_width, y0); |
502 | else | ||
503 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21349 times.
|
21349 | SKIPPED_TRANSFORM_TREE(x0, y0 + trafo_height); |
504 | } else { | ||
505 | 322001 | TransformUnit *tu = add_tu(fc, lc->cu, x0, y0, tu_width, tu_height); | |
506 |
4/4✓ Branch 0 taken 305490 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 304694 times.
✓ Branch 3 taken 796 times.
|
322001 | const int has_chroma = sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA; |
507 | 322001 | const int c_start = cu->tree_type == DUAL_TREE_CHROMA ? CB : LUMA; | |
508 |
2/2✓ Branch 0 taken 304694 times.
✓ Branch 1 taken 17307 times.
|
322001 | const int c_end = has_chroma ? VVC_MAX_SAMPLE_ARRAYS : CB; |
509 | |||
510 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 322001 times.
|
322001 | if (!tu) |
511 | ✗ | return AVERROR_INVALIDDATA; | |
512 |
2/2✓ Branch 0 taken 931389 times.
✓ Branch 1 taken 322001 times.
|
1253390 | for (int i = c_start; i < c_end; i++) { |
513 | 931389 | TransformBlock *tb = add_tb(tu, lc, x0, y0, tu_width >> sps->hshift[i], tu_height >> sps->vshift[i], i); | |
514 |
2/2✓ Branch 0 taken 626695 times.
✓ Branch 1 taken 304694 times.
|
931389 | if (i != CR) |
515 | 626695 | set_tb_pos(fc, tb); | |
516 | } | ||
517 | } | ||
518 | |||
519 | 384072 | return 0; | |
520 | } | ||
521 | |||
522 | //6.4.1 Allowed quad split process | ||
523 | //6.4.2 Allowed binary split process | ||
524 | //6.4.3 Allowed ternary split process | ||
525 | 1509458 | static void can_split(const VVCLocalContext *lc, int x0, int y0,int cb_width, int cb_height, | |
526 | int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, | ||
527 | VVCTreeType tree_type, VVCModeType mode_type, VVCAllowedSplit* split) | ||
528 | { | ||
529 | int min_qt_size, max_bt_size, max_tt_size, max_mtt_depth; | ||
530 | 1509458 | const VVCFrameContext *fc = lc->fc; | |
531 | 1509458 | const VVCSH *sh = &lc->sc->sh; | |
532 | 1509458 | const VVCSPS *sps = fc->ps.sps; | |
533 | 1509458 | const VVCPPS *pps = fc->ps.pps; | |
534 | 1509458 | const int chroma = tree_type == DUAL_TREE_CHROMA; | |
535 | 1509458 | int min_cb_size_y = sps->min_cb_size_y; | |
536 | 1509458 | int *qt = &split->qt; | |
537 | 1509458 | int *btv = &split->btv; | |
538 | 1509458 | int *bth = &split->bth; | |
539 | 1509458 | int *ttv = &split->ttv; | |
540 | 1509458 | int *tth = &split->tth; | |
541 | |||
542 | 1509458 | *qt = *bth = *btv = *tth = *ttv = 1; | |
543 | |||
544 |
2/2✓ Branch 0 taken 1137059 times.
✓ Branch 1 taken 372399 times.
|
1509458 | if (mtt_depth) |
545 | 1137059 | *qt = 0; | |
546 | |||
547 | 1509458 | min_qt_size = sh->min_qt_size[chroma]; | |
548 |
2/2✓ Branch 0 taken 548285 times.
✓ Branch 1 taken 961173 times.
|
1509458 | if (cb_width <= min_qt_size) |
549 | 548285 | *qt = 0; | |
550 | |||
551 |
2/2✓ Branch 0 taken 186683 times.
✓ Branch 1 taken 1322775 times.
|
1509458 | if (chroma) { |
552 | 186683 | int chroma_area = (cb_width >> sps->hshift[1]) * (cb_height >> sps->vshift[1]); | |
553 | 186683 | int chroma_width = cb_width >> sps->hshift[1]; | |
554 | |||
555 |
2/2✓ Branch 0 taken 54834 times.
✓ Branch 1 taken 131849 times.
|
186683 | if (chroma_width == 8) |
556 | 54834 | *ttv = 0; | |
557 |
2/2✓ Branch 0 taken 41938 times.
✓ Branch 1 taken 89911 times.
|
131849 | else if (chroma_width <= 4) { |
558 |
1/2✓ Branch 0 taken 41938 times.
✗ Branch 1 not taken.
|
41938 | if (chroma_width == 4) |
559 | 41938 | *btv = 0; | |
560 | 41938 | *qt = 0; | |
561 | } | ||
562 |
2/2✓ Branch 0 taken 8194 times.
✓ Branch 1 taken 178489 times.
|
186683 | if (mode_type == MODE_TYPE_INTRA) |
563 | 8194 | *qt = *btv = *bth = *ttv = *tth = 0; | |
564 |
2/2✓ Branch 0 taken 59164 times.
✓ Branch 1 taken 127519 times.
|
186683 | if (chroma_area <= 32) { |
565 | 59164 | *ttv = *tth = 0; | |
566 |
2/2✓ Branch 0 taken 23952 times.
✓ Branch 1 taken 35212 times.
|
59164 | if (chroma_area <= 16) |
567 | 23952 | *btv = *bth = 0; | |
568 | } | ||
569 | } | ||
570 | 1509458 | max_bt_size = sh->max_bt_size[chroma]; | |
571 | 1509458 | max_tt_size = sh->max_tt_size[chroma]; | |
572 | 1509458 | max_mtt_depth = sh->max_mtt_depth[chroma] + depth_offset; | |
573 | |||
574 |
2/2✓ Branch 0 taken 59728 times.
✓ Branch 1 taken 1449730 times.
|
1509458 | if (mode_type == MODE_TYPE_INTER) { |
575 | 59728 | int area = cb_width * cb_height; | |
576 |
2/2✓ Branch 0 taken 22842 times.
✓ Branch 1 taken 36886 times.
|
59728 | if (area == 32) |
577 | 22842 | *btv = *bth = 0; | |
578 |
2/2✓ Branch 0 taken 21682 times.
✓ Branch 1 taken 15204 times.
|
36886 | else if (area == 64) |
579 | 21682 | *ttv = *tth = 0; | |
580 | } | ||
581 |
2/2✓ Branch 0 taken 556176 times.
✓ Branch 1 taken 953282 times.
|
1509458 | if (cb_width <= 2 * min_cb_size_y) { |
582 | 556176 | *ttv = 0; | |
583 |
2/2✓ Branch 0 taken 184749 times.
✓ Branch 1 taken 371427 times.
|
556176 | if (cb_width <= min_cb_size_y) |
584 | 184749 | *btv = 0; | |
585 | } | ||
586 |
2/2✓ Branch 0 taken 597003 times.
✓ Branch 1 taken 912455 times.
|
1509458 | if (cb_height <= 2 * min_cb_size_y) { |
587 | 597003 | *tth = 0; | |
588 |
2/2✓ Branch 0 taken 208179 times.
✓ Branch 1 taken 388824 times.
|
597003 | if (cb_height <= min_cb_size_y) |
589 | 208179 | *bth = 0; | |
590 | } | ||
591 |
4/4✓ Branch 0 taken 1485099 times.
✓ Branch 1 taken 24359 times.
✓ Branch 2 taken 590 times.
✓ Branch 3 taken 1484509 times.
|
1509458 | if (cb_width > max_bt_size || cb_height > max_bt_size) |
592 | 24949 | *btv = *bth = 0; | |
593 | 1509458 | max_tt_size = FFMIN(64, max_tt_size); | |
594 |
4/4✓ Branch 0 taken 1425172 times.
✓ Branch 1 taken 84286 times.
✓ Branch 2 taken 6867 times.
✓ Branch 3 taken 1418305 times.
|
1509458 | if (cb_width > max_tt_size || cb_height > max_tt_size) |
595 | 91153 | *ttv = *tth = 0; | |
596 |
2/2✓ Branch 0 taken 309513 times.
✓ Branch 1 taken 1199945 times.
|
1509458 | if (mtt_depth >= max_mtt_depth) |
597 | 309513 | *btv = *bth = *ttv = *tth = 0; | |
598 |
2/2✓ Branch 0 taken 3849 times.
✓ Branch 1 taken 1505609 times.
|
1509458 | if (x0 + cb_width > pps->width) { |
599 | 3849 | *ttv = *tth = 0; | |
600 |
2/2✓ Branch 0 taken 1314 times.
✓ Branch 1 taken 2535 times.
|
3849 | if (cb_height > 64) |
601 | 1314 | *btv = 0; | |
602 |
2/2✓ Branch 0 taken 2743 times.
✓ Branch 1 taken 1106 times.
|
3849 | if (y0 + cb_height <= pps->height) |
603 | 2743 | *bth = 0; | |
604 |
1/2✓ Branch 0 taken 1106 times.
✗ Branch 1 not taken.
|
1106 | else if (cb_width > min_qt_size) |
605 | 1106 | *btv = *bth = 0; | |
606 | } | ||
607 |
2/2✓ Branch 0 taken 45567 times.
✓ Branch 1 taken 1463891 times.
|
1509458 | if (y0 + cb_height > pps->height) { |
608 | 45567 | *btv = *ttv = *tth = 0; | |
609 |
2/2✓ Branch 0 taken 6134 times.
✓ Branch 1 taken 39433 times.
|
45567 | if (cb_width > 64) |
610 | 6134 | *bth = 0; | |
611 | } | ||
612 |
4/4✓ Branch 0 taken 1137059 times.
✓ Branch 1 taken 372399 times.
✓ Branch 2 taken 497487 times.
✓ Branch 3 taken 639572 times.
|
1509458 | if (mtt_depth > 0 && part_idx == 1) { |
613 |
2/2✓ Branch 0 taken 58530 times.
✓ Branch 1 taken 438957 times.
|
497487 | if (last_split_mode == SPLIT_TT_VER) |
614 | 58530 | *btv = 0; | |
615 |
2/2✓ Branch 0 taken 60249 times.
✓ Branch 1 taken 378708 times.
|
438957 | else if (last_split_mode == SPLIT_TT_HOR) |
616 | 60249 | *bth = 0; | |
617 | } | ||
618 |
4/4✓ Branch 0 taken 1467798 times.
✓ Branch 1 taken 41660 times.
✓ Branch 2 taken 2978 times.
✓ Branch 3 taken 1464820 times.
|
1509458 | if (cb_width <= 64 && cb_height > 64) |
619 | 2978 | *btv = 0; | |
620 |
4/4✓ Branch 0 taken 41660 times.
✓ Branch 1 taken 1467798 times.
✓ Branch 2 taken 2946 times.
✓ Branch 3 taken 38714 times.
|
1509458 | if (cb_width > 64 && cb_height <= 64) |
621 | 2946 | *bth = 0; | |
622 | 1509458 | } | |
623 | |||
624 | 328269 | static int get_num_intra_subpartitions(enum IspType isp_split_type, int cb_width, int cb_height) | |
625 | { | ||
626 |
2/2✓ Branch 0 taken 280328 times.
✓ Branch 1 taken 47941 times.
|
328269 | if (isp_split_type == ISP_NO_SPLIT) |
627 | 280328 | return 1; | |
628 |
8/8✓ Branch 0 taken 11158 times.
✓ Branch 1 taken 36783 times.
✓ Branch 2 taken 3194 times.
✓ Branch 3 taken 7964 times.
✓ Branch 4 taken 16631 times.
✓ Branch 5 taken 23346 times.
✓ Branch 6 taken 8889 times.
✓ Branch 7 taken 7742 times.
|
47941 | if ((cb_width == 4 && cb_height == 8) || (cb_width == 8 && cb_height == 4)) |
629 | 16853 | return 2; | |
630 | 31088 | return 4; | |
631 | } | ||
632 | |||
633 | 155695 | static int get_cclm_enabled(const VVCLocalContext *lc, const int x0, const int y0) | |
634 | { | ||
635 | 155695 | const VVCFrameContext *fc = lc->fc; | |
636 | 155695 | const VVCSPS *sps = fc->ps.sps; | |
637 | 155695 | int enabled = 0; | |
638 | |||
639 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 155695 times.
|
155695 | if (!sps->r->sps_cclm_enabled_flag) |
640 | ✗ | return 0; | |
641 |
5/6✓ Branch 0 taken 155695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 108327 times.
✓ Branch 3 taken 47368 times.
✓ Branch 4 taken 868 times.
✓ Branch 5 taken 107459 times.
|
155695 | if (!sps->r->sps_qtbtt_dual_tree_intra_flag || !IS_I(lc->sc->sh.r) || sps->ctb_log2_size_y < 6) |
642 | 48236 | return 1; | |
643 | else { | ||
644 | 107459 | const int x64 = x0 >> 6 << 6; | |
645 | 107459 | const int y64 = y0 >> 6 << 6; | |
646 | 107459 | const int y32 = y0 >> 5 << 5; | |
647 | 107459 | const int x64_cu = x64 >> fc->ps.sps->min_cb_log2_size_y; | |
648 | 107459 | const int y64_cu = y64 >> fc->ps.sps->min_cb_log2_size_y; | |
649 | 107459 | const int y32_cu = y32 >> fc->ps.sps->min_cb_log2_size_y; | |
650 | 107459 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
651 | 107459 | const int depth = SAMPLE_CTB(fc->tab.cqt_depth[1], x64_cu, y64_cu); | |
652 | 107459 | const int min_depth = fc->ps.sps->ctb_log2_size_y - 6; | |
653 | 107459 | const VVCSplitMode msm64 = (VVCSplitMode)TAB_MSM(fc, 0, x64, y64); | |
654 | 107459 | const VVCSplitMode msm32 = (VVCSplitMode)TAB_MSM(fc, 1, x64, y32); | |
655 | |||
656 |
2/2✓ Branch 0 taken 14038 times.
✓ Branch 1 taken 93421 times.
|
121497 | enabled = SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y64_cu) == 64 && |
657 |
2/2✓ Branch 0 taken 4868 times.
✓ Branch 1 taken 9170 times.
|
14038 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y64_cu) == 64; |
658 |
2/2✓ Branch 0 taken 15299 times.
✓ Branch 1 taken 8862 times.
|
24161 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && |
659 |
4/4✓ Branch 0 taken 24161 times.
✓ Branch 1 taken 83298 times.
✓ Branch 2 taken 9156 times.
✓ Branch 3 taken 6143 times.
|
140776 | SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y32_cu) == 64 && |
660 |
2/2✓ Branch 0 taken 3559 times.
✓ Branch 1 taken 5597 times.
|
9156 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y32_cu) == 32; |
661 | 107459 | enabled |= depth > min_depth; | |
662 |
6/6✓ Branch 0 taken 24161 times.
✓ Branch 1 taken 83298 times.
✓ Branch 2 taken 15299 times.
✓ Branch 3 taken 8862 times.
✓ Branch 4 taken 5442 times.
✓ Branch 5 taken 9857 times.
|
107459 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && msm32 == SPLIT_BT_VER; |
663 | |||
664 |
2/2✓ Branch 0 taken 96844 times.
✓ Branch 1 taken 10615 times.
|
107459 | if (enabled) { |
665 | 96844 | const int w = SAMPLE_CTB(fc->tab.cb_width[0], x64_cu, y64_cu); | |
666 | 96844 | const int h = SAMPLE_CTB(fc->tab.cb_height[0], x64_cu, y64_cu); | |
667 | 96844 | const int depth0 = SAMPLE_CTB(fc->tab.cqt_depth[0], x64_cu, y64_cu); | |
668 |
7/8✓ Branch 0 taken 3796 times.
✓ Branch 1 taken 93048 times.
✓ Branch 2 taken 3796 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3316 times.
✓ Branch 5 taken 480 times.
✓ Branch 6 taken 3316 times.
✓ Branch 7 taken 93048 times.
|
96844 | if ((w == 64 && h == 64 && TAB_ISPMF(fc, x64, y64)) || |
669 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 3316 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93048 times.
|
96364 | ((w < 64 || h < 64) && depth0 == min_depth)) |
670 | 480 | return 0; | |
671 | } | ||
672 | |||
673 | } | ||
674 | |||
675 | 106979 | return enabled; | |
676 | } | ||
677 | |||
678 | 536680 | static int less(const void *a, const void *b) | |
679 | { | ||
680 | 536680 | return *(const int*)a - *(const int*)b; | |
681 | } | ||
682 | |||
683 | //8.4.2 Derivation process for luma intra prediction mode | ||
684 | 328269 | static enum IntraPredMode luma_intra_pred_mode(VVCLocalContext* lc, const int intra_subpartitions_mode_flag) | |
685 | { | ||
686 | 328269 | VVCFrameContext *fc = lc->fc; | |
687 | 328269 | CodingUnit *cu = lc->cu; | |
688 | 328269 | const int x0 = cu->x0; | |
689 | 328269 | const int y0 = cu->y0; | |
690 | enum IntraPredMode pred; | ||
691 | 328269 | int intra_luma_not_planar_flag = 1; | |
692 | 328269 | int intra_luma_mpm_remainder = 0; | |
693 | 328269 | int intra_luma_mpm_flag = 1; | |
694 | 328269 | int intra_luma_mpm_idx = 0; | |
695 | |||
696 |
2/2✓ Branch 0 taken 305951 times.
✓ Branch 1 taken 22318 times.
|
328269 | if (!cu->intra_luma_ref_idx) |
697 | 305951 | intra_luma_mpm_flag = ff_vvc_intra_luma_mpm_flag(lc); | |
698 |
2/2✓ Branch 0 taken 251777 times.
✓ Branch 1 taken 76492 times.
|
328269 | if (intra_luma_mpm_flag) { |
699 |
2/2✓ Branch 0 taken 229459 times.
✓ Branch 1 taken 22318 times.
|
251777 | if (!cu->intra_luma_ref_idx) |
700 | 229459 | intra_luma_not_planar_flag = ff_vvc_intra_luma_not_planar_flag(lc, intra_subpartitions_mode_flag); | |
701 |
2/2✓ Branch 0 taken 127936 times.
✓ Branch 1 taken 123841 times.
|
251777 | if (intra_luma_not_planar_flag) |
702 | 127936 | intra_luma_mpm_idx = ff_vvc_intra_luma_mpm_idx(lc); | |
703 | } else { | ||
704 | 76492 | intra_luma_mpm_remainder = ff_vvc_intra_luma_mpm_remainder(lc); | |
705 | } | ||
706 | |||
707 |
2/2✓ Branch 0 taken 123841 times.
✓ Branch 1 taken 204428 times.
|
328269 | if (!intra_luma_not_planar_flag) { |
708 | 123841 | pred = INTRA_PLANAR; | |
709 | } else { | ||
710 | 204428 | const VVCSPS *sps = fc->ps.sps; | |
711 | 204428 | const int x_a = (x0 - 1) >> sps->min_cb_log2_size_y; | |
712 | 204428 | const int y_a = (y0 + cu->cb_height - 1) >> sps->min_cb_log2_size_y; | |
713 | 204428 | const int x_b = (x0 + cu->cb_width - 1) >> sps->min_cb_log2_size_y; | |
714 | 204428 | const int y_b = (y0 - 1) >> sps->min_cb_log2_size_y; | |
715 | 204428 | int min_cb_width = fc->ps.pps->min_cb_width; | |
716 | 204428 | int x0b = av_mod_uintp2(x0, sps->ctb_log2_size_y); | |
717 | 204428 | int y0b = av_mod_uintp2(y0, sps->ctb_log2_size_y); | |
718 |
4/4✓ Branch 0 taken 38174 times.
✓ Branch 1 taken 166254 times.
✓ Branch 2 taken 34788 times.
✓ Branch 3 taken 3386 times.
|
204428 | const int available_l = lc->ctb_left_flag || x0b; |
719 |
4/4✓ Branch 0 taken 68577 times.
✓ Branch 1 taken 135851 times.
✓ Branch 2 taken 64768 times.
✓ Branch 3 taken 3809 times.
|
204428 | const int available_u = lc->ctb_up_flag || y0b; |
720 | |||
721 | int a, b, cand[5]; | ||
722 | |||
723 |
4/4✓ Branch 0 taken 201042 times.
✓ Branch 1 taken 3386 times.
✓ Branch 2 taken 189177 times.
✓ Branch 3 taken 11865 times.
|
204428 | if (!available_l || (SAMPLE_CTB(fc->tab.cpm[0], x_a, y_a) != MODE_INTRA) || |
724 |
2/2✓ Branch 0 taken 26276 times.
✓ Branch 1 taken 162901 times.
|
189177 | SAMPLE_CTB(fc->tab.imf, x_a, y_a)) { |
725 | 41527 | a = INTRA_PLANAR; | |
726 | } else { | ||
727 | 162901 | a = SAMPLE_CTB(fc->tab.ipm, x_a, y_a); | |
728 | } | ||
729 | |||
730 |
4/4✓ Branch 0 taken 200619 times.
✓ Branch 1 taken 3809 times.
✓ Branch 2 taken 188750 times.
✓ Branch 3 taken 11869 times.
|
204428 | if (!available_u || (SAMPLE_CTB(fc->tab.cpm[0], x_b, y_b) != MODE_INTRA) || |
731 |
4/4✓ Branch 0 taken 162138 times.
✓ Branch 1 taken 26612 times.
✓ Branch 2 taken 10022 times.
✓ Branch 3 taken 152116 times.
|
188750 | SAMPLE_CTB(fc->tab.imf, x_b, y_b) || !y0b) { |
732 | 52312 | b = INTRA_PLANAR; | |
733 | } else { | ||
734 | 152116 | b = SAMPLE_CTB(fc->tab.ipm, x_b, y_b); | |
735 | } | ||
736 | |||
737 |
4/4✓ Branch 0 taken 62604 times.
✓ Branch 1 taken 141824 times.
✓ Branch 2 taken 13399 times.
✓ Branch 3 taken 49205 times.
|
204428 | if (a == b && a > INTRA_DC) { |
738 | 13399 | cand[0] = a; | |
739 | 13399 | cand[1] = 2 + ((a + 61) % 64); | |
740 | 13399 | cand[2] = 2 + ((a - 1) % 64); | |
741 | 13399 | cand[3] = 2 + ((a + 60) % 64); | |
742 | 13399 | cand[4] = 2 + (a % 64); | |
743 | } else { | ||
744 | 191029 | const int minab = FFMIN(a, b); | |
745 | 191029 | const int maxab = FFMAX(a, b); | |
746 |
4/4✓ Branch 0 taken 94122 times.
✓ Branch 1 taken 96907 times.
✓ Branch 2 taken 47830 times.
✓ Branch 3 taken 46292 times.
|
238859 | if (a > INTRA_DC && b > INTRA_DC) { |
747 | 47830 | const int diff = maxab - minab; | |
748 | 47830 | cand[0] = a; | |
749 | 47830 | cand[1] = b; | |
750 |
2/2✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 37541 times.
|
47830 | if (diff == 1) { |
751 | 10289 | cand[2] = 2 + ((minab + 61) % 64); | |
752 | 10289 | cand[3] = 2 + ((maxab - 1) % 64); | |
753 | 10289 | cand[4] = 2 + ((minab + 60) % 64); | |
754 |
2/2✓ Branch 0 taken 399 times.
✓ Branch 1 taken 37142 times.
|
37541 | } else if (diff >= 62) { |
755 | 399 | cand[2] = 2 + ((minab - 1) % 64); | |
756 | 399 | cand[3] = 2 + ((maxab + 61) % 64); | |
757 | 399 | cand[4] = 2 + (minab % 64); | |
758 |
2/2✓ Branch 0 taken 4542 times.
✓ Branch 1 taken 32600 times.
|
37142 | } else if (diff == 2) { |
759 | 4542 | cand[2] = 2 + ((minab - 1) % 64); | |
760 | 4542 | cand[3] = 2 + ((minab + 61) % 64); | |
761 | 4542 | cand[4] = 2 + ((maxab - 1) % 64); | |
762 | } else { | ||
763 | 32600 | cand[2] = 2 + ((minab + 61) % 64); | |
764 | 32600 | cand[3] = 2 + ((minab - 1) % 64); | |
765 | 32600 | cand[4] = 2 + ((maxab + 61) % 64); | |
766 | } | ||
767 |
4/4✓ Branch 0 taken 96907 times.
✓ Branch 1 taken 46292 times.
✓ Branch 2 taken 38223 times.
✓ Branch 3 taken 58684 times.
|
143199 | } else if (a > INTRA_DC || b > INTRA_DC) { |
768 | 84515 | cand[0] = maxab; | |
769 | 84515 | cand[1] = 2 + ((maxab + 61 ) % 64); | |
770 | 84515 | cand[2] = 2 + ((maxab - 1) % 64); | |
771 | 84515 | cand[3] = 2 + ((maxab + 60 ) % 64); | |
772 | 84515 | cand[4] = 2 + (maxab % 64); | |
773 | } else { | ||
774 | 58684 | cand[0] = INTRA_DC; | |
775 | 58684 | cand[1] = INTRA_VERT; | |
776 | 58684 | cand[2] = INTRA_HORZ; | |
777 | 58684 | cand[3] = INTRA_VERT - 4; | |
778 | 58684 | cand[4] = INTRA_VERT + 4; | |
779 | } | ||
780 | } | ||
781 |
2/2✓ Branch 0 taken 127936 times.
✓ Branch 1 taken 76492 times.
|
204428 | if (intra_luma_mpm_flag) { |
782 | 127936 | pred = cand[intra_luma_mpm_idx]; | |
783 | } else { | ||
784 | 76492 | qsort(cand, FF_ARRAY_ELEMS(cand), sizeof(cand[0]), less); | |
785 | 76492 | pred = intra_luma_mpm_remainder + 1; | |
786 |
2/2✓ Branch 0 taken 382460 times.
✓ Branch 1 taken 76492 times.
|
458952 | for (int i = 0; i < FF_ARRAY_ELEMS(cand); i++) { |
787 |
2/2✓ Branch 0 taken 188369 times.
✓ Branch 1 taken 194091 times.
|
382460 | if (pred >= cand[i]) |
788 | 188369 | pred++; | |
789 | } | ||
790 | } | ||
791 | } | ||
792 | 328269 | return pred; | |
793 | } | ||
794 | |||
795 | 655498 | static int lfnst_idx_decode(VVCLocalContext *lc) | |
796 | { | ||
797 | 655498 | CodingUnit *cu = lc->cu; | |
798 | 655498 | const VVCTreeType tree_type = cu->tree_type; | |
799 | 655498 | const VVCSPS *sps = lc->fc->ps.sps; | |
800 | 655498 | const int cb_width = cu->cb_width; | |
801 | 655498 | const int cb_height = cu->cb_height; | |
802 | 655498 | const TransformUnit *tu = cu->tus.head; | |
803 | int lfnst_width, lfnst_height, min_lfnst; | ||
804 | 655498 | int lfnst_idx = 0; | |
805 | |||
806 | 655498 | memset(cu->apply_lfnst_flag, 0, sizeof(cu->apply_lfnst_flag)); | |
807 | |||
808 |
5/6✓ Branch 0 taken 499301 times.
✓ Branch 1 taken 156197 times.
✓ Branch 2 taken 404228 times.
✓ Branch 3 taken 95073 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 404228 times.
|
655498 | if (!sps->r->sps_lfnst_enabled_flag || cu->pred_mode != MODE_INTRA || FFMAX(cb_width, cb_height) > sps->max_tb_size_y) |
809 | 251270 | return 0; | |
810 | |||
811 |
2/2✓ Branch 0 taken 490517 times.
✓ Branch 1 taken 393555 times.
|
884072 | while (tu) { |
812 |
2/2✓ Branch 0 taken 646564 times.
✓ Branch 1 taken 479844 times.
|
1126408 | for (int j = 0; j < tu->nb_tbs; j++) { |
813 | 646564 | const TransformBlock *tb = tu->tbs + j; | |
814 |
4/4✓ Branch 0 taken 426015 times.
✓ Branch 1 taken 220549 times.
✓ Branch 2 taken 10673 times.
✓ Branch 3 taken 415342 times.
|
646564 | if (tu->coded_flag[tb->c_idx] && tb->ts) |
815 | 10673 | return 0; | |
816 | } | ||
817 | 479844 | tu = tu->next; | |
818 | } | ||
819 | |||
820 |
2/2✓ Branch 0 taken 91110 times.
✓ Branch 1 taken 302445 times.
|
393555 | if (tree_type == DUAL_TREE_CHROMA) { |
821 | 91110 | lfnst_width = cb_width >> sps->hshift[1]; | |
822 | 91110 | lfnst_height = cb_height >> sps->vshift[1]; | |
823 | } else { | ||
824 | 302445 | const int vs = cu->isp_split_type == ISP_VER_SPLIT; | |
825 | 302445 | const int hs = cu->isp_split_type == ISP_HOR_SPLIT; | |
826 |
2/2✓ Branch 0 taken 13568 times.
✓ Branch 1 taken 288877 times.
|
302445 | lfnst_width = vs ? cb_width / cu->num_intra_subpartitions : cb_width; |
827 |
2/2✓ Branch 0 taken 24025 times.
✓ Branch 1 taken 278420 times.
|
302445 | lfnst_height = hs ? cb_height / cu->num_intra_subpartitions : cb_height; |
828 | } | ||
829 | 393555 | min_lfnst = FFMIN(lfnst_width, lfnst_height); | |
830 |
6/6✓ Branch 0 taken 302445 times.
✓ Branch 1 taken 91110 times.
✓ Branch 2 taken 72268 times.
✓ Branch 3 taken 230177 times.
✓ Branch 4 taken 56448 times.
✓ Branch 5 taken 15820 times.
|
393555 | if (tree_type != DUAL_TREE_CHROMA && cu->intra_mip_flag && min_lfnst < 16) |
831 | 56448 | return 0; | |
832 | |||
833 |
2/2✓ Branch 0 taken 314132 times.
✓ Branch 1 taken 22975 times.
|
337107 | if (min_lfnst >= 4) { |
834 |
6/6✓ Branch 0 taken 292298 times.
✓ Branch 1 taken 21834 times.
✓ Branch 2 taken 132137 times.
✓ Branch 3 taken 160161 times.
✓ Branch 4 taken 131097 times.
✓ Branch 5 taken 22874 times.
|
314132 | if ((cu->isp_split_type != ISP_NO_SPLIT || !lc->parse.lfnst_dc_only) && lc->parse.lfnst_zero_out_sig_coeff_flag) |
835 | 131097 | lfnst_idx = ff_vvc_lfnst_idx(lc, tree_type != SINGLE_TREE); | |
836 | } | ||
837 | |||
838 |
2/2✓ Branch 0 taken 97254 times.
✓ Branch 1 taken 239853 times.
|
337107 | if (lfnst_idx) { |
839 | 97254 | cu->apply_lfnst_flag[LUMA] = tree_type != DUAL_TREE_CHROMA; | |
840 | 97254 | cu->apply_lfnst_flag[CB] = cu->apply_lfnst_flag[CR] = tree_type == DUAL_TREE_CHROMA; | |
841 | } | ||
842 | |||
843 | 337107 | return lfnst_idx; | |
844 | } | ||
845 | |||
846 | 655498 | static MtsIdx mts_idx_decode(VVCLocalContext *lc) | |
847 | { | ||
848 | 655498 | const CodingUnit *cu = lc->cu; | |
849 | 655498 | const VVCSPS *sps = lc->fc->ps.sps; | |
850 | 655498 | const int cb_width = cu->cb_width; | |
851 | 655498 | const int cb_height = cu->cb_height; | |
852 | 655498 | const uint8_t transform_skip_flag = cu->tus.head->tbs[0].ts; //fix me | |
853 | 655498 | int mts_idx = MTS_DCT2_DCT2; | |
854 |
6/6✓ Branch 0 taken 538974 times.
✓ Branch 1 taken 116524 times.
✓ Branch 2 taken 462843 times.
✓ Branch 3 taken 76131 times.
✓ Branch 4 taken 442501 times.
✓ Branch 5 taken 20342 times.
|
655498 | if (cu->tree_type != DUAL_TREE_CHROMA && !cu->lfnst_idx && |
855 |
2/2✓ Branch 0 taken 425218 times.
✓ Branch 1 taken 17283 times.
|
442501 | !transform_skip_flag && FFMAX(cb_width, cb_height) <= 32 && |
856 |
4/4✓ Branch 0 taken 390859 times.
✓ Branch 1 taken 34359 times.
✓ Branch 2 taken 355288 times.
✓ Branch 3 taken 35571 times.
|
425218 | cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag && |
857 |
4/4✓ Branch 0 taken 348660 times.
✓ Branch 1 taken 6628 times.
✓ Branch 2 taken 234754 times.
✓ Branch 3 taken 113906 times.
|
355288 | lc->parse.mts_zero_out_sig_coeff_flag && !lc->parse.mts_dc_only) { |
858 |
3/4✓ Branch 0 taken 51690 times.
✓ Branch 1 taken 183064 times.
✓ Branch 2 taken 51690 times.
✗ Branch 3 not taken.
|
234754 | if ((cu->pred_mode == MODE_INTER && sps->r->sps_explicit_mts_inter_enabled_flag) || |
859 |
4/4✓ Branch 0 taken 183019 times.
✓ Branch 1 taken 51735 times.
✓ Branch 2 taken 180867 times.
✓ Branch 3 taken 2152 times.
|
234754 | (cu->pred_mode == MODE_INTRA && sps->r->sps_explicit_mts_intra_enabled_flag)) { |
860 | 180867 | mts_idx = ff_vvc_mts_idx(lc); | |
861 | } | ||
862 | } | ||
863 | |||
864 | 655498 | return mts_idx; | |
865 | } | ||
866 | |||
867 | 155551 | static enum IntraPredMode derive_center_luma_intra_pred_mode(const VVCFrameContext *fc, const VVCSPS *sps, const VVCPPS *pps, const CodingUnit *cu) | |
868 | { | ||
869 | 155551 | const int x_center = (cu->x0 + cu->cb_width / 2) >> sps->min_cb_log2_size_y; | |
870 | 155551 | const int y_center = (cu->y0 + cu->cb_height / 2) >> sps->min_cb_log2_size_y; | |
871 | 155551 | const int min_cb_width = pps->min_cb_width; | |
872 | 155551 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_center, y_center); | |
873 | 155551 | const int cu_pred_mode = SAMPLE_CTB(fc->tab.cpm[0], x_center, y_center); | |
874 | 155551 | const int intra_pred_mode_y = SAMPLE_CTB(fc->tab.ipm, x_center, y_center); | |
875 | |||
876 |
2/2✓ Branch 0 taken 33286 times.
✓ Branch 1 taken 122265 times.
|
155551 | if (intra_mip_flag) { |
877 |
4/4✓ Branch 0 taken 8686 times.
✓ Branch 1 taken 24600 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 8442 times.
|
33286 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
878 | 244 | return INTRA_INVALID; | |
879 | 33042 | return INTRA_PLANAR; | |
880 | } | ||
881 |
3/4✓ Branch 0 taken 122159 times.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122159 times.
|
122265 | if (cu_pred_mode == MODE_IBC || cu_pred_mode == MODE_PLT) |
882 | 106 | return INTRA_DC; | |
883 | 122159 | return intra_pred_mode_y; | |
884 | } | ||
885 | |||
886 | 155695 | static void derive_chroma_intra_pred_mode(VVCLocalContext *lc, | |
887 | const int cclm_mode_flag, const int cclm_mode_idx, const int intra_chroma_pred_mode) | ||
888 | { | ||
889 | 155695 | const VVCFrameContext *fc = lc->fc; | |
890 | 155695 | CodingUnit *cu = lc->cu; | |
891 | 155695 | const VVCSPS *sps = fc->ps.sps; | |
892 | 155695 | const VVCPPS *pps = fc->ps.pps; | |
893 | 155695 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
894 | 155695 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
895 | 155695 | const int min_cb_width = pps->min_cb_width; | |
896 | 155695 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
897 | 155695 | enum IntraPredMode luma_intra_pred_mode = SAMPLE_CTB(fc->tab.ipm, x_cb, y_cb); | |
898 | |||
899 |
6/6✓ Branch 0 taken 39174 times.
✓ Branch 1 taken 116521 times.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 37049 times.
✓ Branch 4 taken 679 times.
✓ Branch 5 taken 1446 times.
|
155695 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && |
900 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 535 times.
|
679 | intra_chroma_pred_mode == 4 && intra_mip_flag) { |
901 | 144 | cu->mip_chroma_direct_flag = 1; | |
902 | 144 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
903 | 144 | return; | |
904 | } | ||
905 | 155551 | luma_intra_pred_mode = derive_center_luma_intra_pred_mode(fc, sps, pps, cu); | |
906 | |||
907 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 155551 times.
|
155551 | if (cu->act_enabled_flag) { |
908 | ✗ | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
909 | ✗ | return; | |
910 | } | ||
911 |
2/2✓ Branch 0 taken 61263 times.
✓ Branch 1 taken 94288 times.
|
155551 | if (cclm_mode_flag) { |
912 | 61263 | cu->intra_pred_mode_c = INTRA_LT_CCLM + cclm_mode_idx; | |
913 |
2/2✓ Branch 0 taken 71569 times.
✓ Branch 1 taken 22719 times.
|
94288 | } else if (intra_chroma_pred_mode == 4){ |
914 | 71569 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
915 | } else { | ||
916 | const static IntraPredMode pred_mode_c[][4 + 1] = { | ||
917 | {INTRA_VDIAG, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR}, | ||
918 | {INTRA_VERT, INTRA_VDIAG, INTRA_VERT, INTRA_VERT, INTRA_VERT}, | ||
919 | {INTRA_HORZ, INTRA_HORZ, INTRA_VDIAG, INTRA_HORZ, INTRA_HORZ}, | ||
920 | {INTRA_DC, INTRA_DC, INTRA_DC, INTRA_VDIAG, INTRA_DC}, | ||
921 | }; | ||
922 | 22719 | const int modes[4] = {INTRA_PLANAR, INTRA_VERT, INTRA_HORZ, INTRA_DC}; | |
923 | int idx; | ||
924 | |||
925 | // This workaround is necessary to have 4:4:4 video decode correctly | ||
926 | // See VVC ticket https://jvet.hhi.fraunhofer.de/trac/vvc/ticket/1602 | ||
927 | // and VTM source https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM/-/blob/master/source/Lib/CommonLib/UnitTools.cpp#L736 | ||
928 |
6/6✓ Branch 0 taken 1926 times.
✓ Branch 1 taken 20793 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 1683 times.
✓ Branch 4 taken 43 times.
✓ Branch 5 taken 200 times.
|
22719 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && intra_mip_flag) { |
929 | 43 | idx = 4; | |
930 | } else { | ||
931 |
2/2✓ Branch 0 taken 50656 times.
✓ Branch 1 taken 7618 times.
|
58274 | for (idx = 0; idx < FF_ARRAY_ELEMS(modes); idx++) { |
932 |
2/2✓ Branch 0 taken 15058 times.
✓ Branch 1 taken 35598 times.
|
50656 | if (modes[idx] == luma_intra_pred_mode) |
933 | 15058 | break; | |
934 | } | ||
935 | } | ||
936 | |||
937 | 22719 | cu->intra_pred_mode_c = pred_mode_c[intra_chroma_pred_mode][idx]; | |
938 | } | ||
939 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 155551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
155551 | if (sps->r->sps_chroma_format_idc == CHROMA_FORMAT_422 && cu->intra_pred_mode_c <= INTRA_VDIAG) { |
940 | const static int mode_map_422[INTRA_VDIAG + 1] = { | ||
941 | 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 5, 6, 8, 10, 12, 13, | ||
942 | 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 31, 33, 34, 35, 36, 37, | ||
943 | 38, 39, 40, 41, 41, 42, 43, 43, 44, 44, 45, 45, 46, 47, 48, 48, | ||
944 | 49, 49, 50, 51, 51, 52, 52, 53, 54, 55, 55, 56, 56, 57, 57, 58, | ||
945 | 59, 59, 60, | ||
946 | }; | ||
947 | ✗ | cu->intra_pred_mode_c = mode_map_422[cu->intra_pred_mode_c]; | |
948 | } | ||
949 | } | ||
950 | |||
951 | 403254 | static void intra_luma_pred_modes(VVCLocalContext *lc) | |
952 | { | ||
953 | 403254 | VVCFrameContext *fc = lc->fc; | |
954 | 403254 | const VVCSPS *sps = fc->ps.sps; | |
955 | 403254 | const VVCPPS *pps = fc->ps.pps; | |
956 | 403254 | CodingUnit *cu = lc->cu; | |
957 | 403254 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
958 | 403254 | const int x0 = cu->x0; | |
959 | 403254 | const int y0 = cu->y0; | |
960 | 403254 | const int x_cb = x0 >> log2_min_cb_size; | |
961 | 403254 | const int y_cb = y0 >> log2_min_cb_size; | |
962 | 403254 | const int cb_width = cu->cb_width; | |
963 | 403254 | const int cb_height = cu->cb_height; | |
964 | |||
965 | 403254 | cu->intra_luma_ref_idx = 0; | |
966 |
6/6✓ Branch 0 taken 22042 times.
✓ Branch 1 taken 381212 times.
✓ Branch 2 taken 21441 times.
✓ Branch 3 taken 601 times.
✓ Branch 4 taken 21430 times.
✓ Branch 5 taken 11 times.
|
403254 | if (sps->r->sps_bdpcm_enabled_flag && cb_width <= sps->max_ts_size && cb_height <= sps->max_ts_size) |
967 | 21430 | cu->bdpcm_flag[LUMA] = ff_vvc_intra_bdpcm_luma_flag(lc); | |
968 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 403220 times.
|
403254 | if (cu->bdpcm_flag[LUMA]) { |
969 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 2 taken 16 times.
|
34 | cu->intra_pred_mode_y = ff_vvc_intra_bdpcm_luma_dir_flag(lc) ? INTRA_VERT : INTRA_HORZ; |
970 | } else { | ||
971 |
2/2✓ Branch 0 taken 311631 times.
✓ Branch 1 taken 91589 times.
|
403220 | if (sps->r->sps_mip_enabled_flag) |
972 | 311631 | cu->intra_mip_flag = ff_vvc_intra_mip_flag(lc, fc->tab.imf); | |
973 |
2/2✓ Branch 0 taken 74951 times.
✓ Branch 1 taken 328269 times.
|
403220 | if (cu->intra_mip_flag) { |
974 | 74951 | int intra_mip_transposed_flag = ff_vvc_intra_mip_transposed_flag(lc); | |
975 | 74951 | int intra_mip_mode = ff_vvc_intra_mip_mode(lc); | |
976 | 74951 | int x = y_cb * pps->min_cb_width + x_cb; | |
977 |
2/2✓ Branch 0 taken 211095 times.
✓ Branch 1 taken 74951 times.
|
286046 | for (int y = 0; y < (cb_height>>log2_min_cb_size); y++) { |
978 | 211095 | int width = cb_width>>log2_min_cb_size; | |
979 | 211095 | memset(&fc->tab.imf[x], cu->intra_mip_flag, width); | |
980 | 211095 | fc->tab.imtf[x] = intra_mip_transposed_flag; | |
981 | 211095 | fc->tab.imm[x] = intra_mip_mode; | |
982 | 211095 | x += pps->min_cb_width; | |
983 | } | ||
984 | 74951 | cu->intra_pred_mode_y = intra_mip_mode; | |
985 | } else { | ||
986 | 328269 | int intra_subpartitions_mode_flag = 0; | |
987 |
4/4✓ Branch 0 taken 324776 times.
✓ Branch 1 taken 3493 times.
✓ Branch 2 taken 296122 times.
✓ Branch 3 taken 28654 times.
|
328269 | if (sps->r->sps_mrl_enabled_flag && ((y0 % sps->ctb_size_y) > 0)) |
988 | 296122 | cu->intra_luma_ref_idx = ff_vvc_intra_luma_ref_idx(lc); | |
989 |
4/4✓ Branch 0 taken 324776 times.
✓ Branch 1 taken 3493 times.
✓ Branch 2 taken 302458 times.
✓ Branch 3 taken 22318 times.
|
328269 | if (sps->r->sps_isp_enabled_flag && !cu->intra_luma_ref_idx && |
990 |
2/4✓ Branch 0 taken 302458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 302458 times.
✗ Branch 3 not taken.
|
302458 | (cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) && |
991 |
2/2✓ Branch 0 taken 266915 times.
✓ Branch 1 taken 35543 times.
|
302458 | (cb_width * cb_height > MIN_TU_SIZE * MIN_TU_SIZE) && |
992 |
1/2✓ Branch 0 taken 266915 times.
✗ Branch 1 not taken.
|
266915 | !cu->act_enabled_flag) |
993 | 266915 | intra_subpartitions_mode_flag = ff_vvc_intra_subpartitions_mode_flag(lc); | |
994 |
4/4✓ Branch 0 taken 69374 times.
✓ Branch 1 taken 258895 times.
✓ Branch 2 taken 15757 times.
✓ Branch 3 taken 53617 times.
|
328269 | if (!(x0 & 63) && !(y0 & 63)) |
995 | 15757 | TAB_ISPMF(fc, x0, y0) = intra_subpartitions_mode_flag; | |
996 | 328269 | cu->isp_split_type = ff_vvc_isp_split_type(lc, intra_subpartitions_mode_flag); | |
997 | 328269 | cu->num_intra_subpartitions = get_num_intra_subpartitions(cu->isp_split_type, cb_width, cb_height); | |
998 | 328269 | cu->intra_pred_mode_y = luma_intra_pred_mode(lc, intra_subpartitions_mode_flag); | |
999 | } | ||
1000 | } | ||
1001 | 403254 | set_cb_tab(lc, fc->tab.ipm, cu->intra_pred_mode_y); | |
1002 | 403254 | } | |
1003 | |||
1004 | 155698 | static void intra_chroma_pred_modes(VVCLocalContext *lc) | |
1005 | { | ||
1006 | 155698 | const VVCSPS *sps = lc->fc->ps.sps; | |
1007 | 155698 | CodingUnit *cu = lc->cu; | |
1008 | 155698 | const int hs = sps->hshift[CHROMA]; | |
1009 | 155698 | const int vs = sps->vshift[CHROMA]; | |
1010 | |||
1011 | 155698 | cu->mip_chroma_direct_flag = 0; | |
1012 |
2/2✓ Branch 0 taken 20019 times.
✓ Branch 1 taken 135679 times.
|
155698 | if (sps->r->sps_bdpcm_enabled_flag && |
1013 |
2/2✓ Branch 0 taken 19046 times.
✓ Branch 1 taken 973 times.
|
20019 | (cu->cb_width >> hs) <= sps->max_ts_size && |
1014 |
2/2✓ Branch 0 taken 18703 times.
✓ Branch 1 taken 343 times.
|
19046 | (cu->cb_height >> vs) <= sps->max_ts_size) { |
1015 | 18703 | cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = ff_vvc_intra_bdpcm_chroma_flag(lc); | |
1016 | } | ||
1017 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 155695 times.
|
155698 | if (cu->bdpcm_flag[CHROMA]) { |
1018 |
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; |
1019 | } else { | ||
1020 | 155695 | const int cclm_enabled = get_cclm_enabled(lc, cu->x0, cu->y0); | |
1021 | 155695 | int cclm_mode_flag = 0; | |
1022 | 155695 | int cclm_mode_idx = 0; | |
1023 | 155695 | int intra_chroma_pred_mode = 0; | |
1024 | |||
1025 |
2/2✓ Branch 0 taken 144600 times.
✓ Branch 1 taken 11095 times.
|
155695 | if (cclm_enabled) |
1026 | 144600 | cclm_mode_flag = ff_vvc_cclm_mode_flag(lc); | |
1027 | |||
1028 |
2/2✓ Branch 0 taken 61263 times.
✓ Branch 1 taken 94432 times.
|
155695 | if (cclm_mode_flag) |
1029 | 61263 | cclm_mode_idx = ff_vvc_cclm_mode_idx(lc); | |
1030 | else | ||
1031 | 94432 | intra_chroma_pred_mode = ff_vvc_intra_chroma_pred_mode(lc); | |
1032 | 155695 | derive_chroma_intra_pred_mode(lc, cclm_mode_flag, cclm_mode_idx, intra_chroma_pred_mode); | |
1033 | } | ||
1034 | 155698 | } | |
1035 | |||
1036 | 915428 | static PredMode pred_mode_decode(VVCLocalContext *lc, | |
1037 | const VVCTreeType tree_type, | ||
1038 | const VVCModeType mode_type) | ||
1039 | { | ||
1040 | 915428 | const VVCFrameContext *fc = lc->fc; | |
1041 | 915428 | CodingUnit *cu = lc->cu; | |
1042 | 915428 | const VVCSPS *sps = fc->ps.sps; | |
1043 | 915428 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1044 | 915428 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
1045 |
4/4✓ Branch 0 taken 162305 times.
✓ Branch 1 taken 753123 times.
✓ Branch 2 taken 47874 times.
✓ Branch 3 taken 114431 times.
|
915428 | const int is_4x4 = cu->cb_width == 4 && cu->cb_height == 4; |
1046 | int pred_mode_flag; | ||
1047 | int pred_mode_ibc_flag; | ||
1048 | PredMode pred_mode; | ||
1049 | |||
1050 | 915428 | cu->skip_flag = 0; | |
1051 |
4/4✓ Branch 0 taken 442727 times.
✓ Branch 1 taken 472701 times.
✓ Branch 2 taken 2408 times.
✓ Branch 3 taken 440319 times.
|
1390537 | if (!IS_I(rsh) || sps->r->sps_ibc_enabled_flag) { |
1052 |
4/4✓ Branch 0 taken 453153 times.
✓ Branch 1 taken 21956 times.
✓ Branch 2 taken 2145 times.
✓ Branch 3 taken 451008 times.
|
475109 | const int is_128 = cu->cb_width == 128 || cu->cb_height == 128; |
1053 |
4/4✓ Branch 0 taken 466755 times.
✓ Branch 1 taken 8354 times.
✓ Branch 2 taken 458547 times.
✓ Branch 3 taken 8208 times.
|
475109 | if (tree_type != DUAL_TREE_CHROMA && |
1054 |
2/2✓ Branch 0 taken 18714 times.
✓ Branch 1 taken 439833 times.
|
458547 | ((!is_4x4 && mode_type != MODE_TYPE_INTRA) || |
1055 |
3/4✓ Branch 0 taken 436 times.
✓ Branch 1 taken 26486 times.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
|
26922 | (sps->r->sps_ibc_enabled_flag && !is_128))) { |
1056 | 440269 | cu->skip_flag = ff_vvc_cu_skip_flag(lc, fc->tab.skip); | |
1057 | } | ||
1058 | |||
1059 |
6/6✓ Branch 0 taken 466901 times.
✓ Branch 1 taken 8208 times.
✓ Branch 2 taken 439993 times.
✓ Branch 3 taken 26908 times.
✓ Branch 4 taken 2112 times.
✓ Branch 5 taken 437881 times.
|
475109 | if (is_4x4 || mode_type == MODE_TYPE_INTRA || IS_I(rsh)) { |
1060 | 37228 | pred_mode_flag = 1; | |
1061 |
4/4✓ Branch 0 taken 382376 times.
✓ Branch 1 taken 55505 times.
✓ Branch 2 taken 203220 times.
✓ Branch 3 taken 179156 times.
|
437881 | } else if (mode_type == MODE_TYPE_INTER || cu->skip_flag) { |
1062 | 258725 | pred_mode_flag = 0; | |
1063 | } else { | ||
1064 | 179156 | pred_mode_flag = ff_vvc_pred_mode_flag(lc, ch_type); | |
1065 | } | ||
1066 | 475109 | pred_mode = pred_mode_flag ? MODE_INTRA : MODE_INTER; | |
1067 | |||
1068 |
4/4✓ Branch 0 taken 2408 times.
✓ Branch 1 taken 472701 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 2312 times.
|
475109 | if (((IS_I(rsh) && !cu->skip_flag) || |
1069 |
6/6✓ Branch 0 taken 472701 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 78594 times.
✓ Branch 3 taken 394107 times.
✓ Branch 4 taken 70682 times.
✓ Branch 5 taken 7912 times.
|
472797 | (!IS_I(rsh) && (pred_mode != MODE_INTRA || |
1070 |
6/6✓ Branch 0 taken 26908 times.
✓ Branch 1 taken 43774 times.
✓ Branch 2 taken 34796 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 407114 times.
✓ Branch 5 taken 24101 times.
|
475013 | ((is_4x4 || mode_type == MODE_TYPE_INTRA) && !cu->skip_flag)))) && |
1071 |
6/6✓ Branch 0 taken 351609 times.
✓ Branch 1 taken 55505 times.
✓ Branch 2 taken 3239 times.
✓ Branch 3 taken 348370 times.
✓ Branch 4 taken 3032 times.
✓ Branch 5 taken 207 times.
|
407114 | !is_128 && mode_type != MODE_TYPE_INTER && sps->r->sps_ibc_enabled_flag && |
1072 | tree_type != DUAL_TREE_CHROMA) { | ||
1073 | 3032 | pred_mode_ibc_flag = ff_vvc_pred_mode_ibc_flag(lc, ch_type); | |
1074 |
6/6✓ Branch 0 taken 227884 times.
✓ Branch 1 taken 244193 times.
✓ Branch 2 taken 227857 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 227842 times.
|
472077 | } else if (cu->skip_flag && (is_4x4 || mode_type == MODE_TYPE_INTRA)) { |
1075 | 42 | pred_mode_ibc_flag = 1; | |
1076 |
6/6✓ Branch 0 taken 447934 times.
✓ Branch 1 taken 24101 times.
✓ Branch 2 taken 392429 times.
✓ Branch 3 taken 55505 times.
✓ Branch 4 taken 8354 times.
✓ Branch 5 taken 384075 times.
|
472035 | } else if (is_128 || mode_type == MODE_TYPE_INTER || tree_type == DUAL_TREE_CHROMA) { |
1077 | 87960 | pred_mode_ibc_flag = 0; | |
1078 | } else { | ||
1079 |
2/2✓ Branch 0 taken 78 times.
✓ Branch 1 taken 383997 times.
|
384075 | pred_mode_ibc_flag = (IS_I(rsh)) ? sps->r->sps_ibc_enabled_flag : 0; |
1080 | } | ||
1081 |
2/2✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 473527 times.
|
475109 | if (pred_mode_ibc_flag) |
1082 | 1582 | pred_mode = MODE_IBC; | |
1083 | } else { | ||
1084 |
2/4✓ Branch 0 taken 400653 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 400653 times.
|
400653 | pred_mode_flag = is_4x4 || mode_type == MODE_TYPE_INTRA || |
1085 |
2/4✓ Branch 0 taken 400653 times.
✓ Branch 1 taken 39666 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
840972 | mode_type != MODE_TYPE_INTER || IS_I(rsh); |
1086 | 440319 | pred_mode = pred_mode_flag ? MODE_INTRA : MODE_INTER; | |
1087 | } | ||
1088 | 915428 | return pred_mode; | |
1089 | } | ||
1090 | |||
1091 | 655498 | static void sbt_info(VVCLocalContext *lc, const VVCSPS *sps) | |
1092 | { | ||
1093 | 655498 | CodingUnit *cu = lc->cu; | |
1094 | 655498 | const int cb_width = cu->cb_width; | |
1095 | 655498 | const int cb_height = cu->cb_height; | |
1096 | |||
1097 |
6/6✓ Branch 0 taken 134956 times.
✓ Branch 1 taken 520542 times.
✓ Branch 2 taken 132251 times.
✓ Branch 3 taken 2705 times.
✓ Branch 4 taken 117268 times.
✓ Branch 5 taken 14983 times.
|
655498 | if (cu->pred_mode == MODE_INTER && sps->r->sps_sbt_enabled_flag && !cu->ciip_flag |
1098 |
4/4✓ Branch 0 taken 116594 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 116358 times.
✓ Branch 3 taken 236 times.
|
117268 | && cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) { |
1099 | 116358 | const int sbt_ver_h = cb_width >= 8; | |
1100 | 116358 | const int sbt_hor_h = cb_height >= 8; | |
1101 | 116358 | cu->sbt_flag = 0; | |
1102 |
3/4✓ Branch 0 taken 16941 times.
✓ Branch 1 taken 99417 times.
✓ Branch 2 taken 16941 times.
✗ Branch 3 not taken.
|
116358 | if (sbt_ver_h || sbt_hor_h) |
1103 | 116358 | cu->sbt_flag = ff_vvc_sbt_flag(lc); | |
1104 |
2/2✓ Branch 0 taken 37108 times.
✓ Branch 1 taken 79250 times.
|
116358 | if (cu->sbt_flag) { |
1105 | 37108 | const int sbt_ver_q = cb_width >= 16; | |
1106 | 37108 | const int sbt_hor_q = cb_height >= 16; | |
1107 | 37108 | int cu_sbt_quad_flag = 0; | |
1108 | |||
1109 |
7/8✓ Branch 0 taken 5961 times.
✓ Branch 1 taken 31147 times.
✓ Branch 2 taken 5961 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20620 times.
✓ Branch 5 taken 16488 times.
✓ Branch 6 taken 10888 times.
✓ Branch 7 taken 9732 times.
|
37108 | if ((sbt_ver_h || sbt_hor_h) && (sbt_ver_q || sbt_hor_q)) |
1110 | 27376 | cu_sbt_quad_flag = ff_vvc_sbt_quad_flag(lc); | |
1111 |
2/2✓ Branch 0 taken 9577 times.
✓ Branch 1 taken 27531 times.
|
37108 | if (cu_sbt_quad_flag) { |
1112 | 9577 | cu->sbt_horizontal_flag = sbt_hor_q; | |
1113 |
4/4✓ Branch 0 taken 6051 times.
✓ Branch 1 taken 3526 times.
✓ Branch 2 taken 3058 times.
✓ Branch 3 taken 2993 times.
|
9577 | if (sbt_ver_q && sbt_hor_q) |
1114 | 3058 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
1115 | } else { | ||
1116 | 27531 | cu->sbt_horizontal_flag = sbt_hor_h; | |
1117 |
4/4✓ Branch 0 taken 22920 times.
✓ Branch 1 taken 4611 times.
✓ Branch 2 taken 18985 times.
✓ Branch 3 taken 3935 times.
|
27531 | if (sbt_ver_h && sbt_hor_h) |
1118 | 18985 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
1119 | } | ||
1120 | 37108 | cu->sbt_pos_flag = ff_vvc_sbt_pos_flag(lc); | |
1121 | |||
1122 | { | ||
1123 |
2/2✓ Branch 0 taken 9577 times.
✓ Branch 1 taken 27531 times.
|
37108 | const int sbt_min = cu_sbt_quad_flag ? 1 : 2; |
1124 |
2/2✓ Branch 0 taken 17669 times.
✓ Branch 1 taken 19439 times.
|
37108 | lc->parse.sbt_num_fourths_tb0 = cu->sbt_pos_flag ? (4 - sbt_min) : sbt_min; |
1125 | } | ||
1126 | } | ||
1127 | } | ||
1128 | 655498 | } | |
1129 | |||
1130 | 259930 | static int skipped_transform_tree_unit(VVCLocalContext *lc) | |
1131 | { | ||
1132 | 259930 | const H266RawSPS *rsps = lc->fc->ps.sps->r; | |
1133 | 259930 | const CodingUnit *cu = lc->cu; | |
1134 | int ret; | ||
1135 | |||
1136 |
1/2✓ Branch 0 taken 259930 times.
✗ Branch 1 not taken.
|
259930 | if (cu->tree_type != DUAL_TREE_CHROMA) |
1137 | 259930 | set_qp_y(lc, cu->x0, cu->y0, 0); | |
1138 |
4/4✓ Branch 0 taken 243419 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 242623 times.
✓ Branch 3 taken 796 times.
|
259930 | if (rsps->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA) |
1139 | 242623 | set_qp_c(lc); | |
1140 | 259930 | ret = skipped_transform_tree(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
1141 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 259930 times.
|
259930 | if (ret < 0) |
1142 | ✗ | return ret; | |
1143 | 259930 | return 0; | |
1144 | } | ||
1145 | |||
1146 | 915428 | static void set_cb_pos(const VVCFrameContext *fc, const CodingUnit *cu) | |
1147 | { | ||
1148 | 915428 | const VVCSPS *sps = fc->ps.sps; | |
1149 | 915428 | const VVCPPS *pps = fc->ps.pps; | |
1150 | 915428 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
1151 | 915428 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
1152 | 915428 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
1153 | 915428 | const int ch_type = cu->ch_type; | |
1154 | int x, y; | ||
1155 | |||
1156 | 915428 | x = y_cb * pps->min_cb_width + x_cb; | |
1157 |
2/2✓ Branch 0 taken 4251768 times.
✓ Branch 1 taken 915428 times.
|
5167196 | for (y = 0; y < (cu->cb_height >> log2_min_cb_size); y++) { |
1158 | 4251768 | const int width = cu->cb_width >> log2_min_cb_size; | |
1159 | |||
1160 |
2/2✓ Branch 0 taken 43656736 times.
✓ Branch 1 taken 4251768 times.
|
47908504 | for (int i = 0; i < width; i++) { |
1161 | 43656736 | fc->tab.cb_pos_x[ch_type][x + i] = cu->x0; | |
1162 | 43656736 | fc->tab.cb_pos_y[ch_type][x + i] = cu->y0; | |
1163 | } | ||
1164 | 4251768 | memset(&fc->tab.cb_width[ch_type][x], cu->cb_width, width); | |
1165 | 4251768 | memset(&fc->tab.cb_height[ch_type][x], cu->cb_height, width); | |
1166 | 4251768 | memset(&fc->tab.cqt_depth[ch_type][x], cu->cqt_depth, width); | |
1167 | |||
1168 | 4251768 | x += pps->min_cb_width; | |
1169 | } | ||
1170 | 915428 | } | |
1171 | |||
1172 | 915428 | static CodingUnit* alloc_cu(VVCLocalContext *lc, const int x0, const int y0) | |
1173 | { | ||
1174 | 915428 | VVCFrameContext *fc = lc->fc; | |
1175 | 915428 | const VVCSPS *sps = fc->ps.sps; | |
1176 | 915428 | const VVCPPS *pps = fc->ps.pps; | |
1177 | 915428 | const int rx = x0 >> sps->ctb_log2_size_y; | |
1178 | 915428 | const int ry = y0 >> sps->ctb_log2_size_y; | |
1179 | 915428 | CTU *ctu = fc->tab.ctus + ry * pps->ctb_width + rx; | |
1180 | 915428 | CodingUnit *cu = ff_refstruct_pool_get(fc->cu_pool); | |
1181 | |||
1182 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 915428 times.
|
915428 | if (!cu) |
1183 | ✗ | return NULL; | |
1184 | 915428 | cu->next = NULL; | |
1185 | |||
1186 |
2/2✓ Branch 0 taken 872537 times.
✓ Branch 1 taken 42891 times.
|
915428 | if (lc->cu) |
1187 | 872537 | lc->cu->next = cu; | |
1188 | else | ||
1189 | 42891 | ctu->cus = cu; | |
1190 | 915428 | lc->cu = cu; | |
1191 | |||
1192 | 915428 | return cu; | |
1193 | } | ||
1194 | |||
1195 | 915428 | static CodingUnit* add_cu(VVCLocalContext *lc, const int x0, const int y0, | |
1196 | const int cb_width, const int cb_height, const int cqt_depth, const VVCTreeType tree_type) | ||
1197 | { | ||
1198 | 915428 | VVCFrameContext *fc = lc->fc; | |
1199 | 915428 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
1200 | 915428 | CodingUnit *cu = alloc_cu(lc, x0, y0); | |
1201 | |||
1202 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 915428 times.
|
915428 | if (!cu) |
1203 | ✗ | return NULL; | |
1204 | |||
1205 | 915428 | memset(&cu->pu, 0, sizeof(cu->pu)); | |
1206 | |||
1207 | 915428 | lc->parse.prev_tu_cbf_y = 0; | |
1208 | |||
1209 | 915428 | cu->sbt_flag = 0; | |
1210 | 915428 | cu->act_enabled_flag = 0; | |
1211 | |||
1212 | 915428 | cu->tree_type = tree_type; | |
1213 | 915428 | cu->x0 = x0; | |
1214 | 915428 | cu->y0 = y0; | |
1215 | 915428 | cu->cb_width = cb_width; | |
1216 | 915428 | cu->cb_height = cb_height; | |
1217 | 915428 | cu->ch_type = ch_type; | |
1218 | 915428 | cu->cqt_depth = cqt_depth; | |
1219 | 915428 | cu->tus.head = cu->tus.tail = NULL; | |
1220 | 915428 | cu->bdpcm_flag[LUMA] = cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = 0; | |
1221 | 915428 | cu->isp_split_type = ISP_NO_SPLIT; | |
1222 | 915428 | cu->intra_mip_flag = 0; | |
1223 | 915428 | cu->ciip_flag = 0; | |
1224 | 915428 | cu->coded_flag = 1; | |
1225 | 915428 | cu->num_intra_subpartitions = 1; | |
1226 | 915428 | cu->pu.dmvr_flag = 0; | |
1227 | |||
1228 | 915428 | set_cb_pos(fc, cu); | |
1229 | 915428 | return cu; | |
1230 | } | ||
1231 | |||
1232 | 915428 | static void set_cu_tabs(const VVCLocalContext *lc, const CodingUnit *cu) | |
1233 | { | ||
1234 | 915428 | const VVCFrameContext *fc = lc->fc; | |
1235 | 915428 | const TransformUnit *tu = cu->tus.head; | |
1236 | |||
1237 |
2/2✓ Branch 0 taken 798904 times.
✓ Branch 1 taken 116524 times.
|
915428 | if (cu->tree_type != DUAL_TREE_CHROMA) { |
1238 | 798904 | set_cb_tab(lc, fc->tab.cpm[LUMA], cu->pred_mode); | |
1239 | 798904 | set_cb_tab(lc, fc->tab.skip, cu->skip_flag); | |
1240 | } | ||
1241 |
4/4✓ Branch 0 taken 881881 times.
✓ Branch 1 taken 33547 times.
✓ Branch 2 taken 529288 times.
✓ Branch 3 taken 352593 times.
|
915428 | if (fc->ps.sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA) |
1242 | 529288 | set_cb_tab(lc, fc->tab.cpm[CHROMA], cu->pred_mode); | |
1243 | |||
1244 |
2/2✓ Branch 0 taken 1126470 times.
✓ Branch 1 taken 915428 times.
|
2041898 | while (tu) { |
1245 |
2/2✓ Branch 0 taken 2267788 times.
✓ Branch 1 taken 1126470 times.
|
3394258 | for (int j = 0; j < tu->nb_tbs; j++) { |
1246 | 2267788 | const TransformBlock *tb = tu->tbs + j; | |
1247 |
2/2✓ Branch 0 taken 1257842 times.
✓ Branch 1 taken 1009946 times.
|
2267788 | if (tb->c_idx != LUMA) |
1248 | 1257842 | set_qp_c_tab(lc, tu, tb); | |
1249 |
4/4✓ Branch 0 taken 1638867 times.
✓ Branch 1 taken 628921 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 1638830 times.
|
2267788 | if (tb->c_idx != CR && cu->bdpcm_flag[tb->c_idx]) |
1250 | 37 | set_tb_tab(fc->tab.pcmf[tb->c_idx], 1, fc, tb); | |
1251 | } | ||
1252 | 1126470 | tu = tu->next; | |
1253 | } | ||
1254 | 915428 | } | |
1255 | |||
1256 | //8.5.2.7 Derivation process for merge motion vector difference | ||
1257 | 53777 | static void derive_mmvd(const VVCLocalContext *lc, MvField *mvf, const Mv *mmvd_offset) | |
1258 | { | ||
1259 | 53777 | const SliceContext *sc = lc->sc; | |
1260 | Mv mmvd[2]; | ||
1261 | |||
1262 |
2/2✓ Branch 0 taken 22780 times.
✓ Branch 1 taken 30997 times.
|
53777 | if (mvf->pred_flag == PF_BI) { |
1263 | 22780 | const RefPicList *rpl = sc->rpl; | |
1264 | 22780 | const int poc = lc->fc->ps.ph.poc; | |
1265 | 22780 | const int diff[] = { | |
1266 | 22780 | poc - rpl[0].list[mvf->ref_idx[0]], | |
1267 | 22780 | poc - rpl[1].list[mvf->ref_idx[1]] | |
1268 | }; | ||
1269 |
4/4✓ Branch 0 taken 21612 times.
✓ Branch 1 taken 1168 times.
✓ Branch 2 taken 8453 times.
✓ Branch 3 taken 14327 times.
|
22780 | const int sign = FFSIGN(diff[0]) != FFSIGN(diff[1]); |
1270 | |||
1271 |
2/2✓ Branch 0 taken 7775 times.
✓ Branch 1 taken 15005 times.
|
22780 | if (diff[0] == diff[1]) { |
1272 | 7775 | mmvd[1] = mmvd[0] = *mmvd_offset; | |
1273 | } | ||
1274 | else { | ||
1275 | 15005 | const int i = FFABS(diff[0]) < FFABS(diff[1]); | |
1276 | 15005 | const int o = !i; | |
1277 | 15005 | mmvd[i] = *mmvd_offset; | |
1278 |
2/4✓ Branch 0 taken 15005 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15005 times.
✗ Branch 3 not taken.
|
15005 | if (!rpl[0].isLongTerm[mvf->ref_idx[0]] && !rpl[1].isLongTerm[mvf->ref_idx[1]]) { |
1279 | 15005 | ff_vvc_mv_scale(&mmvd[o], mmvd_offset, diff[i], diff[o]); | |
1280 | } | ||
1281 | else { | ||
1282 | ✗ | mmvd[o].x = sign ? -mmvd[i].x : mmvd[i].x; | |
1283 | ✗ | mmvd[o].y = sign ? -mmvd[i].y : mmvd[i].y; | |
1284 | } | ||
1285 | } | ||
1286 | 22780 | mvf->mv[0].x += mmvd[0].x; | |
1287 | 22780 | mvf->mv[0].y += mmvd[0].y; | |
1288 | 22780 | mvf->mv[1].x += mmvd[1].x; | |
1289 | 22780 | mvf->mv[1].y += mmvd[1].y; | |
1290 | } else { | ||
1291 | 30997 | const int idx = mvf->pred_flag - PF_L0; | |
1292 | 30997 | mvf->mv[idx].x += mmvd_offset->x; | |
1293 | 30997 | mvf->mv[idx].y += mmvd_offset->y; | |
1294 | } | ||
1295 | |||
1296 | 53777 | } | |
1297 | |||
1298 | 263955 | static void mvf_to_mi(const MvField *mvf, MotionInfo *mi) | |
1299 | { | ||
1300 | 263955 | mi->pred_flag = mvf->pred_flag; | |
1301 | 263955 | mi->bcw_idx = mvf->bcw_idx; | |
1302 | 263955 | mi->hpel_if_idx = mvf->hpel_if_idx; | |
1303 |
2/2✓ Branch 0 taken 527910 times.
✓ Branch 1 taken 263955 times.
|
791865 | for (int i = 0; i < 2; i++) { |
1304 | 527910 | const PredFlag mask = i + 1; | |
1305 |
2/2✓ Branch 0 taken 416475 times.
✓ Branch 1 taken 111435 times.
|
527910 | if (mvf->pred_flag & mask) { |
1306 | 416475 | mi->mv[i][0] = mvf->mv[i]; | |
1307 | 416475 | mi->ref_idx[i] = mvf->ref_idx[i]; | |
1308 | } | ||
1309 | } | ||
1310 | 263955 | } | |
1311 | |||
1312 | 263955 | static void mv_merge_refine_pred_flag(MvField *mvf, const int width, const int height) | |
1313 | { | ||
1314 |
4/4✓ Branch 0 taken 157288 times.
✓ Branch 1 taken 106667 times.
✓ Branch 2 taken 4768 times.
✓ Branch 3 taken 152520 times.
|
263955 | if (mvf->pred_flag == PF_BI && (width + height) == 12) { |
1315 | 4768 | mvf->pred_flag = PF_L0; | |
1316 | 4768 | mvf->bcw_idx = 0; | |
1317 | } | ||
1318 | 263955 | } | |
1319 | |||
1320 | // subblock-based inter prediction data | ||
1321 | 48394 | static void merge_data_subblock(VVCLocalContext *lc) | |
1322 | { | ||
1323 | 48394 | const VVCFrameContext *fc = lc->fc; | |
1324 | 48394 | const VVCPH *ph = &fc->ps.ph; | |
1325 | 48394 | CodingUnit* cu = lc->cu; | |
1326 | 48394 | PredictionUnit *pu = &cu->pu; | |
1327 | 48394 | int merge_subblock_idx = 0; | |
1328 | |||
1329 | 48394 | set_cb_tab(lc, fc->tab.msf, pu->merge_subblock_flag); | |
1330 |
1/2✓ Branch 0 taken 48394 times.
✗ Branch 1 not taken.
|
48394 | if (ph->max_num_subblock_merge_cand > 1) { |
1331 | 48394 | merge_subblock_idx = ff_vvc_merge_subblock_idx(lc, ph->max_num_subblock_merge_cand); | |
1332 | } | ||
1333 | 48394 | ff_vvc_sb_mv_merge_mode(lc, merge_subblock_idx, pu); | |
1334 | 48394 | } | |
1335 | |||
1336 | 248548 | static void merge_data_regular(VVCLocalContext *lc) | |
1337 | { | ||
1338 | 248548 | const VVCFrameContext *fc = lc->fc; | |
1339 | 248548 | const VVCSPS *sps = fc->ps.sps; | |
1340 | 248548 | const VVCPH *ph = &fc->ps.ph; | |
1341 | 248548 | const CodingUnit* cu = lc->cu; | |
1342 | 248548 | PredictionUnit *pu = &lc->cu->pu; | |
1343 | 248548 | int merge_idx = 0; | |
1344 | Mv mmvd_offset; | ||
1345 | MvField mvf; | ||
1346 | |||
1347 |
1/2✓ Branch 0 taken 248548 times.
✗ Branch 1 not taken.
|
248548 | if (sps->r->sps_mmvd_enabled_flag) |
1348 | 248548 | pu->mmvd_merge_flag = ff_vvc_mmvd_merge_flag(lc); | |
1349 |
2/2✓ Branch 0 taken 53777 times.
✓ Branch 1 taken 194771 times.
|
248548 | if (pu->mmvd_merge_flag) { |
1350 | 53777 | int mmvd_cand_flag = 0; | |
1351 |
1/2✓ Branch 0 taken 53777 times.
✗ Branch 1 not taken.
|
53777 | if (sps->max_num_merge_cand > 1) |
1352 | 53777 | mmvd_cand_flag = ff_vvc_mmvd_cand_flag(lc); | |
1353 | 53777 | ff_vvc_mmvd_offset_coding(lc, &mmvd_offset, ph->r->ph_mmvd_fullpel_only_flag); | |
1354 | 53777 | merge_idx = mmvd_cand_flag; | |
1355 |
1/2✓ Branch 0 taken 194771 times.
✗ Branch 1 not taken.
|
194771 | } else if (sps->max_num_merge_cand > 1) { |
1356 | 194771 | merge_idx = ff_vvc_merge_idx(lc); | |
1357 | } | ||
1358 | 248548 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 0, &mvf); | |
1359 |
2/2✓ Branch 0 taken 53777 times.
✓ Branch 1 taken 194771 times.
|
248548 | if (pu->mmvd_merge_flag) |
1360 | 53777 | derive_mmvd(lc, &mvf, &mmvd_offset); | |
1361 | 248548 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
1362 | 248548 | ff_vvc_store_mvf(lc, &mvf); | |
1363 | 248548 | mvf_to_mi(&mvf, &pu->mi); | |
1364 | 248548 | } | |
1365 | |||
1366 | 39805 | static int ciip_flag_decode(VVCLocalContext *lc, const int ciip_avaiable, const int gpm_avaiable, const int is_128) | |
1367 | { | ||
1368 | 39805 | const VVCFrameContext *fc = lc->fc; | |
1369 | 39805 | const VVCSPS *sps = fc->ps.sps; | |
1370 | 39805 | const CodingUnit *cu = lc->cu; | |
1371 | |||
1372 |
4/4✓ Branch 0 taken 25016 times.
✓ Branch 1 taken 14789 times.
✓ Branch 2 taken 18493 times.
✓ Branch 3 taken 6523 times.
|
39805 | if (ciip_avaiable && gpm_avaiable) |
1373 | 18493 | return ff_vvc_ciip_flag(lc); | |
1374 |
3/4✓ Branch 0 taken 6523 times.
✓ Branch 1 taken 14789 times.
✓ Branch 2 taken 6523 times.
✗ Branch 3 not taken.
|
21312 | return sps->r->sps_ciip_enabled_flag && !cu->skip_flag && |
1375 |
2/4✓ Branch 0 taken 21312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6523 times.
✗ Branch 3 not taken.
|
42624 | !is_128 && (cu->cb_width * cu->cb_height >= 64); |
1376 | } | ||
1377 | |||
1378 | 24398 | static void merge_data_gpm(VVCLocalContext *lc) | |
1379 | { | ||
1380 | 24398 | const VVCFrameContext *fc = lc->fc; | |
1381 | 24398 | const VVCSPS *sps = fc->ps.sps; | |
1382 | 24398 | PredictionUnit *pu = &lc->cu->pu; | |
1383 | int merge_gpm_idx[2]; | ||
1384 | |||
1385 | 24398 | pu->merge_gpm_flag = 1; | |
1386 | 24398 | pu->gpm_partition_idx = ff_vvc_merge_gpm_partition_idx(lc); | |
1387 | 24398 | merge_gpm_idx[0] = ff_vvc_merge_gpm_idx(lc, 0); | |
1388 | 24398 | merge_gpm_idx[1] = 0; | |
1389 |
1/2✓ Branch 0 taken 24398 times.
✗ Branch 1 not taken.
|
24398 | if (sps->max_num_gpm_merge_cand > 2) |
1390 | 24398 | merge_gpm_idx[1] = ff_vvc_merge_gpm_idx(lc, 1); | |
1391 | |||
1392 | 24398 | ff_vvc_luma_mv_merge_gpm(lc, merge_gpm_idx, pu->gpm_mv); | |
1393 | 24398 | ff_vvc_store_gpm_mvf(lc, pu); | |
1394 | 24398 | } | |
1395 | |||
1396 | 15407 | static void merge_data_ciip(VVCLocalContext *lc) | |
1397 | { | ||
1398 | 15407 | const VVCFrameContext* fc = lc->fc; | |
1399 | 15407 | const VVCSPS* sps = fc->ps.sps; | |
1400 | 15407 | CodingUnit *cu = lc->cu; | |
1401 | 15407 | MotionInfo *mi = &cu->pu.mi; | |
1402 | 15407 | int merge_idx = 0; | |
1403 | MvField mvf; | ||
1404 | |||
1405 |
1/2✓ Branch 0 taken 15407 times.
✗ Branch 1 not taken.
|
15407 | if (sps->max_num_merge_cand > 1) |
1406 | 15407 | merge_idx = ff_vvc_merge_idx(lc); | |
1407 | 15407 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 1, &mvf); | |
1408 | 15407 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
1409 | 15407 | ff_vvc_store_mvf(lc, &mvf); | |
1410 | 15407 | mvf_to_mi(&mvf, mi); | |
1411 | 15407 | cu->intra_pred_mode_y = cu->intra_pred_mode_c = INTRA_PLANAR; | |
1412 | 15407 | cu->intra_luma_ref_idx = 0; | |
1413 | 15407 | cu->intra_mip_flag = 0; | |
1414 | 15407 | } | |
1415 | |||
1416 | // block-based inter prediction data | ||
1417 | 288353 | static void merge_data_block(VVCLocalContext *lc) | |
1418 | { | ||
1419 | 288353 | const VVCFrameContext* fc = lc->fc; | |
1420 | 288353 | const VVCSPS *sps = fc->ps.sps; | |
1421 | 288353 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1422 | 288353 | CodingUnit *cu = lc->cu; | |
1423 | 288353 | const int cb_width = cu->cb_width; | |
1424 | 288353 | const int cb_height = cu->cb_height; | |
1425 |
4/4✓ Branch 0 taken 271095 times.
✓ Branch 1 taken 17258 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 269769 times.
|
288353 | const int is_128 = cb_width == 128 || cb_height == 128; |
1426 | 865059 | const int ciip_avaiable = sps->r->sps_ciip_enabled_flag && | |
1427 |
5/6✓ Branch 0 taken 288353 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96292 times.
✓ Branch 3 taken 192061 times.
✓ Branch 4 taken 86290 times.
✓ Branch 5 taken 10002 times.
|
288353 | !cu->skip_flag && (cb_width * cb_height >= 64); |
1428 |
3/4✓ Branch 0 taken 274085 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239944 times.
✓ Branch 3 taken 34141 times.
|
274085 | const int gpm_avaiable = sps->r->sps_gpm_enabled_flag && IS_B(rsh) && |
1429 |
2/2✓ Branch 0 taken 214551 times.
✓ Branch 1 taken 25393 times.
|
239944 | (cb_width >= 8) && (cb_height >=8) && |
1430 |
6/6✓ Branch 0 taken 274085 times.
✓ Branch 1 taken 14268 times.
✓ Branch 2 taken 208504 times.
✓ Branch 3 taken 6047 times.
✓ Branch 4 taken 206744 times.
✓ Branch 5 taken 1760 times.
|
562438 | (cb_width < 8 * cb_height) && (cb_height < 8 *cb_width); |
1431 | |||
1432 | 288353 | int regular_merge_flag = 1; | |
1433 | |||
1434 |
6/6✓ Branch 0 taken 269769 times.
✓ Branch 1 taken 18584 times.
✓ Branch 2 taken 183770 times.
✓ Branch 3 taken 85999 times.
✓ Branch 4 taken 127808 times.
✓ Branch 5 taken 55962 times.
|
288353 | if (!is_128 && (ciip_avaiable || gpm_avaiable)) |
1435 | 213807 | regular_merge_flag = ff_vvc_regular_merge_flag(lc, cu->skip_flag); | |
1436 |
2/2✓ Branch 0 taken 248548 times.
✓ Branch 1 taken 39805 times.
|
288353 | if (regular_merge_flag) { |
1437 | 248548 | merge_data_regular(lc); | |
1438 | } else { | ||
1439 | 39805 | cu->ciip_flag = ciip_flag_decode(lc, ciip_avaiable, gpm_avaiable, is_128); | |
1440 |
2/2✓ Branch 0 taken 15407 times.
✓ Branch 1 taken 24398 times.
|
39805 | if (cu->ciip_flag) |
1441 | 15407 | merge_data_ciip(lc); | |
1442 | else | ||
1443 | 24398 | merge_data_gpm(lc); | |
1444 | } | ||
1445 | 288353 | } | |
1446 | |||
1447 | 240 | static void merge_data_ibc(VVCLocalContext *lc) | |
1448 | { | ||
1449 | 240 | const VVCFrameContext* fc = lc->fc; | |
1450 | 240 | const VVCSPS* sps = fc->ps.sps; | |
1451 | 240 | MotionInfo *mi = &lc->cu->pu.mi; | |
1452 | 240 | int merge_idx = 0; | |
1453 | |||
1454 | 240 | mi->pred_flag = PF_IBC; | |
1455 | |||
1456 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 240 times.
|
240 | if (sps->max_num_ibc_merge_cand > 1) |
1457 | ✗ | merge_idx = ff_vvc_merge_idx(lc); | |
1458 | |||
1459 | 240 | ff_vvc_luma_mv_merge_ibc(lc, merge_idx, &mi->mv[L0][0]); | |
1460 | 240 | ff_vvc_store_mv(lc, mi); | |
1461 | 240 | } | |
1462 | |||
1463 | 336987 | static int hls_merge_data(VVCLocalContext *lc) | |
1464 | { | ||
1465 | 336987 | const VVCFrameContext *fc = lc->fc; | |
1466 | 336987 | const VVCPH *ph = &fc->ps.ph; | |
1467 | 336987 | const CodingUnit *cu = lc->cu; | |
1468 | 336987 | PredictionUnit *pu = &lc->cu->pu; | |
1469 | |||
1470 | 336987 | pu->merge_gpm_flag = 0; | |
1471 | 336987 | pu->mi.num_sb_x = pu->mi.num_sb_y = 1; | |
1472 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 336747 times.
|
336987 | if (cu->pred_mode == MODE_IBC) { |
1473 | 240 | merge_data_ibc(lc); | |
1474 | } else { | ||
1475 |
5/6✓ Branch 0 taken 336747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300954 times.
✓ Branch 3 taken 35793 times.
✓ Branch 4 taken 273947 times.
✓ Branch 5 taken 27007 times.
|
336747 | if (ph->max_num_subblock_merge_cand > 0 && cu->cb_width >= 8 && cu->cb_height >= 8) |
1476 | 273947 | pu->merge_subblock_flag = ff_vvc_merge_subblock_flag(lc); | |
1477 |
2/2✓ Branch 0 taken 48394 times.
✓ Branch 1 taken 288353 times.
|
336747 | if (pu->merge_subblock_flag) |
1478 | 48394 | merge_data_subblock(lc); | |
1479 | else | ||
1480 | 288353 | merge_data_block(lc); | |
1481 | } | ||
1482 | 336987 | return 0; | |
1483 | } | ||
1484 | |||
1485 | 80563 | static void hls_mvd_coding(VVCLocalContext *lc, Mv* mvd) | |
1486 | { | ||
1487 | int16_t mv[2]; | ||
1488 | |||
1489 |
2/2✓ Branch 0 taken 161126 times.
✓ Branch 1 taken 80563 times.
|
241689 | for (int i = 0; i < 2; i++) { |
1490 | 161126 | mv[i] = ff_vvc_abs_mvd_greater0_flag(lc); | |
1491 | } | ||
1492 | |||
1493 |
2/2✓ Branch 0 taken 161126 times.
✓ Branch 1 taken 80563 times.
|
241689 | for (int i = 0; i < 2; i++) { |
1494 |
2/2✓ Branch 0 taken 112328 times.
✓ Branch 1 taken 48798 times.
|
161126 | if (mv[i]) |
1495 | 112328 | mv[i] += ff_vvc_abs_mvd_greater1_flag(lc); | |
1496 | } | ||
1497 | |||
1498 |
2/2✓ Branch 0 taken 161126 times.
✓ Branch 1 taken 80563 times.
|
241689 | for (int i = 0; i < 2; i++) { |
1499 |
2/2✓ Branch 0 taken 112328 times.
✓ Branch 1 taken 48798 times.
|
161126 | if (mv[i] > 0) { |
1500 |
2/2✓ Branch 0 taken 65730 times.
✓ Branch 1 taken 46598 times.
|
112328 | if (mv[i] == 2) |
1501 | 65730 | mv[i] += ff_vvc_abs_mvd_minus2(lc); | |
1502 | 112328 | mv[i] = (1 - 2 * ff_vvc_mvd_sign_flag(lc)) * mv[i]; | |
1503 | } | ||
1504 | } | ||
1505 | 80563 | mvd->x = mv[0]; | |
1506 | 80563 | mvd->y = mv[1]; | |
1507 | 80563 | } | |
1508 | |||
1509 | 57321 | static int bcw_idx_decode(VVCLocalContext *lc, const MotionInfo *mi, const int cb_width, const int cb_height) | |
1510 | { | ||
1511 | 57321 | const VVCFrameContext *fc = lc->fc; | |
1512 | 57321 | const VVCSPS *sps = fc->ps.sps; | |
1513 | 57321 | const VVCPPS *pps = fc->ps.pps; | |
1514 | 57321 | const VVCPH *ph = &fc->ps.ph; | |
1515 | 57321 | const VVCSH *sh = &lc->sc->sh; | |
1516 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 57321 times.
|
57321 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &ph->pwt : &sh->pwt; |
1517 | 57321 | int bcw_idx = 0; | |
1518 | |||
1519 |
4/4✓ Branch 0 taken 55383 times.
✓ Branch 1 taken 1938 times.
✓ Branch 2 taken 17018 times.
✓ Branch 3 taken 38365 times.
|
57321 | if (sps->r->sps_bcw_enabled_flag && mi->pred_flag == PF_BI && |
1520 |
2/2✓ Branch 0 taken 16830 times.
✓ Branch 1 taken 188 times.
|
17018 | !w->weight_flag[L0][LUMA][mi->ref_idx[0]] && |
1521 |
1/2✓ Branch 0 taken 16830 times.
✗ Branch 1 not taken.
|
16830 | !w->weight_flag[L1][LUMA][mi->ref_idx[1]] && |
1522 |
1/2✓ Branch 0 taken 16830 times.
✗ Branch 1 not taken.
|
16830 | !w->weight_flag[L0][CHROMA][mi->ref_idx[0]] && |
1523 |
1/2✓ Branch 0 taken 16830 times.
✗ Branch 1 not taken.
|
16830 | !w->weight_flag[L1][CHROMA][mi->ref_idx[1]] && |
1524 |
2/2✓ Branch 0 taken 11024 times.
✓ Branch 1 taken 5806 times.
|
16830 | cb_width * cb_height >= 256) { |
1525 | 11024 | bcw_idx = ff_vvc_bcw_idx(lc, ff_vvc_no_backward_pred_flag(lc)); | |
1526 | } | ||
1527 | 57321 | return bcw_idx; | |
1528 | } | ||
1529 | |||
1530 | 74339 | static int8_t ref_idx_decode(VVCLocalContext *lc, const VVCSH *sh, const int sym_mvd_flag, const int lx) | |
1531 | { | ||
1532 | 74339 | const H266RawSliceHeader *rsh = sh->r; | |
1533 | 74339 | int ref_idx = 0; | |
1534 | |||
1535 |
4/4✓ Branch 0 taken 58163 times.
✓ Branch 1 taken 16176 times.
✓ Branch 2 taken 46681 times.
✓ Branch 3 taken 11482 times.
|
74339 | if (rsh->num_ref_idx_active[lx] > 1 && !sym_mvd_flag) |
1536 | 46681 | ref_idx = ff_vvc_ref_idx_lx(lc, rsh->num_ref_idx_active[lx]); | |
1537 |
2/2✓ Branch 0 taken 11482 times.
✓ Branch 1 taken 16176 times.
|
27658 | else if (sym_mvd_flag) |
1538 | 11482 | ref_idx = sh->ref_idx_sym[lx]; | |
1539 | 74339 | return ref_idx; | |
1540 | } | ||
1541 | |||
1542 | 74339 | static int mvds_decode(VVCLocalContext *lc, Mv mvds[2][MAX_CONTROL_POINTS], | |
1543 | const int num_cp_mv, const int lx) | ||
1544 | { | ||
1545 | 74339 | const VVCFrameContext *fc = lc->fc; | |
1546 | 74339 | const VVCPH *ph = &fc->ps.ph; | |
1547 | 74339 | const PredictionUnit *pu = &lc->cu->pu; | |
1548 | 74339 | const MotionInfo *mi = &pu->mi; | |
1549 | 74339 | int has_no_zero_mvd = 0; | |
1550 | |||
1551 |
5/6✓ Branch 0 taken 24998 times.
✓ Branch 1 taken 49341 times.
✓ Branch 2 taken 4457 times.
✓ Branch 3 taken 20541 times.
✓ Branch 4 taken 4457 times.
✗ Branch 5 not taken.
|
74339 | if (lx == L1 && ph->r->ph_mvd_l1_zero_flag && mi->pred_flag == PF_BI) { |
1552 |
2/2✓ Branch 0 taken 5756 times.
✓ Branch 1 taken 4457 times.
|
10213 | for (int j = 0; j < num_cp_mv; j++) |
1553 | 5756 | AV_ZERO64(&mvds[lx][j]); | |
1554 | } else { | ||
1555 | 69882 | Mv *mvd0 = &mvds[lx][0]; | |
1556 |
4/4✓ Branch 0 taken 20541 times.
✓ Branch 1 taken 49341 times.
✓ Branch 2 taken 5741 times.
✓ Branch 3 taken 14800 times.
|
69882 | if (lx == L1 && pu->sym_mvd_flag) { |
1557 | 5741 | mvd0->x = -mvds[L0][0].x; | |
1558 | 5741 | mvd0->y = -mvds[L0][0].y; | |
1559 | } else { | ||
1560 | 64141 | hls_mvd_coding(lc, mvd0); | |
1561 | } | ||
1562 |
4/4✓ Branch 0 taken 20743 times.
✓ Branch 1 taken 49139 times.
✓ Branch 2 taken 13209 times.
✓ Branch 3 taken 7534 times.
|
69882 | has_no_zero_mvd |= (mvd0->x || mvd0->y); |
1563 |
2/2✓ Branch 0 taken 15080 times.
✓ Branch 1 taken 69882 times.
|
84962 | for (int j = 1; j < num_cp_mv; j++) { |
1564 | 15080 | Mv *mvd = &mvds[lx][j]; | |
1565 | 15080 | hls_mvd_coding(lc, mvd); | |
1566 | 15080 | mvd->x += mvd0->x; | |
1567 | 15080 | mvd->y += mvd0->y; | |
1568 |
4/4✓ Branch 0 taken 2910 times.
✓ Branch 1 taken 12170 times.
✓ Branch 2 taken 1985 times.
✓ Branch 3 taken 925 times.
|
15080 | has_no_zero_mvd |= (mvd->x || mvd->y); |
1569 | } | ||
1570 | } | ||
1571 | 74339 | return has_no_zero_mvd; | |
1572 | } | ||
1573 | |||
1574 | 57321 | static void mvp_add_difference(MotionInfo *mi, const int num_cp_mv, | |
1575 | const Mv mvds[2][MAX_CONTROL_POINTS], const int amvr_shift) | ||
1576 | { | ||
1577 |
2/2✓ Branch 0 taken 114642 times.
✓ Branch 1 taken 57321 times.
|
171963 | for (int i = 0; i < 2; i++) { |
1578 | 114642 | const PredFlag mask = i + PF_L0; | |
1579 |
2/2✓ Branch 0 taken 74339 times.
✓ Branch 1 taken 40303 times.
|
114642 | if (mi->pred_flag & mask) { |
1580 |
2/2✓ Branch 0 taken 90718 times.
✓ Branch 1 taken 74339 times.
|
165057 | for (int j = 0; j < num_cp_mv; j++) { |
1581 | 90718 | const Mv *mvd = &mvds[i][j]; | |
1582 | 90718 | mi->mv[i][j].x += mvd->x * (1 << amvr_shift); | |
1583 | 90718 | mi->mv[i][j].y += mvd->y * (1 << amvr_shift); | |
1584 | } | ||
1585 | } | ||
1586 | } | ||
1587 | 57321 | } | |
1588 | |||
1589 | 1342 | static int mvp_data_ibc(VVCLocalContext *lc) | |
1590 | { | ||
1591 | 1342 | const VVCFrameContext *fc = lc->fc; | |
1592 | 1342 | const CodingUnit *cu = lc->cu; | |
1593 | 1342 | const PredictionUnit *pu = &lc->cu->pu; | |
1594 | 1342 | const VVCSPS *sps = fc->ps.sps; | |
1595 | 1342 | MotionInfo *mi = &lc->cu->pu.mi; | |
1596 | 1342 | int mvp_l0_flag = 0; | |
1597 | 1342 | int amvr_shift = 4; | |
1598 | 1342 | Mv *mv = &mi->mv[L0][0]; | |
1599 | |||
1600 | 1342 | mi->pred_flag = PF_IBC; | |
1601 | 1342 | mi->num_sb_x = 1; | |
1602 | 1342 | mi->num_sb_y = 1; | |
1603 | |||
1604 | 1342 | hls_mvd_coding(lc, mv); | |
1605 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1342 times.
|
1342 | if (sps->max_num_ibc_merge_cand > 1) |
1606 | ✗ | mvp_l0_flag = ff_vvc_mvp_lx_flag(lc); | |
1607 |
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)) |
1608 | 1078 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, 1); | |
1609 | |||
1610 | 1342 | ff_vvc_mvp_ibc(lc, mvp_l0_flag, amvr_shift, mv); | |
1611 | 1342 | ff_vvc_store_mv(lc, mi); | |
1612 | |||
1613 | 1342 | return 0; | |
1614 | } | ||
1615 | |||
1616 | 57321 | static int mvp_data(VVCLocalContext *lc) | |
1617 | { | ||
1618 | 57321 | const VVCFrameContext *fc = lc->fc; | |
1619 | 57321 | const CodingUnit *cu = lc->cu; | |
1620 | 57321 | PredictionUnit *pu = &lc->cu->pu; | |
1621 | 57321 | const VVCSPS *sps = fc->ps.sps; | |
1622 | 57321 | const VVCPH *ph = &fc->ps.ph; | |
1623 | 57321 | const VVCSH *sh = &lc->sc->sh; | |
1624 | 57321 | const H266RawSliceHeader *rsh = sh->r; | |
1625 | 57321 | MotionInfo *mi = &pu->mi; | |
1626 | 57321 | const int cb_width = cu->cb_width; | |
1627 | 57321 | const int cb_height = cu->cb_height; | |
1628 | |||
1629 | 57321 | int mvp_lx_flag[2] = {0}; | |
1630 | 57321 | int cu_affine_type_flag = 0; | |
1631 | int num_cp_mv; | ||
1632 | 57321 | int amvr_enabled, has_no_zero_mvd = 0, amvr_shift; | |
1633 | Mv mvds[2][MAX_CONTROL_POINTS]; | ||
1634 | |||
1635 | 57321 | mi->pred_flag = ff_vvc_pred_flag(lc, IS_B(rsh)); | |
1636 |
5/6✓ Branch 0 taken 57321 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32852 times.
✓ Branch 3 taken 24469 times.
✓ Branch 4 taken 25325 times.
✓ Branch 5 taken 7527 times.
|
57321 | if (sps->r->sps_affine_enabled_flag && cb_width >= 16 && cb_height >= 16) { |
1637 | 25325 | pu->inter_affine_flag = ff_vvc_inter_affine_flag(lc); | |
1638 | 25325 | set_cb_tab(lc, fc->tab.iaf, pu->inter_affine_flag); | |
1639 |
3/4✓ Branch 0 taken 25325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 16324 times.
|
25325 | if (sps->r->sps_6param_affine_enabled_flag && pu->inter_affine_flag) |
1640 | 9001 | cu_affine_type_flag = ff_vvc_cu_affine_type_flag(lc); | |
1641 | } | ||
1642 | 57321 | mi->motion_model_idc = pu->inter_affine_flag + cu_affine_type_flag; | |
1643 | 57321 | num_cp_mv = mi->motion_model_idc + 1; | |
1644 | |||
1645 |
4/4✓ Branch 0 taken 47609 times.
✓ Branch 1 taken 9712 times.
✓ Branch 2 taken 37569 times.
✓ Branch 3 taken 10040 times.
|
57321 | if (sps->r->sps_smvd_enabled_flag && !ph->r->ph_mvd_l1_zero_flag && |
1646 |
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 && |
1647 |
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) |
1648 | 11430 | pu->sym_mvd_flag = ff_vvc_sym_mvd_flag(lc); | |
1649 | |||
1650 |
2/2✓ Branch 0 taken 114642 times.
✓ Branch 1 taken 57321 times.
|
171963 | for (int i = L0; i <= L1; i++) { |
1651 |
2/2✓ Branch 0 taken 57321 times.
✓ Branch 1 taken 57321 times.
|
114642 | const PredFlag pred_flag = PF_L0 + !i; |
1652 |
2/2✓ Branch 0 taken 74339 times.
✓ Branch 1 taken 40303 times.
|
114642 | if (mi->pred_flag != pred_flag) { |
1653 | 74339 | mi->ref_idx[i] = ref_idx_decode(lc, sh, pu->sym_mvd_flag, i); | |
1654 | 74339 | has_no_zero_mvd |= mvds_decode(lc, mvds, num_cp_mv, i); | |
1655 | 74339 | mvp_lx_flag[i] = ff_vvc_mvp_lx_flag(lc); | |
1656 | } | ||
1657 | } | ||
1658 | |||
1659 | 114642 | amvr_enabled = mi->motion_model_idc == MOTION_TRANSLATION ? | |
1660 |
2/2✓ Branch 0 taken 48320 times.
✓ Branch 1 taken 9001 times.
|
57321 | sps->r->sps_amvr_enabled_flag : sps->r->sps_affine_amvr_enabled_flag; |
1661 | 57321 | amvr_enabled &= has_no_zero_mvd; | |
1662 | |||
1663 | 57321 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, amvr_enabled); | |
1664 | |||
1665 | 57321 | mi->hpel_if_idx = amvr_shift == 3; | |
1666 | 57321 | mi->bcw_idx = bcw_idx_decode(lc, mi, cb_width, cb_height); | |
1667 | |||
1668 |
2/2✓ Branch 0 taken 9001 times.
✓ Branch 1 taken 48320 times.
|
57321 | if (mi->motion_model_idc) |
1669 | 9001 | ff_vvc_affine_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
1670 | else | ||
1671 | 48320 | ff_vvc_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
1672 | |||
1673 | 57321 | mvp_add_difference(mi, num_cp_mv, mvds, amvr_shift); | |
1674 | |||
1675 |
2/2✓ Branch 0 taken 9001 times.
✓ Branch 1 taken 48320 times.
|
57321 | if (mi->motion_model_idc) |
1676 | 9001 | ff_vvc_store_sb_mvs(lc, pu); | |
1677 | else | ||
1678 | 48320 | ff_vvc_store_mv(lc, &pu->mi); | |
1679 | |||
1680 | 57321 | return 0; | |
1681 | } | ||
1682 | |||
1683 | // derive bdofFlag from 8.5.6 Decoding process for inter blocks | ||
1684 | // derive dmvr from 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
1685 | 312275 | static void derive_dmvr_bdof_flag(const VVCLocalContext *lc, PredictionUnit *pu) | |
1686 | { | ||
1687 | 312275 | const VVCFrameContext *fc = lc->fc; | |
1688 | 312275 | const VVCPPS *pps = fc->ps.pps; | |
1689 | 312275 | const VVCPH *ph = &fc->ps.ph; | |
1690 | 312275 | const VVCSH *sh = &lc->sc->sh; | |
1691 | 312275 | const int poc = ph->poc; | |
1692 | 312275 | const RefPicList *rpl0 = lc->sc->rpl + L0; | |
1693 | 312275 | const RefPicList *rpl1 = lc->sc->rpl + L1; | |
1694 | 312275 | const int8_t *ref_idx = pu->mi.ref_idx; | |
1695 | 312275 | const MotionInfo *mi = &pu->mi; | |
1696 | 312275 | const CodingUnit *cu = lc->cu; | |
1697 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 312275 times.
|
312275 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt; |
1698 | |||
1699 | 312275 | pu->bdof_flag = 0; | |
1700 | |||
1701 |
2/2✓ Branch 0 taken 167501 times.
✓ Branch 1 taken 144774 times.
|
312275 | if (mi->pred_flag == PF_BI && |
1702 |
2/2✓ Branch 0 taken 114623 times.
✓ Branch 1 taken 52878 times.
|
167501 | (poc - rpl0->list[ref_idx[L0]] == rpl1->list[ref_idx[L1]] - poc) && |
1703 |
2/4✓ Branch 0 taken 114623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114623 times.
✗ Branch 3 not taken.
|
114623 | !rpl0->isLongTerm[ref_idx[L0]] && !rpl1->isLongTerm[ref_idx[L1]] && |
1704 |
2/2✓ Branch 0 taken 111903 times.
✓ Branch 1 taken 2720 times.
|
114623 | !cu->ciip_flag && |
1705 |
2/2✓ Branch 0 taken 98407 times.
✓ Branch 1 taken 13496 times.
|
111903 | !mi->bcw_idx && |
1706 |
3/4✓ Branch 0 taken 97437 times.
✓ Branch 1 taken 970 times.
✓ Branch 2 taken 97437 times.
✗ Branch 3 not taken.
|
98407 | !w->weight_flag[L0][LUMA][mi->ref_idx[L0]] && !w->weight_flag[L1][LUMA][mi->ref_idx[L1]] && |
1707 |
2/4✓ Branch 0 taken 97437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97437 times.
✗ Branch 3 not taken.
|
97437 | !w->weight_flag[L0][CHROMA][mi->ref_idx[L0]] && !w->weight_flag[L1][CHROMA][mi->ref_idx[L1]] && |
1708 |
4/4✓ Branch 0 taken 91685 times.
✓ Branch 1 taken 5752 times.
✓ Branch 2 taken 88098 times.
✓ Branch 3 taken 3587 times.
|
97437 | cu->cb_width >= 8 && cu->cb_height >= 8 && |
1709 |
2/2✓ Branch 0 taken 83260 times.
✓ Branch 1 taken 4838 times.
|
88098 | (cu->cb_width * cu->cb_height >= 128)) { |
1710 | // fixme: for RprConstraintsActiveFlag | ||
1711 |
1/2✓ Branch 0 taken 83260 times.
✗ Branch 1 not taken.
|
83260 | if (!ph->r->ph_bdof_disabled_flag && |
1712 |
1/2✓ Branch 0 taken 83260 times.
✗ Branch 1 not taken.
|
83260 | mi->motion_model_idc == MOTION_TRANSLATION && |
1713 |
1/2✓ Branch 0 taken 83260 times.
✗ Branch 1 not taken.
|
83260 | !pu->merge_subblock_flag && |
1714 |
2/2✓ Branch 0 taken 80450 times.
✓ Branch 1 taken 2810 times.
|
83260 | !pu->sym_mvd_flag) |
1715 | 80450 | pu->bdof_flag = 1; | |
1716 |
2/2✓ Branch 0 taken 80803 times.
✓ Branch 1 taken 2457 times.
|
83260 | if (!ph->r->ph_dmvr_disabled_flag && |
1717 |
2/2✓ Branch 0 taken 75478 times.
✓ Branch 1 taken 5325 times.
|
80803 | pu->general_merge_flag && |
1718 |
2/2✓ Branch 0 taken 68451 times.
✓ Branch 1 taken 7027 times.
|
75478 | !pu->mmvd_merge_flag) |
1719 | 68451 | pu->dmvr_flag = 1; | |
1720 | } | ||
1721 | 312275 | } | |
1722 | |||
1723 | // part of 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
1724 | 312275 | static void refine_regular_subblock(const VVCLocalContext *lc) | |
1725 | { | ||
1726 | 312275 | const CodingUnit *cu = lc->cu; | |
1727 | 312275 | PredictionUnit *pu = &lc->cu->pu; | |
1728 | |||
1729 | 312275 | derive_dmvr_bdof_flag(lc, pu); | |
1730 |
4/4✓ Branch 0 taken 243824 times.
✓ Branch 1 taken 68451 times.
✓ Branch 2 taken 11999 times.
✓ Branch 3 taken 231825 times.
|
312275 | if (pu->dmvr_flag || pu->bdof_flag) { |
1731 |
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; |
1732 |
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; |
1733 | } | ||
1734 | 312275 | } | |
1735 | |||
1736 | 327199 | static void fill_dmvr_info(const VVCLocalContext *lc) | |
1737 | { | ||
1738 | 327199 | const VVCFrameContext *fc = lc->fc; | |
1739 | 327199 | const CodingUnit *cu = lc->cu; | |
1740 | |||
1741 |
2/2✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 325617 times.
|
327199 | if (cu->pred_mode == MODE_IBC) { |
1742 | 1582 | ff_vvc_set_intra_mvf(lc, 1); | |
1743 | } else { | ||
1744 | 325617 | const VVCPPS *pps = fc->ps.pps; | |
1745 | 325617 | const int w = cu->cb_width >> MIN_PU_LOG2; | |
1746 | |||
1747 |
2/2✓ Branch 0 taken 1865570 times.
✓ Branch 1 taken 325617 times.
|
2191187 | for (int y = cu->y0 >> MIN_PU_LOG2; y < (cu->y0 + cu->cb_height) >> MIN_PU_LOG2; y++) { |
1748 | 1865570 | const int idx = pps->min_pu_width * y + (cu->x0 >> MIN_PU_LOG2); | |
1749 | 1865570 | const MvField *mvf = fc->tab.mvf + idx; | |
1750 | 1865570 | MvField *dmvr_mvf = fc->ref->tab_dmvr_mvf + idx; | |
1751 | |||
1752 | 1865570 | memcpy(dmvr_mvf, mvf, sizeof(MvField) * w); | |
1753 | } | ||
1754 | } | ||
1755 | 327199 | } | |
1756 | |||
1757 | 395650 | static int inter_data(VVCLocalContext *lc) | |
1758 | { | ||
1759 | 395650 | const CodingUnit *cu = lc->cu; | |
1760 | 395650 | PredictionUnit *pu = &lc->cu->pu; | |
1761 | 395650 | const MotionInfo *mi = &pu->mi; | |
1762 | 395650 | int ret = 0; | |
1763 | |||
1764 | 395650 | pu->general_merge_flag = 1; | |
1765 |
2/2✓ Branch 0 taken 167173 times.
✓ Branch 1 taken 228477 times.
|
395650 | if (!cu->skip_flag) |
1766 | 167173 | pu->general_merge_flag = ff_vvc_general_merge_flag(lc); | |
1767 | |||
1768 |
2/2✓ Branch 0 taken 336987 times.
✓ Branch 1 taken 58663 times.
|
395650 | if (pu->general_merge_flag) { |
1769 | 336987 | hls_merge_data(lc); | |
1770 |
2/2✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 57321 times.
|
58663 | } else if (cu->pred_mode == MODE_IBC){ |
1771 | 1342 | ret = mvp_data_ibc(lc); | |
1772 | } else { | ||
1773 | 57321 | ret = mvp_data(lc); | |
1774 | } | ||
1775 | |||
1776 |
2/2✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 394068 times.
|
395650 | if (cu->pred_mode == MODE_IBC) |
1777 | { | ||
1778 | 1582 | ff_vvc_update_hmvp(lc, mi); | |
1779 |
6/6✓ Branch 0 taken 369670 times.
✓ Branch 1 taken 24398 times.
✓ Branch 2 taken 337592 times.
✓ Branch 3 taken 32078 times.
✓ Branch 4 taken 312275 times.
✓ Branch 5 taken 25317 times.
|
394068 | } else if (!pu->merge_gpm_flag && !pu->inter_affine_flag && !pu->merge_subblock_flag) { |
1780 | 312275 | refine_regular_subblock(lc); | |
1781 | 312275 | ff_vvc_update_hmvp(lc, mi); | |
1782 | } | ||
1783 | |||
1784 |
2/2✓ Branch 0 taken 327199 times.
✓ Branch 1 taken 68451 times.
|
395650 | if (!pu->dmvr_flag) |
1785 | 327199 | fill_dmvr_info(lc); | |
1786 | 395650 | return ret; | |
1787 | } | ||
1788 | |||
1789 | 915428 | static int hls_coding_unit(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, | |
1790 | int cqt_depth, const VVCTreeType tree_type, VVCModeType mode_type) | ||
1791 | { | ||
1792 | 915428 | const VVCFrameContext *fc = lc->fc; | |
1793 | 915428 | const VVCSPS *sps = fc->ps.sps; | |
1794 | 915428 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1795 | 915428 | const int hs = sps->hshift[CHROMA]; | |
1796 | 915428 | const int vs = sps->vshift[CHROMA]; | |
1797 |
4/4✓ Branch 0 taken 893472 times.
✓ Branch 1 taken 21956 times.
✓ Branch 2 taken 2145 times.
✓ Branch 3 taken 891327 times.
|
915428 | const int is_128 = cb_width > 64 || cb_height > 64; |
1798 | 915428 | int pred_mode_plt_flag = 0; | |
1799 | int ret; | ||
1800 | |||
1801 | 915428 | CodingUnit *cu = add_cu(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type); | |
1802 | |||
1803 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 915428 times.
|
915428 | if (!cu) |
1804 | ✗ | return AVERROR(ENOMEM); | |
1805 | |||
1806 | 915428 | ff_vvc_set_neighbour_available(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
1807 | |||
1808 |
3/4✓ Branch 0 taken 442727 times.
✓ Branch 1 taken 472701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 442727 times.
|
915428 | if (IS_I(rsh) && is_128) |
1809 | ✗ | mode_type = MODE_TYPE_INTRA; | |
1810 | 915428 | cu->pred_mode = pred_mode_decode(lc, tree_type, mode_type); | |
1811 | |||
1812 |
3/10✓ Branch 0 taken 519778 times.
✓ Branch 1 taken 395650 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 519778 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.
|
915428 | if (cu->pred_mode == MODE_INTRA && sps->r->sps_palette_enabled_flag && !is_128 && !cu->skip_flag && |
1813 | ✗ | mode_type != MODE_TYPE_INTER && ((cb_width * cb_height) > | |
1814 | ✗ | (tree_type != DUAL_TREE_CHROMA ? 16 : (16 << hs << vs))) && | |
1815 | ✗ | (mode_type != MODE_TYPE_INTRA || tree_type != DUAL_TREE_CHROMA)) { | |
1816 | ✗ | pred_mode_plt_flag = ff_vvc_pred_mode_plt_flag(lc); | |
1817 | ✗ | if (pred_mode_plt_flag) { | |
1818 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1819 | ✗ | return AVERROR_PATCHWELCOME; | |
1820 | } | ||
1821 | } | ||
1822 |
3/6✓ Branch 0 taken 519778 times.
✓ Branch 1 taken 395650 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 519778 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
915428 | if (cu->pred_mode == MODE_INTRA && sps->r->sps_act_enabled_flag && tree_type == SINGLE_TREE) { |
1823 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Adaptive Color Transform"); | |
1824 | ✗ | return AVERROR_PATCHWELCOME; | |
1825 | } | ||
1826 |
3/4✓ Branch 0 taken 395650 times.
✓ Branch 1 taken 519778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395650 times.
|
915428 | if (cu->pred_mode == MODE_INTRA || cu->pred_mode == MODE_PLT) { |
1827 |
4/4✓ Branch 0 taken 467574 times.
✓ Branch 1 taken 52204 times.
✓ Branch 2 taken 351050 times.
✓ Branch 3 taken 116524 times.
|
519778 | if (tree_type == SINGLE_TREE || tree_type == DUAL_TREE_LUMA) { |
1828 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 403254 times.
|
403254 | if (pred_mode_plt_flag) { |
1829 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1830 | ✗ | return AVERROR_PATCHWELCOME; | |
1831 | } else { | ||
1832 | 403254 | intra_luma_pred_modes(lc); | |
1833 | } | ||
1834 | 403254 | ff_vvc_set_intra_mvf(lc, 0); | |
1835 | } | ||
1836 |
6/6✓ Branch 0 taken 467574 times.
✓ Branch 1 taken 52204 times.
✓ Branch 2 taken 116524 times.
✓ Branch 3 taken 351050 times.
✓ Branch 4 taken 155698 times.
✓ Branch 5 taken 13030 times.
|
519778 | if ((tree_type == SINGLE_TREE || tree_type == DUAL_TREE_CHROMA) && sps->r->sps_chroma_format_idc) { |
1837 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 155698 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
155698 | if (pred_mode_plt_flag && tree_type == DUAL_TREE_CHROMA) { |
1838 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1839 | ✗ | return AVERROR_PATCHWELCOME; | |
1840 |
1/2✓ Branch 0 taken 155698 times.
✗ Branch 1 not taken.
|
155698 | } else if (!pred_mode_plt_flag) { |
1841 |
1/2✓ Branch 0 taken 155698 times.
✗ Branch 1 not taken.
|
155698 | if (!cu->act_enabled_flag) |
1842 | 155698 | intra_chroma_pred_modes(lc); | |
1843 | } | ||
1844 | } | ||
1845 |
1/2✓ Branch 0 taken 395650 times.
✗ Branch 1 not taken.
|
395650 | } else if (tree_type != DUAL_TREE_CHROMA) { /* MODE_INTER or MODE_IBC */ |
1846 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 395650 times.
|
395650 | if ((ret = inter_data(lc)) < 0) |
1847 | ✗ | return ret; | |
1848 | } | ||
1849 |
5/6✓ Branch 0 taken 395650 times.
✓ Branch 1 taken 519778 times.
✓ Branch 2 taken 395650 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58663 times.
✓ Branch 5 taken 336987 times.
|
915428 | if (cu->pred_mode != MODE_INTRA && !pred_mode_plt_flag && !lc->cu->pu.general_merge_flag) |
1850 | 58663 | cu->coded_flag = ff_vvc_cu_coded_flag(lc); | |
1851 | else | ||
1852 |
3/4✓ Branch 0 taken 628288 times.
✓ Branch 1 taken 228477 times.
✓ Branch 2 taken 628288 times.
✗ Branch 3 not taken.
|
856765 | cu->coded_flag = !(cu->skip_flag || pred_mode_plt_flag); |
1853 | |||
1854 |
2/2✓ Branch 0 taken 655498 times.
✓ Branch 1 taken 259930 times.
|
915428 | if (cu->coded_flag) { |
1855 | 655498 | sbt_info(lc, sps); | |
1856 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 655498 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
655498 | if (sps->r->sps_act_enabled_flag && cu->pred_mode != MODE_INTRA && tree_type == SINGLE_TREE) { |
1857 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Adaptive Color Transform"); | |
1858 | ✗ | return AVERROR_PATCHWELCOME; | |
1859 | } | ||
1860 | 655498 | lc->parse.lfnst_dc_only = 1; | |
1861 | 655498 | lc->parse.lfnst_zero_out_sig_coeff_flag = 1; | |
1862 | 655498 | lc->parse.mts_dc_only = 1; | |
1863 | 655498 | lc->parse.mts_zero_out_sig_coeff_flag = 1; | |
1864 | 655498 | ret = hls_transform_tree(lc, x0, y0, cb_width, cb_height, cu->ch_type); | |
1865 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 655498 times.
|
655498 | if (ret < 0) |
1866 | ✗ | return ret; | |
1867 | 655498 | cu->lfnst_idx = lfnst_idx_decode(lc); | |
1868 | 655498 | cu->mts_idx = mts_idx_decode(lc); | |
1869 | 655498 | set_qp_c(lc); | |
1870 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 655498 times.
|
655498 | if (ret < 0) |
1871 | ✗ | return ret; | |
1872 | } else { | ||
1873 | 259930 | ret = skipped_transform_tree_unit(lc); | |
1874 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 259930 times.
|
259930 | if (ret < 0) |
1875 | ✗ | return ret; | |
1876 | } | ||
1877 | 915428 | set_cu_tabs(lc, cu); | |
1878 | |||
1879 | 915428 | return 0; | |
1880 | } | ||
1881 | |||
1882 | 594030 | static int derive_mode_type_condition(const VVCLocalContext *lc, | |
1883 | const VVCSplitMode split, const int cb_width, const int cb_height, const VVCModeType mode_type_curr) | ||
1884 | { | ||
1885 | 594030 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1886 | 594030 | const VVCSPS *sps = lc->fc->ps.sps; | |
1887 | 594030 | const int area = cb_width * cb_height; | |
1888 | |||
1889 |
6/6✓ Branch 0 taken 298746 times.
✓ Branch 1 taken 295284 times.
✓ Branch 2 taken 5060 times.
✓ Branch 3 taken 293686 times.
✓ Branch 4 taken 291433 times.
✓ Branch 5 taken 8911 times.
|
594030 | if ((IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) || |
1890 |
2/2✓ Branch 0 taken 268777 times.
✓ Branch 1 taken 22656 times.
|
291433 | mode_type_curr != MODE_TYPE_ALL || !sps->r->sps_chroma_format_idc || |
1891 |
2/2✓ Branch 0 taken 41943 times.
✓ Branch 1 taken 226834 times.
|
268777 | sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
1892 | 367196 | return 0; | |
1893 |
7/10✓ Branch 0 taken 9398 times.
✓ Branch 1 taken 217436 times.
✓ Branch 2 taken 9398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9398 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8825 times.
✓ Branch 7 taken 573 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 226261 times.
|
226834 | if ((area == 64 && (split == SPLIT_QT || split == SPLIT_TT_HOR || split == SPLIT_TT_VER)) || |
1894 | ✗ | (area == 32 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER))) | |
1895 | 573 | return 1; | |
1896 |
8/10✓ Branch 0 taken 8825 times.
✓ Branch 1 taken 217436 times.
✓ Branch 2 taken 5522 times.
✓ Branch 3 taken 3303 times.
✓ Branch 4 taken 5522 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 8825 times.
✓ Branch 8 taken 21201 times.
✓ Branch 9 taken 196235 times.
|
226261 | if ((area == 64 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
1897 |
7/8✓ Branch 0 taken 18872 times.
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 2735 times.
✓ Branch 3 taken 16137 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5064 times.
✓ Branch 6 taken 17230 times.
✓ Branch 7 taken 195142 times.
|
217436 | (area == 128 && (split == SPLIT_TT_HOR || split == SPLIT_TT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
1898 |
6/6✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 5310 times.
✓ Branch 2 taken 58931 times.
✓ Branch 3 taken 148131 times.
✓ Branch 4 taken 8240 times.
✓ Branch 5 taken 50691 times.
|
212372 | (cb_width == 8 && split == SPLIT_BT_VER) || (cb_width == 16 && split == SPLIT_TT_VER)) |
1899 |
1/2✓ Branch 0 taken 27439 times.
✗ Branch 1 not taken.
|
27439 | return 1 + !IS_I(rsh); |
1900 | |||
1901 | 198822 | return 0; | |
1902 | } | ||
1903 | |||
1904 | 594030 | static VVCModeType mode_type_decode(VVCLocalContext *lc, const int x0, const int y0, | |
1905 | const int cb_width, const int cb_height, const VVCSplitMode split, const int ch_type, | ||
1906 | const VVCModeType mode_type_curr) | ||
1907 | { | ||
1908 | VVCModeType mode_type; | ||
1909 | 594030 | const int mode_type_condition = derive_mode_type_condition(lc, split, cb_width, cb_height, mode_type_curr); | |
1910 | |||
1911 |
2/2✓ Branch 0 taken 573 times.
✓ Branch 1 taken 593457 times.
|
594030 | if (mode_type_condition == 1) |
1912 | 573 | mode_type = MODE_TYPE_INTRA; | |
1913 |
2/2✓ Branch 0 taken 27439 times.
✓ Branch 1 taken 566018 times.
|
593457 | else if (mode_type_condition == 2) { |
1914 |
2/2✓ Branch 1 taken 7621 times.
✓ Branch 2 taken 19818 times.
|
27439 | mode_type = ff_vvc_non_inter_flag(lc, x0, y0, ch_type) ? MODE_TYPE_INTRA : MODE_TYPE_INTER; |
1915 | } else { | ||
1916 | 566018 | mode_type = mode_type_curr; | |
1917 | } | ||
1918 | |||
1919 | 594030 | return mode_type; | |
1920 | } | ||
1921 | |||
1922 | static int hls_coding_tree(VVCLocalContext *lc, | ||
1923 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1924 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
1925 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr); | ||
1926 | |||
1927 | 175390 | static int coding_tree_btv(VVCLocalContext *lc, | |
1928 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1929 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1930 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1931 | { | ||
1932 | #define CODING_TREE(x, idx) do { \ | ||
1933 | ret = hls_coding_tree(lc, x, y0, cb_width / 2, cb_height, \ | ||
1934 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
1935 | depth_offset, idx, SPLIT_BT_VER, tree_type, mode_type); \ | ||
1936 | if (ret < 0) \ | ||
1937 | return ret; \ | ||
1938 | } while (0); | ||
1939 | |||
1940 | 175390 | const VVCPPS *pps = lc->fc->ps.pps; | |
1941 | 175390 | const int x1 = x0 + cb_width / 2; | |
1942 | 175390 | int ret = 0; | |
1943 | |||
1944 | 175390 | depth_offset += (x0 + cb_width > pps->width) ? 1 : 0; | |
1945 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 175390 times.
|
175390 | CODING_TREE(x0, 0); |
1946 |
2/2✓ Branch 0 taken 174289 times.
✓ Branch 1 taken 1101 times.
|
175390 | if (x1 < pps->width) |
1947 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 174289 times.
|
174289 | CODING_TREE(x1, 1); |
1948 | |||
1949 | 175390 | return 0; | |
1950 | |||
1951 | #undef CODING_TREE | ||
1952 | } | ||
1953 | |||
1954 | 220387 | static int coding_tree_bth(VVCLocalContext *lc, | |
1955 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1956 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1957 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1958 | { | ||
1959 | #define CODING_TREE(y, idx) do { \ | ||
1960 | ret = hls_coding_tree(lc, x0, y, cb_width , cb_height / 2, \ | ||
1961 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
1962 | depth_offset, idx, SPLIT_BT_HOR, tree_type, mode_type); \ | ||
1963 | if (ret < 0) \ | ||
1964 | return ret; \ | ||
1965 | } while (0); | ||
1966 | |||
1967 | 220387 | const VVCPPS *pps = lc->fc->ps.pps; | |
1968 | 220387 | const int y1 = y0 + (cb_height / 2); | |
1969 | 220387 | int ret = 0; | |
1970 | |||
1971 | 220387 | depth_offset += (y0 + cb_height > pps->height) ? 1 : 0; | |
1972 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 220387 times.
|
220387 | CODING_TREE(y0, 0); |
1973 |
2/2✓ Branch 0 taken 204419 times.
✓ Branch 1 taken 15968 times.
|
220387 | if (y1 < pps->height) |
1974 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 204419 times.
|
204419 | CODING_TREE(y1, 1); |
1975 | |||
1976 | 220387 | return 0; | |
1977 | |||
1978 | #undef CODING_TREE | ||
1979 | } | ||
1980 | |||
1981 | 58530 | static int coding_tree_ttv(VVCLocalContext *lc, | |
1982 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1983 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1984 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1985 | { | ||
1986 | #define CODING_TREE(x, w, sub_div, idx) do { \ | ||
1987 | ret = hls_coding_tree(lc, x, y0, w, cb_height, \ | ||
1988 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
1989 | depth_offset, idx, SPLIT_TT_VER, tree_type, mode_type); \ | ||
1990 | if (ret < 0) \ | ||
1991 | return ret; \ | ||
1992 | } while (0); | ||
1993 | |||
1994 | 58530 | const VVCSH *sh = &lc->sc->sh; | |
1995 | 58530 | const int x1 = x0 + cb_width / 4; | |
1996 | 58530 | const int x2 = x0 + cb_width * 3 / 4; | |
1997 | int ret; | ||
1998 | |||
1999 |
3/4✓ Branch 0 taken 39692 times.
✓ Branch 1 taken 18838 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39692 times.
|
58530 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
2000 |
3/4✓ Branch 0 taken 30341 times.
✓ Branch 1 taken 28189 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30341 times.
|
58530 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
2001 | |||
2002 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 58530 times.
|
58530 | CODING_TREE(x0, cb_width / 4, cb_sub_div + 2, 0); |
2003 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 58530 times.
|
58530 | CODING_TREE(x1, cb_width / 2, cb_sub_div + 1, 1); |
2004 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 58530 times.
|
58530 | CODING_TREE(x2, cb_width / 4, cb_sub_div + 2, 2); |
2005 | |||
2006 | 58530 | return 0; | |
2007 | |||
2008 | #undef CODING_TREE | ||
2009 | } | ||
2010 | |||
2011 | 60249 | static int coding_tree_tth(VVCLocalContext *lc, | |
2012 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2013 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2014 | VVCTreeType tree_type, VVCModeType mode_type) | ||
2015 | { | ||
2016 | #define CODING_TREE(y, h, sub_div, idx) do { \ | ||
2017 | ret = hls_coding_tree(lc, x0, y, cb_width, h, \ | ||
2018 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
2019 | depth_offset, idx, SPLIT_TT_HOR, tree_type, mode_type); \ | ||
2020 | if (ret < 0) \ | ||
2021 | return ret; \ | ||
2022 | } while (0); | ||
2023 | |||
2024 | 60249 | const VVCSH *sh = &lc->sc->sh; | |
2025 | 60249 | const int y1 = y0 + (cb_height / 4); | |
2026 | 60249 | const int y2 = y0 + (3 * cb_height / 4); | |
2027 | int ret; | ||
2028 | |||
2029 |
3/4✓ Branch 0 taken 38779 times.
✓ Branch 1 taken 21470 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38779 times.
|
60249 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
2030 |
3/4✓ Branch 0 taken 25836 times.
✓ Branch 1 taken 34413 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25836 times.
|
60249 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
2031 | |||
2032 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60249 times.
|
60249 | CODING_TREE(y0, cb_height / 4, cb_sub_div + 2, 0); |
2033 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60249 times.
|
60249 | CODING_TREE(y1, cb_height / 2, cb_sub_div + 1, 1); |
2034 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60249 times.
|
60249 | CODING_TREE(y2, cb_height / 4, cb_sub_div + 2, 2); |
2035 | |||
2036 | 60249 | return 0; | |
2037 | |||
2038 | #undef CODING_TREE | ||
2039 | } | ||
2040 | |||
2041 | 79474 | static int coding_tree_qt(VVCLocalContext *lc, | |
2042 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2043 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2044 | VVCTreeType tree_type, VVCModeType mode_type) | ||
2045 | { | ||
2046 | #define CODING_TREE(x, y, idx) do { \ | ||
2047 | ret = hls_coding_tree(lc, x, y, cb_width / 2, cb_height / 2, \ | ||
2048 | qg_on_y, qg_on_c, cb_sub_div + 2, cqt_depth + 1, 0, 0, \ | ||
2049 | idx, SPLIT_QT, tree_type, mode_type); \ | ||
2050 | if (ret < 0) \ | ||
2051 | return ret; \ | ||
2052 | } while (0); | ||
2053 | |||
2054 | 79474 | const VVCPPS *pps = lc->fc->ps.pps; | |
2055 | 79474 | const int x1 = x0 + cb_width / 2; | |
2056 | 79474 | const int y1 = y0 + cb_height / 2; | |
2057 | 79474 | int ret = 0; | |
2058 | |||
2059 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 79474 times.
|
79474 | CODING_TREE(x0, y0, 0); |
2060 |
2/2✓ Branch 0 taken 76726 times.
✓ Branch 1 taken 2748 times.
|
79474 | if (x1 < pps->width) |
2061 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 76726 times.
|
76726 | CODING_TREE(x1, y0, 1); |
2062 |
2/2✓ Branch 0 taken 74314 times.
✓ Branch 1 taken 5160 times.
|
79474 | if (y1 < pps->height) |
2063 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 74314 times.
|
74314 | CODING_TREE(x0, y1, 2); |
2064 |
2/2✓ Branch 0 taken 76726 times.
✓ Branch 1 taken 2748 times.
|
79474 | if (x1 < pps->width && |
2065 |
2/2✓ Branch 0 taken 71574 times.
✓ Branch 1 taken 5152 times.
|
76726 | y1 < pps->height) |
2066 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 71574 times.
|
71574 | CODING_TREE(x1, y1, 3); |
2067 | |||
2068 | 79474 | return 0; | |
2069 | |||
2070 | #undef CODING_TREE | ||
2071 | } | ||
2072 | |||
2073 | typedef int (*coding_tree_fn)(VVCLocalContext *lc, | ||
2074 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2075 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2076 | VVCTreeType tree_type, VVCModeType mode_type); | ||
2077 | |||
2078 | const static coding_tree_fn coding_tree[] = { | ||
2079 | coding_tree_tth, | ||
2080 | coding_tree_bth, | ||
2081 | coding_tree_ttv, | ||
2082 | coding_tree_btv, | ||
2083 | coding_tree_qt, | ||
2084 | }; | ||
2085 | |||
2086 | 1509458 | static int hls_coding_tree(VVCLocalContext *lc, | |
2087 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2088 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
2089 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr) | ||
2090 | { | ||
2091 | 1509458 | VVCFrameContext *fc = lc->fc; | |
2092 | 1509458 | const VVCPPS *pps = fc->ps.pps; | |
2093 | 1509458 | const VVCSH *sh = &lc->sc->sh; | |
2094 | 1509458 | const H266RawSliceHeader *rsh = sh->r; | |
2095 | 1509458 | const int ch_type = tree_type_curr == DUAL_TREE_CHROMA; | |
2096 | int ret; | ||
2097 | VVCAllowedSplit allowed; | ||
2098 | |||
2099 |
6/6✓ Branch 0 taken 39623 times.
✓ Branch 1 taken 1469835 times.
✓ Branch 2 taken 22745 times.
✓ Branch 3 taken 16878 times.
✓ Branch 4 taken 464 times.
✓ Branch 5 taken 22281 times.
|
1509458 | if (pps->r->pps_cu_qp_delta_enabled_flag && qg_on_y && cb_sub_div <= sh->cu_qp_delta_subdiv) { |
2100 | 464 | lc->parse.is_cu_qp_delta_coded = 0; | |
2101 | 464 | lc->parse.cu_qg_top_left_x = x0; | |
2102 | 464 | lc->parse.cu_qg_top_left_y = y0; | |
2103 | } | ||
2104 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1509458 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1509458 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && qg_on_c && |
2105 | ✗ | cb_sub_div <= sh->cu_chroma_qp_offset_subdiv) { | |
2106 | ✗ | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
2107 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2108 | } | ||
2109 | |||
2110 | 1509458 | can_split(lc, x0, y0, cb_width, cb_height, mtt_depth, depth_offset, part_idx, | |
2111 | last_split_mode, tree_type_curr, mode_type_curr, &allowed); | ||
2112 |
2/2✓ Branch 1 taken 594030 times.
✓ Branch 2 taken 915428 times.
|
1509458 | if (ff_vvc_split_cu_flag(lc, x0, y0, cb_width, cb_height, ch_type, &allowed)) { |
2113 | 594030 | VVCSplitMode split = ff_vvc_split_mode(lc, x0, y0, cb_width, cb_height, cqt_depth, mtt_depth, ch_type, &allowed); | |
2114 | 594030 | VVCModeType mode_type = mode_type_decode(lc, x0, y0, cb_width, cb_height, split, ch_type, mode_type_curr); | |
2115 | |||
2116 |
2/2✓ Branch 0 taken 581148 times.
✓ Branch 1 taken 12882 times.
|
594030 | VVCTreeType tree_type = (mode_type == MODE_TYPE_INTRA) ? DUAL_TREE_LUMA : tree_type_curr; |
2117 | |||
2118 |
2/2✓ Branch 0 taken 514556 times.
✓ Branch 1 taken 79474 times.
|
594030 | if (split != SPLIT_QT) { |
2119 |
6/6✓ Branch 0 taken 333576 times.
✓ Branch 1 taken 180980 times.
✓ Branch 2 taken 227020 times.
✓ Branch 3 taken 106556 times.
✓ Branch 4 taken 197718 times.
✓ Branch 5 taken 29302 times.
|
514556 | if (!(x0 & 31) && !(y0 & 31) && mtt_depth <= 1) |
2120 | 197718 | TAB_MSM(fc, mtt_depth, x0, y0) = split; | |
2121 | } | ||
2122 | 594030 | ret = coding_tree[split - 1](lc, x0, y0, cb_width, cb_height, qg_on_y, qg_on_c, | |
2123 | cb_sub_div, cqt_depth, mtt_depth, depth_offset, tree_type, mode_type); | ||
2124 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 594030 times.
|
594030 | if (ret < 0) |
2125 | ✗ | return ret; | |
2126 |
4/4✓ Branch 0 taken 585119 times.
✓ Branch 1 taken 8911 times.
✓ Branch 2 taken 8194 times.
✓ Branch 3 taken 576925 times.
|
594030 | if (mode_type_curr == MODE_TYPE_ALL && mode_type == MODE_TYPE_INTRA) { |
2127 | 8194 | ret = hls_coding_tree(lc, x0, y0, cb_width, cb_height, 0, qg_on_c, cb_sub_div, | |
2128 | cqt_depth, mtt_depth, 0, 0, split, DUAL_TREE_CHROMA, mode_type); | ||
2129 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8194 times.
|
8194 | if (ret < 0) |
2130 | ✗ | return ret; | |
2131 | } | ||
2132 | } else { | ||
2133 | 915428 | ret = hls_coding_unit(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type_curr, mode_type_curr); | |
2134 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 915428 times.
|
915428 | if (ret < 0) |
2135 | ✗ | return ret; | |
2136 | } | ||
2137 | |||
2138 | 1509458 | return 0; | |
2139 | } | ||
2140 | |||
2141 | 18685 | static int dual_tree_implicit_qt_split(VVCLocalContext *lc, | |
2142 | const int x0, const int y0, const int cb_size, const int cqt_depth) | ||
2143 | { | ||
2144 | 18685 | const VVCSH *sh = &lc->sc->sh; | |
2145 | 18685 | const H266RawSliceHeader *rsh = sh->r; | |
2146 | 18685 | const VVCPPS *pps = lc->fc->ps.pps; | |
2147 | 18685 | const int cb_subdiv = 2 * cqt_depth; | |
2148 | int ret; | ||
2149 | |||
2150 |
2/2✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 14820 times.
|
18685 | if (cb_size > 64) { |
2151 | #define DUAL_TREE(x, y) do { \ | ||
2152 | ret = dual_tree_implicit_qt_split(lc, x, y, cb_size / 2, cqt_depth + 1); \ | ||
2153 | if (ret < 0) \ | ||
2154 | return ret; \ | ||
2155 | } while (0) | ||
2156 | |||
2157 | 3865 | const int x1 = x0 + (cb_size / 2); | |
2158 | 3865 | const int y1 = y0 + (cb_size / 2); | |
2159 |
3/4✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3841 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
3865 | if (pps->r->pps_cu_qp_delta_enabled_flag && cb_subdiv <= sh->cu_qp_delta_subdiv) { |
2160 | 24 | lc->parse.is_cu_qp_delta_coded = 0; | |
2161 | 24 | lc->parse.cu_qg_top_left_x = x0; | |
2162 | 24 | lc->parse.cu_qg_top_left_y = y0; | |
2163 | } | ||
2164 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3865 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && cb_subdiv <= sh->cu_chroma_qp_offset_subdiv) { |
2165 | ✗ | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
2166 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2167 | } | ||
2168 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3865 times.
|
3865 | DUAL_TREE(x0, y0); |
2169 |
2/2✓ Branch 0 taken 3761 times.
✓ Branch 1 taken 104 times.
|
3865 | if (x1 < pps->width) |
2170 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3761 times.
|
3761 | DUAL_TREE(x1, y0); |
2171 |
2/2✓ Branch 0 taken 3492 times.
✓ Branch 1 taken 373 times.
|
3865 | if (y1 < pps->height) |
2172 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3492 times.
|
3492 | DUAL_TREE(x0, y1); |
2173 |
4/4✓ Branch 0 taken 3761 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 3390 times.
✓ Branch 3 taken 371 times.
|
3865 | if (x1 < pps->width && y1 < pps->height) |
2174 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3390 times.
|
3390 | DUAL_TREE(x1, y1); |
2175 | #undef DUAL_TREE | ||
2176 | } else { | ||
2177 | #define CODING_TREE(tree_type) do { \ | ||
2178 | const int qg_on_y = tree_type == DUAL_TREE_LUMA; \ | ||
2179 | ret = hls_coding_tree(lc, x0, y0, cb_size, cb_size, qg_on_y, !qg_on_y, \ | ||
2180 | cb_subdiv, cqt_depth, 0, 0, 0, SPLIT_NONE, tree_type, MODE_TYPE_ALL); \ | ||
2181 | if (ret < 0) \ | ||
2182 | return ret; \ | ||
2183 | } while (0) | ||
2184 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 14820 times.
|
14820 | CODING_TREE(DUAL_TREE_LUMA); |
2185 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 14820 times.
|
14820 | CODING_TREE(DUAL_TREE_CHROMA); |
2186 | #undef CODING_TREE | ||
2187 | } | ||
2188 | 18685 | return 0; | |
2189 | } | ||
2190 | |||
2191 | #define SET_SAO(elem, value) \ | ||
2192 | do { \ | ||
2193 | if (!sao_merge_up_flag && !sao_merge_left_flag) \ | ||
2194 | sao->elem = value; \ | ||
2195 | else if (sao_merge_left_flag) \ | ||
2196 | sao->elem = CTB(fc->tab.sao, rx-1, ry).elem; \ | ||
2197 | else if (sao_merge_up_flag) \ | ||
2198 | sao->elem = CTB(fc->tab.sao, rx, ry-1).elem; \ | ||
2199 | else \ | ||
2200 | sao->elem = 0; \ | ||
2201 | } while (0) | ||
2202 | |||
2203 | 42891 | static void hls_sao(VVCLocalContext *lc, const int rx, const int ry) | |
2204 | { | ||
2205 | 42891 | VVCFrameContext *fc = lc->fc; | |
2206 | 42891 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
2207 | 42891 | int sao_merge_left_flag = 0; | |
2208 | 42891 | int sao_merge_up_flag = 0; | |
2209 | 42891 | SAOParams *sao = &CTB(fc->tab.sao, rx, ry); | |
2210 | int c_idx, i; | ||
2211 | |||
2212 |
3/4✓ Branch 0 taken 27913 times.
✓ Branch 1 taken 14978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27913 times.
|
42891 | if (rsh->sh_sao_luma_used_flag || rsh->sh_sao_chroma_used_flag) { |
2213 |
2/2✓ Branch 0 taken 13551 times.
✓ Branch 1 taken 1427 times.
|
14978 | if (rx > 0) { |
2214 |
2/2✓ Branch 0 taken 13062 times.
✓ Branch 1 taken 489 times.
|
13551 | if (lc->ctb_left_flag) |
2215 | 13062 | sao_merge_left_flag = ff_vvc_sao_merge_flag_decode(lc); | |
2216 | } | ||
2217 |
4/4✓ Branch 0 taken 12433 times.
✓ Branch 1 taken 2545 times.
✓ Branch 2 taken 6368 times.
✓ Branch 3 taken 6065 times.
|
14978 | if (ry > 0 && !sao_merge_left_flag) { |
2218 |
2/2✓ Branch 0 taken 5806 times.
✓ Branch 1 taken 562 times.
|
6368 | if (lc->ctb_up_flag) |
2219 | 5806 | sao_merge_up_flag = ff_vvc_sao_merge_flag_decode(lc); | |
2220 | } | ||
2221 | } | ||
2222 | |||
2223 |
4/4✓ Branch 0 taken 169484 times.
✓ Branch 1 taken 1040 times.
✓ Branch 2 taken 127633 times.
✓ Branch 3 taken 42891 times.
|
170524 | for (c_idx = 0; c_idx < (fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) { |
2224 |
2/2✓ Branch 0 taken 42891 times.
✓ Branch 1 taken 84742 times.
|
127633 | const int sao_used_flag = !c_idx ? rsh->sh_sao_luma_used_flag : rsh->sh_sao_chroma_used_flag; |
2225 |
2/2✓ Branch 0 taken 97411 times.
✓ Branch 1 taken 30222 times.
|
127633 | if (!sao_used_flag) { |
2226 | 97411 | sao->type_idx[c_idx] = SAO_NOT_APPLIED; | |
2227 | 97411 | continue; | |
2228 | } | ||
2229 | |||
2230 |
2/2✓ Branch 0 taken 7622 times.
✓ Branch 1 taken 22600 times.
|
30222 | if (c_idx == 2) { |
2231 | 7622 | sao->type_idx[2] = sao->type_idx[1]; | |
2232 | 7622 | sao->eo_class[2] = sao->eo_class[1]; | |
2233 | } else { | ||
2234 |
7/8✓ Branch 0 taken 19661 times.
✓ Branch 1 taken 2939 times.
✓ Branch 2 taken 9289 times.
✓ Branch 3 taken 10372 times.
✓ Branch 5 taken 10372 times.
✓ Branch 6 taken 2939 times.
✓ Branch 7 taken 2939 times.
✗ Branch 8 not taken.
|
22600 | SET_SAO(type_idx[c_idx], ff_vvc_sao_type_idx_decode(lc)); |
2235 | } | ||
2236 | |||
2237 |
2/2✓ Branch 0 taken 19299 times.
✓ Branch 1 taken 10923 times.
|
30222 | if (sao->type_idx[c_idx] == SAO_NOT_APPLIED) |
2238 | 19299 | continue; | |
2239 | |||
2240 |
2/2✓ Branch 0 taken 43692 times.
✓ Branch 1 taken 10923 times.
|
54615 | for (i = 0; i < 4; i++) |
2241 |
7/8✓ Branch 0 taken 36048 times.
✓ Branch 1 taken 7644 times.
✓ Branch 2 taken 13912 times.
✓ Branch 3 taken 22136 times.
✓ Branch 5 taken 22136 times.
✓ Branch 6 taken 7644 times.
✓ Branch 7 taken 7644 times.
✗ Branch 8 not taken.
|
43692 | SET_SAO(offset_abs[c_idx][i], ff_vvc_sao_offset_abs_decode(lc)); |
2242 | |||
2243 |
2/2✓ Branch 0 taken 4599 times.
✓ Branch 1 taken 6324 times.
|
10923 | if (sao->type_idx[c_idx] == SAO_BAND) { |
2244 |
2/2✓ Branch 0 taken 18396 times.
✓ Branch 1 taken 4599 times.
|
22995 | for (i = 0; i < 4; i++) { |
2245 |
2/2✓ Branch 0 taken 5502 times.
✓ Branch 1 taken 12894 times.
|
18396 | if (sao->offset_abs[c_idx][i]) { |
2246 |
7/8✓ Branch 0 taken 4830 times.
✓ Branch 1 taken 672 times.
✓ Branch 2 taken 1496 times.
✓ Branch 3 taken 3334 times.
✓ Branch 5 taken 3334 times.
✓ Branch 6 taken 672 times.
✓ Branch 7 taken 672 times.
✗ Branch 8 not taken.
|
5502 | SET_SAO(offset_sign[c_idx][i], |
2247 | ff_vvc_sao_offset_sign_decode(lc)); | ||
2248 | } else { | ||
2249 | 12894 | sao->offset_sign[c_idx][i] = 0; | |
2250 | } | ||
2251 | } | ||
2252 |
7/8✓ Branch 0 taken 4033 times.
✓ Branch 1 taken 566 times.
✓ Branch 2 taken 1031 times.
✓ Branch 3 taken 3002 times.
✓ Branch 5 taken 3002 times.
✓ Branch 6 taken 566 times.
✓ Branch 7 taken 566 times.
✗ Branch 8 not taken.
|
4599 | SET_SAO(band_position[c_idx], ff_vvc_sao_band_position_decode(lc)); |
2253 |
2/2✓ Branch 0 taken 5211 times.
✓ Branch 1 taken 1113 times.
|
6324 | } else if (c_idx != 2) { |
2254 |
7/8✓ Branch 0 taken 4104 times.
✓ Branch 1 taken 1107 times.
✓ Branch 2 taken 1923 times.
✓ Branch 3 taken 2181 times.
✓ Branch 5 taken 2181 times.
✓ Branch 6 taken 1107 times.
✓ Branch 7 taken 1107 times.
✗ Branch 8 not taken.
|
5211 | SET_SAO(eo_class[c_idx], ff_vvc_sao_eo_class_decode(lc)); |
2255 | } | ||
2256 | |||
2257 | // Inferred parameters | ||
2258 | 10923 | sao->offset_val[c_idx][0] = 0; | |
2259 |
2/2✓ Branch 0 taken 43692 times.
✓ Branch 1 taken 10923 times.
|
54615 | for (i = 0; i < 4; i++) { |
2260 | 43692 | sao->offset_val[c_idx][i + 1] = sao->offset_abs[c_idx][i]; | |
2261 |
2/2✓ Branch 0 taken 25296 times.
✓ Branch 1 taken 18396 times.
|
43692 | if (sao->type_idx[c_idx] == SAO_EDGE) { |
2262 |
2/2✓ Branch 0 taken 12648 times.
✓ Branch 1 taken 12648 times.
|
25296 | if (i > 1) |
2263 | 12648 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
2264 |
2/2✓ Branch 0 taken 4779 times.
✓ Branch 1 taken 13617 times.
|
18396 | } else if (sao->offset_sign[c_idx][i]) { |
2265 | 4779 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
2266 | } | ||
2267 | 43692 | sao->offset_val[c_idx][i + 1] *= 1 << (fc->ps.sps->bit_depth - FFMIN(10, fc->ps.sps->bit_depth)); | |
2268 | } | ||
2269 | } | ||
2270 | 42891 | } | |
2271 | |||
2272 | 42891 | static void alf_params(VVCLocalContext *lc, const int rx, const int ry) | |
2273 | { | ||
2274 | 42891 | const VVCFrameContext *fc = lc->fc; | |
2275 | 42891 | const H266RawSliceHeader *sh = lc->sc->sh.r; | |
2276 | 42891 | ALFParams *alf = &CTB(fc->tab.alf, rx, ry); | |
2277 | |||
2278 | 42891 | alf->ctb_flag[LUMA] = alf->ctb_flag[CB] = alf->ctb_flag[CR] = 0; | |
2279 |
2/2✓ Branch 0 taken 24886 times.
✓ Branch 1 taken 18005 times.
|
42891 | if (sh->sh_alf_enabled_flag) { |
2280 | 24886 | alf->ctb_flag[LUMA] = ff_vvc_alf_ctb_flag(lc, rx, ry, LUMA); | |
2281 |
2/2✓ Branch 0 taken 17481 times.
✓ Branch 1 taken 7405 times.
|
24886 | if (alf->ctb_flag[LUMA]) { |
2282 | 17481 | uint8_t alf_use_aps_flag = 0; | |
2283 |
2/2✓ Branch 0 taken 16761 times.
✓ Branch 1 taken 720 times.
|
17481 | if (sh->sh_num_alf_aps_ids_luma > 0) |
2284 | 16761 | alf_use_aps_flag = ff_vvc_alf_use_aps_flag(lc); | |
2285 |
2/2✓ Branch 0 taken 15125 times.
✓ Branch 1 taken 2356 times.
|
17481 | if (alf_use_aps_flag) { |
2286 | 15125 | alf->ctb_filt_set_idx_y = 16; | |
2287 |
2/2✓ Branch 0 taken 4402 times.
✓ Branch 1 taken 10723 times.
|
15125 | if (sh->sh_num_alf_aps_ids_luma > 1) |
2288 | 4402 | alf->ctb_filt_set_idx_y += ff_vvc_alf_luma_prev_filter_idx(lc); | |
2289 | } else { | ||
2290 | 2356 | alf->ctb_filt_set_idx_y = ff_vvc_alf_luma_fixed_filter_idx(lc); | |
2291 | } | ||
2292 | } | ||
2293 |
2/2✓ Branch 0 taken 49772 times.
✓ Branch 1 taken 24886 times.
|
74658 | for (int c_idx = CB; c_idx <= CR; c_idx++) { |
2294 |
2/2✓ Branch 0 taken 24886 times.
✓ Branch 1 taken 24886 times.
|
49772 | const uint8_t alf_enabled_flag = |
2295 | c_idx == CB ? sh->sh_alf_cb_enabled_flag : sh->sh_alf_cr_enabled_flag; | ||
2296 |
2/2✓ Branch 0 taken 28333 times.
✓ Branch 1 taken 21439 times.
|
49772 | if (alf_enabled_flag) { |
2297 | 28333 | const VVCALF *aps = fc->ps.alf_list[sh->sh_alf_aps_id_chroma]; | |
2298 | 28333 | alf->ctb_flag[c_idx] = ff_vvc_alf_ctb_flag(lc, rx, ry, c_idx); | |
2299 | 28333 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = 0; | |
2300 |
4/4✓ Branch 0 taken 20581 times.
✓ Branch 1 taken 7752 times.
✓ Branch 2 taken 13873 times.
✓ Branch 3 taken 6708 times.
|
28333 | if (alf->ctb_flag[c_idx] && aps->num_chroma_filters > 1) |
2301 | 13873 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = ff_vvc_alf_ctb_filter_alt_idx(lc, c_idx, aps->num_chroma_filters); | |
2302 | } | ||
2303 | } | ||
2304 | } | ||
2305 |
2/2✓ Branch 0 taken 33824 times.
✓ Branch 1 taken 9067 times.
|
42891 | if (fc->ps.sps->r->sps_ccalf_enabled_flag) { |
2306 | 33824 | const uint8_t cc_enabled[] = { sh->sh_alf_cc_cb_enabled_flag, sh->sh_alf_cc_cr_enabled_flag }; | |
2307 | 33824 | const uint8_t cc_aps_id[] = { sh->sh_alf_cc_cb_aps_id, sh->sh_alf_cc_cr_aps_id }; | |
2308 |
2/2✓ Branch 0 taken 67648 times.
✓ Branch 1 taken 33824 times.
|
101472 | for (int i = 0; i < 2; i++) { |
2309 | 67648 | alf->ctb_cc_idc[i] = 0; | |
2310 |
2/2✓ Branch 0 taken 19826 times.
✓ Branch 1 taken 47822 times.
|
67648 | if (cc_enabled[i]) { |
2311 | 19826 | const VVCALF *aps = fc->ps.alf_list[cc_aps_id[i]]; | |
2312 | 19826 | alf->ctb_cc_idc[i] = ff_vvc_alf_ctb_cc_idc(lc, rx, ry, i, aps->num_cc_filters[i]); | |
2313 | } | ||
2314 | } | ||
2315 | } | ||
2316 | 42891 | } | |
2317 | |||
2318 | 42891 | static void deblock_params(VVCLocalContext *lc, const int rx, const int ry) | |
2319 | { | ||
2320 | 42891 | VVCFrameContext *fc = lc->fc; | |
2321 | 42891 | const VVCSH *sh = &lc->sc->sh; | |
2322 | 42891 | CTB(fc->tab.deblock, rx, ry) = sh->deblock; | |
2323 | 42891 | } | |
2324 | |||
2325 | 42891 | static int hls_coding_tree_unit(VVCLocalContext *lc, | |
2326 | const int x0, const int y0, const int ctu_idx, const int rx, const int ry) | ||
2327 | { | ||
2328 | 42891 | const VVCFrameContext *fc = lc->fc; | |
2329 | 42891 | const VVCSPS *sps = fc->ps.sps; | |
2330 | 42891 | const VVCPPS *pps = fc->ps.pps; | |
2331 | 42891 | const VVCSH *sh = &lc->sc->sh; | |
2332 | 42891 | const H266RawSliceHeader *rsh = sh->r; | |
2333 | 42891 | const unsigned int ctb_size = sps->ctb_size_y; | |
2334 | 42891 | int ret = 0; | |
2335 | |||
2336 | 42891 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2337 | |||
2338 | 42891 | hls_sao(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2339 | 42891 | alf_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2340 | 42891 | deblock_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2341 | |||
2342 |
4/4✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 38690 times.
✓ Branch 2 taken 4177 times.
✓ Branch 3 taken 24 times.
|
42891 | if (IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) |
2343 | 4177 | ret = dual_tree_implicit_qt_split(lc, x0, y0, ctb_size, 0); | |
2344 | else | ||
2345 | 38714 | ret = hls_coding_tree(lc, x0, y0, ctb_size, ctb_size, | |
2346 | 1, 1, 0, 0, 0, 0, 0, SPLIT_NONE, SINGLE_TREE, MODE_TYPE_ALL); | ||
2347 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 42891 times.
|
42891 | if (ret < 0) |
2348 | ✗ | return ret; | |
2349 | |||
2350 |
2/2✓ Branch 0 taken 4898 times.
✓ Branch 1 taken 37993 times.
|
42891 | if (rx == pps->ctb_to_col_bd[rx + 1] - 1) { |
2351 |
2/2✓ Branch 0 taken 1578 times.
✓ Branch 1 taken 3320 times.
|
4898 | if (ctu_idx == sh->num_ctus_in_curr_slice - 1) { |
2352 | 1578 | const int end_of_slice_one_bit = ff_vvc_end_of_slice_flag_decode(lc); | |
2353 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1578 times.
|
1578 | if (!end_of_slice_one_bit) |
2354 | ✗ | return AVERROR_INVALIDDATA; | |
2355 | } else { | ||
2356 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 3126 times.
|
3320 | if (ry == pps->ctb_to_row_bd[ry + 1] - 1) { |
2357 | 194 | const int end_of_tile_one_bit = ff_vvc_end_of_tile_one_bit(lc); | |
2358 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
|
194 | if (!end_of_tile_one_bit) |
2359 | ✗ | return AVERROR_INVALIDDATA; | |
2360 | } else { | ||
2361 |
2/2✓ Branch 0 taken 150 times.
✓ Branch 1 taken 2976 times.
|
3126 | if (fc->ps.sps->r->sps_entropy_coding_sync_enabled_flag) { |
2362 | 150 | const int end_of_subset_one_bit = ff_vvc_end_of_subset_one_bit(lc); | |
2363 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
|
150 | if (!end_of_subset_one_bit) |
2364 | ✗ | return AVERROR_INVALIDDATA; | |
2365 | } | ||
2366 | } | ||
2367 | } | ||
2368 | } | ||
2369 | |||
2370 | 42891 | return 0; | |
2371 | } | ||
2372 | |||
2373 | 472701 | static int has_inter_luma(const CodingUnit *cu) | |
2374 | { | ||
2375 |
4/6✓ Branch 0 taken 394222 times.
✓ Branch 1 taken 78479 times.
✓ Branch 2 taken 394222 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 394222 times.
✗ Branch 5 not taken.
|
472701 | return cu->pred_mode != MODE_INTRA && cu->pred_mode != MODE_PLT && cu->tree_type != DUAL_TREE_CHROMA; |
2376 | } | ||
2377 | |||
2378 | 7675324 | static int pred_get_y(const int y0, const Mv *mv, const int height) | |
2379 | { | ||
2380 | 7675324 | return FFMAX(0, y0 + (mv->y >> 4) + height); | |
2381 | } | ||
2382 | |||
2383 | 394222 | static void cu_get_max_y(const CodingUnit *cu, int max_y[2][VVC_MAX_REF_ENTRIES], const VVCFrameContext *fc) | |
2384 | { | ||
2385 | 394222 | const PredictionUnit *pu = &cu->pu; | |
2386 | |||
2387 |
2/2✓ Branch 0 taken 24398 times.
✓ Branch 1 taken 369824 times.
|
394222 | if (pu->merge_gpm_flag) { |
2388 |
2/2✓ Branch 0 taken 48796 times.
✓ Branch 1 taken 24398 times.
|
73194 | for (int i = 0; i < FF_ARRAY_ELEMS(pu->gpm_mv); i++) { |
2389 | 48796 | const MvField *mvf = pu->gpm_mv + i; | |
2390 | 48796 | const int lx = mvf->pred_flag - PF_L0; | |
2391 | 48796 | const int idx = mvf->ref_idx[lx]; | |
2392 | 48796 | const int y = pred_get_y(cu->y0, mvf->mv + lx, cu->cb_height); | |
2393 | |||
2394 | 48796 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y); | |
2395 | } | ||
2396 | } else { | ||
2397 | 369824 | const MotionInfo *mi = &pu->mi; | |
2398 |
4/4✓ Branch 0 taken 337746 times.
✓ Branch 1 taken 32078 times.
✓ Branch 2 taken 68451 times.
✓ Branch 3 taken 269295 times.
|
369824 | const int max_dmvr_off = (!pu->inter_affine_flag && pu->dmvr_flag) ? 2 : 0; |
2399 | 369824 | const int sbw = cu->cb_width / mi->num_sb_x; | |
2400 | 369824 | const int sbh = cu->cb_height / mi->num_sb_y; | |
2401 |
2/2✓ Branch 0 taken 817404 times.
✓ Branch 1 taken 369824 times.
|
1187228 | for (int sby = 0; sby < mi->num_sb_y; sby++) { |
2402 |
2/2✓ Branch 0 taken 5251054 times.
✓ Branch 1 taken 817404 times.
|
6068458 | for (int sbx = 0; sbx < mi->num_sb_x; sbx++) { |
2403 | 5251054 | const int x0 = cu->x0 + sbx * sbw; | |
2404 | 5251054 | const int y0 = cu->y0 + sby * sbh; | |
2405 | 5251054 | const MvField *mvf = ff_vvc_get_mvf(fc, x0, y0); | |
2406 |
2/2✓ Branch 0 taken 10502108 times.
✓ Branch 1 taken 5251054 times.
|
15753162 | for (int lx = 0; lx < 2; lx++) { |
2407 | 10502108 | const PredFlag mask = 1 << lx; | |
2408 |
2/2✓ Branch 0 taken 7626528 times.
✓ Branch 1 taken 2875580 times.
|
10502108 | if (mvf->pred_flag & mask) { |
2409 | 7626528 | const int idx = mvf->ref_idx[lx]; | |
2410 | 7626528 | const int y = pred_get_y(y0, mvf->mv + lx, sbh); | |
2411 | |||
2412 | 7626528 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y + max_dmvr_off); | |
2413 | } | ||
2414 | } | ||
2415 | } | ||
2416 | } | ||
2417 | } | ||
2418 | 394222 | } | |
2419 | |||
2420 | 42891 | static void ctu_get_pred(VVCLocalContext *lc, const int rs) | |
2421 | { | ||
2422 | 42891 | const VVCFrameContext *fc = lc->fc; | |
2423 | 42891 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
2424 | 42891 | CTU *ctu = fc->tab.ctus + rs; | |
2425 | 42891 | const CodingUnit *cu = ctu->cus; | |
2426 | |||
2427 |
2/2✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 38690 times.
|
42891 | if (IS_I(rsh)) |
2428 | 4201 | return; | |
2429 | |||
2430 |
2/2✓ Branch 0 taken 77380 times.
✓ Branch 1 taken 38690 times.
|
116070 | for (int lx = 0; lx < 2; lx++) |
2431 | 77380 | memset(ctu->max_y[lx], -1, sizeof(ctu->max_y[0][0]) * rsh->num_ref_idx_active[lx]); | |
2432 | |||
2433 |
2/2✓ Branch 0 taken 472701 times.
✓ Branch 1 taken 38690 times.
|
511391 | while (cu) { |
2434 |
2/2✓ Branch 1 taken 394222 times.
✓ Branch 2 taken 78479 times.
|
472701 | if (has_inter_luma(cu)) { |
2435 | 394222 | cu_get_max_y(cu, ctu->max_y, fc); | |
2436 | 394222 | ctu->has_dmvr |= cu->pu.dmvr_flag; | |
2437 | } | ||
2438 | 472701 | cu = cu->next; | |
2439 | } | ||
2440 | 38690 | ctu->max_y_idx[0] = ctu->max_y_idx[1] = 0; | |
2441 | } | ||
2442 | |||
2443 | 42891 | int ff_vvc_coding_tree_unit(VVCLocalContext *lc, | |
2444 | const int ctu_idx, const int rs, const int rx, const int ry) | ||
2445 | { | ||
2446 | 42891 | const VVCFrameContext *fc = lc->fc; | |
2447 | 42891 | const VVCSPS *sps = fc->ps.sps; | |
2448 | 42891 | const VVCPPS *pps = fc->ps.pps; | |
2449 | 42891 | const int x_ctb = rx << sps->ctb_log2_size_y; | |
2450 | 42891 | const int y_ctb = ry << sps->ctb_log2_size_y; | |
2451 | 42891 | const int ctb_size = 1 << sps->ctb_log2_size_y << sps->ctb_log2_size_y; | |
2452 | 42891 | EntryPoint* ep = lc->ep; | |
2453 | int ret; | ||
2454 | |||
2455 |
2/2✓ Branch 0 taken 4898 times.
✓ Branch 1 taken 37993 times.
|
42891 | if (rx == pps->ctb_to_col_bd[rx]) { |
2456 | 4898 | ep->num_hmvp = 0; | |
2457 | 4898 | ep->num_hmvp_ibc = 0; | |
2458 |
4/4✓ Branch 0 taken 3236 times.
✓ Branch 1 taken 1662 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 3126 times.
|
4898 | ep->is_first_qg = ry == pps->ctb_to_row_bd[ry] || !ctu_idx; |
2459 | } | ||
2460 | |||
2461 | 42891 | lc->coeffs = fc->tab.coeffs + rs * ctb_size * VVC_MAX_SAMPLE_ARRAYS; | |
2462 | 42891 | lc->cu = NULL; | |
2463 | |||
2464 | 42891 | ff_vvc_cabac_init(lc, ctu_idx, rx, ry); | |
2465 | 42891 | ff_vvc_decode_neighbour(lc, x_ctb, y_ctb, rx, ry, rs); | |
2466 | 42891 | ret = hls_coding_tree_unit(lc, x_ctb, y_ctb, ctu_idx, rx, ry); | |
2467 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 42891 times.
|
42891 | if (ret < 0) |
2468 | ✗ | return ret; | |
2469 | 42891 | ctu_get_pred(lc, rs); | |
2470 | |||
2471 | 42891 | return 0; | |
2472 | } | ||
2473 | |||
2474 | 248487 | void ff_vvc_decode_neighbour(VVCLocalContext *lc, const int x_ctb, const int y_ctb, | |
2475 | const int rx, const int ry, const int rs) | ||
2476 | { | ||
2477 | 248487 | VVCFrameContext *fc = lc->fc; | |
2478 | 248487 | const int ctb_size = fc->ps.sps->ctb_size_y; | |
2479 | |||
2480 | 248487 | lc->end_of_tiles_x = fc->ps.pps->width; | |
2481 | 248487 | lc->end_of_tiles_y = fc->ps.pps->height; | |
2482 |
2/2✓ Branch 0 taken 28791 times.
✓ Branch 1 taken 219696 times.
|
248487 | if (fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx + 1]) |
2483 | 28791 | lc->end_of_tiles_x = FFMIN(x_ctb + ctb_size, lc->end_of_tiles_x); | |
2484 |
2/2✓ Branch 0 taken 48693 times.
✓ Branch 1 taken 199794 times.
|
248487 | if (fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry + 1]) |
2485 | 48693 | lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, lc->end_of_tiles_y); | |
2486 | |||
2487 | 248487 | lc->boundary_flags = 0; | |
2488 |
4/4✓ Branch 0 taken 226230 times.
✓ Branch 1 taken 22257 times.
✓ Branch 2 taken 6534 times.
✓ Branch 3 taken 219696 times.
|
248487 | if (rx > 0 && fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx - 1]) |
2489 | 6534 | lc->boundary_flags |= BOUNDARY_LEFT_TILE; | |
2490 |
4/4✓ Branch 0 taken 226230 times.
✓ Branch 1 taken 22257 times.
✓ Branch 2 taken 4386 times.
✓ Branch 3 taken 221844 times.
|
248487 | if (rx > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - 1]) |
2491 | 4386 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; | |
2492 |
4/4✓ Branch 0 taken 209046 times.
✓ Branch 1 taken 39441 times.
✓ Branch 2 taken 9252 times.
✓ Branch 3 taken 199794 times.
|
248487 | if (ry > 0 && fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry - 1]) |
2493 | 9252 | lc->boundary_flags |= BOUNDARY_UPPER_TILE; | |
2494 |
4/4✓ Branch 0 taken 209046 times.
✓ Branch 1 taken 39441 times.
✓ Branch 2 taken 9372 times.
✓ Branch 3 taken 199674 times.
|
248487 | if (ry > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - fc->ps.pps->ctb_width]) |
2495 | 9372 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; | |
2496 |
2/2✓ Branch 0 taken 23895 times.
✓ Branch 1 taken 224592 times.
|
248487 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_x[lc->sc->sh.r->curr_subpic_idx] == rx) |
2497 | 23895 | lc->boundary_flags |= BOUNDARY_LEFT_SUBPIC; | |
2498 |
2/2✓ Branch 0 taken 40683 times.
✓ Branch 1 taken 207804 times.
|
248487 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_y[lc->sc->sh.r->curr_subpic_idx] == ry) |
2499 | 40683 | lc->boundary_flags |= BOUNDARY_UPPER_SUBPIC; | |
2500 |
4/4✓ Branch 0 taken 226230 times.
✓ Branch 1 taken 22257 times.
✓ Branch 2 taken 219696 times.
✓ Branch 3 taken 6534 times.
|
248487 | lc->ctb_left_flag = rx > 0 && !(lc->boundary_flags & BOUNDARY_LEFT_TILE); |
2501 |
6/6✓ Branch 0 taken 209046 times.
✓ Branch 1 taken 39441 times.
✓ Branch 2 taken 199794 times.
✓ Branch 3 taken 9252 times.
✓ Branch 4 taken 197814 times.
✓ Branch 5 taken 1980 times.
|
248487 | lc->ctb_up_flag = ry > 0 && !(lc->boundary_flags & BOUNDARY_UPPER_TILE) && !(lc->boundary_flags & BOUNDARY_UPPER_SLICE); |
2502 |
4/4✓ Branch 0 taken 197814 times.
✓ Branch 1 taken 50673 times.
✓ Branch 2 taken 179588 times.
✓ Branch 3 taken 18226 times.
|
428075 | 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]) && |
2503 |
1/2✓ Branch 0 taken 179588 times.
✗ Branch 1 not taken.
|
179588 | (fc->ps.pps->ctb_to_row_bd[ry] == fc->ps.pps->ctb_to_row_bd[ry - 1]); |
2504 |
4/4✓ Branch 0 taken 219696 times.
✓ Branch 1 taken 28791 times.
✓ Branch 2 taken 179588 times.
✓ Branch 3 taken 40108 times.
|
248487 | lc->ctb_up_left_flag = lc->ctb_left_flag && lc->ctb_up_flag; |
2505 | 248487 | } | |
2506 | |||
2507 | 1984757 | void ff_vvc_set_neighbour_available(VVCLocalContext *lc, | |
2508 | const int x0, const int y0, const int w, const int h) | ||
2509 | { | ||
2510 | 1984757 | const int log2_ctb_size = lc->fc->ps.sps->ctb_log2_size_y; | |
2511 | 1984757 | const int x0b = av_mod_uintp2(x0, log2_ctb_size); | |
2512 | 1984757 | const int y0b = av_mod_uintp2(y0, log2_ctb_size); | |
2513 | |||
2514 |
4/4✓ Branch 0 taken 570769 times.
✓ Branch 1 taken 1413988 times.
✓ Branch 2 taken 503422 times.
✓ Branch 3 taken 67347 times.
|
1984757 | lc->na.cand_up = (lc->ctb_up_flag || y0b); |
2515 |
4/4✓ Branch 0 taken 342227 times.
✓ Branch 1 taken 1642530 times.
✓ Branch 2 taken 293332 times.
✓ Branch 3 taken 48895 times.
|
1984757 | lc->na.cand_left = (lc->ctb_left_flag || x0b); |
2516 |
8/8✓ Branch 0 taken 330335 times.
✓ Branch 1 taken 1654422 times.
✓ Branch 2 taken 234606 times.
✓ Branch 3 taken 95729 times.
✓ Branch 4 taken 1851480 times.
✓ Branch 5 taken 37548 times.
✓ Branch 6 taken 1803930 times.
✓ Branch 7 taken 47550 times.
|
1984757 | lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag; |
2517 | 1984757 | lc->na.cand_up_right_sap = | |
2518 |
6/6✓ Branch 0 taken 307532 times.
✓ Branch 1 taken 1677225 times.
✓ Branch 2 taken 217342 times.
✓ Branch 3 taken 90190 times.
✓ Branch 4 taken 68782 times.
✓ Branch 5 taken 148560 times.
|
1984757 | (x0b + w == 1 << log2_ctb_size) ? lc->ctb_up_right_flag && !y0b : lc->na.cand_up; |
2519 |
4/4✓ Branch 0 taken 1697132 times.
✓ Branch 1 taken 287625 times.
✓ Branch 2 taken 1681754 times.
✓ Branch 3 taken 15378 times.
|
1984757 | lc->na.cand_up_right = lc->na.cand_up_right_sap && (x0 + w) < lc->end_of_tiles_x; |
2520 | 1984757 | } | |
2521 | |||
2522 | 85782 | void ff_vvc_ctu_free_cus(CTU *ctu) | |
2523 | { | ||
2524 | 85782 | CodingUnit **cus = &ctu->cus; | |
2525 |
2/2✓ Branch 0 taken 915428 times.
✓ Branch 1 taken 85782 times.
|
1001210 | while (*cus) { |
2526 | 915428 | CodingUnit *cu = *cus; | |
2527 | 915428 | TransformUnit **head = &cu->tus.head; | |
2528 | |||
2529 | 915428 | *cus = cu->next; | |
2530 | |||
2531 |
2/2✓ Branch 0 taken 1126470 times.
✓ Branch 1 taken 915428 times.
|
2041898 | while (*head) { |
2532 | 1126470 | TransformUnit *tu = *head; | |
2533 | 1126470 | *head = tu->next; | |
2534 | 1126470 | ff_refstruct_unref(&tu); | |
2535 | } | ||
2536 | 915428 | cu->tus.tail = NULL; | |
2537 | |||
2538 | 915428 | ff_refstruct_unref(&cu); | |
2539 | } | ||
2540 | 85782 | } | |
2541 | |||
2542 | 12663405 | int ff_vvc_get_qPy(const VVCFrameContext *fc, const int xc, const int yc) | |
2543 | { | ||
2544 | 12663405 | const int min_cb_log2_size_y = fc->ps.sps->min_cb_log2_size_y; | |
2545 | 12663405 | const int x = xc >> min_cb_log2_size_y; | |
2546 | 12663405 | const int y = yc >> min_cb_log2_size_y; | |
2547 | 12663405 | return fc->tab.qp[LUMA][x + y * fc->ps.pps->min_cb_width]; | |
2548 | } | ||
2549 | |||
2550 | 1922 | void ff_vvc_ep_init_stat_coeff(EntryPoint *ep, | |
2551 | const int bit_depth, const int persistent_rice_adaptation_enabled_flag) | ||
2552 | { | ||
2553 |
2/2✓ Branch 0 taken 5766 times.
✓ Branch 1 taken 1922 times.
|
7688 | for (size_t i = 0; i < FF_ARRAY_ELEMS(ep->stat_coeff); ++i) { |
2554 | 5766 | ep->stat_coeff[i] = | |
2555 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5766 times.
|
5766 | persistent_rice_adaptation_enabled_flag ? 2 * (av_log2(bit_depth - 10)) : 0; |
2556 | } | ||
2557 | 1922 | } | |
2558 |