[FFmpeg-devel] [PATCH v7 09/12] swscale: introduce new, dynamic scaling API

Michael Niedermayer michael at niedermayer.cc
Thu Nov 21 03:12:28 EET 2024


On Sat, Nov 16, 2024 at 12:25:04PM +0100, Niklas Haas wrote:
> From: Niklas Haas <git at haasn.dev>
> 
> As part of a larger, ongoing effort to modernize and partially rewrite
> libswscale, it was decided and generally agreed upon to introduce a new
> public API for libswscale. This API is designed to be less stateful, more
> explicitly defined, and considerably easier to use than the existing one.
> 
> Most of the API work has been already accomplished in the previous commits,
> this commit merely introduces the ability to use sws_scale_frame()
> dynamically, without prior sws_init_context() calls. Instead, the new API
> takes frame properties from the frames themselves, and the implementation is
> based on the new SwsGraph API, which we simply reinitialize as needed.
> 
> This high-level wrapper also recreates the logic that used to live inside
> vf_scale for scaling interlaced frames, enabling it to be reused more easily
> by end users.
> 
> Finally, this function is designed to simply copy refs directly when nothing
> needs to be done, substantially improving throughput of the noop fast path.
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Niklas Haas <git at haasn.dev>
> ---
>  libswscale/graph.c            |  23 +++-
>  libswscale/swscale.c          | 196 ++++++++++++++++++++++++++++++++--
>  libswscale/swscale.h          |  89 +++++++++++----
>  libswscale/swscale_internal.h |   7 +-
>  libswscale/utils.c            |   4 +
>  libswscale/x86/output.asm     |   2 +-
>  6 files changed, 291 insertions(+), 30 deletions(-)

[...]

> +static int validate_params(SwsContext *ctx)
> +{
> +#define VALIDATE(field, min, max) \
> +    if (ctx->field < min || ctx->field > max) { \
> +        av_log(ctx, AV_LOG_ERROR, "'%s' (%d) out of range [%d, %d]\n", \
> +               #field, (int) ctx->field, min, max); \
> +        return AVERROR(EINVAL); \
> +    }
> +

> +    VALIDATE(threads,       0, 8192);

a named "#define" would be better than a litteral number

should be ok otherwise

thx

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

If the United States is serious about tackling the national security threats 
related to an insecure 5G network, it needs to rethink the extent to which it
values corporate profits and government espionage over security.-Bruce Schneier
-------------- 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/91443007/attachment.sig>


More information about the ffmpeg-devel mailing list