diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2018-03-21 21:34:20 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-05-08 23:02:58 +0200 |
commit | 293a6e83325a7379c13469193492fa4cb2488785 (patch) | |
tree | 3b944cf12d8a2ce03924080ec2e0e4a74db4717d /libavformat/mxfenc.c | |
parent | c35ca7e01c887bb32600782668074929e85b2943 (diff) | |
download | ffmpeg-293a6e83325a7379c13469193492fa4cb2488785.tar.gz |
avformat/mxfenc: Write transfer characteristic
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/mxfenc.c')
-rw-r--r-- | libavformat/mxfenc.c | 39 |
1 files changed, 39 insertions, 0 deletions
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); |