sws/aarch64: add ff_hscale_8_to_15_neon

./ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf bench=start,scale=1024x1024,bench=stop -f null -

    before: t:0.489726 avg:0.489883 max:0.491852 min:0.489482
    after:  t:0.256515 avg:0.256458 max:0.256999 min:0.253755
This commit is contained in:
Clément Bœsch 2016-03-18 16:39:34 +01:00
parent be746ae470
commit 263eb76bdf
6 changed files with 106 additions and 3 deletions

View File

@ -1,3 +1,5 @@
OBJS += aarch64/swscale_unscaled.o
OBJS += aarch64/swscale.o \
aarch64/swscale_unscaled.o \
NEON-OBJS += aarch64/yuv2rgb_neon.o
NEON-OBJS += aarch64/hscale.o \
aarch64/yuv2rgb_neon.o \

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2016 Clément Bœsch <clement stupeflix.com>
*
* 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 "libavutil/aarch64/asm.S"
function ff_hscale_8_to_15_neon, export=1
add x10, x4, w6, UXTW #1 // filter2 = filter + filterSize*2 (x2 because int16)
1: ldr w8, [x5], #4 // filterPos[0]
ldr w9, [x5], #4 // filterPos[1]
movi v4.4S, #0 // val sum part 1 (for dst[0])
movi v5.4S, #0 // val sum part 2 (for dst[1])
mov w7, w6 // filterSize counter
mov x13, x3 // srcp = src
2: add x11, x13, w8, UXTW // srcp + filterPos[0]
add x12, x13, w9, UXTW // srcp + filterPos[1]
ld1 {v0.8B}, [x11] // srcp[filterPos[0] + {0..7}]
ld1 {v1.8B}, [x12] // srcp[filterPos[1] + {0..7}]
ld1 {v2.8H}, [x4], #16 // load 8x16-bit filter values, part 1
ld1 {v3.8H}, [x10], #16 // ditto at filter+filterSize for part 2
uxtl v0.8H, v0.8B // unpack part 1 to 16-bit
uxtl v1.8H, v1.8B // unpack part 2 to 16-bit
smull v16.4S, v0.4H, v2.4H // v16.i32{0..3} = part 1 of: srcp[filterPos[0] + {0..7}] * filter[{0..7}]
smull v18.4S, v1.4H, v3.4H // v18.i32{0..3} = part 1 of: srcp[filterPos[1] + {0..7}] * filter[{0..7}]
smull2 v17.4S, v0.8H, v2.8H // v17.i32{0..3} = part 2 of: srcp[filterPos[0] + {0..7}] * filter[{0..7}]
smull2 v19.4S, v1.8H, v3.8H // v19.i32{0..3} = part 2 of: srcp[filterPos[1] + {0..7}] * filter[{0..7}]
addp v16.4S, v16.4S, v17.4S // horizontal pair adding of the 8x32-bit multiplied values for part 1 into 4x32-bit
addp v18.4S, v18.4S, v19.4S // horizontal pair adding of the 8x32-bit multiplied values for part 2 into 4x32-bit
add v4.4S, v4.4S, v16.4S // update val accumulator for part 1
add v5.4S, v5.4S, v18.4S // update val accumulator for part 2
add x13, x13, #8 // srcp += 8
subs w7, w7, #8 // processed 8/filterSize
b.gt 2b // inner loop if filterSize not consumed completely
mov x4, x10 // filter = filter2
add x10, x10, w6, UXTW #1 // filter2 += filterSize*2
addp v4.4S, v4.4S, v5.4S // horizontal pair adding of the 8x32-bit sums into 4x32-bit
addp v4.4S, v4.4S, v4.4S // horizontal pair adding of the 4x32-bit sums into 2x32-bit
sqrshrun v4.4H, v4.4S, #7 // shift and clip the 2x16-bit final values
st1 {v4.S}[0], [x1], #4 // write to destination
subs w2, w2, #2 // dstW -= 2
b.gt 1b // loop until end of line
ret
endfunc

View File

@ -0,0 +1,37 @@
/*
* 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/aarch64/cpu.h"
void ff_hscale_8_to_15_neon(SwsContext *c, int16_t *dst, int dstW,
const uint8_t *src, const int16_t *filter,
const int32_t *filterPos, int filterSize);
av_cold void ff_sws_init_swscale_aarch64(SwsContext *c)
{
int cpu_flags = av_get_cpu_flags();
if (have_neon(cpu_flags)) {
if (c->srcBpc == 8 && c->dstBpc <= 14) {
c->hyScale = c->hcScale = ff_hscale_8_to_15_neon;
}
}
}

View File

@ -889,6 +889,8 @@ SwsFunc ff_getSwsFunc(SwsContext *c)
ff_sws_init_swscale_ppc(c);
if (ARCH_X86)
ff_sws_init_swscale_x86(c);
if (ARCH_AARCH64)
ff_sws_init_swscale_aarch64(c);
return swscale;
}

View File

@ -896,6 +896,7 @@ void ff_sws_init_output_funcs(SwsContext *c,
yuv2anyX_fn *yuv2anyX);
void ff_sws_init_swscale_ppc(SwsContext *c);
void ff_sws_init_swscale_x86(SwsContext *c);
void ff_sws_init_swscale_aarch64(SwsContext *c);
void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
const uint8_t *src, int srcW, int xInc);

View File

@ -49,6 +49,7 @@
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/aarch64/cpu.h"
#include "libavutil/ppc/cpu.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
@ -1614,7 +1615,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
#endif /* HAVE_MMXEXT_INLINE */
{
const int filterAlign = X86_MMX(cpu_flags) ? 4 :
PPC_ALTIVEC(cpu_flags) ? 8 : 1;
PPC_ALTIVEC(cpu_flags) ? 8 :
have_neon(cpu_flags) ? 4 : 1;
if ((ret = initFilter(&c->hLumFilter, &c->hLumFilterPos,
&c->hLumFilterSize, c->lumXInc,