[PATCH 8/8] compact ULs list

Maksym Veremeyenko verem at m1stereo.tv
Tue Feb 22 15:41:18 CET 2011


---
 libavformat/mxfdec.c |   70 +++++++++++++++----------------------------------
 1 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 1dabdb1..b20ad77 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -162,6 +162,7 @@ typedef struct {
 typedef struct {
     UID uid;
     unsigned matching_len;
+    unsigned matching_mask;
     int id;
     enum MXFWrappingScheme wrapping;
 } MXFContainerUL;
@@ -705,11 +706,11 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
  * Match an uid independently of the version byte and up to len common bytes
  * Returns: boolean
  */
-static int mxf_match_uid(const UID key, const UID uid, int len)
+static int mxf_match_uid(const UID key, const UID uid, int len, int mask)
 {
     int i;
     for (i = 0; i < len; i++) {
-        if (i != 7 && key[i] != uid[i])
+        if (i != 7 && key[i] != uid[i] && !(mask & (1 << i)))
             return 0;
     }
     return 1;
@@ -718,7 +719,7 @@ static int mxf_match_uid(const UID key, const UID uid, int len)
 static const MXFCodecUL *mxf_get_codec_ul(const MXFCodecUL *uls, UID *uid)
 {
     while (uls->uid[0]) {
-        if(mxf_match_uid(uls->uid, *uid, uls->matching_len))
+        if(mxf_match_uid(uls->uid, *uid, uls->matching_len, 0))
             break;
         uls++;
     }
@@ -728,7 +729,7 @@ static const MXFCodecUL *mxf_get_codec_ul(const MXFCodecUL *uls, UID *uid)
 static const MXFContainerUL *mxf_get_container_ul(const MXFContainerUL *uls, UID *uid)
 {
     while (uls->uid[0]) {
-        if(mxf_match_uid(uls->uid, *uid, uls->matching_len))
+        if(mxf_match_uid(uls->uid, *uid, uls->matching_len, uls->matching_mask))
             break;
         uls++;
     }
@@ -752,52 +753,25 @@ static void *mxf_resolve_strong_ref(MXFContext *mxf, UID *strong_ref, enum MXFMe
 
 static const MXFContainerUL mxf_essence_container_uls[] = {
     // video essence container uls
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 16, CODEC_ID_MPEG2VIDEO, Frame }, /* MPEG-ES Frame wrapped */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x02 }, 16, CODEC_ID_MPEG2VIDEO,  Clip }, /* Clip-wrapped MPEG-ES VideoStream-0 */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x61,0x01 }, 16, CODEC_ID_MPEG2VIDEO, Frame }, /* Frame-wrapped MPEG-ES VideoStream-1 */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x61,0x02 }, 16, CODEC_ID_MPEG2VIDEO,  Clip }, /* Clip-wrapped MPEG-ES VideoStream-1 */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xe0,0x02 }, 16, CODEC_ID_MPEG2VIDEO,  Clip }, /* MPEG-ES Clip wrapped, 0xe0 MPV stream id */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x02,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped IEC-DV 625x50I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x02,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped IEC-DV 625x50I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x03,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped IEC-DV 525x59.94I 25Mbps SMPTE-322M */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x03,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped IEC-DV 525x59.94I 25Mbps SMPTE-322M */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x04,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped IEC-DV 625x50I 25Mbps SMPTE-322M */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x04,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped IEC-DV 625x50I 25Mbps SMPTE-322M */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x3F,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped IEC-DV UndefinedSource 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x3F,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped IEC-DV UndefinedSource 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x40,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 525x59.94I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x40,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 525x59.94I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 625x50I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 625x50I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 625x50I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 625x50I 25Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x51,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 625x50I 50Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x51,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 625x50I 50Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x60,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 1080x59.94I 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x60,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 1080x59.94I 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x61,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 1080x50I 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x61,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 1080x50I 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x62,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 720x59.94P 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x62,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 720x59.94P 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x63,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* Frame-wrapped DV-based 720x50P 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x63,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* Clip-wrapped DV-based 720x50P 100Mbps */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x7F,0x01 }, 16,    CODEC_ID_DVVIDEO, Frame }, /* MXF-GC Frame-wrapped DV-based UndefinedSource */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x7F,0x02 }, 16,    CODEC_ID_DVVIDEO,  Clip }, /* MXF-GC Clip-wrapped DV-based UndefinedSource */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x0D,0x01,0x03,0x01,0x02,0x10,0x60,0x01 }, 16,    CODEC_ID_H264,    Frame }, /* MXF-GC AVC Byte Stream With VideoStream-0 SID Frame-wrapped */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x0D,0x01,0x03,0x01,0x02,0x10,0x60,0x02 }, 16,    CODEC_ID_H264,     Clip }, /* MXF-GC  AVC Byte Stream With VideoStream-0 SID Clip-wrapped */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xFF,0x01 }, 16, 0x4000, CODEC_ID_MPEG2VIDEO, Frame },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xFF,0x02 }, 16, 0x4000, CODEC_ID_MPEG2VIDEO,  Clip },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0xFF,0x01 }, 16, 0x4000,    CODEC_ID_DVVIDEO, Frame },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0xFF,0x02 }, 16, 0x4000,    CODEC_ID_DVVIDEO,  Clip },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x0D,0x01,0x03,0x01,0x02,0x10,0xFF,0x01 }, 16, 0x4000,       CODEC_ID_H264, Frame },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x0D,0x01,0x03,0x01,0x02,0x10,0xFF,0x02 }, 16, 0x4000,       CODEC_ID_H264,  Clip },
 
     // 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, Frame }, /* BWF Frame wrapped */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x02,0x00 }, 16,  CODEC_ID_PCM_S16LE,  Clip }, /* Clip-wrapped Broadcast Wave audio data */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x03,0x00 }, 16,  CODEC_ID_PCM_S16LE, Frame }, /* AES Frame wrapped */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x04,0x00 }, 16,  CODEC_ID_PCM_S16LE,  Clip }, /* Clip-wrapped AES3 audio data */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 16,        CODEC_ID_MP2, Frame }, /* 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, Frame }, /* 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,  Clip }, /* MPEG-ES Clip wrapped, 0xc0 MPA stream id */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14,  CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 50Mbps PAL Extended Template */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x0D,0x01,0x03,0x01,0x02,0x0A,0x01,0x00 }, 16,   CODEC_ID_PCM_ALAW, Frame }, /* Frame-wrapped A-law Audio */
