[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xine-cvslog
Subject:    [xine-cvs] HG: xine-lib: [1/1] Update to libfaad 2.6.1,
From:       Darren Salt <linux () youmustbejoking ! demon ! co ! uk>
Date:       2008-08-13 16:48:52
Message-ID: 18c0264660b951b8e567.1218634110:1 () hg ! debian ! org
[Download RAW message or body]

# [node 608e33e144c7eebe016fbf306771bff4219d1629 part 1]

diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_dec.c
--- a/src/libfaad/sbr_dec.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_dec.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_dec.c,v 1.9 2006/06/17 20:43:57 dgp85 Exp $
+** $Id: sbr_dec.c,v 1.43 2007/11/01 12:33:34 menno Exp $
 **/
 
 
@@ -176,6 +179,72 @@ void sbrDecodeEnd(sbr_info *sbr)
     }
 }
 
+void sbrReset(sbr_info *sbr)
+{
+    uint8_t j;
+    if (sbr->qmfa[0] != NULL)
+        memset(sbr->qmfa[0]->x, 0, 2 * sbr->qmfa[0]->channels * 10 * \
sizeof(real_t)); +    if (sbr->qmfa[1] != NULL)
+        memset(sbr->qmfa[1]->x, 0, 2 * sbr->qmfa[1]->channels * 10 * \
sizeof(real_t)); +    if (sbr->qmfs[0] != NULL)
+        memset(sbr->qmfs[0]->v, 0, 2 * sbr->qmfs[0]->channels * 20 * \
sizeof(real_t)); +    if (sbr->qmfs[1] != NULL)
+        memset(sbr->qmfs[1]->v, 0, 2 * sbr->qmfs[1]->channels * 20 * \
sizeof(real_t)); +
+    for (j = 0; j < 5; j++)
+    {
+        if (sbr->G_temp_prev[0][j] != NULL)
+            memset(sbr->G_temp_prev[0][j], 0, 64*sizeof(real_t));
+        if (sbr->G_temp_prev[1][j] != NULL)
+            memset(sbr->G_temp_prev[1][j], 0, 64*sizeof(real_t));
+        if (sbr->Q_temp_prev[0][j] != NULL)
+            memset(sbr->Q_temp_prev[0][j], 0, 64*sizeof(real_t));
+        if (sbr->Q_temp_prev[1][j] != NULL)
+            memset(sbr->Q_temp_prev[1][j], 0, 64*sizeof(real_t));
+    }
+
+    memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+    memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+    
+    sbr->GQ_ringbuf_index[0] = 0;
+    sbr->GQ_ringbuf_index[1] = 0;
+    sbr->header_count = 0;
+    sbr->Reset = 1;
+
+    sbr->L_E_prev[0] = 0;
+    sbr->L_E_prev[1] = 0;
+    sbr->bs_freq_scale = 2;
+    sbr->bs_alter_scale = 1;
+    sbr->bs_noise_bands = 2;
+    sbr->bs_limiter_bands = 2;
+    sbr->bs_limiter_gains = 2;
+    sbr->bs_interpol_freq = 1;
+    sbr->bs_smoothing_mode = 1;
+    sbr->bs_start_freq = 5;
+    sbr->bs_amp_res = 1;
+    sbr->bs_samplerate_mode = 1;
+    sbr->prevEnvIsShort[0] = -1;
+    sbr->prevEnvIsShort[1] = -1;
+    sbr->bsco = 0;
+    sbr->bsco_prev = 0;
+    sbr->M_prev = 0;
+    sbr->bs_start_freq_prev = -1;
+
+    sbr->f_prev[0] = 0;
+    sbr->f_prev[1] = 0;
+    for (j = 0; j < MAX_M; j++)
+    {
+        sbr->E_prev[0][j] = 0;
+        sbr->Q_prev[0][j] = 0;
+        sbr->E_prev[1][j] = 0;
+        sbr->Q_prev[1][j] = 0;
+        sbr->bs_add_harmonic_prev[0][j] = 0;
+        sbr->bs_add_harmonic_prev[1][j] = 0;
+    }
+    sbr->bs_add_harmonic_flag_prev[0] = 0;
+    sbr->bs_add_harmonic_flag_prev[1] = 0;
+}
+
 static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
 {
     uint8_t i;
@@ -226,11 +295,12 @@ static void sbr_save_matrix(sbr_info *sb
     }
 }
 
-static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t \
                X[MAX_NTSR][64],
-                                uint8_t ch, uint8_t dont_process,
-                                const uint8_t downSampledSBR)
+static uint8_t sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t \
X[MAX_NTSR][64], +                                   uint8_t ch, uint8_t \
dont_process, +                                   const uint8_t downSampledSBR)
 {
     int16_t k, l;
+    uint8_t ret = 0;
 
 #ifdef SBR_LOW_POWER
     ALIGN real_t deg[64];
@@ -278,7 +348,7 @@ static void sbr_process_channel(sbr_info
             ,ch);
 #endif
 
-#ifdef SBR_LOW_POWER
+#if 0 //def SBR_LOW_POWER
         for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++)
         {
             for (k = 0; k < sbr->kx; k++)
@@ -290,12 +360,16 @@ static void sbr_process_channel(sbr_info
 
 #if 1
         /* hf adjustment */
-        hf_adjustment(sbr, sbr->Xsbr[ch]
+        ret = hf_adjustment(sbr, sbr->Xsbr[ch]
 #ifdef SBR_LOW_POWER
             ,deg
 #endif
             ,ch);
 #endif
+        if (ret > 0)
+        {
+            dont_process = 1;
+        }
     }
 
     if ((sbr->just_seeked != 0) || dont_process)
@@ -367,6 +441,8 @@ static void sbr_process_channel(sbr_info
 #endif
         }
     }
+
+    return ret;
 }
 
 uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
