Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

codecs.h

00001 /*****************************************************************************
00002  * codecs.h: codec related structures needed by the demuxers and decoders
00003  *****************************************************************************
00004  * Copyright (C) 1999-2001 the VideoLAN team
00005  * $Id: codecs.h 12419 2005-08-28 20:57:48Z hartman $
00006  *
00007  * Author: Gildas Bazin <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef _VLC_CODECS_H
00025 #define _VLC_CODECS_H 1
00026 
00027 /* Structures exported to the demuxers and decoders */
00028 
00029 #if !(defined _GUID_DEFINED || defined GUID_DEFINED)
00030 #define GUID_DEFINED
00031 typedef struct _GUID
00032 {
00033     uint32_t Data1;
00034     uint16_t Data2;
00035     uint16_t Data3;
00036     uint8_t  Data4[8];
00037 } GUID, *REFGUID, *LPGUID;
00038 #endif /* GUID_DEFINED */
00039 
00040 #ifndef _WAVEFORMATEX_
00041 #define _WAVEFORMATEX_
00042 typedef struct
00043 #ifdef HAVE_ATTRIBUTE_PACKED
00044     __attribute__((__packed__))
00045 #endif
00046 _WAVEFORMATEX {
00047     uint16_t   wFormatTag;
00048     uint16_t   nChannels;
00049     uint32_t   nSamplesPerSec;
00050     uint32_t   nAvgBytesPerSec;
00051     uint16_t   nBlockAlign;
00052     uint16_t   wBitsPerSample;
00053     uint16_t   cbSize;
00054 } WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
00055 #endif /* _WAVEFORMATEX_ */
00056 
00057 #ifndef _WAVEFORMATEXTENSIBLE_
00058 #define _WAVEFORMATEXTENSIBLE_
00059 typedef struct
00060 #ifdef HAVE_ATTRIBUTE_PACKED
00061     __attribute__((__packed__))
00062 #endif
00063 _WAVEFORMATEXTENSIBLE {
00064     WAVEFORMATEX Format;
00065     union {
00066         uint16_t wValidBitsPerSample;
00067         uint16_t wSamplesPerBlock;
00068         uint16_t wReserved;
00069     } Samples;
00070     uint32_t     dwChannelMask;
00071     GUID SubFormat;
00072 } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
00073 #endif /* _WAVEFORMATEXTENSIBLE_ */
00074 
00075 #ifndef _WAVEHEADER_
00076 #define _WAVEHEADER_
00077 typedef struct
00078 #ifdef HAVE_ATTRIBUTE_PACKED
00079     __attribute__((__packed__))
00080 #endif
00081 _WAVEHEADER {
00082     uint32_t MainChunkID;
00083     uint32_t Length;
00084     uint32_t ChunkTypeID;
00085     uint32_t SubChunkID;
00086     uint32_t SubChunkLength;
00087     uint16_t Format;
00088     uint16_t Modus;
00089     uint32_t SampleFreq;
00090     uint32_t BytesPerSec;
00091     uint16_t BytesPerSample;
00092     uint16_t BitsPerSample;
00093     uint32_t DataChunkID;
00094     uint32_t DataLength;
00095 } WAVEHEADER;
00096 #endif /* _WAVEHEADER_ */
00097 
00098 #if !defined(_BITMAPINFOHEADER_) && !defined(WIN32)
00099 #define _BITMAPINFOHEADER_
00100 typedef struct
00101 #ifdef HAVE_ATTRIBUTE_PACKED
00102     __attribute__((__packed__))
00103 #endif
00104 {
00105     uint32_t   biSize;
00106     uint32_t   biWidth;
00107     uint32_t   biHeight;
00108     uint16_t   biPlanes;
00109     uint16_t   biBitCount;
00110     uint32_t   biCompression;
00111     uint32_t   biSizeImage;
00112     uint32_t   biXPelsPerMeter;
00113     uint32_t   biYPelsPerMeter;
00114     uint32_t   biClrUsed;
00115     uint32_t   biClrImportant;
00116 } BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER;
00117 
00118 typedef struct
00119 #ifdef HAVE_ATTRIBUTE_PACKED
00120     __attribute__((__packed__))
00121 #endif
00122 {
00123     BITMAPINFOHEADER bmiHeader;
00124     int        bmiColors[1];
00125 } BITMAPINFO, *LPBITMAPINFO;
00126 #endif
00127 
00128 #ifndef _RECT32_
00129 #define _RECT32_
00130 typedef struct
00131 #ifdef HAVE_ATTRIBUTE_PACKED
00132     __attribute__((__packed__))
00133 #endif
00134 {
00135     int left, top, right, bottom;
00136 } RECT32;
00137 #endif
00138 
00139 #ifndef _REFERENCE_TIME_
00140 #define _REFERENCE_TIME_
00141 typedef int64_t REFERENCE_TIME;
00142 #endif
00143 
00144 #ifndef _VIDEOINFOHEADER_
00145 #define _VIDEOINFOHEADER_
00146 typedef struct
00147 #ifdef HAVE_ATTRIBUTE_PACKED
00148     __attribute__((__packed__))
00149 #endif
00150 {
00151     RECT32            rcSource;
00152     RECT32            rcTarget;
00153     uint32_t          dwBitRate;
00154     uint32_t          dwBitErrorRate;
00155     REFERENCE_TIME    AvgTimePerFrame;
00156     BITMAPINFOHEADER  bmiHeader;
00157 } VIDEOINFOHEADER;
00158 #endif
00159 
00160 #ifndef _RGBQUAD_
00161 #define _RGBQUAD_
00162 typedef struct
00163 #ifdef HAVE_ATTRIBUTE_PACKED
00164     __attribute__((__packed__))
00165 #endif
00166 {
00167     uint8_t rgbBlue;
00168     uint8_t rgbGreen;
00169     uint8_t rgbRed;
00170     uint8_t rgbReserved;
00171 } RGBQUAD1;
00172 #endif
00173 
00174 #ifndef _TRUECOLORINFO_
00175 #define _TRUECOLORINFO_
00176 typedef struct
00177 #ifdef HAVE_ATTRIBUTE_PACKED
00178     __attribute__((__packed__))
00179 #endif
00180 {
00181     uint32_t dwBitMasks[3];
00182     RGBQUAD1 bmiColors[256];
00183 } TRUECOLORINFO;
00184 #endif
00185 
00186 #ifndef _VIDEOINFO_
00187 #define _VIDEOINFO_
00188 typedef struct
00189 #ifdef HAVE_ATTRIBUTE_PACKED
00190     __attribute__((__packed__))
00191 #endif
00192 {
00193     RECT32            rcSource;
00194     RECT32            rcTarget;
00195     uint32_t          dwBitRate;
00196     uint32_t          dwBitErrorRate;
00197     REFERENCE_TIME    AvgTimePerFrame;
00198     BITMAPINFOHEADER  bmiHeader;
00199 
00200     union
00201     {
00202         RGBQUAD1 bmiColors[256]; /* Colour palette */
00203         uint32_t dwBitMasks[3]; /* True colour masks */
00204         TRUECOLORINFO TrueColorInfo; /* Both of the above */
00205     };
00206 
00207 } VIDEOINFO;
00208 #endif
00209 
00210 /* WAVE format wFormatTag IDs */
00211 #define WAVE_FORMAT_UNKNOWN             0x0000 /* Microsoft Corporation */
00212 #define WAVE_FORMAT_PCM                 0x0001 /* Microsoft Corporation */
00213 #define WAVE_FORMAT_ADPCM               0x0002 /* Microsoft Corporation */
00214 #define WAVE_FORMAT_IEEE_FLOAT          0x0003 /* Microsoft Corporation */
00215 #define WAVE_FORMAT_ALAW                0x0006 /* Microsoft Corporation */
00216 #define WAVE_FORMAT_MULAW               0x0007 /* Microsoft Corporation */
00217 #define WAVE_FORMAT_DTS_MS              0x0008 /* Microsoft Corporation */
00218 #define WAVE_FORMAT_IMA_ADPCM           0x0011 /* Intel Corporation */
00219 #define WAVE_FORMAT_GSM610              0x0031 /* Microsoft Corporation */
00220 #define WAVE_FORMAT_MSNAUDIO            0x0032 /* Microsoft Corporation */
00221 #define WAVE_FORMAT_G726                0x0045 /* ITU-T standard  */
00222 #define WAVE_FORMAT_MPEG                0x0050 /* Microsoft Corporation */
00223 #define WAVE_FORMAT_MPEGLAYER3          0x0055 /* ISO/MPEG Layer3 Format Tag */
00224 #define WAVE_FORMAT_DOLBY_AC3_SPDIF     0x0092 /* Sonic Foundry */
00225 
00226 #define WAVE_FORMAT_A52                 0x2000
00227 #define WAVE_FORMAT_DTS                 0x2001
00228 #define WAVE_FORMAT_WMA1                0x0160 /* WMA version 1 */
00229 #define WAVE_FORMAT_WMA2                0x0161 /* WMA (v2) 7, 8, 9 Series */
00230 #define WAVE_FORMAT_WMAP                0x0162 /* WMA 9 Professional */
00231 #define WAVE_FORMAT_WMAL                0x0163 /* WMA 9 Lossless */
00232 #define WAVE_FORMAT_DIVIO_AAC           0x4143
00233 #define WAVE_FORMAT_AAC                 0x00FF
00234 
00235 /* Need to check these */
00236 #define WAVE_FORMAT_DK3                 0x0061
00237 #define WAVE_FORMAT_DK4                 0x0062
00238 
00239 #define WAVE_FORMAT_VORB_1              0x674f
00240 #define WAVE_FORMAT_VORB_1PLUS          0x676f
00241 #define WAVE_FORMAT_VORB_2              0x6750
00242 #define WAVE_FORMAT_VORB_2PLUS          0x6770
00243 #define WAVE_FORMAT_VORB_3              0x6751
00244 #define WAVE_FORMAT_VORB_3PLUS          0x6771
00245 
00246 
00247 #if !defined(WAVE_FORMAT_EXTENSIBLE)
00248 #define WAVE_FORMAT_EXTENSIBLE          0xFFFE /* Microsoft */
00249 #endif
00250 
00251 /* GUID SubFormat IDs */
00252 /* We need both b/c const variables are not compile-time constants in C, giving
00253  * us an error if we use the const GUID in an enum */
00254 
00255 #ifndef _KSDATAFORMAT_SUBTYPE_PCM_
00256 #define _KSDATAFORMAT_SUBTYPE_PCM_ {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
00257 static const GUID VLC_KSDATAFORMAT_SUBTYPE_PCM = {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}};
00258 #define KSDATAFORMAT_SUBTYPE_PCM VLC_KSDATAFORMAT_SUBTYPE_PCM
00259 #endif
00260 
00261 #ifndef _KSDATAFORMAT_SUBTYPE_UNKNOWN_ 
00262 #define _KSDATAFORMAT_SUBTYPE_UNKNOWN_ {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
00263 static const GUID VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
00264 #define KSDATAFORMAT_SUBTYPE_UNKNOWN VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN
00265 #endif
00266 
00267 /* Microsoft speaker definitions */
00268 #define WAVE_SPEAKER_FRONT_LEFT             0x1
00269 #define WAVE_SPEAKER_FRONT_RIGHT            0x2
00270 #define WAVE_SPEAKER_FRONT_CENTER           0x4
00271 #define WAVE_SPEAKER_LOW_FREQUENCY          0x8
00272 #define WAVE_SPEAKER_BACK_LEFT              0x10
00273 #define WAVE_SPEAKER_BACK_RIGHT             0x20
00274 #define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER   0x40
00275 #define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER  0x80
00276 #define WAVE_SPEAKER_BACK_CENTER            0x100
00277 #define WAVE_SPEAKER_SIDE_LEFT              0x200
00278 #define WAVE_SPEAKER_SIDE_RIGHT             0x400
00279 #define WAVE_SPEAKER_TOP_CENTER             0x800
00280 #define WAVE_SPEAKER_TOP_FRONT_LEFT         0x1000
00281 #define WAVE_SPEAKER_TOP_FRONT_CENTER       0x2000
00282 #define WAVE_SPEAKER_TOP_FRONT_RIGHT        0x4000
00283 #define WAVE_SPEAKER_TOP_BACK_LEFT          0x8000
00284 #define WAVE_SPEAKER_TOP_BACK_CENTER        0x10000
00285 #define WAVE_SPEAKER_TOP_BACK_RIGHT         0x20000
00286 #define WAVE_SPEAKER_RESERVED               0x80000000
00287 
00288 static struct
00289 {
00290     uint16_t     i_tag;
00291     vlc_fourcc_t i_fourcc;
00292     char         *psz_name;
00293 }
00294 wave_format_tag_to_fourcc[] =
00295 {
00296     { WAVE_FORMAT_PCM,        VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" },
00297     { WAVE_FORMAT_ADPCM,      VLC_FOURCC( 'm', 's', 0x00,0x02), "Adpcm" },
00298     { WAVE_FORMAT_IEEE_FLOAT, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" },
00299     { WAVE_FORMAT_ALAW,       VLC_FOURCC( 'a', 'l', 'a', 'w' ), "A-Law" },
00300     { WAVE_FORMAT_MULAW,      VLC_FOURCC( 'm', 'l', 'a', 'w' ), "Mu-Law" },
00301     { WAVE_FORMAT_IMA_ADPCM,  VLC_FOURCC( 'm', 's', 0x00,0x11), "Ima-Adpcm" },
00302     { WAVE_FORMAT_G726,       VLC_FOURCC( 'g', '7', '2', '6' ), "G.726 Adpcm" },
00303     { WAVE_FORMAT_MPEGLAYER3, VLC_FOURCC( 'm', 'p', 'g', 'a' ), "Mpeg Audio" },
00304     { WAVE_FORMAT_MPEG,       VLC_FOURCC( 'm', 'p', 'g', 'a' ), "Mpeg Audio" },
00305     { WAVE_FORMAT_A52,        VLC_FOURCC( 'a', '5', '2', ' ' ), "A/52" },
00306     { WAVE_FORMAT_WMA1,       VLC_FOURCC( 'w', 'm', 'a', '1' ), "Window Media Audio v1" },
00307     { WAVE_FORMAT_WMA2,       VLC_FOURCC( 'w', 'm', 'a', '2' ), "Window Media Audio v2" },
00308     { WAVE_FORMAT_WMA2,       VLC_FOURCC( 'w', 'm', 'a', ' ' ), "Window Media Audio v2" },
00309     { WAVE_FORMAT_WMAP,       VLC_FOURCC( 'w', 'm', 'a', 'p' ), "Window Media Audio 9 Professional" },
00310     { WAVE_FORMAT_WMAL,       VLC_FOURCC( 'w', 'm', 'a', 'l' ), "Window Media Audio 9 Lossless" },
00311     { WAVE_FORMAT_DK3,        VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" },
00312     { WAVE_FORMAT_DK4,        VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" },
00313     { WAVE_FORMAT_DTS,        VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
00314     { WAVE_FORMAT_DTS_MS,     VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
00315     { WAVE_FORMAT_DIVIO_AAC,  VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio (Divio)" },
00316     { WAVE_FORMAT_AAC,        VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio" },
00317     { WAVE_FORMAT_VORB_1,     VLC_FOURCC( 'v', 'o', 'r', '1' ), "Vorbis 1 Audio" },
00318     { WAVE_FORMAT_VORB_1PLUS, VLC_FOURCC( 'v', 'o', '1', '+' ), "Vorbis 1+ Audio" },
00319     { WAVE_FORMAT_VORB_2,     VLC_FOURCC( 'v', 'o', 'r', '2' ), "Vorbis 2 Audio" },
00320     { WAVE_FORMAT_VORB_2PLUS, VLC_FOURCC( 'v', 'o', '2', '+' ), "Vorbis 2+ Audio" },
00321     { WAVE_FORMAT_VORB_3,     VLC_FOURCC( 'v', 'o', 'r', '3' ), "Vorbis 3 Audio" },
00322     { WAVE_FORMAT_VORB_3PLUS, VLC_FOURCC( 'v', 'o', '3', '+' ), "Vorbis 3+ Audio" },
00323     { WAVE_FORMAT_UNKNOWN,    VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
00324 };
00325 
00326 static inline void wf_tag_to_fourcc( uint16_t i_tag, vlc_fourcc_t *fcc,
00327                                      char **ppsz_name )
00328 {
00329     int i;
00330     for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
00331     {
00332         if( wave_format_tag_to_fourcc[i].i_tag == i_tag ) break;
00333     }
00334     if( fcc ) *fcc = wave_format_tag_to_fourcc[i].i_fourcc;
00335     if( ppsz_name ) *ppsz_name = wave_format_tag_to_fourcc[i].psz_name;
00336 }
00337 
00338 static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag )
00339 {
00340     int i;
00341     for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
00342     {
00343         if( wave_format_tag_to_fourcc[i].i_fourcc == fcc ) break;
00344     }
00345     if( pi_tag ) *pi_tag = wave_format_tag_to_fourcc[i].i_tag;
00346 }
00347 
00348 /* If wFormatTag is WAVEFORMATEXTENSIBLE, we must look at the SubFormat tag
00349  * to determine the actual format.  Microsoft has stopped giving out wFormatTag
00350  * assignments in lieu of letting 3rd parties generate their own GUIDs
00351  */
00352 static struct
00353 {
00354     GUID         guid_tag;
00355     vlc_fourcc_t i_fourcc;
00356     char         *psz_name;
00357 }
00358 sub_format_tag_to_fourcc[] =
00359 {
00360     { _KSDATAFORMAT_SUBTYPE_PCM_, VLC_FOURCC( 'p', 'c', 'm', ' ' ), "PCM" },
00361     { _KSDATAFORMAT_SUBTYPE_UNKNOWN_, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
00362 };
00363 
00364 /* compares two GUIDs, returns 1 if identical, 0 otherwise */
00365 static inline int guidcmp( const GUID *s1, const GUID *s2 )
00366 {
00367     return( s1->Data1 == s2->Data1 && s1->Data2 == s2->Data2 &&
00368             s1->Data3 == s2->Data3 && !memcmp( s1->Data4, s2->Data4, 8 ) );
00369 }
00370 
00371 static inline void sf_tag_to_fourcc( GUID *guid_tag,
00372                                      vlc_fourcc_t *fcc, char **ppsz_name )
00373 {
00374     int i;
00375 
00376     for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, 
00377                           &KSDATAFORMAT_SUBTYPE_UNKNOWN ); i++ )
00378     {
00379         if( guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, guid_tag ) ) break;
00380     }
00381     if( fcc ) *fcc = sub_format_tag_to_fourcc[i].i_fourcc;
00382     if( ppsz_name ) *ppsz_name = sub_format_tag_to_fourcc[i].psz_name;
00383 }
00384 
00389 typedef struct es_sys_t
00390 {
00391     char        *psz_header; /* for 'ssa ' and 'subt' */
00392 
00393     /* for spudec */
00394     unsigned int        i_orig_height;
00395     unsigned int        i_orig_width;
00396     unsigned int        i_origin_x;
00397     unsigned int        i_origin_y;
00398     unsigned int        i_scale_h;
00399     unsigned int        i_scale_v;
00400     unsigned int        i_alpha;
00401     vlc_bool_t          b_smooth;
00402     mtime_t             i_fade_in;
00403     mtime_t             i_fade_out;
00404     unsigned int        i_align;
00405     mtime_t             i_time_offset;
00406     vlc_bool_t          b_forced_subs;
00407     unsigned int        palette[16];
00408     unsigned int        colors[4];
00409 
00410 } subtitle_data_t;
00411 
00412 #endif /* "codecs.h" */

Generated on Tue Dec 20 10:14:18 2005 for vlc-0.8.4a by  doxygen 1.4.2