From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id 42419469C9
	for <ffmpegdev@gitmailbox.com>; Thu, 31 Aug 2023 15:33:05 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E68068C7AB;
	Thu, 31 Aug 2023 18:33:03 +0300 (EEST)
Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com
 [209.85.128.51])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5AED68C718
 for <ffmpeg-devel@ffmpeg.org>; Thu, 31 Aug 2023 18:32:57 +0300 (EEST)
Received: by mail-wm1-f51.google.com with SMTP id
 5b1f17b1804b1-401b393df02so10099525e9.1
 for <ffmpeg-devel@ffmpeg.org>; Thu, 31 Aug 2023 08:32:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1693495976; x=1694100776; darn=ffmpeg.org;
 h=user-agent:in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:to:from:date:from:to:cc:subject
 :date:message-id:reply-to;
 bh=s7hUS23l/wUM2RF8iSpVODBSgNODRlPvPxUqxbmc3fI=;
 b=qHXiCeU9LdYL59G71qstSXFySKstoLB+hlweA6+jDVUSZ+0Rwh/OH/9EGqdBBIXJx+
 fmY2GgTgAdKgqhbFtrVIWsk6sxhZfhosstHpbIdhuD9cwx3IkU/LAWlZcnXHgJvvrsF9
 M685wec51pnFF5wtKtb4np6eTIe2v/+FvcC34qKoPBV9p/c4zH/UJ/HOXZKZHyKJw2Wy
 tZkFaZ5EK0SQx1ixUmHDSA9CsS+zqBtggmEQOAiVMx3D8R8ojTUkAl0DxmFGDBp/TRuV
 E5H0t46qeVKBwPkRcLK9eQrNghaMd3dKfxBlGqtXKnbPy7gYFtZilfO0ucThr7vPFoJh
 W1bA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1693495976; x=1694100776;
 h=user-agent:in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:to:from:date:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=s7hUS23l/wUM2RF8iSpVODBSgNODRlPvPxUqxbmc3fI=;
 b=HvMNRWscOxebOLn7TcplzbLimswEXj2eEyRWXp2V5M+KD0uJCa8cBAkYs+M+JjdGyP
 KytfG22WQsi/dJ74bedwLjnKt4GzOj+qgiGAcdTCpI491rNlf98C8EkNx4nC13+ujnhE
 FqEq6s1ymFjEvOFW//F3frLCaGharD6aBKoM156VaxiTX3hXTNevVdlog3KmrPBAh2Az
 KFw1klSokeiKE30caMr/azwicP8WBlCfLD/WYMsZM+z/HHUSygl4gZN9LazgtV98boqo
 dovRS1vgHEvaaxcPGJhVUNJJyoWRMip4zXYxV8xcFx+aRN/vAaNsCoQCdXFCCROfad/3
 V6SA==
X-Gm-Message-State: AOJu0Yz8SkQ59nBt0UftQJaH3UAPxQ7q/ldSDktRERkYQOHqTqF8NLiX
 0p18DZ8SfoUJ7b+XOE53uf7d0y188vY=
X-Google-Smtp-Source: AGHT+IGjAGmTtdnNycufiPacR4lqDHH4nmssX/e++pG5G/SCIq+K97Zu5Rh9Pz7exO6zNsTSjNRyow==
X-Received: by 2002:a7b:c45a:0:b0:3fe:19cf:93c9 with SMTP id
 l26-20020a7bc45a000000b003fe19cf93c9mr4489575wmi.1.1693495976197; 
 Thu, 31 Aug 2023 08:32:56 -0700 (PDT)
Received: from mariano ([82.84.194.139]) by smtp.gmail.com with ESMTPSA id
 d4-20020adfe884000000b0030ae53550f5sm2539484wrm.51.2023.08.31.08.32.55
 for <ffmpeg-devel@ffmpeg.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 31 Aug 2023 08:32:55 -0700 (PDT)
Received: by mariano (Postfix, from userid 1000)
 id 1F3B4BFCDA; Thu, 31 Aug 2023 17:32:54 +0200 (CEST)
Date: Thu, 31 Aug 2023 17:32:54 +0200
From: Stefano Sabatini <stefasab@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <ZPCypjo1y7CZEJ4T@mariano>
Mail-Followup-To: FFmpeg development discussions and patches
 <ffmpeg-devel@ffmpeg.org>
