<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">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">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>