| 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/error.h" | ||
| 24 | #include "libavutil/refstruct.h" | ||
| 25 | |||
| 26 | #include "cabac.h" | ||
| 27 | #include "ctu.h" | ||
| 28 | #include "inter.h" | ||
| 29 | #include "intra.h" | ||
| 30 | #include "mvs.h" | ||
| 31 | |||
| 32 | #define PROF_TEMP_SIZE (PROF_BLOCK_SIZE) * sizeof(int16_t) | ||
| 33 | |||
| 34 | #define TAB_MSM(fc, depth, x, y) fc->tab.msm[(depth)][((y) >> 5) * fc->ps.pps->width32 + ((x) >> 5)] | ||
| 35 | #define TAB_ISPMF(fc, x, y) fc->tab.ispmf[((y) >> 6) * fc->ps.pps->width64 + ((x) >> 6)] | ||
| 36 | |||
| 37 | typedef enum VVCModeType { | ||
| 38 | MODE_TYPE_ALL, | ||
| 39 | MODE_TYPE_INTER, | ||
| 40 | MODE_TYPE_INTRA, | ||
| 41 | } VVCModeType; | ||
| 42 | |||
| 43 | 2368969 | static void set_tb_size(const VVCFrameContext *fc, const TransformBlock *tb) | |
| 44 | { | ||
| 45 | 2368969 | const int x_tb = tb->x0 >> MIN_TU_LOG2; | |
| 46 | 2368969 | const int y_tb = tb->y0 >> MIN_TU_LOG2; | |
| 47 | 2368969 | const int hs = fc->ps.sps->hshift[tb->c_idx]; | |
| 48 | 2368969 | const int vs = fc->ps.sps->vshift[tb->c_idx]; | |
| 49 | 2368969 | const int is_chroma = tb->c_idx != 0; | |
| 50 | 2368969 | const int width = FFMAX(1, tb->tb_width >> (MIN_TU_LOG2 - hs)); | |
| 51 | 2368969 | const int end = y_tb + FFMAX(1, tb->tb_height >> (MIN_TU_LOG2 - vs)); | |
| 52 | |||
| 53 |
2/2✓ Branch 0 taken 11314942 times.
✓ Branch 1 taken 2368969 times.
|
13683911 | for (int y = y_tb; y < end; y++) { |
| 54 | 11314942 | const int off = y * fc->ps.pps->min_tu_width + x_tb; | |
| 55 | 11314942 | memset(fc->tab.tb_width [is_chroma] + off, tb->tb_width, width); | |
| 56 | 11314942 | memset(fc->tab.tb_height[is_chroma] + off, tb->tb_height, width); | |
| 57 | } | ||
| 58 | 2368969 | } | |
| 59 | |||
| 60 | 3263098 | static void set_tb_tab(uint8_t *tab, uint8_t v, const VVCFrameContext *fc, | |
| 61 | const TransformBlock *tb) | ||
| 62 | { | ||
| 63 | 3263098 | const int width = tb->tb_width << fc->ps.sps->hshift[tb->c_idx]; | |
| 64 | 3263098 | const int height = tb->tb_height << fc->ps.sps->vshift[tb->c_idx]; | |
| 65 | |||
| 66 |
2/2✓ Branch 0 taken 15242581 times.
✓ Branch 1 taken 3263098 times.
|
18505679 | for (int h = 0; h < height; h += MIN_TU_SIZE) { |
| 67 | 15242581 | const int y = (tb->y0 + h) >> MIN_TU_LOG2; | |
| 68 | 15242581 | const int off = y * fc->ps.pps->min_tu_width + (tb->x0 >> MIN_TU_LOG2); | |
| 69 | 15242581 | const int w = FFMAX(1, width >> MIN_TU_LOG2); | |
| 70 | 15242581 | memset(tab + off, v, w); | |
| 71 | } | ||
| 72 | 3263098 | } | |
| 73 | |||
| 74 | // 8.7.1 Derivation process for quantization parameters | ||
| 75 | 2765 | static int get_qp_y_pred(const VVCLocalContext *lc) | |
| 76 | { | ||
| 77 | 2765 | const VVCFrameContext *fc = lc->fc; | |
| 78 | 2765 | const VVCSPS *sps = fc->ps.sps; | |
| 79 | 2765 | const VVCPPS *pps = fc->ps.pps; | |
| 80 | 2765 | const CodingUnit *cu = lc->cu; | |
| 81 | 2765 | const int ctb_log2_size = sps->ctb_log2_size_y; | |
| 82 | 2765 | const int ctb_size_mask = (1 << ctb_log2_size) - 1; | |
| 83 | 2765 | const int xQg = lc->parse.cu_qg_top_left_x; | |
| 84 | 2765 | const int yQg = lc->parse.cu_qg_top_left_y; | |
| 85 | 2765 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
| 86 | 2765 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
| 87 | 2765 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
| 88 | 2765 | const int rx = cu->x0 >> ctb_log2_size; | |
| 89 | 2765 | const int ry = cu->y0 >> ctb_log2_size; | |
| 90 |
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; |
| 91 |
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; |
| 92 | int qPy_pred, qPy_a, qPy_b; | ||
| 93 | |||
| 94 |
2/2✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 1084 times.
|
2765 | if (lc->na.cand_up) { |
| 95 |
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); |
| 96 | 1681 | const int qPy_up = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
| 97 |
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) |
| 98 | 438 | return qPy_up; | |
| 99 | } | ||
| 100 | |||
| 101 | // qPy_pred | ||
| 102 |
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; |
| 103 | |||
| 104 | // qPy_b | ||
| 105 |
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) |
| 106 | 2327 | qPy_b = qPy_pred; | |
| 107 | else | ||
| 108 | ✗ | qPy_b = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; | |
| 109 | |||
| 110 | // qPy_a | ||
| 111 |
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) |
| 112 | 2327 | qPy_a = qPy_pred; | |
| 113 | else | ||
| 114 | ✗ | qPy_a = fc->tab.qp[LUMA][(x_cb - 1) + y_cb * min_cb_width]; | |
| 115 | |||
| 116 | av_assert2(qPy_a >= -fc->ps.sps->qp_bd_offset && qPy_a <= 63); | ||
| 117 | av_assert2(qPy_b >= -fc->ps.sps->qp_bd_offset && qPy_b <= 63); | ||
| 118 | |||
| 119 | 2327 | return (qPy_a + qPy_b + 1) >> 1; | |
| 120 | } | ||
| 121 | |||
| 122 | 9693044 | static void set_cb_tab(const VVCLocalContext *lc, uint8_t *tab, const uint8_t v) | |
| 123 | { | ||
| 124 | 9693044 | const VVCFrameContext *fc = lc->fc; | |
| 125 | 9693044 | const VVCPPS *pps = fc->ps.pps; | |
| 126 | 9693044 | const CodingUnit *cu = lc->cu; | |
| 127 | 9693044 | const int log2_min_cb_size = fc->ps.sps->min_cb_log2_size_y; | |
| 128 | 9693044 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
| 129 | 9693044 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
| 130 | 9693044 | const int cb_width = cu->cb_width; | |
| 131 | 9693044 | const int cb_height = cu->cb_height; | |
| 132 | 9693044 | int x = y_cb * pps->min_cb_width + x_cb; | |
| 133 | |||
| 134 |
2/2✓ Branch 0 taken 41587205 times.
✓ Branch 1 taken 9693044 times.
|
51280249 | for (int y = 0; y < (cb_height >> log2_min_cb_size); y++) { |
| 135 | 41587205 | const int width = cb_width >> log2_min_cb_size; | |
| 136 | |||
| 137 | 41587205 | memset(&tab[x], v, width); | |
| 138 | 41587205 | x += pps->min_cb_width; | |
| 139 | } | ||
| 140 | 9693044 | } | |
| 141 | |||
| 142 | 1360949 | static int set_qp_y(VVCLocalContext *lc, const int x0, const int y0, const int has_qp_delta) | |
| 143 | { | ||
| 144 | 1360949 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 145 | 1360949 | EntryPoint *ep = lc->ep; | |
| 146 | 1360949 | CodingUnit *cu = lc->cu; | |
| 147 | 1360949 | int cu_qp_delta = 0; | |
| 148 | |||
| 149 |
2/2✓ Branch 0 taken 1193499 times.
✓ Branch 1 taken 167450 times.
|
1360949 | if (!lc->fc->ps.pps->r->pps_cu_qp_delta_enabled_flag) { |
| 150 | 1193499 | ep->qp_y = lc->sc->sh.slice_qp_y; | |
| 151 |
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)) { |
| 152 | 2765 | ep->qp_y = get_qp_y_pred(lc); | |
| 153 | 2765 | ep->is_first_qg = 0; | |
| 154 | } | ||
| 155 | |||
| 156 |
2/2✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 1359061 times.
|
1360949 | if (has_qp_delta) { |
| 157 | 1888 | const int cu_qp_delta_abs = ff_vvc_cu_qp_delta_abs(lc); | |
| 158 | |||
| 159 |
2/2✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 782 times.
|
1888 | if (cu_qp_delta_abs) |
| 160 |
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; |
| 161 |
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)) |
| 162 | ✗ | return AVERROR_INVALIDDATA; | |
| 163 | 1888 | lc->parse.is_cu_qp_delta_coded = 1; | |
| 164 | |||
| 165 |
2/2✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 782 times.
|
1888 | if (cu_qp_delta) { |
| 166 | 1106 | int off = sps->qp_bd_offset; | |
| 167 |
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; |
| 168 | } | ||
| 169 | } | ||
| 170 | |||
| 171 | 1360949 | set_cb_tab(lc, lc->fc->tab.qp[LUMA], ep->qp_y); | |
| 172 | 1360949 | cu->qp[LUMA] = ep->qp_y; | |
| 173 | |||
| 174 | 1360949 | return 0; | |
| 175 | } | ||
| 176 | |||
| 177 | 1786432 | static void set_qp_c_tab(const VVCLocalContext *lc, const TransformUnit *tu, const TransformBlock *tb) | |
| 178 | { | ||
| 179 |
6/6✓ Branch 0 taken 108450 times.
✓ Branch 1 taken 1677982 times.
✓ Branch 2 taken 92198 times.
✓ Branch 3 taken 16252 times.
✓ Branch 4 taken 62068 times.
✓ Branch 5 taken 30130 times.
|
1786432 | const int is_jcbcr = tu->joint_cbcr_residual_flag && tu->coded_flag[CB] && tu->coded_flag[CR]; |
| 180 |
2/2✓ Branch 0 taken 1724364 times.
✓ Branch 1 taken 62068 times.
|
1786432 | const int idx = is_jcbcr ? JCBCR : tb->c_idx; |
| 181 | |||
| 182 | 1786432 | set_tb_tab(lc->fc->tab.qp[tb->c_idx], lc->cu->qp[idx], lc->fc, tb); | |
| 183 | 1786432 | } | |
| 184 | |||
| 185 | 1297105 | static void set_qp_c(VVCLocalContext *lc) | |
| 186 | { | ||
| 187 | 1297105 | const VVCFrameContext *fc = lc->fc; | |
| 188 | 1297105 | const VVCSPS *sps = fc->ps.sps; | |
| 189 | 1297105 | const VVCPPS *pps = fc->ps.pps; | |
| 190 | 1297105 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 191 | 1297105 | CodingUnit *cu = lc->cu; | |
| 192 | 1297105 | const int x_center = cu->x0 + cu->cb_width / 2; | |
| 193 | 1297105 | const int y_center = cu->y0 + cu->cb_height / 2; | |
| 194 | 1297105 | const int single_tree = cu->tree_type == SINGLE_TREE; | |
| 195 |
2/2✓ Branch 0 taken 554015 times.
✓ Branch 1 taken 743090 times.
|
1297105 | const int qp_luma = (single_tree ? lc->ep->qp_y : ff_vvc_get_qPy(fc, x_center, y_center)) + sps->qp_bd_offset; |
| 196 | 1297105 | const int qp_chroma = av_clip(qp_luma, 0, MAX_QP + sps->qp_bd_offset); | |
| 197 | 1297105 | const int sh_chroma_qp_offset[] = { | |
| 198 | 1297105 | rsh->sh_cb_qp_offset, | |
| 199 | 1297105 | rsh->sh_cr_qp_offset, | |
| 200 | 1297105 | rsh->sh_joint_cbcr_qp_offset, | |
| 201 | }; | ||
| 202 | int qp; | ||
| 203 | |||
| 204 |
2/2✓ Branch 0 taken 3848420 times.
✓ Branch 1 taken 1297105 times.
|
5145525 | for (int i = CB - 1; i < CR + sps->r->sps_joint_cbcr_enabled_flag; i++) { |
| 205 | 3848420 | qp = sps->chroma_qp_table[i][qp_chroma]; | |
| 206 | 3848420 | qp = qp + pps->chroma_qp_offset[i] + sh_chroma_qp_offset[i] + lc->parse.chroma_qp_offset[i]; | |
| 207 | 3848420 | qp = av_clip(qp, -sps->qp_bd_offset, MAX_QP) + sps->qp_bd_offset; | |
| 208 | 3848420 | cu->qp[i + 1] = qp; | |
| 209 | } | ||
| 210 | 1297105 | } | |
| 211 | |||
| 212 | 1663917 | static TransformUnit* alloc_tu(VVCFrameContext *fc, CodingUnit *cu) | |
| 213 | { | ||
| 214 | 1663917 | TransformUnit *tu = av_refstruct_pool_get(fc->tu_pool); | |
| 215 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1663917 times.
|
1663917 | if (!tu) |
| 216 | ✗ | return NULL; | |
| 217 | |||
| 218 | 1663917 | tu->next = NULL; | |
| 219 | |||
| 220 |
2/2✓ Branch 0 taken 319308 times.
✓ Branch 1 taken 1344609 times.
|
1663917 | if (cu->tus.tail) |
| 221 | 319308 | cu->tus.tail->next = tu; | |
| 222 | else | ||
| 223 | 1344609 | cu->tus.head = tu; | |
| 224 | 1663917 | cu->tus.tail = tu; | |
| 225 | |||
| 226 | 1663917 | return tu; | |
| 227 | } | ||
| 228 | |||
| 229 | 1663917 | static TransformUnit* add_tu(VVCFrameContext *fc, CodingUnit *cu, const int x0, const int y0, const int tu_width, const int tu_height) | |
| 230 | { | ||
| 231 | 1663917 | TransformUnit *tu = alloc_tu(fc, cu); | |
| 232 | |||
| 233 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1663917 times.
|
1663917 | if (!tu) |
| 234 | ✗ | return NULL; | |
| 235 | |||
| 236 | 1663917 | tu->x0 = x0; | |
| 237 | 1663917 | tu->y0 = y0; | |
| 238 | 1663917 | tu->width = tu_width; | |
| 239 | 1663917 | tu->height = tu_height; | |
| 240 | 1663917 | tu->joint_cbcr_residual_flag = 0; | |
| 241 | 1663917 | memset(tu->coded_flag, 0, sizeof(tu->coded_flag)); | |
| 242 | 1663917 | tu->avail[LUMA] = tu->avail[CHROMA] = 0; | |
| 243 | 1663917 | tu->nb_tbs = 0; | |
| 244 | |||
| 245 | 1663917 | return tu; | |
| 246 | } | ||
| 247 | |||
| 248 | 3262185 | static TransformBlock* add_tb(TransformUnit *tu, VVCLocalContext *lc, | |
| 249 | const int x0, const int y0, const int tb_width, const int tb_height, const int c_idx) | ||
| 250 | { | ||
| 251 | TransformBlock *tb; | ||
| 252 | |||
| 253 | 3262185 | tb = &tu->tbs[tu->nb_tbs++]; | |
| 254 | 3262185 | tb->has_coeffs = 0; | |
| 255 | 3262185 | tb->x0 = x0; | |
| 256 | 3262185 | tb->y0 = y0; | |
| 257 | 3262185 | tb->tb_width = tb_width; | |
| 258 | 3262185 | tb->tb_height = tb_height; | |
| 259 | 3262185 | tb->log2_tb_width = av_log2(tb_width); | |
| 260 | 3262185 | tb->log2_tb_height = av_log2(tb_height); | |
| 261 | |||
| 262 | 3262185 | tb->max_scan_x = tb->max_scan_y = 0; | |
| 263 | 3262185 | tb->min_scan_x = tb->min_scan_y = 0; | |
| 264 | |||
| 265 | 3262185 | tb->c_idx = c_idx; | |
| 266 | 3262185 | tb->ts = 0; | |
| 267 | 3262185 | tb->coeffs = lc->coeffs; | |
| 268 | 3262185 | lc->coeffs += tb_width * tb_height; | |
| 269 | 3262185 | tu->avail[!!c_idx] = true; | |
| 270 | 3262185 | return tb; | |
| 271 | } | ||
| 272 | |||
| 273 | 1006602 | static uint8_t tu_y_coded_flag_decode(VVCLocalContext *lc, const int is_sbt_not_coded, | |
| 274 | const int sub_tu_index, const int is_isp, const int is_chroma_coded) | ||
| 275 | { | ||
| 276 | 1006602 | uint8_t tu_y_coded_flag = 0; | |
| 277 | 1006602 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 278 | 1006602 | CodingUnit *cu = lc->cu; | |
| 279 | |||
| 280 |
2/2✓ Branch 0 taken 961149 times.
✓ Branch 1 taken 45453 times.
|
1006602 | if (!is_sbt_not_coded) { |
| 281 |
4/4✓ Branch 0 taken 815032 times.
✓ Branch 1 taken 146117 times.
✓ Branch 2 taken 52356 times.
✓ Branch 3 taken 762676 times.
|
961149 | int has_y_coded_flag = sub_tu_index < cu->num_intra_subpartitions - 1 || !lc->parse.infer_tu_cbf_luma; |
| 282 |
2/2✓ Branch 0 taken 750323 times.
✓ Branch 1 taken 210826 times.
|
961149 | if (!is_isp) { |
| 283 |
4/4✓ Branch 0 taken 736039 times.
✓ Branch 1 taken 14284 times.
✓ Branch 2 taken 2942 times.
✓ Branch 3 taken 733097 times.
|
750323 | const int is_large = cu->cb_width > sps->max_tb_size_y || cu->cb_height > sps->max_tb_size_y; |
| 284 |
8/8✓ Branch 0 taken 562305 times.
✓ Branch 1 taken 188018 times.
✓ Branch 2 taken 6377 times.
✓ Branch 3 taken 555928 times.
✓ Branch 4 taken 125716 times.
✓ Branch 5 taken 68679 times.
✓ Branch 6 taken 4881 times.
✓ Branch 7 taken 120835 times.
|
750323 | has_y_coded_flag = (cu->pred_mode == MODE_INTRA && !cu->act_enabled_flag) || is_chroma_coded || is_large; |
| 285 | } | ||
| 286 |
2/2✓ Branch 0 taken 827961 times.
✓ Branch 1 taken 133188 times.
|
961149 | tu_y_coded_flag = has_y_coded_flag ? ff_vvc_tu_y_coded_flag(lc) : 1; |
| 287 | } | ||
| 288 |
2/2✓ Branch 0 taken 210826 times.
✓ Branch 1 taken 795776 times.
|
1006602 | if (is_isp) |
| 289 |
4/4✓ Branch 0 taken 105174 times.
✓ Branch 1 taken 105652 times.
✓ Branch 2 taken 40465 times.
✓ Branch 3 taken 64709 times.
|
210826 | lc->parse.infer_tu_cbf_luma = lc->parse.infer_tu_cbf_luma && !tu_y_coded_flag; |
| 290 | 1006602 | return tu_y_coded_flag; | |
| 291 | } | ||
| 292 | |||
| 293 | 511890 | static void chroma_qp_offset_decode(VVCLocalContext *lc, const int is_128, const int is_chroma_coded) | |
| 294 | { | ||
| 295 | 511890 | const VVCPPS *pps = lc->fc->ps.pps; | |
| 296 | 511890 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 297 | |||
| 298 |
4/4✓ Branch 0 taken 502952 times.
✓ Branch 1 taken 8938 times.
✓ Branch 2 taken 197840 times.
✓ Branch 3 taken 305112 times.
|
511890 | if ((is_128 || is_chroma_coded) && |
| 299 |
4/4✓ Branch 0 taken 39307 times.
✓ Branch 1 taken 167471 times.
✓ Branch 2 taken 1029 times.
✓ Branch 3 taken 38278 times.
|
206778 | rsh->sh_cu_chroma_qp_offset_enabled_flag && !lc->parse.is_cu_chroma_qp_offset_coded) { |
| 300 | 1029 | const int cu_chroma_qp_offset_flag = ff_vvc_cu_chroma_qp_offset_flag(lc); | |
| 301 |
1/2✓ Branch 0 taken 1029 times.
✗ Branch 1 not taken.
|
1029 | if (cu_chroma_qp_offset_flag) { |
| 302 | 1029 | int cu_chroma_qp_offset_idx = 0; | |
| 303 |
2/2✓ Branch 0 taken 931 times.
✓ Branch 1 taken 98 times.
|
1029 | if (pps->r->pps_chroma_qp_offset_list_len_minus1 > 0) |
| 304 | 931 | cu_chroma_qp_offset_idx = ff_vvc_cu_chroma_qp_offset_idx(lc); | |
| 305 |
2/2✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 1029 times.
|
4116 | for (int i = CB - 1; i < JCBCR; i++) |
| 306 | 3087 | lc->parse.chroma_qp_offset[i] = pps->chroma_qp_offset_list[cu_chroma_qp_offset_idx][i]; | |
| 307 | } else { | ||
| 308 | ✗ | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
| 309 | } | ||
| 310 | 1029 | lc->parse.is_cu_chroma_qp_offset_coded = 1; | |
| 311 | } | ||
| 312 | 511890 | } | |
| 313 | |||
| 314 | 1194766 | static int hls_transform_unit(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int sub_tu_index, int ch_type) | |
| 315 | { | ||
| 316 | 1194766 | VVCFrameContext *fc = lc->fc; | |
| 317 | 1194766 | const VVCSPS *sps = fc->ps.sps; | |
| 318 | 1194766 | const VVCPPS *pps = fc->ps.pps; | |
| 319 | 1194766 | CodingUnit *cu = lc->cu; | |
| 320 | 1194766 | TransformUnit *tu = add_tu(fc, cu, x0, y0, tu_width, tu_height); | |
| 321 | 1194766 | const int min_cb_width = pps->min_cb_width; | |
| 322 | 1194766 | const VVCTreeType tree_type = cu->tree_type; | |
| 323 |
4/4✓ Branch 0 taken 1187514 times.
✓ Branch 1 taken 7252 times.
✓ Branch 2 taken 1686 times.
✓ Branch 3 taken 1185828 times.
|
1194766 | const int is_128 = cu->cb_width > 64 || cu->cb_height > 64; |
| 324 | 1194766 | const int is_isp = cu->isp_split_type != ISP_NO_SPLIT; | |
| 325 |
4/4✓ Branch 0 taken 210826 times.
✓ Branch 1 taken 983940 times.
✓ Branch 2 taken 64709 times.
✓ Branch 3 taken 146117 times.
|
1194766 | const int is_isp_last_tu = is_isp && (sub_tu_index == cu->num_intra_subpartitions - 1); |
| 326 |
4/4✓ Branch 0 taken 90906 times.
✓ Branch 1 taken 1103860 times.
✓ Branch 2 taken 45453 times.
✓ Branch 3 taken 45453 times.
|
1285672 | const int is_sbt_not_coded = cu->sbt_flag && |
| 327 |
6/6✓ Branch 0 taken 23704 times.
✓ Branch 1 taken 21749 times.
✓ Branch 2 taken 45453 times.
✓ Branch 3 taken 23704 times.
✓ Branch 4 taken 23704 times.
✓ Branch 5 taken 21749 times.
|
90906 | ((sub_tu_index == 0 && cu->sbt_pos_flag) || (sub_tu_index == 1 && !cu->sbt_pos_flag)); |
| 328 |
6/6✓ Branch 0 taken 511890 times.
✓ Branch 1 taken 682876 times.
✓ Branch 2 taken 488418 times.
✓ Branch 3 taken 23472 times.
✓ Branch 4 taken 22306 times.
✓ Branch 5 taken 466112 times.
|
1217072 | const int chroma_available = tree_type != DUAL_TREE_LUMA && sps->r->sps_chroma_format_idc && |
| 329 |
2/2✓ Branch 0 taken 5627 times.
✓ Branch 1 taken 16679 times.
|
22306 | (!is_isp || is_isp_last_tu); |
| 330 | int ret, xc, yc, wc, hc, is_chroma_coded; | ||
| 331 | |||
| 332 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1194766 times.
|
1194766 | if (!tu) |
| 333 | ✗ | return AVERROR_INVALIDDATA; | |
| 334 | |||
| 335 |
4/4✓ Branch 0 taken 323726 times.
✓ Branch 1 taken 871040 times.
✓ Branch 2 taken 7409 times.
✓ Branch 3 taken 316317 times.
|
1194766 | if (tree_type == SINGLE_TREE && is_isp_last_tu) { |
| 336 | 7409 | const int x_cu = x0 >> fc->ps.sps->min_cb_log2_size_y; | |
| 337 | 7409 | const int y_cu = y0 >> fc->ps.sps->min_cb_log2_size_y; | |
| 338 | 7409 | xc = SAMPLE_CTB(fc->tab.cb_pos_x[ch_type], x_cu, y_cu); | |
| 339 | 7409 | yc = SAMPLE_CTB(fc->tab.cb_pos_y[ch_type], x_cu, y_cu); | |
| 340 | 7409 | wc = SAMPLE_CTB(fc->tab.cb_width[ch_type], x_cu, y_cu); | |
| 341 | 7409 | hc = SAMPLE_CTB(fc->tab.cb_height[ch_type], x_cu, y_cu); | |
| 342 | } else { | ||
| 343 | 1187357 | xc = x0, yc = y0, wc = tu_width, hc = tu_height; | |
| 344 | } | ||
| 345 | |||
| 346 |
4/4✓ Branch 0 taken 471739 times.
✓ Branch 1 taken 723027 times.
✓ Branch 2 taken 427578 times.
✓ Branch 3 taken 44161 times.
|
1194766 | if (chroma_available && !is_sbt_not_coded) { |
| 347 | 427578 | tu->coded_flag[CB] = ff_vvc_tu_cb_coded_flag(lc); | |
| 348 | 427578 | tu->coded_flag[CR] = ff_vvc_tu_cr_coded_flag(lc, tu->coded_flag[CB]); | |
| 349 | } | ||
| 350 | |||
| 351 |
6/6✓ Branch 0 taken 471739 times.
✓ Branch 1 taken 723027 times.
✓ Branch 2 taken 302237 times.
✓ Branch 3 taken 169502 times.
✓ Branch 4 taken 34269 times.
✓ Branch 5 taken 267968 times.
|
1194766 | is_chroma_coded = chroma_available && (tu->coded_flag[CB] || tu->coded_flag[CR]); |
| 352 | |||
| 353 |
2/2✓ Branch 0 taken 1006602 times.
✓ Branch 1 taken 188164 times.
|
1194766 | if (tree_type != DUAL_TREE_CHROMA) { |
| 354 | int has_qp_delta; | ||
| 355 | 1006602 | tu->coded_flag[LUMA] = tu_y_coded_flag_decode(lc, is_sbt_not_coded, sub_tu_index, is_isp, is_chroma_coded); | |
| 356 |
4/4✓ Branch 0 taken 268707 times.
✓ Branch 1 taken 728957 times.
✓ Branch 2 taken 36248 times.
✓ Branch 3 taken 232459 times.
|
997664 | has_qp_delta = (is_128 || tu->coded_flag[LUMA] || is_chroma_coded) && |
| 357 |
6/6✓ Branch 0 taken 997664 times.
✓ Branch 1 taken 8938 times.
✓ Branch 2 taken 77901 times.
✓ Branch 3 taken 696242 times.
✓ Branch 4 taken 1888 times.
✓ Branch 5 taken 76013 times.
|
2004266 | pps->r->pps_cu_qp_delta_enabled_flag && !lc->parse.is_cu_qp_delta_coded; |
| 358 | 1006602 | ret = set_qp_y(lc, x0, y0, has_qp_delta); | |
| 359 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1006602 times.
|
1006602 | if (ret < 0) |
| 360 | ✗ | return ret; | |
| 361 | 1006602 | add_tb(tu, lc, x0, y0, tu_width, tu_height, LUMA); | |
| 362 | } | ||
| 363 |
2/2✓ Branch 0 taken 511890 times.
✓ Branch 1 taken 682876 times.
|
1194766 | if (tree_type != DUAL_TREE_LUMA) { |
| 364 | 511890 | chroma_qp_offset_decode(lc, is_128, is_chroma_coded); | |
| 365 |
2/2✓ Branch 0 taken 471739 times.
✓ Branch 1 taken 40151 times.
|
511890 | if (chroma_available) { |
| 366 | 471739 | const int hs = sps->hshift[CHROMA]; | |
| 367 | 471739 | const int vs = sps->vshift[CHROMA]; | |
| 368 | 471739 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CB); | |
| 369 | 471739 | add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs, CR); | |
| 370 | } | ||
| 371 | } | ||
| 372 |
4/4✓ Branch 0 taken 1151562 times.
✓ Branch 1 taken 43204 times.
✓ Branch 2 taken 926412 times.
✓ Branch 3 taken 225150 times.
|
1194766 | if (sps->r->sps_joint_cbcr_enabled_flag && ((cu->pred_mode == MODE_INTRA && |
| 373 |
4/4✓ Branch 0 taken 819718 times.
✓ Branch 1 taken 106694 times.
✓ Branch 2 taken 793777 times.
✓ Branch 3 taken 25941 times.
|
926412 | (tu->coded_flag[CB] || tu->coded_flag[CR])) || |
| 374 |
5/6✓ Branch 0 taken 57418 times.
✓ Branch 1 taken 961509 times.
✓ Branch 2 taken 25270 times.
✓ Branch 3 taken 32148 times.
✓ Branch 4 taken 157905 times.
✗ Branch 5 not taken.
|
1151562 | (tu->coded_flag[CB] && tu->coded_flag[CR])) && |
| 375 | chroma_available) { | ||
| 376 | 157905 | tu->joint_cbcr_residual_flag = ff_vvc_tu_joint_cbcr_residual_flag(lc, tu->coded_flag[1], tu->coded_flag[2]); | |
| 377 | } | ||
| 378 | |||
| 379 |
2/2✓ Branch 0 taken 1950080 times.
✓ Branch 1 taken 1194766 times.
|
3144846 | for (int i = 0; i < tu->nb_tbs; i++) { |
| 380 | 1950080 | TransformBlock *tb = &tu->tbs[i]; | |
| 381 | 1950080 | const int is_chroma = tb->c_idx != LUMA; | |
| 382 | 1950080 | tb->has_coeffs = tu->coded_flag[tb->c_idx]; | |
| 383 |
4/4✓ Branch 0 taken 1035961 times.
✓ Branch 1 taken 914119 times.
✓ Branch 2 taken 300686 times.
✓ Branch 3 taken 735275 times.
|
1950080 | if (tb->has_coeffs && is_chroma) |
| 384 |
6/6✓ Branch 0 taken 131184 times.
✓ Branch 1 taken 169502 times.
✓ Branch 2 taken 96915 times.
✓ Branch 3 taken 34269 times.
✓ Branch 4 taken 65881 times.
✓ Branch 5 taken 31034 times.
|
300686 | tb->has_coeffs = tb->c_idx == CB ? 1 : !(tu->coded_flag[CB] && tu->joint_cbcr_residual_flag); |
| 385 |
2/2✓ Branch 0 taken 1004927 times.
✓ Branch 1 taken 945153 times.
|
1950080 | if (tb->has_coeffs) { |
| 386 | 1004927 | tb->ts = cu->bdpcm_flag[tb->c_idx]; | |
| 387 |
4/4✓ Branch 0 taken 887299 times.
✓ Branch 1 taken 117628 times.
✓ Branch 2 taken 885094 times.
✓ Branch 3 taken 2205 times.
|
1004927 | if (sps->r->sps_transform_skip_enabled_flag && !cu->bdpcm_flag[tb->c_idx] && |
| 388 |
4/4✓ Branch 0 taken 868538 times.
✓ Branch 1 taken 16556 times.
✓ Branch 2 taken 861219 times.
✓ Branch 3 taken 7319 times.
|
885094 | tb->tb_width <= sps->max_ts_size && tb->tb_height <= sps->max_ts_size && |
| 389 |
6/6✓ Branch 0 taken 820708 times.
✓ Branch 1 taken 40511 times.
✓ Branch 2 taken 629783 times.
✓ Branch 3 taken 190925 times.
✓ Branch 4 taken 491999 times.
✓ Branch 5 taken 137784 times.
|
861219 | !cu->sbt_flag && (is_chroma || !is_isp)) { |
| 390 | 682924 | tb->ts = ff_vvc_transform_skip_flag(lc, is_chroma); | |
| 391 | } | ||
| 392 | 1004927 | ret = ff_vvc_residual_coding(lc, tb); | |
| 393 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1004927 times.
|
1004927 | if (ret < 0) |
| 394 | ✗ | return ret; | |
| 395 | 1004927 | set_tb_tab(fc->tab.tu_coded_flag[tb->c_idx], tu->coded_flag[tb->c_idx], fc, tb); | |
| 396 |
2/2✓ Branch 0 taken 24384 times.
✓ Branch 1 taken 920769 times.
|
945153 | } else if (cu->act_enabled_flag) { |
| 397 | 24384 | memset(tb->coeffs, 0, tb->tb_width * tb->tb_height * sizeof(*tb->coeffs)); | |
| 398 | } | ||
| 399 |
2/2✓ Branch 0 taken 1478341 times.
✓ Branch 1 taken 471739 times.
|
1950080 | if (tb->c_idx != CR) |
| 400 | 1478341 | set_tb_size(fc, tb); | |
| 401 |
2/2✓ Branch 0 taken 471739 times.
✓ Branch 1 taken 1478341 times.
|
1950080 | if (tb->c_idx == CB) |
| 402 | 471739 | set_tb_tab(fc->tab.tu_joint_cbcr_residual_flag, tu->joint_cbcr_residual_flag, fc, tb); | |
| 403 | } | ||
| 404 | |||
| 405 | 1194766 | return 0; | |
| 406 | } | ||
| 407 | |||
| 408 | 1016130 | static int hls_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height, int ch_type) | |
| 409 | { | ||
| 410 | 1016130 | const CodingUnit *cu = lc->cu; | |
| 411 | 1016130 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 412 | int ret; | ||
| 413 | |||
| 414 | 1016130 | lc->parse.infer_tu_cbf_luma = 1; | |
| 415 |
4/4✓ Branch 0 taken 951421 times.
✓ Branch 1 taken 64709 times.
✓ Branch 2 taken 905968 times.
✓ Branch 3 taken 45453 times.
|
1016130 | if (cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag) { |
| 416 |
4/4✓ Branch 0 taken 895007 times.
✓ Branch 1 taken 10961 times.
✓ Branch 2 taken 1973 times.
✓ Branch 3 taken 893034 times.
|
918902 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
| 417 |
4/4✓ Branch 0 taken 10961 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 8066 times.
✓ Branch 3 taken 2895 times.
|
12934 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
| 418 |
2/2✓ Branch 0 taken 8066 times.
✓ Branch 1 taken 4868 times.
|
12934 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
| 419 |
2/2✓ Branch 0 taken 4868 times.
✓ Branch 1 taken 8066 times.
|
12934 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
| 420 | |||
| 421 | #define TRANSFORM_TREE(x, y) do { \ | ||
| 422 | ret = hls_transform_tree(lc, x, y, trafo_width, trafo_height, ch_type); \ | ||
| 423 | if (ret < 0) \ | ||
| 424 | return ret; \ | ||
| 425 | } while (0) | ||
| 426 | |||
| 427 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12934 times.
|
12934 | TRANSFORM_TREE(x0, y0); |
| 428 |
2/2✓ Branch 0 taken 8066 times.
✓ Branch 1 taken 4868 times.
|
12934 | if (ver_split_first) |
| 429 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8066 times.
|
8066 | TRANSFORM_TREE(x0 + trafo_width, y0); |
| 430 | else | ||
| 431 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4868 times.
|
4868 | TRANSFORM_TREE(x0, y0 + trafo_height); |
| 432 | |||
| 433 | } else { | ||
| 434 | 893034 | ret = hls_transform_unit(lc, x0, y0, tu_width, tu_height, 0, ch_type); | |
| 435 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 893034 times.
|
893034 | if (ret < 0) |
| 436 | ✗ | return ret; | |
| 437 | |||
| 438 | } | ||
| 439 |
2/2✓ Branch 0 taken 45453 times.
✓ Branch 1 taken 64709 times.
|
110162 | } else if (cu->sbt_flag) { |
| 440 |
2/2✓ Branch 0 taken 24022 times.
✓ Branch 1 taken 21431 times.
|
45453 | if (!cu->sbt_horizontal_flag) { |
| 441 | #define TRANSFORM_UNIT(x, width, idx) do { \ | ||
| 442 | ret = hls_transform_unit(lc, x, y0, width, tu_height, idx, ch_type); \ | ||
| 443 | if (ret < 0) \ | ||
| 444 | return ret; \ | ||
| 445 | } while (0) | ||
| 446 | |||
| 447 | 24022 | const int trafo_width = tu_width * lc->parse.sbt_num_fourths_tb0 / 4; | |
| 448 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 24022 times.
|
24022 | TRANSFORM_UNIT(x0, trafo_width, 0); |
| 449 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 24022 times.
|
24022 | TRANSFORM_UNIT(x0 + trafo_width, tu_width - trafo_width, 1); |
| 450 | |||
| 451 | #undef TRANSFORM_UNIT | ||
| 452 | } else { | ||
| 453 | #define TRANSFORM_UNIT(y, height, idx) do { \ | ||
| 454 | ret = hls_transform_unit(lc, x0, y, tu_width, height, idx, ch_type); \ | ||
| 455 | if (ret < 0) \ | ||
| 456 | return ret; \ | ||
| 457 | } while (0) | ||
| 458 | |||
| 459 | 21431 | const int trafo_height = tu_height * lc->parse.sbt_num_fourths_tb0 / 4; | |
| 460 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21431 times.
|
21431 | TRANSFORM_UNIT(y0, trafo_height, 0); |
| 461 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 21431 times.
|
21431 | TRANSFORM_UNIT(y0 + trafo_height, tu_height - trafo_height, 1); |
| 462 | |||
| 463 | #undef TRANSFORM_UNIT | ||
| 464 | } | ||
| 465 |
2/2✓ Branch 0 taken 40123 times.
✓ Branch 1 taken 24586 times.
|
64709 | } else if (cu->isp_split_type == ISP_HOR_SPLIT) { |
| 466 | 40123 | const int trafo_height = tu_height / cu->num_intra_subpartitions; | |
| 467 |
2/2✓ Branch 0 taken 134388 times.
✓ Branch 1 taken 40123 times.
|
174511 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
| 468 | 134388 | ret = hls_transform_unit(lc, x0, y0 + trafo_height * i, tu_width, trafo_height, i, 0); | |
| 469 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 134388 times.
|
134388 | if (ret < 0) |
| 470 | ✗ | return ret; | |
| 471 | } | ||
| 472 |
1/2✓ Branch 0 taken 24586 times.
✗ Branch 1 not taken.
|
24586 | } else if (cu->isp_split_type == ISP_VER_SPLIT) { |
| 473 | 24586 | const int trafo_width = tu_width / cu->num_intra_subpartitions; | |
| 474 |
2/2✓ Branch 0 taken 76438 times.
✓ Branch 1 taken 24586 times.
|
101024 | for (int i = 0; i < cu->num_intra_subpartitions; i++) { |
| 475 | 76438 | ret = hls_transform_unit(lc, x0 + trafo_width * i , y0, trafo_width, tu_height, i, 0); | |
| 476 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 76438 times.
|
76438 | if (ret < 0) |
| 477 | ✗ | return ret; | |
| 478 | } | ||
| 479 | } | ||
| 480 | |||
| 481 | 1016130 | return 0; | |
| 482 | } | ||
| 483 | |||
| 484 | 579458 | static int skipped_transform_tree(VVCLocalContext *lc, int x0, int y0,int tu_width, int tu_height) | |
| 485 | { | ||
| 486 | 579458 | VVCFrameContext *fc = lc->fc; | |
| 487 | 579458 | const CodingUnit *cu = lc->cu; | |
| 488 | 579458 | const VVCSPS *sps = fc->ps.sps; | |
| 489 | |||
| 490 |
4/4✓ Branch 0 taken 467477 times.
✓ Branch 1 taken 111981 times.
✓ Branch 2 taken 2823 times.
✓ Branch 3 taken 464654 times.
|
694262 | if (tu_width > sps->max_tb_size_y || tu_height > sps->max_tb_size_y) { |
| 491 |
4/4✓ Branch 0 taken 111981 times.
✓ Branch 1 taken 2823 times.
✓ Branch 2 taken 76282 times.
✓ Branch 3 taken 35699 times.
|
114804 | const int ver_split_first = tu_width > sps->max_tb_size_y && tu_width > tu_height; |
| 492 |
2/2✓ Branch 0 taken 76282 times.
✓ Branch 1 taken 38522 times.
|
114804 | const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width; |
| 493 |
2/2✓ Branch 0 taken 38522 times.
✓ Branch 1 taken 76282 times.
|
114804 | const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height; |
| 494 | |||
| 495 | #define SKIPPED_TRANSFORM_TREE(x, y) do { \ | ||
| 496 | int ret = skipped_transform_tree(lc, x, y, trafo_width, trafo_height); \ | ||
| 497 | if (ret < 0) \ | ||
| 498 | return ret; \ | ||
| 499 | } while (0) | ||
| 500 | |||
| 501 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 114804 times.
|
114804 | SKIPPED_TRANSFORM_TREE(x0, y0); |
| 502 |
2/2✓ Branch 0 taken 76282 times.
✓ Branch 1 taken 38522 times.
|
114804 | if (ver_split_first) |
| 503 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 76282 times.
|
76282 | SKIPPED_TRANSFORM_TREE(x0 + trafo_width, y0); |
| 504 | else | ||
| 505 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 38522 times.
|
38522 | SKIPPED_TRANSFORM_TREE(x0, y0 + trafo_height); |
| 506 | } else { | ||
| 507 | 464654 | TransformUnit *tu = add_tu(fc, lc->cu, x0, y0, tu_width, tu_height); | |
| 508 | int start, end; | ||
| 509 | |||
| 510 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 464654 times.
|
464654 | if (!tu) |
| 511 | ✗ | return AVERROR_INVALIDDATA; | |
| 512 | 464654 | ff_vvc_channel_range(&start, &end, cu->tree_type, sps->r->sps_chroma_format_idc); | |
| 513 |
2/2✓ Branch 0 taken 1299518 times.
✓ Branch 1 taken 464654 times.
|
1764172 | for (int i = start; i < end; i++) { |
| 514 | 1299518 | TransformBlock *tb = add_tb(tu, lc, x0, y0, tu_width >> sps->hshift[i], tu_height >> sps->vshift[i], i); | |
| 515 |
2/2✓ Branch 0 taken 882086 times.
✓ Branch 1 taken 417432 times.
|
1299518 | if (i != CR) |
| 516 | 882086 | set_tb_size(fc, tb); | |
| 517 | } | ||
| 518 | } | ||
| 519 | |||
| 520 | 579458 | return 0; | |
| 521 | } | ||
| 522 | |||
| 523 | //6.4.1 Allowed quad split process | ||
| 524 | //6.4.2 Allowed binary split process | ||
| 525 | //6.4.3 Allowed ternary split process | ||
| 526 | 2212166 | static void can_split(const VVCLocalContext *lc, int x0, int y0,int cb_width, int cb_height, | |
| 527 | int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, | ||
| 528 | VVCTreeType tree_type, VVCModeType mode_type, VVCAllowedSplit* split) | ||
| 529 | { | ||
| 530 | int min_qt_size, max_bt_size, max_tt_size, max_mtt_depth; | ||
| 531 | 2212166 | const VVCFrameContext *fc = lc->fc; | |
| 532 | 2212166 | const VVCSH *sh = &lc->sc->sh; | |
| 533 | 2212166 | const VVCSPS *sps = fc->ps.sps; | |
| 534 | 2212166 | const VVCPPS *pps = fc->ps.pps; | |
| 535 | 2212166 | const int chroma = tree_type == DUAL_TREE_CHROMA; | |
| 536 | 2212166 | int min_cb_size_y = sps->min_cb_size_y; | |
| 537 | 2212166 | int *qt = &split->qt; | |
| 538 | 2212166 | int *btv = &split->btv; | |
| 539 | 2212166 | int *bth = &split->bth; | |
| 540 | 2212166 | int *ttv = &split->ttv; | |
| 541 | 2212166 | int *tth = &split->tth; | |
| 542 | |||
| 543 | 2212166 | *qt = *bth = *btv = *tth = *ttv = 1; | |
| 544 | |||
| 545 |
2/2✓ Branch 0 taken 1695949 times.
✓ Branch 1 taken 516217 times.
|
2212166 | if (mtt_depth) |
| 546 | 1695949 | *qt = 0; | |
| 547 | |||
| 548 | 2212166 | min_qt_size = sh->min_qt_size[chroma]; | |
| 549 |
2/2✓ Branch 0 taken 933527 times.
✓ Branch 1 taken 1278639 times.
|
2212166 | if (cb_width <= min_qt_size) |
| 550 | 933527 | *qt = 0; | |
| 551 | |||
| 552 |
2/2✓ Branch 0 taken 290701 times.
✓ Branch 1 taken 1921465 times.
|
2212166 | if (chroma) { |
| 553 | 290701 | int chroma_area = (cb_width >> sps->hshift[1]) * (cb_height >> sps->vshift[1]); | |
| 554 | 290701 | int chroma_width = cb_width >> sps->hshift[1]; | |
| 555 | |||
| 556 |
2/2✓ Branch 0 taken 90264 times.
✓ Branch 1 taken 200437 times.
|
290701 | if (chroma_width == 8) |
| 557 | 90264 | *ttv = 0; | |
| 558 |
2/2✓ Branch 0 taken 73021 times.
✓ Branch 1 taken 127416 times.
|
200437 | else if (chroma_width <= 4) { |
| 559 |
1/2✓ Branch 0 taken 73021 times.
✗ Branch 1 not taken.
|
73021 | if (chroma_width == 4) |
| 560 | 73021 | *btv = 0; | |
| 561 | 73021 | *qt = 0; | |
| 562 | } | ||
| 563 |
2/2✓ Branch 0 taken 29134 times.
✓ Branch 1 taken 261567 times.
|
290701 | if (mode_type == MODE_TYPE_INTRA) |
| 564 | 29134 | *qt = *btv = *bth = *ttv = *tth = 0; | |
| 565 |
2/2✓ Branch 0 taken 106631 times.
✓ Branch 1 taken 184070 times.
|
290701 | if (chroma_area <= 32) { |
| 566 | 106631 | *ttv = *tth = 0; | |
| 567 |
2/2✓ Branch 0 taken 48250 times.
✓ Branch 1 taken 58381 times.
|
106631 | if (chroma_area <= 16) |
| 568 | 48250 | *btv = *bth = 0; | |
| 569 | } | ||
| 570 | } | ||
| 571 | 2212166 | max_bt_size = sh->max_bt_size[chroma]; | |
| 572 | 2212166 | max_tt_size = sh->max_tt_size[chroma]; | |
| 573 | 2212166 | max_mtt_depth = sh->max_mtt_depth[chroma] + depth_offset; | |
| 574 | |||
| 575 |
2/2✓ Branch 0 taken 71682 times.
✓ Branch 1 taken 2140484 times.
|
2212166 | if (mode_type == MODE_TYPE_INTER) { |
| 576 | 71682 | int area = cb_width * cb_height; | |
| 577 |
2/2✓ Branch 0 taken 29760 times.
✓ Branch 1 taken 41922 times.
|
71682 | if (area == 32) |
| 578 | 29760 | *btv = *bth = 0; | |
| 579 |
2/2✓ Branch 0 taken 24870 times.
✓ Branch 1 taken 17052 times.
|
41922 | else if (area == 64) |
| 580 | 24870 | *ttv = *tth = 0; | |
| 581 | } | ||
| 582 |
2/2✓ Branch 0 taken 918826 times.
✓ Branch 1 taken 1293340 times.
|
2212166 | if (cb_width <= 2 * min_cb_size_y) { |
| 583 | 918826 | *ttv = 0; | |
| 584 |
2/2✓ Branch 0 taken 349320 times.
✓ Branch 1 taken 569506 times.
|
918826 | if (cb_width <= min_cb_size_y) |
| 585 | 349320 | *btv = 0; | |
| 586 | } | ||
| 587 |
2/2✓ Branch 0 taken 1005558 times.
✓ Branch 1 taken 1206608 times.
|
2212166 | if (cb_height <= 2 * min_cb_size_y) { |
| 588 | 1005558 | *tth = 0; | |
| 589 |
2/2✓ Branch 0 taken 404313 times.
✓ Branch 1 taken 601245 times.
|
1005558 | if (cb_height <= min_cb_size_y) |
| 590 | 404313 | *bth = 0; | |
| 591 | } | ||
| 592 |
4/4✓ Branch 0 taken 2155094 times.
✓ Branch 1 taken 57072 times.
✓ Branch 2 taken 705 times.
✓ Branch 3 taken 2154389 times.
|
2212166 | if (cb_width > max_bt_size || cb_height > max_bt_size) |
| 593 | 57777 | *btv = *bth = 0; | |
| 594 | 2212166 | max_tt_size = FFMIN(64, max_tt_size); | |
| 595 |
4/4✓ Branch 0 taken 2078685 times.
✓ Branch 1 taken 133481 times.
✓ Branch 2 taken 8548 times.
✓ Branch 3 taken 2070137 times.
|
2212166 | if (cb_width > max_tt_size || cb_height > max_tt_size) |
| 596 | 142029 | *ttv = *tth = 0; | |
| 597 |
2/2✓ Branch 0 taken 447302 times.
✓ Branch 1 taken 1764864 times.
|
2212166 | if (mtt_depth >= max_mtt_depth) |
| 598 | 447302 | *btv = *bth = *ttv = *tth = 0; | |
| 599 |
2/2✓ Branch 0 taken 5029 times.
✓ Branch 1 taken 2207137 times.
|
2212166 | if (x0 + cb_width > pps->width) { |
| 600 | 5029 | *ttv = *tth = 0; | |
| 601 |
2/2✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 3538 times.
|
5029 | if (cb_height > 64) |
| 602 | 1491 | *btv = 0; | |
| 603 |
2/2✓ Branch 0 taken 3735 times.
✓ Branch 1 taken 1294 times.
|
5029 | if (y0 + cb_height <= pps->height) |
| 604 | 3735 | *bth = 0; | |
| 605 |
2/2✓ Branch 0 taken 1240 times.
✓ Branch 1 taken 54 times.
|
1294 | else if (cb_width > min_qt_size) |
| 606 | 1240 | *btv = *bth = 0; | |
| 607 | } | ||
| 608 |
2/2✓ Branch 0 taken 55685 times.
✓ Branch 1 taken 2156481 times.
|
2212166 | if (y0 + cb_height > pps->height) { |
| 609 | 55685 | *btv = *ttv = *tth = 0; | |
| 610 |
2/2✓ Branch 0 taken 7348 times.
✓ Branch 1 taken 48337 times.
|
55685 | if (cb_width > 64) |
| 611 | 7348 | *bth = 0; | |
| 612 | } | ||
| 613 |
4/4✓ Branch 0 taken 1695949 times.
✓ Branch 1 taken 516217 times.
✓ Branch 2 taken 734322 times.
✓ Branch 3 taken 961627 times.
|
2212166 | if (mtt_depth > 0 && part_idx == 1) { |
| 614 |
2/2✓ Branch 0 taken 87586 times.
✓ Branch 1 taken 646736 times.
|
734322 | if (last_split_mode == SPLIT_TT_VER) |
| 615 | 87586 | *btv = 0; | |
| 616 |
2/2✓ Branch 0 taken 92649 times.
✓ Branch 1 taken 554087 times.
|
646736 | else if (last_split_mode == SPLIT_TT_HOR) |
| 617 | 92649 | *bth = 0; | |
| 618 | } | ||
| 619 |
4/4✓ Branch 0 taken 2162189 times.
✓ Branch 1 taken 49977 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 2158833 times.
|
2212166 | if (cb_width <= 64 && cb_height > 64) |
| 620 | 3356 | *btv = 0; | |
| 621 |
4/4✓ Branch 0 taken 49977 times.
✓ Branch 1 taken 2162189 times.
✓ Branch 2 taken 3466 times.
✓ Branch 3 taken 46511 times.
|
2212166 | if (cb_width > 64 && cb_height <= 64) |
| 622 | 3466 | *bth = 0; | |
| 623 | 2212166 | } | |
| 624 | |||
| 625 | 503220 | static int get_num_intra_subpartitions(enum IspType isp_split_type, int cb_width, int cb_height) | |
| 626 | { | ||
| 627 |
2/2✓ Branch 0 taken 438511 times.
✓ Branch 1 taken 64709 times.
|
503220 | if (isp_split_type == ISP_NO_SPLIT) |
| 628 | 438511 | return 1; | |
| 629 |
8/8✓ Branch 0 taken 15455 times.
✓ Branch 1 taken 49254 times.
✓ Branch 2 taken 4345 times.
✓ Branch 3 taken 11110 times.
✓ Branch 4 taken 23500 times.
✓ Branch 5 taken 30099 times.
✓ Branch 6 taken 12895 times.
✓ Branch 7 taken 10605 times.
|
64709 | if ((cb_width == 4 && cb_height == 8) || (cb_width == 8 && cb_height == 4)) |
| 630 | 24005 | return 2; | |
| 631 | 40704 | return 4; | |
| 632 | } | ||
| 633 | |||
| 634 | 243754 | static int get_cclm_enabled(const VVCLocalContext *lc, const int x0, const int y0) | |
| 635 | { | ||
| 636 | 243754 | const VVCFrameContext *fc = lc->fc; | |
| 637 | 243754 | const VVCSPS *sps = fc->ps.sps; | |
| 638 | 243754 | int enabled = 0; | |
| 639 | |||
| 640 |
2/2✓ Branch 0 taken 449 times.
✓ Branch 1 taken 243305 times.
|
243754 | if (!sps->r->sps_cclm_enabled_flag) |
| 641 | 449 | return 0; | |
| 642 |
6/6✓ Branch 0 taken 222522 times.
✓ Branch 1 taken 20783 times.
✓ Branch 2 taken 158171 times.
✓ Branch 3 taken 64351 times.
✓ Branch 4 taken 1163 times.
✓ Branch 5 taken 157008 times.
|
243305 | if (!sps->r->sps_qtbtt_dual_tree_intra_flag || !IS_I(lc->sc->sh.r) || sps->ctb_log2_size_y < 6) |
| 643 | 86297 | return 1; | |
| 644 | else { | ||
| 645 | 157008 | const int x64 = x0 >> 6 << 6; | |
| 646 | 157008 | const int y64 = y0 >> 6 << 6; | |
| 647 | 157008 | const int y32 = y0 >> 5 << 5; | |
| 648 | 157008 | const int x64_cu = x64 >> fc->ps.sps->min_cb_log2_size_y; | |
| 649 | 157008 | const int y64_cu = y64 >> fc->ps.sps->min_cb_log2_size_y; | |
| 650 | 157008 | const int y32_cu = y32 >> fc->ps.sps->min_cb_log2_size_y; | |
| 651 | 157008 | const int min_cb_width = fc->ps.pps->min_cb_width; | |
| 652 | 157008 | const int depth = SAMPLE_CTB(fc->tab.cqt_depth[1], x64_cu, y64_cu); | |
| 653 | 157008 | const int min_depth = fc->ps.sps->ctb_log2_size_y - 6; | |
| 654 | 157008 | const VVCSplitMode msm64 = (VVCSplitMode)TAB_MSM(fc, 0, x64, y64); | |
| 655 | 157008 | const VVCSplitMode msm32 = (VVCSplitMode)TAB_MSM(fc, 1, x64, y32); | |
| 656 | |||
| 657 |
2/2✓ Branch 0 taken 19375 times.
✓ Branch 1 taken 137633 times.
|
176383 | enabled = SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y64_cu) == 64 && |
| 658 |
2/2✓ Branch 0 taken 6527 times.
✓ Branch 1 taken 12848 times.
|
19375 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y64_cu) == 64; |
| 659 |
2/2✓ Branch 0 taken 21666 times.
✓ Branch 1 taken 16231 times.
|
37897 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && |
| 660 |
4/4✓ Branch 0 taken 37897 times.
✓ Branch 1 taken 119111 times.
✓ Branch 2 taken 12084 times.
✓ Branch 3 taken 9582 times.
|
206989 | SAMPLE_CTB(fc->tab.cb_width[1], x64_cu, y32_cu) == 64 && |
| 661 |
2/2✓ Branch 0 taken 4734 times.
✓ Branch 1 taken 7350 times.
|
12084 | SAMPLE_CTB(fc->tab.cb_height[1], x64_cu, y32_cu) == 32; |
| 662 | 157008 | enabled |= depth > min_depth; | |
| 663 |
6/6✓ Branch 0 taken 37897 times.
✓ Branch 1 taken 119111 times.
✓ Branch 2 taken 21666 times.
✓ Branch 3 taken 16231 times.
✓ Branch 4 taken 7990 times.
✓ Branch 5 taken 13676 times.
|
157008 | enabled |= depth == min_depth && msm64 == SPLIT_BT_HOR && msm32 == SPLIT_BT_VER; |
| 664 | |||
| 665 |
2/2✓ Branch 0 taken 137905 times.
✓ Branch 1 taken 19103 times.
|
157008 | if (enabled) { |
| 666 | 137905 | const int w = SAMPLE_CTB(fc->tab.cb_width[0], x64_cu, y64_cu); | |
| 667 | 137905 | const int h = SAMPLE_CTB(fc->tab.cb_height[0], x64_cu, y64_cu); | |
| 668 | 137905 | const int depth0 = SAMPLE_CTB(fc->tab.cqt_depth[0], x64_cu, y64_cu); | |
| 669 |
8/8✓ Branch 0 taken 5746 times.
✓ Branch 1 taken 132159 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 132159 times.
|
137905 | if ((w == 64 && h == 64 && TAB_ISPMF(fc, x64, y64)) || |
| 670 |
4/4✓ Branch 0 taken 190 times.
✓ Branch 1 taken 4964 times.
✓ Branch 2 taken 1286 times.
✓ Branch 3 taken 131063 times.
|
137313 | ((w < 64 || h < 64) && depth0 == min_depth)) |
| 671 | 1878 | return 0; | |
| 672 | } | ||
| 673 | |||
| 674 | } | ||
| 675 | |||
| 676 | 155130 | return enabled; | |
| 677 | } | ||
| 678 | |||
| 679 | 893971 | static int less(const void *a, const void *b) | |
| 680 | { | ||
| 681 | 893971 | return *(const int*)a - *(const int*)b; | |
| 682 | } | ||
| 683 | |||
| 684 | //8.4.2 Derivation process for luma intra prediction mode | ||
| 685 | 503220 | static enum IntraPredMode luma_intra_pred_mode(VVCLocalContext* lc, const int intra_subpartitions_mode_flag) | |
| 686 | { | ||
| 687 | 503220 | VVCFrameContext *fc = lc->fc; | |
| 688 | 503220 | CodingUnit *cu = lc->cu; | |
| 689 | 503220 | const int x0 = cu->x0; | |
| 690 | 503220 | const int y0 = cu->y0; | |
| 691 | enum IntraPredMode pred; | ||
| 692 | 503220 | int intra_luma_not_planar_flag = 1; | |
| 693 | 503220 | int intra_luma_mpm_remainder = 0; | |
| 694 | 503220 | int intra_luma_mpm_flag = 1; | |
| 695 | 503220 | int intra_luma_mpm_idx = 0; | |
| 696 | |||
| 697 |
2/2✓ Branch 0 taken 458554 times.
✓ Branch 1 taken 44666 times.
|
503220 | if (!cu->intra_luma_ref_idx) |
| 698 | 458554 | intra_luma_mpm_flag = ff_vvc_intra_luma_mpm_flag(lc); | |
| 699 |
2/2✓ Branch 0 taken 375807 times.
✓ Branch 1 taken 127413 times.
|
503220 | if (intra_luma_mpm_flag) { |
| 700 |
2/2✓ Branch 0 taken 331141 times.
✓ Branch 1 taken 44666 times.
|
375807 | if (!cu->intra_luma_ref_idx) |
| 701 | 331141 | intra_luma_not_planar_flag = ff_vvc_intra_luma_not_planar_flag(lc, intra_subpartitions_mode_flag); | |
| 702 |
2/2✓ Branch 0 taken 201212 times.
✓ Branch 1 taken 174595 times.
|
375807 | if (intra_luma_not_planar_flag) |
| 703 | 201212 | intra_luma_mpm_idx = ff_vvc_intra_luma_mpm_idx(lc); | |
| 704 | } else { | ||
| 705 | 127413 | intra_luma_mpm_remainder = ff_vvc_intra_luma_mpm_remainder(lc); | |
| 706 | } | ||
| 707 | |||
| 708 |
2/2✓ Branch 0 taken 174595 times.
✓ Branch 1 taken 328625 times.
|
503220 | if (!intra_luma_not_planar_flag) { |
| 709 | 174595 | pred = INTRA_PLANAR; | |
| 710 | } else { | ||
| 711 | 328625 | const VVCSPS *sps = fc->ps.sps; | |
| 712 | 328625 | const int x_a = (x0 - 1) >> sps->min_cb_log2_size_y; | |
| 713 | 328625 | const int y_a = (y0 + cu->cb_height - 1) >> sps->min_cb_log2_size_y; | |
| 714 | 328625 | const int x_b = (x0 + cu->cb_width - 1) >> sps->min_cb_log2_size_y; | |
| 715 | 328625 | const int y_b = (y0 - 1) >> sps->min_cb_log2_size_y; | |
| 716 | 328625 | int min_cb_width = fc->ps.pps->min_cb_width; | |
| 717 | 328625 | int x0b = av_zero_extend(x0, sps->ctb_log2_size_y); | |
| 718 | 328625 | int y0b = av_zero_extend(y0, sps->ctb_log2_size_y); | |
| 719 |
4/4✓ Branch 0 taken 74041 times.
✓ Branch 1 taken 254584 times.
✓ Branch 2 taken 68035 times.
✓ Branch 3 taken 6006 times.
|
328625 | const int available_l = lc->ctb_left_flag || x0b; |
| 720 |
4/4✓ Branch 0 taken 118009 times.
✓ Branch 1 taken 210616 times.
✓ Branch 2 taken 111455 times.
✓ Branch 3 taken 6554 times.
|
328625 | const int available_u = lc->ctb_up_flag || y0b; |
| 721 | |||
| 722 | int a, b, cand[5]; | ||
| 723 | |||
| 724 |
4/4✓ Branch 0 taken 322619 times.
✓ Branch 1 taken 6006 times.
✓ Branch 2 taken 289714 times.
✓ Branch 3 taken 32905 times.
|
328625 | if (!available_l || (SAMPLE_CTB(fc->tab.cpm[0], x_a, y_a) != MODE_INTRA) || |
| 725 |
2/2✓ Branch 0 taken 40058 times.
✓ Branch 1 taken 249656 times.
|
289714 | SAMPLE_CTB(fc->tab.imf, x_a, y_a)) { |
| 726 | 78969 | a = INTRA_PLANAR; | |
| 727 | } else { | ||
| 728 | 249656 | a = SAMPLE_CTB(fc->tab.ipm, x_a, y_a); | |
| 729 | } | ||
| 730 | |||
| 731 |
4/4✓ Branch 0 taken 322071 times.
✓ Branch 1 taken 6554 times.
✓ Branch 2 taken 287269 times.
✓ Branch 3 taken 34802 times.
|
328625 | if (!available_u || (SAMPLE_CTB(fc->tab.cpm[0], x_b, y_b) != MODE_INTRA) || |
| 732 |
4/4✓ Branch 0 taken 246971 times.
✓ Branch 1 taken 40298 times.
✓ Branch 2 taken 14370 times.
✓ Branch 3 taken 232601 times.
|
287269 | SAMPLE_CTB(fc->tab.imf, x_b, y_b) || !y0b) { |
| 733 | 96024 | b = INTRA_PLANAR; | |
| 734 | } else { | ||
| 735 | 232601 | b = SAMPLE_CTB(fc->tab.ipm, x_b, y_b); | |
| 736 | } | ||
| 737 | |||
| 738 |
4/4✓ Branch 0 taken 102246 times.
✓ Branch 1 taken 226379 times.
✓ Branch 2 taken 19846 times.
✓ Branch 3 taken 82400 times.
|
328625 | if (a == b && a > INTRA_DC) { |
| 739 | 19846 | cand[0] = a; | |
| 740 | 19846 | cand[1] = 2 + ((a + 61) % 64); | |
| 741 | 19846 | cand[2] = 2 + ((a - 1) % 64); | |
| 742 | 19846 | cand[3] = 2 + ((a + 60) % 64); | |
| 743 | 19846 | cand[4] = 2 + (a % 64); | |
| 744 | } else { | ||
| 745 | 308779 | const int minab = FFMIN(a, b); | |
| 746 | 308779 | const int maxab = FFMAX(a, b); | |
| 747 |
4/4✓ Branch 0 taken 149149 times.
✓ Branch 1 taken 159630 times.
✓ Branch 2 taken 73667 times.
✓ Branch 3 taken 75482 times.
|
382446 | if (a > INTRA_DC && b > INTRA_DC) { |
| 748 | 73667 | const int diff = maxab - minab; | |
| 749 | 73667 | cand[0] = a; | |
| 750 | 73667 | cand[1] = b; | |
| 751 |
2/2✓ Branch 0 taken 14566 times.
✓ Branch 1 taken 59101 times.
|
73667 | if (diff == 1) { |
| 752 | 14566 | cand[2] = 2 + ((minab + 61) % 64); | |
| 753 | 14566 | cand[3] = 2 + ((maxab - 1) % 64); | |
| 754 | 14566 | cand[4] = 2 + ((minab + 60) % 64); | |
| 755 |
2/2✓ Branch 0 taken 582 times.
✓ Branch 1 taken 58519 times.
|
59101 | } else if (diff >= 62) { |
| 756 | 582 | cand[2] = 2 + ((minab - 1) % 64); | |
| 757 | 582 | cand[3] = 2 + ((maxab + 61) % 64); | |
| 758 | 582 | cand[4] = 2 + (minab % 64); | |
| 759 |
2/2✓ Branch 0 taken 6924 times.
✓ Branch 1 taken 51595 times.
|
58519 | } else if (diff == 2) { |
| 760 | 6924 | cand[2] = 2 + ((minab - 1) % 64); | |
| 761 | 6924 | cand[3] = 2 + ((minab + 61) % 64); | |
| 762 | 6924 | cand[4] = 2 + ((maxab - 1) % 64); | |
| 763 | } else { | ||
| 764 | 51595 | cand[2] = 2 + ((minab + 61) % 64); | |
| 765 | 51595 | cand[3] = 2 + ((minab - 1) % 64); | |
| 766 | 51595 | cand[4] = 2 + ((maxab + 61) % 64); | |
| 767 | } | ||
| 768 |
4/4✓ Branch 0 taken 159630 times.
✓ Branch 1 taken 75482 times.
✓ Branch 2 taken 62280 times.
✓ Branch 3 taken 97350 times.
|
235112 | } else if (a > INTRA_DC || b > INTRA_DC) { |
| 769 | 137762 | cand[0] = maxab; | |
| 770 | 137762 | cand[1] = 2 + ((maxab + 61 ) % 64); | |
| 771 | 137762 | cand[2] = 2 + ((maxab - 1) % 64); | |
| 772 | 137762 | cand[3] = 2 + ((maxab + 60 ) % 64); | |
| 773 | 137762 | cand[4] = 2 + (maxab % 64); | |
| 774 | } else { | ||
| 775 | 97350 | cand[0] = INTRA_DC; | |
| 776 | 97350 | cand[1] = INTRA_VERT; | |
| 777 | 97350 | cand[2] = INTRA_HORZ; | |
| 778 | 97350 | cand[3] = INTRA_VERT - 4; | |
| 779 | 97350 | cand[4] = INTRA_VERT + 4; | |
| 780 | } | ||
| 781 | } | ||
| 782 |
2/2✓ Branch 0 taken 201212 times.
✓ Branch 1 taken 127413 times.
|
328625 | if (intra_luma_mpm_flag) { |
| 783 | 201212 | pred = cand[intra_luma_mpm_idx]; | |
| 784 | } else { | ||
| 785 | 127413 | qsort(cand, FF_ARRAY_ELEMS(cand), sizeof(cand[0]), less); | |
| 786 | 127413 | pred = intra_luma_mpm_remainder + 1; | |
| 787 |
2/2✓ Branch 0 taken 637065 times.
✓ Branch 1 taken 127413 times.
|
764478 | for (int i = 0; i < FF_ARRAY_ELEMS(cand); i++) { |
| 788 |
2/2✓ Branch 0 taken 312979 times.
✓ Branch 1 taken 324086 times.
|
637065 | if (pred >= cand[i]) |
| 789 | 312979 | pred++; | |
| 790 | } | ||
| 791 | } | ||
| 792 | } | ||
| 793 | 503220 | return pred; | |
| 794 | } | ||
| 795 | |||
| 796 | 990262 | static int lfnst_idx_decode(VVCLocalContext *lc) | |
| 797 | { | ||
| 798 | 990262 | CodingUnit *cu = lc->cu; | |
| 799 | 990262 | const VVCTreeType tree_type = cu->tree_type; | |
| 800 | 990262 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 801 | 990262 | const int cb_width = cu->cb_width; | |
| 802 | 990262 | const int cb_height = cu->cb_height; | |
| 803 | 990262 | const TransformUnit *tu = cu->tus.head; | |
| 804 | int lfnst_width, lfnst_height, min_lfnst; | ||
| 805 | 990262 | int lfnst_idx = 0; | |
| 806 | |||
| 807 | 990262 | memset(cu->apply_lfnst_flag, 0, sizeof(cu->apply_lfnst_flag)); | |
| 808 | |||
| 809 |
6/6✓ Branch 0 taken 766695 times.
✓ Branch 1 taken 223567 times.
✓ Branch 2 taken 633166 times.
✓ Branch 3 taken 133529 times.
✓ Branch 4 taken 1990 times.
✓ Branch 5 taken 631176 times.
|
990262 | if (!sps->r->sps_lfnst_enabled_flag || cu->pred_mode != MODE_INTRA || FFMAX(cb_width, cb_height) > sps->max_tb_size_y) |
| 810 | 359086 | return 0; | |
| 811 | |||
| 812 |
2/2✓ Branch 0 taken 743412 times.
✓ Branch 1 taken 611087 times.
|
1354499 | while (tu) { |
| 813 |
2/2✓ Branch 0 taken 984112 times.
✓ Branch 1 taken 723323 times.
|
1707435 | for (int j = 0; j < tu->nb_tbs; j++) { |
| 814 | 984112 | const TransformBlock *tb = tu->tbs + j; | |
| 815 |
4/4✓ Branch 0 taken 623191 times.
✓ Branch 1 taken 360921 times.
✓ Branch 2 taken 20089 times.
✓ Branch 3 taken 603102 times.
|
984112 | if (tu->coded_flag[tb->c_idx] && tb->ts) |
| 816 | 20089 | return 0; | |
| 817 | } | ||
| 818 | 723323 | tu = tu->next; | |
| 819 | } | ||
| 820 | |||
| 821 |
2/2✓ Branch 0 taken 147717 times.
✓ Branch 1 taken 463370 times.
|
611087 | if (tree_type == DUAL_TREE_CHROMA) { |
| 822 | 147717 | lfnst_width = cb_width >> sps->hshift[1]; | |
| 823 | 147717 | lfnst_height = cb_height >> sps->vshift[1]; | |
| 824 | } else { | ||
| 825 | 463370 | const int vs = cu->isp_split_type == ISP_VER_SPLIT; | |
| 826 | 463370 | const int hs = cu->isp_split_type == ISP_HOR_SPLIT; | |
| 827 |
2/2✓ Branch 0 taken 18121 times.
✓ Branch 1 taken 445249 times.
|
463370 | lfnst_width = vs ? cb_width / cu->num_intra_subpartitions : cb_width; |
| 828 |
2/2✓ Branch 0 taken 31845 times.
✓ Branch 1 taken 431525 times.
|
463370 | lfnst_height = hs ? cb_height / cu->num_intra_subpartitions : cb_height; |
| 829 | } | ||
| 830 | 611087 | min_lfnst = FFMIN(lfnst_width, lfnst_height); | |
| 831 |
6/6✓ Branch 0 taken 463370 times.
✓ Branch 1 taken 147717 times.
✓ Branch 2 taken 106630 times.
✓ Branch 3 taken 356740 times.
✓ Branch 4 taken 86525 times.
✓ Branch 5 taken 20105 times.
|
611087 | if (tree_type != DUAL_TREE_CHROMA && cu->intra_mip_flag && min_lfnst < 16) |
| 832 | 86525 | return 0; | |
| 833 | |||
| 834 |
2/2✓ Branch 0 taken 485309 times.
✓ Branch 1 taken 39253 times.
|
524562 | if (min_lfnst >= 4) { |
| 835 |
6/6✓ Branch 0 taken 456988 times.
✓ Branch 1 taken 28321 times.
✓ Branch 2 taken 194457 times.
✓ Branch 3 taken 262531 times.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 33762 times.
|
485309 | if ((cu->isp_split_type != ISP_NO_SPLIT || !lc->parse.lfnst_dc_only) && lc->parse.lfnst_zero_out_sig_coeff_flag) |
| 836 | 189016 | lfnst_idx = ff_vvc_lfnst_idx(lc, tree_type != SINGLE_TREE); | |
| 837 | } | ||
| 838 | |||
| 839 |
2/2✓ Branch 0 taken 141330 times.
✓ Branch 1 taken 383232 times.
|
524562 | if (lfnst_idx) { |
| 840 | 141330 | cu->apply_lfnst_flag[LUMA] = tree_type != DUAL_TREE_CHROMA; | |
| 841 | 141330 | cu->apply_lfnst_flag[CB] = cu->apply_lfnst_flag[CR] = tree_type == DUAL_TREE_CHROMA; | |
| 842 | } | ||
| 843 | |||
| 844 | 524562 | return lfnst_idx; | |
| 845 | } | ||
| 846 | |||
| 847 | 990262 | static MtsIdx mts_idx_decode(VVCLocalContext *lc) | |
| 848 | { | ||
| 849 | 990262 | const CodingUnit *cu = lc->cu; | |
| 850 | 990262 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 851 | 990262 | const int cb_width = cu->cb_width; | |
| 852 | 990262 | const int cb_height = cu->cb_height; | |
| 853 | 990262 | const uint8_t transform_skip_flag = cu->tus.head->tbs[0].ts; //fix me | |
| 854 | 990262 | int mts_idx = MTS_DCT2_DCT2; | |
| 855 |
6/6✓ Branch 0 taken 802954 times.
✓ Branch 1 taken 187308 times.
✓ Branch 2 taken 695924 times.
✓ Branch 3 taken 107030 times.
✓ Branch 4 taken 653556 times.
✓ Branch 5 taken 42368 times.
|
990262 | if (cu->tree_type != DUAL_TREE_CHROMA && !cu->lfnst_idx && |
| 856 |
2/2✓ Branch 0 taken 630518 times.
✓ Branch 1 taken 23038 times.
|
653556 | !transform_skip_flag && FFMAX(cb_width, cb_height) <= 32 && |
| 857 |
4/4✓ Branch 0 taken 583071 times.
✓ Branch 1 taken 47447 times.
✓ Branch 2 taken 539217 times.
✓ Branch 3 taken 43854 times.
|
630518 | cu->isp_split_type == ISP_NO_SPLIT && !cu->sbt_flag && |
| 858 |
4/4✓ Branch 0 taken 530319 times.
✓ Branch 1 taken 8898 times.
✓ Branch 2 taken 332373 times.
✓ Branch 3 taken 197946 times.
|
539217 | lc->parse.mts_zero_out_sig_coeff_flag && !lc->parse.mts_dc_only) { |
| 859 |
4/4✓ Branch 0 taken 58832 times.
✓ Branch 1 taken 273541 times.
✓ Branch 2 taken 56366 times.
✓ Branch 3 taken 2466 times.
|
332373 | if ((cu->pred_mode == MODE_INTER && sps->r->sps_explicit_mts_inter_enabled_flag) || |
| 860 |
4/4✓ Branch 0 taken 269199 times.
✓ Branch 1 taken 60708 times.
✓ Branch 2 taken 250208 times.
✓ Branch 3 taken 18991 times.
|
329907 | (cu->pred_mode == MODE_INTRA && sps->r->sps_explicit_mts_intra_enabled_flag)) { |
| 861 | 252674 | mts_idx = ff_vvc_mts_idx(lc); | |
| 862 | } | ||
| 863 | } | ||
| 864 | |||
| 865 | 990262 | return mts_idx; | |
| 866 | } | ||
| 867 | |||
| 868 | 249107 | static enum IntraPredMode derive_center_luma_intra_pred_mode(const VVCFrameContext *fc, const VVCSPS *sps, const VVCPPS *pps, const CodingUnit *cu) | |
| 869 | { | ||
| 870 | 249107 | const int x_center = (cu->x0 + cu->cb_width / 2) >> sps->min_cb_log2_size_y; | |
| 871 | 249107 | const int y_center = (cu->y0 + cu->cb_height / 2) >> sps->min_cb_log2_size_y; | |
| 872 | 249107 | const int min_cb_width = pps->min_cb_width; | |
| 873 | 249107 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_center, y_center); | |
| 874 | 249107 | const int cu_pred_mode = SAMPLE_CTB(fc->tab.cpm[0], x_center, y_center); | |
| 875 | 249107 | const int intra_pred_mode_y = SAMPLE_CTB(fc->tab.ipm, x_center, y_center); | |
| 876 | |||
| 877 |
2/2✓ Branch 0 taken 47278 times.
✓ Branch 1 taken 201829 times.
|
249107 | if (intra_mip_flag) { |
| 878 |
4/4✓ Branch 0 taken 9506 times.
✓ Branch 1 taken 37772 times.
✓ Branch 2 taken 251 times.
✓ Branch 3 taken 9255 times.
|
47278 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
| 879 | 251 | return INTRA_INVALID; | |
| 880 | 47027 | return INTRA_PLANAR; | |
| 881 | } | ||
| 882 |
4/4✓ Branch 0 taken 191338 times.
✓ Branch 1 taken 10491 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 191132 times.
|
201829 | if (cu_pred_mode == MODE_IBC || cu_pred_mode == MODE_PLT) |
| 883 | 10697 | return INTRA_DC; | |
| 884 | 191132 | return intra_pred_mode_y; | |
| 885 | } | ||
| 886 | |||
| 887 | 249894 | static void derive_chroma_intra_pred_mode(VVCLocalContext *lc, | |
| 888 | const int cclm_mode_flag, const int cclm_mode_idx, const int intra_chroma_pred_mode) | ||
| 889 | { | ||
| 890 | 249894 | const VVCFrameContext *fc = lc->fc; | |
| 891 | 249894 | CodingUnit *cu = lc->cu; | |
| 892 | 249894 | const VVCSPS *sps = fc->ps.sps; | |
| 893 | 249894 | const VVCPPS *pps = fc->ps.pps; | |
| 894 | 249894 | const int x_cb = cu->x0 >> sps->min_cb_log2_size_y; | |
| 895 | 249894 | const int y_cb = cu->y0 >> sps->min_cb_log2_size_y; | |
| 896 | 249894 | const int min_cb_width = pps->min_cb_width; | |
| 897 | 249894 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
| 898 | 249894 | enum IntraPredMode luma_intra_pred_mode = SAMPLE_CTB(fc->tab.ipm, x_cb, y_cb); | |
| 899 | |||
| 900 |
6/6✓ Branch 0 taken 62631 times.
✓ Branch 1 taken 187263 times.
✓ Branch 2 taken 10433 times.
✓ Branch 3 taken 52198 times.
✓ Branch 4 taken 7648 times.
✓ Branch 5 taken 2785 times.
|
249894 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && |
| 901 |
4/4✓ Branch 0 taken 6140 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 787 times.
✓ Branch 3 taken 8138 times.
|
10433 | (intra_chroma_pred_mode == 4 || cu->act_enabled_flag) && intra_mip_flag) { |
| 902 | 787 | cu->mip_chroma_direct_flag = 1; | |
| 903 | 787 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
| 904 | 787 | return; | |
| 905 | } | ||
| 906 | 249107 | luma_intra_pred_mode = derive_center_luma_intra_pred_mode(fc, sps, pps, cu); | |
| 907 | |||
| 908 |
2/2✓ Branch 0 taken 5583 times.
✓ Branch 1 taken 243524 times.
|
249107 | if (cu->act_enabled_flag) { |
| 909 | 5583 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
| 910 | 5583 | return; | |
| 911 | } | ||
| 912 |
2/2✓ Branch 0 taken 96828 times.
✓ Branch 1 taken 146696 times.
|
243524 | if (cclm_mode_flag) { |
| 913 | 96828 | cu->intra_pred_mode_c = INTRA_LT_CCLM + cclm_mode_idx; | |
| 914 |
2/2✓ Branch 0 taken 102950 times.
✓ Branch 1 taken 43746 times.
|
146696 | } else if (intra_chroma_pred_mode == 4){ |
| 915 | 102950 | cu->intra_pred_mode_c = luma_intra_pred_mode; | |
| 916 | } else { | ||
| 917 | const static IntraPredMode pred_mode_c[][4 + 1] = { | ||
| 918 | {INTRA_VDIAG, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR, INTRA_PLANAR}, | ||
| 919 | {INTRA_VERT, INTRA_VDIAG, INTRA_VERT, INTRA_VERT, INTRA_VERT}, | ||
| 920 | {INTRA_HORZ, INTRA_HORZ, INTRA_VDIAG, INTRA_HORZ, INTRA_HORZ}, | ||
| 921 | {INTRA_DC, INTRA_DC, INTRA_DC, INTRA_VDIAG, INTRA_DC}, | ||
| 922 | }; | ||
| 923 | 43746 | const int modes[4] = {INTRA_PLANAR, INTRA_VERT, INTRA_HORZ, INTRA_DC}; | |
| 924 | int idx; | ||
| 925 | |||
| 926 | // This workaround is necessary to have 4:4:4 video decode correctly | ||
| 927 | // See VVC ticket https://jvet.hhi.fraunhofer.de/trac/vvc/ticket/1602 | ||
| 928 | // and VTM source https://vcgit.hhi.fraunhofer.de/jvet/VVCSoftware_VTM/-/blob/master/source/Lib/CommonLib/UnitTools.cpp#L736 | ||
| 929 |
6/6✓ Branch 0 taken 3354 times.
✓ Branch 1 taken 40392 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 3108 times.
✓ Branch 4 taken 43 times.
✓ Branch 5 taken 203 times.
|
43746 | if (cu->tree_type == SINGLE_TREE && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444 && intra_mip_flag) { |
| 930 | 43 | idx = 4; | |
| 931 | } else { | ||
| 932 |
2/2✓ Branch 0 taken 110605 times.
✓ Branch 1 taken 15253 times.
|
125858 | for (idx = 0; idx < FF_ARRAY_ELEMS(modes); idx++) { |
| 933 |
2/2✓ Branch 0 taken 28450 times.
✓ Branch 1 taken 82155 times.
|
110605 | if (modes[idx] == luma_intra_pred_mode) |
| 934 | 28450 | break; | |
| 935 | } | ||
| 936 | } | ||
| 937 | |||
| 938 | 43746 | cu->intra_pred_mode_c = pred_mode_c[intra_chroma_pred_mode][idx]; | |
| 939 | } | ||
| 940 |
4/4✓ Branch 0 taken 11978 times.
✓ Branch 1 taken 231546 times.
✓ Branch 2 taken 8009 times.
✓ Branch 3 taken 3969 times.
|
243524 | if (sps->r->sps_chroma_format_idc == CHROMA_FORMAT_422 && cu->intra_pred_mode_c <= INTRA_VDIAG) { |
| 941 | const static int mode_map_422[INTRA_VDIAG + 1] = { | ||
| 942 | 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 5, 6, 8, 10, 12, 13, | ||
| 943 | 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 31, 33, 34, 35, 36, 37, | ||
| 944 | 38, 39, 40, 41, 41, 42, 43, 43, 44, 44, 45, 45, 46, 47, 48, 48, | ||
| 945 | 49, 49, 50, 51, 51, 52, 52, 53, 54, 55, 55, 56, 56, 57, 57, 58, | ||
| 946 | 59, 59, 60, | ||
| 947 | }; | ||
| 948 | 8009 | cu->intra_pred_mode_c = mode_map_422[cu->intra_pred_mode_c]; | |
| 949 | } | ||
| 950 | } | ||
| 951 | |||
| 952 | 293947 | static av_always_inline uint8_t pack_mip_info(int intra_mip_flag, | |
| 953 | int intra_mip_transposed_flag, int intra_mip_mode) | ||
| 954 | { | ||
| 955 | 293947 | return (intra_mip_mode << 2) | (intra_mip_transposed_flag << 1) | intra_mip_flag; | |
| 956 | } | ||
| 957 | |||
| 958 | 625022 | static void intra_luma_pred_modes(VVCLocalContext *lc) | |
| 959 | { | ||
| 960 | 625022 | VVCFrameContext *fc = lc->fc; | |
| 961 | 625022 | const VVCSPS *sps = fc->ps.sps; | |
| 962 | 625022 | const VVCPPS *pps = fc->ps.pps; | |
| 963 | 625022 | CodingUnit *cu = lc->cu; | |
| 964 | 625022 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
| 965 | 625022 | const int x0 = cu->x0; | |
| 966 | 625022 | const int y0 = cu->y0; | |
| 967 | 625022 | const int x_cb = x0 >> log2_min_cb_size; | |
| 968 | 625022 | const int y_cb = y0 >> log2_min_cb_size; | |
| 969 | 625022 | const int cb_width = cu->cb_width; | |
| 970 | 625022 | const int cb_height = cu->cb_height; | |
| 971 | |||
| 972 | 625022 | cu->intra_luma_ref_idx = 0; | |
| 973 |
6/6✓ Branch 0 taken 48105 times.
✓ Branch 1 taken 576917 times.
✓ Branch 2 taken 47020 times.
✓ Branch 3 taken 1085 times.
✓ Branch 4 taken 46942 times.
✓ Branch 5 taken 78 times.
|
625022 | if (sps->r->sps_bdpcm_enabled_flag && cb_width <= sps->max_ts_size && cb_height <= sps->max_ts_size) |
| 974 | 46942 | cu->bdpcm_flag[LUMA] = ff_vvc_intra_bdpcm_luma_flag(lc); | |
| 975 |
2/2✓ Branch 0 taken 10719 times.
✓ Branch 1 taken 614303 times.
|
625022 | if (cu->bdpcm_flag[LUMA]) { |
| 976 |
2/2✓ Branch 1 taken 5499 times.
✓ Branch 2 taken 5220 times.
|
10719 | cu->intra_pred_mode_y = ff_vvc_intra_bdpcm_luma_dir_flag(lc) ? INTRA_VERT : INTRA_HORZ; |
| 977 | } else { | ||
| 978 |
2/2✓ Branch 0 taken 471861 times.
✓ Branch 1 taken 142442 times.
|
614303 | if (sps->r->sps_mip_enabled_flag) |
| 979 | 471861 | cu->intra_mip_flag = ff_vvc_intra_mip_flag(lc, fc->tab.imf); | |
| 980 |
2/2✓ Branch 0 taken 111083 times.
✓ Branch 1 taken 503220 times.
|
614303 | if (cu->intra_mip_flag) { |
| 981 | 111083 | int intra_mip_transposed_flag = ff_vvc_intra_mip_transposed_flag(lc); | |
| 982 | 111083 | int intra_mip_mode = ff_vvc_intra_mip_mode(lc); | |
| 983 | 111083 | int x = y_cb * pps->min_cb_width + x_cb; | |
| 984 |
2/2✓ Branch 0 taken 293947 times.
✓ Branch 1 taken 111083 times.
|
405030 | for (int y = 0; y < (cb_height>>log2_min_cb_size); y++) { |
| 985 | 293947 | int width = cb_width>>log2_min_cb_size; | |
| 986 | 293947 | const uint8_t mip_info = pack_mip_info(cu->intra_mip_flag, | |
| 987 | intra_mip_transposed_flag, intra_mip_mode); | ||
| 988 | 293947 | memset(&fc->tab.imf[x], mip_info, width); | |
| 989 | 293947 | x += pps->min_cb_width; | |
| 990 | } | ||
| 991 | 111083 | cu->intra_pred_mode_y = intra_mip_mode; | |
| 992 | } else { | ||
| 993 | 503220 | int intra_subpartitions_mode_flag = 0; | |
| 994 |
4/4✓ Branch 0 taken 484296 times.
✓ Branch 1 taken 18924 times.
✓ Branch 2 taken 443673 times.
✓ Branch 3 taken 40623 times.
|
503220 | if (sps->r->sps_mrl_enabled_flag && ((y0 % sps->ctb_size_y) > 0)) |
| 995 | 443673 | cu->intra_luma_ref_idx = ff_vvc_intra_luma_ref_idx(lc); | |
| 996 |
4/4✓ Branch 0 taken 484296 times.
✓ Branch 1 taken 18924 times.
✓ Branch 2 taken 439630 times.
✓ Branch 3 taken 44666 times.
|
503220 | if (sps->r->sps_isp_enabled_flag && !cu->intra_luma_ref_idx && |
| 997 |
4/4✓ Branch 0 taken 439190 times.
✓ Branch 1 taken 440 times.
✓ Branch 2 taken 438862 times.
✓ Branch 3 taken 328 times.
|
439630 | (cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) && |
| 998 |
2/2✓ Branch 0 taken 372831 times.
✓ Branch 1 taken 66031 times.
|
438862 | (cb_width * cb_height > MIN_TU_SIZE * MIN_TU_SIZE) && |
| 999 |
2/2✓ Branch 0 taken 369433 times.
✓ Branch 1 taken 3398 times.
|
372831 | !cu->act_enabled_flag) |
| 1000 | 369433 | intra_subpartitions_mode_flag = ff_vvc_intra_subpartitions_mode_flag(lc); | |
| 1001 |
4/4✓ Branch 0 taken 97572 times.
✓ Branch 1 taken 405648 times.
✓ Branch 2 taken 21219 times.
✓ Branch 3 taken 76353 times.
|
503220 | if (!(x0 & 63) && !(y0 & 63)) |
| 1002 | 21219 | TAB_ISPMF(fc, x0, y0) = intra_subpartitions_mode_flag; | |
| 1003 | 503220 | cu->isp_split_type = ff_vvc_isp_split_type(lc, intra_subpartitions_mode_flag); | |
| 1004 | 503220 | cu->num_intra_subpartitions = get_num_intra_subpartitions(cu->isp_split_type, cb_width, cb_height); | |
| 1005 | 503220 | cu->intra_pred_mode_y = luma_intra_pred_mode(lc, intra_subpartitions_mode_flag); | |
| 1006 | } | ||
| 1007 | } | ||
| 1008 | 625022 | set_cb_tab(lc, fc->tab.ipm, cu->intra_pred_mode_y); | |
| 1009 | 625022 | } | |
| 1010 | |||
| 1011 | 250026 | static void intra_chroma_pred_modes(VVCLocalContext *lc) | |
| 1012 | { | ||
| 1013 | 250026 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 1014 | 250026 | CodingUnit *cu = lc->cu; | |
| 1015 | 250026 | const int hs = sps->hshift[CHROMA]; | |
| 1016 | 250026 | const int vs = sps->vshift[CHROMA]; | |
| 1017 | 250026 | int cclm_mode_flag = 0; | |
| 1018 | 250026 | int cclm_mode_idx = 0; | |
| 1019 | 250026 | int intra_chroma_pred_mode = 0; | |
| 1020 | |||
| 1021 |
2/2✓ Branch 0 taken 243886 times.
✓ Branch 1 taken 6140 times.
|
250026 | if (!cu->act_enabled_flag) { |
| 1022 | 243886 | cu->mip_chroma_direct_flag = 0; | |
| 1023 |
2/2✓ Branch 0 taken 40212 times.
✓ Branch 1 taken 203674 times.
|
243886 | if (sps->r->sps_bdpcm_enabled_flag && |
| 1024 |
2/2✓ Branch 0 taken 38812 times.
✓ Branch 1 taken 1400 times.
|
40212 | (cu->cb_width >> hs) <= sps->max_ts_size && |
| 1025 |
2/2✓ Branch 0 taken 38304 times.
✓ Branch 1 taken 508 times.
|
38812 | (cu->cb_height >> vs) <= sps->max_ts_size) { |
| 1026 | 38304 | cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = ff_vvc_intra_bdpcm_chroma_flag(lc); | |
| 1027 | } | ||
| 1028 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 243754 times.
|
243886 | if (cu->bdpcm_flag[CHROMA]) { |
| 1029 |
2/2✓ Branch 1 taken 121 times.
✓ Branch 2 taken 11 times.
|
132 | cu->intra_pred_mode_c = ff_vvc_intra_bdpcm_chroma_dir_flag(lc) ? INTRA_VERT : INTRA_HORZ; |
| 1030 | } else { | ||
| 1031 | 243754 | const int cclm_enabled = get_cclm_enabled(lc, cu->x0, cu->y0); | |
| 1032 | |||
| 1033 |
2/2✓ Branch 0 taken 222324 times.
✓ Branch 1 taken 21430 times.
|
243754 | if (cclm_enabled) |
| 1034 | 222324 | cclm_mode_flag = ff_vvc_cclm_mode_flag(lc); | |
| 1035 | |||
| 1036 |
2/2✓ Branch 0 taken 96828 times.
✓ Branch 1 taken 146926 times.
|
243754 | if (cclm_mode_flag) |
| 1037 | 96828 | cclm_mode_idx = ff_vvc_cclm_mode_idx(lc); | |
| 1038 | else | ||
| 1039 | 146926 | intra_chroma_pred_mode = ff_vvc_intra_chroma_pred_mode(lc); | |
| 1040 | } | ||
| 1041 | } | ||
| 1042 | |||
| 1043 |
2/2✓ Branch 0 taken 249894 times.
✓ Branch 1 taken 132 times.
|
250026 | if (!cu->bdpcm_flag[CHROMA]) |
| 1044 | 249894 | derive_chroma_intra_pred_mode(lc, cclm_mode_flag, cclm_mode_idx, intra_chroma_pred_mode); | |
| 1045 | 250026 | } | |
| 1046 | |||
| 1047 | 1344609 | static PredMode pred_mode_decode(VVCLocalContext *lc, | |
| 1048 | const VVCTreeType tree_type, | ||
| 1049 | const VVCModeType mode_type) | ||
| 1050 | { | ||
| 1051 | 1344609 | const VVCFrameContext *fc = lc->fc; | |
| 1052 | 1344609 | CodingUnit *cu = lc->cu; | |
| 1053 | 1344609 | const VVCSPS *sps = fc->ps.sps; | |
| 1054 | 1344609 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 1055 | 1344609 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
| 1056 |
4/4✓ Branch 0 taken 300975 times.
✓ Branch 1 taken 1043634 times.
✓ Branch 2 taken 127632 times.
✓ Branch 3 taken 173343 times.
|
1344609 | const int is_4x4 = cu->cb_width == 4 && cu->cb_height == 4; |
| 1057 |
4/4✓ Branch 0 taken 1318206 times.
✓ Branch 1 taken 26403 times.
✓ Branch 2 taken 2342 times.
✓ Branch 3 taken 1315864 times.
|
1344609 | const int is_128 = cu->cb_width == 128 || cu->cb_height == 128; |
| 1058 | 1344609 | const int hs = sps->hshift[CHROMA]; | |
| 1059 | 1344609 | const int vs = sps->vshift[CHROMA]; | |
| 1060 | int pred_mode_flag; | ||
| 1061 | int pred_mode_ibc_flag; | ||
| 1062 | PredMode pred_mode; | ||
| 1063 | |||
| 1064 | 1344609 | cu->skip_flag = 0; | |
| 1065 |
4/4✓ Branch 0 taken 717365 times.
✓ Branch 1 taken 627244 times.
✓ Branch 2 taken 85795 times.
✓ Branch 3 taken 631570 times.
|
1344609 | if (!IS_I(rsh) || sps->r->sps_ibc_enabled_flag) { |
| 1066 |
4/4✓ Branch 0 taken 678485 times.
✓ Branch 1 taken 34554 times.
✓ Branch 2 taken 615883 times.
✓ Branch 3 taken 62602 times.
|
713039 | if (tree_type != DUAL_TREE_CHROMA && |
| 1067 |
2/2✓ Branch 0 taken 53502 times.
✓ Branch 1 taken 562381 times.
|
615883 | ((!is_4x4 && mode_type != MODE_TYPE_INTRA) || |
| 1068 |
3/4✓ Branch 0 taken 88020 times.
✓ Branch 1 taken 28084 times.
✓ Branch 2 taken 88020 times.
✗ Branch 3 not taken.
|
116104 | (sps->r->sps_ibc_enabled_flag && !is_128))) { |
| 1069 | 650401 | cu->skip_flag = ff_vvc_cu_skip_flag(lc, fc->tab.skip); | |
| 1070 | } | ||
| 1071 | |||
| 1072 |
6/6✓ Branch 0 taken 650437 times.
✓ Branch 1 taken 62602 times.
✓ Branch 2 taken 569963 times.
✓ Branch 3 taken 80474 times.
✓ Branch 4 taken 56533 times.
✓ Branch 5 taken 513430 times.
|
713039 | if (is_4x4 || mode_type == MODE_TYPE_INTRA || IS_I(rsh)) { |
| 1073 | 199609 | pred_mode_flag = 1; | |
| 1074 |
4/4✓ Branch 0 taken 447707 times.
✓ Branch 1 taken 65723 times.
✓ Branch 2 taken 236579 times.
✓ Branch 3 taken 211128 times.
|
513430 | } else if (mode_type == MODE_TYPE_INTER || cu->skip_flag) { |
| 1075 | 302302 | pred_mode_flag = 0; | |
| 1076 | } else { | ||
| 1077 | 211128 | pred_mode_flag = ff_vvc_pred_mode_flag(lc, ch_type); | |
| 1078 | } | ||
| 1079 | 713039 | pred_mode = pred_mode_flag ? MODE_INTRA : MODE_INTER; | |
| 1080 | |||
| 1081 |
4/4✓ Branch 0 taken 85795 times.
✓ Branch 1 taken 627244 times.
✓ Branch 2 taken 9881 times.
✓ Branch 3 taken 75914 times.
|
713039 | if (((IS_I(rsh) && !cu->skip_flag) || |
| 1082 |
6/6✓ Branch 0 taken 627244 times.
✓ Branch 1 taken 9881 times.
✓ Branch 2 taken 162774 times.
✓ Branch 3 taken 464470 times.
✓ Branch 4 taken 115910 times.
✓ Branch 5 taken 46864 times.
|
637125 | (!IS_I(rsh) && (pred_mode != MODE_INTRA || |
| 1083 |
6/6✓ Branch 0 taken 66950 times.
✓ Branch 1 taken 48960 times.
✓ Branch 2 taken 104210 times.
✓ Branch 3 taken 9604 times.
✓ Branch 4 taken 615908 times.
✓ Branch 5 taken 28686 times.
|
703158 | ((is_4x4 || mode_type == MODE_TYPE_INTRA) && !cu->skip_flag)))) && |
| 1084 |
6/6✓ Branch 0 taken 550185 times.
✓ Branch 1 taken 65723 times.
✓ Branch 2 taken 183378 times.
✓ Branch 3 taken 366807 times.
✓ Branch 4 taken 157419 times.
✓ Branch 5 taken 25959 times.
|
615908 | !is_128 && mode_type != MODE_TYPE_INTER && sps->r->sps_ibc_enabled_flag && |
| 1085 | tree_type != DUAL_TREE_CHROMA) { | ||
| 1086 | 157419 | pred_mode_ibc_flag = ff_vvc_pred_mode_ibc_flag(lc, ch_type); | |
| 1087 |
6/6✓ Branch 0 taken 262079 times.
✓ Branch 1 taken 293541 times.
✓ Branch 2 taken 254968 times.
✓ Branch 3 taken 7111 times.
✓ Branch 4 taken 4237 times.
✓ Branch 5 taken 250731 times.
|
555620 | } else if (cu->skip_flag && (is_4x4 || mode_type == MODE_TYPE_INTRA)) { |
| 1088 | 11348 | pred_mode_ibc_flag = 1; | |
| 1089 |
6/6✓ Branch 0 taken 515527 times.
✓ Branch 1 taken 28745 times.
✓ Branch 2 taken 449804 times.
✓ Branch 3 taken 65723 times.
✓ Branch 4 taken 34554 times.
✓ Branch 5 taken 415250 times.
|
544272 | } else if (is_128 || mode_type == MODE_TYPE_INTER || tree_type == DUAL_TREE_CHROMA) { |
| 1090 | 129022 | pred_mode_ibc_flag = 0; | |
| 1091 | } else { | ||
| 1092 |
2/2✓ Branch 0 taken 8137 times.
✓ Branch 1 taken 407113 times.
|
415250 | pred_mode_ibc_flag = (IS_I(rsh)) ? sps->r->sps_ibc_enabled_flag : 0; |
| 1093 | } | ||
| 1094 |
2/2✓ Branch 0 taken 67240 times.
✓ Branch 1 taken 645799 times.
|
713039 | if (pred_mode_ibc_flag) |
| 1095 | 67240 | pred_mode = MODE_IBC; | |
| 1096 | } else { | ||
| 1097 | 631570 | pred_mode = MODE_INTRA; | |
| 1098 | } | ||
| 1099 | |||
| 1100 |
7/10✓ Branch 0 taken 816827 times.
✓ Branch 1 taken 527782 times.
✓ Branch 2 taken 28396 times.
✓ Branch 3 taken 788431 times.
✓ Branch 4 taken 28396 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28396 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28396 times.
✗ Branch 9 not taken.
|
1344609 | if (pred_mode == MODE_INTRA && sps->r->sps_palette_enabled_flag && !is_128 && !cu->skip_flag && |
| 1101 |
2/2✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 3315 times.
|
28396 | mode_type != MODE_TYPE_INTER && ((cu->cb_width * cu->cb_height) > |
| 1102 |
4/4✓ Branch 0 taken 4482 times.
✓ Branch 1 taken 23914 times.
✓ Branch 2 taken 6728 times.
✓ Branch 3 taken 18353 times.
|
53477 | (tree_type != DUAL_TREE_CHROMA ? 16 : (16 << hs << vs))) && |
| 1103 |
2/2✓ Branch 0 taken 2796 times.
✓ Branch 1 taken 3932 times.
|
6728 | (mode_type != MODE_TYPE_INTRA || tree_type != DUAL_TREE_CHROMA)) { |
| 1104 |
2/2✓ Branch 1 taken 4497 times.
✓ Branch 2 taken 16652 times.
|
21149 | if (ff_vvc_pred_mode_plt_flag(lc)) |
| 1105 | 4497 | pred_mode = MODE_PLT; | |
| 1106 | } | ||
| 1107 | |||
| 1108 | 1344609 | set_cb_tab(lc, fc->tab.cpm[cu->ch_type], pred_mode); | |
| 1109 |
2/2✓ Branch 0 taken 570526 times.
✓ Branch 1 taken 774083 times.
|
1344609 | if (tree_type == SINGLE_TREE) |
| 1110 | 570526 | set_cb_tab(lc, fc->tab.cpm[CHROMA], pred_mode); | |
| 1111 | |||
| 1112 | 1344609 | return pred_mode; | |
| 1113 | } | ||
| 1114 | |||
| 1115 | 990262 | static void sbt_info(VVCLocalContext *lc, const VVCSPS *sps) | |
| 1116 | { | ||
| 1117 | 990262 | CodingUnit *cu = lc->cu; | |
| 1118 | 990262 | const int cb_width = cu->cb_width; | |
| 1119 | 990262 | const int cb_height = cu->cb_height; | |
| 1120 | |||
| 1121 |
6/6✓ Branch 0 taken 161068 times.
✓ Branch 1 taken 829194 times.
✓ Branch 2 taken 155340 times.
✓ Branch 3 taken 5728 times.
✓ Branch 4 taken 139437 times.
✓ Branch 5 taken 15903 times.
|
990262 | if (cu->pred_mode == MODE_INTER && sps->r->sps_sbt_enabled_flag && !cu->ciip_flag |
| 1122 |
4/4✓ Branch 0 taken 136583 times.
✓ Branch 1 taken 2854 times.
✓ Branch 2 taken 135700 times.
✓ Branch 3 taken 883 times.
|
139437 | && cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) { |
| 1123 | 135700 | const int sbt_ver_h = cb_width >= 8; | |
| 1124 | 135700 | const int sbt_hor_h = cb_height >= 8; | |
| 1125 | 135700 | cu->sbt_flag = 0; | |
| 1126 |
3/4✓ Branch 0 taken 20760 times.
✓ Branch 1 taken 114940 times.
✓ Branch 2 taken 20760 times.
✗ Branch 3 not taken.
|
135700 | if (sbt_ver_h || sbt_hor_h) |
| 1127 | 135700 | cu->sbt_flag = ff_vvc_sbt_flag(lc); | |
| 1128 |
2/2✓ Branch 0 taken 45453 times.
✓ Branch 1 taken 90247 times.
|
135700 | if (cu->sbt_flag) { |
| 1129 | 45453 | const int sbt_ver_q = cb_width >= 16; | |
| 1130 | 45453 | const int sbt_hor_q = cb_height >= 16; | |
| 1131 | 45453 | int cu_sbt_quad_flag = 0; | |
| 1132 | |||
| 1133 |
7/8✓ Branch 0 taken 7617 times.
✓ Branch 1 taken 37836 times.
✓ Branch 2 taken 7617 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25167 times.
✓ Branch 5 taken 20286 times.
✓ Branch 6 taken 12099 times.
✓ Branch 7 taken 13068 times.
|
45453 | if ((sbt_ver_h || sbt_hor_h) && (sbt_ver_q || sbt_hor_q)) |
| 1134 | 32385 | cu_sbt_quad_flag = ff_vvc_sbt_quad_flag(lc); | |
| 1135 |
2/2✓ Branch 0 taken 11769 times.
✓ Branch 1 taken 33684 times.
|
45453 | if (cu_sbt_quad_flag) { |
| 1136 | 11769 | cu->sbt_horizontal_flag = sbt_hor_q; | |
| 1137 |
4/4✓ Branch 0 taken 7788 times.
✓ Branch 1 taken 3981 times.
✓ Branch 2 taken 3587 times.
✓ Branch 3 taken 4201 times.
|
11769 | if (sbt_ver_q && sbt_hor_q) |
| 1138 | 3587 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
| 1139 | } else { | ||
| 1140 | 33684 | cu->sbt_horizontal_flag = sbt_hor_h; | |
| 1141 |
4/4✓ Branch 0 taken 27602 times.
✓ Branch 1 taken 6082 times.
✓ Branch 2 taken 21950 times.
✓ Branch 3 taken 5652 times.
|
33684 | if (sbt_ver_h && sbt_hor_h) |
| 1142 | 21950 | cu->sbt_horizontal_flag = ff_vvc_sbt_horizontal_flag(lc); | |
| 1143 | } | ||
| 1144 | 45453 | cu->sbt_pos_flag = ff_vvc_sbt_pos_flag(lc); | |
| 1145 | |||
| 1146 | { | ||
| 1147 |
2/2✓ Branch 0 taken 11769 times.
✓ Branch 1 taken 33684 times.
|
45453 | const int sbt_min = cu_sbt_quad_flag ? 1 : 2; |
| 1148 |
2/2✓ Branch 0 taken 21749 times.
✓ Branch 1 taken 23704 times.
|
45453 | lc->parse.sbt_num_fourths_tb0 = cu->sbt_pos_flag ? (4 - sbt_min) : sbt_min; |
| 1149 | } | ||
| 1150 | } | ||
| 1151 | } | ||
| 1152 | 990262 | } | |
| 1153 | |||
| 1154 | 349850 | static int skipped_transform_tree_unit(VVCLocalContext *lc) | |
| 1155 | { | ||
| 1156 | 349850 | const H266RawSPS *rsps = lc->fc->ps.sps->r; | |
| 1157 | 349850 | const CodingUnit *cu = lc->cu; | |
| 1158 | int ret; | ||
| 1159 | |||
| 1160 |
1/2✓ Branch 0 taken 349850 times.
✗ Branch 1 not taken.
|
349850 | if (cu->tree_type != DUAL_TREE_CHROMA) |
| 1161 | 349850 | set_qp_y(lc, cu->x0, cu->y0, 0); | |
| 1162 |
4/4✓ Branch 0 taken 333339 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 302798 times.
✓ Branch 3 taken 30541 times.
|
349850 | if (rsps->sps_chroma_format_idc && cu->tree_type != DUAL_TREE_LUMA) |
| 1163 | 302798 | set_qp_c(lc); | |
| 1164 | 349850 | ret = skipped_transform_tree(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
| 1165 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 349850 times.
|
349850 | if (ret < 0) |
| 1166 | ✗ | return ret; | |
| 1167 | 349850 | return 0; | |
| 1168 | } | ||
| 1169 | |||
| 1170 | 1344609 | static void set_cb_pos(const VVCFrameContext *fc, const CodingUnit *cu) | |
| 1171 | { | ||
| 1172 | 1344609 | const VVCSPS *sps = fc->ps.sps; | |
| 1173 | 1344609 | const VVCPPS *pps = fc->ps.pps; | |
| 1174 | 1344609 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
| 1175 | 1344609 | const int x_cb = cu->x0 >> log2_min_cb_size; | |
| 1176 | 1344609 | const int y_cb = cu->y0 >> log2_min_cb_size; | |
| 1177 | 1344609 | const int ch_type = cu->ch_type; | |
| 1178 | int x, y; | ||
| 1179 | |||
| 1180 | 1344609 | x = y_cb * pps->min_cb_width + x_cb; | |
| 1181 |
2/2✓ Branch 0 taken 5586888 times.
✓ Branch 1 taken 1344609 times.
|
6931497 | for (y = 0; y < (cu->cb_height >> log2_min_cb_size); y++) { |
| 1182 | 5586888 | const int width = cu->cb_width >> log2_min_cb_size; | |
| 1183 | |||
| 1184 |
2/2✓ Branch 0 taken 54219272 times.
✓ Branch 1 taken 5586888 times.
|
59806160 | for (int i = 0; i < width; i++) { |
| 1185 | 54219272 | fc->tab.cb_pos_x[ch_type][x + i] = cu->x0; | |
| 1186 | 54219272 | fc->tab.cb_pos_y[ch_type][x + i] = cu->y0; | |
| 1187 | } | ||
| 1188 | 5586888 | memset(&fc->tab.cb_width[ch_type][x], cu->cb_width, width); | |
| 1189 | 5586888 | memset(&fc->tab.cb_height[ch_type][x], cu->cb_height, width); | |
| 1190 | 5586888 | memset(&fc->tab.cqt_depth[ch_type][x], cu->cqt_depth, width); | |
| 1191 | |||
| 1192 | 5586888 | x += pps->min_cb_width; | |
| 1193 | } | ||
| 1194 | 1344609 | } | |
| 1195 | |||
| 1196 | 1344609 | static CodingUnit* alloc_cu(VVCLocalContext *lc, const int x0, const int y0) | |
| 1197 | { | ||
| 1198 | 1344609 | VVCFrameContext *fc = lc->fc; | |
| 1199 | 1344609 | const VVCSPS *sps = fc->ps.sps; | |
| 1200 | 1344609 | const VVCPPS *pps = fc->ps.pps; | |
| 1201 | 1344609 | const int rx = x0 >> sps->ctb_log2_size_y; | |
| 1202 | 1344609 | const int ry = y0 >> sps->ctb_log2_size_y; | |
| 1203 | 1344609 | CodingUnit **cus = fc->tab.cus + ry * pps->ctb_width + rx; | |
| 1204 | 1344609 | CodingUnit *cu = av_refstruct_pool_get(fc->cu_pool); | |
| 1205 | |||
| 1206 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1344609 times.
|
1344609 | if (!cu) |
| 1207 | ✗ | return NULL; | |
| 1208 | 1344609 | cu->next = NULL; | |
| 1209 | |||
| 1210 |
2/2✓ Branch 0 taken 1291134 times.
✓ Branch 1 taken 53475 times.
|
1344609 | if (lc->cu) |
| 1211 | 1291134 | lc->cu->next = cu; | |
| 1212 | else | ||
| 1213 | 53475 | *cus = cu; | |
| 1214 | 1344609 | lc->cu = cu; | |
| 1215 | |||
| 1216 | 1344609 | return cu; | |
| 1217 | } | ||
| 1218 | |||
| 1219 | 1344609 | static CodingUnit* add_cu(VVCLocalContext *lc, const int x0, const int y0, | |
| 1220 | const int cb_width, const int cb_height, const int cqt_depth, const VVCTreeType tree_type) | ||
| 1221 | { | ||
| 1222 | 1344609 | VVCFrameContext *fc = lc->fc; | |
| 1223 | 1344609 | const int ch_type = tree_type == DUAL_TREE_CHROMA ? 1 : 0; | |
| 1224 | 1344609 | CodingUnit *cu = alloc_cu(lc, x0, y0); | |
| 1225 | |||
| 1226 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1344609 times.
|
1344609 | if (!cu) |
| 1227 | ✗ | return NULL; | |
| 1228 | |||
| 1229 | 1344609 | memset(&cu->pu, 0, sizeof(cu->pu)); | |
| 1230 | |||
| 1231 | 1344609 | lc->parse.prev_tu_cbf_y = 0; | |
| 1232 | |||
| 1233 | 1344609 | cu->sbt_flag = 0; | |
| 1234 | 1344609 | cu->act_enabled_flag = 0; | |
| 1235 | |||
| 1236 | 1344609 | cu->tree_type = tree_type; | |
| 1237 | 1344609 | cu->x0 = x0; | |
| 1238 | 1344609 | cu->y0 = y0; | |
| 1239 | 1344609 | cu->cb_width = cb_width; | |
| 1240 | 1344609 | cu->cb_height = cb_height; | |
| 1241 | 1344609 | cu->ch_type = ch_type; | |
| 1242 | 1344609 | cu->cqt_depth = cqt_depth; | |
| 1243 | 1344609 | cu->tus.head = cu->tus.tail = NULL; | |
| 1244 | 1344609 | cu->bdpcm_flag[LUMA] = cu->bdpcm_flag[CB] = cu->bdpcm_flag[CR] = 0; | |
| 1245 | 1344609 | cu->isp_split_type = ISP_NO_SPLIT; | |
| 1246 | 1344609 | cu->intra_mip_flag = 0; | |
| 1247 | 1344609 | cu->ciip_flag = 0; | |
| 1248 | 1344609 | cu->coded_flag = 1; | |
| 1249 | 1344609 | cu->num_intra_subpartitions = 1; | |
| 1250 | 1344609 | cu->pu.dmvr_flag = 0; | |
| 1251 | |||
| 1252 | 1344609 | set_cb_pos(fc, cu); | |
| 1253 | 1344609 | return cu; | |
| 1254 | } | ||
| 1255 | |||
| 1256 | 1344609 | static void set_cu_tabs(const VVCLocalContext *lc, const CodingUnit *cu) | |
| 1257 | { | ||
| 1258 | 1344609 | const VVCFrameContext *fc = lc->fc; | |
| 1259 | 1344609 | const PredictionUnit *pu = &cu->pu; | |
| 1260 | 1344609 | const TransformUnit *tu = cu->tus.head; | |
| 1261 | |||
| 1262 | 1344609 | set_cb_tab(lc, fc->tab.mmi, pu->mi.motion_model_idc); | |
| 1263 | 1344609 | set_cb_tab(lc, fc->tab.msf, pu->merge_subblock_flag); | |
| 1264 |
2/2✓ Branch 0 taken 1157301 times.
✓ Branch 1 taken 187308 times.
|
1344609 | if (cu->tree_type != DUAL_TREE_CHROMA) { |
| 1265 | 1157301 | set_cb_tab(lc, fc->tab.skip, cu->skip_flag); | |
| 1266 | 1157301 | set_cb_tab(lc, fc->tab.pcmf[LUMA], cu->bdpcm_flag[LUMA]); | |
| 1267 | } | ||
| 1268 |
2/2✓ Branch 0 taken 757834 times.
✓ Branch 1 taken 586775 times.
|
1344609 | if (cu->tree_type != DUAL_TREE_LUMA) |
| 1269 | 757834 | set_cb_tab(lc, fc->tab.pcmf[CHROMA], cu->bdpcm_flag[CHROMA]); | |
| 1270 | |||
| 1271 |
2/2✓ Branch 0 taken 1663917 times.
✓ Branch 1 taken 1344609 times.
|
3008526 | while (tu) { |
| 1272 |
2/2✓ Branch 0 taken 3262185 times.
✓ Branch 1 taken 1663917 times.
|
4926102 | for (int j = 0; j < tu->nb_tbs; j++) { |
| 1273 | 3262185 | const TransformBlock *tb = tu->tbs + j; | |
| 1274 |
2/2✓ Branch 0 taken 1786432 times.
✓ Branch 1 taken 1475753 times.
|
3262185 | if (tb->c_idx != LUMA) |
| 1275 | 1786432 | set_qp_c_tab(lc, tu, tb); | |
| 1276 | } | ||
| 1277 | 1663917 | tu = tu->next; | |
| 1278 | } | ||
| 1279 | 1344609 | } | |
| 1280 | |||
| 1281 | //8.5.2.7 Derivation process for merge motion vector difference | ||
| 1282 | 58026 | static void derive_mmvd(const VVCLocalContext *lc, MvField *mvf, const Mv *mmvd_offset) | |
| 1283 | { | ||
| 1284 | 58026 | const SliceContext *sc = lc->sc; | |
| 1285 | Mv mmvd[2]; | ||
| 1286 | |||
| 1287 |
2/2✓ Branch 0 taken 24450 times.
✓ Branch 1 taken 33576 times.
|
58026 | if (mvf->pred_flag == PF_BI) { |
| 1288 | 24450 | const RefPicList *rpl = sc->rpl; | |
| 1289 | 24450 | const int poc = lc->fc->ps.ph.poc; | |
| 1290 | 24450 | const int diff[] = { | |
| 1291 | 24450 | poc - rpl[L0].refs[mvf->ref_idx[L0]].poc, | |
| 1292 | 24450 | poc - rpl[L1].refs[mvf->ref_idx[L1]].poc | |
| 1293 | }; | ||
| 1294 |
4/4✓ Branch 0 taken 23103 times.
✓ Branch 1 taken 1347 times.
✓ Branch 2 taken 9320 times.
✓ Branch 3 taken 15130 times.
|
24450 | const int sign = FFSIGN(diff[0]) != FFSIGN(diff[1]); |
| 1295 | |||
| 1296 |
2/2✓ Branch 0 taken 8287 times.
✓ Branch 1 taken 16163 times.
|
24450 | if (diff[0] == diff[1]) { |
| 1297 | 8287 | mmvd[1] = mmvd[0] = *mmvd_offset; | |
| 1298 | } | ||
| 1299 | else { | ||
| 1300 | 16163 | const int i = FFABS(diff[0]) < FFABS(diff[1]); | |
| 1301 | 16163 | const int o = !i; | |
| 1302 | 16163 | mmvd[i] = *mmvd_offset; | |
| 1303 |
4/4✓ Branch 0 taken 15919 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 15842 times.
✓ Branch 3 taken 77 times.
|
16163 | if (!rpl[L0].refs[mvf->ref_idx[L0]].is_lt && !rpl[L1].refs[mvf->ref_idx[L1]].is_lt) { |
| 1304 | 15842 | ff_vvc_mv_scale(&mmvd[o], mmvd_offset, diff[i], diff[o]); | |
| 1305 | } | ||
| 1306 | else { | ||
| 1307 |
2/2✓ Branch 0 taken 199 times.
✓ Branch 1 taken 122 times.
|
321 | mmvd[o].x = sign ? -mmvd[i].x : mmvd[i].x; |
| 1308 |
2/2✓ Branch 0 taken 199 times.
✓ Branch 1 taken 122 times.
|
321 | mmvd[o].y = sign ? -mmvd[i].y : mmvd[i].y; |
| 1309 | } | ||
| 1310 | } | ||
| 1311 | 24450 | mvf->mv[0].x += mmvd[0].x; | |
| 1312 | 24450 | mvf->mv[0].y += mmvd[0].y; | |
| 1313 | 24450 | mvf->mv[1].x += mmvd[1].x; | |
| 1314 | 24450 | mvf->mv[1].y += mmvd[1].y; | |
| 1315 | } else { | ||
| 1316 | 33576 | const int idx = mvf->pred_flag - PF_L0; | |
| 1317 | 33576 | mvf->mv[idx].x += mmvd_offset->x; | |
| 1318 | 33576 | mvf->mv[idx].y += mmvd_offset->y; | |
| 1319 | } | ||
| 1320 | |||
| 1321 | 58026 | } | |
| 1322 | |||
| 1323 | 297591 | static void mvf_to_mi(const MvField *mvf, MotionInfo *mi) | |
| 1324 | { | ||
| 1325 | 297591 | mi->pred_flag = mvf->pred_flag; | |
| 1326 | 297591 | mi->bcw_idx = mvf->bcw_idx; | |
| 1327 | 297591 | mi->hpel_if_idx = mvf->hpel_if_idx; | |
| 1328 |
2/2✓ Branch 0 taken 595182 times.
✓ Branch 1 taken 297591 times.
|
892773 | for (int i = 0; i < 2; i++) { |
| 1329 | 595182 | const PredFlag mask = i + 1; | |
| 1330 |
2/2✓ Branch 0 taken 464622 times.
✓ Branch 1 taken 130560 times.
|
595182 | if (mvf->pred_flag & mask) { |
| 1331 | 464622 | mi->mv[i][0] = mvf->mv[i]; | |
| 1332 | 464622 | mi->ref_idx[i] = mvf->ref_idx[i]; | |
| 1333 | } | ||
| 1334 | } | ||
| 1335 | 297591 | } | |
| 1336 | |||
| 1337 | 297591 | static void mv_merge_refine_pred_flag(MvField *mvf, const int width, const int height) | |
| 1338 | { | ||
| 1339 |
4/4✓ Branch 0 taken 172284 times.
✓ Branch 1 taken 125307 times.
✓ Branch 2 taken 5253 times.
✓ Branch 3 taken 167031 times.
|
297591 | if (mvf->pred_flag == PF_BI && (width + height) == 12) { |
| 1340 | 5253 | mvf->pred_flag = PF_L0; | |
| 1341 | 5253 | mvf->bcw_idx = 0; | |
| 1342 | } | ||
| 1343 | 297591 | } | |
| 1344 | |||
| 1345 | // subblock-based inter prediction data | ||
| 1346 | 54720 | static void merge_data_subblock(VVCLocalContext *lc) | |
| 1347 | { | ||
| 1348 | 54720 | const VVCFrameContext *fc = lc->fc; | |
| 1349 | 54720 | const VVCPH *ph = &fc->ps.ph; | |
| 1350 | 54720 | CodingUnit* cu = lc->cu; | |
| 1351 | 54720 | PredictionUnit *pu = &cu->pu; | |
| 1352 | 54720 | int merge_subblock_idx = 0; | |
| 1353 | |||
| 1354 |
1/2✓ Branch 0 taken 54720 times.
✗ Branch 1 not taken.
|
54720 | if (ph->max_num_subblock_merge_cand > 1) { |
| 1355 | 54720 | merge_subblock_idx = ff_vvc_merge_subblock_idx(lc, ph->max_num_subblock_merge_cand); | |
| 1356 | } | ||
| 1357 | 54720 | ff_vvc_sb_mv_merge_mode(lc, merge_subblock_idx, pu); | |
| 1358 | 54720 | } | |
| 1359 | |||
| 1360 | 281264 | static void merge_data_regular(VVCLocalContext *lc) | |
| 1361 | { | ||
| 1362 | 281264 | const VVCFrameContext *fc = lc->fc; | |
| 1363 | 281264 | const VVCSPS *sps = fc->ps.sps; | |
| 1364 | 281264 | const VVCPH *ph = &fc->ps.ph; | |
| 1365 | 281264 | const CodingUnit* cu = lc->cu; | |
| 1366 | 281264 | PredictionUnit *pu = &lc->cu->pu; | |
| 1367 | 281264 | int merge_idx = 0; | |
| 1368 | Mv mmvd_offset; | ||
| 1369 | MvField mvf; | ||
| 1370 | |||
| 1371 |
2/2✓ Branch 0 taken 276100 times.
✓ Branch 1 taken 5164 times.
|
281264 | if (sps->r->sps_mmvd_enabled_flag) |
| 1372 | 276100 | pu->mmvd_merge_flag = ff_vvc_mmvd_merge_flag(lc); | |
| 1373 |
2/2✓ Branch 0 taken 58026 times.
✓ Branch 1 taken 223238 times.
|
281264 | if (pu->mmvd_merge_flag) { |
| 1374 | 58026 | int mmvd_cand_flag = 0; | |
| 1375 |
1/2✓ Branch 0 taken 58026 times.
✗ Branch 1 not taken.
|
58026 | if (sps->max_num_merge_cand > 1) |
| 1376 | 58026 | mmvd_cand_flag = ff_vvc_mmvd_cand_flag(lc); | |
| 1377 | 58026 | ff_vvc_mmvd_offset_coding(lc, &mmvd_offset, ph->r->ph_mmvd_fullpel_only_flag); | |
| 1378 | 58026 | merge_idx = mmvd_cand_flag; | |
| 1379 |
1/2✓ Branch 0 taken 223238 times.
✗ Branch 1 not taken.
|
223238 | } else if (sps->max_num_merge_cand > 1) { |
| 1380 | 223238 | merge_idx = ff_vvc_merge_idx(lc); | |
| 1381 | } | ||
| 1382 | 281264 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 0, &mvf); | |
| 1383 |
2/2✓ Branch 0 taken 58026 times.
✓ Branch 1 taken 223238 times.
|
281264 | if (pu->mmvd_merge_flag) |
| 1384 | 58026 | derive_mmvd(lc, &mvf, &mmvd_offset); | |
| 1385 | 281264 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
| 1386 | 281264 | ff_vvc_store_mvf(lc, &mvf); | |
| 1387 | 281264 | mvf_to_mi(&mvf, &pu->mi); | |
| 1388 | 281264 | } | |
| 1389 | |||
| 1390 | 43921 | static int ciip_flag_decode(VVCLocalContext *lc, const int ciip_avaiable, const int gpm_avaiable, const int is_128) | |
| 1391 | { | ||
| 1392 | 43921 | const VVCFrameContext *fc = lc->fc; | |
| 1393 | 43921 | const VVCSPS *sps = fc->ps.sps; | |
| 1394 | 43921 | const CodingUnit *cu = lc->cu; | |
| 1395 | |||
| 1396 |
4/4✓ Branch 0 taken 27094 times.
✓ Branch 1 taken 16827 times.
✓ Branch 2 taken 20147 times.
✓ Branch 3 taken 6947 times.
|
43921 | if (ciip_avaiable && gpm_avaiable) |
| 1397 | 20147 | return ff_vvc_ciip_flag(lc); | |
| 1398 |
3/4✓ Branch 0 taken 6947 times.
✓ Branch 1 taken 16827 times.
✓ Branch 2 taken 6947 times.
✗ Branch 3 not taken.
|
23774 | return sps->r->sps_ciip_enabled_flag && !cu->skip_flag && |
| 1399 |
2/4✓ Branch 0 taken 23774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6947 times.
✗ Branch 3 not taken.
|
47548 | !is_128 && (cu->cb_width * cu->cb_height >= 64); |
| 1400 | } | ||
| 1401 | |||
| 1402 | 27594 | static void merge_data_gpm(VVCLocalContext *lc) | |
| 1403 | { | ||
| 1404 | 27594 | const VVCFrameContext *fc = lc->fc; | |
| 1405 | 27594 | const VVCSPS *sps = fc->ps.sps; | |
| 1406 | 27594 | PredictionUnit *pu = &lc->cu->pu; | |
| 1407 | int merge_gpm_idx[2]; | ||
| 1408 | |||
| 1409 | 27594 | pu->merge_gpm_flag = 1; | |
| 1410 | 27594 | pu->gpm_partition_idx = ff_vvc_merge_gpm_partition_idx(lc); | |
| 1411 | 27594 | merge_gpm_idx[0] = ff_vvc_merge_gpm_idx(lc, 0); | |
| 1412 | 27594 | merge_gpm_idx[1] = 0; | |
| 1413 |
1/2✓ Branch 0 taken 27594 times.
✗ Branch 1 not taken.
|
27594 | if (sps->max_num_gpm_merge_cand > 2) |
| 1414 | 27594 | merge_gpm_idx[1] = ff_vvc_merge_gpm_idx(lc, 1); | |
| 1415 | |||
| 1416 | 27594 | ff_vvc_luma_mv_merge_gpm(lc, merge_gpm_idx, pu->gpm_mv); | |
| 1417 | 27594 | ff_vvc_store_gpm_mvf(lc, pu); | |
| 1418 | 27594 | } | |
| 1419 | |||
| 1420 | 16327 | static void merge_data_ciip(VVCLocalContext *lc) | |
| 1421 | { | ||
| 1422 | 16327 | const VVCFrameContext* fc = lc->fc; | |
| 1423 | 16327 | const VVCSPS* sps = fc->ps.sps; | |
| 1424 | 16327 | CodingUnit *cu = lc->cu; | |
| 1425 | 16327 | MotionInfo *mi = &cu->pu.mi; | |
| 1426 | 16327 | int merge_idx = 0; | |
| 1427 | MvField mvf; | ||
| 1428 | |||
| 1429 |
1/2✓ Branch 0 taken 16327 times.
✗ Branch 1 not taken.
|
16327 | if (sps->max_num_merge_cand > 1) |
| 1430 | 16327 | merge_idx = ff_vvc_merge_idx(lc); | |
| 1431 | 16327 | ff_vvc_luma_mv_merge_mode(lc, merge_idx, 1, &mvf); | |
| 1432 | 16327 | mv_merge_refine_pred_flag(&mvf, cu->cb_width, cu->cb_height); | |
| 1433 | 16327 | ff_vvc_store_mvf(lc, &mvf); | |
| 1434 | 16327 | mvf_to_mi(&mvf, mi); | |
| 1435 | 16327 | cu->intra_pred_mode_y = cu->intra_pred_mode_c = INTRA_PLANAR; | |
| 1436 | 16327 | cu->intra_luma_ref_idx = 0; | |
| 1437 | 16327 | cu->intra_mip_flag = 0; | |
| 1438 | 16327 | } | |
| 1439 | |||
| 1440 | // block-based inter prediction data | ||
| 1441 | 325185 | static void merge_data_block(VVCLocalContext *lc) | |
| 1442 | { | ||
| 1443 | 325185 | const VVCFrameContext* fc = lc->fc; | |
| 1444 | 325185 | const VVCSPS *sps = fc->ps.sps; | |
| 1445 | 325185 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 1446 | 325185 | CodingUnit *cu = lc->cu; | |
| 1447 | 325185 | const int cb_width = cu->cb_width; | |
| 1448 | 325185 | const int cb_height = cu->cb_height; | |
| 1449 |
4/4✓ Branch 0 taken 304832 times.
✓ Branch 1 taken 20353 times.
✓ Branch 2 taken 1377 times.
✓ Branch 3 taken 303455 times.
|
325185 | const int is_128 = cb_width == 128 || cb_height == 128; |
| 1450 | 970391 | const int ciip_avaiable = sps->r->sps_ciip_enabled_flag && | |
| 1451 |
6/6✓ Branch 0 taken 320021 times.
✓ Branch 1 taken 5164 times.
✓ Branch 2 taken 103733 times.
✓ Branch 3 taken 216288 times.
✓ Branch 4 taken 92605 times.
✓ Branch 5 taken 11128 times.
|
325185 | !cu->skip_flag && (cb_width * cb_height >= 64); |
| 1452 |
4/4✓ Branch 0 taken 304847 times.
✓ Branch 1 taken 906 times.
✓ Branch 2 taken 268592 times.
✓ Branch 3 taken 36255 times.
|
305753 | const int gpm_avaiable = sps->r->sps_gpm_enabled_flag && IS_B(rsh) && |
| 1453 |
2/2✓ Branch 0 taken 239093 times.
✓ Branch 1 taken 29499 times.
|
268592 | (cb_width >= 8) && (cb_height >=8) && |
| 1454 |
6/6✓ Branch 0 taken 305753 times.
✓ Branch 1 taken 19432 times.
✓ Branch 2 taken 232062 times.
✓ Branch 3 taken 7031 times.
✓ Branch 4 taken 230076 times.
✓ Branch 5 taken 1986 times.
|
630938 | (cb_width < 8 * cb_height) && (cb_height < 8 *cb_width); |
| 1455 | |||
| 1456 | 325185 | int regular_merge_flag = 1; | |
| 1457 | |||
| 1458 |
6/6✓ Branch 0 taken 303455 times.
✓ Branch 1 taken 21730 times.
✓ Branch 2 taken 211231 times.
✓ Branch 3 taken 92224 times.
✓ Branch 4 taken 144109 times.
✓ Branch 5 taken 67122 times.
|
325185 | if (!is_128 && (ciip_avaiable || gpm_avaiable)) |
| 1459 | 236333 | regular_merge_flag = ff_vvc_regular_merge_flag(lc, cu->skip_flag); | |
| 1460 |
2/2✓ Branch 0 taken 281264 times.
✓ Branch 1 taken 43921 times.
|
325185 | if (regular_merge_flag) { |
| 1461 | 281264 | merge_data_regular(lc); | |
| 1462 | } else { | ||
| 1463 | 43921 | cu->ciip_flag = ciip_flag_decode(lc, ciip_avaiable, gpm_avaiable, is_128); | |
| 1464 |
2/2✓ Branch 0 taken 16327 times.
✓ Branch 1 taken 27594 times.
|
43921 | if (cu->ciip_flag) |
| 1465 | 16327 | merge_data_ciip(lc); | |
| 1466 | else | ||
| 1467 | 27594 | merge_data_gpm(lc); | |
| 1468 | } | ||
| 1469 | 325185 | } | |
| 1470 | |||
| 1471 | 28190 | static int merge_data_ibc(VVCLocalContext *lc) | |
| 1472 | { | ||
| 1473 | 28190 | const VVCFrameContext* fc = lc->fc; | |
| 1474 | 28190 | const VVCSPS* sps = fc->ps.sps; | |
| 1475 | 28190 | MotionInfo *mi = &lc->cu->pu.mi; | |
| 1476 | 28190 | int merge_idx = 0; | |
| 1477 | int ret; | ||
| 1478 | |||
| 1479 | 28190 | mi->pred_flag = PF_IBC; | |
| 1480 | |||
| 1481 |
2/2✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 240 times.
|
28190 | if (sps->max_num_ibc_merge_cand > 1) |
| 1482 | 27950 | merge_idx = ff_vvc_merge_idx(lc); | |
| 1483 | |||
| 1484 | 28190 | ret = ff_vvc_luma_mv_merge_ibc(lc, merge_idx, &mi->mv[L0][0]); | |
| 1485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 28190 times.
|
28190 | if (ret) |
| 1486 | ✗ | return ret; | |
| 1487 | 28190 | ff_vvc_store_mv(lc, mi); | |
| 1488 | |||
| 1489 | 28190 | return 0; | |
| 1490 | } | ||
| 1491 | |||
| 1492 | 408095 | static int hls_merge_data(VVCLocalContext *lc) | |
| 1493 | { | ||
| 1494 | 408095 | const VVCFrameContext *fc = lc->fc; | |
| 1495 | 408095 | const VVCPH *ph = &fc->ps.ph; | |
| 1496 | 408095 | const CodingUnit *cu = lc->cu; | |
| 1497 | 408095 | PredictionUnit *pu = &lc->cu->pu; | |
| 1498 | int ret; | ||
| 1499 | |||
| 1500 | 408095 | pu->merge_gpm_flag = 0; | |
| 1501 | 408095 | pu->mi.num_sb_x = pu->mi.num_sb_y = 1; | |
| 1502 |
2/2✓ Branch 0 taken 28190 times.
✓ Branch 1 taken 379905 times.
|
408095 | if (cu->pred_mode == MODE_IBC) { |
| 1503 | 28190 | ret = merge_data_ibc(lc); | |
| 1504 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 28190 times.
|
28190 | if (ret) |
| 1505 | ✗ | return ret; | |
| 1506 | } else { | ||
| 1507 |
5/6✓ Branch 0 taken 379905 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 341787 times.
✓ Branch 3 taken 38118 times.
✓ Branch 4 taken 310327 times.
✓ Branch 5 taken 31460 times.
|
379905 | if (ph->max_num_subblock_merge_cand > 0 && cu->cb_width >= 8 && cu->cb_height >= 8) |
| 1508 | 310327 | pu->merge_subblock_flag = ff_vvc_merge_subblock_flag(lc); | |
| 1509 |
2/2✓ Branch 0 taken 54720 times.
✓ Branch 1 taken 325185 times.
|
379905 | if (pu->merge_subblock_flag) |
| 1510 | 54720 | merge_data_subblock(lc); | |
| 1511 | else | ||
| 1512 | 325185 | merge_data_block(lc); | |
| 1513 | } | ||
| 1514 | 408095 | return 0; | |
| 1515 | } | ||
| 1516 | |||
| 1517 | 146617 | static void hls_mvd_coding(VVCLocalContext *lc, Mv* mvd) | |
| 1518 | { | ||
| 1519 | int32_t mv[2]; | ||
| 1520 | |||
| 1521 |
2/2✓ Branch 0 taken 293234 times.
✓ Branch 1 taken 146617 times.
|
439851 | for (int i = 0; i < 2; i++) { |
| 1522 | 293234 | mv[i] = ff_vvc_abs_mvd_greater0_flag(lc); | |
| 1523 | } | ||
| 1524 | |||
| 1525 |
2/2✓ Branch 0 taken 293234 times.
✓ Branch 1 taken 146617 times.
|
439851 | for (int i = 0; i < 2; i++) { |
| 1526 |
2/2✓ Branch 0 taken 191380 times.
✓ Branch 1 taken 101854 times.
|
293234 | if (mv[i]) |
| 1527 | 191380 | mv[i] += ff_vvc_abs_mvd_greater1_flag(lc); | |
| 1528 | } | ||
| 1529 | |||
| 1530 |
2/2✓ Branch 0 taken 293234 times.
✓ Branch 1 taken 146617 times.
|
439851 | for (int i = 0; i < 2; i++) { |
| 1531 |
2/2✓ Branch 0 taken 191380 times.
✓ Branch 1 taken 101854 times.
|
293234 | if (mv[i] > 0) { |
| 1532 |
2/2✓ Branch 0 taken 134361 times.
✓ Branch 1 taken 57019 times.
|
191380 | if (mv[i] == 2) |
| 1533 | 134361 | mv[i] += ff_vvc_abs_mvd_minus2(lc); | |
| 1534 | 191380 | mv[i] = (1 - 2 * ff_vvc_mvd_sign_flag(lc)) * mv[i]; | |
| 1535 | } | ||
| 1536 | } | ||
| 1537 | 146617 | mvd->x = mv[0]; | |
| 1538 | 146617 | mvd->y = mv[1]; | |
| 1539 | 146617 | } | |
| 1540 | |||
| 1541 | 80637 | static int bcw_idx_decode(VVCLocalContext *lc, const MotionInfo *mi, const int cb_width, const int cb_height) | |
| 1542 | { | ||
| 1543 | 80637 | const VVCFrameContext *fc = lc->fc; | |
| 1544 | 80637 | const VVCSPS *sps = fc->ps.sps; | |
| 1545 | 80637 | const VVCPPS *pps = fc->ps.pps; | |
| 1546 | 80637 | const VVCPH *ph = &fc->ps.ph; | |
| 1547 | 80637 | const VVCSH *sh = &lc->sc->sh; | |
| 1548 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80637 times.
|
80637 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &ph->pwt : &sh->pwt; |
| 1549 | 80637 | int bcw_idx = 0; | |
| 1550 | |||
| 1551 |
4/4✓ Branch 0 taken 76906 times.
✓ Branch 1 taken 3731 times.
✓ Branch 2 taken 20933 times.
✓ Branch 3 taken 55973 times.
|
80637 | if (sps->r->sps_bcw_enabled_flag && mi->pred_flag == PF_BI && |
| 1552 |
2/2✓ Branch 0 taken 19581 times.
✓ Branch 1 taken 1352 times.
|
20933 | !w->weight_flag[L0][LUMA][mi->ref_idx[0]] && |
| 1553 |
2/2✓ Branch 0 taken 18935 times.
✓ Branch 1 taken 646 times.
|
19581 | !w->weight_flag[L1][LUMA][mi->ref_idx[1]] && |
| 1554 |
2/2✓ Branch 0 taken 18511 times.
✓ Branch 1 taken 424 times.
|
18935 | !w->weight_flag[L0][CHROMA][mi->ref_idx[0]] && |
| 1555 |
2/2✓ Branch 0 taken 18349 times.
✓ Branch 1 taken 162 times.
|
18511 | !w->weight_flag[L1][CHROMA][mi->ref_idx[1]] && |
| 1556 |
2/2✓ Branch 0 taken 12147 times.
✓ Branch 1 taken 6202 times.
|
18349 | cb_width * cb_height >= 256) { |
| 1557 | 12147 | bcw_idx = ff_vvc_bcw_idx(lc, ff_vvc_no_backward_pred_flag(lc)); | |
| 1558 | } | ||
| 1559 | 80637 | return bcw_idx; | |
| 1560 | } | ||
| 1561 | |||
| 1562 | 102406 | static int8_t ref_idx_decode(VVCLocalContext *lc, const VVCSH *sh, const int sym_mvd_flag, const int lx) | |
| 1563 | { | ||
| 1564 | 102406 | const H266RawSliceHeader *rsh = sh->r; | |
| 1565 | 102406 | int ref_idx = 0; | |
| 1566 | |||
| 1567 |
4/4✓ Branch 0 taken 84743 times.
✓ Branch 1 taken 17663 times.
✓ Branch 2 taken 71767 times.
✓ Branch 3 taken 12976 times.
|
102406 | if (rsh->num_ref_idx_active[lx] > 1 && !sym_mvd_flag) |
| 1568 | 71767 | ref_idx = ff_vvc_ref_idx_lx(lc, rsh->num_ref_idx_active[lx]); | |
| 1569 |
2/2✓ Branch 0 taken 12976 times.
✓ Branch 1 taken 17663 times.
|
30639 | else if (sym_mvd_flag) |
| 1570 | 12976 | ref_idx = sh->ref_idx_sym[lx]; | |
| 1571 | 102406 | return ref_idx; | |
| 1572 | } | ||
| 1573 | |||
| 1574 | 102406 | static int mvds_decode(VVCLocalContext *lc, Mv mvds[2][MAX_CONTROL_POINTS], | |
| 1575 | const int num_cp_mv, const int lx) | ||
| 1576 | { | ||
| 1577 | 102406 | const VVCFrameContext *fc = lc->fc; | |
| 1578 | 102406 | const VVCPH *ph = &fc->ps.ph; | |
| 1579 | 102406 | const PredictionUnit *pu = &lc->cu->pu; | |
| 1580 | 102406 | const MotionInfo *mi = &pu->mi; | |
| 1581 | 102406 | int has_no_zero_mvd = 0; | |
| 1582 | |||
| 1583 |
6/6✓ Branch 0 taken 35441 times.
✓ Branch 1 taken 66965 times.
✓ Branch 2 taken 5040 times.
✓ Branch 3 taken 30401 times.
✓ Branch 4 taken 5026 times.
✓ Branch 5 taken 14 times.
|
102406 | if (lx == L1 && ph->r->ph_mvd_l1_zero_flag && mi->pred_flag == PF_BI) { |
| 1584 |
2/2✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 5026 times.
|
11426 | for (int j = 0; j < num_cp_mv; j++) |
| 1585 | 6400 | AV_ZERO64(&mvds[lx][j]); | |
| 1586 | } else { | ||
| 1587 | 97380 | Mv *mvd0 = &mvds[lx][0]; | |
| 1588 |
4/4✓ Branch 0 taken 30415 times.
✓ Branch 1 taken 66965 times.
✓ Branch 2 taken 6488 times.
✓ Branch 3 taken 23927 times.
|
97380 | if (lx == L1 && pu->sym_mvd_flag) { |
| 1589 | 6488 | mvd0->x = -mvds[L0][0].x; | |
| 1590 | 6488 | mvd0->y = -mvds[L0][0].y; | |
| 1591 | } else { | ||
| 1592 | 90892 | hls_mvd_coding(lc, mvd0); | |
| 1593 | } | ||
| 1594 |
4/4✓ Branch 0 taken 24133 times.
✓ Branch 1 taken 73247 times.
✓ Branch 2 taken 15186 times.
✓ Branch 3 taken 8947 times.
|
97380 | has_no_zero_mvd |= (mvd0->x || mvd0->y); |
| 1595 |
2/2✓ Branch 0 taken 16675 times.
✓ Branch 1 taken 97380 times.
|
114055 | for (int j = 1; j < num_cp_mv; j++) { |
| 1596 | 16675 | Mv *mvd = &mvds[lx][j]; | |
| 1597 | 16675 | hls_mvd_coding(lc, mvd); | |
| 1598 | 16675 | mvd->x += mvd0->x; | |
| 1599 | 16675 | mvd->y += mvd0->y; | |
| 1600 |
4/4✓ Branch 0 taken 3077 times.
✓ Branch 1 taken 13598 times.
✓ Branch 2 taken 2044 times.
✓ Branch 3 taken 1033 times.
|
16675 | has_no_zero_mvd |= (mvd->x || mvd->y); |
| 1601 | } | ||
| 1602 | } | ||
| 1603 | 102406 | return has_no_zero_mvd; | |
| 1604 | } | ||
| 1605 | |||
| 1606 | 80637 | static void mvp_add_difference(MotionInfo *mi, const int num_cp_mv, | |
| 1607 | const Mv mvds[2][MAX_CONTROL_POINTS], const int amvr_shift) | ||
| 1608 | { | ||
| 1609 |
2/2✓ Branch 0 taken 161274 times.
✓ Branch 1 taken 80637 times.
|
241911 | for (int i = 0; i < 2; i++) { |
| 1610 | 161274 | const PredFlag mask = i + PF_L0; | |
| 1611 |
2/2✓ Branch 0 taken 102406 times.
✓ Branch 1 taken 58868 times.
|
161274 | if (mi->pred_flag & mask) { |
| 1612 |
2/2✓ Branch 0 taken 120455 times.
✓ Branch 1 taken 102406 times.
|
222861 | for (int j = 0; j < num_cp_mv; j++) { |
| 1613 | 120455 | const Mv *mvd = &mvds[i][j]; | |
| 1614 | 120455 | mi->mv[i][j].x += mvd->x * (1 << amvr_shift); | |
| 1615 | 120455 | mi->mv[i][j].y += mvd->y * (1 << amvr_shift); | |
| 1616 | } | ||
| 1617 | } | ||
| 1618 | } | ||
| 1619 | 80637 | } | |
| 1620 | |||
| 1621 | 39050 | static int mvp_data_ibc(VVCLocalContext *lc) | |
| 1622 | { | ||
| 1623 | 39050 | const VVCFrameContext *fc = lc->fc; | |
| 1624 | 39050 | const CodingUnit *cu = lc->cu; | |
| 1625 | 39050 | const PredictionUnit *pu = &lc->cu->pu; | |
| 1626 | 39050 | const VVCSPS *sps = fc->ps.sps; | |
| 1627 | 39050 | MotionInfo *mi = &lc->cu->pu.mi; | |
| 1628 | 39050 | int mvp_l0_flag = 0; | |
| 1629 | 39050 | int amvr_shift = 4; | |
| 1630 | 39050 | Mv *mv = &mi->mv[L0][0]; | |
| 1631 | int ret; | ||
| 1632 | |||
| 1633 | 39050 | mi->pred_flag = PF_IBC; | |
| 1634 | 39050 | mi->num_sb_x = 1; | |
| 1635 | 39050 | mi->num_sb_y = 1; | |
| 1636 | |||
| 1637 | 39050 | hls_mvd_coding(lc, mv); | |
| 1638 |
2/2✓ Branch 0 taken 37708 times.
✓ Branch 1 taken 1342 times.
|
39050 | if (sps->max_num_ibc_merge_cand > 1) |
| 1639 | 37708 | mvp_l0_flag = ff_vvc_mvp_lx_flag(lc); | |
| 1640 |
5/6✓ Branch 0 taken 39050 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19377 times.
✓ Branch 3 taken 19673 times.
✓ Branch 4 taken 4502 times.
✓ Branch 5 taken 14875 times.
|
39050 | if (sps->r->sps_amvr_enabled_flag && (mv->x || mv->y)) |
| 1641 | 24175 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, 1); | |
| 1642 | |||
| 1643 | 39050 | ret = ff_vvc_mvp_ibc(lc, mvp_l0_flag, amvr_shift, mv); | |
| 1644 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 39050 times.
|
39050 | if (ret) |
| 1645 | ✗ | return ret; | |
| 1646 | 39050 | ff_vvc_store_mv(lc, mi); | |
| 1647 | |||
| 1648 | 39050 | return 0; | |
| 1649 | } | ||
| 1650 | |||
| 1651 | 80637 | static int mvp_data(VVCLocalContext *lc) | |
| 1652 | { | ||
| 1653 | 80637 | const VVCFrameContext *fc = lc->fc; | |
| 1654 | 80637 | const CodingUnit *cu = lc->cu; | |
| 1655 | 80637 | PredictionUnit *pu = &lc->cu->pu; | |
| 1656 | 80637 | const VVCSPS *sps = fc->ps.sps; | |
| 1657 | 80637 | const VVCPH *ph = &fc->ps.ph; | |
| 1658 | 80637 | const VVCSH *sh = &lc->sc->sh; | |
| 1659 | 80637 | const H266RawSliceHeader *rsh = sh->r; | |
| 1660 | 80637 | MotionInfo *mi = &pu->mi; | |
| 1661 | 80637 | const int cb_width = cu->cb_width; | |
| 1662 | 80637 | const int cb_height = cu->cb_height; | |
| 1663 | |||
| 1664 | 80637 | int mvp_lx_flag[2] = {0}; | |
| 1665 | 80637 | int cu_affine_type_flag = 0; | |
| 1666 | int num_cp_mv; | ||
| 1667 | 80637 | int amvr_enabled, has_no_zero_mvd = 0, amvr_shift; | |
| 1668 | Mv mvds[2][MAX_CONTROL_POINTS]; | ||
| 1669 | |||
| 1670 | 80637 | mi->pred_flag = ff_vvc_pred_flag(lc, IS_B(rsh)); | |
| 1671 |
5/6✓ Branch 0 taken 80637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43846 times.
✓ Branch 3 taken 36791 times.
✓ Branch 4 taken 30284 times.
✓ Branch 5 taken 13562 times.
|
80637 | if (sps->r->sps_affine_enabled_flag && cb_width >= 16 && cb_height >= 16) { |
| 1672 | 30284 | pu->inter_affine_flag = ff_vvc_inter_affine_flag(lc); | |
| 1673 | 30284 | set_cb_tab(lc, fc->tab.iaf, pu->inter_affine_flag); | |
| 1674 |
4/4✓ Branch 0 taken 27938 times.
✓ Branch 1 taken 2346 times.
✓ Branch 2 taken 9332 times.
✓ Branch 3 taken 18606 times.
|
30284 | if (sps->r->sps_6param_affine_enabled_flag && pu->inter_affine_flag) |
| 1675 | 9332 | cu_affine_type_flag = ff_vvc_cu_affine_type_flag(lc); | |
| 1676 | } | ||
| 1677 | 80637 | mi->motion_model_idc = pu->inter_affine_flag + cu_affine_type_flag; | |
| 1678 | 80637 | num_cp_mv = mi->motion_model_idc + 1; | |
| 1679 | |||
| 1680 |
4/4✓ Branch 0 taken 68668 times.
✓ Branch 1 taken 11969 times.
✓ Branch 2 taken 57514 times.
✓ Branch 3 taken 11154 times.
|
80637 | if (sps->r->sps_smvd_enabled_flag && !ph->r->ph_mvd_l1_zero_flag && |
| 1681 |
4/4✓ Branch 0 taken 16147 times.
✓ Branch 1 taken 41367 times.
✓ Branch 2 taken 14750 times.
✓ Branch 3 taken 1397 times.
|
57514 | mi->pred_flag == PF_BI && !pu->inter_affine_flag && |
| 1682 |
4/4✓ Branch 0 taken 13652 times.
✓ Branch 1 taken 1098 times.
✓ Branch 2 taken 12921 times.
✓ Branch 3 taken 731 times.
|
14750 | sh->ref_idx_sym[0] > -1 && sh->ref_idx_sym[1] > -1) |
| 1683 | 12921 | pu->sym_mvd_flag = ff_vvc_sym_mvd_flag(lc); | |
| 1684 | |||
| 1685 |
2/2✓ Branch 0 taken 161274 times.
✓ Branch 1 taken 80637 times.
|
241911 | for (int i = L0; i <= L1; i++) { |
| 1686 |
2/2✓ Branch 0 taken 80637 times.
✓ Branch 1 taken 80637 times.
|
161274 | const PredFlag pred_flag = PF_L0 + !i; |
| 1687 |
2/2✓ Branch 0 taken 102406 times.
✓ Branch 1 taken 58868 times.
|
161274 | if (mi->pred_flag != pred_flag) { |
| 1688 | 102406 | mi->ref_idx[i] = ref_idx_decode(lc, sh, pu->sym_mvd_flag, i); | |
| 1689 | 102406 | has_no_zero_mvd |= mvds_decode(lc, mvds, num_cp_mv, i); | |
| 1690 | 102406 | mvp_lx_flag[i] = ff_vvc_mvp_lx_flag(lc); | |
| 1691 | } | ||
| 1692 | } | ||
| 1693 | |||
| 1694 | 161274 | amvr_enabled = mi->motion_model_idc == MOTION_TRANSLATION ? | |
| 1695 |
2/2✓ Branch 0 taken 70461 times.
✓ Branch 1 taken 10176 times.
|
80637 | sps->r->sps_amvr_enabled_flag : sps->r->sps_affine_amvr_enabled_flag; |
| 1696 | 80637 | amvr_enabled &= has_no_zero_mvd; | |
| 1697 | |||
| 1698 | 80637 | amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag, cu->pred_mode, amvr_enabled); | |
| 1699 | |||
| 1700 | 80637 | mi->hpel_if_idx = amvr_shift == 3; | |
| 1701 | 80637 | mi->bcw_idx = bcw_idx_decode(lc, mi, cb_width, cb_height); | |
| 1702 | |||
| 1703 |
2/2✓ Branch 0 taken 10176 times.
✓ Branch 1 taken 70461 times.
|
80637 | if (mi->motion_model_idc) |
| 1704 | 10176 | ff_vvc_affine_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
| 1705 | else | ||
| 1706 | 70461 | ff_vvc_mvp(lc, mvp_lx_flag, amvr_shift, mi); | |
| 1707 | |||
| 1708 | 80637 | mvp_add_difference(mi, num_cp_mv, mvds, amvr_shift); | |
| 1709 | |||
| 1710 |
2/2✓ Branch 0 taken 10176 times.
✓ Branch 1 taken 70461 times.
|
80637 | if (mi->motion_model_idc) |
| 1711 | 10176 | ff_vvc_store_sb_mvs(lc, pu); | |
| 1712 | else | ||
| 1713 | 70461 | ff_vvc_store_mv(lc, &pu->mi); | |
| 1714 | |||
| 1715 | 80637 | return 0; | |
| 1716 | } | ||
| 1717 | |||
| 1718 | // derive bdofFlag from 8.5.6 Decoding process for inter blocks | ||
| 1719 | // derive dmvr from 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
| 1720 | 368052 | static void derive_dmvr_bdof_flag(const VVCLocalContext *lc, PredictionUnit *pu) | |
| 1721 | { | ||
| 1722 | 368052 | const VVCFrameContext *fc = lc->fc; | |
| 1723 | 368052 | const VVCPPS *pps = fc->ps.pps; | |
| 1724 | 368052 | const VVCPH *ph = &fc->ps.ph; | |
| 1725 | 368052 | const VVCSH *sh = &lc->sc->sh; | |
| 1726 | 368052 | const int poc = ph->poc; | |
| 1727 | 368052 | const MotionInfo *mi = &pu->mi; | |
| 1728 | 368052 | const int8_t *ref_idx = mi->ref_idx; | |
| 1729 | 368052 | const VVCRefPic *rp0 = &lc->sc->rpl[L0].refs[ref_idx[L0]]; | |
| 1730 | 368052 | const VVCRefPic *rp1 = &lc->sc->rpl[L1].refs[ref_idx[L1]]; | |
| 1731 | 368052 | const CodingUnit *cu = lc->cu; | |
| 1732 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 368052 times.
|
368052 | const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt; |
| 1733 | |||
| 1734 | 368052 | pu->bdof_flag = 0; | |
| 1735 | |||
| 1736 |
2/2✓ Branch 0 taken 186444 times.
✓ Branch 1 taken 181608 times.
|
368052 | if (mi->pred_flag == PF_BI && |
| 1737 |
2/2✓ Branch 0 taken 124944 times.
✓ Branch 1 taken 61500 times.
|
186444 | (poc - rp0->poc == rp1->poc - poc) && |
| 1738 |
4/4✓ Branch 0 taken 124886 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 124853 times.
✓ Branch 3 taken 33 times.
|
124944 | !rp0->is_lt && !rp1->is_lt && |
| 1739 |
2/2✓ Branch 0 taken 122021 times.
✓ Branch 1 taken 2832 times.
|
124853 | !cu->ciip_flag && |
| 1740 |
2/2✓ Branch 0 taken 107514 times.
✓ Branch 1 taken 14507 times.
|
122021 | !mi->bcw_idx && |
| 1741 |
4/4✓ Branch 0 taken 106400 times.
✓ Branch 1 taken 1114 times.
✓ Branch 2 taken 106399 times.
✓ Branch 3 taken 1 times.
|
107514 | !w->weight_flag[L0][LUMA][ref_idx[L0]] && !w->weight_flag[L1][LUMA][ref_idx[L1]] && |
| 1742 |
4/4✓ Branch 0 taken 106381 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 106366 times.
✓ Branch 3 taken 15 times.
|
106399 | !w->weight_flag[L0][CHROMA][ref_idx[L0]] && !w->weight_flag[L1][CHROMA][ref_idx[L1]] && |
| 1743 |
4/4✓ Branch 0 taken 100441 times.
✓ Branch 1 taken 5925 times.
✓ Branch 2 taken 96512 times.
✓ Branch 3 taken 3929 times.
|
106366 | cu->cb_width >= 8 && cu->cb_height >= 8 && |
| 1744 |
2/2✓ Branch 0 taken 90547 times.
✓ Branch 1 taken 5965 times.
|
96512 | (cu->cb_width * cu->cb_height >= 128) && |
| 1745 |
2/4✓ Branch 0 taken 90547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90547 times.
✗ Branch 3 not taken.
|
90547 | !rp0->is_scaled && !rp1->is_scaled) { |
| 1746 |
2/2✓ Branch 0 taken 88518 times.
✓ Branch 1 taken 2029 times.
|
90547 | if (!ph->r->ph_bdof_disabled_flag && |
| 1747 |
1/2✓ Branch 0 taken 88518 times.
✗ Branch 1 not taken.
|
88518 | mi->motion_model_idc == MOTION_TRANSLATION && |
| 1748 |
1/2✓ Branch 0 taken 88518 times.
✗ Branch 1 not taken.
|
88518 | !pu->merge_subblock_flag && |
| 1749 |
2/2✓ Branch 0 taken 85573 times.
✓ Branch 1 taken 2945 times.
|
88518 | !pu->sym_mvd_flag) |
| 1750 | 85573 | pu->bdof_flag = 1; | |
| 1751 |
2/2✓ Branch 0 taken 86061 times.
✓ Branch 1 taken 4486 times.
|
90547 | if (!ph->r->ph_dmvr_disabled_flag && |
| 1752 |
2/2✓ Branch 0 taken 80493 times.
✓ Branch 1 taken 5568 times.
|
86061 | pu->general_merge_flag && |
| 1753 |
2/2✓ Branch 0 taken 73298 times.
✓ Branch 1 taken 7195 times.
|
80493 | !pu->mmvd_merge_flag) |
| 1754 | 73298 | pu->dmvr_flag = 1; | |
| 1755 | } | ||
| 1756 | 368052 | } | |
| 1757 | |||
| 1758 | // part of 8.5.1 General decoding process for coding units coded in inter prediction mode | ||
| 1759 | 368052 | static void refine_regular_subblock(const VVCLocalContext *lc) | |
| 1760 | { | ||
| 1761 | 368052 | const CodingUnit *cu = lc->cu; | |
| 1762 | 368052 | PredictionUnit *pu = &lc->cu->pu; | |
| 1763 | |||
| 1764 | 368052 | derive_dmvr_bdof_flag(lc, pu); | |
| 1765 |
4/4✓ Branch 0 taken 294754 times.
✓ Branch 1 taken 73298 times.
✓ Branch 2 taken 12275 times.
✓ Branch 3 taken 282479 times.
|
368052 | if (pu->dmvr_flag || pu->bdof_flag) { |
| 1766 |
2/2✓ Branch 0 taken 51939 times.
✓ Branch 1 taken 33634 times.
|
85573 | pu->mi.num_sb_x = (cu->cb_width > 16) ? (cu->cb_width >> 4) : 1; |
| 1767 |
2/2✓ Branch 0 taken 48935 times.
✓ Branch 1 taken 36638 times.
|
85573 | pu->mi.num_sb_y = (cu->cb_height > 16) ? (cu->cb_height >> 4) : 1; |
| 1768 | } | ||
| 1769 | 368052 | } | |
| 1770 | |||
| 1771 | 454484 | static void fill_dmvr_info(const VVCLocalContext *lc) | |
| 1772 | { | ||
| 1773 | 454484 | const VVCFrameContext *fc = lc->fc; | |
| 1774 | 454484 | const CodingUnit *cu = lc->cu; | |
| 1775 | |||
| 1776 |
3/4✓ Branch 0 taken 387244 times.
✓ Branch 1 taken 67240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387244 times.
|
454484 | if (cu->pred_mode == MODE_IBC || cu->pred_mode == MODE_PLT) { |
| 1777 |
1/2✓ Branch 0 taken 67240 times.
✗ Branch 1 not taken.
|
67240 | ff_vvc_set_intra_mvf(lc, true, cu->pred_mode == MODE_IBC ? PF_IBC : PF_PLT, false); |
| 1778 | } else { | ||
| 1779 | 387244 | const VVCPPS *pps = fc->ps.pps; | |
| 1780 | 387244 | const int w = cu->cb_width >> MIN_PU_LOG2; | |
| 1781 | |||
| 1782 |
2/2✓ Branch 0 taken 2219748 times.
✓ Branch 1 taken 387244 times.
|
2606992 | for (int y = cu->y0 >> MIN_PU_LOG2; y < (cu->y0 + cu->cb_height) >> MIN_PU_LOG2; y++) { |
| 1783 | 2219748 | const int idx = pps->min_pu_width * y + (cu->x0 >> MIN_PU_LOG2); | |
| 1784 | 2219748 | const MvField *mvf = fc->tab.mvf + idx; | |
| 1785 | 2219748 | MvField *dmvr_mvf = fc->ref->tab_dmvr_mvf + idx; | |
| 1786 | |||
| 1787 | 2219748 | memcpy(dmvr_mvf, mvf, sizeof(MvField) * w); | |
| 1788 | } | ||
| 1789 | } | ||
| 1790 | 454484 | } | |
| 1791 | |||
| 1792 | 527782 | static int inter_data(VVCLocalContext *lc) | |
| 1793 | { | ||
| 1794 | 527782 | const CodingUnit *cu = lc->cu; | |
| 1795 | 527782 | PredictionUnit *pu = &lc->cu->pu; | |
| 1796 | 527782 | const MotionInfo *mi = &pu->mi; | |
| 1797 | 527782 | int ret = 0; | |
| 1798 | |||
| 1799 | 527782 | pu->general_merge_flag = 1; | |
| 1800 |
2/2✓ Branch 0 taken 245148 times.
✓ Branch 1 taken 282634 times.
|
527782 | if (!cu->skip_flag) |
| 1801 | 245148 | pu->general_merge_flag = ff_vvc_general_merge_flag(lc); | |
| 1802 | |||
| 1803 |
2/2✓ Branch 0 taken 408095 times.
✓ Branch 1 taken 119687 times.
|
527782 | if (pu->general_merge_flag) { |
| 1804 | 408095 | ret = hls_merge_data(lc); | |
| 1805 |
2/2✓ Branch 0 taken 39050 times.
✓ Branch 1 taken 80637 times.
|
119687 | } else if (cu->pred_mode == MODE_IBC) { |
| 1806 | 39050 | ret = mvp_data_ibc(lc); | |
| 1807 | } else { | ||
| 1808 | 80637 | ret = mvp_data(lc); | |
| 1809 | } | ||
| 1810 | |||
| 1811 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 527782 times.
|
527782 | if (ret) |
| 1812 | ✗ | return ret; | |
| 1813 | |||
| 1814 |
2/2✓ Branch 0 taken 67240 times.
✓ Branch 1 taken 460542 times.
|
527782 | if (cu->pred_mode == MODE_IBC) { |
| 1815 | 67240 | ff_vvc_update_hmvp(lc, mi); | |
| 1816 |
6/6✓ Branch 0 taken 432948 times.
✓ Branch 1 taken 27594 times.
✓ Branch 2 taken 396970 times.
✓ Branch 3 taken 35978 times.
✓ Branch 4 taken 368052 times.
✓ Branch 5 taken 28918 times.
|
460542 | } else if (!pu->merge_gpm_flag && !pu->inter_affine_flag && !pu->merge_subblock_flag) { |
| 1817 | 368052 | refine_regular_subblock(lc); | |
| 1818 | 368052 | ff_vvc_update_hmvp(lc, mi); | |
| 1819 | } | ||
| 1820 | |||
| 1821 |
2/2✓ Branch 0 taken 454484 times.
✓ Branch 1 taken 73298 times.
|
527782 | if (!pu->dmvr_flag) |
| 1822 | 454484 | fill_dmvr_info(lc); | |
| 1823 | 527782 | return ret; | |
| 1824 | } | ||
| 1825 | |||
| 1826 | 4497 | static TransformUnit* palette_add_tu(VVCLocalContext *lc, const int start, const int end, const VVCTreeType tree_type) | |
| 1827 | { | ||
| 1828 | 4497 | CodingUnit *cu = lc->cu; | |
| 1829 | 4497 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 1830 | 4497 | TransformUnit *tu = add_tu(lc->fc, cu, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
| 1831 | |||
| 1832 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4497 times.
|
4497 | if (!tu) |
| 1833 | ✗ | return NULL; | |
| 1834 | |||
| 1835 |
2/2✓ Branch 0 taken 12587 times.
✓ Branch 1 taken 4497 times.
|
17084 | for (int c = start; c < end; c++) { |
| 1836 | 12587 | const int w = tu->width >> sps->hshift[c]; | |
| 1837 | 12587 | const int h = tu->height >> sps->vshift[c]; | |
| 1838 | 12587 | TransformBlock *tb = add_tb(tu, lc, tu->x0, tu->y0, w, h, c); | |
| 1839 |
2/2✓ Branch 0 taken 8542 times.
✓ Branch 1 taken 4045 times.
|
12587 | if (c != CR) |
| 1840 | 8542 | set_tb_size(lc->fc, tb); | |
| 1841 | } | ||
| 1842 | |||
| 1843 |
2/2✓ Branch 0 taken 13491 times.
✓ Branch 1 taken 4497 times.
|
17988 | for (int i = 0; i < FF_ARRAY_ELEMS(cu->plt); i++) |
| 1844 | 13491 | cu->plt[i].size = 0; | |
| 1845 | |||
| 1846 | 4497 | return tu; | |
| 1847 | } | ||
| 1848 | |||
| 1849 | 4497 | static int palette_predicted(VVCLocalContext *lc, const bool local_dual_tree, int start, int end, | |
| 1850 | bool *predictor_reused, const int predictor_size, const int max_entries) | ||
| 1851 | { | ||
| 1852 | 4497 | CodingUnit *cu = lc->cu; | |
| 1853 | 4497 | int nb_predicted = 0; | |
| 1854 | |||
| 1855 |
2/2✓ Branch 0 taken 452 times.
✓ Branch 1 taken 4045 times.
|
4497 | if (local_dual_tree) { |
| 1856 | 452 | start = LUMA; | |
| 1857 | 452 | end = VVC_MAX_SAMPLE_ARRAYS; | |
| 1858 | } | ||
| 1859 | |||
| 1860 |
3/4✓ Branch 0 taken 28514 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 28514 times.
✗ Branch 3 not taken.
|
28625 | for (int i = 0; i < predictor_size && nb_predicted < max_entries; i++) { |
| 1861 | 28514 | const int run = ff_vvc_palette_predictor_run(lc, predictor_size - i); | |
| 1862 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 28514 times.
|
28514 | if (run < 0) |
| 1863 | ✗ | return run; | |
| 1864 | |||
| 1865 |
2/2✓ Branch 0 taken 4386 times.
✓ Branch 1 taken 24128 times.
|
28514 | if (run == 1) |
| 1866 | 4386 | break; | |
| 1867 | |||
| 1868 |
2/2✓ Branch 0 taken 10864 times.
✓ Branch 1 taken 13264 times.
|
24128 | if (run > 1) |
| 1869 | 10864 | i += run - 1; | |
| 1870 | |||
| 1871 | 24128 | predictor_reused[i] = true; | |
| 1872 |
2/2✓ Branch 0 taken 72384 times.
✓ Branch 1 taken 24128 times.
|
96512 | for (int c = start; c < end; c++) |
| 1873 | 72384 | cu->plt[c].entries[nb_predicted] = lc->ep->pp[c].entries[i]; | |
| 1874 | 24128 | nb_predicted++; | |
| 1875 | } | ||
| 1876 | |||
| 1877 |
2/2✓ Branch 0 taken 13491 times.
✓ Branch 1 taken 4497 times.
|
17988 | for (int c = start; c < end; c++) |
| 1878 | 13491 | cu->plt[c].size = nb_predicted; | |
| 1879 | |||
| 1880 | 4497 | return 0; | |
| 1881 | } | ||
| 1882 | |||
| 1883 | 4497 | static int palette_signaled(VVCLocalContext *lc, const bool local_dual_tree, | |
| 1884 | const int start, const int end, const int max_entries) | ||
| 1885 | { | ||
| 1886 | 4497 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 1887 | 4497 | CodingUnit *cu = lc->cu; | |
| 1888 | 4497 | const int nb_predicted = cu->plt[start].size; | |
| 1889 |
1/2✓ Branch 0 taken 4497 times.
✗ Branch 1 not taken.
|
4497 | const int nb_signaled = nb_predicted < max_entries ? ff_vvc_num_signalled_palette_entries(lc, max_entries - nb_predicted) : 0; |
| 1890 | 4497 | const int size = nb_predicted + nb_signaled; | |
| 1891 |
3/4✓ Branch 0 taken 452 times.
✓ Branch 1 taken 4045 times.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
|
4497 | const bool dual_tree_luma = local_dual_tree && cu->tree_type == DUAL_TREE_LUMA; |
| 1892 | |||
| 1893 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4497 times.
|
4497 | if (nb_signaled < 0) |
| 1894 | ✗ | return AVERROR_INVALIDDATA; | |
| 1895 | |||
| 1896 |
2/2✓ Branch 0 taken 12587 times.
✓ Branch 1 taken 4497 times.
|
17084 | for (int c = start; c < end; c++) { |
| 1897 | 12587 | Palette *plt = cu->plt + c; | |
| 1898 |
2/2✓ Branch 0 taken 3654 times.
✓ Branch 1 taken 12587 times.
|
16241 | for (int i = nb_predicted; i < size; i++) { |
| 1899 | 3654 | plt->entries[i] = ff_vvc_new_palette_entries(lc, sps->bit_depth); | |
| 1900 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 3612 times.
|
3654 | if (dual_tree_luma) { |
| 1901 | 42 | plt[CB].entries[i] = 1 << (sps->bit_depth - 1); | |
| 1902 | 42 | plt[CR].entries[i] = 1 << (sps->bit_depth - 1); | |
| 1903 | } | ||
| 1904 | } | ||
| 1905 | 12587 | plt->size = size; | |
| 1906 | } | ||
| 1907 | |||
| 1908 | 4497 | return 0; | |
| 1909 | } | ||
| 1910 | |||
| 1911 | 4497 | static void palette_update_predictor(VVCLocalContext *lc, const bool local_dual_tree, int start, int end, | |
| 1912 | bool *predictor_reused, const int predictor_size) | ||
| 1913 | { | ||
| 1914 | 4497 | CodingUnit *cu = lc->cu; | |
| 1915 |
3/4✓ Branch 0 taken 452 times.
✓ Branch 1 taken 4045 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
|
4497 | const int max_predictor = VVC_MAX_NUM_PALETTE_PREDICTOR_SIZE >> (cu->tree_type != SINGLE_TREE && !local_dual_tree); |
| 1916 | |||
| 1917 |
2/2✓ Branch 0 taken 452 times.
✓ Branch 1 taken 4045 times.
|
4497 | if (local_dual_tree) { |
| 1918 | 452 | start = LUMA; | |
| 1919 | 452 | end = VVC_MAX_SAMPLE_ARRAYS; | |
| 1920 | } | ||
| 1921 | |||
| 1922 |
2/2✓ Branch 0 taken 13491 times.
✓ Branch 1 taken 4497 times.
|
17988 | for (int c = start; c < end; c++) { |
| 1923 | 13491 | Palette *pp = lc->ep->pp + c; | |
| 1924 | 13491 | Palette *plt = cu->plt + c; | |
| 1925 | 13491 | int i = cu->plt[start].size;; | |
| 1926 | |||
| 1927 | // copy unused predictors to the end of plt | ||
| 1928 |
4/4✓ Branch 0 taken 733860 times.
✓ Branch 1 taken 12354 times.
✓ Branch 2 taken 732723 times.
✓ Branch 3 taken 1137 times.
|
746214 | for (int j = 0; j < predictor_size && i < max_predictor; j++) { |
| 1929 |
2/2✓ Branch 0 taken 660684 times.
✓ Branch 1 taken 72039 times.
|
732723 | if (!predictor_reused[j]) { |
| 1930 | 660684 | plt->entries[i] = pp->entries[j]; | |
| 1931 | 660684 | i++; | |
| 1932 | } | ||
| 1933 | } | ||
| 1934 | |||
| 1935 | 13491 | memcpy(pp->entries, plt->entries, i * sizeof(pp->entries[0])); | |
| 1936 | 13491 | pp->size = i; | |
| 1937 | } | ||
| 1938 | 4497 | } | |
| 1939 | |||
| 1940 | 4497 | static void palette_qp(VVCLocalContext *lc, VVCTreeType tree_type, const bool escape_present) | |
| 1941 | { | ||
| 1942 | 4497 | const VVCFrameContext *fc = lc->fc; | |
| 1943 | 4497 | const VVCPPS *pps = fc->ps.pps; | |
| 1944 | 4497 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 1945 | 4497 | const CodingUnit *cu = lc->cu; | |
| 1946 | |||
| 1947 |
1/2✓ Branch 0 taken 4497 times.
✗ Branch 1 not taken.
|
4497 | if (tree_type != DUAL_TREE_CHROMA) { |
| 1948 | 4540 | const bool has_qp_delta = escape_present && | |
| 1949 |
3/6✓ Branch 0 taken 43 times.
✓ Branch 1 taken 4454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4497 | pps->r->pps_cu_qp_delta_enabled_flag && !lc->parse.is_cu_qp_delta_coded; |
| 1950 | 4497 | set_qp_y(lc, cu->x0, cu->y0, has_qp_delta); | |
| 1951 | } | ||
| 1952 | |||
| 1953 |
2/2✓ Branch 0 taken 4045 times.
✓ Branch 1 taken 452 times.
|
4497 | if (tree_type != DUAL_TREE_LUMA) { |
| 1954 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4045 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && !lc->parse.is_cu_chroma_qp_offset_coded) |
| 1955 | ✗ | chroma_qp_offset_decode(lc, 0, 1); | |
| 1956 | 4045 | set_qp_c(lc); | |
| 1957 | } | ||
| 1958 | 4497 | } | |
| 1959 | |||
| 1960 | #define PALETTE_SET_PIXEL(xc, yc, pix) \ | ||
| 1961 | do { \ | ||
| 1962 | const int off = ((xc) >> hs) + ((yc) >> vs) * tb->tb_width; \ | ||
| 1963 | if (sps->bit_depth == 8) \ | ||
| 1964 | u8[off] = pix; \ | ||
| 1965 | else \ | ||
| 1966 | u16[off] = pix; \ | ||
| 1967 | } while (0) | ||
| 1968 | |||
| 1969 | #define PALETTE_INDEX(x, y) index[(y) * width + (x)] | ||
| 1970 | |||
| 1971 | // 6.5.3 Horizontal and vertical traverse scan order array initialization process | ||
| 1972 | // The hTravScan and vTravScan tables require approximately 576 KB of memory. | ||
| 1973 | // To save space, we use a macro to achieve the same functionality. | ||
| 1974 | #define TRAV_COL(p, wlog, mask) ((p & mask) ^ (-((p >> wlog) & 1) & mask)) | ||
| 1975 | #define TRAV_ROW(p, hlog) (p >> hlog) | ||
| 1976 | #define TRAV(trans, p, wlog, hlog, mask) (trans ? TRAV_ROW((p), hlog) : TRAV_COL((p), wlog, mask)) | ||
| 1977 | #define TRAV_X(pos) TRAV(transpose, pos, wlog2, hlog2, wmask) | ||
| 1978 | #define TRAV_Y(pos) TRAV(!transpose, pos, hlog2, wlog2, hmask) | ||
| 1979 | |||
| 1980 | 60236 | static int palette_subblock_data(VVCLocalContext *lc, | |
| 1981 | const int max_index, const int subset_id, const bool transpose, | ||
| 1982 | uint8_t *run_type, uint8_t *index, int *prev_run_pos, bool *adjust) | ||
| 1983 | { | ||
| 1984 | 60236 | const CodingUnit *cu = lc->cu; | |
| 1985 | 60236 | TransformUnit *tu = cu->tus.head; | |
| 1986 | 60236 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 1987 | 60236 | const int width = tu->tbs[0].tb_width; | |
| 1988 | 60236 | const int height = tu->tbs[0].tb_height; | |
| 1989 | 60236 | const int min_pos = subset_id << 4; | |
| 1990 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60236 times.
|
60236 | const int max_pos = FFMIN(min_pos + 16, width * height); |
| 1991 | 60236 | const int wmask = width - 1; | |
| 1992 | 60236 | const int hmask = height - 1; | |
| 1993 | 60236 | const int wlog2 = av_log2(width); | |
| 1994 | 60236 | const int hlog2 = av_log2(height); | |
| 1995 | 60236 | const int start_idx = tu->tbs[0].c_idx; | |
| 1996 | 60236 | const uint8_t esc = cu->plt[tu->tbs[0].c_idx].size; | |
| 1997 | 60236 | uint8_t run_copy[16] = { 0 }; | |
| 1998 | |||
| 1999 |
2/2✓ Branch 0 taken 963776 times.
✓ Branch 1 taken 60236 times.
|
1024012 | for (int i = min_pos; i < max_pos; i++) { |
| 2000 |
2/2✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 853888 times.
|
963776 | const int xc = TRAV_X(i); |
| 2001 |
2/2✓ Branch 0 taken 853888 times.
✓ Branch 1 taken 109888 times.
|
963776 | const int yc = TRAV_Y(i); |
| 2002 | |||
| 2003 |
4/4✓ Branch 0 taken 959279 times.
✓ Branch 1 taken 4497 times.
✓ Branch 2 taken 608210 times.
✓ Branch 3 taken 351069 times.
|
963776 | if (i > 0 && max_index > 0) |
| 2004 | 608210 | run_copy[i - min_pos] = ff_vvc_run_copy_flag(lc, run_type[i - 1], *prev_run_pos, i); | |
| 2005 | |||
| 2006 | 963776 | run_type[i] = 0; | |
| 2007 |
4/4✓ Branch 0 taken 612256 times.
✓ Branch 1 taken 351520 times.
✓ Branch 2 taken 97230 times.
✓ Branch 3 taken 515026 times.
|
963776 | if (max_index > 0 && !run_copy[i - min_pos]) { |
| 2008 |
8/8✓ Branch 0 taken 79104 times.
✓ Branch 1 taken 18126 times.
✓ Branch 2 taken 12936 times.
✓ Branch 3 taken 66168 times.
✓ Branch 4 taken 18126 times.
✓ Branch 5 taken 12936 times.
✓ Branch 6 taken 14450 times.
✓ Branch 7 taken 3676 times.
|
97230 | if (((!transpose && yc > 0) || (transpose && xc > 0)) |
| 2009 |
3/4✓ Branch 0 taken 80618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68722 times.
✓ Branch 3 taken 11896 times.
|
80618 | && i > 0 && !run_type[i - 1]) { |
| 2010 | 68722 | run_type[i] = ff_vvc_copy_above_palette_indices_flag(lc); | |
| 2011 | } | ||
| 2012 | 97230 | *prev_run_pos = i; | |
| 2013 |
2/2✓ Branch 0 taken 866095 times.
✓ Branch 1 taken 451 times.
|
866546 | } else if (i > 0) { |
| 2014 | 866095 | run_type[i] = run_type[i - 1]; | |
| 2015 | } | ||
| 2016 | } | ||
| 2017 | |||
| 2018 |
2/2✓ Branch 0 taken 963776 times.
✓ Branch 1 taken 60236 times.
|
1024012 | for (int i = min_pos; i < max_pos; i++) { |
| 2019 |
2/2✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 853888 times.
|
963776 | const int xc = TRAV_X(i); |
| 2020 |
2/2✓ Branch 0 taken 853888 times.
✓ Branch 1 taken 109888 times.
|
963776 | const int yc = TRAV_Y(i); |
| 2021 |
4/4✓ Branch 0 taken 959279 times.
✓ Branch 1 taken 4497 times.
✓ Branch 2 taken 108832 times.
✓ Branch 3 taken 850447 times.
|
963776 | const int prev_xc = i > 0 ? TRAV_X(i - 1) : 0; |
| 2022 |
4/4✓ Branch 0 taken 959279 times.
✓ Branch 1 taken 4497 times.
✓ Branch 2 taken 850447 times.
✓ Branch 3 taken 108832 times.
|
963776 | const int prev_yc = i > 0 ? TRAV_Y(i - 1) : 0; |
| 2023 | |||
| 2024 | 963776 | int idx = 0; | |
| 2025 |
6/6✓ Branch 0 taken 612256 times.
✓ Branch 1 taken 351520 times.
✓ Branch 2 taken 97230 times.
✓ Branch 3 taken 515026 times.
✓ Branch 4 taken 83845 times.
✓ Branch 5 taken 13385 times.
|
963776 | if (max_index > 0 && !run_copy[i - min_pos] && !run_type[i]) { |
| 2026 |
2/2✓ Branch 0 taken 74987 times.
✓ Branch 1 taken 8858 times.
|
83845 | if (max_index - *adjust > 0) |
| 2027 | 74987 | idx = ff_vvc_palette_idx_idc(lc, max_index, *adjust); | |
| 2028 |
2/2✓ Branch 0 taken 79799 times.
✓ Branch 1 taken 4046 times.
|
83845 | if (i > 0) { |
| 2029 | 159598 | const int ref_idx = !run_type[i - 1] ? | |
| 2030 |
2/2✓ Branch 0 taken 67903 times.
✓ Branch 1 taken 11896 times.
|
79799 | PALETTE_INDEX(prev_xc, prev_yc) : PALETTE_INDEX(xc - transpose, yc - !transpose); |
| 2031 | 79799 | idx += (idx >= ref_idx); | |
| 2032 | } | ||
| 2033 | 83845 | *adjust = true; | |
| 2034 | } else { | ||
| 2035 | 879931 | idx = PALETTE_INDEX(prev_xc, prev_yc); | |
| 2036 | } | ||
| 2037 | |||
| 2038 |
2/2✓ Branch 0 taken 738229 times.
✓ Branch 1 taken 225547 times.
|
963776 | if (!run_type[i]) |
| 2039 | 738229 | PALETTE_INDEX(xc, yc) = idx; | |
| 2040 | else | ||
| 2041 | 225547 | PALETTE_INDEX(xc, yc) = PALETTE_INDEX(xc - transpose, yc - !transpose); | |
| 2042 | } | ||
| 2043 | |||
| 2044 |
2/2✓ Branch 0 taken 177356 times.
✓ Branch 1 taken 60236 times.
|
237592 | for (int c = 0; c < tu->nb_tbs; c++) { |
| 2045 | 177356 | TransformBlock *tb = &tu->tbs[c]; | |
| 2046 | 177356 | const int c_idx = tb->c_idx; | |
| 2047 | 177356 | const Palette *plt = &cu->plt[c_idx]; | |
| 2048 | 177356 | const int scale = ff_vvc_palette_derive_scale(lc, tu, tb); | |
| 2049 | 177356 | const int hs = sps->hshift[c_idx] - sps->hshift[start_idx]; | |
| 2050 | 177356 | const int vs = sps->vshift[c_idx] - sps->vshift[start_idx]; | |
| 2051 | 177356 | uint8_t *u8 = (uint8_t *)tb->coeffs; | |
| 2052 | 177356 | uint16_t *u16 = (uint16_t *)tb->coeffs; | |
| 2053 | |||
| 2054 |
2/2✓ Branch 0 taken 2837696 times.
✓ Branch 1 taken 177356 times.
|
3015052 | for (int i = min_pos; i < max_pos; i++) { |
| 2055 |
2/2✓ Branch 0 taken 309440 times.
✓ Branch 1 taken 2528256 times.
|
2837696 | const int xc = TRAV_X(i); |
| 2056 |
2/2✓ Branch 0 taken 2528256 times.
✓ Branch 1 taken 309440 times.
|
2837696 | const int yc = TRAV_Y(i); |
| 2057 |
3/4✓ Branch 0 taken 2444864 times.
✓ Branch 1 taken 392832 times.
✓ Branch 2 taken 2444864 times.
✗ Branch 3 not taken.
|
2837696 | if (!(xc & hs) && !(yc & vs)) { |
| 2058 | 2444864 | const int v = PALETTE_INDEX(xc, yc); | |
| 2059 |
2/2✓ Branch 0 taken 145 times.
✓ Branch 1 taken 2444719 times.
|
2444864 | if (v == esc) { |
| 2060 | 145 | const int coeff = ff_vvc_palette_escape_val(lc, (1 << sps->bit_depth) - 1); | |
| 2061 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
|
145 | if (coeff < 0) |
| 2062 | ✗ | return AVERROR_INVALIDDATA; | |
| 2063 |
2/2✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
|
145 | const int pixel = av_clip_intp2(RSHIFT(coeff * scale, 6), sps->bit_depth); |
| 2064 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
|
145 | PALETTE_SET_PIXEL(xc, yc, pixel); |
| 2065 | } else { | ||
| 2066 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2444719 times.
|
2444719 | PALETTE_SET_PIXEL(xc, yc, plt->entries[v]); |
| 2067 | } | ||
| 2068 | } | ||
| 2069 | } | ||
| 2070 | } | ||
| 2071 | |||
| 2072 | 60236 | return 0; | |
| 2073 | } | ||
| 2074 | |||
| 2075 | 4497 | static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type) | |
| 2076 | { | ||
| 2077 | 4497 | const VVCFrameContext *fc = lc->fc; | |
| 2078 | 4497 | const VVCSPS *sps = fc->ps.sps; | |
| 2079 | 4497 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 2080 | 4497 | CodingUnit *cu = lc->cu; | |
| 2081 | 4497 | Palette *pp = lc->ep->pp; | |
| 2082 |
2/2✓ Branch 0 taken 4045 times.
✓ Branch 1 taken 452 times.
|
4497 | const int max_entries = tree_type == SINGLE_TREE ? 31 : 15; |
| 2083 |
2/2✓ Branch 0 taken 452 times.
✓ Branch 1 taken 4045 times.
|
4949 | const bool local_dual_tree = tree_type != SINGLE_TREE && |
| 2084 |
3/6✓ Branch 0 taken 452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 452 times.
✗ Branch 5 not taken.
|
452 | (!IS_I(rsh) || (IS_I(rsh) && !sps->r->sps_qtbtt_dual_tree_intra_flag)); |
| 2085 | 4497 | bool escape_present = false; | |
| 2086 | 4497 | bool transpose = false; | |
| 2087 | 4497 | bool adjust = false; | |
| 2088 | 4497 | int max_index = 0; | |
| 2089 | 4497 | int prev_run_pos = 0; | |
| 2090 | |||
| 2091 | int predictor_size, start, end, ret; | ||
| 2092 | bool reused[VVC_MAX_NUM_PALETTE_PREDICTOR_SIZE]; | ||
| 2093 | uint8_t run_type[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE]; | ||
| 2094 | uint8_t index[MAX_PALETTE_CU_SIZE * MAX_PALETTE_CU_SIZE]; | ||
| 2095 | |||
| 2096 | TransformUnit *tu; | ||
| 2097 | |||
| 2098 | 4497 | ff_vvc_channel_range(&start, &end, tree_type, sps->r->sps_chroma_format_idc); | |
| 2099 | |||
| 2100 | 4497 | tu = palette_add_tu(lc, start, end, tree_type); | |
| 2101 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4497 times.
|
4497 | if (!tu) |
| 2102 | ✗ | return AVERROR(ENOMEM); | |
| 2103 | |||
| 2104 | 4497 | predictor_size = pp[start].size; | |
| 2105 | 4497 | memset(reused, 0, sizeof(reused[0]) * predictor_size); | |
| 2106 | |||
| 2107 | 4497 | ret = palette_predicted(lc, local_dual_tree, start, end, reused, predictor_size, max_entries); | |
| 2108 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4497 times.
|
4497 | if (ret < 0) |
| 2109 | ✗ | return ret; | |
| 2110 | |||
| 2111 | 4497 | ret = palette_signaled(lc, local_dual_tree, start, end, max_entries); | |
| 2112 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4497 times.
|
4497 | if (ret < 0) |
| 2113 | ✗ | return ret; | |
| 2114 | |||
| 2115 | 4497 | palette_update_predictor(lc, local_dual_tree, start, end, reused, predictor_size); | |
| 2116 | |||
| 2117 |
1/2✓ Branch 0 taken 4497 times.
✗ Branch 1 not taken.
|
4497 | if (cu->plt[start].size > 0) |
| 2118 | 4497 | escape_present = ff_vvc_palette_escape_val_present_flag(lc); | |
| 2119 | |||
| 2120 | 4497 | max_index = cu->plt[start].size - 1 + escape_present; | |
| 2121 |
2/2✓ Branch 0 taken 4046 times.
✓ Branch 1 taken 451 times.
|
4497 | if (max_index > 0) { |
| 2122 | 4046 | adjust = false; | |
| 2123 | 4046 | transpose = ff_vvc_palette_transpose_flag(lc); | |
| 2124 | } | ||
| 2125 | |||
| 2126 | 4497 | palette_qp(lc, tree_type, escape_present); | |
| 2127 | |||
| 2128 | 4497 | index[0] = 0; | |
| 2129 |
2/2✓ Branch 0 taken 60236 times.
✓ Branch 1 taken 4497 times.
|
64733 | for (int i = 0; i <= (tu->tbs[0].tb_width * tu->tbs[0].tb_height - 1) >> 4; i++) { |
| 2130 | 60236 | ret = palette_subblock_data(lc, max_index, i, transpose, | |
| 2131 | run_type, index, &prev_run_pos, &adjust); | ||
| 2132 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60236 times.
|
60236 | if (ret < 0) |
| 2133 | ✗ | return ret; | |
| 2134 | } | ||
| 2135 | |||
| 2136 | 4497 | return 0; | |
| 2137 | } | ||
| 2138 | |||
| 2139 | 816827 | static int intra_data(VVCLocalContext *lc) | |
| 2140 | { | ||
| 2141 | 816827 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 2142 | 816827 | const CodingUnit *cu = lc->cu; | |
| 2143 | 816827 | const VVCTreeType tree_type = cu->tree_type; | |
| 2144 | 816827 | const bool pred_mode_plt_flag = cu->pred_mode == MODE_PLT; | |
| 2145 | 816827 | int ret = 0; | |
| 2146 | |||
| 2147 |
4/4✓ Branch 0 taken 734942 times.
✓ Branch 1 taken 81885 times.
✓ Branch 2 taken 547634 times.
✓ Branch 3 taken 187308 times.
|
816827 | if (tree_type == SINGLE_TREE || tree_type == DUAL_TREE_LUMA) { |
| 2148 |
2/2✓ Branch 0 taken 4497 times.
✓ Branch 1 taken 625022 times.
|
629519 | if (pred_mode_plt_flag) { |
| 2149 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4497 times.
|
4497 | if ((ret = hls_palette_coding(lc, tree_type)) < 0) |
| 2150 | ✗ | return ret; | |
| 2151 | 4497 | ff_vvc_set_intra_mvf(lc, false, PF_PLT, false); | |
| 2152 | } else { | ||
| 2153 | 625022 | intra_luma_pred_modes(lc); | |
| 2154 | 625022 | ff_vvc_set_intra_mvf(lc, false, PF_INTRA, cu->ciip_flag); | |
| 2155 | } | ||
| 2156 | } | ||
| 2157 |
6/6✓ Branch 0 taken 734942 times.
✓ Branch 1 taken 81885 times.
✓ Branch 2 taken 187308 times.
✓ Branch 3 taken 547634 times.
✓ Branch 4 taken 254071 times.
✓ Branch 5 taken 15122 times.
|
816827 | if ((tree_type == SINGLE_TREE || tree_type == DUAL_TREE_CHROMA) && sps->r->sps_chroma_format_idc) { |
| 2158 |
3/4✓ Branch 0 taken 4045 times.
✓ Branch 1 taken 250026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4045 times.
|
254071 | if (pred_mode_plt_flag && tree_type == DUAL_TREE_CHROMA) { |
| 2159 | ✗ | if ((ret = hls_palette_coding(lc, tree_type)) < 0) | |
| 2160 | ✗ | return ret; | |
| 2161 |
2/2✓ Branch 0 taken 250026 times.
✓ Branch 1 taken 4045 times.
|
254071 | } else if (!pred_mode_plt_flag) { |
| 2162 | 250026 | intra_chroma_pred_modes(lc); | |
| 2163 | } | ||
| 2164 | } | ||
| 2165 | |||
| 2166 | 816827 | return ret; | |
| 2167 | } | ||
| 2168 | |||
| 2169 | 1344609 | static int hls_coding_unit(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, | |
| 2170 | int cqt_depth, const VVCTreeType tree_type, VVCModeType mode_type) | ||
| 2171 | { | ||
| 2172 | 1344609 | const VVCFrameContext *fc = lc->fc; | |
| 2173 | 1344609 | const VVCSPS *sps = fc->ps.sps; | |
| 2174 | 1344609 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 2175 |
4/4✓ Branch 0 taken 1318206 times.
✓ Branch 1 taken 26403 times.
✓ Branch 2 taken 2342 times.
✓ Branch 3 taken 1315864 times.
|
1344609 | const int is_128 = cb_width > 64 || cb_height > 64; |
| 2176 | 1344609 | int ret = 0; | |
| 2177 | |||
| 2178 | 1344609 | CodingUnit *cu = add_cu(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type); | |
| 2179 | |||
| 2180 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1344609 times.
|
1344609 | if (!cu) |
| 2181 | ✗ | return AVERROR(ENOMEM); | |
| 2182 | |||
| 2183 | 1344609 | ff_vvc_set_neighbour_available(lc, cu->x0, cu->y0, cu->cb_width, cu->cb_height); | |
| 2184 | |||
| 2185 |
3/4✓ Branch 0 taken 717365 times.
✓ Branch 1 taken 627244 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 717365 times.
|
1344609 | if (IS_I(rsh) && is_128) |
| 2186 | ✗ | mode_type = MODE_TYPE_INTRA; | |
| 2187 | 1344609 | cu->pred_mode = pred_mode_decode(lc, tree_type, mode_type); | |
| 2188 | |||
| 2189 |
5/6✓ Branch 0 taken 812330 times.
✓ Branch 1 taken 532279 times.
✓ Branch 2 taken 8309 times.
✓ Branch 3 taken 804021 times.
✓ Branch 4 taken 8309 times.
✗ Branch 5 not taken.
|
1344609 | if (cu->pred_mode == MODE_INTRA && sps->r->sps_act_enabled_flag && tree_type == SINGLE_TREE) |
| 2190 | 8309 | cu->act_enabled_flag = ff_vvc_cu_act_enabled_flag(lc); | |
| 2191 | |||
| 2192 |
4/4✓ Branch 0 taken 532279 times.
✓ Branch 1 taken 812330 times.
✓ Branch 2 taken 4497 times.
✓ Branch 3 taken 527782 times.
|
1344609 | if (cu->pred_mode == MODE_INTRA || cu->pred_mode == MODE_PLT) |
| 2193 | 816827 | ret = intra_data(lc); | |
| 2194 |
1/2✓ Branch 0 taken 527782 times.
✗ Branch 1 not taken.
|
527782 | else if (tree_type != DUAL_TREE_CHROMA) /* MODE_INTER or MODE_IBC */ |
| 2195 | 527782 | ret = inter_data(lc); | |
| 2196 | |||
| 2197 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1344609 times.
|
1344609 | if (ret < 0) |
| 2198 | ✗ | return ret; | |
| 2199 | |||
| 2200 |
6/6✓ Branch 0 taken 532279 times.
✓ Branch 1 taken 812330 times.
✓ Branch 2 taken 527782 times.
✓ Branch 3 taken 4497 times.
✓ Branch 4 taken 119687 times.
✓ Branch 5 taken 408095 times.
|
1344609 | if (cu->pred_mode != MODE_INTRA && cu->pred_mode != MODE_PLT && !lc->cu->pu.general_merge_flag) |
| 2201 | 119687 | cu->coded_flag = ff_vvc_cu_coded_flag(lc); | |
| 2202 | else | ||
| 2203 |
4/4✓ Branch 0 taken 942288 times.
✓ Branch 1 taken 282634 times.
✓ Branch 2 taken 937791 times.
✓ Branch 3 taken 4497 times.
|
1224922 | cu->coded_flag = !(cu->skip_flag || cu->pred_mode == MODE_PLT); |
| 2204 | |||
| 2205 |
2/2✓ Branch 0 taken 990262 times.
✓ Branch 1 taken 354347 times.
|
1344609 | if (cu->coded_flag) { |
| 2206 | 990262 | sbt_info(lc, sps); | |
| 2207 |
5/6✓ Branch 0 taken 15652 times.
✓ Branch 1 taken 974610 times.
✓ Branch 2 taken 7343 times.
✓ Branch 3 taken 8309 times.
✓ Branch 4 taken 7343 times.
✗ Branch 5 not taken.
|
990262 | if (sps->r->sps_act_enabled_flag && cu->pred_mode != MODE_INTRA && tree_type == SINGLE_TREE) |
| 2208 | 7343 | cu->act_enabled_flag = ff_vvc_cu_act_enabled_flag(lc); | |
| 2209 | 990262 | lc->parse.lfnst_dc_only = 1; | |
| 2210 | 990262 | lc->parse.lfnst_zero_out_sig_coeff_flag = 1; | |
| 2211 | 990262 | lc->parse.mts_dc_only = 1; | |
| 2212 | 990262 | lc->parse.mts_zero_out_sig_coeff_flag = 1; | |
| 2213 | 990262 | ret = hls_transform_tree(lc, x0, y0, cb_width, cb_height, cu->ch_type); | |
| 2214 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 990262 times.
|
990262 | if (ret < 0) |
| 2215 | ✗ | return ret; | |
| 2216 | 990262 | cu->lfnst_idx = lfnst_idx_decode(lc); | |
| 2217 | 990262 | cu->mts_idx = mts_idx_decode(lc); | |
| 2218 | 990262 | set_qp_c(lc); | |
| 2219 |
2/2✓ Branch 0 taken 349850 times.
✓ Branch 1 taken 4497 times.
|
354347 | } else if (cu->pred_mode != MODE_PLT) { |
| 2220 | 349850 | ret = skipped_transform_tree_unit(lc); | |
| 2221 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 349850 times.
|
349850 | if (ret < 0) |
| 2222 | ✗ | return ret; | |
| 2223 | } | ||
| 2224 | 1344609 | set_cu_tabs(lc, cu); | |
| 2225 | |||
| 2226 | 1344609 | return 0; | |
| 2227 | } | ||
| 2228 | |||
| 2229 | 867557 | static int derive_mode_type_condition(const VVCLocalContext *lc, | |
| 2230 | const VVCSplitMode split, const int cb_width, const int cb_height, const VVCModeType mode_type_curr) | ||
| 2231 | { | ||
| 2232 | 867557 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 2233 | 867557 | const VVCSPS *sps = lc->fc->ps.sps; | |
| 2234 | 867557 | const int area = cb_width * cb_height; | |
| 2235 | |||
| 2236 |
6/6✓ Branch 0 taken 477744 times.
✓ Branch 1 taken 389813 times.
✓ Branch 2 taken 46579 times.
✓ Branch 3 taken 431165 times.
✓ Branch 4 taken 400761 times.
✓ Branch 5 taken 35631 times.
|
867557 | if ((IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) || |
| 2237 |
2/2✓ Branch 0 taken 376582 times.
✓ Branch 1 taken 24179 times.
|
400761 | mode_type_curr != MODE_TYPE_ALL || !sps->r->sps_chroma_format_idc || |
| 2238 |
2/2✓ Branch 0 taken 65766 times.
✓ Branch 1 taken 310816 times.
|
376582 | sps->r->sps_chroma_format_idc == CHROMA_FORMAT_444) |
| 2239 | 556741 | return 0; | |
| 2240 |
9/10✓ Branch 0 taken 24363 times.
✓ Branch 1 taken 286453 times.
✓ Branch 2 taken 22080 times.
✓ Branch 3 taken 2283 times.
✓ Branch 4 taken 22080 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18861 times.
✓ Branch 7 taken 3219 times.
✓ Branch 8 taken 550 times.
✓ Branch 9 taken 304764 times.
|
310816 | if ((area == 64 && (split == SPLIT_QT || split == SPLIT_TT_HOR || split == SPLIT_TT_VER)) || |
| 2241 |
2/4✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
✗ Branch 3 not taken.
|
550 | (area == 32 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER))) |
| 2242 | 6052 | return 1; | |
| 2243 |
9/10✓ Branch 0 taken 18861 times.
✓ Branch 1 taken 285903 times.
✓ Branch 2 taken 12221 times.
✓ Branch 3 taken 6640 times.
✓ Branch 4 taken 12221 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2953 times.
✓ Branch 7 taken 15908 times.
✓ Branch 8 taken 36702 times.
✓ Branch 9 taken 252154 times.
|
304764 | if ((area == 64 && (split == SPLIT_BT_HOR || split == SPLIT_BT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
| 2244 |
8/8✓ Branch 0 taken 32470 times.
✓ Branch 1 taken 4232 times.
✓ Branch 2 taken 6517 times.
✓ Branch 3 taken 25953 times.
✓ Branch 4 taken 1786 times.
✓ Branch 5 taken 8963 times.
✓ Branch 6 taken 27236 times.
✓ Branch 7 taken 252657 times.
|
288856 | (area == 128 && (split == SPLIT_TT_HOR || split == SPLIT_TT_VER) && sps->r->sps_chroma_format_idc == CHROMA_FORMAT_420) || |
| 2245 |
6/6✓ Branch 0 taken 17579 times.
✓ Branch 1 taken 9657 times.
✓ Branch 2 taken 82093 times.
✓ Branch 3 taken 188143 times.
✓ Branch 4 taken 11687 times.
✓ Branch 5 taken 70406 times.
|
279893 | (cb_width == 8 && split == SPLIT_BT_VER) || (cb_width == 16 && split == SPLIT_TT_VER)) |
| 2246 |
2/2✓ Branch 0 taken 42486 times.
✓ Branch 1 taken 3729 times.
|
46215 | return 1 + !IS_I(rsh); |
| 2247 | |||
| 2248 | 258549 | return 0; | |
| 2249 | } | ||
| 2250 | |||
| 2251 | 867557 | static VVCModeType mode_type_decode(VVCLocalContext *lc, const int x0, const int y0, | |
| 2252 | const int cb_width, const int cb_height, const VVCSplitMode split, const int ch_type, | ||
| 2253 | const VVCModeType mode_type_curr) | ||
| 2254 | { | ||
| 2255 | VVCModeType mode_type; | ||
| 2256 | 867557 | const int mode_type_condition = derive_mode_type_condition(lc, split, cb_width, cb_height, mode_type_curr); | |
| 2257 | |||
| 2258 |
2/2✓ Branch 0 taken 9781 times.
✓ Branch 1 taken 857776 times.
|
867557 | if (mode_type_condition == 1) |
| 2259 | 9781 | mode_type = MODE_TYPE_INTRA; | |
| 2260 |
2/2✓ Branch 0 taken 42486 times.
✓ Branch 1 taken 815290 times.
|
857776 | else if (mode_type_condition == 2) { |
| 2261 |
2/2✓ Branch 1 taken 19353 times.
✓ Branch 2 taken 23133 times.
|
42486 | mode_type = ff_vvc_non_inter_flag(lc, x0, y0, ch_type) ? MODE_TYPE_INTRA : MODE_TYPE_INTER; |
| 2262 | } else { | ||
| 2263 | 815290 | mode_type = mode_type_curr; | |
| 2264 | } | ||
| 2265 | |||
| 2266 | 867557 | return mode_type; | |
| 2267 | } | ||
| 2268 | |||
| 2269 | static int hls_coding_tree(VVCLocalContext *lc, | ||
| 2270 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2271 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
| 2272 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr); | ||
| 2273 | |||
| 2274 | 258867 | static int coding_tree_btv(VVCLocalContext *lc, | |
| 2275 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2276 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
| 2277 | VVCTreeType tree_type, VVCModeType mode_type) | ||
| 2278 | { | ||
| 2279 | #define CODING_TREE(x, idx) do { \ | ||
| 2280 | ret = hls_coding_tree(lc, x, y0, cb_width / 2, cb_height, \ | ||
| 2281 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
| 2282 | depth_offset, idx, SPLIT_BT_VER, tree_type, mode_type); \ | ||
| 2283 | if (ret < 0) \ | ||
| 2284 | return ret; \ | ||
| 2285 | } while (0); | ||
| 2286 | |||
| 2287 | 258867 | const VVCPPS *pps = lc->fc->ps.pps; | |
| 2288 | 258867 | const int x1 = x0 + cb_width / 2; | |
| 2289 | 258867 | int ret = 0; | |
| 2290 | |||
| 2291 | 258867 | depth_offset += (x0 + cb_width > pps->width) ? 1 : 0; | |
| 2292 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 258867 times.
|
258867 | CODING_TREE(x0, 0); |
| 2293 |
2/2✓ Branch 0 taken 257239 times.
✓ Branch 1 taken 1628 times.
|
258867 | if (x1 < pps->width) |
| 2294 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 257239 times.
|
257239 | CODING_TREE(x1, 1); |
| 2295 | |||
| 2296 | 258867 | return 0; | |
| 2297 | |||
| 2298 | #undef CODING_TREE | ||
| 2299 | } | ||
| 2300 | |||
| 2301 | 318147 | static int coding_tree_bth(VVCLocalContext *lc, | |
| 2302 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2303 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
| 2304 | VVCTreeType tree_type, VVCModeType mode_type) | ||
| 2305 | { | ||
| 2306 | #define CODING_TREE(y, idx) do { \ | ||
| 2307 | ret = hls_coding_tree(lc, x0, y, cb_width , cb_height / 2, \ | ||
| 2308 | qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \ | ||
| 2309 | depth_offset, idx, SPLIT_BT_HOR, tree_type, mode_type); \ | ||
| 2310 | if (ret < 0) \ | ||
| 2311 | return ret; \ | ||
| 2312 | } while (0); | ||
| 2313 | |||
| 2314 | 318147 | const VVCPPS *pps = lc->fc->ps.pps; | |
| 2315 | 318147 | const int y1 = y0 + (cb_height / 2); | |
| 2316 | 318147 | int ret = 0; | |
| 2317 | |||
| 2318 | 318147 | depth_offset += (y0 + cb_height > pps->height) ? 1 : 0; | |
| 2319 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 318147 times.
|
318147 | CODING_TREE(y0, 0); |
| 2320 |
2/2✓ Branch 0 taken 296848 times.
✓ Branch 1 taken 21299 times.
|
318147 | if (y1 < pps->height) |
| 2321 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 296848 times.
|
296848 | CODING_TREE(y1, 1); |
| 2322 | |||
| 2323 | 318147 | return 0; | |
| 2324 | |||
| 2325 | #undef CODING_TREE | ||
| 2326 | } | ||
| 2327 | |||
| 2328 | 87586 | static int coding_tree_ttv(VVCLocalContext *lc, | |
| 2329 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2330 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
| 2331 | VVCTreeType tree_type, VVCModeType mode_type) | ||
| 2332 | { | ||
| 2333 | #define CODING_TREE(x, w, sub_div, idx) do { \ | ||
| 2334 | ret = hls_coding_tree(lc, x, y0, w, cb_height, \ | ||
| 2335 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
| 2336 | depth_offset, idx, SPLIT_TT_VER, tree_type, mode_type); \ | ||
| 2337 | if (ret < 0) \ | ||
| 2338 | return ret; \ | ||
| 2339 | } while (0); | ||
| 2340 | |||
| 2341 | 87586 | const VVCSH *sh = &lc->sc->sh; | |
| 2342 | 87586 | const int x1 = x0 + cb_width / 4; | |
| 2343 | 87586 | const int x2 = x0 + cb_width * 3 / 4; | |
| 2344 | int ret; | ||
| 2345 | |||
| 2346 |
3/4✓ Branch 0 taken 51647 times.
✓ Branch 1 taken 35939 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51647 times.
|
87586 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
| 2347 |
3/4✓ Branch 0 taken 37974 times.
✓ Branch 1 taken 49612 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37974 times.
|
87586 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
| 2348 | |||
| 2349 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 87586 times.
|
87586 | CODING_TREE(x0, cb_width / 4, cb_sub_div + 2, 0); |
| 2350 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 87586 times.
|
87586 | CODING_TREE(x1, cb_width / 2, cb_sub_div + 1, 1); |
| 2351 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 87586 times.
|
87586 | CODING_TREE(x2, cb_width / 4, cb_sub_div + 2, 2); |
| 2352 | |||
| 2353 | 87586 | return 0; | |
| 2354 | |||
| 2355 | #undef CODING_TREE | ||
| 2356 | } | ||
| 2357 | |||
| 2358 | 92649 | static int coding_tree_tth(VVCLocalContext *lc, | |
| 2359 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2360 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
| 2361 | VVCTreeType tree_type, VVCModeType mode_type) | ||
| 2362 | { | ||
| 2363 | #define CODING_TREE(y, h, sub_div, idx) do { \ | ||
| 2364 | ret = hls_coding_tree(lc, x0, y, cb_width, h, \ | ||
| 2365 | qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \ | ||
| 2366 | depth_offset, idx, SPLIT_TT_HOR, tree_type, mode_type); \ | ||
| 2367 | if (ret < 0) \ | ||
| 2368 | return ret; \ | ||
| 2369 | } while (0); | ||
| 2370 | |||
| 2371 | 92649 | const VVCSH *sh = &lc->sc->sh; | |
| 2372 | 92649 | const int y1 = y0 + (cb_height / 4); | |
| 2373 | 92649 | const int y2 = y0 + (3 * cb_height / 4); | |
| 2374 | int ret; | ||
| 2375 | |||
| 2376 |
3/4✓ Branch 0 taken 53832 times.
✓ Branch 1 taken 38817 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53832 times.
|
92649 | qg_on_y = qg_on_y && (cb_sub_div + 2 <= sh->cu_qp_delta_subdiv); |
| 2377 |
3/4✓ Branch 0 taken 36009 times.
✓ Branch 1 taken 56640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36009 times.
|
92649 | qg_on_c = qg_on_c && (cb_sub_div + 2 <= sh->cu_chroma_qp_offset_subdiv); |
| 2378 | |||
| 2379 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 92649 times.
|
92649 | CODING_TREE(y0, cb_height / 4, cb_sub_div + 2, 0); |
| 2380 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 92649 times.
|
92649 | CODING_TREE(y1, cb_height / 2, cb_sub_div + 1, 1); |
| 2381 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 92649 times.
|
92649 | CODING_TREE(y2, cb_height / 4, cb_sub_div + 2, 2); |
| 2382 | |||
| 2383 | 92649 | return 0; | |
| 2384 | |||
| 2385 | #undef CODING_TREE | ||
| 2386 | } | ||
| 2387 | |||
| 2388 | 110308 | static int coding_tree_qt(VVCLocalContext *lc, | |
| 2389 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2390 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
| 2391 | VVCTreeType tree_type, VVCModeType mode_type) | ||
| 2392 | { | ||
| 2393 | #define CODING_TREE(x, y, idx) do { \ | ||
| 2394 | ret = hls_coding_tree(lc, x, y, cb_width / 2, cb_height / 2, \ | ||
| 2395 | qg_on_y, qg_on_c, cb_sub_div + 2, cqt_depth + 1, 0, 0, \ | ||
| 2396 | idx, SPLIT_QT, tree_type, mode_type); \ | ||
| 2397 | if (ret < 0) \ | ||
| 2398 | return ret; \ | ||
| 2399 | } while (0); | ||
| 2400 | |||
| 2401 | 110308 | const VVCPPS *pps = lc->fc->ps.pps; | |
| 2402 | 110308 | const int x1 = x0 + cb_width / 2; | |
| 2403 | 110308 | const int y1 = y0 + cb_height / 2; | |
| 2404 | 110308 | int ret = 0; | |
| 2405 | |||
| 2406 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 110308 times.
|
110308 | CODING_TREE(x0, y0, 0); |
| 2407 |
2/2✓ Branch 0 taken 106999 times.
✓ Branch 1 taken 3309 times.
|
110308 | if (x1 < pps->width) |
| 2408 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 106999 times.
|
106999 | CODING_TREE(x1, y0, 1); |
| 2409 |
2/2✓ Branch 0 taken 104382 times.
✓ Branch 1 taken 5926 times.
|
110308 | if (y1 < pps->height) |
| 2410 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 104382 times.
|
104382 | CODING_TREE(x0, y1, 2); |
| 2411 |
2/2✓ Branch 0 taken 106999 times.
✓ Branch 1 taken 3309 times.
|
110308 | if (x1 < pps->width && |
| 2412 |
2/2✓ Branch 0 taken 101104 times.
✓ Branch 1 taken 5895 times.
|
106999 | y1 < pps->height) |
| 2413 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 101104 times.
|
101104 | CODING_TREE(x1, y1, 3); |
| 2414 | |||
| 2415 | 110308 | return 0; | |
| 2416 | |||
| 2417 | #undef CODING_TREE | ||
| 2418 | } | ||
| 2419 | |||
| 2420 | typedef int (*coding_tree_fn)(VVCLocalContext *lc, | ||
| 2421 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2422 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, | ||
| 2423 | VVCTreeType tree_type, VVCModeType mode_type); | ||
| 2424 | |||
| 2425 | const static coding_tree_fn coding_tree[] = { | ||
| 2426 | coding_tree_tth, | ||
| 2427 | coding_tree_bth, | ||
| 2428 | coding_tree_ttv, | ||
| 2429 | coding_tree_btv, | ||
| 2430 | coding_tree_qt, | ||
| 2431 | }; | ||
| 2432 | |||
| 2433 | 2212166 | static int hls_coding_tree(VVCLocalContext *lc, | |
| 2434 | int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, | ||
| 2435 | int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, | ||
| 2436 | VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr) | ||
| 2437 | { | ||
| 2438 | 2212166 | VVCFrameContext *fc = lc->fc; | |
| 2439 | 2212166 | const VVCPPS *pps = fc->ps.pps; | |
| 2440 | 2212166 | const VVCSH *sh = &lc->sc->sh; | |
| 2441 | 2212166 | const H266RawSliceHeader *rsh = sh->r; | |
| 2442 | 2212166 | const int ch_type = tree_type_curr == DUAL_TREE_CHROMA; | |
| 2443 | int ret; | ||
| 2444 | VVCAllowedSplit allowed; | ||
| 2445 | |||
| 2446 |
6/6✓ Branch 0 taken 280702 times.
✓ Branch 1 taken 1931464 times.
✓ Branch 2 taken 70213 times.
✓ Branch 3 taken 210489 times.
✓ Branch 4 taken 2635 times.
✓ Branch 5 taken 67578 times.
|
2212166 | if (pps->r->pps_cu_qp_delta_enabled_flag && qg_on_y && cb_sub_div <= sh->cu_qp_delta_subdiv) { |
| 2447 | 2635 | lc->parse.is_cu_qp_delta_coded = 0; | |
| 2448 | 2635 | lc->parse.cu_qg_top_left_x = x0; | |
| 2449 | 2635 | lc->parse.cu_qg_top_left_y = y0; | |
| 2450 | } | ||
| 2451 |
4/4✓ Branch 0 taken 206481 times.
✓ Branch 1 taken 2005685 times.
✓ Branch 2 taken 17504 times.
✓ Branch 3 taken 188977 times.
|
2212166 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && qg_on_c && |
| 2452 |
2/2✓ Branch 0 taken 931 times.
✓ Branch 1 taken 16573 times.
|
17504 | cb_sub_div <= sh->cu_chroma_qp_offset_subdiv) { |
| 2453 | 931 | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
| 2454 | 931 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
| 2455 | } | ||
| 2456 | |||
| 2457 | 2212166 | can_split(lc, x0, y0, cb_width, cb_height, mtt_depth, depth_offset, part_idx, | |
| 2458 | last_split_mode, tree_type_curr, mode_type_curr, &allowed); | ||
| 2459 |
2/2✓ Branch 1 taken 867557 times.
✓ Branch 2 taken 1344609 times.
|
2212166 | if (ff_vvc_split_cu_flag(lc, x0, y0, cb_width, cb_height, ch_type, &allowed)) { |
| 2460 | 867557 | VVCSplitMode split = ff_vvc_split_mode(lc, x0, y0, cb_width, cb_height, cqt_depth, mtt_depth, ch_type, &allowed); | |
| 2461 | 867557 | VVCModeType mode_type = mode_type_decode(lc, x0, y0, cb_width, cb_height, split, ch_type, mode_type_curr); | |
| 2462 | |||
| 2463 |
2/2✓ Branch 0 taken 808751 times.
✓ Branch 1 taken 58806 times.
|
867557 | VVCTreeType tree_type = (mode_type == MODE_TYPE_INTRA) ? DUAL_TREE_LUMA : tree_type_curr; |
| 2464 | |||
| 2465 |
2/2✓ Branch 0 taken 757249 times.
✓ Branch 1 taken 110308 times.
|
867557 | if (split != SPLIT_QT) { |
| 2466 |
6/6✓ Branch 0 taken 460539 times.
✓ Branch 1 taken 296710 times.
✓ Branch 2 taken 299372 times.
✓ Branch 3 taken 161167 times.
✓ Branch 4 taken 253290 times.
✓ Branch 5 taken 46082 times.
|
757249 | if (!(x0 & 31) && !(y0 & 31) && mtt_depth <= 1) |
| 2467 | 253290 | TAB_MSM(fc, mtt_depth, x0, y0) = split; | |
| 2468 | } | ||
| 2469 | 867557 | ret = coding_tree[split - 1](lc, x0, y0, cb_width, cb_height, qg_on_y, qg_on_c, | |
| 2470 | cb_sub_div, cqt_depth, mtt_depth, depth_offset, tree_type, mode_type); | ||
| 2471 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 867557 times.
|
867557 | if (ret < 0) |
| 2472 | ✗ | return ret; | |
| 2473 |
4/4✓ Branch 0 taken 831926 times.
✓ Branch 1 taken 35631 times.
✓ Branch 2 taken 29134 times.
✓ Branch 3 taken 802792 times.
|
867557 | if (mode_type_curr == MODE_TYPE_ALL && mode_type == MODE_TYPE_INTRA) { |
| 2474 | 29134 | ret = hls_coding_tree(lc, x0, y0, cb_width, cb_height, 0, qg_on_c, cb_sub_div, | |
| 2475 | cqt_depth, mtt_depth, 0, 0, split, DUAL_TREE_CHROMA, mode_type); | ||
| 2476 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 29134 times.
|
29134 | if (ret < 0) |
| 2477 | ✗ | return ret; | |
| 2478 | } | ||
| 2479 | } else { | ||
| 2480 | 1344609 | ret = hls_coding_unit(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type_curr, mode_type_curr); | |
| 2481 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1344609 times.
|
1344609 | if (ret < 0) |
| 2482 | ✗ | return ret; | |
| 2483 | } | ||
| 2484 | |||
| 2485 | 2212166 | return 0; | |
| 2486 | } | ||
| 2487 | |||
| 2488 | 25649 | static int dual_tree_implicit_qt_split(VVCLocalContext *lc, | |
| 2489 | const int x0, const int y0, const int cb_size, const int cqt_depth) | ||
| 2490 | { | ||
| 2491 | 25649 | const VVCSH *sh = &lc->sc->sh; | |
| 2492 | 25649 | const H266RawSliceHeader *rsh = sh->r; | |
| 2493 | 25649 | const VVCPPS *pps = lc->fc->ps.pps; | |
| 2494 | 25649 | const int cb_subdiv = 2 * cqt_depth; | |
| 2495 | int ret; | ||
| 2496 | |||
| 2497 |
2/2✓ Branch 0 taken 5308 times.
✓ Branch 1 taken 20341 times.
|
25649 | if (cb_size > 64) { |
| 2498 | #define DUAL_TREE(x, y) do { \ | ||
| 2499 | ret = dual_tree_implicit_qt_split(lc, x, y, cb_size / 2, cqt_depth + 1); \ | ||
| 2500 | if (ret < 0) \ | ||
| 2501 | return ret; \ | ||
| 2502 | } while (0) | ||
| 2503 | |||
| 2504 | 5308 | const int x1 = x0 + (cb_size / 2); | |
| 2505 | 5308 | const int y1 = y0 + (cb_size / 2); | |
| 2506 |
3/4✓ Branch 0 taken 130 times.
✓ Branch 1 taken 5178 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
|
5308 | if (pps->r->pps_cu_qp_delta_enabled_flag && cb_subdiv <= sh->cu_qp_delta_subdiv) { |
| 2507 | 130 | lc->parse.is_cu_qp_delta_coded = 0; | |
| 2508 | 130 | lc->parse.cu_qg_top_left_x = x0; | |
| 2509 | 130 | lc->parse.cu_qg_top_left_y = y0; | |
| 2510 | } | ||
| 2511 |
3/4✓ Branch 0 taken 98 times.
✓ Branch 1 taken 5210 times.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
|
5308 | if (rsh->sh_cu_chroma_qp_offset_enabled_flag && cb_subdiv <= sh->cu_chroma_qp_offset_subdiv) { |
| 2512 | 98 | lc->parse.is_cu_chroma_qp_offset_coded = 0; | |
| 2513 | 98 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
| 2514 | } | ||
| 2515 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5308 times.
|
5308 | DUAL_TREE(x0, y0); |
| 2516 |
2/2✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 163 times.
|
5308 | if (x1 < pps->width) |
| 2517 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5145 times.
|
5145 | DUAL_TREE(x1, y0); |
| 2518 |
2/2✓ Branch 0 taken 4816 times.
✓ Branch 1 taken 492 times.
|
5308 | if (y1 < pps->height) |
| 2519 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4816 times.
|
4816 | DUAL_TREE(x0, y1); |
| 2520 |
4/4✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 4656 times.
✓ Branch 3 taken 489 times.
|
5308 | if (x1 < pps->width && y1 < pps->height) |
| 2521 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4656 times.
|
4656 | DUAL_TREE(x1, y1); |
| 2522 | #undef DUAL_TREE | ||
| 2523 | } else { | ||
| 2524 | #define CODING_TREE(tree_type) do { \ | ||
| 2525 | const int qg_on_y = tree_type == DUAL_TREE_LUMA; \ | ||
| 2526 | ret = hls_coding_tree(lc, x0, y0, cb_size, cb_size, qg_on_y, !qg_on_y, \ | ||
| 2527 | cb_subdiv, cqt_depth, 0, 0, 0, SPLIT_NONE, tree_type, MODE_TYPE_ALL); \ | ||
| 2528 | if (ret < 0) \ | ||
| 2529 | return ret; \ | ||
| 2530 | } while (0) | ||
| 2531 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20341 times.
|
20341 | CODING_TREE(DUAL_TREE_LUMA); |
| 2532 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20341 times.
|
20341 | CODING_TREE(DUAL_TREE_CHROMA); |
| 2533 | #undef CODING_TREE | ||
| 2534 | } | ||
| 2535 | 25649 | return 0; | |
| 2536 | } | ||
| 2537 | |||
| 2538 | #define SET_SAO(elem, value) \ | ||
| 2539 | do { \ | ||
| 2540 | if (!sao_merge_up_flag && !sao_merge_left_flag) \ | ||
| 2541 | sao->elem = value; \ | ||
| 2542 | else if (sao_merge_left_flag) \ | ||
| 2543 | sao->elem = CTB(fc->tab.sao, rx-1, ry).elem; \ | ||
| 2544 | else if (sao_merge_up_flag) \ | ||
| 2545 | sao->elem = CTB(fc->tab.sao, rx, ry-1).elem; \ | ||
| 2546 | else \ | ||
| 2547 | sao->elem = 0; \ | ||
| 2548 | } while (0) | ||
| 2549 | |||
| 2550 | 53475 | static void hls_sao(VVCLocalContext *lc, const int rx, const int ry) | |
| 2551 | { | ||
| 2552 | 53475 | VVCFrameContext *fc = lc->fc; | |
| 2553 | 53475 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 2554 | 53475 | int sao_merge_left_flag = 0; | |
| 2555 | 53475 | int sao_merge_up_flag = 0; | |
| 2556 | 53475 | SAOParams *sao = &CTB(fc->tab.sao, rx, ry); | |
| 2557 | int c_idx, i; | ||
| 2558 | |||
| 2559 |
4/4✓ Branch 0 taken 34291 times.
✓ Branch 1 taken 19184 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 34127 times.
|
53475 | if (rsh->sh_sao_luma_used_flag || rsh->sh_sao_chroma_used_flag) { |
| 2560 |
2/2✓ Branch 0 taken 17452 times.
✓ Branch 1 taken 1896 times.
|
19348 | if (rx > 0) { |
| 2561 |
2/2✓ Branch 0 taken 16635 times.
✓ Branch 1 taken 817 times.
|
17452 | if (lc->ctb_left_flag) |
| 2562 | 16635 | sao_merge_left_flag = ff_vvc_sao_merge_flag_decode(lc); | |
| 2563 | } | ||
| 2564 |
4/4✓ Branch 0 taken 16055 times.
✓ Branch 1 taken 3293 times.
✓ Branch 2 taken 8849 times.
✓ Branch 3 taken 7206 times.
|
19348 | if (ry > 0 && !sao_merge_left_flag) { |
| 2565 |
2/2✓ Branch 0 taken 8048 times.
✓ Branch 1 taken 801 times.
|
8849 | if (lc->ctb_up_flag) |
| 2566 | 8048 | sao_merge_up_flag = ff_vvc_sao_merge_flag_decode(lc); | |
| 2567 | } | ||
| 2568 | } | ||
| 2569 | |||
| 2570 |
4/4✓ Branch 0 taken 211788 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 159369 times.
✓ Branch 3 taken 53475 times.
|
212844 | for (c_idx = 0; c_idx < (fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) { |
| 2571 |
2/2✓ Branch 0 taken 53475 times.
✓ Branch 1 taken 105894 times.
|
159369 | const int sao_used_flag = !c_idx ? rsh->sh_sao_luma_used_flag : rsh->sh_sao_chroma_used_flag; |
| 2572 |
2/2✓ Branch 0 taken 116907 times.
✓ Branch 1 taken 42462 times.
|
159369 | if (!sao_used_flag) { |
| 2573 | 116907 | sao->type_idx[c_idx] = SAO_NOT_APPLIED; | |
| 2574 | 116907 | continue; | |
| 2575 | } | ||
| 2576 | |||
| 2577 |
2/2✓ Branch 0 taken 11639 times.
✓ Branch 1 taken 30823 times.
|
42462 | if (c_idx == 2) { |
| 2578 | 11639 | sao->type_idx[2] = sao->type_idx[1]; | |
| 2579 | 11639 | sao->eo_class[2] = sao->eo_class[1]; | |
| 2580 | } else { | ||
| 2581 |
7/8✓ Branch 0 taken 27167 times.
✓ Branch 1 taken 3656 times.
✓ Branch 2 taken 14160 times.
✓ Branch 3 taken 13007 times.
✓ Branch 5 taken 13007 times.
✓ Branch 6 taken 3656 times.
✓ Branch 7 taken 3656 times.
✗ Branch 8 not taken.
|
30823 | SET_SAO(type_idx[c_idx], ff_vvc_sao_type_idx_decode(lc)); |
| 2582 | } | ||
| 2583 | |||
| 2584 |
2/2✓ Branch 0 taken 26550 times.
✓ Branch 1 taken 15912 times.
|
42462 | if (sao->type_idx[c_idx] == SAO_NOT_APPLIED) |
| 2585 | 26550 | continue; | |
| 2586 | |||
| 2587 |
2/2✓ Branch 0 taken 63648 times.
✓ Branch 1 taken 15912 times.
|
79560 | for (i = 0; i < 4; i++) |
| 2588 |
7/8✓ Branch 0 taken 54008 times.
✓ Branch 1 taken 9640 times.
✓ Branch 2 taken 24836 times.
✓ Branch 3 taken 29172 times.
✓ Branch 5 taken 29172 times.
✓ Branch 6 taken 9640 times.
✓ Branch 7 taken 9640 times.
✗ Branch 8 not taken.
|
63648 | SET_SAO(offset_abs[c_idx][i], ff_vvc_sao_offset_abs_decode(lc)); |
| 2589 | |||
| 2590 |
2/2✓ Branch 0 taken 5836 times.
✓ Branch 1 taken 10076 times.
|
15912 | if (sao->type_idx[c_idx] == SAO_BAND) { |
| 2591 |
2/2✓ Branch 0 taken 23344 times.
✓ Branch 1 taken 5836 times.
|
29180 | for (i = 0; i < 4; i++) { |
| 2592 |
2/2✓ Branch 0 taken 8291 times.
✓ Branch 1 taken 15053 times.
|
23344 | if (sao->offset_abs[c_idx][i]) { |
| 2593 |
7/8✓ Branch 0 taken 7449 times.
✓ Branch 1 taken 842 times.
✓ Branch 2 taken 3042 times.
✓ Branch 3 taken 4407 times.
✓ Branch 5 taken 4407 times.
✓ Branch 6 taken 842 times.
✓ Branch 7 taken 842 times.
✗ Branch 8 not taken.
|
8291 | SET_SAO(offset_sign[c_idx][i], |
| 2594 | ff_vvc_sao_offset_sign_decode(lc)); | ||
| 2595 | } else { | ||
| 2596 | 15053 | sao->offset_sign[c_idx][i] = 0; | |
| 2597 | } | ||
| 2598 | } | ||
| 2599 |
7/8✓ Branch 0 taken 5168 times.
✓ Branch 1 taken 668 times.
✓ Branch 2 taken 1633 times.
✓ Branch 3 taken 3535 times.
✓ Branch 5 taken 3535 times.
✓ Branch 6 taken 668 times.
✓ Branch 7 taken 668 times.
✗ Branch 8 not taken.
|
5836 | SET_SAO(band_position[c_idx], ff_vvc_sao_band_position_decode(lc)); |
| 2600 |
2/2✓ Branch 0 taken 7890 times.
✓ Branch 1 taken 2186 times.
|
10076 | } else if (c_idx != 2) { |
| 2601 |
7/8✓ Branch 0 taken 6485 times.
✓ Branch 1 taken 1405 times.
✓ Branch 2 taken 3376 times.
✓ Branch 3 taken 3109 times.
✓ Branch 5 taken 3109 times.
✓ Branch 6 taken 1405 times.
✓ Branch 7 taken 1405 times.
✗ Branch 8 not taken.
|
7890 | SET_SAO(eo_class[c_idx], ff_vvc_sao_eo_class_decode(lc)); |
| 2602 | } | ||
| 2603 | |||
| 2604 | // Inferred parameters | ||
| 2605 | 15912 | sao->offset_val[c_idx][0] = 0; | |
| 2606 |
2/2✓ Branch 0 taken 63648 times.
✓ Branch 1 taken 15912 times.
|
79560 | for (i = 0; i < 4; i++) { |
| 2607 | 63648 | sao->offset_val[c_idx][i + 1] = sao->offset_abs[c_idx][i]; | |
| 2608 |
2/2✓ Branch 0 taken 40304 times.
✓ Branch 1 taken 23344 times.
|
63648 | if (sao->type_idx[c_idx] == SAO_EDGE) { |
| 2609 |
2/2✓ Branch 0 taken 20152 times.
✓ Branch 1 taken 20152 times.
|
40304 | if (i > 1) |
| 2610 | 20152 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
| 2611 |
2/2✓ Branch 0 taken 6203 times.
✓ Branch 1 taken 17141 times.
|
23344 | } else if (sao->offset_sign[c_idx][i]) { |
| 2612 | 6203 | sao->offset_val[c_idx][i + 1] = -sao->offset_val[c_idx][i + 1]; | |
| 2613 | } | ||
| 2614 | 63648 | sao->offset_val[c_idx][i + 1] *= 1 << (fc->ps.sps->bit_depth - FFMIN(10, fc->ps.sps->bit_depth)); | |
| 2615 | } | ||
| 2616 | } | ||
| 2617 | 53475 | } | |
| 2618 | |||
| 2619 | 53475 | static void alf_params(VVCLocalContext *lc, const int rx, const int ry) | |
| 2620 | { | ||
| 2621 | 53475 | const VVCFrameContext *fc = lc->fc; | |
| 2622 | 53475 | const H266RawSliceHeader *sh = lc->sc->sh.r; | |
| 2623 | 53475 | ALFParams *alf = &CTB(fc->tab.alf, rx, ry); | |
| 2624 | |||
| 2625 | 53475 | alf->ctb_flag[LUMA] = alf->ctb_flag[CB] = alf->ctb_flag[CR] = 0; | |
| 2626 | 53475 | alf->ctb_cc_idc[0] = alf->ctb_cc_idc[1] = 0; | |
| 2627 |
2/2✓ Branch 0 taken 29433 times.
✓ Branch 1 taken 24042 times.
|
53475 | if (sh->sh_alf_enabled_flag) { |
| 2628 | 29433 | alf->ctb_flag[LUMA] = ff_vvc_alf_ctb_flag(lc, rx, ry, LUMA); | |
| 2629 |
2/2✓ Branch 0 taken 20795 times.
✓ Branch 1 taken 8638 times.
|
29433 | if (alf->ctb_flag[LUMA]) { |
| 2630 | 20795 | uint8_t alf_use_aps_flag = 0; | |
| 2631 |
2/2✓ Branch 0 taken 19987 times.
✓ Branch 1 taken 808 times.
|
20795 | if (sh->sh_num_alf_aps_ids_luma > 0) |
| 2632 | 19987 | alf_use_aps_flag = ff_vvc_alf_use_aps_flag(lc); | |
| 2633 |
2/2✓ Branch 0 taken 18004 times.
✓ Branch 1 taken 2791 times.
|
20795 | if (alf_use_aps_flag) { |
| 2634 | 18004 | alf->ctb_filt_set_idx_y = 16; | |
| 2635 |
2/2✓ Branch 0 taken 5167 times.
✓ Branch 1 taken 12837 times.
|
18004 | if (sh->sh_num_alf_aps_ids_luma > 1) |
| 2636 | 5167 | alf->ctb_filt_set_idx_y += ff_vvc_alf_luma_prev_filter_idx(lc); | |
| 2637 | } else { | ||
| 2638 | 2791 | alf->ctb_filt_set_idx_y = ff_vvc_alf_luma_fixed_filter_idx(lc); | |
| 2639 | } | ||
| 2640 | } | ||
| 2641 |
2/2✓ Branch 0 taken 58866 times.
✓ Branch 1 taken 29433 times.
|
88299 | for (int c_idx = CB; c_idx <= CR; c_idx++) { |
| 2642 |
2/2✓ Branch 0 taken 29433 times.
✓ Branch 1 taken 29433 times.
|
58866 | const uint8_t alf_enabled_flag = |
| 2643 | c_idx == CB ? sh->sh_alf_cb_enabled_flag : sh->sh_alf_cr_enabled_flag; | ||
| 2644 |
2/2✓ Branch 0 taken 35508 times.
✓ Branch 1 taken 23358 times.
|
58866 | if (alf_enabled_flag) { |
| 2645 | 35508 | const VVCALF *aps = fc->ps.alf_list[sh->sh_alf_aps_id_chroma]; | |
| 2646 | 35508 | alf->ctb_flag[c_idx] = ff_vvc_alf_ctb_flag(lc, rx, ry, c_idx); | |
| 2647 | 35508 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = 0; | |
| 2648 |
4/4✓ Branch 0 taken 26209 times.
✓ Branch 1 taken 9299 times.
✓ Branch 2 taken 17909 times.
✓ Branch 3 taken 8300 times.
|
35508 | if (alf->ctb_flag[c_idx] && aps->num_chroma_filters > 1) |
| 2649 | 17909 | alf->alf_ctb_filter_alt_idx[c_idx - 1] = ff_vvc_alf_ctb_filter_alt_idx(lc, c_idx, aps->num_chroma_filters); | |
| 2650 | } | ||
| 2651 | } | ||
| 2652 | } | ||
| 2653 |
2/2✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 10566 times.
|
53475 | if (fc->ps.sps->r->sps_ccalf_enabled_flag) { |
| 2654 | 42909 | const uint8_t cc_enabled[] = { sh->sh_alf_cc_cb_enabled_flag, sh->sh_alf_cc_cr_enabled_flag }; | |
| 2655 | 42909 | const uint8_t cc_aps_id[] = { sh->sh_alf_cc_cb_aps_id, sh->sh_alf_cc_cr_aps_id }; | |
| 2656 |
2/2✓ Branch 0 taken 85818 times.
✓ Branch 1 taken 42909 times.
|
128727 | for (int i = 0; i < 2; i++) { |
| 2657 |
2/2✓ Branch 0 taken 22625 times.
✓ Branch 1 taken 63193 times.
|
85818 | if (cc_enabled[i]) { |
| 2658 | 22625 | const VVCALF *aps = fc->ps.alf_list[cc_aps_id[i]]; | |
| 2659 | 22625 | alf->ctb_cc_idc[i] = ff_vvc_alf_ctb_cc_idc(lc, rx, ry, i, aps->num_cc_filters[i]); | |
| 2660 | } | ||
| 2661 | } | ||
| 2662 | } | ||
| 2663 | 53475 | } | |
| 2664 | |||
| 2665 | 53475 | static void deblock_params(VVCLocalContext *lc, const int rx, const int ry) | |
| 2666 | { | ||
| 2667 | 53475 | VVCFrameContext *fc = lc->fc; | |
| 2668 | 53475 | const VVCSH *sh = &lc->sc->sh; | |
| 2669 | 53475 | CTB(fc->tab.deblock, rx, ry) = sh->deblock; | |
| 2670 | 53475 | } | |
| 2671 | |||
| 2672 | 53475 | static int hls_coding_tree_unit(VVCLocalContext *lc, | |
| 2673 | const int x0, const int y0, const int ctu_idx, const int rx, const int ry) | ||
| 2674 | { | ||
| 2675 | 53475 | const VVCFrameContext *fc = lc->fc; | |
| 2676 | 53475 | const VVCSPS *sps = fc->ps.sps; | |
| 2677 | 53475 | const VVCPPS *pps = fc->ps.pps; | |
| 2678 | 53475 | const VVCSH *sh = &lc->sc->sh; | |
| 2679 | 53475 | const H266RawSliceHeader *rsh = sh->r; | |
| 2680 | 53475 | const unsigned int ctb_size = sps->ctb_size_y; | |
| 2681 | 53475 | int ret = 0; | |
| 2682 | |||
| 2683 | 53475 | memset(lc->parse.chroma_qp_offset, 0, sizeof(lc->parse.chroma_qp_offset)); | |
| 2684 | |||
| 2685 | 53475 | hls_sao(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
| 2686 | 53475 | alf_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
| 2687 | 53475 | deblock_params(lc, x0 >> sps->ctb_log2_size_y, y0 >> sps->ctb_log2_size_y); | |
| 2688 | |||
| 2689 |
4/4✓ Branch 0 taken 6370 times.
✓ Branch 1 taken 47105 times.
✓ Branch 2 taken 5724 times.
✓ Branch 3 taken 646 times.
|
53475 | if (IS_I(rsh) && sps->r->sps_qtbtt_dual_tree_intra_flag) |
| 2690 | 5724 | ret = dual_tree_implicit_qt_split(lc, x0, y0, ctb_size, 0); | |
| 2691 | else | ||
| 2692 | 47751 | ret = hls_coding_tree(lc, x0, y0, ctb_size, ctb_size, | |
| 2693 | 1, 1, 0, 0, 0, 0, 0, SPLIT_NONE, SINGLE_TREE, MODE_TYPE_ALL); | ||
| 2694 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 53475 times.
|
53475 | if (ret < 0) |
| 2695 | ✗ | return ret; | |
| 2696 | |||
| 2697 |
2/2✓ Branch 0 taken 6463 times.
✓ Branch 1 taken 47012 times.
|
53475 | if (rx == pps->ctb_to_col_bd[rx + 1] - 1) { |
| 2698 |
2/2✓ Branch 0 taken 1831 times.
✓ Branch 1 taken 4632 times.
|
6463 | if (ctu_idx == sh->num_ctus_in_curr_slice - 1) { |
| 2699 | 1831 | const int end_of_slice_one_bit = ff_vvc_end_of_slice_flag_decode(lc); | |
| 2700 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1831 times.
|
1831 | if (!end_of_slice_one_bit) |
| 2701 | ✗ | return AVERROR_INVALIDDATA; | |
| 2702 | } else { | ||
| 2703 |
2/2✓ Branch 0 taken 493 times.
✓ Branch 1 taken 4139 times.
|
4632 | if (ry == pps->ctb_to_row_bd[ry + 1] - 1) { |
| 2704 | 493 | const int end_of_tile_one_bit = ff_vvc_end_of_tile_one_bit(lc); | |
| 2705 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
|
493 | if (!end_of_tile_one_bit) |
| 2706 | ✗ | return AVERROR_INVALIDDATA; | |
| 2707 | } else { | ||
| 2708 |
2/2✓ Branch 0 taken 153 times.
✓ Branch 1 taken 3986 times.
|
4139 | if (fc->ps.sps->r->sps_entropy_coding_sync_enabled_flag) { |
| 2709 | 153 | const int end_of_subset_one_bit = ff_vvc_end_of_subset_one_bit(lc); | |
| 2710 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
|
153 | if (!end_of_subset_one_bit) |
| 2711 | ✗ | return AVERROR_INVALIDDATA; | |
| 2712 | } | ||
| 2713 | } | ||
| 2714 | } | ||
| 2715 | } | ||
| 2716 | |||
| 2717 | 53475 | return 0; | |
| 2718 | } | ||
| 2719 | |||
| 2720 | 627244 | static int has_inter_luma(const CodingUnit *cu) | |
| 2721 | { | ||
| 2722 |
5/6✓ Branch 0 taken 488388 times.
✓ Branch 1 taken 138856 times.
✓ Branch 2 taken 488172 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 488172 times.
✗ Branch 5 not taken.
|
627244 | return cu->pred_mode != MODE_INTRA && cu->pred_mode != MODE_PLT && cu->tree_type != DUAL_TREE_CHROMA; |
| 2723 | } | ||
| 2724 | |||
| 2725 | 9088207 | static int pred_get_y(const VVCLocalContext *lc, const int y0, const Mv *mv, const int height) | |
| 2726 | { | ||
| 2727 | 9088207 | const VVCPPS *pps = lc->fc->ps.pps; | |
| 2728 | 9088207 | const int idx = lc->sc->sh.r->curr_subpic_idx; | |
| 2729 | 9088207 | const int top = pps->subpic_y[idx]; | |
| 2730 | 9088207 | const int bottom = top + pps->subpic_height[idx]; | |
| 2731 | |||
| 2732 | 9088207 | return av_clip(y0 + (mv->y >> 4) + height, top, bottom); | |
| 2733 | } | ||
| 2734 | |||
| 2735 | 488172 | static void cu_get_max_y(const CodingUnit *cu, int max_y[2][VVC_MAX_REF_ENTRIES], const VVCLocalContext *lc) | |
| 2736 | { | ||
| 2737 | 488172 | const VVCFrameContext *fc = lc->fc; | |
| 2738 | 488172 | const PredictionUnit *pu = &cu->pu; | |
| 2739 | |||
| 2740 |
2/2✓ Branch 0 taken 27594 times.
✓ Branch 1 taken 460578 times.
|
488172 | if (pu->merge_gpm_flag) { |
| 2741 |
2/2✓ Branch 0 taken 55188 times.
✓ Branch 1 taken 27594 times.
|
82782 | for (int i = 0; i < FF_ARRAY_ELEMS(pu->gpm_mv); i++) { |
| 2742 | 55188 | const MvField *mvf = pu->gpm_mv + i; | |
| 2743 | 55188 | const int lx = mvf->pred_flag - PF_L0; | |
| 2744 | 55188 | const int idx = mvf->ref_idx[lx]; | |
| 2745 | 55188 | const int y = pred_get_y(lc, cu->y0, mvf->mv + lx, cu->cb_height); | |
| 2746 | |||
| 2747 | 55188 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y); | |
| 2748 | } | ||
| 2749 | } else { | ||
| 2750 | 460578 | const MotionInfo *mi = &pu->mi; | |
| 2751 |
4/4✓ Branch 0 taken 424600 times.
✓ Branch 1 taken 35978 times.
✓ Branch 2 taken 73298 times.
✓ Branch 3 taken 351302 times.
|
460578 | const int max_dmvr_off = (!pu->inter_affine_flag && pu->dmvr_flag) ? 2 : 0; |
| 2752 | 460578 | const int sbw = cu->cb_width / mi->num_sb_x; | |
| 2753 | 460578 | const int sbh = cu->cb_height / mi->num_sb_y; | |
| 2754 |
2/2✓ Branch 0 taken 972184 times.
✓ Branch 1 taken 460578 times.
|
1432762 | for (int sby = 0; sby < mi->num_sb_y; sby++) { |
| 2755 |
2/2✓ Branch 0 taken 6162268 times.
✓ Branch 1 taken 972184 times.
|
7134452 | for (int sbx = 0; sbx < mi->num_sb_x; sbx++) { |
| 2756 | 6162268 | const int x0 = cu->x0 + sbx * sbw; | |
| 2757 | 6162268 | const int y0 = cu->y0 + sby * sbh; | |
| 2758 | 6162268 | const MvField *mvf = ff_vvc_get_mvf(fc, x0, y0); | |
| 2759 |
2/2✓ Branch 0 taken 12324536 times.
✓ Branch 1 taken 6162268 times.
|
18486804 | for (int lx = 0; lx < 2; lx++) { |
| 2760 | 12324536 | const PredFlag mask = 1 << lx; | |
| 2761 |
2/2✓ Branch 0 taken 9033019 times.
✓ Branch 1 taken 3291517 times.
|
12324536 | if (mvf->pred_flag & mask) { |
| 2762 | 9033019 | const int idx = mvf->ref_idx[lx]; | |
| 2763 | 9033019 | const int y = pred_get_y(lc, y0, mvf->mv + lx, sbh); | |
| 2764 | |||
| 2765 | 9033019 | max_y[lx][idx] = FFMAX(max_y[lx][idx], y + max_dmvr_off); | |
| 2766 | } | ||
| 2767 | } | ||
| 2768 | } | ||
| 2769 | } | ||
| 2770 | } | ||
| 2771 | 488172 | } | |
| 2772 | |||
| 2773 | 53475 | static void ctu_get_pred(VVCLocalContext *lc, const int rs) | |
| 2774 | { | ||
| 2775 | 53475 | const VVCFrameContext *fc = lc->fc; | |
| 2776 | 53475 | const H266RawSliceHeader *rsh = lc->sc->sh.r; | |
| 2777 | 53475 | CTU *ctu = fc->tab.ctus + rs; | |
| 2778 | 53475 | const CodingUnit *cu = fc->tab.cus[rs]; | |
| 2779 | |||
| 2780 | 53475 | ctu->has_dmvr = 0; | |
| 2781 | |||
| 2782 |
2/2✓ Branch 0 taken 6370 times.
✓ Branch 1 taken 47105 times.
|
53475 | if (IS_I(rsh)) |
| 2783 | 6370 | return; | |
| 2784 | |||
| 2785 |
2/2✓ Branch 0 taken 94210 times.
✓ Branch 1 taken 47105 times.
|
141315 | for (int lx = 0; lx < 2; lx++) |
| 2786 | 94210 | memset(ctu->max_y[lx], -1, sizeof(ctu->max_y[0][0]) * rsh->num_ref_idx_active[lx]); | |
| 2787 | |||
| 2788 |
2/2✓ Branch 0 taken 627244 times.
✓ Branch 1 taken 47105 times.
|
674349 | while (cu) { |
| 2789 |
2/2✓ Branch 1 taken 488172 times.
✓ Branch 2 taken 139072 times.
|
627244 | if (has_inter_luma(cu)) { |
| 2790 | 488172 | cu_get_max_y(cu, ctu->max_y, lc); | |
| 2791 | 488172 | ctu->has_dmvr |= cu->pu.dmvr_flag; | |
| 2792 | } | ||
| 2793 | 627244 | cu = cu->next; | |
| 2794 | } | ||
| 2795 | 47105 | ctu->max_y_idx[0] = ctu->max_y_idx[1] = 0; | |
| 2796 | } | ||
| 2797 | |||
| 2798 | 53475 | int ff_vvc_coding_tree_unit(VVCLocalContext *lc, | |
| 2799 | const int ctu_idx, const int rs, const int rx, const int ry) | ||
| 2800 | { | ||
| 2801 | 53475 | const VVCFrameContext *fc = lc->fc; | |
| 2802 | 53475 | const VVCSPS *sps = fc->ps.sps; | |
| 2803 | 53475 | const VVCPPS *pps = fc->ps.pps; | |
| 2804 | 53475 | const int x_ctb = rx << sps->ctb_log2_size_y; | |
| 2805 | 53475 | const int y_ctb = ry << sps->ctb_log2_size_y; | |
| 2806 | 53475 | const int ctb_size = 1 << sps->ctb_log2_size_y << sps->ctb_log2_size_y; | |
| 2807 | 53475 | EntryPoint* ep = lc->ep; | |
| 2808 | int ret; | ||
| 2809 | |||
| 2810 |
2/2✓ Branch 0 taken 6463 times.
✓ Branch 1 taken 47012 times.
|
53475 | if (rx == pps->ctb_to_col_bd[rx]) { |
| 2811 | 6463 | ep->num_hmvp = 0; | |
| 2812 | 6463 | ep->num_hmvp_ibc = 0; | |
| 2813 |
4/4✓ Branch 0 taken 4251 times.
✓ Branch 1 taken 2212 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 4139 times.
|
6463 | ep->is_first_qg = ry == pps->ctb_to_row_bd[ry] || !ctu_idx; |
| 2814 | } | ||
| 2815 | |||
| 2816 | 53475 | lc->coeffs = fc->tab.coeffs + rs * ctb_size * VVC_MAX_SAMPLE_ARRAYS; | |
| 2817 | 53475 | lc->cu = NULL; | |
| 2818 | |||
| 2819 | 53475 | ff_vvc_cabac_init(lc, ctu_idx, rx, ry); | |
| 2820 | 53475 | ff_vvc_decode_neighbour(lc, x_ctb, y_ctb, rx, ry, rs); | |
| 2821 | 53475 | ret = hls_coding_tree_unit(lc, x_ctb, y_ctb, ctu_idx, rx, ry); | |
| 2822 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 53475 times.
|
53475 | if (ret < 0) |
| 2823 | ✗ | return ret; | |
| 2824 | 53475 | ctu_get_pred(lc, rs); | |
| 2825 | |||
| 2826 | 53475 | return 0; | |
| 2827 | } | ||
| 2828 | |||
| 2829 | 363855 | void ff_vvc_decode_neighbour(VVCLocalContext *lc, const int x_ctb, const int y_ctb, | |
| 2830 | const int rx, const int ry, const int rs) | ||
| 2831 | { | ||
| 2832 | 363855 | VVCFrameContext *fc = lc->fc; | |
| 2833 | 363855 | const int ctb_size = fc->ps.sps->ctb_size_y; | |
| 2834 | |||
| 2835 | 363855 | lc->end_of_tiles_x = fc->ps.pps->width; | |
| 2836 | 363855 | lc->end_of_tiles_y = fc->ps.pps->height; | |
| 2837 |
2/2✓ Branch 0 taken 44452 times.
✓ Branch 1 taken 319403 times.
|
363855 | if (fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx + 1]) |
| 2838 | 44452 | lc->end_of_tiles_x = FFMIN(x_ctb + ctb_size, lc->end_of_tiles_x); | |
| 2839 |
2/2✓ Branch 0 taken 72442 times.
✓ Branch 1 taken 291413 times.
|
363855 | if (fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry + 1]) |
| 2840 | 72442 | lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, lc->end_of_tiles_y); | |
| 2841 | |||
| 2842 | 363855 | lc->boundary_flags = 0; | |
| 2843 |
4/4✓ Branch 0 taken 330582 times.
✓ Branch 1 taken 33273 times.
✓ Branch 2 taken 11179 times.
✓ Branch 3 taken 319403 times.
|
363855 | if (rx > 0 && fc->ps.pps->ctb_to_col_bd[rx] != fc->ps.pps->ctb_to_col_bd[rx - 1]) |
| 2844 | 11179 | lc->boundary_flags |= BOUNDARY_LEFT_TILE; | |
| 2845 |
4/4✓ Branch 0 taken 330582 times.
✓ Branch 1 taken 33273 times.
✓ Branch 2 taken 5425 times.
✓ Branch 3 taken 325157 times.
|
363855 | if (rx > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - 1]) |
| 2846 | 5425 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; | |
| 2847 |
4/4✓ Branch 0 taken 305952 times.
✓ Branch 1 taken 57903 times.
✓ Branch 2 taken 14539 times.
✓ Branch 3 taken 291413 times.
|
363855 | if (ry > 0 && fc->ps.pps->ctb_to_row_bd[ry] != fc->ps.pps->ctb_to_row_bd[ry - 1]) |
| 2848 | 14539 | lc->boundary_flags |= BOUNDARY_UPPER_TILE; | |
| 2849 |
4/4✓ Branch 0 taken 305952 times.
✓ Branch 1 taken 57903 times.
✓ Branch 2 taken 12341 times.
✓ Branch 3 taken 293611 times.
|
363855 | if (ry > 0 && fc->tab.slice_idx[rs] != fc->tab.slice_idx[rs - fc->ps.pps->ctb_width]) |
| 2850 | 12341 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; | |
| 2851 |
2/2✓ Branch 0 taken 35436 times.
✓ Branch 1 taken 328419 times.
|
363855 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_x[lc->sc->sh.r->curr_subpic_idx] == rx) |
| 2852 | 35436 | lc->boundary_flags |= BOUNDARY_LEFT_SUBPIC; | |
| 2853 |
2/2✓ Branch 0 taken 60486 times.
✓ Branch 1 taken 303369 times.
|
363855 | if (fc->ps.sps->r->sps_subpic_ctu_top_left_y[lc->sc->sh.r->curr_subpic_idx] == ry) |
| 2854 | 60486 | lc->boundary_flags |= BOUNDARY_UPPER_SUBPIC; | |
| 2855 |
4/4✓ Branch 0 taken 330582 times.
✓ Branch 1 taken 33273 times.
✓ Branch 2 taken 319403 times.
✓ Branch 3 taken 11179 times.
|
363855 | lc->ctb_left_flag = rx > 0 && !(lc->boundary_flags & BOUNDARY_LEFT_TILE); |
| 2856 |
6/6✓ Branch 0 taken 305952 times.
✓ Branch 1 taken 57903 times.
✓ Branch 2 taken 291413 times.
✓ Branch 3 taken 14539 times.
✓ Branch 4 taken 289061 times.
✓ Branch 5 taken 2352 times.
|
363855 | lc->ctb_up_flag = ry > 0 && !(lc->boundary_flags & BOUNDARY_UPPER_TILE) && !(lc->boundary_flags & BOUNDARY_UPPER_SLICE); |
| 2857 |
4/4✓ Branch 0 taken 289061 times.
✓ Branch 1 taken 74794 times.
✓ Branch 2 taken 260770 times.
✓ Branch 3 taken 28291 times.
|
624625 | 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]) && |
| 2858 |
1/2✓ Branch 0 taken 260770 times.
✗ Branch 1 not taken.
|
260770 | (fc->ps.pps->ctb_to_row_bd[ry] == fc->ps.pps->ctb_to_row_bd[ry - 1]); |
| 2859 |
4/4✓ Branch 0 taken 319403 times.
✓ Branch 1 taken 44452 times.
✓ Branch 2 taken 260770 times.
✓ Branch 3 taken 58633 times.
|
363855 | lc->ctb_up_left_flag = lc->ctb_left_flag && lc->ctb_up_flag; |
| 2860 | 363855 | } | |
| 2861 | |||
| 2862 | 2899244 | void ff_vvc_set_neighbour_available(VVCLocalContext *lc, | |
| 2863 | const int x0, const int y0, const int w, const int h) | ||
| 2864 | { | ||
| 2865 | 2899244 | const int log2_ctb_size = lc->fc->ps.sps->ctb_log2_size_y; | |
| 2866 | 2899244 | const int x0b = av_zero_extend(x0, log2_ctb_size); | |
| 2867 | 2899244 | const int y0b = av_zero_extend(y0, log2_ctb_size); | |
| 2868 | |||
| 2869 |
4/4✓ Branch 0 taken 877086 times.
✓ Branch 1 taken 2022158 times.
✓ Branch 2 taken 785622 times.
✓ Branch 3 taken 91464 times.
|
2899244 | lc->na.cand_up = (lc->ctb_up_flag || y0b); |
| 2870 |
4/4✓ Branch 0 taken 562597 times.
✓ Branch 1 taken 2336647 times.
✓ Branch 2 taken 490398 times.
✓ Branch 3 taken 72199 times.
|
2899244 | lc->na.cand_left = (lc->ctb_left_flag || x0b); |
| 2871 |
8/8✓ Branch 0 taken 444056 times.
✓ Branch 1 taken 2455188 times.
✓ Branch 2 taken 323169 times.
✓ Branch 3 taken 120887 times.
✓ Branch 4 taken 2721456 times.
✓ Branch 5 taken 56901 times.
✓ Branch 6 taken 2655452 times.
✓ Branch 7 taken 66004 times.
|
2899244 | lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag; |
| 2872 | 2899244 | lc->na.cand_up_right_sap = | |
| 2873 |
6/6✓ Branch 0 taken 412611 times.
✓ Branch 1 taken 2486633 times.
✓ Branch 2 taken 285431 times.
✓ Branch 3 taken 127180 times.
✓ Branch 4 taken 85800 times.
✓ Branch 5 taken 199631 times.
|
2899244 | (x0b + w == 1 << log2_ctb_size) ? lc->ctb_up_right_flag && !y0b : lc->na.cand_up; |
| 2874 |
4/4✓ Branch 0 taken 2504678 times.
✓ Branch 1 taken 394566 times.
✓ Branch 2 taken 2481735 times.
✓ Branch 3 taken 22943 times.
|
2899244 | lc->na.cand_up_right = lc->na.cand_up_right_sap && (x0 + w) < lc->end_of_tiles_x; |
| 2875 | 2899244 | } | |
| 2876 | |||
| 2877 | 106950 | void ff_vvc_ctu_free_cus(CodingUnit **cus) | |
| 2878 | { | ||
| 2879 |
2/2✓ Branch 0 taken 1344609 times.
✓ Branch 1 taken 106950 times.
|
1451559 | while (*cus) { |
| 2880 | 1344609 | CodingUnit *cu = *cus; | |
| 2881 | 1344609 | TransformUnit **head = &cu->tus.head; | |
| 2882 | |||
| 2883 | 1344609 | *cus = cu->next; | |
| 2884 | |||
| 2885 |
2/2✓ Branch 0 taken 1663917 times.
✓ Branch 1 taken 1344609 times.
|
3008526 | while (*head) { |
| 2886 | 1663917 | TransformUnit *tu = *head; | |
| 2887 | 1663917 | *head = tu->next; | |
| 2888 | 1663917 | av_refstruct_unref(&tu); | |
| 2889 | } | ||
| 2890 | 1344609 | cu->tus.tail = NULL; | |
| 2891 | |||
| 2892 | 1344609 | av_refstruct_unref(&cu); | |
| 2893 | } | ||
| 2894 | 106950 | } | |
| 2895 | |||
| 2896 | 16659518 | int ff_vvc_get_qPy(const VVCFrameContext *fc, const int xc, const int yc) | |
| 2897 | { | ||
| 2898 | 16659518 | const int min_cb_log2_size_y = fc->ps.sps->min_cb_log2_size_y; | |
| 2899 | 16659518 | const int x = xc >> min_cb_log2_size_y; | |
| 2900 | 16659518 | const int y = yc >> min_cb_log2_size_y; | |
| 2901 | 16659518 | return fc->tab.qp[LUMA][x + y * fc->ps.pps->min_cb_width]; | |
| 2902 | } | ||
| 2903 | |||
| 2904 | 2477 | void ff_vvc_ep_init_stat_coeff(EntryPoint *ep, | |
| 2905 | const int bit_depth, const int persistent_rice_adaptation_enabled_flag) | ||
| 2906 | { | ||
| 2907 |
2/2✓ Branch 0 taken 7431 times.
✓ Branch 1 taken 2477 times.
|
9908 | for (size_t i = 0; i < FF_ARRAY_ELEMS(ep->stat_coeff); ++i) { |
| 2908 | 7431 | ep->stat_coeff[i] = | |
| 2909 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7431 times.
|
7431 | persistent_rice_adaptation_enabled_flag ? 2 * (av_log2(bit_depth - 10)) : 0; |
| 2910 | } | ||
| 2911 | 2477 | } | |
| 2912 | |||
| 2913 | 689441 | void ff_vvc_channel_range(int *start, int *end, const VVCTreeType tree_type, const uint8_t chroma_format_idc) | |
| 2914 | { | ||
| 2915 |
4/4✓ Branch 0 taken 672930 times.
✓ Branch 1 taken 16511 times.
✓ Branch 2 taken 547359 times.
✓ Branch 3 taken 125571 times.
|
689441 | const bool has_chroma = chroma_format_idc && tree_type != DUAL_TREE_LUMA; |
| 2916 | 689441 | const bool has_luma = tree_type != DUAL_TREE_CHROMA; | |
| 2917 | |||
| 2918 | 689441 | *start = has_luma ? LUMA : CB; | |
| 2919 |
2/2✓ Branch 0 taken 547359 times.
✓ Branch 1 taken 142082 times.
|
689441 | *end = has_chroma ? VVC_MAX_SAMPLE_ARRAYS : CB; |
| 2920 | 689441 | } | |
| 2921 |