bluray: factorize blurayReleaseVout()
[vlc.git] / include / vlc_codecs.h
blob5721c1ec28fd7ea79b35763ecb737193316c0bfd
1 /*****************************************************************************
2 * vlc_codecs.h: codec related structures needed by the demuxers and decoders
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VLC authors and VideoLAN
5 * $Id$
7 * Author: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef VLC_CODECS_H
25 #define VLC_CODECS_H 1
27 #include <vlc_fourcc.h>
28 /**
29 * \file
30 * This file defines codec related structures needed by the demuxers and decoders
33 /* Structures exported to the demuxers and decoders */
35 #if !(defined _GUID_DEFINED || defined GUID_DEFINED)
36 #define GUID_DEFINED
37 typedef struct _GUID
39 uint32_t Data1;
40 uint16_t Data2;
41 uint16_t Data3;
42 uint8_t Data4[8];
43 } GUID, *REFGUID, *LPGUID;
44 #endif /* GUID_DEFINED */
46 typedef GUID guid_t;
48 #ifdef HAVE_ATTRIBUTE_PACKED
49 # define ATTR_PACKED __attribute__((__packed__))
50 #elif defined(__SUNPRO_C) || defined(_MSC_VER)
51 # pragma pack(1)
52 # define ATTR_PACKED
53 #elif defined(__APPLE__)
54 # pragma pack(push, 1)
55 # define ATTR_PACKED
56 #else
57 # error FIXME
58 #endif
60 #ifndef _WAVEFORMATEX_
61 #define _WAVEFORMATEX_
62 typedef struct
63 ATTR_PACKED
64 _WAVEFORMATEX {
65 uint16_t wFormatTag;
66 uint16_t nChannels;
67 uint32_t nSamplesPerSec;
68 uint32_t nAvgBytesPerSec;
69 uint16_t nBlockAlign;
70 uint16_t wBitsPerSample;
71 uint16_t cbSize;
72 } WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
73 #endif /* _WAVEFORMATEX_ */
75 #ifndef _WAVEFORMATEXTENSIBLE_
76 #define _WAVEFORMATEXTENSIBLE_
77 typedef struct
78 ATTR_PACKED
79 _WAVEFORMATEXTENSIBLE {
80 WAVEFORMATEX Format;
81 union {
82 uint16_t wValidBitsPerSample; /* bits of precision */
83 uint16_t wSamplesPerBlock; /* valid if wBitsPerSample==0 */
84 uint16_t wReserved; /* If neither applies, set to zero. */
85 } Samples;
87 uint32_t dwChannelMask; /* Channels present */
89 GUID SubFormat;
90 } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
91 #endif /* _WAVEFORMATEXTENSIBLE_ */
93 #ifndef _WAVEHEADER_
94 #define _WAVEHEADER_
95 typedef struct
96 ATTR_PACKED
97 _WAVEHEADER {
98 uint32_t MainChunkID;
99 uint32_t Length;
100 uint32_t ChunkTypeID;
101 uint32_t SubChunkID;
102 uint32_t SubChunkLength;
103 uint16_t Format;
104 uint16_t Modus;
105 uint32_t SampleFreq;
106 uint32_t BytesPerSec;
107 uint16_t BytesPerSample;
108 uint16_t BitsPerSample;
109 uint32_t DataChunkID;
110 uint32_t DataLength;
111 } WAVEHEADER;
112 #endif /* _WAVEHEADER_ */
114 #ifndef _VLC_BITMAPINFOHEADER_
115 #define _VLC_BITMAPINFOHEADER_
117 typedef struct
118 ATTR_PACKED
120 uint32_t biSize;
121 uint32_t biWidth;
122 uint32_t biHeight;
123 uint16_t biPlanes;
124 uint16_t biBitCount;
125 uint32_t biCompression;
126 uint32_t biSizeImage;
127 uint32_t biXPelsPerMeter;
128 uint32_t biYPelsPerMeter;
129 uint32_t biClrUsed;
130 uint32_t biClrImportant;
131 } VLC_BITMAPINFOHEADER, *VLC_PBITMAPINFOHEADER, *VLC_LPBITMAPINFOHEADER;
133 typedef struct
134 ATTR_PACKED
136 VLC_BITMAPINFOHEADER bmiHeader;
137 int bmiColors[1];
138 } VLC_BITMAPINFO, *VLC_LPBITMAPINFO;
139 #endif
141 #ifndef _RECT32_
142 #define _RECT32_
143 typedef struct
144 ATTR_PACKED
146 int left, top, right, bottom;
147 } RECT32;
148 #endif
150 #ifndef _REFERENCE_TIME_
151 #define _REFERENCE_TIME_
152 typedef int64_t REFERENCE_TIME;
153 #endif
155 #ifndef _VIDEOINFOHEADER_
156 #define _VIDEOINFOHEADER_
157 typedef struct
158 ATTR_PACKED
160 RECT32 rcSource;
161 RECT32 rcTarget;
162 uint32_t dwBitRate;
163 uint32_t dwBitErrorRate;
164 REFERENCE_TIME AvgTimePerFrame;
165 VLC_BITMAPINFOHEADER bmiHeader;
166 } VIDEOINFOHEADER;
167 #endif
169 #ifndef _RGBQUAD_
170 #define _RGBQUAD_
171 typedef struct
172 ATTR_PACKED
174 uint8_t rgbBlue;
175 uint8_t rgbGreen;
176 uint8_t rgbRed;
177 uint8_t rgbReserved;
178 } RGBQUAD1;
179 #endif
181 #ifndef _TRUECOLORINFO_
182 #define _TRUECOLORINFO_
183 typedef struct
184 ATTR_PACKED
186 uint32_t dwBitMasks[3];
187 RGBQUAD1 bmiColors[256];
188 } TRUECOLORINFO;
189 #endif
191 #ifndef _VIDEOINFO_
192 #define _VIDEOINFO_
193 typedef struct
194 ATTR_PACKED
196 RECT32 rcSource;
197 RECT32 rcTarget;
198 uint32_t dwBitRate;
199 uint32_t dwBitErrorRate;
200 REFERENCE_TIME AvgTimePerFrame;
201 VLC_BITMAPINFOHEADER bmiHeader;
203 union
205 RGBQUAD1 bmiColors[256]; /* Colour palette */
206 uint32_t dwBitMasks[3]; /* True colour masks */
207 TRUECOLORINFO TrueColorInfo; /* Both of the above */
210 } VIDEOINFO;
211 #endif
213 #if defined(__SUNPRO_C) || defined(_MSC_VER)
214 # pragma pack()
215 #elif defined(__APPLE__) && !HAVE_ATTRIBUTE_PACKED
216 # pragma pack(pop)
217 #endif
219 /* WAVE format wFormatTag IDs */
220 /* See http://msdn.microsoft.com/en-us/library/aa904731%28v=vs.80%29.aspx */
221 #define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */
222 #define WAVE_FORMAT_PCM 0x0001 /* Microsoft Corporation */
223 #define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */
224 #define WAVE_FORMAT_IEEE_FLOAT 0x0003 /* Microsoft Corporation */
225 #define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */
226 #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */
227 #define WAVE_FORMAT_DTS_MS 0x0008 /* Microsoft Corporation */
228 #define WAVE_FORMAT_WMAS 0x000a /* WMA 9 Speech */
229 #define WAVE_FORMAT_IMA_ADPCM 0x0011 /* Intel Corporation */
230 #define WAVE_FORMAT_YAMAHA_ADPCM 0x0020 /* Yamaha */
231 #define WAVE_FORMAT_TRUESPEECH 0x0022 /* TrueSpeech */
232 #define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */
233 #define WAVE_FORMAT_MSNAUDIO 0x0032 /* Microsoft Corporation */
234 #define WAVE_FORMAT_AMR_NB_2 0x0038 /* AMR NB rogue */
235 #define WAVE_FORMAT_MSG723 0x0042 /* Microsoft G.723 [G723.1] */
236 #define WAVE_FORMAT_G726 0x0045 /* ITU-T standard */
237 #define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */
238 #define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */
239 #define WAVE_FORMAT_AMR_NB 0x0057 /* AMR NB */
240 #define WAVE_FORMAT_AMR_WB 0x0058 /* AMR Wideband */
241 #define WAVE_FORMAT_G726_ADPCM 0x0064 /* G.726 ADPCM */
242 #define WAVE_FORMAT_VOXWARE_RT29 0x0075 /* VoxWare MetaSound */
243 #define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */
244 #define WAVE_FORMAT_VIVOG723 0x0111 /* Vivo G.723.1 */
246 #define WAVE_FORMAT_AAC 0x00FF /* */
247 #define WAVE_FORMAT_AAC_MS 0xa106 /* Microsoft AAC */
248 #define WAVE_FORMAT_SIPRO 0x0130 /* Sipro Lab Telecom Inc. */
250 #define WAVE_FORMAT_WMA1 0x0160 /* WMA version 1 */
251 #define WAVE_FORMAT_WMA2 0x0161 /* WMA (v2) 7, 8, 9 Series */
252 #define WAVE_FORMAT_WMAP 0x0162 /* WMA 9 Professional */
253 #define WAVE_FORMAT_WMAL 0x0163 /* WMA 9 Lossless */
255 #define WAVE_FORMAT_CREATIVE_ADPCM 0x0200 /* Creative */
257 #define WAVE_FORMAT_ULEAD_DV_AUDIO_NTSC 0x0215 /* Ulead */
258 #define WAVE_FORMAT_ULEAD_DV_AUDIO_PAL 0x0216 /* Ulead */
260 #define WAVE_FORMAT_ATRAC3 0x0270 /* Atrac3, != from MSDN doc */
261 #define WAVE_FORMAT_SONY_ATRAC3 0x0272 /* Atrac3, != from MSDN doc */
263 #define WAVE_FORMAT_IMC 0x0401
264 #define WAVE_FORMAT_INDEO_AUDIO 0x0402 /* Indeo Audio Coder */
266 #define WAVE_FORMAT_ON2_AVC 0x0500 /* VP7 */
267 #define WAVE_FORMAT_ON2_AVC_2 0x0501 /* VP6 */
269 #define WAVE_FORMAT_AAC_2 0x1601 /* Other AAC */
270 #define WAVE_FORMAT_AAC_LATM 0x1602 /* AAC/LATM */
272 #define WAVE_FORMAT_A52 0x2000 /* a52 */
273 #define WAVE_FORMAT_DTS 0x2001 /* DTS */
274 #define WAVE_FORMAT_AVCODEC_AAC 0x706D
275 #define WAVE_FORMAT_DIVIO_AAC 0x4143 /* Divio's AAC */
277 #define WAVE_FORMAT_GSM_AMR_FIXED 0x7A21 /* Fixed bitrate, no SID */
278 #define WAVE_FORMAT_GSM_AMR 0x7A22 /* Variable bitrate, including SID */
280 #define WAVE_FORMAT_DK3 0x0062
281 #define WAVE_FORMAT_DK4 0x0061
283 /* At least libavformat use that ID: from libavformat/riff.c ('Vo' == 0x566f)
284 * { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id?
286 #define WAVE_FORMAT_VORBIS 0x566f
288 /* It seems that these IDs are used by braindead & obsolete VorbisACM encoder
289 * (Windows only)
290 * A few info is available except VorbisACM source (remember, Windows only)
291 * (available on http://svn.xiph.org), but it seems that vo3+ at least is
292 * made of Vorbis data encapsulated in Ogg container...
294 #define WAVE_FORMAT_VORB_1 0x674f
295 #define WAVE_FORMAT_VORB_2 0x6750
296 #define WAVE_FORMAT_VORB_3 0x6751
297 #define WAVE_FORMAT_VORB_1PLUS 0x676f
298 #define WAVE_FORMAT_VORB_2PLUS 0x6770
299 #define WAVE_FORMAT_VORB_3PLUS 0x6771
301 #define WAVE_FORMAT_G723_1 0xa100
302 #define WAVE_FORMAT_AAC_3 0xa106
303 #define WAVE_FORMAT_SPEEX 0xa109 /* Speex audio */
304 #define WAVE_FORMAT_FLAC 0xf1ac /* Xiph Flac */
306 #if !defined(WAVE_FORMAT_EXTENSIBLE)
307 #define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */
308 #endif
310 /* GUID SubFormat IDs */
311 #define VLC_KSDATAFORMAT_SUBTYPE_ATRAC3P {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}} /* Undocumented */
312 #define VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
313 #define VLC_WAVEFORMATEX_GUIDBASE {0x00000000, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} /* Generated from Wave Format */
315 /* Microsoft speaker definitions */
316 #define WAVE_SPEAKER_FRONT_LEFT 0x1
317 #define WAVE_SPEAKER_FRONT_RIGHT 0x2
318 #define WAVE_SPEAKER_FRONT_CENTER 0x4
319 #define WAVE_SPEAKER_LOW_FREQUENCY 0x8
320 #define WAVE_SPEAKER_BACK_LEFT 0x10
321 #define WAVE_SPEAKER_BACK_RIGHT 0x20
322 #define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER 0x40
323 #define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
324 #define WAVE_SPEAKER_BACK_CENTER 0x100
325 #define WAVE_SPEAKER_SIDE_LEFT 0x200
326 #define WAVE_SPEAKER_SIDE_RIGHT 0x400
327 #define WAVE_SPEAKER_TOP_CENTER 0x800
328 #define WAVE_SPEAKER_TOP_FRONT_LEFT 0x1000
329 #define WAVE_SPEAKER_TOP_FRONT_CENTER 0x2000
330 #define WAVE_SPEAKER_TOP_FRONT_RIGHT 0x4000
331 #define WAVE_SPEAKER_TOP_BACK_LEFT 0x8000
332 #define WAVE_SPEAKER_TOP_BACK_CENTER 0x10000
333 #define WAVE_SPEAKER_TOP_BACK_RIGHT 0x20000
334 #define WAVE_SPEAKER_RESERVED 0x80000000
336 static const struct
338 uint16_t i_tag;
339 vlc_fourcc_t i_fourcc;
340 const char *psz_name;
342 wave_format_tag_to_fourcc[] =
344 { WAVE_FORMAT_PCM, VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" },
345 { WAVE_FORMAT_PCM, VLC_CODEC_S8, "PCM S8 audio" },
346 { WAVE_FORMAT_PCM, VLC_CODEC_S16L, "PCM S16L audio" },
347 { WAVE_FORMAT_PCM, VLC_CODEC_S24L, "PCM S24L audio" },
348 { WAVE_FORMAT_PCM, VLC_CODEC_S32L, "PCM S32L audio" },
349 { WAVE_FORMAT_ADPCM, VLC_CODEC_ADPCM_MS, "ADPCM" },
350 { WAVE_FORMAT_IEEE_FLOAT, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" },
351 { WAVE_FORMAT_IEEE_FLOAT, VLC_CODEC_F32L, "PCM 32 (Float) audio" },
352 { WAVE_FORMAT_IEEE_FLOAT, VLC_CODEC_F64L, "PCM 64 (Float) audio" },
353 { WAVE_FORMAT_ALAW, VLC_CODEC_ALAW, "A-Law" },
354 { WAVE_FORMAT_MULAW, VLC_CODEC_MULAW, "Mu-Law" },
355 { WAVE_FORMAT_IMA_ADPCM, VLC_CODEC_ADPCM_IMA_WAV, "Ima-ADPCM" },
356 { WAVE_FORMAT_CREATIVE_ADPCM, VLC_CODEC_ADPCM_CREATIVE, "Creative ADPCM" },
357 { WAVE_FORMAT_YAMAHA_ADPCM, VLC_CODEC_ADPCM_YAMAHA, "Yamaha ADPCM" },
358 { WAVE_FORMAT_TRUESPEECH, VLC_CODEC_TRUESPEECH, "Truespeech" },
359 { WAVE_FORMAT_GSM610, VLC_CODEC_GSM_MS, "Microsoft WAV GSM" },
360 { WAVE_FORMAT_MSNAUDIO, VLC_CODEC_GSM_MS, "Microsoft MSN Audio" },
361 { WAVE_FORMAT_G726, VLC_CODEC_ADPCM_G726, "G.726 ADPCM" },
362 { WAVE_FORMAT_G726_ADPCM, VLC_CODEC_ADPCM_G726, "G.726 ADPCM" },
363 { WAVE_FORMAT_G723_1, VLC_CODEC_G723_1, "G.723.1" },
364 { WAVE_FORMAT_MSG723, VLC_CODEC_G723_1, "Microsoft G.723 [G723.1]" },
365 { WAVE_FORMAT_VIVOG723, VLC_CODEC_G723_1, "Vivo G.723.1" },
366 { WAVE_FORMAT_MPEGLAYER3, VLC_CODEC_MP3, "Mpeg Audio Layer 3" },
367 { WAVE_FORMAT_MPEG, VLC_CODEC_MPGA, "Mpeg Audio" },
368 { WAVE_FORMAT_AMR_NB, VLC_CODEC_AMR_NB, "AMR NB" },
369 { WAVE_FORMAT_AMR_NB_2, VLC_CODEC_AMR_NB, "AMR NB" },
370 { WAVE_FORMAT_AMR_WB, VLC_CODEC_AMR_WB, "AMR Wideband" },
371 { WAVE_FORMAT_SIPRO, VLC_CODEC_SIPR, "Sipr Audio" },
372 { WAVE_FORMAT_A52, VLC_CODEC_A52, "A/52" },
373 { WAVE_FORMAT_WMA1, VLC_CODEC_WMA1, "Window Media Audio v1" },
374 { WAVE_FORMAT_WMA2, VLC_CODEC_WMA2, "Window Media Audio v2" },
375 { WAVE_FORMAT_WMAP, VLC_CODEC_WMAP, "Window Media Audio 9 Professional" },
376 { WAVE_FORMAT_WMAL, VLC_CODEC_WMAL, "Window Media Audio 9 Lossless" },
377 { WAVE_FORMAT_WMAS, VLC_CODEC_WMAS, "Window Media Audio 9 Speech" },
378 { WAVE_FORMAT_ATRAC3, VLC_CODEC_ATRAC3, "Sony Atrac3" },
379 { WAVE_FORMAT_SONY_ATRAC3, VLC_CODEC_ATRAC3, "Sony Atrac3" },
380 { WAVE_FORMAT_DK3, VLC_CODEC_ADPCM_DK3, "Duck DK3" },
381 { WAVE_FORMAT_DK4, VLC_CODEC_ADPCM_DK4, "Duck DK4" },
382 { WAVE_FORMAT_DTS, VLC_CODEC_DTS, "DTS Coherent Acoustics" },
383 { WAVE_FORMAT_DTS_MS, VLC_CODEC_DTS, "DTS Coherent Acoustics" },
384 { WAVE_FORMAT_DIVIO_AAC, VLC_CODEC_MP4A, "MPEG-4 Audio (Divio)" },
385 { WAVE_FORMAT_AAC, VLC_CODEC_MP4A, "MPEG-4 Audio" },
386 { WAVE_FORMAT_AAC_2, VLC_CODEC_MP4A, "MPEG-4 Audio" },
387 { WAVE_FORMAT_AAC_3, VLC_CODEC_MP4A, "MPEG-4 Audio" },
388 { WAVE_FORMAT_AAC_LATM, VLC_CODEC_MP4A, "MPEG-4 Audio" },
389 { WAVE_FORMAT_AVCODEC_AAC, VLC_CODEC_MP4A, "MPEG-4 Audio" },
390 { WAVE_FORMAT_AAC_MS, VLC_CODEC_MP4A, "MPEG-4 Audio" },
391 { WAVE_FORMAT_VORBIS, VLC_CODEC_VORBIS, "Vorbis Audio" },
392 { WAVE_FORMAT_VORB_1, VLC_FOURCC( 'v', 'o', 'r', '1' ), "Vorbis 1 Audio" },
393 { WAVE_FORMAT_VORB_1PLUS, VLC_FOURCC( 'v', 'o', '1', '+' ), "Vorbis 1+ Audio" },
394 { WAVE_FORMAT_VORB_2, VLC_FOURCC( 'v', 'o', 'r', '2' ), "Vorbis 2 Audio" },
395 { WAVE_FORMAT_VORB_2PLUS, VLC_FOURCC( 'v', 'o', '2', '+' ), "Vorbis 2+ Audio" },
396 { WAVE_FORMAT_VORB_3, VLC_FOURCC( 'v', 'o', 'r', '3' ), "Vorbis 3 Audio" },
397 { WAVE_FORMAT_VORB_3PLUS, VLC_FOURCC( 'v', 'o', '3', '+' ), "Vorbis 3+ Audio" },
398 { WAVE_FORMAT_SPEEX, VLC_CODEC_SPEEX, "Speex Audio" },
399 { WAVE_FORMAT_FLAC, VLC_CODEC_FLAC, "FLAC Audio" },
400 { WAVE_FORMAT_GSM_AMR_FIXED, VLC_CODEC_AMR_NB, "GSM-AMR Audio CBR, no SID" },
401 { WAVE_FORMAT_GSM_AMR, VLC_CODEC_AMR_NB, "GSM-AMR Audio VBR, SID" },
402 { WAVE_FORMAT_ULEAD_DV_AUDIO_NTSC, VLC_CODEC_ULEAD_DV_AUDIO_NTSC, "Ulead DV audio NTSC" },
403 { WAVE_FORMAT_ULEAD_DV_AUDIO_PAL, VLC_CODEC_ULEAD_DV_AUDIO_PAL, "Ulead DV audio PAL" },
404 { WAVE_FORMAT_IMC, VLC_CODEC_IMC, "IMC" },
405 { WAVE_FORMAT_INDEO_AUDIO, VLC_CODEC_INDEO_AUDIO, "Indeo Audio Coder" },
406 { WAVE_FORMAT_VOXWARE_RT29, VLC_CODEC_METASOUND, "VoxWare MetaSound" },
407 { WAVE_FORMAT_ON2_AVC, VLC_CODEC_ON2AVC, "On2 Audio for Video Codec (VP7)" },
408 { WAVE_FORMAT_ON2_AVC_2, VLC_CODEC_ON2AVC, "On2 Audio for Video Codec (VP6)" },
410 { WAVE_FORMAT_UNKNOWN, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
413 static inline void wf_tag_to_fourcc( uint16_t i_tag, vlc_fourcc_t *fcc,
414 const char **ppsz_name )
416 int i;
417 for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
419 if( wave_format_tag_to_fourcc[i].i_tag == i_tag ) break;
421 if( fcc ) *fcc = wave_format_tag_to_fourcc[i].i_fourcc;
422 if( ppsz_name ) *ppsz_name = wave_format_tag_to_fourcc[i].psz_name;
425 static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag )
427 int i;
428 for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
430 if( wave_format_tag_to_fourcc[i].i_fourcc == fcc ) break;
432 if( pi_tag ) *pi_tag = wave_format_tag_to_fourcc[i].i_tag;
435 /* If wFormatTag is WAVEFORMATEXTENSIBLE, we must look at the SubFormat tag
436 * to determine the actual format. Microsoft has stopped giving out wFormatTag
437 * assignments in lieu of letting 3rd parties generate their own GUIDs
439 static const struct
441 const GUID guid_tag;
442 const vlc_fourcc_t i_fourcc;
443 const char *psz_name;
445 sub_format_tag_to_fourcc[] =
447 { VLC_KSDATAFORMAT_SUBTYPE_ATRAC3P, VLC_CODEC_ATRAC3P, "Sony Atrac3+" },
448 { VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
451 static inline int guidcmpbase( const GUID *s1, const GUID *s2 )
453 return( s1->Data2 == s2->Data2 &&
454 s1->Data3 == s2->Data3 && !memcmp( s1->Data4, s2->Data4, 8 ) );
457 /* compares two GUIDs, returns 1 if identical, 0 otherwise */
458 static inline int guidcmp( const GUID *s1, const GUID *s2 )
460 return( s1->Data1 == s2->Data1 && guidcmpbase( s1, s2 ) );
463 #define GUID_FMT "0x%x-0x%x-0x%x-0x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x"
464 #define GUID_PRINT( guid ) \
465 (unsigned)(guid).Data1, \
466 (guid).Data2, \
467 (guid).Data3, \
468 (guid).Data4[0],(guid).Data4[1],(guid).Data4[2],(guid).Data4[3], \
469 (guid).Data4[4],(guid).Data4[5],(guid).Data4[6],(guid).Data4[7]
472 static inline void sf_tag_to_fourcc( const GUID *guid_tag,
473 vlc_fourcc_t *fcc, const char **ppsz_name )
475 int i;
476 bool b_found = false;
478 const GUID unknown = VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN;
479 const GUID waveformatex = VLC_WAVEFORMATEX_GUIDBASE;
481 for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag,
482 &unknown ); i++ )
484 if( guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, guid_tag ) )
486 b_found = true;
487 break;
491 if( !b_found && guidcmpbase(guid_tag, &waveformatex) )
493 wf_tag_to_fourcc(guid_tag->Data1, fcc, ppsz_name);
495 else
497 if( fcc ) *fcc = sub_format_tag_to_fourcc[i].i_fourcc;
498 if( ppsz_name ) *ppsz_name = sub_format_tag_to_fourcc[i].psz_name;
502 #endif /* "codecs.h" */