From patchwork Wed Jan 31 12:00:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: flow gg X-Patchwork-Id: 45931 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:8786:b0:199:de12:6fa6 with SMTP id ph6csp2775135pzb; Wed, 31 Jan 2024 04:00:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJdzY1R9Xx3n53ej6TDmEwiXzZXygrmWxfn5Rp2KLOt7X7kqeqOnmWX0yRbkNqv2bZHVhX X-Received: by 2002:a05:6402:22ee:b0:55e:ff9e:8eda with SMTP id dn14-20020a05640222ee00b0055eff9e8edamr1009811edb.34.1706702458479; Wed, 31 Jan 2024 04:00:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706702458; cv=none; d=google.com; s=arc-20160816; b=0hZXzVRT4Ge76xBxxr0doIYPBuugoP/VITmwhU2wF0QPkqh/ffdnhJobCSB87+9xkF C9Q+B/TNpupeSzr64P/8hFdInCsx0ihznUT2zBVerTtvfSPVPi6XrAIKDVatdTvMazRF GgYhZeoeNwI0HeSy5BizQ24kOr4ntGm0cvTcEgMBFeYCDOyQrN/WwUJy7Gsh2HoJQZdo 7/dP3qy+b0c3wVW4a6r7o9z5yVMAwnQnLh8lDB1RB5Jx2Loxo07t+hmBWb/vw+hQQBzm NNuK9lrFsJIT6rUu0B7q2/YJUY/k8lTjQ2qEdZatdLQSJfYPdy6f1hjlPnDneGPDw2DF QYxw== 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=60KdKnHBriPQXiBcyZZLc5S35fWOzzjzMn0uOdhvs6g=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=rHbgAY2+egAElV5hC6LCk1vPCQTSHwOjiLbtO3lIhbUWAExCInKQXECnJVq99G6YP3 KjkDjmbCUcyLmaU13uQJpdu5unEnsNubrOyY1A2nODbDRiCxJ2c3JPKxXYiEfeDx/+OB w+5f2nrDAtFiZyqTmsQUcL50xT6PXb7IuxIEXxUVHaJi6l5jOKRN6MCvwvcYbVrxK5jQ Kj/MdeTqDdWfcqzRMGa7n8m5MRalLHEw7I4ZMIUZLtkxj7kryZJfna00gCQ1HqjdMoG+ YA3jQYFAFiM3pelaRDEOD8IlaWuP8XjJkUX+K7AGH7NBUgOgdSn5xP47EDTwZ0lEd6QQ +Rcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="A9EfNq/H"; 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 fi25-20020a056402551900b0055f98b4432bsi64568edb.50.2024.01.31.04.00.57; Wed, 31 Jan 2024 04:00:58 -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="A9EfNq/H"; 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 0FD6B68C7E6; Wed, 31 Jan 2024 14:00:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A8AC6800C1 for ; Wed, 31 Jan 2024 14:00:48 +0200 (EET) Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-78405c9a152so182244485a.1 for ; Wed, 31 Jan 2024 04:00:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706702447; x=1707307247; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=4I4w2eLFa4oDkJlSvFl9DMAfIUbr/uXytBMpbAl2ZYc=; b=A9EfNq/H7NlO3RvjWVAWDw/hEJVaf6qEqr3k6EBBIEXxxdVBN1kTHrfAMIkbhc1ts9 /txB70CmrGfUTxGdMoz6+SlsDk4XA7w7U1DdbaVtHeRXzj1LN+gAmsyKwpPKDnttE/IC BgBllTPEba6xjOhDotdBYjJ5eAbM5wuTEUnj+YCnNYbzDqR3N+xguVFO2gWo7Z9nEUBx 7NeONzxIsU2aid8vnb9RtyaMyNqAcoXYmx2bfkuTjg8n7LJV7f9fFIsTeCQ8ye4nkXSS VhHMsZ+Ns8XLB+l+Iz7XkG0jLgc46gbBNdcTvCZBkSLUxdtcL9LHrLa77CqKB6GJWqNq vINg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706702447; x=1707307247; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4I4w2eLFa4oDkJlSvFl9DMAfIUbr/uXytBMpbAl2ZYc=; b=q95kH7okWB2G1ExUckKmMmUuaOcb55Ye+bXDDxRSl4Yysi+7DTZpthXySJ9Cu7JmXB K8bmhemBRCkFflo+iZnOOg3FvLOTUrDQqd1bpUld+v9aNwvTn4TPC7qvSj1F+GiR4Ick H1YSEutT361Bik3Q9ot/Ewto8Y7CacIzbXhREySK9YuhyC2NUxtAgh+z+SzkZE+3NK9X ZuVFcYIuObHYcpZKCZCT0YHcgtwNpUnAtetnVhrq0PjhAe0/PSNbHw12B4LQLXcnw9mg ZqYD+kzzggesO+ziQ88iDC/fvZa5SyshFioD0kpEyeGg26cLia1aGQayZN9IhSdnPX6M jWqw== X-Gm-Message-State: AOJu0Yx51+EqXrBfg2nLVsNnl5m67lIHrWyB9eZEQaTMTjI+qaEofOP3 qYiL7O+pp9u9DupLEdFPFhnO+lSbzdzqeqWjm+w2+NE7uCb0JEbh5WD6jNdF//UuLBUqK5NdpOB 1op2R+C4xnkRUPyMi/5kf5P8KQH/7AVhu X-Received: by 2002:a05:6214:2468:b0:68c:425b:ea9 with SMTP id im8-20020a056214246800b0068c425b0ea9mr1576093qvb.42.1706702446814; Wed, 31 Jan 2024 04:00:46 -0800 (PST) MIME-Version: 1.0 From: flow gg Date: Wed, 31 Jan 2024 20:00:35 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH 2/4] lavc/rv34dsp: R-V V rv34_inv_transform_dc 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: ReK7vaSpXDMR From 7e1c8d6b73afad9885222c0c9012543aface5397 Mon Sep 17 00:00:00 2001 From: sunyuechi Date: Wed, 31 Jan 2024 19:03:20 +0800 Subject: [PATCH 2/4] lavc/rv34dsp: R-V V rv34_inv_transform_dc C908: rv34_inv_transform_dc_c: 35.5 rv34_inv_transform_dc_rvv_i32: 27.0 --- libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/rv34dsp_init.c | 39 +++++++++++++++++++++++++++++++++ libavcodec/riscv/rv34dsp_rvv.S | 38 ++++++++++++++++++++++++++++++++ libavcodec/rv34dsp.c | 2 ++ libavcodec/rv34dsp.h | 1 + 5 files changed, 82 insertions(+) create mode 100644 libavcodec/riscv/rv34dsp_init.c create mode 100644 libavcodec/riscv/rv34dsp_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index e15aba58f4..ffe6631cf2 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -44,6 +44,8 @@ RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o RV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvi.o RVV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvv.o +OBJS-$(CONFIG_RV34DSP) += riscv/rv34dsp_init.o +RVV-OBJS-$(CONFIG_RV34DSP) += riscv/rv34dsp_rvv.o OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_init.o RVV-OBJS-$(CONFIG_SVQ1_ENCODER) += riscv/svqenc_rvv.o OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_init.o diff --git a/libavcodec/riscv/rv34dsp_init.c b/libavcodec/riscv/rv34dsp_init.c new file mode 100644 index 0000000000..852c8ad9a8 --- /dev/null +++ b/libavcodec/riscv/rv34dsp_init.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 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/rv34dsp.h" + +void ff_rv34_inv_transform_dc_rvv(int16_t *block); + +av_cold void ff_rv34dsp_init_riscv(RV34DSPContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32 && ff_get_rv_vlenb() >= 16) { + c->rv34_inv_transform_dc = ff_rv34_inv_transform_dc_rvv; + } +#endif +} diff --git a/libavcodec/riscv/rv34dsp_rvv.S b/libavcodec/riscv/rv34dsp_rvv.S new file mode 100644 index 0000000000..acf5b0c3e8 --- /dev/null +++ b/libavcodec/riscv/rv34dsp_rvv.S @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 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_rv34_inv_transform_dc_rvv, zve32x + lh t1, 0(a0) + slliw t2, t1, 7 + subw t2, t2, t1 + slliw t2, t2, 2 + subw t2, t2, t1 + sraiw t2, t2, 11 + slliw t2, t2, 16 + sraiw t2, t2, 16 + vsetivli zero, 16, e16, m2, ta, ma + vmv.v.x v8, t2 + vsetivli zero, 4, e8, mf4, ta, ma + vse64.v v8, (a0) + + ret +endfunc diff --git a/libavcodec/rv34dsp.c b/libavcodec/rv34dsp.c index 8f9d88396c..44486f8edd 100644 --- a/libavcodec/rv34dsp.c +++ b/libavcodec/rv34dsp.c @@ -138,6 +138,8 @@ av_cold void ff_rv34dsp_init(RV34DSPContext *c) #if ARCH_ARM ff_rv34dsp_init_arm(c); +#elif ARCH_RISCV + ff_rv34dsp_init_riscv(c); #elif ARCH_X86 ff_rv34dsp_init_x86(c); #endif diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h index 2e9ec4eee4..b15424d4ae 100644 --- a/libavcodec/rv34dsp.h +++ b/libavcodec/rv34dsp.h @@ -79,6 +79,7 @@ void ff_rv34dsp_init(RV34DSPContext *c); void ff_rv40dsp_init(RV34DSPContext *c); void ff_rv34dsp_init_arm(RV34DSPContext *c); +void ff_rv34dsp_init_riscv(RV34DSPContext *c); void ff_rv34dsp_init_x86(RV34DSPContext *c); void ff_rv40dsp_init_aarch64(RV34DSPContext *c); -- 2.43.0