272 static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
273 static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
274 static const uint8_t mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
275 static const uint8_t mxf_system_item_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
278 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 };
279 static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
280 static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
281 static const uint8_t mxf_random_index_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
282 static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
283 static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
284 static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 };
286 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
291 switch ((*ctx)->type) {
325 int bytes_num = size & 0x7f;
331 size = size << 8 |
avio_r8(pb);
339 for (i = 0; i < size && !
avio_feof(pb); i++) {
343 else if (b != key[i])
357 return klv->
length == -1 ? -1 : 0;
377 const uint8_t *buf_ptr, *end_ptr;
386 data_ptr = pkt->
data;
388 buf_ptr = pkt->
data + 4;
391 uint32_t
sample = bytestream_get_le32(&buf_ptr);
393 bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
395 bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
405 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
411 uint64_t plaintext_size;
438 if (orig_size < plaintext_size)
442 if (size < 32 || size - 32 < orig_size)
448 if (memcmp(tmpbuf, checkv, 16))
454 else if (size < plaintext_size)
456 size -= plaintext_size;
459 &pkt->
data[plaintext_size], size >> 4, ivec, 1);
472 if (item_len != 18) {
476 if (item_num > 65536) {
497 uint64_t footer_partition;
498 uint32_t nb_essence_containers;
517 memset(partition, 0,
sizeof(*partition));
559 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
572 "Overriding PreviousPartition with %"PRIx64
"\n",
577 if (footer_partition) {
580 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
588 "PartitionPack: ThisPartition = 0x%"PRIX64
589 ", PreviousPartition = 0x%"PRIX64
", "
590 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
600 "PreviousPartition points to this partition or forward\n");
604 if (op[12] == 1 && op[13] == 1) mxf->
op =
OP1a;
605 else if (op[12] == 1 && op[13] == 2) mxf->
op =
OP1b;
606 else if (op[12] == 1 && op[13] == 3) mxf->
op =
OP1c;
607 else if (op[12] == 2 && op[13] == 1) mxf->
op =
OP2a;
608 else if (op[12] == 2 && op[13] == 2) mxf->
op =
OP2b;
609 else if (op[12] == 2 && op[13] == 3) mxf->
op =
OP2c;
610 else if (op[12] == 3 && op[13] == 1) mxf->
op =
OP3a;
611 else if (op[12] == 3 && op[13] == 2) mxf->
op =
OP3b;
612 else if (op[12] == 3 && op[13] == 3) mxf->
op =
OP3c;
613 else if (op[12] == 64&& op[13] == 1) mxf->
op =
OPSONYOpt;
614 else if (op[12] == 0x10) {
619 if (nb_essence_containers != 1) {
625 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
626 nb_essence_containers,
627 op ==
OP1a ?
"OP1a" :
"OPAtom");
633 av_log(mxf->
fc,
AV_LOG_ERROR,
"unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
814 buf_size = size + size / 2 + 1;
833 &package->tracks_count);
840 avio_read(pb, package->descriptor_ref, 16);
913 int code,
value, ofs = 0;
922 layout[ofs++] = code;
923 layout[ofs++] =
value;
1022 for (i = 0; i <
len; i++) {
1023 if (i != 7 && key[i] != uid[i])
1031 while (uls->
uid[0]) {
1056 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1057 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO },
1058 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO },
1059 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14,
AV_CODEC_ID_RAWVIDEO },
1060 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1065 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1066 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1071 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
1072 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
1073 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1078 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14,
AV_CODEC_ID_PCM_S16LE },
1079 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2 },
1080 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE },
1081 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
1082 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
1083 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1087 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16, 0 },
1088 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1092 "vbi_vanc_smpte_436M",
1097 int i, j, nb_segments = 0;
1099 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1109 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1110 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1120 *nb_sorted_segments = 0;
1123 for (i = 0; i < nb_segments; i++) {
1124 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1125 uint64_t best_index_duration = 0;
1127 for (j = 0; j < nb_segments; j++) {
1149 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1150 last_body_sid = best_body_sid;
1151 last_index_sid = best_index_sid;
1152 last_index_start = best_index_start;
1166 int64_t offset_in =
offset;
1183 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1184 offset_in, body_sid);
1216 int64_t offset_temp = 0;
1240 av_log(mxf->
fc,
AV_LOG_ERROR,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1246 *edit_unit_out = edit_unit;
1264 int8_t max_temporal_offset = -128;
1290 for (x = 0; x < index_table->
nb_ptses; x++)
1322 int index_delta = 1;
1331 for (j = 0; j <
n; j += index_delta, x++) {
1337 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
1345 if (index < 0 || index >= index_table->
nb_ptses) {
1347 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
1353 max_temporal_offset =
FFMAX(max_temporal_offset, offset);
1357 index_table->
first_dts = -max_temporal_offset;
1368 int i, j, k,
ret, nb_sorted_segments;
1372 nb_sorted_segments <= 0) {
1378 for (i = 0; i < nb_sorted_segments; i++) {
1379 if (i == 0 || sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid)
1381 else if (sorted_segments[i-1]->body_sid != sorted_segments[i]->body_sid) {
1384 goto finish_decoding_index;
1393 goto finish_decoding_index;
1397 for (i = j = 0; i < nb_sorted_segments; i++) {
1398 if (i != 0 && sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid) {
1414 " pointer array\n");
1416 goto finish_decoding_index;
1419 if (sorted_segments[i]->index_start_position)
1420 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
1428 goto finish_decoding_index;
1436 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
1453 finish_decoding_index:
1473 for (i = 0; i <
sizeof(
UID); i++) {
1474 snprintf(p, 2 + 1,
"%.2x", uid[i]);
1476 if (i == 3 || i == 5 || i == 7 || i == 9) {
1493 for (i = 0; i <
sizeof(
UID); i++) {
1498 for (i = 0; i <
sizeof(
UID); i++) {
1499 snprintf(p, 2 + 1,
"%.2X", uid[i]);
1534 switch (component->
type) {
1552 package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], SourcePackage);
1556 if (!memcmp(package->package_uid, package_uid, 16))
1574 if (!sub_descriptor) {
1579 return sub_descriptor;
1622 switch (component->
type) {
1642 int64_t start_position;
1655 if (physical_package->
name && physical_package->
name[0])
1702 if (material_package)
break;
1704 if (!material_package) {
1710 if (material_package->
name && material_package->
name[0])
1721 UID *essence_container_ul =
NULL;
1767 if (!source_package) {
1768 av_dlog(mxf->
fc,
"material track %d: no corresponding source package found\n", material_track->
track_id);
1778 source_track = temp_track;
1782 if (!source_track) {
1787 if (!source_track || !component)
1828 "Invalid edit rate (%d/%d) found on stream #%d, "
1829 "defaulting to 25/1\n",
1858 essence_container_ul = &((
MXFCryptoContext *)metadata)->source_container_ul;
1869 for (k = 0; k < 16; k++) {
1872 if (!(k+1 & 19) || k == 5)
1878 if (source_package->
name && source_package->
name[0])
1885 container_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
1916 "Field dominance %d support",
1954 container_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
1966 "found for stream #%d, time base forced to 1/48000\n",
1994 essence_container_ul)->
id;
1995 if (codec_id >= 0 &&
1998 mxf_data_essence_descriptor[codec_id], 0);
2023 struct tm time = { 0 };
2024 time.tm_year = (timestamp >> 48) - 1900;
2025 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
2026 time.tm_mday = (timestamp >> 32 & 0xFF);
2027 time.tm_hour = (timestamp >> 24 & 0xFF);
2028 time.tm_min = (timestamp >> 16 & 0xFF);
2029 time.tm_sec = (timestamp >> 8 & 0xFF);
2034 time.tm_mon = av_clip(time.tm_mon, 0, 11);
2035 time.tm_mday = av_clip(time.tm_mday, 1, 31);
2036 time.tm_hour = av_clip(time.tm_hour, 0, 23);
2037 time.tm_min = av_clip(time.tm_min, 0, 59);
2038 time.tm_sec = av_clip(time.tm_sec, 0, 59);
2043 if (!strftime(*str, 32,
"%Y-%m-%d %H:%M:%S", &time))
2049 #define SET_STR_METADATA(pb, name, str) do { \
2050 if ((ret = mxf_read_utf16_string(pb, size, &str)) < 0) \
2052 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
2055 #define SET_UID_METADATA(pb, name, var, str) do { \
2056 avio_read(pb, var, 16); \
2057 if ((ret = mxf_uid_to_str(var, &str)) < 0) \
2059 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
2062 #define SET_TS_METADATA(pb, name, var, str) do { \
2063 var = avio_rb64(pb); \
2064 if ((ret = mxf_timestamp_to_str(var, &str)) < 0) \
2066 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
2120 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
2121 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
2122 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
2123 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
2124 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
2125 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
2126 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
2127 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
2128 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
2129 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
2130 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
2131 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 },
mxf_read_preface_metadata },
2132 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
2133 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage, 0,
AnyType },
2134 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
SourcePackage },
2135 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
MaterialPackage },
2136 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
2137 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x05,0x00 },
mxf_read_essence_group,
sizeof(
MXFEssenceGroup),
EssenceGroup},
2138 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
2139 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
2140 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2141 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2142 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2143 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2144 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2145 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2146 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2147 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2148 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2149 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2150 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2151 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
2152 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0c,0x00 },
mxf_read_pulldown_component,
sizeof(
MXFPulldownComponent),
PulldownComponent },
2153 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
2154 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
2155 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
NULL, 0,
AnyType },
2188 av_dlog(mxf->
fc,
"local tag %#04x size %d\n", tag, size);
2197 if (local_tag == tag) {
2199 av_dlog(mxf->
fc,
"local tag %#04x\n", local_tag);
2204 if (ctx_size && tag == 0x3C0A) {
2206 }
else if ((ret = read_child(ctx, pb, tag, size, uid, -1)) < 0) {
2220 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
2241 key[13] >= 2 && key[13] <= 4;
2253 if (klv.
key[5] == 0x53) {
2283 int64_t current_partition_ofs;
2295 av_dlog(mxf->
fc,
"seeking to previous partition\n");
2314 if (klv.
offset >= current_partition_ofs) {
2316 PRIx64
" indirectly points to itself\n", current_partition_ofs);
2339 av_dlog(mxf->
fc,
"no FooterPartition\n");
2343 av_dlog(mxf->
fc,
"seeking to FooterPartition\n");
2356 "failed to seek to FooterPartition @ 0x%" PRIx64
2357 " (%"PRId64
") - partial file?\n",
2405 "partition %i: bad ThisPartition = %"PRIX64
"\n",
2415 int64_t
ret = (position / kag_size) * kag_size;
2416 return ret == position ? ret : ret + kag_size;
2464 int essence_partition_count = 0;
2487 essence_partition_count++;
2491 if (essence_partition_count != 1)
2494 if (!(segment =
av_mallocz(
sizeof(*segment))))
2517 int64_t file_size, max_rip_length, min_rip_length;
2533 max_rip_length = ((file_size - mxf->
run_in) / 105) * 12 + 28;
2534 max_rip_length =
FFMIN(max_rip_length, INT_MAX);
2537 min_rip_length = 16+1+24+4;
2548 klv.
length != length - 20)
2568 int64_t essence_offset = 0;
2613 int64_t op1a_essence_offset =
2631 if (!essence_offset)
2632 essence_offset = klv.
offset;
2647 for (metadata = mxf_metadata_read_table; metadata->
read; metadata++) {
2657 if (!metadata->
read)
2661 if (!essence_offset) {
2681 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
2704 int64_t last_ofs = -1, next_ofs = -1;
2717 if (next_ofs <= last_ofs) {
2721 "next_ofs didn't change. not deriving packet timestamps\n");
2725 if (next_ofs > current_offset)
2728 last_ofs = next_ofs;
2740 uint64_t *sample_count)
2742 int i, total = 0, size = 0;
2749 if ((sample_rate.
num / sample_rate.
den) == 48000)
2752 int remainder = (sample_rate.
num * time_base.
num) %
2753 (time_base.
den * sample_rate.
den);
2755 av_mul_q(sample_rate, time_base)));
2758 "seeking detected on stream #%d with time base (%d/%d) and "
2759 "sample rate (%d/%d), audio pts won't be accurate.\n",
2760 stream_index, time_base.
num, time_base.
den,
2761 sample_rate.
num, sample_rate.
den);
2786 if (!bits_per_sample)
2792 || bits_per_sample <= 0
2793 || codec->
channels * (int64_t)bits_per_sample < 8)
2819 int64_t next_ofs, next_klv;
2826 "error getting stream index %"PRIu32
"\n",
2840 if (next_ofs >= 0 && next_klv > next_ofs) {
2844 "OPAtom misinterpreted as OP1a?"
2845 "KLV for edit unit %i extending into "
2852 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
2903 int64_t ret64, pos, next_pos;
2932 if ((size = next_pos - pos) <= 0) {
2937 if ((ret64 =
avio_seek(s->
pb, pos, SEEK_SET)) < 0)
3000 for (; bufp <
end;) {
3001 if (!((bufp[13] - 1) & 0xF2)){
3035 if (sample_time < 0)
3050 sample_time =
FFMAX(sample_time, 0);
3074 uint64_t current_sample_count = 0;