1 /*****************************************************************************
2 * vlc_codecs.h: codec related structures needed by the demuxers and decoders
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VLC authors and VideoLAN
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 *****************************************************************************/
25 #define VLC_CODECS_H 1
27 #include <vlc_fourcc.h>
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)
43 } GUID
, *REFGUID
, *LPGUID
;
44 #endif /* GUID_DEFINED */
48 #ifdef HAVE_ATTRIBUTE_PACKED
49 # define ATTR_PACKED __attribute__((__packed__))
50 #elif defined(__SUNPRO_C)
57 #ifndef _WAVEFORMATEX_
58 #define _WAVEFORMATEX_
64 uint32_t nSamplesPerSec
;
65 uint32_t nAvgBytesPerSec
;
67 uint16_t wBitsPerSample
;
69 } WAVEFORMATEX
, *PWAVEFORMATEX
, *NPWAVEFORMATEX
, *LPWAVEFORMATEX
;
70 #endif /* _WAVEFORMATEX_ */
72 #ifndef _WAVEFORMATEXTENSIBLE_
73 #define _WAVEFORMATEXTENSIBLE_
76 _WAVEFORMATEXTENSIBLE
{
79 uint16_t wValidBitsPerSample
;
80 uint16_t wSamplesPerBlock
;
83 uint32_t dwChannelMask
;
85 } WAVEFORMATEXTENSIBLE
, *PWAVEFORMATEXTENSIBLE
;
86 #endif /* _WAVEFORMATEXTENSIBLE_ */
97 uint32_t SubChunkLength
;
101 uint32_t BytesPerSec
;
102 uint16_t BytesPerSample
;
103 uint16_t BitsPerSample
;
104 uint32_t DataChunkID
;
107 #endif /* _WAVEHEADER_ */
109 #ifndef _VLC_BITMAPINFOHEADER_
110 #define _VLC_BITMAPINFOHEADER_
120 uint32_t biCompression
;
121 uint32_t biSizeImage
;
122 uint32_t biXPelsPerMeter
;
123 uint32_t biYPelsPerMeter
;
125 uint32_t biClrImportant
;
126 } VLC_BITMAPINFOHEADER
, *VLC_PBITMAPINFOHEADER
, *VLC_LPBITMAPINFOHEADER
;
131 VLC_BITMAPINFOHEADER bmiHeader
;
133 } VLC_BITMAPINFO
, *VLC_LPBITMAPINFO
;
141 int left
, top
, right
, bottom
;
145 #ifndef _REFERENCE_TIME_
146 #define _REFERENCE_TIME_
147 typedef int64_t REFERENCE_TIME
;
150 #ifndef _VIDEOINFOHEADER_
151 #define _VIDEOINFOHEADER_
158 uint32_t dwBitErrorRate
;
159 REFERENCE_TIME AvgTimePerFrame
;
160 VLC_BITMAPINFOHEADER bmiHeader
;
176 #ifndef _TRUECOLORINFO_
177 #define _TRUECOLORINFO_
181 uint32_t dwBitMasks
[3];
182 RGBQUAD1 bmiColors
[256];
194 uint32_t dwBitErrorRate
;
195 REFERENCE_TIME AvgTimePerFrame
;
196 VLC_BITMAPINFOHEADER bmiHeader
;
200 RGBQUAD1 bmiColors
[256]; /* Colour palette */
201 uint32_t dwBitMasks
[3]; /* True colour masks */
202 TRUECOLORINFO TrueColorInfo
; /* Both of the above */
208 #if defined(__SUNPRO_C)
212 /* WAVE format wFormatTag IDs */
213 /* See http://msdn.microsoft.com/en-us/library/aa904731%28v=vs.80%29.aspx */
214 #define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */
215 #define WAVE_FORMAT_PCM 0x0001 /* Microsoft Corporation */
216 #define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */
217 #define WAVE_FORMAT_IEEE_FLOAT 0x0003 /* Microsoft Corporation */
218 #define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */
219 #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */
220 #define WAVE_FORMAT_DTS_MS 0x0008 /* Microsoft Corporation */
221 #define WAVE_FORMAT_WMAS 0x000a /* WMA 9 Speech */
222 #define WAVE_FORMAT_IMA_ADPCM 0x0011 /* Intel Corporation */
223 #define WAVE_FORMAT_TRUESPEECH 0x0022 /* TrueSpeech */
224 #define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */
225 #define WAVE_FORMAT_MSNAUDIO 0x0032 /* Microsoft Corporation */
226 #define WAVE_FORMAT_G726 0x0045 /* ITU-T standard */
227 #define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */
228 #define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */
229 #define WAVE_FORMAT_AMR_NB 0x0057 /* AMR NB */
230 #define WAVE_FORMAT_AMR_WB 0x0058 /* AMR Wideband */
231 #define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */
233 #define WAVE_FORMAT_AAC 0x00FF /* */
234 #define WAVE_FORMAT_SIPRO 0x0130 /* Sipro Lab Telecom Inc. */
236 #define WAVE_FORMAT_WMA1 0x0160 /* WMA version 1 */
237 #define WAVE_FORMAT_WMA2 0x0161 /* WMA (v2) 7, 8, 9 Series */
238 #define WAVE_FORMAT_WMAP 0x0162 /* WMA 9 Professional */
239 #define WAVE_FORMAT_WMAL 0x0163 /* WMA 9 Lossless */
241 #define WAVE_FORMAT_AAC_2 0x1601 /* Other AAC */
242 #define WAVE_FORMAT_AAC_LATM 0x1602 /* AAC/LATM */
244 #define WAVE_FORMAT_A52 0x2000 /* a52 */
245 #define WAVE_FORMAT_DTS 0x2001 /* DTS */
246 #define WAVE_FORMAT_FFMPEG_AAC 0x706D
247 #define WAVE_FORMAT_DIVIO_AAC 0x4143 /* Divio's AAC */
249 /* Need to check these */
250 #define WAVE_FORMAT_DK3 0x0061
251 #define WAVE_FORMAT_DK4 0x0062
253 /* At least FFmpeg use that ID: from libavformat/riff.c ('Vo' == 0x566f)
254 * { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id?
256 #define WAVE_FORMAT_VORBIS 0x566f
258 /* It seems that these IDs are used by braindead & obsolete VorbisACM encoder
260 * A few info is available except VorbisACM source (remember, Windows only)
261 * (available on http://svn.xiph.org), but it seems that vo3+ at least is
262 * made of Vorbis data encapsulated in Ogg container...
264 #define WAVE_FORMAT_VORB_1 0x674f
265 #define WAVE_FORMAT_VORB_2 0x6750
266 #define WAVE_FORMAT_VORB_3 0x6751
267 #define WAVE_FORMAT_VORB_1PLUS 0x676f
268 #define WAVE_FORMAT_VORB_2PLUS 0x6770
269 #define WAVE_FORMAT_VORB_3PLUS 0x6771
271 #define WAVE_FORMAT_SPEEX 0xa109 /* Speex audio */
273 #if !defined(WAVE_FORMAT_EXTENSIBLE)
274 #define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */
277 /* GUID SubFormat IDs */
278 /* We need both b/c const variables are not compile-time constants in C, giving
279 * us an error if we use the const GUID in an enum */
281 #ifndef _KSDATAFORMAT_SUBTYPE_PCM_
282 #define _KSDATAFORMAT_SUBTYPE_PCM_ {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
283 static const GUID VLC_KSDATAFORMAT_SUBTYPE_PCM
= {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}};
284 #define KSDATAFORMAT_SUBTYPE_PCM VLC_KSDATAFORMAT_SUBTYPE_PCM
287 #ifndef _KSDATAFORMAT_SUBTYPE_UNKNOWN_
288 #define _KSDATAFORMAT_SUBTYPE_UNKNOWN_ {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
289 static const GUID VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN
= {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
290 #define KSDATAFORMAT_SUBTYPE_UNKNOWN VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN
293 /* Microsoft speaker definitions */
294 #define WAVE_SPEAKER_FRONT_LEFT 0x1
295 #define WAVE_SPEAKER_FRONT_RIGHT 0x2
296 #define WAVE_SPEAKER_FRONT_CENTER 0x4
297 #define WAVE_SPEAKER_LOW_FREQUENCY 0x8
298 #define WAVE_SPEAKER_BACK_LEFT 0x10
299 #define WAVE_SPEAKER_BACK_RIGHT 0x20
300 #define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER 0x40
301 #define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
302 #define WAVE_SPEAKER_BACK_CENTER 0x100
303 #define WAVE_SPEAKER_SIDE_LEFT 0x200
304 #define WAVE_SPEAKER_SIDE_RIGHT 0x400
305 #define WAVE_SPEAKER_TOP_CENTER 0x800
306 #define WAVE_SPEAKER_TOP_FRONT_LEFT 0x1000
307 #define WAVE_SPEAKER_TOP_FRONT_CENTER 0x2000
308 #define WAVE_SPEAKER_TOP_FRONT_RIGHT 0x4000
309 #define WAVE_SPEAKER_TOP_BACK_LEFT 0x8000
310 #define WAVE_SPEAKER_TOP_BACK_CENTER 0x10000
311 #define WAVE_SPEAKER_TOP_BACK_RIGHT 0x20000
312 #define WAVE_SPEAKER_RESERVED 0x80000000
317 vlc_fourcc_t i_fourcc
;
318 const char *psz_name
;
320 wave_format_tag_to_fourcc
[] =
322 { WAVE_FORMAT_PCM
, VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" },
323 { WAVE_FORMAT_PCM
, VLC_CODEC_S8
, "PCM S8 audio" },
324 { WAVE_FORMAT_PCM
, VLC_CODEC_S16L
, "PCM S16L audio" },
325 { WAVE_FORMAT_PCM
, VLC_CODEC_S24L
, "PCM S24L audio" },
326 { WAVE_FORMAT_PCM
, VLC_CODEC_S32L
, "PCM S32L audio" },
327 { WAVE_FORMAT_ADPCM
, VLC_CODEC_ADPCM_MS
, "ADPCM" },
328 { WAVE_FORMAT_IEEE_FLOAT
, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" },
329 { WAVE_FORMAT_IEEE_FLOAT
, VLC_CODEC_F32L
, "PCM 32 (Float) audio" },
330 { WAVE_FORMAT_IEEE_FLOAT
, VLC_CODEC_F64L
, "PCM 64 (Float) audio" },
331 { WAVE_FORMAT_ALAW
, VLC_CODEC_ALAW
, "A-Law" },
332 { WAVE_FORMAT_MULAW
, VLC_CODEC_MULAW
, "Mu-Law" },
333 { WAVE_FORMAT_IMA_ADPCM
, VLC_CODEC_ADPCM_IMA_WAV
, "Ima-ADPCM" },
334 { WAVE_FORMAT_TRUESPEECH
, VLC_FOURCC(0x22, 0x0, 0x0, 0x0 ), "Truespeech" },
335 { WAVE_FORMAT_GSM610
, VLC_CODEC_GSM_MS
, "Microsoft WAV GSM" },
336 { WAVE_FORMAT_G726
, VLC_CODEC_ADPCM_G726
, "G.726 ADPCM" },
337 { WAVE_FORMAT_MPEGLAYER3
, VLC_CODEC_MPGA
, "Mpeg Audio" },
338 { WAVE_FORMAT_MPEG
, VLC_CODEC_MPGA
, "Mpeg Audio" },
339 { WAVE_FORMAT_AMR_NB
, VLC_CODEC_AMR_NB
, "AMR NB" },
340 { WAVE_FORMAT_AMR_WB
, VLC_CODEC_AMR_WB
, "AMR Wideband" },
341 { WAVE_FORMAT_SIPRO
, VLC_CODEC_SIPR
, "Sipr Audio" },
342 { WAVE_FORMAT_A52
, VLC_CODEC_A52
, "A/52" },
343 { WAVE_FORMAT_WMA1
, VLC_CODEC_WMA1
, "Window Media Audio v1" },
344 { WAVE_FORMAT_WMA2
, VLC_CODEC_WMA2
, "Window Media Audio v2" },
345 { WAVE_FORMAT_WMAP
, VLC_CODEC_WMAP
, "Window Media Audio 9 Professional" },
346 { WAVE_FORMAT_WMAL
, VLC_CODEC_WMAL
, "Window Media Audio 9 Lossless" },
347 { WAVE_FORMAT_WMAS
, VLC_CODEC_WMAS
, "Window Media Audio 9 Speech" },
348 { WAVE_FORMAT_DK3
, VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" },
349 { WAVE_FORMAT_DK4
, VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" },
350 { WAVE_FORMAT_DTS
, VLC_CODEC_DTS
, "DTS Coherent Acoustics" },
351 { WAVE_FORMAT_DTS_MS
, VLC_CODEC_DTS
, "DTS Coherent Acoustics" },
352 { WAVE_FORMAT_DIVIO_AAC
, VLC_CODEC_MP4A
, "MPEG-4 Audio (Divio)" },
353 { WAVE_FORMAT_AAC
, VLC_CODEC_MP4A
, "MPEG-4 Audio" },
354 { WAVE_FORMAT_AAC_2
, VLC_CODEC_MP4A
, "MPEG-4 Audio" },
355 { WAVE_FORMAT_AAC_LATM
, VLC_CODEC_MP4A
, "MPEG-4 Audio" },
356 { WAVE_FORMAT_FFMPEG_AAC
, VLC_CODEC_MP4A
, "MPEG-4 Audio" },
357 { WAVE_FORMAT_VORBIS
, VLC_CODEC_VORBIS
, "Vorbis Audio" },
358 { WAVE_FORMAT_VORB_1
, VLC_FOURCC( 'v', 'o', 'r', '1' ), "Vorbis 1 Audio" },
359 { WAVE_FORMAT_VORB_1PLUS
, VLC_FOURCC( 'v', 'o', '1', '+' ), "Vorbis 1+ Audio" },
360 { WAVE_FORMAT_VORB_2
, VLC_FOURCC( 'v', 'o', 'r', '2' ), "Vorbis 2 Audio" },
361 { WAVE_FORMAT_VORB_2PLUS
, VLC_FOURCC( 'v', 'o', '2', '+' ), "Vorbis 2+ Audio" },
362 { WAVE_FORMAT_VORB_3
, VLC_FOURCC( 'v', 'o', 'r', '3' ), "Vorbis 3 Audio" },
363 { WAVE_FORMAT_VORB_3PLUS
, VLC_FOURCC( 'v', 'o', '3', '+' ), "Vorbis 3+ Audio" },
364 { WAVE_FORMAT_SPEEX
, VLC_CODEC_SPEEX
, "Speex Audio" },
365 { WAVE_FORMAT_UNKNOWN
, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
368 static inline void wf_tag_to_fourcc( uint16_t i_tag
, vlc_fourcc_t
*fcc
,
369 const char **ppsz_name
)
372 for( i
= 0; wave_format_tag_to_fourcc
[i
].i_tag
!= 0; i
++ )
374 if( wave_format_tag_to_fourcc
[i
].i_tag
== i_tag
) break;
376 if( fcc
) *fcc
= wave_format_tag_to_fourcc
[i
].i_fourcc
;
377 if( ppsz_name
) *ppsz_name
= wave_format_tag_to_fourcc
[i
].psz_name
;
380 static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc
, uint16_t *pi_tag
)
383 for( i
= 0; wave_format_tag_to_fourcc
[i
].i_tag
!= 0; i
++ )
385 if( wave_format_tag_to_fourcc
[i
].i_fourcc
== fcc
) break;
387 if( pi_tag
) *pi_tag
= wave_format_tag_to_fourcc
[i
].i_tag
;
390 /* If wFormatTag is WAVEFORMATEXTENSIBLE, we must look at the SubFormat tag
391 * to determine the actual format. Microsoft has stopped giving out wFormatTag
392 * assignments in lieu of letting 3rd parties generate their own GUIDs
397 vlc_fourcc_t i_fourcc
;
398 const char *psz_name
;
400 sub_format_tag_to_fourcc
[] =
402 { _KSDATAFORMAT_SUBTYPE_PCM_
, VLC_FOURCC( 'p', 'c', 'm', ' ' ), "PCM" },
403 { _KSDATAFORMAT_SUBTYPE_UNKNOWN_
, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
406 /* compares two GUIDs, returns 1 if identical, 0 otherwise */
407 static inline int guidcmp( const GUID
*s1
, const GUID
*s2
)
409 return( s1
->Data1
== s2
->Data1
&& s1
->Data2
== s2
->Data2
&&
410 s1
->Data3
== s2
->Data3
&& !memcmp( s1
->Data4
, s2
->Data4
, 8 ) );
413 static inline void sf_tag_to_fourcc( GUID
*guid_tag
,
414 vlc_fourcc_t
*fcc
, const char **ppsz_name
)
418 for( i
= 0; !guidcmp( &sub_format_tag_to_fourcc
[i
].guid_tag
,
419 &KSDATAFORMAT_SUBTYPE_UNKNOWN
); i
++ )
421 if( guidcmp( &sub_format_tag_to_fourcc
[i
].guid_tag
, guid_tag
) ) break;
423 if( fcc
) *fcc
= sub_format_tag_to_fourcc
[i
].i_fourcc
;
424 if( ppsz_name
) *ppsz_name
= sub_format_tag_to_fourcc
[i
].psz_name
;
427 #endif /* "codecs.h" */