diff mxf.c @ 1224:b6eb59aa44ca libavformat

add codec detection based on essence container ul
author bcoudurier
date Thu, 03 Aug 2006 09:14:56 +0000
parents 5f1bf54448e7
children 339cb300decd
line wrap: on
line diff
--- a/mxf.c	Wed Aug 02 15:02:42 2006 +0000
+++ b/mxf.c	Thu Aug 03 09:14:56 2006 +0000
@@ -632,6 +632,20 @@
     { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },       CODEC_ID_NONE },
 };
 
+static const MXFCodecUL mxf_picture_essence_container_uls[] = {
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Frame wrapped */
+    { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },       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 },  CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x03,0x00 },  CODEC_ID_PCM_S16LE }, /* AES Frame wrapped */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 },        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 },        CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0xc0 MPA stream id */
+  //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x05,0x01 },   CODEC_ID_PCM_AES3 }, /* D-10 Mapping 30Mbps PAL Extended Template */
+    { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },       CODEC_ID_NONE },
+};
+
 static enum CodecID mxf_get_codec_id(const MXFCodecUL *uls, UID *uid)
 {
     while (uls->id != CODEC_ID_NONE) {
@@ -784,13 +798,18 @@
         }
 #ifdef DEBUG
         PRINT_KEY(descriptor->essence_codec_ul);
+        PRINT_KEY(descriptor->essence_container_ul);
 #endif
         st->codec->codec_id = mxf_get_codec_id(mxf_codec_uls, &descriptor->essence_codec_ul);
         if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+            if (st->codec->codec_id == CODEC_ID_NONE)
+                st->codec->codec_id = mxf_get_codec_id(mxf_picture_essence_container_uls, &descriptor->essence_container_ul);
             st->codec->width = descriptor->width;
             st->codec->height = descriptor->height;
             st->codec->bits_per_sample = descriptor->bits_per_sample; /* Uncompressed */
         } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+            if (st->codec->codec_id == CODEC_ID_NONE)
+                st->codec->codec_id = mxf_get_codec_id(mxf_sound_essence_container_uls, &descriptor->essence_container_ul);
             st->codec->channels = descriptor->channels;
             st->codec->bits_per_sample = descriptor->bits_per_sample;
             st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;