]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mxf.c
Remove ff_mms_set_stream_selection again from asf demuxer,
[ffmpeg] / libavformat / mxf.c
index f4a1757fbcfeeb30a8a4a0b8898f8520836dcd27..0c69cd2e12e738ca168008f9e20bdaf85792b50e 100644 (file)
@@ -180,6 +180,7 @@ static const uint8_t mxf_klv_key[]                         = { 0x06,0x0e,0x2b,0x
 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 };
 static const uint8_t mxf_encrypted_triplet_key[]           = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
 static const uint8_t mxf_encrypted_essence_container[]     = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
+static const uint8_t mxf_sony_mpeg4_extradata[]            = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
 
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
 
@@ -243,7 +244,8 @@ static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
 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 */
@@ -553,7 +555,7 @@ static void mxf_read_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor)
     } while (code != 0); /* SMPTE 377M E.2.46 */
 }
 
-static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size)
+static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size, UID uid)
 {
     switch(tag) {
     case 0x3F01:
@@ -601,12 +603,15 @@ static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext
     case 0x3401:
         mxf_read_pixel_layout(pb, descriptor);
         break;
-    case 0x8201: /* Private tag used by SONY C0023S01.mxf */
-        descriptor->extradata = av_malloc(size);
-        if (!descriptor->extradata)
-            return -1;
-        descriptor->extradata_size = size;
-        get_buffer(pb, descriptor->extradata, size);
+    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);
+        }
         break;
     }
     return 0;
@@ -642,20 +647,14 @@ static const MXFCodecUL mxf_codec_uls[] = {
 };
 
 static const MXFCodecUL mxf_picture_essence_container_uls[] = {
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 16, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Frame wrapped */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xe0,0x02 }, 16, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Clip wrapped, 0xe0 MPV stream id */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x04,0x61,0x07 }, 16, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Custom wrapped, 0x61 ??? stream id */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 16,    CODEC_ID_DVVIDEO }, /* DV 625 25mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x3F,0x01 }, 16,    CODEC_ID_DVVIDEO }, /* DV IEC 625 25mbps */
-    { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 16,       CODEC_ID_NONE },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Frame wrapped */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14,    CODEC_ID_DVVIDEO }, /* DV 625 25mbps */
+    { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },  0,       CODEC_ID_NONE },
 };
 
 static const MXFCodecUL mxf_sound_essence_container_uls[] = {
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 16, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x03,0x00 }, 16, CODEC_ID_PCM_S16LE }, /* AES Frame wrapped */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 16,       CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xc0,0x01 }, 16,       CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0xc0 MPA stream id */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xc0,0x02 }, 16,       CODEC_ID_MP2 }, /* MPEG-ES Clip wrapped, 0xc0 MPA stream id */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14,       CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, CODEC_ID_PCM_S16LE }, /* D-10 Mapping 50Mbps PAL Extended Template */
     { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },  0,      CODEC_ID_NONE },
 };
@@ -924,7 +923,7 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child
         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);
@@ -945,8 +944,8 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child
         }
         if (ctx_size && tag == 0x3C0A)
             get_buffer(pb, ctx->uid, 16);
-        else
-            read_child(ctx, pb, tag, size, uid);
+        else if (read_child(ctx, pb, tag, size, uid) < 0)
+            return -1;
 
         url_fseek(pb, next, SEEK_SET);
     }