62 #define MXF_MAX_CHUNK_SIZE (32 << 20) 195 int video_line_map[2];
196 #define MXF_FIELD_DOMINANCE_DEFAULT 0 197 #define MXF_FIELD_DOMINANCE_FF 1 198 #define MXF_FIELD_DOMINANCE_FL 2 319 static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
320 static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
321 static const uint8_t mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
322 static const uint8_t mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x0a,0x0e,0x0f,0x03,0x01 };
323 static const uint8_t mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
324 static const uint8_t mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 };
326 static const uint8_t mxf_apple_coll_prefix[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01 };
328 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 };
329 static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
330 static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
331 static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
332 static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
333 static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 };
334 static const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 };
335 static const uint8_t mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 };
336 static const uint8_t mxf_apple_coll_max_cll[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 };
337 static const uint8_t mxf_apple_coll_max_fall[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 };
347 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) 352 switch ((*ctx)->type) {
396 int bytes_num = size & 0x7f;
402 size = size << 8 |
avio_r8(pb);
404 if (size > INT64_MAX)
412 for (i = 0; i < size && !
avio_feof(pb); i++) {
416 else if (b != key[i])
435 if (pos > INT64_MAX - length)
467 if (pack_ofs <= offset)
481 int cdp_identifier, cdp_length, cdp_footer_id, ccdata_id, cc_count;
482 int line_num, sample_coding, sample_count;
483 int did, sdid, data_length;
489 for (i = 0; i <
count; i++) {
498 length -= 6 + 8 + sample_count;
499 if (line_num != 9 && line_num != 11)
501 if (sample_coding == 7 || sample_coding == 8 || sample_coding == 9) {
513 if (did != 0x61 || sdid != 1) {
518 if (cdp_identifier != 0x9669) {
527 if (ccdata_id != 0x72) {
535 if (cdp_length - 9 - 4 < cc_count * 3) {
539 avio_skip(s->
pb, data_length - 9 - 4 - cc_count * 3);
541 if (cdp_footer_id != 0x74) {
556 const uint8_t *buf_ptr, *end_ptr;
565 data_ptr = pkt->
data;
567 buf_ptr = pkt->
data + 4;
570 uint32_t
sample = bytestream_get_le32(&buf_ptr);
572 bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
574 bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
584 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
590 uint64_t plaintext_size;
623 if (orig_size < plaintext_size)
627 if (size < 32 || size - 32 < orig_size)
633 if (memcmp(tmpbuf, checkv, 16))
639 else if (size < plaintext_size)
641 size -= plaintext_size;
644 &pkt->
data[plaintext_size], size >> 4, ivec, 1);
657 if (item_len != 18) {
661 if (item_num > 65536 || item_num < 0) {
683 uint64_t footer_partition;
684 uint32_t nb_essence_containers;
706 memset(partition, 0,
sizeof(*partition));
754 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
767 "Overriding PreviousPartition with %"PRIx64
"\n",
772 if (footer_partition) {
775 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
783 "PartitionPack: ThisPartition = 0x%"PRIX64
784 ", PreviousPartition = 0x%"PRIX64
", " 785 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
795 "PreviousPartition points to this partition or forward\n");
799 if (op[12] == 1 && op[13] == 1) mxf->
op =
OP1a;
800 else if (op[12] == 1 && op[13] == 2) mxf->
op =
OP1b;
801 else if (op[12] == 1 && op[13] == 3) mxf->
op =
OP1c;
802 else if (op[12] == 2 && op[13] == 1) mxf->
op =
OP2a;
803 else if (op[12] == 2 && op[13] == 2) mxf->
op =
OP2b;
804 else if (op[12] == 2 && op[13] == 3) mxf->
op =
OP2c;
805 else if (op[12] == 3 && op[13] == 1) mxf->
op =
OP3a;
806 else if (op[12] == 3 && op[13] == 2) mxf->
op =
OP3b;
807 else if (op[12] == 3 && op[13] == 3) mxf->
op =
OP3c;
808 else if (op[12] == 64&& op[13] == 1) mxf->
op =
OPSONYOpt;
809 else if (op[12] == 0x10) {
814 if (nb_essence_containers != 1) {
820 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
821 nb_essence_containers,
822 op ==
OP1a ?
"OP1a" :
"OPAtom");
828 av_log(mxf->
fc,
AV_LOG_ERROR,
"unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
894 buf_size = size + size / 2 + 1;
913 #define READ_STR16(type, big_endian) \ 914 static int mxf_read_utf16 ## type ##_string(AVIOContext *pb, int size, char** str) \ 916 return mxf_read_utf16_string(pb, size, str, big_endian); \ 997 mxf_read_utf16be_string(pb, size, &track->
name);
1050 &package->tracks_count);
1054 avio_read(pb, package->package_uid, 16);
1057 avio_read(pb, package->descriptor_ref, 16);
1060 return mxf_read_utf16be_string(pb, size, &package->name);
1063 &package->comment_count);
1165 layout[ofs++] =
code;
1166 layout[ofs++] =
value;
1169 }
while (code != 0);
1177 int entry_count, entry_size;
1210 if (entry_size == 4) {
1211 if (entry_count > 0)
1215 if (entry_count > 1)
1298 for (
int i = 0;
i < 3;
i++) {
1328 if (!descriptor->
coll) {
1330 if (!descriptor->
coll)
1356 return mxf_read_utf16le_string(pb, size - 17, &tagged_value->
value);
1358 return mxf_read_utf16be_string(pb, size - 17, &tagged_value->
value);
1368 return mxf_read_utf16be_string(pb, size, &tagged_value->
name);
1382 for (i = 0; i <
len; i++) {
1383 if (i != 7 && key[i] != uid[i])
1391 while (uls->
uid[0]) {
1416 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000,
NULL, 14 },
1417 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 }, 14,
AV_CODEC_ID_H264,
NULL, 15 },
1418 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 }, 14,
AV_CODEC_ID_DNXHD,
NULL, 14 },
1419 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 }, 14,
AV_CODEC_ID_VC1,
NULL, 14 },
1420 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 }, 14,
AV_CODEC_ID_TIFF,
NULL, 14 },
1421 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 }, 14,
AV_CODEC_ID_DIRAC,
NULL, 14 },
1422 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1b,0x01,0x00 }, 14,
AV_CODEC_ID_CFHD,
NULL, 14 },
1423 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1c,0x01,0x00 }, 14,
AV_CODEC_ID_PRORES,
NULL, 14 },
1424 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15 },
1425 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x04,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15,
D10D11Wrap },
1426 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO,
NULL, 15 },
1427 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO,
NULL, 15,
RawVWrap },
1428 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x01,0x01 }, 15,
AV_CODEC_ID_HQ_HQA },
1429 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x02,0x01 }, 15,
AV_CODEC_ID_HQX },
1430 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x15,0x00,0x04,0x02,0x10,0x00,0x01 }, 16,
AV_CODEC_ID_HEVC,
NULL, 15 },
1431 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14,
AV_CODEC_ID_RAWVIDEO },
1432 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1437 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1438 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1443 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
1444 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
1445 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1450 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x01 }, 16, 1440 },
1451 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x02 }, 16, 1440 },
1452 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x03 }, 16, 1440 },
1453 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x04 }, 16, 1440 },
1454 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 },
1459 { { 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 },
1460 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2,
NULL, 15 },
1461 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE,
NULL, 13 },
1462 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
1463 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
1464 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1468 { { 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 },
1469 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16,
AV_CODEC_ID_NONE,
"vbi_vanc_smpte_436M", 11 },
1470 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x13,0x01,0x01 }, 16,
AV_CODEC_ID_TTML },
1471 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1479 codec_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
1480 if (!codec_ul->
uid[0])
1481 codec_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
1482 if (!codec_ul->
uid[0])
1483 codec_ul =
mxf_get_codec_ul(mxf_data_essence_container_uls, essence_container_ul);
1493 if (val == 0x03 || val == 0x04)
1510 int i, j, nb_segments = 0;
1512 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1522 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1523 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1533 unsorted_segments[nb_segments++] =
s;
1535 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1546 *nb_sorted_segments = 0;
1549 for (i = 0; i < nb_segments; i++) {
1550 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1551 uint64_t best_index_duration = 0;
1553 for (j = 0; j < nb_segments; j++) {
1581 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1582 last_body_sid = best_body_sid;
1583 last_index_sid = best_index_sid;
1584 last_index_start = best_index_start;
1607 m0 = m = (a +
b) >> 1;
1609 while (m < b && mxf->partitions[m].body_sid != body_sid)
1612 if (m < b && mxf->partitions[m].
body_offset <= offset)
1624 *partition_out = last_p;
1629 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1659 int64_t offset_temp = 0;
1705 int8_t max_temporal_offset = -128;
1742 for (x = 0; x < index_table->
nb_ptses; x++)
1774 int index_delta = 1;
1783 for (j = 0; j < n; j += index_delta, x++) {
1789 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
1796 if (index < 0 || index >= index_table->
nb_ptses) {
1798 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
1805 max_temporal_offset =
FFMAX(max_temporal_offset, offset);
1810 for (x = 0; x < index_table->
nb_ptses; x++) {
1817 index_table->
first_dts = -max_temporal_offset;
1828 int i, j, k,
ret, nb_sorted_segments;
1832 nb_sorted_segments <= 0) {
1838 for (i = 0; i < nb_sorted_segments; i++) {
1844 goto finish_decoding_index;
1853 goto finish_decoding_index;
1857 for (i = j = 0; i < nb_sorted_segments; i++) {
1875 " pointer array\n");
1877 goto finish_decoding_index;
1880 if (sorted_segments[i]->index_start_position)
1881 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
1889 goto finish_decoding_index;
1912 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
1929 finish_decoding_index:
1949 for (i = 0; i <
sizeof(
UID); i++) {
1950 snprintf(p, 2 + 1,
"%.2x", uid[i]);
1952 if (i == 3 || i == 5 || i == 7 || i == 9) {
1969 for (i = 0; i <
sizeof(
UID); i++) {
1974 for (i = 0; i <
sizeof(
UID); i++) {
1975 snprintf(p, 2 + 1,
"%.2X", uid[i]);
1982 uint16_t patch, uint16_t release,
char **
str)
1984 *str =
av_asprintf(
"%d.%d.%d.%d.%d", major, minor, tertiary, patch, release);
2019 switch (component->
type) {
2037 package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], SourcePackage);
2041 if (!memcmp(package->package_ul, package_ul, 16) && !memcmp(package->package_uid, package_uid, 16))
2059 if (!sub_descriptor) {
2064 return sub_descriptor;
2107 switch (component->
type) {
2147 int64_t start_position;
2160 if (physical_package->
name && physical_package->
name[0])
2180 "Invalid edit rate (%d/%d) found on structural" 2181 " component #%d, defaulting to 25/1\n",
2279 if (material_package)
break;
2281 if (!material_package) {
2287 if (material_package->
name && material_package->
name[0])
2299 UID *essence_container_ul =
NULL;
2349 if (!source_package) {
2360 source_track = temp_track;
2364 if (!source_track) {
2383 if(source_track && component)
2386 if (!source_track || !component || !source_package) {
2430 "Invalid edit rate (%d/%d) found on stream #%d, " 2431 "defaulting to 25/1\n",
2463 essence_container_ul = &((
MXFCryptoContext *)metadata)->source_container_ul;
2479 for (k = 0; k < 16; k++) {
2482 if (!(k+1 & 19) || k == 5)
2488 if (source_package->
name && source_package->
name[0])
2490 if (material_track->
name && material_track->
name[0])
2497 container_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
2538 "Field dominance %d support",
2552 "Field dominance %d support",
2617 if (descriptor->
coll) {
2626 container_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
2637 "found for stream #%d, time base forced to 1/48000\n",
2666 container_ul =
mxf_get_codec_ul(mxf_data_essence_container_uls, essence_container_ul);
2672 if (container_ul->
desc)
2675 !strcmp(container_ul->
desc,
"vbi_vanc_smpte_436M")) {
2711 "with different wrapping\n", i, j, track1->
body_sid);
2724 struct tm time = { 0 };
2726 time.tm_year = (timestamp >> 48) - 1900;
2727 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
2728 time.tm_mday = (timestamp >> 32 & 0xFF);
2729 time.tm_hour = (timestamp >> 24 & 0xFF);
2730 time.tm_min = (timestamp >> 16 & 0xFF);
2731 time.tm_sec = (timestamp >> 8 & 0xFF);
2732 msecs = (timestamp & 0xFF) * 4;
2735 time.tm_mon =
av_clip(time.tm_mon, 0, 11);
2736 time.tm_mday =
av_clip(time.tm_mday, 1, 31);
2737 time.tm_hour =
av_clip(time.tm_hour, 0, 23);
2738 time.tm_min =
av_clip(time.tm_min, 0, 59);
2739 time.tm_sec =
av_clip(time.tm_sec, 0, 59);
2740 msecs =
av_clip(msecs, 0, 999);
2742 return (int64_t)
av_timegm(&time) * 1000000 + msecs * 1000;
2745 #define SET_STR_METADATA(pb, name, str) do { \ 2746 if ((ret = mxf_read_utf16be_string(pb, size, &str)) < 0) \ 2748 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \ 2751 #define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str) do { \ 2752 major = avio_rb16(pb); \ 2753 minor = avio_rb16(pb); \ 2754 tertiary = avio_rb16(pb); \ 2755 patch = avio_rb16(pb); \ 2756 release = avio_rb16(pb); \ 2757 if ((ret = mxf_version_to_str(major, minor, tertiary, patch, release, &str)) < 0) \ 2759 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \ 2762 #define SET_UID_METADATA(pb, name, var, str) do { \ 2763 avio_read(pb, var, 16); \ 2764 if ((ret = mxf_uid_to_str(var, &str)) < 0) \ 2766 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \ 2769 #define SET_TS_METADATA(pb, name, var, str) do { \ 2770 var = avio_rb64(pb); \ 2771 if (var && (ret = avpriv_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \ 2783 uint16_t
major,
minor, tertiary, patch, release;
2830 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
2831 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
2832 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
2833 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
2834 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
2835 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
2836 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
2837 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
2838 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
2839 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
2840 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
2841 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 },
mxf_read_preface_metadata },
2842 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
2843 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage, 0,
AnyType },
2844 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
SourcePackage },
2845 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
MaterialPackage },
2846 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
2847 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x05,0x00 },
mxf_read_essence_group,
sizeof(
MXFEssenceGroup),
EssenceGroup},
2848 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
2849 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3f,0x00 },
mxf_read_tagged_value,
sizeof(
MXFTaggedValue),
TaggedValue },
2850 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
2851 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2852 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2853 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2854 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2855 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2856 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2857 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5b,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2858 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2859 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2860 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2861 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2862 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2863 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
2864 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0c,0x00 },
mxf_read_pulldown_component,
sizeof(
MXFPulldownComponent),
PulldownComponent },
2865 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
2866 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
2867 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x23,0x00 },
mxf_read_essence_container_data,
sizeof(
MXFEssenceContainerData),
EssenceContainerData },
2868 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
NULL, 0, AnyType },
2902 if (next < 0 || next > INT64_MAX - size)
2915 if (local_tag == tag) {
2922 if (ctx_size && tag == 0x3C0A) {
2924 }
else if ((ret = read_child(ctx, pb, tag, size, uid, -1)) < 0) {
2938 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
2958 key[13] >= 2 && key[13] <= 4;
2970 if (klv.
key[5] == 0x53) {
3000 int64_t current_partition_ofs;
3031 if (klv.
offset >= current_partition_ofs) {
3033 PRIx64
" indirectly points to itself\n", current_partition_ofs);
3073 "failed to seek to FooterPartition @ 0x%" PRIx64
3074 " (%"PRId64
") - partial file?\n",
3133 if (x < mxf->partitions_count - 1)
3140 "partition %i: bad ThisPartition = %"PRIX64
"\n",
3203 int essence_partition_count = 0;
3204 int edit_unit_byte_count = 0;
3226 essence_partition_count++;
3230 if (essence_partition_count != 1)
3239 if (edit_unit_byte_count <= 0)
3244 if (!(segment =
av_mallocz(
sizeof(*segment))))
3270 int64_t file_size, max_rip_length, min_rip_length;
3286 max_rip_length = ((file_size - mxf->
run_in) / 105) * 12 + 28;
3287 max_rip_length =
FFMIN(max_rip_length, INT_MAX);
3290 min_rip_length = 16+1+24+4;
3369 if (!essence_offset)
3370 essence_offset = klv.
offset;
3385 for (metadata = mxf_metadata_read_table; metadata->
read; metadata++) {
3392 if (!metadata->
read) {
3399 if (!essence_offset) {
3419 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
3455 if (offset < current_offset)
3477 if ((sample_rate.
num / sample_rate.
den) == 48000) {
3480 int remainder = (sample_rate.
num * time_base.
num) %
3481 (time_base.
den * sample_rate.
den);
3484 "seeking detected on stream #%d with time base (%d/%d) and " 3485 "sample rate (%d/%d), audio pts won't be accurate.\n",
3487 sample_rate.
num, sample_rate.
den);
3499 int64_t next_ofs = -1;
3502 int64_t new_edit_unit;
3515 if (next_ofs > current_offset)
3530 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);
3542 if (!bits_per_sample)
3548 || bits_per_sample <= 0
3549 || par->
channels * (int64_t)bits_per_sample < 8)
3594 int64_t max_data_size;
3602 max_data_size = klv.
length;
3629 "error getting stream index %"PRIu32
"\n",
3645 if (next_ofs <= 0) {
3653 if ((size = next_ofs - pos) <= 0) {
3659 if (size > max_data_size)
3660 size = max_data_size;
3670 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
3757 for (; bufp < end;) {
3758 if (!((bufp[13] - 1) & 0xF2)){
3795 if (sample_time < 0)
3815 source_track = new_source_track;
3826 sample_time =
FFMAX(sample_time, 0);
3835 sample_time < t->ptses[0] &&
3837 sample_time = t->
ptses[0];
3843 sample_time += t->
offsets[sample_time];
3859 if (seekpos < klv.next_klv - klv.length || seekpos >= klv.
next_klv) {
3875 int64_t track_edit_unit = sample_time;
3885 {
"eia608_extract",
"extract eia 608 captions from s436m track",
3909 .priv_class = &demuxer_class,
static const uint8_t mxf_crypto_source_container_ul[]
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
#define FF_MXF_MasteringDisplay_PREFIX
AVContentLightMetadata * coll
static int mxf_parse_structural_metadata(MXFContext *mxf)
enum AVFieldOrder field_order
Video only.
enum AVColorTransferCharacteristic color_trc
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
int64_t avio_size(AVIOContext *s)
Get the filesize.
unsigned int component_depth
KLVPacket current_klv_data
static int mxf_get_eia608_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt, int64_t length)
static int mxf_read_index_table_segment(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
unsigned MaxCLL
Max content light level (cd/m^2).
static const MXFMetadataReadTableEntry mxf_metadata_read_table[]
int structural_components_count
#define PRINT_KEY(pc, s, x)
static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
UID * structural_components_refs
#define AV_LOG_WARNING
Something somehow does not look correct.
static int mxf_seek_to_previous_partition(MXFContext *mxf)
Seeks to the previous partition and parses it, if possible.
#define LIBAVUTIL_VERSION_INT
enum MXFMetadataSetType type
int64_t pos
byte position in stream, -1 if unknown
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
UID * structural_components_refs
static void mxf_read_random_index_pack(AVFormatContext *s)
#define avpriv_request_sample(...)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
#define SET_VERSION_METADATA(pb, name, major, minor, tertiary, patch, release, str)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
#define MXF_MAX_CHUNK_SIZE
int index
stream index in AVFormatContext
#define SET_TS_METADATA(pb, name, var, str)
uint64_t footer_partition
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * av_default_item_name(void *ptr)
Return the context name.
enum MXFMetadataSetType type
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.
static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
static int mxf_uid_to_str(UID uid, char **str)
#define FF_ALLOC_TYPED_ARRAY(p, nelem)
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static int mxf_umid_to_str(UID ul, UID uid, char **str)
static int mxf_add_metadata_set(MXFContext *mxf, MXFMetadataSet **metadata_set)
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...
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
MXFWrappingScheme wrapping
#define FF_MXF_MasteringDisplayWhitePointChromaticity
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static const uint8_t mxf_apple_coll_max_cll[]
#define MXF_FIELD_DOMINANCE_DEFAULT
unsigned int avio_rb16(AVIOContext *s)
static int mxf_is_intra_only(MXFDescriptor *descriptor)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
static int mxf_read_header(AVFormatContext *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.
const MXFCodecUL ff_mxf_color_space_uls[]
This struct describes the properties of an encoded stream.
static int mxf_read_essence_container_data(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
int edit_units_per_packet
static int mxf_parse_klv(MXFContext *mxf, KLVPacket klv, MXFMetadataReadFunc *read, int ctx_size, enum MXFMetadataSetType type)
Parses a metadata KLV.
MXFWrappingIndicatorType wrapping_indicator_type
enum AVColorSpace color_space
unsigned int black_ref_level
Mastering display metadata (based on SMPTE-2086:2014).
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
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)
enum MXFMetadataSetType type
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function...
static const uint8_t index_table[8]
static int mxf_parse_handle_partition_or_eof(MXFContext *mxf)
Called when the next partition or EOF is encountered.
static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
static int is_pcm(enum AVCodecID codec_id)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static const uint8_t mxf_indirect_value_utf16le[]
static const uint8_t mxf_mastering_display_prefix[13]
#define MXF_FIELD_DOMINANCE_FF
Opaque data information usually continuous.
static const uint8_t mxf_avid_essence_element_key[]
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVRational index_edit_rate
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
static int mxf_read_close(AVFormatContext *s)
GLsizei GLboolean const GLfloat * value
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static int mxf_add_umid_metadata(AVDictionary **pm, const char *key, MXFPackage *package)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
AVStream ** streams
A list of all streams in the file.
unsigned wrapping_indicator_pos
static const uint8_t mxf_klv_key[]
int MXFMetadataReadFunc(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_compute_index_tables(MXFContext *mxf)
Sorts and collects index table segments into index tables.
MXFIndexTableSegment ** segments
const MXFCodecUL ff_mxf_codec_uls[]
static const uint8_t mxf_sony_mpeg4_extradata[]
static const uint8_t mxf_apple_coll_prefix[]
#define AVERROR_EOF
End of file.
static const uint8_t mxf_avid_project_name[]
static av_cold int read_close(AVFormatContext *ctx)
#define AV_LOG_VERBOSE
Detailed information.
AVColorRange
Visual content value range.
static int mxf_read_utf16_string(AVIOContext *pb, int size, char **str, int be)
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static const MXFCodecUL mxf_intra_only_essence_container_uls[]
unsigned int vert_subsampling
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
#define MXF_FIELD_DOMINANCE_FL
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int mxf_get_sorted_table_segments(MXFContext *mxf, int *nb_sorted_segments, MXFIndexTableSegment ***sorted_segments)
static MXFDescriptor * mxf_resolve_multidescriptor(MXFContext *mxf, MXFDescriptor *descriptor, int track_id)
int64_t original_duration
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
#define SET_UID_METADATA(pb, name, var, str)
static int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size)
static enum AVColorRange mxf_get_color_range(MXFContext *mxf, MXFDescriptor *descriptor)
static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st, int64_t edit_unit)
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv, int body_sid)
const MXFCodecUL ff_mxf_color_primaries_uls[]
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int last_forward_partition
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVDictionary * metadata
Metadata that applies to the whole file.
static int mxf_read_timecode_component(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static void mxf_compute_essence_containers(AVFormatContext *s)
Figures out the proper offset and length of the essence container in each partition.
static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
static MXFTimecodeComponent * mxf_resolve_timecode_component(MXFContext *mxf, UID *strong_ref)
int8_t * temporal_offset_entries
static int mxf_add_timecode_metadata(AVDictionary **pm, const char *key, AVTimecode *tc)
static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
MXFDescriptor * descriptor
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
uint64_t index_start_position
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVColorPrimaries color_primaries
static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const MXFCodecUL mxf_intra_only_picture_essence_coding_uls[]
enum AVMediaType codec_type
General type of the encoded data.
static const MXFCodecUL mxf_sound_essence_container_uls[]
simple assert() macros that are a bit more flexible than ISO C assert().
static int mxf_parse_handle_essence(MXFContext *mxf)
Called when essence is encountered.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
#define FF_MXF_MasteringDisplayPrimaries
const uint8_t ff_mxf_random_index_pack_key[16]
static int mxf_read_package(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_read_source_clip(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_match_uid(const UID key, const UID uid, int len)
int avio_r8(AVIOContext *s)
static MXFStructuralComponent * mxf_resolve_sourceclip(MXFContext *mxf, UID *strong_ref)
static int mxf_version_to_str(uint16_t major, uint16_t minor, uint16_t tertiary, uint16_t patch, uint16_t release, char **str)
int buf_size
Size of buf except extra allocated bytes.
int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt)
char * av_asprintf(const char *fmt,...)
const MXFCodecUL ff_mxf_pixel_format_uls[]
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static int mxf_probe(const AVProbeData *p)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static const MXFCodecUL * mxf_get_codec_ul(const MXFCodecUL *uls, UID *uid)
static const uint8_t mxf_jp2k_rsiz[]
MXFPartition * partitions