Is there any way to retrieve flags from SWS context?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Is there any way to retrieve flags from SWS context?

Pavel Krasnovskij
When creating SWS context, it can silently internally modify sent flags.
For instance, if trying to sett context flags to SWS_BICUBIC, in many cases
flags for the context are actually set to SWS_BICUBIC | SWS_FULL_CHR_H_INT
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 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 any solution to this?

Thank you,
Pavel K.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".