/*****************************************************************************
* wav.c : wav file input module for vlc
*****************************************************************************
- * Copyright (C) 2001-2008 the VideoLAN team
+ * Copyright (C) 2001-2008 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
- * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
es_out_id_t *p_es;
int64_t i_data_pos;
- unsigned int i_data_size;
+ int64_t i_data_size;
unsigned int i_frame_size;
int i_frame_samples;
date_t pts;
uint32_t i_channel_mask;
- bool b_chan_reorder; /* do we need channel reordering */
- int pi_chan_table[AOUT_CHAN_MAX];
+ uint8_t i_chans_to_reorder; /* do we need channel reordering */
+ uint8_t pi_chan_table[AOUT_CHAN_MAX];
};
static int ChunkFind( demux_t *, const char *, unsigned int * );
demux_sys_t *p_sys;
const uint8_t *p_peek;
+ bool b_is_rf64;
unsigned int i_size;
+ uint64_t i_data_size;
unsigned int i_extended;
const char *psz_name;
if( stream_Peek( p_demux->s, &p_peek, 12 ) < 12 )
return VLC_EGENERIC;
- if( memcmp( p_peek, "RIFF", 4 ) || memcmp( &p_peek[8], "WAVE", 4 ) )
+ b_is_rf64 = ( memcmp( p_peek, "RF64", 4 ) == 0 );
+ if( ( !b_is_rf64 && memcmp( p_peek, "RIFF", 4 ) ) ||
+ memcmp( &p_peek[8], "WAVE", 4 ) )
{
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_sys->p_es = NULL;
- p_sys->b_chan_reorder = false;
+ p_sys->i_data_size = 0;
+ p_sys->i_chans_to_reorder = 0;
p_sys->i_channel_mask = 0;
/* skip riff header */
if( stream_Read( p_demux->s, NULL, 12 ) != 12 )
goto error;
+ if( b_is_rf64 )
+ {
+ /* search datasize64 chunk */
+ if( ChunkFind( p_demux, "ds64", &i_size ) )
+ {
+ msg_Err( p_demux, "cannot find 'ds64' chunk" );
+ goto error;
+ }
+ if( i_size < 24 )
+ {
+ msg_Err( p_demux, "invalid 'ds64' chunk" );
+ goto error;
+ }
+ if( stream_Read( p_demux->s, NULL, 8 ) != 8 )
+ goto error;
+ if( stream_Peek( p_demux->s, &p_peek, 24 ) < 24 )
+ goto error;
+ i_data_size = GetQWLE( &p_peek[8] );
+ if( i_data_size >> 62 )
+ p_sys->i_data_size = (int64_t)1 << 62;
+ else
+ p_sys->i_data_size = i_data_size;
+ if( stream_Read( p_demux->s, NULL, i_size ) != (int)i_size ||
+ ( (i_size & 1) && stream_Read( p_demux->s, NULL, 1 ) != 1 ) )
+ goto error;
+ }
+
/* search fmt chunk */
if( ChunkFind( p_demux, "fmt ", &i_size ) )
{
if( p_sys->i_channel_mask )
{
if( p_sys->fmt.i_codec == VLC_FOURCC('a','r','a','w') ||
- p_sys->fmt.i_codec == VLC_FOURCC('p','c','m',' ') ||
p_sys->fmt.i_codec == VLC_FOURCC('a','f','l','t') )
- p_sys->b_chan_reorder =
+ p_sys->i_chans_to_reorder =
aout_CheckChannelReorder( pi_channels_in, NULL,
p_sys->i_channel_mask,
- p_sys->fmt.audio.i_channels,
p_sys->pi_chan_table );
- msg_Dbg( p_demux, "channel mask: %x, reordering: %i",
- p_sys->i_channel_mask, (int)p_sys->b_chan_reorder );
+ msg_Dbg( p_demux, "channel mask: %x, reordering: %u",
+ p_sys->i_channel_mask, p_sys->i_chans_to_reorder );
}
p_sys->fmt.audio.i_physical_channels =
case VLC_FOURCC( 'u', 'l', 'a', 'w' ):
case VLC_CODEC_ALAW:
case VLC_CODEC_MULAW:
- case VLC_FOURCC( 'p', 'c', 'm', ' ' ):
if( FrameInfo_PCM( &p_sys->i_frame_size, &p_sys->i_frame_samples,
&p_sys->fmt ) )
goto error;
+ p_sys->fmt.i_codec =
+ vlc_fourcc_GetCodecAudio( p_sys->fmt.i_codec,
+ p_sys->fmt.audio.i_bitspersample );
break;
case VLC_CODEC_ADPCM_MS:
+ /* FIXME not sure at all FIXME */
+ case VLC_FOURCC( 'm', 's', 0x00, 0x61 ):
+ case VLC_FOURCC( 'm', 's', 0x00, 0x62 ):
if( FrameInfo_MS_ADPCM( &p_sys->i_frame_size, &p_sys->i_frame_samples,
&p_sys->fmt ) )
goto error;
&p_sys->fmt ) )
goto error;
break;
- case VLC_FOURCC( 'm', 's', 0x00, 0x61 ):
- case VLC_FOURCC( 'm', 's', 0x00, 0x62 ):
- /* FIXME not sure at all FIXME */
- if( FrameInfo_MS_ADPCM( &p_sys->i_frame_size, &p_sys->i_frame_samples,
- &p_sys->fmt ) )
- goto error;
- break;
case VLC_CODEC_MPGA:
case VLC_CODEC_A52:
/* FIXME set end of area FIXME */
goto error;
case VLC_CODEC_GSM_MS:
case VLC_CODEC_ADPCM_G726:
+ case VLC_CODEC_TRUESPEECH:
+ case VLC_CODEC_ATRAC3:
+ case VLC_CODEC_G723_1:
+ case VLC_CODEC_WMA2:
if( FrameInfo_MSGSM( &p_sys->i_frame_size, &p_sys->i_frame_samples,
&p_sys->fmt ) )
goto error;
msg_Dbg( p_demux, "found %s audio format", psz_name );
- if( ChunkFind( p_demux, "data", &p_sys->i_data_size ) )
+ if( ChunkFind( p_demux, "data", &i_size ) )
{
msg_Err( p_demux, "cannot find 'data' chunk" );
goto error;
}
+ if( !b_is_rf64 || i_size < UINT32_MAX )
+ p_sys->i_data_size = i_size;
if( stream_Read( p_demux->s, NULL, 8 ) != 8 )
goto error;
p_sys->i_data_pos = stream_Tell( p_demux->s );
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
/* Do the channel reordering */
- if( p_sys->b_chan_reorder )
+ if( p_sys->i_chans_to_reorder )
aout_ChannelReorder( p_block->p_buffer, p_block->i_buffer,
p_sys->fmt.audio.i_channels,
- p_sys->pi_chan_table,
- p_sys->fmt.audio.i_bitspersample );
+ p_sys->pi_chan_table, p_sys->fmt.i_codec );
es_out_Send( p_demux->out, p_sys->p_es, p_block );