From 5f3c2d34d48eaa30714fb26273c911e8f4dabe18 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sun, 20 Oct 2002 17:44:17 +0000 Subject: [PATCH] * all: fix for correct "i_channels" use. --- modules/codec/araw.c | 23 +++++++++++++++++++++-- modules/codec/faad/decoder.c | 8 +++++--- modules/codec/faad/decoder.h | 9 ++++++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/modules/codec/araw.c b/modules/codec/araw.c index 912d1e0305..c72a3e6aee 100644 --- a/modules/codec/araw.c +++ b/modules/codec/araw.c @@ -2,7 +2,7 @@ * araw.c: Pseudo audio decoder; for raw pcm data ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: araw.c,v 1.1 2002/10/14 21:59:44 fenrir Exp $ + * $Id: araw.c,v 1.2 2002/10/20 17:44:17 fenrir Exp $ * * Authors: Laurent Aimar * @@ -84,6 +84,15 @@ vlc_module_begin(); set_callbacks( OpenDecoder, NULL ); vlc_module_end(); + +static int i_channels_maps[6] = +{ + 0, + AOUT_CHAN_MONO, AOUT_CHAN_STEREO, + AOUT_CHAN_3F, AOUT_CHAN_2F2R, + AOUT_CHAN_3F2R +}; + /***************************************************************************** * OpenDecoder: probe the decoder and return score ***************************************************************************** @@ -223,9 +232,11 @@ static int PESGetSize( pes_packet_t *p_pes ) return( i_size ); } + /***************************************************************************** * InitThread: initialize data before entering main loop *****************************************************************************/ + static int InitThread( adec_thread_t * p_adec ) { @@ -271,7 +282,15 @@ static int InitThread( adec_thread_t * p_adec ) return( -1 ); } p_adec->output_format.i_rate = p_adec->format.i_samplespersec; - p_adec->output_format.i_channels = p_adec->format.i_channels; + if( p_adec->output_format.i_channels <= 0 || + p_adec->output_format.i_channels > 5 ) + { + msg_Err( p_adec->p_fifo, "bad channels count(1-5)" ); + return( -1 ); + } + + p_adec->output_format.i_channels = + i_channels_maps[p_adec->format.i_channels]; p_adec->p_aout = NULL; p_adec->p_aout_input = NULL; diff --git a/modules/codec/faad/decoder.c b/modules/codec/faad/decoder.c index b4fd779176..e3cdfc6c1f 100644 --- a/modules/codec/faad/decoder.c +++ b/modules/codec/faad/decoder.c @@ -2,7 +2,7 @@ * decoder.c: AAC decoder using libfaad2 ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: decoder.c,v 1.5 2002/09/30 21:32:32 massiot Exp $ + * $Id: decoder.c,v 1.6 2002/10/20 17:44:17 fenrir Exp $ * * Authors: Laurent Aimar * @@ -420,7 +420,8 @@ static void DecodeThread( adec_thread_t *p_adec ) return; } if( ( faad_frame.channels <= 0 )|| - ( faad_frame.channels > AAC_MAXCHANNELS) ) + ( faad_frame.channels > AAC_MAXCHANNELS) || + ( faad_frame.channels > 5 ) ) { msg_Warn( p_adec->p_fifo, "invalid channels count(%d)", faad_frame.channels ); @@ -453,7 +454,8 @@ static void DecodeThread( adec_thread_t *p_adec ) } /* **** Create a new audio output **** */ - p_adec->output_format.i_channels = faad_frame.channels; + p_adec->output_format.i_channels = + i_channels_maps[faad_frame.channels]; aout_DateInit( &p_adec->date, p_adec->output_format.i_rate ); p_adec->p_aout_input = aout_DecNew( p_adec->p_fifo, &p_adec->p_aout, diff --git a/modules/codec/faad/decoder.h b/modules/codec/faad/decoder.h index f6f98a8707..6850d9d993 100644 --- a/modules/codec/faad/decoder.h +++ b/modules/codec/faad/decoder.h @@ -3,7 +3,7 @@ * ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: decoder.h,v 1.2 2002/08/23 14:05:22 sam Exp $ + * $Id: decoder.h,v 1.3 2002/10/20 17:44:17 fenrir Exp $ * * Authors: Laurent Aimar * @@ -72,5 +72,12 @@ typedef struct adec_thread_s } adec_thread_t; +static int i_channels_maps[6] = +{ + 0, + AOUT_CHAN_MONO, AOUT_CHAN_STEREO, + AOUT_CHAN_3F, AOUT_CHAN_2F2R, + AOUT_CHAN_3F2R +}; -- 2.39.5