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 | 122138 | 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 | 122138 | const VVCSPS *sps = fc->ps.sps; | |
33 |
2/2✓ Branch 0 taken 122138 times.
✓ Branch 1 taken 61069 times.
|
366414 | for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) { |
34 | 244276 | const int c_idx = i + 1; | |
35 | 244276 | const int x = x0 >> sps->hshift[c_idx]; | |
36 | 244276 | const int y = y0 >> sps->vshift[c_idx]; | |
37 | 244276 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
38 | 244276 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
39 |
2/2✓ Branch 0 taken 1243204 times.
✓ Branch 1 taken 122138 times.
|
2730684 | for (int y = 0; y < h; y++) { |
40 |
2/2✓ Branch 0 taken 20117088 times.
✓ Branch 1 taken 1243204 times.
|
42720584 | for (int x = 0; x < w; x++) { |
41 | 40234176 | const int dsy = pdsy[y * w + x]; | |
42 | 40234176 | const int pred = ((dsy * a[i]) >> k[i]) + b[i]; | |
43 | 40234176 | POS(x, y) = CLIP(pred); | |
44 | } | ||
45 | } | ||
46 | } | ||
47 | 122138 | } | |
48 | |||
49 | #define MAX_PICK_POS 4 | ||
50 | #define TOP 0 | ||
51 | #define LEFT 1 | ||
52 | |||
53 | 636 | static av_always_inline void FUNC(cclm_get_params_default)(int *a, int *b, int *k) | |
54 | { | ||
55 |
2/2✓ Branch 0 taken 636 times.
✓ Branch 1 taken 318 times.
|
1908 | for (int i = 0; i < 2; i++) { |
56 | 1272 | a[i] = k[i] = 0; | |
57 | 1272 | b[i] = 1 << (BIT_DEPTH - 1); | |
58 | } | ||
59 | 636 | } | |
60 | |||
61 | 122138 | 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 | 122138 | const enum IntraPredMode mode = lc->cu->intra_pred_mode_c; | |
66 |
6/6✓ Branch 0 taken 58874 times.
✓ Branch 1 taken 2195 times.
✓ Branch 2 taken 57399 times.
✓ Branch 3 taken 1475 times.
✓ Branch 4 taken 23755 times.
✓ Branch 5 taken 33644 times.
|
122138 | const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM; |
67 | int num_samp[2]; | ||
68 | |||
69 |
2/2✓ Branch 0 taken 36483 times.
✓ Branch 1 taken 24586 times.
|
122138 | if (mode == INTRA_LT_CCLM) { |
70 |
2/2✓ Branch 0 taken 34718 times.
✓ Branch 1 taken 1765 times.
|
72966 | num_samp[TOP] = avail_t ? w : 0; |
71 |
2/2✓ Branch 0 taken 35409 times.
✓ Branch 1 taken 1074 times.
|
72966 | num_samp[LEFT] = avail_l ? h : 0; |
72 | } else { | ||
73 |
4/4✓ Branch 0 taken 24156 times.
✓ Branch 1 taken 430 times.
✓ Branch 2 taken 12869 times.
✓ Branch 3 taken 11287 times.
|
49172 | 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 24185 times.
✓ Branch 1 taken 401 times.
✓ Branch 2 taken 11399 times.
✓ Branch 3 taken 12786 times.
|
49172 | 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 13482 times.
✓ Branch 1 taken 47587 times.
✓ Branch 2 taken 318 times.
✓ Branch 3 taken 13164 times.
|
122138 | if (!num_samp[TOP] && !num_samp[LEFT]) { |
77 | 636 | return 0; | |
78 | } | ||
79 |
2/2✓ Branch 0 taken 121502 times.
✓ Branch 1 taken 60751 times.
|
364506 | for (int i = TOP; i <= LEFT; i++) { |
80 | 243004 | const int start = num_samp[i] >> (2 + num_is4); | |
81 | 243004 | const int step = FFMAX(1, num_samp[i] >> (1 + num_is4)) ; | |
82 | 243004 | cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1); | |
83 |
2/2✓ Branch 0 taken 242668 times.
✓ Branch 1 taken 121502 times.
|
728340 | for (int c = 0; c < cnt[i]; c++) |
84 | 485336 | pos[i][c] = start + c * step; | |
85 | } | ||
86 | 121502 | return 1; | |
87 | } | ||
88 | |||
89 | 40208 | 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 40208 times.
✓ Branch 1 taken 20104 times.
|
120624 | for (int i = 0; i < cnt; i++) |
93 | 80416 | sel_luma[i] = src[pos[i] * step]; | |
94 | 40208 | } | |
95 | |||
96 | 121502 | 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 | 121502 | const VVCSPS *sps = fc->ps.sps; | |
101 | |||
102 | 121502 | const int b_ctu_boundary = !av_mod_uintp2(y0, sps->ctb_log2_size_y); | |
103 | 121502 | const int hs = sps->hshift[1]; | |
104 | 121502 | const int vs = sps->vshift[1]; | |
105 | 121502 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
106 | |||
107 |
3/4✓ Branch 0 taken 10052 times.
✓ Branch 1 taken 50699 times.
✓ Branch 2 taken 10052 times.
✗ Branch 3 not taken.
|
141606 | if (!hs && !vs) { |
108 | 20104 | const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride; | |
109 | 20104 | FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma); | |
110 | 20104 | FUNC(cclm_select_luma_444)(src - avail_l, stride, cnt[LEFT], pos[LEFT], sel_luma + cnt[TOP]); | |
111 | } else { | ||
112 | // top | ||
113 |
3/4✓ Branch 0 taken 50699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42717 times.
✓ Branch 3 taken 7982 times.
|
186832 | if (vs && !b_ctu_boundary) { |
114 | 85434 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride; | |
115 |
2/2✓ Branch 0 taken 89896 times.
✓ Branch 1 taken 42717 times.
|
265226 | for (int i = 0; i < cnt[TOP]; i++) { |
116 | 179792 | const int x = pos[TOP][i] << hs; | |
117 | 179792 | const pixel *src = source + x; | |
118 |
4/4✓ Branch 0 taken 1336 times.
✓ Branch 1 taken 88560 times.
✓ Branch 2 taken 1223 times.
✓ Branch 3 taken 113 times.
|
179792 | const int has_left = x || avail_l; |
119 |
2/2✓ Branch 0 taken 89783 times.
✓ Branch 1 taken 113 times.
|
179792 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
120 |
2/2✓ Branch 0 taken 3536 times.
✓ Branch 1 taken 86360 times.
|
179792 | if (sps->r->sps_chroma_vertical_collocated_flag) { |
121 | 7072 | 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 86247 times.
✓ Branch 1 taken 113 times.
|
172720 | const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1); |
124 | 172720 | 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 | 15964 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride; | |
129 |
2/2✓ Branch 0 taken 12528 times.
✓ Branch 1 taken 7982 times.
|
41020 | for (int i = 0; i < cnt[TOP]; i++) { |
130 | 25056 | const int x = pos[TOP][i] << hs; | |
131 | 25056 | const pixel *src = source + x; | |
132 |
4/4✓ Branch 0 taken 21 times.
✓ Branch 1 taken 12507 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 19 times.
|
25056 | const int has_left = x || avail_l; |
133 |
2/2✓ Branch 0 taken 12509 times.
✓ Branch 1 taken 19 times.
|
25056 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
134 | 25056 | sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
135 | } | ||
136 | } | ||
137 | |||
138 | // left | ||
139 | { | ||
140 | const pixel *left; | ||
141 | 101398 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l; | |
142 | 101398 | left = source - avail_l; | |
143 | |||
144 |
2/2✓ Branch 0 taken 100036 times.
✓ Branch 1 taken 50699 times.
|
301470 | for (int i = 0; i < cnt[LEFT]; i++) { |
145 | 200072 | const int y = pos[LEFT][i] << vs; | |
146 | 200072 | const int offset = y * stride; | |
147 | 200072 | const pixel *l = left + offset; | |
148 | 200072 | const pixel *src = source + offset; | |
149 | pixel pred; | ||
150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 100036 times.
|
200072 | if (!vs) { |
151 | ✗ | pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
152 | } else { | ||
153 |
2/2✓ Branch 0 taken 4884 times.
✓ Branch 1 taken 95152 times.
|
200072 | if (sps->r->sps_chroma_vertical_collocated_flag) { |
154 |
3/4✓ Branch 0 taken 90 times.
✓ Branch 1 taken 4794 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
|
9768 | const int has_top = y || avail_t; |
155 |
1/2✓ Branch 0 taken 4884 times.
✗ Branch 1 not taken.
|
9768 | const pixel t = has_top ? POS(0, -1) : POS(0, 0); |
156 | 9768 | pred = (*l + t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3; | |
157 | } else { | ||
158 | 190304 | pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
159 | } | ||
160 | } | ||
161 | 200072 | sel_luma[i + cnt[TOP]] = pred; | |
162 | } | ||
163 | } | ||
164 | } | ||
165 | 121502 | } | |
166 | |||
167 | 121502 | 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 121502 times.
✓ Branch 1 taken 60751 times.
|
364506 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
172 | 243004 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
173 | |||
174 | //top | ||
175 | 243004 | const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride; | |
176 |
2/2✓ Branch 0 taken 246120 times.
✓ Branch 1 taken 121502 times.
|
735244 | for (int i = 0; i < cnt[TOP]; i++) { |
177 | 492240 | sel[c_idx][i] = src[pos[TOP][i]]; | |
178 | } | ||
179 | |||
180 | //left | ||
181 | 243004 | src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride; | |
182 |
2/2✓ Branch 0 taken 239216 times.
✓ Branch 1 taken 121502 times.
|
721436 | for (int i = 0; i < cnt[LEFT]; i++) { |
183 | 478432 | sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride]; | |
184 | } | ||
185 | } | ||
186 | 121502 | } | |
187 | |||
188 | 122138 | 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 | 122138 | const VVCFrameContext *fc = lc->fc; | |
193 | 122138 | const VVCSPS *sps = fc->ps.sps; | |
194 | 122138 | const int x = x0 >> sps->hshift[1]; | |
195 | 122138 | const int y = y0 >> sps->vshift[1]; | |
196 | int cnt[2], pos[2][MAX_PICK_POS]; | ||
197 | |||
198 |
2/2✓ Branch 1 taken 318 times.
✓ Branch 2 taken 60751 times.
|
122138 | if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos)) |
199 | 636 | return 0; | |
200 | |||
201 | 121502 | FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]); | |
202 | 121502 | FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel); | |
203 | |||
204 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 60583 times.
|
121502 | if (cnt[TOP] + cnt[LEFT] == 2) { |
205 |
2/2✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
|
1344 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
206 | 1008 | sel[c_idx][3] = sel[c_idx][0]; | |
207 | 1008 | sel[c_idx][2] = sel[c_idx][1]; | |
208 | 1008 | sel[c_idx][0] = sel[c_idx][1]; | |
209 | 1008 | sel[c_idx][1] = sel[c_idx][3]; | |
210 | } | ||
211 | } | ||
212 | 121502 | return 1; | |
213 | } | ||
214 | |||
215 | 121502 | static av_always_inline void FUNC(cclm_get_min_max)( | |
216 | const pixel sel[][MAX_PICK_POS * 2], int *min, int *max) | ||
217 | { | ||
218 | 121502 | int min_grp_idx[] = { 0, 2 }; | |
219 | 121502 | int max_grp_idx[] = { 1, 3 }; | |
220 | |||
221 |
2/2✓ Branch 0 taken 29633 times.
✓ Branch 1 taken 31118 times.
|
121502 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]]) |
222 | 59266 | FFSWAP(int, min_grp_idx[0], min_grp_idx[1]); | |
223 |
2/2✓ Branch 0 taken 30160 times.
✓ Branch 1 taken 30591 times.
|
121502 | if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) |
224 | 60320 | FFSWAP(int, max_grp_idx[0], max_grp_idx[1]); | |
225 |
2/2✓ Branch 0 taken 6287 times.
✓ Branch 1 taken 54464 times.
|
121502 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) { |
226 | 12574 | FFSWAP(int, min_grp_idx[0], max_grp_idx[0]); | |
227 | 12574 | FFSWAP(int, min_grp_idx[1], max_grp_idx[1]); | |
228 | } | ||
229 |
2/2✓ Branch 0 taken 46742 times.
✓ Branch 1 taken 14009 times.
|
121502 | if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]]) |
230 | 93484 | FFSWAP(int, min_grp_idx[1], max_grp_idx[0]); | |
231 |
2/2✓ Branch 0 taken 182253 times.
✓ Branch 1 taken 60751 times.
|
486008 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
232 | 364506 | max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1; | |
233 | 364506 | min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1; | |
234 | } | ||
235 | 121502 | } | |
236 | |||
237 | 122138 | 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 318 times.
✓ Branch 2 taken 60751 times.
|
122138 | if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) { |
246 | 636 | FUNC(cclm_get_params_default)(a, b, k); | |
247 | 3124 | return; | |
248 | } | ||
249 | |||
250 | 121502 | FUNC(cclm_get_min_max)(sel, min, max); | |
251 | |||
252 | 121502 | diff = max[LUMA] - min[LUMA]; | |
253 |
2/2✓ Branch 0 taken 1244 times.
✓ Branch 1 taken 59507 times.
|
121502 | if (diff == 0) { |
254 |
2/2✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 1244 times.
|
7464 | for (int i = 0; i < 2; i++) { |
255 | 4976 | a[i] = k[i] = 0; | |
256 | 4976 | b[i] = min[i + 1]; | |
257 | } | ||
258 | 2488 | return; | |
259 | } | ||
260 |
2/2✓ Branch 0 taken 119014 times.
✓ Branch 1 taken 59507 times.
|
357042 | 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 | 238028 | const int diffc = max[i + 1] - min[i + 1]; | |
263 | 238028 | int x = av_log2(diff); | |
264 | int y, v, sign, add; | ||
265 | 238028 | const int norm_diff = ((diff << 4) >> x) & 15; | |
266 | 238028 | x += (norm_diff) ? 1 : 0; | |
267 |
2/2✓ Branch 0 taken 107677 times.
✓ Branch 1 taken 11337 times.
|
238028 | y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0; |
268 | 238028 | v = div_sig_table[norm_diff] | 8; | |
269 | 238028 | add = (1 << y >> 1); | |
270 | 238028 | a[i] = (diffc * v + add) >> y; | |
271 | 238028 | k[i] = FFMAX(1, 3 + x -y); | |
272 |
2/2✓ Branch 0 taken 50935 times.
✓ Branch 1 taken 68079 times.
|
238028 | sign = a[i] < 0 ? -1 : (a[i] > 0); |
273 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 118952 times.
|
238028 | a[i] = ((3 + x - y) < 1) ? sign * 15 : a[i]; |
274 | 238028 | b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]); | |
275 | } | ||
276 | |||
277 | } | ||
278 | |||
279 | #undef TOP | ||
280 | #undef LEFT | ||
281 | |||
282 | 122138 | 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 | 122138 | const int hs = fc->ps.sps->hshift[1]; | |
287 | 122138 | const int vs = fc->ps.sps->vshift[1]; | |
288 | 122138 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
289 | 122138 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + y0 * stride; | |
290 | 122138 | const pixel *left = source - avail_l; | |
291 | 122138 | const pixel *top = source - avail_t * stride; | |
292 | |||
293 | 122138 | const VVCSPS *sps = fc->ps.sps; | |
294 |
3/4✓ Branch 0 taken 10054 times.
✓ Branch 1 taken 51015 times.
✓ Branch 2 taken 10054 times.
✗ Branch 3 not taken.
|
122138 | if (!hs && !vs) { |
295 |
2/2✓ Branch 0 taken 137736 times.
✓ Branch 1 taken 10054 times.
|
295580 | for (int i = 0; i < h; i++) |
296 | 275472 | memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel)); | |
297 | 20108 | return; | |
298 | } | ||
299 |
2/2✓ Branch 0 taken 483866 times.
✓ Branch 1 taken 51015 times.
|
1069762 | for (int i = 0; i < h; i++) { |
300 | 967732 | const pixel *src = source; | |
301 | 967732 | const pixel *l = left; | |
302 | 967732 | const pixel *t = top; | |
303 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 483866 times.
|
967732 | if (!vs) { |
304 | ✗ | for (int j = 0; j < w; j++) { | |
305 | ✗ | pixel pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
306 | ✗ | pdsy[i * w + j] = pred; | |
307 | ✗ | src += 2; | |
308 | ✗ | l = src - 1; | |
309 | } | ||
310 | |||
311 | } else { | ||
312 |
2/2✓ Branch 0 taken 41022 times.
✓ Branch 1 taken 442844 times.
|
967732 | if (sps->r->sps_chroma_vertical_collocated_flag) { |
313 |
2/2✓ Branch 0 taken 1001008 times.
✓ Branch 1 taken 41022 times.
|
2084060 | for (int j = 0; j < w; j++) { |
314 | 2002016 | pixel pred = (*l + *t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3; | |
315 | 2002016 | pdsy[i * w + j] = pred; | |
316 | 2002016 | src += 2; | |
317 | 2002016 | t += 2; | |
318 | 2002016 | l = src - 1; | |
319 | } | ||
320 | } else { | ||
321 |
2/2✓ Branch 0 taken 6451632 times.
✓ Branch 1 taken 442844 times.
|
13788952 | for (int j = 0; j < w; j++) { |
322 | 12903264 | pixel pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
323 | |||
324 | 12903264 | pdsy[i * w + j] = pred; | |
325 | 12903264 | src += 2; | |
326 | 12903264 | l = src - 1; | |
327 | } | ||
328 | } | ||
329 | } | ||
330 | 967732 | source += (stride << vs); | |
331 | 967732 | left += (stride << vs); | |
332 | 967732 | top = source - stride; | |
333 | } | ||
334 | } | ||
335 | |||
336 | 388 | 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 388 times.
✓ Branch 1 taken 194 times.
|
1164 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
340 | 776 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
341 | 776 | pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
342 |
2/2✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 388 times.
|
16216 | for (int i = 0; i < h; i++) { |
343 |
2/2✓ Branch 0 taken 211584 times.
✓ Branch 1 taken 7720 times.
|
438608 | for (int j = 0; j < w; j++) { |
344 | 423168 | dst[j] = 1 << (BIT_DEPTH - 1); | |
345 | } | ||
346 | 15440 | dst += stride; | |
347 | } | ||
348 | } | ||
349 | 388 | } | |
350 | |||
351 | //8.4.5.2.14 Specification of INTRA_LT_CCLM, INTRA_L_CCLM and INTRA_T_CCLM intra prediction mode | ||
352 | 122526 | static void FUNC(intra_cclm_pred)(const VVCLocalContext *lc, const int x0, const int y0, | |
353 | const int width, const int height) | ||
354 | { | ||
355 | 122526 | VVCFrameContext *fc = lc->fc; | |
356 | 122526 | const VVCSPS *sps = fc->ps.sps; | |
357 | 122526 | const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0); | |
358 | 122526 | const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0); | |
359 | 122526 | const int hs = sps->hshift[1]; | |
360 | 122526 | const int vs = sps->vshift[1]; | |
361 | 122526 | const int x = x0 >> hs; | |
362 | 122526 | const int y = y0 >> vs; | |
363 | 122526 | const int w = width >> hs; | |
364 | 122526 | 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 2389 times.
✓ Branch 1 taken 58874 times.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 2195 times.
|
122526 | if (!avail_t && !avail_l) { |
369 | 388 | FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l); | |
370 | 388 | return; | |
371 | } | ||
372 | 122138 | FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy); | |
373 | 122138 | FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k); | |
374 | 122138 | FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k); | |
375 | } | ||
376 | |||
377 | 28480 | static int FUNC(lmcs_sum_samples)(const pixel *start, ptrdiff_t stride, const int avail, const int target_size) | |
378 | { | ||
379 | 28480 | const int size = FFMIN(avail, target_size); | |
380 | 28480 | int sum = 0; | |
381 |
2/2✓ Branch 0 taken 897696 times.
✓ Branch 1 taken 14240 times.
|
1823872 | for (int i = 0; i < size; i++) { |
382 | 1795392 | sum += *start; | |
383 | 1795392 | start += stride; | |
384 | } | ||
385 | 28480 | sum += *(start - stride) * (target_size - size); | |
386 | 28480 | return sum; | |
387 | } | ||
388 | |||
389 | // 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples | ||
390 | 170296 | static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, const int y0) | |
391 | { | ||
392 | 170296 | VVCFrameContext *fc = lc->fc; | |
393 | 170296 | const VVCLMCS *lmcs = &fc->ps.lmcs; | |
394 | 170296 | const int size_y = FFMIN(fc->ps.sps->ctb_size_y, 64); | |
395 | |||
396 | 170296 | const int x = x0 & ~(size_y - 1); | |
397 | 170296 | const int y = y0 & ~(size_y - 1); | |
398 |
4/4✓ Branch 0 taken 77773 times.
✓ Branch 1 taken 7375 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 77164 times.
|
170296 | if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) { |
399 | 15968 | int cnt = 0, luma = 0, i; | |
400 | 15968 | const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift)); | |
401 | 15968 | const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel); | |
402 | 15968 | const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0); | |
403 | 15968 | const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0); | |
404 |
2/2✓ Branch 0 taken 7342 times.
✓ Branch 1 taken 642 times.
|
15968 | if (avail_l) { |
405 | 14684 | luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y); | |
406 | 14684 | cnt = size_y; | |
407 | } | ||
408 |
2/2✓ Branch 0 taken 6898 times.
✓ Branch 1 taken 1086 times.
|
15968 | if (avail_t) { |
409 | 13796 | luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y); | |
410 | 13796 | cnt += size_y; | |
411 | } | ||
412 |
2/2✓ Branch 0 taken 7838 times.
✓ Branch 1 taken 146 times.
|
15968 | if (cnt) |
413 | 15676 | luma = (luma + (cnt >> 1)) >> av_log2(cnt); | |
414 | else | ||
415 | 292 | luma = 1 << (BIT_DEPTH - 1); | |
416 | |||
417 |
1/2✓ Branch 0 taken 50387 times.
✗ Branch 1 not taken.
|
100774 | for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) { |
418 |
2/2✓ Branch 0 taken 7984 times.
✓ Branch 1 taken 42403 times.
|
100774 | if (luma < lmcs->pivot[i + 1]) |
419 | 15968 | break; | |
420 | } | ||
421 | 15968 | i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1); | |
422 | |||
423 | 15968 | lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i]; | |
424 | 15968 | lc->lmcs.x_vpdu = x; | |
425 | 15968 | lc->lmcs.y_vpdu = y; | |
426 | } | ||
427 | 170296 | 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 | 170296 | static void FUNC(lmcs_scale_chroma)(VVCLocalContext *lc, int *dst, const int *coeff, | |
432 | const int width, const int height, const int x0_cu, const int y0_cu) | ||
433 | { | ||
434 | 170296 | const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu); | |
435 | |||
436 |
2/2✓ Branch 0 taken 986290 times.
✓ Branch 1 taken 85148 times.
|
2142876 | for (int y = 0; y < height; y++) { |
437 |
2/2✓ Branch 0 taken 16610264 times.
✓ Branch 1 taken 986290 times.
|
35193108 | for (int x = 0; x < width; x++) { |
438 | 33220528 | const int c = av_clip_intp2(*coeff, BIT_DEPTH); | |
439 | |||
440 |
2/2✓ Branch 0 taken 7212755 times.
✓ Branch 1 taken 9397509 times.
|
33220528 | if (c > 0) |
441 | 14425510 | *dst = (c * chroma_scale + (1 << 10)) >> 11; | |
442 | else | ||
443 | 18795018 | *dst = -((-c * chroma_scale + (1 << 10)) >> 11); | |
444 | 33220528 | coeff++; | |
445 | 33220528 | dst++; | |
446 | } | ||
447 | } | ||
448 | 170296 | } | |
449 | |||
450 | 181642 | static av_always_inline void FUNC(ref_filter)(const pixel *left, const pixel *top, | |
451 | pixel *filtered_left, pixel *filtered_top, const int left_size, const int top_size, | ||
452 | const int unfilter_last_one) | ||
453 | { | ||
454 | 181642 | filtered_left[-1] = filtered_top[-1] = (left[0] + 2 * left[-1] + top[0] + 2 ) >> 2; | |
455 |
2/2✓ Branch 0 taken 1538814 times.
✓ Branch 1 taken 90821 times.
|
3259270 | for (int i = 0; i < left_size - unfilter_last_one; i++) { |
456 | 3077628 | filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2; | |
457 | } | ||
458 |
2/2✓ Branch 0 taken 1778282 times.
✓ Branch 1 taken 90821 times.
|
3738206 | for (int i = 0; i < top_size - unfilter_last_one; i++) { |
459 | 3556564 | filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2; | |
460 | } | ||
461 |
2/2✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 87205 times.
|
181642 | if (unfilter_last_one) { |
462 | 7232 | filtered_top[top_size - 1] = top[top_size - 1]; | |
463 | 7232 | filtered_left[left_size - 1] = left[left_size - 1]; | |
464 | } | ||
465 | 181642 | } | |
466 | |||
467 | 1465214 | static av_always_inline void FUNC(prepare_intra_edge_params)(const VVCLocalContext *lc, | |
468 | IntraEdgeParams* edge, const pixel *src, const ptrdiff_t stride, | ||
469 | const int x, int y, int w, int h, int c_idx, const int is_intra_mip, | ||
470 | const int mode, const int ref_idx, const int need_pdpc) | ||
471 | { | ||
472 | #define EXTEND(ptr, val, len) \ | ||
473 | do { \ | ||
474 | for (i = 0; i < (len); i++) \ | ||
475 | *(ptr + i) = val; \ | ||
476 | } while (0) | ||
477 | 1465214 | const CodingUnit *cu = lc->cu; | |
478 |
2/2✓ Branch 0 taken 657368 times.
✓ Branch 1 taken 75239 times.
|
1465214 | const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode); |
479 |
4/4✓ Branch 0 taken 394235 times.
✓ Branch 1 taken 316054 times.
✓ Branch 2 taken 277127 times.
✓ Branch 3 taken 117108 times.
|
1420578 | const int filter_flag = !ref_idx && w * h > 32 && !c_idx && |
480 |
6/6✓ Branch 0 taken 710289 times.
✓ Branch 1 taken 22318 times.
✓ Branch 2 taken 231098 times.
✓ Branch 3 taken 46029 times.
✓ Branch 4 taken 90821 times.
✓ Branch 5 taken 140277 times.
|
2885792 | cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag; |
481 | 1465214 | int cand_up_left = lc->na.cand_up_left; | |
482 | 1465214 | pixel *left = (pixel*)edge->left_array + MAX_TB_SIZE + 3; | |
483 | 1465214 | pixel *top = (pixel*)edge->top_array + MAX_TB_SIZE + 3; | |
484 | 1465214 | pixel *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3; | |
485 | 1465214 | pixel *filtered_top = (pixel*)edge->filtered_top_array + MAX_TB_SIZE + 3; | |
486 | 1465214 | const int ref_line = ref_idx == 3 ? -4 : (-1 - ref_idx); | |
487 | int left_size, top_size, unfilter_left_size, unfilter_top_size; | ||
488 | int left_available, top_available; | ||
489 | int refw, refh; | ||
490 | int intra_pred_angle, inv_angle; | ||
491 | int i; | ||
492 | |||
493 |
4/4✓ Branch 0 taken 657368 times.
✓ Branch 1 taken 75239 times.
✓ Branch 2 taken 277812 times.
✓ Branch 3 taken 379556 times.
|
1465214 | if (is_intra_mip || mode == INTRA_PLANAR) { |
494 | 706102 | left_size = h + 1; | |
495 | 706102 | top_size = w + 1; | |
496 | 706102 | unfilter_left_size = left_size + filter_flag; | |
497 | 706102 | unfilter_top_size = top_size + filter_flag; | |
498 |
2/2✓ Branch 0 taken 44545 times.
✓ Branch 1 taken 335011 times.
|
759112 | } else if (mode == INTRA_DC) { |
499 | 89090 | unfilter_left_size = left_size = h; | |
500 | 89090 | unfilter_top_size = top_size = w; | |
501 |
2/2✓ Branch 0 taken 35640 times.
✓ Branch 1 taken 299371 times.
|
670022 | } else if (mode == INTRA_VERT) { |
502 | //we may need 1 pixel to predict the top left. | ||
503 |
2/2✓ Branch 0 taken 31184 times.
✓ Branch 1 taken 4456 times.
|
71280 | unfilter_left_size = left_size = need_pdpc ? h : 1; |
504 | 71280 | unfilter_top_size = top_size = w; | |
505 |
2/2✓ Branch 0 taken 34158 times.
✓ Branch 1 taken 265213 times.
|
598742 | } else if (mode == INTRA_HORZ) { |
506 | 68316 | unfilter_left_size = left_size = h; | |
507 | //even need_pdpc == 0, we may need 1 pixel to predict the top left. | ||
508 |
2/2✓ Branch 0 taken 26915 times.
✓ Branch 1 taken 7243 times.
|
68316 | unfilter_top_size = top_size = need_pdpc ? w : 1; |
509 | } else { | ||
510 |
4/4✓ Branch 0 taken 70460 times.
✓ Branch 1 taken 194753 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 67630 times.
|
530426 | if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) { |
511 | 395166 | refw = w * 2; | |
512 | 395166 | refh = h * 2; | |
513 | } else { | ||
514 | 135260 | refw = cu->cb_width + w; | |
515 | 135260 | refh = cu->cb_height + h; | |
516 | } | ||
517 | 530426 | intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
518 | 530426 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
519 | 530426 | unfilter_top_size = top_size = refw; | |
520 | 530426 | unfilter_left_size = left_size = refh; | |
521 | } | ||
522 | |||
523 | 1465214 | left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx); | |
524 |
2/2✓ Branch 0 taken 7978989 times.
✓ Branch 1 taken 732607 times.
|
17423192 | for (i = 0; i < left_available; i++) |
525 | 15957978 | left[i] = POS(ref_line, i); | |
526 | |||
527 | 1465214 | top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx); | |
528 | 1465214 | memcpy(top, src + ref_line * stride, top_available * sizeof(pixel)); | |
529 | |||
530 |
2/2✓ Branch 0 taken 768862 times.
✓ Branch 1 taken 732607 times.
|
3002938 | for (int i = -1; i >= ref_line; i--) { |
531 |
2/2✓ Branch 0 taken 736066 times.
✓ Branch 1 taken 32796 times.
|
1537724 | if (cand_up_left) { |
532 | 1472132 | left[i] = POS(ref_line, i); | |
533 | 1472132 | top[i] = POS(i, ref_line); | |
534 |
2/2✓ Branch 0 taken 15111 times.
✓ Branch 1 taken 17685 times.
|
65592 | } else if (left_available) { |
535 | 30222 | left[i] = top[i] = left[0]; | |
536 |
2/2✓ Branch 0 taken 17079 times.
✓ Branch 1 taken 606 times.
|
35370 | } else if (top_available) { |
537 | 34158 | left[i] = top[i] = top[0]; | |
538 | } else { | ||
539 | 1212 | left[i] = top[i] = 1 << (BIT_DEPTH - 1); | |
540 | } | ||
541 | } | ||
542 | |||
543 |
2/2✓ Branch 0 taken 2664099 times.
✓ Branch 1 taken 732607 times.
|
6793412 | EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available); |
544 |
2/2✓ Branch 0 taken 1964119 times.
✓ Branch 1 taken 732607 times.
|
5393452 | EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available); |
545 | |||
546 |
2/2✓ Branch 0 taken 293725 times.
✓ Branch 1 taken 438882 times.
|
1465214 | if (ref_filter_flag) { |
547 |
8/8✓ Branch 0 taken 293246 times.
✓ Branch 1 taken 479 times.
✓ Branch 2 taken 174515 times.
✓ Branch 3 taken 118731 times.
✓ Branch 4 taken 113147 times.
✓ Branch 5 taken 61368 times.
✓ Branch 6 taken 90821 times.
✓ Branch 7 taken 22326 times.
|
587450 | if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) { |
548 | 181642 | const int unfilter_last_one = left_size == unfilter_left_size; | |
549 | 181642 | FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one); | |
550 | 181642 | left = filtered_left; | |
551 | 181642 | top = filtered_top; | |
552 | } | ||
553 | } | ||
554 |
6/6✓ Branch 0 taken 657368 times.
✓ Branch 1 taken 75239 times.
✓ Branch 2 taken 379556 times.
✓ Branch 3 taken 277812 times.
✓ Branch 4 taken 335011 times.
✓ Branch 5 taken 44545 times.
|
1465214 | if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) { |
555 |
6/6✓ Branch 0 taken 319098 times.
✓ Branch 1 taken 15913 times.
✓ Branch 2 taken 300144 times.
✓ Branch 3 taken 18954 times.
✓ Branch 4 taken 83888 times.
✓ Branch 5 taken 216256 times.
|
670022 | if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) { |
556 | 237510 | edge->filter_flag = 0; | |
557 | } else { | ||
558 | 432512 | const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18)); | |
559 | 432512 | const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0}; | |
560 | 432512 | const int ntbs = (av_log2(w) + av_log2(h)) >> 1; | |
561 | 432512 | edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2]; | |
562 | } | ||
563 | |||
564 |
4/4✓ Branch 0 taken 299371 times.
✓ Branch 1 taken 35640 times.
✓ Branch 2 taken 265213 times.
✓ Branch 3 taken 34158 times.
|
670022 | if (mode != INTRA_VERT && mode != INTRA_HORZ) { |
565 |
2/2✓ Branch 0 taken 136417 times.
✓ Branch 1 taken 128796 times.
|
530426 | if (mode >= INTRA_DIAG) { |
566 |
2/2✓ Branch 0 taken 71372 times.
✓ Branch 1 taken 65045 times.
|
272834 | if (intra_pred_angle < 0) { |
567 | 142744 | pixel *p = top - (ref_idx + 1); | |
568 |
2/2✓ Branch 0 taken 604828 times.
✓ Branch 1 taken 71372 times.
|
1352400 | for (int x = -h; x < 0; x++) { |
569 | 1209656 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h); | |
570 | 1209656 | p[x] = left[idx]; | |
571 | } | ||
572 | } else { | ||
573 |
2/2✓ Branch 0 taken 139368 times.
✓ Branch 1 taken 65045 times.
|
408826 | for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++) |
574 | 278736 | top[i] = top[refw - 1]; | |
575 | } | ||
576 | } else { | ||
577 |
2/2✓ Branch 0 taken 70125 times.
✓ Branch 1 taken 58671 times.
|
257592 | if (intra_pred_angle < 0) { |
578 | 140250 | pixel *p = left - (ref_idx + 1); | |
579 |
2/2✓ Branch 0 taken 1136124 times.
✓ Branch 1 taken 70125 times.
|
2412498 | for (int x = -w; x < 0; x++) { |
580 | 2272248 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w); | |
581 | 2272248 | p[x] = top[idx]; | |
582 | } | ||
583 | } else { | ||
584 |
2/2✓ Branch 0 taken 126173 times.
✓ Branch 1 taken 58671 times.
|
369688 | for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++) |
585 | 252346 | left[i] = left[refh - 1]; | |
586 | } | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | 1465214 | edge->left = (uint8_t*)left; | |
591 | 1465214 | edge->top = (uint8_t*)top; | |
592 | 1465214 | } | |
593 | |||
594 | //8.4.1 General decoding process for coding units coded in intra prediction mode | ||
595 | 1465214 | static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0, | |
596 | const int width, const int height, int c_idx) | ||
597 | { | ||
598 | 1465214 | VVCFrameContext *fc = lc->fc; | |
599 | 1465214 | const VVCSPS *sps = fc->ps.sps; | |
600 | 1465214 | const VVCPPS *pps = fc->ps.pps; | |
601 | 1465214 | const CodingUnit *cu = lc->cu; | |
602 | 1465214 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
603 | 1465214 | const int min_cb_width = pps->min_cb_width; | |
604 | 1465214 | const int x_cb = x0 >> log2_min_cb_size; | |
605 | 1465214 | const int y_cb = y0 >> log2_min_cb_size; | |
606 | |||
607 | 1465214 | const int hshift = fc->ps.sps->hshift[c_idx]; | |
608 | 1465214 | const int vshift = fc->ps.sps->vshift[c_idx]; | |
609 | 1465214 | const int x = x0 >> hshift; | |
610 | 1465214 | const int y = y0 >> vshift; | |
611 | 1465214 | const int w = width >> hshift; | |
612 | 1465214 | const int h = height >> vshift; | |
613 | 1465214 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
614 | |||
615 |
2/2✓ Branch 0 taken 214626 times.
✓ Branch 1 taken 517981 times.
|
1465214 | const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y; |
616 | 1465214 | const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode); | |
617 | |||
618 | 1465214 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
619 |
6/6✓ Branch 0 taken 113103 times.
✓ Branch 1 taken 619504 times.
✓ Branch 2 taken 38152 times.
✓ Branch 3 taken 74951 times.
✓ Branch 4 taken 288 times.
✓ Branch 5 taken 37864 times.
|
1465214 | const int is_intra_mip = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag); |
620 |
2/2✓ Branch 0 taken 517981 times.
✓ Branch 1 taken 214626 times.
|
1465214 | const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx; |
621 | 1465214 | const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx); | |
622 | |||
623 | |||
624 | 1465214 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
625 | IntraEdgeParams edge; | ||
626 | |||
627 | 1465214 | FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc); | |
628 | |||
629 |
2/2✓ Branch 0 taken 75239 times.
✓ Branch 1 taken 657368 times.
|
1465214 | if (is_intra_mip) { |
630 | 150478 | int intra_mip_transposed_flag = SAMPLE_CTB(fc->tab.imtf, x_cb, y_cb); | |
631 | 150478 | int intra_mip_mode = SAMPLE_CTB(fc->tab.imm, x_cb, y_cb); | |
632 | |||
633 | 150478 | 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 277812 times.
✓ Branch 1 taken 379556 times.
|
1314736 | } else if (mode == INTRA_PLANAR) { |
636 | 555624 | fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
637 |
2/2✓ Branch 0 taken 44545 times.
✓ Branch 1 taken 335011 times.
|
759112 | } else if (mode == INTRA_DC) { |
638 | 89090 | fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
639 |
2/2✓ Branch 0 taken 35640 times.
✓ Branch 1 taken 299371 times.
|
670022 | } else if (mode == INTRA_VERT) { |
640 | 71280 | fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride); | |
641 |
2/2✓ Branch 0 taken 34158 times.
✓ Branch 1 taken 265213 times.
|
598742 | } else if (mode == INTRA_HORZ) { |
642 | 68316 | fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride); | |
643 | } else { | ||
644 |
2/2✓ Branch 0 taken 136417 times.
✓ Branch 1 taken 128796 times.
|
530426 | if (mode >= INTRA_DIAG) { |
645 | 272834 | 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 | 257592 | 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 470869 times.
✓ Branch 1 taken 261738 times.
|
1465214 | if (need_pdpc) { |
655 | //8.4.5.2.15 Position-dependent intra prediction sample filtering process | ||
656 |
8/8✓ Branch 0 taken 405192 times.
✓ Branch 1 taken 65677 times.
✓ Branch 2 taken 152630 times.
✓ Branch 3 taken 252562 times.
✓ Branch 4 taken 113724 times.
✓ Branch 5 taken 38906 times.
✓ Branch 6 taken 82540 times.
✓ Branch 7 taken 31184 times.
|
941738 | if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC || |
657 |
2/2✓ Branch 0 taken 26915 times.
✓ Branch 1 taken 55625 times.
|
165080 | mode == INTRA_VERT || mode == INTRA_HORZ)) { |
658 | 699134 | const int scale = (av_log2(w) + av_log2(h) - 2) >> 2; | |
659 | 699134 | const pixel *left = (pixel*)edge.left; | |
660 | 699134 | const pixel *top = (pixel*)edge.top; | |
661 |
2/2✓ Branch 0 taken 3852236 times.
✓ Branch 1 taken 349567 times.
|
8403606 | for (int y = 0; y < h; y++) { |
662 |
2/2✓ Branch 0 taken 66509904 times.
✓ Branch 1 taken 3852236 times.
|
140724280 | for (int x = 0; x < w; x++) { |
663 | int l, t, wl, wt, pred; | ||
664 | pixel val; | ||
665 |
4/4✓ Branch 0 taken 18690656 times.
✓ Branch 1 taken 47819248 times.
✓ Branch 2 taken 7608864 times.
✓ Branch 3 taken 11081792 times.
|
133019808 | if (mode == INTRA_PLANAR || mode == INTRA_DC) { |
666 | 110856224 | l = left[y]; | |
667 | 110856224 | t = top[x]; | |
668 | 110856224 | wl = 32 >> FFMIN((x << 1) >> scale, 31); | |
669 | 110856224 | wt = 32 >> FFMIN((y << 1) >> scale, 31); | |
670 | } else { | ||
671 | 22163584 | l = left[y] - left[-1] + POS(x,y); | |
672 | 22163584 | t = top[x] - top[-1] + POS(x,y); | |
673 |
2/2✓ Branch 0 taken 5264496 times.
✓ Branch 1 taken 5817296 times.
|
22163584 | wl = (mode == INTRA_VERT) ? (32 >> FFMIN((x << 1) >> scale, 31)) : 0; |
674 |
2/2✓ Branch 0 taken 5817296 times.
✓ Branch 1 taken 5264496 times.
|
22163584 | wt = (mode == INTRA_HORZ) ? (32 >> FFMIN((y << 1) >> scale, 31)) : 0; |
675 | } | ||
676 | 133019808 | val = POS(x, y); | |
677 | 133019808 | pred = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6); | |
678 | 133019808 | POS(x, y) = CLIP(pred); | |
679 | } | ||
680 | } | ||
681 | } | ||
682 | } | ||
683 | 1465214 | } | |
684 | |||
685 | //8.4.5.2.11 Specification of INTRA_PLANAR intra prediction mode | ||
686 | 555624 | 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 | 555624 | pixel *src = (pixel *)_src; | |
691 | 555624 | const pixel *top = (const pixel *)_top; | |
692 | 555624 | const pixel *left = (const pixel *)_left; | |
693 | 555624 | const int logw = av_log2(w); | |
694 | 555624 | const int logh = av_log2(h); | |
695 | 555624 | const int size = w * h; | |
696 | 555624 | const int shift = (logw + logh + 1); | |
697 |
2/2✓ Branch 0 taken 2850944 times.
✓ Branch 1 taken 277812 times.
|
6257512 | for (y = 0; y < h; y++) { |
698 |
2/2✓ Branch 0 taken 48484208 times.
✓ Branch 1 taken 2850944 times.
|
102670304 | for (x = 0; x < w; x++) { |
699 | 96968416 | const int pred_v = ((h - 1 - y) * top[x] + (y + 1) * left[h]) << logw; | |
700 | 96968416 | const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh; | |
701 | 96968416 | const int pred = (pred_v + pred_h + size) >> shift; | |
702 | 96968416 | POS(x, y) = pred; | |
703 | } | ||
704 | } | ||
705 | 555624 | } | |
706 | |||
707 | //8.4.5.2.3 MIP boundary sample downsampling process | ||
708 | 300956 | 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 | 300956 | const int b_dwn = n_tb_s / boundary_size; | |
712 | 300956 | const int log2 = av_log2(b_dwn); | |
713 | |||
714 |
2/2✓ Branch 0 taken 26428 times.
✓ Branch 1 taken 124050 times.
|
300956 | if (boundary_size == n_tb_s) { |
715 |
2/2✓ Branch 0 taken 105712 times.
✓ Branch 1 taken 26428 times.
|
264280 | for (int i = 0; i < n_tb_s; i++) |
716 | 211424 | reduced[i] = ref[i]; | |
717 | 52856 | return; | |
718 | } | ||
719 |
2/2✓ Branch 0 taken 464732 times.
✓ Branch 1 taken 124050 times.
|
1177564 | for (int i = 0; i < boundary_size; i++) { |
720 | int r; | ||
721 | 929464 | r = *ref++; | |
722 |
2/2✓ Branch 0 taken 1374156 times.
✓ Branch 1 taken 464732 times.
|
3677776 | for (int j = 1; j < b_dwn; j++) |
723 | 2748312 | r += *ref++; | |
724 | 929464 | reduced[i] = (r + (1 << (log2 - 1))) >> log2; | |
725 | } | ||
726 | } | ||
727 | |||
728 | 150478 | 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 | 150478 | src = &POS(up_hor - 1, up_ver - 1); | |
733 |
2/2✓ Branch 0 taken 434152 times.
✓ Branch 1 taken 75239 times.
|
1018782 | for (int y = 0; y < pred_size; y++) { |
734 |
2/2✓ Branch 0 taken 2802176 times.
✓ Branch 1 taken 434152 times.
|
6472656 | for (int x = 0; x < pred_size; x++) { |
735 | 5604352 | int pred = 0; | |
736 |
2/2✓ Branch 0 taken 19782784 times.
✓ Branch 1 taken 2802176 times.
|
45169920 | for (int i = 0; i < reduced_size; i++) |
737 | 39565568 | pred += reduced[i] * matrix[i]; | |
738 | 5604352 | matrix += reduced_size; | |
739 | 5604352 | pred = ((pred + ow) >> 6) + temp0; | |
740 | 5604352 | pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1); | |
741 |
2/2✓ Branch 0 taken 1412304 times.
✓ Branch 1 taken 1389872 times.
|
5604352 | if (is_transposed) |
742 | 2824608 | POS(y * up_hor, x * up_ver) = pred; | |
743 | else | ||
744 | 2779744 | POS(x * up_hor, y * up_ver) = pred; | |
745 | } | ||
746 | } | ||
747 | 150478 | } | |
748 | |||
749 | 181986 | 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 898964 times.
✓ Branch 1 taken 90993 times.
|
1979914 | for (int i = 0; i < dst_height; i++) { |
754 | 1797928 | const pixel *before = boundary; | |
755 | 1797928 | const pixel *after = dst - dst_step; | |
756 | 1797928 | pixel *d = dst; | |
757 |
2/2✓ Branch 0 taken 6401904 times.
✓ Branch 1 taken 898964 times.
|
14601736 | for (int j = 0; j < pred_size; j++) { |
758 | 12803808 | after += dst_step * factor; | |
759 |
2/2✓ Branch 0 taken 13828752 times.
✓ Branch 1 taken 6401904 times.
|
40461312 | for (int k = 1; k < factor; k++) { |
760 | 27657504 | int mid = (factor - k) * (*before) + k * (*after); | |
761 | 27657504 | *d = (mid + factor / 2) / factor; | |
762 | 27657504 | d += dst_step; | |
763 | } | ||
764 | 12803808 | before = after; | |
765 | 12803808 | d += dst_step; | |
766 | } | ||
767 | 1797928 | boundary += boundary_step; | |
768 | 1797928 | dst += dst_stride; | |
769 | } | ||
770 | 181986 | } | |
771 | |||
772 | //8.4.5.2.2 Matrix-based intra sample prediction | ||
773 | 150478 | 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 | 150478 | pixel *src = (pixel *)_src; | |
778 | 150478 | const pixel *top = (const pixel *)_top; | |
779 | 150478 | const pixel *left = (const pixel *)_left; | |
780 | |||
781 | 150478 | 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 | 150478 | const int boundary_size = boundary_sizes[size_id]; | |
785 | 150478 | const int pred_size = pred_sizes[size_id]; | |
786 | 150478 | const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0); | |
787 | 150478 | const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id); | |
788 | 150478 | const int up_hor = w / pred_size; | |
789 | 150478 | const int up_ver = h / pred_size; | |
790 | |||
791 | int reduced[16]; | ||
792 | 150478 | int *red_t = reduced; | |
793 | 150478 | int *red_l = reduced + boundary_size; | |
794 | 150478 | int off = 1, ow = 0; | |
795 | int temp0; | ||
796 | |||
797 |
2/2✓ Branch 0 taken 38484 times.
✓ Branch 1 taken 36755 times.
|
150478 | if (is_transposed) { |
798 | 76968 | FFSWAP(int*, red_t, red_l); | |
799 | } | ||
800 | 150478 | FUNC(mip_downsampling)(red_t, boundary_size, top, w); | |
801 | 150478 | FUNC(mip_downsampling)(red_l, boundary_size, left, h); | |
802 | |||
803 | 150478 | temp0 = reduced[0]; | |
804 |
2/2✓ Branch 0 taken 41940 times.
✓ Branch 1 taken 33299 times.
|
150478 | if (size_id != 2) { |
805 | 83880 | off = 0; | |
806 | 83880 | ow = (1 << (BIT_DEPTH - 1)) - temp0; | |
807 | } else { | ||
808 | 66598 | ow = reduced[1] - temp0; | |
809 | } | ||
810 | 150478 | reduced[0] = ow; | |
811 |
2/2✓ Branch 0 taken 461906 times.
✓ Branch 1 taken 75239 times.
|
1074290 | for (int i = 1; i < in_size; i++) { |
812 | 923812 | reduced[i] = reduced[i + off] - temp0; | |
813 | 923812 | ow += reduced[i]; | |
814 | } | ||
815 | 150478 | ow = 32 - 32 * ow; | |
816 | |||
817 | 150478 | 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 24076 times.
✓ Branch 1 taken 51163 times.
✓ Branch 2 taken 16209 times.
✓ Branch 3 taken 7867 times.
|
150478 | if (up_hor > 1 || up_ver > 1) { |
819 |
2/2✓ Branch 0 taken 51163 times.
✓ Branch 1 taken 16209 times.
|
134744 | if (up_hor > 1) |
820 | 102326 | 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 39830 times.
✓ Branch 1 taken 27542 times.
|
134744 | if (up_ver > 1) |
822 | 79660 | FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size); | |
823 | } | ||
824 | 150478 | } | |
825 | |||
826 | 89090 | 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 | 89090 | int sum = 0; | |
831 |
2/2✓ Branch 0 taken 14208 times.
✓ Branch 1 taken 30337 times.
|
89090 | unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h); |
832 | 89090 | const int shift = av_log2(offset); | |
833 | 89090 | offset >>= 1; | |
834 |
2/2✓ Branch 0 taken 34264 times.
✓ Branch 1 taken 10281 times.
|
89090 | if (w >= h) { |
835 |
2/2✓ Branch 0 taken 544776 times.
✓ Branch 1 taken 34264 times.
|
1158080 | for (int i = 0; i < w; i++) |
836 | 1089552 | sum += top[i]; | |
837 | } | ||
838 |
2/2✓ Branch 0 taken 24489 times.
✓ Branch 1 taken 20056 times.
|
89090 | if (w <= h) { |
839 |
2/2✓ Branch 0 taken 330816 times.
✓ Branch 1 taken 24489 times.
|
710610 | for (int i = 0; i < h; i++) |
840 | 661632 | sum += left[i]; | |
841 | } | ||
842 | 89090 | dc_val = (sum + offset) >> shift; | |
843 | 89090 | return dc_val; | |
844 | } | ||
845 | |||
846 | //8.4.5.2.12 Specification of INTRA_DC intra prediction mode | ||
847 | 89090 | 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 | 89090 | pixel *src = (pixel *)_src; | |
852 | 89090 | const pixel *top = (const pixel *)_top; | |
853 | 89090 | const pixel *left = (const pixel *)_left; | |
854 | 89090 | const pixel dc = FUNC(pred_dc_val)(top, left, w, h); | |
855 | 89090 | const pixel4 a = PIXEL_SPLAT_X4(dc); | |
856 |
2/2✓ Branch 0 taken 449136 times.
✓ Branch 1 taken 44545 times.
|
987362 | for (y = 0; y < h; y++) { |
857 | 898272 | pixel *s = src; | |
858 |
2/2✓ Branch 0 taken 2040768 times.
✓ Branch 1 taken 449136 times.
|
4979808 | for (x = 0; x < w; x += 4) { |
859 | 4081536 | AV_WN4P(s, a); | |
860 | 4081536 | s += 4; | |
861 | } | ||
862 | 898272 | src += stride; | |
863 | } | ||
864 | 89090 | } | |
865 | |||
866 | 71280 | 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 | 71280 | pixel *src = (pixel *)_src; | |
870 | 71280 | const pixel *top = (const pixel *)_top; | |
871 |
2/2✓ Branch 0 taken 363804 times.
✓ Branch 1 taken 35640 times.
|
798888 | for (int y = 0; y < h; y++) { |
872 | 727608 | memcpy(src, top, sizeof(pixel) * w); | |
873 | 727608 | src += stride; | |
874 | } | ||
875 | 71280 | } | |
876 | |||
877 | 68316 | 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 | 68316 | pixel *src = (pixel *)_src; | |
881 | 68316 | const pixel *left = (const pixel *)_left; | |
882 |
2/2✓ Branch 0 taken 316804 times.
✓ Branch 1 taken 34158 times.
|
701924 | for (int y = 0; y < h; y++) { |
883 | 633608 | const pixel4 a = PIXEL_SPLAT_X4(left[y]); | |
884 |
2/2✓ Branch 0 taken 1570572 times.
✓ Branch 1 taken 316804 times.
|
3774752 | for (int x = 0; x < w; x += 4) { |
885 | 3141144 | AV_WN4P(&POS(x, y), a); | |
886 | } | ||
887 | } | ||
888 | 68316 | } | |
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 | 272834 | 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 | 272834 | pixel *src = (pixel *)_src; | |
899 | 272834 | const pixel *left = (const pixel *)_left; | |
900 | 272834 | const pixel *top = (const pixel *)_top - (1 + ref_idx); | |
901 | 272834 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
902 | 272834 | int pos = (1 + ref_idx) * intra_pred_angle; | |
903 | 272834 | const int dp = intra_pred_angle; | |
904 | 272834 | const int is_luma = !c_idx; | |
905 | int nscale, inv_angle; | ||
906 | |||
907 |
2/2✓ Branch 0 taken 30220 times.
✓ Branch 1 taken 106197 times.
|
272834 | if (need_pdpc) { |
908 | 60440 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
909 | 60440 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
910 | } | ||
911 | |||
912 |
2/2✓ Branch 0 taken 1088804 times.
✓ Branch 1 taken 136417 times.
|
2450442 | for (int y = 0; y < h; y++) { |
913 | 2177608 | const int idx = (pos >> 5) + ref_idx; | |
914 | 2177608 | const int fact = pos & 31; | |
915 |
6/6✓ Branch 0 taken 161638 times.
✓ Branch 1 taken 927166 times.
✓ Branch 2 taken 102000 times.
✓ Branch 3 taken 59638 times.
✓ Branch 4 taken 83971 times.
✓ Branch 5 taken 18029 times.
|
2177608 | if (!fact && (!is_luma || !filter_flag)) { |
916 |
2/2✓ Branch 0 taken 1597888 times.
✓ Branch 1 taken 143609 times.
|
3482994 | for (int x = 0; x < w; x++) { |
917 | 3195776 | const pixel *p = top + x + idx + 1; | |
918 | 3195776 | POS(x, y) = *p; | |
919 | } | ||
920 | } else { | ||
921 |
2/2✓ Branch 0 taken 730101 times.
✓ Branch 1 taken 215094 times.
|
1890390 | if (!c_idx) { |
922 | 1460202 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
923 |
2/2✓ Branch 0 taken 8452088 times.
✓ Branch 1 taken 730101 times.
|
18364378 | for (int x = 0; x < w; x++) { |
924 | 16904176 | const pixel *p = top + x + idx; | |
925 | 16904176 | POS(x, y) = INTRA_LUMA_FILTER(p); | |
926 | } | ||
927 | } else { | ||
928 |
2/2✓ Branch 0 taken 2034792 times.
✓ Branch 1 taken 215094 times.
|
4499772 | for (int x = 0; x < w; x++) { |
929 | 4069584 | const pixel *p = top + x + idx; | |
930 | 4069584 | POS(x, y) = INTRA_CHROMA_FILTER(p); | |
931 | } | ||
932 | } | ||
933 | } | ||
934 |
2/2✓ Branch 0 taken 275208 times.
✓ Branch 1 taken 813596 times.
|
2177608 | if (need_pdpc) { |
935 | 550416 | int inv_angle_sum = 256 + inv_angle; | |
936 |
2/2✓ Branch 0 taken 1502796 times.
✓ Branch 1 taken 275208 times.
|
3556008 | for (int x = 0; x < FFMIN(w, 3 << nscale); x++) { |
937 | 3005592 | const pixel l = left[y + (inv_angle_sum >> 9)]; | |
938 | 3005592 | const pixel val = POS(x, y); | |
939 | 3005592 | const int wl = 32 >> ((x << 1) >> nscale); | |
940 | 3005592 | const int pred = val + (((l - val) * wl + 32) >> 6); | |
941 | 3005592 | POS(x, y) = CLIP(pred); | |
942 | 3005592 | inv_angle_sum += inv_angle; | |
943 | } | ||
944 | } | ||
945 | 2177608 | pos += dp; | |
946 | } | ||
947 | 272834 | } | |
948 | |||
949 | //8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes | ||
950 | 257592 | 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 | 257592 | pixel *src = (pixel *)_src; | |
955 | 257592 | const pixel *left = (const pixel *)_left - (1 + ref_idx); | |
956 | 257592 | const pixel *top = (const pixel *)_top; | |
957 | 257592 | const int is_luma = !c_idx; | |
958 | 257592 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
959 | 257592 | const int dp = intra_pred_angle; | |
960 | 257592 | int nscale = 0, inv_angle, inv_angle_sum; | |
961 | |||
962 |
2/2✓ Branch 0 taken 25405 times.
✓ Branch 1 taken 103391 times.
|
257592 | if (need_pdpc) { |
963 | 50810 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
964 | 50810 | inv_angle_sum = 256 + inv_angle; | |
965 | 50810 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
966 | } | ||
967 | |||
968 |
2/2✓ Branch 0 taken 1069664 times.
✓ Branch 1 taken 128796 times.
|
2396920 | for (int y = 0; y < h; y++) { |
969 | 2139328 | int pos = (1 + ref_idx) * intra_pred_angle; | |
970 | int wt; | ||
971 |
2/2✓ Branch 0 taken 291660 times.
✓ Branch 1 taken 778004 times.
|
2139328 | if (need_pdpc) |
972 | 583320 | wt = (32 >> FFMIN(31, (y * 2) >> nscale)); | |
973 | |||
974 |
2/2✓ Branch 0 taken 16755840 times.
✓ Branch 1 taken 1069664 times.
|
35651008 | for (int x = 0; x < w; x++) { |
975 | 33511680 | const int idx = (pos >> 5) + ref_idx; | |
976 | 33511680 | const int fact = pos & 31; | |
977 | 33511680 | const pixel *p = left + y + idx; | |
978 | int pred; | ||
979 |
6/6✓ Branch 0 taken 1548144 times.
✓ Branch 1 taken 15207696 times.
✓ Branch 2 taken 1235412 times.
✓ Branch 3 taken 312732 times.
✓ Branch 4 taken 707156 times.
✓ Branch 5 taken 528256 times.
|
33511680 | if (!fact && (!is_luma || !filter_flag)) { |
980 | 2039776 | pred = p[1]; | |
981 | } else { | ||
982 |
2/2✓ Branch 0 taken 11988364 times.
✓ Branch 1 taken 3747588 times.
|
31471904 | if (!c_idx) { |
983 | 23976728 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
984 | 23976728 | pred = INTRA_LUMA_FILTER(p); | |
985 | } else { | ||
986 | 7495176 | pred = INTRA_CHROMA_FILTER(p); | |
987 | } | ||
988 | } | ||
989 |
2/2✓ Branch 0 taken 3695664 times.
✓ Branch 1 taken 13060176 times.
|
33511680 | if (need_pdpc) { |
990 |
2/2✓ Branch 0 taken 1428732 times.
✓ Branch 1 taken 2266932 times.
|
7391328 | if (y < (3 << nscale)) { |
991 | 2857464 | const pixel t = top[x + (inv_angle_sum >> 9)]; | |
992 | 2857464 | pred = CLIP(pred + (((t - pred) * wt + 32) >> 6)); | |
993 | } | ||
994 | } | ||
995 | 33511680 | POS(x, y) = pred; | |
996 | 33511680 | pos += dp; | |
997 | } | ||
998 |
2/2✓ Branch 0 taken 291660 times.
✓ Branch 1 taken 778004 times.
|
2139328 | if (need_pdpc) |
999 | 583320 | inv_angle_sum += inv_angle; | |
1000 | } | ||
1001 | 257592 | } | |
1002 | |||
1003 | 2134 | static void FUNC(ff_vvc_intra_dsp_init)(VVCIntraDSPContext *const intra) | |
1004 | { | ||
1005 | 2134 | intra->lmcs_scale_chroma = FUNC(lmcs_scale_chroma); | |
1006 | 2134 | intra->intra_cclm_pred = FUNC(intra_cclm_pred); | |
1007 | 2134 | intra->intra_pred = FUNC(intra_pred); | |
1008 | 2134 | intra->pred_planar = FUNC(pred_planar); | |
1009 | 2134 | intra->pred_mip = FUNC(pred_mip); | |
1010 | 2134 | intra->pred_dc = FUNC(pred_dc); | |
1011 | 2134 | intra->pred_v = FUNC(pred_v); | |
1012 | 2134 | intra->pred_h = FUNC(pred_h); | |
1013 | 2134 | intra->pred_angular_v = FUNC(pred_angular_v); | |
1014 | 2134 | intra->pred_angular_h = FUNC(pred_angular_h); | |
1015 | 2134 | } | |
1016 |