vlc_codecs.h 15.7 KB
Newer Older
Gildas Bazin's avatar
 
Gildas Bazin committed
1
/*****************************************************************************
Pere Orga's avatar
Pere Orga committed
2
 * vlc_codecs.h: codec related structures needed by the demuxers and decoders
Gildas Bazin's avatar
 
Gildas Bazin committed
3
 *****************************************************************************
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
4
 * Copyright (C) 1999-2001 VLC authors and VideoLAN
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
5
 * $Id$
Gildas Bazin's avatar
 
Gildas Bazin committed
6
 *
7
 * Author: Gildas Bazin <gbazin@videolan.org>
Gildas Bazin's avatar
 
Gildas Bazin committed
8
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
9 10 11
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
Gildas Bazin's avatar
 
Gildas Bazin committed
12 13 14 15
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
16 17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
Gildas Bazin's avatar
 
Gildas Bazin committed
18
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
19 20 21
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
Gildas Bazin's avatar
 
Gildas Bazin committed
22 23
 *****************************************************************************/

24 25
#ifndef VLC_CODECS_H
#define VLC_CODECS_H 1
Gildas Bazin's avatar
 
Gildas Bazin committed
26

27
#include <vlc_fourcc.h>
28 29 30 31 32
/**
 * \file
 * This file defines codec related structures needed by the demuxers and decoders
 */

Gildas Bazin's avatar
 
Gildas Bazin committed
33 34
/* Structures exported to the demuxers and decoders */

Gildas Bazin's avatar
 
Gildas Bazin committed
35 36 37 38 39 40 41 42 43 44 45
#if !(defined _GUID_DEFINED || defined GUID_DEFINED)
#define GUID_DEFINED
typedef struct _GUID
{
    uint32_t Data1;
    uint16_t Data2;
    uint16_t Data3;
    uint8_t  Data4[8];
} GUID, *REFGUID, *LPGUID;
#endif /* GUID_DEFINED */

46 47
typedef GUID guid_t;

48 49 50 51 52 53 54 55 56
#ifdef HAVE_ATTRIBUTE_PACKED
#   define ATTR_PACKED __attribute__((__packed__))
#elif defined(__SUNPRO_C)
#   pragma pack(1)
#   define ATTR_PACKED
#else
#   error FIXME
#endif

Gildas Bazin's avatar
 
Gildas Bazin committed
57 58
#ifndef _WAVEFORMATEX_
#define _WAVEFORMATEX_
59
typedef struct
60
ATTR_PACKED
61
_WAVEFORMATEX {
Gildas Bazin's avatar
 
Gildas Bazin committed
62 63 64 65 66 67 68 69 70 71
    uint16_t   wFormatTag;
    uint16_t   nChannels;
    uint32_t   nSamplesPerSec;
    uint32_t   nAvgBytesPerSec;
    uint16_t   nBlockAlign;
    uint16_t   wBitsPerSample;
    uint16_t   cbSize;
} WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
#endif /* _WAVEFORMATEX_ */

Gildas Bazin's avatar
 
Gildas Bazin committed
72 73 74
#ifndef _WAVEFORMATEXTENSIBLE_
#define _WAVEFORMATEXTENSIBLE_
typedef struct
75
ATTR_PACKED
Gildas Bazin's avatar
 
