History

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

Nuo Mi committed 2 years ago

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

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
142 }142 }
143}143}
144 144
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)
145 147
146#define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off) \148#define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off) \
147 emulated_edge(lc, dst, src, src_stride, x_off, y_off, block_w, block_h, 0)149 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
209 return 1;211 return 1;
210}212}
211 213
212static void luma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,214#define INTER_FILTER(t, frac) (is_chroma ? ff_vvc_inter_chroma_filters[t][frac] : ff_vvc_inter_luma_filters[t][frac])
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}
232 215
233static void chroma_mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,216static void mc(VVCLocalContext *lc, int16_t *dst, const AVFrame *ref, const Mv *mv,
234 int x_off, int y_off, const int block_w, const int block_h, const int c_idx)217 int x_off, int y_off, const int block_w, const int block_h, const int c_idx)
235{218{
236 const VVCFrameContext *fc = lc->fc;219 const VVCFrameContext *fc = lc->fc;
237 const uint8_t *src = ref->data[c_idx];220 const uint8_t *src = ref->data[c_idx];
238 ptrdiff_t src_stride = ref->linesize[c_idx];221 ptrdiff_t src_stride = ref->linesize[c_idx];
239 int hs = fc->ps.sps->hshift[c_idx];222 const int is_chroma = !!c_idx;
240 int vs = fc->ps.sps->vshift[c_idx];223 const int hs = fc->ps.sps->hshift[c_idx];
224 const int vs = fc->ps.sps->vshift[c_idx];
241 const int idx = av_log2(block_w) - 1;225 const int idx = av_log2(block_w) - 1;
242 const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (1 - hs);226 const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - hs);
243 const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (1 - vs);227 const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - vs);
244 const int8_t *hf = ff_vvc_inter_chroma_filters[0][mx];228 const int8_t *hf = INTER_FILTER(0, mx);
245 const int8_t *vf = ff_vvc_inter_chroma_filters[0][my];229 const int8_t *vf = INTER_FILTER(0, my);
246 230
247 x_off += mv->x >> (4 + hs);231 x_off += mv->x >> (4 + hs);
248 y_off += mv->y >> (4 + vs);232 y_off += mv->y >> (4 + vs);
249 src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));233 src += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
250 234
251 EMULATED_EDGE_CHROMA(lc->edge_emu_buffer, &src, &src_stride, x_off, y_off);235 MC_EMULATED_EDGE(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);236 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, block_h, hf, vf, block_w);
253}237}
254 238
255static void luma_mc_uni(VVCLocalContext *lc, uint8_t *dst, const ptrdiff_t dst_stride,239static 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
543 VVCFrame *ref = lc->sc->rpl[lx].ref[mv->ref_idx[lx]];527 VVCFrame *ref = lc->sc->rpl[lx].ref[mv->ref_idx[lx]];
544 if (!ref)528 if (!ref)
545 return;529 return;
546 if (c_idx)530 mc(lc, tmp[i], ref->frame, mv->mv + lx, x, y, width, height, 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);
550 }531 }
551 fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);532 fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y);
552 }533 }

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