[FFmpeg-devel] [PATCH 12/24] sws: separate the calls to scaled vs unscaled conversion

Michael Niedermayer michael at niedermayer.cc
Tue Jun 1 15:41:48 EEST 2021


On Mon, May 31, 2021 at 09:55:03AM +0200, Anton Khirnov wrote:
> Call the scaler function directly rather than through a function
> pointer. Drop the now-unused return value from ff_getSwsFunc() and
> rename the function to reflect its new role.
> 
> This will be useful in the following commits, where it will become
> important that the amount of output is different for scaled vs unscaled
> case.
> ---
>  libswscale/swscale.c          | 10 ++++++----
>  libswscale/swscale_internal.h |  6 +-----
>  libswscale/utils.c            |  3 ++-
>  tests/checkasm/sw_scale.c     |  4 ++--
>  4 files changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/libswscale/swscale.c b/libswscale/swscale.c
> index 2db40a6807..4b577ef263 100644
> --- a/libswscale/swscale.c
> +++ b/libswscale/swscale.c
> @@ -579,7 +579,7 @@ static av_cold void sws_init_swscale(SwsContext *c)
>          c->needs_hcscale = 1;
>  }
>  
> -SwsFunc ff_getSwsFunc(SwsContext *c)
> +void ff_sws_init_scale(SwsContext *c)
>  {
>      sws_init_swscale(c);
>  
> @@ -591,8 +591,6 @@ SwsFunc ff_getSwsFunc(SwsContext *c)
>          ff_sws_init_swscale_aarch64(c);
>      if (ARCH_ARM)
>          ff_sws_init_swscale_arm(c);
> -
> -    return swscale;
>  }
>  
>  static void reset_ptr(const uint8_t *src[], enum AVPixelFormat format)

> @@ -988,7 +986,11 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
>      /* reset slice direction at end of frame */
>      if (srcSliceY_internal + srcSliceH == c->srcH)
>          c->sliceDir = 0;
> -    ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2);
> +
> +    if (c->swscale)
> +        ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2);
> +    else
> +        ret = swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2);

sws_scale(), c->swscale(), swscale() is confusing
also the line where it was always passed on to the same pointer becomes
conditional here that adds an additional step to confuse

maybe this can be done differently / clearer

thx

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- 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/20210601/a0abe9aa/attachment.sig>


More information about the ffmpeg-devel mailing list