60 #define MXF_MAX_CHUNK_SIZE (32 << 20) 61 #define RUN_IN_MAX (65535+1) // S377m-2004 section 5.5 and S377-1-2009 section 6.5, the +1 is to be slightly more tolerant 194 int video_line_map[2];
195 #define MXF_FIELD_DOMINANCE_DEFAULT 0 196 #define MXF_FIELD_DOMINANCE_FF 1 197 #define MXF_FIELD_DOMINANCE_FL 2 309 static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
310 static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
311 static const uint8_t mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
312 static const uint8_t mxf_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x0a,0x0e,0x0f,0x03,0x01 };
313 static const uint8_t mxf_system_item_key_cp[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 };
314 static const uint8_t mxf_system_item_key_gc[] = { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x03,0x01,0x14 };
317 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 };
318 static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
319 static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
320 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 };
321 static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
322 static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf };
323 static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 };
324 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 };
325 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 };
327 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) 332 switch ((*ctx)->type) {
373 int bytes_num = size & 0x7f;
379 size = size << 8 |
avio_r8(pb);
381 if (size > INT64_MAX)
389 for (i = 0; i < size && !
avio_feof(pb); i++) {
393 else if (b != key[i])
412 if (pos > INT64_MAX - length)
444 if (this_partition <= offset)
458 int cdp_identifier, cdp_length, cdp_footer_id, ccdata_id, cc_count;
459 int line_num, sample_coding, sample_count;
460 int did, sdid, data_length;
466 for (i = 0; i <
count; i++) {
475 length -= 6 + 8 + sample_count;
476 if (line_num != 9 && line_num != 11)
478 if (sample_coding == 7 || sample_coding == 8 || sample_coding == 9) {
490 if (did != 0x61 || sdid != 1) {
495 if (cdp_identifier != 0x9669) {
504 if (ccdata_id != 0x72) {
512 if (cdp_length - 9 - 4 < cc_count * 3) {
516 avio_skip(s->
pb, data_length - 9 - 4 - cc_count * 3);
518 if (cdp_footer_id != 0x74) {
533 const uint8_t *buf_ptr, *end_ptr;
542 data_ptr = pkt->
data;
544 buf_ptr = pkt->
data + 4;
551 uint32_t
sample = bytestream_get_le32(&buf_ptr);
553 bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
555 bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
565 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
571 uint64_t plaintext_size;
604 if (orig_size < plaintext_size)
608 if (size < 32 || size - 32 < orig_size || (
int)orig_size != orig_size)
614 if (memcmp(tmpbuf, checkv, 16))
620 else if (size < plaintext_size)
622 size -= plaintext_size;
625 &pkt->
data[plaintext_size], size >> 4, ivec, 1);
638 if (item_len != 18) {
642 if (item_num > 65536 || item_num < 0) {
663 uint64_t footer_partition;
664 uint32_t nb_essence_containers;
686 memset(partition, 0,
sizeof(*partition));
728 "PreviousPartition equal to ThisPartition %"PRIx64
"\n",
741 "Overriding PreviousPartition with %"PRIx64
"\n",
746 if (footer_partition) {
749 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
757 "PartitionPack: ThisPartition = 0x%"PRIX64
758 ", PreviousPartition = 0x%"PRIX64
", " 759 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
769 "PreviousPartition points to this partition or forward\n");
773 if (op[12] == 1 && op[13] == 1) mxf->
op =
OP1a;
774 else if (op[12] == 1 && op[13] == 2) mxf->
op =
OP1b;
775 else if (op[12] == 1 && op[13] == 3) mxf->
op =
OP1c;
776 else if (op[12] == 2 && op[13] == 1) mxf->
op =
OP2a;
777 else if (op[12] == 2 && op[13] == 2) mxf->
op =
OP2b;
778 else if (op[12] == 2 && op[13] == 3) mxf->
op =
OP2c;
779 else if (op[12] == 3 && op[13] == 1) mxf->
op =
OP3a;
780 else if (op[12] == 3 && op[13] == 2) mxf->
op =
OP3b;
781 else if (op[12] == 3 && op[13] == 3) mxf->
op =
OP3c;
782 else if (op[12] == 64&& op[13] == 1) mxf->
op =
OPSONYOpt;
783 else if (op[12] == 0x10) {
788 if (nb_essence_containers != 1) {
794 "\"OPAtom\" with %"PRIu32
" ECs - assuming %s\n",
795 nb_essence_containers,
796 op ==
OP1a ?
"OP1a" :
"OPAtom");
802 av_log(mxf->
fc,
AV_LOG_ERROR,
"unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
862 if (size < 0 || size > INT_MAX/2)
865 buf_size = size + size / 2 + 1;
884 #define READ_STR16(type, big_endian) \ 885 static int mxf_read_utf16 ## type ##_string(AVIOContext *pb, int size, char** str) \ 887 return mxf_read_utf16_string(pb, size, str, big_endian); \ 970 mxf_read_utf16be_string(pb, size, &track->
name);
1023 &package->tracks_count);
1027 avio_read(pb, package->package_uid, 16);
1030 avio_read(pb, package->descriptor_ref, 16);
1033 return mxf_read_utf16be_string(pb, size, &package->name);
1036 &package->comment_count);
1132 int code,
value, ofs = 0;
1141 layout[ofs++] = code;
1142 layout[ofs++] =
value;
1145 }
while (code != 0);
1153 int entry_count, entry_size;
1186 if (entry_size == 4) {
1187 if (entry_count > 0)
1191 if (entry_count > 1)
1265 return mxf_read_utf16le_string(pb, size - 17, &tagged_value->
value);
1267 return mxf_read_utf16be_string(pb, size - 17, &tagged_value->
value);
1277 return mxf_read_utf16be_string(pb, size, &tagged_value->
name);
1291 for (i = 0; i <
len; i++) {
1292 if (i != 7 && key[i] != uid[i])
1300 while (uls->
uid[0]) {
1325 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000,
NULL, 14 },
1326 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x10,0x60,0x01 }, 14,
AV_CODEC_ID_H264,
NULL, 15 },
1327 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x11,0x01,0x00 }, 14,
AV_CODEC_ID_DNXHD,
NULL, 14 },
1328 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x12,0x01,0x00 }, 14,
AV_CODEC_ID_VC1,
NULL, 14 },
1329 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x14,0x01,0x00 }, 14,
AV_CODEC_ID_TIFF,
NULL, 14 },
1330 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x15,0x01,0x00 }, 14,
AV_CODEC_ID_DIRAC,
NULL, 14 },
1331 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1b,0x01,0x00 }, 14,
AV_CODEC_ID_CFHD,
NULL, 14 },
1332 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x1c,0x01,0x00 }, 14,
AV_CODEC_ID_PRORES,
NULL, 14 },
1333 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15 },
1334 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x04,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO,
NULL, 15,
D10D11Wrap },
1335 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO,
NULL, 15 },
1336 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO,
NULL, 15,
RawVWrap },
1337 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x01,0x01 }, 15,
AV_CODEC_ID_HQ_HQA },
1338 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x02,0x01 }, 15,
AV_CODEC_ID_HQX },
1339 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14,
AV_CODEC_ID_RAWVIDEO },
1340 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1345 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
1346 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1351 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
1352 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,
AV_CODEC_ID_JPEG2000 },
1353 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1358 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x01 }, 16, 1440 },
1359 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x02 }, 16, 1440 },
1360 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x03 }, 16, 1440 },
1361 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x21,0x04 }, 16, 1440 },
1362 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, 0 },
1367 { { 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 },
1368 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2,
NULL, 15 },
1369 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE,
NULL, 13 },
1370 { { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
1371 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14,
AV_CODEC_ID_AAC },
1372 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1376 { { 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 },
1377 { { 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 },
1378 { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x13,0x01,0x01 }, 16,
AV_CODEC_ID_TTML },
1379 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
1387 codec_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
1388 if (!codec_ul->
uid[0])
1389 codec_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
1390 if (!codec_ul->
uid[0])
1391 codec_ul =
mxf_get_codec_ul(mxf_data_essence_container_uls, essence_container_ul);
1401 if (val == 0x03 || val == 0x04)
1418 int i, j, nb_segments = 0;
1420 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
1430 if (!(unsorted_segments =
av_calloc(nb_segments,
sizeof(*unsorted_segments))) ||
1431 !(*sorted_segments =
av_calloc(nb_segments,
sizeof(**sorted_segments)))) {
1441 unsorted_segments[nb_segments++] =
s;
1443 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1454 *nb_sorted_segments = 0;
1457 for (i = 0; i < nb_segments; i++) {
1458 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
1459 uint64_t best_index_duration = 0;
1461 for (j = 0; j < nb_segments; j++) {
1489 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
1490 last_body_sid = best_body_sid;
1491 last_index_sid = best_index_sid;
1492 last_index_start = best_index_start;
1515 m0 = m = (a +
b) >> 1;
1517 while (m < b && mxf->partitions[m].body_sid != body_sid)
1520 if (m < b && mxf->partitions[m].
body_offset <= offset)
1532 *partition_out = last_p;
1537 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1570 int64_t offset_temp = 0;
1616 int8_t max_temporal_offset = -128;
1653 for (x = 0; x < index_table->
nb_ptses; x++)
1685 int index_delta = 1;
1694 for (j = 0; j <
n; j += index_delta, x++) {
1700 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
1707 if (index < 0 || index >= index_table->
nb_ptses) {
1709 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
1716 max_temporal_offset =
FFMAX(max_temporal_offset, offset);
1721 for (x = 0; x < index_table->
nb_ptses; x++) {
1728 index_table->
first_dts = -max_temporal_offset;
1739 int i, j, k, ret, nb_sorted_segments;
1743 nb_sorted_segments <= 0) {
1749 for (i = 0; i < nb_sorted_segments; i++) {
1755 goto finish_decoding_index;
1764 goto finish_decoding_index;
1768 for (i = j = 0; i < nb_sorted_segments; i++) {
1786 " pointer array\n");
1788 goto finish_decoding_index;
1791 if (sorted_segments[i]->index_start_position)
1792 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
1800 goto finish_decoding_index;
1823 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
1840 finish_decoding_index:
1860 for (i = 0; i <
sizeof(
UID); i++) {
1861 snprintf(p, 2 + 1,
"%.2x", uid[i]);
1863 if (i == 3 || i == 5 || i == 7 || i == 9) {
1880 for (i = 0; i <
sizeof(
UID); i++) {
1885 for (i = 0; i <
sizeof(
UID); i++) {
1886 snprintf(p, 2 + 1,
"%.2X", uid[i]);
1921 switch (component->
type) {
1939 package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], SourcePackage);
1943 if (!memcmp(package->package_ul, package_ul, 16) && !memcmp(package->package_uid, package_uid, 16))
1961 if (!sub_descriptor) {
1966 return sub_descriptor;
2009 switch (component->
type) {
2031 size = strlen(tag->
name) + 8 + 1;
2051 int64_t start_position;
2064 if (physical_package->
name && physical_package->
name[0])
2084 "Invalid edit rate (%d/%d) found on structural" 2085 " component #%d, defaulting to 25/1\n",
2159 if (material_package)
break;
2161 if (!material_package) {
2167 if (material_package->
name && material_package->
name[0])
2179 UID *essence_container_ul =
NULL;
2229 if (!source_package) {
2240 source_track = temp_track;
2244 if (!source_track) {
2263 if(source_track && component)
2266 if (!source_track || !component || !source_package) {
2310 "Invalid edit rate (%d/%d) found on stream #%d, " 2311 "defaulting to 25/1\n",
2343 essence_container_ul = &((
MXFCryptoContext *)metadata)->source_container_ul;
2359 for (k = 0; k < 16; k++) {
2362 if (!(k+1 & 19) || k == 5)
2368 if (source_package->
name && source_package->
name[0])
2370 if (material_track->
name && material_track->
name[0])
2377 container_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
2418 "Field dominance %d support",
2432 "Field dominance %d support",
2474 container_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
2485 "found for stream #%d, time base forced to 1/48000\n",
2514 container_ul =
mxf_get_codec_ul(mxf_data_essence_container_uls, essence_container_ul);
2520 if (container_ul->
desc)
2523 !strcmp(container_ul->
desc,
"vbi_vanc_smpte_436M")) {
2554 struct tm time = { 0 };
2555 time.tm_year = (timestamp >> 48) - 1900;
2556 time.tm_mon = (timestamp >> 40 & 0xFF) - 1;
2557 time.tm_mday = (timestamp >> 32 & 0xFF);
2558 time.tm_hour = (timestamp >> 24 & 0xFF);
2559 time.tm_min = (timestamp >> 16 & 0xFF);
2560 time.tm_sec = (timestamp >> 8 & 0xFF);
2565 time.tm_mon = av_clip(time.tm_mon, 0, 11);
2566 time.tm_mday = av_clip(time.tm_mday, 1, 31);
2567 time.tm_hour = av_clip(time.tm_hour, 0, 23);
2568 time.tm_min = av_clip(time.tm_min, 0, 59);
2569 time.tm_sec = av_clip(time.tm_sec, 0, 59);
2571 return (int64_t)
av_timegm(&time) * 1000000;
2574 #define SET_STR_METADATA(pb, name, str) do { \ 2575 if ((ret = mxf_read_utf16be_string(pb, size, &str)) < 0) \ 2577 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \ 2580 #define SET_UID_METADATA(pb, name, var, str) do { \ 2581 avio_read(pb, var, 16); \ 2582 if ((ret = mxf_uid_to_str(var, &str)) < 0) \ 2584 av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \ 2587 #define SET_TS_METADATA(pb, name, var, str) do { \ 2588 var = avio_rb64(pb); \ 2589 if ((ret = avpriv_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var)) < 0)) \ 2644 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
2645 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
2646 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
2647 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
2648 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
2649 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
2650 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
2651 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
2652 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
2653 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
2654 { { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
2655 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x2f,0x00 },
mxf_read_preface_metadata },
2656 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x30,0x00 },
mxf_read_identification_metadata },
2657 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage, 0,
AnyType },
2658 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
SourcePackage },
2659 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_package,
sizeof(
MXFPackage),
MaterialPackage },
2660 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0f,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
2661 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x05,0x00 },
mxf_read_essence_group,
sizeof(
MXFEssenceGroup),
EssenceGroup},
2662 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
2663 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3f,0x00 },
mxf_read_tagged_value,
sizeof(
MXFTaggedValue),
TaggedValue },
2664 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
2665 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2666 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2667 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2668 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2669 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2670 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2671 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5b,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2672 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5c,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2673 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5e,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2674 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x64,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
2675 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2676 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
2677 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x14,0x00 },
mxf_read_timecode_component,
sizeof(
MXFTimecodeComponent),
TimecodeComponent },
2678 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0c,0x00 },
mxf_read_pulldown_component,
sizeof(
MXFPulldownComponent),
PulldownComponent },
2679 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
2680 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
2681 { { 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x23,0x00 },
mxf_read_essence_container_data,
sizeof(
MXFEssenceContainerData),
EssenceContainerData },
2682 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
NULL, 0, AnyType },
2714 if (next < 0 || next > INT64_MAX - size)
2727 if (local_tag == tag) {
2734 if (ctx_size && tag == 0x3C0A) {
2736 }
else if ((ret = read_child(ctx, pb, tag, size, uid, -1)) < 0) {
2751 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
2772 key[13] >= 2 && key[13] <= 4;
2784 if (klv.
key[5] == 0x53) {
2814 int64_t current_partition_ofs;
2845 if (klv.
offset >= current_partition_ofs) {
2847 PRIx64
" indirectly points to itself\n", current_partition_ofs);
2887 "failed to seek to FooterPartition @ 0x%" PRIx64
2888 " (%"PRId64
") - partial file?\n",
2947 if (x < mxf->partitions_count - 1)
2954 "partition %i: bad ThisPartition = %"PRIX64
"\n",
3017 int essence_partition_count = 0;
3018 int edit_unit_byte_count = 0;
3040 essence_partition_count++;
3044 if (essence_partition_count != 1)
3053 if (edit_unit_byte_count <= 0)
3058 if (!(segment =
av_mallocz(
sizeof(*segment))))
3086 int64_t file_size, max_rip_length, min_rip_length;
3102 max_rip_length = ((file_size - mxf->
run_in) / 105) * 12 + 28;
3103 max_rip_length =
FFMIN(max_rip_length, INT_MAX);
3106 min_rip_length = 16+1+24+4;
3112 if (length < min_rip_length || length > max_rip_length)
3117 klv.
length != length - 20)
3184 if (!essence_offset)
3185 essence_offset = klv.
offset;
3200 for (metadata = mxf_metadata_read_table; metadata->
read; metadata++) {
3207 if (!metadata->
read) {
3214 if (!essence_offset) {
3234 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
3270 if (offset < current_offset)
3284 int i, total = 0, size = 0;
3289 int64_t sample_count;
3295 if ((sample_rate.
num / sample_rate.
den) == 48000)
3298 int remainder = (sample_rate.
num * time_base.
num) %
3299 (time_base.
den * sample_rate.
den);
3302 "seeking detected on stream #%d with time base (%d/%d) and " 3303 "sample rate (%d/%d), audio pts won't be accurate.\n",
3305 sample_rate.
num, sample_rate.
den);
3316 sample_count = (edit_unit /
size) * (uint64_t)total;
3317 for (i = 0; i < edit_unit %
size; i++) {
3321 return sample_count;
3331 int64_t next_ofs = -1;
3334 int64_t new_edit_unit;
3347 if (next_ofs > current_offset)
3362 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);
3374 if (!bits_per_sample)
3380 || bits_per_sample <= 0
3381 || par->
channels * (int64_t)bits_per_sample < 8)
3426 int64_t max_data_size;
3434 max_data_size = klv.
length;
3448 max_data_size = klv.
next_klv - pos;
3461 "error getting stream index %"PRIu32
"\n",
3477 if (next_ofs <= 0) {
3485 if ((size = next_ofs - pos) <= 0) {
3491 if (size > max_data_size)
3492 size = max_data_size;
3502 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
3589 for (; bufp <
end;) {
3590 if (!((bufp[13] - 1) & 0xF2)){
3627 if (sample_time < 0)
3647 source_track = new_source_track;
3658 sample_time =
FFMAX(sample_time, 0);
3667 sample_time < t->ptses[0] &&
3669 sample_time = t->
ptses[0];
3675 sample_time += t->
offsets[sample_time];
3691 if (seekpos < klv.next_klv - klv.length || seekpos >= klv.
next_klv) {
3707 int64_t track_edit_unit = sample_time;
3717 {
"eia608_extract",
"extract eia 608 captions from s436m track",
3741 .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
const char const char void * val
static int mxf_parse_structural_metadata(MXFContext *mxf)
enum AVFieldOrder field_order
Video only.
#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)
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
static int mxf_probe(AVProbeData *p)
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)
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)
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)
static int mxf_umid_to_str(UID ul, UID uid, char **str)
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 MXF_FIELD_DOMINANCE_DEFAULT
unsigned int avio_rb16(AVIOContext *s)
static int mxf_is_intra_only(MXFDescriptor *descriptor)
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.
This struct describes the properties of an encoded stream.
static int find_body_sid_by_offset(MXFContext *mxf, int64_t offset)
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
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 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[]
#define MXF_FIELD_DOMINANCE_FF
const MXFSamplesPerFrame * ff_mxf_get_samples_per_frame(AVFormatContext *s, AVRational time_base)
Opaque data information usually continuous.
static const uint8_t mxf_avid_essence_element_key[]
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
static av_cold int end(AVCodecContext *avctx)
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)
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)
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[]
#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.
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)
Allocate, reallocate, or free an array.
#define MXF_FIELD_DOMINANCE_FL
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static const uint8_t mxf_random_index_pack_key[]
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 int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st, int64_t edit_unit)
static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv, int body_sid)
#define i(width, name, range_min, range_max)
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. ...
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().
enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
Get the type of the given codec.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int mxf_parse_handle_essence(MXFContext *mxf)
Called when essence is encountered.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
static const uint8_t offset[127][2]
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)
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)
const MXFCodecUL ff_mxf_pixel_format_uls[]
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
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
enum MXFMetadataSetType type
static const uint8_t mxf_essence_element_key[]
static void * mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref, enum MXFMetadataSetType type)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
unsigned int horiz_subsampling
static const uint8_t mxf_system_item_key_cp[]
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static MXFStructuralComponent * mxf_resolve_essence_group_choice(MXFContext *mxf, MXFEssenceGroup *essence_group)
static const uint8_t mxf_encrypted_triplet_key[]
static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_t current_offset, int64_t *edit_unit_out)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
enum AVPixelFormat pix_fmt
int64_t essence_offset
absolute offset of essence
static int mxf_parse_package_comments(MXFContext *mxf, AVDictionary **pm, MXFPackage *package)
static MXFPackage * mxf_resolve_source_package(MXFContext *mxf, UID package_ul, UID package_uid)
int64_t last_forward_tell
static const uint8_t mxf_header_partition_pack_key[]
static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const MXFCodecUL mxf_intra_only_picture_coded_width[]
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define FF_PROFILE_JPEG2000_DCINEMA_4K
static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
static int mxf_read_identification_metadata(void *arg, AVIOContext *pb, int tag, int size, UID _uid, int64_t klv_offset)
const MXFCodecUL ff_mxf_data_definition_uls[]
SMPTE RP224 http://www.smpte-ra.org/mdd/index.html.
UID * sub_descriptors_refs
static const uint8_t mxf_system_item_key_gc[]
static MXFIndexTable * mxf_find_index_table(MXFContext *mxf, int index_sid)
static int mxf_read_essence_group(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
preferred ID for MPEG-1/2 video decoding
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
static int read_header(FFV1Context *f)
static const AVClass demuxer_class
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
static int mxf_read_tagged_value(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
#define AV_LOG_INFO
Standard information.
static int mxf_handle_missing_index_segment(MXFContext *mxf, AVStream *st)
Deal with the case where ClipWrapped essences does not have any IndexTableSegments.
UID * essence_container_data_refs
int sub_descriptors_count
AVIOContext * pb
I/O context.
static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_encrypted_essence_container[]
static int mxf_metadataset_init(MXFMetadataSet *ctx, enum MXFMetadataSetType type)
KLVPacket first_essence_klv
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static const MXFCodecUL mxf_data_essence_container_uls[]
Describe the class of an AVClass context structure.
static const AVOption options[]
Rational number (pair of numerator and denominator).
static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static const uint8_t mxf_canopus_essence_element_key[]
AVRational display_aspect_ratio
display aspect ratio (0 if unknown)
unsigned partitions_count
static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t offset, int64_t *offset_out, MXFPartition **partition_out)
Computes the absolute file offset of the given essence container offset.
This structure contains the data a format has to probe a file.
int essence_container_data_count
#define READ_STR16(type, big_endian)
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
#define flags(name, subs,...)
static const uint8_t mxf_indirect_value_utf16be[]
static int64_t klv_decode_ber_length(AVIOContext *pb)
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
static MXFWrappingScheme mxf_get_wrapping_kind(UID *essence_container_ul)
static int mxf_read_pulldown_component(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
int64_t duration
Decoding: duration of the stream, in stream time base.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int sample_rate
Audio only.
static int mxf_parse_physical_source_package(MXFContext *mxf, MXFTrack *source_track, AVStream *st)
static int mxf_set_pts(MXFContext *mxf, AVStream *st, AVPacket *pkt)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
static int mxf_read_content_storage(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const MXFCodecUL mxf_picture_essence_container_uls[]
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
MXFMetadataReadFunc * read
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it...
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
static int mxf_add_metadata_stream(MXFContext *mxf, MXFTrack *track)
static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx)
AVInputFormat ff_mxf_demuxer
AVIndexEntry * fake_index
int64_t pack_ofs
absolute offset of pack in file, including run-in
int structural_components_count
static int64_t mxf_timestamp_to_int64(uint64_t timestamp)
static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_compute_ptses_fake_index(MXFContext *mxf, MXFIndexTable *index_table)
static int mxf_set_audio_pts(MXFContext *mxf, AVCodecParameters *par, AVPacket *pkt)
const MXFCodecUL ff_mxf_codec_tag_uls[]
static int64_t mxf_set_current_edit_unit(MXFContext *mxf, AVStream *st, int64_t current_offset, int resync)
Make sure track->sample_count is correct based on what offset we're currently at. ...
uint64_t * stream_offset_entries
static int mxf_is_partition_pack_key(UID key)
Matches any partition pack key, in other words:
static int mxf_read_preface_metadata(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
void * priv_data
Format private data.
static int64_t mxf_essence_container_end(MXFContext *mxf, int body_sid)
Returns the end position of the essence container with given BodySID, or zero if unknown.
static MXFWrappingScheme mxf_get_wrapping_by_body_sid(AVFormatContext *s, int body_sid)
#define FF_PROFILE_JPEG2000_DCINEMA_2K
static int mxf_read_indirect_value(void *arg, AVIOContext *pb, int size)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
#define SET_STR_METADATA(pb, name, str)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
MXFMetadataSet ** metadata_sets
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
MXFIndexTable * index_tables
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVPixelFormat
Pixel format.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
MXFPartition * current_partition
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint64_t previous_partition
#define AV_TIMECODE_STR_SIZE
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
int64_t header_byte_count