67 #define MXF_MAX_CHUNK_SIZE (32 << 20)
68 #define RUN_IN_MAX (65535+1) // S377m-2004 section 5.5 and S377-1-2009 section 6.5, the +1 is to be slightly more tolerant
177 uint8_t track_number[4];
201 #define MXF_FIELD_DOMINANCE_DEFAULT 0
202 #define MXF_FIELD_DOMINANCE_FF 1
203 #define MXF_FIELD_DOMINANCE_FL 2
334 static const uint8_t
mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
335 static const uint8_t
mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
336 static const uint8_t
mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
337 static const uint8_t
mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x0a,0x0e,0x0f,0x03,0x01 };
338 static const uint8_t
mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
339 static const uint8_t
mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 };
341 static const uint8_t
mxf_apple_coll_prefix[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01 };
344 static const uint8_t
mxf_crypto_source_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 };
345 static const uint8_t
mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
346 static const uint8_t
mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
347 static const uint8_t
mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
348 static const uint8_t
mxf_ffv1_extradata[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x01,0x06,0x0c,0x01,0x00,0x00,0x00 };
349 static const uint8_t
mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
350 static const uint8_t
mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00 };
351 static const uint8_t
mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 };
352 static const uint8_t
mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 };
353 static const uint8_t
mxf_apple_coll_max_cll[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 };
354 static const uint8_t
mxf_apple_coll_max_fall[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 };
356 static const uint8_t
mxf_mca_label_dictionary_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x01,0x00,0x00,0x00 };
357 static const uint8_t
mxf_mca_tag_symbol[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x02,0x00,0x00,0x00 };
358 static const uint8_t
mxf_mca_tag_name[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x03,0x00,0x00,0x00 };
359 static const uint8_t
mxf_group_of_soundfield_groups_link_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x04,0x00,0x00,0x00 };
360 static const uint8_t
mxf_mca_link_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x05,0x00,0x00,0x00 };
361 static const uint8_t
mxf_mca_channel_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x04,0x0a,0x00,0x00,0x00,0x00 };
362 static const uint8_t
mxf_soundfield_group_link_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x06,0x00,0x00,0x00 };
363 static const uint8_t
mxf_mca_rfc5646_spoken_language[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0d,0x03,0x01,0x01,0x02,0x03,0x15,0x00,0x00 };
365 static const uint8_t
mxf_sub_descriptor[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 };
375 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
380 switch ((*ctx)->type) {
434 int bytes_num =
size & 0x7f;
442 if (
size > INT64_MAX)
454 else if (
b !=
key[
i])
473 if (
pos > INT64_MAX - length)
483 for (
i = 0;
i <
s->nb_streams;
i++) {
490 return s->nb_streams == 1 &&
s->streams[0]->priv_data ? 0 : -1;
519 int cdp_identifier, cdp_length, cdp_footer_id, ccdata_id, cc_count;
520 int line_num, sample_coding, sample_count;
521 int did, sdid, data_length;
527 for (
i = 0;
i < count;
i++) {
536 length -= 6 + 8 + sample_count;
537 if (line_num != 9 && line_num != 11)
539 if (sample_coding == 7 || sample_coding == 8 || sample_coding == 9) {
551 if (did != 0x61 || sdid != 1) {
556 if (cdp_identifier != 0x9669) {
565 if (ccdata_id != 0x72) {
573 if (cdp_length - 9 - 4 < cc_count * 3) {
577 avio_skip(
s->pb, data_length - 9 - 4 - cc_count * 3);
579 if (cdp_footer_id != 0x74) {
594 const uint8_t *buf_ptr, *end_ptr;
612 uint32_t
sample = bytestream_get_le32(&buf_ptr);
614 bytestream_put_le24(&data_ptr, (
sample >> 4) & 0xffffff);
616 bytestream_put_le16(&data_ptr, (
sample >> 12) & 0xffff);
627 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
633 uint64_t plaintext_size;
639 if (!mxf->
aesc &&
s->key &&
s->keylen == 16) {
666 if (orig_size < plaintext_size)
670 if (
size < 32 ||
size - 32 < orig_size || (
int)orig_size != orig_size)
676 if (memcmp(tmpbuf, checkv, 16))
682 else if (
size < plaintext_size)
684 size -= plaintext_size;
700 if (item_len != 18) {
704 if (item_num > 65536 || item_num < 0) {
726 uint64_t footer_partition;
727 uint32_t nb_essence_containers;
749 memset(partition, 0,
sizeof(*partition));
797 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
810 "Overriding PreviousPartition with %"PRIx64
"\n",
815 if (footer_partition) {
818 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
826 "PartitionPack: ThisPartition = 0x%"PRIX64
827 ", PreviousPartition = 0x%"PRIX64
", "
828 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
838 "PreviousPartition points to this partition or forward\n");
842 if (
op[12] == 1 &&
op[13] == 1) mxf->
op =
OP1a;
843 else if (
op[12] == 1 &&
op[13] == 2) mxf->
op =
OP1b;
844 else if (
op[12] == 1 &&
op[13] == 3) mxf->
op =
OP1c;
845 else if (
op[12] == 2 &&
op[13] == 1) mxf->
op =
OP2a;
846 else if (
op[12] == 2 &&
op[13] == 2) mxf->
op =
OP2b;
847 else if (
op[12] == 2 &&
op[13] == 3) mxf->
op =
OP2c;
848 else if (
op[12] == 3 &&
op[13] == 1) mxf->
op =
OP3a;
849 else if (
op[12] == 3 &&
op[13] == 2) mxf->
op =
OP3b;
850 else if (
op[12] == 3 &&
op[13] == 3) mxf->
op =
OP3c;
852 else if (
op[12] == 0x10) {
857 if (nb_essence_containers != 1) {
863 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
864 nb_essence_containers,
865 op ==
OP1a ?
"OP1a" :
"OPAtom");
918 uint64_t new_s = (*metadata_set)->partition_score;
953 if (
c > INT_MAX /
sizeof(
UID))
965 if (
ret != *count *
sizeof(
UID)) {
966 *count =
ret < 0 ? 0 :
ret /
sizeof(
UID);
978 if (size < 0 || size > INT_MAX - 1)
1002 if (size < 0 || size > INT_MAX/2)
1024 #define READ_STR16(type, big_endian) \
1025 static int mxf_read_utf16 ## type ##_string(AVIOContext *pb, int size, char** str) \
1027 return mxf_read_utf16_string(pb, size, str, big_endian); \
1108 mxf_read_utf16be_string(pb,
size, &track->
name);
1161 &package->tracks_count);
1165 avio_read(pb, package->package_uid, 16);
1168 avio_read(pb, package->descriptor_ref, 16);
1171 return mxf_read_utf16be_string(pb,
size, &package->name);
1174 &package->comment_count);
1201 uint32_t nb_index_entries;
1203 if (
segment->temporal_offset_entries)
1207 if (nb_index_entries > INT_MAX)
1209 segment->nb_index_entries = nb_index_entries;
1212 if(
segment->nb_index_entries && length < 11)
1223 for (
i = 0;
i <
segment->nb_index_entries;
i++) {
1258 segment->index_edit_rate.den);
1287 }
while (
code != 0);
1295 int entry_count, entry_size;
1328 if (entry_size == 4) {
1329 if (entry_count > 0)
1333 if (entry_count > 1)
1416 for (
int i = 0;
i < 3;
i++) {
1446 if (!descriptor->
coll) {
1448 if (!descriptor->
coll)
1522 return mxf_read_utf16le_string(pb,
size - 17, &tagged_value->
value);
1524 return mxf_read_utf16be_string(pb,
size - 17, &tagged_value->
value);
1534 return mxf_read_utf16be_string(pb,
size, &tagged_value->
name);
1548 for (
i = 0;
i <
len;
i++) {
1557 while (uls->
uid[0]) {
1582 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000,
NULL, 14,
J2KWrap },
1583 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 }, 14,
AV_CODEC_ID_H264,
NULL, 15 },
1584 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 }, 14,
AV_CODEC_ID_DNXHD,
NULL, 14 },
1585 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 }, 14,
AV_CODEC_ID_VC1,
NULL, 14 },
1586 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 }, 14,
AV_CODEC_ID_TIFF,
NULL, 14 },
1587 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 }, 14,
AV_CODEC_ID_DIRAC,
NULL, 14 },
1588 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1b,0x01,0x00 }, 14,
AV_CODEC_ID_CFHD,
NULL, 14 },
1589 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1c,0x01,0x00 }, 14,
AV_CODEC_ID_PRORES,
NULL, 14 },
1590 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15 },
1591 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x04,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15,
D10D11Wrap },
1592 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x23,0x01,0x00 }, 14,
AV_CODEC_ID_FFV1,
NULL, 14 },
1593 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO,
NULL, 15 },
1594 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO,
NULL, 15,
RawVWrap },
1595 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x01,0x01 }, 15,
AV_CODEC_ID_HQ_HQA },
1596 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x02,0x01 }, 15,
AV_CODEC_ID_HQX },
1597 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x15,0x00,0x04,0x02,0x10,0x00,0x01 }, 16,
AV_CODEC_ID_HEVC,
NULL, 15 },
1598 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14,
AV_CODEC_ID_RAWVIDEO },
1599 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1604 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1605 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1610 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
1611 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
1612 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1617 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x01 }, 16, 1440 },
1618 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x02 }, 16, 1440 },
1619 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x03 }, 16, 1440 },
1620 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x04 }, 16, 1440 },
1621 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 },
1626 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14,
AV_CODEC_ID_PCM_S16LE,
NULL, 14,
RawAWrap },
1627 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2,
NULL, 15 },
1628 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE,
NULL, 13 },
1629 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
1630 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
1631 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1635 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0d,0x00,0x00 }, 16,
AV_CODEC_ID_NONE,
"vbi_smpte_436M", 11 },
1636 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16,
AV_CODEC_ID_NONE,
"vbi_vanc_smpte_436M", 11 },
1637 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x13,0x01,0x01 }, 16,
AV_CODEC_ID_TTML },
1638 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1648 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x01,0x00,0x00,0x00,0x00 },
AV_CH_FRONT_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1649 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x02,0x00,0x00,0x00,0x00 },
AV_CH_FRONT_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1650 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x03,0x00,0x00,0x00,0x00 },
AV_CH_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1651 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x04,0x00,0x00,0x00,0x00 },
AV_CH_LOW_FREQUENCY,
AV_AUDIO_SERVICE_TYPE_MAIN },
1652 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x05,0x00,0x00,0x00,0x00 },
AV_CH_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1653 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x06,0x00,0x00,0x00,0x00 },
AV_CH_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1654 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x07,0x00,0x00,0x00,0x00 },
AV_CH_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1655 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x08,0x00,0x00,0x00,0x00 },
AV_CH_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1656 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x09,0x00,0x00,0x00,0x00 },
AV_CH_BACK_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1657 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0a,0x00,0x00,0x00,0x00 },
AV_CH_BACK_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1658 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0b,0x00,0x00,0x00,0x00 },
AV_CH_FRONT_LEFT_OF_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1659 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0c,0x00,0x00,0x00,0x00 },
AV_CH_FRONT_RIGHT_OF_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1660 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0d,0x00,0x00,0x00,0x00 },
AV_CH_BACK_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1661 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0e,0x00,0x00,0x00,0x00 },
AV_CH_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED },
1662 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0f,0x00,0x00,0x00,0x00 },
AV_CH_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED },
1663 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x20,0x03,0x00,0x00,0x00 },
AV_CH_STEREO_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1664 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x20,0x04,0x00,0x00,0x00 },
AV_CH_STEREO_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1665 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x01,0x00,0x00 },
AV_CH_TOP_FRONT_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1666 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x02,0x00,0x00 },
AV_CH_TOP_FRONT_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1667 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x03,0x00,0x00 },
AV_CH_TOP_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1668 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x04,0x00,0x00 },
AV_CH_TOP_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1669 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x05,0x00,0x00 },
AV_CH_TOP_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1670 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x06,0x00,0x00 },
AV_CH_TOP_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1671 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x07,0x00,0x00 },
AV_CH_TOP_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1672 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x08,0x00,0x00 },
AV_CH_TOP_BACK_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1673 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x09,0x00,0x00 },
AV_CH_TOP_BACK_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1674 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0a,0x00,0x00 },
AV_CH_TOP_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1675 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0b,0x00,0x00 },
AV_CH_TOP_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1676 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0c,0x00,0x00 },
AV_CH_TOP_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1677 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0d,0x00,0x00 },
AV_CH_LOW_FREQUENCY,
AV_AUDIO_SERVICE_TYPE_MAIN },
1678 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0e,0x00,0x00 },
AV_CH_LOW_FREQUENCY_2,
AV_AUDIO_SERVICE_TYPE_MAIN },
1679 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0f,0x00,0x00 },
AV_CH_TOP_BACK_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1680 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x10,0x00,0x00 },
AV_CH_BACK_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1681 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x11,0x00,0x00 },
AV_CH_BOTTOM_FRONT_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1682 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x12,0x00,0x00 },
AV_CH_BOTTOM_FRONT_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1683 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x13,0x00,0x00 },
AV_CH_BOTTOM_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1684 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_AUDIO_SERVICE_TYPE_NB },
1700 val = (*essence_container_ul)[
codec_ul->wrapping_indicator_pos];
1701 switch (
codec_ul->wrapping_indicator_type) {
1706 if (
val == 0x03 ||
val == 0x04)
1727 int i, j, nb_segments = 0;
1729 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1739 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1740 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1749 if (
s->edit_unit_byte_count ||
s->nb_index_entries)
1750 unsorted_segments[nb_segments++] =
s;
1752 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1753 s->index_sid,
s->index_start_position);
1763 *nb_sorted_segments = 0;
1766 for (
i = 0;
i < nb_segments;
i++) {
1767 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1768 uint64_t best_index_duration = 0;
1770 for (j = 0; j < nb_segments; j++) {
1778 s->body_sid > last_body_sid ||
1779 s->body_sid == last_body_sid &&
s->index_sid > last_index_sid ||
1780 s->body_sid == last_body_sid &&
s->index_sid == last_index_sid &&
s->index_start_position > last_index_start) &&
1782 s->body_sid < best_body_sid ||
1783 s->body_sid == best_body_sid &&
s->index_sid < best_index_sid ||
1784 s->body_sid == best_body_sid &&
s->index_sid == best_index_sid &&
s->index_start_position < best_index_start ||
1785 s->body_sid == best_body_sid &&
s->index_sid == best_index_sid &&
s->index_start_position == best_index_start &&
s->index_duration > best_index_duration)) {
1787 best_body_sid =
s->body_sid;
1788 best_index_sid =
s->index_sid;
1789 best_index_start =
s->index_start_position;
1790 best_index_duration =
s->index_duration;
1798 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1799 last_body_sid = best_body_sid;
1800 last_index_sid = best_index_sid;
1801 last_index_start = best_index_start;
1824 m0 = m = (
a +
b) >> 1;
1826 while (m < b && mxf->partitions[m].body_sid != body_sid)
1829 if (m < b && mxf->partitions[m].body_offset <=
offset)
1841 *partition_out = last_p;
1846 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1876 int64_t offset_temp = 0;
1883 edit_unit =
FFMAX(edit_unit,
s->index_start_position);
1885 if (edit_unit < s->index_start_position +
s->index_duration) {
1886 int64_t
index = edit_unit -
s->index_start_position;
1888 if (
s->edit_unit_byte_count)
1889 offset_temp +=
s->edit_unit_byte_count *
index;
1891 if (
s->nb_index_entries == 2 *
s->index_duration + 1)
1894 if (index < 0 || index >=
s->nb_index_entries) {
1900 offset_temp =
s->stream_offset_entries[
index];
1904 *edit_unit_out =
av_rescale_q(edit_unit, edit_rate,
s->index_edit_rate);
1909 offset_temp +=
s->edit_unit_byte_count *
s->index_duration;
1922 int8_t max_temporal_offset = -128;
1929 if (!
s->nb_index_entries) {
1934 if (
s->index_duration > INT_MAX -
index_table->nb_ptses) {
1940 if (
s->nb_index_entries !=
s->index_duration &&
1941 s->nb_index_entries !=
s->index_duration + 1 &&
1942 s->nb_index_entries !=
s->index_duration * 2 + 1) {
1944 av_log(mxf->
fc,
AV_LOG_ERROR,
"ignoring IndexSID %d, duration does not match nb_index_entries\n",
s->index_sid);
1999 int index_delta = 1;
2000 int n =
s->nb_index_entries;
2002 if (
s->nb_index_entries == 2 *
s->index_duration + 1)
2004 if (
s->nb_index_entries == index_delta *
s->index_duration + 1)
2008 for (j = 0; j < n; j += index_delta, x++) {
2009 int offset =
s->temporal_offset_entries[j] / index_delta;
2014 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
2015 s->nb_index_entries,
s->index_duration);
2021 if (index < 0 || index >=
index_table->nb_ptses) {
2023 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
2030 max_temporal_offset =
FFMAX(max_temporal_offset,
offset);
2053 int i, j, k,
ret, nb_sorted_segments;
2057 nb_sorted_segments <= 0) {
2063 for (
i = 0;
i < nb_sorted_segments;
i++) {
2064 if (
i == 0 || sorted_segments[
i-1]->index_sid != sorted_segments[
i]->index_sid)
2066 else if (sorted_segments[
i-1]->body_sid != sorted_segments[
i]->body_sid) {
2069 goto finish_decoding_index;
2078 goto finish_decoding_index;
2082 for (
i = j = 0;
i < nb_sorted_segments;
i++) {
2083 if (
i != 0 && sorted_segments[
i-1]->index_sid != sorted_segments[
i]->index_sid) {
2098 " pointer array\n");
2100 goto finish_decoding_index;
2103 if (sorted_segments[
i]->index_start_position)
2104 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
2112 goto finish_decoding_index;
2135 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
2152 finish_decoding_index:
2158 static const uint8_t st_422_essence_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c };
2160 return essence_container_ul &&
mxf_match_uid(*essence_container_ul, st_422_essence_container_ul,
2161 sizeof(st_422_essence_container_ul));
2173 char str[2 +
sizeof(
UID) * 4 + 1])
2181 uint16_t patch, uint16_t release,
char **
str)
2191 char str[2 + 4 *
sizeof(
UID) + 1];
2234 package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], SourcePackage);
2238 if (!memcmp(package->package_ul, package_ul, 16) && !memcmp(package->package_uid, package_uid, 16))
2256 if (!file_descriptor) {
2261 return file_descriptor;
2344 int64_t start_position;
2357 if (physical_package->
name && physical_package->
name[0])
2377 "Invalid edit rate (%d/%d) found on structural"
2378 " component #%d, defaulting to 25/1\n",
2476 if (rfc5646 && strlen(rfc5646) > 1) {
2477 char primary_tag[4] =
2478 {rfc5646[0], rfc5646[1], rfc5646[2] !=
'-' ? rfc5646[2] :
'\0',
'\0'};
2502 if (ffv1_sub_descriptor ==
NULL)
2517 int ambigous_language = 0;
2519 int ambigous_service_type = 0;
2520 int has_channel_label = 0;
2523 char *channel_language;
2529 has_channel_label = 1;
2533 if (target_channel == 0 && descriptor->
channels == 1)
2535 if (target_channel <= 0 || target_channel > descriptor->
channels) {
2536 av_log(mxf->
fc,
AV_LOG_ERROR,
"AudioChannelLabelSubDescriptor has invalid MCA channel ID %d\n", target_channel);
2539 routing[target_channel - 1] = channel_ordering->layout_mask;
2541 service_type = channel_ordering->service_type;
2542 else if (service_type != channel_ordering->service_type)
2543 ambigous_service_type = 1;
2548 channel_language = label->
language;
2549 if (!channel_language) {
2552 channel_language = group->
language;
2557 channel_language = supergroup->
language;
2561 if (channel_language) {
2563 ambigous_language = 1;
2569 if (
language && !ambigous_language) {
2581 *ast = service_type;
2584 if (has_channel_label) {
2585 uint64_t channel_layout = 0;
2590 av_log(mxf->
fc,
AV_LOG_WARNING,
"Designation of audio channel %d in stream #%d is unknown or unsupported, "
2591 "falling back to unknown channel layout\n", st->
index,
i);
2594 if (channel_layout & routing[
i]) {
2598 "falling back to unknown channel layout\n",
2602 if (routing[
i] < channel_layout) {
2604 "falling back to unknown channel layout\n", st->
index);
2607 channel_layout |= routing[
i];
2629 if (material_package)
break;
2631 if (!material_package) {
2637 if (material_package->
name && material_package->
name[0])
2649 UID *essence_container_ul =
NULL;
2700 if (!source_package) {
2711 source_track = temp_track;
2715 if (!source_track) {
2734 if(source_track && component)
2737 if (!source_track || !component || !source_package) {
2782 "Invalid edit rate (%d/%d) found on stream #%d, "
2783 "defaulting to 25/1\n",
2815 essence_container_ul = &((
MXFCryptoContext *)metadata)->source_container_ul;
2831 for (k = 0; k < 16; k++) {
2834 if (!(k+1 & 19) || k == 5)
2840 if (source_package->
name && source_package->
name[0])
2842 if (material_track->
name && material_track->
name[0])
2890 "Field dominance %d support",
2904 "Field dominance %d support",
2917 switch ((*essence_container_ul)[14]) {
2987 if (descriptor->
coll) {
2989 (uint8_t *)descriptor->
coll,
3007 "found for stream #%d, time base forced to 1/48000\n",
3092 "with different wrapping\n",
i, j, track1->
body_sid);
3105 struct tm time = { 0 };
3107 time.tm_year = (timestamp >> 48) - 1900;
3108 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
3109 time.tm_mday = (timestamp >> 32 & 0xFF);
3110 time.tm_hour = (timestamp >> 24 & 0xFF);
3111 time.tm_min = (timestamp >> 16 & 0xFF);
3112 time.tm_sec = (timestamp >> 8 & 0xFF);
3113 msecs = (timestamp & 0xFF) * 4;
3116 time.tm_mon =
av_clip(time.tm_mon, 0, 11);
3117 time.tm_mday =
av_clip(time.tm_mday, 1, 31);
3118 time.tm_hour =
av_clip(time.tm_hour, 0, 23);
3119 time.tm_min =
av_clip(time.tm_min, 0, 59);
3120 time.tm_sec =
av_clip(time.tm_sec, 0, 59);
3121 msecs =
av_clip(msecs, 0, 999);
3123 return (int64_t)
av_timegm(&time) * 1000000 + msecs * 1000;
3126 #define SET_STR_METADATA(pb, name, str) do { \
3127 if ((ret = mxf_read_utf16be_string(pb, size, &str)) < 0) \
3129 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
3132 #define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \
3133 major = avio_rb16(pb); \
3134 minor = avio_rb16(pb); \
3135 tertiary = avio_rb16(pb); \
3136 patch = avio_rb16(pb); \
3137 release = avio_rb16(pb); \
3138 if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \
3140 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
3143 #define SET_UID_METADATA(pb, name, var, str) do { \
3144 char uuid_str[2 * AV_UUID_LEN + 4 + 1]; \
3145 avio_read(pb, var, 16); \
3146 av_uuid_unparse(uid, uuid_str); \
3147 av_dict_set(&s->metadata, name, uuid_str, 0); \
3150 #define SET_TS_METADATA(pb, name, var, str) do { \
3151 var = avio_rb64(pb); \
3152 if (var && (ret = avpriv_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \
3164 uint16_t
major,
minor, tertiary, patch, release;
3214 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
3215 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
3216 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
3217 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
3218 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
3219 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
3220 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
3221 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
3222 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
3223 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
3224 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
3225 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 },
mxf_read_preface_metadata },
3226 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
3227 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage, 0,
AnyType },
3228 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
SourcePackage },
3229 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
MaterialPackage },
3230 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
3231 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x05,0x00 },
mxf_read_essence_group,
sizeof(
MXFEssenceGroup),
EssenceGroup},
3232 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
3233 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3f,0x00 },
mxf_read_tagged_value,
sizeof(
MXFTaggedValue),
TaggedValue },
3234 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
3235 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3236 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3237 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3238 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3239 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3240 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3241 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5b,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3242 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3243 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3244 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3245 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6b,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
AudioChannelLabelSubDescriptor },
3246 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6c,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
SoundfieldGroupLabelSubDescriptor },
3247 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6d,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
GroupOfSoundfieldGroupsLabelSubDescriptor },
3248 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x81,0x03 },
mxf_read_ffv1_sub_descriptor,
sizeof(
MXFFFV1SubDescriptor),
FFV1SubDescriptor },
3249 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
3250 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
3251 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
3252 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0c,0x00 },
mxf_read_pulldown_component,
sizeof(
MXFPulldownComponent),
PulldownComponent },
3253 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
3254 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
3255 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x23,0x00 },
mxf_read_essence_container_data,
sizeof(
MXFEssenceContainerData),
EssenceContainerData },
3256 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
NULL, 0,
AnyType },
3298 if (next < 0 || next > INT64_MAX -
size) {
3315 if (local_tag ==
tag) {
3322 if (meta &&
tag == 0x3C0A) {
3339 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
3359 key[13] >= 2 &&
key[13] <= 4;
3371 if (klv.
key[5] == 0x53) {
3401 int64_t current_partition_ofs;
3432 if (klv.
offset >= current_partition_ofs) {
3434 PRIx64
" indirectly points to itself\n", current_partition_ofs);
3474 "failed to seek to FooterPartition @ 0x%" PRIx64
3475 " (%"PRId64
") - partial file?\n",
3498 for (
int i = 0;
i <
s->nb_streams;
i++) {
3534 if (x < mxf->partitions_count - 1)
3541 "partition %i: bad ThisPartition = %"PRIX64
"\n",
3598 int essence_partition_count = 0;
3599 int edit_unit_byte_count = 0;
3621 essence_partition_count++;
3625 if (essence_partition_count != 1)
3635 if (edit_unit_byte_count <= 0)
3653 segment->edit_unit_byte_count = edit_unit_byte_count;
3654 segment->index_start_position = 0;
3666 int64_t file_size, max_rip_length, min_rip_length;
3682 max_rip_length = ((file_size - mxf->
run_in) / 105) * 12 + 28;
3683 max_rip_length =
FFMIN(max_rip_length, INT_MAX);
3686 min_rip_length = 16+1+24+4;
3692 if (length < min_rip_length || length > max_rip_length)
3694 avio_seek(
s->pb, file_size - length, SEEK_SET);
3720 int64_t essence_offset = 0;
3767 if (!essence_offset)
3768 essence_offset = klv.
offset;
3790 if (!metadata->
read) {
3797 if (!essence_offset) {
3808 for (
int i = 0;
i <
s->nb_streams;
i++)
3816 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
3825 for (
int i = 0;
i <
s->nb_streams;
i++)
3847 if (
offset < current_offset)
3872 int64_t remainder = (
sample_rate.num * (int64_t) time_base.
num) %
3876 "seeking detected on stream #%d with time base (%d/%d) and "
3877 "sample rate (%d/%d), audio pts won't be accurate.\n",
3891 int64_t next_ofs = -1;
3894 int64_t new_edit_unit;
3907 if (next_ofs > current_offset)
3922 av_log(mxf->
fc,
AV_LOG_WARNING,
"edit unit sync lost on stream %d, jumping from %"PRId64
" to %"PRId64
"\n", st->
index, edit_unit, new_edit_unit);
3934 if (!bits_per_sample)
3940 bits_per_sample <= 0 ||
3986 int64_t max_data_size;
3994 max_data_size = klv.
length;
4021 "error getting stream index %"PRIu32
"\n",
4037 if (next_ofs <= 0) {
4045 if ((
size = next_ofs -
pos) <= 0) {
4051 if (
size > max_data_size)
4052 size = max_data_size;
4062 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
4114 for (
i = 0;
i <
s->nb_streams;
i++)
4115 s->streams[
i]->priv_data =
NULL;
4140 const uint8_t *bufp = p->
buf;
4149 for (; bufp < end;) {
4150 if (!((bufp[13] - 1) & 0xF2)){
4168 AVStream *st =
s->streams[stream_index];
4187 if (sample_time < 0)
4191 seekpos =
avio_seek(
s->pb, (
s->bit_rate * seconds) >> 3, SEEK_SET);
4203 for (
i = 0;
i <
s->nb_streams;
i++) {
4204 MXFTrack *new_source_track =
s->streams[
i]->priv_data;
4207 source_track = new_source_track;
4212 if (
i ==
s->nb_streams)
4218 sample_time =
FFMAX(sample_time, 0);
4227 sample_time < t->ptses[0] &&
4229 sample_time = t->
ptses[0];
4235 sample_time += t->
offsets[sample_time];
4251 if (seekpos < klv.next_klv - klv.length || seekpos >= klv.
next_klv) {
4263 for (
i = 0;
i <
s->nb_streams;
i++) {
4267 int64_t track_edit_unit = sample_time;
4277 {
"eia608_extract",
"extract eia 608 captions from s436m track",