//#define DEBUG
+#include "libavutil/aes.h"
+#include "libavcodec/bytestream.h"
#include "avformat.h"
-#include "aes.h"
-#include "bytestream.h"
typedef uint8_t UID[16];
static int mxf_get_d10_aes3_packet(ByteIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length)
{
uint8_t buffer[61444];
- uint8_t *buf_ptr, *end_ptr, *data_ptr;
+ const uint8_t *buf_ptr, *end_ptr;
+ uint8_t *data_ptr;
int i;
if (length > 61444) /* worst case PAL 1920 samples 8 channels */
if (IS_KLV_KEY(klv.key, mxf_essence_element_key)) {
int index = mxf_get_stream_index(s, &klv);
if (index < 0) {
- av_log(s, AV_LOG_ERROR, "error getting stream index\n");
- url_fskip(s->pb, klv.length);
- return -1;
+ av_log(s, AV_LOG_ERROR, "error getting stream index %x\n", AV_RB32(klv.key+12));
+ goto skip;
}
+ if (s->streams[index]->discard == AVDISCARD_ALL)
+ goto skip;
/* check for 8 channels AES3 element */
if (klv.key[12] == 0x06 && klv.key[13] == 0x01 && klv.key[14] == 0x10) {
if (mxf_get_d10_aes3_packet(s->pb, s->streams[index], pkt, klv.length) < 0) {
pkt->pos = klv.offset;
return 0;
} else
+ skip:
url_fskip(s->pb, klv.length);
}
return AVERROR(EIO);
default:
/* Private uid used by SONY C0023S01.mxf */
if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) {
- descriptor->extradata = av_malloc(size);
- if (!descriptor->extradata)
- return -1;
- descriptor->extradata_size = size;
- get_buffer(pb, descriptor->extradata, size);
+ descriptor->extradata = av_malloc(size);
+ if (!descriptor->extradata)
+ return -1;
+ descriptor->extradata_size = size;
+ get_buffer(pb, descriptor->extradata, size);
}
break;
}
int tag = get_be16(pb);
int size = get_be16(pb); /* KLV specified by 0x53 */
uint64_t next = url_ftell(pb) + size;
- UID uid;
+ UID uid = {0};
if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */
av_log(mxf->fc, AV_LOG_ERROR, "local tag 0x%04X with 0 size\n", tag);
case MaterialPackage:
av_freep(&((MXFPackage *)mxf->metadata_sets[i])->tracks_refs);
break;
+ case Track:
+ mxf->metadata_sets[i] = NULL; /* will be freed later */
+ break;
default:
break;
}
AVInputFormat mxf_demuxer = {
"mxf",
- "MXF format",
+ NULL_IF_CONFIG_SMALL("MXF format"),
sizeof(MXFContext),
mxf_probe,
mxf_read_header,