sws_utils: update to handle deprecation of `avcodec_enum_to_chroma_pos`

This has been replaced by `av_chroma_location_enum_to_pos`.
This commit is contained in:
Philip Langdale 2022-11-29 11:22:23 -08:00 committed by Philip Langdale
parent 83257be693
commit 77e7f5de2c
1 changed files with 14 additions and 0 deletions

View File

@ -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.