/*****************************************************************************
* flac.c: flac decoder/packetizer/encoder module making use of libflac
*****************************************************************************
- * Copyright (C) 1999-2001 VideoLAN (Centrale Réseaux) and its contributors
+ * Copyright (C) 1999-2001 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
- * Sigmund Augdal <sigmunau@idi.ntnu.no>
+ * Sigmund Augdal Helberg <dnumgis@videolan.org>
*
* 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
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
STATE_SEND_DATA
};
-static int pi_channels_maps[6] =
+static int pi_channels_maps[7] =
{
0,
AOUT_CHAN_CENTER,
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT
| AOUT_CHAN_REARRIGHT,
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
- | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
+ | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT,
+ AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
+ | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE
};
/*****************************************************************************
#endif
static block_t *PacketizeBlock( decoder_t *, block_t ** );
-static int SyncInfo( decoder_t *, uint8_t *, int *, int *, int *,int * );
+static int SyncInfo( decoder_t *, uint8_t *, unsigned int *, unsigned int *,
+ unsigned int *,int * );
#ifdef USE_LIBFLAC
aout_DateSet( &p_sys->end_date, 0 );
p_sys->i_state = STATE_NOSYNC;
p_sys->b_stream_info = VLC_FALSE;
-
+ p_sys->p_block=NULL;
p_sys->bytestream = block_BytestreamInit( p_dec );
#ifdef USE_LIBFLAC
}
/*****************************************************************************
- * ProcessHeader: processe Flac header.
+ * ProcessHeader: process Flac header.
*****************************************************************************/
static void ProcessHeader( decoder_t *p_dec )
{
if( !p_sys->b_stream_info ) ProcessHeader( p_dec );
+ if( p_sys->stream_info.channels > 6 )
+ {
+ msg_Err( p_dec, "This stream uses too many audio channels" );
+ return NULL;
+ }
+
if( !aout_DateGet( &p_sys->end_date ) && !(*pp_block)->i_pts )
{
/* We've just started the stream, wait for the first PTS. */
switch( status )
{
case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
- msg_Err( p_dec, "an error in the stream caused the decoder to "
+ msg_Warn( p_dec, "an error in the stream caused the decoder to "
"lose synchronization." );
break;
case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
switch ( state )
{
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
- msg_Err( p_dec, "the decoder is ready to search for metadata." );
+ msg_Dbg( p_dec, "the decoder is ready to search for metadata." );
break;
case FLAC__STREAM_DECODER_READ_METADATA:
- msg_Err( p_dec, "the decoder is ready to or is in the process of "
+ msg_Dbg( p_dec, "the decoder is ready to or is in the process of "
"reading metadata." );
break;
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
- msg_Err( p_dec, "the decoder is ready to or is in the process of "
+ msg_Dbg( p_dec, "the decoder is ready to or is in the process of "
"searching for the frame sync code." );
break;
case FLAC__STREAM_DECODER_READ_FRAME:
- msg_Err( p_dec, "the decoder is ready to or is in the process of "
+ msg_Dbg( p_dec, "the decoder is ready to or is in the process of "
"reading a frame." );
break;
case FLAC__STREAM_DECODER_END_OF_STREAM:
- msg_Err( p_dec, "the decoder has reached the end of the stream." );
+ msg_Dbg( p_dec, "the decoder has reached the end of the stream." );
break;
case FLAC__STREAM_DECODER_ABORTED:
- msg_Err( p_dec, "the decoder was aborted by the read callback." );
+ msg_Warn( p_dec, "the decoder was aborted by the read callback." );
break;
case FLAC__STREAM_DECODER_UNPARSEABLE_STREAM:
- msg_Err( p_dec, "the decoder encountered reserved fields in use "
+ msg_Warn( p_dec, "the decoder encountered reserved fields in use "
"in the stream." );
break;
case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
msg_Err( p_dec, "decoder in uninitialized state." );
break;
default:
- msg_Err(p_dec, "unknown error" );
+ msg_Warn(p_dec, "unknown error" );
}
}
#endif
* SyncInfo: parse FLAC sync info
*****************************************************************************/
static int SyncInfo( decoder_t *p_dec, uint8_t *p_buf,
- int * pi_channels, int * pi_channels_conf,
- int * pi_sample_rate, int * pi_bits_per_sample )
+ unsigned int * pi_channels,
+ unsigned int * pi_channels_conf,
+ unsigned int * pi_sample_rate,
+ int * pi_bits_per_sample )
{
decoder_sys_t *p_sys = p_dec->p_sys;
int i_header, i_temp, i_read;
int i_channels;
FLAC__int32 *p_buffer;
- int i_buffer;
+ unsigned int i_buffer;
block_t *p_chain;
{
encoder_sys_t *p_sys = p_enc->p_sys;
block_t *p_chain;
- int i;
+ unsigned int i;
p_sys->i_pts = p_aout_buf->start_date -
(mtime_t)1000000 * (mtime_t)p_sys->i_samples_delay /