Commit 39a2d328 authored by Luca Barbato's avatar Luca Barbato Committed by Vittorio Giovara

mpegvideo: Refactor emulated_edge_mc calls

parent 02423513
...@@ -226,6 +226,38 @@ static inline int hpel_motion(MpegEncContext *s, ...@@ -226,6 +226,38 @@ static inline int hpel_motion(MpegEncContext *s,
return emu; 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 static av_always_inline
void mpeg_motion_internal(MpegEncContext *s, void mpeg_motion_internal(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_y,
...@@ -318,27 +350,8 @@ void mpeg_motion_internal(MpegEncContext *s, ...@@ -318,27 +350,8 @@ void mpeg_motion_internal(MpegEncContext *s,
src_y); src_y);
return; return;
} }
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y, emulated_edge_mc(s, src_x, src_y, uvsrc_x, uvsrc_y, field_based,
s->linesize, s->linesize, &ptr_y, &ptr_cb, &ptr_cr);
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;
}
} }
/* FIXME use this for field pix too instead of the obnoxious hack which /* FIXME use this for field pix too instead of the obnoxious hack which
...@@ -539,27 +552,8 @@ static inline void qpel_motion(MpegEncContext *s, ...@@ -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) || 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)) { (unsigned)src_y > FFMAX(v_edge_pos - (motion_y & 3) - h, 0)) {
s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y, emulated_edge_mc(s, src_x, src_y, uvsrc_x, uvsrc_y, field_based,
s->linesize, s->linesize, &ptr_y, &ptr_cb, &ptr_cr);
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;
}
} }
if (!field_based) if (!field_based)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment