[FFmpeg-devel] [PATCH] swscale: support internal scaler cascades

Clément Bœsch u at pkh.me
Fri Oct 10 23:30:43 CEST 2014


On Wed, Oct 08, 2014 at 02:11:06AM +0200, Michael Niedermayer wrote:
> Fixes Ticket3170
> 
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libswscale/swscale.c          |   13 ++++++++++
>  libswscale/swscale_internal.h |    6 +++++
>  libswscale/utils.c            |   54 ++++++++++++++++++++++++++++++++---------
>  3 files changed, 62 insertions(+), 11 deletions(-)
> 
> diff --git a/libswscale/swscale.c b/libswscale/swscale.c
> index e54d448..409e7db 100644
> --- a/libswscale/swscale.c
> +++ b/libswscale/swscale.c
> @@ -27,6 +27,7 @@
>  #include "libavutil/avutil.h"
>  #include "libavutil/bswap.h"
>  #include "libavutil/cpu.h"
> +#include "libavutil/imgutils.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/mathematics.h"
>  #include "libavutil/pixdesc.h"
> @@ -899,6 +900,18 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
>          av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n");
>          return 0;
>      }
> +    if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) {
> +        ret = sws_scale(c->cascaded_context[0],
> +                        srcSlice, srcStride, srcSliceY, srcSliceH,
> +                        c->cascaded_tmp, c->cascaded_tmpStride);
> +        if (ret < 0)
> +            return ret;
> +        ret = sws_scale(c->cascaded_context[1],
> +                        c->cascaded_tmp, c->cascaded_tmpStride, 0, c->cascaded_context[0]->dstH,
> +                        dst, dstStride);
> +        return ret;
> +    }
> +
>      memcpy(src2, srcSlice, sizeof(src2));
>      memcpy(dst2, dst, sizeof(dst2));
>  
> diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
> index 1e53690..d072bbc 100644
> --- a/libswscale/swscale_internal.h
> +++ b/libswscale/swscale_internal.h
> @@ -61,6 +61,8 @@
>  #   define APCK_SIZE 16
>  #endif
>  
> +#define AVERROR_USE_CASCADE -12345
> +

Please do not use "AV" prefix for non exposed API.

[...]

>  struct SwsContext;
>  
>  typedef enum SwsDither {
> @@ -301,6 +303,10 @@ typedef struct SwsContext {
>      int sliceDir;                 ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
>      double param[2];              ///< Input parameters for scaling algorithms that need them.
>  
> +    struct SwsContext *cascaded_context[2];
> +    int cascaded_tmpStride[4];
> +    uint8_t *cascaded_tmp[4];
> +

I think it would be appropriate to add a comment about what issue these
fields are addressing.

[...]

No opinion on the rest of the patch, but thank you for fixing that issue.

I'm assuming it's now able to rescale from 4k to 1x1?

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141010/955878b3/attachment.asc>


More information about the ffmpeg-devel mailing list