-    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x0D,0x01,0x03,0x01,0x02,0x0A,0x02,0x00 }, 16,   CODEC_ID_PCM_ALAW,  Clip }, /* Clip-wrapped A-law Audio */
-    { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 16,       CODEC_ID_NONE, Frame },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 16, 0x0000,  CODEC_ID_PCM_S16LE, Frame }, /* BWF Frame wrapped */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x02,0x00 }, 16, 0x0000,  CODEC_ID_PCM_S16LE,  Clip }, /* Clip-wrapped Broadcast Wave audio data */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x03,0x00 }, 16, 0x0000,  CODEC_ID_PCM_S16LE, Frame }, /* AES Frame wrapped */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x04,0x00 }, 16, 0x0000,  CODEC_ID_PCM_S16LE,  Clip }, /* Clip-wrapped AES3 audio data */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 16, 0x0000,        CODEC_ID_MP2, Frame }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xc0,0x01 }, 16, 0x0000,        CODEC_ID_MP2, Frame }, /* 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, 0x0000,        CODEC_ID_MP2,  Clip }, /* MPEG-ES Clip wrapped, 0xc0 MPA stream id */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, 0x0000,  CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 50Mbps PAL Extended Template */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x0D,0x01,0x03,0x01,0x02,0x0A,0x01,0x00 }, 16, 0x0000,   CODEC_ID_PCM_ALAW, Frame }, /* Frame-wrapped A-law Audio */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x0D,0x01,0x03,0x01,0x02,0x0A,0x02,0x00 }, 16, 0x0000,   CODEC_ID_PCM_ALAW,  Clip }, /* Clip-wrapped A-law Audio */
+    { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 16, 0x0000,       CODEC_ID_NONE, Frame },
 };
 
 static int mxf_parse_structural_metadata(MXFContext *mxf)
-- 
1.7.4


--------------080409060609020706050401--


More information about the libav-devel mailing list