summaryrefslogtreecommitdiffstats
path: root/video/csputils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2014-04-02 00:40:36 +0200
committerwm4 <wm4@nowhere>2014-06-22 19:05:43 +0200
commit664f8e9832e7ee9835816621faf4b57ffbcc8628 (patch)
tree5a4183678358bdfa04a3a88ec94350b6a430323a /video/csputils.c
parentfbd35caef830a1d0a25f1ee6e3b5d71453c98a59 (diff)
downloadmpv-664f8e9832e7ee9835816621faf4b57ffbcc8628.tar.bz2
mpv-664f8e9832e7ee9835816621faf4b57ffbcc8628.tar.xz
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 <wm4@nowhere>
Diffstat (limited to 'video/csputils.c')
-rw-r--r--video/csputils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/video/csputils.c b/video/csputils.c
index 202585187a..c462c43c34 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -160,6 +160,25 @@ enum mp_csp mp_csp_guess_colorspace(int width, int height)
return width >= 1280 || height > 576 ? MP_CSP_BT_709 : MP_CSP_BT_601;
}
+enum mp_csp_prim mp_csp_guess_primaries(int width, int height)
+{
+ // HD content
+ if (width >= 1280 || height > 576)
+ return MP_CSP_PRIM_BT_709;
+
+ switch (height) {
+ case 576: // Typical PAL content, including anamorphic/squared
+ return MP_CSP_PRIM_BT_601_625;
+
+ case 480: // Typical NTSC content, including squared
+ case 486: // NTSC Pro or anamorphic NTSC
+ return MP_CSP_PRIM_BT_601_525;
+
+ default: // No good metric, just pick BT.709 to minimize damage
+ return MP_CSP_PRIM_BT_709;
+ }
+}
+
enum mp_chroma_location avchroma_location_to_mp(int avloc)
{
switch (avloc) {