234 static const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 };
235 static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 };
236 static const uint8_t mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 };
237 static const uint8_t mxf_system_item_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x03,0x01,0x04 };
240 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 };
241 static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
242 static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
243 static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
245 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
251 int bytes_num = size & 0x7f;
257 size = size << 8 |
avio_r8(pb);
269 else if (b != key[i])
283 return klv->
length == -1 ? -1 : 0;
303 const uint8_t *buf_ptr, *end_ptr;
312 data_ptr = pkt->
data;
313 end_ptr = pkt->
data + length;
314 buf_ptr = pkt->
data + 4;
317 uint32_t
sample = bytestream_get_le32(&buf_ptr);
319 bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
321 bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
331 static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b};
337 uint64_t plaintext_size;
364 if (orig_size < plaintext_size)
368 if (size < 32 || size - 32 < orig_size)
374 if (memcmp(tmpbuf, checkv, 16))
380 else if (size < plaintext_size)
382 size -= plaintext_size;
385 &pkt->
data[plaintext_size], size >> 4, ivec, 1);
398 if (item_len != 18) {
403 if (item_num > UINT_MAX / item_len)
418 uint64_t footer_partition;
419 uint32_t nb_essence_containers;
441 memset(partition, 0,
sizeof(*partition));
477 if (footer_partition) {
480 "inconsistent FooterPartition value: %"PRIu64
" != %"PRIu64
"\n",
488 "PartitionPack: ThisPartition = 0x%"PRIX64
489 ", PreviousPartition = 0x%"PRIX64
", "
490 "FooterPartition = 0x%"PRIX64
", IndexSID = %i, BodySID = %i\n",
499 "PreviousPartition points to this partition or forward\n");
503 if (op[12] == 1 && op[13] == 1) mxf->
op =
OP1a;
504 else if (op[12] == 1 && op[13] == 2) mxf->
op =
OP1b;
505 else if (op[12] == 1 && op[13] == 3) mxf->
op =
OP1c;
506 else if (op[12] == 2 && op[13] == 1) mxf->
op =
OP2a;
507 else if (op[12] == 2 && op[13] == 2) mxf->
op =
OP2b;
508 else if (op[12] == 2 && op[13] == 3) mxf->
op =
OP2c;
509 else if (op[12] == 3 && op[13] == 1) mxf->
op =
OP3a;
510 else if (op[12] == 3 && op[13] == 2) mxf->
op =
OP3b;
511 else if (op[12] == 3 && op[13] == 3) mxf->
op =
OP3c;
512 else if (op[12] == 64&& op[13] == 1) mxf->
op =
OPSonyOpt;
513 else if (op[12] == 0x10) {
518 if (nb_essence_containers != 1) {
524 "\"OPAtom\" with %u ECs - assuming %s\n",
525 nb_essence_containers,
526 op ==
OP1a ?
"OP1a" :
"OPAtom");
532 av_log(mxf->
fc,
AV_LOG_ERROR,
"unknown operational pattern: %02xh %02xh - guessing OP1a\n", op[12], op[13]);
620 if (package->tracks_count >= UINT_MAX /
sizeof(
UID))
622 package->tracks_refs =
av_malloc(package->tracks_count *
sizeof(
UID));
623 if (!package->tracks_refs)
683 if (package->tracks_count >= UINT_MAX /
sizeof(
UID))
685 package->tracks_refs =
av_malloc(package->tracks_count *
sizeof(
UID));
686 if (!package->tracks_refs)
697 avio_read(pb, package->descriptor_ref, 16);
781 int code, value, ofs = 0;
790 layout[ofs++] = code;
791 layout[ofs++] = value;
881 for (i = 0; i <
len; i++) {
882 if (i != 7 && key[i] != uid[i])
890 while (uls->
uid[0]) {
915 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
916 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,
AV_CODEC_ID_DVVIDEO },
917 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14,
AV_CODEC_ID_RAWVIDEO },
918 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
923 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14,
AV_CODEC_ID_MPEG2VIDEO },
924 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
929 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,
AV_CODEC_ID_H264 },
930 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
935 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14,
AV_CODEC_ID_PCM_S16LE },
936 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,
AV_CODEC_ID_MP2 },
937 { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,
AV_CODEC_ID_PCM_S16LE },
938 { { 0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0xFF,0x4B,0x46,0x41,0x41,0x00,0x0D,0x4D,0x4F }, 14,
AV_CODEC_ID_PCM_S16LE },
939 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0,
AV_CODEC_ID_NONE },
944 int i, j, nb_segments = 0;
946 int last_body_sid = -1, last_index_sid = -1, last_index_start = -1;
956 *sorted_segments =
av_mallocz(nb_segments *
sizeof(**sorted_segments));
957 unsorted_segments =
av_mallocz(nb_segments *
sizeof(*unsorted_segments));
958 if (!*sorted_segments || !unsorted_segments) {
968 *nb_sorted_segments = 0;
971 for (i = 0; i < nb_segments; i++) {
972 int best = -1, best_body_sid = -1, best_index_sid = -1, best_index_start = -1;
974 for (j = 0; j < nb_segments; j++) {
993 (*sorted_segments)[(*nb_sorted_segments)++] = unsorted_segments[best];
994 last_body_sid = best_body_sid;
995 last_index_sid = best_index_sid;
996 last_index_start = best_index_start;
1010 int64_t offset_in = offset;
1027 "failed to find absolute offset of %"PRIX64
" in BodySID %i - partial file?\n",
1028 offset_in, body_sid);
1060 int64_t offset_temp = 0;
1084 av_log(mxf->
fc,
AV_LOG_ERROR,
"IndexSID %i segment at %"PRId64
" missing EditUnitByteCount and IndexEntryArray\n",
1090 *edit_unit_out = edit_unit;
1108 int8_t max_temporal_offset = -128;
1140 for (x = 0; x < index_table->
nb_ptses; x++)
1172 int index_delta = 1;
1181 for (j = 0; j < n; j += index_delta, x++) {
1183 int index = x + offset;
1187 "x >= nb_ptses - IndexEntryCount %i < IndexDuration %"PRId64
"?\n",
1195 if (index < 0 || index >= index_table->
nb_ptses) {
1197 "index entry %i + TemporalOffset %i = %i, which is out of bounds\n",
1203 max_temporal_offset =
FFMAX(max_temporal_offset, offset);
1207 index_table->
first_dts = -max_temporal_offset;
1218 int i, j, k, ret, nb_sorted_segments;
1222 nb_sorted_segments <= 0) {
1228 for (i = 0; i < nb_sorted_segments; i++) {
1229 if (i == 0 || sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid)
1231 else if (sorted_segments[i-1]->body_sid != sorted_segments[i]->body_sid) {
1234 goto finish_decoding_index;
1243 goto finish_decoding_index;
1247 for (i = j = 0; i < nb_sorted_segments; i++) {
1248 if (i != 0 && sorted_segments[i-1]->index_sid != sorted_segments[i]->index_sid) {
1264 " pointer array\n");
1266 goto finish_decoding_index;
1269 if (sorted_segments[i]->index_start_position)
1270 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i starts at EditUnit %"PRId64
" - seeking may not work as expected\n",
1278 goto finish_decoding_index;
1286 av_log(mxf->
fc,
AV_LOG_WARNING,
"IndexSID %i segment %i has zero IndexDuration and there's more than one segment\n",
1303 finish_decoding_index:
1326 if (material_package)
break;
1328 if (!material_package) {
1340 UID *essence_container_ul =
NULL;
1368 source_package = temp_package;
1372 if (!source_package) {
1373 av_dlog(mxf->
fc,
"material track %d: no corresponding source package found\n", material_track->
track_id);
1383 source_track = temp_track;
1387 if (!source_track) {
1392 if (!source_track || !component)
1432 if (!sub_descriptor) {
1437 descriptor = sub_descriptor;
1458 essence_container_ul = &((
MXFCryptoContext *)metadata)->source_container_ul;
1473 container_ul =
mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
1483 "SegmentedFrame layout isn't currently supported\n");
1490 "OneField frame layout isn't currently supported\n");
1502 "Unknown frame layout type: %d\n",
1524 container_ul =
mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
1535 "found for stream #%d, time base forced to 1/48000\n",
1568 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 },
mxf_read_primer_pack },
1569 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 },
mxf_read_partition_pack },
1570 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x02,0x00 },
mxf_read_partition_pack },
1571 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x03,0x00 },
mxf_read_partition_pack },
1572 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x04,0x00 },
mxf_read_partition_pack },
1573 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x01,0x00 },
mxf_read_partition_pack },
1574 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x02,0x00 },
mxf_read_partition_pack },
1575 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x03,0x00 },
mxf_read_partition_pack },
1576 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 },
mxf_read_partition_pack },
1577 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 },
mxf_read_partition_pack },
1578 { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 },
mxf_read_partition_pack },
1579 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 },
mxf_read_content_storage, 0,
AnyType },
1580 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 },
mxf_read_source_package,
sizeof(
MXFPackage),
SourcePackage },
1581 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 },
mxf_read_material_package,
sizeof(
MXFPackage),
MaterialPackage },
1582 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0F,0x00 },
mxf_read_sequence,
sizeof(
MXFSequence),
Sequence },
1583 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 },
mxf_read_source_clip,
sizeof(
MXFStructuralComponent),
SourceClip },
1584 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
MultipleDescriptor },
1585 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1586 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1587 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1588 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1589 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1590 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 },
mxf_read_generic_descriptor,
sizeof(
MXFDescriptor),
Descriptor },
1591 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
1592 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 },
mxf_read_track,
sizeof(
MXFTrack),
Track },
1593 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 },
mxf_read_cryptographic_context,
sizeof(
MXFCryptoContext),
CryptoContext },
1594 { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x10,0x01,0x00 },
mxf_read_index_table_segment,
sizeof(
MXFIndexTableSegment),
IndexTableSegment },
1595 { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
NULL, 0,
AnyType },
1613 av_dlog(mxf->
fc,
"local tag %#04x size %d\n", tag, size);
1622 if (local_tag == tag) {
1624 av_dlog(mxf->
fc,
"local tag %#04x\n", local_tag);
1629 if (ctx_size && tag == 0x3C0A)
1631 else if ((ret = read_child(ctx, pb, tag, size, uid, -1)) < 0)
1638 "local tag %#04x extends past end of local set @ %#"PRIx64
"\n",
1644 if (ctx_size) ctx->
type = type;
1664 av_dlog(mxf->
fc,
"seeking to previous partition\n");
1686 av_dlog(mxf->
fc,
"seeking to footer\n");
1698 av_log(mxf->
fc,
AV_LOG_ERROR,
"failed to seek to footer @ 0x%"PRIx64
" (%"PRId64
") - partial file?\n",
1747 "partition %i: bad ThisPartition = %"PRIX64
"\n",
1757 int64_t ret = (position / kag_size) * kag_size;
1758 return ret == position ? ret : ret + kag_size;
1774 int64_t op1a_essence_offset =
1833 int64_t essence_offset = 0;
1867 "found essence prior to first PartitionPack\n");
1875 if (!essence_offset)
1876 essence_offset = klv.
offset;
1892 for (metadata = mxf_metadata_read_table; metadata->
read; metadata++) {
1895 if (klv.
key[5] == 0x53) {
1917 if (!metadata->
read)
1921 if (!essence_offset) {
1939 av_log(mxf->
fc,
AV_LOG_INFO,
"got %i index tables - only the first one (IndexSID %i) will be used\n",
1957 int64_t last_ofs = -1, next_ofs = -1;
1969 NULL, &next_ofs, 0) < 0)
1972 if (next_ofs <= last_ofs) {
1976 "next_ofs didn't change. not deriving packet timestamps\n");
1980 if (next_ofs > current_offset)
1983 last_ofs = next_ofs;
2016 int64_t next_ofs, next_klv;
2034 if (next_ofs >= 0 && next_klv > next_ofs) {
2039 "KLV for edit unit %i extends into next "
2040 "edit unit - OPAtom misinterpreted as "
2047 if (klv.
key[12] == 0x06 && klv.
key[13] == 0x01 && klv.
key[14] == 0x10) {
2092 int64_t ret64, pos, next_pos;
2121 if ((size = next_pos - pos) <= 0) {
2126 if ((ret64 =
avio_seek(s->
pb, pos, SEEK_SET)) < 0)
2203 for (; bufp < end; bufp++) {
2224 if (sample_time < 0)
2236 sample_time =
FFMAX(sample_time, 0);
static const uint8_t mxf_crypto_source_container_ul[]
static void mxf_compute_essence_containers(MXFContext *mxf)
Figure out the proper offset and length of the essence container in each partition.
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
struct MXFContext MXFContext
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int mxf_parse_structural_metadata(MXFContext *mxf)
unsigned int component_depth
KLVPacket current_klv_data
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[]
#define PRINT_KEY(pc, s, x)
static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
UID * structural_components_refs
static int mxf_seek_to_previous_partition(MXFContext *mxf)
Seeks to the previous partition, if possible.
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.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int index
stream index in AVFormatContext
uint64_t footer_partition
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
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_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
unsigned int avio_rb16(AVIOContext *s)
static int mxf_read_header(AVFormatContext *s)
enum MXFMetadataSetType type
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
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)
Opaque data information usually continuous.
static const uint8_t mxf_avid_essence_element_key[]
unsigned int avio_rb32(AVIOContext *s)
AVRational index_edit_rate
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
static int mxf_read_close(AVFormatContext *s)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int mxf_absolute_bodysid_offset(MXFContext *mxf, int body_sid, int64_t offset, int64_t *offset_out)
Computes the absolute file offset of the given essence container offset.
static void compute_partition_essence_offset(AVFormatContext *s, MXFContext *mxf, KLVPacket *klv)
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 av_cold int read_close(AVFormatContext *ctx)
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static const MXFCodecUL mxf_intra_only_essence_container_uls[]
unsigned int vert_subsampling
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 int mxf_read_sync(AVIOContext *pb, const uint8_t *key, unsigned size)
AVCodecID
Identify the syntax and semantics of the bitstream.
int last_forward_partition
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
static void mxf_read_pixel_layout(AVIOContext *pb, MXFDescriptor *descriptor)
int8_t * temporal_offset_entries
static int mxf_read_sequence(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, int64_t *edit_unit_out, int64_t *offset_out, int nag)
MXFDescriptor * descriptor
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)
static const MXFCodecUL mxf_intra_only_picture_essence_coding_uls[]
static const MXFCodecUL mxf_sound_essence_container_uls[]
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
static int mxf_parse_handle_essence(MXFContext *mxf)
Called when essence is encountered.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
static int64_t round_to_kag(int64_t position, int kag_size)
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)
AVCodecContext * codec
Codec context associated with this stream.
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
A list of all streams in the file.
static const MXFCodecUL * mxf_get_codec_ul(const MXFCodecUL *uls, UID *uid)
MXFPartition * partitions
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
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static const uint8_t mxf_encrypted_triplet_key[]
enum AVPixelFormat pix_fmt
int64_t essence_offset
absolute offset of essence
int width
picture width / height.
static int mxf_read_material_package(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
int edit_units_per_packet
how many edit units to read at a time (PCM, OPAtom)
int64_t last_forward_tell
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
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 int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
enum AVPixelFormat pix_fmt
static void mxf_handle_small_eubc(AVFormatContext *s)
Deal with the case where for some audio atoms EditUnitByteCount is very small (2, 4...
const MXFCodecUL ff_mxf_data_definition_uls[]
SMPTE RP224 http://www.smpte-ra.org/mdd/index.html.
UID * sub_descriptors_refs
static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
preferred ID for MPEG-1/2 video decoding
static int read_header(FFV1Context *f)
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
enum AVMediaType codec_type
int sub_descriptors_count
int sample_rate
samples per second
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 read_packet(AVFormatContext *ctx, AVPacket *pkt)
rational number numerator/denominator
static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
static const uint8_t mxf_system_item_key[]
#define FF_INPUT_BUFFER_PADDING_SIZE
unsigned partitions_count
static int mxf_is_intra_only(MXFDescriptor *d)
This structure contains the data a format has to probe a file.
static int64_t klv_decode_ber_length(AVIOContext *pb)
int64_t duration
Decoding: duration of the stream, in stream time base.
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[]
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
MXFMetadataReadFunc * read
#define AVERROR_INVALIDDATA
#define AVPROBE_SCORE_MAX
AVInputFormat ff_mxf_demuxer
AVIndexEntry * fake_index
#define AVERROR_PATCHWELCOME
int structural_components_count
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)
int eof_reached
true if eof reached
uint64_t * stream_offset_entries
int channels
number of audio channels
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 int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static int64_t mxf_set_current_edit_unit(MXFContext *mxf, int64_t current_offset)
Sets mxf->current_edit_unit based on what offset we're currently at.
int bit_rate
Decoding: total stream bitrate in bit/s, 0 if not available.
MXFMetadataSet ** metadata_sets
static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
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.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
MXFPartition * current_partition
uint64_t previous_partition
int64_t header_byte_count