<div dir="ltr">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.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 17 Dec 2019 at 10:08, Pavel Krasnovskij <<a href="mailto:pavel@videntifier.com">pavel@videntifier.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>When creating SWS context, it can silently internally modify sent flags.</div><div>For example, it can add/remove SWS_FULL_CHR_H_INT flag</div><div>(f.ex. <a href="https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L1346" target="_blank">https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L1346</a></div><div><a href="https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L1378" target="_blank">https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L1378</a>)</div><div>Then later, if trying to get cached SWS context using f.ex.:</div><div><br></div><div>sws_getCachedContext(</div><div>          old_context, // Potentialy reusable context</div><div>          dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, // Src params</div><div>          frame_rgb->width, frame_rgb->height, static_cast<AVPixelFormat>(frame_rgb->format),</div><div>          SWS_BICUBIC, NULL, NULL, NULL));</div><div><br></div><div>It will always produce a cache miss, since flags in old context won't be same, here: <a href="https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L2394" target="_blank">https://github.com/FFmpeg/FFmpeg/blob/master/libswscale/utils.c#L2394</a></div><div>It would be helpful to call sws_getCachedContext with old_context->flags instead, like so:</div><div><br></div><div>sws_getCachedContext(</div><div>          old_context, // Potentialy reusable context</div><div>          dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, // Src params</div><div>          frame_rgb->width, frame_rgb->height, static_cast<AVPixelFormat>(frame_rgb->format),</div><div>          old_context->flags, NULL, NULL, NULL));</div><div><br></div><div>However external ffmpeg API doesnt seem to allow access to old_context->flags, there is only forward declartion for SwsContext struct in swscale.h </div><div><br></div><div>Also tried using:</div><div><br></div><div>>  int64_t flags = SWS_BICUBIC;</div><div>>  int success = av_opt_get_int(old_context, "flags", 0, &flags);</div><div>>  uint8_t* aflags = 0;</div><div>>  success = av_opt_get(old_context, "flags", 0, *aflags);</div><div><br></div><div>However, this doesnt succeed (success == -1)</div><div><br></div><div>Is there perhaps some solution to this?</div><div><br></div><div>Thank you,</div><div>Pavel K.</div></div></div></div></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".</blockquote></div>