[FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec
Michael Niedermayer
michael at niedermayer.cc
Fri Sep 1 19:54:40 EEST 2023
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20230901/1304ee36/attachment.sig>
More information about the ffmpeg-devel
mailing list