271 static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
272 static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
273 static const uint8_t mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
274 static const uint8_t mxf_system_item_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
277 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 };
278 static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
279 static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
280 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 };
281 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 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
289 int bytes_num = size & 0x7f;
295 size = size << 8 |
avio_r8(pb);
303 for (i = 0; i < size && !
avio_feof(pb); i++) {
307 else if (b != key[i])
321 return klv->
length == -1 ? -1 : 0;
341 const uint8_t *buf_ptr, *end_ptr;
350 data_ptr = pkt->
data;
352 buf_ptr = pkt->
data + 4;
355 uint32_t
sample = bytestream_get_le32(&buf_ptr);
357 bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
359 bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
369 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
375 uint64_t plaintext_size;
402 if (orig_size < plaintext_size)
406 if (size < 32 || size - 32 < orig_size)
412 if (memcmp(tmpbuf, checkv, 16))
418 else if (size < plaintext_size)
420 size -= plaintext_size;
423 &pkt->
data[plaintext_size], size >> 4, ivec, 1);
436 if (item_len != 18) {
440 if (item_num > 65536) {
461 uint64_t footer_partition;
462 uint32_t nb_essence_containers;
481 memset(partition, 0,
sizeof(*partition));
523 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
536 "Overriding PreviousPartition with %"PRIx64
"\n",
541 if (footer_partition) {
544 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
552 "PartitionPack: ThisPartition = 0x%"PRIX64
553 ", PreviousPartition = 0x%"PRIX64
", "
554 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
564 "PreviousPartition points to this partition or forward\n");
568 if (op[12] == 1 && op[13] == 1) mxf->
op =
OP1a;
569 else if (op[12] == 1 && op[13] == 2) mxf->
op =
OP1b;
570 else if (op[12] == 1 && op[13] == 3) mxf->
op =
OP1c;
571 else if (op[12] == 2 && op[13] == 1) mxf->
op =
OP2a;
572 else if (op[12] == 2 && op[13] == 2) mxf->
op =
OP2b;
573 else if (op[12] == 2 && op[13] == 3) mxf->
op =
OP2c;
574 else if (op[12] == 3 && op[13] == 1) mxf->
op =
OP3a;
575 else if (op[12] == 3 && op[13] == 2) mxf->
op =
OP3b;
576 else if (op[12] == 3 && op[13] == 3) mxf->
op =
OP3c;
577 else if (op[12] == 64&& op[13] == 1) mxf->
op =
OPSONYOpt;
578 else if (op[12] == 0x10) {
583 if (nb_essence_containers != 1) {
589 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
590 nb_essence_containers,
591 op ==
OP1a ?
"OP1a" :
"OPAtom");
597 av_log(mxf->
fc,
AV_LOG_ERROR,
"unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
785 buf_size = size + size / 2 + 1;
804 package->tracks_refs =
av_calloc(package->tracks_count,
sizeof(
UID));
805 if (!package->tracks_refs)
816 avio_read(pb, package->descriptor_ref, 16);
864 av_dlog(NULL,
"IndexEntryArray found\n");
886 int code,
value, ofs = 0;
892 av_dlog(NULL,
"pixel layout: code %#x\n", code);
895 layout[ofs++] = code;
896 layout[ofs++] =
value;
994 for (i = 0; i <
len; i++) {
995 if (i != 7 && key[i] != uid[i])
1003 while (uls->
uid[0]) {
1028 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1029 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO },
1030 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO },
1031 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14,
AV_CODEC_ID_RAWVIDEO },
1032 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1037 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1038 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1043 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
1044 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
1045 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1050 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14,
AV_CODEC_ID_PCM_S16LE },
1051 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2 },
1052 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE },
1053 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
1054 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
1055 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1059 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16, 0 },
1060 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1064 "vbi_vanc_smpte_436M",
1069 int i, j, nb_segments = 0;
1071 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1081 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1082 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1092 *nb_sorted_segments = 0;
1095 for (i = 0; i < nb_segments; i++) {
1096 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1097 uint64_t best_index_duration = 0;
1099 for (j = 0; j < nb_segments; j++) {
1121 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1122 last_body_sid = best_body_sid;
1123 last_index_sid = best_index_sid;
1124 last_index_start = best_index_start;
1138 int64_t offset_in =
offset;
1155 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1156 offset_in, body_sid);
1188 int64_t offset_temp = 0;
1212 av_log(mxf->
fc,
AV_LOG_ERROR,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1218 *edit_unit_out = edit_unit;
1236 int8_t max_temporal_offset = -128;
1262 for (x = 0; x < index_table->
nb_ptses; x++)
1294 int index_delta = 1;
1303 for (j = 0; j <
n; j += index_delta, x++) {
1309 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
1317 if (index < 0 || index >= index_table->
nb_ptses) {
1319 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
1325 max_temporal_offset =
FFMAX(max_temporal_offset, offset);
1329 index_table->
first_dts = -max_temporal_offset;
1340 int i, j, k,
ret, nb_sorted_segments;
1344 nb_sorted_segments <= 0) {
1350 for (i = 0; i < nb_sorted_segments; i++) {
1351 if (i == 0 || sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid)
1353 else if (sorted_segments[i-1]->body_sid != sorted_segments[i]->body_sid) {
1356 goto finish_decoding_index;
1365 goto finish_decoding_index;
1369 for (i = j = 0; i < nb_sorted_segments; i++) {
1370 if (i != 0 && sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid) {
1386 " pointer array\n");
1388 goto finish_decoding_index;
1391 if (sorted_segments[i]->index_start_position)
1392 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
1400 goto finish_decoding_index;
1408 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
1425 finish_decoding_index:
1445 for (i = 0; i <
sizeof(
UID); i++) {
1446 snprintf(p, 2 + 1,
"%.2x", uid[i]);
1448 if (i == 3 || i == 5 || i == 7 || i == 9) {
1483 switch (component->
type) {
1501 package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], SourcePackage);
1505 if (!memcmp(package->package_uid, package_uid, 16))
1535 component->
duration = descriptor->duration;
1549 switch (component->
type) {
1569 int64_t start_position;
1582 if (physical_package->
name && physical_package->
name[0])
1629 if (material_package)
break;
1631 if (!material_package) {
1637 if (material_package->
name && material_package->
name[0])
1648 UID *essence_container_ul = NULL;
1694 if (!source_package) {
1695 av_dlog(mxf->
fc,
"material track %d: no corresponding source package found\n", material_track->
track_id);
1705 source_track = temp_track;
1709 if (!source_track) {
1714 if (!source_track || !component)
1745 "Invalid edit rate (%d/%d) found on stream #%d, "
1746 "defaulting to 25/1\n",
1767 if (!sub_descriptor) {
1772 descriptor = sub_descriptor;
1793 essence_container_ul = &((
MXFCryptoContext *)metadata)->source_container_ul;
1804 for (k = 0; k < 16; k++) {
1807 if (!(k+1 & 19) || k == 5)
1813 if (source_package->
name && source_package->
name[0])
1820 container_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
1851 "Field dominance %d support",
1889 container_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
1901 "found for stream #%d, time base forced to 1/48000\n",
1929 essence_container_ul)->
id;
1930 if (codec_id >= 0 &&
1933 mxf_data_essence_descriptor[codec_id], 0);
1958 struct tm time = { 0 };
1959 time.tm_year = (timestamp >> 48) - 1900;
1960 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
1961 time.tm_mday = (timestamp >> 32 & 0xFF);
1962 time.tm_hour = (timestamp >> 24 & 0xFF);
1963 time.tm_min = (timestamp >> 16 & 0xFF);
1964 time.tm_sec = (timestamp >> 8 & 0xFF);
1969 time.tm_mon = av_clip(time.tm_mon, 0, 11);
1970 time.tm_mday = av_clip(time.tm_mday, 1, 31);
1971 time.tm_hour = av_clip(time.tm_hour, 0, 23);
1972 time.tm_min = av_clip(time.tm_min, 0, 59);
1973 time.tm_sec = av_clip(time.tm_sec, 0, 59);
1978 if (!strftime(*str, 32,
"%Y-%m-%d %H:%M:%S", &time))
1984 #define SET_STR_METADATA(pb, name, str) do { \
1985 if ((ret = mxf_read_utf16_string(pb, size, &str)) < 0) \
1987 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
1990 #define SET_UID_METADATA(pb, name, var, str) do { \
1991 avio_read(pb, var, 16); \
1992 if ((ret = mxf_uid_to_str(var, &str)) < 0) \
1994 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
1997 #define SET_TS_METADATA(pb, name, var, str) do { \
1998 var = avio_rb64(pb); \
1999 if ((ret = mxf_timestamp_to_str(var, &str)) < 0) \
2001 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
2042 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
2043 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
2044 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
2045 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
2046 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
2047 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
2048 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
2049 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
2050 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
2051 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
2052 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
2053 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
2054 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage, 0,
AnyType },
2055 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
SourcePackage },
2056 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
MaterialPackage },
2057 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
2058 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x05,0x00 },
mxf_read_essence_group,
sizeof(
MXFEssenceGroup),
EssenceGroup},
2059 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
2060 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
2061 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2062 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2063 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2064 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2065 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2066 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2067 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2068 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2069 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2070 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2071 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2072 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
2073 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0c,0x00 },
mxf_read_pulldown_component,
sizeof(
MXFPulldownComponent),
PulldownComponent },
2074 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
2075 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
2076 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0,
AnyType },
2109 av_dlog(mxf->
fc,
"local tag %#04x size %d\n", tag, size);
2118 if (local_tag == tag) {
2120 av_dlog(mxf->
fc,
"local tag %#04x\n", local_tag);
2125 if (ctx_size && tag == 0x3C0A)
2127 else if ((ret = read_child(ctx, pb, tag, size, uid, -1)) < 0)
2137 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
2158 key[13] >= 2 && key[13] <= 4;
2170 if (klv.
key[5] == 0x53) {
2200 int64_t current_partition_ofs;
2212 av_dlog(mxf->
fc,
"seeking to previous partition\n");
2231 if (klv.
offset >= current_partition_ofs) {
2233 PRIx64
" indirectly points to itself\n", current_partition_ofs);
2256 av_dlog(mxf->
fc,
"no FooterPartition\n");
2260 av_dlog(mxf->
fc,
"seeking to FooterPartition\n");
2273 "failed to seek to FooterPartition @ 0x%" PRIx64
2274 " (%"PRId64
") - partial file?\n",
2322 "partition %i: bad ThisPartition = %"PRIX64
"\n",
2332 int64_t
ret = (position / kag_size) * kag_size;
2333 return ret == position ? ret : ret + kag_size;
2376 int64_t file_size, max_rip_length, min_rip_length;
2392 max_rip_length = ((file_size - mxf->
run_in) / 105) * 12 + 28;
2393 max_rip_length =
FFMIN(max_rip_length, INT_MAX);
2396 min_rip_length = 16+1+24+4;
2407 klv.
length != length - 20)
2427 int64_t essence_offset = 0;
2472 int64_t op1a_essence_offset =
2490 if (!essence_offset)
2491 essence_offset = klv.
offset;
2506 for (metadata = mxf_metadata_read_table; metadata->
read; metadata++) {
2516 if (!metadata->
read)
2520 if (!essence_offset) {
2538 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
2561 int64_t last_ofs = -1, next_ofs = -1;
2574 if (next_ofs <= last_ofs) {
2578 "next_ofs didn't change. not deriving packet timestamps\n");
2582 if (next_ofs > current_offset)
2585 last_ofs = next_ofs;
2597 uint64_t *sample_count)
2599 int i, total = 0, size = 0;
2606 if ((sample_rate.
num / sample_rate.
den) == 48000)
2609 int remainder = (sample_rate.
num * time_base.
num) %
2610 (time_base.
den * sample_rate.
den);
2612 av_mul_q(sample_rate, time_base)));
2615 "seeking detected on stream #%d with time base (%d/%d) and "
2616 "sample rate (%d/%d), audio pts won't be accurate.\n",
2617 stream_index, time_base.
num, time_base.
den,
2618 sample_rate.
num, sample_rate.
den);
2643 if (!bits_per_sample)
2649 || bits_per_sample <= 0
2650 || codec->
channels * (int64_t)bits_per_sample < 8)
2676 int64_t next_ofs, next_klv;
2683 "error getting stream index %"PRIu32
"\n",
2697 if (next_ofs >= 0 && next_klv > next_ofs) {
2701 "OPAtom misinterpreted as OP1a?"
2702 "KLV for edit unit %i extending into "
2709 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
2760 int64_t ret64, pos, next_pos;
2789 if ((size = next_pos - pos) <= 0) {
2794 if ((ret64 =
avio_seek(s->
pb, pos, SEEK_SET)) < 0)
2885 for (; bufp <
end;) {
2886 if (!((bufp[13] - 1) & 0xF2)){
2920 if (sample_time < 0)
2935 sample_time =
FFMAX(sample_time, 0);
2959 uint64_t current_sample_count = 0;