@@ -400,7 +476,7 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *s
         sbr->just_seeked = 0;
     }
 
-    sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR);
+    sbr->ret += sbr_process_channel(sbr, left_chan, X, 0, dont_process, \
downSampledSBR);  /* subband synthesis */
     if (downSampledSBR)
     {
@@ -409,7 +485,7 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *s
         sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan);
     }
 
-    sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR);
+    sbr->ret += sbr_process_channel(sbr, right_chan, X, 1, dont_process, \
downSampledSBR);  /* subband synthesis */
     if (downSampledSBR)
     {
@@ -483,7 +559,7 @@ uint8_t sbrDecodeSingleFrame(sbr_info *s
         sbr->just_seeked = 0;
     }
 
-    sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR);
+    sbr->ret += sbr_process_channel(sbr, channel, X, 0, dont_process, \
downSampledSBR);  /* subband synthesis */
     if (downSampledSBR)
     {
@@ -526,8 +602,8 @@ uint8_t sbrDecodeSingleFramePS(sbr_info 
     uint8_t l, k;
     uint8_t dont_process = 0;
     uint8_t ret = 0;
-    ALIGN qmf_t X_left[38][64] = {{{0}}};
-    ALIGN qmf_t X_right[38][64] = {{{0}}}; /* must set this to 0 */
+    ALIGN qmf_t X_left[38][64] = {{0}};
+    ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */
 
     if (sbr == NULL)
         return 20;
@@ -558,7 +634,7 @@ uint8_t sbrDecodeSingleFramePS(sbr_info 
         sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
     }
 
-    sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR);
+    sbr->ret += sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, \
downSampledSBR);  
     /* copy some extra data for PS */
     for (l = 32; l < 38; l++)
@@ -574,7 +650,7 @@ uint8_t sbrDecodeSingleFramePS(sbr_info 
 #ifdef DRM_PS
     if (sbr->Is_DRM_SBR)
     {
-        drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, X_left, \
X_right); +        drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), X_left, X_right);
     } else {
 #endif
 #ifdef PS_DEC
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_dec.h
--- a/src/libfaad/sbr_dec.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_dec.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,28 +1,31 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero 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
 ** the Free Software Foundation; either version 2 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
-**
-** $Id: sbr_dec.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_dec.h,v 1.39 2007/11/01 12:33:34 menno Exp $
 **/
 
 #ifndef __SBR_DEC_H__
@@ -183,6 +186,7 @@ typedef struct
 #endif
 #if (defined(PS_DEC) || defined(DRM_PS))
     uint8_t ps_used;
+    uint8_t psResetFlag;
 #endif
 
     /* to get it compiling */
@@ -231,6 +235,7 @@ sbr_info *sbrDecodeInit(uint16_t framele
 #endif
                         );
 void sbrDecodeEnd(sbr_info *sbr);
+void sbrReset(sbr_info *sbr);
 
 uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
                              const uint8_t just_seeked, const uint8_t \
                downSampledSBR);
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_e_nf.c
--- a/src/libfaad/sbr_e_nf.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_e_nf.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_e_nf.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_e_nf.c,v 1.21 2007/11/01 12:33:35 menno Exp $
 **/
 
 #include "common.h"
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_e_nf.h
--- a/src/libfaad/sbr_e_nf.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_e_nf.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_e_nf.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_e_nf.h,v 1.18 2007/11/01 12:33:35 menno Exp $
 **/
 
 #ifndef __SBR_E_NF_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_fbt.c
--- a/src/libfaad/sbr_fbt.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_fbt.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_fbt.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_fbt.c,v 1.21 2007/11/01 12:33:35 menno Exp $
 **/
 
 /* Calculate frequency band tables */
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_fbt.h
--- a/src/libfaad/sbr_fbt.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_fbt.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_fbt.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_fbt.h,v 1.18 2007/11/01 12:33:35 menno Exp $
 **/
 
 #ifndef __SBR_FBT_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_hfadj.c
--- a/src/libfaad/sbr_hfadj.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_hfadj.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfadj.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_hfadj.c,v 1.22 2007/11/01 12:33:35 menno Exp $
 **/
 
 /* High Frequency adjustment */
@@ -39,8 +42,8 @@
 
 
 /* static function declarations */
-static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
-                                      qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
+static uint8_t estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
+                                         qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch);
 static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
 #ifdef SBR_LOW_POWER
 static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, \
uint8_t ch); @@ -49,13 +52,14 @@ static void hf_assembly(sbr_info *sbr, s
 static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t \
Xsbr[MAX_NTSRHFG][64], uint8_t ch);  
 
