255 static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
256 static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
257 static const uint8_t mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
258 static const uint8_t mxf_system_item_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
261 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 };
262 static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
263 static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
264 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 };
265 static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
267 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
273 int bytes_num = size & 0x7f;
279 size = size << 8 |
avio_r8(pb);
287 for (i = 0; i < size && !
avio_feof(pb); i++) {
291 else if (b != key[i])
305 return klv->
length == -1 ? -1 : 0;
325 const uint8_t *buf_ptr, *end_ptr;
334 data_ptr = pkt->
data;
336 buf_ptr = pkt->
data + 4;
339 uint32_t
sample = bytestream_get_le32(&buf_ptr);
341 bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
343 bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
353 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
359 uint64_t plaintext_size;
386 if (orig_size < plaintext_size)
390 if (size < 32 || size - 32 < orig_size)
396 if (memcmp(tmpbuf, checkv, 16))
402 else if (size < plaintext_size)
404 size -= plaintext_size;
407 &pkt->
data[plaintext_size], size >> 4, ivec, 1);
420 if (item_len != 18) {
424 if (item_num > 65536) {
441 uint64_t footer_partition;
442 uint32_t nb_essence_containers;
461 memset(partition, 0,
sizeof(*partition));
502 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
515 "Overriding PreviousPartition with %"PRIx64
"\n",
520 if (footer_partition) {
523 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
531 "PartitionPack: ThisPartition = 0x%"PRIX64
532 ", PreviousPartition = 0x%"PRIX64
", "
533 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
542 "PreviousPartition points to this partition or forward\n");
546 if (op[12] == 1 && op[13] == 1) mxf->
op =
OP1a;
547 else if (op[12] == 1 && op[13] == 2) mxf->
op =
OP1b;
548 else if (op[12] == 1 && op[13] == 3) mxf->
op =
OP1c;
549 else if (op[12] == 2 && op[13] == 1) mxf->
op =
OP2a;
550 else if (op[12] == 2 && op[13] == 2) mxf->
op =
OP2b;
551 else if (op[12] == 2 && op[13] == 3) mxf->
op =
OP2c;
552 else if (op[12] == 3 && op[13] == 1) mxf->
op =
OP3a;
553 else if (op[12] == 3 && op[13] == 2) mxf->
op =
OP3b;
554 else if (op[12] == 3 && op[13] == 3) mxf->
op =
OP3c;
555 else if (op[12] == 64&& op[13] == 1) mxf->
op =
OPSONYOpt;
556 else if (op[12] == 0x10) {
561 if (nb_essence_containers != 1) {
567 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
568 nb_essence_containers,
569 op ==
OP1a ?
"OP1a" :
"OPAtom");
575 av_log(mxf->
fc,
AV_LOG_ERROR,
"unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
661 package->tracks_refs =
av_calloc(package->tracks_count,
sizeof(
UID));
662 if (!package->tracks_refs)
740 package->tracks_refs =
av_calloc(package->tracks_count,
sizeof(
UID));
741 if (!package->tracks_refs)
752 avio_read(pb, package->descriptor_ref, 16);
798 av_dlog(NULL,
"IndexEntryArray found\n");
820 int code,
value, ofs = 0;
826 av_dlog(NULL,
"pixel layout: code %#x\n", code);
829 layout[ofs++] = code;
830 layout[ofs++] =
value;
926 for (i = 0; i <
len; i++) {
927 if (i != 7 && key[i] != uid[i])
935 while (uls->
uid[0]) {
960 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
961 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO },
962 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO },
963 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
968 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
969 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
974 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
975 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
976 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
981 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14,
AV_CODEC_ID_PCM_S16LE },
982 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2 },
983 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE },
984 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
985 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
986 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
990 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16, 0 },
991 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16,
AV_CODEC_ID_NONE },
995 "vbi_vanc_smpte_436M",
1000 int i, j, nb_segments = 0;
1002 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1012 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1013 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1023 *nb_sorted_segments = 0;
1026 for (i = 0; i < nb_segments; i++) {
1027 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1028 uint64_t best_index_duration = 0;
1030 for (j = 0; j < nb_segments; j++) {
1052 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1053 last_body_sid = best_body_sid;
1054 last_index_sid = best_index_sid;
1055 last_index_start = best_index_start;
1069 int64_t offset_in =
offset;
1086 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1087 offset_in, body_sid);
1119 int64_t offset_temp = 0;
1143 av_log(mxf->
fc,
AV_LOG_ERROR,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1149 *edit_unit_out = edit_unit;
1167 int8_t max_temporal_offset = -128;
1193 for (x = 0; x < index_table->
nb_ptses; x++)
1225 int index_delta = 1;
1234 for (j = 0; j <
n; j += index_delta, x++) {
1240 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
1248 if (index < 0 || index >= index_table->
nb_ptses) {
1250 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
1256 max_temporal_offset =
FFMAX(max_temporal_offset, offset);
1260 index_table->
first_dts = -max_temporal_offset;
1271 int i, j, k,
ret, nb_sorted_segments;
1275 nb_sorted_segments <= 0) {
1281 for (i = 0; i < nb_sorted_segments; i++) {
1282 if (i == 0 || sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid)
1284 else if (sorted_segments[i-1]->body_sid != sorted_segments[i]->body_sid) {
1287 goto finish_decoding_index;
1296 goto finish_decoding_index;
1300 for (i = j = 0; i < nb_sorted_segments; i++) {
1301 if (i != 0 && sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid) {
1317 " pointer array\n");
1319 goto finish_decoding_index;
1322 if (sorted_segments[i]->index_start_position)
1323 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
1331 goto finish_decoding_index;
1339 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
1356 finish_decoding_index:
1387 if (material_package)
break;
1389 if (!material_package) {
1402 UID *essence_container_ul = NULL;
1452 source_package = temp_package;
1456 if (!source_package) {
1457 av_dlog(mxf->
fc,
"material track %d: no corresponding source package found\n", material_track->
track_id);
1467 source_track = temp_track;
1471 if (!source_track) {
1476 if (!source_track || !component)
1507 "Invalid edit rate (%d/%d) found on stream #%d, "
1508 "defaulting to 25/1\n",
1529 if (!sub_descriptor) {
1534 descriptor = sub_descriptor;
1555 essence_container_ul = &((
MXFCryptoContext *)metadata)->source_container_ul;
1566 for (k = 0; k < 16; k++) {
1569 if (!(k+1 & 19) || k == 5)
1576 container_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
1607 "Field dominance %d support",
1642 container_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
1654 "found for stream #%d, time base forced to 1/48000\n",
1682 essence_container_ul)->
id;
1683 if (codec_id >= 0 &&
1686 mxf_data_essence_descriptor[codec_id], 0);
1717 buf_size = size + size / 2 + 1;
1737 for (i = 0; i <
sizeof(
UID); i++) {
1738 snprintf(p, 2 + 1,
"%.2x", uid[i]);
1740 if (i == 3 || i == 5 || i == 7 || i == 9) {
1750 struct tm time = { 0 };
1751 time.tm_year = (timestamp >> 48) - 1900;
1752 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
1753 time.tm_mday = (timestamp >> 32 & 0xFF);
1754 time.tm_hour = (timestamp >> 24 & 0xFF);
1755 time.tm_min = (timestamp >> 16 & 0xFF);
1756 time.tm_sec = (timestamp >> 8 & 0xFF);
1761 time.tm_mon = av_clip(time.tm_mon, 0, 11);
1762 time.tm_mday = av_clip(time.tm_mday, 1, 31);
1763 time.tm_hour = av_clip(time.tm_hour, 0, 23);
1764 time.tm_min = av_clip(time.tm_min, 0, 59);
1765 time.tm_sec = av_clip(time.tm_sec, 0, 59);
1770 strftime(*str, 32,
"%Y-%m-%d %H:%M:%S", &time);
1775 #define SET_STR_METADATA(pb, name, str) do { \
1776 if ((ret = mxf_read_utf16_string(pb, size, &str)) < 0) \
1778 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
1781 #define SET_UID_METADATA(pb, name, var, str) do { \
1782 avio_read(pb, var, 16); \
1783 if ((ret = mxf_uid_to_str(var, &str)) < 0) \
1785 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
1788 #define SET_TS_METADATA(pb, name, var, str) do { \
1789 var = avio_rb64(pb); \
1790 if ((ret = mxf_timestamp_to_str(var, &str)) < 0) \
1792 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
1833 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
1834 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
1835 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
1836 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
1837 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
1838 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
1839 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
1840 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
1841 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
1842 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
1843 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
1844 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
1845 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage, 0,
AnyType },
1846 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_source_package,
sizeof(
MXFPackage),
SourcePackage },
1847 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_material_package,
sizeof(
MXFPackage),
MaterialPackage },
1848 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
1849 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
1850 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
1851 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1852 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1853 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1854 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1855 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1856 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1857 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1858 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1859 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1860 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
1861 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
1862 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
1863 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
1864 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
1865 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0,
AnyType },
1883 av_dlog(mxf->
fc,
"local tag %#04x size %d\n", tag, size);
1892 if (local_tag == tag) {
1894 av_dlog(mxf->
fc,
"local tag %#04x\n", local_tag);
1899 if (ctx_size && tag == 0x3C0A)
1901 else if ((ret = read_child(ctx, pb, tag, size, uid, -1)) < 0)
1911 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
1937 av_dlog(mxf->
fc,
"seeking to previous partition\n");
1958 av_dlog(mxf->
fc,
"no last partition\n");
1962 av_dlog(mxf->
fc,
"seeking to last partition\n");
1975 "failed to seek to last partition @ 0x%" PRIx64
1976 " (%"PRId64
") - partial file?\n",
1977 mxf->
run_in + offset, ret);
2024 "partition %i: bad ThisPartition = %"PRIX64
"\n",
2034 int64_t
ret = (position / kag_size) * kag_size;
2035 return ret == position ? ret : ret + kag_size;
2092 klv.
length != length - 20)
2106 int64_t essence_offset = 0;
2107 int64_t last_pos = -1;
2108 uint64_t last_pos_index = 1;
2130 if ((1ULL<<61) % last_pos_index++ == 0)
2158 int64_t op1a_essence_offset =
2176 if (!essence_offset)
2177 essence_offset = klv.
offset;
2193 for (metadata = mxf_metadata_read_table; metadata->
read; metadata++) {
2196 if (klv.
key[5] == 0x53) {
2221 if (!metadata->
read)
2225 if (!essence_offset) {
2243 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
2266 int64_t last_ofs = -1, next_ofs = -1;
2279 if (next_ofs <= last_ofs) {
2283 "next_ofs didn't change. not deriving packet timestamps\n");
2287 if (next_ofs > current_offset)
2290 last_ofs = next_ofs;
2302 uint64_t *sample_count)
2304 int i, total = 0, size = 0;
2311 if ((sample_rate.
num / sample_rate.
den) == 48000)
2314 int remainder = (sample_rate.
num * time_base.
num) %
2315 (time_base.
den * sample_rate.
den);
2317 av_mul_q(sample_rate, time_base)));
2320 "seeking detected on stream #%d with time base (%d/%d) and "
2321 "sample rate (%d/%d), audio pts won't be accurate.\n",
2322 stream_index, time_base.
num, time_base.
den,
2323 sample_rate.
num, sample_rate.
den);
2348 if (!bits_per_sample)
2354 || bits_per_sample <= 0
2355 || codec->
channels * (int64_t)bits_per_sample < 8)
2381 int64_t next_ofs, next_klv;
2388 "error getting stream index %"PRIu32
"\n",
2402 if (next_ofs >= 0 && next_klv > next_ofs) {
2406 "OPAtom misinterpreted as OP1a?"
2407 "KLV for edit unit %i extending into "
2414 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
2465 int64_t ret64, pos, next_pos;
2494 if ((size = next_pos - pos) <= 0) {
2499 if ((ret64 =
avio_seek(s->
pb, pos, SEEK_SET)) < 0)
2586 for (; bufp <
end;) {
2587 if (!((bufp[13] - 1) & 0xF2)){
2621 if (sample_time < 0)
2636 sample_time =
FFMAX(sample_time, 0);
2660 uint64_t current_sample_count = 0;