From patchwork Wed Nov 22 12:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: flow gg X-Patchwork-Id: 44746 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:96ce:b0:181:818d:5e7f with SMTP id hq14csp317350pzc; Wed, 22 Nov 2023 04:00:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGn8Pi/OVgRDGYLRWvib4ckzSygTu+97bTtE4ovoYNo0d21v1ycYPo46wFaCdyrRXYgUYn X-Received: by 2002:a05:6512:3d8a:b0:509:162b:8fe0 with SMTP id k10-20020a0565123d8a00b00509162b8fe0mr1539335lfv.1.1700654443438; Wed, 22 Nov 2023 04:00:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700654443; cv=none; d=google.com; s=arc-20160816; b=I52t2ENYCj6ogIi4bT4mxUtw2M7jGsA08sqCFF/2fA+9m0tFkHm8/tirLCIlppm+cm znA0VusHCoV09CeVR5hF9StwjaW5H4qPSphOFBFHRbX9NoNiG44RcwyHt9sLs6/YOZzi YlWvJ4dIB8+SHVTg/OH8UZdr2mwIns+xx7vCDNqVi3D4uQEnCpuoqjmSkGkj87t1ctpG ZfnZ/yBaaaxgNbxD1wKC2rOqrsBkFMAYDK9ud0rvxDVUbLOgaIxczCmuAm9TnCL7EL9q ujhYTQLsCyQbSYvMLp91luiUEq9GgBGcLeyjn5DeMmjRe/2li5XlJupy/+ehcFPQljZb 997A== 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=WZb8tzAqKSu0zEmzw+LLJgiI5fO5y2HXqkSLwAljWr8=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=fFIYcfI+3POUUip0ZThIhGh/DRrnw+U14xv6GbRRIaEuAL/QnpDW/kyhMXbzc7B31E Ft9KOgKVEr0SrBq4BcJZO5x9F6l2iphULOmTU0SnE3N9aAwE8PcYPQUtq4aDaYwjuY+f 6Z6v2As1OuJTyaXSfwPgIKhX+wSHt555yCnGsz90gQjUKHRo3CClZfFs8ZvbHM7Xhnc4 HE3UnQqeN5jzCusEDAsvLZFkKniNt5eRikLHHuYYCwgwAG5oKuM517UtXbfCW5D1Jxh4 KaDA4ujcTC/52f65EdMGNAZX5kTtq7yabfHQBus8JV3HaWwpOl0QfecAienryQfELNRc 2ywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=W5N2vzdJ; 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 e3-20020aa7d7c3000000b00548b54f8cf0si3341837eds.654.2023.11.22.04.00.31; Wed, 22 Nov 2023 04:00:43 -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=W5N2vzdJ; 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 292F468CDEA; Wed, 22 Nov 2023 14:00:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2794B68CBAE for ; Wed, 22 Nov 2023 14:00:20 +0200 (EET) Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-672096e0e89so24632326d6.1 for ; Wed, 22 Nov 2023 04:00:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700654418; x=1701259218; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=bdmY6Mcblln8q0LySd9znPNJJz8scx05yehs6BrsO1E=; b=W5N2vzdJflPRbVtE9EfMcJQdzga9jKm4zF7xi4mNsKpabbTE/5Gqge+qL4NrSwW63z WQ18aqZGMXuxeoilHYNSedJiJ3kTKNCf4EU+jCtVL3kmu0XupL1SEsXLZ6JEV2snEk+z ixutkDoiss4q9R1Kt7yVfppkTE4Gpf8HtXD99NhpwVDpR7m11BS0zLrK5xkjjxgqf/hF NveGrDF0rzKAvW0UzxMuQj8cTbCU2BP+9lpEJB/rPyHASDeOz5GXyd02JDg2RcKTb7fg LSr4kTGEl0EW6tiy057AQBPLU4q+uvK8qrr6rIefZ28ajIKH42LSp+hDWsYkOCa7zxvB BIvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700654418; x=1701259218; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bdmY6Mcblln8q0LySd9znPNJJz8scx05yehs6BrsO1E=; b=k1nEUVr9a4pOgSAK6X9eALo7U0lxfqxbPiVduoCpapful1AG3z8HdsjwFzJ0VJhUOm j5Q4AdIV+Uha80q0PkHlJdMUxRBF16CmIXaWryxWCloLz4a52wIKfXtHViUxHjs8nx3+ RKUq42TnkeJmEYcmO9J1iUbk6hw79MM4qwdwjc4Qpc7Vah3Mhfa5VbfJSXhuCTGG4xtJ XlR9lQbTf4WzUxysu1vPgzCtOMxioW3HsQE+h4RNdJ7OwVN6IVUnmvJS8AWkvWdJbagO QwGHpKZPFJYsciGu53DRXnfLRyc3wToF9NbunAHZ4GzC2/g/v0ZnwiHvzRnKehmeVkXS mnNA== X-Gm-Message-State: AOJu0YyjnM0bHugYzgr2rW8aKgHDK6pQrkpR89SZ2zKq0+bUHGo2TaD9 TLAj1Yef7IVcBGXfokTKEVFGYpM3iUW35OcIyBp5LahW09Bj6A== X-Received: by 2002:a05:6214:19cf:b0:65b:17e9:1c9d with SMTP id j15-20020a05621419cf00b0065b17e91c9dmr2663597qvc.52.1700654418180; Wed, 22 Nov 2023 04:00:18 -0800 (PST) MIME-Version: 1.0 From: flow gg Date: Wed, 22 Nov 2023 20:00:07 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH] ac3dsp: RISC-V V float_to_fixed24 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: PwzRpzGSSeSr c910 float_to_fixed24_c: 208.2 float_to_fixed24_rvv_f32: 71.5 From 69da974fd0febaa74db4dd551b05172caeefb846 Mon Sep 17 00:00:00 2001 From: sunyuechi Date: Wed, 22 Nov 2023 14:57:29 +0800 Subject: [PATCH] lavc/ac3dsp: R-V V float_to_fixed24 c910 float_to_fixed24_c: 208.2 float_to_fixed24_rvv_f32: 71.5 --- libavcodec/riscv/Makefile | 3 ++- libavcodec/riscv/ac3dsp_init.c | 5 +++++ libavcodec/riscv/ac3dsp_rvv.S | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/ac3dsp_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 8f2a519827..ac7b7c2929 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,7 +1,8 @@ OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o riscv/sbrdsp_init.o RVV-OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_rvv.o riscv/sbrdsp_rvv.o OBJS-$(CONFIG_AC3DSP) += riscv/ac3dsp_init.o \ - riscv/ac3dsp_rvb.o + riscv/ac3dsp_rvb.o \ + riscv/ac3dsp_rvv.o OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_init.o RVV-OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_rvv.o OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ diff --git a/libavcodec/riscv/ac3dsp_init.c b/libavcodec/riscv/ac3dsp_init.c index 20f294f1de..de82d1c7a7 100644 --- a/libavcodec/riscv/ac3dsp_init.c +++ b/libavcodec/riscv/ac3dsp_init.c @@ -26,6 +26,7 @@ #include "libavcodec/ac3dsp.h" void ff_extract_exponents_rvb(uint8_t *exp, int32_t *coef, int nb_coefs); +void ff_float_to_fixed24_rvv(int32_t *dst, const float *src, unsigned int len); av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c) { @@ -35,4 +36,8 @@ av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c) if (flags & AV_CPU_FLAG_RVB_BASIC) c->extract_exponents = ff_extract_exponents_rvb; } + + if (flags & AV_CPU_FLAG_RVV_F32) { + c->float_to_fixed24 = ff_float_to_fixed24_rvv; + } } diff --git a/libavcodec/riscv/ac3dsp_rvv.S b/libavcodec/riscv/ac3dsp_rvv.S new file mode 100644 index 0000000000..4d8ab060e7 --- /dev/null +++ b/libavcodec/riscv/ac3dsp_rvv.S @@ -0,0 +1,40 @@ +/* + * 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/riscv/asm.S" + +func ff_float_to_fixed24_rvv, zve32f + li t1, 1 << 24 + fcvt.s.w f0, t1 +1: + vsetvli t0, a2, e32, m4, ta, ma + vle32.v v0, (a1) + slli t3, t0, 2 + vfmul.vf v0, v0, f0 + vfcvt.x.f.v v0, v0 + add a1, a1, t3 + vse32.v v0, (a0) + add a0, a0, t3 + sub a2, a2, t0 + bgtz a2, 1b + + ret +endfunc -- 2.43.0