Commit 293a6e83 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/mxfenc: Write transfer characteristic

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent c35ca7e0
......@@ -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);
......
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
......
61f2fe7aa57ae3d64db1e2bb6c2acb16
159c175b80f35b924ef55293ef433d0a
f8bb8b13d6c051aa29cc79486f8f555f
aa60f92877322f9e22c90d4fc508d73a
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
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
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
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
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment