70 #define MXF_MAX_CHUNK_SIZE (32 << 20)
71 #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
183 uint8_t track_number[4];
205 #define MXF_FIELD_DOMINANCE_DEFAULT 0
206 #define MXF_FIELD_DOMINANCE_FF 1
207 #define MXF_FIELD_DOMINANCE_FL 2
338 static const uint8_t
mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
339 static const uint8_t
mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
340 static const uint8_t
mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
341 static const uint8_t
mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x0a,0x0e,0x0f,0x03,0x01 };
342 static const uint8_t
mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
343 static const uint8_t
mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 };
345 static const uint8_t
mxf_apple_coll_prefix[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01 };
348 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 };
349 static const uint8_t
mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
350 static const uint8_t
mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
351 static const uint8_t
mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
352 static const uint8_t
mxf_ffv1_extradata[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x01,0x06,0x0c,0x01,0x00,0x00,0x00 };
353 static const uint8_t
mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
354 static const uint8_t
mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00 };
355 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 };
356 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 };
357 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 };
358 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 };
360 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 };
361 static const uint8_t
mxf_mca_tag_symbol[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x02,0x00,0x00,0x00 };
362 static const uint8_t
mxf_mca_tag_name[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x03,0x00,0x00,0x00 };
363 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 };
364 static const uint8_t
mxf_mca_link_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x05,0x00,0x00,0x00 };
365 static const uint8_t
mxf_mca_channel_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x04,0x0a,0x00,0x00,0x00,0x00 };
366 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 };
367 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 };
369 static const uint8_t
mxf_sub_descriptor[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 };
379 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
436 int bytes_num =
size & 0x7f;
441 *llen = bytes_num + 1;
448 if (
size > INT64_MAX)
460 else if (
b !=
key[
i])
501 if (klv->
offset > INT64_MAX - 16 - llen)
505 if (
pos > INT64_MAX - length)
513 for (
int i = 0;
i <
s->nb_streams;
i++) {
520 return s->nb_streams == 1 &&
s->streams[0]->priv_data ? 0 : -1;
549 int cdp_identifier, cdp_length, cdp_footer_id, ccdata_id, cc_count;
550 int line_num, sample_coding, sample_count;
551 int did, sdid, data_length;
557 for (
int i = 0;
i < count;
i++) {
566 length -= 6 + 8 + sample_count;
567 if (line_num != 9 && line_num != 11)
569 if (sample_coding == 7 || sample_coding == 8 || sample_coding == 9) {
581 if (did != 0x61 || sdid != 1) {
586 if (cdp_identifier != 0x9669) {
595 if (ccdata_id != 0x72) {
603 if (cdp_length - 9 - 4 < cc_count * 3) {
607 avio_skip(
s->pb, data_length - 9 - 4 - cc_count * 3);
609 if (cdp_footer_id != 0x74) {
624 const uint8_t *buf_ptr, *end_ptr;
641 uint32_t
sample = bytestream_get_le32(&buf_ptr);
643 bytestream_put_le24(&data_ptr, (
sample >> 4) & 0xffffff);
645 bytestream_put_le16(&data_ptr, (
sample >> 12) & 0xffff);
656 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
662 uint64_t plaintext_size;
669 if (!mxf->
aesc &&
s->key &&
s->keylen == 16) {
696 if (orig_size < plaintext_size)
700 if (
size < 32 ||
size - 32 < orig_size || (
int)orig_size != orig_size)
708 if (memcmp(tmpbuf, checkv, 16))
714 else if (
size < plaintext_size)
716 size -= plaintext_size;
732 if (item_len != 18) {
736 if (item_num > 65536 || item_num < 0) {
758 uint64_t footer_partition;
759 uint32_t nb_essence_containers;
760 uint64_t this_partition;
785 memset(partition, 0,
sizeof(*partition));
811 if (this_partition != klv_offset - mxf->
run_in) {
813 "this_partition %"PRId64
" mismatches %"PRId64
"\n",
814 this_partition, klv_offset - mxf->
run_in);
837 av_dict_set(&
s->metadata,
"operational_pattern_ul", str, 0);
840 if (this_partition &&
843 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
856 "Overriding PreviousPartition with %"PRIx64
"\n",
861 if (footer_partition) {
864 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
872 "PartitionPack: ThisPartition = 0x%"PRIX64
873 ", PreviousPartition = 0x%"PRIX64
", "
874 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
884 "PreviousPartition points to this partition or forward\n");
888 if (
op[12] == 1 &&
op[13] == 1) mxf->
op =
OP1a;
889 else if (
op[12] == 1 &&
op[13] == 2) mxf->
op =
OP1b;
890 else if (
op[12] == 1 &&
op[13] == 3) mxf->
op =
OP1c;
891 else if (
op[12] == 2 &&
op[13] == 1) mxf->
op =
OP2a;
892 else if (
op[12] == 2 &&
op[13] == 2) mxf->
op =
OP2b;
893 else if (
op[12] == 2 &&
op[13] == 3) mxf->
op =
OP2c;
894 else if (
op[12] == 3 &&
op[13] == 1) mxf->
op =
OP3a;
895 else if (
op[12] == 3 &&
op[13] == 2) mxf->
op =
OP3b;
896 else if (
op[12] == 3 &&
op[13] == 3) mxf->
op =
OP3c;
898 else if (
op[12] == 0x10) {
903 if (nb_essence_containers != 1) {
909 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
910 nb_essence_containers,
911 mxfop ==
OP1a ?
"OP1a" :
"OPAtom");
949 return (score << 60) | ((uint64_t)p->
pack_ofs >> 4);
961 for (
int i = 0;
i <
mg->metadata_sets_count;
i++) {
962 if (!memcmp((*metadata_set)->uid,
mg->metadata_sets[
i]->uid, 16)) {
963 uint64_t old_s =
mg->metadata_sets[
i]->partition_score;
964 uint64_t new_s = (*metadata_set)->partition_score;
997 if (
c > INT_MAX /
sizeof(
UID))
1009 if (
ret != *count *
sizeof(
UID)) {
1010 *count =
ret < 0 ? 0 :
ret /
sizeof(
UID);
1022 if (size < 0 || size > INT_MAX - 1)
1025 buf_size =
size + 1;
1046 if (size < 0 || size > INT_MAX/2)
1068 #define READ_STR16(type, big_endian) \
1069 static int mxf_read_utf16 ## type ##_string(AVIOContext *pb, int size, char** str) \
1071 return mxf_read_utf16_string(pb, size, str, big_endian); \
1152 mxf_read_utf16be_string(pb,
size, &track->
name);
1205 &package->tracks_count);
1209 avio_read(pb, package->package_uid, 16);
1212 avio_read(pb, package->descriptor_ref, 16);
1215 return mxf_read_utf16be_string(pb,
size, &package->name);
1218 &package->comment_count);
1245 uint32_t nb_index_entries;
1247 if (
segment->temporal_offset_entries)
1251 if (nb_index_entries > INT_MAX)
1253 segment->nb_index_entries = nb_index_entries;
1256 if(
segment->nb_index_entries && length < 11)
1267 for (
i = 0;
i <
segment->nb_index_entries;
i++) {
1301 if (
segment->index_edit_rate.num <= 0 ||
1302 segment->index_edit_rate.den <= 0)
1305 segment->index_edit_rate.den);
1334 }
while (
code != 0);
1342 int entry_count, entry_size;
1375 if (entry_size == 4) {
1376 if (entry_count > 0)
1380 if (entry_count > 1)
1463 for (
int i = 0;
i < 3;
i++) {
1493 if (!descriptor->
coll) {
1495 if (!descriptor->
coll)
1572 return mxf_read_utf16le_string(pb,
size - 17, &tagged_value->
value);
1574 return mxf_read_utf16be_string(pb,
size - 17, &tagged_value->
value);
1584 return mxf_read_utf16be_string(pb,
size, &tagged_value->
name);
1598 for (
i = 0;
i <
len;
i++) {
1599 if (
i != 7 &&
key[
i] != uid_prefix[
i])
1607 while (uls->
uid[0]) {
1621 for (
int i =
mg->metadata_sets_count - 1;
i >= 0;
i--)
1622 if (!memcmp(*strong_ref,
mg->metadata_sets[
i]->uid, 16))
1623 return mg->metadata_sets[
i];
1630 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000,
NULL, 14,
J2KWrap },
1631 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 }, 14,
AV_CODEC_ID_H264,
NULL, 15 },
1632 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 }, 14,
AV_CODEC_ID_DNXHD,
NULL, 14 },
1633 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x1e,0x01,0x00 }, 14,
AV_CODEC_ID_DNXUC,
NULL, 14 },
1634 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 }, 14,
AV_CODEC_ID_VC1,
NULL, 14 },
1635 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 }, 14,
AV_CODEC_ID_TIFF,
NULL, 14 },
1636 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 }, 14,
AV_CODEC_ID_DIRAC,
NULL, 14 },
1637 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1b,0x01,0x00 }, 14,
AV_CODEC_ID_CFHD,
NULL, 14 },
1638 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1c,0x01,0x00 }, 14,
AV_CODEC_ID_PRORES,
NULL, 14 },
1639 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15 },
1640 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x04,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15,
D10D11Wrap },
1641 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x23,0x01,0x00 }, 14,
AV_CODEC_ID_FFV1,
NULL, 14 },
1642 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO,
NULL, 15 },
1643 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO,
NULL, 15,
RawVWrap },
1644 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x01,0x01 }, 15,
AV_CODEC_ID_HQ_HQA },
1645 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x02,0x01 }, 15,
AV_CODEC_ID_HQX },
1646 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x15,0x00,0x04,0x02,0x10,0x00,0x01 }, 16,
AV_CODEC_ID_HEVC,
NULL, 15 },
1647 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14,
AV_CODEC_ID_RAWVIDEO },
1648 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1653 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1654 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1659 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
1660 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
1661 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1666 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x01 }, 16, 1440 },
1667 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x02 }, 16, 1440 },
1668 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x03 }, 16, 1440 },
1669 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x04 }, 16, 1440 },
1670 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 },
1675 { { 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 },
1676 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2,
NULL, 15 },
1677 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE,
NULL, 13 },
1678 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
1679 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
1680 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x16,0x00,0x00 }, 14,
AV_CODEC_ID_AAC,
NULL, 14 },
1681 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x17,0x00,0x00 }, 14,
AV_CODEC_ID_AAC,
NULL, 14 },
1682 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x18,0x00,0x00 }, 14,
AV_CODEC_ID_AAC,
NULL, 14 },
1683 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1687 { { 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 },
1688 { { 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 },
1689 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x13,0x01,0x01 }, 16,
AV_CODEC_ID_TTML },
1690 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1700 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x01,0x00,0x00,0x00,0x00 },
AV_CHAN_FRONT_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1701 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x02,0x00,0x00,0x00,0x00 },
AV_CHAN_FRONT_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1702 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x03,0x00,0x00,0x00,0x00 },
AV_CHAN_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1703 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x04,0x00,0x00,0x00,0x00 },
AV_CHAN_LOW_FREQUENCY,
AV_AUDIO_SERVICE_TYPE_MAIN },
1704 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x05,0x00,0x00,0x00,0x00 },
AV_CHAN_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1705 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x06,0x00,0x00,0x00,0x00 },
AV_CHAN_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1706 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x07,0x00,0x00,0x00,0x00 },
AV_CHAN_SIDE_SURROUND_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1707 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x08,0x00,0x00,0x00,0x00 },
AV_CHAN_SIDE_SURROUND_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1708 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x09,0x00,0x00,0x00,0x00 },
AV_CHAN_BACK_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1709 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0a,0x00,0x00,0x00,0x00 },
AV_CHAN_BACK_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1710 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0b,0x00,0x00,0x00,0x00 },
AV_CHAN_FRONT_LEFT_OF_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1711 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0c,0x00,0x00,0x00,0x00 },
AV_CHAN_FRONT_RIGHT_OF_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1712 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0d,0x00,0x00,0x00,0x00 },
AV_CHAN_BACK_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1713 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0e,0x00,0x00,0x00,0x00 },
AV_CHAN_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED },
1714 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x0f,0x00,0x00,0x00,0x00 },
AV_CHAN_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED },
1715 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x20,0x03,0x00,0x00,0x00 },
AV_CHAN_STEREO_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1716 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x20,0x04,0x00,0x00,0x00 },
AV_CHAN_STEREO_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1717 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x01,0x00,0x00 },
AV_CHAN_TOP_FRONT_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1718 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x02,0x00,0x00 },
AV_CHAN_TOP_FRONT_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1719 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x03,0x00,0x00 },
AV_CHAN_TOP_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1720 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x04,0x00,0x00 },
AV_CHAN_TOP_SURROUND_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1721 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x05,0x00,0x00 },
AV_CHAN_TOP_SURROUND_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1722 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x06,0x00,0x00 },
AV_CHAN_TOP_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1723 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x07,0x00,0x00 },
AV_CHAN_TOP_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1724 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x08,0x00,0x00 },
AV_CHAN_TOP_BACK_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1725 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x09,0x00,0x00 },
AV_CHAN_TOP_BACK_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1726 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0a,0x00,0x00 },
AV_CHAN_TOP_SIDE_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1727 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0b,0x00,0x00 },
AV_CHAN_TOP_SIDE_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1728 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0c,0x00,0x00 },
AV_CHAN_TOP_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1729 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0d,0x00,0x00 },
AV_CHAN_LOW_FREQUENCY,
AV_AUDIO_SERVICE_TYPE_MAIN },
1730 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0e,0x00,0x00 },
AV_CHAN_LOW_FREQUENCY_2,
AV_AUDIO_SERVICE_TYPE_MAIN },
1731 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x0f,0x00,0x00 },
AV_CHAN_TOP_BACK_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1732 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x10,0x00,0x00 },
AV_CHAN_BACK_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1733 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x11,0x00,0x00 },
AV_CHAN_BOTTOM_FRONT_LEFT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1734 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x12,0x00,0x00 },
AV_CHAN_BOTTOM_FRONT_RIGHT,
AV_AUDIO_SERVICE_TYPE_MAIN },
1735 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x03,0x02,0x01,0x30,0x01,0x13,0x00,0x00 },
AV_CHAN_BOTTOM_FRONT_CENTER,
AV_AUDIO_SERVICE_TYPE_MAIN },
1736 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_AUDIO_SERVICE_TYPE_NB },
1752 val = (*essence_container_ul)[
codec_ul->wrapping_indicator_pos];
1753 switch (
codec_ul->wrapping_indicator_type) {
1758 if (
val == 0x03 ||
val == 0x04)
1779 int i, j, nb_segments = 0;
1781 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1785 nb_segments =
mg->metadata_sets_count;
1789 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1790 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1796 for (
i = nb_segments = 0;
i <
mg->metadata_sets_count;
i++) {
1798 if (
s->edit_unit_byte_count ||
s->nb_index_entries)
1799 unsorted_segments[nb_segments++] =
s;
1801 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1802 s->index_sid,
s->index_start_position);
1811 *nb_sorted_segments = 0;
1814 for (
i = 0;
i < nb_segments;
i++) {
1815 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1816 uint64_t best_index_duration = 0;
1818 for (j = 0; j < nb_segments; j++) {
1826 s->body_sid > last_body_sid ||
1827 s->body_sid == last_body_sid &&
s->index_sid > last_index_sid ||
1828 s->body_sid == last_body_sid &&
s->index_sid == last_index_sid &&
s->index_start_position > last_index_start) &&
1830 s->body_sid < best_body_sid ||
1831 s->body_sid == best_body_sid &&
s->index_sid < best_index_sid ||
1832 s->body_sid == best_body_sid &&
s->index_sid == best_index_sid &&
s->index_start_position < best_index_start ||
1833 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)) {
1835 best_body_sid =
s->body_sid;
1836 best_index_sid =
s->index_sid;
1837 best_index_start =
s->index_start_position;
1838 best_index_duration =
s->index_duration;
1846 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1847 last_body_sid = best_body_sid;
1848 last_index_sid = best_index_sid;
1849 last_index_start = best_index_start;
1872 m0 = m = (
a +
b) >> 1;
1874 while (m < b && mxf->partitions[m].body_sid != body_sid)
1877 if (m < b && mxf->partitions[m].body_offset <=
offset)
1889 *partition_out = last_p;
1894 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1924 int64_t index_duration, index_end;
1949 if (index_duration > 0 && edit_unit <= INT64_MAX / index_table->nb_segments) {
1960 if (
s->index_start_position <= edit_unit && edit_unit < s->index_start_position +
s->index_duration) {
1964 if (
s->edit_unit_byte_count) {
1965 if (
index > INT64_MAX /
s->edit_unit_byte_count ||
1966 s->edit_unit_byte_count *
index > INT64_MAX - offset_temp)
1969 offset_temp +=
s->edit_unit_byte_count *
index;
1971 if (
s->nb_index_entries == 2 *
s->index_duration + 1)
1974 if (index < 0 || index >=
s->nb_index_entries) {
1980 offset_temp =
s->stream_offset_entries[
index];
1984 *edit_unit_out =
av_rescale_q(edit_unit, edit_rate,
s->index_edit_rate);
1987 }
else if (dir == 0) {
1990 if (edit_unit < s->index_start_position) {
2007 int8_t max_temporal_offset = -128;
2014 if (!
s->nb_index_entries) {
2019 if (
s->index_duration > INT_MAX -
index_table->nb_ptses) {
2025 if (
s->nb_index_entries !=
s->index_duration &&
2026 s->nb_index_entries !=
s->index_duration + 1 &&
2027 s->nb_index_entries !=
s->index_duration * 2 + 1) {
2029 av_log(mxf->
fc,
AV_LOG_ERROR,
"ignoring IndexSID %d, duration does not match nb_index_entries\n",
s->index_sid);
2084 int index_delta = 1;
2085 int n =
s->nb_index_entries;
2087 if (
s->nb_index_entries == 2 *
s->index_duration + 1)
2089 if (
s->nb_index_entries == index_delta *
s->index_duration + 1)
2093 for (j = 0; j < n; j += index_delta, x++) {
2094 int offset =
s->temporal_offset_entries[j] / index_delta;
2099 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
2100 s->nb_index_entries,
s->index_duration);
2106 if (index < 0 || index >=
index_table->nb_ptses) {
2108 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
2115 max_temporal_offset =
FFMAX(max_temporal_offset,
offset);
2138 int ret, nb_sorted_segments;
2142 nb_sorted_segments <= 0) {
2148 for (
int i = 0;
i < nb_sorted_segments;
i++) {
2149 if (
i == 0 || sorted_segments[
i-1]->index_sid != sorted_segments[
i]->index_sid)
2151 else if (sorted_segments[
i-1]->body_sid != sorted_segments[
i]->body_sid) {
2154 goto finish_decoding_index;
2163 goto finish_decoding_index;
2167 for (
int i = 0, j = 0;
i < nb_sorted_segments;
i++) {
2168 if (
i != 0 && sorted_segments[
i-1]->index_sid != sorted_segments[
i]->index_sid) {
2184 " pointer array\n");
2186 goto finish_decoding_index;
2189 if (sorted_segments[
i]->index_start_position)
2190 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
2198 goto finish_decoding_index;
2219 s->offset = offset_temp;
2222 if (
s->edit_unit_byte_count && (
s->index_duration > INT64_MAX /
s->edit_unit_byte_count ||
2223 s->edit_unit_byte_count *
s->index_duration > INT64_MAX - offset_temp)) {
2225 goto finish_decoding_index;
2234 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
2251 finish_decoding_index:
2257 static const uint8_t st_422_essence_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c };
2259 return essence_container_ul &&
mxf_match_uid(*essence_container_ul, st_422_essence_container_ul,
2260 sizeof(st_422_essence_container_ul));
2272 char str[2 +
sizeof(
UID) * 4 + 1])
2280 uint16_t patch, uint16_t release,
char **str)
2282 *str =
av_asprintf(
"%d.%d.%d.%d.%d", major, minor, tertiary, patch, release);
2290 char str[2 + 4 *
sizeof(
UID) + 1];
2328 package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], SourcePackage);
2332 if (!memcmp(package->package_ul, package_ul, 16) && !memcmp(package->package_uid, package_uid, 16))
2349 if (!file_descriptor) {
2354 return file_descriptor;
2438 if (physical_package->
name && physical_package->
name[0])
2458 "Invalid edit rate (%d/%d) found on structural"
2459 " component #%d, defaulting to 25/1\n",
2560 if (rfc5646 && strlen(rfc5646) > 1) {
2561 char primary_tag[4] =
2562 {rfc5646[0], rfc5646[1], rfc5646[2] !=
'-' ? rfc5646[2] :
'\0',
'\0'};
2575 for (
int k = 0; k <
mg->metadata_sets_count; k++) {
2587 if (ffv1_sub_descriptor ==
NULL)
2602 int ambigous_language = 0;
2604 int ambigous_service_type = 0;
2608 char *channel_language;
2624 if (target_channel == 0 && descriptor->
channels == 1)
2626 if (target_channel <= 0 || target_channel > descriptor->
channels) {
2627 av_log(mxf->
fc,
AV_LOG_ERROR,
"AudioChannelLabelSubDescriptor has invalid MCA channel ID %d\n", target_channel);
2630 ch_layout->
u.
map[target_channel - 1].
id = channel_ordering->channel;
2632 service_type = channel_ordering->service_type;
2633 else if (service_type != channel_ordering->service_type)
2634 ambigous_service_type = 1;
2639 channel_language = label->
language;
2640 if (!channel_language) {
2643 channel_language = group->
language;
2648 channel_language = supergroup->
language;
2652 if (channel_language) {
2654 ambigous_language = 1;
2660 if (
language && !ambigous_language) {
2675 *ast = service_type;
2693 if (material_package)
break;
2695 if (!material_package) {
2701 if (material_package->
name && material_package->
name[0])
2713 UID *essence_container_ul =
NULL;
2764 if (!source_package) {
2775 source_track = temp_track;
2779 if (!source_track) {
2798 if(source_track && component)
2801 if (!source_track || !component || !source_package) {
2845 "Invalid edit rate (%d/%d) found on stream #%d, "
2846 "defaulting to 25/1\n",
2876 if (
mg->metadata_sets_count) {
2892 for (k = 0; k < 16; k++) {
2895 if (!(k+1 & 19) || k == 5)
2901 if (source_package->
name && source_package->
name[0])
2903 if (material_track->
name && material_track->
name[0])
2951 "Field dominance %d support",
2965 "Field dominance %d support",
2978 switch ((*essence_container_ul)[14]) {
3049 if (descriptor->
coll) {
3070 "found for stream #%d, time base forced to 1/48000\n",
3158 "with different wrapping\n",
i, j, track1->
body_sid);
3171 struct tm time = { 0 };
3173 time.tm_year = (timestamp >> 48) - 1900;
3174 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
3175 time.tm_mday = (timestamp >> 32 & 0xFF);
3176 time.tm_hour = (timestamp >> 24 & 0xFF);
3177 time.tm_min = (timestamp >> 16 & 0xFF);
3178 time.tm_sec = (timestamp >> 8 & 0xFF);
3179 msecs = (timestamp & 0xFF) * 4;
3182 time.tm_mon =
av_clip(time.tm_mon, 0, 11);
3183 time.tm_mday =
av_clip(time.tm_mday, 1, 31);
3184 time.tm_hour =
av_clip(time.tm_hour, 0, 23);
3185 time.tm_min =
av_clip(time.tm_min, 0, 59);
3186 time.tm_sec =
av_clip(time.tm_sec, 0, 59);
3187 msecs =
av_clip(msecs, 0, 999);
3192 #define SET_STR_METADATA(pb, name, str) do { \
3193 if ((ret = mxf_read_utf16be_string(pb, size, &str)) < 0) \
3195 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
3198 #define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \
3199 major = avio_rb16(pb); \
3200 minor = avio_rb16(pb); \
3201 tertiary = avio_rb16(pb); \
3202 patch = avio_rb16(pb); \
3203 release = avio_rb16(pb); \
3204 if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \
3206 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
3209 #define SET_UID_METADATA(pb, name, var, str) do { \
3210 char uuid_str[2 * AV_UUID_LEN + 4 + 1]; \
3211 avio_read(pb, var, 16); \
3212 av_uuid_unparse(uid, uuid_str); \
3213 av_dict_set(&s->metadata, name, uuid_str, 0); \
3216 #define SET_TS_METADATA(pb, name, var, str) do { \
3217 var = avio_rb64(pb); \
3218 if (var && (ret = ff_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \
3230 uint16_t major, minor, tertiary, patch, release;
3280 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
3281 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
3282 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
3283 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
3284 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
3285 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
3286 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
3287 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
3288 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
3289 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
3290 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
3291 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 },
mxf_read_preface_metadata },
3292 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
3293 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage },
3294 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
SourcePackage },
3295 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
MaterialPackage },
3296 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
3297 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x05,0x00 },
mxf_read_essence_group,
sizeof(
MXFEssenceGroup),
EssenceGroup},
3298 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
3299 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3f,0x00 },
mxf_read_tagged_value,
sizeof(
MXFTaggedValue),
TaggedValue },
3300 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
3301 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3302 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3303 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3304 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3305 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3306 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3307 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5b,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3308 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3309 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3310 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3311 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6b,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
AudioChannelLabelSubDescriptor },
3312 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6c,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
SoundfieldGroupLabelSubDescriptor },
3313 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6d,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
GroupOfSoundfieldGroupsLabelSubDescriptor },
3314 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x81,0x03 },
mxf_read_ffv1_sub_descriptor,
sizeof(
MXFFFV1SubDescriptor),
FFV1SubDescriptor },
3315 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
3316 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
3317 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
3318 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0c,0x00 },
mxf_read_pulldown_component,
sizeof(
MXFPulldownComponent),
PulldownComponent },
3319 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
3320 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
3321 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x23,0x00 },
mxf_read_essence_container_data,
sizeof(
MXFEssenceContainerData),
EssenceContainerData },
3322 { { 0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x10,0x01,0x00,0x00,0x00 } },
3363 if (next < 0 || next > INT64_MAX -
size) {
3380 if (local_tag ==
tag) {
3387 if (meta &&
tag == 0x3C0A) {
3404 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
3424 key[13] >= 2 &&
key[13] <= 4;
3436 if (klv.
key[5] == 0x53) {
3466 int64_t current_partition_ofs;
3497 if (klv.
offset >= current_partition_ofs) {
3499 PRIx64
" indirectly points to itself\n", current_partition_ofs);
3539 "failed to seek to FooterPartition @ 0x%" PRIx64
3540 " (%"PRId64
") - partial file?\n",
3563 for (
int i = 0;
i <
s->nb_streams;
i++) {
3599 if (x < mxf->partitions_count - 1)
3606 "partition %i: bad ThisPartition = %"PRIX64
"\n",
3663 int essence_partition_count = 0;
3664 int edit_unit_byte_count = 0;
3672 for (
i = 0;
i <
mg->metadata_sets_count;
i++) {
3685 essence_partition_count++;
3689 if (essence_partition_count != 1)
3699 if (edit_unit_byte_count <= 0)
3716 segment->edit_unit_byte_count = edit_unit_byte_count;
3717 segment->index_start_position = 0;
3729 int64_t file_size, max_rip_length, min_rip_length;
3745 max_rip_length = ((file_size - mxf->
run_in) / 105) * 12 + 28;
3746 max_rip_length =
FFMIN(max_rip_length, INT_MAX);
3749 min_rip_length = 16+1+24+4;
3755 if (length < min_rip_length || length > max_rip_length)
3757 avio_seek(
s->pb, file_size - length, SEEK_SET);
3833 if (!essence_offset)
3834 essence_offset = klv.
offset;
3868 if (!essence_offset) {
3879 for (
int i = 0;
i <
s->nb_streams;
i++)
3887 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
3896 for (
int i = 0;
i <
s->nb_streams;
i++)
3914 m = (
a + (uint64_t)
b) >> 1;
3917 if (
offset < current_offset)
3939 if ((sample_rate.
num / sample_rate.
den) == 48000) {
3946 "seeking detected on stream #%d with time base (%d/%d) and "
3947 "sample rate (%d/%d), audio pts won't be accurate.\n",
3949 sample_rate.
num, sample_rate.
den);
3977 if (next_ofs > current_offset)
3992 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);
4004 if (!bits_per_sample)
4010 bits_per_sample <= 0 ||
4065 max_data_size = klv.
length;
4092 "error getting stream index %"PRIu32
"\n",
4108 if (next_ofs <= 0) {
4116 if ((
size = next_ofs -
pos) <= 0) {
4122 if (
size > max_data_size)
4123 size = max_data_size;
4133 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
4184 for (
int i = 0;
i <
s->nb_streams;
i++)
4185 s->streams[
i]->priv_data =
NULL;
4189 for (
int i = 0;
i <
mg->metadata_sets_count;
i++)
4191 mg->metadata_sets_count = 0;
4212 const uint8_t *bufp = p->
buf;
4221 for (; bufp < end;) {
4222 if (!((bufp[13] - 1) & 0xF2)){
4240 AVStream *st =
s->streams[stream_index];
4259 if (sample_time < 0)
4263 seekpos =
avio_seek(
s->pb, (
s->bit_rate * seconds) >> 3, SEEK_SET);
4276 for (
i = 0;
i <
s->nb_streams;
i++) {
4277 MXFTrack *new_source_track =
s->streams[
i]->priv_data;
4280 source_track = new_source_track;
4285 if (
i ==
s->nb_streams)
4291 sample_time =
FFMAX(sample_time, 0);
4300 sample_time < t->ptses[0] &&
4302 sample_time = t->
ptses[0];
4308 sample_time += t->
offsets[sample_time];
4324 if (seekpos < klv.next_klv - klv.length || seekpos >= klv.
next_klv) {
4336 for (
int i = 0;
i <
s->nb_streams;
i++) {
4340 int64_t track_edit_unit = sample_time;
4350 {
"eia608_extract",
"extract eia 608 captions from s436m track",