Commit 474126cf authored by Laurent Aimar's avatar Laurent Aimar

* all: some clean up with WAVEFORMATEX and endian issues. Somebody could

test if mp4,asf,avi,wav demuxers and araw,ffmpeg,faad decoders work under
big endian architectures ? (else could you give vlc log )
parent 6da19ad6
......@@ -2,7 +2,7 @@
* araw.c: Pseudo audio decoder; for raw pcm data
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: araw.c,v 1.7 2002/11/14 22:38:47 massiot Exp $
* $Id: araw.c,v 1.8 2002/11/28 16:32:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -31,25 +31,16 @@
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include "codecs.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
typedef struct waveformatex_s
{
u16 i_formattag;
u16 i_channels;
u32 i_samplespersec;
u32 i_avgbytespersec;
u16 i_blockalign;
u16 i_bitspersample;
u16 i_size; /* the extra size in bytes */
u8 *p_data; /* The extra data */
} waveformatex_t;
typedef struct adec_thread_s
{
waveformatex_t format;
WAVEFORMATEX *p_wf;
//waveformatex_t format;
/* The bit stream structure handles the PES stream at the bit level */
// bit_stream_t bit_stream;
......@@ -171,7 +162,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
#define GetDWLE( p ) \
( *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) + \
( *((u8*)(p)+2) << 16 ) + ( *((u8*)(p)+3) << 24 ) )
#if 0
static void GetWaveFormatEx( waveformatex_t *p_wh,
u8 *p_data )
{
......@@ -193,6 +185,7 @@ static void GetWaveFormatEx( waveformatex_t *p_wh,
}
}
}
#endif
/*****************************************************************************
* InitThread: initialize data before entering main loop
......@@ -201,31 +194,30 @@ static void GetWaveFormatEx( waveformatex_t *p_wh,
static int InitThread( adec_thread_t * p_adec )
{
if( p_adec->p_fifo->p_demux_data )
{
GetWaveFormatEx( &p_adec->format,
(u8*)p_adec->p_fifo->p_demux_data );
/* fixing some values */
if( p_adec->format.i_formattag == 1 && !p_adec->format.i_blockalign )
{
p_adec->format.i_blockalign = p_adec->format.i_channels *
( ( p_adec->format.i_bitspersample + 7 ) / 8 );
}
}
else
if( !p_adec->p_fifo->p_demux_data )
{
msg_Err( p_adec->p_fifo, "unknown raw format" );
return( -1 );
}
p_adec->p_wf = (WAVEFORMATEX*)p_adec->p_fifo->p_demux_data;
/* fixing some values */
if( p_adec->p_wf->wFormatTag == WAVE_FORMAT_PCM &&
!p_adec->p_wf->nBlockAlign )
{
p_adec->p_wf->nBlockAlign =
p_adec->p_wf->nChannels *
( ( p_adec->p_wf->wBitsPerSample + 7 ) / 8 );
}
msg_Dbg( p_adec->p_fifo,
"raw format: samplerate:%dHz channels:%d bits/sample:%d blockalign:%d",
p_adec->format.i_samplespersec,
p_adec->format.i_channels,
p_adec->format.i_bitspersample, p_adec->format.i_blockalign );
p_adec->p_wf->nSamplesPerSec,
p_adec->p_wf->nChannels,
p_adec->p_wf->wBitsPerSample,
p_adec->p_wf->nBlockAlign );
/* Initialize the thread properties */
switch( ( p_adec->format.i_bitspersample + 7 ) / 8 )
switch( ( p_adec->p_wf->wBitsPerSample + 7 ) / 8 )
{
case( 2 ):
p_adec->output_format.i_format = VLC_FOURCC('s','1','6','l');
......@@ -243,10 +235,10 @@ static int InitThread( adec_thread_t * p_adec )
msg_Err( p_adec->p_fifo, "bad parameters(bits/sample)" );
return( -1 );
}
p_adec->output_format.i_rate = p_adec->format.i_samplespersec;
p_adec->output_format.i_rate = p_adec->p_wf->nSamplesPerSec;
if( p_adec->format.i_channels <= 0 ||
p_adec->format.i_channels > 5 )
if( p_adec->p_wf->nChannels <= 0 ||
p_adec->p_wf->nChannels > 5 )
{
msg_Err( p_adec->p_fifo, "bad channels count(1-5)" );
return( -1 );
......@@ -254,7 +246,7 @@ static int InitThread( adec_thread_t * p_adec )
p_adec->output_format.i_physical_channels =
p_adec->output_format.i_original_channels =
pi_channels_maps[p_adec->format.i_channels];
pi_channels_maps[p_adec->p_wf->nChannels];
p_adec->p_aout = NULL;
p_adec->p_aout_input = NULL;
......@@ -328,11 +320,11 @@ static void DecodeThread( adec_thread_t *p_adec )
}
i_size = p_pes->i_pes_size;
if( p_adec->format.i_blockalign > 0 )
if( p_adec->p_wf->nBlockAlign > 0 )
{
i_size -= i_size % p_adec->format.i_blockalign;
i_size -= i_size % p_adec->p_wf->nBlockAlign;
}
i_size = __MAX( i_size, p_adec->format.i_blockalign );
i_size = __MAX( i_size, p_adec->p_wf->nBlockAlign );
if( !i_size || !p_pes )
{
......@@ -340,8 +332,8 @@ static void DecodeThread( adec_thread_t *p_adec )
return;
}
i_samples = i_size /
( ( p_adec->format.i_bitspersample + 7 ) / 8 ) /
p_adec->format.i_channels;
( ( p_adec->p_wf->wBitsPerSample + 7 ) / 8 ) /
p_adec->p_wf->nChannels;
// msg_Warn( p_adec->p_fifo, "got %d samples (%d bytes)", i_samples, i_size );
p_adec->pts = p_pes->i_pts;
......@@ -390,8 +382,6 @@ static void EndThread (adec_thread_t *p_adec)
aout_DecDelete( p_adec->p_aout, p_adec->p_aout_input );
}
FREE( p_adec->format.p_data );
msg_Dbg( p_adec->p_fifo, "raw audio decoder closed" );
free( p_adec );
......
......@@ -2,7 +2,7 @@
* decoder.c: AAC decoder using libfaad2
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: decoder.c,v 1.13 2002/11/15 01:17:08 fenrir Exp $
* $Id: decoder.c,v 1.14 2002/11/28 16:32:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -33,7 +33,7 @@
#include <string.h> /* strdup() */
#include <faad.h>
#include "codecs.h"
#include "decoder.h"
......@@ -141,19 +141,22 @@ static int pi_channels_maps[6] =
static void faac_GetWaveFormatEx( waveformatex_t *p_wh,
u8 *p_data )
{
p_wh->i_formattag = GetWLE( p_data );
p_wh->i_nb_channels = GetWLE( p_data + 2 );
p_wh->i_samplespersec = GetDWLE( p_data + 4 );
p_wh->i_avgbytespersec= GetDWLE( p_data + 8 );
p_wh->i_blockalign = GetWLE( p_data + 12 );
p_wh->i_bitspersample = GetWLE( p_data + 14 );
p_wh->i_size = GetWLE( p_data + 16 );
WAVEFORMATEX *p_wfdata = (WAVEFORMATEX*)p_data;
p_wh->i_formattag = p_wfdata->wFormatTag;
p_wh->i_nb_channels = p_wfdata->nChannels;
p_wh->i_samplespersec = p_wfdata->nSamplesPerSec;
p_wh->i_avgbytespersec= p_wfdata->nAvgBytesPerSec;
p_wh->i_blockalign = p_wfdata->nBlockAlign;
p_wh->i_bitspersample = p_wfdata->wBitsPerSample;
p_wh->i_size = p_wfdata->cbSize;
if( p_wh->i_size )
{
p_wh->p_data = malloc( p_wh->i_size );
memcpy( p_wh->p_data, p_data + 18, p_wh->i_size );
memcpy( p_wh->p_data,
p_data + sizeof(WAVEFORMATEX) ,
p_wh->i_size );
}
}
......
......@@ -2,7 +2,7 @@
* audio.c: audio decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio.c,v 1.4 2002/11/27 12:41:45 fenrir Exp $
* $Id: audio.c,v 1.5 2002/11/28 16:32:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -42,11 +42,11 @@
#ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
#include "codecs.h"
#include "avcodec.h" /* ffmpeg */
#include "postprocessing/postprocessing.h"
//#include "postprocessing/postprocessing.h"
#include "ffmpeg.h"
#include "audio.h"
......@@ -74,18 +74,22 @@ static int pi_channels_maps[6] =
static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
u8 *p_data )
{
p_wh->i_formattag = GetWLE( p_data );
p_wh->i_nb_channels = GetWLE( p_data + 2 );
p_wh->i_samplespersec = GetDWLE( p_data + 4 );
p_wh->i_avgbytespersec= GetDWLE( p_data + 8 );
p_wh->i_blockalign = GetWLE( p_data + 12 );
p_wh->i_bitspersample = GetWLE( p_data + 14 );
p_wh->i_size = GetWLE( p_data + 16 );
WAVEFORMATEX *p_wfdata = (WAVEFORMATEX*)p_data;
p_wh->i_formattag = p_wfdata->wFormatTag;
p_wh->i_nb_channels = p_wfdata->nChannels;
p_wh->i_samplespersec = p_wfdata->nSamplesPerSec;
p_wh->i_avgbytespersec= p_wfdata->nAvgBytesPerSec;
p_wh->i_blockalign = p_wfdata->nBlockAlign;
p_wh->i_bitspersample = p_wfdata->wBitsPerSample;
p_wh->i_size = p_wfdata->cbSize;
if( p_wh->i_size )
{
p_wh->p_data = malloc( p_wh->i_size );
memcpy( p_wh->p_data, p_data + 18, p_wh->i_size );
memcpy( p_wh->p_data,
p_data + sizeof(WAVEFORMATEX) ,
p_wh->i_size );
}
}
......
......@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.19 2002/11/27 14:44:06 fenrir Exp $
* $Id: ffmpeg.c,v 1.20 2002/11/28 16:32:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -495,6 +495,7 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
case FOURCC_mjpg:
case FOURCC_mjpa:
case FOURCC_jpeg:
case FOURCC_JPEG:
case FOURCC_JFIF:
i_cat = VIDEO_ES;
i_codec = CODEC_ID_MJPEG;
......
......@@ -2,7 +2,7 @@
* ffmpeg_vdec.h: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ffmpeg.h,v 1.9 2002/11/27 12:41:45 fenrir Exp $
* $Id: ffmpeg.h,v 1.10 2002/11/28 16:32:29 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -131,6 +131,7 @@ int E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes );
#define FOURCC_mjpb VLC_FOURCC( 'm', 'j', 'p', 'b' )
#define FOURCC_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' )
#define FOURCC_JPEG VLC_FOURCC( 'J', 'P', 'E', 'G' )
#define FOURCC_JFIF VLC_FOURCC( 'J', 'F', 'I', 'F' )
/* wmv */
......
......@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: asf.c,v 1.8 2002/11/25 15:08:34 fenrir Exp $
* $Id: asf.c,v 1.9 2002/11/28 16:32:29 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -239,11 +239,29 @@ static int Activate( vlc_object_t * p_this )
}
if( p_sp->i_type_specific_data_length > 0 )
{
p_stream->p_es->p_demux_data =
malloc( p_sp->i_type_specific_data_length );
memcpy( p_stream->p_es->p_demux_data,
p_sp->p_type_specific_data,
p_sp->i_type_specific_data_length );
WAVEFORMATEX *p_wf;
int i_size;
uint8_t *p_data;
i_size = p_sp->i_type_specific_data_length;
p_wf = malloc( i_size );
p_stream->p_es->p_demux_data = (void*)p_wf;
p_data = p_sp->p_type_specific_data;
p_wf->wFormatTag = GetWLE( p_data );
p_wf->nChannels = GetWLE( p_data + 2 );
p_wf->nSamplesPerSec = GetDWLE( p_data + 4 );
p_wf->nAvgBytesPerSec = GetDWLE( p_data + 8 );
p_wf->nBlockAlign = GetWLE( p_data + 12 );
p_wf->wBitsPerSample = GetWLE( p_data + 14 );
p_wf->cbSize = i_size - sizeof( WAVEFORMATEX );
if( i_size > sizeof( WAVEFORMATEX ) )
{
memcpy( (uint8_t*)p_stream->p_es->p_demux_data + sizeof( WAVEFORMATEX ),
p_data + sizeof( WAVEFORMATEX ),
i_size - sizeof( WAVEFORMATEX ) );
}
}
}
......@@ -257,7 +275,10 @@ static int Activate( vlc_object_t * p_this )
if( p_sp->p_type_specific_data )
{
p_stream->p_es->i_fourcc =
GetDWLE( p_sp->p_type_specific_data + 27 );
VLC_FOURCC( p_sp->p_type_specific_data + 27,
p_sp->p_type_specific_data + 28,
p_sp->p_type_specific_data + 29,
p_sp->p_type_specific_data + 30 );
}
else
{
......
......@@ -2,7 +2,7 @@
* mp4.c : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mp4.c,v 1.7 2002/11/26 17:28:22 fenrir Exp $
* $Id: mp4.c,v 1.8 2002/11/28 16:32:29 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -90,7 +90,6 @@ static int MP4Init( vlc_object_t * p_this )
{
input_thread_t *p_input = (input_thread_t *)p_this;
uint8_t *p_peek;
uint32_t i_type;
demux_sys_t *p_demux;
......@@ -123,9 +122,9 @@ static int MP4Init( vlc_object_t * p_this )
msg_Warn( p_input, "MP4 plugin discarded (cannot peek)" );
return( -1 );
}
i_type = ( p_peek[4] ) + ( p_peek[5] << 8 ) +
( p_peek[6] << 16 ) + ( p_peek[7] << 24);
switch( i_type )
switch( VLC_FOURCC( p_peek[4], p_peek[5], p_peek[6], p_peek[7] ) )
{
case( FOURCC_ftyp ):
case( FOURCC_moov ):
......@@ -910,6 +909,7 @@ static void MP4_StartDecoder( input_thread_t *p_input,
uint8_t *p_init;
BITMAPINFOHEADER *p_bih;
WAVEFORMATEX *p_wf;
MP4_Box_t *p_esds;
......@@ -1090,24 +1090,22 @@ static void MP4_StartDecoder( input_thread_t *p_input,
break;
case( AUDIO_ES ):
p_init = malloc( 18 + i_decoder_specific_info_len);
memset( p_init, 0, 18 + i_decoder_specific_info_len);
MP4_Set2BytesLE( p_init + 2, /* i_channel */
p_sample->data.p_sample_soun->i_channelcount );
MP4_Set4BytesLE( p_init + 4, /* samplepersec */
p_sample->data.p_sample_soun->i_sampleratehi );
MP4_Set4BytesLE( p_init + 8, /* avgbytespersec */
p_sample->data.p_sample_soun->i_channelcount *
p_sample->data.p_sample_soun->i_sampleratehi *
(p_sample->data.p_sample_soun->i_samplesize/8) );
MP4_Set2BytesLE( p_init + 14, /* bits/sample */
p_sample->data.p_sample_soun->i_samplesize );
MP4_Set2BytesLE( p_init + 16, /* i_size, specific info len*/
i_decoder_specific_info_len );
p_init = malloc( sizeof( WAVEFORMATEX ) + i_decoder_specific_info_len);
p_wf = (WAVEFORMATEX*)p_init;
p_wf->wFormatTag = 0;
p_wf->nChannels = p_sample->data.p_sample_soun->i_channelcount;
p_wf->nSamplesPerSec = p_sample->data.p_sample_soun->i_sampleratehi;
p_wf->nAvgBytesPerSec = p_sample->data.p_sample_soun->i_channelcount *
p_sample->data.p_sample_soun->i_sampleratehi *
p_sample->data.p_sample_soun->i_samplesize / 8;
p_wf->nBlockAlign = 0;
p_wf->wBitsPerSample = p_sample->data.p_sample_soun->i_samplesize;
p_wf->cbSize = i_decoder_specific_info_len;
if( i_decoder_specific_info_len )
{
memcpy( p_init + 18,
memcpy( p_init + sizeof( WAVEFORMATEX ),
p_decoder_specific_info,
i_decoder_specific_info_len);
}
......
......@@ -2,7 +2,7 @@
* wav.c : wav file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: wav.c,v 1.3 2002/11/21 13:53:32 sam Exp $
* $Id: wav.c,v 1.4 2002/11/28 16:32:29 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -29,6 +29,7 @@
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <codecs.h>
#include "wav.h"
/*****************************************************************************
......@@ -227,7 +228,9 @@ static int LoadTag_fmt( input_thread_t *p_input,
{
u8 *p_peek;
u32 i_size;
WAVEFORMATEX *p_wf;
if( input_Peek( p_input, &p_peek , 8 ) < 8 )
{
return( 0 );
......@@ -240,26 +243,22 @@ static int LoadTag_fmt( input_thread_t *p_input,
SkipBytes( p_input, i_size );
return( 0 );
}
p_demux->p_wf = malloc( i_size );
ReadData( p_input, p_demux->p_wf, __EVEN( i_size ) );
p_demux->format.i_format = GetWLE( p_demux->p_wf );
p_demux->format.i_channels = GetWLE( p_demux->p_wf + 2 );
p_demux->format.i_samplepersec = GetDWLE( p_demux->p_wf + 4 );
p_demux->format.i_avgbytespersec = GetDWLE( p_demux->p_wf + 8);
p_demux->format.i_blockalign = GetWLE( p_demux->p_wf + 12 );
p_demux->format.i_bitspersample = GetWLE( p_demux->p_wf + 14);
if( i_size > 18 )
p_wf = p_demux->p_wf = malloc( __MAX( i_size, sizeof( WAVEFORMATEX) ) );
ReadData( p_input, (uint8_t*)p_wf, __EVEN( i_size ) );
p_wf->wFormatTag = GetWLE( (uint8_t*)&p_demux->p_wf->wFormatTag );
p_wf->nChannels = GetWLE( (uint8_t*)&p_demux->p_wf->nChannels );
p_wf->nSamplesPerSec = GetWLE( (uint8_t*)&p_demux->p_wf->nSamplesPerSec );
p_wf->nAvgBytesPerSec = GetWLE( (uint8_t*)&p_demux->p_wf->nAvgBytesPerSec );
p_wf->nBlockAlign = GetWLE( (uint8_t*)&p_demux->p_wf->nBlockAlign );
p_wf->wBitsPerSample = GetWLE( (uint8_t*)&p_demux->p_wf->wBitsPerSample );
if( i_size >= sizeof( WAVEFORMATEX) )
{
p_demux->format.i_size = GetWLE( p_demux->p_wf + 16 );
p_demux->format.p_data = malloc( p_demux->format.i_size );
memcpy( p_demux->format.p_data,
p_demux->p_wf + 18,
p_demux->format.i_size );
p_wf->cbSize = GetWLE( (uint8_t*)&p_demux->p_wf->cbSize );
}
else
{
p_demux->format.i_size = 0;
p_demux->format.p_data = NULL;
p_wf->cbSize = 0;
}
msg_Dbg( p_input, "loaded \"fmt \" chunk" );
......@@ -267,9 +266,9 @@ static int LoadTag_fmt( input_thread_t *p_input,
}
static int PCM_GetFrame( input_thread_t *p_input,
waveformatex_t *p_wf,
pes_packet_t **pp_pes,
mtime_t *pi_length )
WAVEFORMATEX *p_wf,
pes_packet_t **pp_pes,
mtime_t *pi_length )
{
int i_samples;
......@@ -277,20 +276,20 @@ static int PCM_GetFrame( input_thread_t *p_input,
int i_modulo;
/* read samples for 50ms of */
i_samples = __MAX( p_wf->i_samplepersec / 20, 1 );
i_samples = __MAX( p_wf->nSamplesPerSec / 20, 1 );
*pi_length = (mtime_t)1000000 *
(mtime_t)i_samples /
(mtime_t)p_wf->i_samplepersec;
(mtime_t)p_wf->nSamplesPerSec;
i_bytes = i_samples * p_wf->i_channels * ( p_wf->i_bitspersample + 7 ) / 8;
i_bytes = i_samples * p_wf->nChannels * ( p_wf->wBitsPerSample + 7 ) / 8;
if( p_wf->i_blockalign > 0 )
if( p_wf->nBlockAlign > 0 )
{
if( ( i_modulo = i_bytes % p_wf->i_blockalign ) != 0 )
if( ( i_modulo = i_bytes % p_wf->nBlockAlign ) != 0 )
{
i_bytes += p_wf->i_blockalign - i_modulo;
i_bytes += p_wf->nBlockAlign - i_modulo;
}
}
......@@ -348,7 +347,7 @@ static int WAVInit( vlc_object_t * p_this )
}
memset( p_demux, 0, sizeof( demux_sys_t ) );
/* Load waveformatex_t header */
/* Load WAVEFORMATEX header */
if( !LoadTag_fmt( p_input, p_demux ) )
{
msg_Err( p_input, "cannot load \"fmt \" tag" );
......@@ -356,19 +355,18 @@ static int WAVInit( vlc_object_t * p_this )
return( -1 );
}
msg_Dbg( p_input, "format:0x%4.4x channels:%d %dHz %dKo/s blockalign:%d bits/samples:%d extra size:%d",
p_demux->format.i_format,
p_demux->format.i_channels,
p_demux->format.i_samplepersec,
p_demux->format.i_avgbytespersec/1024,
p_demux->format.i_blockalign,
p_demux->format.i_bitspersample,
p_demux->format.i_size );
p_demux->p_wf->wFormatTag,
p_demux->p_wf->nChannels,
p_demux->p_wf->nSamplesPerSec,
p_demux->p_wf->nAvgBytesPerSec / 1024,
p_demux->p_wf->nBlockAlign,
p_demux->p_wf->wBitsPerSample,
p_demux->p_wf->cbSize );
if( !FindTag( p_input, CreateDWLE( 'd', 'a', 't', 'a' ) ) )
{
msg_Err( p_input, "cannot find \"data\" tag" );
FREE( p_demux->p_wf );
FREE( p_demux->format.p_data );
FREE( p_demux );
return( -1 );
}
......@@ -376,7 +374,6 @@ static int WAVInit( vlc_object_t * p_this )
{
msg_Warn( p_input, "WAV plugin discarded (cannot peek)" );
FREE( p_demux->p_wf );
FREE( p_demux->format.p_data );
FREE( p_demux );
return( -1 );
}
......@@ -386,7 +383,7 @@ static int WAVInit( vlc_object_t * p_this )
SkipBytes( p_input, 8 );
/* XXX p_demux->psz_demux shouldn't be NULL ! */
switch( p_demux->format.i_format )
switch( p_demux->p_wf->wFormatTag )
{
case( 0x01 ):
msg_Dbg( p_input,"found raw pcm audio format" );
......@@ -409,11 +406,11 @@ static int WAVInit( vlc_object_t * p_this )
break;
default:
msg_Warn( p_input,"unrecognize audio format(0x%x)",
p_demux->format.i_format );
p_demux->p_wf->wFormatTag );
p_demux->i_fourcc =
VLC_FOURCC( 'm', 's',
(p_demux->format.i_format >> 8)&0xff,
(p_demux->format.i_format )&0xff);
(p_demux->p_wf->wFormatTag >> 8)&0xff,
(p_demux->p_wf->wFormatTag )&0xff);
p_demux->GetFrame = NULL;
p_demux->psz_demux = strdup( "" );
break;
......@@ -451,12 +448,9 @@ static int WAVInit( vlc_object_t * p_this )
p_demux->p_es->i_stream_id = 1;
p_demux->p_es->i_fourcc = p_demux->i_fourcc;
p_demux->p_es->i_cat = AUDIO_ES;
if( p_demux->i_wf > 0 && p_demux->p_wf )
{
memcpy( p_demux->p_es->p_demux_data,
p_demux->p_wf,
p_demux->i_wf );
}
memcpy( p_demux->p_es->p_demux_data,
p_demux->p_wf,
p_demux->i_wf );
input_SelectES( p_input, p_demux->p_es );
......@@ -480,10 +474,9 @@ static int WAVInit( vlc_object_t * p_this )
{
msg_Err( p_input,
"cannot get external demux for formattag 0x%x",
p_demux->format.i_format );
p_demux->p_wf->wFormatTag );
FREE( p_demux->psz_demux );
FREE( p_demux->p_wf );
FREE( p_demux->format.p_data );
FREE( p_demux );
return( -1 );
}
......@@ -496,7 +489,6 @@ static int WAVInit( vlc_object_t * p_this )
}
return( 0 );
}
......@@ -555,10 +547,10 @@ static int WAVDemux( input_thread_t *p_input )
SeekAbsolute( p_input, p_demux->i_data_pos );
}
else
if( p_demux->format.i_blockalign != 0 )
if( p_demux->p_wf->nBlockAlign != 0 )
{
i_offset = i_offset - i_offset % p_demux->format.i_blockalign;
i_offset = i_offset - i_offset % p_demux->p_wf->nBlockAlign;
SeekAbsolute( p_input, p_demux->i_data_pos + i_offset );
}
}
......@@ -572,7 +564,7 @@ static int WAVDemux( input_thread_t *p_input )
return( 0 ); // EOF
}
if( !p_demux->GetFrame( p_input, &p_demux->format, &p_pes, &i_length ) )
if( !p_demux->GetFrame( p_input, p_demux->p_wf, &p_pes, &i_length ) )
{
msg_Warn( p_input, "failed to get one frame" );
return( 0 );
......@@ -607,7 +599,6 @@ static void __WAVEnd ( vlc_object_t * p_this )
demux_sys_t *p_demux = p_input->p_demux_data;
FREE( p_demux->p_wf );
FREE( p_demux->format.p_data );
FREE( p_demux->psz_demux );
if( p_demux->p_demux )
......
......@@ -2,7 +2,7 @@
* wav.h : wav file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: wav.h,v 1.1 2002/10/14 21:59:44 fenrir Exp $
* $Id: wav.h,v 1.2 2002/11/28 16:32:29 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -25,23 +25,6 @@
/*****************************************************************************
* Structure needed for decoder
*****************************************************************************/
typedef struct waveformatex_s
{
u16 i_format;
u16 i_channels;
u32 i_samplepersec;
u32 i_avgbytespersec;
u16 i_blockalign;
u16 i_bitspersample;
u16 i_size; /* This give size of data
imediatly following this header. */
u8 *p_data;
} waveformatex_t;
/*****************************************************************************
*