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 | 165080 | 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 | 165080 | const VVCSPS *sps = fc->ps.sps; | |
33 |
2/2✓ Branch 0 taken 165080 times.
✓ Branch 1 taken 82540 times.
|
495240 | for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) { |
34 | 330160 | const int c_idx = i + 1; | |
35 | 330160 | const int x = x0 >> sps->hshift[c_idx]; | |
36 | 330160 | const int y = y0 >> sps->vshift[c_idx]; | |
37 | 330160 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
38 | 330160 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
39 |
2/2✓ Branch 0 taken 1640192 times.
✓ Branch 1 taken 165080 times.
|
3610544 | for (int y = 0; y < h; y++) { |
40 |
2/2✓ Branch 0 taken 26434944 times.
✓ Branch 1 taken 1640192 times.
|
56150272 | for (int x = 0; x < w; x++) { |
41 | 52869888 | const int dsy = pdsy[y * w + x]; | |
42 | 52869888 | const int pred = ((dsy * a[i]) >> k[i]) + b[i]; | |
43 | 52869888 | POS(x, y) = CLIP(pred); | |
44 | } | ||
45 | } | ||
46 | } | ||
47 | 165080 | } | |
48 | |||
49 | #define MAX_PICK_POS 4 | ||
50 | #define TOP 0 | ||
51 | #define LEFT 1 | ||
52 | |||
53 | 808 | static av_always_inline void FUNC(cclm_get_params_default)(int *a, int *b, int *k) | |
54 | { | ||
55 |
2/2✓ Branch 0 taken 808 times.
✓ Branch 1 taken 404 times.
|
2424 | for (int i = 0; i < 2; i++) { |
56 | 1616 | a[i] = k[i] = 0; | |
57 | 1616 | b[i] = 1 << (BIT_DEPTH - 1); | |
58 | } | ||
59 | 808 | } | |
60 | |||
61 | 165080 | 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 | 165080 | const enum IntraPredMode mode = lc->cu->intra_pred_mode_c; | |
66 |
6/6✓ Branch 0 taken 79707 times.
✓ Branch 1 taken 2833 times.
✓ Branch 2 taken 77854 times.
✓ Branch 3 taken 1853 times.
✓ Branch 4 taken 33415 times.
✓ Branch 5 taken 44439 times.
|
165080 | const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM; |
67 | int num_samp[2]; | ||
68 | |||
69 |
2/2✓ Branch 0 taken 48022 times.
✓ Branch 1 taken 34518 times.
|
165080 | if (mode == INTRA_LT_CCLM) { |
70 |
2/2✓ Branch 0 taken 45761 times.
✓ Branch 1 taken 2261 times.
|
96044 | num_samp[TOP] = avail_t ? w : 0; |
71 |
2/2✓ Branch 0 taken 46700 times.
✓ Branch 1 taken 1322 times.
|
96044 | num_samp[LEFT] = avail_l ? h : 0; |
72 | } else { | ||
73 |
4/4✓ Branch 0 taken 33946 times.
✓ Branch 1 taken 572 times.
✓ Branch 2 taken 17915 times.
✓ Branch 3 taken 16031 times.
|
69036 | 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 33987 times.
✓ Branch 1 taken 531 times.
✓ Branch 2 taken 16199 times.
✓ Branch 3 taken 17788 times.
|
69036 | 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 18864 times.
✓ Branch 1 taken 63676 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 18460 times.
|
165080 | if (!num_samp[TOP] && !num_samp[LEFT]) { |
77 | 808 | return 0; | |
78 | } | ||
79 |
2/2✓ Branch 0 taken 164272 times.
✓ Branch 1 taken 82136 times.
|
492816 | for (int i = TOP; i <= LEFT; i++) { |
80 | 328544 | const int start = num_samp[i] >> (2 + num_is4); | |
81 | 328544 | const int step = FFMAX(1, num_samp[i] >> (1 + num_is4)) ; | |
82 | 328544 | cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1); | |
83 |
2/2✓ Branch 0 taken 328066 times.
✓ Branch 1 taken 164272 times.
|
984676 | for (int c = 0; c < cnt[i]; c++) |
84 | 656132 | pos[i][c] = start + c * step; | |
85 | } | ||
86 | 164272 | return 1; | |
87 | } | ||
88 | |||
89 | 51764 | 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 51764 times.
✓ Branch 1 taken 25882 times.
|
155292 | for (int i = 0; i < cnt; i++) |
93 | 103528 | sel_luma[i] = src[pos[i] * step]; | |
94 | 51764 | } | |
95 | |||
96 | 164272 | 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 | 164272 | const VVCSPS *sps = fc->ps.sps; | |
101 | |||
102 | 164272 | const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y); | |
103 | 164272 | const int hs = sps->hshift[1]; | |
104 | 164272 | const int vs = sps->vshift[1]; | |
105 | 164272 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
106 | |||
107 |
3/4✓ Branch 0 taken 12941 times.
✓ Branch 1 taken 69195 times.
✓ Branch 2 taken 12941 times.
✗ Branch 3 not taken.
|
190154 | if (!hs && !vs) { |
108 | 25882 | const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride; | |
109 | 25882 | FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma); | |
110 | 25882 | 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 69195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58371 times.
✓ Branch 3 taken 10824 times.
|
255132 | if (vs && !b_ctu_boundary) { |
114 | 116742 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride; | |
115 |
2/2✓ Branch 0 taken 122094 times.
✓ Branch 1 taken 58371 times.
|
360930 | for (int i = 0; i < cnt[TOP]; i++) { |
116 | 244188 | const int x = pos[TOP][i] << hs; | |
117 | 244188 | const pixel *src = source + x; | |
118 |
4/4✓ Branch 0 taken 2004 times.
✓ Branch 1 taken 120090 times.
✓ Branch 2 taken 1871 times.
✓ Branch 3 taken 133 times.
|
244188 | const int has_left = x || avail_l; |
119 |
2/2✓ Branch 0 taken 121961 times.
✓ Branch 1 taken 133 times.
|
244188 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
120 |
2/2✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 117854 times.
|
244188 | 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 117721 times.
✓ Branch 1 taken 133 times.
|
235708 | const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1); |
124 | 235708 | 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 | 21648 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride; | |
129 |
2/2✓ Branch 0 taken 17164 times.
✓ Branch 1 taken 10824 times.
|
55976 | for (int i = 0; i < cnt[TOP]; i++) { |
130 | 34328 | const int x = pos[TOP][i] << hs; | |
131 | 34328 | const pixel *src = source + x; | |
132 |
4/4✓ Branch 0 taken 28 times.
✓ Branch 1 taken 17136 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 25 times.
|
34328 | const int has_left = x || avail_l; |
133 |
2/2✓ Branch 0 taken 17139 times.
✓ Branch 1 taken 25 times.
|
34328 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
134 | 34328 | sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
135 | } | ||
136 | } | ||
137 | |||
138 | // left | ||
139 | { | ||
140 | const pixel *left; | ||
141 | 138390 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l; | |
142 | 138390 | left = source - avail_l; | |
143 | |||
144 |
2/2✓ Branch 0 taken 137044 times.
✓ Branch 1 taken 69195 times.
|
412478 | for (int i = 0; i < cnt[LEFT]; i++) { |
145 | 274088 | const int y = pos[LEFT][i] << vs; | |
146 | 274088 | const int offset = y * stride; | |
147 | 274088 | const pixel *l = left + offset; | |
148 | 274088 | const pixel *src = source + offset; | |
149 | pixel pred; | ||
150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 137044 times.
|
274088 | if (!vs) { |
151 | ✗ | pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
152 | } else { | ||
153 |
2/2✓ Branch 0 taken 6058 times.
✓ Branch 1 taken 130986 times.
|
274088 | 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 | 261972 | pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
159 | } | ||
160 | } | ||
161 | 274088 | sel_luma[i + cnt[TOP]] = pred; | |
162 | } | ||
163 | } | ||
164 | } | ||
165 | 164272 | } | |
166 | |||
167 | 164272 | 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 164272 times.
✓ Branch 1 taken 82136 times.
|
492816 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
172 | 328544 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
173 | |||
174 | //top | ||
175 | 328544 | const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride; | |
176 |
2/2✓ Branch 0 taken 331652 times.
✓ Branch 1 taken 164272 times.
|
991848 | for (int i = 0; i < cnt[TOP]; i++) { |
177 | 663304 | sel[c_idx][i] = src[pos[TOP][i]]; | |
178 | } | ||
179 | |||
180 | //left | ||
181 | 328544 | src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride; | |
182 |
2/2✓ Branch 0 taken 324480 times.
✓ Branch 1 taken 164272 times.
|
977504 | for (int i = 0; i < cnt[LEFT]; i++) { |
183 | 648960 | sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride]; | |
184 | } | ||
185 | } | ||
186 | 164272 | } | |
187 | |||
188 | 165080 | 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 | 165080 | const VVCFrameContext *fc = lc->fc; | |
193 | 165080 | const VVCSPS *sps = fc->ps.sps; | |
194 | 165080 | const int x = x0 >> sps->hshift[1]; | |
195 | 165080 | const int y = y0 >> sps->vshift[1]; | |
196 | int cnt[2], pos[2][MAX_PICK_POS]; | ||
197 | |||
198 |
2/2✓ Branch 1 taken 404 times.
✓ Branch 2 taken 82136 times.
|
165080 | if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos)) |
199 | 808 | return 0; | |
200 | |||
201 | 164272 | FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]); | |
202 | 164272 | FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel); | |
203 | |||
204 |
2/2✓ Branch 0 taken 239 times.
✓ Branch 1 taken 81897 times.
|
164272 | if (cnt[TOP] + cnt[LEFT] == 2) { |
205 |
2/2✓ Branch 0 taken 717 times.
✓ Branch 1 taken 239 times.
|
1912 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
206 | 1434 | sel[c_idx][3] = sel[c_idx][0]; | |
207 | 1434 | sel[c_idx][2] = sel[c_idx][1]; | |
208 | 1434 | sel[c_idx][0] = sel[c_idx][1]; | |
209 | 1434 | sel[c_idx][1] = sel[c_idx][3]; | |
210 | } | ||
211 | } | ||
212 | 164272 | return 1; | |
213 | } | ||
214 | |||
215 | 164272 | static av_always_inline void FUNC(cclm_get_min_max)( | |
216 | const pixel sel[][MAX_PICK_POS * 2], int *min, int *max) | ||
217 | { | ||
218 | 164272 | int min_grp_idx[] = { 0, 2 }; | |
219 | 164272 | int max_grp_idx[] = { 1, 3 }; | |
220 | |||
221 |
2/2✓ Branch 0 taken 40049 times.
✓ Branch 1 taken 42087 times.
|
164272 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]]) |
222 | 80098 | FFSWAP(int, min_grp_idx[0], min_grp_idx[1]); | |
223 |
2/2✓ Branch 0 taken 40920 times.
✓ Branch 1 taken 41216 times.
|
164272 | if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) |
224 | 81840 | FFSWAP(int, max_grp_idx[0], max_grp_idx[1]); | |
225 |
2/2✓ Branch 0 taken 8464 times.
✓ Branch 1 taken 73672 times.
|
164272 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) { |
226 | 16928 | FFSWAP(int, min_grp_idx[0], max_grp_idx[0]); | |
227 | 16928 | FFSWAP(int, min_grp_idx[1], max_grp_idx[1]); | |
228 | } | ||
229 |
2/2✓ Branch 0 taken 63249 times.
✓ Branch 1 taken 18887 times.
|
164272 | if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]]) |
230 | 126498 | FFSWAP(int, min_grp_idx[1], max_grp_idx[0]); | |
231 |
2/2✓ Branch 0 taken 246408 times.
✓ Branch 1 taken 82136 times.
|
657088 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
232 | 492816 | max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1; | |
233 | 492816 | min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1; | |
234 | } | ||
235 | 164272 | } | |
236 | |||
237 | 165080 | 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 404 times.
✓ Branch 2 taken 82136 times.
|
165080 | if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) { |
246 | 808 | FUNC(cclm_get_params_default)(a, b, k); | |
247 | 4278 | return; | |
248 | } | ||
249 | |||
250 | 164272 | FUNC(cclm_get_min_max)(sel, min, max); | |
251 | |||
252 | 164272 | diff = max[LUMA] - min[LUMA]; | |
253 |
2/2✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 80401 times.
|
164272 | if (diff == 0) { |
254 |
2/2✓ Branch 0 taken 3470 times.
✓ Branch 1 taken 1735 times.
|
10410 | for (int i = 0; i < 2; i++) { |
255 | 6940 | a[i] = k[i] = 0; | |
256 | 6940 | b[i] = min[i + 1]; | |
257 | } | ||
258 | 3470 | return; | |
259 | } | ||
260 |
2/2✓ Branch 0 taken 160802 times.
✓ Branch 1 taken 80401 times.
|
482406 | 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 | 321604 | const int diffc = max[i + 1] - min[i + 1]; | |
263 | 321604 | int x = av_log2(diff); | |
264 | int y, v, sign, add; | ||
265 | 321604 | const int norm_diff = ((diff << 4) >> x) & 15; | |
266 | 321604 | x += (norm_diff) ? 1 : 0; | |
267 |
2/2✓ Branch 0 taken 144637 times.
✓ Branch 1 taken 16165 times.
|
321604 | y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0; |
268 | 321604 | v = div_sig_table[norm_diff] | 8; | |
269 | 321604 | add = (1 << y >> 1); | |
270 | 321604 | a[i] = (diffc * v + add) >> y; | |
271 | 321604 | k[i] = FFMAX(1, 3 + x -y); | |
272 |
2/2✓ Branch 0 taken 69083 times.
✓ Branch 1 taken 91719 times.
|
321604 | sign = a[i] < 0 ? -1 : (a[i] > 0); |
273 |
2/2✓ Branch 0 taken 81 times.
✓ Branch 1 taken 160721 times.
|
321604 | a[i] = ((3 + x - y) < 1) ? sign * 15 : a[i]; |
274 | 321604 | b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]); | |
275 | } | ||
276 | |||
277 | } | ||
278 | |||
279 | #undef TOP | ||
280 | #undef LEFT | ||
281 | |||
282 | 165080 | 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 | 165080 | const int hs = fc->ps.sps->hshift[1]; | |
287 | 165080 | const int vs = fc->ps.sps->vshift[1]; | |
288 | 165080 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
289 | 165080 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + y0 * stride; | |
290 | 165080 | const pixel *left = source - avail_l; | |
291 | 165080 | const pixel *top = source - avail_t * stride; | |
292 | |||
293 | 165080 | const VVCSPS *sps = fc->ps.sps; | |
294 |
3/4✓ Branch 0 taken 12944 times.
✓ Branch 1 taken 69596 times.
✓ Branch 2 taken 12944 times.
✗ Branch 3 not taken.
|
165080 | if (!hs && !vs) { |
295 |
2/2✓ Branch 0 taken 178996 times.
✓ Branch 1 taken 12944 times.
|
383880 | for (int i = 0; i < h; i++) |
296 | 357992 | memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel)); | |
297 | 25888 | return; | |
298 | } | ||
299 |
2/2✓ Branch 0 taken 641100 times.
✓ Branch 1 taken 69596 times.
|
1421392 | for (int i = 0; i < h; i++) { |
300 | 1282200 | const pixel *src = source; | |
301 | 1282200 | const pixel *l = left; | |
302 | 1282200 | const pixel *t = top; | |
303 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 641100 times.
|
1282200 | 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 54676 times.
✓ Branch 1 taken 586424 times.
|
1282200 | 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 8386384 times.
✓ Branch 1 taken 586424 times.
|
17945616 | for (int j = 0; j < w; j++) { |
322 | 16772768 | pixel pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
323 | |||
324 | 16772768 | pdsy[i * w + j] = pred; | |
325 | 16772768 | src += 2; | |
326 | 16772768 | l = src - 1; | |
327 | } | ||
328 | } | ||
329 | } | ||
330 | 1282200 | source += (stride << vs); | |
331 | 1282200 | left += (stride << vs); | |
332 | 1282200 | top = source - stride; | |
333 | } | ||
334 | } | ||
335 | |||
336 | 472 | 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 472 times.
✓ Branch 1 taken 236 times.
|
1416 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
340 | 944 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
341 | 944 | pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
342 |
2/2✓ Branch 0 taken 9356 times.
✓ Branch 1 taken 472 times.
|
19656 | for (int i = 0; i < h; i++) { |
343 |
2/2✓ Branch 0 taken 257664 times.
✓ Branch 1 taken 9356 times.
|
534040 | for (int j = 0; j < w; j++) { |
344 | 515328 | dst[j] = 1 << (BIT_DEPTH - 1); | |
345 | } | ||
346 | 18712 | dst += stride; | |
347 | } | ||
348 | } | ||
349 | 472 | } | |
350 | |||
351 | //8.4.5.2.14 Specification of INTRA_LT_CCLM, INTRA_L_CCLM and INTRA_T_CCLM intra prediction mode | ||
352 | 165552 | static void FUNC(intra_cclm_pred)(const VVCLocalContext *lc, const int x0, const int y0, | |
353 | const int width, const int height) | ||
354 | { | ||
355 | 165552 | VVCFrameContext *fc = lc->fc; | |
356 | 165552 | const VVCSPS *sps = fc->ps.sps; | |
357 | 165552 | const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0); | |
358 | 165552 | const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0); | |
359 | 165552 | const int hs = sps->hshift[1]; | |
360 | 165552 | const int vs = sps->vshift[1]; | |
361 | 165552 | const int x = x0 >> hs; | |
362 | 165552 | const int y = y0 >> vs; | |
363 | 165552 | const int w = width >> hs; | |
364 | 165552 | 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 3069 times.
✓ Branch 1 taken 79707 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 2833 times.
|
165552 | if (!avail_t && !avail_l) { |
369 | 472 | FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l); | |
370 | 472 | return; | |
371 | } | ||
372 | 165080 | FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy); | |
373 | 165080 | FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k); | |
374 | 165080 | FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k); | |
375 | } | ||
376 | |||
377 | 33992 | static int FUNC(lmcs_sum_samples)(const pixel *start, ptrdiff_t stride, const int avail, const int target_size) | |
378 | { | ||
379 | 33992 | const int size = FFMIN(avail, target_size); | |
380 | 33992 | int sum = 0; | |
381 |
2/2✓ Branch 0 taken 1070880 times.
✓ Branch 1 taken 16996 times.
|
2175752 | for (int i = 0; i < size; i++) { |
382 | 2141760 | sum += *start; | |
383 | 2141760 | start += stride; | |
384 | } | ||
385 | 33992 | sum += *(start - stride) * (target_size - size); | |
386 | 33992 | return sum; | |
387 | } | ||
388 | |||
389 | // 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples | ||
390 | 212018 | static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, const int y0) | |
391 | { | ||
392 | 212018 | VVCFrameContext *fc = lc->fc; | |
393 | 212018 | const VVCLMCS *lmcs = &fc->ps.lmcs; | |
394 | 212018 | const int size_y = FFMIN(fc->ps.sps->ctb_size_y, 64); | |
395 | |||
396 | 212018 | const int x = x0 & ~(size_y - 1); | |
397 | 212018 | const int y = y0 & ~(size_y - 1); | |
398 |
4/4✓ Branch 0 taken 97191 times.
✓ Branch 1 taken 8818 times.
✓ Branch 2 taken 681 times.
✓ Branch 3 taken 96510 times.
|
212018 | if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) { |
399 | 18998 | int cnt = 0, luma = 0, i; | |
400 | 18998 | const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift)); | |
401 | 18998 | const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel); | |
402 | 18998 | const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0); | |
403 | 18998 | const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0); | |
404 |
2/2✓ Branch 0 taken 8755 times.
✓ Branch 1 taken 744 times.
|
18998 | if (avail_l) { |
405 | 17510 | luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y); | |
406 | 17510 | cnt = size_y; | |
407 | } | ||
408 |
2/2✓ Branch 0 taken 8241 times.
✓ Branch 1 taken 1258 times.
|
18998 | if (avail_t) { |
409 | 16482 | luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y); | |
410 | 16482 | cnt += size_y; | |
411 | } | ||
412 |
2/2✓ Branch 0 taken 9335 times.
✓ Branch 1 taken 164 times.
|
18998 | if (cnt) |
413 | 18670 | luma = (luma + (cnt >> 1)) >> av_log2(cnt); | |
414 | else | ||
415 | 328 | luma = 1 << (BIT_DEPTH - 1); | |
416 | |||
417 |
1/2✓ Branch 0 taken 60548 times.
✗ Branch 1 not taken.
|
121096 | for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) { |
418 |
2/2✓ Branch 0 taken 9499 times.
✓ Branch 1 taken 51049 times.
|
121096 | if (luma < lmcs->pivot[i + 1]) |
419 | 18998 | break; | |
420 | } | ||
421 | 18998 | i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1); | |
422 | |||
423 | 18998 | lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i]; | |
424 | 18998 | lc->lmcs.x_vpdu = x; | |
425 | 18998 | lc->lmcs.y_vpdu = y; | |
426 | } | ||
427 | 212018 | 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 | 212018 | 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 | 212018 | const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu); | |
435 | |||
436 |
2/2✓ Branch 0 taken 1242162 times.
✓ Branch 1 taken 106009 times.
|
2696342 | for (int y = 0; y < height; y++) { |
437 |
2/2✓ Branch 0 taken 21423560 times.
✓ Branch 1 taken 1242162 times.
|
45331444 | for (int x = 0; x < width; x++) { |
438 | 42847120 | const int c = av_clip_intp2(*coeff, BIT_DEPTH); | |
439 | |||
440 |
2/2✓ Branch 0 taken 9307817 times.
✓ Branch 1 taken 12115743 times.
|
42847120 | if (c > 0) |
441 | 18615634 | *dst = (c * chroma_scale + (1 << 10)) >> 11; | |
442 | else | ||
443 | 24231486 | *dst = -((-c * chroma_scale + (1 << 10)) >> 11); | |
444 | 42847120 | coeff++; | |
445 | 42847120 | dst++; | |
446 | } | ||
447 | } | ||
448 | 212018 | } | |
449 | |||
450 | 234964 | 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 | 234964 | filtered_left[-1] = filtered_top[-1] = (left[0] + 2 * left[-1] + top[0] + 2 ) >> 2; | |
455 |
2/2✓ Branch 0 taken 1956622 times.
✓ Branch 1 taken 117482 times.
|
4148208 | for (int i = 0; i < left_size - unfilter_last_one; i++) { |
456 | 3913244 | filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2; | |
457 | } | ||
458 |
2/2✓ Branch 0 taken 2272482 times.
✓ Branch 1 taken 117482 times.
|
4779928 | for (int i = 0; i < top_size - unfilter_last_one; i++) { |
459 | 4544964 | filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2; | |
460 | } | ||
461 |
2/2✓ Branch 0 taken 5118 times.
✓ Branch 1 taken 112364 times.
|
234964 | if (unfilter_last_one) { |
462 | 10236 | filtered_top[top_size - 1] = top[top_size - 1]; | |
463 | 10236 | filtered_left[left_size - 1] = left[left_size - 1]; | |
464 | } | ||
465 | 234964 | } | |
466 | |||
467 | 1904736 | 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 | 1904736 | const CodingUnit *cu = lc->cu; | |
478 |
2/2✓ Branch 0 taken 854097 times.
✓ Branch 1 taken 98271 times.
|
1904736 | const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode); |
479 |
4/4✓ Branch 0 taken 497827 times.
✓ Branch 1 taken 424395 times.
✓ Branch 2 taken 356423 times.
✓ Branch 3 taken 141404 times.
|
1844444 | const int filter_flag = !ref_idx && w * h > 32 && !c_idx && |
480 |
6/6✓ Branch 0 taken 922222 times.
✓ Branch 1 taken 30146 times.
✓ Branch 2 taken 300778 times.
✓ Branch 3 taken 55645 times.
✓ Branch 4 taken 117482 times.
✓ Branch 5 taken 183296 times.
|
3749180 | cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag; |
481 | 1904736 | int cand_up_left = lc->na.cand_up_left; | |
482 | 1904736 | pixel *left = (pixel*)edge->left_array + MAX_TB_SIZE + 3; | |
483 | 1904736 | pixel *top = (pixel*)edge->top_array + MAX_TB_SIZE + 3; | |
484 | 1904736 | pixel *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3; | |
485 | 1904736 | pixel *filtered_top = (pixel*)edge->filtered_top_array + MAX_TB_SIZE + 3; | |
486 | 1904736 | 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 854097 times.
✓ Branch 1 taken 98271 times.
✓ Branch 2 taken 353681 times.
✓ Branch 3 taken 500416 times.
|
1904736 | if (is_intra_mip || mode == INTRA_PLANAR) { |
494 | 903904 | left_size = h + 1; | |
495 | 903904 | top_size = w + 1; | |
496 | 903904 | unfilter_left_size = left_size + filter_flag; | |
497 | 903904 | unfilter_top_size = top_size + filter_flag; | |
498 |
2/2✓ Branch 0 taken 60439 times.
✓ Branch 1 taken 439977 times.
|
1000832 | } else if (mode == INTRA_DC) { |
499 | 120878 | unfilter_left_size = left_size = h; | |
500 | 120878 | unfilter_top_size = top_size = w; | |
501 |
2/2✓ Branch 0 taken 46845 times.
✓ Branch 1 taken 393132 times.
|
879954 | } else if (mode == INTRA_VERT) { |
502 | //we may need 1 pixel to predict the top left. | ||
503 |
2/2✓ Branch 0 taken 41097 times.
✓ Branch 1 taken 5748 times.
|
93690 | unfilter_left_size = left_size = need_pdpc ? h : 1; |
504 | 93690 | unfilter_top_size = top_size = w; | |
505 |
2/2✓ Branch 0 taken 46627 times.
✓ Branch 1 taken 346505 times.
|
786264 | } else if (mode == INTRA_HORZ) { |
506 | 93254 | 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 37018 times.
✓ Branch 1 taken 9609 times.
|
93254 | unfilter_top_size = top_size = need_pdpc ? w : 1; |
509 | } else { | ||
510 |
4/4✓ Branch 0 taken 88273 times.
✓ Branch 1 taken 258232 times.
✓ Branch 2 taken 2868 times.
✓ Branch 3 taken 85405 times.
|
693010 | if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) { |
511 | 522200 | refw = w * 2; | |
512 | 522200 | refh = h * 2; | |
513 | } else { | ||
514 | 170810 | refw = cu->cb_width + w; | |
515 | 170810 | refh = cu->cb_height + h; | |
516 | } | ||
517 | 693010 | intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
518 | 693010 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
519 | 693010 | unfilter_top_size = top_size = refw; | |
520 | 693010 | unfilter_left_size = left_size = refh; | |
521 | } | ||
522 | |||
523 | 1904736 | left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx); | |
524 |
2/2✓ Branch 0 taken 10154098 times.
✓ Branch 1 taken 952368 times.
|
22212932 | for (i = 0; i < left_available; i++) |
525 | 20308196 | left[i] = POS(ref_line, i); | |
526 | |||
527 | 1904736 | top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx); | |
528 | 1904736 | memcpy(top, src + ref_line * stride, top_available * sizeof(pixel)); | |
529 | |||
530 |
2/2✓ Branch 0 taken 1001276 times.
✓ Branch 1 taken 952368 times.
|
3907288 | for (int i = -1; i >= ref_line; i--) { |
531 |
2/2✓ Branch 0 taken 960957 times.
✓ Branch 1 taken 40319 times.
|
2002552 | if (cand_up_left) { |
532 | 1921914 | left[i] = POS(ref_line, i); | |
533 | 1921914 | top[i] = POS(i, ref_line); | |
534 |
2/2✓ Branch 0 taken 18705 times.
✓ Branch 1 taken 21614 times.
|
80638 | } else if (left_available) { |
535 | 37410 | left[i] = top[i] = left[0]; | |
536 |
2/2✓ Branch 0 taken 20881 times.
✓ Branch 1 taken 733 times.
|
43228 | } else if (top_available) { |
537 | 41762 | left[i] = top[i] = top[0]; | |
538 | } else { | ||
539 | 1466 | left[i] = top[i] = 1 << (BIT_DEPTH - 1); | |
540 | } | ||
541 | } | ||
542 | |||
543 |
2/2✓ Branch 0 taken 3342839 times.
✓ Branch 1 taken 952368 times.
|
8590414 | EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available); |
544 |
2/2✓ Branch 0 taken 2504234 times.
✓ Branch 1 taken 952368 times.
|
6913204 | EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available); |
545 | |||
546 |
2/2✓ Branch 0 taken 375614 times.
✓ Branch 1 taken 576754 times.
|
1904736 | if (ref_filter_flag) { |
547 |
8/8✓ Branch 0 taken 374955 times.
✓ Branch 1 taken 659 times.
✓ Branch 2 taken 215265 times.
✓ Branch 3 taken 159690 times.
✓ Branch 4 taken 144283 times.
✓ Branch 5 taken 70982 times.
✓ Branch 6 taken 117482 times.
✓ Branch 7 taken 26801 times.
|
751228 | if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) { |
548 | 234964 | const int unfilter_last_one = left_size == unfilter_left_size; | |
549 | 234964 | FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one); | |
550 | 234964 | left = filtered_left; | |
551 | 234964 | top = filtered_top; | |
552 | } | ||
553 | } | ||
554 |
6/6✓ Branch 0 taken 854097 times.
✓ Branch 1 taken 98271 times.
✓ Branch 2 taken 500416 times.
✓ Branch 3 taken 353681 times.
✓ Branch 4 taken 439977 times.
✓ Branch 5 taken 60439 times.
|
1904736 | if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) { |
555 |
6/6✓ Branch 0 taken 418044 times.
✓ Branch 1 taken 21933 times.
✓ Branch 2 taken 392684 times.
✓ Branch 3 taken 25360 times.
✓ Branch 4 taken 105316 times.
✓ Branch 5 taken 287368 times.
|
879954 | if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) { |
556 | 305218 | edge->filter_flag = 0; | |
557 | } else { | ||
558 | 574736 | const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18)); | |
559 | 574736 | const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0}; | |
560 | 574736 | const int ntbs = (av_log2(w) + av_log2(h)) >> 1; | |
561 | 574736 | edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2]; | |
562 | } | ||
563 | |||
564 |
4/4✓ Branch 0 taken 393132 times.
✓ Branch 1 taken 46845 times.
✓ Branch 2 taken 346505 times.
✓ Branch 3 taken 46627 times.
|
879954 | if (mode != INTRA_VERT && mode != INTRA_HORZ) { |
565 |
2/2✓ Branch 0 taken 179314 times.
✓ Branch 1 taken 167191 times.
|
693010 | if (mode >= INTRA_DIAG) { |
566 |
2/2✓ Branch 0 taken 92870 times.
✓ Branch 1 taken 86444 times.
|
358628 | if (intra_pred_angle < 0) { |
567 | 185740 | pixel *p = top - (ref_idx + 1); | |
568 |
2/2✓ Branch 0 taken 779664 times.
✓ Branch 1 taken 92870 times.
|
1745068 | for (int x = -h; x < 0; x++) { |
569 | 1559328 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h); | |
570 | 1559328 | p[x] = left[idx]; | |
571 | } | ||
572 | } else { | ||
573 |
2/2✓ Branch 0 taken 185439 times.
✓ Branch 1 taken 86444 times.
|
543766 | for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++) |
574 | 370878 | top[i] = top[refw - 1]; | |
575 | } | ||
576 | } else { | ||
577 |
2/2✓ Branch 0 taken 88506 times.
✓ Branch 1 taken 78685 times.
|
334382 | if (intra_pred_angle < 0) { |
578 | 177012 | pixel *p = left - (ref_idx + 1); | |
579 |
2/2✓ Branch 0 taken 1387784 times.
✓ Branch 1 taken 88506 times.
|
2952580 | for (int x = -w; x < 0; x++) { |
580 | 2775568 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w); | |
581 | 2775568 | p[x] = top[idx]; | |
582 | } | ||
583 | } else { | ||
584 |
2/2✓ Branch 0 taken 169378 times.
✓ Branch 1 taken 78685 times.
|
496126 | for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++) |
585 | 338756 | left[i] = left[refh - 1]; | |
586 | } | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | 1904736 | edge->left = (uint8_t*)left; | |
591 | 1904736 | edge->top = (uint8_t*)top; | |
592 | 1904736 | } | |
593 | |||
594 | //8.4.1 General decoding process for coding units coded in intra prediction mode | ||
595 | 1904736 | static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0, | |
596 | const int width, const int height, int c_idx) | ||
597 | { | ||
598 | 1904736 | VVCFrameContext *fc = lc->fc; | |
599 | 1904736 | const VVCSPS *sps = fc->ps.sps; | |
600 | 1904736 | const VVCPPS *pps = fc->ps.pps; | |
601 | 1904736 | const CodingUnit *cu = lc->cu; | |
602 | 1904736 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
603 | 1904736 | const int min_cb_width = pps->min_cb_width; | |
604 | 1904736 | const int x_cb = x0 >> log2_min_cb_size; | |
605 | 1904736 | const int y_cb = y0 >> log2_min_cb_size; | |
606 | |||
607 | 1904736 | const int hshift = fc->ps.sps->hshift[c_idx]; | |
608 | 1904736 | const int vshift = fc->ps.sps->vshift[c_idx]; | |
609 | 1904736 | const int x = x0 >> hshift; | |
610 | 1904736 | const int y = y0 >> vshift; | |
611 | 1904736 | const int w = width >> hshift; | |
612 | 1904736 | const int h = height >> vshift; | |
613 | 1904736 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
614 | |||
615 |
2/2✓ Branch 0 taken 267568 times.
✓ Branch 1 taken 684800 times.
|
1904736 | const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y; |
616 | 1904736 | const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode); | |
617 | |||
618 | 1904736 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
619 |
6/6✓ Branch 0 taken 145347 times.
✓ Branch 1 taken 807021 times.
✓ Branch 2 taken 47364 times.
✓ Branch 3 taken 97983 times.
✓ Branch 4 taken 288 times.
✓ Branch 5 taken 47076 times.
|
1904736 | const int is_intra_mip = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag); |
620 |
2/2✓ Branch 0 taken 684800 times.
✓ Branch 1 taken 267568 times.
|
1904736 | const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx; |
621 | 1904736 | const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx); | |
622 | |||
623 | |||
624 | 1904736 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
625 | IntraEdgeParams edge; | ||
626 | |||
627 | 1904736 | 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 98271 times.
✓ Branch 1 taken 854097 times.
|
1904736 | if (is_intra_mip) { |
630 | 196542 | int intra_mip_transposed_flag = SAMPLE_CTB(fc->tab.imtf, x_cb, y_cb); | |
631 | 196542 | int intra_mip_mode = SAMPLE_CTB(fc->tab.imm, x_cb, y_cb); | |
632 | |||
633 | 196542 | 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 353681 times.
✓ Branch 1 taken 500416 times.
|
1708194 | } else if (mode == INTRA_PLANAR) { |
636 | 707362 | fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
637 |
2/2✓ Branch 0 taken 60439 times.
✓ Branch 1 taken 439977 times.
|
1000832 | } else if (mode == INTRA_DC) { |
638 | 120878 | fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
639 |
2/2✓ Branch 0 taken 46845 times.
✓ Branch 1 taken 393132 times.
|
879954 | } else if (mode == INTRA_VERT) { |
640 | 93690 | fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride); | |
641 |
2/2✓ Branch 0 taken 46627 times.
✓ Branch 1 taken 346505 times.
|
786264 | } else if (mode == INTRA_HORZ) { |
642 | 93254 | fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride); | |
643 | } else { | ||
644 |
2/2✓ Branch 0 taken 179314 times.
✓ Branch 1 taken 167191 times.
|
693010 | if (mode >= INTRA_DIAG) { |
645 | 358628 | 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 | 334382 | 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 610779 times.
✓ Branch 1 taken 341589 times.
|
1904736 | if (need_pdpc) { |
655 | //8.4.5.2.15 Position-dependent intra prediction sample filtering process | ||
656 |
8/8✓ Branch 0 taken 525072 times.
✓ Branch 1 taken 85707 times.
✓ Branch 2 taken 203985 times.
✓ Branch 3 taken 321087 times.
✓ Branch 4 taken 151347 times.
✓ Branch 5 taken 52638 times.
✓ Branch 6 taken 110250 times.
✓ Branch 7 taken 41097 times.
|
1221558 | if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC || |
657 |
2/2✓ Branch 0 taken 37018 times.
✓ Branch 1 taken 73232 times.
|
220500 | mode == INTRA_VERT || mode == INTRA_HORZ)) { |
658 | 903680 | const int scale = (av_log2(w) + av_log2(h) - 2) >> 2; | |
659 | 903680 | const pixel *left = (pixel*)edge.left; | |
660 | 903680 | const pixel *top = (pixel*)edge.top; | |
661 |
2/2✓ Branch 0 taken 4846552 times.
✓ Branch 1 taken 451840 times.
|
10596784 | for (int y = 0; y < h; y++) { |
662 |
2/2✓ Branch 0 taken 82751696 times.
✓ Branch 1 taken 4846552 times.
|
175196496 | for (int x = 0; x < w; x++) { |
663 | int l, t, wl, wt, pred; | ||
664 | pixel val; | ||
665 |
4/4✓ Branch 0 taken 23692848 times.
✓ Branch 1 taken 59058848 times.
✓ Branch 2 taken 9566320 times.
✓ Branch 3 taken 14126528 times.
|
165503392 | if (mode == INTRA_PLANAR || mode == INTRA_DC) { |
666 | 137250336 | l = left[y]; | |
667 | 137250336 | t = top[x]; | |
668 | 137250336 | wl = 32 >> FFMIN((x << 1) >> scale, 31); | |
669 | 137250336 | wt = 32 >> FFMIN((y << 1) >> scale, 31); | |
670 | } else { | ||
671 | 28253056 | l = left[y] - left[-1] + POS(x,y); | |
672 | 28253056 | t = top[x] - top[-1] + POS(x,y); | |
673 |
2/2✓ Branch 0 taken 6529952 times.
✓ Branch 1 taken 7596576 times.
|
28253056 | wl = (mode == INTRA_VERT) ? (32 >> FFMIN((x << 1) >> scale, 31)) : 0; |
674 |
2/2✓ Branch 0 taken 7596576 times.
✓ Branch 1 taken 6529952 times.
|
28253056 | wt = (mode == INTRA_HORZ) ? (32 >> FFMIN((y << 1) >> scale, 31)) : 0; |
675 | } | ||
676 | 165503392 | val = POS(x, y); | |
677 | 165503392 | pred = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6); | |
678 | 165503392 | POS(x, y) = CLIP(pred); | |
679 | } | ||
680 | } | ||
681 | } | ||
682 | } | ||
683 | 1904736 | } | |
684 | |||
685 | //8.4.5.2.11 Specification of INTRA_PLANAR intra prediction mode | ||
686 | 707362 | 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 | 707362 | pixel *src = (pixel *)_src; | |
691 | 707362 | const pixel *top = (const pixel *)_top; | |
692 | 707362 | const pixel *left = (const pixel *)_left; | |
693 | 707362 | const int logw = av_log2(w); | |
694 | 707362 | const int logh = av_log2(h); | |
695 | 707362 | const int size = w * h; | |
696 | 707362 | const int shift = (logw + logh + 1); | |
697 |
2/2✓ Branch 0 taken 3534480 times.
✓ Branch 1 taken 353681 times.
|
7776322 | for (y = 0; y < h; y++) { |
698 |
2/2✓ Branch 0 taken 59903712 times.
✓ Branch 1 taken 3534480 times.
|
126876384 | for (x = 0; x < w; x++) { |
699 | 119807424 | const int pred_v = ((h - 1 - y) * top[x] + (y + 1) * left[h]) << logw; | |
700 | 119807424 | const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh; | |
701 | 119807424 | const int pred = (pred_v + pred_h + size) >> shift; | |
702 | 119807424 | POS(x, y) = pred; | |
703 | } | ||
704 | } | ||
705 | 707362 | } | |
706 | |||
707 | //8.4.5.2.3 MIP boundary sample downsampling process | ||
708 | 393084 | 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 | 393084 | const int b_dwn = n_tb_s / boundary_size; | |
712 | 393084 | const int log2 = av_log2(b_dwn); | |
713 | |||
714 |
2/2✓ Branch 0 taken 35062 times.
✓ Branch 1 taken 161480 times.
|
393084 | if (boundary_size == n_tb_s) { |
715 |
2/2✓ Branch 0 taken 140248 times.
✓ Branch 1 taken 35062 times.
|
350620 | for (int i = 0; i < n_tb_s; i++) |
716 | 280496 | reduced[i] = ref[i]; | |
717 | 70124 | return; | |
718 | } | ||
719 |
2/2✓ Branch 0 taken 604444 times.
✓ Branch 1 taken 161480 times.
|
1531848 | for (int i = 0; i < boundary_size; i++) { |
720 | int r; | ||
721 | 1208888 | r = *ref++; | |
722 |
2/2✓ Branch 0 taken 1733644 times.
✓ Branch 1 taken 604444 times.
|
4676176 | for (int j = 1; j < b_dwn; j++) |
723 | 3467288 | r += *ref++; | |
724 | 1208888 | reduced[i] = (r + (1 << (log2 - 1))) >> log2; | |
725 | } | ||
726 | } | ||
727 | |||
728 | 196542 | 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 | 196542 | src = &POS(up_hor - 1, up_ver - 1); | |
733 |
2/2✓ Branch 0 taken 563664 times.
✓ Branch 1 taken 98271 times.
|
1323870 | for (int y = 0; y < pred_size; y++) { |
734 |
2/2✓ Branch 0 taken 3619296 times.
✓ Branch 1 taken 563664 times.
|
8365920 | for (int x = 0; x < pred_size; x++) { |
735 | 7238592 | int pred = 0; | |
736 |
2/2✓ Branch 0 taken 25561472 times.
✓ Branch 1 taken 3619296 times.
|
58361536 | for (int i = 0; i < reduced_size; i++) |
737 | 51122944 | pred += reduced[i] * matrix[i]; | |
738 | 7238592 | matrix += reduced_size; | |
739 | 7238592 | pred = ((pred + ow) >> 6) + temp0; | |
740 | 7238592 | pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1); | |
741 |
2/2✓ Branch 0 taken 1823520 times.
✓ Branch 1 taken 1795776 times.
|
7238592 | if (is_transposed) |
742 | 3647040 | POS(y * up_hor, x * up_ver) = pred; | |
743 | else | ||
744 | 3591552 | POS(x * up_hor, y * up_ver) = pred; | |
745 | } | ||
746 | } | ||
747 | 196542 | } | |
748 | |||
749 | 235840 | 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 1135172 times.
✓ Branch 1 taken 117920 times.
|
2506184 | for (int i = 0; i < dst_height; i++) { |
754 | 2270344 | const pixel *before = boundary; | |
755 | 2270344 | const pixel *after = dst - dst_step; | |
756 | 2270344 | pixel *d = dst; | |
757 |
2/2✓ Branch 0 taken 8031024 times.
✓ Branch 1 taken 1135172 times.
|
18332392 | for (int j = 0; j < pred_size; j++) { |
758 | 16062048 | after += dst_step * factor; | |
759 |
2/2✓ Branch 0 taken 16958576 times.
✓ Branch 1 taken 8031024 times.
|
49979200 | for (int k = 1; k < factor; k++) { |
760 | 33917152 | int mid = (factor - k) * (*before) + k * (*after); | |
761 | 33917152 | *d = (mid + factor / 2) / factor; | |
762 | 33917152 | d += dst_step; | |
763 | } | ||
764 | 16062048 | before = after; | |
765 | 16062048 | d += dst_step; | |
766 | } | ||
767 | 2270344 | boundary += boundary_step; | |
768 | 2270344 | dst += dst_stride; | |
769 | } | ||
770 | 235840 | } | |
771 | |||
772 | //8.4.5.2.2 Matrix-based intra sample prediction | ||
773 | 196542 | 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 | 196542 | pixel *src = (pixel *)_src; | |
778 | 196542 | const pixel *top = (const pixel *)_top; | |
779 | 196542 | const pixel *left = (const pixel *)_left; | |
780 | |||
781 | 196542 | 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 | 196542 | const int boundary_size = boundary_sizes[size_id]; | |
785 | 196542 | const int pred_size = pred_sizes[size_id]; | |
786 | 196542 | const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0); | |
787 | 196542 | const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id); | |
788 | 196542 | const int up_hor = w / pred_size; | |
789 | 196542 | const int up_ver = h / pred_size; | |
790 | |||
791 | int reduced[16]; | ||
792 | 196542 | int *red_t = reduced; | |
793 | 196542 | int *red_l = reduced + boundary_size; | |
794 | 196542 | int off = 1, ow = 0; | |
795 | int temp0; | ||
796 | |||
797 |
2/2✓ Branch 0 taken 50325 times.
✓ Branch 1 taken 47946 times.
|
196542 | if (is_transposed) { |
798 | 100650 | FFSWAP(int*, red_t, red_l); | |
799 | } | ||
800 | 196542 | FUNC(mip_downsampling)(red_t, boundary_size, top, w); | |
801 | 196542 | FUNC(mip_downsampling)(red_l, boundary_size, left, h); | |
802 | |||
803 | 196542 | temp0 = reduced[0]; | |
804 |
2/2✓ Branch 0 taken 55626 times.
✓ Branch 1 taken 42645 times.
|
196542 | if (size_id != 2) { |
805 | 111252 | off = 0; | |
806 | 111252 | ow = (1 << (BIT_DEPTH - 1)) - temp0; | |
807 | } else { | ||
808 | 85290 | ow = reduced[1] - temp0; | |
809 | } | ||
810 | 196542 | reduced[0] = ow; | |
811 |
2/2✓ Branch 0 taken 603776 times.
✓ Branch 1 taken 98271 times.
|
1404094 | for (int i = 1; i < in_size; i++) { |
812 | 1207552 | reduced[i] = reduced[i + off] - temp0; | |
813 | 1207552 | ow += reduced[i]; | |
814 | } | ||
815 | 196542 | ow = 32 - 32 * ow; | |
816 | |||
817 | 196542 | 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 31375 times.
✓ Branch 1 taken 66896 times.
✓ Branch 2 taken 21006 times.
✓ Branch 3 taken 10369 times.
|
196542 | if (up_hor > 1 || up_ver > 1) { |
819 |
2/2✓ Branch 0 taken 66896 times.
✓ Branch 1 taken 21006 times.
|
175804 | if (up_hor > 1) |
820 | 133792 | 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 51024 times.
✓ Branch 1 taken 36878 times.
|
175804 | if (up_ver > 1) |
822 | 102048 | FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size); | |
823 | } | ||
824 | 196542 | } | |
825 | |||
826 | 120878 | 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 | 120878 | int sum = 0; | |
831 |
2/2✓ Branch 0 taken 20216 times.
✓ Branch 1 taken 40223 times.
|
120878 | unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h); |
832 | 120878 | const int shift = av_log2(offset); | |
833 | 120878 | offset >>= 1; | |
834 |
2/2✓ Branch 0 taken 47058 times.
✓ Branch 1 taken 13381 times.
|
120878 | if (w >= h) { |
835 |
2/2✓ Branch 0 taken 720832 times.
✓ Branch 1 taken 47058 times.
|
1535780 | for (int i = 0; i < w; i++) |
836 | 1441664 | sum += top[i]; | |
837 | } | ||
838 |
2/2✓ Branch 0 taken 33597 times.
✓ Branch 1 taken 26842 times.
|
120878 | if (w <= h) { |
839 |
2/2✓ Branch 0 taken 435232 times.
✓ Branch 1 taken 33597 times.
|
937658 | for (int i = 0; i < h; i++) |
840 | 870464 | sum += left[i]; | |
841 | } | ||
842 | 120878 | dc_val = (sum + offset) >> shift; | |
843 | 120878 | return dc_val; | |
844 | } | ||
845 | |||
846 | //8.4.5.2.12 Specification of INTRA_DC intra prediction mode | ||
847 | 120878 | 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 | 120878 | pixel *src = (pixel *)_src; | |
852 | 120878 | const pixel *top = (const pixel *)_top; | |
853 | 120878 | const pixel *left = (const pixel *)_left; | |
854 | 120878 | const pixel dc = FUNC(pred_dc_val)(top, left, w, h); | |
855 | 120878 | const pixel4 a = PIXEL_SPLAT_X4(dc); | |
856 |
2/2✓ Branch 0 taken 592008 times.
✓ Branch 1 taken 60439 times.
|
1304894 | for (y = 0; y < h; y++) { |
857 | 1184016 | pixel *s = src; | |
858 |
2/2✓ Branch 0 taken 2583880 times.
✓ Branch 1 taken 592008 times.
|
6351776 | for (x = 0; x < w; x += 4) { |
859 | 5167760 | AV_WN4P(s, a); | |
860 | 5167760 | s += 4; | |
861 | } | ||
862 | 1184016 | src += stride; | |
863 | } | ||
864 | 120878 | } | |
865 | |||
866 | 93690 | 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 | 93690 | pixel *src = (pixel *)_src; | |
870 | 93690 | const pixel *top = (const pixel *)_top; | |
871 |
2/2✓ Branch 0 taken 467080 times.
✓ Branch 1 taken 46845 times.
|
1027850 | for (int y = 0; y < h; y++) { |
872 | 934160 | memcpy(src, top, sizeof(pixel) * w); | |
873 | 934160 | src += stride; | |
874 | } | ||
875 | 93690 | } | |
876 | |||
877 | 93254 | 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 | 93254 | pixel *src = (pixel *)_src; | |
881 | 93254 | const pixel *left = (const pixel *)_left; | |
882 |
2/2✓ Branch 0 taken 423388 times.
✓ Branch 1 taken 46627 times.
|
940030 | for (int y = 0; y < h; y++) { |
883 | 846776 | const pixel4 a = PIXEL_SPLAT_X4(left[y]); | |
884 |
2/2✓ Branch 0 taken 2050708 times.
✓ Branch 1 taken 423388 times.
|
4948192 | for (int x = 0; x < w; x += 4) { |
885 | 4101416 | AV_WN4P(&POS(x, y), a); | |
886 | } | ||
887 | } | ||
888 | 93254 | } | |
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 | 358628 | 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 | 358628 | pixel *src = (pixel *)_src; | |
899 | 358628 | const pixel *left = (const pixel *)_left; | |
900 | 358628 | const pixel *top = (const pixel *)_top - (1 + ref_idx); | |
901 | 358628 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
902 | 358628 | int pos = (1 + ref_idx) * intra_pred_angle; | |
903 | 358628 | const int dp = intra_pred_angle; | |
904 | 358628 | const int is_luma = !c_idx; | |
905 | int nscale, inv_angle; | ||
906 | |||
907 |
2/2✓ Branch 0 taken 39594 times.
✓ Branch 1 taken 139720 times.
|
358628 | if (need_pdpc) { |
908 | 79188 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
909 | 79188 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
910 | } | ||
911 | |||
912 |
2/2✓ Branch 0 taken 1411960 times.
✓ Branch 1 taken 179314 times.
|
3182548 | for (int y = 0; y < h; y++) { |
913 | 2823920 | const int idx = (pos >> 5) + ref_idx; | |
914 | 2823920 | const int fact = pos & 31; | |
915 |
6/6✓ Branch 0 taken 213112 times.
✓ Branch 1 taken 1198848 times.
✓ Branch 2 taken 135830 times.
✓ Branch 3 taken 77282 times.
✓ Branch 4 taken 112988 times.
✓ Branch 5 taken 22842 times.
|
2823920 | if (!fact && (!is_luma || !filter_flag)) { |
916 |
2/2✓ Branch 0 taken 2077540 times.
✓ Branch 1 taken 190270 times.
|
4535620 | for (int x = 0; x < w; x++) { |
917 | 4155080 | const pixel *p = top + x + idx + 1; | |
918 | 4155080 | POS(x, y) = *p; | |
919 | } | ||
920 | } else { | ||
921 |
2/2✓ Branch 0 taken 953092 times.
✓ Branch 1 taken 268598 times.
|
2443380 | if (!c_idx) { |
922 | 1906184 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
923 |
2/2✓ Branch 0 taken 10751124 times.
✓ Branch 1 taken 953092 times.
|
23408432 | for (int x = 0; x < w; x++) { |
924 | 21502248 | const pixel *p = top + x + idx; | |
925 | 21502248 | POS(x, y) = INTRA_LUMA_FILTER(p); | |
926 | } | ||
927 | } else { | ||
928 |
2/2✓ Branch 0 taken 2506056 times.
✓ Branch 1 taken 268598 times.
|
5549308 | for (int x = 0; x < w; x++) { |
929 | 5012112 | const pixel *p = top + x + idx; | |
930 | 5012112 | POS(x, y) = INTRA_CHROMA_FILTER(p); | |
931 | } | ||
932 | } | ||
933 | } | ||
934 |
2/2✓ Branch 0 taken 353672 times.
✓ Branch 1 taken 1058288 times.
|
2823920 | if (need_pdpc) { |
935 | 707344 | int inv_angle_sum = 256 + inv_angle; | |
936 |
2/2✓ Branch 0 taken 1917472 times.
✓ Branch 1 taken 353672 times.
|
4542288 | for (int x = 0; x < FFMIN(w, 3 << nscale); x++) { |
937 | 3834944 | const pixel l = left[y + (inv_angle_sum >> 9)]; | |
938 | 3834944 | const pixel val = POS(x, y); | |
939 | 3834944 | const int wl = 32 >> ((x << 1) >> nscale); | |
940 | 3834944 | const int pred = val + (((l - val) * wl + 32) >> 6); | |
941 | 3834944 | POS(x, y) = CLIP(pred); | |
942 | 3834944 | inv_angle_sum += inv_angle; | |
943 | } | ||
944 | } | ||
945 | 2823920 | pos += dp; | |
946 | } | ||
947 | 358628 | } | |
948 | |||
949 | //8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes | ||
950 | 334382 | 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 | 334382 | pixel *src = (pixel *)_src; | |
955 | 334382 | const pixel *left = (const pixel *)_left - (1 + ref_idx); | |
956 | 334382 | const pixel *top = (const pixel *)_top; | |
957 | 334382 | const int is_luma = !c_idx; | |
958 | 334382 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
959 | 334382 | const int dp = intra_pred_angle; | |
960 | 334382 | int nscale = 0, inv_angle, inv_angle_sum; | |
961 | |||
962 |
2/2✓ Branch 0 taken 33638 times.
✓ Branch 1 taken 133553 times.
|
334382 | if (need_pdpc) { |
963 | 67276 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
964 | 67276 | inv_angle_sum = 256 + inv_angle; | |
965 | 67276 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
966 | } | ||
967 | |||
968 |
2/2✓ Branch 0 taken 1367604 times.
✓ Branch 1 taken 167191 times.
|
3069590 | for (int y = 0; y < h; y++) { |
969 | 2735208 | int pos = (1 + ref_idx) * intra_pred_angle; | |
970 | int wt; | ||
971 |
2/2✓ Branch 0 taken 378132 times.
✓ Branch 1 taken 989472 times.
|
2735208 | if (need_pdpc) |
972 | 756264 | wt = (32 >> FFMIN(31, (y * 2) >> nscale)); | |
973 | |||
974 |
2/2✓ Branch 0 taken 20777488 times.
✓ Branch 1 taken 1367604 times.
|
44290184 | for (int x = 0; x < w; x++) { |
975 | 41554976 | const int idx = (pos >> 5) + ref_idx; | |
976 | 41554976 | const int fact = pos & 31; | |
977 | 41554976 | const pixel *p = left + y + idx; | |
978 | int pred; | ||
979 |
6/6✓ Branch 0 taken 1952440 times.
✓ Branch 1 taken 18825048 times.
✓ Branch 2 taken 1570672 times.
✓ Branch 3 taken 381768 times.
✓ Branch 4 taken 918268 times.
✓ Branch 5 taken 652404 times.
|
41554976 | if (!fact && (!is_luma || !filter_flag)) { |
980 | 2600072 | pred = p[1]; | |
981 | } else { | ||
982 |
2/2✓ Branch 0 taken 14923412 times.
✓ Branch 1 taken 4554040 times.
|
38954904 | if (!c_idx) { |
983 | 29846824 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
984 | 29846824 | pred = INTRA_LUMA_FILTER(p); | |
985 | } else { | ||
986 | 9108080 | pred = INTRA_CHROMA_FILTER(p); | |
987 | } | ||
988 | } | ||
989 |
2/2✓ Branch 0 taken 4689616 times.
✓ Branch 1 taken 16087872 times.
|
41554976 | if (need_pdpc) { |
990 |
2/2✓ Branch 0 taken 1835792 times.
✓ Branch 1 taken 2853824 times.
|
9379232 | if (y < (3 << nscale)) { |
991 | 3671584 | const pixel t = top[x + (inv_angle_sum >> 9)]; | |
992 | 3671584 | pred = CLIP(pred + (((t - pred) * wt + 32) >> 6)); | |
993 | } | ||
994 | } | ||
995 | 41554976 | POS(x, y) = pred; | |
996 | 41554976 | pos += dp; | |
997 | } | ||
998 |
2/2✓ Branch 0 taken 378132 times.
✓ Branch 1 taken 989472 times.
|
2735208 | if (need_pdpc) |
999 | 756264 | inv_angle_sum += inv_angle; | |
1000 | } | ||
1001 | 334382 | } | |
1002 | |||
1003 | 2600 | static void FUNC(ff_vvc_intra_dsp_init)(VVCIntraDSPContext *const intra) | |
1004 | { | ||
1005 | 2600 | intra->lmcs_scale_chroma = FUNC(lmcs_scale_chroma); | |
1006 | 2600 | intra->intra_cclm_pred = FUNC(intra_cclm_pred); | |
1007 | 2600 | intra->intra_pred = FUNC(intra_pred); | |
1008 | 2600 | intra->pred_planar = FUNC(pred_planar); | |
1009 | 2600 | intra->pred_mip = FUNC(pred_mip); | |
1010 | 2600 | intra->pred_dc = FUNC(pred_dc); | |
1011 | 2600 | intra->pred_v = FUNC(pred_v); | |
1012 | 2600 | intra->pred_h = FUNC(pred_h); | |
1013 | 2600 | intra->pred_angular_v = FUNC(pred_angular_v); | |
1014 | 2600 | intra->pred_angular_h = FUNC(pred_angular_h); | |
1015 | 2600 | } | |
1016 |