71#define MXF_MAX_CHUNK_SIZE (32 << 20)
72#define RUN_IN_MAX (65535+1)
195#define MXF_BLACK_REF_LEVEL_PRESENT (1 << 0)
196#define MXF_WHITE_REF_LEVEL_PRESENT (1 << 1)
197#define MXF_COLOR_RANGE_PRESENT (1 << 2)
210#define MXF_FIELD_DOMINANCE_DEFAULT 0
211#define MXF_FIELD_DOMINANCE_FF 1
212#define MXF_FIELD_DOMINANCE_FL 2
345static const uint8_t
mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
346static const uint8_t
mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
347static const uint8_t
mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
348static const uint8_t
mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x0a,0x0e,0x0f,0x03,0x01 };
349static const uint8_t
mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
350static const uint8_t
mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 };
352static const uint8_t
mxf_apple_coll_prefix[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01 };
355static const uint8_t
mxf_crypto_source_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 };
356static const uint8_t
mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
357static const uint8_t
mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
358static const uint8_t
mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
359static const uint8_t
mxf_ffv1_extradata[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x01,0x06,0x0c,0x01,0x00,0x00,0x00 };
360static const uint8_t
mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
361static const uint8_t
mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00 };
362static const uint8_t
mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 };
363static const uint8_t
mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 };
364static const uint8_t
mxf_apple_coll_max_cll[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 };
365static const uint8_t
mxf_apple_coll_max_fall[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 };
367static const uint8_t
mxf_mca_label_dictionary_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x01,0x00,0x00,0x00 };
368static const uint8_t
mxf_mca_tag_symbol[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x02,0x00,0x00,0x00 };
369static const uint8_t
mxf_mca_tag_name[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x03,0x00,0x00,0x00 };
370static 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 };
371static const uint8_t
mxf_mca_link_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x05,0x00,0x00,0x00 };
372static const uint8_t
mxf_mca_channel_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x04,0x0a,0x00,0x00,0x00,0x00 };
373static const uint8_t
mxf_soundfield_group_link_id[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x01,0x03,0x07,0x01,0x06,0x00,0x00,0x00 };
374static const uint8_t
mxf_mca_rfc5646_spoken_language[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0d,0x03,0x01,0x01,0x02,0x03,0x15,0x00,0x00 };
376static const uint8_t
mxf_sub_descriptor[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x04,0x06,0x10,0x00,0x00 };
386#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
444 int bytes_num =
size & 0x7f;
449 *llen = bytes_num + 1;
456 if (
size > INT64_MAX)
468 else if (
b !=
key[
i])
509 if (klv->
offset > INT64_MAX - 16 - llen)
513 if (
pos > INT64_MAX - length)
521 for (
int i = 0;
i <
s->nb_streams;
i++) {
528 return s->nb_streams == 1 &&
s->streams[0]->priv_data ? 0 : -1;
557 int cdp_identifier, cdp_length, cdp_footer_id, ccdata_id, cc_count;
558 int line_num, sample_coding, sample_count;
559 int did, sdid, data_length;
565 for (
int i = 0;
i < count;
i++) {
574 length -= 6 + 8 + sample_count;
575 if (line_num != 9 && line_num != 11)
577 if (sample_coding == 7 || sample_coding == 8 || sample_coding == 9) {
589 if (did != 0x61 || sdid != 1) {
594 if (cdp_identifier != 0x9669) {
603 if (ccdata_id != 0x72) {
611 if (cdp_length - 9 - 4 < cc_count * 3) {
615 avio_skip(
s->pb, data_length - 9 - 4 - cc_count * 3);
617 if (cdp_footer_id != 0x74) {
632 const uint8_t *buf_ptr, *end_ptr;
640 data_ptr =
pkt->data;
641 end_ptr =
pkt->data + length;
642 buf_ptr =
pkt->data + 4;
649 uint32_t
sample = bytestream_get_le32(&buf_ptr);
651 bytestream_put_le24(&data_ptr, (
sample >> 4) & 0xffffff);
653 bytestream_put_le16(&data_ptr, (
sample >> 12) & 0xffff);
664 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
670 uint64_t plaintext_size;
677 if (!mxf->
aesc &&
s->key &&
s->keylen == 16) {
704 if (orig_size < plaintext_size)
708 if (
size < 32 ||
size - 32 < orig_size || (
int)orig_size != orig_size)
716 if (memcmp(tmpbuf, checkv, 16))
722 else if (
size < plaintext_size)
724 size -= plaintext_size;
727 &
pkt->data[plaintext_size],
size >> 4, ivec, 1);
740 if (item_len != 18) {
744 if (item_num > 65536 || item_num < 0) {
766 uint64_t footer_partition;
767 uint32_t nb_essence_containers;
768 uint64_t this_partition;
793 memset(partition, 0,
sizeof(*partition));
819 if (this_partition != klv_offset - mxf->
run_in) {
821 "this_partition %"PRId64
" mismatches %"PRId64
"\n",
822 this_partition, klv_offset - mxf->
run_in);
845 av_dict_set(&
s->metadata,
"operational_pattern_ul", str, 0);
848 if (this_partition &&
851 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
864 "Overriding PreviousPartition with %"PRIx64
"\n",
869 if (footer_partition) {
872 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
880 "PartitionPack: ThisPartition = 0x%"PRIX64
881 ", PreviousPartition = 0x%"PRIX64
", "
882 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
892 "PreviousPartition points to this partition or forward\n");
896 if (
op[12] == 1 &&
op[13] == 1) mxf->
op =
OP1a;
897 else if (
op[12] == 1 &&
op[13] == 2) mxf->
op =
OP1b;
898 else if (
op[12] == 1 &&
op[13] == 3) mxf->
op =
OP1c;
899 else if (
op[12] == 2 &&
op[13] == 1) mxf->
op =
OP2a;
900 else if (
op[12] == 2 &&
op[13] == 2) mxf->
op =
OP2b;
901 else if (
op[12] == 2 &&
op[13] == 3) mxf->
op =
OP2c;
902 else if (
op[12] == 3 &&
op[13] == 1) mxf->
op =
OP3a;
903 else if (
op[12] == 3 &&
op[13] == 2) mxf->
op =
OP3b;
904 else if (
op[12] == 3 &&
op[13] == 3) mxf->
op =
OP3c;
906 else if (
op[12] == 0x10) {
911 if (nb_essence_containers != 1) {
917 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
918 nb_essence_containers,
919 mxfop ==
OP1a ?
"OP1a" :
"OPAtom");
951 else if (p->complete)
957 return (score << 60) | ((uint64_t)p->pack_ofs >> 4);
969 for (
int i = 0;
i <
mg->metadata_sets_count;
i++) {
970 if (!memcmp((*metadata_set)->uid,
mg->metadata_sets[
i]->uid, 16)) {
971 uint64_t old_s =
mg->metadata_sets[
i]->partition_score;
972 uint64_t new_s = (*metadata_set)->partition_score;
1005 if (
c > INT_MAX /
sizeof(
UID))
1017 if (
ret != *count *
sizeof(
UID)) {
1018 *count =
ret < 0 ? 0 :
ret /
sizeof(
UID);
1033 buf_size =
size + 1;
1076#define READ_STR16(type, big_endian) \
1077static int mxf_read_utf16 ## type ##_string(AVIOContext *pb, int size, char** str) \
1079return mxf_read_utf16_string(pb, size, str, big_endian); \
1160 mxf_read_utf16be_string(pb,
size, &track->
name);
1213 &package->tracks_count);
1217 avio_read(pb, package->package_uid, 16);
1220 avio_read(pb, package->descriptor_ref, 16);
1223 return mxf_read_utf16be_string(pb,
size, &package->name);
1226 &package->comment_count);
1253 uint32_t nb_index_entries;
1255 if (
segment->temporal_offset_entries)
1259 if (nb_index_entries > INT_MAX)
1261 segment->nb_index_entries = nb_index_entries;
1264 if(
segment->nb_index_entries && length < 11)
1275 for (
i = 0;
i <
segment->nb_index_entries;
i++) {
1309 if (
segment->index_edit_rate.num <= 0 ||
1310 segment->index_edit_rate.den <= 0)
1313 segment->index_edit_rate.den);
1342 }
while (
code != 0);
1350 int entry_count, entry_size;
1383 if (entry_size == 4) {
1384 if (entry_count > 0)
1388 if (entry_count > 1)
1477 for (
int i = 0;
i < 3;
i++) {
1507 if (!descriptor->
coll) {
1509 if (!descriptor->
coll)
1586 return mxf_read_utf16le_string(pb,
size - 17, &tagged_value->
value);
1588 return mxf_read_utf16be_string(pb,
size - 17, &tagged_value->
value);
1598 return mxf_read_utf16be_string(pb,
size, &tagged_value->
name);
1612 for (
i = 0;
i <
len;
i++) {
1613 if (
i != 7 &&
key[
i] != uid_prefix[
i])
1621 while (uls->
uid[0]) {
1635 for (
int i =
mg->metadata_sets_count - 1;
i >= 0;
i--)
1636 if (!memcmp(*strong_ref,
mg->metadata_sets[
i]->uid, 16))
1637 return mg->metadata_sets[
i];
1644 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000,
NULL, 14,
J2KWrap },
1645 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 }, 14,
AV_CODEC_ID_H264,
NULL, 15 },
1646 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 }, 14,
AV_CODEC_ID_DNXHD,
NULL, 14 },
1647 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x1e,0x01,0x00 }, 14,
AV_CODEC_ID_DNXUC,
NULL, 14 },
1648 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 }, 14,
AV_CODEC_ID_VC1,
NULL, 14 },
1649 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 }, 14,
AV_CODEC_ID_TIFF,
NULL, 14 },
1650 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 }, 14,
AV_CODEC_ID_DIRAC,
NULL, 14 },
1651 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1b,0x01,0x00 }, 14,
AV_CODEC_ID_CFHD,
NULL, 14 },
1652 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1c,0x01,0x00 }, 14,
AV_CODEC_ID_PRORES,
NULL, 14 },
1653 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15 },
1654 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x04,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15,
D10D11Wrap },
1655 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x23,0x01,0x00 }, 14,
AV_CODEC_ID_FFV1,
NULL, 14 },
1656 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO,
NULL, 15 },
1657 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO,
NULL, 15,
RawVWrap },
1658 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x01,0x01 }, 15,
AV_CODEC_ID_HQ_HQA },
1659 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x02,0x01 }, 15,
AV_CODEC_ID_HQX },
1660 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x15,0x00,0x04,0x02,0x10,0x00,0x01 }, 16,
AV_CODEC_ID_HEVC,
NULL, 15 },
1661 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14,
AV_CODEC_ID_RAWVIDEO },
1662 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1667 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1668 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1673 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
1674 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
1675 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1680 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x01 }, 16, 1440 },
1681 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x02 }, 16, 1440 },
1682 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x03 }, 16, 1440 },
1683 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x04 }, 16, 1440 },
1684 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 },
1689 { { 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 },
1690 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2,
NULL, 15 },
1691 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE,
NULL, 13 },
1692 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
1693 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
1694 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x16,0x00,0x00 }, 14,
AV_CODEC_ID_AAC,
NULL, 14 },
1695 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x17,0x00,0x00 }, 14,
AV_CODEC_ID_AAC,
NULL, 14 },
1696 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0d,0x0d,0x01,0x03,0x01,0x02,0x18,0x00,0x00 }, 14,
AV_CODEC_ID_AAC,
NULL, 14 },
1697 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1701 { { 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 },
1702 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16,
AV_CODEC_ID_SMPTE_436M_ANC,
"vbi_vanc_smpte_436M", 11 },
1703 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x13,0x01,0x01 }, 16,
AV_CODEC_ID_TTML },
1704 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1714 { { 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 },
1715 { { 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 },
1716 { { 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 },
1717 { { 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 },
1718 { { 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 },
1719 { { 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 },
1720 { { 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 },
1721 { { 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 },
1722 { { 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 },
1723 { { 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 },
1724 { { 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 },
1725 { { 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 },
1726 { { 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 },
1727 { { 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 },
1728 { { 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 },
1729 { { 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 },
1730 { { 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 },
1731 { { 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 },
1732 { { 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 },
1733 { { 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 },
1734 { { 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 },
1735 { { 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 },
1736 { { 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 },
1737 { { 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 },
1738 { { 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 },
1739 { { 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 },
1740 { { 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 },
1741 { { 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 },
1742 { { 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 },
1743 { { 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 },
1744 { { 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 },
1745 { { 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 },
1746 { { 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 },
1747 { { 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 },
1748 { { 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 },
1749 { { 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 },
1750 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_AUDIO_SERVICE_TYPE_NB },
1766 val = (*essence_container_ul)[
codec_ul->wrapping_indicator_pos];
1767 switch (
codec_ul->wrapping_indicator_type) {
1772 if (
val == 0x03 ||
val == 0x04)
1793 int i, j, nb_segments = 0;
1795 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1799 nb_segments =
mg->metadata_sets_count;
1803 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1804 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1810 for (
i = nb_segments = 0;
i <
mg->metadata_sets_count;
i++) {
1812 if (
s->edit_unit_byte_count ||
s->nb_index_entries)
1813 unsorted_segments[nb_segments++] =
s;
1815 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1816 s->index_sid,
s->index_start_position);
1825 *nb_sorted_segments = 0;
1828 for (
i = 0;
i < nb_segments;
i++) {
1829 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1830 uint64_t best_index_duration = 0;
1832 for (j = 0; j < nb_segments; j++) {
1840 s->body_sid > last_body_sid ||
1841 s->body_sid == last_body_sid &&
s->index_sid > last_index_sid ||
1842 s->body_sid == last_body_sid &&
s->index_sid == last_index_sid &&
s->index_start_position > last_index_start) &&
1844 s->body_sid < best_body_sid ||
1845 s->body_sid == best_body_sid &&
s->index_sid < best_index_sid ||
1846 s->body_sid == best_body_sid &&
s->index_sid == best_index_sid &&
s->index_start_position < best_index_start ||
1847 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)) {
1849 best_body_sid =
s->body_sid;
1850 best_index_sid =
s->index_sid;
1851 best_index_start =
s->index_start_position;
1852 best_index_duration =
s->index_duration;
1860 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1861 last_body_sid = best_body_sid;
1862 last_index_sid = best_index_sid;
1863 last_index_start = best_index_start;
1886 m0 = m = (
a +
b) >> 1;
1888 while (m < b && mxf->partitions[m].body_sid != body_sid)
1891 if (m < b && mxf->partitions[m].body_offset <=
offset)
1903 *partition_out = last_p;
1908 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1922 if (p->body_sid != body_sid)
1925 if (!p->essence_length)
1928 return p->essence_offset + p->essence_length;
1938 int64_t index_duration, index_end;
1963 if (index_duration > 0 && edit_unit <= INT64_MAX / index_table->nb_segments) {
1974 if (
s->index_start_position <= edit_unit && edit_unit < s->index_start_position +
s->index_duration) {
1978 if (
s->edit_unit_byte_count) {
1979 if (
index > INT64_MAX /
s->edit_unit_byte_count ||
1980 s->edit_unit_byte_count *
index > INT64_MAX - offset_temp)
1983 offset_temp +=
s->edit_unit_byte_count *
index;
1985 if (
s->nb_index_entries == 2 *
s->index_duration + 1)
1994 offset_temp =
s->stream_offset_entries[
index];
1998 *edit_unit_out =
av_rescale_q(edit_unit, edit_rate,
s->index_edit_rate);
2001 }
else if (dir == 0) {
2004 if (edit_unit < s->index_start_position) {
2021 int8_t max_temporal_offset = -128;
2028 if (!
s->nb_index_entries) {
2033 if (
s->index_duration > INT_MAX -
index_table->nb_ptses) {
2039 if (
s->nb_index_entries !=
s->index_duration &&
2040 s->nb_index_entries !=
s->index_duration + 1 &&
2041 s->nb_index_entries !=
s->index_duration * 2 + 1) {
2043 av_log(mxf->
fc,
AV_LOG_ERROR,
"ignoring IndexSID %d, duration does not match nb_index_entries\n",
s->index_sid);
2098 int index_delta = 1;
2099 int n =
s->nb_index_entries;
2101 if (
s->nb_index_entries == 2 *
s->index_duration + 1)
2103 if (
s->nb_index_entries == index_delta *
s->index_duration + 1)
2107 for (j = 0; j < n; j += index_delta, x++) {
2108 int offset =
s->temporal_offset_entries[j] / index_delta;
2113 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
2114 s->nb_index_entries,
s->index_duration);
2122 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
2129 max_temporal_offset =
FFMAX(max_temporal_offset,
offset);
2152 int ret, nb_sorted_segments;
2156 nb_sorted_segments <= 0) {
2162 for (
int i = 0;
i < nb_sorted_segments;
i++) {
2163 if (
i == 0 || sorted_segments[
i-1]->index_sid != sorted_segments[
i]->index_sid)
2165 else if (sorted_segments[
i-1]->body_sid != sorted_segments[
i]->body_sid) {
2168 goto finish_decoding_index;
2177 goto finish_decoding_index;
2181 for (
int i = 0, j = 0;
i < nb_sorted_segments;
i++) {
2182 if (
i != 0 && sorted_segments[
i-1]->index_sid != sorted_segments[
i]->index_sid) {
2198 " pointer array\n");
2200 goto finish_decoding_index;
2203 if (sorted_segments[
i]->index_start_position)
2204 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
2212 goto finish_decoding_index;
2233 s->offset = offset_temp;
2236 if (
s->edit_unit_byte_count && (
s->index_duration > INT64_MAX /
s->edit_unit_byte_count ||
2237 s->edit_unit_byte_count *
s->index_duration > INT64_MAX - offset_temp)) {
2239 goto finish_decoding_index;
2248 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
2265finish_decoding_index:
2271 static const uint8_t st_422_essence_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c };
2273 return essence_container_ul &&
mxf_match_uid(*essence_container_ul, st_422_essence_container_ul,
2274 sizeof(st_422_essence_container_ul));
2286 char str[2 +
sizeof(
UID) * 4 + 1])
2288 snprintf(str, 2 +
sizeof(
UID) * 4 + 1,
"0x");
2294 uint16_t patch, uint16_t release,
char **str)
2296 *str =
av_asprintf(
"%d.%d.%d.%d.%d", major, minor, tertiary, patch, release);
2304 char str[2 + 4 *
sizeof(
UID) + 1];
2342 package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], SourcePackage);
2346 if (!memcmp(package->package_ul, package_ul, 16) && !memcmp(package->package_uid, package_uid, 16))
2363 if (!file_descriptor) {
2368 return file_descriptor;
2452 if (physical_package->
name && physical_package->
name[0])
2472 "Invalid edit rate (%d/%d) found on structural"
2473 " component #%d, defaulting to 25/1\n",
2553 unsigned def_black, def_white, def_range;
2558 def_black = 16 << (depth - 8);
2559 def_white = 235 << (depth - 8);
2560 def_range = (224 << (depth - 8)) + 1;
2562 def_black = depth == 8 ? 16 : depth == 10 ? 64 : 0;
2563 def_white = depth == 8 ? 235 : depth == 10 ? 940 : (1U << depth) - 1;
2564 def_range = (1U << depth) - 1;
2573 if (black == 0 && white == (1U << depth) - 1 &&
2574 (
range == 1U << depth ||
range == (1U << depth) - 1))
2577 black == 16 << (depth - 8) &&
2578 white == 235 << (depth - 8) &&
2579 range == (224 << (depth - 8)) + 1)
2583 range, black, white, depth);
2597 if (rfc5646 && strlen(rfc5646) > 1) {
2598 char primary_tag[4] =
2599 {rfc5646[0], rfc5646[1], rfc5646[2] !=
'-' ? rfc5646[2] :
'\0',
'\0'};
2612 for (
int k = 0; k <
mg->metadata_sets_count; k++) {
2614 if (!memcmp(&group->
mca_link_id, mca_link_id, 16))
2624 if (ffv1_sub_descriptor ==
NULL)
2638 char *language =
NULL;
2639 int ambigous_language = 0;
2641 int ambigous_service_type = 0;
2645 char *channel_language;
2659 if (
IS_KLV_KEY(channel_ordering->uid,
label->mca_label_dictionary_id)) {
2660 int target_channel =
label->mca_channel_id;
2661 if (target_channel == 0 && descriptor->
channels == 1)
2663 if (target_channel <= 0 || target_channel > descriptor->
channels) {
2664 av_log(mxf->
fc,
AV_LOG_ERROR,
"AudioChannelLabelSubDescriptor has invalid MCA channel ID %d\n", target_channel);
2667 ch_layout->
u.
map[target_channel - 1].
id = channel_ordering->channel;
2669 service_type = channel_ordering->service_type;
2670 else if (service_type != channel_ordering->service_type)
2671 ambigous_service_type = 1;
2676 channel_language =
label->language;
2677 if (!channel_language) {
2680 channel_language = group->
language;
2685 channel_language = supergroup->
language;
2689 if (channel_language) {
2690 if (language && strcmp(language, channel_language))
2691 ambigous_language = 1;
2693 language = channel_language;
2697 if (language && !ambigous_language) {
2712 *ast = service_type;
2730 if (material_package)
break;
2732 if (!material_package) {
2738 if (material_package->
name && material_package->
name[0])
2750 UID *essence_container_ul =
NULL;
2801 if (!source_package) {
2812 source_track = temp_track;
2816 if (!source_track) {
2835 if(source_track && component)
2838 if (!source_track || !component || !source_package) {
2882 "Invalid edit rate (%d/%d) found on stream #%d, "
2883 "defaulting to 25/1\n",
2913 if (
mg->metadata_sets_count) {
2929 for (k = 0; k < 16; k++) {
2932 if (!(k+1 & 19) || k == 5)
2938 if (source_package->
name && source_package->
name[0])
2940 if (material_track->
name && material_track->
name[0])
2989 "Field dominance %d support",
3003 "Field dominance %d support",
3016 switch ((*essence_container_ul)[14]) {
3066 if (material_track->
origin) {
3069 if (source_track->
origin) {
3087 if (descriptor->
coll) {
3108 "found for stream #%d, time base forced to 1/48000\n",
3194 "with different wrapping\n",
i, j, track1->
body_sid);
3207 struct tm time = { 0 };
3209 time.tm_year = (timestamp >> 48) - 1900;
3210 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
3211 time.tm_mday = (timestamp >> 32 & 0xFF);
3212 time.tm_hour = (timestamp >> 24 & 0xFF);
3213 time.tm_min = (timestamp >> 16 & 0xFF);
3214 time.tm_sec = (timestamp >> 8 & 0xFF);
3215 msecs = (timestamp & 0xFF) * 4;
3218 time.tm_mon =
av_clip(time.tm_mon, 0, 11);
3219 time.tm_mday =
av_clip(time.tm_mday, 1, 31);
3220 time.tm_hour =
av_clip(time.tm_hour, 0, 23);
3221 time.tm_min =
av_clip(time.tm_min, 0, 59);
3222 time.tm_sec =
av_clip(time.tm_sec, 0, 59);
3223 msecs =
av_clip(msecs, 0, 999);
3228#define SET_STR_METADATA(pb, name, str) do { \
3229 if ((ret = mxf_read_utf16be_string(pb, size, &str)) < 0) \
3231 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
3234#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \
3235 major = avio_rb16(pb); \
3236 minor = avio_rb16(pb); \
3237 tertiary = avio_rb16(pb); \
3238 patch = avio_rb16(pb); \
3239 release = avio_rb16(pb); \
3240 if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \
3242 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
3245#define SET_UID_METADATA(pb, name, var, str) do { \
3246 char uuid_str[2 * AV_UUID_LEN + 4 + 1]; \
3247 avio_read(pb, var, 16); \
3248 av_uuid_unparse(uid, uuid_str); \
3249 av_dict_set(&s->metadata, name, uuid_str, 0); \
3252#define SET_TS_METADATA(pb, name, var, str) do { \
3253 var = avio_rb64(pb); \
3254 if (var && (ret = ff_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \
3266 uint16_t major, minor, tertiary, patch, release;
3316 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
3317 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
3318 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
3319 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
3320 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
3321 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
3322 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
3323 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
3324 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
3325 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
3326 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
3327 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 },
mxf_read_preface_metadata },
3328 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
3329 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage },
3330 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
SourcePackage },
3331 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
MaterialPackage },
3332 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
3333 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x05,0x00 },
mxf_read_essence_group,
sizeof(
MXFEssenceGroup),
EssenceGroup},
3334 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
3335 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3f,0x00 },
mxf_read_tagged_value,
sizeof(
MXFTaggedValue),
TaggedValue },
3336 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
3337 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3338 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3339 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3340 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3341 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3342 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3343 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5b,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3344 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3345 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3346 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
3347 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6b,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
AudioChannelLabelSubDescriptor },
3348 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6c,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
SoundfieldGroupLabelSubDescriptor },
3349 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6d,0x00 },
mxf_read_mca_sub_descriptor,
sizeof(
MXFMCASubDescriptor),
GroupOfSoundfieldGroupsLabelSubDescriptor },
3350 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x81,0x03 },
mxf_read_ffv1_sub_descriptor,
sizeof(
MXFFFV1SubDescriptor),
FFV1SubDescriptor },
3351 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
3352 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
3353 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
3354 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0c,0x00 },
mxf_read_pulldown_component,
sizeof(
MXFPulldownComponent),
PulldownComponent },
3355 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
3356 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
3357 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x23,0x00 },
mxf_read_essence_container_data,
sizeof(
MXFEssenceContainerData),
EssenceContainerData },
3358 { { 0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x10,0x01,0x00,0x00,0x00 } },
3399 if (next < 0 || next > INT64_MAX -
size) {
3416 if (local_tag ==
tag) {
3423 if (meta &&
tag == 0x3C0A) {
3440 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
3460 key[13] >= 2 &&
key[13] <= 4;
3472 if (klv.
key[5] == 0x53) {
3502 int64_t current_partition_ofs;
3533 if (klv.
offset >= current_partition_ofs) {
3535 PRIx64
" indirectly points to itself\n", current_partition_ofs);
3575 "failed to seek to FooterPartition @ 0x%" PRIx64
3576 " (%"PRId64
") - partial file?\n",
3599 for (
int i = 0;
i <
s->nb_streams;
i++) {
3629 p->essence_offset = p->first_essence_klv.next_klv - p->first_essence_klv.length;
3630 p->essence_length = p->first_essence_klv.length;
3632 p->essence_offset = p->first_essence_klv.offset;
3635 if (x < mxf->partitions_count - 1)
3638 if (p->essence_length < 0) {
3640 p->essence_length = 0;
3642 "partition %i: bad ThisPartition = %"PRIX64
"\n",
3699 int essence_partition_count = 0;
3700 int edit_unit_byte_count = 0;
3708 for (
i = 0;
i <
mg->metadata_sets_count;
i++) {
3721 essence_partition_count++;
3725 if (essence_partition_count != 1)
3731 }
else if (st->
duration > 0 && p->first_essence_klv.length > 0 && p->first_essence_klv.length % st->
duration == 0) {
3732 edit_unit_byte_count = p->first_essence_klv.length / st->
duration;
3735 if (edit_unit_byte_count <= 0)
3752 segment->edit_unit_byte_count = edit_unit_byte_count;
3753 segment->index_start_position = 0;
3757 segment->body_sid = p->body_sid;
3765 int64_t file_size, max_rip_length, min_rip_length;
3781 max_rip_length = ((file_size - mxf->
run_in) / 105) * 12 + 28;
3782 max_rip_length =
FFMIN(max_rip_length, INT_MAX);
3785 min_rip_length = 16+1+24+4;
3791 if (length < min_rip_length || length > max_rip_length)
3793 avio_seek(
s->pb, file_size - length, SEEK_SET);
3869 if (!essence_offset)
3870 essence_offset = klv.
offset;
3904 if (!essence_offset) {
3915 for (
int i = 0;
i <
s->nb_streams;
i++)
3923 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
3932 for (
int i = 0;
i <
s->nb_streams;
i++)
3950 m = (
a + (uint64_t)
b) >> 1;
3953 if (
offset < current_offset)
3975 if ((sample_rate.
num / sample_rate.
den) == 48000) {
3982 "seeking detected on stream #%d with time base (%d/%d) and "
3983 "sample rate (%d/%d), audio pts won't be accurate.\n",
3985 sample_rate.
num, sample_rate.
den);
4013 if (next_ofs > current_offset)
4028 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);
4040 if (!bits_per_sample)
4046 bits_per_sample <= 0 ||
4101 max_data_size = klv.
length;
4128 "error getting stream index %"PRIu32
"\n",
4144 if (next_ofs <= 0) {
4152 if ((
size = next_ofs -
pos) <= 0) {
4158 if (
size > max_data_size)
4159 size = max_data_size;
4169 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
4220 for (
int i = 0;
i <
s->nb_streams;
i++)
4221 s->streams[
i]->priv_data =
NULL;
4225 for (
int i = 0;
i <
mg->metadata_sets_count;
i++)
4227 mg->metadata_sets_count = 0;
4248 const uint8_t *bufp = p->buf;
4257 for (; bufp < end;) {
4258 if (!((bufp[13] - 1) & 0xF2)){
4276 AVStream *st =
s->streams[stream_index];
4295 if (sample_time < 0)
4299 seekpos =
avio_seek(
s->pb, (
s->bit_rate * seconds) >> 3, SEEK_SET);
4312 for (
i = 0;
i <
s->nb_streams;
i++) {
4313 MXFTrack *new_source_track =
s->streams[
i]->priv_data;
4316 source_track = new_source_track;
4321 if (
i ==
s->nb_streams)
4327 sample_time =
FFMAX(sample_time, 0);
4336 sample_time < t->ptses[0] &&
4338 sample_time = t->
ptses[0];
4344 sample_time += t->
offsets[sample_time];
4360 if (seekpos < klv.next_klv - klv.length || seekpos >= klv.
next_klv) {
4372 for (
int i = 0;
i <
s->nb_streams;
i++) {
4376 int64_t track_edit_unit = sample_time;
4386 {
"eia608_extract",
"extract eia 608 captions from s436m track",
4393 .class_name =
"mxf",
static double val(void *priv, double ch)
static AVFormatContext * ctx
static const AVClass demuxer_class
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint64_t avio_rb64(AVIOContext *s)
int64_t avio_size(AVIOContext *s)
Get the filesize.
unsigned int avio_rb16(AVIOContext *s)
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a UTF-16 string from pb and convert it to UTF-8.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
char * av_asprintf(const char *fmt,...)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
Public libavutil channel layout APIs header.
Misc types and constants that do not belong anywhere else.
#define AV_PROFILE_JPEG2000_DCINEMA_2K
#define AV_EF_EXPLODE
abort decoding on minor error detection
@ AV_FIELD_TT
Top coded_first, top displayed first.
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
@ AV_FIELD_BT
Bottom coded first, top displayed first.
@ AV_FIELD_TB
Top coded first, bottom displayed first.
#define AV_PROFILE_JPEG2000_DCINEMA_4K
@ AV_AUDIO_SERVICE_TYPE_MAIN
@ AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED
@ AV_AUDIO_SERVICE_TYPE_NB
Not part of ABI.
@ AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries, int64_t wanted_timestamp, int flags)
Internal version of av_index_search_timestamp.
int ff_generate_avci_extradata(AVStream *st)
Generate standard extradata for AVC-Intra based on width/height and field order.
void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
Update cur_dts of all streams based on the given timestamp and AVStream.
static int read_header(FFV1Context *f, RangeCoder *c)
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
Get the type of the given codec.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_PCM_S24DAUD
@ AV_CODEC_ID_SMPTE_436M_ANC
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AVDISCARD_ALL
discard all
AVPacketSideData * av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, size_t size, int flags)
Allocate a new packet side data.
AVPacketSideData * av_packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size, int flags)
Wrap existing data as packet side data.
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context.
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
@ AV_CHAN_TOP_SURROUND_RIGHT
-110 degrees, Rvs, TpRS
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_SIDE_SURROUND_RIGHT
-90 degrees, Rss, SiR
@ AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHAN_TOP_SURROUND_LEFT
+110 degrees, Lvs, TpLS
@ AV_CHAN_SIDE_SURROUND_LEFT
+90 degrees, Lss, SiL
@ AV_CHAN_FRONT_LEFT_OF_CENTER
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_TOP_BACK_CENTER
@ AV_CHAN_BOTTOM_FRONT_CENTER
@ AV_CHAN_BOTTOM_FRONT_RIGHT
@ AV_CHAN_STEREO_RIGHT
See above.
@ AV_CHAN_BOTTOM_FRONT_LEFT
@ AV_CHAN_STEREO_LEFT
Stereo downmix.
@ AV_CHAN_TOP_FRONT_CENTER
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define LIBAVUTIL_VERSION_INT
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
common internal api header.
#define FF_SANE_NB_CHANNELS
Macro definitions for various function/variable attributes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_ALLOC_TYPED_ARRAY(p, nelem)
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
@ AV_CLASS_CATEGORY_DEMUXER
#define MKTAG(a, b, c, d)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
const MXFCodecUL ff_mxf_data_definition_uls[]
SMPTE RP224 http://www.smpte-ra.org/mdd/index.html.
const uint8_t ff_mxf_random_index_pack_key[16]
const MXFCodecUL ff_mxf_pixel_format_uls[]
const MXFCodecUL ff_mxf_color_space_uls[]
const MXFCodecUL ff_mxf_color_trc_uls[]
int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt)
const MXFCodecUL ff_mxf_codec_tag_uls[]
const MXFCodecUL ff_mxf_codec_uls[]
const MXFCodecUL ff_mxf_color_primaries_uls[]
#define FF_MXF_MasteringDisplayMinimumLuminance
#define PRINT_KEY(pc, s, x)
#define FF_MXF_MasteringDisplayPrimaries
#define FF_MXF_MasteringDisplayWhitePointChromaticity
#define FF_MXF_MASTERING_CHROMA_DEN
#define FF_MXF_MASTERING_LUMA_DEN
#define FF_MXF_MasteringDisplay_PREFIX
#define FF_MXF_MasteringDisplayMaximumLuminance
@ SoundfieldGroupLabelSubDescriptor
@ AudioChannelLabelSubDescriptor
@ GroupOfSoundfieldGroupsLabelSubDescriptor
static int mxf_read_package(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_encrypted_essence_container[]
static int mxf_read_mca_sub_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int64_t klv_decode_ber_length(AVIOContext *pb, int *llen)
static int mxf_set_pts(MXFContext *mxf, AVStream *st, AVPacket *pkt)
static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static void mxf_free_metadataset(MXFMetadataSet **ctx, enum MXFMetadataSetType type)
static int mxf_compute_ptses_fake_index(MXFContext *mxf, MXFIndexTable *index_table)
static const uint8_t mxf_canopus_essence_element_key[]
static const MXFCodecUL mxf_picture_essence_container_uls[]
static int64_t mxf_timestamp_to_int64(uint64_t timestamp)
static const MXFCodecUL mxf_intra_only_essence_container_uls[]
static int mxf_read_essence_container_data(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const MXFChannelOrderingUL mxf_channel_ordering[]
static int mxf_read_source_clip(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_soundfield_group_link_id[]
static MXFMCASubDescriptor * find_mca_link_id(MXFContext *mxf, enum MXFMetadataSetType type, UID *mca_link_id)
static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
static MXFIndexTable * mxf_find_index_table(MXFContext *mxf, int index_sid)
static const uint8_t mxf_sub_descriptor[]
static void parse_ffv1_sub_descriptor(MXFContext *mxf, MXFTrack *source_track, MXFDescriptor *descriptor, AVStream *st)
static const MXFMetadataReadTableEntry mxf_metadata_read_table[]
static int mxf_read_preface_metadata(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_add_metadata_stream(MXFContext *mxf, MXFTrack *track)
static const uint8_t mxf_crypto_source_container_ul[]
static int mxf_read_tagged_value(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_apple_coll_max_fall[]
static int mxf_add_metadata_set(MXFContext *mxf, MXFMetadataSet **metadata_set, enum MXFMetadataSetType type)
static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_track, AVStream *st)
#define MXF_FIELD_DOMINANCE_FF
static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
static int mxf_parse_structural_metadata(MXFContext *mxf)
static const uint8_t mxf_mca_tag_name[]
static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
static int64_t mxf_set_current_edit_unit(MXFContext *mxf, AVStream *st, int64_t current_offset, int resync)
Make sure track->sample_count is correct based on what offset we're currently at.
static const uint8_t mxf_klv_key[]
static const uint8_t mxf_encrypted_triplet_key[]
static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, AVRational edit_rate, int64_t *edit_unit_out, int64_t *offset_out, MXFPartition **partition_out, int nag)
static const uint8_t mxf_header_partition_pack_key[]
#define MXF_FIELD_DOMINANCE_DEFAULT
static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segments, MXFIndexTableSegment ***sorted_segments)
static const MXFCodecUL mxf_intra_only_picture_coded_width[]
static const MXFCodecUL mxf_data_essence_container_uls[]
static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
#define SET_TS_METADATA(pb, name, var, str)
static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_t current_offset, int64_t *edit_unit_out)
#define SET_UID_METADATA(pb, name, var, str)
static int mxf_is_st_422(const UID *essence_container_ul)
static const uint8_t mxf_sony_mpeg4_extradata[]
static const uint8_t mxf_mca_link_id[]
static int mxf_read_identification_metadata(void *arg, AVIOContext *pb, int tag, int size, UID _uid, int64_t klv_offset)
static const uint8_t mxf_indirect_value_utf16le[]
static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
#define MXF_BLACK_REF_LEVEL_PRESENT
static int64_t mxf_essence_container_end(MXFContext *mxf, int body_sid)
Returns the end position of the essence container with given BodySID, or zero if unknown.
static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_mca_channel_id[]
static const uint8_t mxf_mastering_display_prefix[13]
static int klv_read_packet(MXFContext *mxf, KLVPacket *klv, AVIOContext *pb)
static int mxf_read_timecode_component(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_avid_essence_element_key[]
#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str)
static int mxf_add_umid_metadata(AVDictionary **pm, const char *key, MXFPackage *package)
#define SET_STR_METADATA(pb, name, str)
#define MXF_MAX_CHUNK_SIZE
static const uint8_t mxf_mastering_display_uls[4][16]
static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st, int64_t edit_unit)
#define READ_STR16(type, big_endian)
static int mxf_read_header(AVFormatContext *s)
static void mxf_compute_edit_units_per_packet(MXFContext *mxf, AVStream *st)
Deal with the case where for some audio atoms EditUnitByteCount is very small (2, 4....
static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t offset, int64_t *offset_out, MXFPartition **partition_out)
Computes the absolute file offset of the given essence container offset.
static int mxf_parse_handle_partition_or_eof(MXFContext *mxf)
Called when the next partition or EOF is encountered.
static int find_body_sid_by_absolute_offset(MXFContext *mxf, int64_t offset)
static int mxf_parse_handle_essence(MXFContext *mxf)
Called when essence is encountered.
static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_read_close(AVFormatContext *s)
static int mxf_read_ffv1_sub_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_set_audio_pts(MXFContext *mxf, AVCodecParameters *par, AVPacket *pkt)
static int is_pcm(enum AVCodecID codec_id)
static MXFStructuralComponent * mxf_resolve_sourceclip(MXFContext *mxf, UID *strong_ref)
static void * mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref, enum MXFMetadataSetType type)
static int mxf_read_us_ascii_string(AVIOContext *pb, int size, char **str)
static const MXFCodecUL * mxf_get_codec_ul(const MXFCodecUL *uls, UID *uid)
static const uint8_t mxf_mca_label_dictionary_id[]
static int mxf_seek_to_previous_partition(MXFContext *mxf)
Seeks to the previous partition and parses it, if possible.
#define MXF_COLOR_RANGE_PRESENT
static int set_language(AVFormatContext *s, const char *rfc5646, AVDictionary **met)
static int mxf_handle_missing_index_segment(MXFContext *mxf, AVStream *st)
Deal with the case where ClipWrapped essences does not have any IndexTableSegments.
static int mxf_is_partition_pack_key(UID key)
Matches any partition pack key, in other words:
static int mxf_parse_klv(MXFContext *mxf, KLVPacket klv, MXFMetadataReadFunc *read, int ctx_size, enum MXFMetadataSetType type)
Parses a metadata KLV.
static const uint8_t mxf_mca_rfc5646_spoken_language[]
int MXFMetadataReadFunc(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_avid_project_name[]
static int mxf_read_indirect_value(void *arg, AVIOContext *pb, int size)
static MXFWrappingScheme mxf_get_wrapping_kind(UID *essence_container_ul)
static int mxf_get_eia608_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt, int64_t length)
static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size)
static int mxf_add_timecode_metadata(AVDictionary **pm, const char *key, AVTimecode *tc)
static const uint8_t mxf_mca_tag_symbol[]
static void mxf_read_random_index_pack(AVFormatContext *s)
static int mxf_read_pulldown_component(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static MXFPackage * mxf_resolve_source_package(MXFContext *mxf, UID package_ul, UID package_uid)
static enum AVColorRange mxf_get_color_range(MXFContext *mxf, MXFDescriptor *descriptor)
static const uint8_t mxf_apple_coll_max_cll[]
static int mxf_read_essence_group(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t tertiary, uint16_t patch, uint16_t release, char **str)
static int mxf_read_sync_klv(AVIOContext *pb)
static int mxf_probe(const AVProbeData *p)
static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length)
static uint64_t partition_score(MXFPartition *p)
static const uint8_t mxf_essence_element_key[]
static int mxf_match_uid(const UID key, const uint8_t uid_prefix[], int len)
static MXFWrappingScheme mxf_get_wrapping_by_body_sid(AVFormatContext *s, int body_sid)
static const MXFCodecUL mxf_intra_only_picture_essence_coding_uls[]
static const uint8_t mxf_indirect_value_utf16be[]
#define MXF_FIELD_DOMINANCE_FL
static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static MXFDescriptor * mxf_resolve_descriptor(MXFContext *mxf, UID *strong_ref, int track_id)
#define MXF_WHITE_REF_LEVEL_PRESENT
static int mxf_metadataset_init(MXFMetadataSet *ctx, enum MXFMetadataSetType type, MXFPartition *partition)
static int mxf_parse_package_comments(MXFContext *mxf, AVDictionary **pm, MXFPackage *package)
static const uint8_t mxf_apple_coll_prefix[]
static const MXFCodecUL mxf_sound_essence_container_uls[]
static const uint8_t mxf_jp2k_rsiz[]
static MXFTimecodeComponent * mxf_resolve_timecode_component(MXFContext *mxf, UID *strong_ref)
static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv, int body_sid)
static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_ffv1_extradata[]
static int parse_mca_labels(MXFContext *mxf, MXFTrack *source_track, MXFDescriptor *descriptor, AVStream *st)
static void mxf_compute_essence_containers(AVFormatContext *s)
Figures out the proper offset and length of the essence container in each partition.
static int mxf_read_utf16_string(AVIOContext *pb, int size, char **str, int be)
static int mxf_compute_index_tables(MXFContext *mxf)
Sorts and collects index table segments into index tables.
static const uint8_t mxf_system_item_key_gc[]
static int mxf_is_intra_only(MXFDescriptor *descriptor)
static const uint8_t mxf_group_of_soundfield_groups_link_id[]
static void mxf_umid_to_str(const UID ul, const UID uid, char str[2+sizeof(UID) *4+1])
static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
static const uint8_t mxf_system_item_key_cp[]
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value, saturated to the range of time_t.
AVColorRange
Visual content value range.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define FF_ARRAY_ELEMS(a)
static const uint8_t index_table[8]
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
int nb_channels
Number of channels in this layout.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
Describe the class of an AVClass context structure.
This struct describes the properties of an encoded stream.
enum AVColorSpace color_space
enum AVFieldOrder field_order
The order of the fields in interlaced video.
int height
The height of the video frame in pixels.
int nb_coded_side_data
Amount of entries in coded_side_data.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
enum AVColorPrimaries color_primaries
int sample_rate
The number of audio samples per second.
enum AVColorTransferCharacteristic color_trc
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
enum AVColorRange color_range
Additional colorspace characteristics.
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVIOContext * pb
I/O context.
AVDictionary * metadata
Metadata that applies to the whole file.
AVStream ** streams
A list of all streams in the file.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
This structure stores compressed data.
This structure contains the data a format has to probe a file.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t duration
Decoding: duration of the stream, in stream time base.
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
AVRational r_frame_rate
Real base framerate of the stream.
AVRational display_aspect_ratio
display aspect ratio (0 if unknown)
enum AVStreamParseType need_parsing
enum AVAudioServiceType service_type
MXFPartition * partitions
MXFIndexTable * index_tables
int64_t last_forward_tell
uint64_t footer_partition
int last_forward_partition
KLVPacket current_klv_data
MXFPartition * current_partition
int essence_container_data_count
unsigned partitions_count
MXFMetadataSetGroup metadata_set_groups[MetadataSetTypeNB]
UID * essence_container_data_refs
unsigned int component_depth
enum AVPixelFormat pix_fmt
unsigned int horiz_subsampling
unsigned int black_ref_level
unsigned int vert_subsampling
UID * file_descriptors_refs
unsigned int white_ref_level
int file_descriptors_count
int sub_descriptors_count
UID * sub_descriptors_refs
AVMasteringDisplayMetadata * mastering
unsigned int range_items
MXF_*_PRESENT flags of the range items that were read.
AVContentLightMetadata * coll
UID * structural_components_refs
int structural_components_count
uint64_t * stream_offset_entries
unsigned edit_unit_byte_count
uint64_t index_start_position
AVRational index_edit_rate
int8_t * temporal_offset_entries
AVIndexEntry * fake_index
MXFIndexTableSegment ** segments
UID soundfield_group_link_id
UID mca_label_dictionary_id
UID * group_of_soundfield_groups_link_id_refs
int group_of_soundfield_groups_link_id_count
enum MXFMetadataSetType type
MXFMetadataReadFunc * read
uint64_t previous_partition
int64_t pack_ofs
absolute offset of pack in file, including run-in
int64_t essence_offset
absolute offset of essence
KLVPacket first_essence_klv
int64_t header_byte_count
UID * structural_components_refs
int structural_components_count
int64_t original_duration
int edit_units_per_packet
MXFWrappingScheme wrapping
#define av_malloc_array(a, b)
#define avpriv_request_sample(...)
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum_arg)
Load timecode string in buf.
#define AV_TIMECODE_STR_SIZE
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame