[vlc-commits] arm_neon: Add an optimized routine for NV12/21 to I420/YV12
Martin Storsjö
git at videolan.org
Sun Oct 6 19:53:34 CEST 2013
vlc | branch: master | Martin Storsjö <martin at martin.st> | Tue Oct 1 23:04:55 2013 +0300| [653b800e139fe11768d3639b1430096cfa085498] | committer: Jean-Baptiste Kempf
arm_neon: Add an optimized routine for NV12/21 to I420/YV12
This avoids hitting swscale for this conversion, for hw decoders
that return NV12/21 in combination with the android vout in YUV
mode.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=653b800e139fe11768d3639b1430096cfa085498
---
modules/arm_neon/Makefile.am | 1 +
modules/arm_neon/chroma_neon.h | 5 +++
modules/arm_neon/chroma_yuv.c | 65 ++++++++++++++++++++++++++++++++++
modules/arm_neon/semiplanar_planar.S | 64 +++++++++++++++++++++++++++++++++
4 files changed, 135 insertions(+)
diff --git a/modules/arm_neon/Makefile.am b/modules/arm_neon/Makefile.am
index 212605f..c375c10 100644
--- a/modules/arm_neon/Makefile.am
+++ b/modules/arm_neon/Makefile.am
@@ -9,6 +9,7 @@ libsimple_channel_mixer_neon_plugin_LIBTOOLFLAGS = --tag=CC
libchroma_yuv_neon_plugin_la_SOURCES = \
arm_neon/i420_yuyv.S \
arm_neon/i422_yuyv.S \
+ arm_neon/semiplanar_planar.S \
arm_neon/yuyv_i422.S \
arm_neon/chroma_yuv.c arm_neon/chroma_neon.h
libchroma_yuv_neon_plugin_la_CFLAGS = $(AM_CFLAGS)
diff --git a/modules/arm_neon/chroma_neon.h b/modules/arm_neon/chroma_neon.h
index 865315a..a5ce775 100644
--- a/modules/arm_neon/chroma_neon.h
+++ b/modules/arm_neon/chroma_neon.h
@@ -67,6 +67,11 @@ void uyvy_i422_neon (struct yuv_planes *const out,
const struct yuv_pack *const in,
int width, int height) asm("uyvy_i422_neon");
+/* Semiplanar to planar conversion. */
+void semiplanar_planar_neon (struct yuv_planes *const out,
+ const struct yuv_planes *const in,
+ int width, int height) asm("semiplanar_planar_neon");
+
/* I420 to RGBA conversion. */
void i420_rgb_neon (struct yuv_pack *const out,
const struct yuv_planes *const in,
diff --git a/modules/arm_neon/chroma_yuv.c b/modules/arm_neon/chroma_yuv.c
index b54732e..0129c30 100644
--- a/modules/arm_neon/chroma_yuv.c
+++ b/modules/arm_neon/chroma_yuv.c
@@ -83,6 +83,42 @@ static void I420_VYUY (filter_t *filter, picture_t *src, picture_t *dst)
VIDEO_FILTER_WRAPPER (I420_VYUY)
+/* Semiplanar NV12/21 to planar I420/YV12 */
+static void copy_y_plane(filter_t *filter, picture_t *src, picture_t *dst)
+{
+ uint8_t *src_y = src->Y_PIXELS;
+ uint8_t *dst_y = dst->Y_PIXELS;
+ if (src->Y_PITCH == dst->Y_PITCH) {
+ memcpy(dst_y, src_y, dst->Y_PITCH * filter->fmt_in.video.i_height);
+ } else {
+ for (unsigned y = 0; y < filter->fmt_in.video.i_height;
+ y++, dst_y += dst->Y_PITCH, src_y += src->Y_PITCH)
+ memcpy(dst_y, src_y, filter->fmt_in.video.i_width);
+ }
+}
+
+static void Semiplanar_Planar (filter_t *filter, picture_t *src, picture_t *dst)
+{
+ DEFINE_PLANES(out, dst);
+ DEFINE_PLANES(in, src);
+ copy_y_plane (filter, src, dst);
+ semiplanar_planar_neon (&out, &in, filter->fmt_in.video.i_width,
+ filter->fmt_in.video.i_height);
+}
+VIDEO_FILTER_WRAPPER (Semiplanar_Planar)
+
+static void Semiplanar_Planar_Swap (filter_t *filter, picture_t *src,
+ picture_t *dst)
+{
+ DEFINE_PLANES_SWAP(out, dst);
+ DEFINE_PLANES(in, src);
+ copy_y_plane (filter, src, dst);
+ semiplanar_planar_neon (&out, &in, filter->fmt_in.video.i_width,
+ filter->fmt_in.video.i_height);
+}
+VIDEO_FILTER_WRAPPER (Semiplanar_Planar_Swap)
+
+
/* Planar YUV422 to packed YUV422 */
static void I422_YUYV (filter_t *filter, picture_t *src, picture_t *dst)
{
@@ -231,6 +267,35 @@ static int Open (vlc_object_t *obj)
}
break;
+ /* Semiplanar to planar */
+ case VLC_CODEC_NV12:
+ switch (filter->fmt_out.video.i_chroma)
+ {
+ case VLC_CODEC_I420:
+ filter->pf_video_filter = Semiplanar_Planar_Filter;
+ break;
+ case VLC_CODEC_YV12:
+ filter->pf_video_filter = Semiplanar_Planar_Swap_Filter;
+ break;
+ default:
+ return VLC_EGENERIC;
+ }
+ break;
+
+ case VLC_CODEC_NV21:
+ switch (filter->fmt_out.video.i_chroma)
+ {
+ case VLC_CODEC_I420:
+ filter->pf_video_filter = Semiplanar_Planar_Swap_Filter;
+ break;
+ case VLC_CODEC_YV12:
+ filter->pf_video_filter = Semiplanar_Planar_Filter;
+ break;
+ default:
+ return VLC_EGENERIC;
+ }
+ break;
+
/* Packed to planar */
case VLC_CODEC_YUYV:
switch (filter->fmt_out.video.i_chroma)
diff --git a/modules/arm_neon/semiplanar_planar.S b/modules/arm_neon/semiplanar_planar.S
new file mode 100644
index 0000000..d099add
--- /dev/null
+++ b/modules/arm_neon/semiplanar_planar.S
@@ -0,0 +1,64 @@
+ @*****************************************************************************
+ @ nv12_i420.S : ARM NEONv1 NV12 to I420 chroma conversion
+ @*****************************************************************************
+ @ Copyright (C) 2009-2011 Rémi Denis-Courmont
+ @ Copyright (C) 2013 Martin Storsjö
+ @
+ @ This program 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.
+ @
+ @ This program 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 this program; if not, write to the Free Software Foundation,
+ @ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ @****************************************************************************/
+
+ .syntax unified
+ .fpu neon
+ .text
+
+#define IPITCH r0
+#define IPAD r0
+#define COUNT r1
+#define WIDTH r2
+#define HEIGHT r3
+#define UV r4
+#define U r5
+#define V r6
+#define OPITCH lr
+#define OPAD lr
+
+ .align 2
+ .global semiplanar_planar_neon
+ .type semiplanar_planar_neon, %function
+semiplanar_planar_neon:
+ push {r4-r6,lr}
+ add r0, r0, #4 @ first plane is unused
+ ldmia r0, {U, V, OPITCH}
+ ldr UV, [r1, #4] @ only need the second plane
+ ldr IPITCH, [r1, #12]
+ cmp HEIGHT, #0
+ sub IPAD, IPITCH, WIDTH
+ sub OPAD, OPITCH, WIDTH
+1:
+ movsgt COUNT, WIDTH
+ pople {r4-r6,pc}
+2:
+ pld [UV, #64]
+ vld2.u8 {d0, d1}, [UV,:128]!
+ subs COUNT, COUNT, #16
+ vst1.u8 {d0}, [U,:64]!
+ vst1.u8 {d1}, [V,:64]!
+ bgt 2b
+
+ subs HEIGHT, #2
+ add UV, UV, IPAD
+ add U, U, OPAD, lsr #1
+ add V, V, OPAD, lsr #1
+ b 1b
More information about the vlc-commits
mailing list