-void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
+uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
-                   ,real_t *deg /* aliasing degree */
-#endif
-                   ,uint8_t ch)
+                      ,real_t *deg /* aliasing degree */
+#endif
+                      ,uint8_t ch)
 {
     ALIGN sbr_hfadj_info adj = {{{0}}};
+    uint8_t ret = 0;
 
     if (sbr->bs_frame_class[ch] == FIXFIX)
     {
@@ -72,7 +76,9 @@ void hf_adjustment(sbr_info *sbr, qmf_t 
             sbr->l_A[ch] = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch];
     }
 
-    estimate_current_envelope(sbr, &adj, Xsbr, ch);
+    ret = estimate_current_envelope(sbr, &adj, Xsbr, ch);
+    if (ret > 0)
+        return 1;
 
     calculate_gain(sbr, &adj, ch);
 
@@ -82,6 +88,8 @@ void hf_adjustment(sbr_info *sbr, qmf_t 
 #endif
 
     hf_assembly(sbr, &adj, Xsbr, ch);
+
+    return 0;
 }
 
 static uint8_t get_S_mapped(sbr_info *sbr, uint8_t ch, uint8_t l, uint8_t \
current_band) @@ -125,8 +133,8 @@ static uint8_t get_S_mapped(sbr_info *sb
     return 0;
 }
 
-static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
-                                      qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch)
+static uint8_t estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
+                                         qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch)
 {
     uint8_t m, l, j, k, k_l, k_h, p;
     real_t nrg, div;
@@ -141,6 +149,9 @@ static void estimate_current_envelope(sb
             u_i = sbr->t_E[ch][l+1];
 
             div = (real_t)(u_i - l_i);
+
+            if (div == 0)
+                div = 1;
 
             for (m = 0; m < sbr->M; m++)
             {
@@ -191,6 +202,9 @@ static void estimate_current_envelope(sb
                     u_i = sbr->t_E[ch][l+1];
 
                     div = (real_t)((u_i - l_i)*(k_h - k_l));
+
+                    if (div == 0)
+                        div = 1;
 
                     for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++)
                     {
@@ -225,6 +239,8 @@ static void estimate_current_envelope(sb
             }
         }
     }
+
+    return 0;
 }
 
 #ifdef FIXED_POINT
@@ -1342,15 +1358,27 @@ static void calc_gain_groups(sbr_info *s
 {
     uint8_t l, k, i;
     uint8_t grouping;
+    uint8_t S_mapped;
 
     for (l = 0; l < sbr->L_E[ch]; l++)
     {
+        uint8_t current_res_band = 0;
         i = 0;
         grouping = 0;
 
+        S_mapped = get_S_mapped(sbr, ch, l, current_res_band);
+
         for (k = sbr->kx; k < sbr->kx + sbr->M - 1; k++)
         {
-            if (deg[k + 1] && adj->S_mapped[l][k-sbr->kx] == 0)
+            if (k == sbr->f_table_res[sbr->f[ch][l]][current_res_band+1])
+            {
+                /* step to next resolution band */
+                current_res_band++;
+
+                S_mapped = get_S_mapped(sbr, ch, l, current_res_band);
+            }
+
+            if (deg[k + 1] && S_mapped == 0)
             {
                 if (grouping == 0)
                 {
@@ -1361,7 +1389,7 @@ static void calc_gain_groups(sbr_info *s
             } else {
                 if (grouping)
                 {
-                    if (adj->S_mapped[l][k-sbr->kx])
+                    if (S_mapped)
                     {
                         sbr->f_group[l][i] = k;
                     } else {
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_hfadj.h
--- a/src/libfaad/sbr_hfadj.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_hfadj.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfadj.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_hfadj.h,v 1.19 2007/11/01 12:33:35 menno Exp $
 **/
 
 #ifndef __SBR_HFADJ_H__
@@ -40,11 +43,11 @@ typedef struct
 } sbr_hfadj_info;
 
 
-void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
+uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64]
 #ifdef SBR_LOW_POWER
-                   ,real_t *deg
+                      ,real_t *deg
 #endif
-                   ,uint8_t ch);
+                      ,uint8_t ch);
 
 
 #ifdef __cplusplus
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_hfgen.c
--- a/src/libfaad/sbr_hfgen.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_hfgen.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfgen.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_hfgen.c,v 1.26 2007/11/01 12:33:35 menno Exp $
 **/
 
 /* High Frequency generation */
@@ -35,7 +38,6 @@
 #include "sbr_syntax.h"
 #include "sbr_hfgen.h"
 #include "sbr_fbt.h"
-
 
 /* static function declarations */
 #ifdef SBR_LOW_POWER
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_hfgen.h
--- a/src/libfaad/sbr_hfgen.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_hfgen.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_hfgen.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_hfgen.h,v 1.20 2007/11/01 12:33:35 menno Exp $
 **/
 
 #ifndef __SBR_HFGEN_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_huff.c
--- a/src/libfaad/sbr_huff.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_huff.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
-**
-** $Id: sbr_huff.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_huff.c,v 1.21 2007/11/01 12:33:35 menno Exp $
 **/
 
 #include "common.h"
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_huff.h
--- a/src/libfaad/sbr_huff.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_huff.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_huff.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_huff.h,v 1.21 2007/11/01 12:33:35 menno Exp $
 **/
 
 #ifndef __SBR_HUFF_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_noise.h
--- a/src/libfaad/sbr_noise.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_noise.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_noise.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_noise.h,v 1.17 2007/11/01 12:33:35 menno Exp $
 **/
 
 #ifndef __SBR_NOISE_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_qmf.c
--- a/src/libfaad/sbr_qmf.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_qmf.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,28 +1,31 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero 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
 ** the Free Software Foundation; either version 2 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_qmf.c,v 1.32 2007/11/01 12:33:36 menno Exp $
 **/
 
 #include "common.h"
@@ -72,7 +75,7 @@ void sbr_qmf_analysis_32(sbr_info *sbr, 
 #else
     ALIGN real_t y[32];
 #endif
-    uint16_t in = 0;
+    uint32_t in = 0;
     uint8_t l;
 
     /* qmf subsample l */
@@ -251,7 +254,7 @@ void sbr_qmf_synthesis_32(sbr_info *sbr,
 {
     ALIGN real_t x[16];
     ALIGN real_t y[16];
-    int16_t n, k, out = 0;
+    int32_t n, k, out = 0;
     uint8_t l;
 
     /* qmf subsample l */
@@ -320,7 +323,7 @@ void sbr_qmf_synthesis_64(sbr_info *sbr,
 {
     ALIGN real_t x[64];
     ALIGN real_t y[64];
-    int16_t n, k, out = 0;
+    int32_t n, k, out = 0;
     uint8_t l;
 
 
@@ -392,7 +395,7 @@ void sbr_qmf_synthesis_32(sbr_info *sbr,
 #ifndef FIXED_POINT
     real_t scale = 1.f/64.f;
 #endif
-    int16_t n, k, out = 0;
+    int32_t n, k, out = 0;
     uint8_t l;
 
 
@@ -475,7 +478,7 @@ void sbr_qmf_synthesis_64(sbr_info *sbr,
 #ifndef FIXED_POINT
     real_t scale = 1.f/64.f;
 #endif
-    int16_t n, k, out = 0;
+    int32_t n, k, out = 0;
     uint8_t l;
 
 
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_qmf.h
--- a/src/libfaad/sbr_qmf.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_qmf.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_qmf.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_qmf.h,v 1.25 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SBR_QMF_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_qmf_c.h
--- a/src/libfaad/sbr_qmf_c.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_qmf_c.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,28 +1,31 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero 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
 ** the Free Software Foundation; either version 2 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
-**
-** $Id: sbr_qmf_c.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_qmf_c.h,v 1.17 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SBR_QMF_C_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_syntax.c
--- a/src/libfaad/sbr_syntax.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_syntax.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_syntax.c,v 1.38 2007/11/01 12:33:36 menno Exp $
 **/
 
 #include "common.h"
@@ -45,6 +48,7 @@
 #endif
 #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,
@@ -131,15 +135,22 @@ static uint8_t calc_sbr_tables(sbr_info 
 }
 
 /* table 2 */
-uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
+uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt,
+                           uint8_t psResetFlag)
 {
     uint8_t result = 0;
     uint16_t num_align_bits = 0;
-    uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld);
+    uint16_t num_sbr_bits1 = (uint16_t)faad_get_processed_bits(ld);
+    uint16_t num_sbr_bits2;
 
     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)
@@ -206,28 +217,40 @@ uint8_t sbr_extension_data(bitfile *ld, 
             {
                 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 */
-            result = 0;
+            /* we should be able to safely set result to 0 now, */
+            /* but practise indicates this doesn't work well */
         }
     } 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_bits;
+        num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits2;
 
         while (num_align_bits > 7)
         {
@@ -364,11 +387,14 @@ static uint8_t sbr_single_channel_elemen
 #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);
@@ -431,7 +457,11 @@ static uint8_t sbr_single_channel_elemen
                 } 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
@@ -829,12 +859,21 @@ static uint16_t sbr_extension(bitfile *l
         {
             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 */
         if (sbr->ps_used == 0 && header == 1)
         {
             sbr->ps_used = 1;
+        }
+
+        if (header == 1)
+        {
+            sbr->psResetFlag = 0;
         }
 
         return ret;
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_syntax.h
--- a/src/libfaad/sbr_syntax.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_syntax.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_syntax.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_syntax.h,v 1.23 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SBR_SYNTAX_H__
@@ -55,7 +58,8 @@ extern "C" {
 #define NOISE_FLOOR_OFFSET 6
 
 
-uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt);
+uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt,
+                           uint8_t resetFlag);
 
 #ifdef __cplusplus
 }
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_tf_grid.c
--- a/src/libfaad/sbr_tf_grid.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_tf_grid.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
-**
-** $Id: sbr_tf_grid.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: sbr_tf_grid.c,v 1.19 2007/11/01 12:33:36 menno Exp $
 **/
 
 /* Time/Frequency grid */
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sbr_tf_grid.h
--- a/src/libfaad/sbr_tf_grid.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sbr_tf_grid.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sbr_tf_grid.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sbr_tf_grid.h,v 1.17 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SBR_TF_GRID_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/sine_win.h
--- a/src/libfaad/sine_win.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/sine_win.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: sine_win.h,v 1.6 2005/10/29 23:57:07 tmmm Exp $
+** $Id: sine_win.h,v 1.19 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SINE_WIN_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/specrec.c
--- a/src/libfaad/specrec.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/specrec.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,28 +1,31 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero 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
 ** the Free Software Foundation; either version 2 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: specrec.c,v 1.10 2006/06/17 20:43:57 dgp85 Exp $
+** $Id: specrec.c,v 1.60 2007/11/01 12:33:36 menno Exp $
 **/
 
 /*
@@ -327,6 +330,11 @@ uint8_t window_grouping_info(NeAACDecHan
         }
 #endif
 
+        if (ics->max_sfb > ics->num_swb)
+        {
+            return 32;
+        }
+
         /* preparation of sect_sfb_offset for long blocks */
         /* also copy the last value! */
 #ifdef LD_DEC
@@ -348,6 +356,7 @@ uint8_t window_grouping_info(NeAACDecHan
             }
             ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
             ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
+            ics->swb_offset_max = hDecoder->frameLength;
         } else {
 #endif
             for (i = 0; i < ics->num_swb; i++)
@@ -357,6 +366,7 @@ uint8_t window_grouping_info(NeAACDecHan
             }
             ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength;
             ics->swb_offset[ics->num_swb] = hDecoder->frameLength;
+            ics->swb_offset_max = hDecoder->frameLength;
 #ifdef LD_DEC
         }
 #endif
@@ -367,9 +377,15 @@ uint8_t window_grouping_info(NeAACDecHan
         ics->window_group_length[ics->num_window_groups-1] = 1;
         ics->num_swb = num_swb_128_window[sf_index];
 
+        if (ics->max_sfb > ics->num_swb)
+        {
+            return 32;
+        }
+
         for (i = 0; i < ics->num_swb; i++)
             ics->swb_offset[i] = swb_offset_128_window[sf_index][i];
         ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8;
+        ics->swb_offset_max = hDecoder->frameLength/8;
 
         for (i = 0; i < ics->num_windows-1; i++) {
             if (bit_set(ics->scale_factor_grouping, 6-i) == 0)
@@ -405,7 +421,7 @@ uint8_t window_grouping_info(NeAACDecHan
         }
         return 0;
     default:
-        return 1;
+        return 32;
     }
 }
 
@@ -667,25 +683,46 @@ static uint8_t allocate_single_channel(N
 static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel,
                                        uint8_t output_channels)
 {
-    uint8_t mul = 1;
+    int mul = 1;
 
 #ifdef MAIN_DEC
     /* MAIN object type prediction */
     if (hDecoder->object_type == MAIN)
     {
-            hDecoder->pred_stat[channel] = \
(pred_state*)realloc(hDecoder->pred_stat[channel], hDecoder->frameLength * \
                sizeof(pred_state));
-            reset_all_predictors(hDecoder->pred_stat[channel], \
hDecoder->frameLength); +        /* allocate the state only when needed */
+        if (hDecoder->pred_stat[channel] != NULL)
+        {
+            faad_free(hDecoder->pred_stat[channel]);
+            hDecoder->pred_stat[channel] = NULL;
+        }
+
+        hDecoder->pred_stat[channel] = \
(pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); +        \
reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);  }
 #endif
 
 #ifdef LTP_DEC
     if (is_ltp_ot(hDecoder->object_type))
     {
-            hDecoder->lt_pred_stat[channel] = \
(int16_t*)realloc(hDecoder->lt_pred_stat[channel], hDecoder->frameLength*4 * \
                sizeof(int16_t));
-            memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * \
                sizeof(int16_t));
-    }
-#endif
-
[... 118 lines omitted ...]
-    if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] < output_channels)
-    {
+    if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
+    {
+        /* element_output_channels not set yet */
         hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels;
+    } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != \
output_channels) { +        /* element inconsistency */
+
+        /* this only happens if PS is actually found but not in the first frame
+         * this means that there is only 1 bitstream element!
+         */
+
+        /* reset the allocation */
+        hDecoder->element_alloced[hDecoder->fr_ch_ele] = 0;
+
+        hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels;
+
+        //return 21;
+    }
+
+    if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
+    {
         retval = allocate_single_channel(hDecoder, sce->channel, output_channels);
         if (retval > 0)
             return retval;
@@ -870,7 +951,8 @@ uint8_t reconstruct_single_channel(NeAAC
 
 
     /* pns decoding */
-    pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, \
hDecoder->object_type); +    pns_decode(ics, NULL, spec_coef, NULL, \
hDecoder->frameLength, 0, hDecoder->object_type, +        &(hDecoder->__r1), \
&(hDecoder->__r2));  
 #ifdef MAIN_DEC
     /* MAIN object type prediction */
@@ -954,8 +1036,8 @@ uint8_t reconstruct_single_channel(NeAAC
     if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
         && hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
     {
-        uint8_t ele = hDecoder->fr_ch_ele;
-        uint8_t ch = sce->channel;
+        int ele = hDecoder->fr_ch_ele;
+        int ch = sce->channel;
 
         /* following case can happen when forceUpSampling == 1 */
         if (hDecoder->sbr[ele] == NULL)
@@ -970,9 +1052,9 @@ uint8_t reconstruct_single_channel(NeAAC
         }
 
         if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
-            hDecoder->sbr[ele]->maxAACLine = \
8*sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; +            \
hDecoder->sbr[ele]->maxAACLine = 8*min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, \
0)], sce->ics1.swb_offset_max);  else
-            hDecoder->sbr[ele]->maxAACLine = \
sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; +            \
hDecoder->sbr[ele]->maxAACLine = min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, \
0)], sce->ics1.swb_offset_max);  
         /* check if any of the PS tools is used */
 #if (defined(PS_DEC) || defined(DRM_PS))
@@ -995,19 +1077,20 @@ uint8_t reconstruct_single_channel(NeAAC
     {
         return 23;
     }
+#endif
 
     /* copy L to R when no PS is used */
 #if (defined(PS_DEC) || defined(DRM_PS))
-    if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) && (output_channels == 2))
-    {
-        uint8_t ele = hDecoder->fr_ch_ele;
-        uint8_t ch = sce->channel;
-        uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1;
+    if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) &&
+        (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2))
+    {
+        int ele = hDecoder->fr_ch_ele;
+        int ch = sce->channel;
+        int frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1;
         frame_size *= hDecoder->frameLength*sizeof(real_t);
 
         memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size);
     }
-#endif
 #endif
 
     return 0;
@@ -1049,10 +1132,13 @@ uint8_t reconstruct_channel_pair(NeAACDe
     /* pns decoding */
     if (ics1->ms_mask_present)
     {
-        pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, \
hDecoder->object_type); +        pns_decode(ics1, ics2, spec_coef1, spec_coef2, \
hDecoder->frameLength, 1, hDecoder->object_type, +            &(hDecoder->__r1), \
&(hDecoder->__r2));  } else {
-        pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, \
                hDecoder->object_type);
-        pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, \
hDecoder->object_type); +        pns_decode(ics1, NULL, spec_coef1, NULL, \
hDecoder->frameLength, 0, hDecoder->object_type, +            &(hDecoder->__r1), \
&(hDecoder->__r2)); +        pns_decode(ics2, NULL, spec_coef2, NULL, \
hDecoder->frameLength, 0, hDecoder->object_type, +            &(hDecoder->__r1), \
&(hDecoder->__r2));  }
 
     /* mid/side decoding */
