From: Hao Chen <chenhao@loongson.cn>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v2 1/3] swscale/la: Optimize hscale functions with lasx.
Date: Tue, 6 Sep 2022 16:06:33 +0800
Message-ID: <f61cba9f-a192-387d-ecf6-fcc5aa019ee1@loongson.cn> (raw)
In-Reply-To: <AS8P250MB074468CD5DD8F34718347AEC8F7D9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
在 2022/9/3 下午8:31, Andreas Rheinhardt 写道:
> Hao Chen:
>> 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 <chenhao@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(chenhao@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);
> According to
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=7366 this
> patchset creates new warnings and as I have explained in
> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/300682.html this
> is (most likely) due to lasxintrin.h and lsxintrin.h not accepting
> pointers to void in the load-functions. The above __lasx_xvldx() is
> affected by this. Could you please fix this issue and provide an updated
> toolchain able to compile lsx and lasx?
>
Thanks for your attention to loongson. The __lasx_xvldx() is defined in
lasxintrin.h as following:
extern __inline __attribute__((__gnu_inline__, __always_inline__,
__artificial__))
__m256i __lasx_xvldx(void * _1, long int _2)
{
return (void)__builtin_lasx_xvstx((v32i8)_1, (void *)_2, (long int)_3);
}
A warning appears when the parameter passed is a pointer to a const.
Now, I have fed it back to my colleagues in the compiler group to
discuss how to solve it.
I believe it will be solved soon.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-09-06 8:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-03 2:23 [FFmpeg-devel] Add LoongArch SIMD optimization in swscale lib Hao Chen
2022-09-03 2:23 ` [FFmpeg-devel] [PATCH v2 1/3] swscale/la: Optimize hscale functions with lasx Hao Chen
2022-09-03 12:31 ` Andreas Rheinhardt
2022-09-06 8:06 ` Hao Chen [this message]
2022-09-03 2:23 ` [FFmpeg-devel] [PATCH v2 2/3] swscale/la: Add yuv2rgb_lasx.c and rgb2rgb_lasx.c files Hao Chen
2022-09-03 2:23 ` [FFmpeg-devel] [PATCH v2 3/3] swscale/la: Add output_lasx.c file Hao Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f61cba9f-a192-387d-ecf6-fcc5aa019ee1@loongson.cn \
--to=chenhao@loongson.cn \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git