* modules/codec/mpeg_audio.c, modules/codec/a52.c, modules/packetizer/mpeg4audio.c: fixed a couple of issues.
* vlc_block_helper.h: Helper functions for data blocks management.
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: vlc_block_helper.h,v 1.3 2003/10/05 00:50:05 gbazin Exp $
+ * $Id: vlc_block_helper.h,v 1.4 2003/10/23 20:51:20 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
{
i_copy = __MIN( i_size, p_block->i_buffer - i_offset );
i_size -= i_copy;
- i_offset = 0;
if( !i_size ) break;
+
+ i_offset = 0;
}
/* Copy the data */
- i_offset = i_copy;
+ i_offset += i_copy;
i_size = i_data;
i_copy = 0;
for( ; p_block != NULL; p_block = p_block->p_next )
* a52.c: A/52 basic parser
*****************************************************************************
* Copyright (C) 2001-2002 VideoLAN
- * $Id: a52.c,v 1.27 2003/10/08 21:03:36 gbazin Exp $
+ * $Id: a52.c,v 1.28 2003/10/23 20:51:20 gbazin Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
* Christophe Massiot <massiot@via.ecp.fr>
* Input properties
*/
int i_state;
- vlc_bool_t b_synchro;
block_t *p_chain;
block_bytestream_t bytestream;
static int InitDecoder( decoder_t *p_dec )
{
p_dec->p_sys->i_state = STATE_NOSYNC;
- p_dec->p_sys->b_synchro = VLC_FALSE;
p_dec->p_sys->p_out_buffer = NULL;
aout_DateSet( &p_dec->p_sys->end_date, 0 );
return VLC_SUCCESS;
}
+ if( p_block->b_discontinuity )
+ {
+ p_sys->i_state = STATE_SYNC;
+ }
+
if( p_sys->p_chain )
{
block_ChainAppend( &p_sys->p_chain, p_block );
break;
}
block_SkipByte( &p_sys->bytestream );
- p_sys->b_synchro = VLC_FALSE;
}
if( p_sys->i_state != STATE_SYNC )
{
+ if( block_PeekByte( &p_sys->bytestream, p_header )
+ == VLC_SUCCESS && p_header[0] == 0x0b )
+ {
+ /* Start of a sync word, need more data */
+ return VLC_SUCCESS;
+ }
+
block_ChainRelease( p_sys->p_chain );
p_sys->p_chain = NULL;
msg_Dbg( p_dec, "emulated sync word" );
block_SkipByte( &p_sys->bytestream );
p_sys->i_state = STATE_NOSYNC;
- p_sys->b_synchro = VLC_FALSE;
break;
}
p_sys->i_state = STATE_DATA;
/* TODO: If p_block == NULL, flush the buffer without checking the
* next sync word */
- if( !p_sys->b_synchro )
- {
- /* Check if next expected frame contains the sync word */
- if( block_PeekOffsetBytes( &p_sys->bytestream,
- p_sys->i_frame_size, p_header, 2 )
- != VLC_SUCCESS )
- {
- /* Need more data */
- return VLC_SUCCESS;
- }
-
- if( p_header[0] != 0x0b || p_header[1] != 0x77 )
- {
- msg_Dbg( p_dec, "emulated sync word "
- "(no sync on following frame)" );
- p_sys->i_state = STATE_NOSYNC;
- block_SkipByte( &p_sys->bytestream );
- p_sys->b_synchro = VLC_FALSE;
- break;
- }
+ /* Check if next expected frame contains the sync word */
+ if( block_PeekOffsetBytes( &p_sys->bytestream,
+ p_sys->i_frame_size, p_header, 2 )
+ != VLC_SUCCESS )
+ {
+ /* Need more data */
+ return VLC_SUCCESS;
+ }
+
+ if( p_header[0] != 0x0b || p_header[1] != 0x77 )
+ {
+ msg_Dbg( p_dec, "emulated sync word "
+ "(no sync on following frame)" );
+ p_sys->i_state = STATE_NOSYNC;
+ block_SkipByte( &p_sys->bytestream );
+ break;
}
if( !p_sys->p_out_buffer )
SendOutBuffer( p_dec );
p_sys->i_state = STATE_NOSYNC;
- p_sys->b_synchro = VLC_TRUE;
/* Make sure we don't reuse the same pts twice */
if( p_sys->pts == p_sys->bytestream.p_block->i_pts )
* mpeg_audio.c: parse MPEG audio sync info and packetize the stream
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
- * $Id: mpeg_audio.c,v 1.19 2003/10/05 00:50:05 gbazin Exp $
+ * $Id: mpeg_audio.c,v 1.20 2003/10/23 20:51:20 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
* Input properties
*/
int i_state;
- vlc_bool_t b_synchro;
block_t *p_chain;
block_bytestream_t bytestream;
static int InitDecoder( decoder_t *p_dec )
{
p_dec->p_sys->i_state = STATE_NOSYNC;
- p_dec->p_sys->b_synchro = VLC_FALSE;
p_dec->p_sys->p_out_buffer = NULL;
aout_DateSet( &p_dec->p_sys->end_date, 0 );
uint8_t p_header[MAD_BUFFER_GUARD];
uint32_t i_header;
- if( (!aout_DateGet( &p_sys->end_date ) && !p_block->i_pts)
- || p_block->b_discontinuity )
+ if( !aout_DateGet( &p_sys->end_date ) && !p_block->i_pts )
{
/* We've just started the stream, wait for the first PTS. */
block_Release( p_block );
- p_sys->b_synchro = VLC_FALSE;
return VLC_SUCCESS;
}
+ if( p_block->b_discontinuity )
+ {
+ p_sys->i_state = STATE_SYNC;
+ }
+
if( p_sys->p_chain )
{
block_ChainAppend( &p_sys->p_chain, p_block );
break;
}
block_SkipByte( &p_sys->bytestream );
- p_sys->b_synchro = VLC_FALSE;
}
if( p_sys->i_state != STATE_SYNC )
{
+ if( block_PeekByte( &p_sys->bytestream, p_header )
+ == VLC_SUCCESS && p_header[0] == 0xff )
+ {
+ /* Start of a sync word, need more data */
+ return VLC_SUCCESS;
+ }
+
block_ChainRelease( p_sys->p_chain );
p_sys->p_chain = NULL;
if( p_sys->pts != 0 &&
p_sys->pts != aout_DateGet( &p_sys->end_date ) )
{
+ msg_Err( p_dec, "set PTS: %lli old: %lli", p_sys->pts,
+ aout_DateGet( &p_sys->end_date ) );
aout_DateSet( &p_sys->end_date, p_sys->pts );
}
p_sys->i_state = STATE_HEADER;
msg_Dbg( p_dec, "emulated start code" );
block_SkipByte( &p_sys->bytestream );
p_sys->i_state = STATE_NOSYNC;
- p_sys->b_synchro = VLC_FALSE;
break;
}
"(emulated startcode ?)" );
block_SkipByte( &p_sys->bytestream );
p_sys->i_state = STATE_NOSYNC;
- p_sys->b_synchro = VLC_FALSE;
break;
}
}
break;
}
- if( !p_sys->b_synchro )
- {
- msg_Dbg( p_dec, "emulated startcode "
- "(no startcode on following frame)" );
- p_sys->i_state = STATE_NOSYNC;
- block_SkipByte( &p_sys->bytestream );
- break;
- }
+ msg_Dbg( p_dec, "emulated startcode "
+ "(no startcode on following frame)" );
+ p_sys->i_state = STATE_NOSYNC;
+ block_SkipByte( &p_sys->bytestream );
+ break;
}
if( GetOutBuffer( p_dec, &p_sys->p_out_buffer ) != VLC_SUCCESS )
SendOutBuffer( p_dec );
p_sys->i_state = STATE_NOSYNC;
- p_sys->b_synchro = VLC_TRUE;
/* Make sure we don't reuse the same pts twice */
if( p_sys->pts == p_sys->bytestream.p_block->i_pts )
};
int i_version, i_mode, i_emphasis;
- vlc_bool_t b_padding, b_mpeg_2_5;
+ vlc_bool_t b_padding, b_mpeg_2_5, b_crc;
int i_frame_size = 0;
int i_bitrate_index, i_samplerate_index;
int i_max_bit_rate;
b_mpeg_2_5 = 1 - ((i_header & 0x100000) >> 20);
i_version = 1 - ((i_header & 0x80000) >> 19);
*pi_layer = 4 - ((i_header & 0x60000) >> 17);
- /* CRC */
+ b_crc = !((i_header >> 16) & 0x01);
i_bitrate_index = (i_header & 0xf000) >> 12;
i_samplerate_index = (i_header & 0xc00) >> 10;
b_padding = (i_header & 0x200) >> 9;
* mpeg4audio.c: parse and packetize an MPEG 4 audio stream
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: mpeg4audio.c,v 1.9 2003/10/05 18:09:36 gbazin Exp $
+ * $Id: mpeg4audio.c,v 1.10 2003/10/23 20:51:20 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* Input properties
*/
int i_state;
- vlc_bool_t b_synchro;
block_t *p_chain;
block_bytestream_t bytestream;
WAVEFORMATEX *p_wf;
p_sys->i_state = STATE_NOSYNC;
- p_sys->b_synchro = VLC_FALSE;
aout_DateSet( &p_sys->end_date, 0 );
decoder_sys_t *p_sys = p_dec->p_sys;
uint8_t p_header[ADTS_HEADER_SIZE];
- if( (!aout_DateGet( &p_sys->end_date ) && !p_block->i_pts)
- || p_block->b_discontinuity )
+ if( !aout_DateGet( &p_sys->end_date ) && !p_block->i_pts )
{
/* We've just started the stream, wait for the first PTS. */
block_Release( p_block );
- p_sys->b_synchro = VLC_FALSE;
return VLC_SUCCESS;
}
+ if( p_block->b_discontinuity )
+ {
+ p_sys->i_state = STATE_SYNC;
+ }
+
if( p_sys->p_chain )
{
block_ChainAppend( &p_sys->p_chain, p_block );
break;
}
block_SkipByte( &p_sys->bytestream );
- p_sys->b_synchro = VLC_FALSE;
}
if( p_sys->i_state != STATE_SYNC )
{
+ if( block_PeekByte( &p_sys->bytestream, p_header )
+ == VLC_SUCCESS && p_header[0] == 0xff )
+ {
+ /* Start of a sync word, need more data */
+ return VLC_SUCCESS;
+ }
+
block_ChainRelease( p_sys->p_chain );
p_sys->p_chain = NULL;
msg_Dbg( p_dec, "emulated sync word" );
block_SkipByte( &p_sys->bytestream );
p_sys->i_state = STATE_NOSYNC;
- p_sys->b_synchro = VLC_FALSE;
break;
}
/* TODO: If p_block == NULL, flush the buffer without checking the
* next sync word */
- if( !p_sys->b_synchro )
+ /* Check if next expected frame contains the sync word */
+ if( block_PeekOffsetBytes( &p_sys->bytestream,
+ p_sys->i_frame_size, p_header, 2 )
+ != VLC_SUCCESS )
{
- /* Check if next expected frame contains the sync word */
- if( block_PeekOffsetBytes( &p_sys->bytestream,
- p_sys->i_frame_size, p_header, 2 )
- != VLC_SUCCESS )
- {
- /* Need more data */
- return VLC_SUCCESS;
- }
+ /* Need more data */
+ return VLC_SUCCESS;
+ }
- if( p_header[0] != 0xff || (p_header[1] & 0xf6) != 0xf0 )
- {
- msg_Dbg( p_dec, "emulated sync word "
- "(no sync on following frame)" );
- p_sys->i_state = STATE_NOSYNC;
- block_SkipByte( &p_sys->bytestream );
- p_sys->b_synchro = VLC_FALSE;
- break;
- }
+ if( p_header[0] != 0xff || (p_header[1] & 0xf6) != 0xf0 )
+ {
+ msg_Dbg( p_dec, "emulated sync word "
+ "(no sync on following frame)" );
+ p_sys->i_state = STATE_NOSYNC;
+ block_SkipByte( &p_sys->bytestream );
+ break;
}
if( !p_sys->p_sout_buffer )
p_sys->i_state = STATE_NOSYNC;
p_sys->p_sout_buffer = NULL;
- p_sys->b_synchro = VLC_TRUE;
/* Make sure we don't reuse the same pts twice */
if( p_sys->pts == p_sys->bytestream.p_block->i_pts )