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 | 183518 | 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 | 183518 | const VVCSPS *sps = fc->ps.sps; | |
33 |
2/2✓ Branch 0 taken 183518 times.
✓ Branch 1 taken 91759 times.
|
550554 | for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) { |
34 | 367036 | const int c_idx = i + 1; | |
35 | 367036 | const int x = x0 >> sps->hshift[c_idx]; | |
36 | 367036 | const int y = y0 >> sps->vshift[c_idx]; | |
37 | 367036 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
38 | 367036 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
39 |
2/2✓ Branch 0 taken 1751792 times.
✓ Branch 1 taken 183518 times.
|
3870620 | for (int y = 0; y < h; y++) { |
40 |
2/2✓ Branch 0 taken 27326848 times.
✓ Branch 1 taken 1751792 times.
|
58157280 | for (int x = 0; x < w; x++) { |
41 | 54653696 | const int dsy = pdsy[y * w + x]; | |
42 | 54653696 | const int pred = ((dsy * a[i]) >> k[i]) + b[i]; | |
43 | 54653696 | POS(x, y) = CLIP(pred); | |
44 | } | ||
45 | } | ||
46 | } | ||
47 | 183518 | } | |
48 | |||
49 | #define MAX_PICK_POS 4 | ||
50 | #define TOP 0 | ||
51 | #define LEFT 1 | ||
52 | |||
53 | 1612 | static av_always_inline void FUNC(cclm_get_params_default)(int *a, int *b, int *k) | |
54 | { | ||
55 |
2/2✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 806 times.
|
4836 | for (int i = 0; i < 2; i++) { |
56 | 3224 | a[i] = k[i] = 0; | |
57 | 3224 | b[i] = 1 << (BIT_DEPTH - 1); | |
58 | } | ||
59 | 1612 | } | |
60 | |||
61 | 183518 | 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 | 183518 | const enum IntraPredMode mode = lc->cu->intra_pred_mode_c; | |
66 |
6/6✓ Branch 0 taken 88468 times.
✓ Branch 1 taken 3291 times.
✓ Branch 2 taken 85877 times.
✓ Branch 3 taken 2591 times.
✓ Branch 4 taken 38740 times.
✓ Branch 5 taken 47137 times.
|
183518 | const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM; |
67 | int num_samp[2]; | ||
68 | |||
69 |
2/2✓ Branch 0 taken 51117 times.
✓ Branch 1 taken 40642 times.
|
183518 | if (mode == INTRA_LT_CCLM) { |
70 |
2/2✓ Branch 0 taken 48695 times.
✓ Branch 1 taken 2422 times.
|
102234 | num_samp[TOP] = avail_t ? w : 0; |
71 |
2/2✓ Branch 0 taken 49559 times.
✓ Branch 1 taken 1558 times.
|
102234 | num_samp[LEFT] = avail_l ? h : 0; |
72 | } else { | ||
73 |
4/4✓ Branch 0 taken 39773 times.
✓ Branch 1 taken 869 times.
✓ Branch 2 taken 20774 times.
✓ Branch 3 taken 18999 times.
|
81284 | 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 39609 times.
✓ Branch 1 taken 1033 times.
✓ Branch 2 taken 19062 times.
✓ Branch 3 taken 20547 times.
|
81284 | 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 22290 times.
✓ Branch 1 taken 69469 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 21484 times.
|
183518 | if (!num_samp[TOP] && !num_samp[LEFT]) { |
77 | 1612 | return 0; | |
78 | } | ||
79 |
2/2✓ Branch 0 taken 181906 times.
✓ Branch 1 taken 90953 times.
|
545718 | for (int i = TOP; i <= LEFT; i++) { |
80 | 363812 | const int start = num_samp[i] >> (2 + num_is4); | |
81 | 363812 | const int step = FFMAX(1, num_samp[i] >> (1 + num_is4)) ; | |
82 | 363812 | cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1); | |
83 |
2/2✓ Branch 0 taken 362456 times.
✓ Branch 1 taken 181906 times.
|
1088724 | for (int c = 0; c < cnt[i]; c++) |
84 | 724912 | pos[i][c] = start + c * step; | |
85 | } | ||
86 | 181906 | 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 | 181906 | 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 | 181906 | const VVCSPS *sps = fc->ps.sps; | |
101 | |||
102 | 181906 | const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y); | |
103 | 181906 | const int hs = sps->hshift[1]; | |
104 | 181906 | const int vs = sps->vshift[1]; | |
105 | 181906 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
106 | |||
107 |
3/4✓ Branch 0 taken 12941 times.
✓ Branch 1 taken 78012 times.
✓ Branch 2 taken 12941 times.
✗ Branch 3 not taken.
|
207788 | 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 78012 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66544 times.
✓ Branch 3 taken 11468 times.
|
289112 | if (vs && !b_ctu_boundary) { |
114 | 133088 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride; | |
115 |
2/2✓ Branch 0 taken 139146 times.
✓ Branch 1 taken 66544 times.
|
411380 | for (int i = 0; i < cnt[TOP]; i++) { |
116 | 278292 | const int x = pos[TOP][i] << hs; | |
117 | 278292 | const pixel *src = source + x; | |
118 |
4/4✓ Branch 0 taken 2665 times.
✓ Branch 1 taken 136481 times.
✓ Branch 2 taken 2430 times.
✓ Branch 3 taken 235 times.
|
278292 | const int has_left = x || avail_l; |
119 |
2/2✓ Branch 0 taken 138911 times.
✓ Branch 1 taken 235 times.
|
278292 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
120 |
2/2✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 134906 times.
|
278292 | 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 134671 times.
✓ Branch 1 taken 235 times.
|
269812 | const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1); |
124 | 269812 | 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 | 22936 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride; | |
129 |
2/2✓ Branch 0 taken 17888 times.
✓ Branch 1 taken 11468 times.
|
58712 | for (int i = 0; i < cnt[TOP]; i++) { |
130 | 35776 | const int x = pos[TOP][i] << hs; | |
131 | 35776 | const pixel *src = source + x; | |
132 |
4/4✓ Branch 0 taken 34 times.
✓ Branch 1 taken 17854 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 27 times.
|
35776 | const int has_left = x || avail_l; |
133 |
2/2✓ Branch 0 taken 17861 times.
✓ Branch 1 taken 27 times.
|
35776 | const pixel l = has_left ? POS(-1, 0) : POS(0, 0); |
134 | 35776 | sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2; | |
135 | } | ||
136 | } | ||
137 | |||
138 | // left | ||
139 | { | ||
140 | const pixel *left; | ||
141 | 156024 | const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l; | |
142 | 156024 | left = source - avail_l; | |
143 | |||
144 |
2/2✓ Branch 0 taken 153658 times.
✓ Branch 1 taken 78012 times.
|
463340 | for (int i = 0; i < cnt[LEFT]; i++) { |
145 | 307316 | const int y = pos[LEFT][i] << vs; | |
146 | 307316 | const int offset = y * stride; | |
147 | 307316 | const pixel *l = left + offset; | |
148 | 307316 | const pixel *src = source + offset; | |
149 | pixel pred; | ||
150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 153658 times.
|
307316 | 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 147600 times.
|
307316 | 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 | 295200 | pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
159 | } | ||
160 | } | ||
161 | 307316 | sel_luma[i + cnt[TOP]] = pred; | |
162 | } | ||
163 | } | ||
164 | } | ||
165 | 181906 | } | |
166 | |||
167 | 181906 | 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 181906 times.
✓ Branch 1 taken 90953 times.
|
545718 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
172 | 363812 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
173 | |||
174 | //top | ||
175 | 363812 | const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride; | |
176 |
2/2✓ Branch 0 taken 367204 times.
✓ Branch 1 taken 181906 times.
|
1098220 | for (int i = 0; i < cnt[TOP]; i++) { |
177 | 734408 | sel[c_idx][i] = src[pos[TOP][i]]; | |
178 | } | ||
179 | |||
180 | //left | ||
181 | 363812 | src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride; | |
182 |
2/2✓ Branch 0 taken 357708 times.
✓ Branch 1 taken 181906 times.
|
1079228 | for (int i = 0; i < cnt[LEFT]; i++) { |
183 | 715416 | sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride]; | |
184 | } | ||
185 | } | ||
186 | 181906 | } | |
187 | |||
188 | 183518 | 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 | 183518 | const VVCFrameContext *fc = lc->fc; | |
193 | 183518 | const VVCSPS *sps = fc->ps.sps; | |
194 | 183518 | const int x = x0 >> sps->hshift[1]; | |
195 | 183518 | const int y = y0 >> sps->vshift[1]; | |
196 | int cnt[2], pos[2][MAX_PICK_POS]; | ||
197 | |||
198 |
2/2✓ Branch 1 taken 806 times.
✓ Branch 2 taken 90953 times.
|
183518 | if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos)) |
199 | 1612 | return 0; | |
200 | |||
201 | 181906 | FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]); | |
202 | 181906 | FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel); | |
203 | |||
204 |
2/2✓ Branch 0 taken 678 times.
✓ Branch 1 taken 90275 times.
|
181906 | if (cnt[TOP] + cnt[LEFT] == 2) { |
205 |
2/2✓ Branch 0 taken 2034 times.
✓ Branch 1 taken 678 times.
|
5424 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
206 | 4068 | sel[c_idx][3] = sel[c_idx][0]; | |
207 | 4068 | sel[c_idx][2] = sel[c_idx][1]; | |
208 | 4068 | sel[c_idx][0] = sel[c_idx][1]; | |
209 | 4068 | sel[c_idx][1] = sel[c_idx][3]; | |
210 | } | ||
211 | } | ||
212 | 181906 | return 1; | |
213 | } | ||
214 | |||
215 | 181906 | static av_always_inline void FUNC(cclm_get_min_max)( | |
216 | const pixel sel[][MAX_PICK_POS * 2], int *min, int *max) | ||
217 | { | ||
218 | 181906 | int min_grp_idx[] = { 0, 2 }; | |
219 | 181906 | int max_grp_idx[] = { 1, 3 }; | |
220 | |||
221 |
2/2✓ Branch 0 taken 42928 times.
✓ Branch 1 taken 48025 times.
|
181906 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]]) |
222 | 85856 | FFSWAP(int, min_grp_idx[0], min_grp_idx[1]); | |
223 |
2/2✓ Branch 0 taken 43712 times.
✓ Branch 1 taken 47241 times.
|
181906 | if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) |
224 | 87424 | FFSWAP(int, max_grp_idx[0], max_grp_idx[1]); | |
225 |
2/2✓ Branch 0 taken 8970 times.
✓ Branch 1 taken 81983 times.
|
181906 | if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) { |
226 | 17940 | FFSWAP(int, min_grp_idx[0], max_grp_idx[0]); | |
227 | 17940 | FFSWAP(int, min_grp_idx[1], max_grp_idx[1]); | |
228 | } | ||
229 |
2/2✓ Branch 0 taken 68090 times.
✓ Branch 1 taken 22863 times.
|
181906 | if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]]) |
230 | 136180 | FFSWAP(int, min_grp_idx[1], max_grp_idx[0]); | |
231 |
2/2✓ Branch 0 taken 272859 times.
✓ Branch 1 taken 90953 times.
|
727624 | for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
232 | 545718 | max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1; | |
233 | 545718 | min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1; | |
234 | } | ||
235 | 181906 | } | |
236 | |||
237 | 183518 | 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 806 times.
✓ Branch 2 taken 90953 times.
|
183518 | if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) { |
246 | 1612 | FUNC(cclm_get_params_default)(a, b, k); | |
247 | 9846 | return; | |
248 | } | ||
249 | |||
250 | 181906 | FUNC(cclm_get_min_max)(sel, min, max); | |
251 | |||
252 | 181906 | diff = max[LUMA] - min[LUMA]; | |
253 |
2/2✓ Branch 0 taken 4117 times.
✓ Branch 1 taken 86836 times.
|
181906 | if (diff == 0) { |
254 |
2/2✓ Branch 0 taken 8234 times.
✓ Branch 1 taken 4117 times.
|
24702 | for (int i = 0; i < 2; i++) { |
255 | 16468 | a[i] = k[i] = 0; | |
256 | 16468 | b[i] = min[i + 1]; | |
257 | } | ||
258 | 8234 | return; | |
259 | } | ||
260 |
2/2✓ Branch 0 taken 173672 times.
✓ Branch 1 taken 86836 times.
|
521016 | 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 | 347344 | const int diffc = max[i + 1] - min[i + 1]; | |
263 | 347344 | int x = av_log2(diff); | |
264 | int y, v, sign, add; | ||
265 | 347344 | const int norm_diff = ((diff << 4) >> x) & 15; | |
266 | 347344 | x += (norm_diff) ? 1 : 0; | |
267 |
2/2✓ Branch 0 taken 154901 times.
✓ Branch 1 taken 18771 times.
|
347344 | y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0; |
268 | 347344 | v = div_sig_table[norm_diff] | 8; | |
269 | 347344 | add = (1 << y >> 1); | |
270 | 347344 | a[i] = (diffc * v + add) >> y; | |
271 | 347344 | k[i] = FFMAX(1, 3 + x -y); | |
272 |
2/2✓ Branch 0 taken 76985 times.
✓ Branch 1 taken 96687 times.
|
347344 | sign = a[i] < 0 ? -1 : (a[i] > 0); |
273 |
2/2✓ Branch 0 taken 1711 times.
✓ Branch 1 taken 171961 times.
|
347344 | a[i] = ((3 + x - y) < 1) ? sign * 15 : a[i]; |
274 | 347344 | b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]); | |
275 | } | ||
276 | |||
277 | } | ||
278 | |||
279 | #undef TOP | ||
280 | #undef LEFT | ||
281 | |||
282 | 183518 | 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 | 183518 | const int hs = fc->ps.sps->hshift[1]; | |
287 | 183518 | const int vs = fc->ps.sps->vshift[1]; | |
288 | 183518 | const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel); | |
289 | 183518 | const pixel *source = (pixel*)fc->frame->data[0] + x0 + y0 * stride; | |
290 | 183518 | const pixel *left = source - avail_l; | |
291 | 183518 | const pixel *top = source - avail_t * stride; | |
292 | |||
293 | 183518 | const VVCSPS *sps = fc->ps.sps; | |
294 |
3/4✓ Branch 0 taken 12944 times.
✓ Branch 1 taken 78815 times.
✓ Branch 2 taken 12944 times.
✗ Branch 3 not taken.
|
183518 | 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 696900 times.
✓ Branch 1 taken 78815 times.
|
1551430 | for (int i = 0; i < h; i++) { |
300 | 1393800 | const pixel *src = source; | |
301 | 1393800 | const pixel *l = left; | |
302 | 1393800 | const pixel *t = top; | |
303 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 696900 times.
|
1393800 | 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 642224 times.
|
1393800 | 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 8832336 times.
✓ Branch 1 taken 642224 times.
|
18949120 | for (int j = 0; j < w; j++) { |
322 | 17664672 | pixel pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3; | |
323 | |||
324 | 17664672 | pdsy[i * w + j] = pred; | |
325 | 17664672 | src += 2; | |
326 | 17664672 | l = src - 1; | |
327 | } | ||
328 | } | ||
329 | } | ||
330 | 1393800 | source += (stride << vs); | |
331 | 1393800 | left += (stride << vs); | |
332 | 1393800 | top = source - stride; | |
333 | } | ||
334 | } | ||
335 | |||
336 | 566 | 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 566 times.
✓ Branch 1 taken 283 times.
|
1698 | for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) { |
340 | 1132 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
341 | 1132 | pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
342 |
2/2✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 566 times.
|
21772 | for (int i = 0; i < h; i++) { |
343 |
2/2✓ Branch 0 taken 266880 times.
✓ Branch 1 taken 10320 times.
|
554400 | for (int j = 0; j < w; j++) { |
344 | 533760 | dst[j] = 1 << (BIT_DEPTH - 1); | |
345 | } | ||
346 | 20640 | dst += stride; | |
347 | } | ||
348 | } | ||
349 | 566 | } | |
350 | |||
351 | //8.4.5.2.14 Specification of INTRA_LT_CCLM, INTRA_L_CCLM and INTRA_T_CCLM intra prediction mode | ||
352 | 184084 | static void FUNC(intra_cclm_pred)(const VVCLocalContext *lc, const int x0, const int y0, | |
353 | const int width, const int height) | ||
354 | { | ||
355 | 184084 | VVCFrameContext *fc = lc->fc; | |
356 | 184084 | const VVCSPS *sps = fc->ps.sps; | |
357 | 184084 | const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0); | |
358 | 184084 | const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0); | |
359 | 184084 | const int hs = sps->hshift[1]; | |
360 | 184084 | const int vs = sps->vshift[1]; | |
361 | 184084 | const int x = x0 >> hs; | |
362 | 184084 | const int y = y0 >> vs; | |
363 | 184084 | const int w = width >> hs; | |
364 | 184084 | 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 3574 times.
✓ Branch 1 taken 88468 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 3291 times.
|
184084 | if (!avail_t && !avail_l) { |
369 | 566 | FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l); | |
370 | 566 | return; | |
371 | } | ||
372 | 183518 | FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy); | |
373 | 183518 | FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k); | |
374 | 183518 | FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k); | |
375 | } | ||
376 | |||
377 | 37780 | static int FUNC(lmcs_sum_samples)(const pixel *start, ptrdiff_t stride, const int avail, const int target_size) | |
378 | { | ||
379 | 37780 | const int size = FFMIN(avail, target_size); | |
380 | 37780 | int sum = 0; | |
381 |
2/2✓ Branch 0 taken 1186248 times.
✓ Branch 1 taken 18890 times.
|
2410276 | for (int i = 0; i < size; i++) { |
382 | 2372496 | sum += *start; | |
383 | 2372496 | start += stride; | |
384 | } | ||
385 | 37780 | sum += *(start - stride) * (target_size - size); | |
386 | 37780 | return sum; | |
387 | } | ||
388 | |||
389 | // 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples | ||
390 | 286044 | static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, const int y0) | |
391 | { | ||
392 | 286044 | VVCFrameContext *fc = lc->fc; | |
393 | 286044 | const VVCLMCS *lmcs = &fc->ps.lmcs; | |
394 | 286044 | const int size_y = FFMIN(fc->ps.sps->ctb_size_y, 64); | |
395 | |||
396 | 286044 | const int x = x0 & ~(size_y - 1); | |
397 | 286044 | const int y = y0 & ~(size_y - 1); | |
398 |
4/4✓ Branch 0 taken 132963 times.
✓ Branch 1 taken 10059 times.
✓ Branch 2 taken 879 times.
✓ Branch 3 taken 132084 times.
|
286044 | if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) { |
399 | 21876 | int cnt = 0, luma = 0, i; | |
400 | 21876 | const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift)); | |
401 | 21876 | const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel); | |
402 | 21876 | const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0); | |
403 | 21876 | const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0); | |
404 |
2/2✓ Branch 0 taken 9668 times.
✓ Branch 1 taken 1270 times.
|
21876 | if (avail_l) { |
405 | 19336 | luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y); | |
406 | 19336 | cnt = size_y; | |
407 | } | ||
408 |
2/2✓ Branch 0 taken 9222 times.
✓ Branch 1 taken 1716 times.
|
21876 | if (avail_t) { |
409 | 18444 | luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y); | |
410 | 18444 | cnt += size_y; | |
411 | } | ||
412 |
2/2✓ Branch 0 taken 10612 times.
✓ Branch 1 taken 326 times.
|
21876 | if (cnt) |
413 | 21224 | luma = (luma + (cnt >> 1)) >> av_log2(cnt); | |
414 | else | ||
415 | 652 | luma = 1 << (BIT_DEPTH - 1); | |
416 | |||
417 |
2/2✓ Branch 0 taken 64910 times.
✓ Branch 1 taken 466 times.
|
130752 | for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) { |
418 |
2/2✓ Branch 0 taken 10472 times.
✓ Branch 1 taken 54438 times.
|
129820 | if (luma < lmcs->pivot[i + 1]) |
419 | 20944 | break; | |
420 | } | ||
421 | 21876 | i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1); | |
422 | |||
423 | 21876 | lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i]; | |
424 | 21876 | lc->lmcs.x_vpdu = x; | |
425 | 21876 | lc->lmcs.y_vpdu = y; | |
426 | } | ||
427 | 286044 | 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 | 286044 | 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 | 286044 | const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu); | |
435 | |||
436 |
2/2✓ Branch 0 taken 1504614 times.
✓ Branch 1 taken 143022 times.
|
3295272 | for (int y = 0; y < height; y++) { |
437 |
2/2✓ Branch 0 taken 24330192 times.
✓ Branch 1 taken 1504614 times.
|
51669612 | for (int x = 0; x < width; x++) { |
438 | 48660384 | const int c = av_clip_intp2(*coeff, BIT_DEPTH); | |
439 | |||
440 |
2/2✓ Branch 0 taken 10880650 times.
✓ Branch 1 taken 13449542 times.
|
48660384 | if (c > 0) |
441 | 21761300 | *dst = (c * chroma_scale + (1 << 10)) >> 11; | |
442 | else | ||
443 | 26899084 | *dst = -((-c * chroma_scale + (1 << 10)) >> 11); | |
444 | 48660384 | coeff++; | |
445 | 48660384 | dst++; | |
446 | } | ||
447 | } | ||
448 | 286044 | } | |
449 | |||
450 | 236478 | 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 | 236478 | filtered_left[-1] = filtered_top[-1] = (left[0] + 2 * left[-1] + top[0] + 2 ) >> 2; | |
455 |
2/2✓ Branch 0 taken 1973330 times.
✓ Branch 1 taken 118239 times.
|
4183138 | for (int i = 0; i < left_size - unfilter_last_one; i++) { |
456 | 3946660 | filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2; | |
457 | } | ||
458 |
2/2✓ Branch 0 taken 2285746 times.
✓ Branch 1 taken 118239 times.
|
4807970 | for (int i = 0; i < top_size - unfilter_last_one; i++) { |
459 | 4571492 | filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2; | |
460 | } | ||
461 |
2/2✓ Branch 0 taken 5384 times.
✓ Branch 1 taken 112855 times.
|
236478 | if (unfilter_last_one) { |
462 | 10768 | filtered_top[top_size - 1] = top[top_size - 1]; | |
463 | 10768 | filtered_left[left_size - 1] = left[left_size - 1]; | |
464 | } | ||
465 | 236478 | } | |
466 | |||
467 | 2081122 | 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 | 2081122 | const CodingUnit *cu = lc->cu; | |
478 |
2/2✓ Branch 0 taken 931612 times.
✓ Branch 1 taken 108949 times.
|
2081122 | const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode); |
479 |
4/4✓ Branch 0 taken 513539 times.
✓ Branch 1 taken 483487 times.
✓ Branch 2 taken 365149 times.
✓ Branch 3 taken 148390 times.
|
1994052 | const int filter_flag = !ref_idx && w * h > 32 && !c_idx && |
480 |
6/6✓ Branch 0 taken 997026 times.
✓ Branch 1 taken 43535 times.
✓ Branch 2 taken 309285 times.
✓ Branch 3 taken 55864 times.
✓ Branch 4 taken 118239 times.
✓ Branch 5 taken 191046 times.
|
4075174 | cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag; |
481 | 2081122 | int cand_up_left = lc->na.cand_up_left; | |
482 | 2081122 | pixel *left = (pixel*)edge->left_array + MAX_TB_SIZE + 3; | |
483 | 2081122 | pixel *top = (pixel*)edge->top_array + MAX_TB_SIZE + 3; | |
484 | 2081122 | pixel *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3; | |
485 | 2081122 | pixel *filtered_top = (pixel*)edge->filtered_top_array + MAX_TB_SIZE + 3; | |
486 | 2081122 | 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 931612 times.
✓ Branch 1 taken 108949 times.
✓ Branch 2 taken 362393 times.
✓ Branch 3 taken 569219 times.
|
2081122 | if (is_intra_mip || mode == INTRA_PLANAR) { |
494 | 942684 | left_size = h + 1; | |
495 | 942684 | top_size = w + 1; | |
496 | 942684 | unfilter_left_size = left_size + filter_flag; | |
497 | 942684 | unfilter_top_size = top_size + filter_flag; | |
498 |
2/2✓ Branch 0 taken 69675 times.
✓ Branch 1 taken 499544 times.
|
1138438 | } else if (mode == INTRA_DC) { |
499 | 139350 | unfilter_left_size = left_size = h; | |
500 | 139350 | unfilter_top_size = top_size = w; | |
501 |
2/2✓ Branch 0 taken 55223 times.
✓ Branch 1 taken 444321 times.
|
999088 | } else if (mode == INTRA_VERT) { |
502 | //we may need 1 pixel to predict the top left. | ||
503 |
2/2✓ Branch 0 taken 46321 times.
✓ Branch 1 taken 8902 times.
|
110446 | unfilter_left_size = left_size = need_pdpc ? h : 1; |
504 | 110446 | unfilter_top_size = top_size = w; | |
505 |
2/2✓ Branch 0 taken 55044 times.
✓ Branch 1 taken 389277 times.
|
888642 | } else if (mode == INTRA_HORZ) { |
506 | 110088 | 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 42330 times.
✓ Branch 1 taken 12714 times.
|
110088 | unfilter_top_size = top_size = need_pdpc ? w : 1; |
509 | } else { | ||
510 |
4/4✓ Branch 0 taken 89821 times.
✓ Branch 1 taken 299456 times.
✓ Branch 2 taken 2870 times.
✓ Branch 3 taken 86951 times.
|
778554 | if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) { |
511 | 604652 | refw = w * 2; | |
512 | 604652 | refh = h * 2; | |
513 | } else { | ||
514 | 173902 | refw = cu->cb_width + w; | |
515 | 173902 | refh = cu->cb_height + h; | |
516 | } | ||
517 | 778554 | intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
518 | 778554 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
519 | 778554 | unfilter_top_size = top_size = refw; | |
520 | 778554 | unfilter_left_size = left_size = refh; | |
521 | } | ||
522 | |||
523 | 2081122 | left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx); | |
524 |
2/2✓ Branch 0 taken 10799419 times.
✓ Branch 1 taken 1040561 times.
|
23679960 | for (i = 0; i < left_available; i++) |
525 | 21598838 | left[i] = POS(ref_line, i); | |
526 | |||
527 | 2081122 | top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx); | |
528 | 2081122 | memcpy(top, src + ref_line * stride, top_available * sizeof(pixel)); | |
529 | |||
530 |
2/2✓ Branch 0 taken 1109595 times.
✓ Branch 1 taken 1040561 times.
|
4300312 | for (int i = -1; i >= ref_line; i--) { |
531 |
2/2✓ Branch 0 taken 1060545 times.
✓ Branch 1 taken 49050 times.
|
2219190 | if (cand_up_left) { |
532 | 2121090 | left[i] = POS(ref_line, i); | |
533 | 2121090 | top[i] = POS(i, ref_line); | |
534 |
2/2✓ Branch 0 taken 21990 times.
✓ Branch 1 taken 27060 times.
|
98100 | } else if (left_available) { |
535 | 43980 | left[i] = top[i] = left[0]; | |
536 |
2/2✓ Branch 0 taken 26043 times.
✓ Branch 1 taken 1017 times.
|
54120 | } else if (top_available) { |
537 | 52086 | left[i] = top[i] = top[0]; | |
538 | } else { | ||
539 | 2034 | left[i] = top[i] = 1 << (BIT_DEPTH - 1); | |
540 | } | ||
541 | } | ||
542 | |||
543 |
2/2✓ Branch 0 taken 3537959 times.
✓ Branch 1 taken 1040561 times.
|
9157040 | EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available); |
544 |
2/2✓ Branch 0 taken 2721948 times.
✓ Branch 1 taken 1040561 times.
|
7525018 | EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available); |
545 | |||
546 |
2/2✓ Branch 0 taken 389090 times.
✓ Branch 1 taken 651471 times.
|
2081122 | if (ref_filter_flag) { |
547 |
8/8✓ Branch 0 taken 388154 times.
✓ Branch 1 taken 936 times.
✓ Branch 2 taken 217943 times.
✓ Branch 3 taken 170211 times.
✓ Branch 4 taken 145077 times.
✓ Branch 5 taken 72866 times.
✓ Branch 6 taken 118239 times.
✓ Branch 7 taken 26838 times.
|
778180 | if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) { |
548 | 236478 | const int unfilter_last_one = left_size == unfilter_left_size; | |
549 | 236478 | FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one); | |
550 | 236478 | left = filtered_left; | |
551 | 236478 | top = filtered_top; | |
552 | } | ||
553 | } | ||
554 |
6/6✓ Branch 0 taken 931612 times.
✓ Branch 1 taken 108949 times.
✓ Branch 2 taken 569219 times.
✓ Branch 3 taken 362393 times.
✓ Branch 4 taken 499544 times.
✓ Branch 5 taken 69675 times.
|
2081122 | if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) { |
555 |
6/6✓ Branch 0 taken 472847 times.
✓ Branch 1 taken 26697 times.
✓ Branch 2 taken 436132 times.
✓ Branch 3 taken 36715 times.
✓ Branch 4 taken 107002 times.
✓ Branch 5 taken 329130 times.
|
999088 | if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) { |
556 | 340828 | edge->filter_flag = 0; | |
557 | } else { | ||
558 | 658260 | const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18)); | |
559 | 658260 | const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0}; | |
560 | 658260 | const int ntbs = (av_log2(w) + av_log2(h)) >> 1; | |
561 | 658260 | edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2]; | |
562 | } | ||
563 | |||
564 |
4/4✓ Branch 0 taken 444321 times.
✓ Branch 1 taken 55223 times.
✓ Branch 2 taken 389277 times.
✓ Branch 3 taken 55044 times.
|
999088 | if (mode != INTRA_VERT && mode != INTRA_HORZ) { |
565 |
2/2✓ Branch 0 taken 203959 times.
✓ Branch 1 taken 185318 times.
|
778554 | if (mode >= INTRA_DIAG) { |
566 |
2/2✓ Branch 0 taken 103821 times.
✓ Branch 1 taken 100138 times.
|
407918 | if (intra_pred_angle < 0) { |
567 | 207642 | pixel *p = top - (ref_idx + 1); | |
568 |
2/2✓ Branch 0 taken 850276 times.
✓ Branch 1 taken 103821 times.
|
1908194 | for (int x = -h; x < 0; x++) { |
569 | 1700552 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h); | |
570 | 1700552 | p[x] = left[idx]; | |
571 | } | ||
572 | } else { | ||
573 |
2/2✓ Branch 0 taken 218651 times.
✓ Branch 1 taken 100138 times.
|
637578 | for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++) |
574 | 437302 | top[i] = top[refw - 1]; | |
575 | } | ||
576 | } else { | ||
577 |
2/2✓ Branch 0 taken 96654 times.
✓ Branch 1 taken 88664 times.
|
370636 | if (intra_pred_angle < 0) { |
578 | 193308 | pixel *p = left - (ref_idx + 1); | |
579 |
2/2✓ Branch 0 taken 1436464 times.
✓ Branch 1 taken 96654 times.
|
3066236 | for (int x = -w; x < 0; x++) { |
580 | 2872928 | const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w); | |
581 | 2872928 | p[x] = top[idx]; | |
582 | } | ||
583 | } else { | ||
584 |
2/2✓ Branch 0 taken 193762 times.
✓ Branch 1 taken 88664 times.
|
564852 | for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++) |
585 | 387524 | left[i] = left[refh - 1]; | |
586 | } | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | 2081122 | edge->left = (uint8_t*)left; | |
591 | 2081122 | edge->top = (uint8_t*)top; | |
592 | 2081122 | } | |
593 | |||
594 | //8.4.1 General decoding process for coding units coded in intra prediction mode | ||
595 | 2081122 | static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0, | |
596 | const int width, const int height, int c_idx) | ||
597 | { | ||
598 | 2081122 | VVCFrameContext *fc = lc->fc; | |
599 | 2081122 | const VVCSPS *sps = fc->ps.sps; | |
600 | 2081122 | const VVCPPS *pps = fc->ps.pps; | |
601 | 2081122 | const CodingUnit *cu = lc->cu; | |
602 | 2081122 | const int log2_min_cb_size = sps->min_cb_log2_size_y; | |
603 | 2081122 | const int min_cb_width = pps->min_cb_width; | |
604 | 2081122 | const int x_cb = x0 >> log2_min_cb_size; | |
605 | 2081122 | const int y_cb = y0 >> log2_min_cb_size; | |
606 | |||
607 | 2081122 | const int hshift = fc->ps.sps->hshift[c_idx]; | |
608 | 2081122 | const int vshift = fc->ps.sps->vshift[c_idx]; | |
609 | 2081122 | const int x = x0 >> hshift; | |
610 | 2081122 | const int y = y0 >> vshift; | |
611 | 2081122 | const int w = width >> hshift; | |
612 | 2081122 | const int h = height >> vshift; | |
613 | 2081122 | const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel); | |
614 | |||
615 |
2/2✓ Branch 0 taken 299738 times.
✓ Branch 1 taken 740823 times.
|
2081122 | const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y; |
616 | 2081122 | const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode); | |
617 | |||
618 | 2081122 | const int intra_mip_flag = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb); | |
619 |
6/6✓ Branch 0 taken 162885 times.
✓ Branch 1 taken 877676 times.
✓ Branch 2 taken 54224 times.
✓ Branch 3 taken 108661 times.
✓ Branch 4 taken 288 times.
✓ Branch 5 taken 53936 times.
|
2081122 | const int is_intra_mip = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag); |
620 |
2/2✓ Branch 0 taken 740823 times.
✓ Branch 1 taken 299738 times.
|
2081122 | const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx; |
621 | 2081122 | const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx); | |
622 | |||
623 | |||
624 | 2081122 | pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride; | |
625 | IntraEdgeParams edge; | ||
626 | |||
627 | 2081122 | 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 108949 times.
✓ Branch 1 taken 931612 times.
|
2081122 | if (is_intra_mip) { |
630 | int intra_mip_transposed_flag; | ||
631 | int intra_mip_mode; | ||
632 | 217898 | unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag); | |
633 | |||
634 | 217898 | fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left, | |
635 | w, h, stride, intra_mip_mode, intra_mip_transposed_flag); | ||
636 |
2/2✓ Branch 0 taken 362393 times.
✓ Branch 1 taken 569219 times.
|
1863224 | } else if (mode == INTRA_PLANAR) { |
637 | 724786 | fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
638 |
2/2✓ Branch 0 taken 69675 times.
✓ Branch 1 taken 499544 times.
|
1138438 | } else if (mode == INTRA_DC) { |
639 | 139350 | fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride); | |
640 |
2/2✓ Branch 0 taken 55223 times.
✓ Branch 1 taken 444321 times.
|
999088 | } else if (mode == INTRA_VERT) { |
641 | 110446 | fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride); | |
642 |
2/2✓ Branch 0 taken 55044 times.
✓ Branch 1 taken 389277 times.
|
888642 | } else if (mode == INTRA_HORZ) { |
643 | 110088 | fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride); | |
644 | } else { | ||
645 |
2/2✓ Branch 0 taken 203959 times.
✓ Branch 1 taken 185318 times.
|
778554 | if (mode >= INTRA_DIAG) { |
646 | 407918 | fc->vvcdsp.intra.pred_angular_v((uint8_t *)src, edge.top, edge.left, | |
647 | w, h, stride, c_idx, mode, ref_idx, | ||
648 | edge.filter_flag, need_pdpc); | ||
649 | } else { | ||
650 | 370636 | fc->vvcdsp.intra.pred_angular_h((uint8_t *)src, edge.top, edge.left, | |
651 | w, h, stride, c_idx, mode, ref_idx, | ||
652 | edge.filter_flag, need_pdpc); | ||
653 | } | ||
654 | } | ||
655 |
2/2✓ Branch 0 taken 646032 times.
✓ Branch 1 taken 394529 times.
|
2081122 | if (need_pdpc) { |
656 | //8.4.5.2.15 Position-dependent intra prediction sample filtering process | ||
657 |
8/8✓ Branch 0 taken 554388 times.
✓ Branch 1 taken 91644 times.
✓ Branch 2 taken 226813 times.
✓ Branch 3 taken 327575 times.
✓ Branch 4 taken 168844 times.
✓ Branch 5 taken 57969 times.
✓ Branch 6 taken 122523 times.
✓ Branch 7 taken 46321 times.
|
1292064 | if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC || |
658 |
2/2✓ Branch 0 taken 42330 times.
✓ Branch 1 taken 80193 times.
|
245046 | mode == INTRA_VERT || mode == INTRA_HORZ)) { |
659 | 948390 | const int scale = (av_log2(w) + av_log2(h) - 2) >> 2; | |
660 | 948390 | const pixel *left = (pixel*)edge.left; | |
661 | 948390 | const pixel *top = (pixel*)edge.top; | |
662 |
2/2✓ Branch 0 taken 5008164 times.
✓ Branch 1 taken 474195 times.
|
10964718 | for (int y = 0; y < h; y++) { |
663 |
2/2✓ Branch 0 taken 84022480 times.
✓ Branch 1 taken 5008164 times.
|
178061288 | for (int x = 0; x < w; x++) { |
664 | int l, t, wl, wt, pred; | ||
665 | pixel val; | ||
666 |
4/4✓ Branch 0 taken 24594768 times.
✓ Branch 1 taken 59427712 times.
✓ Branch 2 taken 9857136 times.
✓ Branch 3 taken 14737632 times.
|
168044960 | if (mode == INTRA_PLANAR || mode == INTRA_DC) { |
667 | 138569696 | l = left[y]; | |
668 | 138569696 | t = top[x]; | |
669 | 138569696 | wl = 32 >> FFMIN((x << 1) >> scale, 31); | |
670 | 138569696 | wt = 32 >> FFMIN((y << 1) >> scale, 31); | |
671 | } else { | ||
672 | 29475264 | l = left[y] - left[-1] + POS(x,y); | |
673 | 29475264 | t = top[x] - top[-1] + POS(x,y); | |
674 |
2/2✓ Branch 0 taken 6844448 times.
✓ Branch 1 taken 7893184 times.
|
29475264 | wl = (mode == INTRA_VERT) ? (32 >> FFMIN((x << 1) >> scale, 31)) : 0; |
675 |
2/2✓ Branch 0 taken 7893184 times.
✓ Branch 1 taken 6844448 times.
|
29475264 | wt = (mode == INTRA_HORZ) ? (32 >> FFMIN((y << 1) >> scale, 31)) : 0; |
676 | } | ||
677 | 168044960 | val = POS(x, y); | |
678 | 168044960 | pred = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6); | |
679 | 168044960 | POS(x, y) = CLIP(pred); | |
680 | } | ||
681 | } | ||
682 | } | ||
683 | } | ||
684 | 2081122 | } | |
685 | |||
686 | //8.4.5.2.11 Specification of INTRA_PLANAR intra prediction mode | ||
687 | 724786 | static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top, | |
688 | const uint8_t *_left, const int w, const int h, const ptrdiff_t stride) | ||
689 | { | ||
690 | int x, y; | ||
691 | 724786 | pixel *src = (pixel *)_src; | |
692 | 724786 | const pixel *top = (const pixel *)_top; | |
693 | 724786 | const pixel *left = (const pixel *)_left; | |
694 | 724786 | const int logw = av_log2(w); | |
695 | 724786 | const int logh = av_log2(h); | |
696 | 724786 | const int size = w * h; | |
697 | 724786 | const int shift = (logw + logh + 1); | |
698 |
2/2✓ Branch 0 taken 3585212 times.
✓ Branch 1 taken 362393 times.
|
7895210 | for (y = 0; y < h; y++) { |
699 |
2/2✓ Branch 0 taken 60315712 times.
✓ Branch 1 taken 3585212 times.
|
127801848 | for (x = 0; x < w; x++) { |
700 | 120631424 | const int pred_v = ((h - 1 - y) * top[x] + (y + 1) * left[h]) << logw; | |
701 | 120631424 | const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh; | |
702 | 120631424 | const int pred = (pred_v + pred_h + size) >> shift; | |
703 | 120631424 | POS(x, y) = pred; | |
704 | } | ||
705 | } | ||
706 | 724786 | } | |
707 | |||
708 | //8.4.5.2.3 MIP boundary sample downsampling process | ||
709 | 435796 | static av_always_inline void FUNC(mip_downsampling)(int *reduced, const int boundary_size, | |
710 | const pixel *ref, const int n_tb_s) | ||
711 | { | ||
712 | 435796 | const int b_dwn = n_tb_s / boundary_size; | |
713 | 435796 | const int log2 = av_log2(b_dwn); | |
714 | |||
715 |
2/2✓ Branch 0 taken 38780 times.
✓ Branch 1 taken 179118 times.
|
435796 | if (boundary_size == n_tb_s) { |
716 |
2/2✓ Branch 0 taken 155120 times.
✓ Branch 1 taken 38780 times.
|
387800 | for (int i = 0; i < n_tb_s; i++) |
717 | 310240 | reduced[i] = ref[i]; | |
718 | 77560 | return; | |
719 | } | ||
720 |
2/2✓ Branch 0 taken 655188 times.
✓ Branch 1 taken 179118 times.
|
1668612 | for (int i = 0; i < boundary_size; i++) { |
721 | int r; | ||
722 | 1310376 | r = *ref++; | |
723 |
2/2✓ Branch 0 taken 1846788 times.
✓ Branch 1 taken 655188 times.
|
5003952 | for (int j = 1; j < b_dwn; j++) |
724 | 3693576 | r += *ref++; | |
725 | 1310376 | reduced[i] = (r + (1 << (log2 - 1))) >> log2; | |
726 | } | ||
727 | } | ||
728 | |||
729 | 217898 | static av_always_inline void FUNC(mip_reduced_pred)(pixel *src, const ptrdiff_t stride, | |
730 | const int up_hor, const int up_ver, const int pred_size, const int *reduced, const int reduced_size, | ||
731 | const int ow, const int temp0, const uint8_t *matrix, int is_transposed) | ||
732 | { | ||
733 | 217898 | src = &POS(up_hor - 1, up_ver - 1); | |
734 |
2/2✓ Branch 0 taken 612736 times.
✓ Branch 1 taken 108949 times.
|
1443370 | for (int y = 0; y < pred_size; y++) { |
735 |
2/2✓ Branch 0 taken 3866464 times.
✓ Branch 1 taken 612736 times.
|
8958400 | for (int x = 0; x < pred_size; x++) { |
736 | 7732928 | int pred = 0; | |
737 |
2/2✓ Branch 0 taken 27120128 times.
✓ Branch 1 taken 3866464 times.
|
61973184 | for (int i = 0; i < reduced_size; i++) |
738 | 54240256 | pred += reduced[i] * matrix[i]; | |
739 | 7732928 | matrix += reduced_size; | |
740 | 7732928 | pred = ((pred + ow) >> 6) + temp0; | |
741 | 7732928 | pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1); | |
742 |
2/2✓ Branch 0 taken 1945248 times.
✓ Branch 1 taken 1921216 times.
|
7732928 | if (is_transposed) |
743 | 3890496 | POS(y * up_hor, x * up_ver) = pred; | |
744 | else | ||
745 | 3842432 | POS(x * up_hor, y * up_ver) = pred; | |
746 | } | ||
747 | } | ||
748 | 217898 | } | |
749 | |||
750 | 250258 | 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, | |
751 | const pixel *boundary, const int boundary_step, const int pred_size) | ||
752 | { | ||
753 | |||
754 |
2/2✓ Branch 0 taken 1197764 times.
✓ Branch 1 taken 125129 times.
|
2645786 | for (int i = 0; i < dst_height; i++) { |
755 | 2395528 | const pixel *before = boundary; | |
756 | 2395528 | const pixel *after = dst - dst_step; | |
757 | 2395528 | pixel *d = dst; | |
758 |
2/2✓ Branch 0 taken 8452208 times.
✓ Branch 1 taken 1197764 times.
|
19299944 | for (int j = 0; j < pred_size; j++) { |
759 | 16904416 | after += dst_step * factor; | |
760 |
2/2✓ Branch 0 taken 17946896 times.
✓ Branch 1 taken 8452208 times.
|
52798208 | for (int k = 1; k < factor; k++) { |
761 | 35893792 | int mid = (factor - k) * (*before) + k * (*after); | |
762 | 35893792 | *d = (mid + factor / 2) / factor; | |
763 | 35893792 | d += dst_step; | |
764 | } | ||
765 | 16904416 | before = after; | |
766 | 16904416 | d += dst_step; | |
767 | } | ||
768 | 2395528 | boundary += boundary_step; | |
769 | 2395528 | dst += dst_stride; | |
770 | } | ||
771 | 250258 | } | |
772 | |||
773 | //8.4.5.2.2 Matrix-based intra sample prediction | ||
774 | 217898 | static av_always_inline void FUNC(pred_mip)(uint8_t *_src, const uint8_t *_top, | |
775 | const uint8_t *_left, const int w, const int h, const ptrdiff_t stride, | ||
776 | int mode_id, int is_transposed) | ||
777 | { | ||
778 | 217898 | pixel *src = (pixel *)_src; | |
779 | 217898 | const pixel *top = (const pixel *)_top; | |
780 | 217898 | const pixel *left = (const pixel *)_left; | |
781 | |||
782 | 217898 | const int size_id = ff_vvc_get_mip_size_id(w, h); | |
783 | static const int boundary_sizes[] = {2, 4, 4}; | ||
784 | static const int pred_sizes[] = {4, 4, 8}; | ||
785 | 217898 | const int boundary_size = boundary_sizes[size_id]; | |
786 | 217898 | const int pred_size = pred_sizes[size_id]; | |
787 | 217898 | const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0); | |
788 | 217898 | const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id); | |
789 | 217898 | const int up_hor = w / pred_size; | |
790 | 217898 | const int up_ver = h / pred_size; | |
791 | |||
792 | int reduced[16]; | ||
793 | 217898 | int *red_t = reduced; | |
794 | 217898 | int *red_l = reduced + boundary_size; | |
795 | 217898 | int off = 1, ow = 0; | |
796 | int temp0; | ||
797 | |||
798 |
2/2✓ Branch 0 taken 55617 times.
✓ Branch 1 taken 53332 times.
|
217898 | if (is_transposed) { |
799 | 111234 | FFSWAP(int*, red_t, red_l); | |
800 | } | ||
801 | 217898 | FUNC(mip_downsampling)(red_t, boundary_size, top, w); | |
802 | 217898 | FUNC(mip_downsampling)(red_l, boundary_size, left, h); | |
803 | |||
804 | 217898 | temp0 = reduced[0]; | |
805 |
2/2✓ Branch 0 taken 64714 times.
✓ Branch 1 taken 44235 times.
|
217898 | if (size_id != 2) { |
806 | 129428 | off = 0; | |
807 | 129428 | ow = (1 << (BIT_DEPTH - 1)) - temp0; | |
808 | } else { | ||
809 | 88470 | ow = reduced[1] - temp0; | |
810 | } | ||
811 | 217898 | reduced[0] = ow; | |
812 |
2/2✓ Branch 0 taken 657124 times.
✓ Branch 1 taken 108949 times.
|
1532146 | for (int i = 1; i < in_size; i++) { |
813 | 1314248 | reduced[i] = reduced[i + off] - temp0; | |
814 | 1314248 | ow += reduced[i]; | |
815 | } | ||
816 | 217898 | ow = 32 - 32 * ow; | |
817 | |||
818 | 217898 | FUNC(mip_reduced_pred)(src, stride, up_hor, up_ver, pred_size, reduced, in_size, ow, temp0, matrix, is_transposed); | |
819 |
4/4✓ Branch 0 taken 38542 times.
✓ Branch 1 taken 70407 times.
✓ Branch 2 taken 23221 times.
✓ Branch 3 taken 15321 times.
|
217898 | if (up_hor > 1 || up_ver > 1) { |
820 |
2/2✓ Branch 0 taken 70407 times.
✓ Branch 1 taken 23221 times.
|
187256 | if (up_hor > 1) |
821 | 140814 | 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); | |
822 |
2/2✓ Branch 0 taken 54722 times.
✓ Branch 1 taken 38906 times.
|
187256 | if (up_ver > 1) |
823 | 109444 | FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size); | |
824 | } | ||
825 | 217898 | } | |
826 | |||
827 | 139350 | static av_always_inline pixel FUNC(pred_dc_val)(const pixel *top, const pixel *left, | |
828 | const int w, const int h) | ||
829 | { | ||
830 | pixel dc_val; | ||
831 | 139350 | int sum = 0; | |
832 |
2/2✓ Branch 0 taken 24231 times.
✓ Branch 1 taken 45444 times.
|
139350 | unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h); |
833 | 139350 | const int shift = av_log2(offset); | |
834 | 139350 | offset >>= 1; | |
835 |
2/2✓ Branch 0 taken 54571 times.
✓ Branch 1 taken 15104 times.
|
139350 | if (w >= h) { |
836 |
2/2✓ Branch 0 taken 778552 times.
✓ Branch 1 taken 54571 times.
|
1666246 | for (int i = 0; i < w; i++) |
837 | 1557104 | sum += top[i]; | |
838 | } | ||
839 |
2/2✓ Branch 0 taken 39335 times.
✓ Branch 1 taken 30340 times.
|
139350 | if (w <= h) { |
840 |
2/2✓ Branch 0 taken 478472 times.
✓ Branch 1 taken 39335 times.
|
1035614 | for (int i = 0; i < h; i++) |
841 | 956944 | sum += left[i]; | |
842 | } | ||
843 | 139350 | dc_val = (sum + offset) >> shift; | |
844 | 139350 | return dc_val; | |
845 | } | ||
846 | |||
847 | //8.4.5.2.12 Specification of INTRA_DC intra prediction mode | ||
848 | 139350 | static av_always_inline void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top, | |
849 | const uint8_t *_left, const int w, const int h, const ptrdiff_t stride) | ||
850 | { | ||
851 | int x, y; | ||
852 | 139350 | pixel *src = (pixel *)_src; | |
853 | 139350 | const pixel *top = (const pixel *)_top; | |
854 | 139350 | const pixel *left = (const pixel *)_left; | |
855 | 139350 | const pixel dc = FUNC(pred_dc_val)(top, left, w, h); | |
856 | 139350 | const pixel4 a = PIXEL_SPLAT_X4(dc); | |
857 |
2/2✓ Branch 0 taken 645736 times.
✓ Branch 1 taken 69675 times.
|
1430822 | for (y = 0; y < h; y++) { |
858 | 1291472 | pixel *s = src; | |
859 |
2/2✓ Branch 0 taken 2689600 times.
✓ Branch 1 taken 645736 times.
|
6670672 | for (x = 0; x < w; x += 4) { |
860 | 5379200 | AV_WN4P(s, a); | |
861 | 5379200 | s += 4; | |
862 | } | ||
863 | 1291472 | src += stride; | |
864 | } | ||
865 | 139350 | } | |
866 | |||
867 | 110446 | static av_always_inline void FUNC(pred_v)(uint8_t *_src, const uint8_t *_top, | |
868 | const int w, const int h, const ptrdiff_t stride) | ||
869 | { | ||
870 | 110446 | pixel *src = (pixel *)_src; | |
871 | 110446 | const pixel *top = (const pixel *)_top; | |
872 |
2/2✓ Branch 0 taken 515992 times.
✓ Branch 1 taken 55223 times.
|
1142430 | for (int y = 0; y < h; y++) { |
873 | 1031984 | memcpy(src, top, sizeof(pixel) * w); | |
874 | 1031984 | src += stride; | |
875 | } | ||
876 | 110446 | } | |
877 | |||
878 | 110088 | static void FUNC(pred_h)(uint8_t *_src, const uint8_t *_left, const int w, const int h, | |
879 | const ptrdiff_t stride) | ||
880 | { | ||
881 | 110088 | pixel *src = (pixel *)_src; | |
882 | 110088 | const pixel *left = (const pixel *)_left; | |
883 |
2/2✓ Branch 0 taken 473196 times.
✓ Branch 1 taken 55044 times.
|
1056480 | for (int y = 0; y < h; y++) { |
884 | 946392 | const pixel4 a = PIXEL_SPLAT_X4(left[y]); | |
885 |
2/2✓ Branch 0 taken 2145484 times.
✓ Branch 1 taken 473196 times.
|
5237360 | for (int x = 0; x < w; x += 4) { |
886 | 4290968 | AV_WN4P(&POS(x, y), a); | |
887 | } | ||
888 | } | ||
889 | 110088 | } | |
890 | |||
891 | #define INTRA_LUMA_FILTER(p) CLIP((p[0] * f[0] + p[1] * f[1] + p[2] * f[2] + p[3] * f[3] + 32) >> 6) | ||
892 | #define INTRA_CHROMA_FILTER(p) (((32 - fact) * p[1] + fact * p[2] + 16) >> 5) | ||
893 | |||
894 | //8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes | ||
895 | 407918 | static void FUNC(pred_angular_v)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, | |
896 | const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode, | ||
897 | const int ref_idx, const int filter_flag, const int need_pdpc) | ||
898 | { | ||
899 | 407918 | pixel *src = (pixel *)_src; | |
900 | 407918 | const pixel *left = (const pixel *)_left; | |
901 | 407918 | const pixel *top = (const pixel *)_top - (1 + ref_idx); | |
902 | 407918 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
903 | 407918 | int pos = (1 + ref_idx) * intra_pred_angle; | |
904 | 407918 | const int dp = intra_pred_angle; | |
905 | 407918 | const int is_luma = !c_idx; | |
906 | int nscale, inv_angle; | ||
907 | |||
908 |
2/2✓ Branch 0 taken 43530 times.
✓ Branch 1 taken 160429 times.
|
407918 | if (need_pdpc) { |
909 | 87060 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
910 | 87060 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
911 | } | ||
912 | |||
913 |
2/2✓ Branch 0 taken 1556012 times.
✓ Branch 1 taken 203959 times.
|
3519942 | for (int y = 0; y < h; y++) { |
914 | 3112024 | const int idx = (pos >> 5) + ref_idx; | |
915 | 3112024 | const int fact = pos & 31; | |
916 |
6/6✓ Branch 0 taken 240583 times.
✓ Branch 1 taken 1315429 times.
✓ Branch 2 taken 149653 times.
✓ Branch 3 taken 90930 times.
✓ Branch 4 taken 125136 times.
✓ Branch 5 taken 24517 times.
|
3112024 | if (!fact && (!is_luma || !filter_flag)) { |
917 |
2/2✓ Branch 0 taken 2285172 times.
✓ Branch 1 taken 216066 times.
|
5002476 | for (int x = 0; x < w; x++) { |
918 | 4570344 | const pixel *p = top + x + idx + 1; | |
919 | 4570344 | POS(x, y) = *p; | |
920 | } | ||
921 | } else { | ||
922 |
2/2✓ Branch 0 taken 1064364 times.
✓ Branch 1 taken 275582 times.
|
2679892 | if (!c_idx) { |
923 | 2128728 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
924 |
2/2✓ Branch 0 taken 11698108 times.
✓ Branch 1 taken 1064364 times.
|
25524944 | for (int x = 0; x < w; x++) { |
925 | 23396216 | const pixel *p = top + x + idx; | |
926 | 23396216 | POS(x, y) = INTRA_LUMA_FILTER(p); | |
927 | } | ||
928 | } else { | ||
929 |
2/2✓ Branch 0 taken 2563728 times.
✓ Branch 1 taken 275582 times.
|
5678620 | for (int x = 0; x < w; x++) { |
930 | 5127456 | const pixel *p = top + x + idx; | |
931 | 5127456 | POS(x, y) = INTRA_CHROMA_FILTER(p); | |
932 | } | ||
933 | } | ||
934 | } | ||
935 |
2/2✓ Branch 0 taken 380792 times.
✓ Branch 1 taken 1175220 times.
|
3112024 | if (need_pdpc) { |
936 | 761584 | int inv_angle_sum = 256 + inv_angle; | |
937 |
2/2✓ Branch 0 taken 2067868 times.
✓ Branch 1 taken 380792 times.
|
4897320 | for (int x = 0; x < FFMIN(w, 3 << nscale); x++) { |
938 | 4135736 | const pixel l = left[y + (inv_angle_sum >> 9)]; | |
939 | 4135736 | const pixel val = POS(x, y); | |
940 | 4135736 | const int wl = 32 >> ((x << 1) >> nscale); | |
941 | 4135736 | const int pred = val + (((l - val) * wl + 32) >> 6); | |
942 | 4135736 | POS(x, y) = CLIP(pred); | |
943 | 4135736 | inv_angle_sum += inv_angle; | |
944 | } | ||
945 | } | ||
946 | 3112024 | pos += dp; | |
947 | } | ||
948 | 407918 | } | |
949 | |||
950 | //8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes | ||
951 | 370636 | static void FUNC(pred_angular_h)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left, | |
952 | const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode, | ||
953 | const int ref_idx, const int filter_flag, const int need_pdpc) | ||
954 | { | ||
955 | 370636 | pixel *src = (pixel *)_src; | |
956 | 370636 | const pixel *left = (const pixel *)_left - (1 + ref_idx); | |
957 | 370636 | const pixel *top = (const pixel *)_top; | |
958 | 370636 | const int is_luma = !c_idx; | |
959 | 370636 | const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode); | |
960 | 370636 | const int dp = intra_pred_angle; | |
961 | 370636 | int nscale = 0, inv_angle, inv_angle_sum; | |
962 | |||
963 |
2/2✓ Branch 0 taken 36663 times.
✓ Branch 1 taken 148655 times.
|
370636 | if (need_pdpc) { |
964 | 73326 | inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle); | |
965 | 73326 | inv_angle_sum = 256 + inv_angle; | |
966 | 73326 | nscale = ff_vvc_nscale_derive(w, h, mode); | |
967 | } | ||
968 | |||
969 |
2/2✓ Branch 0 taken 1497032 times.
✓ Branch 1 taken 185318 times.
|
3364700 | for (int y = 0; y < h; y++) { |
970 | 2994064 | int pos = (1 + ref_idx) * intra_pred_angle; | |
971 | int wt; | ||
972 |
2/2✓ Branch 0 taken 411780 times.
✓ Branch 1 taken 1085252 times.
|
2994064 | if (need_pdpc) |
973 | 823560 | wt = (32 >> FFMIN(31, (y * 2) >> nscale)); | |
974 | |||
975 |
2/2✓ Branch 0 taken 21672240 times.
✓ Branch 1 taken 1497032 times.
|
46338544 | for (int x = 0; x < w; x++) { |
976 | 43344480 | const int idx = (pos >> 5) + ref_idx; | |
977 | 43344480 | const int fact = pos & 31; | |
978 | 43344480 | const pixel *p = left + y + idx; | |
979 | int pred; | ||
980 |
6/6✓ Branch 0 taken 2036876 times.
✓ Branch 1 taken 19635364 times.
✓ Branch 2 taken 1650716 times.
✓ Branch 3 taken 386160 times.
✓ Branch 4 taken 975604 times.
✓ Branch 5 taken 675112 times.
|
43344480 | if (!fact && (!is_luma || !filter_flag)) { |
981 | 2723528 | pred = p[1]; | |
982 | } else { | ||
983 |
2/2✓ Branch 0 taken 15676988 times.
✓ Branch 1 taken 4633488 times.
|
40620952 | if (!c_idx) { |
984 | 31353976 | const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact]; | |
985 | 31353976 | pred = INTRA_LUMA_FILTER(p); | |
986 | } else { | ||
987 | 9266976 | pred = INTRA_CHROMA_FILTER(p); | |
988 | } | ||
989 | } | ||
990 |
2/2✓ Branch 0 taken 4965520 times.
✓ Branch 1 taken 16706720 times.
|
43344480 | if (need_pdpc) { |
991 |
2/2✓ Branch 0 taken 1935032 times.
✓ Branch 1 taken 3030488 times.
|
9931040 | if (y < (3 << nscale)) { |
992 | 3870064 | const pixel t = top[x + (inv_angle_sum >> 9)]; | |
993 | 3870064 | pred = CLIP(pred + (((t - pred) * wt + 32) >> 6)); | |
994 | } | ||
995 | } | ||
996 | 43344480 | POS(x, y) = pred; | |
997 | 43344480 | pos += dp; | |
998 | } | ||
999 |
2/2✓ Branch 0 taken 411780 times.
✓ Branch 1 taken 1085252 times.
|
2994064 | if (need_pdpc) |
1000 | 823560 | inv_angle_sum += inv_angle; | |
1001 | } | ||
1002 | 370636 | } | |
1003 | |||
1004 | 2646 | static void FUNC(ff_vvc_intra_dsp_init)(VVCIntraDSPContext *const intra) | |
1005 | { | ||
1006 | 2646 | intra->lmcs_scale_chroma = FUNC(lmcs_scale_chroma); | |
1007 | 2646 | intra->intra_cclm_pred = FUNC(intra_cclm_pred); | |
1008 | 2646 | intra->intra_pred = FUNC(intra_pred); | |
1009 | 2646 | intra->pred_planar = FUNC(pred_planar); | |
1010 | 2646 | intra->pred_mip = FUNC(pred_mip); | |
1011 | 2646 | intra->pred_dc = FUNC(pred_dc); | |
1012 | 2646 | intra->pred_v = FUNC(pred_v); | |
1013 | 2646 | intra->pred_h = FUNC(pred_h); | |
1014 | 2646 | intra->pred_angular_v = FUNC(pred_angular_v); | |
1015 | 2646 | intra->pred_angular_h = FUNC(pred_angular_h); | |
1016 | 2646 | } | |
1017 |