From 77e7f5de2c01361a88c501fcd78b51c2fe2d9df0 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Tue, 29 Nov 2022 11:22:23 -0800 Subject: sws_utils: update to handle deprecation of `avcodec_enum_to_chroma_pos` This has been replaced by `av_chroma_location_enum_to_pos`. --- video/sws_utils.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/video/sws_utils.c b/video/sws_utils.c index 4945734f4f..fb3e844cb0 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -21,6 +21,9 @@ #include #include #include +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100) +#include +#endif #include "config.h" @@ -303,6 +306,16 @@ int mp_sws_reinit(struct mp_sws_context *ctx) int cr_src = mp_chroma_location_to_av(src.chroma_location); int cr_dst = mp_chroma_location_to_av(dst.chroma_location); int cr_xpos, cr_ypos; +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100) + if (av_chroma_location_enum_to_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) { + av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0); + av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0); + } + if (av_chroma_location_enum_to_pos(&cr_xpos, &cr_ypos, cr_dst) >= 0) { + av_opt_set_int(ctx->sws, "dst_h_chr_pos", cr_xpos, 0); + av_opt_set_int(ctx->sws, "dst_v_chr_pos", cr_ypos, 0); + } +#else if (avcodec_enum_to_chroma_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) { av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0); av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0); @@ -311,6 +324,7 @@ int mp_sws_reinit(struct mp_sws_context *ctx) av_opt_set_int(ctx->sws, "dst_h_chr_pos", cr_xpos, 0); av_opt_set_int(ctx->sws, "dst_v_chr_pos", cr_ypos, 0); } +#endif // This can fail even with normal operation, e.g. if a conversion path // simply does not support these settings. -- cgit v1.2.3