]> git.sesse.net Git - vlc/commitdiff
* all: fix for correct "i_channels" use.
authorLaurent Aimar <fenrir@videolan.org>
Sun, 20 Oct 2002 17:44:17 +0000 (17:44 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 20 Oct 2002 17:44:17 +0000 (17:44 +0000)
modules/codec/araw.c
modules/codec/faad/decoder.c
modules/codec/faad/decoder.h

index 912d1e0305fe2eff606145b5eb7fc0351450bafc..c72a3e6aee7ea703a2d71fd7068a3e607405fe54 100644 (file)
@@ -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 <fenrir@via.ecp.fr>
  *      
@@ -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;
 
index b4fd779176a6e7e39bbe38fcd0b6804781b7b169..e3cdfc6c1f6bfa3eccb9bb1acbffaf7a72338443 100644 (file)
@@ -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 <fenrir@via.ecp.fr>
  *      
@@ -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,
index f6f98a87076e17deee64f04821fe5f5f0c6dfa0e..6850d9d9938b7c92fc9eab93510a23e6bdc11b10 100644 (file)
@@ -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 <fenrir@via.ecp.fr>
  *      
@@ -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
+};