diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 052e687926..a43aab8ed0 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -485,6 +485,7 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = { { 0x3208, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0B,0x00,0x00,0x00}}, /* Display Height */ { 0x320B, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0E,0x00,0x00,0x00}}, /* Presentation Y 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 */ @@ -1136,6 +1137,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; @@ -1145,6 +1174,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 + 6; + UID transfer_ul = {0}; + if (sc->interlaced && sc->field_dominance) desc_size += 5; if (sc->signal_standard) @@ -1155,6 +1186,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); @@ -1270,6 +1303,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 fedff45105..231cdafa17 100644 --- a/tests/ref/fate/copy-trac4914 +++ b/tests/ref/fate/copy-trac4914 @@ -1,4 +1,4 @@ -a3631810ebed2db905db7554e137b48e *tests/data/fate/copy-trac4914.mxf +efa819aae97478b7e8e486a52e7ca7ab *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 03dab69544..8985965222 100644 --- a/tests/ref/fate/mxf-reel_name +++ b/tests/ref/fate/mxf-reel_name @@ -1 +1 @@ -61f2fe7aa57ae3d64db1e2bb6c2acb16 +159c175b80f35b924ef55293ef433d0a diff --git a/tests/ref/fate/time_base b/tests/ref/fate/time_base index c2e9c40a3b..460eae195e 100644 --- a/tests/ref/fate/time_base +++ b/tests/ref/fate/time_base @@ -1 +1 @@ -f8bb8b13d6c051aa29cc79486f8f555f +aa60f92877322f9e22c90d4fc508d73a diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf index 590f7228a6..b3be23f7c8 100644 --- a/tests/ref/lavf/mxf +++ b/tests/ref/lavf/mxf @@ -1,9 +1,9 @@ -b522a40e24cca5b7f86c99bb5bd78060 *./tests/data/lavf/lavf.mxf +24b059ddbf6022df8059b7e13a11d2a9 *./tests/data/lavf/lavf.mxf 526393 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0x8dddfaab -3b09745afe0bcd331666ac92e84cf6b8 *./tests/data/lavf/lavf.mxf +937b67f0d27d44da8f10f862445a376b *./tests/data/lavf/lavf.mxf 561721 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0xf21b1b48 -fe00f21d74ec5a33de0d8fb23f397e42 *./tests/data/lavf/lavf.mxf +ffb3f5fb2473ce2895ffc0b6ca38ba1f *./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 c81fc512fd..e3d764c2b4 100644 --- a/tests/ref/lavf/mxf_d10 +++ b/tests/ref/lavf/mxf_d10 @@ -1,3 +1,3 @@ -85ce91f9d1c08072d902dae63a3d31d9 *./tests/data/lavf/lavf.mxf_d10 +f429e5c52dadb28236bd72c75544f757 *./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 27bc9066ae..d22bb3126e 100644 --- a/tests/ref/lavf/mxf_dv25 +++ b/tests/ref/lavf/mxf_dv25 @@ -1,3 +1,3 @@ -788d6d38bd9086a7100ad5bccb93ab59 *./tests/data/lavf/lavf.mxf_dv25 +f570a233ee440058987a5b9f3642fea5 *./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 94fa092af0..9d0db2b654 100644 --- a/tests/ref/lavf/mxf_dvcpro50 +++ b/tests/ref/lavf/mxf_dvcpro50 @@ -1,3 +1,3 @@ -58e2477bf49c5fa50b6f2266aafae43f *./tests/data/lavf/lavf.mxf_dvcpro50 +914aed46af112523de45ae3487aa6d79 *./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 25d3347a96..13a4ff36a2 100644 --- a/tests/ref/lavf/mxf_opatom +++ b/tests/ref/lavf/mxf_opatom @@ -1,3 +1,3 @@ -e95dc4f86864b4c3d63f81b8966077a3 *./tests/data/lavf/lavf.mxf_opatom +75ccb51d422e319f4b284a94815bb0c7 *./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 74723f5e77..f8bfb606e4 100644 --- a/tests/ref/lavf/mxf_opatom_audio +++ b/tests/ref/lavf/mxf_opatom_audio @@ -1,3 +1,3 @@ -c0e14eec21b75875a6c898f71cbeded0 *./tests/data/lavf/lavf.mxf_opatom_audio +55868441de7088b20438417ecdf77d93 *./tests/data/lavf/lavf.mxf_opatom_audio 102969 ./tests/data/lavf/lavf.mxf_opatom_audio ./tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff