1 /*****************************************************************************
2 * codecs.h: codec related structures needed by the demuxers and decoders
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
7 * Author: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 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 General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 #define _VLC_CODECS_H 1
27 /* Structures exported to the demuxers and decoders */
29 #if !(defined _GUID_DEFINED || defined GUID_DEFINED)
37 } GUID, *REFGUID, *LPGUID;
38 #endif /* GUID_DEFINED */
40 #ifndef _WAVEFORMATEX_
41 #define _WAVEFORMATEX_
43 #ifdef HAVE_ATTRIBUTE_PACKED
44 __attribute__((__packed__))
49 uint32_t nSamplesPerSec;
50 uint32_t nAvgBytesPerSec;
52 uint16_t wBitsPerSample;
54 } WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
55 #endif /* _WAVEFORMATEX_ */
57 #ifndef _WAVEFORMATEXTENSIBLE_
58 #define _WAVEFORMATEXTENSIBLE_
60 #ifdef HAVE_ATTRIBUTE_PACKED
61 __attribute__((__packed__))
63 _WAVEFORMATEXTENSIBLE {
66 uint16_t wValidBitsPerSample;
67 uint16_t wSamplesPerBlock;
70 uint32_t dwChannelMask;
72 } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
73 #endif /* _WAVEFORMATEXTENSIBLE_ */
78 #ifdef HAVE_ATTRIBUTE_PACKED
79 __attribute__((__packed__))
86 uint32_t SubChunkLength;
91 uint16_t BytesPerSample;
92 uint16_t BitsPerSample;
96 #endif /* _WAVEHEADER_ */
98 #if !defined(_BITMAPINFOHEADER_) && !defined(WIN32)
99 #define _BITMAPINFOHEADER_
101 #ifdef HAVE_ATTRIBUTE_PACKED
102 __attribute__((__packed__))
110 uint32_t biCompression;
111 uint32_t biSizeImage;
112 uint32_t biXPelsPerMeter;
113 uint32_t biYPelsPerMeter;
115 uint32_t biClrImportant;
116 } BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER;
119 #ifdef HAVE_ATTRIBUTE_PACKED
120 __attribute__((__packed__))
123 BITMAPINFOHEADER bmiHeader;
125 } BITMAPINFO, *LPBITMAPINFO;
131 #ifdef HAVE_ATTRIBUTE_PACKED
132 __attribute__((__packed__))
135 int left, top, right, bottom;
139 #ifndef _REFERENCE_TIME_
140 #define _REFERENCE_TIME_
141 typedef int64_t REFERENCE_TIME;
144 #ifndef _VIDEOINFOHEADER_
145 #define _VIDEOINFOHEADER_
147 #ifdef HAVE_ATTRIBUTE_PACKED
148 __attribute__((__packed__))
154 uint32_t dwBitErrorRate;
155 REFERENCE_TIME AvgTimePerFrame;
156 BITMAPINFOHEADER bmiHeader;
163 #ifdef HAVE_ATTRIBUTE_PACKED
164 __attribute__((__packed__))
174 #ifndef _TRUECOLORINFO_
175 #define _TRUECOLORINFO_
177 #ifdef HAVE_ATTRIBUTE_PACKED
178 __attribute__((__packed__))
181 uint32_t dwBitMasks[3];
182 RGBQUAD1 bmiColors[256];
189 #ifdef HAVE_ATTRIBUTE_PACKED
190 __attribute__((__packed__))
196 uint32_t dwBitErrorRate;
197 REFERENCE_TIME AvgTimePerFrame;
198 BITMAPINFOHEADER bmiHeader;
202 RGBQUAD1 bmiColors[256]; /* Colour palette */
203 uint32_t dwBitMasks[3]; /* True colour masks */
204 TRUECOLORINFO TrueColorInfo; /* Both of the above */
210 /* WAVE format wFormatTag IDs */
211 #define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */
212 #define WAVE_FORMAT_PCM 0x0001 /* Microsoft Corporation */
213 #define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */
214 #define WAVE_FORMAT_IEEE_FLOAT 0x0003 /* Microsoft Corporation */
215 #define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */
216 #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */
217 #define WAVE_FORMAT_DTS_MS 0x0008 /* Microsoft Corporation */
218 #define WAVE_FORMAT_IMA_ADPCM 0x0011 /* Intel Corporation */
219 #define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */
220 #define WAVE_FORMAT_MSNAUDIO 0x0032 /* Microsoft Corporation */
221 #define WAVE_FORMAT_G726 0x0045 /* ITU-T standard */
222 #define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */
223 #define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */
224 #define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */
226 #define WAVE_FORMAT_A52 0x2000
227 #define WAVE_FORMAT_DTS 0x2001
228 #define WAVE_FORMAT_WMA1 0x0160 /* WMA version 1 */
229 #define WAVE_FORMAT_WMA2 0x0161 /* WMA (v2) 7, 8, 9 Series */
230 #define WAVE_FORMAT_WMAP 0x0162 /* WMA 9 Professional */
231 #define WAVE_FORMAT_WMAL 0x0163 /* WMA 9 Lossless */
232 #define WAVE_FORMAT_DIVIO_AAC 0x4143
233 #define WAVE_FORMAT_AAC 0x00FF
235 /* Need to check these */
236 #define WAVE_FORMAT_DK3 0x0061
237 #define WAVE_FORMAT_DK4 0x0062
239 #if !defined(WAVE_FORMAT_EXTENSIBLE)
240 #define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */
243 /* GUID SubFormat IDs */
244 /* We need both b/c const variables are not compile-time constants in C, giving
245 * us an error if we use the const GUID in an enum */
247 #ifndef _KSDATAFORMAT_SUBTYPE_PCM_
248 #define _KSDATAFORMAT_SUBTYPE_PCM_ {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
249 static const GUID VLC_KSDATAFORMAT_SUBTYPE_PCM = {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}};
250 #define KSDATAFORMAT_SUBTYPE_PCM VLC_KSDATAFORMAT_SUBTYPE_PCM
253 #ifndef _KSDATAFORMAT_SUBTYPE_UNKNOWN_
254 #define _KSDATAFORMAT_SUBTYPE_UNKNOWN_ {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
255 static const GUID VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
256 #define KSDATAFORMAT_SUBTYPE_UNKNOWN VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN
259 /* Microsoft speaker definitions */
260 #define WAVE_SPEAKER_FRONT_LEFT 0x1
261 #define WAVE_SPEAKER_FRONT_RIGHT 0x2
262 #define WAVE_SPEAKER_FRONT_CENTER 0x4
263 #define WAVE_SPEAKER_LOW_FREQUENCY 0x8
264 #define WAVE_SPEAKER_BACK_LEFT 0x10
265 #define WAVE_SPEAKER_BACK_RIGHT 0x20
266 #define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER 0x40
267 #define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
268 #define WAVE_SPEAKER_BACK_CENTER 0x100
269 #define WAVE_SPEAKER_SIDE_LEFT 0x200
270 #define WAVE_SPEAKER_SIDE_RIGHT 0x400
271 #define WAVE_SPEAKER_TOP_CENTER 0x800
272 #define WAVE_SPEAKER_TOP_FRONT_LEFT 0x1000
273 #define WAVE_SPEAKER_TOP_FRONT_CENTER 0x2000
274 #define WAVE_SPEAKER_TOP_FRONT_RIGHT 0x4000
275 #define WAVE_SPEAKER_TOP_BACK_LEFT 0x8000
276 #define WAVE_SPEAKER_TOP_BACK_CENTER 0x10000
277 #define WAVE_SPEAKER_TOP_BACK_RIGHT 0x20000
278 #define WAVE_SPEAKER_RESERVED 0x80000000
283 vlc_fourcc_t i_fourcc;
286 wave_format_tag_to_fourcc[] =
288 { WAVE_FORMAT_PCM, VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" },
289 { WAVE_FORMAT_ADPCM, VLC_FOURCC( 'm', 's', 0x00,0x02), "Adpcm" },
290 { WAVE_FORMAT_IEEE_FLOAT, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" },
291 { WAVE_FORMAT_ALAW, VLC_FOURCC( 'a', 'l', 'a', 'w' ), "A-Law" },
292 { WAVE_FORMAT_MULAW, VLC_FOURCC( 'm', 'l', 'a', 'w' ), "Mu-Law" },
293 { WAVE_FORMAT_IMA_ADPCM,VLC_FOURCC( 'm', 's', 0x00,0x11), "Ima-Adpcm" },
294 { WAVE_FORMAT_G726, VLC_FOURCC( 'g', '7', '2', '6' ), "G.726 Adpcm" },
295 { WAVE_FORMAT_MPEGLAYER3,VLC_FOURCC('m', 'p', 'g', 'a' ), "Mpeg Audio" },
296 { WAVE_FORMAT_MPEG, VLC_FOURCC( 'm', 'p', 'g', 'a' ), "Mpeg Audio" },
297 { WAVE_FORMAT_A52, VLC_FOURCC( 'a', '5', '2', ' ' ), "A/52" },
298 { WAVE_FORMAT_WMA1, VLC_FOURCC( 'w', 'm', 'a', '1' ), "Window Media Audio v1" },
299 { WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', '2' ), "Window Media Audio v2" },
300 { WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', ' ' ), "Window Media Audio v2" },
301 { WAVE_FORMAT_WMAP, VLC_FOURCC( 'w', 'm', 'a', 'p' ), "Window Media Audio 9 Professional" },
302 { WAVE_FORMAT_WMAL, VLC_FOURCC( 'w', 'm', 'a', 'l' ), "Window Media Audio 9 Lossless" },
303 { WAVE_FORMAT_DK3, VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" },
304 { WAVE_FORMAT_DK4, VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" },
305 { WAVE_FORMAT_DTS, VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
306 { WAVE_FORMAT_DTS_MS, VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
307 { WAVE_FORMAT_DIVIO_AAC,VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio (Divio)" },
308 { WAVE_FORMAT_AAC, VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio" },
309 { WAVE_FORMAT_UNKNOWN, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
312 static inline void wf_tag_to_fourcc( uint16_t i_tag, vlc_fourcc_t *fcc,
316 for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
318 if( wave_format_tag_to_fourcc[i].i_tag == i_tag ) break;
320 if( fcc ) *fcc = wave_format_tag_to_fourcc[i].i_fourcc;
321 if( ppsz_name ) *ppsz_name = wave_format_tag_to_fourcc[i].psz_name;
324 static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag )
327 for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
329 if( wave_format_tag_to_fourcc[i].i_fourcc == fcc ) break;
331 if( pi_tag ) *pi_tag = wave_format_tag_to_fourcc[i].i_tag;
334 /* If wFormatTag is WAVEFORMATEXTENSIBLE, we must look at the SubFormat tag
335 * to determine the actual format. Microsoft has stopped giving out wFormatTag
336 * assignments in lieu of letting 3rd parties generate their own GUIDs
341 vlc_fourcc_t i_fourcc;
344 sub_format_tag_to_fourcc[] =
346 { _KSDATAFORMAT_SUBTYPE_PCM_, VLC_FOURCC( 'p', 'c', 'm', ' ' ), "PCM" },
347 { _KSDATAFORMAT_SUBTYPE_UNKNOWN_, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
350 /* compares two GUIDs, returns 1 if identical, 0 otherwise */
351 static inline int guidcmp( const GUID *s1, const GUID *s2 )
353 return( s1->Data1 == s2->Data1 && s1->Data2 == s2->Data2 &&
354 s1->Data3 == s2->Data3 && !memcmp( s1->Data4, s2->Data4, 8 ) );
357 static inline void sf_tag_to_fourcc( GUID *guid_tag,
358 vlc_fourcc_t *fcc, char **ppsz_name )
362 for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag,
363 &KSDATAFORMAT_SUBTYPE_UNKNOWN ); i++ )
365 if( guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, guid_tag ) ) break;
367 if( fcc ) *fcc = sub_format_tag_to_fourcc[i].i_fourcc;
368 if( ppsz_name ) *ppsz_name = sub_format_tag_to_fourcc[i].psz_name;
372 * Structure to hold information concerning subtitles.
373 * Used between demuxers and decoders of subtitles.
375 typedef struct es_sys_t
377 char *psz_header; /* for 'ssa ' and 'subt' */
380 unsigned int i_orig_height;
381 unsigned int i_orig_width;
382 unsigned int i_origin_x;
383 unsigned int i_origin_y;
384 unsigned int i_scale_h;
385 unsigned int i_scale_v;
386 unsigned int i_alpha;
390 unsigned int i_align;
391 mtime_t i_time_offset;
392 vlc_bool_t b_forced_subs;
393 unsigned int palette[16];
394 unsigned int colors[4];
398 #endif /* "codecs.h" */