From 664f8e9832e7ee9835816621faf4b57ffbcc8628 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 2 Apr 2014 00:40:36 +0200 Subject: video: Include better heuristics for guessing primaries These consult the vertical resolution, matching against 576 for PAL and 480/486 for NTSC. The documentation has also been updated. Signed-off-by: wm4 --- video/mp_image.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'video/mp_image.c') diff --git a/video/mp_image.c b/video/mp_image.c index eb754499d1..d83a9ae3c1 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -537,14 +537,15 @@ void mp_image_params_guess_csp(struct mp_image_params *params) if (params->colorlevels == MP_CSP_LEVELS_AUTO) params->colorlevels = MP_CSP_LEVELS_TV; if (params->primaries == MP_CSP_PRIM_AUTO) { - // We assume BT.709 primaries for all untagged BT.609/BT.709 - // content, because it offers the minimal deviation from all three, - // including both NTSC and PAL/SECAM. + // Guess based on the colormatrix as a first priority if (params->colorspace == MP_CSP_BT_2020_NC || params->colorspace == MP_CSP_BT_2020_C) { params->primaries = MP_CSP_PRIM_BT_2020; - } else { + } else if (params->colorspace == MP_CSP_BT_709) { params->primaries = MP_CSP_PRIM_BT_709; + } else { + // Ambiguous colormatrix for BT.601, guess based on res + params->primaries = mp_csp_guess_primaries(params->w, params->h); } } } else if (fmt.flags & MP_IMGFLAG_RGB) { -- cgit v1.2.3