From patchwork Wed May 29 14:59:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49347 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:8f0d:0:b0:460:55fa:d5ed with SMTP id i13csp706521vqu; Wed, 29 May 2024 08:00:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXFzTuENp7o88uU0OZlQd7O9CfOxroNA2kvc4PeTZbhwQbbDOwx6UlJS3ZbZ44Zie2eKBdVsfkv0iC59Dev0yja03Z9uesTFQDKFw== X-Google-Smtp-Source: AGHT+IETPa/VO+CXlKA+LLU/YLX8Ar3vNv6SQKHXHvLJrrOUDdiEqv2sovWfxHn1yFuSwnKP6otX X-Received: by 2002:a17:907:7ea1:b0:a62:fcf7:8927 with SMTP id a640c23a62f3a-a62fcf78a7cmr1197322066b.56.1716994808863; Wed, 29 May 2024 08:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716994808; cv=none; d=google.com; s=arc-20160816; b=qokyMLSZCN+nNRIsS1cff1lJj9+Xa4Eapz814etUHGCGI05QN5hQWew3bFqT/bRPhA KkP7I46/HU2Uh1jboqgD51HSYwJmkhue9e5eTqXMVNs1YrxzLnhOTmsAbXhFEOG2F0qy MgiDBzKdipJOJvF2oCJO4Qe057VBulqdDe5N0rfPPGyIepH6NNGxVIbgHccF/e5wLxvp GF83V1fck1qjuMHvyt0JEVubTVAJ2rJqYmnvusyxpcZL24Uagqw0Ba1e2TFfTFAka/rR 6MtD/KU6JMEpjmFwgM/ha3iK4Ri9DIZued1594FKptQbx8lxDd2cTCw/C+cP+Asli4yR tNkQ== 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=YH+3E6O3uRKGWvhb2eDNdKrEVNj4dUu7WeZgD75jrUg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lrNyZybCSsHn27qtKS6X2MJo7gsaCcMzQI7ulTmrelw/io7qTEZhs8leaGpcEi+Hd1 YbL37wJ9DIx585smSZxPQys/jHOQUbQQfrrq/EMFa6cqu+sJGF3LM3GFhfZM4LpILsdG sK6x8G0tdWYbjCtsBLMgzNuYoqUx2PI9jtm1TDGRuSEVSzT0SirXrR2zwJcRyM2l/yQh 3NsaJhOv6NU4Ag62jESSJXsh5ZtEzDjeP/A2vLsPCoPFY3AKs3OsZdoxCU9BSx3JqUUj N3NiiR5SLoUeaclbEQFgDkWVeRyOh0Zxn1fH/2j+c4JcHsBtMWb5IoWmLuDr+BSw0M7a F0kw==; dara=google.com 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 a640c23a62f3a-a626cc66decsi620635766b.599.2024.05.29.08.00.07; Wed, 29 May 2024 08:00:08 -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 01BE268D2FE; Wed, 29 May 2024 18:00:04 +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 A674E68D189 for ; Wed, 29 May 2024 17:59:56 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 28EBBC006D for ; Wed, 29 May 2024 17:59:56 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 29 May 2024 17:59:52 +0300 Message-ID: <20240529145955.32189-1-remi@remlab.net> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] lavu/float_dsp: add double-precision scalar product 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: N6GvbjpbooZ3 The function pointer is appended to the structure for backward binary compatibility. Fortunately, this is allocated by libavutil, not by the user, so increasing the structure size is safe. --- doc/APIchanges | 3 +++ libavutil/float_dsp.c | 12 ++++++++++++ libavutil/float_dsp.h | 14 ++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 60f056b863..50c51c664f 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-05-29 - xxxxxxxxxx - lavu 59.21.100 - float_dsp.h + Add AVFloatDSPContext.scalarproduct_double. + 2024-05-23 - xxxxxxxxxx - lavu 59.20.100 - channel_layout.h Add av_channel_layout_ambisonic_order(). diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c index e9fb023466..1c5bb05636 100644 --- a/libavutil/float_dsp.c +++ b/libavutil/float_dsp.c @@ -132,6 +132,17 @@ float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len) return p; } +static double ff_scalarproduct_double_c(const double *v1, const double *v2, + size_t len) +{ + double p = 0.0; + + for (size_t i = 0; i < len; i++) + p += v1[i] * v2[i]; + + return p; +} + av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) { AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext)); @@ -149,6 +160,7 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) fdsp->vector_fmul_reverse = vector_fmul_reverse_c; fdsp->butterflies_float = butterflies_float_c; fdsp->scalarproduct_float = avpriv_scalarproduct_float_c; + fdsp->scalarproduct_double = ff_scalarproduct_double_c; #if ARCH_AARCH64 ff_float_dsp_init_aarch64(fdsp); diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h index 342a8715c5..b6b5b0a3b3 100644 --- a/libavutil/float_dsp.h +++ b/libavutil/float_dsp.h @@ -19,6 +19,8 @@ #ifndef AVUTIL_FLOAT_DSP_H #define AVUTIL_FLOAT_DSP_H +#include + typedef struct AVFloatDSPContext { /** * Calculate the entry wise product of two vectors of floats and store the result in @@ -187,6 +189,18 @@ typedef struct AVFloatDSPContext { */ void (*vector_dmul)(double *dst, const double *src0, const double *src1, int len); + + /** + * Calculate the scalar product of two vectors of doubles. + * + * @param v1 first vector + * @param v2 second vector + * @param len length of vectors + * + * @return inner product of the vectors + */ + double (*scalarproduct_double)(const double *v1, const double *v2, + size_t len); } AVFloatDSPContext; /** diff --git a/libavutil/version.h b/libavutil/version.h index 9c7146c228..9d08d56884 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 20 +#define LIBAVUTIL_VERSION_MINOR 21 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \