]> git.sesse.net Git - vlc/commitdiff
Fix decoding for aac streams with ADTS config set to 0 channels
authorRafaël Carré <funman@videolan.org>
Thu, 18 Apr 2013 00:17:56 +0000 (02:17 +0200)
committerRafaël Carré <funman@videolan.org>
Thu, 18 Apr 2013 00:19:15 +0000 (02:19 +0200)
Assuming stereo is fairly safe and still better than not decoding anything.
This is what gstreamer does, and mplayer might do the same thing.

modules/packetizer/mpeg4audio.c

index 41f3216a5cb32d6b07fffdc8bdda08ef41dca983..7d77c28a1ac972580041a52aaf44d6a53f657a51 100644 (file)
@@ -330,6 +330,8 @@ static int ADTSSyncInfo( decoder_t * p_dec, const uint8_t * p_buf,
     *pi_sample_rate = pi_sample_rates[i_sample_rate_idx];
     //private_bit = (p_buf[2] >> 1) & 0x01;
     *pi_channels = ((p_buf[2] & 0x01) << 2) | ((p_buf[3] >> 6) & 0x03);
+    if (*pi_channels == 0) /* workaround broken streams */
+        *pi_channels = 2;
     //original_copy = (p_buf[3] >> 5) & 0x01;
     //home = (p_buf[3] >> 4) & 0x01;
 
@@ -341,7 +343,7 @@ static int ADTSSyncInfo( decoder_t * p_dec, const uint8_t * p_buf,
     //uint16_t buffer_fullness = ((p_buf[5] & 0x1f) << 6) | (p_buf[6] >> 2);
     unsigned short i_raw_blocks_in_frame = p_buf[6] & 0x03;
 
-    if( !*pi_sample_rate || !*pi_channels || !i_frame_size )
+    if( !*pi_sample_rate || !i_frame_size )
     {
         msg_Warn( p_dec, "Invalid ADTS header" );
         return 0;