FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vvc/inter.c
Date: 2026-04-18 02:30:19
Exec Total Coverage
Lines: 618 625 98.9%
Functions: 36 36 100.0%
Branches: 306 324 94.4%

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 23771521 static void subpic_get_rect(VVCRect *r, const VVCFrame *src_frame, const int subpic_idx, const int is_chroma)
34 {
35 23771521 const VVCSPS *sps = src_frame->sps;
36 23771521 const VVCPPS *pps = src_frame->pps;
37 23771521 const int hs = sps->hshift[is_chroma];
38 23771521 const int vs = sps->vshift[is_chroma];
39
40 23771521 r->l = pps->subpic_x[subpic_idx] >> hs;
41 23771521 r->t = pps->subpic_y[subpic_idx] >> vs;
42 23771521 r->r = r->l + (pps->subpic_width[subpic_idx] >> hs);
43 23771521 r->b = r->t + (pps->subpic_height[subpic_idx] >> vs);
44 23771521 }
45
46 // clip to subblock and subpicture process in 8.5.6.3.2 Luma sample interpolation filtering process
47 23773762 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 1801622 times.
✓ Branch 1 taken 21972140 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1801494 times.
23773762 const int l = dmvr_clip ? FFMIN(FFMAX(subpic->l, sb->l), subpic->r - 1) : subpic->l;
50
4/4
✓ Branch 0 taken 1801622 times.
✓ Branch 1 taken 21972140 times.
✓ Branch 2 taken 1066 times.
✓ Branch 3 taken 1800556 times.
23773762 const int t = dmvr_clip ? FFMIN(FFMAX(subpic->t, sb->t), subpic->b - 1) : subpic->t;
51
2/2
✓ Branch 0 taken 1801622 times.
✓ Branch 1 taken 21972140 times.
23773762 const int r = dmvr_clip ? FFMAX(FFMIN(subpic->r, sb->r), subpic->l + 1) : subpic->r;
52
2/2
✓ Branch 0 taken 1801622 times.
✓ Branch 1 taken 21972140 times.
23773762 const int b = dmvr_clip ? FFMAX(FFMIN(subpic->b, sb->b), subpic->t + 1) : subpic->b;
53
54 23773762 *x_off -= l;
55 23773762 *y_off -= t;
56 23773762 *pic_width = r - l;
57 23773762 *pic_height = b - t;
58 23773762 }
59
60 23769280 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 23769280 const VVCFrameContext *fc = lc->fc;
67 23769280 const int extra = extra_before + extra_after;
68 int pic_width, pic_height;
69
70 23769280 *src += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
71
72 23769280 clip_to_subpic(&x_off, &y_off, &pic_width, &pic_height, subpic, sb, dmvr_clip);
73
74
6/6
✓ Branch 0 taken 21967768 times.
✓ Branch 1 taken 1801512 times.
✓ Branch 2 taken 21764932 times.
✓ Branch 3 taken 202836 times.
✓ Branch 4 taken 21432882 times.
✓ Branch 5 taken 332050 times.
23769280 if (dmvr_clip || x_off < extra_before || y_off < extra_before ||
75
2/2
✓ Branch 0 taken 21206265 times.
✓ Branch 1 taken 226617 times.
21432882 x_off >= pic_width - block_w - extra_after ||
76
2/2
✓ Branch 0 taken 295064 times.
✓ Branch 1 taken 20911201 times.
21206265 y_off >= pic_height - block_h - extra_after) {
77 2858079 const int ps = fc->ps.sps->pixel_shift;
78 2858079 const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << ps;
79 2858079 const int offset = extra_before * *src_stride + (extra_before << ps);
80 2858079 const int buf_offset = extra_before * edge_emu_stride + (extra_before << ps);
81
82 2858079 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 2858079 *src = dst + buf_offset;
87 2858079 *src_stride = edge_emu_stride;
88 }
89 23769280 }
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 23771521 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 23771521 const VVCSPS *sps = src_frame->sps;
124 23771521 const VVCPPS *pps = src_frame->pps;
125 23771521 const int ps = sps->pixel_shift;
126 23771521 const int subpic_idx = lc->sc->sh.r->curr_subpic_idx;
127 23771521 const int extra = extra_before + extra_after;
128
4/4
✓ Branch 0 taken 22391254 times.
✓ Branch 1 taken 1380267 times.
✓ Branch 2 taken 421300 times.
✓ Branch 3 taken 21969954 times.
23771521 const int dmvr_clip = x_sb != x_off || y_sb != y_off;
129 23771521 const int dmvr_left = FFMAX(x_off, x_sb) - extra_before;
130 23771521 const int dmvr_right = FFMIN(x_off, x_sb) + block_w + extra_after;
131 23771521 const int left = x_off - extra_before;
132 23771521 const int top = y_off - extra_before;
133 23771521 const int pic_width = pps->width >> sps->hshift[is_chroma];
134 23771521 const int wrap = pps->ref_wraparound_offset << (sps->min_cb_log2_size_y - sps->hshift[is_chroma]);
135 23771521 const ptrdiff_t dst_stride = EDGE_EMU_BUFFER_STRIDE << ps;
136 23771521 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 23771521 subpic_get_rect(&subpic, src_frame, subpic_idx, is_chroma);
140
141
6/6
✓ Branch 0 taken 257536 times.
✓ Branch 1 taken 23513985 times.
✓ Branch 2 taken 251971 times.
✓ Branch 3 taken 5565 times.
✓ Branch 4 taken 247639 times.
✓ Branch 5 taken 4332 times.
23771521 if (!wrap_enabled || (dmvr_left >= 0 && dmvr_right <= pic_width)) {
142 23761624 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 23769280 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 6467183 static int derive_weight_uni(int *denom, int *wx, int *ox,
201 const VVCLocalContext *lc, const MvField *mvf, const int c_idx)
202 {
203 6467183 const VVCFrameContext *fc = lc->fc;
204 6467183 const VVCPPS *pps = fc->ps.pps;
205 6467183 const VVCSH *sh = &lc->sc->sh;
206
4/4
✓ Branch 0 taken 1707465 times.
✓ Branch 1 taken 4759718 times.
✓ Branch 2 taken 1593390 times.
✓ Branch 3 taken 114075 times.
12820291 const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) ||
207
4/4
✓ Branch 0 taken 4759718 times.
✓ Branch 1 taken 1593390 times.
✓ Branch 2 taken 163995 times.
✓ Branch 3 taken 4595723 times.
6353108 (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag);
208
2/2
✓ Branch 0 taken 278070 times.
✓ Branch 1 taken 6189113 times.
6467183 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 6467183 return weight_flag;
217 }
218
219 // part of 8.5.6.6 Weighted sample prediction process
220 7100105 static void apply_averaging(uint8_t *dst, const ptrdiff_t dst_stride,
221 const int16_t *src0, const int16_t *src1, int width, int height,
222 const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int dmvr_flag)
223 {
224 7100105 const VVCFrameContext *fc = lc->fc;
225 7100105 const VVCPPS *pps = fc->ps.pps;
226 7100105 const VVCSH *sh = &lc->sc->sh;
227 7100105 const int bcw_idx = mvf->bcw_idx;
228 av_assert2(IS_B(sh->r));
229
4/4
✓ Branch 0 taken 134264 times.
✓ Branch 1 taken 6965841 times.
✓ Branch 2 taken 134256 times.
✓ Branch 3 taken 8 times.
7100105 const int weight_flag = pps->r->pps_weighted_bipred_flag && !dmvr_flag;
230
8/8
✓ Branch 0 taken 6965849 times.
✓ Branch 1 taken 134256 times.
✓ Branch 2 taken 537580 times.
✓ Branch 3 taken 6428269 times.
✓ Branch 4 taken 538183 times.
✓ Branch 5 taken 133653 times.
✓ Branch 6 taken 3844 times.
✓ Branch 7 taken 534339 times.
7100105 if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag)) {
231 6432113 fc->vvcdsp.inter.avg(dst, dst_stride, src0, src1, width, height);
232 6432113 return;
233 }
234
235 int denom, w0, w1, o;
236
2/2
✓ Branch 0 taken 534339 times.
✓ Branch 1 taken 133653 times.
667992 if (bcw_idx) {
237 534339 denom = 2;
238 534339 w1 = bcw_w_lut[bcw_idx];
239 534339 w0 = 8 - w1;
240 534339 o = 0;
241 } else {
242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133653 times.
133653 const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
243
244 133653 denom = w->log2_denom[c_idx > 0];
245 133653 w0 = w->weight[L0][c_idx][mvf->ref_idx[L0]];
246 133653 w1 = w->weight[L1][c_idx][mvf->ref_idx[L1]];
247 133653 o = w->offset[L0][c_idx][mvf->ref_idx[L0]]
248 133653 + w->offset[L1][c_idx][mvf->ref_idx[L1]];
249 }
250 667992 fc->vvcdsp.inter.w_avg(dst, dst_stride, src0, src1, width, height, denom, w0, w1, o);
251 }
252
253 #define INTER_FILTER(t, frac) (is_chroma ? ff_vvc_inter_chroma_filters[t][frac] : ff_vvc_inter_luma_filters[t][frac])
254
255 155738 static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const Mv *mv,
256 int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
257 {
258 155738 const VVCFrameContext *fc = lc->fc;
259 155738 const PredictionUnit *pu = &lc->cu->pu;
260 155738 const uint8_t *src = ref->frame->data[c_idx];
261 155738 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
262 155738 const int is_chroma = !!c_idx;
263 155738 const int hs = fc->ps.sps->hshift[c_idx];
264 155738 const int vs = fc->ps.sps->vshift[c_idx];
265 155738 const int idx = av_log2(block_w) - 1;
266 155738 const intptr_t mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
267 155738 const intptr_t my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
268
4/4
✓ Branch 0 taken 54954 times.
✓ Branch 1 taken 100784 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 54915 times.
155738 const int hpel_if_idx = (is_chroma || pu->merge_gpm_flag) ? 0 : pu->mi.hpel_if_idx;
269
2/2
✓ Branch 0 taken 100784 times.
✓ Branch 1 taken 54954 times.
155738 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
270
2/2
✓ Branch 0 taken 100784 times.
✓ Branch 1 taken 54954 times.
155738 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
271 155738 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
272
273 155738 x_off += mv->x >> (4 + hs);
274 155738 y_off += mv->y >> (4 + vs);
275
276
4/4
✓ Branch 0 taken 100784 times.
✓ Branch 1 taken 54954 times.
✓ Branch 2 taken 100784 times.
✓ Branch 3 taken 54954 times.
155738 MC_EMULATED_EDGE(lc->pred.edge_emu_buffer, &src, &src_stride, x_off, y_off);
277 155738 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
278 155738 }
279
280 3980338 static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
281 const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
282 const int c_idx)
283 {
284 3980338 const VVCFrameContext *fc = lc->fc;
285 3980338 const PredictionUnit *pu = &lc->cu->pu;
286 3980338 const uint8_t *src = ref->frame->data[c_idx];
287 3980338 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
288 3980338 const int lx = mvf->pred_flag - PF_L0;
289 3980338 const int hs = fc->ps.sps->hshift[c_idx];
290 3980338 const int vs = fc->ps.sps->vshift[c_idx];
291 3980338 const int idx = av_log2(block_w) - 1;
292 3980338 const Mv *mv = &mvf->mv[lx];
293 3980338 const int is_chroma = !!c_idx;
294 3980338 const intptr_t mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
295 3980338 const intptr_t my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
296
2/2
✓ Branch 0 taken 786876 times.
✓ Branch 1 taken 3193462 times.
3980338 const int hpel_if_idx = is_chroma ? 0 : pu->mi.hpel_if_idx;
297
2/2
✓ Branch 0 taken 3193462 times.
✓ Branch 1 taken 786876 times.
3980338 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
298
2/2
✓ Branch 0 taken 3193462 times.
✓ Branch 1 taken 786876 times.
3980338 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
299 3980338 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
300 int denom, wx, ox;
301
302 3980338 x_off += mv->x >> (4 + hs);
303 3980338 y_off += mv->y >> (4 + vs);
304
305
4/4
✓ Branch 0 taken 3193462 times.
✓ Branch 1 taken 786876 times.
✓ Branch 2 taken 3193462 times.
✓ Branch 3 taken 786876 times.
3980338 MC_EMULATED_EDGE(lc->pred.edge_emu_buffer, &src, &src_stride, x_off, y_off);
306
2/2
✓ Branch 1 taken 133490 times.
✓ Branch 2 taken 3846848 times.
3980338 if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
307 133490 fc->vvcdsp.inter.put_uni_w[is_chroma][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
308 block_h, denom, wx, ox, hf, vf, block_w);
309 } else {
310 3846848 fc->vvcdsp.inter.put_uni[is_chroma][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
311 block_h, hf, vf, block_w);
312 }
313 3980338 }
314
315 6403365 static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
316 const VVCFrame *ref0, const VVCFrame *ref1, const MvField *mvf, const MvField *orig_mv,
317 const int x_off, const int y_off, const int block_w, const int block_h, const int c_idx,
318 const int sb_bdof_flag)
319 {
320 6403365 const VVCFrameContext *fc = lc->fc;
321 6403365 const PredictionUnit *pu = &lc->cu->pu;
322 6403365 const int hs = fc->ps.sps->hshift[c_idx];
323 6403365 const int vs = fc->ps.sps->vshift[c_idx];
324 6403365 const int idx = av_log2(block_w) - 1;
325 6403365 const VVCFrame *refs[] = { ref0, ref1 };
326 6403365 int16_t *tmp[] = { lc->pred.tmp + sb_bdof_flag * PROF_TEMP_OFFSET, lc->pred.tmp1 + sb_bdof_flag * PROF_TEMP_OFFSET };
327 6403365 const int is_chroma = !!c_idx;
328
2/2
✓ Branch 0 taken 1817441 times.
✓ Branch 1 taken 4585924 times.
6403365 const int hpel_if_idx = is_chroma ? 0 : pu->mi.hpel_if_idx;
329
330
2/2
✓ Branch 0 taken 12806730 times.
✓ Branch 1 taken 6403365 times.
19210095 for (int i = L0; i <= L1; i++) {
331 12806730 const Mv *mv = mvf->mv + i;
332 12806730 const int mx = av_zero_extend(mv->x, 4 + hs) << (is_chroma - hs);
333 12806730 const int my = av_zero_extend(mv->y, 4 + vs) << (is_chroma - vs);
334 12806730 const int ox = x_off + (mv->x >> (4 + hs));
335 12806730 const int oy = y_off + (mv->y >> (4 + vs));
336 12806730 const VVCFrame *ref = refs[i];
337 12806730 ptrdiff_t src_stride = ref->frame->linesize[c_idx];
338 12806730 const uint8_t *src = ref->frame->data[c_idx];
339
2/2
✓ Branch 0 taken 9171848 times.
✓ Branch 1 taken 3634882 times.
12806730 const int8_t *hf = INTER_FILTER(hpel_if_idx, mx);
340
2/2
✓ Branch 0 taken 9171848 times.
✓ Branch 1 taken 3634882 times.
12806730 const int8_t *vf = INTER_FILTER(hpel_if_idx, my);
341 12806730 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
342
343
2/2
✓ Branch 0 taken 6664892 times.
✓ Branch 1 taken 6141838 times.
12806730 if (pu->dmvr_flag) {
344 6664892 const int x_sb = x_off + (orig_mv->mv[i].x >> (4 + hs));
345 6664892 const int y_sb = y_off + (orig_mv->mv[i].y >> (4 + vs));
346
347
4/4
✓ Branch 0 taken 4432304 times.
✓ Branch 1 taken 2232588 times.
✓ Branch 2 taken 4432304 times.
✓ Branch 3 taken 2232588 times.
6664892 MC_EMULATED_EDGE_DMVR(lc->pred.edge_emu_buffer, &src, &src_stride, x_sb, y_sb, ox, oy);
348 } else {
349
4/4
✓ Branch 0 taken 4739544 times.
✓ Branch 1 taken 1402294 times.
✓ Branch 2 taken 4739544 times.
✓ Branch 3 taken 1402294 times.
6141838 MC_EMULATED_EDGE(lc->pred.edge_emu_buffer, &src, &src_stride, ox, oy);
350 }
351 12806730 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
352
2/2
✓ Branch 0 taken 715100 times.
✓ Branch 1 taken 12091630 times.
12806730 if (sb_bdof_flag)
353 715100 fc->vvcdsp.inter.bdof_fetch_samples(tmp[i], src, src_stride, mx, my, block_w, block_h);
354 }
355
2/2
✓ Branch 0 taken 357550 times.
✓ Branch 1 taken 6045815 times.
6403365 if (sb_bdof_flag)
356 357550 fc->vvcdsp.inter.apply_bdof(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
357 else
358 6045815 apply_averaging(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h,
359 6045815 lc, mvf, c_idx, pu->dmvr_flag);
360 6403365 }
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->pred.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 1086 const VVCRefPic *refps[] = { refp0, refp1 };
473 1086 int16_t *tmp[] = { lc->pred.tmp, lc->pred.tmp1 };
474
475
2/2
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 1086 times.
3258 for (int i = L0; i <= L1; i++) {
476 2172 const Mv *mv = mvf->mv + i;
477 2172 const VVCRefPic *refp = refps[i];
478
479
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 117 times.
2172 if (refp->is_scaled)
480 2055 mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, c_idx);
481 else
482 117 mc(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, c_idx);
483 }
484 1086 apply_averaging(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h,
485 1086 lc, mvf, c_idx, lc->cu->pu.dmvr_flag);
486 1086 }
487
488 2460088 static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
489 const VVCFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
490 const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
491 {
492 2460088 const VVCFrameContext *fc = lc->fc;
493 2460088 const uint8_t *src = ref->frame->data[LUMA];
494 2460088 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
495 2460088 uint16_t *prof_tmp = lc->pred.tmp + PROF_TEMP_OFFSET;
496 2460088 const int idx = av_log2(block_w) - 1;
497 2460088 const int lx = mvf->pred_flag - PF_L0;
498 2460088 const Mv *mv = mvf->mv + lx;
499 2460088 const int mx = mv->x & 0xf;
500 2460088 const int my = mv->y & 0xf;
501 2460088 const int8_t *hf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
502 2460088 const int8_t *vf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
503 int denom, wx, ox;
504 2460088 const int weight_flag = derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA);
505 2460088 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
506 2460088 const int is_chroma = 0;
507
508 2460088 x_off += mv->x >> 4;
509 2460088 y_off += mv->y >> 4;
510
511
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2460088 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2460088 times.
2460088 MC_EMULATED_EDGE(lc->pred.edge_emu_buffer, &src, &src_stride, x_off, y_off);
512
2/2
✓ Branch 0 taken 2150840 times.
✓ Branch 1 taken 309248 times.
2460088 if (cb_prof_flag) {
513 2150840 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
514 2150840 fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
515
2/2
✓ Branch 0 taken 2136508 times.
✓ Branch 1 taken 14332 times.
2150840 if (!weight_flag)
516 2136508 fc->vvcdsp.inter.apply_prof_uni(dst, dst_stride, prof_tmp, diff_mv_x, diff_mv_y);
517 else
518 14332 fc->vvcdsp.inter.apply_prof_uni_w(dst, dst_stride, prof_tmp, diff_mv_x, diff_mv_y, denom, wx, ox);
519 } else {
520
2/2
✓ Branch 0 taken 179000 times.
✓ Branch 1 taken 130248 times.
309248 if (!weight_flag)
521 179000 fc->vvcdsp.inter.put_uni[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride, block_h, hf, vf, block_w);
522 else
523 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);
524 }
525 2460088 }
526
527 2103336 static void luma_prof(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref,
528 const Mv *mv , const int x_off, const int y_off, const int block_w, const int block_h, const int lx)
529 {
530 2103336 const VVCFrameContext *fc = lc->fc;
531 2103336 const PredictionUnit *pu = &lc->cu->pu;
532 2103336 const int mx = mv->x & 0xf;
533 2103336 const int my = mv->y & 0xf;
534 2103336 const int ox = x_off + (mv->x >> 4);
535 2103336 const int oy = y_off + (mv->y >> 4);
536 2103336 const int idx = av_log2(block_w) - 1;
537 2103336 const int is_chroma = 0;
538 2103336 int16_t *prof_tmp = lc->pred.prof_tmp + PROF_TEMP_OFFSET;
539 2103336 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
540 2103336 const uint8_t *src = ref->frame->data[LUMA];
541 2103336 const int8_t *hf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
542 2103336 const int8_t *vf = ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
543 2103336 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
544
545
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2103336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2103336 times.
2103336 MC_EMULATED_EDGE(lc->pred.edge_emu_buffer, &src, &src_stride, ox, oy);
546
2/2
✓ Branch 0 taken 692840 times.
✓ Branch 1 taken 1410496 times.
2103336 if (!pu->cb_prof_flag[lx]) {
547 692840 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
548 } else {
549 1410496 fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
550 1410496 fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
551 1410496 fc->vvcdsp.inter.apply_prof(dst, prof_tmp, pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
552 }
553 2103336 }
554
555 1053204 static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
556 const VVCRefPic *ref0, const VVCRefPic *ref1, const MvField *mvf, const int x_off, const int y_off,
557 const int block_w, const int block_h)
558 {
559 1053204 const VVCRefPic *refps[] = { ref0, ref1 };
560 1053204 int16_t *tmp[] = { lc->pred.tmp, lc->pred.tmp1 };
561
562
2/2
✓ Branch 0 taken 2106408 times.
✓ Branch 1 taken 1053204 times.
3159612 for (int i = L0; i <= L1; i++) {
563 2106408 const VVCRefPic *refp = refps[i];
564 2106408 const Mv *mv = mvf->mv + i;
565
566
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 2103336 times.
2106408 if (refp->is_scaled)
567 3072 mc_scaled(lc, tmp[i], refp, mv, x_off, y_off, block_w, block_h, LUMA);
568 else
569 2103336 luma_prof(lc, tmp[i], refp->ref, mv, x_off, y_off, block_w, block_h, i);
570 }
571
572 1053204 apply_averaging(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, lc, mvf, LUMA, 0);
573 1053204 }
574
575 8568981 static int pred_get_refs(const VVCLocalContext *lc, VVCRefPic *refp[2], const MvField *mv)
576 {
577 8568981 RefPicList *rpl = lc->sc->rpl;
578
579
2/2
✓ Branch 0 taken 17137962 times.
✓ Branch 1 taken 8568981 times.
25706943 for (int mask = PF_L0; mask <= PF_L1; mask++) {
580
2/2
✓ Branch 0 taken 13046512 times.
✓ Branch 1 taken 4091450 times.
17137962 if (mv->pred_flag & mask) {
581 13046512 const int lx = mask - PF_L0;
582 13046512 refp[lx] = rpl[lx].refs + mv->ref_idx[lx];
583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13046512 times.
13046512 if (!refp[lx]->ref)
584 return AVERROR_INVALIDDATA;
585 }
586 }
587 8568981 return 0;
588 }
589
590 #define POS(c_idx, x, y) \
591 &fc->frame->data[c_idx][((y) >> fc->ps.sps->vshift[c_idx]) * fc->frame->linesize[c_idx] + \
592 (((x) >> fc->ps.sps->hshift[c_idx]) << fc->ps.sps->pixel_shift)]
593
594 27594 static void pred_gpm_blk(VVCLocalContext *lc)
595 {
596 27594 const VVCFrameContext *fc = lc->fc;
597 27594 const CodingUnit *cu = lc->cu;
598 27594 const PredictionUnit *pu = &cu->pu;
599
600 27594 const uint8_t angle_idx = ff_vvc_gpm_angle_idx[pu->gpm_partition_idx];
601 27594 const uint8_t weights_idx = ff_vvc_gpm_angle_to_weights_idx[angle_idx];
602 27594 const int w = av_log2(cu->cb_width) - 3;
603 27594 const int h = av_log2(cu->cb_height) - 3;
604 27594 const uint8_t off_x = ff_vvc_gpm_weights_offset_x[pu->gpm_partition_idx][h][w];
605 27594 const uint8_t off_y = ff_vvc_gpm_weights_offset_y[pu->gpm_partition_idx][h][w];
606 27594 const uint8_t mirror_type = ff_vvc_gpm_angle_to_mirror[angle_idx];
607 const uint8_t *weights;
608
609
2/2
✓ Branch 0 taken 25313 times.
✓ Branch 1 taken 2281 times.
27594 const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1;
610
611 27594 int16_t *tmp[2] = {lc->pred.tmp, lc->pred.tmp1};
612
613
2/2
✓ Branch 0 taken 78220 times.
✓ Branch 1 taken 27594 times.
105814 for (int c_idx = 0; c_idx < c_end; c_idx++) {
614 78220 const int hs = fc->ps.sps->hshift[c_idx];
615 78220 const int vs = fc->ps.sps->vshift[c_idx];
616 78220 const int x = lc->cu->x0 >> hs;
617 78220 const int y = lc->cu->y0 >> vs;
618 78220 const int width = cu->cb_width >> hs;
619 78220 const int height = cu->cb_height >> vs;
620 78220 uint8_t *dst = POS(c_idx, lc->cu->x0, lc->cu->y0);
621 78220 ptrdiff_t dst_stride = fc->frame->linesize[c_idx];
622
623 78220 int step_x = 1 << hs;
624 78220 int step_y = VVC_GPM_WEIGHT_SIZE << vs;
625
2/2
✓ Branch 0 taken 49435 times.
✓ Branch 1 taken 28785 times.
78220 if (!mirror_type) {
626 49435 weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + off_x];
627
2/2
✓ Branch 0 taken 12311 times.
✓ Branch 1 taken 16474 times.
28785 } else if (mirror_type == 1) {
628 12311 step_x = -step_x;
629 12311 weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + VVC_GPM_WEIGHT_SIZE - 1- off_x];
630 } else {
631 16474 step_y = -step_y;
632 16474 weights = &ff_vvc_gpm_weights[weights_idx][(VVC_GPM_WEIGHT_SIZE - 1 - off_y) * VVC_GPM_WEIGHT_SIZE + off_x];
633 }
634
635
2/2
✓ Branch 0 taken 156440 times.
✓ Branch 1 taken 78220 times.
234660 for (int i = 0; i < 2; i++) {
636 156440 const MvField *mv = pu->gpm_mv + i;
637 156440 const int lx = mv->pred_flag - PF_L0;
638 156440 VVCRefPic *refp = lc->sc->rpl[lx].refs + mv->ref_idx[lx];
639
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156440 times.
156440 if (!refp->ref)
641 return;
642
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 155621 times.
156440 if (refp->is_scaled)
643 819 mc_scaled(lc, tmp[i], refp, mv->mv + lx, x, y, width, height, c_idx);
644 else
645 155621 mc(lc, tmp[i], refp->ref, mv->mv + lx, x, y, width, height, c_idx);
646 }
647 78220 fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
648 }
649 27594 return;
650 }
651
652 43833 static int ciip_derive_intra_weight(const VVCLocalContext *lc, const int x0, const int y0,
653 const int width, const int height)
654 {
655 43833 const VVCFrameContext *fc = lc->fc;
656 43833 const VVCSPS *sps = fc->ps.sps;
657 43833 const int x0b = av_zero_extend(x0, sps->ctb_log2_size_y);
658 43833 const int y0b = av_zero_extend(y0, sps->ctb_log2_size_y);
659
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;
660
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;
661 43833 const int min_pu_width = fc->ps.pps->min_pu_width;
662 43833 int w = 1;
663
664
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)
665 6198 w++;
666
667
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)
668 5922 w++;
669
670 43833 return w;
671 }
672
673 3923387 static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField *orig_mvf,
674 const int x0, const int y0, const int sbw, const int sbh, const int sb_bdof_flag, const int c_start)
675 {
676 3923387 const VVCFrameContext *fc = lc->fc;
677
2/2
✓ Branch 0 taken 3895100 times.
✓ Branch 1 taken 28287 times.
3923387 const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? CR : LUMA;
678 VVCRefPic *refp[2];
679
680
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3923387 times.
3923387 if (pred_get_refs(lc, refp, mvf) < 0)
681 return;
682
683
2/2
✓ Branch 0 taken 10395538 times.
✓ Branch 1 taken 3923387 times.
14318925 for (int c_idx = c_start; c_idx <= c_end; c_idx++) {
684 10395538 uint8_t *dst = POS(c_idx, x0, y0);
685 10395538 const ptrdiff_t dst_stride = fc->frame->linesize[c_idx];
686 10395538 const int hs = fc->ps.sps->hshift[c_idx];
687 10395538 const int vs = fc->ps.sps->vshift[c_idx];
688 10395538 const int x = x0 >> hs;
689 10395538 const int y = y0 >> vs;
690 10395538 const int w = sbw >> hs;
691 10395538 const int h = sbh >> vs;
692 10395538 const int is_luma = !c_idx;
693
6/6
✓ Branch 0 taken 48347 times.
✓ Branch 1 taken 10347191 times.
✓ Branch 2 taken 32020 times.
✓ Branch 3 taken 16327 times.
✓ Branch 4 taken 27506 times.
✓ Branch 5 taken 4514 times.
10395538 const int do_ciip = lc->cu->ciip_flag && (is_luma || (w > 2));
694
2/2
✓ Branch 0 taken 43833 times.
✓ Branch 1 taken 10351705 times.
10395538 uint8_t *inter = do_ciip ? lc->pred.ciip_tmp : dst;
695
2/2
✓ Branch 0 taken 10351705 times.
✓ Branch 1 taken 43833 times.
10395538 const ptrdiff_t inter_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride;
696
4/4
✓ Branch 0 taken 2605338 times.
✓ Branch 1 taken 7790200 times.
✓ Branch 2 taken 357550 times.
✓ Branch 3 taken 2247788 times.
10395538 const int do_bdof = is_luma && sb_bdof_flag;
697
698
2/2
✓ Branch 0 taken 3991087 times.
✓ Branch 1 taken 6404451 times.
10395538 if (mvf->pred_flag != PF_BI) {
699 3991087 const int lx = mvf->pred_flag - PF_L0;
700
701
2/2
✓ Branch 0 taken 10749 times.
✓ Branch 1 taken 3980338 times.
3991087 if (refp[lx]->is_scaled) {
702 10749 mc_uni_scaled(lc, inter, inter_stride, refp[lx], mvf,
703 x, y, w, h, c_idx);
704 } else {
705 3980338 mc_uni(lc, inter, inter_stride, refp[lx]->ref, mvf,
706 x, y, w, h, c_idx);
707 }
708 } else {
709
4/4
✓ Branch 0 taken 6403374 times.
✓ Branch 1 taken 1077 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 6403365 times.
6404451 if (refp[L0]->is_scaled || refp[L1]->is_scaled) {
710 1086 mc_bi_scaled(lc, inter, inter_stride, refp[L0], refp[L1], mvf,
711 x, y, w, h, c_idx);
712 } else {
713 6403365 mc_bi(lc, inter, inter_stride, refp[L0]->ref, refp[L1]->ref, mvf, orig_mvf,
714 x, y, w, h, c_idx, do_bdof);
715 }
716 }
717
2/2
✓ Branch 0 taken 43833 times.
✓ Branch 1 taken 10351705 times.
10395538 if (do_ciip) {
718 43833 const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
719 43833 fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, c_idx);
720
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)
721 8428 fc->vvcdsp.lmcs.filter(inter, inter_stride, w, h, &fc->ps.lmcs.fwd_lut);
722 43833 fc->vvcdsp.inter.put_ciip(dst, dst_stride, w, h, inter, inter_stride, intra_weight);
723 }
724 }
725 }
726
727 // 8.5.3.5 Parametric motion vector refinement process
728 514500 static int parametric_mv_refine(const int *sad, const int stride)
729 {
730 514500 const int sad_minus = sad[-stride];
731 514500 const int sad_center = sad[0];
732 514500 const int sad_plus = sad[stride];
733 int dmvc;
734 514500 int denom = (( sad_minus + sad_plus) - (sad_center << 1 ) ) << 3;
735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 514500 times.
514500 if (!denom)
736 dmvc = 0;
737 else {
738
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 514442 times.
514500 if (sad_minus == sad_center)
739 58 dmvc = -8;
740
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 514198 times.
514442 else if (sad_plus == sad_center)
741 244 dmvc = 8;
742 else {
743 514198 int num = ( sad_minus - sad_plus ) * (1 << 4);
744 514198 int sign_num = 0;
745 514198 int quotient = 0;
746 514198 int counter = 3;
747
2/2
✓ Branch 0 taken 260163 times.
✓ Branch 1 taken 254035 times.
514198 if (num < 0 ) {
748 260163 num = - num;
749 260163 sign_num = 1;
750 }
751
2/2
✓ Branch 0 taken 1542594 times.
✓ Branch 1 taken 514198 times.
2056792 while (counter > 0) {
752 1542594 counter = counter - 1;
753 1542594 quotient = quotient << 1;
754
2/2
✓ Branch 0 taken 445866 times.
✓ Branch 1 taken 1096728 times.
1542594 if ( num >= denom ) {
755 445866 num = num - denom;
756 445866 quotient = quotient + 1;
757 }
758 1542594 denom = (denom >> 1);
759 }
760
2/2
✓ Branch 0 taken 260163 times.
✓ Branch 1 taken 254035 times.
514198 if (sign_num == 1 )
761 260163 dmvc = -quotient;
762 else
763 254035 dmvc = quotient;
764 }
765 }
766 514500 return dmvc;
767 }
768
769 #define SAD_ARRAY_SIZE 5
770 //8.5.3 Decoder-side motion vector refinement process
771 1116294 static void dmvr_mv_refine(VVCLocalContext *lc, MvField *mvf, MvField *orig_mv, int *sb_bdof_flag,
772 const VVCFrame *ref0, const VVCFrame *ref1, const int x_off, const int y_off, const int block_w, const int block_h)
773 {
774 1116294 const VVCFrameContext *fc = lc->fc;
775 1116294 const int sr_range = 2;
776 1116294 const VVCFrame *refs[] = { ref0, ref1 };
777 1116294 int16_t *tmp[] = { lc->pred.tmp, lc->pred.tmp1 };
778 int sad[SAD_ARRAY_SIZE][SAD_ARRAY_SIZE];
779 int min_dx, min_dy, min_sad, dx, dy;
780
781 1116294 *orig_mv = *mvf;
782 1116294 min_dx = min_dy = dx = dy = 2;
783
784
2/2
✓ Branch 0 taken 2232588 times.
✓ Branch 1 taken 1116294 times.
3348882 for (int i = L0; i <= L1; i++) {
785 2232588 const int pred_w = block_w + 2 * sr_range;
786 2232588 const int pred_h = block_h + 2 * sr_range;
787 2232588 const Mv *mv = mvf->mv + i;
788 2232588 const int mx = mv->x & 0xf;
789 2232588 const int my = mv->y & 0xf;
790 2232588 const int ox = x_off + (mv->x >> 4) - sr_range;
791 2232588 const int oy = y_off + (mv->y >> 4) - sr_range;
792 2232588 const VVCFrame *ref = refs[i];
793 2232588 ptrdiff_t src_stride = ref->frame->linesize[LUMA];
794 2232588 const uint8_t *src = ref->frame->data[LUMA];
795 2232588 const int wrap_enabled = fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
796
797 2232588 MC_EMULATED_EDGE_BILINEAR(lc->pred.edge_emu_buffer, &src, &src_stride, ox, oy);
798 2232588 fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, my, pred_w);
799 }
800
801 1116294 min_sad = fc->vvcdsp.inter.sad(tmp[L0], tmp[L1], dx, dy, block_w, block_h);
802 1116294 min_sad -= min_sad >> 2;
803 1116294 sad[dy][dx] = min_sad;
804
805
2/2
✓ Branch 0 taken 460533 times.
✓ Branch 1 taken 655761 times.
1116294 if (min_sad >= block_w * block_h) {
806 int dmv[2];
807 // 8.5.3.4 Array entry selection process
808
2/2
✓ Branch 0 taken 2302665 times.
✓ Branch 1 taken 460533 times.
2763198 for (dy = 0; dy < SAD_ARRAY_SIZE; dy++) {
809
2/2
✓ Branch 0 taken 11513325 times.
✓ Branch 1 taken 2302665 times.
13815990 for (dx = 0; dx < SAD_ARRAY_SIZE; dx++) {
810
4/4
✓ Branch 0 taken 2302665 times.
✓ Branch 1 taken 9210660 times.
✓ Branch 2 taken 1842132 times.
✓ Branch 3 taken 460533 times.
11513325 if (dx != sr_range || dy != sr_range) {
811 11052792 sad[dy][dx] = fc->vvcdsp.inter.sad(lc->pred.tmp, lc->pred.tmp1, dx, dy, block_w, block_h);
812
2/2
✓ Branch 0 taken 650256 times.
✓ Branch 1 taken 10402536 times.
11052792 if (sad[dy][dx] < min_sad) {
813 650256 min_sad = sad[dy][dx];
814 650256 min_dx = dx;
815 650256 min_dy = dy;
816 }
817 }
818 }
819 }
820 460533 dmv[0] = (min_dx - sr_range) * (1 << 4);
821 460533 dmv[1] = (min_dy - sr_range) * (1 << 4);
822
8/8
✓ Branch 0 taken 382857 times.
✓ Branch 1 taken 77676 times.
✓ Branch 2 taken 317984 times.
✓ Branch 3 taken 64873 times.
✓ Branch 4 taken 265754 times.
✓ Branch 5 taken 52230 times.
✓ Branch 6 taken 257250 times.
✓ Branch 7 taken 8504 times.
460533 if (min_dx != 0 && min_dx != 4 && min_dy != 0 && min_dy != 4) {
823 257250 dmv[0] += parametric_mv_refine(&sad[min_dy][min_dx], 1);
824 257250 dmv[1] += parametric_mv_refine(&sad[min_dy][min_dx], SAD_ARRAY_SIZE);
825 }
826
827
2/2
✓ Branch 0 taken 921066 times.
✓ Branch 1 taken 460533 times.
1381599 for (int i = L0; i <= L1; i++) {
828 921066 Mv *mv = mvf->mv + i;
829 921066 mv->x += (1 - 2 * i) * dmv[0];
830 921066 mv->y += (1 - 2 * i) * dmv[1];
831 921066 ff_vvc_clip_mv(mv);
832 }
833 }
834
2/2
✓ Branch 0 taken 825554 times.
✓ Branch 1 taken 290740 times.
1116294 if (min_sad < 2 * block_w * block_h) {
835 825554 *sb_bdof_flag = 0;
836 }
837 1116294 }
838
839 1116294 static void set_dmvr_info(VVCFrameContext *fc, const int x0, const int y0,
840 const int width, const int height, const MvField *mvf)
841
842 {
843 1116294 const VVCPPS *pps = fc->ps.pps;
844
845
2/2
✓ Branch 0 taken 4420952 times.
✓ Branch 1 taken 1116294 times.
5537246 for (int y = y0; y < y0 + height; y += MIN_PU_SIZE) {
846
2/2
✓ Branch 0 taken 17546936 times.
✓ Branch 1 taken 4420952 times.
21967888 for (int x = x0; x < x0 + width; x += MIN_PU_SIZE) {
847 17546936 const int idx = pps->min_pu_width * (y >> MIN_PU_LOG2) + (x >> MIN_PU_LOG2);
848 17546936 fc->ref->tab_dmvr_mvf[idx] = *mvf;
849 }
850 }
851 1116294 }
852
853 2605338 static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int *sb_bdof_flag,
854 const int x0, const int y0, const int sbw, const int sbh)
855 {
856 2605338 VVCFrameContext *fc = lc->fc;
857 2605338 const PredictionUnit *pu = &lc->cu->pu;
858
859 2605338 *orig_mv = *mv = *ff_vvc_get_mvf(fc, x0, y0);
860
2/2
✓ Branch 0 taken 1183104 times.
✓ Branch 1 taken 1422234 times.
2605338 if (pu->bdof_flag)
861 1183104 *sb_bdof_flag = 1;
862
2/2
✓ Branch 0 taken 1116294 times.
✓ Branch 1 taken 1489044 times.
2605338 if (pu->dmvr_flag) {
863 VVCRefPic *refp[2];
864
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1116294 times.
1116294 if (pred_get_refs(lc, refp, mv) < 0)
865 return;
866 1116294 dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, refp[L0]->ref, refp[L1]->ref, x0, y0, sbw, sbh);
867 1116294 set_dmvr_info(fc, x0, y0, sbw, sbh, mv);
868 }
869 }
870
871 413297 static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip)
872 {
873 413297 const CodingUnit *cu = lc->cu;
874 413297 PredictionUnit *pu = &lc->cu->pu;
875 413297 const MotionInfo *mi = &pu->mi;
876 MvField mv, orig_mv;
877 413297 int sbw, sbh, sb_bdof_flag = 0;
878
879
4/4
✓ Branch 0 taken 32654 times.
✓ Branch 1 taken 380643 times.
✓ Branch 2 taken 16327 times.
✓ Branch 3 taken 16327 times.
413297 if (cu->ciip_flag && skip_ciip)
880 16327 return;
881
882 396970 sbw = cu->cb_width / mi->num_sb_x;
883 396970 sbh = cu->cb_height / mi->num_sb_y;
884
885
2/2
✓ Branch 0 taken 660268 times.
✓ Branch 1 taken 396970 times.
1057238 for (int sby = 0; sby < mi->num_sb_y; sby++) {
886
2/2
✓ Branch 0 taken 2605338 times.
✓ Branch 1 taken 660268 times.
3265606 for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
887 2605338 const int x0 = cu->x0 + sbx * sbw;
888 2605338 const int y0 = cu->y0 + sby * sbh;
889
890
2/2
✓ Branch 0 taken 16327 times.
✓ Branch 1 taken 2589011 times.
2605338 if (cu->ciip_flag)
891 16327 ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh);
892
893 2605338 derive_sb_mv(lc, &mv, &orig_mv, &sb_bdof_flag, x0, y0, sbw, sbh);
894 2605338 pred_regular(lc, &mv, &orig_mv, x0, y0, sbw, sbh, sb_bdof_flag, LUMA);
895 }
896 }
897 }
898
899 1318049 static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, const MvField *mv,
900 const int x0, const int y0, const int sbw, const int sbh)
901 {
902 1318049 const int hs = fc->ps.sps->hshift[1];
903 1318049 const int vs = fc->ps.sps->vshift[1];
904 1318049 const MvField* mv2 = ff_vvc_get_mvf(fc, x0 + hs * sbw, y0 + vs * sbh);
905 1318049 *mvc = *mv;
906
907 // Due to different pred_flag, one of the motion vectors may have an invalid value.
908 // Cast them to an unsigned type to avoid undefined behavior.
909 1318049 mvc->mv[0].x += (unsigned int)mv2->mv[0].x;
910 1318049 mvc->mv[0].y += (unsigned int)mv2->mv[0].y;
911 1318049 mvc->mv[1].x += (unsigned int)mv2->mv[1].x;
912 1318049 mvc->mv[1].y += (unsigned int)mv2->mv[1].y;
913 1318049 ff_vvc_round_mv(mvc->mv + 0, 0, 1);
914 1318049 ff_vvc_round_mv(mvc->mv + 1, 0, 1);
915 1318049 }
916
917 35978 static void pred_affine_blk(VVCLocalContext *lc)
918 {
919 35978 const VVCFrameContext *fc = lc->fc;
920 35978 const CodingUnit *cu = lc->cu;
921 35978 const PredictionUnit *pu = &cu->pu;
922 35978 const MotionInfo *mi = &pu->mi;
923 35978 const int x0 = cu->x0;
924 35978 const int y0 = cu->y0;
925 35978 const int sbw = cu->cb_width / mi->num_sb_x;
926 35978 const int sbh = cu->cb_height / mi->num_sb_y;
927 35978 const int hs = fc->ps.sps->hshift[1];
928 35978 const int vs = fc->ps.sps->vshift[1];
929 35978 const int dst_stride = fc->frame->linesize[LUMA];
930
931
2/2
✓ Branch 0 taken 284286 times.
✓ Branch 1 taken 35978 times.
320264 for (int sby = 0; sby < mi->num_sb_y; sby++) {
932
2/2
✓ Branch 0 taken 3529300 times.
✓ Branch 1 taken 284286 times.
3813586 for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
933 3529300 const int x = x0 + sbx * sbw;
934 3529300 const int y = y0 + sby * sbh;
935
936 3529300 uint8_t *dst0 = POS(0, x, y);
937 3529300 const MvField *mv = ff_vvc_get_mvf(fc, x, y);
938 VVCRefPic *refp[2];
939
940
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3529300 times.
3529300 if (pred_get_refs(lc, refp, mv) < 0)
941 return;
942
943
2/2
✓ Branch 0 taken 2476096 times.
✓ Branch 1 taken 1053204 times.
3529300 if (mi->pred_flag != PF_BI) {
944 2476096 const int lx = mi->pred_flag - PF_L0;
945
2/2
✓ Branch 0 taken 16008 times.
✓ Branch 1 taken 2460088 times.
2476096 if (refp[lx]->is_scaled) {
946 16008 mc_uni_scaled(lc, dst0, dst_stride, refp[lx], mv, x, y, sbw, sbh, LUMA);
947 } else {
948 2460088 luma_prof_uni(lc, dst0, dst_stride, refp[lx]->ref,
949 2460088 mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
950 2460088 pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
951 }
952 } else {
953 1053204 luma_prof_bi(lc, dst0, dst_stride, refp[L0], refp[L1], mv, x, y, sbw, sbh);
954 }
955
2/2
✓ Branch 0 taken 3491192 times.
✓ Branch 1 taken 38108 times.
3529300 if (fc->ps.sps->r->sps_chroma_format_idc) {
956
4/4
✓ Branch 0 taken 2042986 times.
✓ Branch 1 taken 1448206 times.
✓ Branch 2 taken 1318049 times.
✓ Branch 3 taken 724937 times.
3491192 if (!av_zero_extend(sby, vs) && !av_zero_extend(sbx, hs)) {
957 MvField mvc;
958
959 1318049 derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh);
960 1318049 pred_regular(lc, &mvc, NULL, x, y, sbw << hs, sbh << vs, 0, CB);
961 }
962 }
963
964 }
965 }
966 }
967
968 460542 static void predict_inter(VVCLocalContext *lc)
969 {
970 460542 const VVCFrameContext *fc = lc->fc;
971 460542 const CodingUnit *cu = lc->cu;
972 460542 const PredictionUnit *pu = &cu->pu;
973
974
2/2
✓ Branch 0 taken 27594 times.
✓ Branch 1 taken 432948 times.
460542 if (pu->merge_gpm_flag)
975 27594 pred_gpm_blk(lc);
976
2/2
✓ Branch 0 taken 35978 times.
✓ Branch 1 taken 396970 times.
432948 else if (pu->inter_affine_flag)
977 35978 pred_affine_blk(lc);
978 else
979 396970 pred_regular_blk(lc, 1); //intra block is not ready yet, skip ciip
980
981
4/4
✓ Branch 0 taken 189745 times.
✓ Branch 1 taken 270797 times.
✓ Branch 2 taken 181317 times.
✓ Branch 3 taken 8428 times.
460542 if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) {
982 181317 uint8_t* dst0 = POS(0, cu->x0, cu->y0);
983 181317 fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, &fc->ps.lmcs.fwd_lut);
984 }
985 460542 }
986
987 1382471 static int has_inter_luma(const CodingUnit *cu)
988 {
989
4/6
✓ Branch 0 taken 921929 times.
✓ Branch 1 taken 460542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 921929 times.
✓ Branch 4 taken 460542 times.
✗ Branch 5 not taken.
1382471 return (cu->pred_mode == MODE_INTER || cu->pred_mode == MODE_SKIP) && cu->tree_type != DUAL_TREE_CHROMA;
990 }
991
992 53745 int ff_vvc_predict_inter(VVCLocalContext *lc, const int rs)
993 {
994 53745 const VVCFrameContext *fc = lc->fc;
995 53745 CodingUnit *cu = fc->tab.cus[rs];
996
997
2/2
✓ Branch 0 taken 1382471 times.
✓ Branch 1 taken 53745 times.
1436216 while (cu) {
998 1382471 lc->cu = cu;
999
2/2
✓ Branch 1 taken 460542 times.
✓ Branch 2 taken 921929 times.
1382471 if (has_inter_luma(cu))
1000 460542 predict_inter(lc);
1001 1382471 cu = cu->next;
1002 }
1003
1004 53745 return 0;
1005 }
1006
1007 16327 void ff_vvc_predict_ciip(VVCLocalContext *lc)
1008 {
1009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16327 times.
16327 av_assert0(lc->cu->ciip_flag);
1010
1011 //todo: refact out ciip from pred_regular_blk
1012 16327 pred_regular_blk(lc, 0);
1013 16327 }
1014
1015 #undef POS
1016