diff options
author | wm4 <wm4@nowhere> | 2013-07-25 23:02:23 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-25 23:03:20 +0200 |
commit | 9cc5630fd54d9abadd52fdedb1bac30d1b09d99a (patch) | |
tree | 3b23a26819021d51e813755a8d6c5f7cef689230 /video/sws_utils.c | |
parent | 24e50ee74e69ff4c4f66510360a611f612c0f140 (diff) | |
download | mpv-9cc5630fd54d9abadd52fdedb1bac30d1b09d99a.tar.bz2 mpv-9cc5630fd54d9abadd52fdedb1bac30d1b09d99a.tar.xz |
video: support setting libswscale chroma position
Diffstat (limited to 'video/sws_utils.c')
-rw-r--r-- | video/sws_utils.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/video/sws_utils.c b/video/sws_utils.c index ff139ea794..c63e447762 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -19,6 +19,7 @@ #include <assert.h> #include <libswscale/swscale.h> +#include <libavcodec/avcodec.h> #include <libavutil/opt.h> #include "sws_utils.h" @@ -227,6 +228,20 @@ int mp_sws_reinit(struct mp_sws_context *ctx) av_opt_set_double(ctx->sws, "param0", ctx->params[0], 0); av_opt_set_double(ctx->sws, "param1", ctx->params[1], 0); +#if HAVE_AVCODEC_CHROMA_POS_API + 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 (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); + } + if (avcodec_enum_to_chroma_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); + } +#endif + // This can fail even with normal operation, e.g. if a conversion path // simply does not support these settings. sws_setColorspaceDetails(ctx->sws, sws_getCoefficients(s_csp), s_range, |