References: <20230826122328.95416-1-stefasab@gmail.com>
 <DU0P250MB074716BF4EB559C52F4F32EF8FE2A@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="oTXpCB2QLRWr7SHp"
Content-Disposition: inline
In-Reply-To: <DU0P250MB074716BF4EB559C52F4F32EF8FE2A@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM>
User-Agent: Mutt/2.1.4 (2021-12-11)
Subject: Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce
 sws_get_gaussian_vec
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/ZPCypjo1y7CZEJ4T@mariano/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>


--oTXpCB2QLRWr7SHp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On date Saturday 2023-08-26 17:15:27 +0200, Andreas Rheinhardt wrote:
> Stefano Sabatini:
> > Use in place of sws_getGaussianVec.
> > 
> > The new function enable better log handling, and provide better naming
> 
> Better log handling? Why?
> 
> > for the variance variable, now named standard_deviation to reflect the
> > meaning of the parameter.
> > ---
> >  doc/APIchanges             |  3 +++
> >  libswscale/swscale.h       | 21 ++++++++++++++++++-
> >  libswscale/utils.c         | 41 +++++++++++++++++++++++++++++---------
> >  libswscale/version.h       |  2 +-
> >  libswscale/version_major.h |  4 ++++
> >  5 files changed, 60 insertions(+), 11 deletions(-)
> > 
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index ad1efe708d..bad2d61027 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
> >  
> >  API changes, most recent first:
> >  
> > +2023-08-26 - xxxxxxxxxx - lsws 7.4.100 - swscale.h
> > +  Introduce sws_get_gaussian_vec, use in place of sws_getGaussianVec.
> > +
> >  2023-08-18 - xxxxxxxxxx - lavu 58.17.100 - channel_layout.h
> >    All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
> >  
> > diff --git a/libswscale/swscale.h b/libswscale/swscale.h
> > index 9d4612aaf3..f002b5c7d2 100644
> > --- a/libswscale/swscale.h
> > +++ b/libswscale/swscale.h
> > @@ -355,11 +355,30 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
> >   */
> >  SwsVector *sws_allocVec(int length);
> >  
> > +#if FF_API_SWS_GET_GAUSSIAN_VEC
> >  /**
> > - * Return a normalized Gaussian curve used to filter stuff
> > + * Return a normalized Gaussian curve used to filter stuff.
> > + *
> >   * quality = 3 is high quality, lower is lower quality.
> >   */
> >  SwsVector *sws_getGaussianVec(double variance, double quality);
> 
> Missing attribute_deprecated as well as the @deprecated doxygen thing
> refering to its replacement.

Updated.

--oTXpCB2QLRWr7SHp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="0001-lsws-swscale.h-introduce-sws_get_gaussian_vec.patch"

>From 49efd5c9d711ba605bd19be67adc425dc52aeeb1 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini <stefasab@gmail.com>
Date: Sat, 26 Aug 2023 14:20:35 +0200
Subject: [PATCH 1/4] lsws/swscale.h: introduce sws_get_gaussian_vec

Use in place of sws_getGaussianVec.

The new function enable better error handling, and provide better naming
for the variance variable, now named standard_deviation to reflect the
meaning of the parameter.
---
 doc/APIchanges             |  3 +++
 libswscale/swscale.h       | 25 ++++++++++++++++++++++-
 libswscale/utils.c         | 42 ++++++++++++++++++++++++++++++--------
 libswscale/version.h       |  2 +-
 libswscale/version_major.h |  4 ++++
 5 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ad1efe708d..bad2d61027 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-08-26 - xxxxxxxxxx - lsws 7.4.100 - swscale.h
+  Introduce sws_get_gaussian_vec, use in place of sws_getGaussianVec.
+
 2023-08-18 - xxxxxxxxxx - lavu 58.17.100 - channel_layout.h
   All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
 
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 9d4612aaf3..febcb97bfd 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -355,11 +355,34 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
  */
 SwsVector *sws_allocVec(int length);
 
+#if FF_API_SWS_GET_GAUSSIAN_VEC
 /**
- * Return a normalized Gaussian curve used to filter stuff
+ * Return a normalized Gaussian curve used to filter stuff.
+ *
  * quality = 3 is high quality, lower is lower quality.
+ * @deprecated use sws_get_gaussian_vector()
  */
