[Libav-user] Is there any way to retrieve flags from SWS context?

Jonathan Noble jonnobleuk at gmail.com
Tue Dec 17 12:28:35 EET 2019


I would also be interested in this as i've recently come into this problem
when I was trying to identify how an SWSContext was created.

On Tue, 17 Dec 2019 at 10:08, Pavel Krasnovskij <pavel at videntifier.com>
wrote:

> When creating SWS context, it can silently internally modify sent flags.
> For example, it can add/remove SWS_FULL_CHR_H_INT flag
> (f.ex.
> https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L1346
> https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L1378)
> Then later, if trying to get cached SWS context using f.ex.:
>
> sws_getCachedContext(
>           old_context, // Potentialy reusable context
>           dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, // Src params
>           frame_rgb->width, frame_rgb->height,
> static_cast<AVPixelFormat>(frame_rgb->format),
>           SWS_BICUBIC, NULL, NULL, NULL));
>
> It will always produce a cache miss, since flags in old context won't be
> same, here:
> https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L2394
> It would be helpful to call sws_getCachedContext with old_context->flags
> instead, like so:
>
> sws_getCachedContext(
>           old_context, // Potentialy reusable context
>           dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, // Src params
>           frame_rgb->width, frame_rgb->height,
> static_cast<AVPixelFormat>(frame_rgb->format),
>           old_context->flags, NULL, NULL, NULL));
>
> However external ffmpeg API doesnt seem to allow access to
> old_context->flags, there is only forward declartion for SwsContext struct
> in swscale.h
>
> Also tried using:
>
> >  int64_t flags = SWS_BICUBIC;
> >  int success = av_opt_get_int(old_context, "flags", 0, &flags);
> >  uint8_t* aflags = 0;
> >  success = av_opt_get(old_context, "flags", 0, *aflags);
>
> However, this doesnt succeed (success == -1)
>
> Is there perhaps some solution to this?
>
> Thank you,
> Pavel K.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20191217/d0734f92/attachment.html>


More information about the Libav-user mailing list