]> git.sesse.net Git - vlc/blob - include/codecs.h
* include/vlc_interface.h: forgot that in last commit.
[vlc] / include / codecs.h
1 /*****************************************************************************
2  * codecs.h: codec related structures needed by the demuxers and decoders
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  * $Id$
6  *
7  * Author: Gildas Bazin <gbazin@netcourrier.com>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #ifndef _VLC_CODECS_H
25 #define _VLC_CODECS_H 1
26
27 /* Structures exported to the demuxers and decoders */
28
29 #if !(defined _GUID_DEFINED || defined GUID_DEFINED)
30 #define GUID_DEFINED
31 typedef struct _GUID
32 {
33     uint32_t Data1;
34     uint16_t Data2;
35     uint16_t Data3;
36     uint8_t  Data4[8];
37 } GUID, *REFGUID, *LPGUID;
38 #endif /* GUID_DEFINED */
39
40 #ifndef _WAVEFORMATEX_
41 #define _WAVEFORMATEX_
42 typedef struct
43 #ifdef HAVE_ATTRIBUTE_PACKED
44     __attribute__((__packed__))
45 #endif
46 _WAVEFORMATEX {
47     uint16_t   wFormatTag;
48     uint16_t   nChannels;
49     uint32_t   nSamplesPerSec;
50     uint32_t   nAvgBytesPerSec;
51     uint16_t   nBlockAlign;
52     uint16_t   wBitsPerSample;
53     uint16_t   cbSize;
54 } WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
55 #endif /* _WAVEFORMATEX_ */
56
57 #ifndef _WAVEFORMATEXTENSIBLE_
58 #define _WAVEFORMATEXTENSIBLE_
59 typedef struct
60 #ifdef HAVE_ATTRIBUTE_PACKED
61     __attribute__((__packed__))
62 #endif
63 _WAVEFORMATEXTENSIBLE {
64     WAVEFORMATEX Format;
65     union {
66         uint16_t wValidBitsPerSample;
67         uint16_t wSamplesPerBlock;
68         uint16_t wReserved;
69     } Samples;
70     uint32_t     dwChannelMask;
71     GUID SubFormat;
72 } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
73 #endif /* _WAVEFORMATEXTENSIBLE_ */
74
75 #ifndef _WAVEHEADER_
76 #define _WAVEHEADER_
77 typedef struct
78 #ifdef HAVE_ATTRIBUTE_PACKED
79     __attribute__((__packed__))
80 #endif
81 _WAVEHEADER {
82     uint32_t MainChunkID;
83     uint32_t Length;
84     uint32_t ChunkTypeID;
85     uint32_t SubChunkID;
86     uint32_t SubChunkLength;
87     uint16_t Format;
88     uint16_t Modus;
89     uint32_t SampleFreq;
90     uint32_t BytesPerSec;
91     uint16_t BytesPerSample;
92     uint16_t BitsPerSample;
93     uint32_t DataChunkID;
94     uint32_t DataLength;
95 } WAVEHEADER;
96 #endif /* _WAVEHEADER_ */
97
98 #if !defined(_BITMAPINFOHEADER_) && !defined(WIN32)
99 #define _BITMAPINFOHEADER_
100 typedef struct
101 #ifdef HAVE_ATTRIBUTE_PACKED
102     __attribute__((__packed__))
103 #endif
104 {
105     uint32_t   biSize;
106     uint32_t   biWidth;
107     uint32_t   biHeight;
108     uint16_t   biPlanes;
109     uint16_t   biBitCount;
110     uint32_t   biCompression;
111     uint32_t   biSizeImage;
112     uint32_t   biXPelsPerMeter;
113     uint32_t   biYPelsPerMeter;
114     uint32_t   biClrUsed;
115     uint32_t   biClrImportant;
116 } BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER;
117 typedef struct {
118     BITMAPINFOHEADER bmiHeader;
119     int        bmiColors[1];
120 } BITMAPINFO, *LPBITMAPINFO;
121 #endif
122
123 /* dvb_spuinfo_t exports the id of the selected track to the decoder */
124 typedef struct
125 {
126     unsigned int i_id;
127 } dvb_spuinfo_t;
128
129 /* WAVE format wFormatTag IDs */
130 #define WAVE_FORMAT_UNKNOWN             0x0000 /* Microsoft Corporation */
131 #define WAVE_FORMAT_PCM                 0x0001 /* Microsoft Corporation */
132 #define WAVE_FORMAT_ADPCM               0x0002 /* Microsoft Corporation */
133 #define WAVE_FORMAT_IEEE_FLOAT          0x0003 /* Microsoft Corporation */
134 #define WAVE_FORMAT_ALAW                0x0006 /* Microsoft Corporation */
135 #define WAVE_FORMAT_MULAW               0x0007 /* Microsoft Corporation */
136 #define WAVE_FORMAT_DTS_MS              0x0008 /* Microsoft Corporation */
137 #define WAVE_FORMAT_IMA_ADPCM           0x0011 /* Intel Corporation */
138 #define WAVE_FORMAT_GSM610              0x0031 /* Microsoft Corporation */
139 #define WAVE_FORMAT_MSNAUDIO            0x0032 /* Microsoft Corporation */
140 #define WAVE_FORMAT_MPEG                0x0050 /* Microsoft Corporation */
141 #define WAVE_FORMAT_MPEGLAYER3          0x0055 /* ISO/MPEG Layer3 Format Tag */
142 #define WAVE_FORMAT_DOLBY_AC3_SPDIF     0x0092 /* Sonic Foundry */
143
144 #define WAVE_FORMAT_A52                 0x2000
145 #define WAVE_FORMAT_DTS                 0x2001
146 #define WAVE_FORMAT_WMA1                0x0160
147 #define WAVE_FORMAT_WMA2                0x0161
148 #define WAVE_FORMAT_WMA3                0x0162
149 #define WAVE_FORMAT_DIVIO_AAC           0x4143
150
151 /* Need to check these */
152 #define WAVE_FORMAT_DK3                 0x0061
153 #define WAVE_FORMAT_DK4                 0x0062
154
155 #if !defined(WAVE_FORMAT_EXTENSIBLE)
156 #define WAVE_FORMAT_EXTENSIBLE          0xFFFE /* Microsoft */
157 #endif
158
159 /* Microsoft speaker definitions */
160 #define WAVE_SPEAKER_FRONT_LEFT             0x1
161 #define WAVE_SPEAKER_FRONT_RIGHT            0x2
162 #define WAVE_SPEAKER_FRONT_CENTER           0x4
163 #define WAVE_SPEAKER_LOW_FREQUENCY          0x8
164 #define WAVE_SPEAKER_BACK_LEFT              0x10
165 #define WAVE_SPEAKER_BACK_RIGHT             0x20
166 #define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER   0x40
167 #define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER  0x80
168 #define WAVE_SPEAKER_BACK_CENTER            0x100
169 #define WAVE_SPEAKER_SIDE_LEFT              0x200
170 #define WAVE_SPEAKER_SIDE_RIGHT             0x400
171 #define WAVE_SPEAKER_TOP_CENTER             0x800
172 #define WAVE_SPEAKER_TOP_FRONT_LEFT         0x1000
173 #define WAVE_SPEAKER_TOP_FRONT_CENTER       0x2000
174 #define WAVE_SPEAKER_TOP_FRONT_RIGHT        0x4000
175 #define WAVE_SPEAKER_TOP_BACK_LEFT          0x8000
176 #define WAVE_SPEAKER_TOP_BACK_CENTER        0x10000
177 #define WAVE_SPEAKER_TOP_BACK_RIGHT         0x20000
178 #define WAVE_SPEAKER_RESERVED               0x80000000
179
180 static struct
181 {
182     uint16_t     i_tag;
183     vlc_fourcc_t i_fourcc;
184     char         *psz_name;
185 }
186 wave_format_tag_to_fourcc[] =
187 {
188     { WAVE_FORMAT_PCM,      VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" },
189     { WAVE_FORMAT_ADPCM,    VLC_FOURCC( 'm', 's', 0x00,0x02), "Adpcm" },
190     { WAVE_FORMAT_IEEE_FLOAT, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" },
191     { WAVE_FORMAT_ALAW,     VLC_FOURCC( 'a', 'l', 'a', 'w' ), "A-Law" },
192     { WAVE_FORMAT_MULAW,    VLC_FOURCC( 'm', 'l', 'a', 'w' ), "Mu-Law" },
193     { WAVE_FORMAT_IMA_ADPCM,VLC_FOURCC( 'm', 's', 0x00,0x11), "Ima-Adpcm" },
194     { WAVE_FORMAT_MPEGLAYER3,VLC_FOURCC('m', 'p', 'g', 'a' ), "Mpeg Audio" },
195     { WAVE_FORMAT_MPEG,     VLC_FOURCC( 'm', 'p', 'g', 'a' ), "Mpeg Audio" },
196     { WAVE_FORMAT_A52,      VLC_FOURCC( 'a', '5', '2', ' ' ), "A/52" },
197     { WAVE_FORMAT_WMA1,     VLC_FOURCC( 'w', 'm', 'a', '1' ), "Window Media Audio 1" },
198     { WAVE_FORMAT_WMA2,     VLC_FOURCC( 'w', 'm', 'a', '2' ), "Window Media Audio 2" },
199     { WAVE_FORMAT_WMA3,     VLC_FOURCC( 'w', 'm', 'a', '3' ), "Window Media Audio 3" },
200     { WAVE_FORMAT_DK3,      VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" },
201     { WAVE_FORMAT_DK4,      VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" },
202     { WAVE_FORMAT_DTS,      VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
203     { WAVE_FORMAT_DTS_MS,   VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
204     { WAVE_FORMAT_DIVIO_AAC,VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio (Divio)" },
205     { WAVE_FORMAT_UNKNOWN,  VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
206 };
207
208 static inline void wf_tag_to_fourcc( uint16_t i_tag,
209                                      vlc_fourcc_t *fcc, char **ppsz_name )
210 {
211     int i;
212     for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
213     {
214         if( wave_format_tag_to_fourcc[i].i_tag == i_tag )
215         {
216             break;
217         }
218     }
219     if( fcc )
220     {
221         *fcc = wave_format_tag_to_fourcc[i].i_fourcc;
222     }
223     if( ppsz_name )
224     {
225         *ppsz_name = wave_format_tag_to_fourcc[i].psz_name;
226     }
227 }
228
229 /**
230  * Structure to hold information concerning subtitles.
231  * Used between demuxers and decoders of subtitles.
232  */
233 typedef struct es_sys_t
234 {
235     char        *psz_header; /* for 'ssa ' and 'subt' */
236
237     /* for spudec */
238     unsigned int        i_orig_height;
239     unsigned int        i_orig_width;
240     unsigned int        i_origin_x;
241     unsigned int        i_origin_y;
242     unsigned int        i_scale_h;
243     unsigned int        i_scale_v;
244     unsigned int        i_alpha;
245     vlc_bool_t          b_smooth;
246     mtime_t             i_fade_in;
247     mtime_t             i_fade_out;
248     unsigned int        i_align;
249     mtime_t             i_time_offset;
250     vlc_bool_t          b_forced_subs;
251     unsigned int        palette[16];
252     unsigned int        colors[4];
253 } subtitle_data_t;
254
255 #endif /* "codecs.h" */