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 "libavutil/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 | 2056903 | static void set_tb_size(const VVCFrameContext *fc, const TransformBlock *tb) | |
42 | { | ||
43 | 2056903 | const int x_tb = tb->x0 >> MIN_TU_LOG2; | |
44 | 2056903 | const int y_tb = tb->y0 >> MIN_TU_LOG2; | |
45 | 2056903 | const int hs = fc->ps.sps->hshift[tb->c_idx]; | |
46 | 2056903 | const int vs = fc->ps.sps->vshift[tb->c_idx]; | |
47 | 2056903 | const int is_chroma = tb->c_idx != 0; | |
48 | 2056903 | const int width = FFMAX(1, tb->tb_width >> (MIN_TU_LOG2 - hs)); | |
49 | 2056903 | const int end = y_tb + FFMAX(1, tb->tb_height >> (MIN_TU_LOG2 - vs)); | |
50 | |||
51 |
2/2✓ Branch 0 taken 9683367 times.
✓ Branch 1 taken 2056903 times.
|
11740270 | for (int y = y_tb; y < end; y++) { |
52 | 9683367 | const int off = y * fc->ps.pps->min_tu_width + x_tb; | |
53 | 9683367 | memset(fc->tab.tb_width [is_chroma] + off, tb->tb_width, width); | |
54 | 9683367 | memset(fc->tab.tb_height[is_chroma] + off, tb->tb_height, width); | |
55 | } | ||
56 | 2056903 | } | |
57 | |||
58 | 2876061 | static void set_tb_tab(uint8_t *tab, uint8_t v, const VVCFrameContext *fc, | |
59 | const TransformBlock *tb) | ||
60 | { | ||
61 | 2876061 | const int width = tb->tb_width << fc->ps.sps->hshift[tb->c_idx]; | |
62 | 2876061 | const int height = tb->tb_height << fc->ps.sps->vshift[tb->c_idx]; | |
63 | |||
64 |
2/2✓ Branch 0 taken 13390863 times.
✓ Branch 1 taken 2876061 times.
|
16266924 | for (int h = 0; h < height; h += MIN_TU_SIZE) { |
65 | 13390863 | const int y = (tb->y0 + h) >> MIN_TU_LOG2; | |
66 | 13390863 | const int off = y * fc->ps.pps->min_tu_width + (tb->x0 >> MIN_TU_LOG2); | |
67 | 13390863 | const int w = FFMAX(1, width >> MIN_TU_LOG2); | |
68 | 13390863 | memset(tab + off, v, w); | |
69 | } | ||
70 | 2876061 | } | |
71 | |||
72 | // 8.7.1 Derivation process for quantization parameters | ||
73 | 2765 | static int get_qp_y_pred(const VVCLocalContext *lc) | |
74 | { | ||
75 | 2765 | const VVCFrameContext *fc = lc->fc; | |
76 | 2765 | const VVCSPS *sps = fc->ps.sps; | |
77 | 2765 | const VVCPPS *pps = fc->ps.pps; | |
78 | 2765 | const CodingUnit *cu = lc->cu; | |
79 | 2765 | const int ctb_log2_size = sps->ctb_log2_size_y; | |
80 | 2765 | const int ctb_size_mask = (1 << ctb_log2_size) - 1; | |
81 | 2765 | const int xQg = lc->parse.cu_qg_top_left_x; | |
82 | 2765 | const int yQg = lc->parse.cu_qg_top_left_y; | |
83 | 2765 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
84 | 2765 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
85 | 2765 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
86 | 2765 | const int rx = cu->x0 >> ctb_log2_size; | |
87 | 2765 | const int ry = cu->y0 >> ctb_log2_size; | |
88 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2765 | const int in_same_ctb_a = ((xQg - 1) >> ctb_log2_size) == rx && (yQg >> ctb_log2_size) == ry; |
89 |
2/4✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2765 times.
|
2765 | const int in_same_ctb_b = (xQg >> ctb_log2_size) == rx && ((yQg - 1) >> ctb_log2_size) == ry; |
90 | int qPy_pred, qPy_a, qPy_b; | ||
91 | |||
92 |
2/2✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 1084 times.
|
2765 | if (lc->na.cand_up) { |
93 |
2/4✓ Branch 0 taken 1681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1681 times.
✗ Branch 3 not taken.
|
1681 | const int first_qg_in_ctu = !(xQg & ctb_size_mask) && !(yQg & ctb_size_mask); |
94 | 1681 | const int qPy_up = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
95 |
3/4✓ Branch 0 taken 1681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 438 times.
✓ Branch 3 taken 1243 times.
|
1681 | if (first_qg_in_ctu && pps->ctb_to_col_bd[xQg >> ctb_log2_size] == xQg >> ctb_log2_size) |
96 | 438 | return qPy_up; | |
97 | } | ||
98 | |||
99 | // qPy_pred | ||
100 |
2/2✓ Branch 0 taken 429 times.
✓ Branch 1 taken 1898 times.
|
2327 | qPy_pred = lc->ep->is_first_qg ? lc->sc->sh.slice_qp_y : lc->ep->qp_y; |
101 | |||
102 | // qPy_b | ||
103 |
3/4✓ Branch 0 taken 1243 times.
✓ Branch 1 taken 1084 times.
✓ Branch 2 taken 1243 times.
✗ Branch 3 not taken.
|
2327 | if (!lc->na.cand_up || !in_same_ctb_b) |
104 | 2327 | qPy_b = qPy_pred; | |
105 | else | ||
106 | ✗ | qPy_b = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
107 | |||
108 | // qPy_a | ||
109 |
3/4✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 429 times.
✓ Branch 2 taken 1898 times.
✗ Branch 3 not taken.
|
2327 | if (!lc->na.cand_left || !in_same_ctb_a) |
110 | 2327 | qPy_a = qPy_pred; | |
111 | else | ||
112 | ✗ | qPy_a = fc->tab.qp[LUMA][(x_cb - 1) + y_cb * min_cb_width]; | |
113 | |||
114 | av_assert2(qPy_a >= -fc->ps.sps->qp_bd_offset && qPy_a <= 63); | ||
115 | av_assert2(qPy_b >= -fc->ps.sps->qp_bd_offset && qPy_b <= 63); | ||
116 | |||
117 | 2327 | return (qPy_a + qPy_b + 1) >> 1; | |
118 | } | ||
119 | |||
120 | 8822805 | static void set_cb_tab(const VVCLocalContext *lc, uint8_t *tab, const uint8_t v) | |
121 | { | ||
122 | 8822805 | const VVCFrameContext *fc = lc->fc; | |
123 | 8822805 | const VVCPPS *pps = fc->ps.pps; | |
124 | 8822805 | const CodingUnit *cu = lc->cu; | |
125 | 8822805 | const int log2_min_cb_size = fc->ps.sps->min_cb_log2_size_y; | |
126 | 8822805 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
127 | 8822805 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
128 | 8822805 | const int cb_width = cu->cb_width; | |
129 | 8822805 | const int cb_height = cu->cb_height; | |
130 | 8822805 | int x = y_cb * pps->min_cb_width + x_cb; | |
131 | |||
132 |
2/2✓ Branch 0 taken 37635607 times.
✓ Branch 1 taken 8822805 times.
|
46458412 | for (int y = 0; y < (cb_height >> log2_min_cb_size); y++) { |
133 | 37635607 | const int width = cb_width >> log2_min_cb_size; | |
134 | |||
135 | 37635607 | memset(&tab[x], v, width); | |
136 | 37635607 | x += pps->min_cb_width; | |
137 | } | ||
138 | 8822805 | } | |
139 | |||
140 | 1247587 | static int set_qp_y(VVCLocalContext *lc, const int x0, const int y0, const int has_qp_delta) | |
141 | { | ||
142 | 1247587 | const VVCSPS *sps = lc->fc->ps.sps; | |
143 | 1247587 | EntryPoint *ep = lc->ep; | |
144 | 1247587 | CodingUnit *cu = lc->cu; | |
145 | 1247587 | int cu_qp_delta = 0; | |
146 | |||
147 |
2/2✓ Branch 0 taken 1080137 times.
✓ Branch 1 taken 167450 times.
|
1247587 | if (!lc->fc->ps.pps->r->pps_cu_qp_delta_enabled_flag) { |
148 | 1080137 | ep->qp_y = lc->sc->sh.slice_qp_y; | |
149 |
6/6✓ Branch 0 taken 167021 times.
✓ Branch 1 taken 429 times.
✓ Branch 2 taken 15446 times.
✓ Branch 3 taken 151575 times.
✓ Branch 4 taken 2336 times.
✓ Branch 5 taken 13110 times.
|
167450 | } else if (ep->is_first_qg || (lc->parse.cu_qg_top_left_x == x0 && lc->parse.cu_qg_top_left_y == y0)) { |
150 | 2765 | ep->qp_y = get_qp_y_pred(lc); | |
151 | 2765 | ep->is_first_qg = 0; | |
152 | } | ||
153 | |||
154 |
2/2✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1245699 times.
|
1247587 | if (has_qp_delta) { |
155 | 1888 | const int cu_qp_delta_abs = ff_vvc_cu_qp_delta_abs(lc); | |
156 | |||
157 |
2/2✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 782 times.
|
1888 | if (cu_qp_delta_abs) |
158 |
2/2✓ Branch 1 taken 649 times.
✓ Branch 2 taken 457 times.
|
1106 | cu_qp_delta = ff_vvc_cu_qp_delta_sign_flag(lc) ? -cu_qp_delta_abs : cu_qp_delta_abs; |
159 |
2/4✓ Branch 0 taken 1888 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1888 times.
|
1888 | if (cu_qp_delta > (31 + sps->qp_bd_offset / 2) || cu_qp_delta < -(32 + sps->qp_bd_offset / 2)) |
160 | ✗ | return AVERROR_INVALIDDATA; | |
161 | 1888 | lc->parse.is_cu_qp_delta_coded = 1; | |
162 | |||
163 |
2/2✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 782 times.
|
1888 | if (cu_qp_delta) { |
164 | 1106 | int off = sps->qp_bd_offset; | |
165 |
1/2✓ Branch 0 taken 1106 times.
✗ Branch 1 not taken.
|
1106 | ep->qp_y = FFUMOD(ep->qp_y + cu_qp_delta + 64 + 2 * off, 64 + off) - off; |
166 | } | ||
167 | } | ||
168 | |||
169 | 1247587 | set_cb_tab(lc, lc->fc->tab.qp[LUMA], ep->qp_y); | |
170 | 1247587 | cu->qp[LUMA] = ep->qp_y; | |
171 | |||
172 | 1247587 | return 0; | |
173 | } | ||
174 | |||
175 | 1493204 | static void set_qp_c_tab(const VVCLocalContext *lc, const TransformUnit *tu, const TransformBlock *tb) | |
176 | { | ||
177 |
6/6✓ Branch 0 taken 104464 times.
✓ Branch 1 taken 1388740 times.
✓ Branch 2 taken 89064 times.
✓ Branch 3 taken 15400 times.
✓ Branch 4 taken 59526 times.
✓ Branch 5 taken 29538 times.
|
1493204 | const int is_jcbcr = tu->joint_cbcr_residual_flag && tu->coded_flag[CB] && tu->coded_flag[CR]; |
178 |
2/2✓ Branch 0 taken 1433678 times.
✓ Branch 1 taken 59526 times.
|
1493204 | const int idx = is_jcbcr ? JCBCR : tb->c_idx; |
179 | |||
180 | 1493204 | set_tb_tab(lc->fc->tab.qp[tb->c_idx], lc->cu->qp[idx], lc->fc, tb); | |
181 | 1493204 | } | |
182 | |||
183 | 1189864 | static void set_qp_c(VVCLocalContext *lc) | |
184 | { | ||
185 | 1189864 | const VVCFrameContext *fc = lc->fc; | |
186 | 1189864 | const VVCSPS *sps = fc->ps.sps; | |
187 | 1189864 | const VVCPPS *pps = fc->ps.pps; | |
188 | 1189864 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
189 | 1189864 | CodingUnit *cu = lc->cu; | |
190 | 1189864 | const int x_center = cu->x0 + cu->cb_width / 2; | |
191 | 1189864 | const int y_center = cu->y0 + cu->cb_height / 2; | |
192 | 1189864 | const int single_tree = cu->tree_type == SINGLE_TREE; | |
193 |
2/2✓ Branch 0 taken 468948 times.
✓ Branch 1 taken 720916 times.
|
1189864 | const int qp_luma = (single_tree ? lc->ep->qp_y : ff_vvc_get_qPy(fc, x_center, y_center)) + sps->qp_bd_offset; |
194 | 1189864 | const int qp_chroma = av_clip(qp_luma, 0, MAX_QP + sps->qp_bd_offset); | |
195 | 1189864 | const int sh_chroma_qp_offset[] = { | |
196 | 1189864 | rsh->sh_cb_qp_offset, | |
197 | 1189864 | rsh->sh_cr_qp_offset, | |
198 | 1189864 | rsh->sh_joint_cbcr_qp_offset, | |
199 | }; | ||
200 | int qp; | ||
201 | |||
202 |
2/2✓ Branch 0 taken 3526697 times.
✓ Branch 1 taken 1189864 times.
|
4716561 | for (int i = CB - 1; i < CR + sps->r->sps_joint_cbcr_enabled_flag; i++) { |
203 | 3526697 | qp = sps->chroma_qp_table[i][qp_chroma]; | |
204 | 3526697 | qp = qp + pps->chroma_qp_offset[i] + sh_chroma_qp_offset[i] + lc->parse.chroma_qp_offset[i]; | |
205 | 3526697 | qp = av_clip(qp, -sps->qp_bd_offset, MAX_QP) + sps->qp_bd_offset; | |
206 | 3526697 | cu->qp[i + 1] = qp; | |
207 | } | ||
208 | 1189864 | } | |
209 | |||
210 | 1491918 | static TransformUnit* alloc_tu(VVCFrameContext *fc, CodingUnit *cu) | |
211 | { | ||
212 | 1491918 | TransformUnit *tu = av_refstruct_pool_get(fc->tu_pool); | |
213 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1491918 times.
|
1491918 | if (!tu) |
214 | ✗ | return NULL; | |
215 | |||
216 | 1491918 | tu->next = NULL; | |
217 | |||
218 |
2/2✓ Branch 0 taken 259849 times.
✓ Branch 1 taken 1232069 times.
|
1491918 | if (cu->tus.tail) |
219 | 259849 | cu->tus.tail->next = tu; | |
220 | else | ||
221 | 1232069 | cu->tus.head = tu; | |
222 | 1491918 | cu->tus.tail = tu; | |
223 | |||
224 | 1491918 | return tu; | |
225 | } | ||
226 | |||
227 | 1491918 | static TransformUnit* add_tu(VVCFrameContext *fc, CodingUnit *cu, const int x0, const int y0, const int tu_width, const int tu_height) | |
228 | { | ||
229 | 1491918 | TransformUnit *tu = alloc_tu(fc, cu); | |
230 | |||
231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1491918 times.
|
1491918 | if (!tu) |
232 | ✗ | return NULL; | |
233 | |||
234 | 1491918 | tu->x0 = x0; | |
235 | 1491918 | tu->y0 = y0; | |
236 | 1491918 | tu->width = tu_width; | |
237 | 1491918 | tu->height = tu_height; | |
238 | 1491918 | tu->joint_cbcr_residual_flag = 0; | |
239 | 1491918 | memset(tu->coded_flag, 0, sizeof(tu->coded_flag)); | |
240 | 1491918 | tu->avail[LUMA] = tu->avail[CHROMA] = 0; | |
241 | 1491918 | tu->nb_tbs = 0; | |
242 | |||
243 | 1491918 | return tu; | |
244 | } | ||
245 | |||
246 | 2803505 | static TransformBlock* add_tb(TransformUnit *tu, VVCLocalContext *lc, | |
247 | const int x0, const int y0, const int tb_width, const int tb_height, const int c_idx) | ||
248 | { | ||
249 | TransformBlock *tb; | ||
250 | |||
251 | 2803505 | tb = &tu->tbs[tu->nb_tbs++]; | |
252 | 2803505 | tb->has_coeffs = 0; | |
253 | 2803505 | tb->x0 = x0; | |
254 | 2803505 | tb->y0 = y0; | |
255 | 2803505 | tb->tb_width = tb_width; | |
256 | 2803505 | tb->tb_height = tb_height; | |
257 | 2803505 | tb->log2_tb_width = av_log2(tb_width); | |
258 | 2803505 | tb->log2_tb_height = av_log2(tb_height); | |
259 | |||
260 | 2803505 | tb->max_scan_x = tb->max_scan_y = 0; | |
261 | 2803505 | tb->min_scan_x = tb->min_scan_y = 0; | |
262 | |||
263 | 2803505 | tb->c_idx = c_idx; | |
264 | 2803505 | tb->ts = 0; | |
265 | 2803505 | tb->coeffs = lc->coeffs; | |
266 | 2803505 | lc->coeffs += tb_width * tb_height; | |
267 | 2803505 | tu->avail[!!c_idx] = true; | |
268 | 2803505 | return tb; | |
269 | } | ||
270 | |||
271 | 952753 | static uint8_t tu_y_coded_flag_decode(VVCLocalContext *lc, const int is_sbt_not_coded, | |
272 | const int sub_tu_index, const int is_isp, const int is_chroma_coded) | ||
273 | { | ||
274 | 952753 | uint8_t tu_y_coded_flag = 0; | |
275 | 952753 | const VVCSPS *sps = lc->fc->ps.sps; | |
276 | 952753 | CodingUnit *cu = lc->cu; | |
277 | |||
278 |
2/2✓ Branch 0 taken 908158 times.
✓ Branch 1 taken 44595 times.
|
952753 | if (!is_sbt_not_coded) { |
279 |
4/4✓ Branch 0 taken 766500 times.
✓ Branch 1 taken 141658 times.
✓ Branch 2 taken 50597 times.
✓ Branch 3 taken 715903 times.
|
908158 | int has_y_coded_flag = sub_tu_index < cu->num_intra_subpartitions - 1 || !lc->parse.infer_tu_cbf_luma; |
280 |
2/2✓ Branch 0 taken 704096 times.
✓ Branch 1 taken 204062 times.
|
908158 | if (!is_isp) { |
281 |
4/4✓ Branch 0 taken 692608 times.
✓ Branch 1 taken 11488 times.
✓ Branch 2 taken 2504 times.
✓ Branch 3 taken 690104 times.
|
704096 | const int is_large = cu->cb_width > sps->max_tb_size_y || cu->cb_height > sps->max_tb_size_y; |
282 |
7/8✓ Branch 0 taken 535230 times.
✓ Branch 1 taken 168866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 535230 times.
✓ Branch 4 taken 108215 times.
✓ Branch 5 taken 60651 times.
✓ Branch 6 taken 2550 times.
✓ Branch 7 taken 105665 times.
|
704096 | has_y_coded_flag = (cu->pred_mode == MODE_INTRA && !cu->act_enabled_flag) || is_chroma_coded || is_large; |
283 | } | ||
284 |
2/2✓ Branch 0 taken 790686 times.
✓ Branch 1 taken 117472 times.
|
908158 | tu_y_coded_flag = has_y_coded_flag ? ff_vvc_tu_y_coded_flag(lc) : 1; |
285 | } | ||
286 |
2/2✓ Branch 0 taken 204062 times.
✓ Branch 1 taken 748691 times.
|
952753 | if (is_isp) |
287 |
4/4✓ Branch 0 taken 101546 times.
✓ Branch 1 taken 102516 times.
✓ Branch 2 taken 39142 times.
✓ Branch 3 taken 62404 times.
|
204062 | lc->parse.infer_tu_cbf_luma = lc->parse.infer_tu_cbf_luma && !tu_y_coded_flag; |
288 | 952753 | return tu_y_coded_flag; | |
289 | } | ||
290 | |||
291 | 470420 | static void chroma_qp_offset_decode(VVCLocalContext *lc, const int is_128, const int is_chroma_coded) | |
292 | { | ||
293 | 470420 | const VVCPPS *pps = lc->fc->ps.pps; | |
294 | 470420 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
295 | |||
296 |
4/4✓ Branch 0 taken 462206 times.
✓ Branch 1 taken 8214 times.
✓ Branch 2 taken 186185 times.
✓ Branch 3 taken 276021 times.
|
470420 | if ((is_128 || is_chroma_coded) && |
297 |
4/4✓ Branch 0 taken 39307 times.
✓ Branch 1 taken 155092 times.
✓ Branch 2 taken 1029 times.
✓ Branch 3 taken 38278 times.
|
194399 | rsh->sh_cu_chroma_qp_offset_enabled_flag && !lc->parse.is_cu_chroma_qp_offset_coded) { |
298 | 1029 | const int cu_chroma_qp_offset_flag = ff_vvc_cu_chroma_qp_offset_flag(lc); | |
299 |
1/2✓ Branch 0 taken 1029 times.
✗ Branch 1 not taken.
|
1029 | if (cu_chroma_qp_offset_flag) { |
300 | 1029 | int cu_chroma_qp_offset_idx = 0; | |
301 |
2/2✓ Branch 0 taken 931 times.
✓ Branch 1 taken 98 times.
|
1029 | if (pps->r->pps_chroma_qp_offset_list_len_minus1 > 0) |
302 | 931 | cu_chroma_qp_offset_idx = ff_vvc_cu_chroma_qp_offset_idx(lc); | |
303 |
2/2✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 1029 times.
|
4116 | for (int i = CB - 1; i < JCBCR; i++) |
304 | 3087 | lc->parse.chroma_qp_offset[i] = pps->chroma_qp_offset_list[cu_chroma_qp_offset_idx][i]; | |
305 | } else { | ||
306 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
307 | } | ||
308 | 1029 | lc->parse.is_cu_chroma_qp_offset_coded = 1; | |
309 | } | ||
310 | 470420 | } | |
311 | |||
312 | 1134370 | static int hls_transform_unit(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int sub_tu_index, int ch_type) | |
313 | { | ||
314 | 1134370 | VVCFrameContext *fc = lc->fc; | |
315 | 1134370 | const VVCSPS *sps = fc->ps.sps; | |
316 | 1134370 | const VVCPPS *pps = fc->ps.pps; | |
317 | 1134370 | CodingUnit *cu = lc->cu; | |
318 | 1134370 | TransformUnit *tu = add_tu(fc, cu, x0, y0, tu_width, tu_height); | |
319 | 1134370 | const int min_cb_width = pps->min_cb_width; | |
320 | 1134370 | const VVCTreeType tree_type = cu->tree_type; | |
321 |
4/4✓ Branch 0 taken 1127794 times.
✓ Branch 1 taken 6576 times.
✓ Branch 2 taken 1638 times.
✓ Branch 3 taken 1126156 times.
|
1134370 | const int is_128 = cu->cb_width > 64 || cu->cb_height > 64; |
322 | 1134370 | const int is_isp = cu->isp_split_type != ISP_NO_SPLIT; | |
323 |
4/4✓ Branch 0 taken 204062 times.
✓ Branch 1 taken 930308 times.
✓ Branch 2 taken 62404 times.
✓ Branch 3 taken 141658 times.
|
1134370 | const int is_isp_last_tu = is_isp && (sub_tu_index == cu->num_intra_subpartitions - 1); |
324 |
4/4✓ Branch 0 taken 89190 times.
✓ Branch 1 taken 1045180 times.
✓ Branch 2 taken 44595 times.
✓ Branch 3 taken 44595 times.
|
1223560 | const int is_sbt_not_coded = cu->sbt_flag && |
325 |
6/6✓ Branch 0 taken 23208 times.
✓ Branch 1 taken 21387 times.
✓ Branch 2 taken 44595 times.
✓ Branch 3 taken 23208 times.
✓ Branch 4 taken 23208 times.
✓ Branch 5 taken 21387 times.
|
89190 | ((sub_tu_index == 0 && cu->sbt_pos_flag) || (sub_tu_index == 1 && !cu->sbt_pos_flag)); |
326 |
6/6✓ Branch 0 taken 470420 times.
✓ Branch 1 taken 663950 times.
✓ Branch 2 taken 446948 times.
✓ Branch 3 taken 23472 times.
✓ Branch 4 taken 20710 times.
✓ Branch 5 taken 426238 times.
|
1155080 | const int chroma_available = tree_type != DUAL_TREE_LUMA && sps->r->sps_chroma_format_idc && |
327 |
2/2✓ Branch 0 taken 5191 times.
✓ Branch 1 taken 15519 times.
|
20710 | (!is_isp || is_isp_last_tu); |
328 | int ret, xc, yc, wc, hc, is_chroma_coded; | ||
329 | |||
330 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1134370 times.
|
1134370 | if (!tu) |
331 | ✗ | return AVERROR_INVALIDDATA; | |
332 | |||
333 |
4/4✓ Branch 0 taken 288803 times.
✓ Branch 1 taken 845567 times.
✓ Branch 2 taken 6973 times.
✓ Branch 3 taken 281830 times.
|
1134370 | if (tree_type == SINGLE_TREE && is_isp_last_tu) { |
334 | 6973 | const int x_cu = x0 >> fc->ps.sps->min_cb_log2_size_y; | |
335 | 6973 | const int y_cu = y0 >> fc->ps.sps->min_cb_log2_size_y; | |
336 | 6973 | xc = SAMPLE_CTB(fc->tab.cb_pos_x[ch_type], x_cu, y_cu); | |
337 | 6973 | yc = SAMPLE_CTB(fc->tab.cb_pos_y[ch_type], x_cu, y_cu); | |
338 | 6973 | wc = SAMPLE_CTB(fc->tab.cb_width[ch_type], x_cu, y_cu); | |
339 | 6973 | hc = SAMPLE_CTB(fc->tab.cb_height[ch_type], x_cu, y_cu); | |
340 | } else { | ||
341 | 1127397 | xc = x0, yc = y0, wc = tu_width, hc = tu_height; | |
342 | } | ||
343 | |||
344 |
4/4✓ Branch 0 taken 431429 times.
✓ Branch 1 taken 702941 times.
✓ Branch 2 taken 388126 times.
✓ Branch 3 taken 43303 times.
|
1134370 | if (chroma_available && !is_sbt_not_coded) { |
345 | 388126 | tu->coded_flag[CB] = ff_vvc_tu_cb_coded_flag(lc); | |
346 | 388126 | tu->coded_flag[CR] = ff_vvc_tu_cr_coded_flag(lc, tu->coded_flag[CB]); | |
347 | } | ||
348 | |||
349 |
6/6✓ Branch 0 taken 431429 times.
✓ Branch 1 taken 702941 times.
✓ Branch 2 taken 268175 times.
✓ Branch 3 taken 163254 times.
✓ Branch 4 taken 28723 times.
✓ Branch 5 taken 239452 times.
|
1134370 | is_chroma_coded = chroma_available && (tu->coded_flag[CB] || tu->coded_flag[CR]); |
350 | |||
351 |
2/2✓ Branch 0 taken 952753 times.
✓ Branch 1 taken 181617 times.
|
1134370 | if (tree_type != DUAL_TREE_CHROMA) { |
352 | int has_qp_delta; | ||
353 | 952753 | tu->coded_flag[LUMA] = tu_y_coded_flag_decode(lc, is_sbt_not_coded, sub_tu_index, is_isp, is_chroma_coded); | |
354 |
4/4✓ Branch 0 taken 253293 times.
✓ Branch 1 taken 691246 times.
✓ Branch 2 taken 34290 times.
✓ Branch 3 taken 219003 times.
|
944539 | has_qp_delta = (is_128 || tu->coded_flag[LUMA] || is_chroma_coded) && |
355 |
6/6✓ Branch 0 taken 944539 times.
✓ Branch 1 taken 8214 times.
✓ Branch 2 taken 77901 times.
✓ Branch 3 taken 655849 times.
✓ Branch 4 taken 1888 times.
✓ Branch 5 taken 76013 times.
|
1897292 | pps->r->pps_cu_qp_delta_enabled_flag && !lc->parse.is_cu_qp_delta_coded; |
356 | 952753 | ret = set_qp_y(lc, x0, y0, has_qp_delta); | |
357 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 952753 times.
|
952753 | if (ret < 0) |
358 | ✗ | return ret; | |
359 | 952753 | add_tb(tu, lc, x0, y0, tu_width, tu_height, LUMA); | |
360 | } | ||
361 |
2/2✓ Branch 0 taken 470420 times.
✓ Branch 1 taken 663950 times.
|
1134370 | if (tree_type != DUAL_TREE_LUMA) { |
362 | 470420 | chroma_qp_offset_decode(lc, is_128, is_chroma_coded); | |
363 |
2/2✓ Branch 0 taken 431429 times.
✓ Branch 1 taken 38991 times.
|
470420 | if (chroma_available) { |
364 | 431429 | const int hs = sps->hshift[CHROMA]; | |
365 | 431429 | const int vs = sps->vshift[CHROMA]; | |
366 | 431429 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CB); | |
367 | 431429 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CR); | |
368 | } | ||
369 | } | ||
370 |
4/4✓ Branch 0 taken 1091166 times.
✓ Branch 1 taken 43204 times.
✓ Branch 2 taken 886026 times.
✓ Branch 3 taken 205140 times.
|
1134370 | if (sps->r->sps_joint_cbcr_enabled_flag && ((cu->pred_mode == MODE_INTRA && |
371 |
4/4✓ Branch 0 taken 783525 times.
✓ Branch 1 taken 102501 times.
✓ Branch 2 taken 760236 times.
✓ Branch 3 taken 23289 times.
|
886026 | (tu->coded_flag[CB] || tu->coded_flag[CR])) || |
372 |
5/6✓ Branch 0 taken 55363 times.
✓ Branch 1 taken 910013 times.
✓ Branch 2 taken 23815 times.
✓ Branch 3 taken 31548 times.
✓ Branch 4 taken 149605 times.
✗ Branch 5 not taken.
|
1091166 | (tu->coded_flag[CB] && tu->coded_flag[CR])) && |
373 | chroma_available) { | ||
374 | 149605 | tu->joint_cbcr_residual_flag = ff_vvc_tu_joint_cbcr_residual_flag(lc, tu->coded_flag[1], tu->coded_flag[2]); | |
375 | } | ||
376 | |||
377 |
2/2✓ Branch 0 taken 1815611 times.
✓ Branch 1 taken 1134370 times.
|
2949981 | for (int i = 0; i < tu->nb_tbs; i++) { |
378 | 1815611 | TransformBlock *tb = &tu->tbs[i]; | |
379 | 1815611 | const int is_chroma = tb->c_idx != LUMA; | |
380 | 1815611 | tb->has_coeffs = tu->coded_flag[tb->c_idx]; | |
381 |
4/4✓ Branch 0 taken 981191 times.
✓ Branch 1 taken 834420 times.
✓ Branch 2 taken 284154 times.
✓ Branch 3 taken 697037 times.
|
1815611 | if (tb->has_coeffs && is_chroma) |
382 |
6/6✓ Branch 0 taken 120900 times.
✓ Branch 1 taken 163254 times.
✓ Branch 2 taken 92177 times.
✓ Branch 3 taken 28723 times.
✓ Branch 4 taken 62414 times.
✓ Branch 5 taken 29763 times.
|
284154 | tb->has_coeffs = tb->c_idx == CB ? 1 : !(tu->coded_flag[CB] && tu->joint_cbcr_residual_flag); |
383 |
2/2✓ Branch 0 taken 951428 times.
✓ Branch 1 taken 864183 times.
|
1815611 | if (tb->has_coeffs) { |
384 | 951428 | tb->ts = cu->bdpcm_flag[tb->c_idx]; | |
385 |
4/4✓ Branch 0 taken 833800 times.
✓ Branch 1 taken 117628 times.
✓ Branch 2 taken 833790 times.
✓ Branch 3 taken 10 times.
|
951428 | if (sps->r->sps_transform_skip_enabled_flag && !cu->bdpcm_flag[tb->c_idx] && |
386 |
4/4✓ Branch 0 taken 817404 times.
✓ Branch 1 taken 16386 times.
✓ Branch 2 taken 810235 times.
✓ Branch 3 taken 7169 times.
|
833790 | tb->tb_width <= sps->max_ts_size && tb->tb_height <= sps->max_ts_size && |
387 |
6/6✓ Branch 0 taken 770591 times.
✓ Branch 1 taken 39644 times.
✓ Branch 2 taken 594591 times.
✓ Branch 3 taken 176000 times.
✓ Branch 4 taken 461363 times.
✓ Branch 5 taken 133228 times.
|
810235 | !cu->sbt_flag && (is_chroma || !is_isp)) { |
388 | 637363 | tb->ts = ff_vvc_transform_skip_flag(lc, is_chroma); | |
389 | } | ||
390 | 951428 | ret = ff_vvc_residual_coding(lc, tb); | |
391 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 951428 times.
|
951428 | if (ret < 0) |
392 | ✗ | return ret; | |
393 | 951428 | set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], tu->coded_flag[tb->c_idx], fc, tb); | |
394 | } | ||
395 |
2/2✓ Branch 0 taken 1384182 times.
✓ Branch 1 taken 431429 times.
|
1815611 | if (tb->c_idx != CR) |
396 | 1384182 | set_tb_size(fc, tb); | |
397 |
2/2✓ Branch 0 taken 431429 times.
✓ Branch 1 taken 1384182 times.
|
1815611 | if (tb->c_idx == CB) |
398 | 431429 | set_tb_tab(fc->tab.tu_joint_cbcr_residual_flag, tu->joint_cbcr_residual_flag, fc, tb); | |
399 | } | ||
400 | |||
401 | 1134370 | return 0; | |
402 | } | ||
403 | |||
404 | 958999 | static int hls_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int ch_type) | |
405 | { | ||
406 | 958999 | const CodingUnit *cu = lc->cu; | |
407 | 958999 | const VVCSPS *sps = lc->fc->ps.sps; | |
408 | int ret; | ||
409 | |||
410 | 958999 | lc->parse.infer_tu_cbf_luma = 1; | |
411 |
4/4✓ Branch 0 taken 896595 times.
✓ Branch 1 taken 62404 times.
✓ Branch 2 taken 852000 times.
✓ Branch 3 taken 44595 times.
|
958999 | if (cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag) { |
412 |
4/4✓ Branch 0 taken 842872 times.
✓ Branch 1 taken 9128 times.
✓ Branch 2 taken 1754 times.
✓ Branch 3 taken 841118 times.
|
862882 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
413 |
4/4✓ Branch 0 taken 9128 times.
✓ Branch 1 taken 1754 times.
✓ Branch 2 taken 6596 times.
✓ Branch 3 taken 2532 times.
|
10882 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
414 |
2/2✓ Branch 0 taken 6596 times.
✓ Branch 1 taken 4286 times.
|
10882 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
415 |
2/2✓ Branch 0 taken 4286 times.
✓ Branch 1 taken 6596 times.
|
10882 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
416 | |||
417 | #define TRANSFORM_TREE(x, y) do { \ | ||
418 | ret = hls_transform_tree(lc, x, y, trafo_width, trafo_height, ch_type); \ | ||
419 | if (ret < 0) \ | ||
420 | return ret; \ | ||
421 | } while (0) | ||
422 | |||
423 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10882 times.
|
10882 | TRANSFORM_TREE(x0, y0); |
424 |
2/2✓ Branch 0 taken 6596 times.
✓ Branch 1 taken 4286 times.
|
10882 | if (ver_split_first) |
425 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6596 times.
|
6596 | TRANSFORM_TREE(x0 + trafo_width, y0); |
426 | else | ||
427 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4286 times.
|
4286 | TRANSFORM_TREE(x0, y0 + trafo_height); |
428 | |||
429 | } else { | ||
430 | 841118 | ret = hls_transform_unit(lc, x0, y0, tu_width, tu_height, 0, ch_type); | |
431 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 841118 times.
|
841118 | if (ret < 0) |
432 | ✗ | return ret; | |
433 | |||
434 | } | ||
435 |
2/2✓ Branch 0 taken 44595 times.
✓ Branch 1 taken 62404 times.
|
106999 | } else if (cu->sbt_flag) { |
436 |
2/2✓ Branch 0 taken 23565 times.
✓ Branch 1 taken 21030 times.
|
44595 | if (!cu->sbt_horizontal_flag) { |
437 | #define TRANSFORM_UNIT(x, width, idx) do { \ | ||
438 | ret = hls_transform_unit(lc, x, y0, width, tu_height, idx, ch_type); \ | ||
439 | if (ret < 0) \ | ||
440 | return ret; \ | ||
441 | } while (0) | ||
442 | |||
443 | 23565 | const int trafo_width = tu_width * lc->parse.sbt_num_fourths_tb0 / 4; | |
444 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 23565 times.
|
23565 | TRANSFORM_UNIT(x0, trafo_width, 0); |
445 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 23565 times.
|
23565 | TRANSFORM_UNIT(x0 + trafo_width, tu_width - trafo_width, 1); |
446 | |||
447 | #undef TRANSFORM_UNIT | ||
448 | } else { | ||
449 | #define TRANSFORM_UNIT(y, height, idx) do { \ | ||
450 | ret = hls_transform_unit(lc, x0, y, tu_width, height, idx, ch_type); \ | ||
451 | if (ret < 0) \ | ||
452 | return ret; \ | ||
453 | } while (0) | ||
454 | |||
455 | 21030 | const int trafo_height = tu_height * lc->parse.sbt_num_fourths_tb0 / 4; | |
456 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21030 times.
|
21030 | TRANSFORM_UNIT(y0, trafo_height, 0); |
457 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21030 times.
|
21030 | TRANSFORM_UNIT(y0 + trafo_height, tu_height - trafo_height, 1); |
458 | |||
459 | #undef TRANSFORM_UNIT | ||
460 | } | ||
461 |
2/2✓ Branch 0 taken 38598 times.
✓ Branch 1 taken 23806 times.
|
62404 | } else if (cu->isp_split_type == ISP_HOR_SPLIT) { |
462 | 38598 | const int trafo_height = tu_height / cu->num_intra_subpartitions; | |
463 |
2/2✓ Branch 0 taken 129958 times.
✓ Branch 1 taken 38598 times.
|
168556 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
464 | 129958 | ret = hls_transform_unit(lc, x0, y0 + trafo_height * i, tu_width, trafo_height, i, 0); | |
465 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 129958 times.
|
129958 | if (ret < 0) |
466 | ✗ | return ret; | |
467 | } | ||
468 |
1/2✓ Branch 0 taken 23806 times.
✗ Branch 1 not taken.
|
23806 | } else if (cu->isp_split_type == ISP_VER_SPLIT) { |
469 | 23806 | const int trafo_width = tu_width / cu->num_intra_subpartitions; | |
470 |
2/2✓ Branch 0 taken 74104 times.
✓ Branch 1 taken 23806 times.
|
97910 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
471 | 74104 | ret = hls_transform_unit(lc, x0 + trafo_width * i , y0, trafo_width, tu_height, i, 0); | |
472 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 74104 times.
|
74104 | if (ret < 0) |
473 | ✗ | return ret; | |
474 | } | ||
475 | } | ||
476 | |||
477 | 958999 | return 0; | |
478 | } | ||
479 | |||
480 | 420262 | static int skipped_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height) | |
481 | { | ||
482 | 420262 | VVCFrameContext *fc = lc->fc; | |
483 | 420262 | const CodingUnit *cu = lc->cu; | |
484 | 420262 | const VVCSPS *sps = fc->ps.sps; | |
485 | |||
486 |
4/4✓ Branch 0 taken 359840 times.
✓ Branch 1 taken 60422 times.
✓ Branch 2 taken 2292 times.
✓ Branch 3 taken 357548 times.
|
482976 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
487 |
4/4✓ Branch 0 taken 60422 times.
✓ Branch 1 taken 2292 times.
✓ Branch 2 taken 41002 times.
✓ Branch 3 taken 19420 times.
|
62714 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
488 |
2/2✓ Branch 0 taken 41002 times.
✓ Branch 1 taken 21712 times.
|
62714 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
489 |
2/2✓ Branch 0 taken 21712 times.
✓ Branch 1 taken 41002 times.
|
62714 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
490 | |||
491 | #define SKIPPED_TRANSFORM_TREE(x, y) do { \ | ||
492 | int ret = skipped_transform_tree(lc, x, y, trafo_width, trafo_height); \ | ||
493 | if (ret < 0) \ | ||
494 | return ret; \ | ||
495 | } while (0) | ||
496 | |||
497 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 62714 times.
|
62714 | SKIPPED_TRANSFORM_TREE(x0, y0); |
498 |
2/2✓ Branch 0 taken 41002 times.
✓ Branch 1 taken 21712 times.
|
62714 | if (ver_split_first) |
499 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 41002 times.
|
41002 | SKIPPED_TRANSFORM_TREE(x0 + trafo_width, y0); |
500 | else | ||
501 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21712 times.
|
21712 | SKIPPED_TRANSFORM_TREE(x0, y0 + trafo_height); |
502 | } else { | ||
503 | 357548 | TransformUnit *tu = add_tu(fc, lc->cu, x0, y0, tu_width, tu_height); | |
504 |
4/4✓ Branch 0 taken 341037 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 315173 times.
✓ Branch 3 taken 25864 times.
|
357548 | const int has_chroma = sps->r->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA; |
505 | 357548 | const int c_start = cu->tree_type == DUAL_TREE_CHROMA ? CB : LUMA; | |
506 |
2/2✓ Branch 0 taken 315173 times.
✓ Branch 1 taken 42375 times.
|
357548 | const int c_end = has_chroma ? VVC_MAX_SAMPLE_ARRAYS : CB; |
507 | |||
508 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 357548 times.
|
357548 | if (!tu) |
509 | ✗ | return AVERROR_INVALIDDATA; | |
510 |
2/2✓ Branch 0 taken 987894 times.
✓ Branch 1 taken 357548 times.
|
1345442 | for (int i = c_start; i < c_end; i++) { |
511 | 987894 | TransformBlock *tb = add_tb(tu, lc, x0, y0, tu_width >> sps->hshift[i], tu_height >> sps->vshift[i], i); | |
512 |
2/2✓ Branch 0 taken 672721 times.
✓ Branch 1 taken 315173 times.
|
987894 | if (i != CR) |
513 | 672721 | set_tb_size(fc, tb); | |
514 | } | ||
515 | } | ||
516 | |||
517 | 420262 | return 0; | |
518 | } | ||
519 | |||
520 | //6.4.1 Allowed quad split process | ||
521 | //6.4.2 Allowed binary split process | ||
522 | //6.4.3 Allowed ternary split process | ||
523 | 2030593 | static void can_split(const VVCLocalContext *lc, int x0, int y0,int cb_width, int cb_height, | |
524 | int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, | ||
525 | VVCTreeType tree_type, VVCModeType mode_type, VVCAllowedSplit* split) | ||
526 | { | ||
527 | int min_qt_size, max_bt_size, max_tt_size, max_mtt_depth; | ||
528 | 2030593 | const VVCFrameContext *fc = lc->fc; | |
529 | 2030593 | const VVCSH *sh = &lc->sc->sh; | |
530 | 2030593 | const VVCSPS *sps = fc->ps.sps; | |
531 | 2030593 | const VVCPPS *pps = fc->ps.pps; | |
532 | 2030593 | const int chroma = tree_type == DUAL_TREE_CHROMA; | |
533 | 2030593 | int min_cb_size_y = sps->min_cb_size_y; | |
534 | 2030593 | int *qt = &split->qt; | |
535 | 2030593 | int *btv = &split->btv; | |
536 | 2030593 | int *bth = &split->bth; | |
537 | 2030593 | int *ttv = &split->ttv; | |
538 | 2030593 | int *tth = &split->tth; | |
539 | |||
540 | 2030593 | *qt = *bth = *btv = *tth = *ttv = 1; | |
541 | |||
542 |
2/2✓ Branch 0 taken 1564280 times.
✓ Branch 1 taken 466313 times.
|
2030593 | if (mtt_depth) |
543 | 1564280 | *qt = 0; | |
544 | |||
545 | 2030593 | min_qt_size = sh->min_qt_size[chroma]; | |
546 |
2/2✓ Branch 0 taken 860326 times.
✓ Branch 1 taken 1170267 times.
|
2030593 | if (cb_width <= min_qt_size) |
547 | 860326 | *qt = 0; | |
548 | |||
549 |
2/2✓ Branch 0 taken 282818 times.
✓ Branch 1 taken 1747775 times.
|
2030593 | if (chroma) { |
550 | 282818 | int chroma_area = (cb_width >> sps->hshift[1]) * (cb_height >> sps->vshift[1]); | |
551 | 282818 | int chroma_width = cb_width >> sps->hshift[1]; | |
552 | |||
553 |
2/2✓ Branch 0 taken 87252 times.
✓ Branch 1 taken 195566 times.
|
282818 | if (chroma_width == 8) |
554 | 87252 | *ttv = 0; | |
555 |
2/2✓ Branch 0 taken 69468 times.
✓ Branch 1 taken 126098 times.
|
195566 | else if (chroma_width <= 4) { |
556 |
1/2✓ Branch 0 taken 69468 times.
✗ Branch 1 not taken.
|
69468 | if (chroma_width == 4) |
557 | 69468 | *btv = 0; | |
558 | 69468 | *qt = 0; | |
559 | } | ||
560 |
2/2✓ Branch 0 taken 24495 times.
✓ Branch 1 taken 258323 times.
|
282818 | if (mode_type == MODE_TYPE_INTRA) |
561 | 24495 | *qt = *btv = *bth = *ttv = *tth = 0; | |
562 |
2/2✓ Branch 0 taken 102923 times.
✓ Branch 1 taken 179895 times.
|
282818 | if (chroma_area <= 32) { |
563 | 102923 | *ttv = *tth = 0; | |
564 |
2/2✓ Branch 0 taken 47148 times.
✓ Branch 1 taken 55775 times.
|
102923 | if (chroma_area <= 16) |
565 | 47148 | *btv = *bth = 0; | |
566 | } | ||
567 | } | ||
568 | 2030593 | max_bt_size = sh->max_bt_size[chroma]; | |
569 | 2030593 | max_tt_size = sh->max_tt_size[chroma]; | |
570 | 2030593 | max_mtt_depth = sh->max_mtt_depth[chroma] + depth_offset; | |
571 | |||
572 |
2/2✓ Branch 0 taken 68840 times.
✓ Branch 1 taken 1961753 times.
|
2030593 | if (mode_type == MODE_TYPE_INTER) { |
573 | 68840 | int area = cb_width * cb_height; | |
574 |
2/2✓ Branch 0 taken 28596 times.
✓ Branch 1 taken 40244 times.
|
68840 | if (area == 32) |
575 | 28596 | *btv = *bth = 0; | |
576 |
2/2✓ Branch 0 taken 23813 times.
✓ Branch 1 taken 16431 times.
|
40244 | else if (area == 64) |
577 | 23813 | *ttv = *tth = 0; | |
578 | } | ||
579 |
2/2✓ Branch 0 taken 842809 times.
✓ Branch 1 taken 1187784 times.
|
2030593 | if (cb_width <= 2 * min_cb_size_y) { |
580 | 842809 | *ttv = 0; | |
581 |
2/2✓ Branch 0 taken 321708 times.
✓ Branch 1 taken 521101 times.
|
842809 | if (cb_width <= min_cb_size_y) |
582 | 321708 | *btv = 0; | |
583 | } | ||
584 |
2/2✓ Branch 0 taken 917630 times.
✓ Branch 1 taken 1112963 times.
|
2030593 | if (cb_height <= 2 * min_cb_size_y) { |
585 | 917630 | *tth = 0; | |
586 |
2/2✓ Branch 0 taken 368563 times.
✓ Branch 1 taken 549067 times.
|
917630 | if (cb_height <= min_cb_size_y) |
587 | 368563 | *bth = 0; | |
588 | } | ||
589 |
4/4✓ Branch 0 taken 1980512 times.
✓ Branch 1 taken 50081 times.
✓ Branch 2 taken 705 times.
✓ Branch 3 taken 1979807 times.
|
2030593 | if (cb_width > max_bt_size || cb_height > max_bt_size) |
590 | 50786 | *btv = *bth = 0; | |
591 | 2030593 | max_tt_size = FFMIN(64, max_tt_size); | |
592 |
4/4✓ Branch 0 taken 1910440 times.
✓ Branch 1 taken 120153 times.
✓ Branch 2 taken 8424 times.
✓ Branch 3 taken 1902016 times.
|
2030593 | if (cb_width > max_tt_size || cb_height > max_tt_size) |
593 | 128577 | *ttv = *tth = 0; | |
594 |
2/2✓ Branch 0 taken 409766 times.
✓ Branch 1 taken 1620827 times.
|
2030593 | if (mtt_depth >= max_mtt_depth) |
595 | 409766 | *btv = *bth = *ttv = *tth = 0; | |
596 |
2/2✓ Branch 0 taken 4664 times.
✓ Branch 1 taken 2025929 times.
|
2030593 | if (x0 + cb_width > pps->width) { |
597 | 4664 | *ttv = *tth = 0; | |
598 |
2/2✓ Branch 0 taken 1423 times.
✓ Branch 1 taken 3241 times.
|
4664 | if (cb_height > 64) |
599 | 1423 | *btv = 0; | |
600 |
2/2✓ Branch 0 taken 3465 times.
✓ Branch 1 taken 1199 times.
|
4664 | if (y0 + cb_height <= pps->height) |
601 | 3465 | *bth = 0; | |
602 |
2/2✓ Branch 0 taken 1145 times.
✓ Branch 1 taken 54 times.
|
1199 | else if (cb_width > min_qt_size) |
603 | 1145 | *btv = *bth = 0; | |
604 | } | ||
605 |
2/2✓ Branch 0 taken 49171 times.
✓ Branch 1 taken 1981422 times.
|
2030593 | if (y0 + cb_height > pps->height) { |
606 | 49171 | *btv = *ttv = *tth = 0; | |
607 |
2/2✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 42927 times.
|
49171 | if (cb_width > 64) |
608 | 6244 | *bth = 0; | |
609 | } | ||
610 |
4/4✓ Branch 0 taken 1564280 times.
✓ Branch 1 taken 466313 times.
✓ Branch 2 taken 680011 times.
✓ Branch 3 taken 884269 times.
|
2030593 | if (mtt_depth > 0 && part_idx == 1) { |
611 |
2/2✓ Branch 0 taken 80720 times.
✓ Branch 1 taken 599291 times.
|
680011 | if (last_split_mode == SPLIT_TT_VER) |
612 | 80720 | *btv = 0; | |
613 |
2/2✓ Branch 0 taken 84287 times.
✓ Branch 1 taken 515004 times.
|
599291 | else if (last_split_mode == SPLIT_TT_HOR) |
614 | 84287 | *bth = 0; | |
615 | } | ||
616 |
4/4✓ Branch 0 taken 1987508 times.
✓ Branch 1 taken 43085 times.
✓ Branch 2 taken 3288 times.
✓ Branch 3 taken 1984220 times.
|
2030593 | if (cb_width <= 64 && cb_height > 64) |
617 | 3288 | *btv = 0; | |
618 |
4/4✓ Branch 0 taken 43085 times.
✓ Branch 1 taken 1987508 times.
✓ Branch 2 taken 3312 times.
✓ Branch 3 taken 39773 times.
|
2030593 | if (cb_width > 64 && cb_height <= 64) |
619 | 3312 | *bth = 0; | |
620 | 2030593 | } | |
621 | |||
622 | 488004 | static int get_num_intra_subpartitions(enum IspType isp_split_type, int cb_width, int cb_height) | |
623 | { | ||
624 |
2/2✓ Branch 0 taken 425600 times.
✓ Branch 1 taken 62404 times.
|
488004 | if (isp_split_type == ISP_NO_SPLIT) |
625 | 425600 | return 1; | |
626 |
8/8✓ Branch 0 taken 14949 times.
✓ Branch 1 taken 47455 times.
✓ Branch 2 taken 4225 times.
✓ Branch 3 taken 10724 times.
✓ Branch 4 taken 22224 times.
✓ Branch 5 taken 29456 times.
✓ Branch 6 taken 12053 times.
✓ Branch 7 taken 10171 times.
|
62404 | if ((cb_width == 4 && cb_height == 8) || (cb_width == 8 && cb_height == 4)) |
627 | 22777 | return 2; | |
628 | 39627 | return 4; | |
629 | } | ||
630 | |||
631 | 226984 | static int get_cclm_enabled(const VVCLocalContext *lc, const int x0, const int y0) | |
632 | { | ||
633 | 226984 | const VVCFrameContext *fc = lc->fc; | |
634 | 226984 | const VVCSPS *sps = fc->ps.sps; | |
635 | 226984 | int enabled = 0; | |
636 | |||
637 |
2/2✓ Branch 0 taken 449 times.
✓ Branch 1 taken 226535 times.
|
226984 | if (!sps->r->sps_cclm_enabled_flag) |
638 | 449 | return 0; | |
639 |
6/6✓ Branch 0 taken 219898 times.
✓ Branch 1 taken 6637 times.
✓ Branch 2 taken 156263 times.
✓ Branch 3 taken 63635 times.
✓ Branch 4 taken 1163 times.
✓ Branch 5 taken 155100 times.
|
226535 | if (!sps->r->sps_qtbtt_dual_tree_intra_flag || !IS_I(lc->sc->sh.r) || sps->ctb_log2_size_y < 6) |
640 | 71435 | return 1; | |
641 | else { | ||
642 | 155100 | const int x64 = x0 >> 6 << 6; | |
643 | 155100 | const int y64 = y0 >> 6 << 6; | |
644 | 155100 | const int y32 = y0 >> 5 << 5; | |
645 | 155100 | const int x64_cu = x64 >> fc->ps.sps->min_cb_log2_size_y; | |
646 | 155100 | const int y64_cu = y64 >> fc->ps.sps->min_cb_log2_size_y; | |
647 | 155100 | const int y32_cu = y32 >> fc->ps.sps->min_cb_log2_size_y; | |
648 | 155100 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
649 | 155100 | const int depth = SAMPLE_CTB(fc->tab.cqt_depth[1], x64_cu, y64_cu); | |
650 | 155100 | const int min_depth = fc->ps.sps->ctb_log2_size_y - 6; | |
651 | 155100 | const VVCSplitMode msm64 = (VVCSplitMode)TAB_MSM(fc, 0, x64, y64); | |
652 | 155100 | const VVCSplitMode msm32 = (VVCSplitMode)TAB_MSM(fc, 1, x64, y32); | |
653 | |||
654 |
2/2✓ Branch 0 taken 19353 times.
✓ Branch 1 taken 135747 times.
|
174453 | enabled = SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y64_cu) == 64 && |
655 |
2/2✓ Branch 0 taken 6523 times.
✓ Branch 1 taken 12830 times.
|
19353 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y64_cu) == 64; |
656 |
2/2✓ Branch 0 taken 21626 times.
✓ Branch 1 taken 16195 times.
|
37821 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && |
657 |
4/4✓ Branch 0 taken 37821 times.
✓ Branch 1 taken 117279 times.
✓ Branch 2 taken 12074 times.
✓ Branch 3 taken 9552 times.
|
204995 | SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y32_cu) == 64 && |
658 |
2/2✓ Branch 0 taken 4732 times.
✓ Branch 1 taken 7342 times.
|
12074 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y32_cu) == 32; |
659 | 155100 | enabled |= depth > min_depth; | |
660 |
6/6✓ Branch 0 taken 37821 times.
✓ Branch 1 taken 117279 times.
✓ Branch 2 taken 21626 times.
✓ Branch 3 taken 16195 times.
✓ Branch 4 taken 7960 times.
✓ Branch 5 taken 13666 times.
|
155100 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && msm32 == SPLIT_BT_VER; |
661 | |||
662 |
2/2✓ Branch 0 taken 136037 times.
✓ Branch 1 taken 19063 times.
|
155100 | if (enabled) { |
663 | 136037 | const int w = SAMPLE_CTB(fc->tab.cb_width[0], x64_cu, y64_cu); | |
664 | 136037 | const int h = SAMPLE_CTB(fc->tab.cb_height[0], x64_cu, y64_cu); | |
665 | 136037 | const int depth0 = SAMPLE_CTB(fc->tab.cqt_depth[0], x64_cu, y64_cu); | |
666 |
8/8✓ Branch 0 taken 5746 times.
✓ Branch 1 taken 130291 times.
✓ Branch 2 taken 5556 times.
✓ Branch 3 taken 190 times.
✓ Branch 4 taken 4964 times.
✓ Branch 5 taken 592 times.
✓ Branch 6 taken 5154 times.
✓ Branch 7 taken 130291 times.
|
136037 | if ((w == 64 && h == 64 && TAB_ISPMF(fc, x64, y64)) || |
667 |
4/4✓ Branch 0 taken 190 times.
✓ Branch 1 taken 4964 times.
✓ Branch 2 taken 1286 times.
✓ Branch 3 taken 129195 times.
|
135445 | ((w < 64 || h < 64) && depth0 == min_depth)) |
668 | 1878 | return 0; | |
669 | } | ||
670 | |||
671 | } | ||
672 | |||
673 | 153222 | return enabled; | |
674 | } | ||
675 | |||
676 | 869230 | static int less(const void *a, const void *b) | |
677 | { | ||
678 | 869230 | return *(const int*)a - *(const int*)b; | |
679 | } | ||
680 | |||
681 | //8.4.2 Derivation process for luma intra prediction mode | ||
682 | 488004 | static enum IntraPredMode luma_intra_pred_mode(VVCLocalContext* lc, const int intra_subpartitions_mode_flag) | |
683 | { | ||
684 | 488004 | VVCFrameContext *fc = lc->fc; | |
685 | 488004 | CodingUnit *cu = lc->cu; | |
686 | 488004 | const int x0 = cu->x0; | |
687 | 488004 | const int y0 = cu->y0; | |
688 | enum IntraPredMode pred; | ||
689 | 488004 | int intra_luma_not_planar_flag = 1; | |
690 | 488004 | int intra_luma_mpm_remainder = 0; | |
691 | 488004 | int intra_luma_mpm_flag = 1; | |
692 | 488004 | int intra_luma_mpm_idx = 0; | |
693 | |||
694 |
2/2✓ Branch 0 taken 444607 times.
✓ Branch 1 taken 43397 times.
|
488004 | if (!cu->intra_luma_ref_idx) |
695 | 444607 | intra_luma_mpm_flag = ff_vvc_intra_luma_mpm_flag(lc); | |
696 |
2/2✓ Branch 0 taken 364109 times.
✓ Branch 1 taken 123895 times.
|
488004 | if (intra_luma_mpm_flag) { |
697 |
2/2✓ Branch 0 taken 320712 times.
✓ Branch 1 taken 43397 times.
|
364109 | if (!cu->intra_luma_ref_idx) |
698 | 320712 | intra_luma_not_planar_flag = ff_vvc_intra_luma_not_planar_flag(lc, intra_subpartitions_mode_flag); | |
699 |
2/2✓ Branch 0 taken 192364 times.
✓ Branch 1 taken 171745 times.
|
364109 | if (intra_luma_not_planar_flag) |
700 | 192364 | intra_luma_mpm_idx = ff_vvc_intra_luma_mpm_idx(lc); | |
701 | } else { | ||
702 | 123895 | intra_luma_mpm_remainder = ff_vvc_intra_luma_mpm_remainder(lc); | |
703 | } | ||
704 | |||
705 |
2/2✓ Branch 0 taken 171745 times.
✓ Branch 1 taken 316259 times.
|
488004 | if (!intra_luma_not_planar_flag) { |
706 | 171745 | pred = INTRA_PLANAR; | |
707 | } else { | ||
708 | 316259 | const VVCSPS *sps = fc->ps.sps; | |
709 | 316259 | const int x_a = (x0 - 1) >> sps->min_cb_log2_size_y; | |
710 | 316259 | const int y_a = (y0 + cu->cb_height - 1) >> sps->min_cb_log2_size_y; | |
711 | 316259 | const int x_b = (x0 + cu->cb_width - 1) >> sps->min_cb_log2_size_y; | |
712 | 316259 | const int y_b = (y0 - 1) >> sps->min_cb_log2_size_y; | |
713 | 316259 | int min_cb_width = fc->ps.pps->min_cb_width; | |
714 | 316259 | int x0b = av_zero_extend(x0, sps->ctb_log2_size_y); | |
715 | 316259 | int y0b = av_zero_extend(y0, sps->ctb_log2_size_y); | |
716 |
4/4✓ Branch 0 taken 71493 times.
✓ Branch 1 taken 244766 times.
✓ Branch 2 taken 65678 times.
✓ Branch 3 taken 5815 times.
|
316259 | const int available_l = lc->ctb_left_flag || x0b; |
717 |
4/4✓ Branch 0 taken 112074 times.
✓ Branch 1 taken 204185 times.
✓ Branch 2 taken 105877 times.
✓ Branch 3 taken 6197 times.
|
316259 | const int available_u = lc->ctb_up_flag || y0b; |
718 | |||
719 | int a, b, cand[5]; | ||
720 | |||
721 |
4/4✓ Branch 0 taken 310444 times.
✓ Branch 1 taken 5815 times.
✓ Branch 2 taken 280103 times.
✓ Branch 3 taken 30341 times.
|
316259 | if (!available_l || (SAMPLE_CTB(fc->tab.cpm[0], x_a, y_a) != MODE_INTRA) || |
722 |
2/2✓ Branch 0 taken 38852 times.
✓ Branch 1 taken 241251 times.
|
280103 | SAMPLE_CTB(fc->tab.imf, x_a, y_a)) { |
723 | 75008 | a = INTRA_PLANAR; | |
724 | } else { | ||
725 | 241251 | a = SAMPLE_CTB(fc->tab.ipm, x_a, y_a); | |
726 | } | ||
727 | |||
728 |
4/4✓ Branch 0 taken 310062 times.
✓ Branch 1 taken 6197 times.
✓ Branch 2 taken 277921 times.
✓ Branch 3 taken 32141 times.
|
316259 | if (!available_u || (SAMPLE_CTB(fc->tab.cpm[0], x_b, y_b) != MODE_INTRA) || |
729 |
4/4✓ Branch 0 taken 238892 times.
✓ Branch 1 taken 39029 times.
✓ Branch 2 taken 14035 times.
✓ Branch 3 taken 224857 times.
|
277921 | SAMPLE_CTB(fc->tab.imf, x_b, y_b) || !y0b) { |
730 | 91402 | b = INTRA_PLANAR; | |
731 | } else { | ||
732 | 224857 | b = SAMPLE_CTB(fc->tab.ipm, x_b, y_b); | |
733 | } | ||
734 | |||
735 |
4/4✓ Branch 0 taken 98211 times.
✓ Branch 1 taken 218048 times.
✓ Branch 2 taken 18531 times.
✓ Branch 3 taken 79680 times.
|
316259 | if (a == b && a > INTRA_DC) { |
736 | 18531 | cand[0] = a; | |
737 | 18531 | cand[1] = 2 + ((a + 61) % 64); | |
738 | 18531 | cand[2] = 2 + ((a - 1) % 64); | |
739 | 18531 | cand[3] = 2 + ((a + 60) % 64); | |
740 | 18531 | cand[4] = 2 + (a % 64); | |
741 | } else { | ||
742 | 297728 | const int minab = FFMIN(a, b); | |
743 | 297728 | const int maxab = FFMAX(a, b); | |
744 |
4/4✓ Branch 0 taken 143495 times.
✓ Branch 1 taken 154233 times.
✓ Branch 2 taken 71052 times.
✓ Branch 3 taken 72443 times.
|
368780 | if (a > INTRA_DC && b > INTRA_DC) { |
745 | 71052 | const int diff = maxab - minab; | |
746 | 71052 | cand[0] = a; | |
747 | 71052 | cand[1] = b; | |
748 |
2/2✓ Branch 0 taken 14136 times.
✓ Branch 1 taken 56916 times.
|
71052 | if (diff == 1) { |
749 | 14136 | cand[2] = 2 + ((minab + 61) % 64); | |
750 | 14136 | cand[3] = 2 + ((maxab - 1) % 64); | |
751 | 14136 | cand[4] = 2 + ((minab + 60) % 64); | |
752 |
2/2✓ Branch 0 taken 574 times.
✓ Branch 1 taken 56342 times.
|
56916 | } else if (diff >= 62) { |
753 | 574 | cand[2] = 2 + ((minab - 1) % 64); | |
754 | 574 | cand[3] = 2 + ((maxab + 61) % 64); | |
755 | 574 | cand[4] = 2 + (minab % 64); | |
756 |
2/2✓ Branch 0 taken 6771 times.
✓ Branch 1 taken 49571 times.
|
56342 | } else if (diff == 2) { |
757 | 6771 | cand[2] = 2 + ((minab - 1) % 64); | |
758 | 6771 | cand[3] = 2 + ((minab + 61) % 64); | |
759 | 6771 | cand[4] = 2 + ((maxab - 1) % 64); | |
760 | } else { | ||
761 | 49571 | cand[2] = 2 + ((minab + 61) % 64); | |
762 | 49571 | cand[3] = 2 + ((minab - 1) % 64); | |
763 | 49571 | cand[4] = 2 + ((maxab + 61) % 64); | |
764 | } | ||
765 |
4/4✓ Branch 0 taken 154233 times.
✓ Branch 1 taken 72443 times.
✓ Branch 2 taken 59944 times.
✓ Branch 3 taken 94289 times.
|
226676 | } else if (a > INTRA_DC || b > INTRA_DC) { |
766 | 132387 | cand[0] = maxab; | |
767 | 132387 | cand[1] = 2 + ((maxab + 61 ) % 64); | |
768 | 132387 | cand[2] = 2 + ((maxab - 1) % 64); | |
769 | 132387 | cand[3] = 2 + ((maxab + 60 ) % 64); | |
770 | 132387 | cand[4] = 2 + (maxab % 64); | |
771 | } else { | ||
772 | 94289 | cand[0] = INTRA_DC; | |
773 | 94289 | cand[1] = INTRA_VERT; | |
774 | 94289 | cand[2] = INTRA_HORZ; | |
775 | 94289 | cand[3] = INTRA_VERT - 4; | |
776 | 94289 | cand[4] = INTRA_VERT + 4; | |
777 | } | ||
778 | } | ||
779 |
2/2✓ Branch 0 taken 192364 times.
✓ Branch 1 taken 123895 times.
|
316259 | if (intra_luma_mpm_flag) { |
780 | 192364 | pred = cand[intra_luma_mpm_idx]; | |
781 | } else { | ||
782 | 123895 | qsort(cand, FF_ARRAY_ELEMS(cand), sizeof(cand[0]), less); | |
783 | 123895 | pred = intra_luma_mpm_remainder + 1; | |
784 |
2/2✓ Branch 0 taken 619475 times.
✓ Branch 1 taken 123895 times.
|
743370 | for (int i = 0; i < FF_ARRAY_ELEMS(cand); i++) { |
785 |
2/2✓ Branch 0 taken 303864 times.
✓ Branch 1 taken 315611 times.
|
619475 | if (pred >= cand[i]) |
786 | 303864 | pred++; | |
787 | } | ||
788 | } | ||
789 | } | ||
790 | 488004 | return pred; | |
791 | } | ||
792 | |||
793 | 937235 | static int lfnst_idx_decode(VVCLocalContext *lc) | |
794 | { | ||
795 | 937235 | CodingUnit *cu = lc->cu; | |
796 | 937235 | const VVCTreeType tree_type = cu->tree_type; | |
797 | 937235 | const VVCSPS *sps = lc->fc->ps.sps; | |
798 | 937235 | const int cb_width = cu->cb_width; | |
799 | 937235 | const int cb_height = cu->cb_height; | |
800 | 937235 | const TransformUnit *tu = cu->tus.head; | |
801 | int lfnst_width, lfnst_height, min_lfnst; | ||
802 | 937235 | int lfnst_idx = 0; | |
803 | |||
804 | 937235 | memset(cu->apply_lfnst_flag, 0, sizeof(cu->apply_lfnst_flag)); | |
805 | |||
806 |
6/6✓ Branch 0 taken 713668 times.
✓ Branch 1 taken 223567 times.
✓ Branch 2 taken 597657 times.
✓ Branch 3 taken 116011 times.
✓ Branch 4 taken 1674 times.
✓ Branch 5 taken 595983 times.
|
937235 | if (!sps->r->sps_lfnst_enabled_flag || cu->pred_mode != MODE_INTRA || FFMAX(cb_width, cb_height) > sps->max_tb_size_y) |
807 | 341252 | return 0; | |
808 | |||
809 |
2/2✓ Branch 0 taken 703760 times.
✓ Branch 1 taken 582125 times.
|
1285885 | while (tu) { |
810 |
2/2✓ Branch 0 taken 913252 times.
✓ Branch 1 taken 689902 times.
|
1603154 | for (int j = 0; j < tu->nb_tbs; j++) { |
811 | 913252 | const TransformBlock *tb = tu->tbs + j; | |
812 |
4/4✓ Branch 0 taken 595037 times.
✓ Branch 1 taken 318215 times.
✓ Branch 2 taken 13858 times.
✓ Branch 3 taken 581179 times.
|
913252 | if (tu->coded_flag[tb->c_idx] && tb->ts) |
813 | 13858 | return 0; | |
814 | } | ||
815 | 689902 | tu = tu->next; | |
816 | } | ||
817 | |||
818 |
2/2✓ Branch 0 taken 141277 times.
✓ Branch 1 taken 440848 times.
|
582125 | if (tree_type == DUAL_TREE_CHROMA) { |
819 | 141277 | lfnst_width = cb_width >> sps->hshift[1]; | |
820 | 141277 | lfnst_height = cb_height >> sps->vshift[1]; | |
821 | } else { | ||
822 | 440848 | const int vs = cu->isp_split_type == ISP_VER_SPLIT; | |
823 | 440848 | const int hs = cu->isp_split_type == ISP_HOR_SPLIT; | |
824 |
2/2✓ Branch 0 taken 17341 times.
✓ Branch 1 taken 423507 times.
|
440848 | lfnst_width = vs ? cb_width / cu->num_intra_subpartitions : cb_width; |
825 |
2/2✓ Branch 0 taken 30322 times.
✓ Branch 1 taken 410526 times.
|
440848 | lfnst_height = hs ? cb_height / cu->num_intra_subpartitions : cb_height; |
826 | } | ||
827 | 582125 | min_lfnst = FFMIN(lfnst_width, lfnst_height); | |
828 |
6/6✓ Branch 0 taken 440848 times.
✓ Branch 1 taken 141277 times.
✓ Branch 2 taken 104213 times.
✓ Branch 3 taken 336635 times.
✓ Branch 4 taken 84232 times.
✓ Branch 5 taken 19981 times.
|
582125 | if (tree_type != DUAL_TREE_CHROMA && cu->intra_mip_flag && min_lfnst < 16) |
829 | 84232 | return 0; | |
830 | |||
831 |
2/2✓ Branch 0 taken 460520 times.
✓ Branch 1 taken 37373 times.
|
497893 | if (min_lfnst >= 4) { |
832 |
6/6✓ Branch 0 taken 432979 times.
✓ Branch 1 taken 27541 times.
✓ Branch 2 taken 187598 times.
✓ Branch 3 taken 245381 times.
✓ Branch 4 taken 182831 times.
✓ Branch 5 taken 32308 times.
|
460520 | if ((cu->isp_split_type != ISP_NO_SPLIT || !lc->parse.lfnst_dc_only) && lc->parse.lfnst_zero_out_sig_coeff_flag) |
833 | 182831 | lfnst_idx = ff_vvc_lfnst_idx(lc, tree_type != SINGLE_TREE); | |
834 | } | ||
835 | |||
836 |
2/2✓ Branch 0 taken 138076 times.
✓ Branch 1 taken 359817 times.
|
497893 | if (lfnst_idx) { |
837 | 138076 | cu->apply_lfnst_flag[LUMA] = tree_type != DUAL_TREE_CHROMA; | |
838 | 138076 | cu->apply_lfnst_flag[CB] = cu->apply_lfnst_flag[CR] = tree_type == DUAL_TREE_CHROMA; | |
839 | } | ||
840 | |||
841 | 497893 | return lfnst_idx; | |
842 | } | ||
843 | |||
844 | 937235 | static MtsIdx mts_idx_decode(VVCLocalContext *lc) | |
845 | { | ||
846 | 937235 | const CodingUnit *cu = lc->cu; | |
847 | 937235 | const VVCSPS *sps = lc->fc->ps.sps; | |
848 | 937235 | const int cb_width = cu->cb_width; | |
849 | 937235 | const int cb_height = cu->cb_height; | |
850 | 937235 | const uint8_t transform_skip_flag = cu->tus.head->tbs[0].ts; //fix me | |
851 | 937235 | int mts_idx = MTS_DCT2_DCT2; | |
852 |
6/6✓ Branch 0 taken 756474 times.
✓ Branch 1 taken 180761 times.
✓ Branch 2 taken 652099 times.
✓ Branch 3 taken 104375 times.
✓ Branch 4 taken 626840 times.
✓ Branch 5 taken 25259 times.
|
937235 | if (cu->tree_type != DUAL_TREE_CHROMA && !cu->lfnst_idx && |
853 |
2/2✓ Branch 0 taken 605257 times.
✓ Branch 1 taken 21583 times.
|
626840 | !transform_skip_flag && FFMAX(cb_width, cb_height) <= 32 && |
854 |
4/4✓ Branch 0 taken 559764 times.
✓ Branch 1 taken 45493 times.
✓ Branch 2 taken 516706 times.
✓ Branch 3 taken 43058 times.
|
605257 | cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag && |
855 |
4/4✓ Branch 0 taken 507853 times.
✓ Branch 1 taken 8853 times.
✓ Branch 2 taken 324107 times.
✓ Branch 3 taken 183746 times.
|
516706 | lc->parse.mts_zero_out_sig_coeff_flag && !lc->parse.mts_dc_only) { |
856 |
4/4✓ Branch 0 taken 57155 times.
✓ Branch 1 taken 266952 times.
✓ Branch 2 taken 54689 times.
✓ Branch 3 taken 2466 times.
|
324107 | if ((cu->pred_mode == MODE_INTER && sps->r->sps_explicit_mts_inter_enabled_flag) || |
857 |
4/4✓ Branch 0 taken 263458 times.
✓ Branch 1 taken 58183 times.
✓ Branch 2 taken 244467 times.
✓ Branch 3 taken 18991 times.
|
321641 | (cu->pred_mode == MODE_INTRA && sps->r->sps_explicit_mts_intra_enabled_flag)) { |
858 | 246933 | mts_idx = ff_vvc_mts_idx(lc); | |
859 | } | ||
860 | } | ||
861 | |||
862 | 937235 | return mts_idx; | |
863 | } | ||
864 | |||
865 | 226840 | static enum IntraPredMode derive_center_luma_intra_pred_mode(const VVCFrameContext *fc, const VVCSPS *sps, const VVCPPS *pps, const CodingUnit *cu) | |
866 | { | ||
867 | 226840 | const int x_center = (cu->x0 + cu->cb_width / 2) >> sps->min_cb_log2_size_y; | |
868 | 226840 | const int y_center = (cu->y0 + cu->cb_height / 2) >> sps->min_cb_log2_size_y; | |
869 | 226840 | const int min_cb_width = pps->min_cb_width; | |
870 | 226840 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_center, y_center); | |
871 | 226840 | const int cu_pred_mode = SAMPLE_CTB(fc->tab.cpm[0], x_center, y_center); | |
872 | 226840 | const int intra_pred_mode_y = SAMPLE_CTB(fc->tab.ipm, x_center, y_center); | |
873 | |||
874 |
2/2✓ Branch 0 taken 46540 times.
✓ Branch 1 taken 180300 times.
|
226840 | if (intra_mip_flag) { |
875 |
4/4✓ Branch 0 taken 9274 times.
✓ Branch 1 taken 37266 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 9030 times.
|
46540 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
876 | 244 | return INTRA_INVALID; | |
877 | 46296 | return INTRA_PLANAR; | |
878 | } | ||
879 |
3/4✓ Branch 0 taken 172902 times.
✓ Branch 1 taken 7398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172902 times.
|
180300 | if (cu_pred_mode == MODE_IBC || cu_pred_mode == MODE_PLT) |
880 | 7398 | return INTRA_DC; | |
881 | 172902 | return intra_pred_mode_y; | |
882 | } | ||
883 | |||
884 | 226984 | static void derive_chroma_intra_pred_mode(VVCLocalContext *lc, | |
885 | const int cclm_mode_flag, const int cclm_mode_idx, const int intra_chroma_pred_mode) | ||
886 | { | ||
887 | 226984 | const VVCFrameContext *fc = lc->fc; | |
888 | 226984 | CodingUnit *cu = lc->cu; | |
889 | 226984 | const VVCSPS *sps = fc->ps.sps; | |
890 | 226984 | const VVCPPS *pps = fc->ps.pps; | |
891 | 226984 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
892 | 226984 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
893 | 226984 | const int min_cb_width = pps->min_cb_width; | |
894 | 226984 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
895 | 226984 | enum IntraPredMode luma_intra_pred_mode = SAMPLE_CTB(fc->tab.ipm, x_cb, y_cb); | |
896 | |||
897 |
6/6✓ Branch 0 taken 46226 times.
✓ Branch 1 taken 180758 times.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 44101 times.
✓ Branch 4 taken 679 times.
✓ Branch 5 taken 1446 times.
|
226984 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && |
898 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 535 times.
|
679 | intra_chroma_pred_mode == 4 && intra_mip_flag) { |
899 | 144 | cu->mip_chroma_direct_flag = 1; | |
900 | 144 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
901 | 144 | return; | |
902 | } | ||
903 | 226840 | luma_intra_pred_mode = derive_center_luma_intra_pred_mode(fc, sps, pps, cu); | |
904 | |||
905 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 226840 times.
|
226840 | if (cu->act_enabled_flag) { |
906 | ✗ | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
907 | ✗ | return; | |
908 | } | ||
909 |
2/2✓ Branch 0 taken 91243 times.
✓ Branch 1 taken 135597 times.
|
226840 | if (cclm_mode_flag) { |
910 | 91243 | cu->intra_pred_mode_c = INTRA_LT_CCLM + cclm_mode_idx; | |
911 |
2/2✓ Branch 0 taken 92595 times.
✓ Branch 1 taken 43002 times.
|
135597 | } else if (intra_chroma_pred_mode == 4){ |
912 | 92595 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
913 | } else { | ||
914 | const static IntraPredMode pred_mode_c[][4 + 1] = { | ||
915 | {INTRA_VDIAG, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR}, | ||
916 | {INTRA_VERT, INTRA_VDIAG, INTRA_VERT, INTRA_VERT, INTRA_VERT}, | ||
917 | {INTRA_HORZ, INTRA_HORZ, INTRA_VDIAG, INTRA_HORZ, INTRA_HORZ}, | ||
918 | {INTRA_DC, INTRA_DC, INTRA_DC, INTRA_VDIAG, INTRA_DC}, | ||
919 | }; | ||
920 | 43002 | const int modes[4] = {INTRA_PLANAR, INTRA_VERT, INTRA_HORZ, INTRA_DC}; | |
921 | int idx; | ||
922 | |||
923 | // This workaround is necessary to have 4:4:4 video decode correctly | ||
924 | // See VVC ticket https://jvet.hhi.fraunhofer.de/trac/vvc/ticket/1602 | ||
925 | // and VTM source https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM/-/blob/master/source/Lib/CommonLib/UnitTools.cpp#L736 | ||
926 |
6/6✓ Branch 0 taken 3283 times.
✓ Branch 1 taken 39719 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 3040 times.
✓ Branch 4 taken 43 times.
✓ Branch 5 taken 200 times.
|
43002 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && intra_mip_flag) { |
927 | 43 | idx = 4; | |
928 | } else { | ||
929 |
2/2✓ Branch 0 taken 108088 times.
✓ Branch 1 taken 15145 times.
|
123233 | for (idx = 0; idx < FF_ARRAY_ELEMS(modes); idx++) { |
930 |
2/2✓ Branch 0 taken 27814 times.
✓ Branch 1 taken 80274 times.
|
108088 | if (modes[idx] == luma_intra_pred_mode) |
931 | 27814 | break; | |
932 | } | ||
933 | } | ||
934 | |||
935 | 43002 | cu->intra_pred_mode_c = pred_mode_c[intra_chroma_pred_mode][idx]; | |
936 | } | ||
937 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 226840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
226840 | if (sps->r->sps_chroma_format_idc == CHROMA_FORMAT_422 && cu->intra_pred_mode_c <= INTRA_VDIAG) { |
938 | const static int mode_map_422[INTRA_VDIAG + 1] = { | ||
939 | 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 5, 6, 8, 10, 12, 13, | ||
940 | 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 31, 33, 34, 35, 36, 37, | ||
941 | 38, 39, 40, 41, 41, 42, 43, 43, 44, 44, 45, 45, 46, 47, 48, 48, | ||
942 | 49, 49, 50, 51, 51, 52, 52, 53, 54, 55, 55, 56, 56, 57, 57, 58, | ||
943 | 59, 59, 60, | ||
944 | }; | ||
945 | ✗ | cu->intra_pred_mode_c = mode_map_422[cu->intra_pred_mode_c]; | |
946 | } | ||
947 | } | ||
948 | |||
949 | 288800 | static av_always_inline uint8_t pack_mip_info(int intra_mip_flag, | |
950 | int intra_mip_transposed_flag, int intra_mip_mode) | ||
951 | { | ||
952 | 288800 | return (intra_mip_mode << 2) | (intra_mip_transposed_flag << 1) | intra_mip_flag; | |
953 | } | ||
954 | |||
955 | 596060 | static void intra_luma_pred_modes(VVCLocalContext *lc) | |
956 | { | ||
957 | 596060 | VVCFrameContext *fc = lc->fc; | |
958 | 596060 | const VVCSPS *sps = fc->ps.sps; | |
959 | 596060 | const VVCPPS *pps = fc->ps.pps; | |
960 | 596060 | CodingUnit *cu = lc->cu; | |
961 | 596060 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
962 | 596060 | const int x0 = cu->x0; | |
963 | 596060 | const int y0 = cu->y0; | |
964 | 596060 | const int x_cb = x0 >> log2_min_cb_size; | |
965 | 596060 | const int y_cb = y0 >> log2_min_cb_size; | |
966 | 596060 | const int cb_width = cu->cb_width; | |
967 | 596060 | const int cb_height = cu->cb_height; | |
968 | |||
969 | 596060 | cu->intra_luma_ref_idx = 0; | |
970 |
6/6✓ Branch 0 taken 28688 times.
✓ Branch 1 taken 567372 times.
✓ Branch 2 taken 27889 times.
✓ Branch 3 taken 799 times.
✓ Branch 4 taken 27878 times.
✓ Branch 5 taken 11 times.
|
596060 | if (sps->r->sps_bdpcm_enabled_flag && cb_width <= sps->max_ts_size && cb_height <= sps->max_ts_size) |
971 | 27878 | cu->bdpcm_flag[LUMA] = ff_vvc_intra_bdpcm_luma_flag(lc); | |
972 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 596022 times.
|
596060 | if (cu->bdpcm_flag[LUMA]) { |
973 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 2 taken 18 times.
|
38 | cu->intra_pred_mode_y = ff_vvc_intra_bdpcm_luma_dir_flag(lc) ? INTRA_VERT : INTRA_HORZ; |
974 | } else { | ||
975 |
2/2✓ Branch 0 taken 453580 times.
✓ Branch 1 taken 142442 times.
|
596022 | if (sps->r->sps_mip_enabled_flag) |
976 | 453580 | cu->intra_mip_flag = ff_vvc_intra_mip_flag(lc, fc->tab.imf); | |
977 |
2/2✓ Branch 0 taken 108018 times.
✓ Branch 1 taken 488004 times.
|
596022 | if (cu->intra_mip_flag) { |
978 | 108018 | int intra_mip_transposed_flag = ff_vvc_intra_mip_transposed_flag(lc); | |
979 | 108018 | int intra_mip_mode = ff_vvc_intra_mip_mode(lc); | |
980 | 108018 | int x = y_cb * pps->min_cb_width + x_cb; | |
981 |
2/2✓ Branch 0 taken 288800 times.
✓ Branch 1 taken 108018 times.
|
396818 | for (int y = 0; y < (cb_height>>log2_min_cb_size); y++) { |
982 | 288800 | int width = cb_width>>log2_min_cb_size; | |
983 | 288800 | const uint8_t mip_info = pack_mip_info(cu->intra_mip_flag, | |
984 | intra_mip_transposed_flag, intra_mip_mode); | ||
985 | 288800 | memset(&fc->tab.imf[x], mip_info, width); | |
986 | 288800 | x += pps->min_cb_width; | |
987 | } | ||
988 | 108018 | cu->intra_pred_mode_y = intra_mip_mode; | |
989 | } else { | ||
990 | 488004 | int intra_subpartitions_mode_flag = 0; | |
991 |
4/4✓ Branch 0 taken 469080 times.
✓ Branch 1 taken 18924 times.
✓ Branch 2 taken 429638 times.
✓ Branch 3 taken 39442 times.
|
488004 | if (sps->r->sps_mrl_enabled_flag && ((y0 % sps->ctb_size_y) > 0)) |
992 | 429638 | cu->intra_luma_ref_idx = ff_vvc_intra_luma_ref_idx(lc); | |
993 |
4/4✓ Branch 0 taken 469080 times.
✓ Branch 1 taken 18924 times.
✓ Branch 2 taken 425683 times.
✓ Branch 3 taken 43397 times.
|
488004 | if (sps->r->sps_isp_enabled_flag && !cu->intra_luma_ref_idx && |
994 |
4/4✓ Branch 0 taken 425468 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 425202 times.
✓ Branch 3 taken 266 times.
|
425683 | (cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) && |
995 |
2/2✓ Branch 0 taken 361942 times.
✓ Branch 1 taken 63260 times.
|
425202 | (cb_width * cb_height > MIN_TU_SIZE * MIN_TU_SIZE) && |
996 |
1/2✓ Branch 0 taken 361942 times.
✗ Branch 1 not taken.
|
361942 | !cu->act_enabled_flag) |
997 | 361942 | intra_subpartitions_mode_flag = ff_vvc_intra_subpartitions_mode_flag(lc); | |
998 |
4/4✓ Branch 0 taken 94981 times.
✓ Branch 1 taken 393023 times.
✓ Branch 2 taken 20699 times.
✓ Branch 3 taken 74282 times.
|
488004 | if (!(x0 & 63) && !(y0 & 63)) |
999 | 20699 | TAB_ISPMF(fc, x0, y0) = intra_subpartitions_mode_flag; | |
1000 | 488004 | cu->isp_split_type = ff_vvc_isp_split_type(lc, intra_subpartitions_mode_flag); | |
1001 | 488004 | cu->num_intra_subpartitions = get_num_intra_subpartitions(cu->isp_split_type, cb_width, cb_height); | |
1002 | 488004 | cu->intra_pred_mode_y = luma_intra_pred_mode(lc, intra_subpartitions_mode_flag); | |
1003 | } | ||
1004 | } | ||
1005 | 596060 | set_cb_tab(lc, fc->tab.ipm, cu->intra_pred_mode_y); | |
1006 | 596060 | } | |
1007 | |||
1008 | 226987 | static void intra_chroma_pred_modes(VVCLocalContext *lc) | |
1009 | { | ||
1010 | 226987 | const VVCSPS *sps = lc->fc->ps.sps; | |
1011 | 226987 | CodingUnit *cu = lc->cu; | |
1012 | 226987 | const int hs = sps->hshift[CHROMA]; | |
1013 | 226987 | const int vs = sps->vshift[CHROMA]; | |
1014 | |||
1015 | 226987 | cu->mip_chroma_direct_flag = 0; | |
1016 |
2/2✓ Branch 0 taken 25937 times.
✓ Branch 1 taken 201050 times.
|
226987 | if (sps->r->sps_bdpcm_enabled_flag && |
1017 |
2/2✓ Branch 0 taken 24636 times.
✓ Branch 1 taken 1301 times.
|
25937 | (cu->cb_width >> hs) <= sps->max_ts_size && |
1018 |
2/2✓ Branch 0 taken 24174 times.
✓ Branch 1 taken 462 times.
|
24636 | (cu->cb_height >> vs) <= sps->max_ts_size) { |
1019 | 24174 | cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = ff_vvc_intra_bdpcm_chroma_flag(lc); | |
1020 | } | ||
1021 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 226984 times.
|
226987 | if (cu->bdpcm_flag[CHROMA]) { |
1022 |
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; |
1023 | } else { | ||
1024 | 226984 | const int cclm_enabled = get_cclm_enabled(lc, cu->x0, cu->y0); | |
1025 | 226984 | int cclm_mode_flag = 0; | |
1026 | 226984 | int cclm_mode_idx = 0; | |
1027 | 226984 | int intra_chroma_pred_mode = 0; | |
1028 | |||
1029 |
2/2✓ Branch 0 taken 205594 times.
✓ Branch 1 taken 21390 times.
|
226984 | if (cclm_enabled) |
1030 | 205594 | cclm_mode_flag = ff_vvc_cclm_mode_flag(lc); | |
1031 | |||
1032 |
2/2✓ Branch 0 taken 91243 times.
✓ Branch 1 taken 135741 times.
|
226984 | if (cclm_mode_flag) |
1033 | 91243 | cclm_mode_idx = ff_vvc_cclm_mode_idx(lc); | |
1034 | else | ||
1035 | 135741 | intra_chroma_pred_mode = ff_vvc_intra_chroma_pred_mode(lc); | |
1036 | 226984 | derive_chroma_intra_pred_mode(lc, cclm_mode_flag, cclm_mode_idx, intra_chroma_pred_mode); | |
1037 | } | ||
1038 | 226987 | } | |
1039 | |||
1040 | 1232069 | static PredMode pred_mode_decode(VVCLocalContext *lc, | |
1041 | const VVCTreeType tree_type, | ||
1042 | const VVCModeType mode_type) | ||
1043 | { | ||
1044 | 1232069 | const VVCFrameContext *fc = lc->fc; | |
1045 | 1232069 | CodingUnit *cu = lc->cu; | |
1046 | 1232069 | const VVCSPS *sps = fc->ps.sps; | |
1047 | 1232069 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1048 | 1232069 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
1049 |
4/4✓ Branch 0 taken 276111 times.
✓ Branch 1 taken 955958 times.
✓ Branch 2 taken 118852 times.
✓ Branch 3 taken 157259 times.
|
1232069 | const int is_4x4 = cu->cb_width == 4 && cu->cb_height == 4; |
1050 | int pred_mode_flag; | ||
1051 | int pred_mode_ibc_flag; | ||
1052 | PredMode pred_mode; | ||
1053 | |||
1054 | 1232069 | cu->skip_flag = 0; | |
1055 |
4/4✓ Branch 0 taken 648328 times.
✓ Branch 1 taken 583741 times.
✓ Branch 2 taken 27214 times.
✓ Branch 3 taken 621114 times.
|
1843024 | if (!IS_I(rsh) || sps->r->sps_ibc_enabled_flag) { |
1056 |
4/4✓ Branch 0 taken 588646 times.
✓ Branch 1 taken 22309 times.
✓ Branch 2 taken 2293 times.
✓ Branch 3 taken 586353 times.
|
610955 | const int is_128 = cu->cb_width == 128 || cu->cb_height == 128; |
1057 |
4/4✓ Branch 0 taken 581040 times.
✓ Branch 1 taken 29915 times.
✓ Branch 2 taken 525194 times.
✓ Branch 3 taken 55846 times.
|
610955 | if (tree_type != DUAL_TREE_CHROMA && |
1058 |
2/2✓ Branch 0 taken 43948 times.
✓ Branch 1 taken 481246 times.
|
525194 | ((!is_4x4 && mode_type != MODE_TYPE_INTRA) || |
1059 |
3/4✓ Branch 0 taken 72148 times.
✓ Branch 1 taken 27646 times.
✓ Branch 2 taken 72148 times.
✗ Branch 3 not taken.
|
99794 | (sps->r->sps_ibc_enabled_flag && !is_128))) { |
1060 | 553394 | cu->skip_flag = ff_vvc_cu_skip_flag(lc, fc->tab.skip); | |
1061 | } | ||
1062 | |||
1063 |
6/6✓ Branch 0 taken 555109 times.
✓ Branch 1 taken 55846 times.
✓ Branch 2 taken 488828 times.
✓ Branch 3 taken 66281 times.
✓ Branch 4 taken 17902 times.
✓ Branch 5 taken 470926 times.
|
610955 | if (is_4x4 || mode_type == MODE_TYPE_INTRA || IS_I(rsh)) { |
1064 | 140029 | pred_mode_flag = 1; | |
1065 |
4/4✓ Branch 0 taken 407897 times.
✓ Branch 1 taken 63029 times.
✓ Branch 2 taken 208783 times.
✓ Branch 3 taken 199114 times.
|
470926 | } else if (mode_type == MODE_TYPE_INTER || cu->skip_flag) { |
1066 | 271812 | pred_mode_flag = 0; | |
1067 | } else { | ||
1068 | 199114 | pred_mode_flag = ff_vvc_pred_mode_flag(lc, ch_type); | |
1069 | } | ||
1070 | 610955 | pred_mode = pred_mode_flag ? MODE_INTRA : MODE_INTER; | |
1071 | |||
1072 |
4/4✓ Branch 0 taken 27214 times.
✓ Branch 1 taken 583741 times.
✓ Branch 2 taken 1682 times.
✓ Branch 3 taken 25532 times.
|
610955 | if (((IS_I(rsh) && !cu->skip_flag) || |
1073 |
6/6✓ Branch 0 taken 583741 times.
✓ Branch 1 taken 1682 times.
✓ Branch 2 taken 159630 times.
✓ Branch 3 taken 424111 times.
✓ Branch 4 taken 113096 times.
✓ Branch 5 taken 46534 times.
|
585423 | (!IS_I(rsh) && (pred_mode != MODE_INTRA || |
1074 |
6/6✓ Branch 0 taken 66281 times.
✓ Branch 1 taken 46815 times.
✓ Branch 2 taken 103298 times.
✓ Branch 3 taken 9517 times.
✓ Branch 4 taken 528398 times.
✓ Branch 5 taken 24543 times.
|
609273 | ((is_4x4 || mode_type == MODE_TYPE_INTRA) && !cu->skip_flag)))) && |
1075 |
6/6✓ Branch 0 taken 465369 times.
✓ Branch 1 taken 63029 times.
✓ Branch 2 taken 106224 times.
✓ Branch 3 taken 359145 times.
✓ Branch 4 taken 84747 times.
✓ Branch 5 taken 21477 times.
|
528398 | !is_128 && mode_type != MODE_TYPE_INTER && sps->r->sps_ibc_enabled_flag && |
1076 | tree_type != DUAL_TREE_CHROMA) { | ||
1077 | 84747 | pred_mode_ibc_flag = ff_vvc_pred_mode_ibc_flag(lc, ch_type); | |
1078 |
6/6✓ Branch 0 taken 244296 times.
✓ Branch 1 taken 281912 times.
✓ Branch 2 taken 238109 times.
✓ Branch 3 taken 6187 times.
✓ Branch 4 taken 3752 times.
✓ Branch 5 taken 234357 times.
|
526208 | } else if (cu->skip_flag && (is_4x4 || mode_type == MODE_TYPE_INTRA)) { |
1079 | 9939 | pred_mode_ibc_flag = 1; | |
1080 |
6/6✓ Branch 0 taken 491667 times.
✓ Branch 1 taken 24602 times.
✓ Branch 2 taken 428638 times.
✓ Branch 3 taken 63029 times.
✓ Branch 4 taken 29915 times.
✓ Branch 5 taken 398723 times.
|
516269 | } else if (is_128 || mode_type == MODE_TYPE_INTER || tree_type == DUAL_TREE_CHROMA) { |
1081 | 117546 | pred_mode_ibc_flag = 0; | |
1082 | } else { | ||
1083 |
2/2✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 397463 times.
|
398723 | pred_mode_ibc_flag = (IS_I(rsh)) ? sps->r->sps_ibc_enabled_flag : 0; |
1084 | } | ||
1085 |
2/2✓ Branch 0 taken 31182 times.
✓ Branch 1 taken 579773 times.
|
610955 | if (pred_mode_ibc_flag) |
1086 | 31182 | pred_mode = MODE_IBC; | |
1087 | } else { | ||
1088 | 621114 | pred_mode = MODE_INTRA; | |
1089 | } | ||
1090 | |||
1091 | 1232069 | set_cb_tab(lc, fc->tab.cpm[cu->ch_type], pred_mode); | |
1092 |
2/2✓ Branch 0 taken 485459 times.
✓ Branch 1 taken 746610 times.
|
1232069 | if (tree_type == SINGLE_TREE) |
1093 | 485459 | set_cb_tab(lc, fc->tab.cpm[CHROMA], pred_mode); | |
1094 | |||
1095 | 1232069 | return pred_mode; | |
1096 | } | ||
1097 | |||
1098 | 937235 | static void sbt_info(VVCLocalContext *lc, const VVCSPS *sps) | |
1099 | { | ||
1100 | 937235 | CodingUnit *cu = lc->cu; | |
1101 | 937235 | const int cb_width = cu->cb_width; | |
1102 | 937235 | const int cb_height = cu->cb_height; | |
1103 | |||
1104 |
6/6✓ Branch 0 taken 154951 times.
✓ Branch 1 taken 782284 times.
✓ Branch 2 taken 149223 times.
✓ Branch 3 taken 5728 times.
✓ Branch 4 taken 133961 times.
✓ Branch 5 taken 15262 times.
|
937235 | if (cu->pred_mode == MODE_INTER && sps->r->sps_sbt_enabled_flag && !cu->ciip_flag |
1105 |
4/4✓ Branch 0 taken 131754 times.
✓ Branch 1 taken 2207 times.
✓ Branch 2 taken 130991 times.
✓ Branch 3 taken 763 times.
|
133961 | && cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) { |
1106 | 130991 | const int sbt_ver_h = cb_width >= 8; | |
1107 | 130991 | const int sbt_hor_h = cb_height >= 8; | |
1108 | 130991 | cu->sbt_flag = 0; | |
1109 |
3/4✓ Branch 0 taken 20091 times.
✓ Branch 1 taken 110900 times.
✓ Branch 2 taken 20091 times.
✗ Branch 3 not taken.
|
130991 | if (sbt_ver_h || sbt_hor_h) |
1110 | 130991 | cu->sbt_flag = ff_vvc_sbt_flag(lc); | |
1111 |
2/2✓ Branch 0 taken 44595 times.
✓ Branch 1 taken 86396 times.
|
130991 | if (cu->sbt_flag) { |
1112 | 44595 | const int sbt_ver_q = cb_width >= 16; | |
1113 | 44595 | const int sbt_hor_q = cb_height >= 16; | |
1114 | 44595 | int cu_sbt_quad_flag = 0; | |
1115 | |||
1116 |
7/8✓ Branch 0 taken 7563 times.
✓ Branch 1 taken 37032 times.
✓ Branch 2 taken 7563 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24860 times.
✓ Branch 5 taken 19735 times.
✓ Branch 6 taken 11976 times.
✓ Branch 7 taken 12884 times.
|
44595 | if ((sbt_ver_h || sbt_hor_h) && (sbt_ver_q || sbt_hor_q)) |
1117 | 31711 | cu_sbt_quad_flag = ff_vvc_sbt_quad_flag(lc); | |
1118 |
2/2✓ Branch 0 taken 11525 times.
✓ Branch 1 taken 33070 times.
|
44595 | if (cu_sbt_quad_flag) { |
1119 | 11525 | cu->sbt_horizontal_flag = sbt_hor_q; | |
1120 |
4/4✓ Branch 0 taken 7579 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 3455 times.
✓ Branch 3 taken 4124 times.
|
11525 | if (sbt_ver_q && sbt_hor_q) |
1121 | 3455 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
1122 | } else { | ||
1123 | 33070 | cu->sbt_horizontal_flag = sbt_hor_h; | |
1124 |
4/4✓ Branch 0 taken 27033 times.
✓ Branch 1 taken 6037 times.
✓ Branch 2 taken 21511 times.
✓ Branch 3 taken 5522 times.
|
33070 | if (sbt_ver_h && sbt_hor_h) |
1125 | 21511 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
1126 | } | ||
1127 | 44595 | cu->sbt_pos_flag = ff_vvc_sbt_pos_flag(lc); | |
1128 | |||
1129 | { | ||
1130 |
2/2✓ Branch 0 taken 11525 times.
✓ Branch 1 taken 33070 times.
|
44595 | const int sbt_min = cu_sbt_quad_flag ? 1 : 2; |
1131 |
2/2✓ Branch 0 taken 21387 times.
✓ Branch 1 taken 23208 times.
|
44595 | lc->parse.sbt_num_fourths_tb0 = cu->sbt_pos_flag ? (4 - sbt_min) : sbt_min; |
1132 | } | ||
1133 | } | ||
1134 | } | ||
1135 | 937235 | } | |
1136 | |||
1137 | 294834 | static int skipped_transform_tree_unit(VVCLocalContext *lc) | |
1138 | { | ||
1139 | 294834 | const H266RawSPS *rsps = lc->fc->ps.sps->r; | |
1140 | 294834 | const CodingUnit *cu = lc->cu; | |
1141 | int ret; | ||
1142 | |||
1143 |
1/2✓ Branch 0 taken 294834 times.
✗ Branch 1 not taken.
|
294834 | if (cu->tree_type != DUAL_TREE_CHROMA) |
1144 | 294834 | set_qp_y(lc, cu->x0, cu->y0, 0); | |
1145 |
4/4✓ Branch 0 taken 278323 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 252629 times.
✓ Branch 3 taken 25694 times.
|
294834 | if (rsps->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA) |
1146 | 252629 | set_qp_c(lc); | |
1147 | 294834 | ret = skipped_transform_tree(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
1148 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 294834 times.
|
294834 | if (ret < 0) |
1149 | ✗ | return ret; | |
1150 | 294834 | return 0; | |
1151 | } | ||
1152 | |||
1153 | 1232069 | static void set_cb_pos(const VVCFrameContext *fc, const CodingUnit *cu) | |
1154 | { | ||
1155 | 1232069 | const VVCSPS *sps = fc->ps.sps; | |
1156 | 1232069 | const VVCPPS *pps = fc->ps.pps; | |
1157 | 1232069 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
1158 | 1232069 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
1159 | 1232069 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
1160 | 1232069 | const int ch_type = cu->ch_type; | |
1161 | int x, y; | ||
1162 | |||
1163 | 1232069 | x = y_cb * pps->min_cb_width + x_cb; | |
1164 |
2/2✓ Branch 0 taken 5088546 times.
✓ Branch 1 taken 1232069 times.
|
6320615 | for (y = 0; y < (cu->cb_height >> log2_min_cb_size); y++) { |
1165 | 5088546 | const int width = cu->cb_width >> log2_min_cb_size; | |
1166 | |||
1167 |
2/2✓ Branch 0 taken 47692016 times.
✓ Branch 1 taken 5088546 times.
|
52780562 | for (int i = 0; i < width; i++) { |
1168 | 47692016 | fc->tab.cb_pos_x[ch_type][x + i] = cu->x0; | |
1169 | 47692016 | fc->tab.cb_pos_y[ch_type][x + i] = cu->y0; | |
1170 | } | ||
1171 | 5088546 | memset(&fc->tab.cb_width[ch_type][x], cu->cb_width, width); | |
1172 | 5088546 | memset(&fc->tab.cb_height[ch_type][x], cu->cb_height, width); | |
1173 | 5088546 | memset(&fc->tab.cqt_depth[ch_type][x], cu->cqt_depth, width); | |
1174 | |||
1175 | 5088546 | x += pps->min_cb_width; | |
1176 | } | ||
1177 | 1232069 | } | |
1178 | |||
1179 | 1232069 | static CodingUnit* alloc_cu(VVCLocalContext *lc, const int x0, const int y0) | |
1180 | { | ||
1181 | 1232069 | VVCFrameContext *fc = lc->fc; | |
1182 | 1232069 | const VVCSPS *sps = fc->ps.sps; | |
1183 | 1232069 | const VVCPPS *pps = fc->ps.pps; | |
1184 | 1232069 | const int rx = x0 >> sps->ctb_log2_size_y; | |
1185 | 1232069 | const int ry = y0 >> sps->ctb_log2_size_y; | |
1186 | 1232069 | CodingUnit **cus = fc->tab.cus + ry * pps->ctb_width + rx; | |
1187 | 1232069 | CodingUnit *cu = av_refstruct_pool_get(fc->cu_pool); | |
1188 | |||
1189 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1232069 times.
|
1232069 | if (!cu) |
1190 | ✗ | return NULL; | |
1191 | 1232069 | cu->next = NULL; | |
1192 | |||
1193 |
2/2✓ Branch 0 taken 1185364 times.
✓ Branch 1 taken 46705 times.
|
1232069 | if (lc->cu) |
1194 | 1185364 | lc->cu->next = cu; | |
1195 | else | ||
1196 | 46705 | *cus = cu; | |
1197 | 1232069 | lc->cu = cu; | |
1198 | |||
1199 | 1232069 | return cu; | |
1200 | } | ||
1201 | |||
1202 | 1232069 | static CodingUnit* add_cu(VVCLocalContext *lc, const int x0, const int y0, | |
1203 | const int cb_width, const int cb_height, const int cqt_depth, const VVCTreeType tree_type) | ||
1204 | { | ||
1205 | 1232069 | VVCFrameContext *fc = lc->fc; | |
1206 | 1232069 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
1207 | 1232069 | CodingUnit *cu = alloc_cu(lc, x0, y0); | |
1208 | |||
1209 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1232069 times.
|
1232069 | if (!cu) |
1210 | ✗ | return NULL; | |
1211 | |||
1212 | 1232069 | memset(&cu->pu, 0, sizeof(cu->pu)); | |
1213 | |||
1214 | 1232069 | lc->parse.prev_tu_cbf_y = 0; | |
1215 | |||
1216 | 1232069 | cu->sbt_flag = 0; | |
1217 | 1232069 | cu->act_enabled_flag = 0; | |
1218 | |||
1219 | 1232069 | cu->tree_type = tree_type; | |
1220 | 1232069 | cu->x0 = x0; | |
1221 | 1232069 | cu->y0 = y0; | |
1222 | 1232069 | cu->cb_width = cb_width; | |
1223 | 1232069 | cu->cb_height = cb_height; | |
1224 | 1232069 | cu->ch_type = ch_type; | |
1225 | 1232069 | cu->cqt_depth = cqt_depth; | |
1226 | 1232069 | cu->tus.head = cu->tus.tail = NULL; | |
1227 | 1232069 | cu->bdpcm_flag[LUMA] = cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = 0; | |
1228 | 1232069 | cu->isp_split_type = ISP_NO_SPLIT; | |
1229 | 1232069 | cu->intra_mip_flag = 0; | |
1230 | 1232069 | cu->ciip_flag = 0; | |
1231 | 1232069 | cu->coded_flag = 1; | |
1232 | 1232069 | cu->num_intra_subpartitions = 1; | |
1233 | 1232069 | cu->pu.dmvr_flag = 0; | |
1234 | |||
1235 | 1232069 | set_cb_pos(fc, cu); | |
1236 | 1232069 | return cu; | |
1237 | } | ||
1238 | |||
1239 | 1232069 | static void set_cu_tabs(const VVCLocalContext *lc, const CodingUnit *cu) | |
1240 | { | ||
1241 | 1232069 | const VVCFrameContext *fc = lc->fc; | |
1242 | 1232069 | const PredictionUnit *pu = &cu->pu; | |
1243 | 1232069 | const TransformUnit *tu = cu->tus.head; | |
1244 | |||
1245 | 1232069 | set_cb_tab(lc, fc->tab.mmi, pu->mi.motion_model_idc); | |
1246 | 1232069 | set_cb_tab(lc, fc->tab.msf, pu->merge_subblock_flag); | |
1247 |
2/2✓ Branch 0 taken 1051308 times.
✓ Branch 1 taken 180761 times.
|
1232069 | if (cu->tree_type != DUAL_TREE_CHROMA) { |
1248 | 1051308 | set_cb_tab(lc, fc->tab.skip, cu->skip_flag); | |
1249 | 1051308 | set_cb_tab(lc, fc->tab.pcmf[LUMA], cu->bdpcm_flag[LUMA]); | |
1250 | } | ||
1251 |
2/2✓ Branch 0 taken 666220 times.
✓ Branch 1 taken 565849 times.
|
1232069 | if (cu->tree_type != DUAL_TREE_LUMA) |
1252 | 666220 | set_cb_tab(lc, fc->tab.pcmf[CHROMA], cu->bdpcm_flag[CHROMA]); | |
1253 | |||
1254 |
2/2✓ Branch 0 taken 1491918 times.
✓ Branch 1 taken 1232069 times.
|
2723987 | while (tu) { |
1255 |
2/2✓ Branch 0 taken 2803505 times.
✓ Branch 1 taken 1491918 times.
|
4295423 | for (int j = 0; j < tu->nb_tbs; j++) { |
1256 | 2803505 | const TransformBlock *tb = tu->tbs + j; | |
1257 |
2/2✓ Branch 0 taken 1493204 times.
✓ Branch 1 taken 1310301 times.
|
2803505 | if (tb->c_idx != LUMA) |
1258 | 1493204 | set_qp_c_tab(lc, tu, tb); | |
1259 | } | ||
1260 | 1491918 | tu = tu->next; | |
1261 | } | ||
1262 | 1232069 | } | |
1263 | |||
1264 | //8.5.2.7 Derivation process for merge motion vector difference | ||
1265 | 55977 | static void derive_mmvd(const VVCLocalContext *lc, MvField *mvf, const Mv *mmvd_offset) | |
1266 | { | ||
1267 | 55977 | const SliceContext *sc = lc->sc; | |
1268 | Mv mmvd[2]; | ||
1269 | |||
1270 |
2/2✓ Branch 0 taken 23351 times.
✓ Branch 1 taken 32626 times.
|
55977 | if (mvf->pred_flag == PF_BI) { |
1271 | 23351 | const RefPicList *rpl = sc->rpl; | |
1272 | 23351 | const int poc = lc->fc->ps.ph.poc; | |
1273 | 23351 | const int diff[] = { | |
1274 | 23351 | poc - rpl[L0].refs[mvf->ref_idx[L0]].poc, | |
1275 | 23351 | poc - rpl[L1].refs[mvf->ref_idx[L1]].poc | |
1276 | }; | ||
1277 |
4/4✓ Branch 0 taken 22020 times.
✓ Branch 1 taken 1331 times.
✓ Branch 2 taken 8875 times.
✓ Branch 3 taken 14476 times.
|
23351 | const int sign = FFSIGN(diff[0]) != FFSIGN(diff[1]); |
1278 | |||
1279 |
2/2✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 15382 times.
|
23351 | if (diff[0] == diff[1]) { |
1280 | 7969 | mmvd[1] = mmvd[0] = *mmvd_offset; | |
1281 | } | ||
1282 | else { | ||
1283 | 15382 | const int i = FFABS(diff[0]) < FFABS(diff[1]); | |
1284 | 15382 | const int o = !i; | |
1285 | 15382 | mmvd[i] = *mmvd_offset; | |
1286 |
4/4✓ Branch 0 taken 15138 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 15061 times.
✓ Branch 3 taken 77 times.
|
15382 | if (!rpl[L0].refs[mvf->ref_idx[L0]].is_lt && !rpl[L1].refs[mvf->ref_idx[L1]].is_lt) { |
1287 | 15061 | ff_vvc_mv_scale(&mmvd[o], mmvd_offset, diff[i], diff[o]); | |
1288 | } | ||
1289 | else { | ||
1290 |
2/2✓ Branch 0 taken 199 times.
✓ Branch 1 taken 122 times.
|
321 | mmvd[o].x = sign ? -mmvd[i].x : mmvd[i].x; |
1291 |
2/2✓ Branch 0 taken 199 times.
✓ Branch 1 taken 122 times.
|
321 | mmvd[o].y = sign ? -mmvd[i].y : mmvd[i].y; |
1292 | } | ||
1293 | } | ||
1294 | 23351 | mvf->mv[0].x += mmvd[0].x; | |
1295 | 23351 | mvf->mv[0].y += mmvd[0].y; | |
1296 | 23351 | mvf->mv[1].x += mmvd[1].x; | |
1297 | 23351 | mvf->mv[1].y += mmvd[1].y; | |
1298 | } else { | ||
1299 | 32626 | const int idx = mvf->pred_flag - PF_L0; | |
1300 | 32626 | mvf->mv[idx].x += mmvd_offset->x; | |
1301 | 32626 | mvf->mv[idx].y += mmvd_offset->y; | |
1302 | } | ||
1303 | |||
1304 | 55977 | } | |
1305 | |||
1306 | 273411 | static void mvf_to_mi(const MvField *mvf, MotionInfo *mi) | |
1307 | { | ||
1308 | 273411 | mi->pred_flag = mvf->pred_flag; | |
1309 | 273411 | mi->bcw_idx = mvf->bcw_idx; | |
1310 | 273411 | mi->hpel_if_idx = mvf->hpel_if_idx; | |
1311 |
2/2✓ Branch 0 taken 546822 times.
✓ Branch 1 taken 273411 times.
|
820233 | for (int i = 0; i < 2; i++) { |
1312 | 546822 | const PredFlag mask = i + 1; | |
1313 |
2/2✓ Branch 0 taken 430639 times.
✓ Branch 1 taken 116183 times.
|
546822 | if (mvf->pred_flag & mask) { |
1314 | 430639 | mi->mv[i][0] = mvf->mv[i]; | |
1315 | 430639 | mi->ref_idx[i] = mvf->ref_idx[i]; | |
1316 | } | ||
1317 | } | ||
1318 | 273411 | } | |
1319 | |||
1320 | 273411 | static void mv_merge_refine_pred_flag(MvField *mvf, const int width, const int height) | |
1321 | { | ||
1322 |
4/4✓ Branch 0 taken 162286 times.
✓ Branch 1 taken 111125 times.
✓ Branch 2 taken 5058 times.
✓ Branch 3 taken 157228 times.
|
273411 | if (mvf->pred_flag == PF_BI && (width + height) == 12) { |
1323 | 5058 | mvf->pred_flag = PF_L0; | |
1324 | 5058 | mvf->bcw_idx = 0; | |
1325 | } | ||
1326 | 273411 | } | |
1327 | |||
1328 | // subblock-based inter prediction data | ||
1329 | 50089 | static void merge_data_subblock(VVCLocalContext *lc) | |
1330 | { | ||
1331 | 50089 | const VVCFrameContext *fc = lc->fc; | |
1332 | 50089 | const VVCPH *ph = &fc->ps.ph; | |
1333 | 50089 | CodingUnit* cu = lc->cu; | |
1334 | 50089 | PredictionUnit *pu = &cu->pu; | |
1335 | 50089 | int merge_subblock_idx = 0; | |
1336 | |||
1337 |
1/2✓ Branch 0 taken 50089 times.
✗ Branch 1 not taken.
|
50089 | if (ph->max_num_subblock_merge_cand > 1) { |
1338 | 50089 | merge_subblock_idx = ff_vvc_merge_subblock_idx(lc, ph->max_num_subblock_merge_cand); | |
1339 | } | ||
1340 | 50089 | ff_vvc_sb_mv_merge_mode(lc, merge_subblock_idx, pu); | |
1341 | 50089 | } | |
1342 | |||
1343 | 257725 | static void merge_data_regular(VVCLocalContext *lc) | |
1344 | { | ||
1345 | 257725 | const VVCFrameContext *fc = lc->fc; | |
1346 | 257725 | const VVCSPS *sps = fc->ps.sps; | |
1347 | 257725 | const VVCPH *ph = &fc->ps.ph; | |
1348 | 257725 | const CodingUnit* cu = lc->cu; | |
1349 | 257725 | PredictionUnit *pu = &lc->cu->pu; | |
1350 | 257725 | int merge_idx = 0; | |
1351 | Mv mmvd_offset; | ||
1352 | MvField mvf; | ||
1353 | |||
1354 |
2/2✓ Branch 0 taken 252561 times.
✓ Branch 1 taken 5164 times.
|
257725 | if (sps->r->sps_mmvd_enabled_flag) |
1355 | 252561 | pu->mmvd_merge_flag = ff_vvc_mmvd_merge_flag(lc); | |
1356 |
2/2✓ Branch 0 taken 55977 times.
✓ Branch 1 taken 201748 times.
|
257725 | if (pu->mmvd_merge_flag) { |
1357 | 55977 | int mmvd_cand_flag = 0; | |
1358 |
1/2✓ Branch 0 taken 55977 times.
✗ Branch 1 not taken.
|
55977 | if (sps->max_num_merge_cand > 1) |
1359 | 55977 | mmvd_cand_flag = ff_vvc_mmvd_cand_flag(lc); | |
1360 | 55977 | ff_vvc_mmvd_offset_coding(lc, &mmvd_offset, ph->r->ph_mmvd_fullpel_only_flag); | |
1361 | 55977 | merge_idx = mmvd_cand_flag; | |
1362 |
1/2✓ Branch 0 taken 201748 times.
✗ Branch 1 not taken.
|
201748 | } else if (sps->max_num_merge_cand > 1) { |
1363 | 201748 | merge_idx = ff_vvc_merge_idx(lc); | |
1364 | } | ||
1365 | 257725 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 0, &mvf); | |
1366 |
2/2✓ Branch 0 taken 55977 times.
✓ Branch 1 taken 201748 times.
|
257725 | if (pu->mmvd_merge_flag) |
1367 | 55977 | derive_mmvd(lc, &mvf, &mmvd_offset); | |
1368 | 257725 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
1369 | 257725 | ff_vvc_store_mvf(lc, &mvf); | |
1370 | 257725 | mvf_to_mi(&mvf, &pu->mi); | |
1371 | 257725 | } | |
1372 | |||
1373 | 41301 | static int ciip_flag_decode(VVCLocalContext *lc, const int ciip_avaiable, const int gpm_avaiable, const int is_128) | |
1374 | { | ||
1375 | 41301 | const VVCFrameContext *fc = lc->fc; | |
1376 | 41301 | const VVCSPS *sps = fc->ps.sps; | |
1377 | 41301 | const CodingUnit *cu = lc->cu; | |
1378 | |||
1379 |
4/4✓ Branch 0 taken 26109 times.
✓ Branch 1 taken 15192 times.
✓ Branch 2 taken 19469 times.
✓ Branch 3 taken 6640 times.
|
41301 | if (ciip_avaiable && gpm_avaiable) |
1380 | 19469 | return ff_vvc_ciip_flag(lc); | |
1381 |
3/4✓ Branch 0 taken 6640 times.
✓ Branch 1 taken 15192 times.
✓ Branch 2 taken 6640 times.
✗ Branch 3 not taken.
|
21832 | return sps->r->sps_ciip_enabled_flag && !cu->skip_flag && |
1382 |
2/4✓ Branch 0 taken 21832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6640 times.
✗ Branch 3 not taken.
|
43664 | !is_128 && (cu->cb_width * cu->cb_height >= 64); |
1383 | } | ||
1384 | |||
1385 | 25615 | static void merge_data_gpm(VVCLocalContext *lc) | |
1386 | { | ||
1387 | 25615 | const VVCFrameContext *fc = lc->fc; | |
1388 | 25615 | const VVCSPS *sps = fc->ps.sps; | |
1389 | 25615 | PredictionUnit *pu = &lc->cu->pu; | |
1390 | int merge_gpm_idx[2]; | ||
1391 | |||
1392 | 25615 | pu->merge_gpm_flag = 1; | |
1393 | 25615 | pu->gpm_partition_idx = ff_vvc_merge_gpm_partition_idx(lc); | |
1394 | 25615 | merge_gpm_idx[0] = ff_vvc_merge_gpm_idx(lc, 0); | |
1395 | 25615 | merge_gpm_idx[1] = 0; | |
1396 |
1/2✓ Branch 0 taken 25615 times.
✗ Branch 1 not taken.
|
25615 | if (sps->max_num_gpm_merge_cand > 2) |
1397 | 25615 | merge_gpm_idx[1] = ff_vvc_merge_gpm_idx(lc, 1); | |
1398 | |||
1399 | 25615 | ff_vvc_luma_mv_merge_gpm(lc, merge_gpm_idx, pu->gpm_mv); | |
1400 | 25615 | ff_vvc_store_gpm_mvf(lc, pu); | |
1401 | 25615 | } | |
1402 | |||
1403 | 15686 | static void merge_data_ciip(VVCLocalContext *lc) | |
1404 | { | ||
1405 | 15686 | const VVCFrameContext* fc = lc->fc; | |
1406 | 15686 | const VVCSPS* sps = fc->ps.sps; | |
1407 | 15686 | CodingUnit *cu = lc->cu; | |
1408 | 15686 | MotionInfo *mi = &cu->pu.mi; | |
1409 | 15686 | int merge_idx = 0; | |
1410 | MvField mvf; | ||
1411 | |||
1412 |
1/2✓ Branch 0 taken 15686 times.
✗ Branch 1 not taken.
|
15686 | if (sps->max_num_merge_cand > 1) |
1413 | 15686 | merge_idx = ff_vvc_merge_idx(lc); | |
1414 | 15686 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 1, &mvf); | |
1415 | 15686 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
1416 | 15686 | ff_vvc_store_mvf(lc, &mvf); | |
1417 | 15686 | mvf_to_mi(&mvf, mi); | |
1418 | 15686 | cu->intra_pred_mode_y = cu->intra_pred_mode_c = INTRA_PLANAR; | |
1419 | 15686 | cu->intra_luma_ref_idx = 0; | |
1420 | 15686 | cu->intra_mip_flag = 0; | |
1421 | 15686 | } | |
1422 | |||
1423 | // block-based inter prediction data | ||
1424 | 299026 | static void merge_data_block(VVCLocalContext *lc) | |
1425 | { | ||
1426 | 299026 | const VVCFrameContext* fc = lc->fc; | |
1427 | 299026 | const VVCSPS *sps = fc->ps.sps; | |
1428 | 299026 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1429 | 299026 | CodingUnit *cu = lc->cu; | |
1430 | 299026 | const int cb_width = cu->cb_width; | |
1431 | 299026 | const int cb_height = cu->cb_height; | |
1432 |
4/4✓ Branch 0 taken 281734 times.
✓ Branch 1 taken 17292 times.
✓ Branch 2 taken 1346 times.
✓ Branch 3 taken 280388 times.
|
299026 | const int is_128 = cb_width == 128 || cb_height == 128; |
1433 | 891914 | const int ciip_avaiable = sps->r->sps_ciip_enabled_flag && | |
1434 |
6/6✓ Branch 0 taken 293862 times.
✓ Branch 1 taken 5164 times.
✓ Branch 2 taken 99782 times.
✓ Branch 3 taken 194080 times.
✓ Branch 4 taken 89097 times.
✓ Branch 5 taken 10685 times.
|
299026 | !cu->skip_flag && (cb_width * cb_height >= 64); |
1435 |
4/4✓ Branch 0 taken 278688 times.
✓ Branch 1 taken 906 times.
✓ Branch 2 taken 244049 times.
✓ Branch 3 taken 34639 times.
|
279594 | const int gpm_avaiable = sps->r->sps_gpm_enabled_flag && IS_B(rsh) && |
1436 |
2/2✓ Branch 0 taken 217965 times.
✓ Branch 1 taken 26084 times.
|
244049 | (cb_width >= 8) && (cb_height >=8) && |
1437 |
6/6✓ Branch 0 taken 279594 times.
✓ Branch 1 taken 19432 times.
✓ Branch 2 taken 211881 times.
✓ Branch 3 taken 6084 times.
✓ Branch 4 taken 210032 times.
✓ Branch 5 taken 1849 times.
|
578620 | (cb_width < 8 * cb_height) && (cb_height < 8 *cb_width); |
1438 | |||
1439 | 299026 | int regular_merge_flag = 1; | |
1440 | |||
1441 |
6/6✓ Branch 0 taken 280388 times.
✓ Branch 1 taken 18638 times.
✓ Branch 2 taken 191650 times.
✓ Branch 3 taken 88738 times.
✓ Branch 4 taken 129273 times.
✓ Branch 5 taken 62377 times.
|
299026 | if (!is_128 && (ciip_avaiable || gpm_avaiable)) |
1442 | 218011 | regular_merge_flag = ff_vvc_regular_merge_flag(lc, cu->skip_flag); | |
1443 |
2/2✓ Branch 0 taken 257725 times.
✓ Branch 1 taken 41301 times.
|
299026 | if (regular_merge_flag) { |
1444 | 257725 | merge_data_regular(lc); | |
1445 | } else { | ||
1446 | 41301 | cu->ciip_flag = ciip_flag_decode(lc, ciip_avaiable, gpm_avaiable, is_128); | |
1447 |
2/2✓ Branch 0 taken 15686 times.
✓ Branch 1 taken 25615 times.
|
41301 | if (cu->ciip_flag) |
1448 | 15686 | merge_data_ciip(lc); | |
1449 | else | ||
1450 | 25615 | merge_data_gpm(lc); | |
1451 | } | ||
1452 | 299026 | } | |
1453 | |||
1454 | 14146 | static int merge_data_ibc(VVCLocalContext *lc) | |
1455 | { | ||
1456 | 14146 | const VVCFrameContext* fc = lc->fc; | |
1457 | 14146 | const VVCSPS* sps = fc->ps.sps; | |
1458 | 14146 | MotionInfo *mi = &lc->cu->pu.mi; | |
1459 | 14146 | int merge_idx = 0; | |
1460 | int ret; | ||
1461 | |||
1462 | 14146 | mi->pred_flag = PF_IBC; | |
1463 | |||
1464 |
2/2✓ Branch 0 taken 13906 times.
✓ Branch 1 taken 240 times.
|
14146 | if (sps->max_num_ibc_merge_cand > 1) |
1465 | 13906 | merge_idx = ff_vvc_merge_idx(lc); | |
1466 | |||
1467 | 14146 | ret = ff_vvc_luma_mv_merge_ibc(lc, merge_idx, &mi->mv[L0][0]); | |
1468 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14146 times.
|
14146 | if (ret) |
1469 | ✗ | return ret; | |
1470 | 14146 | ff_vvc_store_mv(lc, mi); | |
1471 | |||
1472 | 14146 | return 0; | |
1473 | } | ||
1474 | |||
1475 | 363261 | static int hls_merge_data(VVCLocalContext *lc) | |
1476 | { | ||
1477 | 363261 | const VVCFrameContext *fc = lc->fc; | |
1478 | 363261 | const VVCPH *ph = &fc->ps.ph; | |
1479 | 363261 | const CodingUnit *cu = lc->cu; | |
1480 | 363261 | PredictionUnit *pu = &lc->cu->pu; | |
1481 | int ret; | ||
1482 | |||
1483 | 363261 | pu->merge_gpm_flag = 0; | |
1484 | 363261 | pu->mi.num_sb_x = pu->mi.num_sb_y = 1; | |
1485 |
2/2✓ Branch 0 taken 14146 times.
✓ Branch 1 taken 349115 times.
|
363261 | if (cu->pred_mode == MODE_IBC) { |
1486 | 14146 | ret = merge_data_ibc(lc); | |
1487 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14146 times.
|
14146 | if (ret) |
1488 | ✗ | return ret; | |
1489 | } else { | ||
1490 |
5/6✓ Branch 0 taken 349115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312613 times.
✓ Branch 3 taken 36502 times.
✓ Branch 4 taken 284568 times.
✓ Branch 5 taken 28045 times.
|
349115 | if (ph->max_num_subblock_merge_cand > 0 && cu->cb_width >= 8 && cu->cb_height >= 8) |
1491 | 284568 | pu->merge_subblock_flag = ff_vvc_merge_subblock_flag(lc); | |
1492 |
2/2✓ Branch 0 taken 50089 times.
✓ Branch 1 taken 299026 times.
|
349115 | if (pu->merge_subblock_flag) |
1493 | 50089 | merge_data_subblock(lc); | |
1494 | else | ||
1495 | 299026 | merge_data_block(lc); | |
1496 | } | ||
1497 | 363261 | return 0; | |
1498 | } | ||
1499 | |||
1500 | 117924 | static void hls_mvd_coding(VVCLocalContext *lc, Mv* mvd) | |
1501 | { | ||
1502 | int32_t mv[2]; | ||
1503 | |||
1504 |
2/2✓ Branch 0 taken 235848 times.
✓ Branch 1 taken 117924 times.
|
353772 | for (int i = 0; i < 2; i++) { |
1505 | 235848 | mv[i] = ff_vvc_abs_mvd_greater0_flag(lc); | |
1506 | } | ||
1507 | |||
1508 |
2/2✓ Branch 0 taken 235848 times.
✓ Branch 1 taken 117924 times.
|
353772 | for (int i = 0; i < 2; i++) { |
1509 |
2/2✓ Branch 0 taken 164462 times.
✓ Branch 1 taken 71386 times.
|
235848 | if (mv[i]) |
1510 | 164462 | mv[i] += ff_vvc_abs_mvd_greater1_flag(lc); | |
1511 | } | ||
1512 | |||
1513 |
2/2✓ Branch 0 taken 235848 times.
✓ Branch 1 taken 117924 times.
|
353772 | for (int i = 0; i < 2; i++) { |
1514 |
2/2✓ Branch 0 taken 164462 times.
✓ Branch 1 taken 71386 times.
|
235848 | if (mv[i] > 0) { |
1515 |
2/2✓ Branch 0 taken 111369 times.
✓ Branch 1 taken 53093 times.
|
164462 | if (mv[i] == 2) |
1516 | 111369 | mv[i] += ff_vvc_abs_mvd_minus2(lc); | |
1517 | 164462 | mv[i] = (1 - 2 * ff_vvc_mvd_sign_flag(lc)) * mv[i]; | |
1518 | } | ||
1519 | } | ||
1520 | 117924 | mvd->x = mv[0]; | |
1521 | 117924 | mvd->y = mv[1]; | |
1522 | 117924 | } | |
1523 | |||
1524 | 74951 | static int bcw_idx_decode(VVCLocalContext *lc, const MotionInfo *mi, const int cb_width, const int cb_height) | |
1525 | { | ||
1526 | 74951 | const VVCFrameContext *fc = lc->fc; | |
1527 | 74951 | const VVCSPS *sps = fc->ps.sps; | |
1528 | 74951 | const VVCPPS *pps = fc->ps.pps; | |
1529 | 74951 | const VVCPH *ph = &fc->ps.ph; | |
1530 | 74951 | const VVCSH *sh = &lc->sc->sh; | |
1531 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 74951 times.
|
74951 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &ph->pwt : &sh->pwt; |
1532 | 74951 | int bcw_idx = 0; | |
1533 | |||
1534 |
4/4✓ Branch 0 taken 71220 times.
✓ Branch 1 taken 3731 times.
✓ Branch 2 taken 19738 times.
✓ Branch 3 taken 51482 times.
|
74951 | if (sps->r->sps_bcw_enabled_flag && mi->pred_flag == PF_BI && |
1535 |
2/2✓ Branch 0 taken 18386 times.
✓ Branch 1 taken 1352 times.
|
19738 | !w->weight_flag[L0][LUMA][mi->ref_idx[0]] && |
1536 |
2/2✓ Branch 0 taken 17740 times.
✓ Branch 1 taken 646 times.
|
18386 | !w->weight_flag[L1][LUMA][mi->ref_idx[1]] && |
1537 |
2/2✓ Branch 0 taken 17316 times.
✓ Branch 1 taken 424 times.
|
17740 | !w->weight_flag[L0][CHROMA][mi->ref_idx[0]] && |
1538 |
2/2✓ Branch 0 taken 17154 times.
✓ Branch 1 taken 162 times.
|
17316 | !w->weight_flag[L1][CHROMA][mi->ref_idx[1]] && |
1539 |
2/2✓ Branch 0 taken 11245 times.
✓ Branch 1 taken 5909 times.
|
17154 | cb_width * cb_height >= 256) { |
1540 | 11245 | bcw_idx = ff_vvc_bcw_idx(lc, ff_vvc_no_backward_pred_flag(lc)); | |
1541 | } | ||
1542 | 74951 | return bcw_idx; | |
1543 | } | ||
1544 | |||
1545 | 95525 | static int8_t ref_idx_decode(VVCLocalContext *lc, const VVCSH *sh, const int sym_mvd_flag, const int lx) | |
1546 | { | ||
1547 | 95525 | const H266RawSliceHeader *rsh = sh->r; | |
1548 | 95525 | int ref_idx = 0; | |
1549 | |||
1550 |
4/4✓ Branch 0 taken 78510 times.
✓ Branch 1 taken 17015 times.
✓ Branch 2 taken 66272 times.
✓ Branch 3 taken 12238 times.
|
95525 | if (rsh->num_ref_idx_active[lx] > 1 && !sym_mvd_flag) |
1551 | 66272 | ref_idx = ff_vvc_ref_idx_lx(lc, rsh->num_ref_idx_active[lx]); | |
1552 |
2/2✓ Branch 0 taken 12238 times.
✓ Branch 1 taken 17015 times.
|
29253 | else if (sym_mvd_flag) |
1553 | 12238 | ref_idx = sh->ref_idx_sym[lx]; | |
1554 | 95525 | return ref_idx; | |
1555 | } | ||
1556 | |||
1557 | 95525 | static int mvds_decode(VVCLocalContext *lc, Mv mvds[2][MAX_CONTROL_POINTS], | |
1558 | const int num_cp_mv, const int lx) | ||
1559 | { | ||
1560 | 95525 | const VVCFrameContext *fc = lc->fc; | |
1561 | 95525 | const VVCPH *ph = &fc->ps.ph; | |
1562 | 95525 | const PredictionUnit *pu = &lc->cu->pu; | |
1563 | 95525 | const MotionInfo *mi = &pu->mi; | |
1564 | 95525 | int has_no_zero_mvd = 0; | |
1565 | |||
1566 |
6/6✓ Branch 0 taken 33107 times.
✓ Branch 1 taken 62418 times.
✓ Branch 2 taken 4768 times.
✓ Branch 3 taken 28339 times.
✓ Branch 4 taken 4754 times.
✓ Branch 5 taken 14 times.
|
95525 | if (lx == L1 && ph->r->ph_mvd_l1_zero_flag && mi->pred_flag == PF_BI) { |
1567 |
2/2✓ Branch 0 taken 6065 times.
✓ Branch 1 taken 4754 times.
|
10819 | for (int j = 0; j < num_cp_mv; j++) |
1568 | 6065 | AV_ZERO64(&mvds[lx][j]); | |
1569 | } else { | ||
1570 | 90771 | Mv *mvd0 = &mvds[lx][0]; | |
1571 |
4/4✓ Branch 0 taken 28353 times.
✓ Branch 1 taken 62418 times.
✓ Branch 2 taken 6119 times.
✓ Branch 3 taken 22234 times.
|
90771 | if (lx == L1 && pu->sym_mvd_flag) { |
1572 | 6119 | mvd0->x = -mvds[L0][0].x; | |
1573 | 6119 | mvd0->y = -mvds[L0][0].y; | |
1574 | } else { | ||
1575 | 84652 | hls_mvd_coding(lc, mvd0); | |
1576 | } | ||
1577 |
4/4✓ Branch 0 taken 21817 times.
✓ Branch 1 taken 68954 times.
✓ Branch 2 taken 13976 times.
✓ Branch 3 taken 7841 times.
|
90771 | has_no_zero_mvd |= (mvd0->x || mvd0->y); |
1578 |
2/2✓ Branch 0 taken 16236 times.
✓ Branch 1 taken 90771 times.
|
107007 | for (int j = 1; j < num_cp_mv; j++) { |
1579 | 16236 | Mv *mvd = &mvds[lx][j]; | |
1580 | 16236 | hls_mvd_coding(lc, mvd); | |
1581 | 16236 | mvd->x += mvd0->x; | |
1582 | 16236 | mvd->y += mvd0->y; | |
1583 |
4/4✓ Branch 0 taken 2930 times.
✓ Branch 1 taken 13306 times.
✓ Branch 2 taken 2004 times.
✓ Branch 3 taken 926 times.
|
16236 | has_no_zero_mvd |= (mvd->x || mvd->y); |
1584 | } | ||
1585 | } | ||
1586 | 95525 | return has_no_zero_mvd; | |
1587 | } | ||
1588 | |||
1589 | 74951 | static void mvp_add_difference(MotionInfo *mi, const int num_cp_mv, | |
1590 | const Mv mvds[2][MAX_CONTROL_POINTS], const int amvr_shift) | ||
1591 | { | ||
1592 |
2/2✓ Branch 0 taken 149902 times.
✓ Branch 1 taken 74951 times.
|
224853 | for (int i = 0; i < 2; i++) { |
1593 | 149902 | const PredFlag mask = i + PF_L0; | |
1594 |
2/2✓ Branch 0 taken 95525 times.
✓ Branch 1 taken 54377 times.
|
149902 | if (mi->pred_flag & mask) { |
1595 |
2/2✓ Branch 0 taken 113072 times.
✓ Branch 1 taken 95525 times.
|
208597 | for (int j = 0; j < num_cp_mv; j++) { |
1596 | 113072 | const Mv *mvd = &mvds[i][j]; | |
1597 | 113072 | mi->mv[i][j].x += mvd->x * (1 << amvr_shift); | |
1598 | 113072 | mi->mv[i][j].y += mvd->y * (1 << amvr_shift); | |
1599 | } | ||
1600 | } | ||
1601 | } | ||
1602 | 74951 | } | |
1603 | |||
1604 | 17036 | static int mvp_data_ibc(VVCLocalContext *lc) | |
1605 | { | ||
1606 | 17036 | const VVCFrameContext *fc = lc->fc; | |
1607 | 17036 | const CodingUnit *cu = lc->cu; | |
1608 | 17036 | const PredictionUnit *pu = &lc->cu->pu; | |
1609 | 17036 | const VVCSPS *sps = fc->ps.sps; | |
1610 | 17036 | MotionInfo *mi = &lc->cu->pu.mi; | |
1611 | 17036 | int mvp_l0_flag = 0; | |
1612 | 17036 | int amvr_shift = 4; | |
1613 | 17036 | Mv *mv = &mi->mv[L0][0]; | |
1614 | int ret; | ||
1615 | |||
1616 | 17036 | mi->pred_flag = PF_IBC; | |
1617 | 17036 | mi->num_sb_x = 1; | |
1618 | 17036 | mi->num_sb_y = 1; | |
1619 | |||
1620 | 17036 | hls_mvd_coding(lc, mv); | |
1621 |
2/2✓ Branch 0 taken 15694 times.
✓ Branch 1 taken 1342 times.
|
17036 | if (sps->max_num_ibc_merge_cand > 1) |
1622 | 15694 | mvp_l0_flag = ff_vvc_mvp_lx_flag(lc); | |
1623 |
5/6✓ Branch 0 taken 17036 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 6941 times.
✓ Branch 4 taken 2942 times.
✓ Branch 5 taken 7153 times.
|
17036 | if (sps->r->sps_amvr_enabled_flag && (mv->x || mv->y)) |
1624 | 9883 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, 1); | |
1625 | |||
1626 | 17036 | ret = ff_vvc_mvp_ibc(lc, mvp_l0_flag, amvr_shift, mv); | |
1627 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17036 times.
|
17036 | if (ret) |
1628 | ✗ | return ret; | |
1629 | 17036 | ff_vvc_store_mv(lc, mi); | |
1630 | |||
1631 | 17036 | return 0; | |
1632 | } | ||
1633 | |||
1634 | 74951 | static int mvp_data(VVCLocalContext *lc) | |
1635 | { | ||
1636 | 74951 | const VVCFrameContext *fc = lc->fc; | |
1637 | 74951 | const CodingUnit *cu = lc->cu; | |
1638 | 74951 | PredictionUnit *pu = &lc->cu->pu; | |
1639 | 74951 | const VVCSPS *sps = fc->ps.sps; | |
1640 | 74951 | const VVCPH *ph = &fc->ps.ph; | |
1641 | 74951 | const VVCSH *sh = &lc->sc->sh; | |
1642 | 74951 | const H266RawSliceHeader *rsh = sh->r; | |
1643 | 74951 | MotionInfo *mi = &pu->mi; | |
1644 | 74951 | const int cb_width = cu->cb_width; | |
1645 | 74951 | const int cb_height = cu->cb_height; | |
1646 | |||
1647 | 74951 | int mvp_lx_flag[2] = {0}; | |
1648 | 74951 | int cu_affine_type_flag = 0; | |
1649 | int num_cp_mv; | ||
1650 | 74951 | int amvr_enabled, has_no_zero_mvd = 0, amvr_shift; | |
1651 | Mv mvds[2][MAX_CONTROL_POINTS]; | ||
1652 | |||
1653 | 74951 | mi->pred_flag = ff_vvc_pred_flag(lc, IS_B(rsh)); | |
1654 |
5/6✓ Branch 0 taken 74951 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40853 times.
✓ Branch 3 taken 34098 times.
✓ Branch 4 taken 28656 times.
✓ Branch 5 taken 12197 times.
|
74951 | if (sps->r->sps_affine_enabled_flag && cb_width >= 16 && cb_height >= 16) { |
1655 | 28656 | pu->inter_affine_flag = ff_vvc_inter_affine_flag(lc); | |
1656 | 28656 | set_cb_tab(lc, fc->tab.iaf, pu->inter_affine_flag); | |
1657 |
4/4✓ Branch 0 taken 26310 times.
✓ Branch 1 taken 2346 times.
✓ Branch 2 taken 9103 times.
✓ Branch 3 taken 17207 times.
|
28656 | if (sps->r->sps_6param_affine_enabled_flag && pu->inter_affine_flag) |
1658 | 9103 | cu_affine_type_flag = ff_vvc_cu_affine_type_flag(lc); | |
1659 | } | ||
1660 | 74951 | mi->motion_model_idc = pu->inter_affine_flag + cu_affine_type_flag; | |
1661 | 74951 | num_cp_mv = mi->motion_model_idc + 1; | |
1662 | |||
1663 |
4/4✓ Branch 0 taken 62982 times.
✓ Branch 1 taken 11969 times.
✓ Branch 2 taken 52942 times.
✓ Branch 3 taken 10040 times.
|
74951 | if (sps->r->sps_smvd_enabled_flag && !ph->r->ph_mvd_l1_zero_flag && |
1664 |
4/4✓ Branch 0 taken 15224 times.
✓ Branch 1 taken 37718 times.
✓ Branch 2 taken 13921 times.
✓ Branch 3 taken 1303 times.
|
52942 | mi->pred_flag == PF_BI && !pu->inter_affine_flag && |
1665 |
4/4✓ Branch 0 taken 12823 times.
✓ Branch 1 taken 1098 times.
✓ Branch 2 taken 12092 times.
✓ Branch 3 taken 731 times.
|
13921 | sh->ref_idx_sym[0] > -1 && sh->ref_idx_sym[1] > -1) |
1666 | 12092 | pu->sym_mvd_flag = ff_vvc_sym_mvd_flag(lc); | |
1667 | |||
1668 |
2/2✓ Branch 0 taken 149902 times.
✓ Branch 1 taken 74951 times.
|
224853 | for (int i = L0; i <= L1; i++) { |
1669 |
2/2✓ Branch 0 taken 74951 times.
✓ Branch 1 taken 74951 times.
|
149902 | const PredFlag pred_flag = PF_L0 + !i; |
1670 |
2/2✓ Branch 0 taken 95525 times.
✓ Branch 1 taken 54377 times.
|
149902 | if (mi->pred_flag != pred_flag) { |
1671 | 95525 | mi->ref_idx[i] = ref_idx_decode(lc, sh, pu->sym_mvd_flag, i); | |
1672 | 95525 | has_no_zero_mvd |= mvds_decode(lc, mvds, num_cp_mv, i); | |
1673 | 95525 | mvp_lx_flag[i] = ff_vvc_mvp_lx_flag(lc); | |
1674 | } | ||
1675 | } | ||
1676 | |||
1677 | 149902 | amvr_enabled = mi->motion_model_idc == MOTION_TRANSLATION ? | |
1678 |
2/2✓ Branch 0 taken 65004 times.
✓ Branch 1 taken 9947 times.
|
74951 | sps->r->sps_amvr_enabled_flag : sps->r->sps_affine_amvr_enabled_flag; |
1679 | 74951 | amvr_enabled &= has_no_zero_mvd; | |
1680 | |||
1681 | 74951 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, amvr_enabled); | |
1682 | |||
1683 | 74951 | mi->hpel_if_idx = amvr_shift == 3; | |
1684 | 74951 | mi->bcw_idx = bcw_idx_decode(lc, mi, cb_width, cb_height); | |
1685 | |||
1686 |
2/2✓ Branch 0 taken 9947 times.
✓ Branch 1 taken 65004 times.
|
74951 | if (mi->motion_model_idc) |
1687 | 9947 | ff_vvc_affine_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
1688 | else | ||
1689 | 65004 | ff_vvc_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
1690 | |||
1691 | 74951 | mvp_add_difference(mi, num_cp_mv, mvds, amvr_shift); | |
1692 | |||
1693 |
2/2✓ Branch 0 taken 9947 times.
✓ Branch 1 taken 65004 times.
|
74951 | if (mi->motion_model_idc) |
1694 | 9947 | ff_vvc_store_sb_mvs(lc, pu); | |
1695 | else | ||
1696 | 65004 | ff_vvc_store_mv(lc, &pu->mi); | |
1697 | |||
1698 | 74951 | return 0; | |
1699 | } | ||
1700 | |||
1701 | // derive bdofFlag from 8.5.6 Decoding process for inter blocks | ||
1702 | // derive dmvr from 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
1703 | 338415 | static void derive_dmvr_bdof_flag(const VVCLocalContext *lc, PredictionUnit *pu) | |
1704 | { | ||
1705 | 338415 | const VVCFrameContext *fc = lc->fc; | |
1706 | 338415 | const VVCPPS *pps = fc->ps.pps; | |
1707 | 338415 | const VVCPH *ph = &fc->ps.ph; | |
1708 | 338415 | const VVCSH *sh = &lc->sc->sh; | |
1709 | 338415 | const int poc = ph->poc; | |
1710 | 338415 | const MotionInfo *mi = &pu->mi; | |
1711 | 338415 | const int8_t *ref_idx = mi->ref_idx; | |
1712 | 338415 | const VVCRefPic *rp0 = &lc->sc->rpl[L0].refs[ref_idx[L0]]; | |
1713 | 338415 | const VVCRefPic *rp1 = &lc->sc->rpl[L1].refs[ref_idx[L1]]; | |
1714 | 338415 | const CodingUnit *cu = lc->cu; | |
1715 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 338415 times.
|
338415 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt; |
1716 | |||
1717 | 338415 | pu->bdof_flag = 0; | |
1718 | |||
1719 |
2/2✓ Branch 0 taken 175583 times.
✓ Branch 1 taken 162832 times.
|
338415 | if (mi->pred_flag == PF_BI && |
1720 |
2/2✓ Branch 0 taken 117784 times.
✓ Branch 1 taken 57799 times.
|
175583 | (poc - rp0->poc == rp1->poc - poc) && |
1721 |
4/4✓ Branch 0 taken 117726 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 117693 times.
✓ Branch 3 taken 33 times.
|
117784 | !rp0->is_lt && !rp1->is_lt && |
1722 |
2/2✓ Branch 0 taken 114965 times.
✓ Branch 1 taken 2728 times.
|
117693 | !cu->ciip_flag && |
1723 |
2/2✓ Branch 0 taken 101469 times.
✓ Branch 1 taken 13496 times.
|
114965 | !mi->bcw_idx && |
1724 |
4/4✓ Branch 0 taken 100355 times.
✓ Branch 1 taken 1114 times.
✓ Branch 2 taken 100354 times.
✓ Branch 3 taken 1 times.
|
101469 | !w->weight_flag[L0][LUMA][ref_idx[L0]] && !w->weight_flag[L1][LUMA][ref_idx[L1]] && |
1725 |
4/4✓ Branch 0 taken 100336 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 100321 times.
✓ Branch 3 taken 15 times.
|
100354 | !w->weight_flag[L0][CHROMA][ref_idx[L0]] && !w->weight_flag[L1][CHROMA][ref_idx[L1]] && |
1726 |
4/4✓ Branch 0 taken 94569 times.
✓ Branch 1 taken 5752 times.
✓ Branch 2 taken 90981 times.
✓ Branch 3 taken 3588 times.
|
100321 | cu->cb_width >= 8 && cu->cb_height >= 8 && |
1727 |
2/2✓ Branch 0 taken 85083 times.
✓ Branch 1 taken 5898 times.
|
90981 | (cu->cb_width * cu->cb_height >= 128) && |
1728 |
2/4✓ Branch 0 taken 85083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85083 times.
✗ Branch 3 not taken.
|
85083 | !rp0->is_scaled && !rp1->is_scaled) { |
1729 |
2/2✓ Branch 0 taken 83054 times.
✓ Branch 1 taken 2029 times.
|
85083 | if (!ph->r->ph_bdof_disabled_flag && |
1730 |
1/2✓ Branch 0 taken 83054 times.
✗ Branch 1 not taken.
|
83054 | mi->motion_model_idc == MOTION_TRANSLATION && |
1731 |
1/2✓ Branch 0 taken 83054 times.
✗ Branch 1 not taken.
|
83054 | !pu->merge_subblock_flag && |
1732 |
2/2✓ Branch 0 taken 80244 times.
✓ Branch 1 taken 2810 times.
|
83054 | !pu->sym_mvd_flag) |
1733 | 80244 | pu->bdof_flag = 1; | |
1734 |
2/2✓ Branch 0 taken 80597 times.
✓ Branch 1 taken 4486 times.
|
85083 | if (!ph->r->ph_dmvr_disabled_flag && |
1735 |
2/2✓ Branch 0 taken 75272 times.
✓ Branch 1 taken 5325 times.
|
80597 | pu->general_merge_flag && |
1736 |
2/2✓ Branch 0 taken 68245 times.
✓ Branch 1 taken 7027 times.
|
75272 | !pu->mmvd_merge_flag) |
1737 | 68245 | pu->dmvr_flag = 1; | |
1738 | } | ||
1739 | 338415 | } | |
1740 | |||
1741 | // part of 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
1742 | 338415 | static void refine_regular_subblock(const VVCLocalContext *lc) | |
1743 | { | ||
1744 | 338415 | const CodingUnit *cu = lc->cu; | |
1745 | 338415 | PredictionUnit *pu = &lc->cu->pu; | |
1746 | |||
1747 | 338415 | derive_dmvr_bdof_flag(lc, pu); | |
1748 |
4/4✓ Branch 0 taken 270170 times.
✓ Branch 1 taken 68245 times.
✓ Branch 2 taken 11999 times.
✓ Branch 3 taken 258171 times.
|
338415 | if (pu->dmvr_flag || pu->bdof_flag) { |
1749 |
2/2✓ Branch 0 taken 47422 times.
✓ Branch 1 taken 32822 times.
|
80244 | pu->mi.num_sb_x = (cu->cb_width > 16) ? (cu->cb_width >> 4) : 1; |
1750 |
2/2✓ Branch 0 taken 45341 times.
✓ Branch 1 taken 34903 times.
|
80244 | pu->mi.num_sb_y = (cu->cb_height > 16) ? (cu->cb_height >> 4) : 1; |
1751 | } | ||
1752 | 338415 | } | |
1753 | |||
1754 | 387003 | static void fill_dmvr_info(const VVCLocalContext *lc) | |
1755 | { | ||
1756 | 387003 | const VVCFrameContext *fc = lc->fc; | |
1757 | 387003 | const CodingUnit *cu = lc->cu; | |
1758 | |||
1759 |
2/2✓ Branch 0 taken 31182 times.
✓ Branch 1 taken 355821 times.
|
387003 | if (cu->pred_mode == MODE_IBC) { |
1760 | 31182 | ff_vvc_set_intra_mvf(lc, 1); | |
1761 | } else { | ||
1762 | 355821 | const VVCPPS *pps = fc->ps.pps; | |
1763 | 355821 | const int w = cu->cb_width >> MIN_PU_LOG2; | |
1764 | |||
1765 |
2/2✓ Branch 0 taken 1996451 times.
✓ Branch 1 taken 355821 times.
|
2352272 | for (int y = cu->y0 >> MIN_PU_LOG2; y < (cu->y0 + cu->cb_height) >> MIN_PU_LOG2; y++) { |
1766 | 1996451 | const int idx = pps->min_pu_width * y + (cu->x0 >> MIN_PU_LOG2); | |
1767 | 1996451 | const MvField *mvf = fc->tab.mvf + idx; | |
1768 | 1996451 | MvField *dmvr_mvf = fc->ref->tab_dmvr_mvf + idx; | |
1769 | |||
1770 | 1996451 | memcpy(dmvr_mvf, mvf, sizeof(MvField) * w); | |
1771 | } | ||
1772 | } | ||
1773 | 387003 | } | |
1774 | |||
1775 | 455248 | static int inter_data(VVCLocalContext *lc) | |
1776 | { | ||
1777 | 455248 | const CodingUnit *cu = lc->cu; | |
1778 | 455248 | PredictionUnit *pu = &lc->cu->pu; | |
1779 | 455248 | const MotionInfo *mi = &pu->mi; | |
1780 | 455248 | int ret = 0; | |
1781 | |||
1782 | 455248 | pu->general_merge_flag = 1; | |
1783 |
2/2✓ Branch 0 taken 209686 times.
✓ Branch 1 taken 245562 times.
|
455248 | if (!cu->skip_flag) |
1784 | 209686 | pu->general_merge_flag = ff_vvc_general_merge_flag(lc); | |
1785 | |||
1786 |
2/2✓ Branch 0 taken 363261 times.
✓ Branch 1 taken 91987 times.
|
455248 | if (pu->general_merge_flag) { |
1787 | 363261 | ret = hls_merge_data(lc); | |
1788 |
2/2✓ Branch 0 taken 17036 times.
✓ Branch 1 taken 74951 times.
|
91987 | } else if (cu->pred_mode == MODE_IBC) { |
1789 | 17036 | ret = mvp_data_ibc(lc); | |
1790 | } else { | ||
1791 | 74951 | ret = mvp_data(lc); | |
1792 | } | ||
1793 | |||
1794 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 455248 times.
|
455248 | if (ret) |
1795 | ✗ | return ret; | |
1796 | |||
1797 |
2/2✓ Branch 0 taken 31182 times.
✓ Branch 1 taken 424066 times.
|
455248 | if (cu->pred_mode == MODE_IBC) { |
1798 | 31182 | ff_vvc_update_hmvp(lc, mi); | |
1799 |
6/6✓ Branch 0 taken 398451 times.
✓ Branch 1 taken 25615 times.
✓ Branch 2 taken 363728 times.
✓ Branch 3 taken 34723 times.
✓ Branch 4 taken 338415 times.
✓ Branch 5 taken 25313 times.
|
424066 | } else if (!pu->merge_gpm_flag && !pu->inter_affine_flag && !pu->merge_subblock_flag) { |
1800 | 338415 | refine_regular_subblock(lc); | |
1801 | 338415 | ff_vvc_update_hmvp(lc, mi); | |
1802 | } | ||
1803 | |||
1804 |
2/2✓ Branch 0 taken 387003 times.
✓ Branch 1 taken 68245 times.
|
455248 | if (!pu->dmvr_flag) |
1805 | 387003 | fill_dmvr_info(lc); | |
1806 | 455248 | return ret; | |
1807 | } | ||
1808 | |||
1809 | 1232069 | static int hls_coding_unit(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, | |
1810 | int cqt_depth, const VVCTreeType tree_type, VVCModeType mode_type) | ||
1811 | { | ||
1812 | 1232069 | const VVCFrameContext *fc = lc->fc; | |
1813 | 1232069 | const VVCSPS *sps = fc->ps.sps; | |
1814 | 1232069 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1815 | 1232069 | const int hs = sps->hshift[CHROMA]; | |
1816 | 1232069 | const int vs = sps->vshift[CHROMA]; | |
1817 |
4/4✓ Branch 0 taken 1209760 times.
✓ Branch 1 taken 22309 times.
✓ Branch 2 taken 2293 times.
✓ Branch 3 taken 1207467 times.
|
1232069 | const int is_128 = cb_width > 64 || cb_height > 64; |
1818 | 1232069 | int pred_mode_plt_flag = 0; | |
1819 | int ret; | ||
1820 | |||
1821 | 1232069 | CodingUnit *cu = add_cu(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type); | |
1822 | |||
1823 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1232069 times.
|
1232069 | if (!cu) |
1824 | ✗ | return AVERROR(ENOMEM); | |
1825 | |||
1826 | 1232069 | ff_vvc_set_neighbour_available(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
1827 | |||
1828 |
3/4✓ Branch 0 taken 648328 times.
✓ Branch 1 taken 583741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 648328 times.
|
1232069 | if (IS_I(rsh) && is_128) |
1829 | ✗ | mode_type = MODE_TYPE_INTRA; | |
1830 | 1232069 | cu->pred_mode = pred_mode_decode(lc, tree_type, mode_type); | |
1831 | |||
1832 |
3/10✓ Branch 0 taken 776821 times.
✓ Branch 1 taken 455248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 776821 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.
|
1232069 | if (cu->pred_mode == MODE_INTRA && sps->r->sps_palette_enabled_flag && !is_128 && !cu->skip_flag && |
1833 | ✗ | mode_type != MODE_TYPE_INTER && ((cb_width * cb_height) > | |
1834 | ✗ | (tree_type != DUAL_TREE_CHROMA ? 16 : (16 << hs << vs))) && | |
1835 | ✗ | (mode_type != MODE_TYPE_INTRA || tree_type != DUAL_TREE_CHROMA)) { | |
1836 | ✗ | pred_mode_plt_flag = ff_vvc_pred_mode_plt_flag(lc); | |
1837 | ✗ | if (pred_mode_plt_flag) { | |
1838 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1839 | ✗ | return AVERROR_PATCHWELCOME; | |
1840 | } | ||
1841 | } | ||
1842 |
3/6✓ Branch 0 taken 776821 times.
✓ Branch 1 taken 455248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 776821 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1232069 | if (cu->pred_mode == MODE_INTRA && sps->r->sps_act_enabled_flag && tree_type == SINGLE_TREE) { |
1843 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Adaptive Color Transform"); | |
1844 | ✗ | return AVERROR_PATCHWELCOME; | |
1845 | } | ||
1846 |
3/4✓ Branch 0 taken 455248 times.
✓ Branch 1 taken 776821 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 455248 times.
|
1232069 | if (cu->pred_mode == MODE_INTRA || cu->pred_mode == MODE_PLT) { |
1847 |
4/4✓ Branch 0 taken 715473 times.
✓ Branch 1 taken 61348 times.
✓ Branch 2 taken 534712 times.
✓ Branch 3 taken 180761 times.
|
776821 | if (tree_type == SINGLE_TREE || tree_type == DUAL_TREE_LUMA) { |
1848 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 596060 times.
|
596060 | if (pred_mode_plt_flag) { |
1849 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1850 | ✗ | return AVERROR_PATCHWELCOME; | |
1851 | } else { | ||
1852 | 596060 | intra_luma_pred_modes(lc); | |
1853 | } | ||
1854 | 596060 | ff_vvc_set_intra_mvf(lc, 0); | |
1855 | } | ||
1856 |
6/6✓ Branch 0 taken 715473 times.
✓ Branch 1 taken 61348 times.
✓ Branch 2 taken 180761 times.
✓ Branch 3 taken 534712 times.
✓ Branch 4 taken 226987 times.
✓ Branch 5 taken 15122 times.
|
776821 | if ((tree_type == SINGLE_TREE || tree_type == DUAL_TREE_CHROMA) && sps->r->sps_chroma_format_idc) { |
1857 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 226987 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
226987 | if (pred_mode_plt_flag && tree_type == DUAL_TREE_CHROMA) { |
1858 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Palette"); | |
1859 | ✗ | return AVERROR_PATCHWELCOME; | |
1860 |
1/2✓ Branch 0 taken 226987 times.
✗ Branch 1 not taken.
|
226987 | } else if (!pred_mode_plt_flag) { |
1861 |
1/2✓ Branch 0 taken 226987 times.
✗ Branch 1 not taken.
|
226987 | if (!cu->act_enabled_flag) |
1862 | 226987 | intra_chroma_pred_modes(lc); | |
1863 | } | ||
1864 | } | ||
1865 |
1/2✓ Branch 0 taken 455248 times.
✗ Branch 1 not taken.
|
455248 | } else if (tree_type != DUAL_TREE_CHROMA) { /* MODE_INTER or MODE_IBC */ |
1866 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 455248 times.
|
455248 | if ((ret = inter_data(lc)) < 0) |
1867 | ✗ | return ret; | |
1868 | } | ||
1869 |
5/6✓ Branch 0 taken 455248 times.
✓ Branch 1 taken 776821 times.
✓ Branch 2 taken 455248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 91987 times.
✓ Branch 5 taken 363261 times.
|
1232069 | if (cu->pred_mode != MODE_INTRA && !pred_mode_plt_flag && !lc->cu->pu.general_merge_flag) |
1870 | 91987 | cu->coded_flag = ff_vvc_cu_coded_flag(lc); | |
1871 | else | ||
1872 |
3/4✓ Branch 0 taken 894520 times.
✓ Branch 1 taken 245562 times.
✓ Branch 2 taken 894520 times.
✗ Branch 3 not taken.
|
1140082 | cu->coded_flag = !(cu->skip_flag || pred_mode_plt_flag); |
1873 | |||
1874 |
2/2✓ Branch 0 taken 937235 times.
✓ Branch 1 taken 294834 times.
|
1232069 | if (cu->coded_flag) { |
1875 | 937235 | sbt_info(lc, sps); | |
1876 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 937235 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
937235 | if (sps->r->sps_act_enabled_flag && cu->pred_mode != MODE_INTRA && tree_type == SINGLE_TREE) { |
1877 | ✗ | avpriv_report_missing_feature(fc->log_ctx, "Adaptive Color Transform"); | |
1878 | ✗ | return AVERROR_PATCHWELCOME; | |
1879 | } | ||
1880 | 937235 | lc->parse.lfnst_dc_only = 1; | |
1881 | 937235 | lc->parse.lfnst_zero_out_sig_coeff_flag = 1; | |
1882 | 937235 | lc->parse.mts_dc_only = 1; | |
1883 | 937235 | lc->parse.mts_zero_out_sig_coeff_flag = 1; | |
1884 | 937235 | ret = hls_transform_tree(lc, x0, y0, cb_width, cb_height, cu->ch_type); | |
1885 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 937235 times.
|
937235 | if (ret < 0) |
1886 | ✗ | return ret; | |
1887 | 937235 | cu->lfnst_idx = lfnst_idx_decode(lc); | |
1888 | 937235 | cu->mts_idx = mts_idx_decode(lc); | |
1889 | 937235 | set_qp_c(lc); | |
1890 | } else { | ||
1891 | 294834 | ret = skipped_transform_tree_unit(lc); | |
1892 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 294834 times.
|
294834 | if (ret < 0) |
1893 | ✗ | return ret; | |
1894 | } | ||
1895 | 1232069 | set_cu_tabs(lc, cu); | |
1896 | |||
1897 | 1232069 | return 0; | |
1898 | } | ||
1899 | |||
1900 | 798524 | static int derive_mode_type_condition(const VVCLocalContext *lc, | |
1901 | const VVCSplitMode split, const int cb_width, const int cb_height, const VVCModeType mode_type_curr) | ||
1902 | { | ||
1903 | 798524 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
1904 | 798524 | const VVCSPS *sps = lc->fc->ps.sps; | |
1905 | 798524 | const int area = cb_width * cb_height; | |
1906 | |||
1907 |
6/6✓ Branch 0 taken 434535 times.
✓ Branch 1 taken 363989 times.
✓ Branch 2 taken 10978 times.
✓ Branch 3 taken 423557 times.
✓ Branch 4 taken 340623 times.
✓ Branch 5 taken 34344 times.
|
798524 | if ((IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) || |
1908 |
2/2✓ Branch 0 taken 316444 times.
✓ Branch 1 taken 24179 times.
|
340623 | mode_type_curr != MODE_TYPE_ALL || !sps->r->sps_chroma_format_idc || |
1909 |
2/2✓ Branch 0 taken 41943 times.
✓ Branch 1 taken 274501 times.
|
316444 | sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
1910 | 524023 | return 0; | |
1911 |
8/10✓ Branch 0 taken 20837 times.
✓ Branch 1 taken 253664 times.
✓ Branch 2 taken 18554 times.
✓ Branch 3 taken 2283 times.
✓ Branch 4 taken 18554 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15678 times.
✓ Branch 7 taken 2876 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 269342 times.
|
274501 | if ((area == 64 && (split == SPLIT_QT || split == SPLIT_TT_HOR || split == SPLIT_TT_VER)) || |
1912 | ✗ | (area == 32 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER))) | |
1913 | 5159 | return 1; | |
1914 |
8/10✓ Branch 0 taken 15678 times.
✓ Branch 1 taken 253664 times.
✓ Branch 2 taken 10067 times.
✓ Branch 3 taken 5611 times.
✓ Branch 4 taken 10067 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 15678 times.
✓ Branch 8 taken 30659 times.
✓ Branch 9 taken 223005 times.
|
269342 | if ((area == 64 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
1915 |
7/8✓ Branch 0 taken 27262 times.
✓ Branch 1 taken 3397 times.
✓ Branch 2 taken 5439 times.
✓ Branch 3 taken 21823 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8836 times.
✓ Branch 6 taken 21471 times.
✓ Branch 7 taken 223357 times.
|
253664 | (area == 128 && (split == SPLIT_TT_HOR || split == SPLIT_TT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
1916 |
6/6✓ Branch 0 taken 14300 times.
✓ Branch 1 taken 7171 times.
✓ Branch 2 taken 69699 times.
✓ Branch 3 taken 167958 times.
✓ Branch 4 taken 9832 times.
✓ Branch 5 taken 59867 times.
|
244828 | (cb_width == 8 && split == SPLIT_BT_VER) || (cb_width == 16 && split == SPLIT_TT_VER)) |
1917 |
2/2✓ Branch 0 taken 41362 times.
✓ Branch 1 taken 155 times.
|
41517 | return 1 + !IS_I(rsh); |
1918 | |||
1919 | 227825 | return 0; | |
1920 | } | ||
1921 | |||
1922 | 798524 | static VVCModeType mode_type_decode(VVCLocalContext *lc, const int x0, const int y0, | |
1923 | const int cb_width, const int cb_height, const VVCSplitMode split, const int ch_type, | ||
1924 | const VVCModeType mode_type_curr) | ||
1925 | { | ||
1926 | VVCModeType mode_type; | ||
1927 | 798524 | const int mode_type_condition = derive_mode_type_condition(lc, split, cb_width, cb_height, mode_type_curr); | |
1928 | |||
1929 |
2/2✓ Branch 0 taken 5314 times.
✓ Branch 1 taken 793210 times.
|
798524 | if (mode_type_condition == 1) |
1930 | 5314 | mode_type = MODE_TYPE_INTRA; | |
1931 |
2/2✓ Branch 0 taken 41362 times.
✓ Branch 1 taken 751848 times.
|
793210 | else if (mode_type_condition == 2) { |
1932 |
2/2✓ Branch 1 taken 19181 times.
✓ Branch 2 taken 22181 times.
|
41362 | mode_type = ff_vvc_non_inter_flag(lc, x0, y0, ch_type) ? MODE_TYPE_INTRA : MODE_TYPE_INTER; |
1933 | } else { | ||
1934 | 751848 | mode_type = mode_type_curr; | |
1935 | } | ||
1936 | |||
1937 | 798524 | return mode_type; | |
1938 | } | ||
1939 | |||
1940 | static int hls_coding_tree(VVCLocalContext *lc, | ||
1941 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1942 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
1943 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr); | ||
1944 | |||
1945 | 240125 | static int coding_tree_btv(VVCLocalContext *lc, | |
1946 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1947 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1948 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1949 | { | ||
1950 | #define CODING_TREE(x, idx) do { \ | ||
1951 | ret = hls_coding_tree(lc, x, y0, cb_width / 2, cb_height, \ | ||
1952 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
1953 | depth_offset, idx, SPLIT_BT_VER, tree_type, mode_type); \ | ||
1954 | if (ret < 0) \ | ||
1955 | return ret; \ | ||
1956 | } while (0); | ||
1957 | |||
1958 | 240125 | const VVCPPS *pps = lc->fc->ps.pps; | |
1959 | 240125 | const int x1 = x0 + cb_width / 2; | |
1960 | 240125 | int ret = 0; | |
1961 | |||
1962 | 240125 | depth_offset += (x0 + cb_width > pps->width) ? 1 : 0; | |
1963 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 240125 times.
|
240125 | CODING_TREE(x0, 0); |
1964 |
2/2✓ Branch 0 taken 238694 times.
✓ Branch 1 taken 1431 times.
|
240125 | if (x1 < pps->width) |
1965 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 238694 times.
|
238694 | CODING_TREE(x1, 1); |
1966 | |||
1967 | 240125 | return 0; | |
1968 | |||
1969 | #undef CODING_TREE | ||
1970 | } | ||
1971 | |||
1972 | 293921 | static int coding_tree_bth(VVCLocalContext *lc, | |
1973 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
1974 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
1975 | VVCTreeType tree_type, VVCModeType mode_type) | ||
1976 | { | ||
1977 | #define CODING_TREE(y, idx) do { \ | ||
1978 | ret = hls_coding_tree(lc, x0, y, cb_width , cb_height / 2, \ | ||
1979 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
1980 | depth_offset, idx, SPLIT_BT_HOR, tree_type, mode_type); \ | ||
1981 | if (ret < 0) \ | ||
1982 | return ret; \ | ||
1983 | } while (0); | ||
1984 | |||
1985 | 293921 | const VVCPPS *pps = lc->fc->ps.pps; | |
1986 | 293921 | const int y1 = y0 + (cb_height / 2); | |
1987 | 293921 | int ret = 0; | |
1988 | |||
1989 | 293921 | depth_offset += (y0 + cb_height > pps->height) ? 1 : 0; | |
1990 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 293921 times.
|
293921 | CODING_TREE(y0, 0); |
1991 |
2/2✓ Branch 0 taken 276310 times.
✓ Branch 1 taken 17611 times.
|
293921 | if (y1 < pps->height) |
1992 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 276310 times.
|
276310 | CODING_TREE(y1, 1); |
1993 | |||
1994 | 293921 | return 0; | |
1995 | |||
1996 | #undef CODING_TREE | ||
1997 | } | ||
1998 | |||
1999 | 80720 | static int coding_tree_ttv(VVCLocalContext *lc, | |
2000 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2001 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2002 | VVCTreeType tree_type, VVCModeType mode_type) | ||
2003 | { | ||
2004 | #define CODING_TREE(x, w, sub_div, idx) do { \ | ||
2005 | ret = hls_coding_tree(lc, x, y0, w, cb_height, \ | ||
2006 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
2007 | depth_offset, idx, SPLIT_TT_VER, tree_type, mode_type); \ | ||
2008 | if (ret < 0) \ | ||
2009 | return ret; \ | ||
2010 | } while (0); | ||
2011 | |||
2012 | 80720 | const VVCSH *sh = &lc->sc->sh; | |
2013 | 80720 | const int x1 = x0 + cb_width / 4; | |
2014 | 80720 | const int x2 = x0 + cb_width * 3 / 4; | |
2015 | int ret; | ||
2016 | |||
2017 |
3/4✓ Branch 0 taken 47214 times.
✓ Branch 1 taken 33506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47214 times.
|
80720 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
2018 |
3/4✓ Branch 0 taken 33927 times.
✓ Branch 1 taken 46793 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33927 times.
|
80720 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
2019 | |||
2020 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80720 times.
|
80720 | CODING_TREE(x0, cb_width / 4, cb_sub_div + 2, 0); |
2021 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80720 times.
|
80720 | CODING_TREE(x1, cb_width / 2, cb_sub_div + 1, 1); |
2022 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80720 times.
|
80720 | CODING_TREE(x2, cb_width / 4, cb_sub_div + 2, 2); |
2023 | |||
2024 | 80720 | return 0; | |
2025 | |||
2026 | #undef CODING_TREE | ||
2027 | } | ||
2028 | |||
2029 | 84287 | static int coding_tree_tth(VVCLocalContext *lc, | |
2030 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2031 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2032 | VVCTreeType tree_type, VVCModeType mode_type) | ||
2033 | { | ||
2034 | #define CODING_TREE(y, h, sub_div, idx) do { \ | ||
2035 | ret = hls_coding_tree(lc, x0, y, cb_width, h, \ | ||
2036 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
2037 | depth_offset, idx, SPLIT_TT_HOR, tree_type, mode_type); \ | ||
2038 | if (ret < 0) \ | ||
2039 | return ret; \ | ||
2040 | } while (0); | ||
2041 | |||
2042 | 84287 | const VVCSH *sh = &lc->sc->sh; | |
2043 | 84287 | const int y1 = y0 + (cb_height / 4); | |
2044 | 84287 | const int y2 = y0 + (3 * cb_height / 4); | |
2045 | int ret; | ||
2046 | |||
2047 |
3/4✓ Branch 0 taken 47676 times.
✓ Branch 1 taken 36611 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47676 times.
|
84287 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
2048 |
3/4✓ Branch 0 taken 30107 times.
✓ Branch 1 taken 54180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30107 times.
|
84287 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
2049 | |||
2050 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84287 times.
|
84287 | CODING_TREE(y0, cb_height / 4, cb_sub_div + 2, 0); |
2051 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84287 times.
|
84287 | CODING_TREE(y1, cb_height / 2, cb_sub_div + 1, 1); |
2052 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84287 times.
|
84287 | CODING_TREE(y2, cb_height / 4, cb_sub_div + 2, 2); |
2053 | |||
2054 | 84287 | return 0; | |
2055 | |||
2056 | #undef CODING_TREE | ||
2057 | } | ||
2058 | |||
2059 | 99471 | static int coding_tree_qt(VVCLocalContext *lc, | |
2060 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2061 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2062 | VVCTreeType tree_type, VVCModeType mode_type) | ||
2063 | { | ||
2064 | #define CODING_TREE(x, y, idx) do { \ | ||
2065 | ret = hls_coding_tree(lc, x, y, cb_width / 2, cb_height / 2, \ | ||
2066 | qg_on_y, qg_on_c, cb_sub_div + 2, cqt_depth + 1, 0, 0, \ | ||
2067 | idx, SPLIT_QT, tree_type, mode_type); \ | ||
2068 | if (ret < 0) \ | ||
2069 | return ret; \ | ||
2070 | } while (0); | ||
2071 | |||
2072 | 99471 | const VVCPPS *pps = lc->fc->ps.pps; | |
2073 | 99471 | const int x1 = x0 + cb_width / 2; | |
2074 | 99471 | const int y1 = y0 + cb_height / 2; | |
2075 | 99471 | int ret = 0; | |
2076 | |||
2077 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 99471 times.
|
99471 | CODING_TREE(x0, y0, 0); |
2078 |
2/2✓ Branch 0 taken 96292 times.
✓ Branch 1 taken 3179 times.
|
99471 | if (x1 < pps->width) |
2079 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 96292 times.
|
96292 | CODING_TREE(x1, y0, 1); |
2080 |
2/2✓ Branch 0 taken 93998 times.
✓ Branch 1 taken 5473 times.
|
99471 | if (y1 < pps->height) |
2081 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 93998 times.
|
93998 | CODING_TREE(x0, y1, 2); |
2082 |
2/2✓ Branch 0 taken 96292 times.
✓ Branch 1 taken 3179 times.
|
99471 | if (x1 < pps->width && |
2083 |
2/2✓ Branch 0 taken 90827 times.
✓ Branch 1 taken 5465 times.
|
96292 | y1 < pps->height) |
2084 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 90827 times.
|
90827 | CODING_TREE(x1, y1, 3); |
2085 | |||
2086 | 99471 | return 0; | |
2087 | |||
2088 | #undef CODING_TREE | ||
2089 | } | ||
2090 | |||
2091 | typedef int (*coding_tree_fn)(VVCLocalContext *lc, | ||
2092 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2093 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
2094 | VVCTreeType tree_type, VVCModeType mode_type); | ||
2095 | |||
2096 | const static coding_tree_fn coding_tree[] = { | ||
2097 | coding_tree_tth, | ||
2098 | coding_tree_bth, | ||
2099 | coding_tree_ttv, | ||
2100 | coding_tree_btv, | ||
2101 | coding_tree_qt, | ||
2102 | }; | ||
2103 | |||
2104 | 2030593 | static int hls_coding_tree(VVCLocalContext *lc, | |
2105 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
2106 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
2107 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr) | ||
2108 | { | ||
2109 | 2030593 | VVCFrameContext *fc = lc->fc; | |
2110 | 2030593 | const VVCPPS *pps = fc->ps.pps; | |
2111 | 2030593 | const VVCSH *sh = &lc->sc->sh; | |
2112 | 2030593 | const H266RawSliceHeader *rsh = sh->r; | |
2113 | 2030593 | const int ch_type = tree_type_curr == DUAL_TREE_CHROMA; | |
2114 | int ret; | ||
2115 | VVCAllowedSplit allowed; | ||
2116 | |||
2117 |
6/6✓ Branch 0 taken 280702 times.
✓ Branch 1 taken 1749891 times.
✓ Branch 2 taken 70213 times.
✓ Branch 3 taken 210489 times.
✓ Branch 4 taken 2635 times.
✓ Branch 5 taken 67578 times.
|
2030593 | if (pps->r->pps_cu_qp_delta_enabled_flag && qg_on_y && cb_sub_div <= sh->cu_qp_delta_subdiv) { |
2118 | 2635 | lc->parse.is_cu_qp_delta_coded = 0; | |
2119 | 2635 | lc->parse.cu_qg_top_left_x = x0; | |
2120 | 2635 | lc->parse.cu_qg_top_left_y = y0; | |
2121 | } | ||
2122 |
4/4✓ Branch 0 taken 206481 times.
✓ Branch 1 taken 1824112 times.
✓ Branch 2 taken 17504 times.
✓ Branch 3 taken 188977 times.
|
2030593 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && qg_on_c && |
2123 |
2/2✓ Branch 0 taken 931 times.
✓ Branch 1 taken 16573 times.
|
17504 | cb_sub_div <= sh->cu_chroma_qp_offset_subdiv) { |
2124 | 931 | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
2125 | 931 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2126 | } | ||
2127 | |||
2128 | 2030593 | can_split(lc, x0, y0, cb_width, cb_height, mtt_depth, depth_offset, part_idx, | |
2129 | last_split_mode, tree_type_curr, mode_type_curr, &allowed); | ||
2130 |
2/2✓ Branch 1 taken 798524 times.
✓ Branch 2 taken 1232069 times.
|
2030593 | if (ff_vvc_split_cu_flag(lc, x0, y0, cb_width, cb_height, ch_type, &allowed)) { |
2131 | 798524 | VVCSplitMode split = ff_vvc_split_mode(lc, x0, y0, cb_width, cb_height, cqt_depth, mtt_depth, ch_type, &allowed); | |
2132 | 798524 | VVCModeType mode_type = mode_type_decode(lc, x0, y0, cb_width, cb_height, split, ch_type, mode_type_curr); | |
2133 | |||
2134 |
2/2✓ Branch 0 taken 745496 times.
✓ Branch 1 taken 53028 times.
|
798524 | VVCTreeType tree_type = (mode_type == MODE_TYPE_INTRA) ? DUAL_TREE_LUMA : tree_type_curr; |
2135 | |||
2136 |
2/2✓ Branch 0 taken 699053 times.
✓ Branch 1 taken 99471 times.
|
798524 | if (split != SPLIT_QT) { |
2137 |
6/6✓ Branch 0 taken 425679 times.
✓ Branch 1 taken 273374 times.
✓ Branch 2 taken 277517 times.
✓ Branch 3 taken 148162 times.
✓ Branch 4 taken 233672 times.
✓ Branch 5 taken 43845 times.
|
699053 | if (!(x0 & 31) && !(y0 & 31) && mtt_depth <= 1) |
2138 | 233672 | TAB_MSM(fc, mtt_depth, x0, y0) = split; | |
2139 | } | ||
2140 | 798524 | ret = coding_tree[split - 1](lc, x0, y0, cb_width, cb_height, qg_on_y, qg_on_c, | |
2141 | cb_sub_div, cqt_depth, mtt_depth, depth_offset, tree_type, mode_type); | ||
2142 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 798524 times.
|
798524 | if (ret < 0) |
2143 | ✗ | return ret; | |
2144 |
4/4✓ Branch 0 taken 764180 times.
✓ Branch 1 taken 34344 times.
✓ Branch 2 taken 24495 times.
✓ Branch 3 taken 739685 times.
|
798524 | if (mode_type_curr == MODE_TYPE_ALL && mode_type == MODE_TYPE_INTRA) { |
2145 | 24495 | ret = hls_coding_tree(lc, x0, y0, cb_width, cb_height, 0, qg_on_c, cb_sub_div, | |
2146 | cqt_depth, mtt_depth, 0, 0, split, DUAL_TREE_CHROMA, mode_type); | ||
2147 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24495 times.
|
24495 | if (ret < 0) |
2148 | ✗ | return ret; | |
2149 | } | ||
2150 | } else { | ||
2151 | 1232069 | ret = hls_coding_unit(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type_curr, mode_type_curr); | |
2152 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1232069 times.
|
1232069 | if (ret < 0) |
2153 | ✗ | return ret; | |
2154 | } | ||
2155 | |||
2156 | 2030593 | return 0; | |
2157 | } | ||
2158 | |||
2159 | 25489 | static int dual_tree_implicit_qt_split(VVCLocalContext *lc, | |
2160 | const int x0, const int y0, const int cb_size, const int cqt_depth) | ||
2161 | { | ||
2162 | 25489 | const VVCSH *sh = &lc->sc->sh; | |
2163 | 25489 | const H266RawSliceHeader *rsh = sh->r; | |
2164 | 25489 | const VVCPPS *pps = lc->fc->ps.pps; | |
2165 | 25489 | const int cb_subdiv = 2 * cqt_depth; | |
2166 | int ret; | ||
2167 | |||
2168 |
2/2✓ Branch 0 taken 5276 times.
✓ Branch 1 taken 20213 times.
|
25489 | if (cb_size > 64) { |
2169 | #define DUAL_TREE(x, y) do { \ | ||
2170 | ret = dual_tree_implicit_qt_split(lc, x, y, cb_size / 2, cqt_depth + 1); \ | ||
2171 | if (ret < 0) \ | ||
2172 | return ret; \ | ||
2173 | } while (0) | ||
2174 | |||
2175 | 5276 | const int x1 = x0 + (cb_size / 2); | |
2176 | 5276 | const int y1 = y0 + (cb_size / 2); | |
2177 |
3/4✓ Branch 0 taken 130 times.
✓ Branch 1 taken 5146 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
|
5276 | if (pps->r->pps_cu_qp_delta_enabled_flag && cb_subdiv <= sh->cu_qp_delta_subdiv) { |
2178 | 130 | lc->parse.is_cu_qp_delta_coded = 0; | |
2179 | 130 | lc->parse.cu_qg_top_left_x = x0; | |
2180 | 130 | lc->parse.cu_qg_top_left_y = y0; | |
2181 | } | ||
2182 |
3/4✓ Branch 0 taken 98 times.
✓ Branch 1 taken 5178 times.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
|
5276 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && cb_subdiv <= sh->cu_chroma_qp_offset_subdiv) { |
2183 | 98 | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
2184 | 98 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2185 | } | ||
2186 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5276 times.
|
5276 | DUAL_TREE(x0, y0); |
2187 |
2/2✓ Branch 0 taken 5113 times.
✓ Branch 1 taken 163 times.
|
5276 | if (x1 < pps->width) |
2188 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5113 times.
|
5113 | DUAL_TREE(x1, y0); |
2189 |
2/2✓ Branch 0 taken 4784 times.
✓ Branch 1 taken 492 times.
|
5276 | if (y1 < pps->height) |
2190 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4784 times.
|
4784 | DUAL_TREE(x0, y1); |
2191 |
4/4✓ Branch 0 taken 5113 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 4624 times.
✓ Branch 3 taken 489 times.
|
5276 | if (x1 < pps->width && y1 < pps->height) |
2192 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4624 times.
|
4624 | DUAL_TREE(x1, y1); |
2193 | #undef DUAL_TREE | ||
2194 | } else { | ||
2195 | #define CODING_TREE(tree_type) do { \ | ||
2196 | const int qg_on_y = tree_type == DUAL_TREE_LUMA; \ | ||
2197 | ret = hls_coding_tree(lc, x0, y0, cb_size, cb_size, qg_on_y, !qg_on_y, \ | ||
2198 | cb_subdiv, cqt_depth, 0, 0, 0, SPLIT_NONE, tree_type, MODE_TYPE_ALL); \ | ||
2199 | if (ret < 0) \ | ||
2200 | return ret; \ | ||
2201 | } while (0) | ||
2202 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20213 times.
|
20213 | CODING_TREE(DUAL_TREE_LUMA); |
2203 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20213 times.
|
20213 | CODING_TREE(DUAL_TREE_CHROMA); |
2204 | #undef CODING_TREE | ||
2205 | } | ||
2206 | 25489 | return 0; | |
2207 | } | ||
2208 | |||
2209 | #define SET_SAO(elem, value) \ | ||
2210 | do { \ | ||
2211 | if (!sao_merge_up_flag && !sao_merge_left_flag) \ | ||
2212 | sao->elem = value; \ | ||
2213 | else if (sao_merge_left_flag) \ | ||
2214 | sao->elem = CTB(fc->tab.sao, rx-1, ry).elem; \ | ||
2215 | else if (sao_merge_up_flag) \ | ||
2216 | sao->elem = CTB(fc->tab.sao, rx, ry-1).elem; \ | ||
2217 | else \ | ||
2218 | sao->elem = 0; \ | ||
2219 | } while (0) | ||
2220 | |||
2221 | 46705 | static void hls_sao(VVCLocalContext *lc, const int rx, const int ry) | |
2222 | { | ||
2223 | 46705 | VVCFrameContext *fc = lc->fc; | |
2224 | 46705 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
2225 | 46705 | int sao_merge_left_flag = 0; | |
2226 | 46705 | int sao_merge_up_flag = 0; | |
2227 | 46705 | SAOParams *sao = &CTB(fc->tab.sao, rx, ry); | |
2228 | int c_idx, i; | ||
2229 | |||
2230 |
4/4✓ Branch 0 taken 28597 times.
✓ Branch 1 taken 18108 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28433 times.
|
46705 | if (rsh->sh_sao_luma_used_flag || rsh->sh_sao_chroma_used_flag) { |
2231 |
2/2✓ Branch 0 taken 16472 times.
✓ Branch 1 taken 1800 times.
|
18272 | if (rx > 0) { |
2232 |
2/2✓ Branch 0 taken 15659 times.
✓ Branch 1 taken 813 times.
|
16472 | if (lc->ctb_left_flag) |
2233 | 15659 | sao_merge_left_flag = ff_vvc_sao_merge_flag_decode(lc); | |
2234 | } | ||
2235 |
4/4✓ Branch 0 taken 15147 times.
✓ Branch 1 taken 3125 times.
✓ Branch 2 taken 8304 times.
✓ Branch 3 taken 6843 times.
|
18272 | if (ry > 0 && !sao_merge_left_flag) { |
2236 |
2/2✓ Branch 0 taken 7507 times.
✓ Branch 1 taken 797 times.
|
8304 | if (lc->ctb_up_flag) |
2237 | 7507 | sao_merge_up_flag = ff_vvc_sao_merge_flag_decode(lc); | |
2238 | } | ||
2239 | } | ||
2240 | |||
2241 |
4/4✓ Branch 0 taken 184708 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 139059 times.
✓ Branch 3 taken 46705 times.
|
185764 | for (c_idx = 0; c_idx < (fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) { |
2242 |
2/2✓ Branch 0 taken 46705 times.
✓ Branch 1 taken 92354 times.
|
139059 | const int sao_used_flag = !c_idx ? rsh->sh_sao_luma_used_flag : rsh->sh_sao_chroma_used_flag; |
2243 |
2/2✓ Branch 0 taken 99435 times.
✓ Branch 1 taken 39624 times.
|
139059 | if (!sao_used_flag) { |
2244 | 99435 | sao->type_idx[c_idx] = SAO_NOT_APPLIED; | |
2245 | 99435 | continue; | |
2246 | } | ||
2247 | |||
2248 |
2/2✓ Branch 0 taken 10758 times.
✓ Branch 1 taken 28866 times.
|
39624 | if (c_idx == 2) { |
2249 | 10758 | sao->type_idx[2] = sao->type_idx[1]; | |
2250 | 10758 | sao->eo_class[2] = sao->eo_class[1]; | |
2251 | } else { | ||
2252 |
7/8✓ Branch 0 taken 25353 times.
✓ Branch 1 taken 3513 times.
✓ Branch 2 taken 13126 times.
✓ Branch 3 taken 12227 times.
✓ Branch 5 taken 12227 times.
✓ Branch 6 taken 3513 times.
✓ Branch 7 taken 3513 times.
✗ Branch 8 not taken.
|
28866 | SET_SAO(type_idx[c_idx], ff_vvc_sao_type_idx_decode(lc)); |
2253 | } | ||
2254 | |||
2255 |
2/2✓ Branch 0 taken 25073 times.
✓ Branch 1 taken 14551 times.
|
39624 | if (sao->type_idx[c_idx] == SAO_NOT_APPLIED) |
2256 | 25073 | continue; | |
2257 | |||
2258 |
2/2✓ Branch 0 taken 58204 times.
✓ Branch 1 taken 14551 times.
|
72755 | for (i = 0; i < 4; i++) |
2259 |
7/8✓ Branch 0 taken 49000 times.
✓ Branch 1 taken 9204 times.
✓ Branch 2 taken 22552 times.
✓ Branch 3 taken 26448 times.
✓ Branch 5 taken 26448 times.
✓ Branch 6 taken 9204 times.
✓ Branch 7 taken 9204 times.
✗ Branch 8 not taken.
|
58204 | SET_SAO(offset_abs[c_idx][i], ff_vvc_sao_offset_abs_decode(lc)); |
2260 | |||
2261 |
2/2✓ Branch 0 taken 5150 times.
✓ Branch 1 taken 9401 times.
|
14551 | if (sao->type_idx[c_idx] == SAO_BAND) { |
2262 |
2/2✓ Branch 0 taken 20600 times.
✓ Branch 1 taken 5150 times.
|
25750 | for (i = 0; i < 4; i++) { |
2263 |
2/2✓ Branch 0 taken 6968 times.
✓ Branch 1 taken 13632 times.
|
20600 | if (sao->offset_abs[c_idx][i]) { |
2264 |
7/8✓ Branch 0 taken 6216 times.
✓ Branch 1 taken 752 times.
✓ Branch 2 taken 2469 times.
✓ Branch 3 taken 3747 times.
✓ Branch 5 taken 3747 times.
✓ Branch 6 taken 752 times.
✓ Branch 7 taken 752 times.
✗ Branch 8 not taken.
|
6968 | SET_SAO(offset_sign[c_idx][i], |
2265 | ff_vvc_sao_offset_sign_decode(lc)); | ||
2266 | } else { | ||
2267 | 13632 | sao->offset_sign[c_idx][i] = 0; | |
2268 | } | ||
2269 | } | ||
2270 |
7/8✓ Branch 0 taken 4537 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 1353 times.
✓ Branch 3 taken 3184 times.
✓ Branch 5 taken 3184 times.
✓ Branch 6 taken 613 times.
✓ Branch 7 taken 613 times.
✗ Branch 8 not taken.
|
5150 | SET_SAO(band_position[c_idx], ff_vvc_sao_band_position_decode(lc)); |
2271 |
2/2✓ Branch 0 taken 7419 times.
✓ Branch 1 taken 1982 times.
|
9401 | } else if (c_idx != 2) { |
2272 |
7/8✓ Branch 0 taken 6053 times.
✓ Branch 1 taken 1366 times.
✓ Branch 2 taken 3175 times.
✓ Branch 3 taken 2878 times.
✓ Branch 5 taken 2878 times.
✓ Branch 6 taken 1366 times.
✓ Branch 7 taken 1366 times.
✗ Branch 8 not taken.
|
7419 | SET_SAO(eo_class[c_idx], ff_vvc_sao_eo_class_decode(lc)); |
2273 | } | ||
2274 | |||
2275 | // Inferred parameters | ||
2276 | 14551 | sao->offset_val[c_idx][0] = 0; | |
2277 |
2/2✓ Branch 0 taken 58204 times.
✓ Branch 1 taken 14551 times.
|
72755 | for (i = 0; i < 4; i++) { |
2278 | 58204 | sao->offset_val[c_idx][i + 1] = sao->offset_abs[c_idx][i]; | |
2279 |
2/2✓ Branch 0 taken 37604 times.
✓ Branch 1 taken 20600 times.
|
58204 | if (sao->type_idx[c_idx] == SAO_EDGE) { |
2280 |
2/2✓ Branch 0 taken 18802 times.
✓ Branch 1 taken 18802 times.
|
37604 | if (i > 1) |
2281 | 18802 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
2282 |
2/2✓ Branch 0 taken 5558 times.
✓ Branch 1 taken 15042 times.
|
20600 | } else if (sao->offset_sign[c_idx][i]) { |
2283 | 5558 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
2284 | } | ||
2285 | 58204 | sao->offset_val[c_idx][i + 1] *= 1 << (fc->ps.sps->bit_depth - FFMIN(10, fc->ps.sps->bit_depth)); | |
2286 | } | ||
2287 | } | ||
2288 | 46705 | } | |
2289 | |||
2290 | 46705 | static void alf_params(VVCLocalContext *lc, const int rx, const int ry) | |
2291 | { | ||
2292 | 46705 | const VVCFrameContext *fc = lc->fc; | |
2293 | 46705 | const H266RawSliceHeader *sh = lc->sc->sh.r; | |
2294 | 46705 | ALFParams *alf = &CTB(fc->tab.alf, rx, ry); | |
2295 | |||
2296 | 46705 | alf->ctb_flag[LUMA] = alf->ctb_flag[CB] = alf->ctb_flag[CR] = 0; | |
2297 | 46705 | alf->ctb_cc_idc[0] = alf->ctb_cc_idc[1] = 0; | |
2298 |
2/2✓ Branch 0 taken 27178 times.
✓ Branch 1 taken 19527 times.
|
46705 | if (sh->sh_alf_enabled_flag) { |
2299 | 27178 | alf->ctb_flag[LUMA] = ff_vvc_alf_ctb_flag(lc, rx, ry, LUMA); | |
2300 |
2/2✓ Branch 0 taken 19551 times.
✓ Branch 1 taken 7627 times.
|
27178 | if (alf->ctb_flag[LUMA]) { |
2301 | 19551 | uint8_t alf_use_aps_flag = 0; | |
2302 |
2/2✓ Branch 0 taken 18743 times.
✓ Branch 1 taken 808 times.
|
19551 | if (sh->sh_num_alf_aps_ids_luma > 0) |
2303 | 18743 | alf_use_aps_flag = ff_vvc_alf_use_aps_flag(lc); | |
2304 |
2/2✓ Branch 0 taken 16776 times.
✓ Branch 1 taken 2775 times.
|
19551 | if (alf_use_aps_flag) { |
2305 | 16776 | alf->ctb_filt_set_idx_y = 16; | |
2306 |
2/2✓ Branch 0 taken 4928 times.
✓ Branch 1 taken 11848 times.
|
16776 | if (sh->sh_num_alf_aps_ids_luma > 1) |
2307 | 4928 | alf->ctb_filt_set_idx_y += ff_vvc_alf_luma_prev_filter_idx(lc); | |
2308 | } else { | ||
2309 | 2775 | alf->ctb_filt_set_idx_y = ff_vvc_alf_luma_fixed_filter_idx(lc); | |
2310 | } | ||
2311 | } | ||
2312 |
2/2✓ Branch 0 taken 54356 times.
✓ Branch 1 taken 27178 times.
|
81534 | for (int c_idx = CB; c_idx <= CR; c_idx++) { |
2313 |
2/2✓ Branch 0 taken 27178 times.
✓ Branch 1 taken 27178 times.
|
54356 | const uint8_t alf_enabled_flag = |
2314 | c_idx == CB ? sh->sh_alf_cb_enabled_flag : sh->sh_alf_cr_enabled_flag; | ||
2315 |
2/2✓ Branch 0 taken 32240 times.
✓ Branch 1 taken 22116 times.
|
54356 | if (alf_enabled_flag) { |
2316 | 32240 | const VVCALF *aps = fc->ps.alf_list[sh->sh_alf_aps_id_chroma]; | |
2317 | 32240 | alf->ctb_flag[c_idx] = ff_vvc_alf_ctb_flag(lc, rx, ry, c_idx); | |
2318 | 32240 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = 0; | |
2319 |
4/4✓ Branch 0 taken 24189 times.
✓ Branch 1 taken 8051 times.
✓ Branch 2 taken 16033 times.
✓ Branch 3 taken 8156 times.
|
32240 | if (alf->ctb_flag[c_idx] && aps->num_chroma_filters > 1) |
2320 | 16033 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = ff_vvc_alf_ctb_filter_alt_idx(lc, c_idx, aps->num_chroma_filters); | |
2321 | } | ||
2322 | } | ||
2323 | } | ||
2324 |
2/2✓ Branch 0 taken 36139 times.
✓ Branch 1 taken 10566 times.
|
46705 | if (fc->ps.sps->r->sps_ccalf_enabled_flag) { |
2325 | 36139 | const uint8_t cc_enabled[] = { sh->sh_alf_cc_cb_enabled_flag, sh->sh_alf_cc_cr_enabled_flag }; | |
2326 | 36139 | const uint8_t cc_aps_id[] = { sh->sh_alf_cc_cb_aps_id, sh->sh_alf_cc_cr_aps_id }; | |
2327 |
2/2✓ Branch 0 taken 72278 times.
✓ Branch 1 taken 36139 times.
|
108417 | for (int i = 0; i < 2; i++) { |
2328 |
2/2✓ Branch 0 taken 22609 times.
✓ Branch 1 taken 49669 times.
|
72278 | if (cc_enabled[i]) { |
2329 | 22609 | const VVCALF *aps = fc->ps.alf_list[cc_aps_id[i]]; | |
2330 | 22609 | alf->ctb_cc_idc[i] = ff_vvc_alf_ctb_cc_idc(lc, rx, ry, i, aps->num_cc_filters[i]); | |
2331 | } | ||
2332 | } | ||
2333 | } | ||
2334 | 46705 | } | |
2335 | |||
2336 | 46705 | static void deblock_params(VVCLocalContext *lc, const int rx, const int ry) | |
2337 | { | ||
2338 | 46705 | VVCFrameContext *fc = lc->fc; | |
2339 | 46705 | const VVCSH *sh = &lc->sc->sh; | |
2340 | 46705 | CTB(fc->tab.deblock, rx, ry) = sh->deblock; | |
2341 | 46705 | } | |
2342 | |||
2343 | 46705 | static int hls_coding_tree_unit(VVCLocalContext *lc, | |
2344 | const int x0, const int y0, const int ctu_idx, const int rx, const int ry) | ||
2345 | { | ||
2346 | 46705 | const VVCFrameContext *fc = lc->fc; | |
2347 | 46705 | const VVCSPS *sps = fc->ps.sps; | |
2348 | 46705 | const VVCPPS *pps = fc->ps.pps; | |
2349 | 46705 | const VVCSH *sh = &lc->sc->sh; | |
2350 | 46705 | const H266RawSliceHeader *rsh = sh->r; | |
2351 | 46705 | const unsigned int ctb_size = sps->ctb_size_y; | |
2352 | 46705 | int ret = 0; | |
2353 | |||
2354 | 46705 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
2355 | |||
2356 | 46705 | hls_sao(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2357 | 46705 | alf_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2358 | 46705 | deblock_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
2359 | |||
2360 |
4/4✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 40817 times.
✓ Branch 2 taken 5692 times.
✓ Branch 3 taken 196 times.
|
46705 | if (IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) |
2361 | 5692 | ret = dual_tree_implicit_qt_split(lc, x0, y0, ctb_size, 0); | |
2362 | else | ||
2363 | 41013 | ret = hls_coding_tree(lc, x0, y0, ctb_size, ctb_size, | |
2364 | 1, 1, 0, 0, 0, 0, 0, SPLIT_NONE, SINGLE_TREE, MODE_TYPE_ALL); | ||
2365 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 46705 times.
|
46705 | if (ret < 0) |
2366 | ✗ | return ret; | |
2367 | |||
2368 |
2/2✓ Branch 0 taken 5825 times.
✓ Branch 1 taken 40880 times.
|
46705 | if (rx == pps->ctb_to_col_bd[rx + 1] - 1) { |
2369 |
2/2✓ Branch 0 taken 1709 times.
✓ Branch 1 taken 4116 times.
|
5825 | if (ctu_idx == sh->num_ctus_in_curr_slice - 1) { |
2370 | 1709 | const int end_of_slice_one_bit = ff_vvc_end_of_slice_flag_decode(lc); | |
2371 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1709 times.
|
1709 | if (!end_of_slice_one_bit) |
2372 | ✗ | return AVERROR_INVALIDDATA; | |
2373 | } else { | ||
2374 |
2/2✓ Branch 0 taken 487 times.
✓ Branch 1 taken 3629 times.
|
4116 | if (ry == pps->ctb_to_row_bd[ry + 1] - 1) { |
2375 | 487 | const int end_of_tile_one_bit = ff_vvc_end_of_tile_one_bit(lc); | |
2376 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 487 times.
|
487 | if (!end_of_tile_one_bit) |
2377 | ✗ | return AVERROR_INVALIDDATA; | |
2378 | } else { | ||
2379 |
2/2✓ Branch 0 taken 153 times.
✓ Branch 1 taken 3476 times.
|
3629 | if (fc->ps.sps->r->sps_entropy_coding_sync_enabled_flag) { |
2380 | 153 | const int end_of_subset_one_bit = ff_vvc_end_of_subset_one_bit(lc); | |
2381 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
|
153 | if (!end_of_subset_one_bit) |
2382 | ✗ | return AVERROR_INVALIDDATA; | |
2383 | } | ||
2384 | } | ||
2385 | } | ||
2386 | } | ||
2387 | |||
2388 | 46705 | return 0; | |
2389 | } | ||
2390 | |||
2391 | 583741 | static int has_inter_luma(const CodingUnit *cu) | |
2392 | { | ||
2393 |
4/6✓ Branch 0 taken 447542 times.
✓ Branch 1 taken 136199 times.
✓ Branch 2 taken 447542 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 447542 times.
✗ Branch 5 not taken.
|
583741 | return cu->pred_mode != MODE_INTRA && cu->pred_mode != MODE_PLT && cu->tree_type != DUAL_TREE_CHROMA; |
2394 | } | ||
2395 | |||
2396 | 8050651 | static int pred_get_y(const VVCLocalContext *lc, const int y0, const Mv *mv, const int height) | |
2397 | { | ||
2398 | 8050651 | const VVCPPS *pps = lc->fc->ps.pps; | |
2399 | 8050651 | const int idx = lc->sc->sh.r->curr_subpic_idx; | |
2400 | 8050651 | const int top = pps->subpic_y[idx]; | |
2401 | 8050651 | const int bottom = top + pps->subpic_height[idx]; | |
2402 | |||
2403 | 8050651 | return av_clip(y0 + (mv->y >> 4) + height, top, bottom); | |
2404 | } | ||
2405 | |||
2406 | 447542 | static void cu_get_max_y(const CodingUnit *cu, int max_y[2][VVC_MAX_REF_ENTRIES], const VVCLocalContext *lc) | |
2407 | { | ||
2408 | 447542 | const VVCFrameContext *fc = lc->fc; | |
2409 | 447542 | const PredictionUnit *pu = &cu->pu; | |
2410 | |||
2411 |
2/2✓ Branch 0 taken 25615 times.
✓ Branch 1 taken 421927 times.
|
447542 | if (pu->merge_gpm_flag) { |
2412 |
2/2✓ Branch 0 taken 51230 times.
✓ Branch 1 taken 25615 times.
|
76845 | for (int i = 0; i < FF_ARRAY_ELEMS(pu->gpm_mv); i++) { |
2413 | 51230 | const MvField *mvf = pu->gpm_mv + i; | |
2414 | 51230 | const int lx = mvf->pred_flag - PF_L0; | |
2415 | 51230 | const int idx = mvf->ref_idx[lx]; | |
2416 | 51230 | const int y = pred_get_y(lc, cu->y0, mvf->mv + lx, cu->cb_height); | |
2417 | |||
2418 | 51230 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y); | |
2419 | } | ||
2420 | } else { | ||
2421 | 421927 | const MotionInfo *mi = &pu->mi; | |
2422 |
4/4✓ Branch 0 taken 387204 times.
✓ Branch 1 taken 34723 times.
✓ Branch 2 taken 68245 times.
✓ Branch 3 taken 318959 times.
|
421927 | const int max_dmvr_off = (!pu->inter_affine_flag && pu->dmvr_flag) ? 2 : 0; |
2423 | 421927 | const int sbw = cu->cb_width / mi->num_sb_x; | |
2424 | 421927 | const int sbh = cu->cb_height / mi->num_sb_y; | |
2425 |
2/2✓ Branch 0 taken 886922 times.
✓ Branch 1 taken 421927 times.
|
1308849 | for (int sby = 0; sby < mi->num_sb_y; sby++) { |
2426 |
2/2✓ Branch 0 taken 5545694 times.
✓ Branch 1 taken 886922 times.
|
6432616 | for (int sbx = 0; sbx < mi->num_sb_x; sbx++) { |
2427 | 5545694 | const int x0 = cu->x0 + sbx * sbw; | |
2428 | 5545694 | const int y0 = cu->y0 + sby * sbh; | |
2429 | 5545694 | const MvField *mvf = ff_vvc_get_mvf(fc, x0, y0); | |
2430 |
2/2✓ Branch 0 taken 11091388 times.
✓ Branch 1 taken 5545694 times.
|
16637082 | for (int lx = 0; lx < 2; lx++) { |
2431 | 11091388 | const PredFlag mask = 1 << lx; | |
2432 |
2/2✓ Branch 0 taken 7999421 times.
✓ Branch 1 taken 3091967 times.
|
11091388 | if (mvf->pred_flag & mask) { |
2433 | 7999421 | const int idx = mvf->ref_idx[lx]; | |
2434 | 7999421 | const int y = pred_get_y(lc, y0, mvf->mv + lx, sbh); | |
2435 | |||
2436 | 7999421 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y + max_dmvr_off); | |
2437 | } | ||
2438 | } | ||
2439 | } | ||
2440 | } | ||
2441 | } | ||
2442 | 447542 | } | |
2443 | |||
2444 | 46705 | static void ctu_get_pred(VVCLocalContext *lc, const int rs) | |
2445 | { | ||
2446 | 46705 | const VVCFrameContext *fc = lc->fc; | |
2447 | 46705 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
2448 | 46705 | CTU *ctu = fc->tab.ctus + rs; | |
2449 | 46705 | const CodingUnit *cu = fc->tab.cus[rs]; | |
2450 | |||
2451 | 46705 | ctu->has_dmvr = 0; | |
2452 | |||
2453 |
2/2✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 40817 times.
|
46705 | if (IS_I(rsh)) |
2454 | 5888 | return; | |
2455 | |||
2456 |
2/2✓ Branch 0 taken 81634 times.
✓ Branch 1 taken 40817 times.
|
122451 | for (int lx = 0; lx < 2; lx++) |
2457 | 81634 | memset(ctu->max_y[lx], -1, sizeof(ctu->max_y[0][0]) * rsh->num_ref_idx_active[lx]); | |
2458 | |||
2459 |
2/2✓ Branch 0 taken 583741 times.
✓ Branch 1 taken 40817 times.
|
624558 | while (cu) { |
2460 |
2/2✓ Branch 1 taken 447542 times.
✓ Branch 2 taken 136199 times.
|
583741 | if (has_inter_luma(cu)) { |
2461 | 447542 | cu_get_max_y(cu, ctu->max_y, lc); | |
2462 | 447542 | ctu->has_dmvr |= cu->pu.dmvr_flag; | |
2463 | } | ||
2464 | 583741 | cu = cu->next; | |
2465 | } | ||
2466 | 40817 | ctu->max_y_idx[0] = ctu->max_y_idx[1] = 0; | |
2467 | } | ||
2468 | |||
2469 | 46705 | int ff_vvc_coding_tree_unit(VVCLocalContext *lc, | |
2470 | const int ctu_idx, const int rs, const int rx, const int ry) | ||
2471 | { | ||
2472 | 46705 | const VVCFrameContext *fc = lc->fc; | |
2473 | 46705 | const VVCSPS *sps = fc->ps.sps; | |
2474 | 46705 | const VVCPPS *pps = fc->ps.pps; | |
2475 | 46705 | const int x_ctb = rx << sps->ctb_log2_size_y; | |
2476 | 46705 | const int y_ctb = ry << sps->ctb_log2_size_y; | |
2477 | 46705 | const int ctb_size = 1 << sps->ctb_log2_size_y << sps->ctb_log2_size_y; | |
2478 | 46705 | EntryPoint* ep = lc->ep; | |
2479 | int ret; | ||
2480 | |||
2481 |
2/2✓ Branch 0 taken 5825 times.
✓ Branch 1 taken 40880 times.
|
46705 | if (rx == pps->ctb_to_col_bd[rx]) { |
2482 | 5825 | ep->num_hmvp = 0; | |
2483 | 5825 | ep->num_hmvp_ibc = 0; | |
2484 |
4/4✓ Branch 0 taken 3741 times.
✓ Branch 1 taken 2084 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 3629 times.
|
5825 | ep->is_first_qg = ry == pps->ctb_to_row_bd[ry] || !ctu_idx; |
2485 | } | ||
2486 | |||
2487 | 46705 | lc->coeffs = fc->tab.coeffs + rs * ctb_size * VVC_MAX_SAMPLE_ARRAYS; | |
2488 | 46705 | lc->cu = NULL; | |
2489 | |||
2490 | 46705 | ff_vvc_cabac_init(lc, ctu_idx, rx, ry); | |
2491 | 46705 | ff_vvc_decode_neighbour(lc, x_ctb, y_ctb, rx, ry, rs); | |
2492 | 46705 | ret = hls_coding_tree_unit(lc, x_ctb, y_ctb, ctu_idx, rx, ry); | |
2493 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 46705 times.
|
46705 | if (ret < 0) |
2494 | ✗ | return ret; | |
2495 | 46705 | ctu_get_pred(lc, rs); | |
2496 | |||
2497 | 46705 | return 0; | |
2498 | } | ||
2499 | |||
2500 | 316465 | void ff_vvc_decode_neighbour(VVCLocalContext *lc, const int x_ctb, const int y_ctb, | |
2501 | const int rx, const int ry, const int rs) | ||
2502 | { | ||
2503 | 316465 | VVCFrameContext *fc = lc->fc; | |
2504 | 316465 | const int ctb_size = fc->ps.sps->ctb_size_y; | |
2505 | |||
2506 | 316465 | lc->end_of_tiles_x = fc->ps.pps->width; | |
2507 | 316465 | lc->end_of_tiles_y = fc->ps.pps->height; | |
2508 |
2/2✓ Branch 0 taken 39986 times.
✓ Branch 1 taken 276479 times.
|
316465 | if (fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx + 1]) |
2509 | 39986 | lc->end_of_tiles_x = FFMIN(x_ctb + ctb_size, lc->end_of_tiles_x); | |
2510 |
2/2✓ Branch 0 taken 64574 times.
✓ Branch 1 taken 251891 times.
|
316465 | if (fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry + 1]) |
2511 | 64574 | lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, lc->end_of_tiles_y); | |
2512 | |||
2513 | 316465 | lc->boundary_flags = 0; | |
2514 |
4/4✓ Branch 0 taken 287630 times.
✓ Branch 1 taken 28835 times.
✓ Branch 2 taken 11151 times.
✓ Branch 3 taken 276479 times.
|
316465 | if (rx > 0 && fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx - 1]) |
2515 | 11151 | lc->boundary_flags |= BOUNDARY_LEFT_TILE; | |
2516 |
4/4✓ Branch 0 taken 287630 times.
✓ Branch 1 taken 28835 times.
✓ Branch 2 taken 5425 times.
✓ Branch 3 taken 282205 times.
|
316465 | if (rx > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - 1]) |
2517 | 5425 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; | |
2518 |
4/4✓ Branch 0 taken 266402 times.
✓ Branch 1 taken 50063 times.
✓ Branch 2 taken 14511 times.
✓ Branch 3 taken 251891 times.
|
316465 | if (ry > 0 && fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry - 1]) |
2519 | 14511 | lc->boundary_flags |= BOUNDARY_UPPER_TILE; | |
2520 |
4/4✓ Branch 0 taken 266402 times.
✓ Branch 1 taken 50063 times.
✓ Branch 2 taken 12341 times.
✓ Branch 3 taken 254061 times.
|
316465 | if (ry > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - fc->ps.pps->ctb_width]) |
2521 | 12341 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; | |
2522 |
2/2✓ Branch 0 taken 30998 times.
✓ Branch 1 taken 285467 times.
|
316465 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_x[lc->sc->sh.r->curr_subpic_idx] == rx) |
2523 | 30998 | lc->boundary_flags |= BOUNDARY_LEFT_SUBPIC; | |
2524 |
2/2✓ Branch 0 taken 52646 times.
✓ Branch 1 taken 263819 times.
|
316465 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_y[lc->sc->sh.r->curr_subpic_idx] == ry) |
2525 | 52646 | lc->boundary_flags |= BOUNDARY_UPPER_SUBPIC; | |
2526 |
4/4✓ Branch 0 taken 287630 times.
✓ Branch 1 taken 28835 times.
✓ Branch 2 taken 276479 times.
✓ Branch 3 taken 11151 times.
|
316465 | lc->ctb_left_flag = rx > 0 && !(lc->boundary_flags & BOUNDARY_LEFT_TILE); |
2527 |
6/6✓ Branch 0 taken 266402 times.
✓ Branch 1 taken 50063 times.
✓ Branch 2 taken 251891 times.
✓ Branch 3 taken 14511 times.
✓ Branch 4 taken 249539 times.
✓ Branch 5 taken 2352 times.
|
316465 | lc->ctb_up_flag = ry > 0 && !(lc->boundary_flags & BOUNDARY_UPPER_TILE) && !(lc->boundary_flags & BOUNDARY_UPPER_SLICE); |
2528 |
4/4✓ Branch 0 taken 249539 times.
✓ Branch 1 taken 66926 times.
✓ Branch 2 taken 224818 times.
✓ Branch 3 taken 24721 times.
|
541283 | 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]) && |
2529 |
1/2✓ Branch 0 taken 224818 times.
✗ Branch 1 not taken.
|
224818 | (fc->ps.pps->ctb_to_row_bd[ry] == fc->ps.pps->ctb_to_row_bd[ry - 1]); |
2530 |
4/4✓ Branch 0 taken 276479 times.
✓ Branch 1 taken 39986 times.
✓ Branch 2 taken 224818 times.
✓ Branch 3 taken 51661 times.
|
316465 | lc->ctb_up_left_flag = lc->ctb_left_flag && lc->ctb_up_flag; |
2531 | 316465 | } | |
2532 | |||
2533 | 2656915 | void ff_vvc_set_neighbour_available(VVCLocalContext *lc, | |
2534 | const int x0, const int y0, const int w, const int h) | ||
2535 | { | ||
2536 | 2656915 | const int log2_ctb_size = lc->fc->ps.sps->ctb_log2_size_y; | |
2537 | 2656915 | const int x0b = av_zero_extend(x0, log2_ctb_size); | |
2538 | 2656915 | const int y0b = av_zero_extend(y0, log2_ctb_size); | |
2539 | |||
2540 |
4/4✓ Branch 0 taken 816211 times.
✓ Branch 1 taken 1840704 times.
✓ Branch 2 taken 730590 times.
✓ Branch 3 taken 85621 times.
|
2656915 | lc->na.cand_up = (lc->ctb_up_flag || y0b); |
2541 |
4/4✓ Branch 0 taken 535684 times.
✓ Branch 1 taken 2121231 times.
✓ Branch 2 taken 466999 times.
✓ Branch 3 taken 68685 times.
|
2656915 | lc->na.cand_left = (lc->ctb_left_flag || x0b); |
2542 |
8/8✓ Branch 0 taken 403864 times.
✓ Branch 1 taken 2253051 times.
✓ Branch 2 taken 296852 times.
✓ Branch 3 taken 107012 times.
✓ Branch 4 taken 2495187 times.
✓ Branch 5 taken 54716 times.
✓ Branch 6 taken 2432670 times.
✓ Branch 7 taken 62517 times.
|
2656915 | lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag; |
2543 | 2656915 | lc->na.cand_up_right_sap = | |
2544 |
6/6✓ Branch 0 taken 374321 times.
✓ Branch 1 taken 2282594 times.
✓ Branch 2 taken 256784 times.
✓ Branch 3 taken 117537 times.
✓ Branch 4 taken 75350 times.
✓ Branch 5 taken 181434 times.
|
2656915 | (x0b + w == 1 << log2_ctb_size) ? lc->ctb_up_right_flag && !y0b : lc->na.cand_up; |
2545 |
4/4✓ Branch 0 taken 2293748 times.
✓ Branch 1 taken 363167 times.
✓ Branch 2 taken 2271478 times.
✓ Branch 3 taken 22270 times.
|
2656915 | lc->na.cand_up_right = lc->na.cand_up_right_sap && (x0 + w) < lc->end_of_tiles_x; |
2546 | 2656915 | } | |
2547 | |||
2548 | 93530 | void ff_vvc_ctu_free_cus(CodingUnit **cus) | |
2549 | { | ||
2550 |
2/2✓ Branch 0 taken 1232069 times.
✓ Branch 1 taken 93530 times.
|
1325599 | while (*cus) { |
2551 | 1232069 | CodingUnit *cu = *cus; | |
2552 | 1232069 | TransformUnit **head = &cu->tus.head; | |
2553 | |||
2554 | 1232069 | *cus = cu->next; | |
2555 | |||
2556 |
2/2✓ Branch 0 taken 1491918 times.
✓ Branch 1 taken 1232069 times.
|
2723987 | while (*head) { |
2557 | 1491918 | TransformUnit *tu = *head; | |
2558 | 1491918 | *head = tu->next; | |
2559 | 1491918 | av_refstruct_unref(&tu); | |
2560 | } | ||
2561 | 1232069 | cu->tus.tail = NULL; | |
2562 | |||
2563 | 1232069 | av_refstruct_unref(&cu); | |
2564 | } | ||
2565 | 93530 | } | |
2566 | |||
2567 | 15555026 | int ff_vvc_get_qPy(const VVCFrameContext *fc, const int xc, const int yc) | |
2568 | { | ||
2569 | 15555026 | const int min_cb_log2_size_y = fc->ps.sps->min_cb_log2_size_y; | |
2570 | 15555026 | const int x = xc >> min_cb_log2_size_y; | |
2571 | 15555026 | const int y = yc >> min_cb_log2_size_y; | |
2572 | 15555026 | return fc->tab.qp[LUMA][x + y * fc->ps.pps->min_cb_width]; | |
2573 | } | ||
2574 | |||
2575 | 2349 | void ff_vvc_ep_init_stat_coeff(EntryPoint *ep, | |
2576 | const int bit_depth, const int persistent_rice_adaptation_enabled_flag) | ||
2577 | { | ||
2578 |
2/2✓ Branch 0 taken 7047 times.
✓ Branch 1 taken 2349 times.
|
9396 | for (size_t i = 0; i < FF_ARRAY_ELEMS(ep->stat_coeff); ++i) { |
2579 | 7047 | ep->stat_coeff[i] = | |
2580 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7047 times.
|
7047 | persistent_rice_adaptation_enabled_flag ? 2 * (av_log2(bit_depth - 10)) : 0; |
2581 | } | ||
2582 | 2349 | } | |
2583 |