Commit 52847eaf authored by Francois Cartegnie's avatar Francois Cartegnie

vlc_codecs: fix the waveformatex, ksformat stuff

Were unused static Guids, incorrect Atrac3 to pcm mapping
constness, and incomplete waveformat->guid mapping.
parent d5a10c74
......@@ -308,27 +308,9 @@ ATTR_PACKED
#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_IEEE_FLOAT_
#define _KSDATAFORMAT_SUBTYPE_IEEE_FLOAT_ {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}
static const GUID VLC_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
#define KSDATAFORMAT_SUBTYPE_IEEE_FLOAT 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
#define VLC_KSDATAFORMAT_SUBTYPE_ATRAC3P {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}} /* Undocumented */
#define VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
#define VLC_WAVEFORMATEX_GUIDBASE {0x00000000, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} /* Generated from Wave Format */
/* Microsoft speaker definitions */
#define WAVE_SPEAKER_FRONT_LEFT 0x1
......@@ -456,22 +438,26 @@ static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag )
*/
static const struct
{
GUID guid_tag;
vlc_fourcc_t i_fourcc;
const GUID guid_tag;
const vlc_fourcc_t i_fourcc;
const char *psz_name;
}
sub_format_tag_to_fourcc[] =
{
{ _KSDATAFORMAT_SUBTYPE_PCM_, VLC_FOURCC( 'a', 'r', 'a', 'w' ), "PCM" },
{ _KSDATAFORMAT_SUBTYPE_IEEE_FLOAT_, VLC_FOURCC( 'a', 'f', 'l', 't' ), "Float PCM" },
{ _KSDATAFORMAT_SUBTYPE_UNKNOWN_, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
{ VLC_KSDATAFORMAT_SUBTYPE_ATRAC3P, VLC_CODEC_ATRAC3P, "Sony Atrac3+" },
{ VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
};
static inline int guidcmpbase( const GUID *s1, const GUID *s2 )
{
return( s1->Data2 == s2->Data2 &&
s1->Data3 == s2->Data3 && !memcmp( s1->Data4, s2->Data4, 8 ) );
}
/* 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 ) );
return( s1->Data1 == s2->Data1 && guidcmpbase( s1, s2 ) );
}
#define GUID_FMT "0x%x-0x%x-0x%x-0x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x"
......@@ -483,18 +469,34 @@ static inline int guidcmp( const GUID *s1, const GUID *s2 )
(guid).Data4[4],(guid).Data4[5],(guid).Data4[6],(guid).Data4[7]
static inline void sf_tag_to_fourcc( GUID *guid_tag,
static inline void sf_tag_to_fourcc( const GUID *guid_tag,
vlc_fourcc_t *fcc, const char **ppsz_name )
{
int i;
bool b_found = false;
const GUID unknown = VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN;
const GUID waveformatex = VLC_WAVEFORMATEX_GUIDBASE;
for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag,
&KSDATAFORMAT_SUBTYPE_UNKNOWN ); i++ )
&unknown ); i++ )
{
if( guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, guid_tag ) )
{
b_found = true;
break;
}
}
if( !b_found && guidcmpbase(guid_tag, &waveformatex) )
{
wf_tag_to_fourcc(guid_tag->Data1, fcc, ppsz_name);
}
else
{
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;
}
if( fcc ) *fcc = sub_format_tag_to_fourcc[i].i_fourcc;
if( ppsz_name ) *ppsz_name = sub_format_tag_to_fourcc[i].psz_name;
}
#endif /* "codecs.h" */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment