Unified · Split
| @@ -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 | 148 | #define EMULATED_EDGE_LUMA(dst, src, src_stride, x_off, y_off) \ |
| 147 | 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 | 211 | return 1; |
| 210 | 212 | } |
| 211 | 213 | |
| 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]) | |
| 232 | 215 | |
| 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, | |
| 234 | 217 | int x_off, int y_off, const int block_w, const int block_h, const int c_idx) |
| 235 | 218 | { |
| 236 | 219 | const VVCFrameContext *fc = lc->fc; |
| 237 | 220 | const uint8_t *src = ref->data[c_idx]; |
| 238 | 221 | 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]; | |
| 241 | 225 | 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); | |
| 246 | 230 | |
| 247 | 231 | x_off += mv->x >> (4 + hs); |
| 248 | 232 | y_off += mv->y >> (4 + vs); |
| 249 | 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); | |
| 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); | |
| 253 | 237 | } |
| 254 | 238 | |
| 255 | 239 | 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 | ||
| 543 | 527 | VVCFrame *ref = lc->sc->rpl[lx].ref[mv->ref_idx[lx]]; |
| 544 | 528 | if (!ref) |
| 545 | 529 | 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); | |
| 550 | 531 | } |
| 551 | 532 | fc->vvcdsp.inter.put_gpm(dst, dst_stride, width, height, tmp[0], tmp[1], weights, step_x, step_y); |
| 552 | 533 | } |