[FFmpeg-devel] [PATCH 08/13] avformat/mxfenc: add white/black ref /color range

Michael Niedermayer michael at niedermayer.cc
Mon May 7 13:38:12 EEST 2018


Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/mxfenc.c            | 22 ++++++++++++++++++++++
 tests/ref/fate/copy-trac4914    |  2 +-
 tests/ref/fate/mxf-reel_name    |  2 +-
 tests/ref/fate/time_base        |  2 +-
 tests/ref/lavf/mxf              |  6 +++---
 tests/ref/lavf/mxf_d10          |  2 +-
 tests/ref/lavf/mxf_dv25         |  2 +-
 tests/ref/lavf/mxf_dvcpro50     |  2 +-
 tests/ref/lavf/mxf_opatom       |  2 +-
 tests/ref/lavf/mxf_opatom_audio |  2 +-
 10 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 8039be846a..722830615e 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -500,6 +500,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 */
@@ -1153,6 +1156,8 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
         desc_size += 8;
     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);
 
@@ -1223,6 +1228,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);
diff --git a/tests/ref/fate/copy-trac4914 b/tests/ref/fate/copy-trac4914
index a50a7ecd86..f868753d45 100644
--- a/tests/ref/fate/copy-trac4914
+++ b/tests/ref/fate/copy-trac4914
@@ -1,4 +1,4 @@
-16e212762efcb66302386c196af2a361 *tests/data/fate/copy-trac4914.mxf
+2296e01ba6794ab91c78d8bc1215a801 *tests/data/fate/copy-trac4914.mxf
 561721 tests/data/fate/copy-trac4914.mxf
 #tb 0: 1001/30000
 #media_type 0: video
diff --git a/tests/ref/fate/mxf-reel_name b/tests/ref/fate/mxf-reel_name
index 7a9ff7cf58..50023ce52a 100644
--- a/tests/ref/fate/mxf-reel_name
+++ b/tests/ref/fate/mxf-reel_name
@@ -1 +1 @@
-a6dfa4a37d4d5681ef04a88e9a6b6e6c
+c5752bf1b72694455e1b348cad8660c5
diff --git a/tests/ref/fate/time_base b/tests/ref/fate/time_base
index 23b36b98c1..979aa08972 100644
--- a/tests/ref/fate/time_base
+++ b/tests/ref/fate/time_base
@@ -1 +1 @@
-f7e24ab873f0b524f327b1003991dd83
+6aac6c1a2e367e43d665bdb974bb7679
diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
index 8b1599578b..df1c2607c7 100644
--- a/tests/ref/lavf/mxf
+++ b/tests/ref/lavf/mxf
@@ -1,9 +1,9 @@
-24083dc0939d1d45e4bf27e738816a6f *./tests/data/lavf/lavf.mxf
+b2c881236ca2791a6f378545d82a891b *./tests/data/lavf/lavf.mxf
 526393 ./tests/data/lavf/lavf.mxf
 ./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
-ed1ef4bd833c30ff37cf7b83d6ef1439 *./tests/data/lavf/lavf.mxf
+b14305ee249cc9a7f1708737dbd6daa7 *./tests/data/lavf/lavf.mxf
 561721 ./tests/data/lavf/lavf.mxf
 ./tests/data/lavf/lavf.mxf CRC=0xf21b1b48
-a56f5638b1f9c0ffaa74cb1cee6c3455 *./tests/data/lavf/lavf.mxf
+0c8ddc85308c8e00d588c33f2458d4be *./tests/data/lavf/lavf.mxf
 526393 ./tests/data/lavf/lavf.mxf
 ./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
diff --git a/tests/ref/lavf/mxf_d10 b/tests/ref/lavf/mxf_d10
index 07b7c24667..3f91f9c30e 100644
--- a/tests/ref/lavf/mxf_d10
+++ b/tests/ref/lavf/mxf_d10
@@ -1,3 +1,3 @@
-ad23b67a8eea7f0f0c67c4b059d3c516 *./tests/data/lavf/lavf.mxf_d10
+e167b53d927a43d6b14c5d0631640adb *./tests/data/lavf/lavf.mxf_d10
 5332013 ./tests/data/lavf/lavf.mxf_d10
 ./tests/data/lavf/lavf.mxf_d10 CRC=0x6c74d488
diff --git a/tests/ref/lavf/mxf_dv25 b/tests/ref/lavf/mxf_dv25
index 11fbbb7526..992f0a927d 100644
--- a/tests/ref/lavf/mxf_dv25
+++ b/tests/ref/lavf/mxf_dv25
@@ -1,3 +1,3 @@
-1b1187ed4191e011e3ddf17c057c3d89 *./tests/data/lavf/lavf.mxf_dv25
+7ff3cc1ee0a68cc08221c28a1b801490 *./tests/data/lavf/lavf.mxf_dv25
 3834413 ./tests/data/lavf/lavf.mxf_dv25
 ./tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52
diff --git a/tests/ref/lavf/mxf_dvcpro50 b/tests/ref/lavf/mxf_dvcpro50
index 31c5d288e6..74b0bd17de 100644
--- a/tests/ref/lavf/mxf_dvcpro50
+++ b/tests/ref/lavf/mxf_dvcpro50
@@ -1,3 +1,3 @@
-a734fc5c0dccb1d77b96a716a139ceef *./tests/data/lavf/lavf.mxf_dvcpro50
+b6b24c4c562e2d4c866a3f53907c8745 *./tests/data/lavf/lavf.mxf_dvcpro50
 7431213 ./tests/data/lavf/lavf.mxf_dvcpro50
 ./tests/data/lavf/lavf.mxf_dvcpro50 CRC=0xe3bbe4b4
diff --git a/tests/ref/lavf/mxf_opatom b/tests/ref/lavf/mxf_opatom
index 173d7db69d..c72481b193 100644
--- a/tests/ref/lavf/mxf_opatom
+++ b/tests/ref/lavf/mxf_opatom
@@ -1,3 +1,3 @@
-76299119fc99df9e43fb88ac0ad661b5 *./tests/data/lavf/lavf.mxf_opatom
+6cf21f1d5e2406c50edf9c34ecdf2b45 *./tests/data/lavf/lavf.mxf_opatom
 4717625 ./tests/data/lavf/lavf.mxf_opatom
 ./tests/data/lavf/lavf.mxf_opatom CRC=0xf55aa22a
diff --git a/tests/ref/lavf/mxf_opatom_audio b/tests/ref/lavf/mxf_opatom_audio
index d6464261f8..f020530cc7 100644
--- a/tests/ref/lavf/mxf_opatom_audio
+++ b/tests/ref/lavf/mxf_opatom_audio
@@ -1,3 +1,3 @@
-4741df53f58557e57f409a0ab52d4717 *./tests/data/lavf/lavf.mxf_opatom_audio
+0778fda8cea977d37674868ad8ddc2fd *./tests/data/lavf/lavf.mxf_opatom_audio
 102969 ./tests/data/lavf/lavf.mxf_opatom_audio
 ./tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff
-- 
2.17.0



More information about the ffmpeg-devel mailing list