From d340dabb76357ed4238fcdc859132007f54f51e8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 19 Apr 2014 00:08:15 +0200 Subject: avfilter/vf_rotate: make int*90° rotates suck less speedwise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Niedermayer --- libavfilter/vf_rotate.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'libavfilter/vf_rotate.c') diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c index 16c4a11873..7e5b12b42d 100644 --- a/libavfilter/vf_rotate.c +++ b/libavfilter/vf_rotate.c @@ -36,6 +36,8 @@ #include "internal.h" #include "video.h" +#include + static const char *var_names[] = { "in_w" , "iw", ///< width of the input video "in_h" , "ih", ///< height of the input video @@ -308,6 +310,62 @@ static uint8_t *interpolate_bilinear(uint8_t *dst_color, return dst_color; } +static av_always_inline void copy_elem(uint8_t *pout, const uint8_t *pin, int elem_size) +{ + int v; + switch (elem_size) { + case 1: + *pout = *pin; + break; + case 2: + *((uint16_t *)pout) = *((uint16_t *)pin); + break; + case 3: + v = AV_RB24(pin); + AV_WB24(pout, v); + break; + case 4: + *((uint32_t *)pout) = *((uint32_t *)pin); + break; + default: + memcpy(pout, pin, elem_size); + break; + } +} + +static av_always_inline void simple_rotate_internal(uint8_t *dst, const uint8_t *src, int src_linesize, int angle, int elem_size, int len) +{ + int i; + switch(angle) { + case 0: + memcpy(dst, src, elem_size * len); + break; + case 1: + for (i = 0; iangle - 0) < FLT_EPSILON && outw == inw && outh == inh) { + simple_rotate(out->data[plane] + j * out->linesize[plane], + in->data[plane] + j * in->linesize[plane], + in->linesize[plane], 0, rot->draw.pixelstep[plane], outw); + } else if (fabs(rot->angle - M_PI/2) < FLT_EPSILON && outw == inh && outh == inw) { + simple_rotate(out->data[plane] + j * out->linesize[plane], + in->data[plane] + j * rot->draw.pixelstep[plane], + in->linesize[plane], 1, rot->draw.pixelstep[plane], outw); + } else if (fabs(rot->angle - M_PI) < FLT_EPSILON && outw == inw && outh == inh) { + simple_rotate(out->data[plane] + j * out->linesize[plane], + in->data[plane] + (outh-j-1) * in->linesize[plane], + in->linesize[plane], 2, rot->draw.pixelstep[plane], outw); + } else if (fabs(rot->angle - 3*M_PI/2) < FLT_EPSILON && outw == inh && outh == inw) { + simple_rotate(out->data[plane] + j * out->linesize[plane], + in->data[plane] + (outh-j-1) * rot->draw.pixelstep[plane], + in->linesize[plane], 3, rot->draw.pixelstep[plane], outw); + } else { + for (i = 0; i < outw; i++) { int32_t v; int x1, y1; @@ -373,6 +449,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) x += c; y -= s; } + } xprime += s; yprime += c; } -- cgit v1.2.3