ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -s 640x480 -y /dev/null -an
before: 101fps
after: 138fps
Signed-off-by: Hao Chen <chen...@loongson.cn>
---
libswscale/loongarch/Makefile | 3 +
libswscale/loongarch/input_lasx.c | 202 ++++
libswscale/loongarch/swscale_init_loongarch.c | 50 +
libswscale/loongarch/swscale_lasx.c | 972 ++++++++++++++++++
libswscale/loongarch/swscale_loongarch.h | 50 +
libswscale/swscale.c | 2 +
libswscale/swscale_internal.h | 2 +
libswscale/utils.c | 13 +-
8 files changed, 1293 insertions(+), 1 deletion(-)
create mode 100644 libswscale/loongarch/Makefile
create mode 100644 libswscale/loongarch/input_lasx.c
create mode 100644 libswscale/loongarch/swscale_init_loongarch.c
create mode 100644 libswscale/loongarch/swscale_lasx.c
create mode 100644 libswscale/loongarch/swscale_loongarch.h
diff --git a/libswscale/loongarch/Makefile b/libswscale/loongarch/Makefile
new file mode 100644
index 0000000000..586a1717b6
--- /dev/null
+++ b/libswscale/loongarch/Makefile
@@ -0,0 +1,3 @@
+OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_init_loongarch.o
+LASX-OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_lasx.o \
+ loongarch/input_lasx.o \
diff --git a/libswscale/loongarch/input_lasx.c
b/libswscale/loongarch/input_lasx.c
new file mode 100644
index 0000000000..c3060ea6a3
--- /dev/null
+++ b/libswscale/loongarch/input_lasx.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2022 Loongson Technology Corporation Limited
+ * Contributed by Hao Chen(chen...@loongson.cn)
+ *
+ * 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 "swscale_loongarch.h"
+#include "libavutil/loongarch/loongson_intrinsics.h"
+
+void planar_rgb_to_uv_lasx(uint8_t *_dstU, uint8_t *_dstV, const uint8_t
*src[4],
+ int width, int32_t *rgb2yuv)
+{
+ int i;
+ uint16_t *dstU = (uint16_t *)_dstU;
+ uint16_t *dstV = (uint16_t *)_dstV;
+ int set = 0x4001 << (RGB2YUV_SHIFT - 7);
+ int len = width - 15;
+ int32_t tem_ru = rgb2yuv[RU_IDX], tem_gu = rgb2yuv[GU_IDX];
+ int32_t tem_bu = rgb2yuv[BU_IDX], tem_rv = rgb2yuv[RV_IDX];
+ int32_t tem_gv = rgb2yuv[GV_IDX], tem_bv = rgb2yuv[BV_IDX];
+ int shift = RGB2YUV_SHIFT - 6;
+ const uint8_t *src0 = src[0], *src1 = src[1], *src2 = src[2];
+ __m256i ru, gu, bu, rv, gv, bv;
+ __m256i mask = {0x0D0C090805040100, 0x1D1C191815141110,
+ 0x0D0C090805040100, 0x1D1C191815141110};
+ __m256i temp = __lasx_xvreplgr2vr_w(set);
+ __m256i sra = __lasx_xvreplgr2vr_w(shift);
+
+ ru = __lasx_xvreplgr2vr_w(tem_ru);
+ gu = __lasx_xvreplgr2vr_w(tem_gu);
+ bu = __lasx_xvreplgr2vr_w(tem_bu);
+ rv = __lasx_xvreplgr2vr_w(tem_rv);
+ gv = __lasx_xvreplgr2vr_w(tem_gv);
+ bv = __lasx_xvreplgr2vr_w(tem_bv);
+ for (i = 0; i < len; i += 16) {
+ __m256i _g, _b, _r;
+ __m256i g_l, g_h, b_l, b_h, r_l, r_h;
+ __m256i v_l, v_h, u_l, u_h, u_lh, v_lh;
+
+ _g = __lasx_xvldx(src0, i);