diff options
author | Philip Langdale <philipl@overt.org> | 2022-11-29 11:22:23 -0800 |
---|---|---|
committer | Philip Langdale <github.philipl@overt.org> | 2022-12-01 10:45:47 -0800 |
commit | 77e7f5de2c01361a88c501fcd78b51c2fe2d9df0 (patch) | |
tree | 5fcb72bdf988036d0036d6781bc252f605f56ffa /video/sws_utils.c | |
parent | 83257be693967415f1160f2fa37de9de677c1cab (diff) | |
download | mpv-77e7f5de2c01361a88c501fcd78b51c2fe2d9df0.tar.bz2 mpv-77e7f5de2c01361a88c501fcd78b51c2fe2d9df0.tar.xz |
sws_utils: update to handle deprecation of `avcodec_enum_to_chroma_pos`
This has been replaced by `av_chroma_location_enum_to_pos`.
Diffstat (limited to 'video/sws_utils.c')
-rw-r--r-- | video/sws_utils.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 <libavcodec/avcodec.h> #include <libavutil/bswap.h> #include <libavutil/opt.h> +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100) +#include <libavutil/pixdesc.h> +#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. |