From patchwork Wed Dec 20 08:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: flow gg X-Patchwork-Id: 45261 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5184:b0:194:e134:edd4 with SMTP id j4csp77359pzf; Wed, 20 Dec 2023 00:41:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNCPSYZsfDyI9/0IItQxPad1fGkmYKhhLJjvrsIyjBCk/hv8o+z9spPwanRiI2IHrBjGjl X-Received: by 2002:a17:906:f586:b0:a23:5c9d:4233 with SMTP id cm6-20020a170906f58600b00a235c9d4233mr6857176ejd.7.1703061676891; Wed, 20 Dec 2023 00:41:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703061676; cv=none; d=google.com; s=arc-20160816; b=MJwbj9HAzMSyuRkEu1oCrPMwUyKx7ZJvy+yRlHsuEbKmMOS0nJWjdin36/V1/bwVY1 bbIrwkJ9muCt0indVNHgc/xuBv/4bClZErzhdfu4Nqxd5VmQnlfk9CkzNyvuop1DSdvW TUcP37lKcDg+AR7UldMT/YvRvLm3iQ/iHBagSYDi5wWg1kySq8dTUE7agfA0shPpJOOn jbbVGOYSs/fkmNJnEJWRQaHJM8ASeog7kPqZRvWTIJrCb4y5gSD4ZgvjdvN3sroLOAv3 wRkx3uJQEzMRFSLcr2ZKZz5A8l08ZknTOGtyezqpZSckijT2dlur/SIeRWlmpvUcNwWS lyYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to; bh=rUcN+9iKeL0KCGfQ03X+AvrZ8IhsUw5+fwqzZa88PVw=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=OFzqb+vc0JjDd8QGcCrQgQbNFBO6/jAkrny1kBZfbNAmpJzvz1/CUyTq9OxuMsH0hh +XMI2eFNok+nEaR9uUiniBPrU9MV069WM+6e0kd/ItXZRmpx+PgOvzxihoXYfDyPMnOC SNoihh5Bikm96hVIj+VR5zGTijal1qcYUrWIRGrcEm1j5A57uO1S2cA4B/rQX78RN8Of aDr79D2xrqqQ8P5q40Su6oSdsfy5hMoU1dJ75QTs9u1RR3WaoZnPWkMWe24MqVUFKT8c sPKqjOoGnCRbsBV/9YwGU2Iza/Sc3gLOoiIMGWca8e6jUhd5/GOEkPlNfnPaiv7qE8iN Vm7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=SPrKlbWl; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q11-20020a17090622cb00b00a232eab89d3si3503887eja.698.2023.12.20.00.41.16; Wed, 20 Dec 2023 00:41:16 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=SPrKlbWl; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C94468D1BE; Wed, 20 Dec 2023 10:41:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0632B68CCB4 for ; Wed, 20 Dec 2023 10:41:08 +0200 (EET) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-5e637faa52fso26289687b3.1 for ; Wed, 20 Dec 2023 00:41:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703061666; x=1703666466; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=DzV0dR3HTzfMxO7QD5VJS0QRyf3r3f/b8qnHvpHbubc=; b=SPrKlbWl2IQxMaB7XCE4q/CFcixMY5EkGEEqM3LRoTMhEH3aFebzREZ5dXHjp+1/qG +h5jA9nE8fMmnGMOfwZIMjo5143/fxO9wNSHBApQ4yyFWWUEQl/GlH3+EcRXqklVW/v6 jzzWGEC4i+ZZeXT5JpOjWAUx44L0WeDhvIeuZdFQaXdACAcmQx2LkuUlx4zFBWJ5D83S WIS1jBbwBzrNeB350pf9MG2Z0CDkqzg1VgTe5RsNjxRalLfupX4BuiYEIGnQBvGEpgMv 0ecACZBHf3M31k9KErwqdbebZMHKhEyWKTFKK3JKbagpjfAVqHRZmx9LZI7KlAKkbeh6 YrMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703061666; x=1703666466; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DzV0dR3HTzfMxO7QD5VJS0QRyf3r3f/b8qnHvpHbubc=; b=G2mPff6a8f9GhK7vUqeDjKASbAy2lAGoaD8BB5Qrd4mDxGFLrxjYE3d8RA6kZB198C IwO5CHRlS8qGOLI9yXpYa0aVzi2SgrWi0rBDPzJLjOvjTEIr3+814/fQM0K8F8FeAiYf Ua2dgC8P+PC7XXrC5e6f7KPD+gNZCMEzXw2JKlUyIBMkpV08nVoTe/QMccpTPibaIoa6 IzHQnITdQGn2pBak1ChYt0fmoKomHndj29KRdTgywUbLmCzgmw3vJGy+e3VvibT2Sgso 2z6RKSHGHn7rLe+Gy357UvBTZjZNY26/Tdf8uVLNfSYd6Wc3/AZzxB8n6WTEFm4Jbd1F yxoA== X-Gm-Message-State: AOJu0YwOz3YmPI7JvoYekOWFpzihb89m8Sbc0iSvd7tfX/h7mJG0kw7U ofWl1qEwiNHq5NSXEd4h9ExUOXCb+pHdCoKPxZroNqs4ktFeI+IE X-Received: by 2002:a25:ae96:0:b0:dbd:727f:c74a with SMTP id b22-20020a25ae96000000b00dbd727fc74amr1180555ybj.90.1703061665853; Wed, 20 Dec 2023 00:41:05 -0800 (PST) MIME-Version: 1.0 From: flow gg Date: Wed, 20 Dec 2023 16:40:54 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] Subject: [PATCH 3/3] lavc/dnxhdenc: R-V V get_pixels_8x4_sym X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1KJpS/yWnaU+ C908: get_pixels_8x4_sym_c: 297.2 get_pixels_8x4_sym_rvv_i64: 52.7 From 6fe4dbe9af39af50a1bf2069e91dfa542d83fee3 Mon Sep 17 00:00:00 2001 From: sunyuechi 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