FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vvc/inter.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 627 635 98.7%
Functions: 36 36 100.0%
Branches: 311 336 92.6%

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 20046855 static void subpic_get_rect(VVCRect *r, const VVCFrame *src_frame, const int subpic_idx, const int is_chroma)
34 {
35 20046855 const VVCSPS *sps = src_frame->sps;
36 20046855 const VVCPPS *pps = src_frame->pps;
37 20046855 const int hs = sps->hshift[is_chroma];
38 20046855 const int vs = sps->vshift[is_chroma];
39
40 20046855 r->l = pps->subpic_x[subpic_idx] >> hs;
41 20046855 r->t = pps->subpic_y[subpic_idx] >> vs;
42 20046855 r->r = r->l + (pps->subpic_width[subpic_idx] >> hs);
43 20046855 r->b = r->t + (pps->subpic_height[subpic_idx] >> vs);
44 20046855 }
45
46 // clip to subblock and subpicture process in 8.5.6.3.2 Luma sample interpolation filtering process
47 20049096 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 1783896 times.
✓ Branch 1 taken 18265200 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1783768 times.
20049096 const int l = dmvr_clip ? FFMIN(FFMAX(subpic->l, sb->l), subpic->r - 1) : subpic->l;
50
4/4
✓ Branch 0 taken 1783896 times.
✓ Branch 1 taken 18265200 times.
✓ Branch 2 taken 1066 times.
✓ Branch 3 taken 1782830 times.
20049096 const int t = dmvr_clip ? FFMIN(FFMAX(subpic->t, sb->t), subpic->b - 1) : subpic->t;
51
2/2
✓ Branch 0 taken 1783896 times.
✓ Branch 1 taken 18265200 times.
20049096 const int r = dmvr_clip ? FFMAX(FFMIN(subpic->r, sb->r), subpic->l + 1) : subpic->r;
52
2/2
✓ Branch 0 taken 1783896 times.
✓ Branch 1 taken 18265200 times.
20049096 const int b = dmvr_clip ? FFMAX(FFMIN(subpic->b, sb->b), subpic->t + 1) : subpic->b;
53
54 20049096 *x_off -= l;
55 20049096 *y_off -= t;
56 20049096 *pic_width = r - l;
57 20049096 *pic_height = b - t;
58 20049096 }
59
60 20044614 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 20044614 const VVCFrameContext *fc = lc->fc;
67 20044614 const int extra = extra_before + extra_after;
68 int pic_width, pic_height;
69
70 20044614 *src += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
71
72 20044614 clip_to_subpic(&x_off, &y_off, &pic_width, &pic_height, subpic, sb, dmvr_clip);
73
74
6/6
✓ Branch 0 taken 18260828 times.
✓ Branch 1 taken 1783786 times.
✓ Branch 2 taken 18147789 times.
✓ Branch 3 taken 113039 times.
✓ Branch 4 taken 17920930 times.
✓ Branch 5 taken 226859 times.
20044614 if (dmvr_clip || x_off < extra_before || y_off < extra_before ||
75
2/2
✓ Branch 0 taken 17790903 times.
✓ Branch 1 taken 130027 times.
17920930 x_off >= pic_width - block_w - extra_after ||
76
2/2
✓ Branch 0 taken 215596 times.
✓ Branch 1 taken 17575307 times.
17790903 y_off >= pic_height - block_h - extra_after) {
77 2469307 const int ps = fc->ps.sps->pixel_shift;
78 2469307 const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << ps;
79 2469307 const int offset = extra_before * *src_stride + (extra_before << ps);
80 2469307 const int buf_offset = extra_before * edge_emu_stride + (extra_before << ps);
81
82 2469307 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 2469307 *src = dst + buf_offset;
87 2469307 *src_stride = edge_emu_stride;
88 }
89 20044614 }
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 20046855 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 20046855 const VVCSPS *sps = src_frame->sps;
124 20046855 const VVCPPS *pps = src_frame->pps;
125 20046855 const int ps = sps->pixel_shift;
126 20046855 const int subpic_idx = lc->sc->sh.r->curr_subpic_idx;
127 20046855 const int extra = extra_before + extra_after;
128
4/4
✓ Branch 0 taken 18678690 times.
✓ Branch 1 taken 1368165 times.
✓ Branch 2 taken 415676 times.
✓ Branch 3 taken 18263014 times.
20046855 const int dmvr_clip = x_sb != x_off || y_sb != y_off;
129 20046855 const int dmvr_left = FFMAX(x_off, x_sb) - extra_before;
130 20046855 const int dmvr_right = FFMIN(x_off, x_sb) + block_w + extra_after;
131 20046855 const int left = x_off - extra_before;
132 20046855 const int top = y_off - extra_before;
133 20046855 const int pic_width = pps->width >> sps->hshift[is_chroma];
134 20046855 const int wrap = pps->ref_wraparound_offset << (sps->min_cb_log2_size_y - sps->hshift[is_chroma]);
135 20046855 const ptrdiff_t dst_stride = EDGE_EMU_BUFFER_STRIDE << ps;
136 20046855 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 20046855 subpic_get_rect(&subpic, src_frame, subpic_idx, is_chroma);
140
141
6/6
✓ Branch 0 taken 257536 times.
✓ Branch 1 taken 19789319 times.
✓ Branch 2 taken 251971 times.
✓ Branch 3 taken 5565 times.
✓ Branch 4 taken 247639 times.
✓ Branch 5 taken 4332 times.
20046855 if (!wrap_enabled || (dmvr_left >= 0 && dmvr_right <= pic_width)) {
142 20036958 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 20044614 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 5656789 static int derive_weight_uni(int *denom, int *wx, int *ox,
201 const VVCLocalContext *lc, const MvField *mvf, const int c_idx)
202 {
203 5656789 const VVCFrameContext *fc = lc->fc;
204 5656789 const VVCPPS *pps = fc->ps.pps;
205 5656789 const VVCSH *sh = &lc->sc->sh;
206
3/4
✓ Branch 0 taken 1593390 times.
✓ Branch 1 taken 4063399 times.
✓ Branch 2 taken 1593390 times.
✗ Branch 3 not taken.
11313578 const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) ||
207
4/4
✓ Branch 0 taken 4063399 times.
✓ Branch 1 taken 1593390 times.
✓ Branch 2 taken 22668 times.
✓ Branch 3 taken 4040731 times.
5656789 (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag);
208
2/2
✓ Branch 0 taken 22668 times.
✓ Branch 1 taken 5634121 times.
5656789 if (weight_flag) {
209 22668 const int lx = mvf->pred_flag - PF_L0;
210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22668 times.
22668 const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
211
212 22668 *denom = w->log2_denom[c_idx > 0];
213 22668 *wx = w->weight[lx][c_idx][mvf->ref_idx[lx]];
214 22668 *ox = w->offset[lx][c_idx][mvf->ref_idx[lx]];
215 }
216 5656789 return weight_flag;
217 }
218
219 // part of 8.5.6.6 Weighted sample prediction process
220 6139018 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 6139018 const VVCFrameContext *fc = lc->fc;
224 6139018 const VVCPPS *pps = fc->ps.pps;
225 6139018 const VVCSH *sh = &lc->sc->sh;
226 6139018 const int bcw_idx = mvf->bcw_idx;
227
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6139018 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12278036 const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) ||
228
4/6
✓ Branch 0 taken 6139018 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16347 times.
✓ Branch 3 taken 6122671 times.
✓ Branch 4 taken 16347 times.
✗ Branch 5 not taken.
6139018 (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag && !dmvr_flag);
229
8/8
✓ Branch 0 taken 6122671 times.
✓ Branch 1 taken 16347 times.
✓ Branch 2 taken 500326 times.
✓ Branch 3 taken 5622345 times.
✓ Branch 4 taken 500326 times.
✓ Branch 5 taken 16347 times.
✓ Branch 6 taken 3703 times.
✓ Branch 7 taken 496623 times.
6139018 if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag))
230 5626048 return 0;
231
232
2/2
✓ Branch 0 taken 496623 times.
✓ Branch 1 taken 16347 times.
512970 if (bcw_idx) {
233 496623 *denom = 2;
234 496623 *w1 = bcw_w_lut[bcw_idx];
235 496623 *w0 = 8 - *w1;
236 496623 *o0 = *o1 = 0;
237 } else {
238 16347 const VVCPPS *pps = fc->ps.pps;
239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16347 times.
16347 const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
240
241 16347 *denom = w->log2_denom[c_idx > 0];
242 16347 *w0 = w->weight[L0][c_idx][mvf->ref_idx[L0]];
243 16347 *w1 = w->weight[L1][c_idx][mvf->ref_idx[L1]];
244 16347 *o0 = w->offset[L0][c_idx][mvf->ref_idx[L0]];
245 16347 *o1 = w->offset[L1][c_idx][mvf->ref_idx[L1]];
246 }
247 512970 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 138596 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 138596 const VVCFrameContext *fc = lc->fc;
256 138596 const PredictionUnit *pu = &lc->cu->pu;
257 138596 const uint8_t *src = ref->frame->data[c_idx];
258 138596 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
259 138596 const int is_chroma = !!c_idx;
260 138596 const int hs = fc->ps.sps->hshift[c_idx];
261 138596 const int vs = fc->ps.sps->vshift[c_idx];
262 138596 const int idx = av_log2(block_w) - 1;
263 138596 const intptr_t mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
264 138596 const intptr_t my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
265
4/4
✓ Branch 0 taken 49240 times.
✓ Branch 1 taken 89356 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 49201 times.
138596 const int hpel_if_idx = (is_chroma || pu->merge_gpm_flag) ? 0 : pu->mi.hpel_if_idx;
266
2/2
✓ Branch 0 taken 89356 times.
✓ Branch 1 taken 49240 times.
138596 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
267
2/2
✓ Branch 0 taken 89356 times.
✓ Branch 1 taken 49240 times.
138596 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
268 138596 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
269
270 138596 x_off += mv->x >> (4 + hs);
271 138596 y_off += mv->y >> (4 + vs);
272
273
4/4
✓ Branch 0 taken 89356 times.
✓ Branch 1 taken 49240 times.
✓ Branch 2 taken 89356 times.
✓ Branch 3 taken 49240 times.
138596 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
274 138596 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
275 138596 }
276
277 3345036 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 3345036 const VVCFrameContext *fc = lc->fc;
282 3345036 const PredictionUnit *pu = &lc->cu->pu;
283 3345036 const uint8_t *src = ref->frame->data[c_idx];
284 3345036 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
285 3345036 const int lx = mvf->pred_flag - PF_L0;
286 3345036 const int hs = fc->ps.sps->hshift[c_idx];
287 3345036 const int vs = fc->ps.sps->vshift[c_idx];
288 3345036 const int idx = av_log2(block_w) - 1;
289 3345036 const Mv *mv = &mvf->mv[lx];
290 3345036 const int is_chroma = !!c_idx;
291 3345036 const intptr_t mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
292 3345036 const intptr_t my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
293
2/2
✓ Branch 0 taken 617678 times.
✓ Branch 1 taken 2727358 times.
3345036 const int hpel_if_idx = is_chroma ? 0 : pu->mi.hpel_if_idx;
294
2/2
✓ Branch 0 taken 2727358 times.
✓ Branch 1 taken 617678 times.
3345036 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
295
2/2
✓ Branch 0 taken 2727358 times.
✓ Branch 1 taken 617678 times.
3345036 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
296 3345036 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
297 int denom, wx, ox;
298
299 3345036 x_off += mv->x >> (4 + hs);
300 3345036 y_off += mv->y >> (4 + vs);
301
302
4/4
✓ Branch 0 taken 2727358 times.
✓ Branch 1 taken 617678 times.
✓ Branch 2 taken 2727358 times.
✓ Branch 3 taken 617678 times.
3345036 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
303
2/2
✓ Branch 1 taken 17244 times.
✓ Branch 2 taken 3327792 times.
3345036 if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
304 17244 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 3327792 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 3345036 }
311
312 5269696 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 5269696 const VVCFrameContext *fc = lc->fc;
318 5269696 const PredictionUnit *pu = &lc->cu->pu;
319 5269696 const int hs = fc->ps.sps->hshift[c_idx];
320 5269696 const int vs = fc->ps.sps->vshift[c_idx];
321 5269696 const int idx = av_log2(block_w) - 1;
322 5269696 const VVCFrame *refs[] = { ref0, ref1 };
323 5269696 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 5269696 const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, pu->dmvr_flag);
326 5269696 const int is_chroma = !!c_idx;
327
2/2
✓ Branch 0 taken 1517616 times.
✓ Branch 1 taken 3752080 times.
5269696 const int hpel_if_idx = is_chroma ? 0 : pu->mi.hpel_if_idx;
328
329
2/2
✓ Branch 0 taken 10539392 times.
✓ Branch 1 taken 5269696 times.
15809088 for (int i = L0; i <= L1; i++) {
330 10539392 const Mv *mv = mvf->mv + i;
331 10539392 const int mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
332 10539392 const int my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
333 10539392 const int ox = x_off + (mv->x >> (4 + hs));
334 10539392 const int oy = y_off + (mv->y >> (4 + vs));
335 10539392 const VVCFrame *ref = refs[i];
336 10539392 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
337 10539392 const uint8_t *src = ref->frame->data[c_idx];
338
2/2
✓ Branch 0 taken 7504160 times.
✓ Branch 1 taken 3035232 times.
10539392 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
339
2/2
✓ Branch 0 taken 7504160 times.
✓ Branch 1 taken 3035232 times.
10539392 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
340 10539392 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
341
342
2/2
✓ Branch 0 taken 5885324 times.
✓ Branch 1 taken 4654068 times.
10539392 if (pu->dmvr_flag) {
343 5885324 const int x_sb = x_off + (orig_mv->mv[i].x >> (4 + hs));
344 5885324 const int y_sb = y_off + (orig_mv->mv[i].y >> (4 + vs));
345
346
4/4
✓ Branch 0 taken 3912592 times.
✓ Branch 1 taken 1972732 times.
✓ Branch 2 taken 3912592 times.
✓ Branch 3 taken 1972732 times.
5885324 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 3591568 times.
✓ Branch 1 taken 1062500 times.
✓ Branch 2 taken 3591568 times.
✓ Branch 3 taken 1062500 times.
4654068 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
349 }
350 10539392 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 700286 times.
✓ Branch 1 taken 9839106 times.
10539392 if (sb_bdof_flag)
352 700286 fc->vvcdsp.inter.bdof_fetch_samples(tmp[i], src, src_stride, mx, my, block_w, block_h);
353 }
354
2/2
✓ Branch 0 taken 350143 times.
✓ Branch 1 taken 4919553 times.
5269696 if (sb_bdof_flag)
355 350143 fc->vvcdsp.inter.apply_bdof(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
356
2/2
✓ Branch 0 taken 309902 times.
✓ Branch 1 taken 4609651 times.
4919553 else if (weight_flag)
357 309902 fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
358 else
359 4609651 fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
360 5269696 }
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 2284996 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 2284996 const VVCFrameContext *fc = lc->fc;
498 2284996 const uint8_t *src = ref->frame->data[LUMA];
499 2284996 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
500 2284996 uint16_t *prof_tmp = lc->tmp + PROF_TEMP_OFFSET;
501 2284996 const int idx = av_log2(block_w) - 1;
502 2284996 const int lx = mvf->pred_flag - PF_L0;
503 2284996 const Mv *mv = mvf->mv + lx;
504 2284996 const int mx = mv->x & 0xf;
505 2284996 const int my = mv->y & 0xf;
506 2284996 const int8_t *hf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
507 2284996 const int8_t *vf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
508 int denom, wx, ox;
509 2284996 const int weight_flag = derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA);
510 2284996 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
511 2284996 const int is_chroma = 0;
512
513 2284996 x_off += mv->x >> 4;
514 2284996 y_off += mv->y >> 4;
515
516
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2284996 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2284996 times.
2284996 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
517
2/2
✓ Branch 0 taken 2128360 times.
✓ Branch 1 taken 156636 times.
2284996 if (cb_prof_flag) {
518 2128360 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
519 2128360 fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
520
2/2
✓ Branch 0 taken 2123076 times.
✓ Branch 1 taken 5284 times.
2128360 if (!weight_flag)
521 2123076 fc->vvcdsp.inter.apply_prof_uni(dst, dst_stride, prof_tmp, diff_mv_x, diff_mv_y);
522 else
523 5284 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 156496 times.
✓ Branch 1 taken 140 times.
156636 if (!weight_flag)
526 156496 fc->vvcdsp.inter.put_uni[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride, block_h, hf, vf, block_w);
527 else
528 140 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 2284996 }
531
532 1733400 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 1733400 const VVCFrameContext *fc = lc->fc;
536 1733400 const PredictionUnit *pu = &lc->cu->pu;
537 1733400 const int mx = mv->x & 0xf;
538 1733400 const int my = mv->y & 0xf;
539 1733400 const int ox = x_off + (mv->x >> 4);
540 1733400 const int oy = y_off + (mv->y >> 4);
541 1733400 const int idx = av_log2(block_w) - 1;
542 1733400 const int is_chroma = 0;
543 1733400 uint16_t *prof_tmp = lc->tmp2 + PROF_TEMP_OFFSET;
544 1733400 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
545 1733400 const uint8_t *src = ref->frame->data[LUMA];
546 1733400 const int8_t *hf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
547 1733400 const int8_t *vf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
548 1733400 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
549
550
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1733400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1733400 times.
1733400 MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
551
2/2
✓ Branch 0 taken 366992 times.
✓ Branch 1 taken 1366408 times.
1733400 if (!pu->cb_prof_flag[lx]) {
552 366992 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
553 } else {
554 1366408 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
555 1366408 fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
556 1366408 fc->vvcdsp.inter.apply_prof(dst, prof_tmp, pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
557 }
558 1733400 }
559
560 868236 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 868236 const VVCFrameContext *fc = lc->fc;
565 868236 const VVCRefPic *refps[] = { ref0, ref1 };
566 868236 int16_t *tmp[] = { lc->tmp, lc->tmp1 };
567 int denom, w0, w1, o0, o1;
568 868236 const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, 0);
569
570
2/2
✓ Branch 0 taken 1736472 times.
✓ Branch 1 taken 868236 times.
2604708 for (int i = L0; i <= L1; i++) {
571 1736472 const VVCRefPic *refp = refps[i];
572 1736472 const Mv *mv = mvf->mv + i;
573
574
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1733400 times.
1736472 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 1733400 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 203068 times.
✓ Branch 1 taken 665168 times.
868236 if (weight_flag)
581 203068 fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
582 else
583 665168 fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
584 868236 }
585
586 7429019 static int pred_get_refs(const VVCLocalContext *lc, VVCRefPic *refp[2], const MvField *mv)
587 {
588 7429019 RefPicList *rpl = lc->sc->rpl;
589
590
2/2
✓ Branch 0 taken 14858038 times.
✓ Branch 1 taken 7429019 times.
22287057 for (int mask = PF_L0; mask <= PF_L1; mask++) {
591
2/2
✓ Branch 0 taken 11174732 times.
✓ Branch 1 taken 3683306 times.
14858038 if (mv->pred_flag & mask) {
592 11174732 const int lx = mask - PF_L0;
593 11174732 refp[lx] = rpl[lx].refs + mv->ref_idx[lx];
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11174732 times.
11174732 if (!refp[lx]->ref)
595 return AVERROR_INVALIDDATA;
596 }
597 }
598 7429019 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 24737 static void pred_gpm_blk(VVCLocalContext *lc)
606 {
607 24737 const VVCFrameContext *fc = lc->fc;
608 24737 const CodingUnit *cu = lc->cu;
609 24737 const PredictionUnit *pu = &cu->pu;
610
611 24737 const uint8_t angle_idx = ff_vvc_gpm_angle_idx[pu->gpm_partition_idx];
612 24737 const uint8_t weights_idx = ff_vvc_gpm_angle_to_weights_idx[angle_idx];
613 24737 const int w = av_log2(cu->cb_width) - 3;
614 24737 const int h = av_log2(cu->cb_height) - 3;
615 24737 const uint8_t off_x = ff_vvc_gpm_weights_offset_x[pu->gpm_partition_idx][h][w];
616 24737 const uint8_t off_y = ff_vvc_gpm_weights_offset_y[pu->gpm_partition_idx][h][w];
617 24737 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 22456 times.
✓ Branch 1 taken 2281 times.
24737 const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1;
621
622 24737 int16_t *tmp[2] = {lc->tmp, lc->tmp1};
623
624
2/2
✓ Branch 0 taken 69649 times.
✓ Branch 1 taken 24737 times.
94386 for (int c_idx = 0; c_idx < c_end; c_idx++) {
625 69649 const int hs = fc->ps.sps->hshift[c_idx];
626 69649 const int vs = fc->ps.sps->vshift[c_idx];
627 69649 const int x = lc->cu->x0 >> hs;
628 69649 const int y = lc->cu->y0 >> vs;
629 69649 const int width = cu->cb_width >> hs;
630 69649 const int height = cu->cb_height >> vs;
631 69649 uint8_t *dst = POS(c_idx, lc->cu->x0, lc->cu->y0);
632 69649 ptrdiff_t dst_stride = fc->frame->linesize[c_idx];
633
634 69649 int step_x = 1 << hs;
635 69649 int step_y = VVC_GPM_WEIGHT_SIZE << vs;
636
2/2
✓ Branch 0 taken 43456 times.
✓ Branch 1 taken 26193 times.
69649 if (!mirror_type) {
637 43456 weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + off_x];
638
2/2
✓ Branch 0 taken 11195 times.
✓ Branch 1 taken 14998 times.
26193 } else if (mirror_type == 1) {
639 11195 step_x = -step_x;
640 11195 weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + VVC_GPM_WEIGHT_SIZE - 1- off_x];
641 } else {
642 14998 step_y = -step_y;
643 14998 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 139298 times.
✓ Branch 1 taken 69649 times.
208947 for (int i = 0; i < 2; i++) {
647 139298 const MvField *mv = pu->gpm_mv + i;
648 139298 const int lx = mv->pred_flag - PF_L0;
649 139298 VVCRefPic *refp = lc->sc->rpl[lx].refs + mv->ref_idx[lx];
650
651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139298 times.
139298 if (!refp->ref)
652 return;
653
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 138479 times.
139298 if (refp->is_scaled)
654 819 mc_scaled(lc, tmp[i], refp, mv->mv + lx, x, y, width, height, c_idx);
655 else
656 138479 mc(lc, tmp[i], refp->ref, mv->mv + lx, x, y, width, height, c_idx);
657 }
658 69649 fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
659 }
660 24737 return;
661 }
662
663 41475 static int ciip_derive_intra_weight(const VVCLocalContext *lc, const int x0, const int y0,
664 const int width, const int height)
665 {
666 41475 const VVCFrameContext *fc = lc->fc;
667 41475 const VVCSPS *sps = fc->ps.sps;
668 41475 const int x0b = av_zero_extend(x0, sps->ctb_log2_size_y);
669 41475 const int y0b = av_zero_extend(y0, sps->ctb_log2_size_y);
670
4/4
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 36929 times.
✓ Branch 2 taken 3698 times.
✓ Branch 3 taken 848 times.
41475 const int available_l = lc->ctb_left_flag || x0b;
671
4/4
✓ Branch 0 taken 5970 times.
✓ Branch 1 taken 35505 times.
✓ Branch 2 taken 5211 times.
✓ Branch 3 taken 759 times.
41475 const int available_u = lc->ctb_up_flag || y0b;
672 41475 const int min_pu_width = fc->ps.pps->min_pu_width;
673 41475 int w = 1;
674
675
4/4
✓ Branch 0 taken 40716 times.
✓ Branch 1 taken 759 times.
✓ Branch 2 taken 5893 times.
✓ Branch 3 taken 34823 times.
41475 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 5893 w++;
677
678
4/4
✓ Branch 0 taken 40627 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 5621 times.
✓ Branch 3 taken 35006 times.
41475 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 5621 w++;
680
681 41475 return w;
682 }
683
684 3273413 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 3273413 const VVCFrameContext *fc = lc->fc;
688
2/2
✓ Branch 0 taken 3245126 times.
✓ Branch 1 taken 28287 times.
3273413 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 3273413 times.
3273413 if (pred_get_refs(lc, refp, mvf) < 0)
692 return;
693
694
2/2
✓ Branch 0 taken 8626567 times.
✓ Branch 1 taken 3273413 times.
11899980 for (int c_idx = c_start; c_idx <= c_end; c_idx++) {
695 8626567 uint8_t *dst = POS(c_idx, x0, y0);
696 8626567 const ptrdiff_t dst_stride = fc->frame->linesize[c_idx];
697 8626567 const int hs = fc->ps.sps->hshift[c_idx];
698 8626567 const int vs = fc->ps.sps->vshift[c_idx];
699 8626567 const int x = x0 >> hs;
700 8626567 const int y = y0 >> vs;
701 8626567 const int w = sbw >> hs;
702 8626567 const int h = sbh >> vs;
703 8626567 const int is_luma = !c_idx;
704
6/6
✓ Branch 0 taken 45917 times.
✓ Branch 1 taken 8580650 times.
✓ Branch 2 taken 30400 times.
✓ Branch 3 taken 15517 times.
✓ Branch 4 taken 25958 times.
✓ Branch 5 taken 4442 times.
8626567 const int do_ciip = lc->cu->ciip_flag && (is_luma || (w > 2));
705
2/2
✓ Branch 0 taken 41475 times.
✓ Branch 1 taken 8585092 times.
8626567 uint8_t *inter = do_ciip ? (uint8_t *)lc->ciip_tmp : dst;
706
2/2
✓ Branch 0 taken 8585092 times.
✓ Branch 1 taken 41475 times.
8626567 const ptrdiff_t inter_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride;
707
4/4
✓ Branch 0 taken 2136315 times.
✓ Branch 1 taken 6490252 times.
✓ Branch 2 taken 350143 times.
✓ Branch 3 taken 1786172 times.
8626567 const int do_bdof = is_luma && sb_bdof_flag;
708
709
2/2
✓ Branch 0 taken 3355785 times.
✓ Branch 1 taken 5270782 times.
8626567 if (mvf->pred_flag != PF_BI) {
710 3355785 const int lx = mvf->pred_flag - PF_L0;
711
712
2/2
✓ Branch 0 taken 10749 times.
✓ Branch 1 taken 3345036 times.
3355785 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 3345036 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 5269705 times.
✓ Branch 1 taken 1077 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 5269696 times.
5270782 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 5269696 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 41475 times.
✓ Branch 1 taken 8585092 times.
8626567 if (do_ciip) {
729 41475 const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
730 41475 fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, c_idx);
731
4/4
✓ Branch 0 taken 15517 times.
✓ Branch 1 taken 25958 times.
✓ Branch 2 taken 8204 times.
✓ Branch 3 taken 7313 times.
41475 if (!c_idx && lc->sc->sh.r->sh_lmcs_used_flag)
732 8204 fc->vvcdsp.lmcs.filter(inter, inter_stride, w, h, &fc->ps.lmcs.fwd_lut);
733 41475 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 495820 static int parametric_mv_refine(const int *sad, const int stride)
740 {
741 495820 const int sad_minus = sad[-stride];
742 495820 const int sad_center = sad[0];
743 495820 const int sad_plus = sad[stride];
744 int dmvc;
745 495820 int denom = (( sad_minus + sad_plus) - (sad_center << 1 ) ) << 3;
746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 495820 times.
495820 if (!denom)
747 dmvc = 0;
748 else {
749
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 495762 times.
495820 if (sad_minus == sad_center)
750 58 dmvc = -8;
751
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 495523 times.
495762 else if (sad_plus == sad_center)
752 239 dmvc = 8;
753 else {
754 495523 int num = ( sad_minus - sad_plus ) * (1 << 4);
755 495523 int sign_num = 0;
756 495523 int quotient = 0;
757 495523 int counter = 3;
758
2/2
✓ Branch 0 taken 250794 times.
✓ Branch 1 taken 244729 times.
495523 if (num < 0 ) {
759 250794 num = - num;
760 250794 sign_num = 1;
761 }
762
2/2
✓ Branch 0 taken 1486569 times.
✓ Branch 1 taken 495523 times.
1982092 while (counter > 0) {
763 1486569 counter = counter - 1;
764 1486569 quotient = quotient << 1;
765
2/2
✓ Branch 0 taken 440318 times.
✓ Branch 1 taken 1046251 times.
1486569 if ( num >= denom ) {
766 440318 num = num - denom;
767 440318 quotient = quotient + 1;
768 }
769 1486569 denom = (denom >> 1);
770 }
771
2/2
✓ Branch 0 taken 250794 times.
✓ Branch 1 taken 244729 times.
495523 if (sign_num == 1 )
772 250794 dmvc = -quotient;
773 else
774 244729 dmvc = quotient;
775 }
776 }
777 495820 return dmvc;
778 }
779
780 #define SAD_ARRAY_SIZE 5
781 //8.5.3 Decoder-side motion vector refinement process
782 986366 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 986366 const VVCFrameContext *fc = lc->fc;
786 986366 const int sr_range = 2;
787 986366 const VVCFrame *refs[] = { ref0, ref1 };
788 986366 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 986366 *orig_mv = *mvf;
793 986366 min_dx = min_dy = dx = dy = 2;
794
795
2/2
✓ Branch 0 taken 1972732 times.
✓ Branch 1 taken 986366 times.
2959098 for (int i = L0; i <= L1; i++) {
796 1972732 const int pred_w = block_w + 2 * sr_range;
797 1972732 const int pred_h = block_h + 2 * sr_range;
798 1972732 const Mv *mv = mvf->mv + i;
799 1972732 const int mx = mv->x & 0xf;
800 1972732 const int my = mv->y & 0xf;
801 1972732 const int ox = x_off + (mv->x >> 4) - sr_range;
802 1972732 const int oy = y_off + (mv->y >> 4) - sr_range;
803 1972732 const VVCFrame *ref = refs[i];
804 1972732 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
805 1972732 const uint8_t *src = ref->frame->data[LUMA];
806 1972732 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
807
808 1972732 MC_EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
809 1972732 fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, my, pred_w);
810 }
811
812 986366 min_sad = fc->vvcdsp.inter.sad(tmp[L0], tmp[L1], dx, dy, block_w, block_h);
813 986366 min_sad -= min_sad >> 2;
814 986366 sad[dy][dx] = min_sad;
815
816
2/2
✓ Branch 0 taken 449926 times.
✓ Branch 1 taken 536440 times.
986366 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 2249630 times.
✓ Branch 1 taken 449926 times.
2699556 for (dy = 0; dy < SAD_ARRAY_SIZE; dy++) {
820
2/2
✓ Branch 0 taken 11248150 times.
✓ Branch 1 taken 2249630 times.
13497780 for (dx = 0; dx < SAD_ARRAY_SIZE; dx++) {
821
4/4
✓ Branch 0 taken 2249630 times.
✓ Branch 1 taken 8998520 times.
✓ Branch 2 taken 1799704 times.
✓ Branch 3 taken 449926 times.
11248150 if (dx != sr_range || dy != sr_range) {
822 10798224 sad[dy][dx] = fc->vvcdsp.inter.sad(lc->tmp, lc->tmp1, dx, dy, block_w, block_h);
823
2/2
✓ Branch 0 taken 645265 times.
✓ Branch 1 taken 10152959 times.
10798224 if (sad[dy][dx] < min_sad) {
824 645265 min_sad = sad[dy][dx];
825 645265 min_dx = dx;
826 645265 min_dy = dy;
827 }
828 }
829 }
830 }
831 449926 dmv[0] = (min_dx - sr_range) * (1 << 4);
832 449926 dmv[1] = (min_dy - sr_range) * (1 << 4);
833
8/8
✓ Branch 0 taken 372784 times.
✓ Branch 1 taken 77142 times.
✓ Branch 2 taken 308341 times.
✓ Branch 3 taken 64443 times.
✓ Branch 4 taken 256333 times.
✓ Branch 5 taken 52008 times.
✓ Branch 6 taken 247910 times.
✓ Branch 7 taken 8423 times.
449926 if (min_dx != 0 && min_dx != 4 && min_dy != 0 && min_dy != 4) {
834 247910 dmv[0] += parametric_mv_refine(&sad[min_dy][min_dx], 1);
835 247910 dmv[1] += parametric_mv_refine(&sad[min_dy][min_dx], SAD_ARRAY_SIZE);
836 }
837
838
2/2
✓ Branch 0 taken 899852 times.
✓ Branch 1 taken 449926 times.
1349778 for (int i = L0; i <= L1; i++) {
839 899852 Mv *mv = mvf->mv + i;
840 899852 mv->x += (1 - 2 * i) * dmv[0];
841 899852 mv->y += (1 - 2 * i) * dmv[1];
842 899852 ff_vvc_clip_mv(mv);
843 }
844 }
845
2/2
✓ Branch 0 taken 701735 times.
✓ Branch 1 taken 284631 times.
986366 if (min_sad < 2 * block_w * block_h) {
846 701735 *sb_bdof_flag = 0;
847 }
848 986366 }
849
850 986366 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 986366 const VVCPPS *pps = fc->ps.pps;
855
856
2/2
✓ Branch 0 taken 3903492 times.
✓ Branch 1 taken 986366 times.
4889858 for (int y = y0; y < y0 + height; y += MIN_PU_SIZE) {
857
2/2
✓ Branch 0 taken 15480184 times.
✓ Branch 1 taken 3903492 times.
19383676 for (int x = x0; x < x0 + width; x += MIN_PU_SIZE) {
858 15480184 const int idx = pps->min_pu_width * (y >> MIN_PU_LOG2) + (x >> MIN_PU_LOG2);
859 15480184 fc->ref->tab_dmvr_mvf[idx] = *mvf;
860 }
861 }
862 986366 }
863
864 2136315 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 2136315 VVCFrameContext *fc = lc->fc;
868 2136315 const PredictionUnit *pu = &lc->cu->pu;
869
870 2136315 *orig_mv = *mv = *ff_vvc_get_mvf(fc, x0, y0);
871
2/2
✓ Branch 0 taken 1051878 times.
✓ Branch 1 taken 1084437 times.
2136315 if (pu->bdof_flag)
872 1051878 *sb_bdof_flag = 1;
873
2/2
✓ Branch 0 taken 986366 times.
✓ Branch 1 taken 1149949 times.
2136315 if (pu->dmvr_flag) {
874 VVCRefPic *refp[2];
875
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 986366 times.
986366 if (pred_get_refs(lc, refp, mv) < 0)
876 return;
877 986366 dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, refp[L0]->ref, refp[L1]->ref, x0, y0, sbw, sbh);
878 986366 set_dmvr_info(fc, x0, y0, sbw, sbh, mv);
879 }
880 }
881
882 362179 static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip)
883 {
884 362179 const CodingUnit *cu = lc->cu;
885 362179 PredictionUnit *pu = &lc->cu->pu;
886 362179 const MotionInfo *mi = &pu->mi;
887 MvField mv, orig_mv;
888 362179 int sbw, sbh, sb_bdof_flag = 0;
889
890
4/4
✓ Branch 0 taken 31034 times.
✓ Branch 1 taken 331145 times.
✓ Branch 2 taken 15517 times.
✓ Branch 3 taken 15517 times.
362179 if (cu->ciip_flag && skip_ciip)
891 15517 return;
892
893 346662 sbw = cu->cb_width / mi->num_sb_x;
894 346662 sbh = cu->cb_height / mi->num_sb_y;
895
896
2/2
✓ Branch 0 taken 572896 times.
✓ Branch 1 taken 346662 times.
919558 for (int sby = 0; sby < mi->num_sb_y; sby++) {
897
2/2
✓ Branch 0 taken 2136315 times.
✓ Branch 1 taken 572896 times.
2709211 for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
898 2136315 const int x0 = cu->x0 + sbx * sbw;
899 2136315 const int y0 = cu->y0 + sby * sbh;
900
901
2/2
✓ Branch 0 taken 15517 times.
✓ Branch 1 taken 2120798 times.
2136315 if (cu->ciip_flag)
902 15517 ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh);
903
904 2136315 derive_sb_mv(lc, &mv, &orig_mv, &sb_bdof_flag, x0, y0, sbw, sbh);
905 2136315 pred_regular(lc, &mv, &orig_mv, x0, y0, sbw, sbh, sb_bdof_flag, LUMA);
906 }
907 }
908 }
909
910 1137098 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 1137098 const int hs = fc->ps.sps->hshift[1];
914 1137098 const int vs = fc->ps.sps->vshift[1];
915 1137098 const MvField* mv2 = ff_vvc_get_mvf(fc, x0 + hs * sbw, y0 + vs * sbh);
916 1137098 *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 1137098 mvc->mv[0].x += (unsigned int)mv2->mv[0].x;
921 1137098 mvc->mv[0].y += (unsigned int)mv2->mv[0].y;
922 1137098 mvc->mv[1].x += (unsigned int)mv2->mv[1].x;
923 1137098 mvc->mv[1].y += (unsigned int)mv2->mv[1].y;
924 1137098 ff_vvc_round_mv(mvc->mv + 0, 0, 1);
925 1137098 ff_vvc_round_mv(mvc->mv + 1, 0, 1);
926 1137098 }
927
928 32577 static void pred_affine_blk(VVCLocalContext *lc)
929 {
930 32577 const VVCFrameContext *fc = lc->fc;
931 32577 const CodingUnit *cu = lc->cu;
932 32577 const PredictionUnit *pu = &cu->pu;
933 32577 const MotionInfo *mi = &pu->mi;
934 32577 const int x0 = cu->x0;
935 32577 const int y0 = cu->y0;
936 32577 const int sbw = cu->cb_width / mi->num_sb_x;
937 32577 const int sbh = cu->cb_height / mi->num_sb_y;
938 32577 const int hs = fc->ps.sps->hshift[1];
939 32577 const int vs = fc->ps.sps->vshift[1];
940 32577 const int dst_stride = fc->frame->linesize[LUMA];
941
942
2/2
✓ Branch 0 taken 258140 times.
✓ Branch 1 taken 32577 times.
290717 for (int sby = 0; sby < mi->num_sb_y; sby++) {
943
2/2
✓ Branch 0 taken 3169240 times.
✓ Branch 1 taken 258140 times.
3427380 for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
944 3169240 const int x = x0 + sbx * sbw;
945 3169240 const int y = y0 + sby * sbh;
946
947 3169240 uint8_t *dst0 = POS(0, x, y);
948 3169240 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 3169240 times.
3169240 if (pred_get_refs(lc, refp, mv) < 0)
952 return;
953
954
2/2
✓ Branch 0 taken 2301004 times.
✓ Branch 1 taken 868236 times.
3169240 if (mi->pred_flag != PF_BI) {
955 2301004 const int lx = mi->pred_flag - PF_L0;
956
2/2
✓ Branch 0 taken 16008 times.
✓ Branch 1 taken 2284996 times.
2301004 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 2284996 luma_prof_uni(lc, dst0, dst_stride, refp[lx]->ref,
960 2284996 mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
961 2284996 pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
962 }
963 } else {
964 868236 luma_prof_bi(lc, dst0, dst_stride, refp[L0], refp[L1], mv, x, y, sbw, sbh);
965 }
966
2/2
✓ Branch 0 taken 3131132 times.
✓ Branch 1 taken 38108 times.
3169240 if (fc->ps.sps->r->sps_chroma_format_idc) {
967
4/4
✓ Branch 0 taken 1801776 times.
✓ Branch 1 taken 1329356 times.
✓ Branch 2 taken 1137098 times.
✓ Branch 3 taken 664678 times.
3131132 if (!av_zero_extend(sby, vs) && !av_zero_extend(sbx, hs)) {
968 MvField mvc;
969
970 1137098 derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh);
971 1137098 pred_regular(lc, &mvc, NULL, x, y, sbw << hs, sbh << vs, 0, CB);
972 }
973 }
974
975 }
976 }
977 }
978
979 403976 static void predict_inter(VVCLocalContext *lc)
980 {
981 403976 const VVCFrameContext *fc = lc->fc;
982 403976 const CodingUnit *cu = lc->cu;
983 403976 const PredictionUnit *pu = &cu->pu;
984
985
2/2
✓ Branch 0 taken 24737 times.
✓ Branch 1 taken 379239 times.
403976 if (pu->merge_gpm_flag)
986 24737 pred_gpm_blk(lc);
987
2/2
✓ Branch 0 taken 32577 times.
✓ Branch 1 taken 346662 times.
379239 else if (pu->inter_affine_flag)
988 32577 pred_affine_blk(lc);
989 else
990 346662 pred_regular_blk(lc, 1); //intra block is not ready yet, skip ciip
991
992
4/4
✓ Branch 0 taken 174368 times.
✓ Branch 1 taken 229608 times.
✓ Branch 2 taken 166164 times.
✓ Branch 3 taken 8204 times.
403976 if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) {
993 166164 uint8_t* dst0 = POS(0, cu->x0, cu->y0);
994 166164 fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, &fc->ps.lmcs.fwd_lut);
995 }
996 403976 }
997
998 1107877 static int has_inter_luma(const CodingUnit *cu)
999 {
1000
4/6
✓ Branch 0 taken 703901 times.
✓ Branch 1 taken 403976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 703901 times.
✓ Branch 4 taken 403976 times.
✗ Branch 5 not taken.
1107877 return (cu->pred_mode == MODE_INTER || cu->pred_mode == MODE_SKIP) && cu->tree_type != DUAL_TREE_CHROMA;
1001 }
1002
1003 45792 int ff_vvc_predict_inter(VVCLocalContext *lc, const int rs)
1004 {
1005 45792 const VVCFrameContext *fc = lc->fc;
1006 45792 CodingUnit *cu = fc->tab.cus[rs];
1007
1008
2/2
✓ Branch 0 taken 1107877 times.
✓ Branch 1 taken 45792 times.
1153669 while (cu) {
1009 1107877 lc->cu = cu;
1010
2/2
✓ Branch 1 taken 403976 times.
✓ Branch 2 taken 703901 times.
1107877 if (has_inter_luma(cu))
1011 403976 predict_inter(lc);
1012 1107877 cu = cu->next;
1013 }
1014
1015 45792 return 0;
1016 }
1017
1018 15517 void ff_vvc_predict_ciip(VVCLocalContext *lc)
1019 {
1020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15517 times.
15517 av_assert0(lc->cu->ciip_flag);
1021
1022 //todo: refact out ciip from pred_regular_blk
1023 15517 pred_regular_blk(lc, 0);
1024 15517 }
1025
1026 #undef POS
1027