FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vvc/inter.c
Date: 2025-08-19 23:55:23
Exec Total Coverage
Lines: 627 635 98.7%
Functions: 36 36 100.0%
Branches: 313 336 93.2%

Line Branch Exec Source
1 /*
2 * VVC inter prediction
3 *
4 * Copyright (C) 2022 Nuo Mi
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 #include "libavutil/frame.h"
23
24 #include "data.h"
25 #include "inter.h"
26 #include "mvs.h"
27 #include "refs.h"
28
29 // +1 is enough, + 32 for asm alignment
30 #define PROF_TEMP_OFFSET (MAX_PB_SIZE + 32)
31 static const int bcw_w_lut[] = {4, 5, 3, 10, -2};
32
33 23707305 static void subpic_get_rect(VVCRect *r, const VVCFrame *src_frame, const int subpic_idx, const int is_chroma)
34 {
35 23707305 const VVCSPS *sps = src_frame->sps;
36 23707305 const VVCPPS *pps = src_frame->pps;
37 23707305 const int hs = sps->hshift[is_chroma];
38 23707305 const int vs = sps->vshift[is_chroma];
39
40 23707305 r->l = pps->subpic_x[subpic_idx] >> hs;
41 23707305 r->t = pps->subpic_y[subpic_idx] >> vs;
42 23707305 r->r = r->l + (pps->subpic_width[subpic_idx] >> hs);
43 23707305 r->b = r->t + (pps->subpic_height[subpic_idx] >> vs);
44 23707305 }
45
46 // clip to subblock and subpicture process in 8.5.6.3.2 Luma sample interpolation filtering process
47 23709546 static void clip_to_subpic(int *x_off, int *y_off, int *pic_width, int *pic_height, const VVCRect *subpic, const VVCRect *sb, const int dmvr_clip)
48 {
49
4/4
✓ Branch 0 taken 1794619 times.
✓ Branch 1 taken 21914927 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1794491 times.
23709546 const int l = dmvr_clip ? FFMIN(FFMAX(subpic->l, sb->l), subpic->r - 1) : subpic->l;
50
4/4
✓ Branch 0 taken 1794619 times.
✓ Branch 1 taken 21914927 times.
✓ Branch 2 taken 1066 times.
✓ Branch 3 taken 1793553 times.
23709546 const int t = dmvr_clip ? FFMIN(FFMAX(subpic->t, sb->t), subpic->b - 1) : subpic->t;
51
2/2
✓ Branch 0 taken 1794619 times.
✓ Branch 1 taken 21914927 times.
23709546 const int r = dmvr_clip ? FFMAX(FFMIN(subpic->r, sb->r), subpic->l + 1) : subpic->r;
52
2/2
✓ Branch 0 taken 1794619 times.
✓ Branch 1 taken 21914927 times.
23709546 const int b = dmvr_clip ? FFMAX(FFMIN(subpic->b, sb->b), subpic->t + 1) : subpic->b;
53
54 23709546 *x_off -= l;
55 23709546 *y_off -= t;
56 23709546 *pic_width = r - l;
57 23709546 *pic_height = b - t;
58 23709546 }
59
60 23705064 static void emulated_edge_no_wrap(const VVCLocalContext *lc, uint8_t *dst,
61 const uint8_t **src, ptrdiff_t *src_stride,
62 int x_off, int y_off, const int block_w, const int block_h,
63 const int extra_before, const int extra_after,
64 const VVCRect *subpic, const VVCRect *sb, const int dmvr_clip)
65 {
66 23705064 const VVCFrameContext *fc = lc->fc;
67 23705064 const int extra = extra_before + extra_after;
68 int pic_width, pic_height;
69
70 23705064 *src += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
71
72 23705064 clip_to_subpic(&x_off, &y_off, &pic_width, &pic_height, subpic, sb, dmvr_clip);
73
74
6/6
✓ Branch 0 taken 21910555 times.
✓ Branch 1 taken 1794509 times.
✓ Branch 2 taken 21708902 times.
✓ Branch 3 taken 201653 times.
✓ Branch 4 taken 21379117 times.
✓ Branch 5 taken 329785 times.
23705064 if (dmvr_clip || x_off < extra_before || y_off < extra_before ||
75
2/2
✓ Branch 0 taken 21153555 times.
✓ Branch 1 taken 225562 times.
21379117 x_off >= pic_width - block_w - extra_after ||
76
2/2
✓ Branch 0 taken 292482 times.
✓ Branch 1 taken 20861073 times.
21153555 y_off >= pic_height - block_h - extra_after) {
77 2843991 const int ps = fc->ps.sps->pixel_shift;
78 2843991 const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << ps;
79 2843991 const int offset = extra_before * *src_stride + (extra_before << ps);
80 2843991 const int buf_offset = extra_before * edge_emu_stride + (extra_before << ps);
81
82 2843991 fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride,
83 block_w + extra, block_h + extra, x_off - extra_before, y_off - extra_before,
84 pic_width, pic_height);
85
86 2843991 *src = dst + buf_offset;
87 2843991 *src_stride = edge_emu_stride;
88 }
89 23705064 }
90
91 4482 static void emulated_half(const VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
92 const uint8_t *src, const ptrdiff_t src_stride, const int ps,
93 int x_off, int y_off, const int block_w, const int block_h,
94 const VVCRect *subpic,const VVCRect *half_sb, const int dmvr_clip)
95 {
96 4482 const VVCFrameContext *fc = lc->fc;
97 int pic_width, pic_height;
98
99 4482 src += y_off * src_stride + x_off * (1 << ps);
100
101 4482 clip_to_subpic(&x_off, &y_off, &pic_width, &pic_height, subpic, half_sb, dmvr_clip);
102
103 4482 fc->vdsp.emulated_edge_mc(dst, src, dst_stride, src_stride,
104 block_w, block_h, x_off, y_off, pic_width, pic_height);
105 4482 }
106
107 9897 static void sb_set_lr(VVCRect *sb, const int l, const int r)
108 {
109 9897 sb->l = l;
110 9897 sb->r = r;
111 9897 }
112
113 7656 static void sb_wrap(VVCRect *sb, const int wrap)
114 {
115 7656 sb_set_lr(sb, sb->l + wrap, sb->r + wrap);
116 7656 }
117
118 23707305 static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
119 const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
120 int x_sb, int y_sb, int x_off, int y_off, int block_w, int block_h, const int wrap_enabled,
121 const int is_chroma, const int extra_before, const int extra_after)
122 {
123 23707305 const VVCSPS *sps = src_frame->sps;
124 23707305 const VVCPPS *pps = src_frame->pps;
125 23707305 const int ps = sps->pixel_shift;
126 23707305 const int subpic_idx = lc->sc->sh.r->curr_subpic_idx;
127 23707305 const int extra = extra_before + extra_after;
128
4/4
✓ Branch 0 taken 22332934 times.
✓ Branch 1 taken 1374371 times.
✓ Branch 2 taken 420193 times.
✓ Branch 3 taken 21912741 times.
23707305 const int dmvr_clip = x_sb != x_off || y_sb != y_off;
129 23707305 const int dmvr_left = FFMAX(x_off, x_sb) - extra_before;
130 23707305 const int dmvr_right = FFMIN(x_off, x_sb) + block_w + extra_after;
131 23707305 const int left = x_off - extra_before;
132 23707305 const int top = y_off - extra_before;
133 23707305 const int pic_width = pps->width >> sps->hshift[is_chroma];
134 23707305 const int wrap = pps->ref_wraparound_offset << (sps->min_cb_log2_size_y - sps->hshift[is_chroma]);
135 23707305 const ptrdiff_t dst_stride = EDGE_EMU_BUFFER_STRIDE << ps;
136 23707305 VVCRect sb = { x_sb - extra_before, y_sb - extra_before, x_sb + block_w + extra_after, y_sb + block_h + extra_after };
137 VVCRect subpic;
138
139 23707305 subpic_get_rect(&subpic, src_frame, subpic_idx, is_chroma);
140
141
6/6
✓ Branch 0 taken 257536 times.
✓ Branch 1 taken 23449769 times.
✓ Branch 2 taken 251971 times.
✓ Branch 3 taken 5565 times.
✓ Branch 4 taken 247639 times.
✓ Branch 5 taken 4332 times.
23707305 if (!wrap_enabled || (dmvr_left >= 0 && dmvr_right <= pic_width)) {
142 23697408 emulated_edge_no_wrap(lc, dst, src, src_stride,
143 x_off, y_off, block_w, block_h, extra_before, extra_after, &subpic, &sb, dmvr_clip);
144 23705064 return;
145 }
146
2/2
✓ Branch 0 taken 4161 times.
✓ Branch 1 taken 5736 times.
9897 if (dmvr_right <= 0) {
147 4161 sb_wrap(&sb, wrap);
148 4161 emulated_edge_no_wrap(lc, dst, src, src_stride,
149 x_off + wrap, y_off, block_w, block_h, extra_before, extra_after, &subpic, &sb, dmvr_clip);
150 4161 return;
151 }
152
2/2
✓ Branch 0 taken 3495 times.
✓ Branch 1 taken 2241 times.
5736 if (dmvr_left >= pic_width) {
153 3495 sb_wrap(&sb, -wrap);
154 3495 emulated_edge_no_wrap(lc, dst, src, src_stride,
155 x_off - wrap, y_off, block_w, block_h, extra_before, extra_after, &subpic, &sb, dmvr_clip);
156 3495 return;
157 }
158
159 2241 block_w += extra;
160 2241 block_h += extra;
161
162 // half block are wrapped
163
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 837 times.
2241 if (dmvr_left < 0 ) {
164 1404 const int w = -left;
165 1404 VVCRect half_sb = { sb.l + wrap, sb.t, 0 + wrap, sb.b };
166 1404 emulated_half(lc, dst, dst_stride, *src, *src_stride, ps,
167 left + wrap, top, w, block_h, &subpic, &half_sb, dmvr_clip);
168
169 1404 sb_set_lr(&half_sb, 0, sb.r);
170 1404 emulated_half(lc, dst + (w << ps), dst_stride, *src, *src_stride, ps,
171 0, top, block_w - w, block_h, &subpic, &half_sb, dmvr_clip);
172 } else {
173 837 const int w = pic_width - left;
174 837 VVCRect half_sb = { sb.l, sb.t, pic_width, sb.b };
175 837 emulated_half(lc, dst, dst_stride, *src, *src_stride, ps,
176 left, top, w, block_h, &subpic, &half_sb, dmvr_clip);
177
178 837 sb_set_lr(&half_sb, pic_width - wrap, sb.r - wrap);
179 837 emulated_half(lc, dst + (w << ps), dst_stride, *src, *src_stride, ps,
180 pic_width - wrap , top, block_w - w, block_h, &subpic, &half_sb, dmvr_clip);
181 }
182
183 2241 *src = dst + extra_before * dst_stride + (extra_before << ps);
184 2241 *src_stride = dst_stride;
185 }
186
187 #define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off) \
188 emulated_edge(lc, dst, src, src_stride, ref, x_off, y_off, x_off, y_off, block_w, block_h, wrap_enabled, is_chroma, \
189 is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE, is_chroma ? CHROMA_EXTRA_AFTER : LUMA_EXTRA_AFTER)
190
191 #define MC_EMULATED_EDGE_DMVR(dst, src, src_stride, x_sb, y_sb, x_off, y_off) \
192 emulated_edge(lc, dst, src, src_stride, ref, x_sb, y_sb, x_off, y_off, block_w, block_h, wrap_enabled, is_chroma, \
193 is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE, is_chroma ? CHROMA_EXTRA_AFTER : LUMA_EXTRA_AFTER)
194
195 #define MC_EMULATED_EDGE_BILINEAR(dst, src, src_stride, x_off, y_off) \
196 emulated_edge(lc, dst, src, src_stride, ref, x_off, y_off, x_off, y_off, pred_w, pred_h, wrap_enabled, 0, \
197 BILINEAR_EXTRA_BEFORE, BILINEAR_EXTRA_AFTER)
198
199 // part of 8.5.6.6 Weighted sample prediction process
200 6452345 static int derive_weight_uni(int *denom, int *wx, int *ox,
201 const VVCLocalContext *lc, const MvField *mvf, const int c_idx)
202 {
203 6452345 const VVCFrameContext *fc = lc->fc;
204 6452345 const VVCPPS *pps = fc->ps.pps;
205 6452345 const VVCSH *sh = &lc->sc->sh;
206
4/4
✓ Branch 0 taken 1707465 times.
✓ Branch 1 taken 4744880 times.
✓ Branch 2 taken 1593390 times.
✓ Branch 3 taken 114075 times.
12790615 const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) ||
207
4/4
✓ Branch 0 taken 4744880 times.
✓ Branch 1 taken 1593390 times.
✓ Branch 2 taken 163995 times.
✓ Branch 3 taken 4580885 times.
6338270 (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag);
208
2/2
✓ Branch 0 taken 278070 times.
✓ Branch 1 taken 6174275 times.
6452345 if (weight_flag) {
209 278070 const int lx = mvf->pred_flag - PF_L0;
210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278070 times.
278070 const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
211
212 278070 *denom = w->log2_denom[c_idx > 0];
213 278070 *wx = w->weight[lx][c_idx][mvf->ref_idx[lx]];
214 278070 *ox = w->offset[lx][c_idx][mvf->ref_idx[lx]];
215 }
216 6452345 return weight_flag;
217 }
218
219 // part of 8.5.6.6 Weighted sample prediction process
220 7435887 static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1,
221 const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int dmvr_flag)
222 {
223 7435887 const VVCFrameContext *fc = lc->fc;
224 7435887 const VVCPPS *pps = fc->ps.pps;
225 7435887 const VVCSH *sh = &lc->sc->sh;
226 7435887 const int bcw_idx = mvf->bcw_idx;
227
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7435887 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14871774 const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) ||
228
5/6
✓ Branch 0 taken 7435887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134292 times.
✓ Branch 3 taken 7301595 times.
✓ Branch 4 taken 134280 times.
✓ Branch 5 taken 12 times.
7435887 (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag && !dmvr_flag);
229
8/8
✓ Branch 0 taken 7301607 times.
✓ Branch 1 taken 134280 times.
✓ Branch 2 taken 537580 times.
✓ Branch 3 taken 6764027 times.
✓ Branch 4 taken 538183 times.
✓ Branch 5 taken 133677 times.
✓ Branch 6 taken 3844 times.
✓ Branch 7 taken 534339 times.
7435887 if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag))
230 6767871 return 0;
231
232
2/2
✓ Branch 0 taken 534339 times.
✓ Branch 1 taken 133677 times.
668016 if (bcw_idx) {
233 534339 *denom = 2;
234 534339 *w1 = bcw_w_lut[bcw_idx];
235 534339 *w0 = 8 - *w1;
236 534339 *o0 = *o1 = 0;
237 } else {
238 133677 const VVCPPS *pps = fc->ps.pps;
239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133677 times.
133677 const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
240
241 133677 *denom = w->log2_denom[c_idx > 0];
242 133677 *w0 = w->weight[L0][c_idx][mvf->ref_idx[L0]];
243 133677 *w1 = w->weight[L1][c_idx][mvf->ref_idx[L1]];
244 133677 *o0 = w->offset[L0][c_idx][mvf->ref_idx[L0]];
245 133677 *o1 = w->offset[L1][c_idx][mvf->ref_idx[L1]];
246 }
247 668016 return 1;
248 }
249
250 #define INTER_FILTER(t, frac) (is_chroma ? ff_vvc_inter_chroma_filters[t][frac] : ff_vvc_inter_luma_filters[t][frac])
251
252 155720 static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const Mv *mv,
253 int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
254 {
255 155720 const VVCFrameContext *fc = lc->fc;
256 155720 const PredictionUnit *pu = &lc->cu->pu;
257 155720 const uint8_t *src = ref->frame->data[c_idx];
258 155720 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
259 155720 const int is_chroma = !!c_idx;
260 155720 const int hs = fc->ps.sps->hshift[c_idx];
261 155720 const int vs = fc->ps.sps->vshift[c_idx];
262 155720 const int idx = av_log2(block_w) - 1;
263 155720 const intptr_t mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
264 155720 const intptr_t my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
265
4/4
✓ Branch 0 taken 54948 times.
✓ Branch 1 taken 100772 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 54909 times.
155720 const int hpel_if_idx = (is_chroma || pu->merge_gpm_flag) ? 0 : pu->mi.hpel_if_idx;
266
2/2
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 54948 times.
155720 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
267
2/2
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 54948 times.
155720 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
268 155720 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
269
270 155720 x_off += mv->x >> (4 + hs);
271 155720 y_off += mv->y >> (4 + vs);
272
273
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 54948 times.
✓ Branch 2 taken 100772 times.
✓ Branch 3 taken 54948 times.
155720 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
274 155720 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
275 155720 }
276
277 3967244 static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
278 const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
279 const int c_idx)
280 {
281 3967244 const VVCFrameContext *fc = lc->fc;
282 3967244 const PredictionUnit *pu = &lc->cu->pu;
283 3967244 const uint8_t *src = ref->frame->data[c_idx];
284 3967244 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
285 3967244 const int lx = mvf->pred_flag - PF_L0;
286 3967244 const int hs = fc->ps.sps->hshift[c_idx];
287 3967244 const int vs = fc->ps.sps->vshift[c_idx];
288 3967244 const int idx = av_log2(block_w) - 1;
289 3967244 const Mv *mv = &mvf->mv[lx];
290 3967244 const int is_chroma = !!c_idx;
291 3967244 const intptr_t mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
292 3967244 const intptr_t my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
293
2/2
✓ Branch 0 taken 782802 times.
✓ Branch 1 taken 3184442 times.
3967244 const int hpel_if_idx = is_chroma ? 0 : pu->mi.hpel_if_idx;
294
2/2
✓ Branch 0 taken 3184442 times.
✓ Branch 1 taken 782802 times.
3967244 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
295
2/2
✓ Branch 0 taken 3184442 times.
✓ Branch 1 taken 782802 times.
3967244 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
296 3967244 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
297 int denom, wx, ox;
298
299 3967244 x_off += mv->x >> (4 + hs);
300 3967244 y_off += mv->y >> (4 + vs);
301
302
4/4
✓ Branch 0 taken 3184442 times.
✓ Branch 1 taken 782802 times.
✓ Branch 2 taken 3184442 times.
✓ Branch 3 taken 782802 times.
3967244 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
303
2/2
✓ Branch 1 taken 133490 times.
✓ Branch 2 taken 3833754 times.
3967244 if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
304 133490 fc->vvcdsp.inter.put_uni_w[is_chroma][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
305 block_h, denom, wx, ox, hf, vf, block_w);
306 } else {
307 3833754 fc->vvcdsp.inter.put_uni[is_chroma][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
308 block_h, hf, vf, block_w);
309 }
310 3967244 }
311
312 6382109 static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
313 const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const MvField *orig_mv,
314 const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx,
315 const int sb_bdof_flag)
316 {
317 6382109 const VVCFrameContext *fc = lc->fc;
318 6382109 const PredictionUnit *pu = &lc->cu->pu;
319 6382109 const int hs = fc->ps.sps->hshift[c_idx];
320 6382109 const int vs = fc->ps.sps->vshift[c_idx];
321 6382109 const int idx = av_log2(block_w) - 1;
322 6382109 const VVCFrame *refs[] = { ref0, ref1 };
323 6382109 int16_t *tmp[] = { lc->tmp + sb_bdof_flag * PROF_TEMP_OFFSET, lc->tmp1 + sb_bdof_flag * PROF_TEMP_OFFSET };
324 int denom, w0, w1, o0, o1;
325 6382109 const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, pu->dmvr_flag);
326 6382109 const int is_chroma = !!c_idx;
327
2/2
✓ Branch 0 taken 1810441 times.
✓ Branch 1 taken 4571668 times.
6382109 const int hpel_if_idx = is_chroma ? 0 : pu->mi.hpel_if_idx;
328
329
2/2
✓ Branch 0 taken 12764218 times.
✓ Branch 1 taken 6382109 times.
19146327 for (int i = L0; i <= L1; i++) {
330 12764218 const Mv *mv = mvf->mv + i;
331 12764218 const int mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
332 12764218 const int my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
333 12764218 const int ox = x_off + (mv->x >> (4 + hs));
334 12764218 const int oy = y_off + (mv->y >> (4 + vs));
335 12764218 const VVCFrame *ref = refs[i];
336 12764218 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
337 12764218 const uint8_t *src = ref->frame->data[c_idx];
338
2/2
✓ Branch 0 taken 9143336 times.
✓ Branch 1 taken 3620882 times.
12764218 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
339
2/2
✓ Branch 0 taken 9143336 times.
✓ Branch 1 taken 3620882 times.
12764218 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
340 12764218 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
341
342
2/2
✓ Branch 0 taken 6647420 times.
✓ Branch 1 taken 6116798 times.
12764218 if (pu->dmvr_flag) {
343 6647420 const int x_sb = x_off + (orig_mv->mv[i].x >> (4 + hs));
344 6647420 const int y_sb = y_off + (orig_mv->mv[i].y >> (4 + vs));
345
346
4/4
✓ Branch 0 taken 4420656 times.
✓ Branch 1 taken 2226764 times.
✓ Branch 2 taken 4420656 times.
✓ Branch 3 taken 2226764 times.
6647420 MC_EMULATED_EDGE_DMVR(lc->edge_emu_buffer, &src, &src_stride, x_sb, y_sb, ox, oy);
347 } else {
348
4/4
✓ Branch 0 taken 4722680 times.
✓ Branch 1 taken 1394118 times.
✓ Branch 2 taken 4722680 times.
✓ Branch 3 taken 1394118 times.
6116798 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
349 }
350 12764218 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
351
2/2
✓ Branch 0 taken 711264 times.
✓ Branch 1 taken 12052954 times.
12764218 if (sb_bdof_flag)
352 711264 fc->vvcdsp.inter.bdof_fetch_samples(tmp[i], src, src_stride, mx, my, block_w, block_h);
353 }
354
2/2
✓ Branch 0 taken 355632 times.
✓ Branch 1 taken 6026477 times.
6382109 if (sb_bdof_flag)
355 355632 fc->vvcdsp.inter.apply_bdof(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
356
2/2
✓ Branch 0 taken 381272 times.
✓ Branch 1 taken 5645205 times.
6026477 else if (weight_flag)
357 381272 fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
358 else
359 5645205 fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
360 6382109 }
361
362 65406 static const int8_t* inter_filter_scaled(const int scale, const int is_chroma, const int is_affine)
363 {
364 #define SCALE_THRESHOLD_1 20480
365 #define SCALE_THRESHOLD_2 28672
366
367 65406 const int i = (scale > SCALE_THRESHOLD_2) + (scale > SCALE_THRESHOLD_1);
368
369
2/2
✓ Branch 0 taken 40882 times.
✓ Branch 1 taken 24524 times.
65406 if (!is_chroma) {
370
2/2
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 38160 times.
40882 if (!is_affine)
371 2722 return &ff_vvc_inter_luma_filters[i + !!i][0][0]; //hpel 1 is not needed for scaled
372 38160 return &ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE + i][0][0];
373 }
374
375 24524 return &ff_vvc_inter_chroma_filters[i][0][0];
376 }
377 #define INTER_FILTER_SCALED(scale) inter_filter_scaled(scale, is_chroma, is_affine)
378
379 #define SCALED_CHROMA_ADDIN(scale, collocated_flag) (is_chroma ? (collocated_flag ? 0 : 8 * (scale - (1 << 14))) : 0)
380 #define SCALED_REF_SB(off, scaling_off, ref_mv, scale, add, shift) ((((off - (scaling_off << shift)) << (4 + shift)) + ref_mv) * scale + add)
381 #define SCALED_REF(ref_sb, offset, shift) (FFSIGN(ref_sb) * ((FFABS(ref_sb) + (128 << is_chroma)) >> (8 + is_chroma)) + (offset << (10 - shift)) + (32 >> is_chroma))
382 #define SCALED_STEP(scale) ((scale + 8) >> 4)
383
384 32703 static void scaled_ref_pos_and_step(const VVCLocalContext *lc, const VVCRefPic *refp, const Mv *mv, const int x_off, const int y_off, const int c_idx,
385 int *x, int *y, int *dx, int *dy)
386 {
387 32703 const VVCFrameContext *fc = lc->fc;
388 32703 const VVCSPS *sps = fc->ps.sps;
389 32703 const int is_chroma = !!c_idx;
390 32703 const int hs = sps->hshift[c_idx];
391 32703 const int vs = sps->vshift[c_idx];
392 32703 const int left_offset = fc->ref->scaling_win.left_offset;
393 32703 const int top_offset = fc->ref->scaling_win.top_offset;
394
3/4
✓ Branch 0 taken 12262 times.
✓ Branch 1 taken 20441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12262 times.
32703 const int addx = SCALED_CHROMA_ADDIN(refp->scale[0], sps->r->sps_chroma_horizontal_collocated_flag);
395
3/4
✓ Branch 0 taken 12262 times.
✓ Branch 1 taken 20441 times.
✓ Branch 2 taken 12262 times.
✗ Branch 3 not taken.
32703 const int addy = SCALED_CHROMA_ADDIN(refp->scale[1], sps->r->sps_chroma_vertical_collocated_flag);
396 32703 const int refx_sb = SCALED_REF_SB(x_off, left_offset, mv->x, refp->scale[0], addx, hs);
397 32703 const int refy_sb = SCALED_REF_SB(y_off, top_offset, mv->y, refp->scale[1], addy, vs);
398
399
2/2
✓ Branch 0 taken 32637 times.
✓ Branch 1 taken 66 times.
32703 *x = SCALED_REF(refx_sb, left_offset, hs);
400
2/2
✓ Branch 0 taken 32535 times.
✓ Branch 1 taken 168 times.
32703 *y = SCALED_REF(refy_sb, top_offset, vs);
401 32703 *dx = SCALED_STEP(refp->scale[0]);
402 32703 *dy = SCALED_STEP(refp->scale[1]);
403 32703 }
404
405 32703 static void emulated_edge_scaled(VVCLocalContext *lc, const uint8_t **src, ptrdiff_t *src_stride, int *src_height,
406 const VVCFrame *ref, const int x, const int y, const int dx, const int dy, const int w, const int h, const int is_chroma)
407 {
408 32703 const int x_off = SCALED_INT(x);
409 32703 const int y_off = SCALED_INT(y);
410 32703 const int x_end = SCALED_INT(x + w * dx);
411 32703 const int y_end = SCALED_INT(y + h * dy);
412 32703 const int x_last = SCALED_INT(x + (w - 1) * dx);
413 32703 const int y_last = SCALED_INT(y + (h - 1) * dy);
414 32703 const int block_w = x_end - x_off + (x_end == x_last);
415 32703 const int block_h = *src_height = y_end - y_off + (y_end == y_last);
416 32703 const int wrap_enabled = 0;
417
418
4/4
✓ Branch 0 taken 12262 times.
✓ Branch 1 taken 20441 times.
✓ Branch 2 taken 12262 times.
✓ Branch 3 taken 20441 times.
32703 MC_EMULATED_EDGE(lc->edge_emu_buffer, src, src_stride, x_off, y_off);
419 32703 }
420
421 5946 static void mc_scaled(VVCLocalContext *lc, int16_t *dst, const VVCRefPic *refp, const Mv *mv,
422 int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
423 {
424 5946 const VVCFrameContext *fc = lc->fc;
425 5946 const PredictionUnit *pu = &lc->cu->pu;
426 5946 const uint8_t *src = refp->ref->frame->data[c_idx];
427 5946 ptrdiff_t src_stride = refp->ref->frame->linesize[c_idx];
428 5946 const int is_affine = pu->inter_affine_flag;
429 5946 const int is_chroma = !!c_idx;
430 5946 const int idx = av_log2(block_w) - 1;
431 5946 const int8_t *hf = INTER_FILTER_SCALED(refp->scale[0]);
432 5946 const int8_t *vf = INTER_FILTER_SCALED(refp->scale[1]);
433 int x, y, dx, dy, src_height;
434
435 5946 scaled_ref_pos_and_step(lc, refp, mv, x_off, y_off, c_idx, &x, &y, &dx, &dy);
436 5946 emulated_edge_scaled(lc, &src, &src_stride, &src_height, refp->ref, x, y, dx, dy, block_w, block_h, is_chroma);
437 5946 fc->vvcdsp.inter.put_scaled[is_chroma][idx](dst, src, src_stride, src_height, x, y, dx, dy, block_h, hf, vf, block_w);
438 5946 }
439
440 26757 static void mc_uni_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const VVCRefPic *refp,
441 const MvField *mvf, const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx)
442 {
443 26757 const VVCFrameContext *fc = lc->fc;
444 26757 const PredictionUnit *pu = &lc->cu->pu;
445 26757 const uint8_t *src = refp->ref->frame->data[c_idx];
446 26757 ptrdiff_t src_stride = refp->ref->frame->linesize[c_idx];
447 26757 const int lx = mvf->pred_flag - PF_L0;
448 26757 const Mv *mv = &mvf->mv[lx];
449 26757 const int is_affine = pu->inter_affine_flag;
450 26757 const int is_chroma = !!c_idx;
451 26757 const int idx = av_log2(block_w) - 1;
452 26757 const int8_t *hf = INTER_FILTER_SCALED(refp->scale[0]);
453 26757 const int8_t *vf = INTER_FILTER_SCALED(refp->scale[1]);
454 int denom, wx, ox, x, y, dx, dy, src_height;
455
456 26757 scaled_ref_pos_and_step(lc, refp, mv, x_off, y_off, c_idx, &x, &y, &dx, &dy);
457 26757 emulated_edge_scaled(lc, &src, &src_stride, &src_height, refp->ref, x, y, dx, dy, block_w, block_h, is_chroma);
458
459
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 26757 times.
26757 if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
460 fc->vvcdsp.inter.put_uni_w_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height,
461 x, y, dx, dy, block_h, denom, wx, ox, hf, vf, block_w);
462 } else {
463 26757 fc->vvcdsp.inter.put_uni_scaled[is_chroma][idx](dst, dst_stride, src, src_stride, src_height,
464 x, y, dx, dy, block_h, hf, vf, block_w);
465 }
466 26757 }
467
468 1086 static void mc_bi_scaled(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
469 const VVCRefPic *refp0, const VVCRefPic *refp1, const MvField *mvf,
470 const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx)
471 {
472 int denom, w0, w1, o0, o1;
473 1086 const VVCFrameContext *fc = lc->fc;
474 1086 const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, lc->cu->pu.dmvr_flag);
475 1086 const VVCRefPic *refps[] = { refp0, refp1 };
476 1086 int16_t *tmp[] = { lc->tmp, lc->tmp1 };
477
478
2/2
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 1086 times.
3258 for (int i = L0; i <= L1; i++) {
479 2172 const Mv *mv = mvf->mv + i;
480 2172 const VVCRefPic *refp = refps[i];
481
482
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 117 times.
2172 if (refp->is_scaled)
483 2055 mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, c_idx);
484 else
485 117 mc(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, c_idx);
486 }
487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
1086 if (weight_flag)
488 fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
489 else
490 1086 fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
491 1086 }
492
493 2458344 static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
494 const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
495 const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
496 {
497 2458344 const VVCFrameContext *fc = lc->fc;
498 2458344 const uint8_t *src = ref->frame->data[LUMA];
499 2458344 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
500 2458344 uint16_t *prof_tmp = lc->tmp + PROF_TEMP_OFFSET;
501 2458344 const int idx = av_log2(block_w) - 1;
502 2458344 const int lx = mvf->pred_flag - PF_L0;
503 2458344 const Mv *mv = mvf->mv + lx;
504 2458344 const int mx = mv->x & 0xf;
505 2458344 const int my = mv->y & 0xf;
506 2458344 const int8_t *hf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
507 2458344 const int8_t *vf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
508 int denom, wx, ox;
509 2458344 const int weight_flag = derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA);
510 2458344 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
511 2458344 const int is_chroma = 0;
512
513 2458344 x_off += mv->x >> 4;
514 2458344 y_off += mv->y >> 4;
515
516
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2458344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2458344 times.
2458344 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
517
2/2
✓ Branch 0 taken 2149224 times.
✓ Branch 1 taken 309120 times.
2458344 if (cb_prof_flag) {
518 2149224 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
519 2149224 fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
520
2/2
✓ Branch 0 taken 2134892 times.
✓ Branch 1 taken 14332 times.
2149224 if (!weight_flag)
521 2134892 fc->vvcdsp.inter.apply_prof_uni(dst, dst_stride, prof_tmp, diff_mv_x, diff_mv_y);
522 else
523 14332 fc->vvcdsp.inter.apply_prof_uni_w(dst, dst_stride, prof_tmp, diff_mv_x, diff_mv_y, denom, wx, ox);
524 } else {
525
2/2
✓ Branch 0 taken 178872 times.
✓ Branch 1 taken 130248 times.
309120 if (!weight_flag)
526 178872 fc->vvcdsp.inter.put_uni[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride, block_h, hf, vf, block_w);
527 else
528 130248 fc->vvcdsp.inter.put_uni_w[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride, block_h, denom, wx, ox, hf, vf, block_w);
529 }
530 2458344 }
531
532 2102312 static void luma_prof(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref,
533 const Mv *mv , const int x_off, const int y_off, const int block_w, const int block_h, const int lx)
534 {
535 2102312 const VVCFrameContext *fc = lc->fc;
536 2102312 const PredictionUnit *pu = &lc->cu->pu;
537 2102312 const int mx = mv->x & 0xf;
538 2102312 const int my = mv->y & 0xf;
539 2102312 const int ox = x_off + (mv->x >> 4);
540 2102312 const int oy = y_off + (mv->y >> 4);
541 2102312 const int idx = av_log2(block_w) - 1;
542 2102312 const int is_chroma = 0;
543 2102312 uint16_t *prof_tmp = lc->tmp2 + PROF_TEMP_OFFSET;
544 2102312 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
545 2102312 const uint8_t *src = ref->frame->data[LUMA];
546 2102312 const int8_t *hf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
547 2102312 const int8_t *vf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
548 2102312 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
549
550
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2102312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2102312 times.
2102312 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
551
2/2
✓ Branch 0 taken 692840 times.
✓ Branch 1 taken 1409472 times.
2102312 if (!pu->cb_prof_flag[lx]) {
552 692840 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
553 } else {
554 1409472 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
555 1409472 fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
556 1409472 fc->vvcdsp.inter.apply_prof(dst, prof_tmp, pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
557 }
558 2102312 }
559
560 1052692 static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
561 const VVCRefPic *ref0, const VVCRefPic *ref1, const MvField *mvf, const int x_off, const int y_off,
562 const int block_w, const int block_h)
563 {
564 1052692 const VVCFrameContext *fc = lc->fc;
565 1052692 const VVCRefPic *refps[] = { ref0, ref1 };
566 1052692 int16_t *tmp[] = { lc->tmp, lc->tmp1 };
567 int denom, w0, w1, o0, o1;
568 1052692 const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, 0);
569
570
2/2
✓ Branch 0 taken 2105384 times.
✓ Branch 1 taken 1052692 times.
3158076 for (int i = L0; i <= L1; i++) {
571 2105384 const VVCRefPic *refp = refps[i];
572 2105384 const Mv *mv = mvf->mv + i;
573
574
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 2102312 times.
2105384 if (refp->is_scaled)
575 3072 mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, LUMA);
576 else
577 2102312 luma_prof(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, i);
578 }
579
580
2/2
✓ Branch 0 taken 286720 times.
✓ Branch 1 taken 765972 times.
1052692 if (weight_flag)
581 286720 fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
582 else
583 765972 fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
584 1052692 }
585
586 8552175 static int pred_get_refs(const VVCLocalContext *lc, VVCRefPic *refp[2], const MvField *mv)
587 {
588 8552175 RefPicList *rpl = lc->sc->rpl;
589
590
2/2
✓ Branch 0 taken 17104350 times.
✓ Branch 1 taken 8552175 times.
25656525 for (int mask = PF_L0; mask <= PF_L1; mask++) {
591
2/2
✓ Branch 0 taken 13019154 times.
✓ Branch 1 taken 4085196 times.
17104350 if (mv->pred_flag & mask) {
592 13019154 const int lx = mask - PF_L0;
593 13019154 refp[lx] = rpl[lx].refs + mv->ref_idx[lx];
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13019154 times.
13019154 if (!refp[lx]->ref)
595 return AVERROR_INVALIDDATA;
596 }
597 }
598 8552175 return 0;
599 }
600
601 #define POS(c_idx, x, y) \
602 &fc->frame->data[c_idx][((y) >> fc->ps.sps->vshift[c_idx]) * fc->frame->linesize[c_idx] + \
603 (((x) >> fc->ps.sps->hshift[c_idx]) << fc->ps.sps->pixel_shift)]
604
605 27591 static void pred_gpm_blk(VVCLocalContext *lc)
606 {
607 27591 const VVCFrameContext *fc = lc->fc;
608 27591 const CodingUnit *cu = lc->cu;
609 27591 const PredictionUnit *pu = &cu->pu;
610
611 27591 const uint8_t angle_idx = ff_vvc_gpm_angle_idx[pu->gpm_partition_idx];
612 27591 const uint8_t weights_idx = ff_vvc_gpm_angle_to_weights_idx[angle_idx];
613 27591 const int w = av_log2(cu->cb_width) - 3;
614 27591 const int h = av_log2(cu->cb_height) - 3;
615 27591 const uint8_t off_x = ff_vvc_gpm_weights_offset_x[pu->gpm_partition_idx][h][w];
616 27591 const uint8_t off_y = ff_vvc_gpm_weights_offset_y[pu->gpm_partition_idx][h][w];
617 27591 const uint8_t mirror_type = ff_vvc_gpm_angle_to_mirror[angle_idx];
618 const uint8_t *weights;
619
620
2/2
✓ Branch 0 taken 25310 times.
✓ Branch 1 taken 2281 times.
27591 const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1;
621
622 27591 int16_t *tmp[2] = {lc->tmp, lc->tmp1};
623
624
2/2
✓ Branch 0 taken 78211 times.
✓ Branch 1 taken 27591 times.
105802 for (int c_idx = 0; c_idx < c_end; c_idx++) {
625 78211 const int hs = fc->ps.sps->hshift[c_idx];
626 78211 const int vs = fc->ps.sps->vshift[c_idx];
627 78211 const int x = lc->cu->x0 >> hs;
628 78211 const int y = lc->cu->y0 >> vs;
629 78211 const int width = cu->cb_width >> hs;
630 78211 const int height = cu->cb_height >> vs;
631 78211 uint8_t *dst = POS(c_idx, lc->cu->x0, lc->cu->y0);
632 78211 ptrdiff_t dst_stride = fc->frame->linesize[c_idx];
633
634 78211 int step_x = 1 << hs;
635 78211 int step_y = VVC_GPM_WEIGHT_SIZE << vs;
636
2/2
✓ Branch 0 taken 49429 times.
✓ Branch 1 taken 28782 times.
78211 if (!mirror_type) {
637 49429 weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + off_x];
638
2/2
✓ Branch 0 taken 12311 times.
✓ Branch 1 taken 16471 times.
28782 } else if (mirror_type == 1) {
639 12311 step_x = -step_x;
640 12311 weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + VVC_GPM_WEIGHT_SIZE - 1- off_x];
641 } else {
642 16471 step_y = -step_y;
643 16471 weights = &ff_vvc_gpm_weights[weights_idx][(VVC_GPM_WEIGHT_SIZE - 1 - off_y) * VVC_GPM_WEIGHT_SIZE + off_x];
644 }
645
646
2/2
✓ Branch 0 taken 156422 times.
✓ Branch 1 taken 78211 times.
234633 for (int i = 0; i < 2; i++) {
647 156422 const MvField *mv = pu->gpm_mv + i;
648 156422 const int lx = mv->pred_flag - PF_L0;
649 156422 VVCRefPic *refp = lc->sc->rpl[lx].refs + mv->ref_idx[lx];
650
651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156422 times.
156422 if (!refp->ref)
652 return;
653
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 155603 times.
156422 if (refp->is_scaled)
654 819 mc_scaled(lc, tmp[i], refp, mv->mv + lx, x, y, width, height, c_idx);
655 else
656 155603 mc(lc, tmp[i], refp->ref, mv->mv + lx, x, y, width, height, c_idx);
657 }
658 78211 fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
659 }
660 27591 return;
661 }
662
663 43833 static int ciip_derive_intra_weight(const VVCLocalContext *lc, const int x0, const int y0,
664 const int width, const int height)
665 {
666 43833 const VVCFrameContext *fc = lc->fc;
667 43833 const VVCSPS *sps = fc->ps.sps;
668 43833 const int x0b = av_zero_extend(x0, sps->ctb_log2_size_y);
669 43833 const int y0b = av_zero_extend(y0, sps->ctb_log2_size_y);
670
4/4
✓ Branch 0 taken 5187 times.
✓ Branch 1 taken 38646 times.
✓ Branch 2 taken 4249 times.
✓ Branch 3 taken 938 times.
43833 const int available_l = lc->ctb_left_flag || x0b;
671
4/4
✓ Branch 0 taken 6832 times.
✓ Branch 1 taken 37001 times.
✓ Branch 2 taken 6016 times.
✓ Branch 3 taken 816 times.
43833 const int available_u = lc->ctb_up_flag || y0b;
672 43833 const int min_pu_width = fc->ps.pps->min_pu_width;
673 43833 int w = 1;
674
675
4/4
✓ Branch 0 taken 43017 times.
✓ Branch 1 taken 816 times.
✓ Branch 2 taken 6198 times.
✓ Branch 3 taken 36819 times.
43833 if (available_u &&fc->tab.mvf[((y0 - 1) >> MIN_PU_LOG2) * min_pu_width + ((x0 - 1 + width)>> MIN_PU_LOG2)].pred_flag == PF_INTRA)
676 6198 w++;
677
678
4/4
✓ Branch 0 taken 42895 times.
✓ Branch 1 taken 938 times.
✓ Branch 2 taken 5922 times.
✓ Branch 3 taken 36973 times.
43833 if (available_l && fc->tab.mvf[((y0 - 1 + height)>> MIN_PU_LOG2) * min_pu_width + ((x0 - 1) >> MIN_PU_LOG2)].pred_flag == PF_INTRA)
679 5922 w++;
680
681 43833 return w;
682 }
683
684 3911749 static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField *orig_mvf,
685 const int x0, const int y0, const int sbw, const int sbh, const int sb_bdof_flag, const int c_start)
686 {
687 3911749 const VVCFrameContext *fc = lc->fc;
688
2/2
✓ Branch 0 taken 3883462 times.
✓ Branch 1 taken 28287 times.
3911749 const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? CR : LUMA;
689 VVCRefPic *refp[2];
690
691
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3911749 times.
3911749 if (pred_get_refs(lc, refp, mvf) < 0)
692 return;
693
694
2/2
✓ Branch 0 taken 10361188 times.
✓ Branch 1 taken 3911749 times.
14272937 for (int c_idx = c_start; c_idx <= c_end; c_idx++) {
695 10361188 uint8_t *dst = POS(c_idx, x0, y0);
696 10361188 const ptrdiff_t dst_stride = fc->frame->linesize[c_idx];
697 10361188 const int hs = fc->ps.sps->hshift[c_idx];
698 10361188 const int vs = fc->ps.sps->vshift[c_idx];
699 10361188 const int x = x0 >> hs;
700 10361188 const int y = y0 >> vs;
701 10361188 const int w = sbw >> hs;
702 10361188 const int h = sbh >> vs;
703 10361188 const int is_luma = !c_idx;
704
6/6
✓ Branch 0 taken 48347 times.
✓ Branch 1 taken 10312841 times.
✓ Branch 2 taken 32020 times.
✓ Branch 3 taken 16327 times.
✓ Branch 4 taken 27506 times.
✓ Branch 5 taken 4514 times.
10361188 const int do_ciip = lc->cu->ciip_flag && (is_luma || (w > 2));
705
2/2
✓ Branch 0 taken 43833 times.
✓ Branch 1 taken 10317355 times.
10361188 uint8_t *inter = do_ciip ? (uint8_t *)lc->ciip_tmp : dst;
706
2/2
✓ Branch 0 taken 10317355 times.
✓ Branch 1 taken 43833 times.
10361188 const ptrdiff_t inter_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride;
707
4/4
✓ Branch 0 taken 2594264 times.
✓ Branch 1 taken 7766924 times.
✓ Branch 2 taken 355632 times.
✓ Branch 3 taken 2238632 times.
10361188 const int do_bdof = is_luma && sb_bdof_flag;
708
709
2/2
✓ Branch 0 taken 3977993 times.
✓ Branch 1 taken 6383195 times.
10361188 if (mvf->pred_flag != PF_BI) {
710 3977993 const int lx = mvf->pred_flag - PF_L0;
711
712
2/2
✓ Branch 0 taken 10749 times.
✓ Branch 1 taken 3967244 times.
3977993 if (refp[lx]->is_scaled) {
713 10749 mc_uni_scaled(lc, inter, inter_stride, refp[lx], mvf,
714 x, y, w, h, c_idx);
715 } else {
716 3967244 mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf,
717 x, y, w, h, c_idx);
718 }
719 } else {
720
4/4
✓ Branch 0 taken 6382118 times.
✓ Branch 1 taken 1077 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 6382109 times.
6383195 if (refp[L0]->is_scaled || refp[L1]->is_scaled) {
721 1086 mc_bi_scaled(lc, inter, inter_stride, refp[L0], refp[L1], mvf,
722 x, y, w, h, c_idx);
723 } else {
724 6382109 mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf,
725 x, y, w, h, c_idx, do_bdof);
726 }
727 }
728
2/2
✓ Branch 0 taken 43833 times.
✓ Branch 1 taken 10317355 times.
10361188 if (do_ciip) {
729 43833 const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
730 43833 fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, c_idx);
731
4/4
✓ Branch 0 taken 16327 times.
✓ Branch 1 taken 27506 times.
✓ Branch 2 taken 8428 times.
✓ Branch 3 taken 7899 times.
43833 if (!c_idx && lc->sc->sh.r->sh_lmcs_used_flag)
732 8428 fc->vvcdsp.lmcs.filter(inter, inter_stride, w, h, &fc->ps.lmcs.fwd_lut);
733 43833 fc->vvcdsp.inter.put_ciip(dst, dst_stride, w, h, inter, inter_stride, intra_weight);
734 }
735 }
736 }
737
738 // 8.5.3.5 Parametric motion vector refinement process
739 512092 static int parametric_mv_refine(const int *sad, const int stride)
740 {
741 512092 const int sad_minus = sad[-stride];
742 512092 const int sad_center = sad[0];
743 512092 const int sad_plus = sad[stride];
744 int dmvc;
745 512092 int denom = (( sad_minus + sad_plus) - (sad_center << 1 ) ) << 3;
746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512092 times.
512092 if (!denom)
747 dmvc = 0;
748 else {
749
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 512034 times.
512092 if (sad_minus == sad_center)
750 58 dmvc = -8;
751
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 511790 times.
512034 else if (sad_plus == sad_center)
752 244 dmvc = 8;
753 else {
754 511790 int num = ( sad_minus - sad_plus ) * (1 << 4);
755 511790 int sign_num = 0;
756 511790 int quotient = 0;
757 511790 int counter = 3;
758
2/2
✓ Branch 0 taken 258956 times.
✓ Branch 1 taken 252834 times.
511790 if (num < 0 ) {
759 258956 num = - num;
760 258956 sign_num = 1;
761 }
762
2/2
✓ Branch 0 taken 1535370 times.
✓ Branch 1 taken 511790 times.
2047160 while (counter > 0) {
763 1535370 counter = counter - 1;
764 1535370 quotient = quotient << 1;
765
2/2
✓ Branch 0 taken 444398 times.
✓ Branch 1 taken 1090972 times.
1535370 if ( num >= denom ) {
766 444398 num = num - denom;
767 444398 quotient = quotient + 1;
768 }
769 1535370 denom = (denom >> 1);
770 }
771
2/2
✓ Branch 0 taken 258956 times.
✓ Branch 1 taken 252834 times.
511790 if (sign_num == 1 )
772 258956 dmvc = -quotient;
773 else
774 252834 dmvc = quotient;
775 }
776 }
777 512092 return dmvc;
778 }
779
780 #define SAD_ARRAY_SIZE 5
781 //8.5.3 Decoder-side motion vector refinement process
782 1113382 static void dmvr_mv_refine(VVCLocalContext *lc, MvField *mvf, MvField *orig_mv, int *sb_bdof_flag,
783 const VVCFrame *ref0, const VVCFrame *ref1, const int x_off, const int y_off, const int block_w, const int block_h)
784 {
785 1113382 const VVCFrameContext *fc = lc->fc;
786 1113382 const int sr_range = 2;
787 1113382 const VVCFrame *refs[] = { ref0, ref1 };
788 1113382 int16_t *tmp[] = { lc->tmp, lc->tmp1 };
789 int sad[SAD_ARRAY_SIZE][SAD_ARRAY_SIZE];
790 int min_dx, min_dy, min_sad, dx, dy;
791
792 1113382 *orig_mv = *mvf;
793 1113382 min_dx = min_dy = dx = dy = 2;
794
795
2/2
✓ Branch 0 taken 2226764 times.
✓ Branch 1 taken 1113382 times.
3340146 for (int i = L0; i <= L1; i++) {
796 2226764 const int pred_w = block_w + 2 * sr_range;
797 2226764 const int pred_h = block_h + 2 * sr_range;
798 2226764 const Mv *mv = mvf->mv + i;
799 2226764 const int mx = mv->x & 0xf;
800 2226764 const int my = mv->y & 0xf;
801 2226764 const int ox = x_off + (mv->x >> 4) - sr_range;
802 2226764 const int oy = y_off + (mv->y >> 4) - sr_range;
803 2226764 const VVCFrame *ref = refs[i];
804 2226764 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
805 2226764 const uint8_t *src = ref->frame->data[LUMA];
806 2226764 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
807
808 2226764 MC_EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
809 2226764 fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, my, pred_w);
810 }
811
812 1113382 min_sad = fc->vvcdsp.inter.sad(tmp[L0], tmp[L1], dx, dy, block_w, block_h);
813 1113382 min_sad -= min_sad >> 2;
814 1113382 sad[dy][dx] = min_sad;
815
816
2/2
✓ Branch 0 taken 458521 times.
✓ Branch 1 taken 654861 times.
1113382 if (min_sad >= block_w * block_h) {
817 int dmv[2];
818 // 8.5.3.4 Array entry selection process
819
2/2
✓ Branch 0 taken 2292605 times.
✓ Branch 1 taken 458521 times.
2751126 for (dy = 0; dy < SAD_ARRAY_SIZE; dy++) {
820
2/2
✓ Branch 0 taken 11463025 times.
✓ Branch 1 taken 2292605 times.
13755630 for (dx = 0; dx < SAD_ARRAY_SIZE; dx++) {
821
4/4
✓ Branch 0 taken 2292605 times.
✓ Branch 1 taken 9170420 times.
✓ Branch 2 taken 1834084 times.
✓ Branch 3 taken 458521 times.
11463025 if (dx != sr_range || dy != sr_range) {
822 11004504 sad[dy][dx] = fc->vvcdsp.inter.sad(lc->tmp, lc->tmp1, dx, dy, block_w, block_h);
823
2/2
✓ Branch 0 taken 647972 times.
✓ Branch 1 taken 10356532 times.
11004504 if (sad[dy][dx] < min_sad) {
824 647972 min_sad = sad[dy][dx];
825 647972 min_dx = dx;
826 647972 min_dy = dy;
827 }
828 }
829 }
830 }
831 458521 dmv[0] = (min_dx - sr_range) * (1 << 4);
832 458521 dmv[1] = (min_dy - sr_range) * (1 << 4);
833
8/8
✓ Branch 0 taken 381217 times.
✓ Branch 1 taken 77304 times.
✓ Branch 2 taken 316684 times.
✓ Branch 3 taken 64533 times.
✓ Branch 4 taken 264494 times.
✓ Branch 5 taken 52190 times.
✓ Branch 6 taken 256046 times.
✓ Branch 7 taken 8448 times.
458521 if (min_dx != 0 && min_dx != 4 && min_dy != 0 && min_dy != 4) {
834 256046 dmv[0] += parametric_mv_refine(&sad[min_dy][min_dx], 1);
835 256046 dmv[1] += parametric_mv_refine(&sad[min_dy][min_dx], SAD_ARRAY_SIZE);
836 }
837
838
2/2
✓ Branch 0 taken 917042 times.
✓ Branch 1 taken 458521 times.
1375563 for (int i = L0; i <= L1; i++) {
839 917042 Mv *mv = mvf->mv + i;
840 917042 mv->x += (1 - 2 * i) * dmv[0];
841 917042 mv->y += (1 - 2 * i) * dmv[1];
842 917042 ff_vvc_clip_mv(mv);
843 }
844 }
845
2/2
✓ Branch 0 taken 824464 times.
✓ Branch 1 taken 288918 times.
1113382 if (min_sad < 2 * block_w * block_h) {
846 824464 *sb_bdof_flag = 0;
847 }
848 1113382 }
849
850 1113382 static void set_dmvr_info(VVCFrameContext *fc, const int x0, const int y0,
851 const int width, const int height, const MvField *mvf)
852
853 {
854 1113382 const VVCPPS *pps = fc->ps.pps;
855
856
2/2
✓ Branch 0 taken 4409304 times.
✓ Branch 1 taken 1113382 times.
5522686 for (int y = y0; y < y0 + height; y += MIN_PU_SIZE) {
857
2/2
✓ Branch 0 taken 17500344 times.
✓ Branch 1 taken 4409304 times.
21909648 for (int x = x0; x < x0 + width; x += MIN_PU_SIZE) {
858 17500344 const int idx = pps->min_pu_width * (y >> MIN_PU_LOG2) + (x >> MIN_PU_LOG2);
859 17500344 fc->ref->tab_dmvr_mvf[idx] = *mvf;
860 }
861 }
862 1113382 }
863
864 2594264 static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int *sb_bdof_flag,
865 const int x0, const int y0, const int sbw, const int sbh)
866 {
867 2594264 VVCFrameContext *fc = lc->fc;
868 2594264 const PredictionUnit *pu = &lc->cu->pu;
869
870 2594264 *orig_mv = *mv = *ff_vvc_get_mvf(fc, x0, y0);
871
2/2
✓ Branch 0 taken 1180096 times.
✓ Branch 1 taken 1414168 times.
2594264 if (pu->bdof_flag)
872 1180096 *sb_bdof_flag = 1;
873
2/2
✓ Branch 0 taken 1113382 times.
✓ Branch 1 taken 1480882 times.
2594264 if (pu->dmvr_flag) {
874 VVCRefPic *refp[2];
875
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1113382 times.
1113382 if (pred_get_refs(lc, refp, mv) < 0)
876 return;
877 1113382 dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, refp[L0]->ref, refp[L1]->ref, x0, y0, sbw, sbh);
878 1113382 set_dmvr_info(fc, x0, y0, sbw, sbh, mv);
879 }
880 }
881
882 412855 static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip)
883 {
884 412855 const CodingUnit *cu = lc->cu;
885 412855 PredictionUnit *pu = &lc->cu->pu;
886 412855 const MotionInfo *mi = &pu->mi;
887 MvField mv, orig_mv;
888 412855 int sbw, sbh, sb_bdof_flag = 0;
889
890
4/4
✓ Branch 0 taken 32654 times.
✓ Branch 1 taken 380201 times.
✓ Branch 2 taken 16327 times.
✓ Branch 3 taken 16327 times.
412855 if (cu->ciip_flag && skip_ciip)
891 16327 return;
892
893 396528 sbw = cu->cb_width / mi->num_sb_x;
894 396528 sbh = cu->cb_height / mi->num_sb_y;
895
896
2/2
✓ Branch 0 taken 658629 times.
✓ Branch 1 taken 396528 times.
1055157 for (int sby = 0; sby < mi->num_sb_y; sby++) {
897
2/2
✓ Branch 0 taken 2594264 times.
✓ Branch 1 taken 658629 times.
3252893 for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
898 2594264 const int x0 = cu->x0 + sbx * sbw;
899 2594264 const int y0 = cu->y0 + sby * sbh;
900
901
2/2
✓ Branch 0 taken 16327 times.
✓ Branch 1 taken 2577937 times.
2594264 if (cu->ciip_flag)
902 16327 ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh);
903
904 2594264 derive_sb_mv(lc, &mv, &orig_mv, &sb_bdof_flag, x0, y0, sbw, sbh);
905 2594264 pred_regular(lc, &mv, &orig_mv, x0, y0, sbw, sbh, sb_bdof_flag, LUMA);
906 }
907 }
908 }
909
910 1317485 static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, const MvField *mv,
911 const int x0, const int y0, const int sbw, const int sbh)
912 {
913 1317485 const int hs = fc->ps.sps->hshift[1];
914 1317485 const int vs = fc->ps.sps->vshift[1];
915 1317485 const MvField* mv2 = ff_vvc_get_mvf(fc, x0 + hs * sbw, y0 + vs * sbh);
916 1317485 *mvc = *mv;
917
918 // Due to different pred_flag, one of the motion vectors may have an invalid value.
919 // Cast them to an unsigned type to avoid undefined behavior.
920 1317485 mvc->mv[0].x += (unsigned int)mv2->mv[0].x;
921 1317485 mvc->mv[0].y += (unsigned int)mv2->mv[0].y;
922 1317485 mvc->mv[1].x += (unsigned int)mv2->mv[1].x;
923 1317485 mvc->mv[1].y += (unsigned int)mv2->mv[1].y;
924 1317485 ff_vvc_round_mv(mvc->mv + 0, 0, 1);
925 1317485 ff_vvc_round_mv(mvc->mv + 1, 0, 1);
926 1317485 }
927
928 35964 static void pred_affine_blk(VVCLocalContext *lc)
929 {
930 35964 const VVCFrameContext *fc = lc->fc;
931 35964 const CodingUnit *cu = lc->cu;
932 35964 const PredictionUnit *pu = &cu->pu;
933 35964 const MotionInfo *mi = &pu->mi;
934 35964 const int x0 = cu->x0;
935 35964 const int y0 = cu->y0;
936 35964 const int sbw = cu->cb_width / mi->num_sb_x;
937 35964 const int sbh = cu->cb_height / mi->num_sb_y;
938 35964 const int hs = fc->ps.sps->hshift[1];
939 35964 const int vs = fc->ps.sps->vshift[1];
940 35964 const int dst_stride = fc->frame->linesize[LUMA];
941
942
2/2
✓ Branch 0 taken 284102 times.
✓ Branch 1 taken 35964 times.
320066 for (int sby = 0; sby < mi->num_sb_y; sby++) {
943
2/2
✓ Branch 0 taken 3527044 times.
✓ Branch 1 taken 284102 times.
3811146 for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
944 3527044 const int x = x0 + sbx * sbw;
945 3527044 const int y = y0 + sby * sbh;
946
947 3527044 uint8_t *dst0 = POS(0, x, y);
948 3527044 const MvField *mv = ff_vvc_get_mvf(fc, x, y);
949 VVCRefPic *refp[2];
950
951
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3527044 times.
3527044 if (pred_get_refs(lc, refp, mv) < 0)
952 return;
953
954
2/2
✓ Branch 0 taken 2474352 times.
✓ Branch 1 taken 1052692 times.
3527044 if (mi->pred_flag != PF_BI) {
955 2474352 const int lx = mi->pred_flag - PF_L0;
956
2/2
✓ Branch 0 taken 16008 times.
✓ Branch 1 taken 2458344 times.
2474352 if (refp[lx]->is_scaled) {
957 16008 mc_uni_scaled(lc, dst0, dst_stride, refp[lx], mv, x, y, sbw, sbh, LUMA);
958 } else {
959 2458344 luma_prof_uni(lc, dst0, dst_stride, refp[lx]->ref,
960 2458344 mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
961 2458344 pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
962 }
963 } else {
964 1052692 luma_prof_bi(lc, dst0, dst_stride, refp[L0], refp[L1], mv, x, y, sbw, sbh);
965 }
966
2/2
✓ Branch 0 taken 3488936 times.
✓ Branch 1 taken 38108 times.
3527044 if (fc->ps.sps->r->sps_chroma_format_idc) {
967
4/4
✓ Branch 0 taken 2041858 times.
✓ Branch 1 taken 1447078 times.
✓ Branch 2 taken 1317485 times.
✓ Branch 3 taken 724373 times.
3488936 if (!av_zero_extend(sby, vs) && !av_zero_extend(sbx, hs)) {
968 MvField mvc;
969
970 1317485 derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh);
971 1317485 pred_regular(lc, &mvc, NULL, x, y, sbw << hs, sbh << vs, 0, CB);
972 }
973 }
974
975 }
976 }
977 }
978
979 460083 static void predict_inter(VVCLocalContext *lc)
980 {
981 460083 const VVCFrameContext *fc = lc->fc;
982 460083 const CodingUnit *cu = lc->cu;
983 460083 const PredictionUnit *pu = &cu->pu;
984
985
2/2
✓ Branch 0 taken 27591 times.
✓ Branch 1 taken 432492 times.
460083 if (pu->merge_gpm_flag)
986 27591 pred_gpm_blk(lc);
987
2/2
✓ Branch 0 taken 35964 times.
✓ Branch 1 taken 396528 times.
432492 else if (pu->inter_affine_flag)
988 35964 pred_affine_blk(lc);
989 else
990 396528 pred_regular_blk(lc, 1); //intra block is not ready yet, skip ciip
991
992
4/4
✓ Branch 0 taken 189286 times.
✓ Branch 1 taken 270797 times.
✓ Branch 2 taken 180858 times.
✓ Branch 3 taken 8428 times.
460083 if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) {
993 180858 uint8_t* dst0 = POS(0, cu->x0, cu->y0);
994 180858 fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, &fc->ps.lmcs.fwd_lut);
995 }
996 460083 }
997
998 1344148 static int has_inter_luma(const CodingUnit *cu)
999 {
1000
4/6
✓ Branch 0 taken 884065 times.
✓ Branch 1 taken 460083 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 884065 times.
✓ Branch 4 taken 460083 times.
✗ Branch 5 not taken.
1344148 return (cu->pred_mode == MODE_INTER || cu->pred_mode == MODE_SKIP) && cu->tree_type != DUAL_TREE_CHROMA;
1001 }
1002
1003 53355 int ff_vvc_predict_inter(VVCLocalContext *lc, const int rs)
1004 {
1005 53355 const VVCFrameContext *fc = lc->fc;
1006 53355 CodingUnit *cu = fc->tab.cus[rs];
1007
1008
2/2
✓ Branch 0 taken 1344148 times.
✓ Branch 1 taken 53355 times.
1397503 while (cu) {
1009 1344148 lc->cu = cu;
1010
2/2
✓ Branch 1 taken 460083 times.
✓ Branch 2 taken 884065 times.
1344148 if (has_inter_luma(cu))
1011 460083 predict_inter(lc);
1012 1344148 cu = cu->next;
1013 }
1014
1015 53355 return 0;
1016 }
1017
1018 16327 void ff_vvc_predict_ciip(VVCLocalContext *lc)
1019 {
1020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16327 times.
16327 av_assert0(lc->cu->ciip_flag);
1021
1022 //todo: refact out ciip from pred_regular_blk
1023 16327 pred_regular_blk(lc, 0);
1024 16327 }
1025
1026 #undef POS
1027