Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec
Date: Fri, 1 Sep 2023 18:54:40 +0200
Message-ID: <20230901165440.GA7802@pb2> (raw)
In-Reply-To: <ZPDK5KUnjUTLYNUh@mariano>


[-- Attachment #1.1: Type: text/plain, Size: 5369 bytes --]

On Thu, Aug 31, 2023 at 07:16:20PM +0200, Stefano Sabatini wrote:
> On date Thursday 2023-08-31 18:51:52 +0200, Andreas Rheinhardt wrote:
> > Stefano Sabatini:
> > > +int sws_get_gaussian_vec(SwsVector **vecp,
> > > +                         AVClass *log_ctx,
> > > +                         double standard_deviation, double quality);
> > >  
> > 
> > Seriously? A pointer to an AVClass as log_ctx? It is actually AVClass**
> > (the logcontext must have a pointer to an AVClass as its first member),
> > but we always use NULL.
> 
> Sorry, sloppy editing on my side.
> 
> > Apart from that: I am not really convinced that the improvement is worth
> > the hassle.
> 
> This is not a high-profile function (probably it's never used outside
> lavfi) and provides an opportunity to move the API to the correct
> direction.

>  doc/APIchanges             |    3 +++
>  libswscale/swscale.h       |   27 ++++++++++++++++++++++++++-
>  libswscale/utils.c         |   42 +++++++++++++++++++++++++++++++++---------
>  libswscale/version.h       |    2 +-
>  libswscale/version_major.h |    4 ++++
>  5 files changed, 67 insertions(+), 11 deletions(-)
> b91b721cea2752b28a51aaeab2a464b2699dfb49  0001-lsws-swscale.h-introduce-sws_get_gaussian_vec.patch
> From 69c33f62e15de3d199d54187d38c0856418f0981 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/2] 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       | 27 +++++++++++++++++++++++-
>  libswscale/utils.c         | 42 ++++++++++++++++++++++++++++++--------
>  libswscale/version.h       |  2 +-
>  libswscale/version_major.h |  4 ++++
>  5 files changed, 67 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..55f2fc4a48 100644
> --- a/libswscale/swscale.h
> +++ b/libswscale/swscale.h
> @@ -355,11 +355,36 @@ 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 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.
> + * @param log_ctx a pointer to an arbitrary struct of which the first
> + *        field is a pointer to an AVClass struct (used for av_log)
> + *        used for logging, can be NULL
> + *
> + * @return a negative error code on error, non negative otherwise
> + */
> +int sws_get_gaussian_vec(SwsVector **vecp,
> +                         double standard_deviation, double quality,
> +                         void *log_ctx);

which of the two do you consider better?

First, here the central part we return is the vector

SwsVector *gaus_vec = sws_getGaussianVec(NULL, 1, 2);
SwsVector *temp_vec = sws_ConvolveVec(NULL, in_vec, gaus_vec);
sws_averageVec(temp_vec, temp_vec, in_vec);

av_free(gaus_vec);
return temp_vec; // Error checking here happens by temp_vec being NULL in all cases of error

vs.

Second, here the central part we return is the error code

SwsVector *gaus_vec = NULL;
SwsVector *temp_vec = NULL;
int err = sws_getGaussianVec(&gaus_vec, 1, 2);
if (err<0)
    goto fail;

err = sws_ConvolveVec(&temp_vec, in_vec, gaus_vec);
if (err<0)
    goto fail;

err = sws_averageVec(&temp_vec, temp_vec, in_vec);
if (err<0)
    goto fail;

*ret_argument = temp_vec
return 0;
fail:
    av_free(gaus_vec)
    av_free(temp_vec)
return ret;

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

  reply	other threads:[~2023-09-01 16:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-26 12:23 Stefano Sabatini
2023-08-26 15:15 ` Andreas Rheinhardt
2023-08-31 15:32   ` Stefano Sabatini
2023-08-31 16:51     ` Andreas Rheinhardt
2023-08-31 17:16       ` Stefano Sabatini
2023-09-01 16:54         ` Michael Niedermayer [this message]
2023-09-01 18:38           ` Stefano Sabatini
2023-09-02 20:07             ` Michael Niedermayer
2023-09-03  0:25               ` Stefano Sabatini
2023-09-03 16:34                 ` Michael Niedermayer
2023-08-26 15:15 ` Anton Khirnov
2023-08-31 15:06   ` Stefano Sabatini
2023-09-01 15:50     ` Anton Khirnov
2023-09-01 18:28       ` Stefano Sabatini
2023-09-05 11:19         ` Anton Khirnov
2023-09-05 22:59           ` Stefano Sabatini
2023-09-06 11:13             ` Anton Khirnov
2023-11-04 21:38               ` Stefano Sabatini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230901165440.GA7802@pb2 \
    --to=michael@niedermayer.cc \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git