avformat/mxfenc: add white/black ref /color range
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 5 Apr 2018 20:53:22 +0000 (22:53 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 8 May 2018 21:02:58 +0000 (23:02 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mxfenc.c
tests/ref/fate/copy-trac4914
tests/ref/fate/mxf-reel_name
tests/ref/fate/time_base
tests/ref/lavf/mxf
tests/ref/lavf/mxf_d10
tests/ref/lavf/mxf_dv25
tests/ref/lavf/mxf_dvcpro50
tests/ref/lavf/mxf_opatom
tests/ref/lavf/mxf_opatom_audio

index ce2f0ed..37121b9 100644 (file)
@@ -493,6 +493,9 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
     { 0x3302, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x05,0x00,0x00,0x00}}, /* Horizontal Subsampling */
     { 0x3308, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x01,0x10,0x00,0x00,0x00}}, /* Vertical Subsampling */
     { 0x3303, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x06,0x00,0x00,0x00}}, /* Color Siting */
+    { 0x3304, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x03,0x00,0x00,0x00}}, /* Black Ref level */
+    { 0x3305, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x04,0x00,0x00,0x00}}, /* White Ref level */
+    { 0x3306, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x05,0x00,0x00,0x00}}, /* Color Range */
     // Generic Sound Essence Descriptor
     { 0x3D02, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x04,0x04,0x02,0x03,0x01,0x04,0x00,0x00,0x00}}, /* Locked/Unlocked */
     { 0x3D03, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x01,0x01,0x01,0x00,0x00}}, /* Audio sampling rate */
@@ -1144,6 +1147,8 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
         desc_size += 5;
     if (sc->v_chroma_sub_sample)
         desc_size += 8;
+    if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED)
+        desc_size += 8 * 3;
 
     mxf_write_generic_desc(s, st, key, desc_size);
 
@@ -1188,6 +1193,23 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
     mxf_write_local_tag(pb, 1, 0x3303);
     avio_w8(pb, sc->color_siting);
 
+    if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) {
+        int black = 0,
+            white = (1<<sc->component_depth) - 1,
+            color = (1<<sc->component_depth) - 1;
+        if (st->codecpar->color_range == AVCOL_RANGE_MPEG) {
+            black = 1   << (sc->component_depth - 4);
+            white = 235 << (sc->component_depth - 8);
+            color = (14 << (sc->component_depth - 4)) + 1;
+        }
+        mxf_write_local_tag(pb, 4, 0x3304);
+        avio_wb32(pb, black);
+        mxf_write_local_tag(pb, 4, 0x3305);
+        avio_wb32(pb, white);
+        mxf_write_local_tag(pb, 4, 0x3306);
+        avio_wb32(pb, color);
+    }
+
     if (sc->signal_standard) {
         mxf_write_local_tag(pb, 1, 0x3215);
         avio_w8(pb, sc->signal_standard);
index d588930..82f0e20 100644 (file)
@@ -1,4 +1,4 @@
-3d0c809bc8e9405663c9a5e610f9e8ef *tests/data/fate/copy-trac4914.mxf
+413822e81bf2e8e15253c5f454dd4f89 *tests/data/fate/copy-trac4914.mxf
 561209 tests/data/fate/copy-trac4914.mxf
 #tb 0: 1001/30000
 #media_type 0: video
index 2b7ce6b..06eed08 100644 (file)
@@ -1 +1 @@
-db983aa35ff8fb11eecc353e8dbede0c
+af45493a137fefc30012b622e87655fb
index 6975886..ab73dc9 100644 (file)
@@ -1 +1 @@
-cc250f19ecf194deeca1b7b22809d19b
+a2af9615e99800d1a8d9d4beb52fde17
index 46c820f..c232602 100644 (file)
@@ -1,9 +1,9 @@
-6b19d9f36c84cbfce55b4345d07a4a50 *./tests/data/lavf/lavf.mxf
+b88e19419e438822ce844f2126ead987 *./tests/data/lavf/lavf.mxf
 525881 ./tests/data/lavf/lavf.mxf
 ./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
-f74437af61c3b405ab3fc7629b6c0389 *./tests/data/lavf/lavf.mxf
+518a71066087fef4f24b0e1b3c1c31f0 *./tests/data/lavf/lavf.mxf
 561209 ./tests/data/lavf/lavf.mxf
 ./tests/data/lavf/lavf.mxf CRC=0xf21b1b48
-90cefadb27b8df45e87c1066780dbf5d *./tests/data/lavf/lavf.mxf
+cf62629801992052a4c6bfc4793ce489 *./tests/data/lavf/lavf.mxf
 525881 ./tests/data/lavf/lavf.mxf
 ./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
index 7c9a4eb..e34f57e 100644 (file)
@@ -1,3 +1,3 @@
-6cef072ed3bc838e776334c665a0e4e0 *./tests/data/lavf/lavf.mxf_d10
+4e54e7d5be04c5b7db145b2315d23771 *./tests/data/lavf/lavf.mxf_d10
 5331501 ./tests/data/lavf/lavf.mxf_d10
 ./tests/data/lavf/lavf.mxf_d10 CRC=0x6c74d488
index 46a5d42..7ba1003 100644 (file)
@@ -1,3 +1,3 @@
-a1360106323c36ca5c0822ea9cbee3ea *./tests/data/lavf/lavf.mxf_dv25
+eb9eff93337cc2273cd01fa0e5416555 *./tests/data/lavf/lavf.mxf_dv25
 3833901 ./tests/data/lavf/lavf.mxf_dv25
 ./tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52
index 2b97b6e..3760830 100644 (file)
@@ -1,3 +1,3 @@
-f7942565dab23159d6aa60d6a943757a *./tests/data/lavf/lavf.mxf_dvcpro50
+1665f75a926581a3bc94723e95c16d08 *./tests/data/lavf/lavf.mxf_dvcpro50
 7430701 ./tests/data/lavf/lavf.mxf_dvcpro50
 ./tests/data/lavf/lavf.mxf_dvcpro50 CRC=0xe3bbe4b4
index fa44998..da7596e 100644 (file)
@@ -1,3 +1,3 @@
-deaf3a54743b718422248c318c935277 *./tests/data/lavf/lavf.mxf_opatom
+69f093d69ba6bd61b3904c259e6f3817 *./tests/data/lavf/lavf.mxf_opatom
 4717113 ./tests/data/lavf/lavf.mxf_opatom
 ./tests/data/lavf/lavf.mxf_opatom CRC=0xf55aa22a
index 7df1801..ad591f1 100644 (file)
@@ -1,3 +1,3 @@
-ac49423bc7350dba64bde66768c26cc1 *./tests/data/lavf/lavf.mxf_opatom_audio
+2adc59eeb7f4ce094b735527cfd13bfb *./tests/data/lavf/lavf.mxf_opatom_audio
 102457 ./tests/data/lavf/lavf.mxf_opatom_audio
 ./tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff