FFmpeg
vvc_inter.c
Go to the documentation of this file.
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 "vvc_data.h"
25 #include "vvc_inter.h"
26 #include "vvc_mvs.h"
27 #include "vvc_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 static int emulated_edge(const VVCFrameContext *fc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride,
34  const int x_off, const int y_off, const int block_w, const int block_h, const int is_luma)
35 {
36  const int extra_before = is_luma ? LUMA_EXTRA_BEFORE : CHROMA_EXTRA_BEFORE;
37  const int extra_after = is_luma ? LUMA_EXTRA_AFTER : CHROMA_EXTRA_AFTER;
38  const int extra = is_luma ? LUMA_EXTRA : CHROMA_EXTRA;
39  const int pic_width = is_luma ? fc->ps.pps->width : (fc->ps.pps->width >> fc->ps.sps->hshift[1]);
40  const int pic_height = is_luma ? fc->ps.pps->height : (fc->ps.pps->height >> fc->ps.sps->vshift[1]);
41 
42  if (x_off < extra_before || y_off < extra_before ||
43  x_off >= pic_width - block_w - extra_after ||
44  y_off >= pic_height - block_h - extra_after) {
45  const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << fc->ps.sps->pixel_shift;
46  int offset = extra_before * *src_stride + (extra_before << fc->ps.sps->pixel_shift);
47  int buf_offset = extra_before * edge_emu_stride + (extra_before << fc->ps.sps->pixel_shift);
48 
49  fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride,
50  block_w + extra, block_h + extra, x_off - extra_before, y_off - extra_before,
51  pic_width, pic_height);
52 
53  *src = dst + buf_offset;
54  *src_stride = edge_emu_stride;
55  return 1;
56  }
57  return 0;
58 }
59 
60 static void emulated_edge_dmvr(const VVCFrameContext *fc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride,
61  const int x_sb, const int y_sb, const int x_off, const int y_off, const int block_w, const int block_h, const int is_luma)
62 {
63  const int extra_before = is_luma ? LUMA_EXTRA_BEFORE : CHROMA_EXTRA_BEFORE;
64  const int extra_after = is_luma ? LUMA_EXTRA_AFTER : CHROMA_EXTRA_AFTER;
65  const int extra = is_luma ? LUMA_EXTRA : CHROMA_EXTRA;
66  const int pic_width = is_luma ? fc->ps.pps->width : (fc->ps.pps->width >> fc->ps.sps->hshift[1]);
67  const int pic_height = is_luma ? fc->ps.pps->height : (fc->ps.pps->height >> fc->ps.sps->vshift[1]);
68 
69  if (x_off < extra_before || y_off < extra_before ||
70  x_off >= pic_width - block_w - extra_after ||
71  y_off >= pic_height - block_h - extra_after||
72  (x_off != x_sb || y_off != y_sb)) {
73  const int ps = fc->ps.sps->pixel_shift;
74  const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << ps;
75  const int offset = extra_before * *src_stride + (extra_before << ps);
76  const int buf_offset = extra_before * edge_emu_stride + (extra_before << ps);
77 
78  const int start_x = FFMIN(FFMAX(x_sb - extra_before, 0), pic_width - 1);
79  const int start_y = FFMIN(FFMAX(y_sb - extra_before, 0), pic_height - 1);
80  const int width = FFMAX(FFMIN(pic_width, x_sb + block_w + extra_after) - start_x, 1);
81  const int height = FFMAX(FFMIN(pic_height, y_sb + block_h + extra_after) - start_y, 1);
82 
83  fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride, block_w + extra, block_h + extra,
84  x_off - start_x - extra_before, y_off - start_y - extra_before, width, height);
85 
86  *src = dst + buf_offset;
87  *src_stride = edge_emu_stride;
88  }
89 }
90 
91 static void emulated_edge_bilinear(const VVCFrameContext *fc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride,
92  const int x_off, const int y_off, const int block_w, const int block_h)
93 {
94  int pic_width = fc->ps.pps->width;
95  int pic_height = fc->ps.pps->height;
96 
97  if (x_off < BILINEAR_EXTRA_BEFORE || y_off < BILINEAR_EXTRA_BEFORE ||
98  x_off >= pic_width - block_w - BILINEAR_EXTRA_AFTER ||
99  y_off >= pic_height - block_h - BILINEAR_EXTRA_AFTER) {
100  const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << fc->ps.sps->pixel_shift;
101  const int offset = BILINEAR_EXTRA_BEFORE * *src_stride + (BILINEAR_EXTRA_BEFORE << fc->ps.sps->pixel_shift);
102  const int buf_offset = BILINEAR_EXTRA_BEFORE * edge_emu_stride + (BILINEAR_EXTRA_BEFORE << fc->ps.sps->pixel_shift);
103 
104  fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, *src_stride, block_w + BILINEAR_EXTRA, block_h + BILINEAR_EXTRA,
105  x_off - BILINEAR_EXTRA_BEFORE, y_off - BILINEAR_EXTRA_BEFORE, pic_width, pic_height);
106 
107  *src = dst + buf_offset;
108  *src_stride = edge_emu_stride;
109  }
110 }
111 
112 
113 #define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off) \
114  emulated_edge(fc, dst, src, src_stride, x_off, y_off, block_w, block_h, 1)
115 
116 #define EMULATED_EDGE_CHROMA(dst, src, src_stride, x_off, y_off) \
117  emulated_edge(fc, dst, src, src_stride, x_off, y_off, block_w, block_h, 0)
118 
119 #define EMULATED_EDGE_DMVR_LUMA(dst, src, src_stride, x_sb, y_sb, x_off, y_off) \
120  emulated_edge_dmvr(fc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, 1)
121 
122 #define EMULATED_EDGE_DMVR_CHROMA(dst, src, src_stride, x_sb, y_sb, x_off, y_off) \
123  emulated_edge_dmvr(fc, dst, src, src_stride, x_sb, y_sb, x_off, y_off, block_w, block_h, 0)
124 
125 #define EMULATED_EDGE_BILINEAR(dst, src, src_stride, x_off, y_off) \
126  emulated_edge_bilinear(fc, dst, src, src_stride, x_off, y_off, pred_w, pred_h)
127 
128 // part of 8.5.6.6 Weighted sample prediction process
129 static int derive_weight_uni(int *denom, int *wx, int *ox,
130  const VVCLocalContext *lc, const MvField *mvf, const int c_idx)
131 {
132  const VVCFrameContext *fc = lc->fc;
133  const VVCPPS *pps = fc->ps.pps;
134  const VVCSH *sh = &lc->sc->sh;
135  const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) ||
136  (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag);
137  if (weight_flag) {
138  const int lx = mvf->pred_flag - PF_L0;
139  const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
140 
141  *denom = w->log2_denom[c_idx > 0];
142  *wx = w->weight[lx][c_idx][mvf->ref_idx[lx]];
143  *ox = w->offset[lx][c_idx][mvf->ref_idx[lx]];
144  }
145  return weight_flag;
146 }
147 
148 // part of 8.5.6.6 Weighted sample prediction process
149 static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1,
150  const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int dmvr_flag)
151 {
152  const VVCFrameContext *fc = lc->fc;
153  const VVCPPS *pps = fc->ps.pps;
154  const VVCSH *sh = &lc->sc->sh;
155  const int bcw_idx = mvf->bcw_idx;
156  const int weight_flag = (IS_P(sh->r) && pps->r->pps_weighted_pred_flag) ||
157  (IS_B(sh->r) && pps->r->pps_weighted_bipred_flag && !dmvr_flag);
158  if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag))
159  return 0;
160 
161  if (bcw_idx) {
162  *denom = 2;
163  *w1 = bcw_w_lut[bcw_idx];
164  *w0 = 8 - *w1;
165  *o0 = *o1 = 0;
166  } else {
167  const VVCPPS *pps = fc->ps.pps;
168  const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? &fc->ps.ph.pwt : &sh->pwt;
169 
170  *denom = w->log2_denom[c_idx > 0];
171  *w0 = w->weight[L0][c_idx][mvf->ref_idx[L0]];
172  *w1 = w->weight[L1][c_idx][mvf->ref_idx[L1]];
173  *o0 = w->offset[L0][c_idx][mvf->ref_idx[L0]];
174  *o1 = w->offset[L1][c_idx][mvf->ref_idx[L1]];
175  }
176  return 1;
177 }
178 
179 static void luma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
180  int x_off, int y_off, const int block_w, const int block_h)
181 {
182  const VVCFrameContext *fc = lc->fc;
183  const uint8_t *src = ref->data[0];
184  ptrdiff_t src_stride = ref->linesize[0];
185  const int idx = av_log2(block_w) - 1;
186  const int mx = mv->x & 0xf;
187  const int my = mv->y & 0xf;
188  const int8_t *hf = ff_vvc_inter_luma_filters[0][mx];
189  const int8_t *vf = ff_vvc_inter_luma_filters[0][my];
190 
191  x_off += mv->x >> 4;
192  y_off += mv->y >> 4;
193  src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
194 
195  EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
196 
197  fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
198 }
199 
200 static void chroma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
201  int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
202 {
203  const VVCFrameContext *fc = lc->fc;
204  const uint8_t *src = ref->data[c_idx];
205  ptrdiff_t src_stride = ref->linesize[c_idx];
206  int hs = fc->ps.sps->hshift[c_idx];
207  int vs = fc->ps.sps->vshift[c_idx];
208  const int idx = av_log2(block_w) - 1;
209  const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);
210  const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);
211  const int8_t *hf = ff_vvc_inter_chroma_filters[0][mx];
212  const int8_t *vf = ff_vvc_inter_chroma_filters[0][my];
213 
214  x_off += mv->x >> (4 + hs);
215  y_off += mv->y >> (4 + vs);
216  src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
217 
218  EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
219  fc->vvcdsp.inter.put[CHROMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
220 }
221 
222 static void luma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
223  const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
224  const int hf_idx, const int vf_idx)
225 {
226  const VVCFrameContext *fc = lc->fc;
227  const int lx = mvf->pred_flag - PF_L0;
228  const Mv *mv = mvf->mv + lx;
229  const uint8_t *src = ref->data[0];
230  ptrdiff_t src_stride = ref->linesize[0];
231  const int idx = av_log2(block_w) - 1;
232  const int mx = mv->x & 0xf;
233  const int my = mv->y & 0xf;
234  const int8_t *hf = ff_vvc_inter_luma_filters[hf_idx][mx];
235  const int8_t *vf = ff_vvc_inter_luma_filters[vf_idx][my];
236  int denom, wx, ox;
237 
238  x_off += mv->x >> 4;
239  y_off += mv->y >> 4;
240  src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
241 
242  EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
243 
244  if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA)) {
245  fc->vvcdsp.inter.put_uni_w[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
246  block_h, denom, wx, ox, hf, vf, block_w);
247  } else {
248  fc->vvcdsp.inter.put_uni[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
249  block_h, hf, vf, block_w);
250  }
251 }
252 
253 static void luma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
254  const AVFrame *ref0, const Mv *mv0, const int x_off, const int y_off, const int block_w, const int block_h,
255  const AVFrame *ref1, const Mv *mv1, const MvField *mvf, const int hf_idx, const int vf_idx,
256  const MvField *orig_mv, const int sb_bdof_flag)
257 {
258  const VVCFrameContext *fc = lc->fc;
259  const PredictionUnit *pu = &lc->cu->pu;
260  const int idx = av_log2(block_w) - 1;
261  const AVFrame *ref[] = { ref0, ref1 };
262  int16_t *tmp[] = { lc->tmp + sb_bdof_flag * PROF_TEMP_OFFSET, lc->tmp1 + sb_bdof_flag * PROF_TEMP_OFFSET };
263  int denom, w0, w1, o0, o1;
264  const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, pu->dmvr_flag);
265 
266  for (int i = L0; i <= L1; i++) {
267  const Mv *mv = mvf->mv + i;
268  const int mx = mv->x & 0xf;
269  const int my = mv->y & 0xf;
270  const int ox = x_off + (mv->x >> 4);
271  const int oy = y_off + (mv->y >> 4);
272  ptrdiff_t src_stride = ref[i]->linesize[0];
273  const uint8_t *src = ref[i]->data[0] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
274  const int8_t *hf = ff_vvc_inter_luma_filters[hf_idx][mx];
275  const int8_t *vf = ff_vvc_inter_luma_filters[vf_idx][my];
276 
277  if (pu->dmvr_flag) {
278  const int x_sb = x_off + (orig_mv->mv[i].x >> 4);
279  const int y_sb = y_off + (orig_mv->mv[i].y >> 4);
280 
281  EMULATED_EDGE_DMVR_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_sb, y_sb, ox, oy);
282  } else {
283  EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
284  }
285  fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
286  if (sb_bdof_flag)
287  fc->vvcdsp.inter.bdof_fetch_samples(tmp[i], src, src_stride, mx, my, block_w, block_h);
288  }
289 
290  if (sb_bdof_flag)
291  fc->vvcdsp.inter.apply_bdof(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
292  else if (weight_flag)
293  fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
294  else
295  fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
296 }
297 
298 static void chroma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
299  const uint8_t *src, ptrdiff_t src_stride, int x_off, int y_off,
300  const int block_w, const int block_h, const MvField *mvf, const int c_idx,
301  const int hf_idx, const int vf_idx)
302 {
303  const VVCFrameContext *fc = lc->fc;
304  const int lx = mvf->pred_flag - PF_L0;
305  const int hs = fc->ps.sps->hshift[1];
306  const int vs = fc->ps.sps->vshift[1];
307  const int idx = av_log2(block_w) - 1;
308  const Mv *mv = &mvf->mv[lx];
309  const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);
310  const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);
311  const int8_t *hf = ff_vvc_inter_chroma_filters[hf_idx][mx];
312  const int8_t *vf = ff_vvc_inter_chroma_filters[vf_idx][my];
313  int denom, wx, ox;
314 
315  x_off += mv->x >> (4 + hs);
316  y_off += mv->y >> (4 + vs);
317  src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
318 
319 
320  EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
321  if (derive_weight_uni(&denom, &wx, &ox, lc, mvf, c_idx)) {
322  fc->vvcdsp.inter.put_uni_w[CHROMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
323  block_h, denom, wx, ox, hf, vf, block_w);
324  } else {
325  fc->vvcdsp.inter.put_uni[CHROMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride,
326  block_h, hf, vf, block_w);
327  }
328 }
329 
330 static void chroma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
331  const AVFrame *ref0, const AVFrame *ref1, const int x_off, const int y_off,
332  const int block_w, const int block_h, const MvField *mvf, const int c_idx,
333  const int hf_idx, const int vf_idx, const MvField *orig_mv, const int dmvr_flag, const int ciip_flag)
334 {
335  const VVCFrameContext *fc = lc->fc;
336  const int hs = fc->ps.sps->hshift[1];
337  const int vs = fc->ps.sps->vshift[1];
338  const int idx = av_log2(block_w) - 1;
339  const AVFrame *ref[] = { ref0, ref1 };
340  int16_t *tmp[] = { lc->tmp, lc->tmp1 };
341  int denom, w0, w1, o0, o1;
342  const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, c_idx, dmvr_flag);
343 
344  for (int i = L0; i <= L1; i++) {
345  const Mv *mv = mvf->mv + i;
346  const int mx = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);
347  const int my = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);
348  const int ox = x_off + (mv->x >> (4 + hs));
349  const int oy = y_off + (mv->y >> (4 + vs));
350  ptrdiff_t src_stride = ref[i]->linesize[c_idx];
351  const uint8_t *src = ref[i]->data[c_idx] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
352  const int8_t *hf = ff_vvc_inter_chroma_filters[hf_idx][mx];
353  const int8_t *vf = ff_vvc_inter_chroma_filters[vf_idx][my];
354  if (dmvr_flag) {
355  const int x_sb = x_off + (orig_mv->mv[i].x >> (4 + hs));
356  const int y_sb = y_off + (orig_mv->mv[i].y >> (4 + vs));
357  EMULATED_EDGE_DMVR_CHROMA(lc->edge_emu_buffer, &src, &src_stride, x_sb, y_sb, ox, oy);
358  } else {
359  EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
360  }
361  fc->vvcdsp.inter.put[CHROMA][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
362  }
363  if (weight_flag)
364  fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
365  else
366  fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
367 }
368 
369 static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
370  const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h,
371  const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
372 {
373  const VVCFrameContext *fc = lc->fc;
374  const uint8_t *src = ref->data[0];
375  ptrdiff_t src_stride = ref->linesize[0];
376  uint16_t *prof_tmp = lc->tmp + PROF_TEMP_OFFSET;
377  const int idx = av_log2(block_w) - 1;
378  const int lx = mvf->pred_flag - PF_L0;
379  const Mv *mv = mvf->mv + lx;
380  const int mx = mv->x & 0xf;
381  const int my = mv->y & 0xf;
382  const int8_t *hf = ff_vvc_inter_luma_filters[2][mx];
383  const int8_t *vf = ff_vvc_inter_luma_filters[2][my];
384  int denom, wx, ox;
385  const int weight_flag = derive_weight_uni(&denom, &wx, &ox, lc, mvf, LUMA);
386 
387  x_off += mv->x >> 4;
388  y_off += mv->y >> 4;
389  src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
390 
391  EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
392  if (cb_prof_flag) {
393  fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
394  fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
395  if (!weight_flag)
396  fc->vvcdsp.inter.apply_prof_uni(dst, dst_stride, prof_tmp, diff_mv_x, diff_mv_y);
397  else
398  fc->vvcdsp.inter.apply_prof_uni_w(dst, dst_stride, prof_tmp, diff_mv_x, diff_mv_y, denom, wx, ox);
399  } else {
400  if (!weight_flag)
401  fc->vvcdsp.inter.put_uni[LUMA][idx][!!my][!!mx](dst, dst_stride, src, src_stride, block_h, hf, vf, block_w);
402  else
403  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);
404  }
405 }
406 
407 static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
408  const AVFrame *ref0, const AVFrame *ref1, const MvField *mvf, const int x_off, const int y_off,
409  const int block_w, const int block_h)
410 {
411  const VVCFrameContext *fc = lc->fc;
412  const PredictionUnit *pu = &lc->cu->pu;
413  const AVFrame *ref[] = { ref0, ref1 };
414  int16_t *tmp[] = { lc->tmp, lc->tmp1 };
415  uint16_t *prof_tmp = lc->tmp2 + PROF_TEMP_OFFSET;
416  const int idx = av_log2(block_w) - 1;
417  int denom, w0, w1, o0, o1;
418  const int weight_flag = derive_weight(&denom, &w0, &w1, &o0, &o1, lc, mvf, LUMA, 0);
419 
420  for (int i = L0; i <= L1; i++) {
421  const Mv *mv = mvf->mv + i;
422  const int mx = mv->x & 0xf;
423  const int my = mv->y & 0xf;
424  const int ox = x_off + (mv->x >> 4);
425  const int oy = y_off + (mv->y >> 4);
426  ptrdiff_t src_stride = ref[i]->linesize[0];
427  const uint8_t *src = ref[i]->data[0] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
428  const int8_t *hf = ff_vvc_inter_luma_filters[2][mx];
429  const int8_t *vf = ff_vvc_inter_luma_filters[2][my];
430 
431  EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
432  if (!pu->cb_prof_flag[i]) {
433  fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](tmp[i], src, src_stride, block_h, hf, vf, block_w);
434  } else {
435  fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](prof_tmp, src, src_stride, AFFINE_MIN_BLOCK_SIZE, hf, vf, AFFINE_MIN_BLOCK_SIZE);
436  fc->vvcdsp.inter.fetch_samples(prof_tmp, src, src_stride, mx, my);
437  fc->vvcdsp.inter.apply_prof(tmp[i], prof_tmp, pu->diff_mv_x[i], pu->diff_mv_y[i]);
438  }
439  }
440 
441  if (weight_flag)
442  fc->vvcdsp.inter.w_avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h, denom, w0, w1, o0, o1);
443  else
444  fc->vvcdsp.inter.avg(dst, dst_stride, tmp[L0], tmp[L1], block_w, block_h);
445 }
446 
447 static int pred_get_refs(const VVCLocalContext *lc, VVCFrame *ref[2], const MvField *mv)
448 {
449  const RefPicList *rpl = lc->sc->rpl;
450 
451  for (int mask = PF_L0; mask <= PF_L1; mask++) {
452  if (mv->pred_flag & mask) {
453  const int lx = mask - PF_L0;
454  ref[lx] = rpl[lx].ref[mv->ref_idx[lx]];
455  if (!ref[lx])
456  return AVERROR_INVALIDDATA;
457  }
458  }
459  return 0;
460 }
461 
462 #define POS(c_idx, x, y) \
463  &fc->frame->data[c_idx][((y) >> fc->ps.sps->vshift[c_idx]) * fc->frame->linesize[c_idx] + \
464  (((x) >> fc->ps.sps->hshift[c_idx]) << fc->ps.sps->pixel_shift)]
465 
467 {
468  const VVCFrameContext *fc = lc->fc;
469  const CodingUnit *cu = lc->cu;
470  const PredictionUnit *pu = &cu->pu;
471 
472  const uint8_t angle_idx = ff_vvc_gpm_angle_idx[pu->gpm_partition_idx];
473  const uint8_t weights_idx = ff_vvc_gpm_angle_to_weights_idx[angle_idx];
474  const int w = av_log2(cu->cb_width) - 3;
475  const int h = av_log2(cu->cb_height) - 3;
476  const uint8_t off_x = ff_vvc_gpm_weights_offset_x[pu->gpm_partition_idx][h][w];
477  const uint8_t off_y = ff_vvc_gpm_weights_offset_y[pu->gpm_partition_idx][h][w];
478  const uint8_t mirror_type = ff_vvc_gpm_angle_to_mirror[angle_idx];
479  const uint8_t *weights;
480 
481  const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1;
482 
483  int16_t *tmp[2] = {lc->tmp, lc->tmp1};
484 
485  for (int c_idx = 0; c_idx < c_end; c_idx++) {
486  const int hs = fc->ps.sps->hshift[c_idx];
487  const int vs = fc->ps.sps->vshift[c_idx];
488  const int x = lc->cu->x0 >> hs;
489  const int y = lc->cu->y0 >> vs;
490  const int width = cu->cb_width >> hs;
491  const int height = cu->cb_height >> vs;
492  uint8_t *dst = POS(c_idx, lc->cu->x0, lc->cu->y0);
493  ptrdiff_t dst_stride = fc->frame->linesize[c_idx];
494 
495  int step_x = 1 << hs;
496  int step_y = VVC_GPM_WEIGHT_SIZE << vs;
497  if (!mirror_type) {
498  weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + off_x];
499  } else if (mirror_type == 1) {
500  step_x = -step_x;
501  weights = &ff_vvc_gpm_weights[weights_idx][off_y * VVC_GPM_WEIGHT_SIZE + VVC_GPM_WEIGHT_SIZE - 1- off_x];
502  } else {
503  step_y = -step_y;
504  weights = &ff_vvc_gpm_weights[weights_idx][(VVC_GPM_WEIGHT_SIZE - 1 - off_y) * VVC_GPM_WEIGHT_SIZE + off_x];
505  }
506 
507  for (int i = 0; i < 2; i++) {
508  const MvField *mv = pu->gpm_mv + i;
509  const int lx = mv->pred_flag - PF_L0;
510  VVCFrame *ref = lc->sc->rpl[lx].ref[mv->ref_idx[lx]];
511  if (!ref)
512  return;
513  if (c_idx)
514  chroma_mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, c_idx);
515  else
516  luma_mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height);
517  }
518  fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
519  }
520  return;
521 }
522 
523 static int ciip_derive_intra_weight(const VVCLocalContext *lc, const int x0, const int y0,
524  const int width, const int height)
525 {
526  const VVCFrameContext *fc = lc->fc;
527  const VVCSPS *sps = fc->ps.sps;
528  const int x0b = av_mod_uintp2(x0, sps->ctb_log2_size_y);
529  const int y0b = av_mod_uintp2(y0, sps->ctb_log2_size_y);
530  const int available_l = lc->ctb_left_flag || x0b;
531  const int available_u = lc->ctb_up_flag || y0b;
532  const int min_pu_width = fc->ps.pps->min_pu_width;
533 
534  int w = 1;
535 
536  if (available_u &&fc->tab.mvf[((y0 - 1) >> MIN_PU_LOG2) * min_pu_width + ((x0 - 1 + width)>> MIN_PU_LOG2)].pred_flag == PF_INTRA)
537  w++;
538 
539  if (available_l && fc->tab.mvf[((y0 - 1 + height)>> MIN_PU_LOG2) * min_pu_width + ((x0 - 1) >> MIN_PU_LOG2)].pred_flag == PF_INTRA)
540  w++;
541 
542  return w;
543 }
544 
545 static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int vf_idx, const MvField *mv,
546  const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int sb_bdof_flag)
547 {
548  const SliceContext *sc = lc->sc;
549  const VVCFrameContext *fc = lc->fc;
550  const int ciip_flag = lc->cu->ciip_flag;
551  uint8_t *dst = POS(0, x0, y0);
552  const ptrdiff_t dst_stride = fc->frame->linesize[0];
553  uint8_t *inter = ciip_flag ? (uint8_t *)lc->ciip_tmp1 : dst;
554  const ptrdiff_t inter_stride = ciip_flag ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride;
555  VVCFrame *ref[2];
556 
557  if (pred_get_refs(lc, ref, mv) < 0)
558  return;
559 
560  if (mv->pred_flag != PF_BI) {
561  const int lx = mv->pred_flag - PF_L0;
562  luma_mc_uni(lc, inter, inter_stride, ref[lx]->frame,
563  mv, x0, y0, sbw, sbh, hf_idx, vf_idx);
564  } else {
565  luma_mc_bi(lc, inter, inter_stride, ref[0]->frame,
566  &mv->mv[0], x0, y0, sbw, sbh, ref[1]->frame, &mv->mv[1], mv,
567  hf_idx, vf_idx, orig_mv, sb_bdof_flag);
568  }
569 
570  if (ciip_flag) {
571  const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
572  fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 0);
573  if (sc->sh.r->sh_lmcs_used_flag)
574  fc->vvcdsp.lmcs.filter(inter, inter_stride, sbw, sbh, &fc->ps.lmcs.fwd_lut);
575  fc->vvcdsp.inter.put_ciip(dst, dst_stride, sbw, sbh, inter, inter_stride, intra_weight);
576 
577  }
578 }
579 
581  const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int dmvr_flag)
582 {
583  const VVCFrameContext *fc = lc->fc;
584  const int hs = fc->ps.sps->hshift[1];
585  const int vs = fc->ps.sps->vshift[1];
586  const int x0_c = x0 >> hs;
587  const int y0_c = y0 >> vs;
588  const int w_c = sbw >> hs;
589  const int h_c = sbh >> vs;
590  const int do_ciip = lc->cu->ciip_flag && (w_c > 2);
591 
592  uint8_t* dst1 = POS(1, x0, y0);
593  uint8_t* dst2 = POS(2, x0, y0);
594  const ptrdiff_t dst1_stride = fc->frame->linesize[1];
595  const ptrdiff_t dst2_stride = fc->frame->linesize[2];
596 
597  uint8_t *inter1 = do_ciip ? (uint8_t *)lc->ciip_tmp1 : dst1;
598  const ptrdiff_t inter1_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst1_stride;
599 
600  uint8_t *inter2 = do_ciip ? (uint8_t *)lc->ciip_tmp2 : dst2;
601  const ptrdiff_t inter2_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst2_stride;
602 
603  //fix me
604  const int hf_idx = 0;
605  const int vf_idx = 0;
606  VVCFrame *ref[2];
607 
608  if (pred_get_refs(lc, ref, mv) < 0)
609  return;
610 
611  if (mv->pred_flag != PF_BI) {
612  const int lx = mv->pred_flag - PF_L0;
613  if (!ref[lx])
614  return;
615 
616  chroma_mc_uni(lc, inter1, inter1_stride, ref[lx]->frame->data[1], ref[lx]->frame->linesize[1],
617  x0_c, y0_c, w_c, h_c, mv, CB, hf_idx, vf_idx);
618  chroma_mc_uni(lc, inter2, inter2_stride, ref[lx]->frame->data[2], ref[lx]->frame->linesize[2],
619  x0_c, y0_c, w_c, h_c, mv, CR, hf_idx, vf_idx);
620  } else {
621  if (!ref[0] || !ref[1])
622  return;
623 
624  chroma_mc_bi(lc, inter1, inter1_stride, ref[0]->frame, ref[1]->frame,
625  x0_c, y0_c, w_c, h_c, mv, CB, hf_idx, vf_idx, orig_mv, dmvr_flag, lc->cu->ciip_flag);
626 
627  chroma_mc_bi(lc, inter2, inter2_stride, ref[0]->frame, ref[1]->frame,
628  x0_c, y0_c, w_c, h_c, mv, CR, hf_idx, vf_idx, orig_mv, dmvr_flag, lc->cu->ciip_flag);
629 
630  }
631  if (do_ciip) {
632  const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh);
633  fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 1);
634  fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 2);
635  fc->vvcdsp.inter.put_ciip(dst1, dst1_stride, w_c, h_c, inter1, inter1_stride, intra_weight);
636  fc->vvcdsp.inter.put_ciip(dst2, dst2_stride, w_c, h_c, inter2, inter2_stride, intra_weight);
637 
638  }
639 }
640 
641 // 8.5.3.5 Parametric motion vector refinement process
642 static int parametric_mv_refine(const int *sad, const int stride)
643 {
644  const int sad_minus = sad[-stride];
645  const int sad_center = sad[0];
646  const int sad_plus = sad[stride];
647  int dmvc;
648  int denom = (( sad_minus + sad_plus) - (sad_center << 1 ) ) << 3;
649  if (!denom)
650  dmvc = 0;
651  else {
652  if (sad_minus == sad_center)
653  dmvc = -8;
654  else if (sad_plus == sad_center)
655  dmvc = 8;
656  else {
657  int num = ( sad_minus - sad_plus ) * (1 << 4);
658  int sign_num = 0;
659  int quotient = 0;
660  int counter = 3;
661  if (num < 0 ) {
662  num = - num;
663  sign_num = 1;
664  }
665  while (counter > 0) {
666  counter = counter - 1;
667  quotient = quotient << 1;
668  if ( num >= denom ) {
669  num = num - denom;
670  quotient = quotient + 1;
671  }
672  denom = (denom >> 1);
673  }
674  if (sign_num == 1 )
675  dmvc = -quotient;
676  else
677  dmvc = quotient;
678  }
679  }
680  return dmvc;
681 }
682 
683 #define SAD_ARRAY_SIZE 5
684 //8.5.3 Decoder-side motion vector refinement process
685 static void dmvr_mv_refine(VVCLocalContext *lc, MvField *mvf, MvField *orig_mv, int *sb_bdof_flag,
686  const AVFrame *ref0, const AVFrame *ref1, const int x_off, const int y_off, const int block_w, const int block_h)
687 {
688  const VVCFrameContext *fc = lc->fc;
689  const int sr_range = 2;
690  const AVFrame *ref[] = { ref0, ref1 };
691  int16_t *tmp[] = { lc->tmp, lc->tmp1 };
692  int sad[SAD_ARRAY_SIZE][SAD_ARRAY_SIZE];
693  int min_dx, min_dy, min_sad, dx, dy;
694 
695  *orig_mv = *mvf;
696  min_dx = min_dy = dx = dy = 2;
697 
698  for (int i = L0; i <= L1; i++) {
699  const int pred_w = block_w + 2 * sr_range;
700  const int pred_h = block_h + 2 * sr_range;
701  const Mv *mv = mvf->mv + i;
702  const int mx = mv->x & 0xf;
703  const int my = mv->y & 0xf;
704  const int ox = x_off + (mv->x >> 4) - sr_range;
705  const int oy = y_off + (mv->y >> 4) - sr_range;
706  ptrdiff_t src_stride = ref[i]->linesize[LUMA];
707  const uint8_t *src = ref[i]->data[LUMA] + oy * src_stride + (ox * (1 << fc->ps.sps->pixel_shift));
708  EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, &src, &src_stride, ox, oy);
709  fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, my, pred_w);
710  }
711 
712  min_sad = fc->vvcdsp.inter.sad(tmp[L0], tmp[L1], dx, dy, block_w, block_h);
713  min_sad -= min_sad >> 2;
714  sad[dy][dx] = min_sad;
715 
716  if (min_sad >= block_w * block_h) {
717  int dmv[2];
718  // 8.5.3.4 Array entry selection process
719  for (dy = 0; dy < SAD_ARRAY_SIZE; dy++) {
720  for (dx = 0; dx < SAD_ARRAY_SIZE; dx++) {
721  if (dx != sr_range || dy != sr_range) {
722  sad[dy][dx] = fc->vvcdsp.inter.sad(lc->tmp, lc->tmp1, dx, dy, block_w, block_h);
723  if (sad[dy][dx] < min_sad) {
724  min_sad = sad[dy][dx];
725  min_dx = dx;
726  min_dy = dy;
727  }
728  }
729  }
730  }
731  dmv[0] = (min_dx - sr_range) * (1 << 4);
732  dmv[1] = (min_dy - sr_range) * (1 << 4);
733  if (min_dx != 0 && min_dx != 4 && min_dy != 0 && min_dy != 4) {
734  dmv[0] += parametric_mv_refine(&sad[min_dy][min_dx], 1);
735  dmv[1] += parametric_mv_refine(&sad[min_dy][min_dx], SAD_ARRAY_SIZE);
736  }
737 
738  for (int i = L0; i <= L1; i++) {
739  Mv *mv = mvf->mv + i;
740  mv->x += (1 - 2 * i) * dmv[0];
741  mv->y += (1 - 2 * i) * dmv[1];
743  }
744  }
745  if (min_sad < 2 * block_w * block_h) {
746  *sb_bdof_flag = 0;
747  }
748 }
749 
750 static void set_dmvr_info(VVCFrameContext *fc, const int x0, const int y0,
751  const int width, const int height, const MvField *mvf)
752 
753 {
754  const VVCPPS *pps = fc->ps.pps;
755 
756  for (int y = y0; y < y0 + height; y += MIN_PU_SIZE) {
757  for (int x = x0; x < x0 + width; x += MIN_PU_SIZE) {
758  const int idx = pps->min_pu_width * (y >> MIN_PU_LOG2) + (x >> MIN_PU_LOG2);
759  fc->ref->tab_dmvr_mvf[idx] = *mvf;
760  }
761  }
762 }
763 
764 static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int *sb_bdof_flag,
765  const int x0, const int y0, const int sbw, const int sbh)
766 {
767  VVCFrameContext *fc = lc->fc;
768  const PredictionUnit *pu = &lc->cu->pu;
769 
770  *orig_mv = *mv = *ff_vvc_get_mvf(fc, x0, y0);
771  if (pu->bdof_flag)
772  *sb_bdof_flag = 1;
773  if (pu->dmvr_flag) {
774  VVCFrame* ref[2];
775  if (pred_get_refs(lc, ref, mv) < 0)
776  return;
777  dmvr_mv_refine(lc, mv, orig_mv, sb_bdof_flag, ref[0]->frame, ref[1]->frame, x0, y0, sbw, sbh);
778  set_dmvr_info(fc, x0, y0, sbw, sbh, mv);
779  }
780 }
781 
782 static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip)
783 {
784  const VVCFrameContext *fc = lc->fc;
785  const CodingUnit *cu = lc->cu;
786  PredictionUnit *pu = &lc->cu->pu;
787  const MotionInfo *mi = &pu->mi;
788  MvField mv, orig_mv;
789  int sbw, sbh, sb_bdof_flag = 0;
790 
791  if (cu->ciip_flag && skip_ciip)
792  return;
793 
794  sbw = cu->cb_width / mi->num_sb_x;
795  sbh = cu->cb_height / mi->num_sb_y;
796 
797  for (int sby = 0; sby < mi->num_sb_y; sby++) {
798  for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
799  const int x0 = cu->x0 + sbx * sbw;
800  const int y0 = cu->y0 + sby * sbh;
801 
802  if (cu->ciip_flag)
803  ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh);
804 
805  derive_sb_mv(lc, &mv, &orig_mv, &sb_bdof_flag, x0, y0, sbw, sbh);
806  pred_regular_luma(lc, mi->hpel_if_idx, mi->hpel_if_idx, &mv, x0, y0, sbw, sbh, &orig_mv, sb_bdof_flag);
807  if (fc->ps.sps->r->sps_chroma_format_idc)
808  pred_regular_chroma(lc, &mv, x0, y0, sbw, sbh, &orig_mv, pu->dmvr_flag);
809  }
810  }
811 }
812 
813 static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, const MvField *mv,
814  const int x0, const int y0, const int sbw, const int sbh)
815 {
816  const int hs = fc->ps.sps->hshift[1];
817  const int vs = fc->ps.sps->vshift[1];
818  const MvField* mv2 = ff_vvc_get_mvf(fc, x0 + hs * sbw, y0 + vs * sbh);
819  *mvc = *mv;
820 
821  // Due to different pred_flag, one of the motion vectors may have an invalid value.
822  // Cast them to an unsigned type to avoid undefined behavior.
823  mvc->mv[0].x += (unsigned int)mv2->mv[0].x;
824  mvc->mv[0].y += (unsigned int)mv2->mv[0].y;
825  mvc->mv[1].x += (unsigned int)mv2->mv[1].x;
826  mvc->mv[1].y += (unsigned int)mv2->mv[1].y;
827  ff_vvc_round_mv(mvc->mv + 0, 0, 1);
828  ff_vvc_round_mv(mvc->mv + 1, 0, 1);
829 }
830 
832 {
833  const VVCFrameContext *fc = lc->fc;
834  const CodingUnit *cu = lc->cu;
835  const PredictionUnit *pu = &cu->pu;
836  const MotionInfo *mi = &pu->mi;
837  const int x0 = cu->x0;
838  const int y0 = cu->y0;
839  const int sbw = cu->cb_width / mi->num_sb_x;
840  const int sbh = cu->cb_height / mi->num_sb_y;
841  const int hs = fc->ps.sps->hshift[1];
842  const int vs = fc->ps.sps->vshift[1];
843 
844  for (int sby = 0; sby < mi->num_sb_y; sby++) {
845  for (int sbx = 0; sbx < mi->num_sb_x; sbx++) {
846  const int x = x0 + sbx * sbw;
847  const int y = y0 + sby * sbh;
848 
849  uint8_t *dst0 = POS(0, x, y);
850  const MvField *mv = ff_vvc_get_mvf(fc, x, y);
851  VVCFrame *ref[2];
852 
853  if (pred_get_refs(lc, ref, mv) < 0)
854  return;
855 
856  if (mi->pred_flag != PF_BI) {
857  const int lx = mi->pred_flag - PF_L0;
858  luma_prof_uni(lc, dst0, fc->frame->linesize[0], ref[lx]->frame,
859  mv, x, y, sbw, sbh, pu->cb_prof_flag[lx],
860  pu->diff_mv_x[lx], pu->diff_mv_y[lx]);
861  } else {
862  luma_prof_bi(lc, dst0, fc->frame->linesize[0], ref[0]->frame, ref[1]->frame,
863  mv, x, y, sbw, sbh);
864  }
865  if (fc->ps.sps->r->sps_chroma_format_idc) {
866  if (!av_mod_uintp2(sby, vs) && !av_mod_uintp2(sbx, hs)) {
867  MvField mvc;
868  derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh);
869  pred_regular_chroma(lc, &mvc, x, y, sbw<<hs, sbh<<vs, NULL, 0);
870 
871  }
872  }
873 
874  }
875  }
876 }
877 
879 {
880  const VVCFrameContext *fc = lc->fc;
881  const CodingUnit *cu = lc->cu;
882  const PredictionUnit *pu = &cu->pu;
883 
884  if (pu->merge_gpm_flag)
885  pred_gpm_blk(lc);
886  else if (pu->inter_affine_flag)
887  pred_affine_blk(lc);
888  else
889  pred_regular_blk(lc, 1); //intra block is not ready yet, skip ciip
890 
891  if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) {
892  uint8_t* dst0 = POS(0, cu->x0, cu->y0);
893  fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, &fc->ps.lmcs.fwd_lut);
894  }
895 }
896 
897 static int has_inter_luma(const CodingUnit *cu)
898 {
899  return (cu->pred_mode == MODE_INTER || cu->pred_mode == MODE_SKIP) && cu->tree_type != DUAL_TREE_CHROMA;
900 }
901 
902 int ff_vvc_predict_inter(VVCLocalContext *lc, const int rs)
903 {
904  const VVCFrameContext *fc = lc->fc;
905  const CTU *ctu = fc->tab.ctus + rs;
906  CodingUnit *cu = ctu->cus;
907 
908  while (cu) {
909  lc->cu = cu;
910  if (has_inter_luma(cu))
911  predict_inter(lc);
912  cu = cu->next;
913  }
914 
915  return 0;
916 }
917 
919 {
920  av_assert0(lc->cu->ciip_flag);
921 
922  //todo: refact out ciip from pred_regular_blk
923  pred_regular_blk(lc, 0);
924 }
925 
926 #undef POS
ff_vvc_gpm_weights
const uint8_t ff_vvc_gpm_weights[6][VVC_GPM_WEIGHT_SIZE *VVC_GPM_WEIGHT_SIZE]
Definition: vvc_data.c:2801
CHROMA_EXTRA_AFTER
#define CHROMA_EXTRA_AFTER
Definition: vvc_ctu.h:52
CB
#define CB
Definition: hevc_filter.c:32
EMULATED_EDGE_DMVR_LUMA
#define EMULATED_EDGE_DMVR_LUMA(dst, src, src_stride, x_sb, y_sb, x_off, y_off)
Definition: vvc_inter.c:119
VVCSPS
Definition: vvc_ps.h:58
L1
F H1 F F H1 F F F F H1<-F-------F-------F v v v H2 H3 H2 ^ ^ ^ F-------F-------F-> H1<-F-------F-------F|||||||||F H1 F|||||||||F H1 Funavailable fullpel samples(outside the picture for example) shall be equalto the closest available fullpel sampleSmaller pel interpolation:--------------------------if diag_mc is set then points which lie on a line between 2 vertically, horizontally or diagonally adjacent halfpel points shall be interpolatedlinearly with rounding to nearest and halfway values rounded up.points which lie on 2 diagonals at the same time should only use the onediagonal not containing the fullpel point F--> O q O<--h1-> O q O<--F v \/v \/v O O O O O O O|/|\|q q q q q|/|\|O O O O O O O ^/\ ^/\ ^ h2--> O q O<--h3-> O q O<--h2 v \/v \/v O O O O O O O|\|/|q q q q q|\|/|O O O O O O O ^/\ ^/\ ^ F--> O q O<--h1-> O q O<--Fthe remaining points shall be bilinearly interpolated from theup to 4 surrounding halfpel and fullpel points, again rounding should be tonearest and halfway values rounded upcompliant Snow decoders MUST support 1-1/8 pel luma and 1/2-1/16 pel chromainterpolation at leastOverlapped block motion compensation:-------------------------------------FIXMELL band prediction:===================Each sample in the LL0 subband is predicted by the median of the left, top andleft+top-topleft samples, samples outside the subband shall be considered tobe 0. To reverse this prediction in the decoder apply the following.for(y=0;y< height;y++){ for(x=0;x< width;x++){ sample[y][x]+=median(sample[y-1][x], sample[y][x-1], sample[y-1][x]+sample[y][x-1]-sample[y-1][x-1]);}}sample[-1][ *]=sample[ *][-1]=0;width, height here are the width and height of the LL0 subband not of the finalvideoDequantization:===============FIXMEWavelet Transform:==================Snow supports 2 wavelet transforms, the symmetric biorthogonal 5/3 integertransform and an integer approximation of the symmetric biorthogonal 9/7daubechies wavelet.2D IDWT(inverse discrete wavelet transform) --------------------------------------------The 2D IDWT applies a 2D filter recursively, each time combining the4 lowest frequency subbands into a single subband until only 1 subbandremains.The 2D filter is done by first applying a 1D filter in the vertical directionand then applying it in the horizontal one. --------------- --------------- --------------- ---------------|LL0|HL0|||||||||||||---+---|HL1||L0|H0|HL1||LL1|HL1|||||LH0|HH0|||||||||||||-------+-------|-> L1 H1 LH1 HH1 LH1 HH1 LH1 HH1 L1
Definition: snow.txt:554
VVCPPS
Definition: vvc_ps.h:92
has_inter_luma
static int has_inter_luma(const CodingUnit *cu)
Definition: vvc_inter.c:897
emulated_edge_dmvr
static void emulated_edge_dmvr(const VVCFrameContext *fc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride, const int x_sb, const int y_sb, const int x_off, const int y_off, const int block_w, const int block_h, const int is_luma)
Definition: vvc_inter.c:60
MotionInfo
Definition: vvc_ctu.h:236
PROF_TEMP_OFFSET
#define PROF_TEMP_OFFSET
Definition: vvc_inter.c:30
pred_regular_luma
static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int vf_idx, const MvField *mv, const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int sb_bdof_flag)
Definition: vvc_inter.c:545
ff_vvc_get_mvf
MvField * ff_vvc_get_mvf(const VVCFrameContext *fc, const int x0, const int y0)
Definition: vvc_mvs.c:1911
CodingUnit
Definition: hevcdec.h:282
mv
static const int8_t mv[256][2]
Definition: 4xm.c:80
ff_vvc_predict_inter
int ff_vvc_predict_inter(VVCLocalContext *lc, const int rs)
Loop entire CTU to predict all inter coding blocks.
Definition: vvc_inter.c:902
PredictionUnit::gpm_partition_idx
uint8_t gpm_partition_idx
Definition: vvc_ctu.h:258
VVCLocalContext::tmp
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
Definition: vvc_ctu.h:380
MIN_PU_LOG2
#define MIN_PU_LOG2
Definition: vvcdec.h:40
av_mod_uintp2
#define av_mod_uintp2
Definition: common.h:125
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
w
uint8_t w
Definition: llviddspenc.c:38
VVCLocalContext::sc
SliceContext * sc
Definition: vvc_ctu.h:430
ff_vvc_gpm_angle_idx
const uint8_t ff_vvc_gpm_angle_idx[VVC_GPM_NUM_PARTITION]
Definition: vvc_data.c:1998
CHROMA_EXTRA_BEFORE
#define CHROMA_EXTRA_BEFORE
Definition: h2656_inter_template.c:24
Mv::y
int16_t y
vertical component of motion vector
Definition: hevcdec.h:297
VVCSH::r
const H266RawSliceHeader * r
RefStruct reference.
Definition: vvc_ps.h:225
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:472
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
EMULATED_EDGE_BILINEAR
#define EMULATED_EDGE_BILINEAR(dst, src, src_stride, x_off, y_off)
Definition: vvc_inter.c:125
RefPicList
Definition: hevcdec.h:189
ff_vvc_gpm_angle_to_weights_idx
const uint8_t ff_vvc_gpm_angle_to_weights_idx[VVC_GPM_NUM_ANGLES]
Definition: vvc_data.c:2021
PF_INTRA
@ PF_INTRA
Definition: hevcdec.h:113
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:365
luma_prof_uni
static void luma_prof_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h, const int cb_prof_flag, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
Definition: vvc_inter.c:369
MODE_SKIP
@ MODE_SKIP
Definition: hevcdec.h:103
EMULATED_EDGE_CHROMA
#define EMULATED_EDGE_CHROMA(dst, src, src_stride, x_off, y_off)
Definition: vvc_inter.c:116
PredictionUnit::gpm_mv
MvField gpm_mv[2]
Definition: vvc_ctu.h:259
vvc_data.h
VVCLocalContext::fc
VVCFrameContext * fc
Definition: vvc_ctu.h:431
VVCSH::pwt
PredWeightTable pwt
Definition: vvc_ps.h:233
PredictionUnit
Definition: hevcdec.h:315
MODE_INTER
@ MODE_INTER
Definition: hevcdec.h:101
VVCLocalContext::tmp1
int16_t tmp1[MAX_PB_SIZE *MAX_PB_SIZE]
Definition: vvc_ctu.h:381
vvc_refs.h
SliceContext::rpl
RefPicList * rpl
Definition: vvcdec.h:88
luma_mc
static void luma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv, int x_off, int y_off, const int block_w, const int block_h)
Definition: vvc_inter.c:179
CodingUnit::cb_width
int cb_width
Definition: vvc_ctu.h:278
ff_vvc_inter_chroma_filters
const int8_t ff_vvc_inter_chroma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_CHROMA_FACTS][VVC_INTER_CHROMA_TAPS]
Definition: vvc_data.c:1798
CodingUnit::pu
PredictionUnit pu
Definition: vvc_ctu.h:323
chroma_mc_bi
static void chroma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const AVFrame *ref0, const AVFrame *ref1, const int x_off, const int y_off, const int block_w, const int block_h, const MvField *mvf, const int c_idx, const int hf_idx, const int vf_idx, const MvField *orig_mv, const int dmvr_flag, const int ciip_flag)
Definition: vvc_inter.c:330
EMULATED_EDGE_DMVR_CHROMA
#define EMULATED_EDGE_DMVR_CHROMA(dst, src, src_stride, x_sb, y_sb, x_off, y_off)
Definition: vvc_inter.c:122
mask
static const uint16_t mask[17]
Definition: lzw.c:38
width
#define width
luma_prof_bi
static void luma_prof_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const AVFrame *ref0, const AVFrame *ref1, const MvField *mvf, const int x_off, const int y_off, const int block_w, const int block_h)
Definition: vvc_inter.c:407
mi
#define mi
Definition: vf_colormatrix.c:106
emulated_edge_bilinear
static void emulated_edge_bilinear(const VVCFrameContext *fc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride, const int x_off, const int y_off, const int block_w, const int block_h)
Definition: vvc_inter.c:91
vvc_mvs.h
EMULATED_EDGE_LUMA
#define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off)
Definition: vvc_inter.c:113
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
luma_mc_bi
static void luma_mc_bi(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const AVFrame *ref0, const Mv *mv0, const int x_off, const int y_off, const int block_w, const int block_h, const AVFrame *ref1, const Mv *mv1, const MvField *mvf, const int hf_idx, const int vf_idx, const MvField *orig_mv, const int sb_bdof_flag)
Definition: vvc_inter.c:253
VVCSH
Definition: vvc_ps.h:224
PredWeightTable
Definition: vvc_ps.h:133
RefPicList::ref
struct HEVCFrame * ref[HEVC_MAX_REFS]
Definition: hevcdec.h:190
CodingUnit::tree_type
VVCTreeType tree_type
Definition: vvc_ctu.h:275
LUMA_EXTRA
#define LUMA_EXTRA
Definition: h2656_inter_template.c:27
bcw_w_lut
static const int bcw_w_lut[]
Definition: vvc_inter.c:31
PredictionUnit::bdof_flag
uint8_t bdof_flag
Definition: vvc_ctu.h:267
derive_weight
static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1, const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int dmvr_flag)
Definition: vvc_inter.c:149
pred_regular_chroma
static void pred_regular_chroma(VVCLocalContext *lc, const MvField *mv, const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int dmvr_flag)
Definition: vvc_inter.c:580
frame
static AVFrame * frame
Definition: demux_decode.c:54
H266RawSliceHeader::sh_lmcs_used_flag
uint8_t sh_lmcs_used_flag
Definition: cbs_h266.h:792
LUMA_EXTRA_AFTER
#define LUMA_EXTRA_AFTER
Definition: vvc_ctu.h:55
CTU
Definition: vvc_ctu.h:328
ciip_derive_intra_weight
static int ciip_derive_intra_weight(const VVCLocalContext *lc, const int x0, const int y0, const int width, const int height)
Definition: vvc_inter.c:523
NULL
#define NULL
Definition: coverity.c:32
VVCLocalContext
Definition: vvc_ctu.h:368
luma_mc_uni
static void luma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const AVFrame *ref, const MvField *mvf, int x_off, int y_off, const int block_w, const int block_h, const int hf_idx, const int vf_idx)
Definition: vvc_inter.c:222
L0
#define L0
Definition: hevcdec.h:57
SAD_ARRAY_SIZE
#define SAD_ARRAY_SIZE
Definition: vvc_inter.c:683
LUMA_EXTRA_BEFORE
#define LUMA_EXTRA_BEFORE
Definition: h2656_inter_template.c:26
parametric_mv_refine
static int parametric_mv_refine(const int *sad, const int stride)
Definition: vvc_inter.c:642
Mv::x
int16_t x
horizontal component of motion vector
Definition: hevcdec.h:296
PF_BI
@ PF_BI
Definition: hevcdec.h:116
derive_weight_uni
static int derive_weight_uni(int *denom, int *wx, int *ox, const VVCLocalContext *lc, const MvField *mvf, const int c_idx)
Definition: vvc_inter.c:129
SliceContext
Definition: mss12.h:70
chroma_mc
static void chroma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv, int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
Definition: vvc_inter.c:200
DUAL_TREE_CHROMA
@ DUAL_TREE_CHROMA
Definition: vvc_ctu.h:164
pps
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Definition: cbs_h264_syntax_template.c:404
pred_gpm_blk
static void pred_gpm_blk(VVCLocalContext *lc)
Definition: vvc_inter.c:466
AFFINE_MIN_BLOCK_SIZE
#define AFFINE_MIN_BLOCK_SIZE
Definition: vvc_ctu.h:63
PredictionUnit::merge_gpm_flag
uint8_t merge_gpm_flag
Definition: vvc_ctu.h:257
PredictionUnit::cb_prof_flag
int cb_prof_flag[2]
Definition: vvc_ctu.h:271
CR
#define CR
Definition: hevc_filter.c:33
MvField
Definition: hevcdec.h:300
frame.h
derive_sb_mv
static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int *sb_bdof_flag, const int x0, const int y0, const int sbw, const int sbh)
Definition: vvc_inter.c:764
PF_L1
@ PF_L1
Definition: hevcdec.h:115
VVCLocalContext::ctb_up_flag
uint8_t ctb_up_flag
Definition: vvc_ctu.h:370
PredictionUnit::diff_mv_x
int16_t diff_mv_x[2][AFFINE_MIN_BLOCK_SIZE *AFFINE_MIN_BLOCK_SIZE]
diffMvLX
Definition: vvc_ctu.h:269
VVCFrame
Definition: vvcdec.h:56
VVCLocalContext::edge_emu_buffer
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
Definition: vvc_ctu.h:377
height
#define height
pred_affine_blk
static void pred_affine_blk(VVCLocalContext *lc)
Definition: vvc_inter.c:831
VVC_GPM_WEIGHT_SIZE
#define VVC_GPM_WEIGHT_SIZE
Definition: vvc_data.h:64
ff_vvc_gpm_weights_offset_x
const uint8_t ff_vvc_gpm_weights_offset_x[VVC_GPM_NUM_PARTITION][4][4]
Definition: vvc_data.c:2027
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
MIN_PU_SIZE
#define MIN_PU_SIZE
Definition: vvc_ctu.h:40
MvField::pred_flag
int8_t pred_flag
Definition: hevcdec.h:303
pred_h
static void FUNC() pred_h(uint8_t *_src, const uint8_t *_left, const int w, const int h, const ptrdiff_t stride)
Definition: vvc_intra_template.c:877
PredictionUnit::mi
MotionInfo mi
Definition: vvc_ctu.h:263
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
MAX_PB_SIZE
#define MAX_PB_SIZE
Definition: hevcdsp.h:32
weights
static const int weights[]
Definition: hevc_pel.c:32
VVCLocalContext::ciip_tmp2
uint8_t ciip_tmp2[MAX_PB_SIZE *MAX_PB_SIZE *2]
Definition: vvc_ctu.h:384
IS_B
#define IS_B(rsh)
Definition: vvc_ps.h:40
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
PF_L0
@ PF_L0
Definition: hevcdec.h:114
EDGE_EMU_BUFFER_STRIDE
#define EDGE_EMU_BUFFER_STRIDE
Definition: hevcdec.h:67
chroma_mc_uni
static void chroma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int x_off, int y_off, const int block_w, const int block_h, const MvField *mvf, const int c_idx, const int hf_idx, const int vf_idx)
Definition: vvc_inter.c:298
CodingUnit::x0
int x0
Definition: vvc_ctu.h:276
ff_vvc_set_neighbour_available
void ff_vvc_set_neighbour_available(VVCLocalContext *lc, const int x0, const int y0, const int w, const int h)
Definition: vvc_ctu.c:2501
dmvr_mv_refine
static void dmvr_mv_refine(VVCLocalContext *lc, MvField *mvf, MvField *orig_mv, int *sb_bdof_flag, const AVFrame *ref0, const AVFrame *ref1, const int x_off, const int y_off, const int block_w, const int block_h)
Definition: vvc_inter.c:685
VVCLocalContext::cu
CodingUnit * cu
Definition: vvc_ctu.h:416
stride
#define stride
Definition: h264pred_template.c:537
ff_vvc_clip_mv
void ff_vvc_clip_mv(Mv *mv)
Definition: vvc_mvs.c:1851
CHROMA_EXTRA
#define CHROMA_EXTRA
Definition: h2656_inter_template.c:25
PredictionUnit::dmvr_flag
uint8_t dmvr_flag
Definition: vvc_ctu.h:266
derive_affine_mvc
static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, const MvField *mv, const int x0, const int y0, const int sbw, const int sbh)
Definition: vvc_inter.c:813
ff_vvc_predict_ciip
void ff_vvc_predict_ciip(VVCLocalContext *lc)
CIIP(Combined Inter-Intra Prediction) for a coding block.
Definition: vvc_inter.c:918
CHROMA
@ CHROMA
Definition: vf_waveform.c:49
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
PredictionUnit::inter_affine_flag
uint8_t inter_affine_flag
Definition: vvc_ctu.h:252
CodingUnit::cb_height
int cb_height
Definition: vvc_ctu.h:279
ff_vvc_gpm_angle_to_mirror
const uint8_t ff_vvc_gpm_angle_to_mirror[VVC_GPM_NUM_ANGLES]
Definition: vvc_data.c:2016
BILINEAR_EXTRA_AFTER
#define BILINEAR_EXTRA_AFTER
Definition: vvc_ctu.h:58
IS_P
#define IS_P(rsh)
Definition: vvc_ps.h:39
predict_inter
static void predict_inter(VVCLocalContext *lc)
Definition: vvc_inter.c:878
ff_vvc_round_mv
void ff_vvc_round_mv(Mv *mv, const int lshift, const int rshift)
Definition: vvc_mvs.c:1839
CodingUnit::pred_mode
enum PredMode pred_mode
PredMode.
Definition: hevcdec.h:286
VVCLocalContext::tmp2
int16_t tmp2[MAX_PB_SIZE *MAX_PB_SIZE]
Definition: vvc_ctu.h:382
ff_vvc_gpm_weights_offset_y
const uint8_t ff_vvc_gpm_weights_offset_y[VVC_GPM_NUM_PARTITION][4][4]
Definition: vvc_data.c:2414
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
VVCLocalContext::ciip_tmp1
uint8_t ciip_tmp1[MAX_PB_SIZE *MAX_PB_SIZE *2]
Definition: vvc_ctu.h:383
BILINEAR_EXTRA_BEFORE
#define BILINEAR_EXTRA_BEFORE
Definition: vvc_ctu.h:57
pred_regular_blk
static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip)
Definition: vvc_inter.c:782
PredictionUnit::diff_mv_y
int16_t diff_mv_y[2][AFFINE_MIN_BLOCK_SIZE *AFFINE_MIN_BLOCK_SIZE]
diffMvLX
Definition: vvc_ctu.h:270
CodingUnit::next
struct CodingUnit * next
RefStruct reference.
Definition: vvc_ctu.h:325
MvField::mv
Mv mv[2]
mvL0, vvL1
Definition: hevcdec.h:301
Mv
Definition: hevcdec.h:295
MvField::ref_idx
int8_t ref_idx[2]
refIdxL0, refIdxL1
Definition: hevcdec.h:302
CTU::cus
CodingUnit * cus
Definition: vvc_ctu.h:329
ff_vvc_inter_luma_filters
const int8_t ff_vvc_inter_luma_filters[VVC_INTER_FILTER_TYPES][VVC_INTER_LUMA_FACTS][VVC_INTER_LUMA_TAPS]
Definition: vvc_data.c:1735
BILINEAR_EXTRA
#define BILINEAR_EXTRA
Definition: vvc_ctu.h:59
POS
#define POS(c_idx, x, y)
Definition: vvc_inter.c:462
SliceContext::sh
VVCSH sh
Definition: vvcdec.h:85
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
VVCFrameContext
Definition: vvcdec.h:92
MvField::bcw_idx
uint8_t bcw_idx
bcwIdx
Definition: vvc_ctu.h:199
pred_get_refs
static int pred_get_refs(const VVCLocalContext *lc, VVCFrame *ref[2], const MvField *mv)
Definition: vvc_inter.c:447
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
h
h
Definition: vp9dsp_template.c:2038
emulated_edge
static int emulated_edge(const VVCFrameContext *fc, uint8_t *dst, const uint8_t **src, ptrdiff_t *src_stride, const int x_off, const int y_off, const int block_w, const int block_h, const int is_luma)
Definition: vvc_inter.c:33
int
int
Definition: ffmpeg_filter.c:409
CodingUnit::ciip_flag
uint8_t ciip_flag
Definition: vvc_ctu.h:299
set_dmvr_info
static void set_dmvr_info(VVCFrameContext *fc, const int x0, const int y0, const int width, const int height, const MvField *mvf)
Definition: vvc_inter.c:750
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
w_c
static int w_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int w, int h, int type)
Definition: snow_dwt.c:743
LUMA
#define LUMA
Definition: hevc_filter.c:31
VVCLocalContext::ctb_left_flag
uint8_t ctb_left_flag
Definition: vvc_ctu.h:369
CodingUnit::y0
int y0
Definition: vvc_ctu.h:277
vvc_inter.h