Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> --- libavformat/mxfenc.c | 39 +++++++++++++++++++++++++++++++++ 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, 50 insertions(+), 11 deletions(-)
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index eda26e1a3f..8443334512 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -492,6 +492,7 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = { { 0x320B, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0E,0x00,0x00,0x00}}, /* Presentation Y offset */ { 0x3217, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x07,0x00,0x00,0x00}}, /* Display F2 offset */ { 0x320E, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x00,0x00,0x00}}, /* Aspect Ratio */ + { 0x3210, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x02,0x01,0x01,0x01,0x02,0x00}}, /* Transfer characteristic */ { 0x3213, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x02,0x00,0x00,0x00,0x00}}, /* Image Start Offset */ { 0x3214, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x03,0x00,0x00,0x00,0x00}}, /* Image End Offset */ { 0x3201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x06,0x01,0x00,0x00,0x00,0x00}}, /* Picture Essence Coding */ @@ -1143,6 +1144,34 @@ static const UID mxf_aes3_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53, static const UID mxf_cdci_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x28,0x00 }; static const UID mxf_generic_sound_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x42,0x00 }; +static int get_trc(UID ul, enum AVColorTransferCharacteristic trc) +{ + switch (trc){ + case AVCOL_TRC_GAMMA28 : + case AVCOL_TRC_GAMMA22 : + memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00}, 16); + return 0; + case AVCOL_TRC_BT709 : + case AVCOL_TRC_SMPTE170M : + memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00}, 16); + return 0; + case AVCOL_TRC_SMPTE240M : + memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x03,0x00,0x00}, 16); + return 0; + case AVCOL_TRC_BT1361_ECG: + memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x05,0x00,0x00}, 16); + return 0; + case AVCOL_TRC_LINEAR : + memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x06,0x04,0x01,0x01,0x01,0x01,0x06,0x00,0x00}, 16); + return 0; + case AVCOL_TRC_SMPTE428 : + memcpy(ul, (UID){0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x08,0x04,0x01,0x01,0x01,0x01,0x07,0x00,0x00}, 16); + return 0; + default: + return -1; + } +} + static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size) { MXFStreamContext *sc = st->priv_data; @@ -1152,6 +1181,8 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke int display_height; int f1, f2; unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8 + 6; + UID transfer_ul = {0}; + if (sc->interlaced && sc->field_dominance) desc_size += 5; if (sc->signal_standard) @@ -1164,6 +1195,8 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke desc_size += 8 * 3; if (s->oformat == &ff_mxf_d10_muxer) desc_size += 8 + 8 + 8; + if (get_trc(transfer_ul, st->codecpar->color_trc) >= 0) + desc_size += 20; mxf_write_generic_desc(s, st, key, desc_size); @@ -1305,6 +1338,12 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke avio_wb32(pb, sc->aspect_ratio.num); avio_wb32(pb, sc->aspect_ratio.den); + //Transfer characteristic + if (transfer_ul[0]) { + mxf_write_local_tag(pb, 16, 0x3210); + avio_write(pb, transfer_ul, 16); + }; + mxf_write_local_tag(pb, 16, 0x3201); avio_write(pb, *sc->codec_ul, 16); diff --git a/tests/ref/fate/copy-trac4914 b/tests/ref/fate/copy-trac4914 index 4cadb21adc..a805699374 100644 --- a/tests/ref/fate/copy-trac4914 +++ b/tests/ref/fate/copy-trac4914 @@ -1,4 +1,4 @@ -ccce4918a1a4682cf431e7bb14b8120d *tests/data/fate/copy-trac4914.mxf +ed7921a1218fce5ca0fd27217ddd7863 *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 1a1731e431..273e51d6e5 100644 --- a/tests/ref/fate/mxf-reel_name +++ b/tests/ref/fate/mxf-reel_name @@ -1 +1 @@ -1ab725f1bbf60e4ac127859727735784 +02b2c67154665a72c6adebe9c234b778 diff --git a/tests/ref/fate/time_base b/tests/ref/fate/time_base index 9ba0e92b58..d5fd8e0523 100644 --- a/tests/ref/fate/time_base +++ b/tests/ref/fate/time_base @@ -1 +1 @@ -bedb164d507d07714c2a908f4ddb240a +b27e3b5e01771daa4425db36366aafb5 diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf index d20bded186..30a7846143 100644 --- a/tests/ref/lavf/mxf +++ b/tests/ref/lavf/mxf @@ -1,9 +1,9 @@ -b445776832c7deba50665282a5987f2c *./tests/data/lavf/lavf.mxf +93367bc02b8997b84224e7eb359cae8a *./tests/data/lavf/lavf.mxf 526393 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0x8dddfaab -d130f0a9c7404fe4f2e7c975d8fd6a52 *./tests/data/lavf/lavf.mxf +0087ea968d20cc9192456fcd4c00019e *./tests/data/lavf/lavf.mxf 561721 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0xf21b1b48 -41cd471fe44cd27ec558980c20b71676 *./tests/data/lavf/lavf.mxf +7754550ff6fe5895555610f586a15fc5 *./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 51f26c7b85..4c272048a1 100644 --- a/tests/ref/lavf/mxf_d10 +++ b/tests/ref/lavf/mxf_d10 @@ -1,3 +1,3 @@ -d92737f65555cceeb61ec6a79dd7a054 *./tests/data/lavf/lavf.mxf_d10 +693c6e28c56607aba86e73da3d14cecf *./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 f6dc12e09b..ac9147d284 100644 --- a/tests/ref/lavf/mxf_dv25 +++ b/tests/ref/lavf/mxf_dv25 @@ -1,3 +1,3 @@ -ac97dec181de5ca64d096bfc38924978 *./tests/data/lavf/lavf.mxf_dv25 +37ad73c526ecc698dbae5a8995c7dd4d *./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 e53ac45fc0..19740a9a30 100644 --- a/tests/ref/lavf/mxf_dvcpro50 +++ b/tests/ref/lavf/mxf_dvcpro50 @@ -1,3 +1,3 @@ -fd35b5adf7601ef08cda45d0124a284a *./tests/data/lavf/lavf.mxf_dvcpro50 +8e989e5eb6f64741c1f3f2a9bfdb6f9a *./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 5ace27e0fb..29b1b58843 100644 --- a/tests/ref/lavf/mxf_opatom +++ b/tests/ref/lavf/mxf_opatom @@ -1,3 +1,3 @@ -e4236ef5fb2948ad6b3985f2c48471d8 *./tests/data/lavf/lavf.mxf_opatom +b6e1fde300f68808ead5c316fd9a4543 *./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 ab161b0ec6..a86aa991e9 100644 --- a/tests/ref/lavf/mxf_opatom_audio +++ b/tests/ref/lavf/mxf_opatom_audio @@ -1,3 +1,3 @@ -0bb1e7389b51c604ed5dd98d8826a55f *./tests/data/lavf/lavf.mxf_opatom_audio +cc0dc4aacd82f5495456000c4ce38b08 *./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 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel