]> git.sesse.net Git - vlc/blobdiff - include/codecs.h
* configure.ac: oops, forgot something.
[vlc] / include / codecs.h
index a1447655331673d40bb424dfc8365a2236c6bdf9..edd60934f1f19800e60fadc6ca72c549c05a87be 100644 (file)
@@ -120,6 +120,8 @@ typedef struct {
 } BITMAPINFO, *LPBITMAPINFO;
 #endif
 
+#ifndef _RECT32_
+#define _RECT32_
 typedef struct
 #ifdef HAVE_ATTRIBUTE_PACKED
     __attribute__((__packed__))
@@ -127,9 +129,15 @@ typedef struct
 {
     int left, top, right, bottom;
 } RECT32;
+#endif
 
+#ifndef _REFERENCE_TIME_
+#define _REFERENCE_TIME_
 typedef int64_t REFERENCE_TIME;
+#endif
 
+#ifndef _VIDEOINFOHEADER_
+#define _VIDEOINFOHEADER_
 typedef struct
 #ifdef HAVE_ATTRIBUTE_PACKED
     __attribute__((__packed__))
@@ -143,6 +151,7 @@ typedef struct
     BITMAPINFOHEADER  bmiHeader;
     //int               reserved[3];
 } VIDEOINFOHEADER;
+#endif
 
 /* WAVE format wFormatTag IDs */
 #define WAVE_FORMAT_UNKNOWN             0x0000 /* Microsoft Corporation */
@@ -166,6 +175,7 @@ typedef struct
 #define WAVE_FORMAT_WMA2                0x0161
 #define WAVE_FORMAT_WMA3                0x0162
 #define WAVE_FORMAT_DIVIO_AAC           0x4143
+#define WAVE_FORMAT_AAC                 0x00FF
 
 /* Need to check these */
 #define WAVE_FORMAT_DK3                 0x0061
@@ -175,6 +185,22 @@ typedef struct
 #define WAVE_FORMAT_EXTENSIBLE          0xFFFE /* Microsoft */
 #endif
 
+/* GUID SubFormat IDs */
+/* We need both b/c const variables are not compile-time constants in C, giving
+ * us an error if we use the const GUID in an enum */
+
+#ifndef _KSDATAFORMAT_SUBTYPE_PCM_
+#define _KSDATAFORMAT_SUBTYPE_PCM_ {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
+static const GUID VLC_KSDATAFORMAT_SUBTYPE_PCM = {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}};
+#define KSDATAFORMAT_SUBTYPE_PCM VLC_KSDATAFORMAT_SUBTYPE_PCM
+#endif
+
+#ifndef _KSDATAFORMAT_SUBTYPE_UNKNOWN_ 
+#define _KSDATAFORMAT_SUBTYPE_UNKNOWN_ {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
+static const GUID VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
+#define KSDATAFORMAT_SUBTYPE_UNKNOWN VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN
+#endif
+
 /* Microsoft speaker definitions */
 #define WAVE_SPEAKER_FRONT_LEFT             0x1
 #define WAVE_SPEAKER_FRONT_RIGHT            0x2
@@ -222,6 +248,7 @@ wave_format_tag_to_fourcc[] =
     { WAVE_FORMAT_DTS,      VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
     { WAVE_FORMAT_DTS_MS,   VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
     { WAVE_FORMAT_DIVIO_AAC,VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio (Divio)" },
+    { WAVE_FORMAT_AAC,      VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio" },
     { WAVE_FORMAT_UNKNOWN,  VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
 };
 
@@ -247,6 +274,43 @@ static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag )
     if( pi_tag ) *pi_tag = wave_format_tag_to_fourcc[i].i_tag;
 }
 
+/* If wFormatTag is WAVEFORMATEXTENSIBLE, we must look at the SubFormat tag
+ * to determine the actual format.  Microsoft has stopped giving out wFormatTag
+ * assignments in lieu of letting 3rd parties generate their own GUIDs
+ */
+static struct
+{
+    GUID         guid_tag;
+    vlc_fourcc_t i_fourcc;
+    char         *psz_name;
+}
+sub_format_tag_to_fourcc[] =
+{
+    { _KSDATAFORMAT_SUBTYPE_PCM_, VLC_FOURCC( 'p', 'c', 'm', ' ' ), "PCM" },
+    { _KSDATAFORMAT_SUBTYPE_UNKNOWN_, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
+};
+
+/* compares two GUIDs, returns 1 if identical, 0 otherwise */
+static inline int guidcmp( const GUID *s1, const GUID *s2 )
+{
+    return( s1->Data1 == s2->Data1 && s1->Data2 == s2->Data2 &&
+            s1->Data3 == s2->Data3 && !memcmp( s1->Data4, s2->Data4, 8 ) );
+}
+
+static inline void sf_tag_to_fourcc( GUID *guid_tag,
+                                     vlc_fourcc_t *fcc, char **ppsz_name )
+{
+    int i;
+
+    for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, 
+                          &KSDATAFORMAT_SUBTYPE_UNKNOWN ); i++ )
+    {
+        if( guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, guid_tag ) ) break;
+    }
+    if( fcc ) *fcc = sub_format_tag_to_fourcc[i].i_fourcc;
+    if( ppsz_name ) *ppsz_name = sub_format_tag_to_fourcc[i].psz_name;
+}
+
 /**
  * Structure to hold information concerning subtitles.
  * Used between demuxers and decoders of subtitles.