Commit 98be9ffa authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Wav: cosmetics (alignment, unlikely, locality)

parent efeb2e71
...@@ -100,9 +100,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -100,9 +100,9 @@ static int Open( vlc_object_t * p_this )
demux_sys_t *p_sys; demux_sys_t *p_sys;
const uint8_t *p_peek; const uint8_t *p_peek;
unsigned int i_size; unsigned int i_size;
unsigned int i_extended; unsigned int i_extended;
const char *psz_name; const char *psz_name;
WAVEFORMATEXTENSIBLE *p_wf_ext = NULL; WAVEFORMATEXTENSIBLE *p_wf_ext = NULL;
WAVEFORMATEX *p_wf = NULL; WAVEFORMATEX *p_wf = NULL;
...@@ -116,13 +116,13 @@ static int Open( vlc_object_t * p_this ) ...@@ -116,13 +116,13 @@ static int Open( vlc_object_t * p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_demux->pf_demux = Demux; p_demux->pf_demux = Demux;
p_demux->pf_control = Control; p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( *p_sys ) ); p_demux->p_sys = p_sys = malloc( sizeof( *p_sys ) );
if( p_sys == NULL ) if( unlikely(!p_sys) )
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys->p_es = NULL; p_sys->p_es = NULL;
p_sys->b_chan_reorder = false; p_sys->b_chan_reorder = false;
p_sys->i_channel_mask = 0; p_sys->i_channel_mask = 0;
...@@ -148,12 +148,12 @@ static int Open( vlc_object_t * p_this ) ...@@ -148,12 +148,12 @@ static int Open( vlc_object_t * p_this )
/* load waveformatex */ /* load waveformatex */
p_wf_ext = malloc( i_size ); p_wf_ext = malloc( i_size );
if( p_wf_ext == NULL ) if( unlikely( !p_wf_ext ) )
goto error; goto error;
p_wf = &p_wf_ext->Format; p_wf = &p_wf_ext->Format;
p_wf->cbSize = 0; p_wf->cbSize = 0;
i_size -= 2; i_size -= 2;
if( stream_Read( p_demux->s, p_wf, i_size ) != (int)i_size || if( stream_Read( p_demux->s, p_wf, i_size ) != (int)i_size ||
( ( i_size & 1 ) && stream_Read( p_demux->s, NULL, 1 ) != 1 ) ) ( ( i_size & 1 ) && stream_Read( p_demux->s, NULL, 1 ) != 1 ) )
{ {
...@@ -164,10 +164,10 @@ static int Open( vlc_object_t * p_this ) ...@@ -164,10 +164,10 @@ static int Open( vlc_object_t * p_this )
es_format_Init( &p_sys->fmt, AUDIO_ES, 0 ); es_format_Init( &p_sys->fmt, AUDIO_ES, 0 );
wf_tag_to_fourcc( GetWLE( &p_wf->wFormatTag ), &p_sys->fmt.i_codec, wf_tag_to_fourcc( GetWLE( &p_wf->wFormatTag ), &p_sys->fmt.i_codec,
&psz_name ); &psz_name );
p_sys->fmt.audio.i_channels = GetWLE ( &p_wf->nChannels ); p_sys->fmt.audio.i_channels = GetWLE ( &p_wf->nChannels );
p_sys->fmt.audio.i_rate = GetDWLE( &p_wf->nSamplesPerSec ); p_sys->fmt.audio.i_rate = GetDWLE( &p_wf->nSamplesPerSec );
p_sys->fmt.audio.i_blockalign = GetWLE( &p_wf->nBlockAlign ); p_sys->fmt.audio.i_blockalign = GetWLE( &p_wf->nBlockAlign );
p_sys->fmt.i_bitrate = GetDWLE( &p_wf->nAvgBytesPerSec ) * 8; p_sys->fmt.i_bitrate = GetDWLE( &p_wf->nAvgBytesPerSec ) * 8;
p_sys->fmt.audio.i_bitspersample = GetWLE( &p_wf->wBitsPerSample ); p_sys->fmt.audio.i_bitspersample = GetWLE( &p_wf->wBitsPerSample );
if( i_size >= sizeof(WAVEFORMATEX) ) if( i_size >= sizeof(WAVEFORMATEX) )
p_sys->fmt.i_extra = __MIN( GetWLE( &p_wf->cbSize ), i_size - sizeof(WAVEFORMATEX) ); p_sys->fmt.i_extra = __MIN( GetWLE( &p_wf->cbSize ), i_size - sizeof(WAVEFORMATEX) );
...@@ -181,7 +181,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -181,7 +181,7 @@ static int Open( vlc_object_t * p_this )
( p_sys->fmt.i_extra + sizeof( WAVEFORMATEX ) ( p_sys->fmt.i_extra + sizeof( WAVEFORMATEX )
>= sizeof( WAVEFORMATEXTENSIBLE ) ) ) >= sizeof( WAVEFORMATEXTENSIBLE ) ) )
{ {
unsigned i, i_channel_mask; unsigned i_channel_mask;
GUID guid_subformat; GUID guid_subformat;
guid_subformat = p_wf_ext->SubFormat; guid_subformat = p_wf_ext->SubFormat;
...@@ -198,7 +198,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -198,7 +198,7 @@ static int Open( vlc_object_t * p_this )
if( i_channel_mask ) if( i_channel_mask )
{ {
int i_match = 0; int i_match = 0;
for( i = 0; i < sizeof(pi_channels_src)/sizeof(*pi_channels_src); i++ ) for( unsigned i = 0; i < sizeof(pi_channels_src)/sizeof(*pi_channels_src); i++ )
{ {
if( i_channel_mask & pi_channels_src[i] ) if( i_channel_mask & pi_channels_src[i] )
{ {
...@@ -286,7 +286,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -286,7 +286,7 @@ static int Open( vlc_object_t * p_this )
if( p_sys->fmt.i_extra > 0 ) if( p_sys->fmt.i_extra > 0 )
{ {
p_sys->fmt.p_extra = malloc( p_sys->fmt.i_extra ); p_sys->fmt.p_extra = malloc( p_sys->fmt.i_extra );
if( !p_sys->fmt.p_extra ) if( unlikely(!p_sys->fmt.p_extra) )
{ {
p_sys->fmt.i_extra = 0; p_sys->fmt.i_extra = 0;
goto error; goto error;
...@@ -444,7 +444,7 @@ static int Demux( demux_t *p_demux ) ...@@ -444,7 +444,7 @@ static int Demux( demux_t *p_demux )
static void Close ( vlc_object_t * p_this ) static void Close ( vlc_object_t * p_this )
{ {
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
free( p_sys ); free( p_sys );
} }
......
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