* [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym @ 2023-12-20 8:40 flow gg 2023-12-20 8:46 ` flow gg 2023-12-20 10:15 ` flow gg 0 siblings, 2 replies; 8+ messages in thread From: flow gg @ 2023-12-20 8:40 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1: Type: text/plain, Size: 67 bytes --] C908: get_pixels_8x4_sym_c: 297.2 get_pixels_8x4_sym_rvv_i64: 52.7 [-- Attachment #2: 0003-lavc-dnxhdenc-R-V-V-get_pixels_8x4_sym.patch --] [-- Type: text/x-patch, Size: 5715 bytes --] From 6fe4dbe9af39af50a1bf2069e91dfa542d83fee3 Mon Sep 17 00:00:00 2001 From: sunyuechi <sunyuechi@iscas.ac.cn> Date: Wed, 20 Dec 2023 16:28:33 +0800 Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym C908: get_pixels_8x4_sym_c: 297.2 get_pixels_8x4_sym_rvv_i64: 52.7 --- libavcodec/dnxhdenc.c | 4 ++- libavcodec/dnxhdenc.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/dnxenc_init.c | 41 ++++++++++++++++++++++++++++ libavcodec/riscv/dnxenc_rvv.S | 50 ++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/dnxenc_init.c create mode 100644 libavcodec/riscv/dnxenc_rvv.S diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 1ac8116f53..8dbda5eea1 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1379,7 +1379,9 @@ const FFCodec ff_dnxhd_encoder = { }; void ff_dnxhdenc_init(DNXHDEncContext *ctx) { -#if ARCH_X86 +#if ARCH_RISCV + ff_dnxhdenc_init_riscv(ctx); +#elif ARCH_X86 ff_dnxhdenc_init_x86(ctx); #endif } diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 95aea83d28..3ed1451431 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -112,6 +112,7 @@ typedef struct DNXHDEncContext { } DNXHDEncContext; void ff_dnxhdenc_init(DNXHDEncContext *ctx); +void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx); void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx); #endif /* AVCODEC_DNXHDENC_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index aa758eba1c..35ad149326 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -13,6 +13,8 @@ RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o +OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_init.o +RVV-OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_rvv.o OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o diff --git a/libavcodec/riscv/dnxenc_init.c b/libavcodec/riscv/dnxenc_init.c new file mode 100644 index 0000000000..43bd61afd4 --- /dev/null +++ b/libavcodec/riscv/dnxenc_init.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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 "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/dnxhdenc.h" + +void ff_get_pixels_8x4_sym_rvv(int16_t *block, const uint8_t *pixels, + ptrdiff_t line_size); + +av_cold void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I64) { + if (ctx->cid_table->bit_depth == 8) { + ctx->get_pixels_8x4_sym = ff_get_pixels_8x4_sym_rvv; + } + } +#endif +} diff --git a/libavcodec/riscv/dnxenc_rvv.S b/libavcodec/riscv/dnxenc_rvv.S new file mode 100644 index 0000000000..f287a05575 --- /dev/null +++ b/libavcodec/riscv/dnxenc_rvv.S @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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/riscv/asm.S" + +func ff_get_pixels_8x4_sym_rvv, zve64x + vsetivli zero, 8, e8, mf2, ta, ma + vlse64.v v16, (a1), a2 + li t0, 8 * 8 + vsetvli zero, t0, e16, m4, ta, ma + vzext.vf2 v8, v16 + vse16.v v8, (a0) + vsetivli zero, 2, e64, m1, ta, ma + addi a0, a0, 32*2 + li a2, 8*2 + sub a1, a0, a2 + vle64.v v0, (a1) + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + + ret +endfunc -- 2.43.0 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym 2023-12-20 8:40 [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym flow gg @ 2023-12-20 8:46 ` flow gg 2023-12-20 10:15 ` flow gg 1 sibling, 0 replies; 8+ messages in thread From: flow gg @ 2023-12-20 8:46 UTC (permalink / raw) To: FFmpeg development discussions and patches There are only three emails in my Sent Items, but there are six at ffmpeg-devel.. I'm not quite sure why, please ignore the three duplicates. flow gg <hlefthleft@gmail.com> 于2023年12月20日周三 16:41写道: > C908: > get_pixels_8x4_sym_c: 297.2 > get_pixels_8x4_sym_rvv_i64: 52.7 > _______________________________________________ > 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". > _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym 2023-12-20 8:40 [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym flow gg 2023-12-20 8:46 ` flow gg @ 2023-12-20 10:15 ` flow gg 2024-01-29 13:51 ` flow gg 1 sibling, 1 reply; 8+ messages in thread From: flow gg @ 2023-12-20 10:15 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1: Type: text/plain, Size: 550 bytes --] Because the format of [PATCH 1/3] was modified, this patch needs to be changed, and it has been modified in this reply. flow gg <hlefthleft@gmail.com> 于2023年12月20日周三 16:41写道: > C908: > get_pixels_8x4_sym_c: 297.2 > get_pixels_8x4_sym_rvv_i64: 52.7 > _______________________________________________ > 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". > [-- Attachment #2: 0003-lavc-dnxhdenc-R-V-V-get_pixels_8x4_sym.patch --] [-- Type: text/x-patch, Size: 5712 bytes --] From b7900ed41724cc42871362b73b2e4ac661d8728a Mon Sep 17 00:00:00 2001 From: sunyuechi <sunyuechi@iscas.ac.cn> Date: Wed, 20 Dec 2023 16:28:33 +0800 Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym C908: get_pixels_8x4_sym_c: 297.2 get_pixels_8x4_sym_rvv_i64: 52.7 --- libavcodec/dnxhdenc.c | 4 ++- libavcodec/dnxhdenc.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/dnxenc_init.c | 41 ++++++++++++++++++++++++++++ libavcodec/riscv/dnxenc_rvv.S | 50 ++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/dnxenc_init.c create mode 100644 libavcodec/riscv/dnxenc_rvv.S diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 0d9727bbbf..bab92753fa 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1378,7 +1378,9 @@ const FFCodec ff_dnxhd_encoder = { void ff_dnxhdenc_init(DNXHDEncContext *ctx) { -#if ARCH_X86 +#if ARCH_RISCV + ff_dnxhdenc_init_riscv(ctx); +#elif ARCH_X86 ff_dnxhdenc_init_x86(ctx); #endif } diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 95aea83d28..3ed1451431 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -112,6 +112,7 @@ typedef struct DNXHDEncContext { } DNXHDEncContext; void ff_dnxhdenc_init(DNXHDEncContext *ctx); +void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx); void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx); #endif /* AVCODEC_DNXHDENC_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index aa758eba1c..35ad149326 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -13,6 +13,8 @@ RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o +OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_init.o +RVV-OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_rvv.o OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o diff --git a/libavcodec/riscv/dnxenc_init.c b/libavcodec/riscv/dnxenc_init.c new file mode 100644 index 0000000000..43bd61afd4 --- /dev/null +++ b/libavcodec/riscv/dnxenc_init.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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 "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/dnxhdenc.h" + +void ff_get_pixels_8x4_sym_rvv(int16_t *block, const uint8_t *pixels, + ptrdiff_t line_size); + +av_cold void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I64) { + if (ctx->cid_table->bit_depth == 8) { + ctx->get_pixels_8x4_sym = ff_get_pixels_8x4_sym_rvv; + } + } +#endif +} diff --git a/libavcodec/riscv/dnxenc_rvv.S b/libavcodec/riscv/dnxenc_rvv.S new file mode 100644 index 0000000000..f287a05575 --- /dev/null +++ b/libavcodec/riscv/dnxenc_rvv.S @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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/riscv/asm.S" + +func ff_get_pixels_8x4_sym_rvv, zve64x + vsetivli zero, 8, e8, mf2, ta, ma + vlse64.v v16, (a1), a2 + li t0, 8 * 8 + vsetvli zero, t0, e16, m4, ta, ma + vzext.vf2 v8, v16 + vse16.v v8, (a0) + vsetivli zero, 2, e64, m1, ta, ma + addi a0, a0, 32*2 + li a2, 8*2 + sub a1, a0, a2 + vle64.v v0, (a1) + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + + ret +endfunc -- 2.43.0 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym 2023-12-20 10:15 ` flow gg @ 2024-01-29 13:51 ` flow gg 2024-01-29 15:40 ` Rémi Denis-Courmont 0 siblings, 1 reply; 8+ messages in thread From: flow gg @ 2024-01-29 13:51 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1: Type: text/plain, Size: 717 bytes --] I have slightly adjusted the rvv and updated patch in this reply. flow gg <hlefthleft@gmail.com> 于2023年12月20日周三 18:15写道: > Because the format of [PATCH 1/3] was modified, this patch needs to be > changed, and it has been modified in this reply. > > flow gg <hlefthleft@gmail.com> 于2023年12月20日周三 16:41写道: > >> C908: >> get_pixels_8x4_sym_c: 297.2 >> get_pixels_8x4_sym_rvv_i64: 52.7 >> _______________________________________________ >> 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". >> > [-- Attachment #2: 0003-lavc-dnxhdenc-R-V-V-get_pixels_8x4_sym.patch --] [-- Type: text/x-patch, Size: 5712 bytes --] From 69cd1aaa5289fa2bdf23125f694c9821c7760e19 Mon Sep 17 00:00:00 2001 From: sunyuechi <sunyuechi@iscas.ac.cn> Date: Wed, 20 Dec 2023 16:28:33 +0800 Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym C908: get_pixels_8x4_sym_c: 297.2 get_pixels_8x4_sym_rvv_i64: 52.7 --- libavcodec/dnxhdenc.c | 4 ++- libavcodec/dnxhdenc.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/dnxenc_init.c | 41 ++++++++++++++++++++++++++++ libavcodec/riscv/dnxenc_rvv.S | 50 ++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/dnxenc_init.c create mode 100644 libavcodec/riscv/dnxenc_rvv.S diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 0d9727bbbf..bab92753fa 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1378,7 +1378,9 @@ const FFCodec ff_dnxhd_encoder = { void ff_dnxhdenc_init(DNXHDEncContext *ctx) { -#if ARCH_X86 +#if ARCH_RISCV + ff_dnxhdenc_init_riscv(ctx); +#elif ARCH_X86 ff_dnxhdenc_init_x86(ctx); #endif } diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 95aea83d28..3ed1451431 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -112,6 +112,7 @@ typedef struct DNXHDEncContext { } DNXHDEncContext; void ff_dnxhdenc_init(DNXHDEncContext *ctx); +void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx); void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx); #endif /* AVCODEC_DNXHDENC_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index fe604a1156..e15aba58f4 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -13,6 +13,8 @@ RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o +OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_init.o +RVV-OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_rvv.o OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o diff --git a/libavcodec/riscv/dnxenc_init.c b/libavcodec/riscv/dnxenc_init.c new file mode 100644 index 0000000000..43bd61afd4 --- /dev/null +++ b/libavcodec/riscv/dnxenc_init.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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 "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/dnxhdenc.h" + +void ff_get_pixels_8x4_sym_rvv(int16_t *block, const uint8_t *pixels, + ptrdiff_t line_size); + +av_cold void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I64) { + if (ctx->cid_table->bit_depth == 8) { + ctx->get_pixels_8x4_sym = ff_get_pixels_8x4_sym_rvv; + } + } +#endif +} diff --git a/libavcodec/riscv/dnxenc_rvv.S b/libavcodec/riscv/dnxenc_rvv.S new file mode 100644 index 0000000000..d965905597 --- /dev/null +++ b/libavcodec/riscv/dnxenc_rvv.S @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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/riscv/asm.S" + +func ff_get_pixels_8x4_sym_rvv, zve64x + vsetivli zero, 8, e8, mf2, ta, ma + vlse64.v v16, (a1), a2 + li t0, 8 * 8 + vsetvli zero, t0, e16, m4, ta, ma + vzext.vf2 v8, v16 + vse16.v v8, (a0) + li a2, 8*2 + vsetivli zero, 2, e8, mf8, ta, ma + addi a1, a0, 48 + addi a0, a0, 32*2 + vle64.v v0, (a1) + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + + ret +endfunc -- 2.43.0 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym 2024-01-29 13:51 ` flow gg @ 2024-01-29 15:40 ` Rémi Denis-Courmont 2024-01-29 16:22 ` flow gg 0 siblings, 1 reply; 8+ messages in thread From: Rémi Denis-Courmont @ 2024-01-29 15:40 UTC (permalink / raw) To: FFmpeg development discussions and patches Hi, +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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/riscv/asm.S" + +func ff_get_pixels_8x4_sym_rvv, zve64x + vsetivli zero, 8, e8, mf2, ta, ma + vlse64.v v16, (a1), a2 + li t0, 8 * 8 + vsetvli zero, t0, e16, m4, ta, ma + vzext.vf2 v8, v16 + vse16.v v8, (a0) + li a2, 8*2 That's not needed. You can use immediate values. + vsetivli zero, 2, e8, mf8, ta, ma + addi a1, a0, 48 + addi a0, a0, 32*2 + vle64.v v0, (a1) + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) + sub a1, a1, a2 + vle64.v v0, (a1) + add a0, a0, a2 + vse64.v v0, (a0) You can reorder to avoid immediate data dependencies on the addresses. I expect that it would be faster to make one large load, and then 4 small stores, but that might work only for exactly 128-bit vectors? In any case, you need to check the vector length in init. + + ret +endfunc -- 雷米‧德尼-库尔蒙 http://www.remlab.net/ _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym 2024-01-29 15:40 ` Rémi Denis-Courmont @ 2024-01-29 16:22 ` flow gg 2024-02-18 12:27 ` flow gg 0 siblings, 1 reply; 8+ messages in thread From: flow gg @ 2024-01-29 16:22 UTC (permalink / raw) To: FFmpeg development discussions and patches [-- Attachment #1: Type: text/plain, Size: 3132 bytes --] > I expect that it would be faster to make one large load, and then 4 small > stores, but that might work only for exactly 128-bit vectors? This seems to require vle128, so I didn't modify it. > That's not needed. You can use immediate values. > You can reorder to avoid immediate data dependencies on the addresses. > In any case, you need to check the vector length in init. Okay, I've updated it in the reply. Rémi Denis-Courmont <remi@remlab.net> 于2024年1月29日周一 23:41写道: > Hi, > > +/* > + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences > (ISCAS). > + * > + * 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/riscv/asm.S" > + > +func ff_get_pixels_8x4_sym_rvv, zve64x > + vsetivli zero, 8, e8, mf2, ta, ma > + vlse64.v v16, (a1), a2 > + li t0, 8 * 8 > + vsetvli zero, t0, e16, m4, ta, ma > + vzext.vf2 v8, v16 > + vse16.v v8, (a0) > + li a2, 8*2 > > That's not needed. You can use immediate values. > > + vsetivli zero, 2, e8, mf8, ta, ma > + addi a1, a0, 48 > + addi a0, a0, 32*2 > + vle64.v v0, (a1) > + vse64.v v0, (a0) > + sub a1, a1, a2 > + vle64.v v0, (a1) > + add a0, a0, a2 > + vse64.v v0, (a0) > + sub a1, a1, a2 > + vle64.v v0, (a1) > + add a0, a0, a2 > + vse64.v v0, (a0) > + sub a1, a1, a2 > + vle64.v v0, (a1) > + add a0, a0, a2 > + vse64.v v0, (a0) > > You can reorder to avoid immediate data dependencies on the addresses. > > I expect that it would be faster to make one large load, and then 4 small > stores, but that might work only for exactly 128-bit vectors? > > In any case, you need to check the vector length in init. > > + > + ret > +endfunc > > -- > 雷米‧德尼-库尔蒙 > http://www.remlab.net/ > > > > _______________________________________________ > 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". > [-- Attachment #2: 0003-lavc-dnxhdenc-R-V-V-get_pixels_8x4_sym.patch --] [-- Type: text/x-patch, Size: 5748 bytes --] From 70e40a02d04d91c7f25c2127eb561c03e34792b9 Mon Sep 17 00:00:00 2001 From: sunyuechi <sunyuechi@iscas.ac.cn> Date: Wed, 20 Dec 2023 16:28:33 +0800 Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym C908: get_pixels_8x4_sym_c: 297.2 get_pixels_8x4_sym_rvv_i64: 52.7 --- libavcodec/dnxhdenc.c | 4 ++- libavcodec/dnxhdenc.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/dnxenc_init.c | 42 +++++++++++++++++++++++++++++ libavcodec/riscv/dnxenc_rvv.S | 49 ++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/dnxenc_init.c create mode 100644 libavcodec/riscv/dnxenc_rvv.S diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 0d9727bbbf..bab92753fa 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1378,7 +1378,9 @@ const FFCodec ff_dnxhd_encoder = { void ff_dnxhdenc_init(DNXHDEncContext *ctx) { -#if ARCH_X86 +#if ARCH_RISCV + ff_dnxhdenc_init_riscv(ctx); +#elif ARCH_X86 ff_dnxhdenc_init_x86(ctx); #endif } diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 95aea83d28..3ed1451431 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -112,6 +112,7 @@ typedef struct DNXHDEncContext { } DNXHDEncContext; void ff_dnxhdenc_init(DNXHDEncContext *ctx); +void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx); void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx); #endif /* AVCODEC_DNXHDENC_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index fe604a1156..e15aba58f4 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -13,6 +13,8 @@ RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o +OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_init.o +RVV-OBJS-$(CONFIG_DNXHD_ENCODER) += riscv/dnxenc_rvv.o OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o diff --git a/libavcodec/riscv/dnxenc_init.c b/libavcodec/riscv/dnxenc_init.c new file mode 100644 index 0000000000..9a42b17224 --- /dev/null +++ b/libavcodec/riscv/dnxenc_init.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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 "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavcodec/dnxhdenc.h" + +void ff_get_pixels_8x4_sym_rvv(int16_t *block, const uint8_t *pixels, + ptrdiff_t line_size); + +av_cold void ff_dnxhdenc_init_riscv(DNXHDEncContext *ctx) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I64 && ff_get_rv_vlenb() >= 16) { + if (ctx->cid_table->bit_depth == 8) { + ctx->get_pixels_8x4_sym = ff_get_pixels_8x4_sym_rvv; + } + } +#endif +} diff --git a/libavcodec/riscv/dnxenc_rvv.S b/libavcodec/riscv/dnxenc_rvv.S new file mode 100644 index 0000000000..ac4a274009 --- /dev/null +++ b/libavcodec/riscv/dnxenc_rvv.S @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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/riscv/asm.S" + +func ff_get_pixels_8x4_sym_rvv, zve64x + vsetivli zero, 8, e8, mf2, ta, ma + vlse64.v v16, (a1), a2 + li t0, 8 * 8 + vsetvli zero, t0, e16, m4, ta, ma + vzext.vf2 v8, v16 + vse16.v v8, (a0) + vsetivli zero, 2, e8, mf8, ta, ma + addi a1, a0, 48 + addi a0, a0, 32*2 + vle64.v v0, (a1) + vse64.v v0, (a0) + addi a1, a1, -16 + addi a0, a0, 16 + vle64.v v0, (a1) + vse64.v v0, (a0) + addi a1, a1, -16 + addi a0, a0, 16 + vle64.v v0, (a1) + vse64.v v0, (a0) + addi a1, a1, -16 + addi a0, a0, 16 + vle64.v v0, (a1) + vse64.v v0, (a0) + + ret +endfunc -- 2.43.0 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym 2024-01-29 16:22 ` flow gg @ 2024-02-18 12:27 ` flow gg 2024-02-19 17:48 ` Rémi Denis-Courmont 0 siblings, 1 reply; 8+ messages in thread From: flow gg @ 2024-02-18 12:27 UTC (permalink / raw) To: FFmpeg development discussions and patches ping flow gg <hlefthleft@gmail.com> 于2024年1月30日周二 00:22写道: > > I expect that it would be faster to make one large load, and then 4 small > > stores, but that might work only for exactly 128-bit vectors? > > This seems to require vle128, so I didn't modify it. > > > That's not needed. You can use immediate values. > > You can reorder to avoid immediate data dependencies on the addresses. > > In any case, you need to check the vector length in init. > > Okay, I've updated it in the reply. > > Rémi Denis-Courmont <remi@remlab.net> 于2024年1月29日周一 23:41写道: > >> Hi, >> >> +/* >> + * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences >> (ISCAS). >> + * >> + * 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/riscv/asm.S" >> + >> +func ff_get_pixels_8x4_sym_rvv, zve64x >> + vsetivli zero, 8, e8, mf2, ta, ma >> + vlse64.v v16, (a1), a2 >> + li t0, 8 * 8 >> + vsetvli zero, t0, e16, m4, ta, ma >> + vzext.vf2 v8, v16 >> + vse16.v v8, (a0) >> + li a2, 8*2 >> >> That's not needed. You can use immediate values. >> >> + vsetivli zero, 2, e8, mf8, ta, ma >> + addi a1, a0, 48 >> + addi a0, a0, 32*2 >> + vle64.v v0, (a1) >> + vse64.v v0, (a0) >> + sub a1, a1, a2 >> + vle64.v v0, (a1) >> + add a0, a0, a2 >> + vse64.v v0, (a0) >> + sub a1, a1, a2 >> + vle64.v v0, (a1) >> + add a0, a0, a2 >> + vse64.v v0, (a0) >> + sub a1, a1, a2 >> + vle64.v v0, (a1) >> + add a0, a0, a2 >> + vse64.v v0, (a0) >> >> You can reorder to avoid immediate data dependencies on the addresses. >> >> I expect that it would be faster to make one large load, and then 4 small >> stores, but that might work only for exactly 128-bit vectors? >> >> In any case, you need to check the vector length in init. >> >> + >> + ret >> +endfunc >> >> -- >> 雷米‧德尼-库尔蒙 >> http://www.remlab.net/ >> >> >> >> _______________________________________________ >> 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". >> > _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym 2024-02-18 12:27 ` flow gg @ 2024-02-19 17:48 ` Rémi Denis-Courmont 0 siblings, 0 replies; 8+ messages in thread From: Rémi Denis-Courmont @ 2024-02-19 17:48 UTC (permalink / raw) To: FFmpeg development discussions and patches Le sunnuntaina 18. helmikuuta 2024, 14.27.56 EET flow gg a écrit : > ping Patch does not apply here. -- Rémi Denis-Courmont http://www.remlab.net/ _______________________________________________ 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". ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-02-19 17:48 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-12-20 8:40 [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym flow gg 2023-12-20 8:46 ` flow gg 2023-12-20 10:15 ` flow gg 2024-01-29 13:51 ` flow gg 2024-01-29 15:40 ` Rémi Denis-Courmont 2024-01-29 16:22 ` flow gg 2024-02-18 12:27 ` flow gg 2024-02-19 17:48 ` Rémi Denis-Courmont
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