shithub: aacdec

Download patch

ref: 44e7816658ea0f995343ee7bb288001b3647925b
parent: 6e334f585508b2e4f92f331f4553a6dae93820a9
author: menno <menno>
date: Mon Dec 2 15:28:04 EST 2002

mono decoding bug
some more ssr stuff

--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.c,v 1.40 2002/11/28 18:48:29 menno Exp $
+** $Id: decoder.c,v 1.41 2002/12/02 20:27:51 menno Exp $
 **/
 
 #include "common.h"
@@ -81,6 +81,9 @@
     {
         hDecoder->window_shape_prev[i] = 0;
         hDecoder->time_out[i] = NULL;
+#ifdef SSR_DEC
+        hDecoder->ssr_overlap[i] = NULL;
+#endif
 #ifdef MAIN_DEC
         hDecoder->pred_stat[i] = NULL;
 #endif
@@ -271,6 +274,9 @@
     for (i = 0; i < MAX_CHANNELS; i++)
     {
         if (hDecoder->time_out[i]) free(hDecoder->time_out[i]);
+#ifdef SSR_DEC
+        if (hDecoder->ssr_overlap[i]) free(hDecoder->ssr_overlap[i]);
+#endif
 #ifdef MAIN_DEC
         if (hDecoder->pred_stat[i]) free(hDecoder->pred_stat[i]);
 #endif
@@ -326,6 +332,9 @@
 #endif
     uint8_t *window_shape_prev = hDecoder->window_shape_prev;
     real_t **time_out      =  hDecoder->time_out;
+#ifdef SSR_DEC
+    real_t **ssr_overlap   =  hDecoder->ssr_overlap;
+#endif
     fb_info *fb            =  hDecoder->fb;
     drc_info *drc          =  hDecoder->drc;
     uint8_t outputFormat   =  hDecoder->config.outputFormat;
@@ -458,7 +467,7 @@
         else if ((pch == -1) || ((pch != -1) && (!ics->ms_mask_present)))
             pns_decode(ics, NULL, spec_coef[ch], NULL, frame_len, 0);
 
-        if (!right_channel)
+        if (!right_channel && (pch != -1))
         {
             /* mid/side decoding */
             ms_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len);
@@ -551,9 +560,15 @@
                 time_out[ch], object_type, frame_len);
 #ifdef SSR_DEC
         } else {
+            if (ssr_overlap[ch] == NULL)
+            {
+                ssr_overlap[ch] = (real_t*)malloc(2*frame_len*sizeof(real_t));
+                memset(ssr_overlap[ch], 0, 2*frame_len*sizeof(real_t));
+            }
+
             ssr_decode(&(ics->ssr), fb, ics->window_sequence, ics->window_shape,
                 window_shape_prev[ch], spec_coef[ch],
-                time_out[ch], frame_len);
+                time_out[ch], ssr_overlap[ch], frame_len);
         }
 #endif
         /* save window shape for next frame */
--- a/libfaad/libfaad.vcproj
+++ b/libfaad/libfaad.vcproj
@@ -33,15 +33,13 @@
 				WarningLevel="3"
 				SuppressStartupBanner="TRUE"
 				DebugInformationFormat="4"
-				CompileAs="0"
-				AdditionalOptions="">
+				CompileAs="0">
 				<IntelOptions
 					Optimization="0"
 					MinimalRebuild="1"
 					BasicRuntimeChecks="3"
 					RuntimeLibrary="1"
-					AllOptions="/c  /I &quot;fftw&quot; /ZI /nologo /W3 /Od /D &quot;_DEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;FFTW_ENABLE_FLOAT&quot; /D &quot;_MBCS&quot; /Gm /EHsc /RTC1 /MTd /YX&quot;StdAfx.h&quot; /Fp&quot;.\Debug/libfaad.pch&quot; /Fo&quot;.\Debug/&quot; /Fd&quot;.\Debug/&quot; /Gd"
-					MSOriginalAdditionalOptions=""/>
+					AllOptions="/c  /I &quot;fftw&quot; /ZI /nologo /W3 /Od /D &quot;_DEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;FFTW_ENABLE_FLOAT&quot; /D &quot;_MBCS&quot; /Gm /EHsc /RTC1 /MTd /YX&quot;StdAfx.h&quot; /Fp&quot;.\Debug/libfaad.pch&quot; /Fo&quot;.\Debug/&quot; /Fd&quot;.\Debug/&quot; /Gd"/>
 			</Tool>
 			<Tool
 				Name="VCCustomBuildTool"/>
@@ -48,11 +46,9 @@
 			<Tool
 				Name="VCLibrarianTool"
 				OutputFile=".\Debug\libfaad.lib"
-				SuppressStartupBanner="TRUE"
-				AdditionalOptions="">
+				SuppressStartupBanner="TRUE">
 				<IntelOptions
-					AllOptions="/OUT:&quot;.\Debug\libfaad.lib&quot; /NOLOGO"
-					MSOriginalAdditionalOptions=""/>
+					AllOptions="/OUT:&quot;.\Debug\libfaad.lib&quot; /NOLOGO"/>
 			</Tool>
 			<Tool
 				Name="VCMIDLTool"/>
@@ -69,7 +65,7 @@
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
 			<IntelOptions
-				CompilerName="0"/>
+				CompilerName="1"/>
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
@@ -99,8 +95,7 @@
 				WarningLevel="3"
 				SuppressStartupBanner="TRUE"
 				Detect64BitPortabilityProblems="FALSE"
-				CompileAs="0"
-				AdditionalOptions="">
+				CompileAs="0">
 				<IntelOptions
 					Optimization="2"
 					GlobalOptimizations="0"
@@ -116,8 +111,7 @@
 					RuntimeLibrary="0"
 					BufferSecurityCheck="1"
 					FunctionLevelLinking="1"
-					AllOptions="/c  /nologo /W3 /O2 /Ob1 /Oi /Ot /Oy /G6 /D &quot;NDEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;FFTW_ENABLE_FLOAT&quot; /D &quot;_MBCS&quot; /GF /FD /EHsc /MT /GS /Gy /YX&quot;StdAfx.h&quot; /Fp&quot;.\Release/libfaad.pch&quot; /Fo&quot;.\Release/&quot; /Fd&quot;.\Release/&quot; /Gd"
-					MSOriginalAdditionalOptions=""/>
+					AllOptions="/c  /nologo /W3 /O2 /Ob1 /Oi /Ot /Oy /G6 /D &quot;NDEBUG&quot; /D &quot;WIN32&quot; /D &quot;_LIB&quot; /D &quot;FFTW_ENABLE_FLOAT&quot; /D &quot;_MBCS&quot; /GF /FD /EHsc /MT /GS /Gy /YX&quot;StdAfx.h&quot; /Fp&quot;.\Release/libfaad.pch&quot; /Fo&quot;.\Release/&quot; /Fd&quot;.\Release/&quot; /Gd"/>
 			</Tool>
 			<Tool
 				Name="VCCustomBuildTool"/>
@@ -124,11 +118,9 @@
 			<Tool
 				Name="VCLibrarianTool"
 				OutputFile=".\Release\libfaad.lib"
-				SuppressStartupBanner="TRUE"
-				AdditionalOptions="">
+				SuppressStartupBanner="TRUE">
 				<IntelOptions
-					AllOptions="/OUT:&quot;.\Release\libfaad.lib&quot; /NOLOGO"
-					MSOriginalAdditionalOptions=""/>
+					AllOptions="/OUT:&quot;.\Release\libfaad.lib&quot; /NOLOGO"/>
 			</Tool>
 			<Tool
 				Name="VCMIDLTool"/>
--- a/libfaad/ssr.c
+++ b/libfaad/ssr.c
@@ -16,7 +16,7 @@
 ** 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.c,v 1.1 2002/11/28 18:48:30 menno Exp $
+** $Id: ssr.c,v 1.2 2002/12/02 20:27:59 menno Exp $
 **/
 
 #include "common.h"
@@ -31,12 +31,17 @@
 
 void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence,
                 uint8_t window_shape, uint8_t window_shape_prev,
-                real_t *freq_in, real_t *time_out, uint16_t frame_len)
+                real_t *freq_in, real_t *time_out, real_t *overlap,
+                uint16_t frame_len)
 {
     uint8_t band;
     uint16_t ssr_frame_len = frame_len/SSR_BANDS;
     real_t time_tmp[2048];
+    real_t output[1024];
 
+    memset(output, 0, 1024*sizeof(real_t));
+    memset(time_tmp, 0, 2048*sizeof(real_t));
+
     for (band = 0; band < SSR_BANDS; band++)
     {
         int16_t j;
@@ -59,25 +64,62 @@
             freq_in + band*ssr_frame_len, time_tmp + band*ssr_frame_len,
             ssr_frame_len);
 
-#if 0
         /* gain control */
-        ssr_gain_control(ssr, time_tmp, window_sequence, ssr_frame_len);
-#endif
+        ssr_gain_control(ssr, time_tmp, output, overlap, band,
+            window_sequence, ssr_frame_len);
     }
 
 #if 0
     /* inverse pqf to bring subbands together again */
-    ssr_ipqf();
+    ssr_ipqf(ssr_info *ssr, real_t *time_tmp);
 #endif
 }
 
-static void ssr_gain_control(ssr_info *ssr, real_t *data, uint8_t window_sequence,
-                             uint16_t frame_len)
+static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output,
+                             real_t *overlap, uint8_t band,
+                             uint8_t window_sequence, uint16_t frame_len)
 {
+    uint16_t i;
+
     if (window_sequence != EIGHT_SHORT_SEQUENCE)
     {
 //        ssr_gc_function();
+//        for (i = 0; i < frame_len*2; i++)
+//          input[band * frame_len*2 + i] *= gc_function[i];
+        for (i = 0; i < frame_len; i++)
+        {
+            output[band*frame_len + i] = overlap[band*frame_len + i] +
+                data[band*frame_len*2 + i];
+        }
+        for (i = 0; i < frame_len; i++)
+        {
+            overlap[band*frame_len + i] =
+                data[band*frame_len*2 + frame_len + i];
+        }
     } else {
+        uint8_t w;
+        for (w = 0; w < 8; w++)
+        {
+            uint16_t frame_len8 = frame_len/8;
+            uint16_t frame_len16 = frame_len/16;
+//            ssr_gc_function();
+//            for (i = 0; i < frame_len*2/8; i++)
+//                input[band*frame_len*2 + w*frame_len*2/8+j] *= gc_function[j];
+            for (i = 0; i < frame_len8; i++)
+            {
+                overlap[band*frame_len + i + 7*frame_len16 + w*frame_len8] +=
+                    data[band*frame_len*2 + 2*w*frame_len8 + i];
+            }
+            for (i = 0; i < frame_len8; i++)
+            {
+                overlap[band*frame_len + i + 7*frame_len16 + (w+1)*frame_len8] =
+                    data[band*frame_len*2 + 2*w*frame_len8 + frame_len8 + i];
+            }
+        }
+        for (i = 0; i < frame_len; i++)
+            output[band*frame_len + i] = overlap[band*frame_len + i];
+        for (i = 0; i < frame_len; i++)
+            overlap[band*frame_len + i] = overlap[band*frame_len + i + frame_len];
     }
 }
 
--- a/libfaad/ssr.h
+++ b/libfaad/ssr.h
@@ -16,7 +16,7 @@
 ** 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.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+** $Id: ssr.h,v 1.2 2002/12/02 20:28:02 menno Exp $
 **/
 
 #ifndef __SSR_H__
@@ -30,7 +30,13 @@
 
 void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence,
                 uint8_t window_shape, uint8_t window_shape_prev,
-                real_t *freq_in, real_t *time_out, uint16_t frame_len);
+                real_t *freq_in, real_t *time_out, real_t *overlap,
+                uint16_t frame_len);
+
+
+static void ssr_gain_control(ssr_info *ssr, real_t *data, real_t *output,
+                             real_t *overlap, uint8_t band,
+                             uint8_t window_sequence, uint16_t frame_len);
 
 #ifdef __cplusplus
 }
--- a/libfaad/structs.h
+++ b/libfaad/structs.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: structs.h,v 1.1 2002/11/28 18:48:30 menno Exp $
+** $Id: structs.h,v 1.2 2002/12/02 20:28:04 menno Exp $
 **/
 
 #ifndef __STRUCTS_H__
@@ -321,6 +321,10 @@
     drc_info *drc;
 
     real_t *time_out[MAX_CHANNELS];
+
+#ifdef SSR_DEC
+    real_t *ssr_overlap[MAX_CHANNELS];
+#endif
 
 #ifdef MAIN_DEC
     pred_state *pred_stat[MAX_CHANNELS];