From patchwork Sun May 12 12:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: uk7b@foxmail.com X-Patchwork-Id: 48815 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1706:b0:1af:cdee:28c5 with SMTP id nv6csp560955pzb; Sun, 12 May 2024 05:43:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWmOAVdSlVALV+Fs3+6yPw5r1bLzfiYcVf6O85KVTUhMr8txbm/AQpE8DpxUCoYpaUWfLTBackobTESy0NboyBSA0cpePPpbJPJCw== X-Google-Smtp-Source: AGHT+IF0BWPJ7TZKKH9F7PJkIh1qQK4savLxU97c1qYwbQh3KhYEzrnDDh529k/dfwe1EMFyFFld X-Received: by 2002:a17:906:852:b0:a59:aa0d:6d with SMTP id a640c23a62f3a-a5a2d6287b5mr438247166b.62.1715517827774; Sun, 12 May 2024 05:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715517827; cv=none; d=google.com; s=arc-20160816; b=mpLGMmzVpgor5Kmq7180wD641Md9hXax/0XJ/WWY4Ie5r26a0kWvZ/cbBWsrZTwKRv dEQvpH8mtkNmDGLa7V6jDTL+x0xRxGmMecGJoCpjUNhGrv2Cm0ChA0LsYwvJ0ynaD2ff F9mfmmU5A6OuInpFULjy1qV0XlFWaPkVGag6/CAeuWWJlF9Cno0Kj+QZX5Mcy8fhdliE s07GRANTGfEu5UnhqnNThD7dThWxl1/imX5RGEBxpRWfnfSg+e86/y7a+QwURKUkLEFm KQiSM19h087MGZ6vBws3qW13R3U8zPsZOQ+oWlEywHkxXufIcgCUW3sMjUeSsloAUGUw 9P+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=MbP3ENu3E1HLzVhluQNJzEoTPCfugzzikxYbNRiBml0=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=ddmJh9QbOjR5JzHXHKIZNAc2/6FHp4EdtUCg8G1ZOGSKuq8dekjNMcRwVIdNzczhKU nex/II3rAkqdR6CrtyE449UwP6Z57JXbe2Y+hGDFXkmYjFmslD4AmPIK3cSRqJiiqxqV LECB0KMJfbRPRud+c0uiYhU/NoCayOJDHapz/5hmZXFHO8gShPesDELoxYCc4onEwyjI QK0lAKbqJjIAPPh1Xynv4HrBzkJbWuZs5+g72xIT5byJC3hI4itf+9zf+l7CO3dQmALR QjnFTsNDhehweQGVwgZrPr5uawZZ4mWK/Sjd+q71KR71Qewjk5ZSg+QPu30+wiiiGgO+ M7Ng==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=i7e5a3EY; 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=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a5a17946063si402069766b.100.2024.05.12.05.43.46; Sun, 12 May 2024 05:43:47 -0700 (PDT) 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=@foxmail.com header.s=s201512 header.b=i7e5a3EY; 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=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2F12D68D647; Sun, 12 May 2024 15:43:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-205.mail.qq.com (out203-205-221-205.mail.qq.com [203.205.221.205]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4CCBC68D5B3 for ; Sun, 12 May 2024 15:43:34 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1715517799; bh=986vP8jBavy/F8HY6a1fNGrmJwCA9aYU3zdAbQe5D+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i7e5a3EY0fMVS8kuM2Zm0CFU6EiPRmIwG+6RWPGd0N6iDYFpasJgf08gk9wY5fJ+f MIGjT2tUyD09OVvqIE/Y7x7W3ClRiuEomT6WdI4jAETrhtWzXBnBWZMBP9FtfSBR1C QQRM1YMwKpao+tb8eiUjingG/D/Nlhl/Ki7rwW8g= Received: from localhost.localdomain ([42.56.223.122]) by newxmesmtplogicsvrszc13-0.qq.com (NewEsmtp) with SMTP id AD238015; Sun, 12 May 2024 20:43:18 +0800 X-QQ-mid: xmsmtpt1715517798tifkruccu Message-ID: X-QQ-XMAILINFO: MFWpArBVhhGTwIlVUBnXsgNQzpcFl2vOcCEboPjCzZzU9u1/fmj4WjWGiU18jG cOhYLR2/5jJ/u1tYjgSniaXJr+wSB1N+rp/zW1kpeBG039oFPYYJ3skwrCIbu8/tWjwoVUMFB5zK UeSvaKTwdSMQ8v37QGeQcwdY84qXYjWRl2uit6HNeHJBOYAO4DiWEaY8do1f2qnp64frl+v1xj3Z 72orG9Mv9g0x67ouNwR2UejT4N2Jh3UvCPQjRjA2mmvo+mdyEvWRB8qow1WbVls7DdXi53osWcCv GLtjSHOd0BPj5l15Y8RCt0IrLoOymP7IHIrJhPhZdYhzrUymN35cshEozIW0DC1/94DopkP4zG0r LrXE4SCG/Wr9njd73Vj0nkoV8EHuy8bI9Jf4wHK6IXGktoA5y0tTqS/wN0SdI0kTpBsBKlc3h6IH QaGhtzawdQQ3pY+BmbEofmC0iLxFBb1+yq0q4aMSIDTciwnRGJ2ozamS0hiaP5onl8ngoTkyWWol dIxzFFKkXeq5mmSlrl5BG0FYKBJycyEgp2SHUPF5CLM/Oeg8BB0Eg3g1TWI3BiJ2h7oW62qHLiNr cyCRRSvKn+Z2zmKWIoopV8hjYsw0RttuYgyEC47lNSG0g0iOy2IjuzDpnqlHNh5R7A8asuwKpvYL UtpdQpMnavCi2dmfuYMmnXYDnNCblP+iqlEap/DOVORGx32Fzn/zauFjnjIkJ5R7StfBUqnc1i/k KPIvyn62ZvY4YFZFSXvtyGGFkTR0sMGa5tFOZ1pZy2BuWgcRwPuGLhQEZ37Gv5s801YhJAZqTlx1 rwl6eMWI+FhExYEefTTaHScIKwb+0bk1ZTku4Tbbjm5pPW1iWFS4B1dVqi93sG4GOjPKR5RA0U8m pFan5NXBHefW0SKrVoVbdfG6mASEC/rOimglhoTfqqQz1eWskSJkvMEIkUBWhX/w== X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 May 2024 20:43:15 +0800 X-OQ-MSGID: <20240512124315.1807803-1-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <3172497.tWg0yfUdDb@basile.remlab.net> References: <3172497.tWg0yfUdDb@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/vc1dsp: R-V V mspel_pixels 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 Cc: sunyuechi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7kq4B806bDUC From: sunyuechi C908 X60 vc1dsp.avg_vc1_mspel_pixels_tab[0][0]_c : 14.7 13.2 vc1dsp.avg_vc1_mspel_pixels_tab[0][0]_rvv_i32 : 2.5 2.2 vc1dsp.avg_vc1_mspel_pixels_tab[1][0]_c : 3.7 3.5 vc1dsp.avg_vc1_mspel_pixels_tab[1][0]_rvv_i64 : 1.0 1.2 vc1dsp.put_vc1_mspel_pixels_tab[0][0]_c : 9.0 8.0 vc1dsp.put_vc1_mspel_pixels_tab[0][0]_rvi : 1.0 1.0 vc1dsp.put_vc1_mspel_pixels_tab[1][0]_c : 2.5 2.2 vc1dsp.put_vc1_mspel_pixels_tab[1][0]_rvi : 0.5 0.5 --- libavcodec/riscv/Makefile | 1 + libavcodec/riscv/vc1dsp_init.c | 16 +++++++++++- libavcodec/riscv/vc1dsp_rvi.S | 47 +++++++++++++++++++++++++++++++++ libavcodec/riscv/vc1dsp_rvv.S | 48 ++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/vc1dsp_rvi.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index f2348e259e..6f4869145a 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -58,6 +58,7 @@ RVV-OBJS-$(CONFIG_TAK_DECODER) += riscv/takdsp_rvv.o OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_init.o RVV-OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_rvv.o OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_init.o +RV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvi.o RVV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvv.o OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_init.o RV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvi.o diff --git a/libavcodec/riscv/vc1dsp_init.c b/libavcodec/riscv/vc1dsp_init.c index e47b644f80..2b7071d6ff 100644 --- a/libavcodec/riscv/vc1dsp_init.c +++ b/libavcodec/riscv/vc1dsp_init.c @@ -29,19 +29,33 @@ void ff_vc1_inv_trans_8x8_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block void ff_vc1_inv_trans_4x8_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block); void ff_vc1_inv_trans_8x4_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block); void ff_vc1_inv_trans_4x4_dc_rvv(uint8_t *dest, ptrdiff_t stride, int16_t *block); +void ff_put_pixels16x16_rvi(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd); +void ff_put_pixels8x8_rvi(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd); +void ff_avg_pixels16x16_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd); +void ff_avg_pixels8x8_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t line_size, int rnd); av_cold void ff_vc1dsp_init_riscv(VC1DSPContext *dsp) { -#if HAVE_RVV +#if HAVE_RV int flags = av_get_cpu_flags(); +# if __riscv_xlen >= 64 + if (flags & AV_CPU_FLAG_RVI & AV_CPU_FLAG_RV_MISALIGNED) { + dsp->put_vc1_mspel_pixels_tab[1][0] = ff_put_pixels8x8_rvi; + dsp->put_vc1_mspel_pixels_tab[0][0] = ff_put_pixels16x16_rvi; + } +# endif +#if HAVE_RVV if (flags & AV_CPU_FLAG_RVV_I32 && ff_get_rv_vlenb() >= 16) { dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_rvv; dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_rvv; + dsp->avg_vc1_mspel_pixels_tab[0][0] = ff_avg_pixels16x16_rvv; if (flags & AV_CPU_FLAG_RVV_I64) { dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_rvv; dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_rvv; + dsp->avg_vc1_mspel_pixels_tab[1][0] = ff_avg_pixels8x8_rvv; } } #endif +#endif } diff --git a/libavcodec/riscv/vc1dsp_rvi.S b/libavcodec/riscv/vc1dsp_rvi.S new file mode 100644 index 0000000000..d4a1b5bf49 --- /dev/null +++ b/libavcodec/riscv/vc1dsp_rvi.S @@ -0,0 +1,47 @@ +/* + * 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" + +#if __riscv_xlen >= 64 +func ff_put_pixels8x8_rvi +.rept 8 + ld t0, (a1) + sd t0, (a0) + add a1, a1, a2 + add a0, a0, a2 +.endr + + ret +endfunc + +func ff_put_pixels16x16_rvi +.rept 16 + ld t0, (a1) + ld t1, 8(a1) + sd t0, (a0) + sd t1, 8(a0) + add a1, a1, a2 + add a0, a0, a2 +.endr + + ret +endfunc +#endif diff --git a/libavcodec/riscv/vc1dsp_rvv.S b/libavcodec/riscv/vc1dsp_rvv.S index 4a00945ead..7c2b47f66c 100644 --- a/libavcodec/riscv/vc1dsp_rvv.S +++ b/libavcodec/riscv/vc1dsp_rvv.S @@ -111,3 +111,51 @@ func ff_vc1_inv_trans_4x4_dc_rvv, zve32x vsse32.v v0, (a0), a1 ret endfunc + +.macro mspel_op op pos n1 n2 + add t1, \pos, a2 + v\op\()e8.v v\n1, (\pos) + sh1add \pos, a2, \pos + v\op\()e8.v v\n2, (t1) +.endm + +.macro mspel_op_all op pos a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 + mspel_op \op \pos \a1 \a2 + mspel_op \op \pos \a3 \a4 + mspel_op \op \pos \a5 \a6 + mspel_op \op \pos \a7 \a8 + mspel_op \op \pos \a9 \a10 + mspel_op \op \pos \a11 \a12 + mspel_op \op \pos \a13 \a14 + mspel_op \op \pos \a15 \a16 +.endm + +func ff_avg_pixels16x16_rvv, zve32x + csrwi vxrm, 0 + vsetivli zero, 16, e8, m1, ta, ma + mspel_op_all l a1 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 + mspel_op_all l a0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + vsetvli t0, zero, e8, m8, ta, ma + sub a0, a0, a2 + vaaddu.vv v0, v0, v16 + neg a2, a2 + vaaddu.vv v8, v8, v24 + vsetivli zero, 16, e8, m1, ta, ma + mspel_op_all s a0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + + ret +endfunc + +func ff_avg_pixels8x8_rvv, zve64x + csrwi vxrm, 0 + li t0, 64 + vsetivli zero, 8, e8, mf2, ta, ma + vlse64.v v16, (a1), a2 + vlse64.v v8, (a0), a2 + vsetvli zero, t0, e8, m4, ta, ma + vaaddu.vv v16, v16, v8 + vsetivli zero, 8, e8, mf2, ta, ma + vsse64.v v16, (a0), a2 + + ret +endfunc