History

avcodec/vvcdec: refact, unify {luma, chroma}_mc to mc

Nuo Mi committed 2 years ago

Commit bc099af1 parent 1289da91 file · +14 −33Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vvc/inter.c+14−33
@@ -142,6 +142,8 @@ static void emulated_edge_bilinear(const VVCLocalContext *lc, uint8_t *dst, cons · 141 unmodified lines
142142 }
143143 }
144144
145+#define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off) \
146+ emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, is_chroma)
145147
146148 #define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off) \
147149 emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, 0)
@@ -209,47 +211,29 @@ static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1, · 61 unmodified lines
209211 return 1;
210212 }
211213
212−static void luma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
213− int x_off, int y_off, const int block_w, const int block_h)
214−{
215− const VVCFrameContext *fc = lc->fc;
216− const uint8_t *src = ref->data[0];
217− ptrdiff_t src_stride = ref->linesize[0];
218− const int idx = av_log2(block_w) - 1;
219− const int mx = mv->x & 0xf;
220− const int my = mv->y & 0xf;
221− const int8_t *hf = ff_vvc_inter_luma_filters[0][mx];
222− const int8_t *vf = ff_vvc_inter_luma_filters[0][my];
223−
224− x_off += mv->x >> 4;
225− y_off += mv->y >> 4;
226− src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
227−
228− EMULATED_EDGE_LUMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
229−
230− fc->vvcdsp.inter.put[LUMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
231−}
214+#define INTER_FILTER(t, frac) (is_chroma ? ff_vvc_inter_chroma_filters[t][frac] : ff_vvc_inter_luma_filters[t][frac])
232215
233−static void chroma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
216+static void mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
234217 int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
235218 {
236219 const VVCFrameContext *fc = lc->fc;
237220 const uint8_t *src = ref->data[c_idx];
238221 ptrdiff_t src_stride = ref->linesize[c_idx];
239− int hs = fc->ps.sps->hshift[c_idx];
240− int vs = fc->ps.sps->vshift[c_idx];
222+ const int is_chroma = !!c_idx;
223+ const int hs = fc->ps.sps->hshift[c_idx];
224+ const int vs = fc->ps.sps->vshift[c_idx];
241225 const int idx = av_log2(block_w) - 1;
242− const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);
243− const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);
244− const int8_t *hf = ff_vvc_inter_chroma_filters[0][mx];
245− const int8_t *vf = ff_vvc_inter_chroma_filters[0][my];
226+ const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - hs);
227+ const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
228+ const int8_t *hf = INTER_FILTER(0, mx);
229+ const int8_t *vf = INTER_FILTER(0, my);
246230
247231 x_off += mv->x >> (4 + hs);
248232 y_off += mv->y >> (4 + vs);
249233 src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
250234
251− EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
252− fc->vvcdsp.inter.put[CHROMA][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
235+ MC_EMULATED_EDGE(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);
236+ fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
253237 }
254238
255239 static void luma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,
@@ -543,10 +527,7 @@ static void pred_gpm_blk(VVCLocalContext *lc) · 287 unmodified lines
543527 VVCFrame *ref = lc->sc->rpl[lx].ref[mv->ref_idx[lx]];
544528 if (!ref)
545529 return;
546− if (c_idx)
547− chroma_mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, c_idx);
548− else
549− luma_mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height);
530+ mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, c_idx);
550531 }
551532 fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
552533 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t