@@ -1204,9 +1290,9 @@ uint8_t reconstruct_channel_pair(NeAACDe
     if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
         && hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
     {
-        uint8_t ele = hDecoder->fr_ch_ele;
-        uint8_t ch0 = cpe->channel;
-        uint8_t ch1 = cpe->paired_channel;
+        int ele = hDecoder->fr_ch_ele;
+        int ch0 = cpe->channel;
+        int ch1 = cpe->paired_channel;
 
         /* following case can happen when forceUpSampling == 1 */
         if (hDecoder->sbr[ele] == NULL)
@@ -1221,9 +1307,9 @@ uint8_t reconstruct_channel_pair(NeAACDe
         }
 
         if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
-            hDecoder->sbr[ele]->maxAACLine = \
8*cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; +            \
hDecoder->sbr[ele]->maxAACLine = 8*min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, \
0)], cpe->ics1.swb_offset_max);  else
-            hDecoder->sbr[ele]->maxAACLine = \
cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; +            \
hDecoder->sbr[ele]->maxAACLine = min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, \
0)], cpe->ics1.swb_offset_max);  
         retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele],
             hDecoder->time_out[ch0], hDecoder->time_out[ch1],
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/specrec.h
--- a/src/libfaad/specrec.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/specrec.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: specrec.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** $Id: specrec.h,v 1.32 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SPECREC_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/ssr.c
--- a/src/libfaad/ssr.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/ssr.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr.c,v 1.6 2005/10/29 23:57:07 tmmm Exp $
+** $Id: ssr.c,v 1.19 2007/11/01 12:33:36 menno Exp $
 **/
 
 #include "common.h"
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/ssr.h
--- a/src/libfaad/ssr.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/ssr.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr.h,v 1.6 2005/10/29 23:57:07 tmmm Exp $
+** $Id: ssr.h,v 1.19 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SSR_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/ssr_fb.c
--- a/src/libfaad/ssr_fb.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/ssr_fb.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr_fb.c,v 1.6 2005/10/29 23:57:07 tmmm Exp $
+** $Id: ssr_fb.c,v 1.17 2007/11/01 12:33:36 menno Exp $
 **/
 
 #include "common.h"
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/ssr_fb.h
--- a/src/libfaad/ssr_fb.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/ssr_fb.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
-** FAAD - Freeware Advanced Audio Decoder
-** Copyright (C) 2002 M. Bakker
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 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
@@ -16,7 +16,16 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: ssr_fb.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_fb.h,v 1.16 2007/11/01 12:33:36 menno Exp $
 **/
 
 #ifndef __SSR_FB_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/ssr_ipqf.c
--- a/src/libfaad/ssr_ipqf.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/ssr_ipqf.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: ssr_ipqf.c,v 1.6 2005/10/29 23:57:07 tmmm Exp $
+** $Id: ssr_ipqf.c,v 1.18 2007/11/01 12:33:39 menno Exp $
 **/
 
 #include "common.h"
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/ssr_ipqf.h
--- a/src/libfaad/ssr_ipqf.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/ssr_ipqf.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
-** FAAD - Freeware Advanced Audio Decoder
-** Copyright (C) 2002 M. Bakker
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 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
@@ -16,7 +16,16 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: ssr_ipqf.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_ipqf.h,v 1.17 2007/11/01 12:33:39 menno Exp $
 **/
 
 #ifndef __SSR_IPQF_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/ssr_win.h
--- a/src/libfaad/ssr_win.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/ssr_win.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
-** FAAD - Freeware Advanced Audio Decoder
-** Copyright (C) 2002 M. Bakker
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2005 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
@@ -16,7 +16,16 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: ssr_win.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: ssr_win.h,v 1.16 2007/11/01 12:33:39 menno Exp $
 **/
 
 #ifndef __SSR_WIN_H__
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/structs.h
--- a/src/libfaad/structs.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/structs.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,28 +1,31 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
-**
+** Copyright (C) 2003-2005 M. Bakker, Nero 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
 ** the Free Software Foundation; either version 2 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: structs.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $
