From 1c67ad9d93031839e6e5032190cd95f6dfda8f59 Mon Sep 17 00:00:00 2001 From: Yu Xiaolei Date: Sat, 14 Dec 2013 15:31:42 +0800 Subject: swscale: NEON optimized unscaled rgba to nv12 conversion Signed-off-by: Yu Xiaolei Signed-off-by: Michael Niedermayer --- libswscale/arm/swscale_unscaled.c | 79 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 libswscale/arm/swscale_unscaled.c (limited to 'libswscale/arm/swscale_unscaled.c') diff --git a/libswscale/arm/swscale_unscaled.c b/libswscale/arm/swscale_unscaled.c new file mode 100644 index 0000000..04be762 --- /dev/null +++ b/libswscale/arm/swscale_unscaled.c @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2013 Xiaolei Yu + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" +#include "libavutil/arm/cpu.h" + +extern void rgbx_to_nv12_neon_32(const uint8_t *src, uint8_t *y, uint8_t *chroma, + int width, int height, + int y_stride, int c_stride, int src_stride, + int32_t coeff_tbl[9]); + +extern void rgbx_to_nv12_neon_16(const uint8_t *src, uint8_t *y, uint8_t *chroma, + int width, int height, + int y_stride, int c_stride, int src_stride, + int32_t coeff_tbl[9]); + +static int rgbx_to_nv12_neon_32_wrapper(SwsContext *context, const uint8_t *src[], + int srcStride[], int srcSliceY, int srcSliceH, + uint8_t *dst[], int dstStride[]) { + + rgbx_to_nv12_neon_32(src[0] + srcSliceY * srcStride[0], + dst[0] + srcSliceY * dstStride[0], + dst[1] + (srcSliceY / 2) * dstStride[1], + context->srcW, srcSliceH, + dstStride[0], dstStride[1], srcStride[0], + context->input_rgb2yuv_table); + + return 0; +} + +static int rgbx_to_nv12_neon_16_wrapper(SwsContext *context, const uint8_t *src[], + int srcStride[], int srcSliceY, int srcSliceH, + uint8_t *dst[], int dstStride[]) { + + rgbx_to_nv12_neon_16(src[0] + srcSliceY * srcStride[0], + dst[0] + srcSliceY * dstStride[0], + dst[1] + (srcSliceY / 2) * dstStride[1], + context->srcW, srcSliceH, + dstStride[0], dstStride[1], srcStride[0], + context->input_rgb2yuv_table); + + return 0; +} + +static void get_unscaled_swscale_neon(SwsContext *c) { + int accurate_rnd = c->flags & SWS_ACCURATE_RND; + if (c->srcFormat == AV_PIX_FMT_RGBA + && c->dstFormat == AV_PIX_FMT_NV12 + && (c->srcW >= 16)) { + c->swscale = accurate_rnd ? rgbx_to_nv12_neon_32_wrapper + : rgbx_to_nv12_neon_16_wrapper; + } +} + +void ff_get_unscaled_swscale_arm(SwsContext *c) +{ + int cpu_flags = av_get_cpu_flags(); + if (have_neon(cpu_flags)) + get_unscaled_swscale_neon(c); +} -- cgit v1.1