From e740de13f5dd9867565dab604b07a8158ac1f4ca Mon Sep 17 00:00:00 2001
From: Damiano Galassi <damiog@gmail.com>
Date: Sat, 30 Nov 2024 08:59:51 +0100
Subject: [PATCH 4/6] add new matrix coefficients from H.273 v3

---
 doc/reST/cli.rst        | 3 +++
 source/common/param.cpp | 4 ++--
 source/x265.h           | 2 +-
 source/x265cli.cpp      | 2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
index 6bb99f92e..e9bc86d23 100755
--- a/doc/reST/cli.rst
+++ b/doc/reST/cli.rst
@@ -2369,6 +2369,9 @@ VUI fields must be manually specified.
 	12. chroma-derived-nc
 	13. chroma-derived-c
 	14. ictcp
+	15. ipt-c2
+	16. ycgco-re
+	17. ycgco-ro
 
 .. option:: --chromaloc <0..5>
 
diff --git a/source/common/param.cpp b/source/common/param.cpp
index adf157f61..9534e0bd4 100755
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -1810,10 +1810,10 @@ int x265_check_params(x265_param* param)
           " smpte170m, smpte240m, linear, log100, log316, iec61966-2-4, bt1361e,"
           " iec61966-2-1, bt2020-10, bt2020-12, smpte-st-2084, smpte-st-428 or arib-std-b67");
     CHECK(param->vui.matrixCoeffs < 0
-          || param->vui.matrixCoeffs > 14
+          || param->vui.matrixCoeffs > 17
           || param->vui.matrixCoeffs == 3,
           "Matrix Coefficients must be unknown, bt709, fcc, bt470bg, smpte170m,"
-          " smpte240m, gbr, ycgco, bt2020nc, bt2020c, smpte-st-2085, chroma-nc, chroma-c or ictcp");
+          " smpte240m, gbr, ycgco, bt2020nc, bt2020c, smpte-st-2085, chroma-nc, chroma-c, ictcp, ipt-c2, ycgco-re, or ycgco-ro");
     CHECK(param->vui.chromaSampleLocTypeTopField < 0
           || param->vui.chromaSampleLocTypeTopField > 5,
           "Chroma Sample Location Type Top Field must be 0-5");
diff --git a/source/x265.h b/source/x265.h
index 70cd66dcb..32c901194 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -748,7 +748,7 @@ static const char * const x265_transfer_names[] = { "reserved", "bt709", "unknow
                                                     "log316", "iec61966-2-4", "bt1361e", "iec61966-2-1", "bt2020-10", "bt2020-12",
                                                     "smpte2084", "smpte428", "arib-std-b67", 0 };
 static const char * const x265_colmatrix_names[] = { "gbr", "bt709", "unknown", "", "fcc", "bt470bg", "smpte170m", "smpte240m",
-                                                     "ycgco", "bt2020nc", "bt2020c", "smpte2085", "chroma-derived-nc", "chroma-derived-c", "ictcp", 0 };
+                                                     "ycgco", "bt2020nc", "bt2020c", "smpte2085", "chroma-derived-nc", "chroma-derived-c", "ictcp", "ipt-c2", "ycgco-re", "ycgco-ro", 0 };
 static const char * const x265_sar_names[] = { "unknown", "1:1", "12:11", "10:11", "16:11", "40:33", "24:11", "20:11",
                                                "32:11", "80:33", "18:11", "15:11", "64:33", "160:99", "4:3", "3:2", "2:1", 0 };
 static const char * const x265_interlace_names[] = { "prog", "tff", "bff", 0 };
diff --git a/source/x265cli.cpp b/source/x265cli.cpp
index c5fd26a68..47e69c85d 100755
--- a/source/x265cli.cpp
+++ b/source/x265cli.cpp
@@ -327,7 +327,7 @@ namespace X265_NS {
         H0("                                 smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1,\n");
         H0("                                 bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67. Default unknown\n");
         H1("   --colormatrix <string>        Specify color matrix setting from unknown, bt709, fcc, bt470bg, smpte170m,\n");
-        H1("                                 smpte240m, gbr, ycgco, bt2020nc, bt2020c, smpte2085, chroma-derived-nc, chroma-derived-c, ictcp. Default unknown\n");
+        H1("                                 smpte240m, gbr, ycgco, bt2020nc, bt2020c, smpte2085, chroma-derived-nc, chroma-derived-c, ictcp, ipt-c2, ycgco-re, ycgco-ro. Default unknown\n");
         H1("   --chromaloc <integer>         Specify chroma sample location (0 to 5). Default of %d\n", param->vui.chromaSampleLocTypeTopField);
         H0("   --master-display <string>     SMPTE ST 2086 master display color volume info SEI (HDR)\n");
         H0("                                    format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
-- 
2.39.5 (Apple Git-154)

