From patchwork Tue Sep 27 20:04:21 2022 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: 38384 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp776193pzh; Tue, 27 Sep 2022 13:04:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7VKd8rLyRoij+BJHQ59d69by2JX2CQhVNCAvhb8xc80HLvRYzHIn5A+Jvy/FpwIcgzcDCI X-Received: by 2002:a17:907:7fa0:b0:782:948b:e212 with SMTP id qk32-20020a1709077fa000b00782948be212mr20696728ejc.231.1664309078321; Tue, 27 Sep 2022 13:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664309078; cv=none; d=google.com; s=arc-20160816; b=tTUQXfd8RJdmv4F2bXU7iWp0pOh79IMFuTMaTCLD9pVAOAD+9e4tEk9d6iNFGYICtT q12/Q17jFBTRWxYvwu4F78ExgqZPx59rDNm1djyQClftEYewS0DFt9Qip0pRujUgqb16 QdluQU5s03dI0oYNmNkkD6jGf1oKj3AhzyHwLFa3caIsku57C3MRqQtEbdxg3dLrdLiu Gls0EZu1ldPFdl1W9H1e5ElvTwtq8p6Cm47tOEYH7dvAdebsKocwnLYyrV7Lddf5jjM/ FSzLdWYw/Gdn6UYxTjVZz5wlYLcpLuZDALXZZDv+S1sEIWy8xvwC189KG/4YWHXy3DXf AOGw== 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:references:in-reply-to:message-id :date:to:from:delivered-to; bh=HyeA28eMfamp25p9SqAhTVAflzJRtMtkJ+2fW3AUDQ0=; b=0mXn8LcitsIgpv2zKhm75ljQlZiwixrLT1CQtJl/GbTIDc8KjODnKa2zbi6J11shHT WTrtgB7D78jW7OCq5aslVLSnKl5c7D2idzL8HuPmbtZ5hPtQw6MtI9yglf010NqEF+5W S3LqDFYraUt+F3V4zWisEkPsrwRYiGcbLURm2tuH+OYYKS3P/rcH6l47hJtFYjX7ijYw reZFjJfMZQhHL7sL0NQuCicjEn2L4ojbvX+NWJJxm05kNanTmeYcAXEAXgATsQecTtFI 2z2FeF5PqQFs6jaCKt01spUWBTUEFrk/EbSG0WvOCZRbMajTUKRv9bm6mYP3Wbv1j/sw XKXg== 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 hq28-20020a1709073f1c00b0078307781936si2501275ejc.359.2022.09.27.13.04.36; Tue, 27 Sep 2022 13:04:38 -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 2FF6068BAE8; Tue, 27 Sep 2022 23:04:34 +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 31B2168BA58 for ; Tue, 27 Sep 2022 23:04:28 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id D2D63C0012 for ; Tue, 27 Sep 2022 23:04:27 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Sep 2022 23:04:21 +0300 Message-Id: <20220927200427.11811-1-remi@remlab.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <2846208.e9J7NaK4W3@basile.remlab.net> References: <2846208.e9J7NaK4W3@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7] lavu/riscv: helper to read the vector length 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: MprgUgHEhqa6 From: Rémi Denis-Courmont --- libavutil/riscv/cpu.h | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 libavutil/riscv/cpu.h diff --git a/libavutil/riscv/cpu.h b/libavutil/riscv/cpu.h new file mode 100644 index 0000000000..56035f8556 --- /dev/null +++ b/libavutil/riscv/cpu.h @@ -0,0 +1,45 @@ +/* + * Copyright © 2022 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 + */ + +#ifndef AVUTIL_RISCV_CPU_H +#define AVUTIL_RISCV_CPU_H + +#include "config.h" +#include +#include "libavutil/cpu.h" + +#if HAVE_RVV +/** + * Returns the vector size in bytes (always a power of two and at least 4). + * This is undefined behaviour if vectors are not implemented. + */ +static inline size_t ff_get_rv_vlenb(void) +{ + size_t vlenb; + + __asm__ ( + ".option push\n" + ".option arch, +v\n" + " csrr %0, vlenb\n" + ".option pop\n" : "=r" (vlenb)); + return vlenb; +} +#endif +#endif