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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Pavel Krasnovskij
When creating SWS context, it can silently internally modify sent flags.
For example, it can add/remove SWS_FULL_CHR_H_INT flag
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
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Is there any way to retrieve flags from SWS context?

Jonathan Noble
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 <[hidden email]> wrote:
When creating SWS context, it can silently internally modify sent flags.
For example, it can add/remove SWS_FULL_CHR_H_INT flag
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
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

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

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

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