+attribute_deprecated
 SwsVector *sws_getGaussianVec(double variance, double quality);
+#endif
+
+/**
+ * Compute and return a normalized Gaussian vector.
+ *
+ * @param vecp: pointer where the computed vector is put in case of
+ *        success
+ * @param log_ctx context used for logging, can be NULL
+ * @param standard_deviation the standard deviation used to generate
+ *        the Gaussian vector, must be a non-negative value
+ * @param quality the quality of the generated Gaussian vector, must
+ *        be a non-negative value. It affects the lenght of the generated
+ *        vector. A value equal to 3 corresponds to high quality.
+ *
+ * @return a negative error code on error, non negative otherwise
+ */
+int sws_get_gaussian_vec(SwsVector **vecp,
+                         AVClass *log_ctx,
+                         double standard_deviation, double quality);
 
 /**
  * Scale all the coefficients of a by the scalar value.
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 8e74c6603e..e56df87d9f 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2139,31 +2139,55 @@ SwsVector *sws_allocVec(int length)
     return vec;
 }
 
-SwsVector *sws_getGaussianVec(double variance, double quality)
+int sws_get_gaussian_vec(SwsVector **vecp,
+                         AVClass *log_ctx,
+                         double standard_deviation, double quality)
 {
-    const int length = (int)(variance * quality + 0.5) | 1;
+    const int length = (int)(standard_deviation * quality + 0.5) | 1;
     int i;
     double middle  = (length - 1) * 0.5;
     SwsVector *vec;
+    const double variance = standard_deviation * standard_deviation;
 
-    if(variance < 0 || quality < 0)
-        return NULL;
+    if (standard_deviation < 0 || quality < 0) {
+        av_log(NULL, AV_LOG_ERROR,
+               "Invalid negative standard deviation %f or quality %f provided as input to the sws_get_gaussian_vec function\n",
+               standard_deviation, quality);
+        return AVERROR(EINVAL);
+    }
 
     vec = sws_allocVec(length);
-
-    if (!vec)
-        return NULL;
+    if (!vec) {
+        av_log(log_ctx, AV_LOG_ERROR,
+               "Could not allocate vector for the sws_get_gaussian_vec function\n");
+        return AVERROR(ENOMEM);
+    }
 
     for (i = 0; i < length; i++) {
         double dist = i - middle;
-        vec->coeff[i] = exp(-dist * dist / (2 * variance * variance)) /
-                        sqrt(2 * variance * M_PI);
+        vec->coeff[i] = exp(-dist * dist / (2 * variance)) /
+                        sqrt(2 * standard_deviation * M_PI);
     }
 
     sws_normalizeVec(vec, 1.0);
+    *vecp = vec;
 
+    return 0;
+}
+
+#if FF_API_SWS_GET_GAUSSIAN_VEC
+SwsVector *sws_getGaussianVec(double variance, double quality)
+{
+    SwsVector *vec;
+    int ret;
+
+    ret = sws_get_gaussian_vec(&vec, NULL, variance, quality);
+    if (ret < 0) {
+        return NULL;
+    }
     return vec;
 }
+#endif // FF_API_SWS_GET_GAUSSIAN_VEC
 
 /**
  * Allocate and return a vector with length coefficients, all
diff --git a/libswscale/version.h b/libswscale/version.h
index 51eb013a29..12412bd538 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -28,7 +28,7 @@
 
 #include "version_major.h"
 
-#define LIBSWSCALE_VERSION_MINOR   3
+#define LIBSWSCALE_VERSION_MINOR   4
 #define LIBSWSCALE_VERSION_MICRO 100
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
diff --git a/libswscale/version_major.h b/libswscale/version_major.h
index 88577a2b42..aa0baef7c6 100644
--- a/libswscale/version_major.h
+++ b/libswscale/version_major.h
@@ -32,4 +32,8 @@
  * the public API and may change, break or disappear at any time.
  */
 
+#ifndef FF_API_SWS_GET_GAUSSIAN_VEC
+#define FF_API_SWS_GET_GAUSSIAN_VEC       (LIBSWSCALE_VERSION_MAJOR < 8)
+#endif
+
 #endif /* SWSCALE_VERSION_MAJOR_H */
-- 
2.34.1


--oTXpCB2QLRWr7SHp
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

--oTXpCB2QLRWr7SHp--