[FFmpeg-devel] [PATCH v7 04/12] swscale: expose SwsContext publicly

Michael Niedermayer michael at niedermayer.cc
Thu Nov 21 02:04:38 EET 2024


On Thu, Nov 21, 2024 at 12:49:37AM +0100, Niklas Haas wrote:
> On Thu, 21 Nov 2024 00:42:23 +0100 Michael Niedermayer <michael at niedermayer.cc> wrote:
> > Hi Niklas
> > 
> > On Sat, Nov 16, 2024 at 12:24:59PM +0100, Niklas Haas wrote:
> > > From: Niklas Haas <git at haasn.dev>
> > > 
> > > Following in the footsteps of the work in the previous commit, it's now
> > > relatively straightforward to expose the options struct publicly as
> > > SwsContext. This is a step towards making this more user friendly, as
> > > well as following API conventions established elsewhere.
> > > 
> > > Sponsored-by: Sovereign Tech Fund
> > > Signed-off-by: Niklas Haas <git at haasn.dev>
> > > ---
> > >  libswscale/swscale.h          |  93 +++++++++++++++++++++++--
> > >  libswscale/swscale_internal.h |  45 +------------
> > >  libswscale/utils.c            | 123 +++++++++++++++-------------------
> > >  3 files changed, 144 insertions(+), 117 deletions(-)
> > > 
> > > diff --git a/libswscale/swscale.h b/libswscale/swscale.h
> > > index 50c705ae06..4baef532b6 100644
> > > --- a/libswscale/swscale.h
> > > +++ b/libswscale/swscale.h
> > > @@ -42,8 +42,6 @@
> > >  #include "version.h"
> > >  #endif
> > >  
> > > -typedef struct SwsContext SwsContext;
> > > -
> > >  /**
> > >   * @defgroup libsws libswscale
> > >   * Color conversion and scaling library.
> > > @@ -65,17 +63,98 @@ const char *swscale_configuration(void);
> > >  const char *swscale_license(void);
> > >  
> > >  /**
> > > - * Get the AVClass for swsContext. It can be used in combination with
> > > + * Get the AVClass for SwsContext. It can be used in combination with
> > >   * AV_OPT_SEARCH_FAKE_OBJ for examining options.
> > >   *
> > >   * @see av_opt_find().
> > >   */
> > >  const AVClass *sws_get_class(void);
> > >  
> > > -/**
> > > - * Allocate an empty SwsContext. This must be filled and passed to
> > > - * sws_init_context(). For filling see AVOptions, options.c and
> > > - * sws_setColorspaceDetails().
> > > +/******************************
> > > + * Flags and quality settings *
> > > + ******************************/
> > > +
> > > +typedef enum SwsDither {
> > > +    SWS_DITHER_NONE = 0, /* disable dithering */
> > > +    SWS_DITHER_AUTO,     /* auto-select from preset */
> > > +    SWS_DITHER_BAYER,    /* ordered dither matrix */
> > > +    SWS_DITHER_ED,       /* error diffusion */
> > > +    SWS_DITHER_A_DITHER, /* arithmetic addition */
> > > +    SWS_DITHER_X_DITHER, /* arithmetic xor */
> > > +    SWS_DITHER_NB,       /* not part of the ABI */
> > > +} SwsDither;
> > > +
> > > +typedef enum SwsAlphaBlend {
> > > +    SWS_ALPHA_BLEND_NONE = 0,
> > > +    SWS_ALPHA_BLEND_UNIFORM,
> > > +    SWS_ALPHA_BLEND_CHECKERBOARD,
> > > +    SWS_ALPHA_BLEND_NB,  /* not part of the ABI */
> > > +} SwsAlphaBlend;
> > > +
> > > +/***********************************
> > > + * Context creation and management *
> > > + ***********************************/
> > > +
> > > +/**
> > > + * Main external API structure. New fields can be added to the end with
> > > + * minor version bumps. Removal, reordering and changes to existing fields
> > > + * require a major version bump. sizeof(SwsContext) is not part of the ABI.
> > > + */
> > > +typedef struct SwsContext {
> > > +    const AVClass *av_class;
> > > +
> > > +    /**
> > > +     * Private data of the user, can be used to carry app specific stuff.
> > > +     */
> > > +    void *opaque;
> > > +
> > 
> > > +    /**
> > > +     * Bitmask of SWS_*.
> > > +     */
> > > +    unsigned flags;
> > 
> > uint64_t seems more future proof
> 
> I wanted to make it uint64_t, but we don't currently have a way to handle 64-bit
> flars with AVOption. If you care strongly, I could write a patch for that first,
> but I think that after deprecating all of the scaler/dither selection flags,
> this will no longer be an issue.

up to you, but a 64bit flags for AVOption seem useful outside sws

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- 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/20241121/87cc738a/attachment.sig>


More information about the ffmpeg-devel mailing list