| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * VVC intra prediction DSP | ||
| 3 | * | ||
| 4 | * Copyright (C) 2021-2023 Nuomi | ||
| 5 | * | ||
| 6 | * This file is part of FFmpeg. | ||
| 7 | * | ||
| 8 | * FFmpeg is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with FFmpeg; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include "libavcodec/bit_depth_template.c" | ||
| 24 | |||
| 25 | #include "intra.h" | ||
| 26 | |||
| 27 | #define POS(x, y) src[(x) + stride * (y)] | ||
| 28 | |||
| 29 | 194692 | static av_always_inline void FUNC(cclm_linear_pred)(VVCFrameContext *fc, const int x0, const int y0, | |
| 30 | const int w, const int h, const pixel* pdsy, const int *a, const int *b, const int *k) | ||
| 31 | { | ||
| 32 | 194692 | const VVCSPS *sps = fc->ps.sps; | |
| 33 |
2/2✓ Branch 0 taken 194692 times.
✓ Branch 1 taken 97346 times.
|
584076 | for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) { |
| 34 | 389384 | const int c_idx = i + 1; | |
| 35 | 389384 | const int x = x0 >> sps->hshift[c_idx]; | |
| 36 | 389384 | const int y = y0 >> sps->vshift[c_idx]; | |
| 37 | 389384 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
| 38 | 389384 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
| 39 |
2/2✓ Branch 0 taken 1866472 times.
✓ Branch 1 taken 194692 times.
|
4122328 | for (int y = 0; y < h; y++) { |
| 40 |
2/2✓ Branch 0 taken 28183392 times.
✓ Branch 1 taken 1866472 times.
|
60099728 | for (int x = 0; x < w; x++) { |
| 41 | 56366784 | const int dsy = pdsy[y * w + x]; | |
| 42 | 56366784 | const int pred = ((dsy * a[i]) >> k[i]) + b[i]; | |
| 43 | 56366784 | POS(x, y) = CLIP(pred); | |
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||
| 47 | 194692 | } | |
| 48 | |||
| 49 | #define MAX_PICK_POS 4 | ||
| 50 | #define TOP 0 | ||
| 51 | #define LEFT 1 | ||
| 52 | |||
| 53 | 1628 | static av_always_inline void FUNC(cclm_get_params_default)(int *a, int *b, int *k) | |
| 54 | { | ||
| 55 |
2/2✓ Branch 0 taken 1628 times.
✓ Branch 1 taken 814 times.
|
4884 | for (int i = 0; i < 2; i++) { |
| 56 | 3256 | a[i] = k[i] = 0; | |
| 57 | 3256 | b[i] = 1 << (BIT_DEPTH - 1); | |
| 58 | } | ||
| 59 | 1628 | } | |
| 60 | |||
| 61 | 194692 | static av_always_inline int FUNC(cclm_get_select_pos)(const VVCLocalContext *lc, | |
| 62 | const int x, const int y, const int w, const int h, const int avail_t, const int avail_l, | ||
| 63 | int cnt[2], int pos[2][MAX_PICK_POS]) | ||
| 64 | { | ||
| 65 | 194692 | const enum IntraPredMode mode = lc->cu->intra_pred_mode_c; | |
| 66 |
6/6✓ Branch 0 taken 93967 times.
✓ Branch 1 taken 3379 times.
✓ Branch 2 taken 91314 times.
✓ Branch 3 taken 2653 times.
✓ Branch 4 taken 40819 times.
✓ Branch 5 taken 50495 times.
|
194692 | const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM; |
| 67 | int num_samp[2]; | ||
| 68 | |||
| 69 |
2/2✓ Branch 0 taken 54602 times.
✓ Branch 1 taken 42744 times.
|
194692 | if (mode == INTRA_LT_CCLM) { |
| 70 |
2/2✓ Branch 0 taken 52110 times.
✓ Branch 1 taken 2492 times.
|
109204 | num_samp[TOP] = avail_t ? w : 0; |
| 71 |
2/2✓ Branch 0 taken 52987 times.
✓ Branch 1 taken 1615 times.
|
109204 | num_samp[LEFT] = avail_l ? h : 0; |
| 72 | } else { | ||
| 73 |
4/4✓ Branch 0 taken 41857 times.
✓ Branch 1 taken 887 times.
✓ Branch 2 taken 22001 times.
✓ Branch 3 taken 19856 times.
|
85488 | num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc, x, y, w + FFMIN(w, h), 1) : 0; |
| 74 |
4/4✓ Branch 0 taken 41706 times.
✓ Branch 1 taken 1038 times.
✓ Branch 2 taken 19929 times.
✓ Branch 3 taken 21777 times.
|
85488 | num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMIN(w, h), 1) : 0; |
| 75 | } | ||
| 76 |
4/4✓ Branch 0 taken 23235 times.
✓ Branch 1 taken 74111 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 22421 times.
|
194692 | if (!num_samp[TOP] && !num_samp[LEFT]) { |
| 77 | 1628 | return 0; | |
| 78 | } | ||
| 79 |
2/2✓ Branch 0 taken 193064 times.
✓ Branch 1 taken 96532 times.
|
579192 | for (int i = TOP; i <= LEFT; i++) { |
| 80 | 386128 | const int start = num_samp[i] >> (2 + num_is4); | |
| 81 | 386128 | const int step = FFMAX(1, num_samp[i] >> (1 + num_is4)) ; | |
| 82 | 386128 | cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1); | |
| 83 |
2/2✓ Branch 0 taken 384734 times.
✓ Branch 1 taken 193064 times.
|
1155596 | for (int c = 0; c < cnt[i]; c++) |
| 84 | 769468 | pos[i][c] = start + c * step; | |
| 85 | } | ||
| 86 | 193064 | return 1; | |
| 87 | } | ||
| 88 | |||
| 89 | 52040 | static av_always_inline void FUNC(cclm_select_luma_444)(const pixel *src, const int step, | |
| 90 | const int cnt, const int pos[MAX_PICK_POS], pixel *sel_luma) | ||
| 91 | { | ||
| 92 |
2/2✓ Branch 0 taken 52040 times.
✓ Branch 1 taken 26020 times.
|
156120 | for (int i = 0; i < cnt; i++) |
| 93 | 104080 | sel_luma[i] = src[pos[i] * step]; | |
| 94 | 52040 | } | |
| 95 | |||
| 96 | 193064 | static av_always_inline void FUNC(cclm_select_luma)(const VVCFrameContext *fc, | |
| 97 | const int x0, const int y0, const int avail_t, const int avail_l, const int cnt[2], const int pos[2][MAX_PICK_POS], | ||
| 98 | pixel *sel_luma) | ||
| 99 | { | ||
| 100 | 193064 | const VVCSPS *sps = fc->ps.sps; | |
| 101 | |||
| 102 | 193064 | const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y); | |
| 103 | 193064 | const int hs = sps->hshift[1]; | |
| 104 | 193064 | const int vs = sps->vshift[1]; | |
| 105 | 193064 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
| 106 | |||
| 107 |
3/4✓ Branch 0 taken 13010 times.
✓ Branch 1 taken 83522 times.
✓ Branch 2 taken 13010 times.
✗ Branch 3 not taken.
|
219084 | if (!hs && !vs) { |
| 108 | 26020 | const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride; | |
| 109 | 26020 | FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma); | |
| 110 | 26020 | FUNC(cclm_select_luma_444)(src - avail_l, stride, cnt[LEFT], pos[LEFT], sel_luma + cnt[TOP]); | |
| 111 | } else { | ||
| 112 | // top | ||
| 113 |
4/4✓ Branch 0 taken 79555 times.
✓ Branch 1 taken 3967 times.
✓ Branch 2 taken 67948 times.
✓ Branch 3 taken 11607 times.
|
302940 | if (vs && !b_ctu_boundary) { |
| 114 | 135896 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride; | |
| 115 |
2/2✓ Branch 0 taken 142024 times.
✓ Branch 1 taken 67948 times.
|
419944 | for (int i = 0; i < cnt[TOP]; i++) { |
| 116 | 284048 | const int x = pos[TOP][i] << hs; | |
| 117 | 284048 | const pixel *src = source + x; | |
| 118 |
4/4✓ Branch 0 taken 2703 times.
✓ Branch 1 taken 139321 times.
✓ Branch 2 taken 2456 times.
✓ Branch 3 taken 247 times.
|
284048 | const int has_left = x || avail_l; |
| 119 |
2/2✓ Branch 0 taken 141777 times.
✓ Branch 1 taken 247 times.
|
284048 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
| 120 |
2/2✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 137784 times.
|
284048 | if (sps->r->sps_chroma_vertical_collocated_flag) { |
| 121 | 8480 | sel_luma[i] = (POS(0, -1) + l + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3; | |
| 122 | } else { | ||
| 123 |
2/2✓ Branch 0 taken 137537 times.
✓ Branch 1 taken 247 times.
|
275568 | const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1); |
| 124 | 275568 | sel_luma[i] = (l + l1 + 2 * (POS(0, 0) + POS(0, 1)) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
| 125 | } | ||
| 126 | } | ||
| 127 | } else { | ||
| 128 | 31148 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride; | |
| 129 |
2/2✓ Branch 0 taken 26748 times.
✓ Branch 1 taken 15574 times.
|
84644 | for (int i = 0; i < cnt[TOP]; i++) { |
| 130 | 53496 | const int x = pos[TOP][i] << hs; | |
| 131 | 53496 | const pixel *src = source + x; | |
| 132 |
4/4✓ Branch 0 taken 345 times.
✓ Branch 1 taken 26403 times.
✓ Branch 2 taken 308 times.
✓ Branch 3 taken 37 times.
|
53496 | const int has_left = x || avail_l; |
| 133 |
2/2✓ Branch 0 taken 26711 times.
✓ Branch 1 taken 37 times.
|
53496 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
| 134 | 53496 | sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 138 | // left | ||
| 139 | { | ||
| 140 | const pixel *left; | ||
| 141 | 167044 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l; | |
| 142 | 167044 | left = source - avail_l; | |
| 143 | |||
| 144 |
2/2✓ Branch 0 taken 163922 times.
✓ Branch 1 taken 83522 times.
|
494888 | for (int i = 0; i < cnt[LEFT]; i++) { |
| 145 | 327844 | const int y = pos[LEFT][i] << vs; | |
| 146 | 327844 | const int offset = y * stride; | |
| 147 | 327844 | const pixel *l = left + offset; | |
| 148 | 327844 | const pixel *src = source + offset; | |
| 149 | pixel pred; | ||
| 150 |
2/2✓ Branch 0 taken 7146 times.
✓ Branch 1 taken 156776 times.
|
327844 | if (!vs) { |
| 151 | 14292 | pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
| 152 | } else { | ||
| 153 |
2/2✓ Branch 0 taken 6058 times.
✓ Branch 1 taken 150718 times.
|
313552 | if (sps->r->sps_chroma_vertical_collocated_flag) { |
| 154 |
3/4✓ Branch 0 taken 94 times.
✓ Branch 1 taken 5964 times.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
|
12116 | const int has_top = y || avail_t; |
| 155 |
1/2✓ Branch 0 taken 6058 times.
✗ Branch 1 not taken.
|
12116 | const pixel t = has_top ? POS(0, -1) : POS(0, 0); |
| 156 | 12116 | pred = (*l + t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3; | |
| 157 | } else { | ||
| 158 | 301436 | pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
| 159 | } | ||
| 160 | } | ||
| 161 | 327844 | sel_luma[i + cnt[TOP]] = pred; | |
| 162 | } | ||
| 163 | } | ||
| 164 | } | ||
| 165 | 193064 | } | |
| 166 | |||
| 167 | 193064 | static av_always_inline void FUNC(cclm_select_chroma)(const VVCFrameContext *fc, | |
| 168 | const int x, const int y, const int cnt[2], const int pos[2][MAX_PICK_POS], | ||
| 169 | pixel sel[][MAX_PICK_POS * 2]) | ||
| 170 | { | ||
| 171 |
2/2✓ Branch 0 taken 193064 times.
✓ Branch 1 taken 96532 times.
|
579192 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
| 172 | 386128 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
| 173 | |||
| 174 | //top | ||
| 175 | 386128 | const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride; | |
| 176 |
2/2✓ Branch 0 taken 390908 times.
✓ Branch 1 taken 193064 times.
|
1167944 | for (int i = 0; i < cnt[TOP]; i++) { |
| 177 | 781816 | sel[c_idx][i] = src[pos[TOP][i]]; | |
| 178 | } | ||
| 179 | |||
| 180 | //left | ||
| 181 | 386128 | src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride; | |
| 182 |
2/2✓ Branch 0 taken 378560 times.
✓ Branch 1 taken 193064 times.
|
1143248 | for (int i = 0; i < cnt[LEFT]; i++) { |
| 183 | 757120 | sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride]; | |
| 184 | } | ||
| 185 | } | ||
| 186 | 193064 | } | |
| 187 | |||
| 188 | 194692 | static av_always_inline int FUNC(cclm_select_samples)(const VVCLocalContext *lc, | |
| 189 | const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l, | ||
| 190 | pixel sel[][MAX_PICK_POS * 2]) | ||
| 191 | { | ||
| 192 | 194692 | const VVCFrameContext *fc = lc->fc; | |
| 193 | 194692 | const VVCSPS *sps = fc->ps.sps; | |
| 194 | 194692 | const int x = x0 >> sps->hshift[1]; | |
| 195 | 194692 | const int y = y0 >> sps->vshift[1]; | |
| 196 | int cnt[2], pos[2][MAX_PICK_POS]; | ||
| 197 | |||
| 198 |
2/2✓ Branch 1 taken 814 times.
✓ Branch 2 taken 96532 times.
|
194692 | if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos)) |
| 199 | 1628 | return 0; | |
| 200 | |||
| 201 | 193064 | FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]); | |
| 202 | 193064 | FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel); | |
| 203 | |||
| 204 |
2/2✓ Branch 0 taken 697 times.
✓ Branch 1 taken 95835 times.
|
193064 | if (cnt[TOP] + cnt[LEFT] == 2) { |
| 205 |
2/2✓ Branch 0 taken 2091 times.
✓ Branch 1 taken 697 times.
|
5576 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
| 206 | 4182 | sel[c_idx][3] = sel[c_idx][0]; | |
| 207 | 4182 | sel[c_idx][2] = sel[c_idx][1]; | |
| 208 | 4182 | sel[c_idx][0] = sel[c_idx][1]; | |
| 209 | 4182 | sel[c_idx][1] = sel[c_idx][3]; | |
| 210 | } | ||
| 211 | } | ||
| 212 | 193064 | return 1; | |
| 213 | } | ||
| 214 | |||
| 215 | 193064 | static av_always_inline void FUNC(cclm_get_min_max)( | |
| 216 | const pixel sel[][MAX_PICK_POS * 2], int *min, int *max) | ||
| 217 | { | ||
| 218 | 193064 | int min_grp_idx[] = { 0, 2 }; | |
| 219 | 193064 | int max_grp_idx[] = { 1, 3 }; | |
| 220 | |||
| 221 |
2/2✓ Branch 0 taken 45043 times.
✓ Branch 1 taken 51489 times.
|
193064 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]]) |
| 222 | 90086 | FFSWAP(int, min_grp_idx[0], min_grp_idx[1]); | |
| 223 |
2/2✓ Branch 0 taken 45719 times.
✓ Branch 1 taken 50813 times.
|
193064 | if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) |
| 224 | 91438 | FFSWAP(int, max_grp_idx[0], max_grp_idx[1]); | |
| 225 |
2/2✓ Branch 0 taken 9273 times.
✓ Branch 1 taken 87259 times.
|
193064 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) { |
| 226 | 18546 | FFSWAP(int, min_grp_idx[0], max_grp_idx[0]); | |
| 227 | 18546 | FFSWAP(int, min_grp_idx[1], max_grp_idx[1]); | |
| 228 | } | ||
| 229 |
2/2✓ Branch 0 taken 71563 times.
✓ Branch 1 taken 24969 times.
|
193064 | if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]]) |
| 230 | 143126 | FFSWAP(int, min_grp_idx[1], max_grp_idx[0]); | |
| 231 |
2/2✓ Branch 0 taken 289596 times.
✓ Branch 1 taken 96532 times.
|
772256 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
| 232 | 579192 | max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1; | |
| 233 | 579192 | min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1; | |
| 234 | } | ||
| 235 | 193064 | } | |
| 236 | |||
| 237 | 194692 | static av_always_inline void FUNC(cclm_get_params)(const VVCLocalContext *lc, | |
| 238 | const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l, | ||
| 239 | int *a, int *b, int *k) | ||
| 240 | { | ||
| 241 | pixel sel[VVC_MAX_SAMPLE_ARRAYS][MAX_PICK_POS * 2]; | ||
| 242 | int max[VVC_MAX_SAMPLE_ARRAYS], min[VVC_MAX_SAMPLE_ARRAYS]; | ||
| 243 | int diff; | ||
| 244 | |||
| 245 |
2/2✓ Branch 1 taken 814 times.
✓ Branch 2 taken 96532 times.
|
194692 | if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) { |
| 246 | 1628 | FUNC(cclm_get_params_default)(a, b, k); | |
| 247 | 11986 | return; | |
| 248 | } | ||
| 249 | |||
| 250 | 193064 | FUNC(cclm_get_min_max)(sel, min, max); | |
| 251 | |||
| 252 | 193064 | diff = max[LUMA] - min[LUMA]; | |
| 253 |
2/2✓ Branch 0 taken 5179 times.
✓ Branch 1 taken 91353 times.
|
193064 | if (diff == 0) { |
| 254 |
2/2✓ Branch 0 taken 10358 times.
✓ Branch 1 taken 5179 times.
|
31074 | for (int i = 0; i < 2; i++) { |
| 255 | 20716 | a[i] = k[i] = 0; | |
| 256 | 20716 | b[i] = min[i + 1]; | |
| 257 | } | ||
| 258 | 10358 | return; | |
| 259 | } | ||
| 260 |
2/2✓ Branch 0 taken 182706 times.
✓ Branch 1 taken 91353 times.
|
548118 | for (int i = 0; i < 2; i++) { |
| 261 | const static int div_sig_table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0}; | ||
| 262 | 365412 | const int diffc = max[i + 1] - min[i + 1]; | |
| 263 | 365412 | int x = av_log2(diff); | |
| 264 | int y, v, sign, add; | ||
| 265 | 365412 | const int norm_diff = ((diff << 4) >> x) & 15; | |
| 266 | 365412 | x += (norm_diff) ? 1 : 0; | |
| 267 |
2/2✓ Branch 0 taken 163279 times.
✓ Branch 1 taken 19427 times.
|
365412 | y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0; |
| 268 | 365412 | v = div_sig_table[norm_diff] | 8; | |
| 269 | 365412 | add = (1 << y >> 1); | |
| 270 | 365412 | a[i] = (diffc * v + add) >> y; | |
| 271 | 365412 | k[i] = FFMAX(1, 3 + x -y); | |
| 272 |
2/2✓ Branch 0 taken 81088 times.
✓ Branch 1 taken 101618 times.
|
365412 | sign = a[i] < 0 ? -1 : (a[i] > 0); |
| 273 |
2/2✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 180983 times.
|
365412 | a[i] = ((3 + x - y) < 1) ? sign * 15 : a[i]; |
| 274 | 365412 | b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]); | |
| 275 | } | ||
| 276 | |||
| 277 | } | ||
| 278 | |||
| 279 | #undef TOP | ||
| 280 | #undef LEFT | ||
| 281 | |||
| 282 | 194692 | static av_always_inline void FUNC(cclm_get_luma_rec_pixels)(const VVCFrameContext *fc, | |
| 283 | const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l, | ||
| 284 | pixel *pdsy) | ||
| 285 | { | ||
| 286 | 194692 | const int hs = fc->ps.sps->hshift[1]; | |
| 287 | 194692 | const int vs = fc->ps.sps->vshift[1]; | |
| 288 | 194692 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
| 289 | 194692 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + y0 * stride; | |
| 290 | 194692 | const pixel *left = source - avail_l; | |
| 291 | 194692 | const pixel *top = source - avail_t * stride; | |
| 292 | |||
| 293 | 194692 | const VVCSPS *sps = fc->ps.sps; | |
| 294 |
3/4✓ Branch 0 taken 13013 times.
✓ Branch 1 taken 84333 times.
✓ Branch 2 taken 13013 times.
✗ Branch 3 not taken.
|
194692 | if (!hs && !vs) { |
| 295 |
2/2✓ Branch 0 taken 179928 times.
✓ Branch 1 taken 13013 times.
|
385882 | for (int i = 0; i < h; i++) |
| 296 | 359856 | memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel)); | |
| 297 | 26026 | return; | |
| 298 | } | ||
| 299 |
2/2✓ Branch 0 taken 753308 times.
✓ Branch 1 taken 84333 times.
|
1675282 | for (int i = 0; i < h; i++) { |
| 300 | 1506616 | const pixel *src = source; | |
| 301 | 1506616 | const pixel *l = left; | |
| 302 | 1506616 | const pixel *t = top; | |
| 303 |
2/2✓ Branch 0 taken 47016 times.
✓ Branch 1 taken 706292 times.
|
1506616 | if (!vs) { |
| 304 |
2/2✓ Branch 0 taken 329120 times.
✓ Branch 1 taken 47016 times.
|
752272 | for (int j = 0; j < w; j++) { |
| 305 | 658240 | pixel pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
| 306 | 658240 | pdsy[i * w + j] = pred; | |
| 307 | 658240 | src += 2; | |
| 308 | 658240 | l = src - 1; | |
| 309 | } | ||
| 310 | |||
| 311 | } else { | ||
| 312 |
2/2✓ Branch 0 taken 54676 times.
✓ Branch 1 taken 651616 times.
|
1412584 | if (sps->r->sps_chroma_vertical_collocated_flag) { |
| 313 |
2/2✓ Branch 0 taken 1396000 times.
✓ Branch 1 taken 54676 times.
|
2901352 | for (int j = 0; j < w; j++) { |
| 314 | 2792000 | pixel pred = (*l + *t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3; | |
| 315 | 2792000 | pdsy[i * w + j] = pred; | |
| 316 | 2792000 | src += 2; | |
| 317 | 2792000 | t += 2; | |
| 318 | 2792000 | l = src - 1; | |
| 319 | } | ||
| 320 | } else { | ||
| 321 |
2/2✓ Branch 0 taken 8911872 times.
✓ Branch 1 taken 651616 times.
|
19126976 | for (int j = 0; j < w; j++) { |
| 322 | 17823744 | pixel pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
| 323 | |||
| 324 | 17823744 | pdsy[i * w + j] = pred; | |
| 325 | 17823744 | src += 2; | |
| 326 | 17823744 | l = src - 1; | |
| 327 | } | ||
| 328 | } | ||
| 329 | } | ||
| 330 | 1506616 | source += (stride << vs); | |
| 331 | 1506616 | left += (stride << vs); | |
| 332 | 1506616 | top = source - stride; | |
| 333 | } | ||
| 334 | } | ||
| 335 | |||
| 336 | 582 | static av_always_inline void FUNC(cclm_pred_default)(VVCFrameContext *fc, | |
| 337 | const int x, const int y, const int w, const int h, const int avail_t, const int avail_l) | ||
| 338 | { | ||
| 339 |
2/2✓ Branch 0 taken 582 times.
✓ Branch 1 taken 291 times.
|
1746 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
| 340 | 1164 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
| 341 | 1164 | pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
| 342 |
2/2✓ Branch 0 taken 10432 times.
✓ Branch 1 taken 582 times.
|
22028 | for (int i = 0; i < h; i++) { |
| 343 |
2/2✓ Branch 0 taken 268096 times.
✓ Branch 1 taken 10432 times.
|
557056 | for (int j = 0; j < w; j++) { |
| 344 | 536192 | dst[j] = 1 << (BIT_DEPTH - 1); | |
| 345 | } | ||
| 346 | 20864 | dst += stride; | |
| 347 | } | ||
| 348 | } | ||
| 349 | 582 | } | |
| 350 | |||
| 351 | //8.4.5.2.14 Specification of INTRA_LT_CCLM, INTRA_L_CCLM and INTRA_T_CCLM intra prediction mode | ||
| 352 | 195274 | static void FUNC(intra_cclm_pred)(const VVCLocalContext *lc, const int x0, const int y0, | |
| 353 | const int width, const int height) | ||
| 354 | { | ||
| 355 | 195274 | VVCFrameContext *fc = lc->fc; | |
| 356 | 195274 | const VVCSPS *sps = fc->ps.sps; | |
| 357 | 195274 | const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0); | |
| 358 | 195274 | const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0); | |
| 359 | 195274 | const int hs = sps->hshift[1]; | |
| 360 | 195274 | const int vs = sps->vshift[1]; | |
| 361 | 195274 | const int x = x0 >> hs; | |
| 362 | 195274 | const int y = y0 >> vs; | |
| 363 | 195274 | const int w = width >> hs; | |
| 364 | 195274 | const int h = height >> vs; | |
| 365 | int a[2], b[2], k[2]; | ||
| 366 | |||
| 367 | pixel dsy[MAX_TB_SIZE * MAX_TB_SIZE]; | ||
| 368 |
4/4✓ Branch 0 taken 3670 times.
✓ Branch 1 taken 93967 times.
✓ Branch 2 taken 291 times.
✓ Branch 3 taken 3379 times.
|
195274 | if (!avail_t && !avail_l) { |
| 369 | 582 | FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l); | |
| 370 | 582 | return; | |
| 371 | } | ||
| 372 | 194692 | FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy); | |
| 373 | 194692 | FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k); | |
| 374 | 194692 | FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k); | |
| 375 | } | ||
| 376 | |||
| 377 | 40890 | static int FUNC(lmcs_sum_samples)(const pixel *start, ptrdiff_t stride, const int avail, const int target_size) | |
| 378 | { | ||
| 379 | 40890 | const int size = FFMIN(avail, target_size); | |
| 380 | 40890 | int sum = 0; | |
| 381 |
2/2✓ Branch 0 taken 1284712 times.
✓ Branch 1 taken 20445 times.
|
2610314 | for (int i = 0; i < size; i++) { |
| 382 | 2569424 | sum += *start; | |
| 383 | 2569424 | start += stride; | |
| 384 | } | ||
| 385 | 40890 | sum += *(start - stride) * (target_size - size); | |
| 386 | 40890 | return sum; | |
| 387 | } | ||
| 388 | |||
| 389 | // 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples | ||
| 390 | 302420 | static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, const int y0) | |
| 391 | { | ||
| 392 | 302420 | VVCFrameContext *fc = lc->fc; | |
| 393 | 302420 | const VVCLMCS *lmcs = &fc->ps.lmcs; | |
| 394 | 302420 | const int size_y = FFMIN(fc->ps.sps->ctb_size_y, 64); | |
| 395 | |||
| 396 | 302420 | const int x = x0 & ~(size_y - 1); | |
| 397 | 302420 | const int y = y0 & ~(size_y - 1); | |
| 398 |
4/4✓ Branch 0 taken 140339 times.
✓ Branch 1 taken 10871 times.
✓ Branch 2 taken 908 times.
✓ Branch 3 taken 139431 times.
|
302420 | if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) { |
| 399 | 23558 | int cnt = 0, luma = 0, i; | |
| 400 | 23558 | const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift)); | |
| 401 | 23558 | const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel); | |
| 402 | 23558 | const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0); | |
| 403 | 23558 | const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0); | |
| 404 |
2/2✓ Branch 0 taken 10454 times.
✓ Branch 1 taken 1325 times.
|
23558 | if (avail_l) { |
| 405 | 20908 | luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y); | |
| 406 | 20908 | cnt = size_y; | |
| 407 | } | ||
| 408 |
2/2✓ Branch 0 taken 9991 times.
✓ Branch 1 taken 1788 times.
|
23558 | if (avail_t) { |
| 409 | 19982 | luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y); | |
| 410 | 19982 | cnt += size_y; | |
| 411 | } | ||
| 412 |
2/2✓ Branch 0 taken 11441 times.
✓ Branch 1 taken 338 times.
|
23558 | if (cnt) |
| 413 | 22882 | luma = (luma + (cnt >> 1)) >> av_log2(cnt); | |
| 414 | else | ||
| 415 | 676 | luma = 1 << (BIT_DEPTH - 1); | |
| 416 | |||
| 417 |
2/2✓ Branch 0 taken 73696 times.
✓ Branch 1 taken 466 times.
|
148324 | for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) { |
| 418 |
2/2✓ Branch 0 taken 11313 times.
✓ Branch 1 taken 62383 times.
|
147392 | if (luma < lmcs->pivot[i + 1]) |
| 419 | 22626 | break; | |
| 420 | } | ||
| 421 | 23558 | i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1); | |
| 422 | |||
| 423 | 23558 | lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i]; | |
| 424 | 23558 | lc->lmcs.x_vpdu = x; | |
| 425 | 23558 | lc->lmcs.y_vpdu = y; | |
| 426 | } | ||
| 427 | 302420 | return lc->lmcs.chroma_scale; | |
| 428 | } | ||
| 429 | |||
| 430 | // 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples | ||
| 431 | 302420 | static void FUNC(lmcs_scale_chroma)(VVCLocalContext *lc, int *coeff, | |
| 432 | const int width, const int height, const int x0_cu, const int y0_cu) | ||
| 433 | { | ||
| 434 | 302420 | const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu); | |
| 435 | |||
| 436 |
2/2✓ Branch 0 taken 1588208 times.
✓ Branch 1 taken 151210 times.
|
3478836 | for (int y = 0; y < height; y++) { |
| 437 |
2/2✓ Branch 0 taken 24846984 times.
✓ Branch 1 taken 1588208 times.
|
52870384 | for (int x = 0; x < width; x++) { |
| 438 | 49693968 | const int c = av_clip_intp2(*coeff, BIT_DEPTH); | |
| 439 | |||
| 440 |
2/2✓ Branch 0 taken 11123275 times.
✓ Branch 1 taken 13723709 times.
|
49693968 | if (c > 0) |
| 441 | 22246550 | *coeff = (c * chroma_scale + (1 << 10)) >> 11; | |
| 442 | else | ||
| 443 | 27447418 | *coeff = -((-c * chroma_scale + (1 << 10)) >> 11); | |
| 444 | 49693968 | coeff++; | |
| 445 | } | ||
| 446 | } | ||
| 447 | 302420 | } | |
| 448 | |||
| 449 | 239662 | static av_always_inline void FUNC(ref_filter)(const pixel *left, const pixel *top, | |
| 450 | pixel *filtered_left, pixel *filtered_top, const int left_size, const int top_size, | ||
| 451 | const int unfilter_last_one) | ||
| 452 | { | ||
| 453 | 239662 | filtered_left[-1] = filtered_top[-1] = (left[0] + 2 * left[-1] + top[0] + 2 ) >> 2; | |
| 454 |
2/2✓ Branch 0 taken 1999119 times.
✓ Branch 1 taken 119831 times.
|
4237900 | for (int i = 0; i < left_size - unfilter_last_one; i++) { |
| 455 | 3998238 | filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2; | |
| 456 | } | ||
| 457 |
2/2✓ Branch 0 taken 2320111 times.
✓ Branch 1 taken 119831 times.
|
4879884 | for (int i = 0; i < top_size - unfilter_last_one; i++) { |
| 458 | 4640222 | filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2; | |
| 459 | } | ||
| 460 |
2/2✓ Branch 0 taken 5437 times.
✓ Branch 1 taken 114394 times.
|
239662 | if (unfilter_last_one) { |
| 461 | 10874 | filtered_top[top_size - 1] = top[top_size - 1]; | |
| 462 | 10874 | filtered_left[left_size - 1] = left[left_size - 1]; | |
| 463 | } | ||
| 464 | 239662 | } | |
| 465 | |||
| 466 | 2222634 | static av_always_inline void FUNC(prepare_intra_edge_params)(const VVCLocalContext *lc, | |
| 467 | IntraEdgeParams* edge, const pixel *src, const ptrdiff_t stride, | ||
| 468 | const int x, int y, int w, int h, int c_idx, const int is_intra_mip, | ||
| 469 | const int mode, const int ref_idx, const int need_pdpc) | ||
| 470 | { | ||
| 471 | #define EXTEND(ptr, val, len) \ | ||
| 472 | do { \ | ||
| 473 | for (i = 0; i < (len); i++) \ | ||
| 474 | *(ptr + i) = val; \ | ||
| 475 | } while (0) | ||
| 476 | 2222634 | const CodingUnit *cu = lc->cu; | |
| 477 |
2/2✓ Branch 0 taken 997918 times.
✓ Branch 1 taken 113399 times.
|
2222634 | const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode); |
| 478 |
4/4✓ Branch 0 taken 550291 times.
✓ Branch 1 taken 516212 times.
✓ Branch 2 taken 380971 times.
✓ Branch 3 taken 169320 times.
|
2133006 | const int filter_flag = !ref_idx && w * h > 32 && !c_idx && |
| 479 |
6/6✓ Branch 0 taken 1066503 times.
✓ Branch 1 taken 44814 times.
✓ Branch 2 taken 324419 times.
✓ Branch 3 taken 56552 times.
✓ Branch 4 taken 119831 times.
✓ Branch 5 taken 204588 times.
|
4355640 | cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag; |
| 480 | 2222634 | int cand_up_left = lc->na.cand_up_left; | |
| 481 | 2222634 | pixel *left = (pixel*)edge->left_array + MAX_TB_SIZE + 3; | |
| 482 | 2222634 | pixel *top = (pixel*)edge->top_array + MAX_TB_SIZE + 3; | |
| 483 | 2222634 | pixel *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3; | |
| 484 | 2222634 | pixel *filtered_top = (pixel*)edge->filtered_top_array + MAX_TB_SIZE + 3; | |
| 485 | 2222634 | const int ref_line = ref_idx == 3 ? -4 : (-1 - ref_idx); | |
| 486 | int left_size, top_size, unfilter_left_size, unfilter_top_size; | ||
| 487 | int left_available, top_available; | ||
| 488 | int refw, refh; | ||
| 489 | int intra_pred_angle, inv_angle; | ||
| 490 | int i; | ||
| 491 | |||
| 492 |
4/4✓ Branch 0 taken 997918 times.
✓ Branch 1 taken 113399 times.
✓ Branch 2 taken 370914 times.
✓ Branch 3 taken 627004 times.
|
2222634 | if (is_intra_mip || mode == INTRA_PLANAR) { |
| 493 | 968626 | left_size = h + 1; | |
| 494 | 968626 | top_size = w + 1; | |
| 495 | 968626 | unfilter_left_size = left_size + filter_flag; | |
| 496 | 968626 | unfilter_top_size = top_size + filter_flag; | |
| 497 |
2/2✓ Branch 0 taken 73844 times.
✓ Branch 1 taken 553160 times.
|
1254008 | } else if (mode == INTRA_DC) { |
| 498 | 147688 | unfilter_left_size = left_size = h; | |
| 499 | 147688 | unfilter_top_size = top_size = w; | |
| 500 |
2/2✓ Branch 0 taken 74985 times.
✓ Branch 1 taken 478175 times.
|
1106320 | } else if (mode == INTRA_VERT) { |
| 501 | //we may need 1 pixel to predict the top left. | ||
| 502 |
2/2✓ Branch 0 taken 59962 times.
✓ Branch 1 taken 15023 times.
|
149970 | unfilter_left_size = left_size = need_pdpc ? h : 1; |
| 503 | 149970 | unfilter_top_size = top_size = w; | |
| 504 |
2/2✓ Branch 0 taken 76806 times.
✓ Branch 1 taken 401369 times.
|
956350 | } else if (mode == INTRA_HORZ) { |
| 505 | 153612 | unfilter_left_size = left_size = h; | |
| 506 | //even need_pdpc == 0, we may need 1 pixel to predict the top left. | ||
| 507 |
2/2✓ Branch 0 taken 57734 times.
✓ Branch 1 taken 19072 times.
|
153612 | unfilter_top_size = top_size = need_pdpc ? w : 1; |
| 508 | } else { | ||
| 509 |
4/4✓ Branch 0 taken 92254 times.
✓ Branch 1 taken 309115 times.
✓ Branch 2 taken 2964 times.
✓ Branch 3 taken 89290 times.
|
802738 | if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) { |
| 510 | 624158 | refw = w * 2; | |
| 511 | 624158 | refh = h * 2; | |
| 512 | } else { | ||
| 513 | 178580 | refw = cu->cb_width + w; | |
| 514 | 178580 | refh = cu->cb_height + h; | |
| 515 | } | ||
| 516 | 802738 | intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
| 517 | 802738 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
| 518 | 802738 | unfilter_top_size = top_size = refw; | |
| 519 | 802738 | unfilter_left_size = left_size = refh; | |
| 520 | } | ||
| 521 | |||
| 522 | 2222634 | left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx); | |
| 523 |
2/2✓ Branch 0 taken 11468204 times.
✓ Branch 1 taken 1111317 times.
|
25159042 | for (i = 0; i < left_available; i++) |
| 524 | 22936408 | left[i] = POS(ref_line, i); | |
| 525 | |||
| 526 | 2222634 | top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx); | |
| 527 | 2222634 | memcpy(top, src + ref_line * stride, top_available * sizeof(pixel)); | |
| 528 | |||
| 529 |
2/2✓ Branch 0 taken 1182555 times.
✓ Branch 1 taken 1111317 times.
|
4587744 | for (int i = -1; i >= ref_line; i--) { |
| 530 |
2/2✓ Branch 0 taken 1130945 times.
✓ Branch 1 taken 51610 times.
|
2365110 | if (cand_up_left) { |
| 531 | 2261890 | left[i] = POS(ref_line, i); | |
| 532 | 2261890 | top[i] = POS(i, ref_line); | |
| 533 |
2/2✓ Branch 0 taken 23615 times.
✓ Branch 1 taken 27995 times.
|
103220 | } else if (left_available) { |
| 534 | 47230 | left[i] = top[i] = left[0]; | |
| 535 |
2/2✓ Branch 0 taken 26961 times.
✓ Branch 1 taken 1034 times.
|
55990 | } else if (top_available) { |
| 536 | 53922 | left[i] = top[i] = top[0]; | |
| 537 | } else { | ||
| 538 | 2068 | left[i] = top[i] = 1 << (BIT_DEPTH - 1); | |
| 539 | } | ||
| 540 | } | ||
| 541 | |||
| 542 |
2/2✓ Branch 0 taken 3637325 times.
✓ Branch 1 taken 1111317 times.
|
9497284 | EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available); |
| 543 |
2/2✓ Branch 0 taken 2796582 times.
✓ Branch 1 taken 1111317 times.
|
7815798 | EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available); |
| 544 | |||
| 545 |
2/2✓ Branch 0 taken 398406 times.
✓ Branch 1 taken 712911 times.
|
2222634 | if (ref_filter_flag) { |
| 546 |
8/8✓ Branch 0 taken 397451 times.
✓ Branch 1 taken 955 times.
✓ Branch 2 taken 221597 times.
✓ Branch 3 taken 175854 times.
✓ Branch 4 taken 146831 times.
✓ Branch 5 taken 74766 times.
✓ Branch 6 taken 119831 times.
✓ Branch 7 taken 27000 times.
|
796812 | if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) { |
| 547 | 239662 | const int unfilter_last_one = left_size == unfilter_left_size; | |
| 548 | 239662 | FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one); | |
| 549 | 239662 | left = filtered_left; | |
| 550 | 239662 | top = filtered_top; | |
| 551 | } | ||
| 552 | } | ||
| 553 |
6/6✓ Branch 0 taken 997918 times.
✓ Branch 1 taken 113399 times.
✓ Branch 2 taken 627004 times.
✓ Branch 3 taken 370914 times.
✓ Branch 4 taken 553160 times.
✓ Branch 5 taken 73844 times.
|
2222634 | if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) { |
| 554 |
6/6✓ Branch 0 taken 525668 times.
✓ Branch 1 taken 27492 times.
✓ Branch 2 taken 487852 times.
✓ Branch 3 taken 37816 times.
✓ Branch 4 taken 111185 times.
✓ Branch 5 taken 376667 times.
|
1106320 | if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) { |
| 555 | 352986 | edge->filter_flag = 0; | |
| 556 | } else { | ||
| 557 | 753334 | const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18)); | |
| 558 | 753334 | const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0}; | |
| 559 | 753334 | const int ntbs = (av_log2(w) + av_log2(h)) >> 1; | |
| 560 | 753334 | edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2]; | |
| 561 | } | ||
| 562 | |||
| 563 |
4/4✓ Branch 0 taken 478175 times.
✓ Branch 1 taken 74985 times.
✓ Branch 2 taken 401369 times.
✓ Branch 3 taken 76806 times.
|
1106320 | if (mode != INTRA_VERT && mode != INTRA_HORZ) { |
| 564 |
2/2✓ Branch 0 taken 209834 times.
✓ Branch 1 taken 191535 times.
|
802738 | if (mode >= INTRA_DIAG) { |
| 565 |
2/2✓ Branch 0 taken 106853 times.
✓ Branch 1 taken 102981 times.
|
419668 | if (intra_pred_angle < 0) { |
| 566 | 213706 | pixel *p = top - (ref_idx + 1); | |
| 567 |
2/2✓ Branch 0 taken 871144 times.
✓ Branch 1 taken 106853 times.
|
1955994 | for (int x = -h; x < 0; x++) { |
| 568 | 1742288 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h); | |
| 569 | 1742288 | p[x] = left[idx]; | |
| 570 | } | ||
| 571 | } else { | ||
| 572 |
2/2✓ Branch 0 taken 224515 times.
✓ Branch 1 taken 102981 times.
|
654992 | for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++) |
| 573 | 449030 | top[i] = top[refw - 1]; | |
| 574 | } | ||
| 575 | } else { | ||
| 576 |
2/2✓ Branch 0 taken 99514 times.
✓ Branch 1 taken 92021 times.
|
383070 | if (intra_pred_angle < 0) { |
| 577 | 199028 | pixel *p = left - (ref_idx + 1); | |
| 578 |
2/2✓ Branch 0 taken 1459692 times.
✓ Branch 1 taken 99514 times.
|
3118412 | for (int x = -w; x < 0; x++) { |
| 579 | 2919384 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w); | |
| 580 | 2919384 | p[x] = top[idx]; | |
| 581 | } | ||
| 582 | } else { | ||
| 583 |
2/2✓ Branch 0 taken 200756 times.
✓ Branch 1 taken 92021 times.
|
585554 | for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++) |
| 584 | 401512 | left[i] = left[refh - 1]; | |
| 585 | } | ||
| 586 | } | ||
| 587 | } | ||
| 588 | } | ||
| 589 | 2222634 | edge->left = (uint8_t*)left; | |
| 590 | 2222634 | edge->top = (uint8_t*)top; | |
| 591 | 2222634 | } | |
| 592 | |||
| 593 | //8.4.1 General decoding process for coding units coded in intra prediction mode | ||
| 594 | 2222634 | static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0, | |
| 595 | const int width, const int height, int c_idx) | ||
| 596 | { | ||
| 597 | 2222634 | VVCFrameContext *fc = lc->fc; | |
| 598 | 2222634 | const VVCSPS *sps = fc->ps.sps; | |
| 599 | 2222634 | const VVCPPS *pps = fc->ps.pps; | |
| 600 | 2222634 | const CodingUnit *cu = lc->cu; | |
| 601 | 2222634 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
| 602 | 2222634 | const int min_cb_width = pps->min_cb_width; | |
| 603 | 2222634 | const int x_cb = x0 >> log2_min_cb_size; | |
| 604 | 2222634 | const int y_cb = y0 >> log2_min_cb_size; | |
| 605 | |||
| 606 | 2222634 | const int hshift = fc->ps.sps->hshift[c_idx]; | |
| 607 | 2222634 | const int vshift = fc->ps.sps->vshift[c_idx]; | |
| 608 | 2222634 | const int x = x0 >> hshift; | |
| 609 | 2222634 | const int y = y0 >> vshift; | |
| 610 | 2222634 | const int w = width >> hshift; | |
| 611 | 2222634 | const int h = height >> vshift; | |
| 612 | 2222634 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
| 613 | |||
| 614 |
2/2✓ Branch 0 taken 336696 times.
✓ Branch 1 taken 774621 times.
|
2222634 | const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y; |
| 615 | 2222634 | const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode); | |
| 616 | |||
| 617 | 2222634 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
| 618 |
6/6✓ Branch 0 taken 167893 times.
✓ Branch 1 taken 943424 times.
✓ Branch 2 taken 56130 times.
✓ Branch 3 taken 111763 times.
✓ Branch 4 taken 1636 times.
✓ Branch 5 taken 54494 times.
|
2222634 | const int is_intra_mip = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag); |
| 619 |
2/2✓ Branch 0 taken 774621 times.
✓ Branch 1 taken 336696 times.
|
2222634 | const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx; |
| 620 | 2222634 | const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx); | |
| 621 | |||
| 622 | |||
| 623 | 2222634 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
| 624 | IntraEdgeParams edge; | ||
| 625 | |||
| 626 | 2222634 | FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc); | |
| 627 | |||
| 628 |
2/2✓ Branch 0 taken 113399 times.
✓ Branch 1 taken 997918 times.
|
2222634 | if (is_intra_mip) { |
| 629 | int intra_mip_transposed_flag; | ||
| 630 | int intra_mip_mode; | ||
| 631 | 226798 | unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag); | |
| 632 | |||
| 633 | 226798 | fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left, | |
| 634 | w, h, stride, intra_mip_mode, intra_mip_transposed_flag); | ||
| 635 |
2/2✓ Branch 0 taken 370914 times.
✓ Branch 1 taken 627004 times.
|
1995836 | } else if (mode == INTRA_PLANAR) { |
| 636 | 741828 | fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
| 637 |
2/2✓ Branch 0 taken 73844 times.
✓ Branch 1 taken 553160 times.
|
1254008 | } else if (mode == INTRA_DC) { |
| 638 | 147688 | fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
| 639 |
2/2✓ Branch 0 taken 74985 times.
✓ Branch 1 taken 478175 times.
|
1106320 | } else if (mode == INTRA_VERT) { |
| 640 | 149970 | fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride); | |
| 641 |
2/2✓ Branch 0 taken 76806 times.
✓ Branch 1 taken 401369 times.
|
956350 | } else if (mode == INTRA_HORZ) { |
| 642 | 153612 | fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride); | |
| 643 | } else { | ||
| 644 |
2/2✓ Branch 0 taken 209834 times.
✓ Branch 1 taken 191535 times.
|
802738 | if (mode >= INTRA_DIAG) { |
| 645 | 419668 | fc->vvcdsp.intra.pred_angular_v((uint8_t *)src, edge.top, edge.left, | |
| 646 | w, h, stride, c_idx, mode, ref_idx, | ||
| 647 | edge.filter_flag, need_pdpc); | ||
| 648 | } else { | ||
| 649 | 383070 | fc->vvcdsp.intra.pred_angular_h((uint8_t *)src, edge.top, edge.left, | |
| 650 | w, h, stride, c_idx, mode, ref_idx, | ||
| 651 | edge.filter_flag, need_pdpc); | ||
| 652 | } | ||
| 653 | } | ||
| 654 |
2/2✓ Branch 0 taken 690803 times.
✓ Branch 1 taken 420514 times.
|
2222634 | if (need_pdpc) { |
| 655 | //8.4.5.2.15 Position-dependent intra prediction sample filtering process | ||
| 656 |
8/8✓ Branch 0 taken 595767 times.
✓ Branch 1 taken 95036 times.
✓ Branch 2 taken 261351 times.
✓ Branch 3 taken 334416 times.
✓ Branch 4 taken 199544 times.
✓ Branch 5 taken 61807 times.
✓ Branch 6 taken 139582 times.
✓ Branch 7 taken 59962 times.
|
1381606 | if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC || |
| 657 |
2/2✓ Branch 0 taken 57734 times.
✓ Branch 1 taken 81848 times.
|
279164 | mode == INTRA_VERT || mode == INTRA_HORZ)) { |
| 658 | 1027838 | const int scale = (av_log2(w) + av_log2(h) - 2) >> 2; | |
| 659 | 1027838 | const pixel *left = (pixel*)edge.left; | |
| 660 | 1027838 | const pixel *top = (pixel*)edge.top; | |
| 661 |
2/2✓ Branch 0 taken 5459076 times.
✓ Branch 1 taken 513919 times.
|
11945990 | for (int y = 0; y < h; y++) { |
| 662 |
2/2✓ Branch 0 taken 89642640 times.
✓ Branch 1 taken 5459076 times.
|
190203432 | for (int x = 0; x < w; x++) { |
| 663 | int l, t, wl, wt, pred; | ||
| 664 | pixel val; | ||
| 665 |
4/4✓ Branch 0 taken 29119840 times.
✓ Branch 1 taken 60522800 times.
✓ Branch 2 taken 10163712 times.
✓ Branch 3 taken 18956128 times.
|
179285280 | if (mode == INTRA_PLANAR || mode == INTRA_DC) { |
| 666 | 141373024 | l = left[y]; | |
| 667 | 141373024 | t = top[x]; | |
| 668 | 141373024 | wl = 32 >> FFMIN((x << 1) >> scale, 31); | |
| 669 | 141373024 | wt = 32 >> FFMIN((y << 1) >> scale, 31); | |
| 670 | } else { | ||
| 671 | 37912256 | l = left[y] - left[-1] + POS(x,y); | |
| 672 | 37912256 | t = top[x] - top[-1] + POS(x,y); | |
| 673 |
2/2✓ Branch 0 taken 8418096 times.
✓ Branch 1 taken 10538032 times.
|
37912256 | wl = (mode == INTRA_VERT) ? (32 >> FFMIN((x << 1) >> scale, 31)) : 0; |
| 674 |
2/2✓ Branch 0 taken 10538032 times.
✓ Branch 1 taken 8418096 times.
|
37912256 | wt = (mode == INTRA_HORZ) ? (32 >> FFMIN((y << 1) >> scale, 31)) : 0; |
| 675 | } | ||
| 676 | 179285280 | val = POS(x, y); | |
| 677 | 179285280 | pred = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6); | |
| 678 | 179285280 | POS(x, y) = CLIP(pred); | |
| 679 | } | ||
| 680 | } | ||
| 681 | } | ||
| 682 | } | ||
| 683 | 2222634 | } | |
| 684 | |||
| 685 | //8.4.5.2.11 Specification of INTRA_PLANAR intra prediction mode | ||
| 686 | 741828 | static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top, | |
| 687 | const uint8_t *_left, const int w, const int h, const ptrdiff_t stride) | ||
| 688 | { | ||
| 689 | int x, y; | ||
| 690 | 741828 | pixel *src = (pixel *)_src; | |
| 691 | 741828 | const pixel *top = (const pixel *)_top; | |
| 692 | 741828 | const pixel *left = (const pixel *)_left; | |
| 693 | 741828 | const int logw = av_log2(w); | |
| 694 | 741828 | const int logh = av_log2(h); | |
| 695 | 741828 | const int size = w * h; | |
| 696 | 741828 | const int shift = (logw + logh + 1); | |
| 697 |
2/2✓ Branch 0 taken 3658348 times.
✓ Branch 1 taken 370914 times.
|
8058524 | for (y = 0; y < h; y++) { |
| 698 |
2/2✓ Branch 0 taken 61444336 times.
✓ Branch 1 taken 3658348 times.
|
130205368 | for (x = 0; x < w; x++) { |
| 699 | 122888672 | const int pred_v = ((h - 1 - y) * top[x] + (y + 1) * left[h]) << logw; | |
| 700 | 122888672 | const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh; | |
| 701 | 122888672 | const int pred = (pred_v + pred_h + size) >> shift; | |
| 702 | 122888672 | POS(x, y) = pred; | |
| 703 | } | ||
| 704 | } | ||
| 705 | 741828 | } | |
| 706 | |||
| 707 | //8.4.5.2.3 MIP boundary sample downsampling process | ||
| 708 | 453596 | static av_always_inline void FUNC(mip_downsampling)(int *reduced, const int boundary_size, | |
| 709 | const pixel *ref, const int n_tb_s) | ||
| 710 | { | ||
| 711 | 453596 | const int b_dwn = n_tb_s / boundary_size; | |
| 712 | 453596 | const int log2 = av_log2(b_dwn); | |
| 713 | |||
| 714 |
2/2✓ Branch 0 taken 40952 times.
✓ Branch 1 taken 185846 times.
|
453596 | if (boundary_size == n_tb_s) { |
| 715 |
2/2✓ Branch 0 taken 163808 times.
✓ Branch 1 taken 40952 times.
|
409520 | for (int i = 0; i < n_tb_s; i++) |
| 716 | 327616 | reduced[i] = ref[i]; | |
| 717 | 81904 | return; | |
| 718 | } | ||
| 719 |
2/2✓ Branch 0 taken 677528 times.
✓ Branch 1 taken 185846 times.
|
1726748 | for (int i = 0; i < boundary_size; i++) { |
| 720 | int r; | ||
| 721 | 1355056 | r = *ref++; | |
| 722 |
2/2✓ Branch 0 taken 1895200 times.
✓ Branch 1 taken 677528 times.
|
5145456 | for (int j = 1; j < b_dwn; j++) |
| 723 | 3790400 | r += *ref++; | |
| 724 | 1355056 | reduced[i] = (r + (1 << (log2 - 1))) >> log2; | |
| 725 | } | ||
| 726 | } | ||
| 727 | |||
| 728 | 226798 | static av_always_inline void FUNC(mip_reduced_pred)(pixel *src, const ptrdiff_t stride, | |
| 729 | const int up_hor, const int up_ver, const int pred_size, const int *reduced, const int reduced_size, | ||
| 730 | const int ow, const int temp0, const uint8_t *matrix, int is_transposed) | ||
| 731 | { | ||
| 732 | 226798 | src = &POS(up_hor - 1, up_ver - 1); | |
| 733 |
2/2✓ Branch 0 taken 633780 times.
✓ Branch 1 taken 113399 times.
|
1494358 | for (int y = 0; y < pred_size; y++) { |
| 734 |
2/2✓ Branch 0 taken 3976592 times.
✓ Branch 1 taken 633780 times.
|
9220744 | for (int x = 0; x < pred_size; x++) { |
| 735 | 7953184 | int pred = 0; | |
| 736 |
2/2✓ Branch 0 taken 27876096 times.
✓ Branch 1 taken 3976592 times.
|
63705376 | for (int i = 0; i < reduced_size; i++) |
| 737 | 55752192 | pred += reduced[i] * matrix[i]; | |
| 738 | 7953184 | matrix += reduced_size; | |
| 739 | 7953184 | pred = ((pred + ow) >> 6) + temp0; | |
| 740 | 7953184 | pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1); | |
| 741 |
2/2✓ Branch 0 taken 2000656 times.
✓ Branch 1 taken 1975936 times.
|
7953184 | if (is_transposed) |
| 742 | 4001312 | POS(y * up_hor, x * up_ver) = pred; | |
| 743 | else | ||
| 744 | 3951872 | POS(x * up_hor, y * up_ver) = pred; | |
| 745 | } | ||
| 746 | } | ||
| 747 | 226798 | } | |
| 748 | |||
| 749 | 258378 | static av_always_inline void FUNC(mip_upsampling_1d)(pixel *dst, const int dst_step, const int dst_stride, const int dst_height, const int factor, | |
| 750 | const pixel *boundary, const int boundary_step, const int pred_size) | ||
| 751 | { | ||
| 752 | |||
| 753 |
2/2✓ Branch 0 taken 1229436 times.
✓ Branch 1 taken 129189 times.
|
2717250 | for (int i = 0; i < dst_height; i++) { |
| 754 | 2458872 | const pixel *before = boundary; | |
| 755 | 2458872 | const pixel *after = dst - dst_step; | |
| 756 | 2458872 | pixel *d = dst; | |
| 757 |
2/2✓ Branch 0 taken 8655280 times.
✓ Branch 1 taken 1229436 times.
|
19769432 | for (int j = 0; j < pred_size; j++) { |
| 758 | 17310560 | after += dst_step * factor; | |
| 759 |
2/2✓ Branch 0 taken 18341424 times.
✓ Branch 1 taken 8655280 times.
|
53993408 | for (int k = 1; k < factor; k++) { |
| 760 | 36682848 | int mid = (factor - k) * (*before) + k * (*after); | |
| 761 | 36682848 | *d = (mid + factor / 2) / factor; | |
| 762 | 36682848 | d += dst_step; | |
| 763 | } | ||
| 764 | 17310560 | before = after; | |
| 765 | 17310560 | d += dst_step; | |
| 766 | } | ||
| 767 | 2458872 | boundary += boundary_step; | |
| 768 | 2458872 | dst += dst_stride; | |
| 769 | } | ||
| 770 | 258378 | } | |
| 771 | |||
| 772 | //8.4.5.2.2 Matrix-based intra sample prediction | ||
| 773 | 226798 | static av_always_inline void FUNC(pred_mip)(uint8_t *_src, const uint8_t *_top, | |
| 774 | const uint8_t *_left, const int w, const int h, const ptrdiff_t stride, | ||
| 775 | int mode_id, int is_transposed) | ||
| 776 | { | ||
| 777 | 226798 | pixel *src = (pixel *)_src; | |
| 778 | 226798 | const pixel *top = (const pixel *)_top; | |
| 779 | 226798 | const pixel *left = (const pixel *)_left; | |
| 780 | |||
| 781 | 226798 | const int size_id = ff_vvc_get_mip_size_id(w, h); | |
| 782 | static const int boundary_sizes[] = {2, 4, 4}; | ||
| 783 | static const int pred_sizes[] = {4, 4, 8}; | ||
| 784 | 226798 | const int boundary_size = boundary_sizes[size_id]; | |
| 785 | 226798 | const int pred_size = pred_sizes[size_id]; | |
| 786 | 226798 | const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0); | |
| 787 | 226798 | const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id); | |
| 788 | 226798 | const int up_hor = w / pred_size; | |
| 789 | 226798 | const int up_ver = h / pred_size; | |
| 790 | |||
| 791 | int reduced[16]; | ||
| 792 | 226798 | int *red_t = reduced; | |
| 793 | 226798 | int *red_l = reduced + boundary_size; | |
| 794 | 226798 | int off = 1, ow = 0; | |
| 795 | int temp0; | ||
| 796 | |||
| 797 |
2/2✓ Branch 0 taken 57817 times.
✓ Branch 1 taken 55582 times.
|
226798 | if (is_transposed) { |
| 798 | 115634 | FFSWAP(int*, red_t, red_l); | |
| 799 | } | ||
| 800 | 226798 | FUNC(mip_downsampling)(red_t, boundary_size, top, w); | |
| 801 | 226798 | FUNC(mip_downsampling)(red_l, boundary_size, left, h); | |
| 802 | |||
| 803 | 226798 | temp0 = reduced[0]; | |
| 804 |
2/2✓ Branch 0 taken 68353 times.
✓ Branch 1 taken 45046 times.
|
226798 | if (size_id != 2) { |
| 805 | 136706 | off = 0; | |
| 806 | 136706 | ow = (1 << (BIT_DEPTH - 1)) - temp0; | |
| 807 | } else { | ||
| 808 | 90092 | ow = reduced[1] - temp0; | |
| 809 | } | ||
| 810 | 226798 | reduced[0] = ow; | |
| 811 |
2/2✓ Branch 0 taken 682891 times.
✓ Branch 1 taken 113399 times.
|
1592580 | for (int i = 1; i < in_size; i++) { |
| 812 | 1365782 | reduced[i] = reduced[i + off] - temp0; | |
| 813 | 1365782 | ow += reduced[i]; | |
| 814 | } | ||
| 815 | 226798 | ow = 32 - 32 * ow; | |
| 816 | |||
| 817 | 226798 | FUNC(mip_reduced_pred)(src, stride, up_hor, up_ver, pred_size, reduced, in_size, ow, temp0, matrix, is_transposed); | |
| 818 |
4/4✓ Branch 0 taken 40544 times.
✓ Branch 1 taken 72855 times.
✓ Branch 2 taken 24080 times.
✓ Branch 3 taken 16464 times.
|
226798 | if (up_hor > 1 || up_ver > 1) { |
| 819 |
2/2✓ Branch 0 taken 72855 times.
✓ Branch 1 taken 24080 times.
|
193870 | if (up_hor > 1) |
| 820 | 145710 | FUNC(mip_upsampling_1d)(&POS(0, up_ver - 1), 1, up_ver * stride, pred_size, up_hor, left + up_ver - 1, up_ver, pred_size); | |
| 821 |
2/2✓ Branch 0 taken 56334 times.
✓ Branch 1 taken 40601 times.
|
193870 | if (up_ver > 1) |
| 822 | 112668 | FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size); | |
| 823 | } | ||
| 824 | 226798 | } | |
| 825 | |||
| 826 | 147688 | static av_always_inline pixel FUNC(pred_dc_val)(const pixel *top, const pixel *left, | |
| 827 | const int w, const int h) | ||
| 828 | { | ||
| 829 | pixel dc_val; | ||
| 830 | 147688 | int sum = 0; | |
| 831 |
2/2✓ Branch 0 taken 25642 times.
✓ Branch 1 taken 48202 times.
|
147688 | unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h); |
| 832 | 147688 | const int shift = av_log2(offset); | |
| 833 | 147688 | offset >>= 1; | |
| 834 |
2/2✓ Branch 0 taken 56870 times.
✓ Branch 1 taken 16974 times.
|
147688 | if (w >= h) { |
| 835 |
2/2✓ Branch 0 taken 799408 times.
✓ Branch 1 taken 56870 times.
|
1712556 | for (int i = 0; i < w; i++) |
| 836 | 1598816 | sum += top[i]; | |
| 837 | } | ||
| 838 |
2/2✓ Branch 0 taken 42616 times.
✓ Branch 1 taken 31228 times.
|
147688 | if (w <= h) { |
| 839 |
2/2✓ Branch 0 taken 512680 times.
✓ Branch 1 taken 42616 times.
|
1110592 | for (int i = 0; i < h; i++) |
| 840 | 1025360 | sum += left[i]; | |
| 841 | } | ||
| 842 | 147688 | dc_val = (sum + offset) >> shift; | |
| 843 | 147688 | return dc_val; | |
| 844 | } | ||
| 845 | |||
| 846 | //8.4.5.2.12 Specification of INTRA_DC intra prediction mode | ||
| 847 | 147688 | static av_always_inline void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top, | |
| 848 | const uint8_t *_left, const int w, const int h, const ptrdiff_t stride) | ||
| 849 | { | ||
| 850 | int x, y; | ||
| 851 | 147688 | pixel *src = (pixel *)_src; | |
| 852 | 147688 | const pixel *top = (const pixel *)_top; | |
| 853 | 147688 | const pixel *left = (const pixel *)_left; | |
| 854 | 147688 | const pixel dc = FUNC(pred_dc_val)(top, left, w, h); | |
| 855 | 147688 | const pixel4 a = PIXEL_SPLAT_X4(dc); | |
| 856 |
2/2✓ Branch 0 taken 683736 times.
✓ Branch 1 taken 73844 times.
|
1515160 | for (y = 0; y < h; y++) { |
| 857 | 1367472 | pixel *s = src; | |
| 858 |
2/2✓ Branch 0 taken 2769768 times.
✓ Branch 1 taken 683736 times.
|
6907008 | for (x = 0; x < w; x += 4) { |
| 859 | 5539536 | AV_WN4P(s, a); | |
| 860 | 5539536 | s += 4; | |
| 861 | } | ||
| 862 | 1367472 | src += stride; | |
| 863 | } | ||
| 864 | 147688 | } | |
| 865 | |||
| 866 | 149970 | static av_always_inline void FUNC(pred_v)(uint8_t *_src, const uint8_t *_top, | |
| 867 | const int w, const int h, const ptrdiff_t stride) | ||
| 868 | { | ||
| 869 | 149970 | pixel *src = (pixel *)_src; | |
| 870 | 149970 | const pixel *top = (const pixel *)_top; | |
| 871 |
2/2✓ Branch 0 taken 766840 times.
✓ Branch 1 taken 74985 times.
|
1683650 | for (int y = 0; y < h; y++) { |
| 872 | 1533680 | memcpy(src, top, sizeof(pixel) * w); | |
| 873 | 1533680 | src += stride; | |
| 874 | } | ||
| 875 | 149970 | } | |
| 876 | |||
| 877 | 153612 | static void FUNC(pred_h)(uint8_t *_src, const uint8_t *_left, const int w, const int h, | |
| 878 | const ptrdiff_t stride) | ||
| 879 | { | ||
| 880 | 153612 | pixel *src = (pixel *)_src; | |
| 881 | 153612 | const pixel *left = (const pixel *)_left; | |
| 882 |
2/2✓ Branch 0 taken 704372 times.
✓ Branch 1 taken 76806 times.
|
1562356 | for (int y = 0; y < h; y++) { |
| 883 | 1408744 | const pixel4 a = PIXEL_SPLAT_X4(left[y]); | |
| 884 |
2/2✓ Branch 0 taken 3049444 times.
✓ Branch 1 taken 704372 times.
|
7507632 | for (int x = 0; x < w; x += 4) { |
| 885 | 6098888 | AV_WN4P(&POS(x, y), a); | |
| 886 | } | ||
| 887 | } | ||
| 888 | 153612 | } | |
| 889 | |||
| 890 | #define INTRA_LUMA_FILTER(p) CLIP((p[0] * f[0] + p[1] * f[1] + p[2] * f[2] + p[3] * f[3] + 32) >> 6) | ||
| 891 | #define INTRA_CHROMA_FILTER(p) (((32 - fact) * p[1] + fact * p[2] + 16) >> 5) | ||
| 892 | |||
| 893 | //8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes | ||
| 894 | 419668 | static void FUNC(pred_angular_v)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, | |
| 895 | const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode, | ||
| 896 | const int ref_idx, const int filter_flag, const int need_pdpc) | ||
| 897 | { | ||
| 898 | 419668 | pixel *src = (pixel *)_src; | |
| 899 | 419668 | const pixel *left = (const pixel *)_left; | |
| 900 | 419668 | const pixel *top = (const pixel *)_top - (1 + ref_idx); | |
| 901 | 419668 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
| 902 | 419668 | int pos = (1 + ref_idx) * intra_pred_angle; | |
| 903 | 419668 | const int dp = intra_pred_angle; | |
| 904 | 419668 | const int is_luma = !c_idx; | |
| 905 | int nscale, inv_angle; | ||
| 906 | |||
| 907 |
2/2✓ Branch 0 taken 44386 times.
✓ Branch 1 taken 165448 times.
|
419668 | if (need_pdpc) { |
| 908 | 88772 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
| 909 | 88772 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
| 910 | } | ||
| 911 | |||
| 912 |
2/2✓ Branch 0 taken 1595368 times.
✓ Branch 1 taken 209834 times.
|
3610404 | for (int y = 0; y < h; y++) { |
| 913 | 3190736 | const int idx = (pos >> 5) + ref_idx; | |
| 914 | 3190736 | const int fact = pos & 31; | |
| 915 |
6/6✓ Branch 0 taken 245849 times.
✓ Branch 1 taken 1349519 times.
✓ Branch 2 taken 152279 times.
✓ Branch 3 taken 93570 times.
✓ Branch 4 taken 127675 times.
✓ Branch 5 taken 24604 times.
|
3190736 | if (!fact && (!is_luma || !filter_flag)) { |
| 916 |
2/2✓ Branch 0 taken 2323072 times.
✓ Branch 1 taken 221245 times.
|
5088634 | for (int x = 0; x < w; x++) { |
| 917 | 4646144 | const pixel *p = top + x + idx + 1; | |
| 918 | 4646144 | POS(x, y) = *p; | |
| 919 | } | ||
| 920 | } else { | ||
| 921 |
2/2✓ Branch 0 taken 1081713 times.
✓ Branch 1 taken 292410 times.
|
2748246 | if (!c_idx) { |
| 922 | 2163426 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
| 923 |
2/2✓ Branch 0 taken 11835448 times.
✓ Branch 1 taken 1081713 times.
|
25834322 | for (int x = 0; x < w; x++) { |
| 924 | 23670896 | const pixel *p = top + x + idx; | |
| 925 | 23670896 | POS(x, y) = INTRA_LUMA_FILTER(p); | |
| 926 | } | ||
| 927 | } else { | ||
| 928 |
2/2✓ Branch 0 taken 2701336 times.
✓ Branch 1 taken 292410 times.
|
5987492 | for (int x = 0; x < w; x++) { |
| 929 | 5402672 | const pixel *p = top + x + idx; | |
| 930 | 5402672 | POS(x, y) = INTRA_CHROMA_FILTER(p); | |
| 931 | } | ||
| 932 | } | ||
| 933 | } | ||
| 934 |
2/2✓ Branch 0 taken 386428 times.
✓ Branch 1 taken 1208940 times.
|
3190736 | if (need_pdpc) { |
| 935 | 772856 | int inv_angle_sum = 256 + inv_angle; | |
| 936 |
2/2✓ Branch 0 taken 2095192 times.
✓ Branch 1 taken 386428 times.
|
4963240 | for (int x = 0; x < FFMIN(w, 3 << nscale); x++) { |
| 937 | 4190384 | const pixel l = left[y + (inv_angle_sum >> 9)]; | |
| 938 | 4190384 | const pixel val = POS(x, y); | |
| 939 | 4190384 | const int wl = 32 >> ((x << 1) >> nscale); | |
| 940 | 4190384 | const int pred = val + (((l - val) * wl + 32) >> 6); | |
| 941 | 4190384 | POS(x, y) = CLIP(pred); | |
| 942 | 4190384 | inv_angle_sum += inv_angle; | |
| 943 | } | ||
| 944 | } | ||
| 945 | 3190736 | pos += dp; | |
| 946 | } | ||
| 947 | 419668 | } | |
| 948 | |||
| 949 | //8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes | ||
| 950 | 383070 | static void FUNC(pred_angular_h)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, | |
| 951 | const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode, | ||
| 952 | const int ref_idx, const int filter_flag, const int need_pdpc) | ||
| 953 | { | ||
| 954 | 383070 | pixel *src = (pixel *)_src; | |
| 955 | 383070 | const pixel *left = (const pixel *)_left - (1 + ref_idx); | |
| 956 | 383070 | const pixel *top = (const pixel *)_top; | |
| 957 | 383070 | const int is_luma = !c_idx; | |
| 958 | 383070 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
| 959 | 383070 | const int dp = intra_pred_angle; | |
| 960 | 383070 | int nscale = 0, inv_angle, inv_angle_sum; | |
| 961 | |||
| 962 |
2/2✓ Branch 0 taken 37462 times.
✓ Branch 1 taken 154073 times.
|
383070 | if (need_pdpc) { |
| 963 | 74924 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
| 964 | 74924 | inv_angle_sum = 256 + inv_angle; | |
| 965 | 74924 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
| 966 | } | ||
| 967 | |||
| 968 |
2/2✓ Branch 0 taken 1537992 times.
✓ Branch 1 taken 191535 times.
|
3459054 | for (int y = 0; y < h; y++) { |
| 969 | 3075984 | int pos = (1 + ref_idx) * intra_pred_angle; | |
| 970 | int wt; | ||
| 971 |
2/2✓ Branch 0 taken 420720 times.
✓ Branch 1 taken 1117272 times.
|
3075984 | if (need_pdpc) |
| 972 | 841440 | wt = (32 >> FFMIN(31, (y * 2) >> nscale)); | |
| 973 | |||
| 974 |
2/2✓ Branch 0 taken 22115536 times.
✓ Branch 1 taken 1537992 times.
|
47307056 | for (int x = 0; x < w; x++) { |
| 975 | 44231072 | const int idx = (pos >> 5) + ref_idx; | |
| 976 | 44231072 | const int fact = pos & 31; | |
| 977 | 44231072 | const pixel *p = left + y + idx; | |
| 978 | int pred; | ||
| 979 |
6/6✓ Branch 0 taken 2075156 times.
✓ Branch 1 taken 20040380 times.
✓ Branch 2 taken 1669260 times.
✓ Branch 3 taken 405896 times.
✓ Branch 4 taken 986940 times.
✓ Branch 5 taken 682320 times.
|
44231072 | if (!fact && (!is_luma || !filter_flag)) { |
| 980 | 2785672 | pred = p[1]; | |
| 981 | } else { | ||
| 982 |
2/2✓ Branch 0 taken 15895316 times.
✓ Branch 1 taken 4827384 times.
|
41445400 | if (!c_idx) { |
| 983 | 31790632 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
| 984 | 31790632 | pred = INTRA_LUMA_FILTER(p); | |
| 985 | } else { | ||
| 986 | 9654768 | pred = INTRA_CHROMA_FILTER(p); | |
| 987 | } | ||
| 988 | } | ||
| 989 |
2/2✓ Branch 0 taken 5118560 times.
✓ Branch 1 taken 16996976 times.
|
44231072 | if (need_pdpc) { |
| 990 |
2/2✓ Branch 0 taken 1979384 times.
✓ Branch 1 taken 3139176 times.
|
10237120 | if (y < (3 << nscale)) { |
| 991 | 3958768 | const pixel t = top[x + (inv_angle_sum >> 9)]; | |
| 992 | 3958768 | pred = CLIP(pred + (((t - pred) * wt + 32) >> 6)); | |
| 993 | } | ||
| 994 | } | ||
| 995 | 44231072 | POS(x, y) = pred; | |
| 996 | 44231072 | pos += dp; | |
| 997 | } | ||
| 998 |
2/2✓ Branch 0 taken 420720 times.
✓ Branch 1 taken 1117272 times.
|
3075984 | if (need_pdpc) |
| 999 | 841440 | inv_angle_sum += inv_angle; | |
| 1000 | } | ||
| 1001 | 383070 | } | |
| 1002 | |||
| 1003 | 3084 | static void FUNC(ff_vvc_intra_dsp_init)(VVCIntraDSPContext *const intra) | |
| 1004 | { | ||
| 1005 | 3084 | intra->lmcs_scale_chroma = FUNC(lmcs_scale_chroma); | |
| 1006 | 3084 | intra->intra_cclm_pred = FUNC(intra_cclm_pred); | |
| 1007 | 3084 | intra->intra_pred = FUNC(intra_pred); | |
| 1008 | 3084 | intra->pred_planar = FUNC(pred_planar); | |
| 1009 | 3084 | intra->pred_mip = FUNC(pred_mip); | |
| 1010 | 3084 | intra->pred_dc = FUNC(pred_dc); | |
| 1011 | 3084 | intra->pred_v = FUNC(pred_v); | |
| 1012 | 3084 | intra->pred_h = FUNC(pred_h); | |
| 1013 | 3084 | intra->pred_angular_v = FUNC(pred_angular_v); | |
| 1014 | 3084 | intra->pred_angular_h = FUNC(pred_angular_h); | |
| 1015 | 3084 | } | |
| 1016 |