Gildas Bazin committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
_WAVEFORMATEXTENSIBLE {
    WAVEFORMATEX Format;
    union {
        uint16_t wValidBitsPerSample;
        uint16_t wSamplesPerBlock;
        uint16_t wReserved;
    } Samples;
    uint32_t     dwChannelMask;
    GUID SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
#endif /* _WAVEFORMATEXTENSIBLE_ */

#ifndef _WAVEHEADER_
#define _WAVEHEADER_
typedef struct
91
ATTR_PACKED
Gildas Bazin's avatar
 
Gildas Bazin committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
_WAVEHEADER {
    uint32_t MainChunkID;
    uint32_t Length;
    uint32_t ChunkTypeID;
    uint32_t SubChunkID;
    uint32_t SubChunkLength;
    uint16_t Format;
    uint16_t Modus;
    uint32_t SampleFreq;
    uint32_t BytesPerSec;
    uint16_t BytesPerSample;
    uint16_t BitsPerSample;
    uint32_t DataChunkID;
    uint32_t DataLength;
} WAVEHEADER;
#endif /* _WAVEHEADER_ */

Gildas Bazin's avatar
 
Gildas Bazin committed
109
#if !defined(_BITMAPINFOHEADER_) && !defined(WIN32)
Gildas Bazin's avatar
 
Gildas Bazin committed
110
#define _BITMAPINFOHEADER_
111
typedef struct
112
ATTR_PACKED
Gildas Bazin's avatar
 
Gildas Bazin committed
113 114 115 116 117 118 119 120 121 122 123 124 125
{
    uint32_t   biSize;
    uint32_t   biWidth;
    uint32_t   biHeight;
    uint16_t   biPlanes;
    uint16_t   biBitCount;
    uint32_t   biCompression;
    uint32_t   biSizeImage;
    uint32_t   biXPelsPerMeter;
    uint32_t   biYPelsPerMeter;
    uint32_t   biClrUsed;
    uint32_t   biClrImportant;
} BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER;
126 127

typedef struct
128
ATTR_PACKED
129
{
Gildas Bazin's avatar
 
Gildas Bazin committed
130 131 132 133 134
    BITMAPINFOHEADER bmiHeader;
    int        bmiColors[1];
} BITMAPINFO, *LPBITMAPINFO;
#endif

135 136
#ifndef _RECT32_
#define _RECT32_
137
typedef struct
138
ATTR_PACKED
139 140 141
{
    int left, top, right, bottom;
} RECT32;
142
#endif
143

144 145
#ifndef _REFERENCE_TIME_
#define _REFERENCE_TIME_
146
typedef int64_t REFERENCE_TIME;
147
#endif
148

149 150
#ifndef _VIDEOINFOHEADER_
#define _VIDEOINFOHEADER_
151
typedef struct
152
ATTR_PACKED
153
{
154 155 156 157 158 159 160
    RECT32            rcSource;
    RECT32            rcTarget;
    uint32_t          dwBitRate;
    uint32_t          dwBitErrorRate;
    REFERENCE_TIME    AvgTimePerFrame;
    BITMAPINFOHEADER  bmiHeader;
} VIDEOINFOHEADER;
161
#endif
162

163 164 165
#ifndef _RGBQUAD_
#define _RGBQUAD_
typedef struct
166
ATTR_PACKED
167 168 169 170 171 172 173 174 175 176 177
{
    uint8_t rgbBlue;
    uint8_t rgbGreen;
    uint8_t rgbRed;
    uint8_t rgbReserved;
} RGBQUAD1;
#endif

#ifndef _TRUECOLORINFO_
#define _TRUECOLORINFO_
typedef struct
178
ATTR_PACKED
179 180 181 182 183 184 185 186 187
{
    uint32_t dwBitMasks[3];
    RGBQUAD1 bmiColors[256];
} TRUECOLORINFO;
#endif

#ifndef _VIDEOINFO_
#define _VIDEOINFO_
typedef struct
188
ATTR_PACKED
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
{
    RECT32            rcSource;
    RECT32            rcTarget;
    uint32_t          dwBitRate;
    uint32_t          dwBitErrorRate;
    REFERENCE_TIME    AvgTimePerFrame;
    BITMAPINFOHEADER  bmiHeader;

    union
    {
        RGBQUAD1 bmiColors[256]; /* Colour palette */
        uint32_t dwBitMasks[3]; /* True colour masks */
        TRUECOLORINFO TrueColorInfo; /* Both of the above */
    };

} VIDEOINFO;
#endif

207 208 209 210
#if defined(__SUNPRO_C)
#   pragma pack()
#endif

Gildas Bazin's avatar
 
Gildas Bazin committed
211
/* WAVE format wFormatTag IDs */
212
/* See http://msdn.microsoft.com/en-us/library/aa904731%28v=vs.80%29.aspx */
213 214 215 216 217 218
#define WAVE_FORMAT_UNKNOWN             0x0000 /* Microsoft Corporation */
#define WAVE_FORMAT_PCM                 0x0001 /* Microsoft Corporation */
#define WAVE_FORMAT_ADPCM               0x0002 /* Microsoft Corporation */
#define WAVE_FORMAT_IEEE_FLOAT          0x0003 /* Microsoft Corporation */
#define WAVE_FORMAT_ALAW                0x0006 /* Microsoft Corporation */
#define WAVE_FORMAT_MULAW               0x0007 /* Microsoft Corporation */
Derk-Jan Hartman's avatar
Derk-Jan Hartman committed
219
#define WAVE_FORMAT_DTS_MS              0x0008 /* Microsoft Corporation */
220
#define WAVE_FORMAT_WMAS                0x000a /* WMA 9 Speech */
221
#define WAVE_FORMAT_IMA_ADPCM           0x0011 /* Intel Corporation */
222
#define WAVE_FORMAT_TRUESPEECH          0x0022 /* TrueSpeech */
223 224
#define WAVE_FORMAT_GSM610              0x0031 /* Microsoft Corporation */
#define WAVE_FORMAT_MSNAUDIO            0x0032 /* Microsoft Corporation */
225
#define WAVE_FORMAT_G726                0x0045 /* ITU-T standard  */
226 227
#define WAVE_FORMAT_MPEG                0x0050 /* Microsoft Corporation */
#define WAVE_FORMAT_MPEGLAYER3          0x0055 /* ISO/MPEG Layer3 Format Tag */
228 229
#define WAVE_FORMAT_AMR_NB              0x0057 /* AMR NB */
#define WAVE_FORMAT_AMR_WB              0x0058 /* AMR Wideband */
230
#define WAVE_FORMAT_DOLBY_AC3_SPDIF     0x0092 /* Sonic Foundry */
Gildas Bazin's avatar
 
Gildas Bazin committed
231

232 233 234
#define WAVE_FORMAT_AAC                 0x00FF /* */
#define WAVE_FORMAT_SIPRO               0x0130 /* Sipro Lab Telecom Inc. */

235 236 237 238
#define WAVE_FORMAT_WMA1                0x0160 /* WMA version 1 */
#define WAVE_FORMAT_WMA2                0x0161 /* WMA (v2) 7, 8, 9 Series */
#define WAVE_FORMAT_WMAP                0x0162 /* WMA 9 Professional */
#define WAVE_FORMAT_WMAL                0x0163 /* WMA 9 Lossless */
239

240 241 242
#define WAVE_FORMAT_AAC_2               0x1601 /* Other AAC */
#define WAVE_FORMAT_AAC_LATM            0x1602 /* AAC/LATM */

243 244
#define WAVE_FORMAT_A52                 0x2000 /* a52 */
#define WAVE_FORMAT_DTS                 0x2001 /* DTS */
Laurent Aimar's avatar
Laurent Aimar committed
245
#define WAVE_FORMAT_FFMPEG_AAC          0x706D
246
#define WAVE_FORMAT_DIVIO_AAC           0x4143 /* Divio's AAC */
Gildas Bazin's avatar
 
Gildas Bazin committed
247

248
/* Need to check these */
Sam Hocevar's avatar
Sam Hocevar committed
249 250
#define WAVE_FORMAT_DK3                 0x0061
#define WAVE_FORMAT_DK4                 0x0062
251

252 253 254 255 256 257 258 259 260 261 262
/* At least FFmpeg use that ID: from libavformat/riff.c ('Vo' == 0x566f)
 * { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id?
 */
#define WAVE_FORMAT_VORBIS              0x566f

/* It seems that these IDs are used by braindead & obsolete VorbisACM encoder
 * (Windows only)
 * A few info is available except VorbisACM source (remember, Windows only)
 * (available on http://svn.xiph.org), but it seems that vo3+ at least is
 * made of Vorbis data encapsulated in Ogg container...
 */
263 264 265
#define WAVE_FORMAT_VORB_1              0x674f
#define WAVE_FORMAT_VORB_2              0x6750
#define WAVE_FORMAT_VORB_3              0x6751
266 267
#define WAVE_FORMAT_VORB_1PLUS          0x676f
#define WAVE_FORMAT_VORB_2PLUS          0x6770
268
#define WAVE_FORMAT_VORB_3PLUS          0x6771
269

270
#define WAVE_FORMAT_SPEEX               0xa109 /* Speex audio */
271

Gildas Bazin's avatar
 
Gildas Bazin committed
272
#if !defined(WAVE_FORMAT_EXTENSIBLE)
273
  #define WAVE_FORMAT_EXTENSIBLE          0xFFFE /* Microsoft */
Gildas Bazin's avatar
 
Gildas Bazin committed
274 275
#endif

276 277 278 279 280 281 282 283 284 285
/* 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

286
#ifndef _KSDATAFORMAT_SUBTYPE_UNKNOWN_
287 288 289 290 291
#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

Gildas Bazin's avatar
 
Gildas Bazin committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
/* Microsoft speaker definitions */
#define WAVE_SPEAKER_FRONT_LEFT             0x1
#define WAVE_SPEAKER_FRONT_RIGHT            0x2
#define WAVE_SPEAKER_FRONT_CENTER           0x4
#define WAVE_SPEAKER_LOW_FREQUENCY          0x8
#define WAVE_SPEAKER_BACK_LEFT              0x10
#define WAVE_SPEAKER_BACK_RIGHT             0x20
#define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER   0x40
#define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER  0x80
#define WAVE_SPEAKER_BACK_CENTER            0x100
#define WAVE_SPEAKER_SIDE_LEFT              0x200
#define WAVE_SPEAKER_SIDE_RIGHT             0x400
#define WAVE_SPEAKER_TOP_CENTER             0x800
#define WAVE_SPEAKER_TOP_FRONT_LEFT         0x1000
#define WAVE_SPEAKER_TOP_FRONT_CENTER       0x2000
#define WAVE_SPEAKER_TOP_FRONT_RIGHT        0x4000
#define WAVE_SPEAKER_TOP_BACK_LEFT          0x8000
#define WAVE_SPEAKER_TOP_BACK_CENTER        0x10000
#define WAVE_SPEAKER_TOP_BACK_RIGHT         0x20000
#define WAVE_SPEAKER_RESERVED               0x80000000

313
static const struct
314 315 316
{
    uint16_t     i_tag;
    vlc_fourcc_t i_fourcc;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
317
    const char  *psz_name;
318 319 320
}
wave_format_tag_to_fourcc[] =
{
321
    { WAVE_FORMAT_PCM,        VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" },
322 323 324 325
    { WAVE_FORMAT_PCM,        VLC_CODEC_S8,                     "PCM S8 audio" },
    { WAVE_FORMAT_PCM,        VLC_CODEC_S16L,                   "PCM S16L audio" },
    { WAVE_FORMAT_PCM,        VLC_CODEC_S24L,                   "PCM S24L audio" },
    { WAVE_FORMAT_PCM,        VLC_CODEC_S32L,                   "PCM S32L audio" },
326
    { WAVE_FORMAT_ADPCM,      VLC_CODEC_ADPCM_MS,               "ADPCM" },
Gildas Bazin's avatar
 
Gildas Bazin committed
327
    { WAVE_FORMAT_IEEE_FLOAT, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" },
328 329
    { WAVE_FORMAT_IEEE_FLOAT, VLC_CODEC_F32L,                   "PCM 32 (Float) audio" },
    { WAVE_FORMAT_IEEE_FLOAT, VLC_CODEC_F64L,                   "PCM 64 (Float) audio" },
330 331
    { WAVE_FORMAT_ALAW,       VLC_CODEC_ALAW,                   "A-Law" },
    { WAVE_FORMAT_MULAW,      VLC_CODEC_MULAW,                  "Mu-Law" },
332
    { WAVE_FORMAT_IMA_ADPCM,  VLC_CODEC_ADPCM_IMA_WAV,          "Ima-ADPCM" },
333
    { WAVE_FORMAT_TRUESPEECH, VLC_FOURCC(0x22, 0x0, 0x0, 0x0 ), "Truespeech" },
334 335 336 337
    { WAVE_FORMAT_GSM610,     VLC_CODEC_GSM_MS,                 "Microsoft WAV GSM" },
    { WAVE_FORMAT_G726,       VLC_CODEC_ADPCM_G726,             "G.726 ADPCM" },
    { WAVE_FORMAT_MPEGLAYER3, VLC_CODEC_MPGA,                   "Mpeg Audio" },
    { WAVE_FORMAT_MPEG,       VLC_CODEC_MPGA,                   "Mpeg Audio" },
338 339 340
    { WAVE_FORMAT_AMR_NB,     VLC_CODEC_AMR_NB,                 "AMR NB" },
    { WAVE_FORMAT_AMR_WB,     VLC_CODEC_AMR_WB,                 "AMR Wideband" },
    { WAVE_FORMAT_SIPRO,      VLC_CODEC_SIPR,                   "Sipr Audio" },
341 342 343 344 345 346
    { WAVE_FORMAT_A52,        VLC_CODEC_A52,                    "A/52" },
    { WAVE_FORMAT_WMA1,       VLC_CODEC_WMA1,                   "Window Media Audio v1" },
    { WAVE_FORMAT_WMA2,       VLC_CODEC_WMA2,                   "Window Media Audio v2" },
    { WAVE_FORMAT_WMAP,       VLC_CODEC_WMAP,                   "Window Media Audio 9 Professional" },
    { WAVE_FORMAT_WMAL,       VLC_CODEC_WMAL,                   "Window Media Audio 9 Lossless" },
    { WAVE_FORMAT_WMAS,       VLC_CODEC_WMAS,                   "Window Media Audio 9 Speech" },
347 348
    { WAVE_FORMAT_DK3,        VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" },
    { WAVE_FORMAT_DK4,        VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" },
349 350 351 352
    { WAVE_FORMAT_DTS,        VLC_CODEC_DTS,                    "DTS Coherent Acoustics" },
    { WAVE_FORMAT_DTS_MS,     VLC_CODEC_DTS,                    "DTS Coherent Acoustics" },
    { WAVE_FORMAT_DIVIO_AAC,  VLC_CODEC_MP4A,                   "MPEG-4 Audio (Divio)" },
    { WAVE_FORMAT_AAC,        VLC_CODEC_MP4A,                   "MPEG-4 Audio" },
353 354
    { WAVE_FORMAT_AAC_2,      VLC_CODEC_MP4A,                   "MPEG-4 Audio" },
    { WAVE_FORMAT_AAC_LATM,   VLC_CODEC_MP4A,                   "MPEG-4 Audio" },
355 356
    { WAVE_FORMAT_FFMPEG_AAC, VLC_CODEC_MP4A,                   "MPEG-4 Audio" },
    { WAVE_FORMAT_VORBIS,     VLC_CODEC_VORBIS,                 "Vorbis Audio" },
357 358 359 360 361 362
    { WAVE_FORMAT_VORB_1,     VLC_FOURCC( 'v', 'o', 'r', '1' ), "Vorbis 1 Audio" },
    { WAVE_FORMAT_VORB_1PLUS, VLC_FOURCC( 'v', 'o', '1', '+' ), "Vorbis 1+ Audio" },
    { WAVE_FORMAT_VORB_2,     VLC_FOURCC( 'v', 'o', 'r', '2' ), "Vorbis 2 Audio" },
    { WAVE_FORMAT_VORB_2PLUS, VLC_FOURCC( 'v', 'o', '2', '+' ), "Vorbis 2+ Audio" },
    { WAVE_FORMAT_VORB_3,     VLC_FOURCC( 'v', 'o', 'r', '3' ), "Vorbis 3 Audio" },
    { WAVE_FORMAT_VORB_3PLUS, VLC_FOURCC( 'v', 'o', '3', '+' ), "Vorbis 3+ Audio" },
363
    { WAVE_FORMAT_SPEEX,      VLC_CODEC_SPEEX,                  "Speex Audio" },
364
    { WAVE_FORMAT_UNKNOWN,    VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
365 366
};

367
static inline void wf_tag_to_fourcc( uint16_t i_tag, vlc_fourcc_t *fcc,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
368
                                     const char **ppsz_name )
369 370 371 372
{
    int i;
    for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
    {
373
        if( wave_format_tag_to_fourcc[i].i_tag == i_tag ) break;
374
    }
375 376 377 378 379 380 381 382
    if( fcc ) *fcc = wave_format_tag_to_fourcc[i].i_fourcc;
    if( ppsz_name ) *ppsz_name = wave_format_tag_to_fourcc[i].psz_name;
}

static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag )
{
    int i;
    for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
383
    {
384
        if( wave_format_tag_to_fourcc[i].i_fourcc == fcc ) break;
385
    }
386
    if( pi_tag ) *pi_tag = wave_format_tag_to_fourcc[i].i_tag;
387 388
}

389 390 391 392
/* 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
 */
393
static const struct
394 395 396
{
    GUID         guid_tag;
    vlc_fourcc_t i_fourcc;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
397
    const char  *psz_name;
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
}
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,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
413
                                     vlc_fourcc_t *fcc, const char **ppsz_name )
414 415 416
{
    int i;

417
    for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag,
418 419 420 421 422 423 424 425
                          &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;
}

Gildas Bazin's avatar
 
Gildas Bazin committed
426
#endif /* "codecs.h" */