diff src/aac/libfaad2/sbr_syntax.c @ 691:e6c5fdae6e88 trunk

[svn] - oh yes, commit mplayer patches as well
author nenolod
date Tue, 20 Feb 2007 06:38:03 -0800
parents 1d8b08df98c3
children f1b6f1b2cdb3
line wrap: on
line diff
--- a/src/aac/libfaad2/sbr_syntax.c	Tue Feb 20 06:31:29 2007 -0800
+++ b/src/aac/libfaad2/sbr_syntax.c	Tue Feb 20 06:38:03 2007 -0800
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** 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
@@ -19,15 +19,10 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Software using this code must display the following message visibly in or
-** on each copy of the software:
-** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
-** in, for example, the about-box or help/startup screen.
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** Commercial non-GPL licensing of this software is possible.
-** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
-**
-** $Id: sbr_syntax.c,v 1.36 2006/05/07 18:09:02 menno Exp $
+** $Id: sbr_syntax.c,v 1.34 2004/09/04 14:56:28 menno Exp $
 **/
 
 #include "common.h"
@@ -51,7 +46,6 @@
 #include "analysis.h"
 
 /* static function declarations */
-/* static function declarations */
 static void sbr_header(bitfile *ld, sbr_info *sbr);
 static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq,
                                uint8_t samplerate_mode, uint8_t freq_scale,
@@ -137,23 +131,16 @@
 }
 
 /* table 2 */
-uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt,
-                           uint8_t psResetFlag)
+uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
 {
     uint8_t result = 0;
     uint16_t num_align_bits = 0;
-    uint16_t num_sbr_bits1 = (uint16_t)faad_get_processed_bits(ld);
-    uint16_t num_sbr_bits2;
+    uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld);
 
     uint8_t saved_start_freq, saved_samplerate_mode;
     uint8_t saved_stop_freq, saved_freq_scale;
     uint8_t saved_alter_scale, saved_xover_band;
 
-#if (defined(PS_DEC) || defined(DRM_PS))
-    if (psResetFlag)
-        sbr->psResetFlag = psResetFlag;
-#endif
-
 #ifdef DRM
     if (!sbr->Is_DRM_SBR)
 #endif
@@ -219,40 +206,28 @@
             {
                 calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq,
                     saved_samplerate_mode, saved_freq_scale,
-                    saved_alter_scale, saved_xover_band);          
+                    saved_alter_scale, saved_xover_band);
             }
 
-            /* we should be able to safely set result to 0 now, */
-            /* but practise indicates this doesn't work well */
+            /* we should be able to safely set result to 0 now */
+            result = 0;
         }
     } else {
         result = 1;
     }
 
-    num_sbr_bits2 = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits1;
-
-    /* check if we read more bits then were available for sbr */
-    if (8*cnt < num_sbr_bits2)
-    {
-        faad_resetbits(ld, num_sbr_bits1 + 8*cnt);
-        num_sbr_bits2 = 8*cnt;
-
-#ifdef PS_DEC
-        /* turn off PS for the unfortunate case that we randomly read some
-         * PS data that looks correct */
-        sbr->ps_used = 0;
-#endif
-
-        /* Make sure it doesn't decode SBR in this frame, or we'll get glitches */
-        return 1;
-    }
-
 #ifdef DRM
     if (!sbr->Is_DRM_SBR)
 #endif
-    {       
+    {
+        num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits;
+
+        /* check if we read more bits then were available for sbr */
+        if (8*cnt < num_sbr_bits)
+            return 1;
+
         /* -4 does not apply, bs_extension_type is re-read in this function */
-        num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits2;
+        num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits;
 
         while (num_align_bits > 7)
         {
@@ -389,14 +364,11 @@
 #ifdef DRM
     /* bs_coupling, from sbr_channel_pair_base_element(bs_amp_res) */
     if (sbr->Is_DRM_SBR)
-    {
         faad_get1bit(ld);
-    }
 #endif
 
     if ((result = sbr_grid(ld, sbr, 0)) > 0)
         return result;
-
     sbr_dtdf(ld, sbr, 0);
     invf_mode(ld, sbr, 0);
     sbr_envelope(ld, sbr, 0);
@@ -459,11 +431,7 @@
                 } else {
                     /* to be safe make it 3, will switch to "default"
                      * in sbr_extension() */
-#ifdef DRM
-                    return 1;
-#else
                     sbr->bs_extension_id = 3;
-#endif
                 }
             }
 #endif
@@ -861,10 +829,6 @@
         {
             sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
         }
-        if (sbr->psResetFlag)
-        {
-            sbr->ps->header_read = 0;
-        }
         ret = ps_data(sbr->ps, ld, &header);
 
         /* enable PS if and only if: a header has been decoded */
@@ -873,11 +837,6 @@
             sbr->ps_used = 1;
         }
 
-        if (header == 1)
-        {
-            sbr->psResetFlag = 0;
-        }
-
         return ret;
 #endif
 #ifdef DRM_PS