Commit 25c8c4c9 authored by Laurent Aimar's avatar Laurent Aimar

* all: fix mpeg2 handling.

parent c4f86070
......@@ -2,7 +2,7 @@
* mpeg_audio.c: parse MPEG audio sync info and packetize the stream
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: mpeg_audio.c,v 1.9 2003/01/28 23:55:57 massiot Exp $
* $Id: mpeg_audio.c,v 1.10 2003/02/16 08:56:24 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -507,29 +507,27 @@ static int SyncInfo( uint32_t i_header, unsigned int * pi_channels,
switch( *pi_layer )
{
case 1:
i_current_frame_size = ( ( i_version ? 6000 : 12000 ) *
i_current_frame_size = ( 12000 *
*pi_bit_rate / *pi_sample_rate
+ b_padding ) * 4;
*pi_frame_size = ( ( i_version ? 6000 : 12000 ) *
*pi_frame_size = ( 12000 *
i_max_bit_rate / *pi_sample_rate + 1 ) * 4;
*pi_frame_length = 384;
break;
case 2:
i_current_frame_size = ( i_version ? 72000 : 144000 ) *
i_current_frame_size = 144000 *
*pi_bit_rate / *pi_sample_rate
+ b_padding;
*pi_frame_size = ( i_version ? 72000 : 144000 ) *
i_max_bit_rate / *pi_sample_rate + 1;
*pi_frame_size = 144000 * i_max_bit_rate / *pi_sample_rate + 1;
*pi_frame_length = 1152;
break;
case 3:
i_current_frame_size = ( i_version ? 72000 : 144000 ) *
i_current_frame_size = 144000 *
*pi_bit_rate / *pi_sample_rate
+ b_padding;
*pi_frame_size = ( i_version ? 72000 : 144000 ) *
i_max_bit_rate / *pi_sample_rate + 1;
*pi_frame_size = 144000 * i_max_bit_rate / *pi_sample_rate + 1;
*pi_frame_length = i_version ? 576 : 1152;
break;
......
......@@ -2,7 +2,7 @@
* audio.c : mpeg audio Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: audio.c,v 1.11 2003/02/07 01:22:55 fenrir Exp $
* $Id: audio.c,v 1.12 2003/02/16 08:56:24 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -62,7 +62,7 @@ vlc_module_end();
typedef struct mpeg_header_s
{
u32 i_header;
uint32_t i_header;
int i_version;
int i_layer;
int i_crc;
......@@ -89,7 +89,7 @@ typedef struct xing_header_s
int i_frames; /* total bit stream frames from Xing header data */
int i_bytes; /* total bit stream bytes from Xing header data */
int i_vbr_scale; /* encoded vbr scale from Xing header data */
u8 i_toc[100]; /* for seek */
uint8_t i_toc[100]; /* for seek */
int i_avgbitrate; /* calculated, XXX: bits/sec not Kb */
} xing_header_t;
......@@ -141,7 +141,7 @@ static char* mpegaudio_mode[4] =
"stereo", "joint stereo", "dual channel", "mono"
};
static inline u32 GetDWBE( u8 *p_buff )
static inline uint32_t GetDWBE( uint8_t *p_buff )
{
return( ( p_buff[0] << 24 )|( p_buff[1] << 16 )|
( p_buff[2] << 8 )|( p_buff[3] ) );
......@@ -222,7 +222,7 @@ static int ReadPES( input_thread_t *p_input,
/*****************************************************************************
* CheckHeader : Test the validity of the header
*****************************************************************************/
static int CheckHeader( u32 i_header )
static int CheckHeader( uint32_t i_header )
{
if( ((( i_header >> 20 )&0x0FFF) != 0x0FFF ) /* header sync */
|| (((i_header >> 17)&0x03) == 0 ) /* valid layer ?*/
......@@ -262,8 +262,8 @@ static int GetHeader( input_thread_t *p_input,
int i_max_pos,
int *pi_skip )
{
u32 i_header;
u8 *p_peek;
uint32_t i_header;
uint8_t *p_peek;
int i_size;
*pi_skip = 0;
......@@ -315,7 +315,7 @@ static void ExtractXingHeader( input_thread_t *p_input,
{
int i_skip;
int i_size;
u8 *p_peek;
uint8_t *p_peek;
mpeg_header_t mpeg;
p_xh->i_flags = 0; /* nothing present */
......@@ -406,8 +406,10 @@ static void ExtractXingHeader( input_thread_t *p_input,
if( ( p_xh->i_flags&FRAMES_FLAG )&&( p_xh->i_flags&BYTES_FLAG ) )
{
p_xh->i_avgbitrate =
((u64)p_xh->i_bytes * (u64)8 * (u64)mpeg.i_samplerate) /
((u64)p_xh->i_frames * (u64)DecodedFrameSize( &mpeg ) );
( (uint64_t)p_xh->i_bytes *
(uint64_t)8 *
(uint64_t)mpeg.i_samplerate) /
((uint64_t)p_xh->i_frames * (uint64_t)DecodedFrameSize( &mpeg ) );
}
}
......@@ -425,14 +427,12 @@ static void ExtractConfiguration( demux_sys_t *p_demux )
{
case( 0 ):
p_demux->i_framelength =
( ( ( !p_demux->mpeg.i_version ? 12000 : 6000 ) *
p_demux->mpeg.i_bitrate ) /
( ( 12000 * p_demux->mpeg.i_bitrate ) /
p_demux->mpeg.i_samplerate + p_demux->mpeg.i_padding ) * 4;
case( 1 ):
case( 2 ):
p_demux->i_framelength =
( ( !p_demux->mpeg.i_version ? 144000 : 72000 ) *
p_demux->mpeg.i_bitrate ) /
( 144000 * p_demux->mpeg.i_bitrate ) /
p_demux->mpeg.i_samplerate + p_demux->mpeg.i_padding;
}
}
......@@ -444,7 +444,7 @@ static void ExtractConfiguration( demux_sys_t *p_demux )
****************************************************************************/
static int CheckPS( input_thread_t *p_input )
{
u8 *p_peek;
uint8_t *p_peek;
int i_startcode = 0;
int i_size = input_Peek( p_input, &p_peek, 8196 );
......@@ -625,20 +625,6 @@ static int Activate( vlc_object_t * p_this )
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
#if 0
/* seems now to be ok */
/* FIXME FIXME FIXME FIXME FIXME FIXME FIXME */
/* if i don't do that, it don't work correctly but why ??? */
/* XXX Sigmund : if you want to seek use this :)
but it work only with file .... ( http doesn't like seeking */
if( p_input->stream.b_seekable )
{
p_input->pf_seek( p_input, 0 ); // 0 -> seek at position 0
input_AccessReinit( p_input );
}
#endif
return( 0 );
}
......
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