summaryrefslogtreecommitdiffstats
path: root/libswscale/aarch64
diff options
context:
space:
mode:
authorClément Bœsch <clement@stupeflix.com>2016-03-18 16:39:34 +0100
committerClément Bœsch <clement@stupeflix.com>2016-03-31 10:12:55 +0200
commit263eb76bdf5c5486c9eed0ac2e3416ce13db9821 (patch)
tree72f7d570682063efab98a672bb682e6b50933f02 /libswscale/aarch64
parentbe746ae4706302a100cc9e53f93fa6167215a674 (diff)
downloadffmpeg-streaming-263eb76bdf5c5486c9eed0ac2e3416ce13db9821.zip
ffmpeg-streaming-263eb76bdf5c5486c9eed0ac2e3416ce13db9821.tar.gz
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
Diffstat (limited to 'libswscale/aarch64')
-rw-r--r--libswscale/aarch64/Makefile6
-rw-r--r--libswscale/aarch64/hscale.S59
-rw-r--r--libswscale/aarch64/swscale.c37
3 files changed, 100 insertions, 2 deletions
diff --git a/libswscale/aarch64/Makefile b/libswscale/aarch64/Makefile
index 823806e..51bff08 100644
--- a/libswscale/aarch64/Makefile
+++ b/libswscale/aarch64/Makefile
@@ -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 \
diff --git a/libswscale/aarch64/hscale.S b/libswscale/aarch64/hscale.S
new file mode 100644
index 0000000..c32394c
--- /dev/null
+++ b/libswscale/aarch64/hscale.S
@@ -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
diff --git a/libswscale/aarch64/swscale.c b/libswscale/aarch64/swscale.c
new file mode 100644
index 0000000..6b9b046
--- /dev/null
+++ b/libswscale/aarch64/swscale.c
@@ -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;
+ }
+ }
+}
OpenPOWER on IntegriCloud