From patchwork Sat Oct 28 13:56:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 44404 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dd83:b0:15d:8365:d4b8 with SMTP id kw3csp472374pzb; Sat, 28 Oct 2023 06:56:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkIgGPwdtjk47X6S3JP+bj2abyBl+gCM6RdyoLCAykMxOia2z0Op0HUMDQ8ccc6gf7FEs9 X-Received: by 2002:a50:9f63:0:b0:53e:7ae7:bc5e with SMTP id b90-20020a509f63000000b0053e7ae7bc5emr4596313edf.3.1698501414256; Sat, 28 Oct 2023 06:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698501414; cv=none; d=google.com; s=arc-20160816; b=v6BBDG2q+pNRDSpsvxDeah7vASY0VMPz00OpasfMAUnBIeGwngB+wv33vfwObi1ecD /UKXLbkiwRC2mIhjdIxqYw1UyB7wwaUdwz4wp10A7BWwiuyrJPtUwff5xK51PYTWst2K AjCipNI8hcfan7ZnMe5rqWRClX6S2b0nrlcrPYu56UdiCr8eI51ayB9Zuws1tJPueRNx V6AQ6ucuR23VQ+rkRikOwNFntrsmL/ifr6VMW0DacQn0of4TxR0Klei5Y4uCtNxrh3AP APAkz+XF1n1mYvuZ7wnLyeWpbg6xFCQircMOOV2rTCS4/Wwk6vMAhjhkdDjdq4zi9WlG cIyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=YGQmAqEHHlsRmxiAyAjZwWVnJH7Md7ZHw1xPlpI5M74=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=eO52ENE727YbEimW3zaLApDZSfBfEbZdvBIfaPcNxbWBh7XTcI+pUIQ9D4SEj/M7OS qDtoFPvaC/EJiQUZsY3TXBxqkk9xncrpI9PqGw8LWzW5EtCWKuoRgqwDEi6OJclKPuWh BRdBbjq+5PkFb2umDOdhiO0NkU5tSoOq2VdtJsHrkhGxLNS9hA6jGF3LaeF+lvXl4xr3 dqago0EGz0uD3rRMrLUcO0Ovsi0SWomj278ZtjXyKg043OUoTJgwps4IoxCaO+gxeJMV 6fAuesJpU/yW+JL+d/PP8Zn16WB5fH7LLs3po5VqhjN3WKyDmysrAY8OJ8rZ9YXD8+SQ mgag== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q24-20020a50aa98000000b00533cae6dce0si1668487edc.624.2023.10.28.06.56.52; Sat, 28 Oct 2023 06:56:54 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EBF1368C9EB; Sat, 28 Oct 2023 16:56:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4806868C6BF for ; Sat, 28 Oct 2023 16:56:42 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id D1D31C006B for ; Sat, 28 Oct 2023 16:56:41 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Oct 2023 16:56:40 +0300 Message-ID: <20231028135641.49976-1-remi@remlab.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/huffyuvdsp: R-V V add_int16 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: qpSmJwhOEVRt add_int16_128_c: 2390.5 add_int16_128_rvv_i32: 832.0 add_int16_rnd_width_c: 2390.2 add_int16_rnd_width_rvv_i32: 832.5 --- libavcodec/huffyuvdsp.c | 4 +++- libavcodec/huffyuvdsp.h | 2 ++ libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/huffyuvdsp_init.c | 37 ++++++++++++++++++++++++++++++ libavcodec/riscv/huffyuvdsp_rvv.S | 37 ++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/huffyuvdsp_init.c create mode 100644 libavcodec/riscv/huffyuvdsp_rvv.S diff --git a/libavcodec/huffyuvdsp.c b/libavcodec/huffyuvdsp.c index fb98836cc4..80587dac85 100644 --- a/libavcodec/huffyuvdsp.c +++ b/libavcodec/huffyuvdsp.c @@ -87,7 +87,9 @@ av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt c->add_hfyu_median_pred_int16 = add_hfyu_median_pred_int16_c; c->add_hfyu_left_pred_bgr32 = add_hfyu_left_pred_bgr32_c; -#if ARCH_X86 +#if ARCH_RISCV + ff_huffyuvdsp_init_riscv(c, pix_fmt); +#elif ARCH_X86 ff_huffyuvdsp_init_x86(c, pix_fmt); #endif } diff --git a/libavcodec/huffyuvdsp.h b/libavcodec/huffyuvdsp.h index 90e50b5429..34bed58ef2 100644 --- a/libavcodec/huffyuvdsp.h +++ b/libavcodec/huffyuvdsp.h @@ -34,6 +34,8 @@ typedef struct HuffYUVDSPContext { } HuffYUVDSPContext; void ff_huffyuvdsp_init(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt); +void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c, + enum AVPixelFormat pix_fmt); void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt); #endif /* AVCODEC_HUFFYUVDSP_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 69d5980e65..9c31c901cf 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -18,6 +18,8 @@ OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_init.o RVV-OBJS-$(CONFIG_G722DSP) += riscv/g722dsp_rvv.o OBJS-$(CONFIG_H264CHROMA) += riscv/h264_chroma_init_riscv.o RVV-OBJS-$(CONFIG_H264CHROMA) += riscv/h264_mc_chroma.o +OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_init.o +RVV-OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_rvv.o OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_init.o diff --git a/libavcodec/riscv/huffyuvdsp_init.c b/libavcodec/riscv/huffyuvdsp_init.c new file mode 100644 index 0000000000..0f7bc4d692 --- /dev/null +++ b/libavcodec/riscv/huffyuvdsp_init.c @@ -0,0 +1,37 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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/huffyuvdsp.h" + +void ff_add_int16_rvv(uint16_t *dst, const uint16_t *src, unsigned m, int w); + +av_cold void ff_huffyuvdsp_init_riscv(HuffYUVDSPContext *c, + enum AVPixelFormat pix_fmt) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32) + c->add_int16 = ff_add_int16_rvv; +#endif +} diff --git a/libavcodec/riscv/huffyuvdsp_rvv.S b/libavcodec/riscv/huffyuvdsp_rvv.S new file mode 100644 index 0000000000..f8926fdaea --- /dev/null +++ b/libavcodec/riscv/huffyuvdsp_rvv.S @@ -0,0 +1,37 @@ +/* + * Copyright © 2023 Rémi Denis-Courmont. + * + * 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_add_int16_rvv, zve32x +1: + vsetvli t0, a3, e16, m8, ta, ma + vle16.v v16, (a0) + sub a3, a3, t0 + vle16.v v24, (a1) + sh1add a1, t0, a1 + vadd.vv v16, v16, v24 + vand.vx v16, v16, a2 + vse16.v v16, (a0) + sh1add a0, t0, a0 + bnez a3, 1b + + ret +endfunc