+** $Id: structs.h,v 1.46 2007/11/01 12:33:40 menno Exp $
 **/
 
 #ifndef __STRUCTS_H__
@@ -247,6 +250,7 @@ typedef struct
     uint8_t scale_factor_grouping;
     uint16_t sect_sfb_offset[8][15*8];
     uint16_t swb_offset[52];
+    uint16_t swb_offset_max;
 
     uint8_t sect_cb[8][15*8];
     uint16_t sect_start[8][15*8];
@@ -261,6 +265,7 @@ typedef struct
     uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
 
     uint8_t noise_used;
+    uint8_t is_used;
 
     uint8_t pulse_data_present;
     uint8_t tns_data_present;
@@ -447,6 +452,14 @@ typedef struct
     int16_t *lt_pred_stat[MAX_CHANNELS];
 #endif
 
+#ifdef DRM
+    uint8_t error_state;
+#endif
+
+    /* RNG states */
+    uint32_t __r1;
+    uint32_t __r2;
+
     /* Program Config Element */
     uint8_t pce_set;
     program_config pce;
@@ -463,6 +476,7 @@ typedef struct
     int64_t scalefac_cycles;
     int64_t requant_cycles;
 #endif
+	const unsigned char *cmes;
 } NeAACDecStruct, *NeAACDecHandle;
 
 
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/syntax.c
--- a/src/libfaad/syntax.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/syntax.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: syntax.c,v 1.10 2006/09/26 17:48:24 dgp85 Exp $
+** $Id: syntax.c,v 1.89 2007/11/01 12:33:40 menno Exp $
 **/
 
 /*
@@ -93,9 +96,11 @@ static void adts_error_check(adts_header
 static void adts_error_check(adts_header *adts, bitfile *ld);
 static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc);
 static uint8_t excluded_channels(bitfile *ld, drc_info *drc);
-#ifdef SCALABLE_DEC
-static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, \
                ic_stream *ics2,
-                                       bitfile *ld, uint8_t this_layer_stereo);
+static uint8_t side_info(NeAACDecHandle hDecoder, element *ele,
+                         bitfile *ld, ic_stream *ics, uint8_t scal_flag);
+#ifdef DRM
+static int8_t DRM_aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, \
ic_stream *ics2, +                                           bitfile *ld, uint8_t \
this_layer_stereo);  #endif
 
 
@@ -323,7 +328,7 @@ static void decode_sce_lfe(NeAACDecHandl
     uint8_t channels = hDecoder->fr_channels;
     uint8_t tag = 0;
 
-    if (channels+1 >= MAX_CHANNELS)
+    if (channels+1 > MAX_CHANNELS)
     {
         hInfo->error = 12;
         return;
@@ -413,6 +418,7 @@ void raw_data_block(NeAACDecHandle hDeco
                     bitfile *ld, program_config *pce, drc_info *drc)
 {
     uint8_t id_syn_ele;
+    uint8_t ele_this_frame = 0;
 
     hDecoder->fr_channels = 0;
     hDecoder->fr_ch_ele = 0;
@@ -429,36 +435,55 @@ void raw_data_block(NeAACDecHandle hDeco
         {
             switch (id_syn_ele) {
             case ID_SCE:
+                ele_this_frame++;
                 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = \
id_syn_ele;  decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
                 if (hInfo->error > 0)
                     return;
                 break;
             case ID_CPE:
+                ele_this_frame++;
                 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = \
id_syn_ele;  decode_cpe(hDecoder, hInfo, ld, id_syn_ele);
                 if (hInfo->error > 0)
                     return;
                 break;
             case ID_LFE:
+#ifdef DRM
+                hInfo->error = 32;
+#else
+                ele_this_frame++;
                 hDecoder->has_lfe++;
                 decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
+#endif
                 if (hInfo->error > 0)
                     return;
                 break;
             case ID_CCE: /* not implemented yet, but skip the bits */
