mpegvideo: Refactor emulated_edge_mc calls

This commit is contained in:
Luca Barbato 2016-03-04 16:57:30 +01:00 committed by Vittorio Giovara
parent 0242351390
commit 39a2d3288e
1 changed files with 36 additions and 42 deletions

View File

@ -226,6 +226,38 @@ static inline int hpel_motion(MpegEncContext *s,
return emu;
}
static av_always_inline
void emulated_edge_mc(MpegEncContext *s,
int src_x, int src_y,
int uvsrc_x, int uvsrc_y,
int field_based,
uint8_t **ptr_y,
uint8_t **ptr_cb,
uint8_t **ptr_cr)
{
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, *ptr_y,
s->linesize, s->linesize,
17, 17 + field_based,
src_x, src_y * (1 << field_based),
s->h_edge_pos, s->v_edge_pos);
*ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->sc.edge_emu_buffer + 18 * s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, *ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y * (1 << field_based),
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, *ptr_cr,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y * (1 << field_based),
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
*ptr_cb = uvbuf;
*ptr_cr = uvbuf + 16;
}
}
static av_always_inline
void mpeg_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
@ -318,27 +350,8 @@ void mpeg_motion_internal(MpegEncContext *s,
src_y);
return;
}
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
s->linesize, s->linesize,
17, 17 + field_based,
src_x, src_y * (1 << field_based),
s->h_edge_pos, s->v_edge_pos);
ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->sc.edge_emu_buffer + 18 * s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y * (1 << field_based),
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y * (1 << field_based),
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
emulated_edge_mc(s, src_x, src_y, uvsrc_x, uvsrc_y, field_based,
&ptr_y, &ptr_cb, &ptr_cr);
}
/* FIXME use this for field pix too instead of the obnoxious hack which
@ -539,27 +552,8 @@ static inline void qpel_motion(MpegEncContext *s,
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 3) - 16, 0) ||
(unsigned)src_y > FFMAX(v_edge_pos - (motion_y & 3) - h, 0)) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
s->linesize, s->linesize,
17, 17 + field_based,
src_x, src_y * (1 << field_based),
s->h_edge_pos, s->v_edge_pos);
ptr_y = s->sc.edge_emu_buffer;
if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->sc.edge_emu_buffer + 18 * s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y * (1 << field_based),
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y * (1 << field_based),
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
emulated_edge_mc(s, src_x, src_y, uvsrc_x, uvsrc_y, field_based,
&ptr_y, &ptr_cb, &ptr_cr);
}
if (!field_based)