* wav.c : wav file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: wav.c,v 1.1 2003/08/01 00:09:37 fenrir Exp $
+ * $Id: wav.c,v 1.4 2003/08/18 00:17:44 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* Module descriptor
*****************************************************************************/
-static int Activate ( vlc_object_t * );
-static void Deactivate ( vlc_object_t * );
+static int Open ( vlc_object_t * );
+static void Close ( vlc_object_t * );
vlc_module_begin();
set_description( _("WAV demuxer") );
set_capability( "demux", 142 );
- set_callbacks( Activate, Deactivate );
+ set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
*****************************************************************************/
#define __EVEN( x ) ( ( (x)%2 != 0 ) ? ((x)+1) : (x) )
-#define GetWLE( p ) __GetWLE( (uint8_t*)(p) )
-static inline uint32_t __GetWLE( uint8_t *p )
-{
- return( p[0] + ( p[1] << 8 ) );
-}
-#define GetDWLE( p ) __GetDWLE( (uint8_t*)(p) )
-static inline uint32_t __GetDWLE( uint8_t *p )
-{
- return( p[0] + ( p[1] << 8 ) + ( p[2] << 16 ) + ( p[3] << 24 ) );
-}
-
static int ChunkFind( input_thread_t *, char *, unsigned int * );
static void FrameInfo_IMA_ADPCM( input_thread_t *, unsigned int *, mtime_t * );
static void FrameInfo_PCM ( input_thread_t *, unsigned int *, mtime_t * );
/*****************************************************************************
- * Activate: check file and initializes structures
+ * Open: check file and initializes structures
*****************************************************************************/
-static int Activate( vlc_object_t * p_this )
+static int Open( vlc_object_t * p_this )
{
input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_sys;
uint8_t *p_peek;
unsigned int i_size;
vlc_fourcc_t i_fourcc;
+ char *psz_name;
/* Is it a wav file ? */
if( input_Peek( p_input, &p_peek, 12 ) < 12 )
stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */
- /* XXX p_sys->psz_demux shouldn't be NULL ! */
- switch( p_sys->p_wf->wFormatTag )
+ wf_tag_to_fourcc( p_sys->p_wf->wFormatTag, &i_fourcc, &psz_name );
+ if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) )
{
- case( WAVE_FORMAT_PCM ):
- msg_Dbg( p_input,"found raw pcm audio format" );
- i_fourcc = VLC_FOURCC( 'a', 'r', 'a', 'w' );
- FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
- break;
- case( WAVE_FORMAT_MULAW ):
- msg_Dbg( p_input,"found mulaw pcm audio format" );
- i_fourcc = VLC_FOURCC( 'u', 'l', 'a', 'w' );
- FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
- break;
- case( WAVE_FORMAT_ALAW ):
- msg_Dbg( p_input,"found alaw pcm audio format" );
- i_fourcc = VLC_FOURCC( 'a', 'l', 'a', 'w' );
+ msg_Err( p_input,"unrecognize audio format(0x%x)",
+ p_sys->p_wf->wFormatTag );
+ goto error;
+ }
+
+ switch( i_fourcc )
+ {
+ case VLC_FOURCC( 'a', 'r', 'a', 'w' ):
+ case VLC_FOURCC( 'u', 'l', 'a', 'w' ):
+ case VLC_FOURCC( 'a', 'l', 'a', 'w' ):
FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
- case( WAVE_FORMAT_ADPCM ):
- msg_Dbg( p_input, "found ms adpcm audio format" );
- i_fourcc = VLC_FOURCC( 'm', 's', 0x00, 0x02 );
+ case VLC_FOURCC( 'm', 's', 0x00, 0x02 ):
FrameInfo_MS_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
- case( WAVE_FORMAT_IMA_ADPCM ):
- msg_Dbg( p_input, "found ima adpcm audio format" );
- i_fourcc = VLC_FOURCC( 'm', 's', 0x00, 0x11 );
+ case VLC_FOURCC( 'm', 's', 0x00, 0x11 ):
FrameInfo_IMA_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
-
- case( WAVE_FORMAT_MPEG ):
- case( WAVE_FORMAT_MPEGLAYER3 ):
- msg_Dbg( p_input, "found mpeg audio format (relaying to another demux)" );
- /* FIXME set end of area FIXME */
- goto relay;
- case( WAVE_FORMAT_A52 ):
- msg_Dbg( p_input,"found a52 audio format (relaying to another demux)" );
+ case VLC_FOURCC( 'm', 's', 0x00, 0x61 ):
+ case VLC_FOURCC( 'm', 's', 0x00, 0x62 ):
+ /* FIXME not sure at all FIXME */
+ FrameInfo_MS_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
+ break;
+ case VLC_FOURCC( 'm', 'p', 'g', 'a' ):
+ case VLC_FOURCC( 'a', '5', '2', ' ' ):
/* FIXME set end of area FIXME */
goto relay;
-
default:
- msg_Err( p_input,"unrecognize audio format(0x%x)",
- p_sys->p_wf->wFormatTag );
+ msg_Err( p_input, "unsupported codec (%4.4s)", (char*)&i_fourcc );
goto error;
}
+ msg_Dbg( p_input, "found %s audio format", psz_name );
/* create one program */
if( p_sys->i_data_size > 0 )
{
- p_input->stream.i_mux_rate = (mtime_t)p_sys->i_frame_size * (mtime_t)1000000 / 50 / p_sys->i_frame_length;
+ p_input->stream.i_mux_rate = (mtime_t)p_sys->i_frame_size *
+ (mtime_t)1000000 / 50 / p_sys->i_frame_length;
}
else
{
}
/*****************************************************************************
- * Deactivate: frees unused data
+ * Close: frees unused data
*****************************************************************************/
-static void Deactivate ( vlc_object_t * p_this )
+static void Close ( vlc_object_t * p_this )
{
input_thread_t *p_input = (input_thread_t *)p_this;
demux_sys_t *p_sys = p_input->p_demux_data;