+#ifdef DRM
+                hInfo->error = 32;
+#else
+                ele_this_frame++;
 #ifdef COUPLING_DEC
                 hInfo->error = coupling_channel_element(hDecoder, ld);
 #else
                 hInfo->error = 6;
 #endif
+#endif
                 if (hInfo->error > 0)
                     return;
                 break;
             case ID_DSE:
+                ele_this_frame++;
                 data_stream_element(hDecoder, ld);
                 break;
             case ID_PCE:
+                if (ele_this_frame != 0)
+                {
+                    hInfo->error = 31;
+                    return;
+                }
+                ele_this_frame++;
                 /* 14496-4: 5.6.4.1.2.1.3: */
                 /* program_configuration_element()'s in access units shall be \
ignored */  program_config_element(pce, ld);
@@ -467,6 +492,7 @@ void raw_data_block(NeAACDecHandle hDeco
                 //hDecoder->pce_set = 1;
                 break;
             case ID_FIL:
+                ele_this_frame++;
                 /* one sbr_info describes a channel_element not a channel! */
                 /* if we encounter SBR data here: error */
                 /* SBR data will be read directly in the SCE/LFE/CPE element */
@@ -577,6 +603,10 @@ static uint8_t single_lfe_channel_elemen
     if (retval > 0)
         return retval;
 
+    /* IS not allowed in single channel */
[... 369 lines omitted ...]
@@ -1523,10 +1603,13 @@ static uint8_t individual_channel_stream
 #ifdef DRM
     /* CRC check */
     if (hDecoder->object_type == DRM_ER_LC)
+    {
         if ((result = (uint8_t)faad_check_CRC(ld, \
(uint16_t)faad_get_processed_bits(ld) - 8)) > 0)  return result;
-#endif
-
+    }
+#endif
+
+#ifdef ERROR_RESILIENCE
     if (hDecoder->aacSpectralDataResilienceFlag)
     {
         /* error resilient spectral data decoding */
@@ -1594,7 +1677,7 @@ static uint8_t section_data(NeAACDecHand
 
             /* if "faad_getbits" detects error and returns "0", "k" is never
                incremented and we cannot leave the while loop */
-            if ((ld->error != 0) || (ld->no_more_reading))
+            if (ld->error != 0)
                 return 14;
 
 #ifdef ERROR_RESILIENCE
@@ -1605,12 +1688,23 @@ static uint8_t section_data(NeAACDecHand
             ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits
                 DEBUGVAR(1,71,"section_data(): sect_cb"));
 
+            if (ics->sect_cb[g][i] == 12)
+                return 32;
+
 #if 0
             printf("%d\n", ics->sect_cb[g][i]);
 #endif
 
+#ifndef DRM
             if (ics->sect_cb[g][i] == NOISE_HCB)
                 ics->noise_used = 1;
+#else
+            /* PNS not allowed in DRM */
+            if (ics->sect_cb[g][i] == NOISE_HCB)
+                return 29;
+#endif
+            if (ics->sect_cb[g][i] == INTENSITY_HCB2 || ics->sect_cb[g][i] == \
INTENSITY_HCB) +                ics->is_used = 1;
 
 #ifdef ERROR_RESILIENCE
             if (hDecoder->aacSectionDataResilienceFlag)
@@ -1651,10 +1745,18 @@ static uint8_t section_data(NeAACDecHand
             printf("%d\n", ics->sect_end[g][i]);
 #endif
 
-            if (k + sect_len >= 8*15)
-                return 15;
-            if (i >= 8*15)
-                return 15;
+            if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
+            {
+                if (k + sect_len > 8*15)
+                    return 15;
+                if (i >= 8*15)
+                    return 15;
+            } else {
+                if (k + sect_len > MAX_SFB)
+                    return 15;
+                if (i >= MAX_SFB)
+                    return 15;
+            }
 
             for (sfb = k; sfb < k + sect_len; sfb++)
             {
@@ -1675,6 +1777,13 @@ static uint8_t section_data(NeAACDecHand
             i++;
         }
         ics->num_sec[g] = i;
+
+        /* the sum of all sect_len_incr elements for a given window
+         * group shall equal max_sfb */
+        if (k != ics->max_sfb)
+        {
+            return 32;
+        }
 #if 0
         printf("%d\n", ics->num_sec[g]);
 #endif
@@ -1735,6 +1844,7 @@ static uint8_t decode_scale_factors(ic_s
                 break;
             case NOISE_HCB: /* noise books */
 
+#ifndef DRM
                 /* decode noise energy */
                 if (noise_pcm_flag)
                 {
@@ -1750,6 +1860,10 @@ static uint8_t decode_scale_factors(ic_s
 #ifdef SF_PRINT
                 printf("%d\n", ics->scale_factors[g][sfb]);
 #endif
+#else
+                /* PNS not allowed in DRM */
+                return 29;
+#endif
 
                 break;
             default: /* spectral books */
@@ -2048,11 +2162,11 @@ static uint16_t extension_payload(bitfil
         return n;
     case EXT_FILL_DATA:
         /* fill_nibble = */ faad_getbits(ld, 4
-            DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be '0000' \
*/ +            DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be \
‘0000’ */  for (i = 0; i < count-1; i++)
         {
             /* fill_byte[i] = */ faad_getbits(ld, 8
-                DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be \
'10100101' */ +                DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* \
must be ‘10100101’ */  }
         return count;
     case EXT_DATA_ELEMENT:
@@ -2127,7 +2241,7 @@ static uint8_t dynamic_range_info(bitfil
         n++;
         drc->num_bands += band_incr;
 
-        for (i = 0; i < drc->num_bands; i++);
+        for (i = 0; i < drc->num_bands; i++)
         {
             drc->band_top[i] = (uint8_t)faad_getbits(ld, 8
                 DEBUGVAR(1,97,"dynamic_range_info(): band_top"));
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/syntax.h
--- a/src/libfaad/syntax.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/syntax.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: syntax.h,v 1.10 2005/10/29 23:57:07 tmmm Exp $
+** $Id: syntax.h,v 1.58 2007/11/01 12:33:40 menno Exp $
 **/
 
 #ifndef __SYNTAX_H__
@@ -114,9 +117,10 @@ void raw_data_block(NeAACDecHandle hDeco
                     bitfile *ld, program_config *pce, drc_info *drc);
 uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile \
*ld,  int16_t *spectral_data);
-void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
-                               bitfile *ld, program_config *pce, drc_info *drc);
-
+#ifdef DRM
+void DRM_aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo \
*hInfo, +                                   bitfile *ld, program_config *pce, \
drc_info *drc); +#endif
 
 #ifdef __cplusplus
 }
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/tns.c
--- a/src/libfaad/tns.c	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/tns.c	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
-**
-** $Id: tns.c,v 1.8 2005/10/29 23:57:07 tmmm Exp $
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
+**
+** $Id: tns.c,v 1.40 2007/11/01 12:33:40 menno Exp $
 **/
 
 #include "common.h"
@@ -106,11 +109,11 @@ void tns_decode_frame(ic_stream *ics, tn
 
             start = min(bottom, max_tns_sfb(sr_index, object_type, \
(ics->window_sequence == EIGHT_SHORT_SEQUENCE)));  start = min(start, ics->max_sfb);
-            start = ics->swb_offset[start];
+            start = min(ics->swb_offset[start], ics->swb_offset_max);
 
             end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence \
== EIGHT_SHORT_SEQUENCE)));  end = min(end, ics->max_sfb);
-            end = ics->swb_offset[end];
+            end = min(ics->swb_offset[end], ics->swb_offset_max);
 
             size = end - start;
             if (size <= 0)
@@ -160,11 +163,11 @@ void tns_encode_frame(ic_stream *ics, tn
 
             start = min(bottom, max_tns_sfb(sr_index, object_type, \
(ics->window_sequence == EIGHT_SHORT_SEQUENCE)));  start = min(start, ics->max_sfb);
-            start = ics->swb_offset[start];
+            start = min(ics->swb_offset[start], ics->swb_offset_max);
 
             end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence \
== EIGHT_SHORT_SEQUENCE)));  end = min(end, ics->max_sfb);
-            end = ics->swb_offset[end];
+            end = min(ics->swb_offset[end], ics->swb_offset_max);
 
             size = end - start;
             if (size <= 0)
@@ -292,7 +295,7 @@ static void tns_ma_filter(real_t *spectr
         y = *spectrum;
 
         for (j = 0; j < order; j++)
-            y += MUL_C(state[j], lpc[j+1]);
+            y += MUL_C(state[state_index+j], lpc[j+1]);
 
         /* double ringbuffer state */
         state_index--;
diff -r 18c0264660b951b8e5672f1a66d1bcecdfeb6ea8 -r \
                608e33e144c7eebe016fbf306771bff4219d1629 src/libfaad/tns.h
--- a/src/libfaad/tns.h	Wed Aug 13 14:28:30 2008 +0100
+++ b/src/libfaad/tns.h	Fri Aug 08 11:18:08 2008 +0100
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2005 M. Bakker, Nero 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,10 +19,13 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
+** The "appropriate copyright message" mentioned in section 2c of the GPLv2
+** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
+**
 ** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
 **
-** $Id: tns.h,v 1.8 2005/10/29 23:57:07 tmmm Exp $
+** $Id: tns.h,v 1.23 2007/11/01 12:33:41 menno Exp $
 **/
 
 #ifndef __TNS_H__



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Xine-cvslog mailing list
Xine-cvslog@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xine-cvslog


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic