summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorcantabile <cantabile.desu@gmail.com>2012-08-21 00:03:59 +0300
committerwm4 <wm4@nowhere>2012-08-21 18:17:41 +0200
commita1380f394597e06e04195b1812300550f3c2df40 (patch)
treedb2303737c451586f1f427e0f3b562f1c7f0dade /libmpcodecs
parent27262dec1be623618a2e55ab1dbc35371e0ec758 (diff)
downloadmpv-a1380f394597e06e04195b1812300550f3c2df40.tar.bz2
mpv-a1380f394597e06e04195b1812300550f3c2df40.tar.xz
video: honor the video's colormatrix and color range flags
If either of them is not defined, the old behavior is used: - the colormatrix is guessed based on resolution. - the color range is assumed to be tv aka limited range.
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/dec_video.c6
-rw-r--r--libmpcodecs/vd_ffmpeg.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c
index 148514db95..e328f3e948 100644
--- a/libmpcodecs/dec_video.c
+++ b/libmpcodecs/dec_video.c
@@ -129,9 +129,15 @@ void get_detected_video_colorspace(struct sh_video *sh, struct mp_csp_details *c
csp->levels_out = opts->requested_output_range;
if (csp->format == MP_CSP_AUTO)
+ csp->format = sh->colorspace;
+ if (csp->format == MP_CSP_AUTO)
csp->format = mp_csp_guess_colorspace(vf->w, vf->h);
+
+ if (csp->levels_in == MP_CSP_LEVELS_AUTO)
+ csp->levels_in = sh->color_range;
if (csp->levels_in == MP_CSP_LEVELS_AUTO)
csp->levels_in = MP_CSP_LEVELS_TV;
+
if (csp->levels_out == MP_CSP_LEVELS_AUTO)
csp->levels_out = MP_CSP_LEVELS_PC;
}
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index b30648b6f6..b2150579ea 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -42,6 +42,7 @@
#include "libmpdemux/demux_packet.h"
#include "codec-cfg.h"
#include "osdep/numcores.h"
+#include "libvo/csputils.h"
static const vd_info_t info = {
"libavcodec video codecs",
@@ -463,6 +464,10 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt)
};
else
supported_fmts = (const unsigned int[]){ctx->best_csp, 0xffffffff};
+
+ sh->colorspace = avcol_spc_to_mp_csp(avctx->colorspace);
+ sh->color_range = avcol_range_to_mp_csp_levels(avctx->color_range);
+
if (!mpcodecs_config_vo2(sh, sh->disp_w, sh->disp_h, supported_fmts,
ctx->best_csp))
return -1;