aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2016-03-04 16:57:30 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-03-05 08:26:36 -0500
commit39a2d3288e82e4e576c03efb32179ef5a19fff50 (patch)
tree509a364ff445b5d16d4a9150b8ca68017233a40d
parent0242351390643d176b10600c2eb854414f9559e6 (diff)
downloadffmpeg-39a2d3288e82e4e576c03efb32179ef5a19fff50.tar.gz
mpegvideo: Refactor emulated_edge_mc calls
-rw-r--r--libavcodec/mpegvideo_motion.c78
1 files changed, 36 insertions, 42 deletions
diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index aaa6e6116e..42e2612c04 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -227,6 +227,38 @@ static inline int hpel_motion(MpegEncContext *s,
}
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,
uint8_t *dest_cb,
@@ -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)