X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fcodecs.h;h=c1571002b3a5dc995a35d2c2ac65d3dcecd39e23;hb=f7e9331f7e0558234055d6255d628556813be15e;hp=2d9e78fd4f3bb4ea3a57cc2b8d04f9c616cffc8e;hpb=354c7ab964f7e4bcc31a39ed0358b7f8c1135d38;p=vlc diff --git a/include/codecs.h b/include/codecs.h index 2d9e78fd4f..c1571002b3 100644 --- a/include/codecs.h +++ b/include/codecs.h @@ -2,9 +2,9 @@ * codecs.h: codec related structures needed by the demuxers and decoders ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: codecs.h,v 1.7 2003/11/05 00:17:50 hartman Exp $ + * $Id$ * - * Authors: Gildas Bazin + * Author: Gildas Bazin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,17 @@ /* Structures exported to the demuxers and decoders */ +#if !(defined _GUID_DEFINED || defined GUID_DEFINED) +#define GUID_DEFINED +typedef struct _GUID +{ + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; +} GUID, *REFGUID, *LPGUID; +#endif /* GUID_DEFINED */ + #ifndef _WAVEFORMATEX_ #define _WAVEFORMATEX_ typedef struct @@ -43,6 +54,47 @@ _WAVEFORMATEX { } WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX; #endif /* _WAVEFORMATEX_ */ +#ifndef _WAVEFORMATEXTENSIBLE_ +#define _WAVEFORMATEXTENSIBLE_ +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +_WAVEFORMATEXTENSIBLE { + WAVEFORMATEX Format; + union { + uint16_t wValidBitsPerSample; + uint16_t wSamplesPerBlock; + uint16_t wReserved; + } Samples; + uint32_t dwChannelMask; + GUID SubFormat; +} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE; +#endif /* _WAVEFORMATEXTENSIBLE_ */ + +#ifndef _WAVEHEADER_ +#define _WAVEHEADER_ +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +_WAVEHEADER { + uint32_t MainChunkID; + uint32_t Length; + uint32_t ChunkTypeID; + uint32_t SubChunkID; + uint32_t SubChunkLength; + uint16_t Format; + uint16_t Modus; + uint32_t SampleFreq; + uint32_t BytesPerSec; + uint16_t BytesPerSample; + uint16_t BitsPerSample; + uint32_t DataChunkID; + uint32_t DataLength; +} WAVEHEADER; +#endif /* _WAVEHEADER_ */ + #if !defined(_BITMAPINFOHEADER_) && !defined(WIN32) #define _BITMAPINFOHEADER_ typedef struct @@ -62,41 +114,169 @@ typedef struct uint32_t biClrUsed; uint32_t biClrImportant; } BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER; -typedef struct { + +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +{ BITMAPINFOHEADER bmiHeader; int bmiColors[1]; } BITMAPINFO, *LPBITMAPINFO; #endif -/* WAVE form wFormatTag IDs */ +#ifndef _RECT32_ +#define _RECT32_ +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +{ + int left, top, right, bottom; +} RECT32; +#endif + +#ifndef _REFERENCE_TIME_ +#define _REFERENCE_TIME_ +typedef int64_t REFERENCE_TIME; +#endif + +#ifndef _VIDEOINFOHEADER_ +#define _VIDEOINFOHEADER_ +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +{ + RECT32 rcSource; + RECT32 rcTarget; + uint32_t dwBitRate; + uint32_t dwBitErrorRate; + REFERENCE_TIME AvgTimePerFrame; + BITMAPINFOHEADER bmiHeader; +} VIDEOINFOHEADER; +#endif + +#ifndef _RGBQUAD_ +#define _RGBQUAD_ +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +{ + uint8_t rgbBlue; + uint8_t rgbGreen; + uint8_t rgbRed; + uint8_t rgbReserved; +} RGBQUAD1; +#endif + +#ifndef _TRUECOLORINFO_ +#define _TRUECOLORINFO_ +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +{ + uint32_t dwBitMasks[3]; + RGBQUAD1 bmiColors[256]; +} TRUECOLORINFO; +#endif + +#ifndef _VIDEOINFO_ +#define _VIDEOINFO_ +typedef struct +#ifdef HAVE_ATTRIBUTE_PACKED + __attribute__((__packed__)) +#endif +{ + RECT32 rcSource; + RECT32 rcTarget; + uint32_t dwBitRate; + uint32_t dwBitErrorRate; + REFERENCE_TIME AvgTimePerFrame; + BITMAPINFOHEADER bmiHeader; + + union + { + RGBQUAD1 bmiColors[256]; /* Colour palette */ + uint32_t dwBitMasks[3]; /* True colour masks */ + TRUECOLORINFO TrueColorInfo; /* Both of the above */ + }; + +} VIDEOINFO; +#endif +/* WAVE format wFormatTag IDs */ #define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */ #define WAVE_FORMAT_PCM 0x0001 /* Microsoft Corporation */ #define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */ #define WAVE_FORMAT_IEEE_FLOAT 0x0003 /* Microsoft Corporation */ #define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */ #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */ -#define WAVE_FORMAT_DTS 0x0008 /* Microsoft Corporation */ +#define WAVE_FORMAT_DTS_MS 0x0008 /* Microsoft Corporation */ #define WAVE_FORMAT_IMA_ADPCM 0x0011 /* Intel Corporation */ #define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */ #define WAVE_FORMAT_MSNAUDIO 0x0032 /* Microsoft Corporation */ +#define WAVE_FORMAT_G726 0x0045 /* ITU-T standard */ #define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */ #define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */ #define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */ -#define WAVE_FORMAT_A52 0x2000 -#define WAVE_FORMAT_WMA1 0x0160 -#define WAVE_FORMAT_WMA2 0x0161 -#define WAVE_FORMAT_WMA3 0x0162 +#define WAVE_FORMAT_A52 0x2000 +#define WAVE_FORMAT_DTS 0x2001 +#define WAVE_FORMAT_WMA1 0x0160 /* WMA version 1 */ +#define WAVE_FORMAT_WMA2 0x0161 /* WMA (v2) 7, 8, 9 Series */ +#define WAVE_FORMAT_WMAP 0x0162 /* WMA 9 Professional */ +#define WAVE_FORMAT_WMAL 0x0163 /* WMA 9 Lossless */ +#define WAVE_FORMAT_DIVIO_AAC 0x4143 +#define WAVE_FORMAT_AAC 0x00FF /* Need to check these */ -#define WAVE_FORMAT_DK3 0x0061 -#define WAVE_FORMAT_DK4 0x0062 +#define WAVE_FORMAT_DK3 0x0061 +#define WAVE_FORMAT_DK4 0x0062 #if !defined(WAVE_FORMAT_EXTENSIBLE) -#define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */ +#define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */ #endif +/* GUID SubFormat IDs */ +/* We need both b/c const variables are not compile-time constants in C, giving + * us an error if we use the const GUID in an enum */ + +#ifndef _KSDATAFORMAT_SUBTYPE_PCM_ +#define _KSDATAFORMAT_SUBTYPE_PCM_ {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} +static const GUID VLC_KSDATAFORMAT_SUBTYPE_PCM = {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}}; +#define KSDATAFORMAT_SUBTYPE_PCM VLC_KSDATAFORMAT_SUBTYPE_PCM +#endif + +#ifndef _KSDATAFORMAT_SUBTYPE_UNKNOWN_ +#define _KSDATAFORMAT_SUBTYPE_UNKNOWN_ {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} +static const GUID VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; +#define KSDATAFORMAT_SUBTYPE_UNKNOWN VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN +#endif + +/* Microsoft speaker definitions */ +#define WAVE_SPEAKER_FRONT_LEFT 0x1 +#define WAVE_SPEAKER_FRONT_RIGHT 0x2 +#define WAVE_SPEAKER_FRONT_CENTER 0x4 +#define WAVE_SPEAKER_LOW_FREQUENCY 0x8 +#define WAVE_SPEAKER_BACK_LEFT 0x10 +#define WAVE_SPEAKER_BACK_RIGHT 0x20 +#define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER 0x40 +#define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 +#define WAVE_SPEAKER_BACK_CENTER 0x100 +#define WAVE_SPEAKER_SIDE_LEFT 0x200 +#define WAVE_SPEAKER_SIDE_RIGHT 0x400 +#define WAVE_SPEAKER_TOP_CENTER 0x800 +#define WAVE_SPEAKER_TOP_FRONT_LEFT 0x1000 +#define WAVE_SPEAKER_TOP_FRONT_CENTER 0x2000 +#define WAVE_SPEAKER_TOP_FRONT_RIGHT 0x4000 +#define WAVE_SPEAKER_TOP_BACK_LEFT 0x8000 +#define WAVE_SPEAKER_TOP_BACK_CENTER 0x10000 +#define WAVE_SPEAKER_TOP_BACK_RIGHT 0x20000 +#define WAVE_SPEAKER_RESERVED 0x80000000 + static struct { uint16_t i_tag; @@ -107,39 +287,85 @@ wave_format_tag_to_fourcc[] = { { WAVE_FORMAT_PCM, VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" }, { WAVE_FORMAT_ADPCM, VLC_FOURCC( 'm', 's', 0x00,0x02), "Adpcm" }, + { WAVE_FORMAT_IEEE_FLOAT, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" }, { WAVE_FORMAT_ALAW, VLC_FOURCC( 'a', 'l', 'a', 'w' ), "A-Law" }, { WAVE_FORMAT_MULAW, VLC_FOURCC( 'm', 'l', 'a', 'w' ), "Mu-Law" }, { WAVE_FORMAT_IMA_ADPCM,VLC_FOURCC( 'm', 's', 0x00,0x11), "Ima-Adpcm" }, + { WAVE_FORMAT_G726, VLC_FOURCC( 'g', '7', '2', '6' ), "G.726 Adpcm" }, { WAVE_FORMAT_MPEGLAYER3,VLC_FOURCC('m', 'p', 'g', 'a' ), "Mpeg Audio" }, { WAVE_FORMAT_MPEG, VLC_FOURCC( 'm', 'p', 'g', 'a' ), "Mpeg Audio" }, { WAVE_FORMAT_A52, VLC_FOURCC( 'a', '5', '2', ' ' ), "A/52" }, - { WAVE_FORMAT_WMA1, VLC_FOURCC( 'w', 'm', 'a', '1' ), "Window Media Audio 1" }, - { WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', '2' ), "Window Media Audio 2" }, - { WAVE_FORMAT_WMA3, VLC_FOURCC( 'w', 'm', 'a', '3' ), "Window Media Audio 3" }, + { WAVE_FORMAT_WMA1, VLC_FOURCC( 'w', 'm', 'a', '1' ), "Window Media Audio v1" }, + { WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', '2' ), "Window Media Audio v2" }, + { WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', ' ' ), "Window Media Audio v2" }, + { WAVE_FORMAT_WMAP, VLC_FOURCC( 'w', 'm', 'a', 'p' ), "Window Media Audio 9 Professional" }, + { WAVE_FORMAT_WMAL, VLC_FOURCC( 'w', 'm', 'a', 'l' ), "Window Media Audio 9 Lossless" }, { WAVE_FORMAT_DK3, VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" }, { WAVE_FORMAT_DK4, VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" }, + { WAVE_FORMAT_DTS, VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" }, + { WAVE_FORMAT_DTS_MS, VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" }, + { WAVE_FORMAT_DIVIO_AAC,VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio (Divio)" }, + { WAVE_FORMAT_AAC, VLC_FOURCC( 'm', 'p', '4', 'a' ), "MPEG-4 Audio" }, { WAVE_FORMAT_UNKNOWN, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" } }; -static inline void wf_tag_to_fourcc( uint16_t i_tag, - vlc_fourcc_t *fcc, char **ppsz_name ) +static inline void wf_tag_to_fourcc( uint16_t i_tag, vlc_fourcc_t *fcc, + char **ppsz_name ) { int i; for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ ) { - if( wave_format_tag_to_fourcc[i].i_tag == i_tag ) - { - break; - } + if( wave_format_tag_to_fourcc[i].i_tag == i_tag ) break; } - if( fcc ) + if( fcc ) *fcc = wave_format_tag_to_fourcc[i].i_fourcc; + if( ppsz_name ) *ppsz_name = wave_format_tag_to_fourcc[i].psz_name; +} + +static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag ) +{ + int i; + for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ ) { - *fcc = wave_format_tag_to_fourcc[i].i_fourcc; + if( wave_format_tag_to_fourcc[i].i_fourcc == fcc ) break; } - if( ppsz_name ) + if( pi_tag ) *pi_tag = wave_format_tag_to_fourcc[i].i_tag; +} + +/* If wFormatTag is WAVEFORMATEXTENSIBLE, we must look at the SubFormat tag + * to determine the actual format. Microsoft has stopped giving out wFormatTag + * assignments in lieu of letting 3rd parties generate their own GUIDs + */ +static struct +{ + GUID guid_tag; + vlc_fourcc_t i_fourcc; + char *psz_name; +} +sub_format_tag_to_fourcc[] = +{ + { _KSDATAFORMAT_SUBTYPE_PCM_, VLC_FOURCC( 'p', 'c', 'm', ' ' ), "PCM" }, + { _KSDATAFORMAT_SUBTYPE_UNKNOWN_, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" } +}; + +/* compares two GUIDs, returns 1 if identical, 0 otherwise */ +static inline int guidcmp( const GUID *s1, const GUID *s2 ) +{ + return( s1->Data1 == s2->Data1 && s1->Data2 == s2->Data2 && + s1->Data3 == s2->Data3 && !memcmp( s1->Data4, s2->Data4, 8 ) ); +} + +static inline void sf_tag_to_fourcc( GUID *guid_tag, + vlc_fourcc_t *fcc, char **ppsz_name ) +{ + int i; + + for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, + &KSDATAFORMAT_SUBTYPE_UNKNOWN ); i++ ) { - *ppsz_name = wave_format_tag_to_fourcc[i].psz_name; + if( guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, guid_tag ) ) break; } + if( fcc ) *fcc = sub_format_tag_to_fourcc[i].i_fourcc; + if( ppsz_name ) *ppsz_name = sub_format_tag_to_fourcc[i].psz_name; } /** @@ -149,7 +375,7 @@ static inline void wf_tag_to_fourcc( uint16_t i_tag, typedef struct es_sys_t { char *psz_header; /* for 'ssa ' and 'subt' */ - + /* for spudec */ unsigned int i_orig_height; unsigned int i_orig_width; @@ -166,7 +392,7 @@ typedef struct es_sys_t vlc_bool_t b_forced_subs; unsigned int palette[16]; unsigned int colors[4]; + } subtitle_data_t; #endif /* "codecs.h" */ -