shithub: aacenc

Download patch

ref: 8bbe025bcaa0772024b78f0c204ea35cb886f662
parent: 31d76c761fffa88a3a1f8909eefcab8925c6e9f9
author: lenox <lenox>
date: Mon Feb 7 02:45:00 EST 2000

added support for different window shapes

--- a/all.h
+++ b/all.h
@@ -60,11 +60,5 @@
     MS_Info ms_info;    /* MS information */
 } Ch_Info;
 
-#ifdef MPEG4V1
-#define _WINDOW_TYPE_EXT
-typedef byte WINDOW_TYPE_EXT;
-#include "nok_lt_prediction.h"
-#endif /* MPEG4V1 */
-
 #endif	/* _all_h_ */
 
--- a/block.h
+++ b/block.h
@@ -26,9 +26,6 @@
 #ifndef BLOCK_H
 #define BLOCK_H 1
 
-#include "dolby_def.h"
-
-
 #define IN_DATATYPE  double
 #define OUT_DATATYPE double
 
@@ -35,11 +32,6 @@
 #define BLOCK_LEN_LONG	   1024
 #define BLOCK_LEN_MEDIUM   512
 #define BLOCK_LEN_SHORT    128
-#define BLOCK_LEN_LONG_S   960
-#define BLOCK_LEN_MEDIUM_S 480
-#define BLOCK_LEN_SHORT_S  120
-#define BLOCK_LEN_LONG_SSR	  256 /* 980129 added for SSR */
-#define BLOCK_LEN_SHORT_SSR   32  /* 980129 added for SSR */
 
 #define NWINLONG	(BLOCK_LEN_LONG)
 #define ALFALONG	4.0
@@ -53,7 +45,7 @@
 
 
 typedef enum {
-    WS_FHG, WS_DOLBY, N_WINDOW_SHAPES
+    WS_SIN, WS_KBD, N_WINDOW_SHAPES
 } 
 Window_shape;
 
--- a/enc_tf.c
+++ b/enc_tf.c
@@ -403,8 +403,8 @@
 		for (chanNum=0;chanNum<max_ch;chanNum++) {
 
 			/* Set window shape paremeter in quantInfo */
-//			quantInfo[chanNum].window_shape = WS_DOLBY;
-			quantInfo[chanNum].window_shape = WS_FHG;
+//			quantInfo[chanNum].window_shape = WS_KBD;
+			quantInfo[chanNum].window_shape = WS_SIN;
 
 			switch( block_type[chanNum] ) {
 			case ONLY_SHORT_WINDOW  :
@@ -469,9 +469,8 @@
 				overlap_buffer[chanNum],
 				block_type[chanNum],
 //				quantInfo[chanNum].window_shape,
-//				block_size_samples,
-//				block_size_samples/2,
-//				block_size_samples/short_win_in_long,
+                                WS_SIN,
+                                WS_SIN,
 				MOVERLAPPED
 				);
 
@@ -607,7 +606,7 @@
 						nok_ltp_enc(spectral_line_vector[leftChan], 
 							nok_tmp_DTimeSigBuf[leftChan], 
 							block_type[leftChan], 
-							WS_FHG,
+							WS_SIN,
 							block_size_samples,
 							1,
 							block_size_samples/short_win_in_long, 
@@ -630,7 +629,7 @@
 							nok_ltp_enc(spectral_line_vector[rightChan],
 							nok_tmp_DTimeSigBuf[rightChan], 
 							block_type[rightChan], 
-							WS_FHG,
+							WS_SIN,
 							block_size_samples,
 							1,
 							block_size_samples/short_win_in_long, 
@@ -644,7 +643,7 @@
 					nok_ltp_enc(spectral_line_vector[chanNum], 
 					nok_tmp_DTimeSigBuf[chanNum], 
 					block_type[chanNum], 
-					WS_FHG,
+					WS_SIN,
 					block_size_samples,
 					1,
 					block_size_samples/short_win_in_long, 
@@ -740,7 +739,7 @@
                   for (chanNum=0;chanNum<max_ch;chanNum++) {
 			nok_ltp_reconstruct(reconstructed_spectrum[chanNum],
 				block_type[chanNum],
-				WS_FHG, block_size_samples,
+				WS_SIN, block_size_samples,
 				block_size_samples/2,
 				block_size_samples/short_win_in_long,
 				&sfb_offset_table[chanNum][0],
--- a/nok_ltp_enc.c
+++ b/nok_ltp_enc.c
@@ -34,8 +34,8 @@
 /**************************************************************************
   Version Control Information			Method: CVS
   Identifiers:
-  $Revision: 1.4 $
-  $Date: 2000/01/29 17:11:25 $ (check in)
+  $Revision: 1.5 $
+  $Date: 2000/02/07 07:45:00 $ (check in)
   $Author: lenox $
   *************************************************************************/
 
@@ -82,7 +82,7 @@
                         - weight_idx : 
                           3 bit number indicating the LTP coefficient in 
                           the codebook 
-                        - sbk_prediction_used: 
+                        - sbk_prediction_used:
                           1 bit for each subblock indicating wheather
                           LTP is used in that subblock 
                         - sfb_prediction_used:
@@ -174,7 +174,7 @@
   *************************************************************************/
 
 int
-nok_ltp_enc(double *p_spectrum, double *p_time_signal, enum WINDOW_TYPE win_type, 
+nok_ltp_enc(double *p_spectrum, double *p_time_signal, enum WINDOW_TYPE win_type,
             Window_shape win_shape, int block_size_long, int block_size_medium,
 	    int block_size_short, int *sfb_offset, int num_of_sfb,
             NOK_LT_PRED_STATUS *lt_status)
@@ -181,7 +181,7 @@
 {
     int i;
     int last_band;
-	double num_bit[MAX_SHORT_WINDOWS];
+    double num_bit[MAX_SHORT_WINDOWS];
     double predicted_samples[2 * NOK_MAX_BLOCK_LEN_LONG];
 
     lt_status->global_pred_flag = 0;
@@ -198,19 +198,16 @@
 
 //		fprintf(stderr, "(LTP) lag : %i ", lt_status->delay[0]);
 
-		pitch (p_time_signal, predicted_samples, lt_status->buffer, 
+		pitch (p_time_signal, predicted_samples, lt_status->buffer,
 			&lt_status->weight_idx, lt_status->delay[0], 2 * block_size_long);
 
 		/* Transform prediction to frequency domain and save it for subsequent use. */
-//		buffer2freq (predicted_samples, lt_status->pred_mdct, NULL, win_type,
-//			win_shape, block_size_long, block_size_medium,
-//			block_size_short, MNON_OVERLAPPED);
-		buffer2freq (predicted_samples, lt_status->pred_mdct, NULL, win_type, MNON_OVERLAPPED);
+		buffer2freq (predicted_samples, lt_status->pred_mdct, NULL, win_type, win_shape, WS_SIN, MNON_OVERLAPPED);
 
 		lt_status->side_info = LEN_LTP_DATA_PRESENT + last_band + LEN_LTP_LAG + LEN_LTP_COEF;
-    
+
 		num_bit[0] = snr_pred (p_spectrum, lt_status->pred_mdct,
-			lt_status->sfb_prediction_used, sfb_offset, 
+			lt_status->sfb_prediction_used, sfb_offset,
 			win_type, lt_status->side_info, last_band);
 
 //		if (num_bit[0] > 0) {
@@ -230,7 +227,7 @@
 	case ONLY_SHORT_WINDOW:
 		break;
     }
-    
+
     return (lt_status->global_pred_flag);
 }
 
@@ -253,7 +250,7 @@
 
   Output:	p_spectrum    - reconstructed spectrum
                 lt_status     - buffer: history buffer
-                           
+
   References:	1.) buffer2freq
                 2.) freq2buffer
                 3.) double_to_int
@@ -281,16 +278,13 @@
 	case LONG_SHORT_WINDOW:
 	case SHORT_LONG_WINDOW:
 		last_band = (num_of_sfb < NOK_MAX_LT_PRED_LONG_SFB) ? num_of_sfb : NOK_MAX_LT_PRED_LONG_SFB;
-		
+
 		if(lt_status->global_pred_flag)
 			for (i = 0; i < sfb_offset[last_band]; i++)
 				p_spectrum[i] += lt_status->pred_mdct[i];
 
 		/* Finally update the time domain history buffer. */
-//		freq2buffer (p_spectrum, predicted_samples, overlap_buffer, win_type,
-//			block_size_long, block_size_medium, block_size_short,
-//			win_shape, MNON_OVERLAPPED);
-		freq2buffer (p_spectrum, predicted_samples, overlap_buffer, win_type, MNON_OVERLAPPED);
+		freq2buffer (p_spectrum, predicted_samples, overlap_buffer, win_type, WS_SIN, WS_SIN, MNON_OVERLAPPED);
 
 		for (i = 0; i < NOK_LT_BLEN - block_size_long; i++)
 			lt_status->buffer[i] = lt_status->buffer[i + block_size_long];
@@ -304,12 +298,12 @@
 				double_to_int (predicted_samples[i + block_size_long]);
 		}
 		break;
-	
+
     case ONLY_SHORT_WINDOW:
 #if 0
 		for (i = 0; i < NOK_LT_BLEN - block_size_long; i++)
 			lt_status->buffer[i] = lt_status->buffer[i + block_size_long];
-		
+
 		for (i = NOK_LT_BLEN - block_size_long; i < NOK_LT_BLEN; i++)
 			lt_status->buffer[i] = 0;
 
@@ -317,7 +311,7 @@
 			overlap_buffer[i] = 0;
 
 		/* Finally update the time domain history buffer. */
-		freq2buffer (p_spectrum, predicted_samples, overlap_buffer, win_type, block_size_long, 
+		freq2buffer (p_spectrum, predicted_samples, overlap_buffer, win_type, block_size_long,
 			block_size_medium, block_size_short, win_shape, MNON_OVERLAPPED);
 
 		for(sw = 0; sw < MAX_SHORT_WINDOWS; sw++)
--- a/tf_main.h
+++ b/tf_main.h
@@ -118,26 +118,29 @@
   double           p_out_data[],
   double           p_overlap[],
   enum WINDOW_TYPE block_type,
-//  int              nlong,            /* shift length for long windows   */
-  Mdct_in	   overlap_select);    /* select imdct output *TK*	*/
+  Window_shape     wfun_select,      
+  Window_shape     wfun_select_prev,   
+  Mdct_in	   overlap_select
+);
 
-void buffer2freq(                    /* Input: Time signal              */
-  double           p_in_data[],      /* Output: MDCT cofficients        */
+void buffer2freq(                    
+  double           p_in_data[],      
   double           p_out_mdct[],
   double           p_overlap[],
   enum WINDOW_TYPE block_type,
-//  Window_shape     wfun_select,      /* offers the possibility to select different window functions */
-  Mdct_in        overlap_select      /* YT 970615 for Son_PP */
+  Window_shape     wfun_select,      
+  Window_shape     wfun_select_prev,   
+  Mdct_in          overlap_select      
 );
 
 void make_MDCT_windows(void);
 
 void specFilter (double p_in[],
-				 double p_out[],
-				 int  samp_rate,
-				 int lowpass_freq,
-				 int    specLen
-				 );
+		 double p_out[],
+		 int  samp_rate,
+		 int lowpass_freq,
+		 int    specLen
+);
 
 #endif	/* #ifndef _TF_MAIN_H_INCLUDED */
 
--- a/transfo.c
+++ b/transfo.c
@@ -2,6 +2,7 @@
 #include <string.h>
 #include "all.h"
 #include "transfo.h"
+#include "kbd_win.h"
 
 #ifndef M_PI
 #define M_PI        3.14159265358979323846
@@ -13,8 +14,8 @@
 
 #define NFLAT_LS 448  // (BLOCK_LEN_LONG - BLOCK_LEN_SHORT) / 2
 
-double       fhg_window_long[BLOCK_LEN_LONG];
-double       fhg_window_short[BLOCK_LEN_SHORT];
+double       sin_window_long[BLOCK_LEN_LONG];
+double       sin_window_short[BLOCK_LEN_SHORT];
 int sizedouble; // temp value
 
 /*******************************************************************************
@@ -201,9 +202,9 @@
 {
 int i;
 for( i=0; i<BLOCK_LEN_LONG; i++ )
-	fhg_window_long[i] = sin((M_PI/(2*BLOCK_LEN_LONG)) * (i + 0.5));
+	sin_window_long[i] = sin((M_PI/(2*BLOCK_LEN_LONG)) * (i + 0.5));
 for( i=0; i<BLOCK_LEN_SHORT; i++ )
-	fhg_window_short[i] = sin((M_PI/(2*BLOCK_LEN_SHORT)) * (i + 0.5));
+	sin_window_short[i] = sin((M_PI/(2*BLOCK_LEN_SHORT)) * (i + 0.5));
 sizedouble = sizeof (double);
 }
 /*******************************************************************************
@@ -213,12 +214,13 @@
 		 double           p_out_mdct[],
 		 double           p_overlap[],
 		 enum WINDOW_TYPE block_type,
-//		 Window_shape     wfun_select,      /* offers the possibility to select different window functions */
-		 Mdct_in      overlap_select     /*  YT 970615 for son_PP */
+		 Window_shape     wfun_select,      /*  current window shape */
+		 Window_shape     wfun_select_prev, /*  previous window shape */
+		 Mdct_in          overlap_select
 		 )
 {
 	double         transf_buf[ 2*BLOCK_LEN_LONG ];
-	double         *p_o_buf;
+	double         *p_o_buf, *first_window, *second_window;
 	int            k,i;
 
 	static int firstTime=1;
@@ -225,7 +227,6 @@
 
 	/* create / shift old values */
 	/* We use p_overlap here as buffer holding the last frame time signal*/
-	/* YT 970615 for son_pp */
 	if(overlap_select != MNON_OVERLAPPED){
 		if (firstTime){
 			firstTime=0;
@@ -240,26 +241,56 @@
                 memcpy(transf_buf,p_in_data,2*BLOCK_LEN_LONG*sizedouble);
 	}
 
+        /*  Window shape processing */
+        switch (wfun_select_prev){
+                case WS_SIN:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW))
+                                          first_window = sin_window_long;
+                                     else
+                                          first_window = sin_window_short;
+                                break;
+                case WS_KBD:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW))
+                                          first_window = kbd_window_long;
+                                     else
+                                          first_window = kbd_window_short;
+                                break;
+                }
+
+        switch (wfun_select){
+                case WS_SIN:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW))
+                                          second_window = sin_window_long;
+                                     else
+                                          second_window = sin_window_short;
+                                break;
+                case WS_KBD:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW))
+                                          second_window = kbd_window_long;
+                                     else
+                                          second_window = kbd_window_short;
+                                break;
+                }
+
 	/* Set ptr to transf-Buffer */
 	p_o_buf = transf_buf;
 
-
 	/* Separate action for each Block Type */
 	switch( block_type ) {
 	case ONLY_LONG_WINDOW :
                 for ( i = 0 ; i < BLOCK_LEN_LONG ; i++){
-                        p_out_mdct[i] = p_o_buf[i] * fhg_window_long[i];
-                        p_out_mdct[i+BLOCK_LEN_LONG] = p_o_buf[i+BLOCK_LEN_LONG] * fhg_window_long[BLOCK_LEN_LONG-i-1];
+                        p_out_mdct[i] = p_o_buf[i] * first_window[i];
+                        p_out_mdct[i+BLOCK_LEN_LONG] = p_o_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1];
                         }
 		MDCT( p_out_mdct, 2*BLOCK_LEN_LONG );
 		break;
 
 	case LONG_SHORT_WINDOW :
-                for ( i = 0 ; i < BLOCK_LEN_LONG ; i++)
-                        p_out_mdct[i] = p_o_buf[i] * fhg_window_long[i];
+//                for ( i = 0 ; i < BLOCK_LEN_LONG ; i++)
+//                        p_out_mdct[i] = p_o_buf[i] * first_window[i];
                 memcpy(p_out_mdct+BLOCK_LEN_LONG,p_o_buf+BLOCK_LEN_LONG,NFLAT_LS*sizedouble);
+//                for ( ; i < NFLAT_LS + BLOCK_LEN_LONG; i++){
+//                        p_out_mdct[i] = 1.0;
+//                        p_out_mdct[i+NFLAT_LS+BLOCK_LEN_SHORT] = 0.0;
+//                        }
                 for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++)
-                        p_out_mdct[i+BLOCK_LEN_LONG+NFLAT_LS] = p_o_buf[i+BLOCK_LEN_LONG+NFLAT_LS] * fhg_window_short[BLOCK_LEN_SHORT-i-1];
+                        p_out_mdct[i+BLOCK_LEN_LONG+NFLAT_LS] = p_o_buf[i+BLOCK_LEN_LONG+NFLAT_LS] * second_window[BLOCK_LEN_SHORT-i-1];
                 memset(p_out_mdct+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizedouble);
 		MDCT( p_out_mdct, 2*BLOCK_LEN_LONG );
 		break;
@@ -266,11 +297,15 @@
 
 	case SHORT_LONG_WINDOW :
                 memset(p_out_mdct,0,NFLAT_LS*sizedouble);
+//                for ( i = 0 ; i < NFLAT_LS ; i++){
+//                        p_out_mdct[i] = 0.0;
+//                        p_out_mdct[i+NFLAT_LS+BLOCK_LEN_SHORT] = 1.0;
+//                        }
                 for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++)
-                        p_out_mdct[i+NFLAT_LS] = p_o_buf[i+NFLAT_LS] * fhg_window_short[i];
+                        p_out_mdct[i+NFLAT_LS] = p_o_buf[i+NFLAT_LS] * first_window[i];
                 memcpy(p_out_mdct+NFLAT_LS+BLOCK_LEN_SHORT,p_o_buf+NFLAT_LS+BLOCK_LEN_SHORT,NFLAT_LS*sizedouble);
                 for ( i = 0 ; i < BLOCK_LEN_LONG ; i++)
-                        p_out_mdct[i+BLOCK_LEN_LONG] = p_o_buf[i+BLOCK_LEN_LONG] * fhg_window_long[BLOCK_LEN_LONG-i-1];
+                        p_out_mdct[i+BLOCK_LEN_LONG] = p_o_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1];
 		MDCT( p_out_mdct, 2*BLOCK_LEN_LONG );
 		break;
 
@@ -280,15 +315,15 @@
 		}
 		for ( k=0; k < MAX_SHORT_WINDOWS; k++ ) {
                         for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++ ){
-                                p_out_mdct[i] = p_o_buf[i] * fhg_window_short[i];
-                                p_out_mdct[i+BLOCK_LEN_SHORT] = p_o_buf[i+BLOCK_LEN_SHORT] * fhg_window_short[BLOCK_LEN_SHORT-i-1];
+                                p_out_mdct[i] = p_o_buf[i] * first_window[i];
+                                p_out_mdct[i+BLOCK_LEN_SHORT] = p_o_buf[i+BLOCK_LEN_SHORT] * second_window[BLOCK_LEN_SHORT-i-1];
                                 }
 			MDCT( p_out_mdct, 2*BLOCK_LEN_SHORT );
 
 			p_out_mdct += BLOCK_LEN_SHORT;
-			/* YT 970615 for sonPP*/
 			if(overlap_select != MNON_OVERLAPPED) p_o_buf += BLOCK_LEN_SHORT;
         			else 	p_o_buf += 2*BLOCK_LEN_SHORT;
+                        first_window = second_window;
 		}
 		break;
 	}
@@ -298,16 +333,44 @@
 		 double           p_out_data[],
 		 double           p_overlap[],
 		 enum WINDOW_TYPE block_type,
-//		 Window_shape     wfun_select,      /* offers the possibility to select different window functions */
-		 Mdct_in	   overlap_select		/* select imdct output *TK*	*/
+		 Window_shape     wfun_select,      /*  current window shape */
+		 Window_shape     wfun_select_prev, /*  previous window shape */
+		 Mdct_in	  overlap_select
 		 )
 {
 	double           *o_buf, transf_buf[ 2*BLOCK_LEN_LONG ];
-	double           overlap_buf[ 2*BLOCK_LEN_LONG ];
+	double           overlap_buf[ 2*BLOCK_LEN_LONG ], *first_window, *second_window;
 
 	double  *fp;
 	int     k,i;
 
+        /*  Window shape processing */
+        switch (wfun_select_prev){
+                case WS_SIN:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW))
+                                          first_window = sin_window_long;
+                                     else
+                                          first_window = sin_window_short;
+                                break;
+                case WS_KBD:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == LONG_SHORT_WINDOW))
+                                          first_window = kbd_window_long;
+                                     else
+                                          first_window = kbd_window_short;
+                                break;
+                }
+
+        switch (wfun_select){
+                case WS_SIN:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW))
+                                          second_window = sin_window_long;
+                                     else
+                                          second_window = sin_window_short;
+                                break;
+                case WS_KBD:  if ( (block_type == ONLY_LONG_WINDOW) || (block_type == SHORT_LONG_WINDOW))
+                                          second_window = kbd_window_long;
+                                     else
+                                          second_window = kbd_window_short;
+                                break;
+                }
+
 	/* Assemble overlap buffer */
         memcpy(overlap_buf,p_overlap,BLOCK_LEN_LONG*sizedouble);
 	o_buf = overlap_buf;
@@ -318,16 +381,16 @@
                 memcpy(transf_buf, p_in_data,BLOCK_LEN_LONG*sizedouble);
 		IMDCT( transf_buf, 2*BLOCK_LEN_LONG );
                 for ( i = 0 ; i < BLOCK_LEN_LONG ; i++)
-                        transf_buf[i] *= fhg_window_long[i];
+                        transf_buf[i] *= first_window[i];
 		if (overlap_select != MNON_OVERLAPPED) {
                         for ( i = 0 ; i < BLOCK_LEN_LONG; i++ ){
                             o_buf[i] += transf_buf[i];
-                            o_buf[i+BLOCK_LEN_LONG] = transf_buf[i+BLOCK_LEN_LONG] * fhg_window_long[BLOCK_LEN_LONG-i-1];
+                            o_buf[i+BLOCK_LEN_LONG] = transf_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1];
                             }
 		}
 		else { /* overlap_select == NON_OVERLAPPED */
                         for ( i = 0 ; i < BLOCK_LEN_LONG; i++ )
-                            transf_buf[i+BLOCK_LEN_LONG] *= fhg_window_long[BLOCK_LEN_LONG-i-1];
+                            transf_buf[i+BLOCK_LEN_LONG] *= second_window[BLOCK_LEN_LONG-i-1];
 		}
 		break;
 
@@ -335,18 +398,18 @@
                 memcpy(transf_buf, p_in_data,BLOCK_LEN_LONG*sizedouble);
 		IMDCT( transf_buf, 2*BLOCK_LEN_LONG );
                 for ( i = 0 ; i < BLOCK_LEN_LONG ; i++)
-                        transf_buf[i] *= fhg_window_long[i];
+                        transf_buf[i] *= first_window[i];
 		if (overlap_select != MNON_OVERLAPPED) {
                         for ( i = 0 ; i < BLOCK_LEN_LONG; i++ )
                             o_buf[i] += transf_buf[i];
                         memcpy(o_buf+BLOCK_LEN_LONG,transf_buf+BLOCK_LEN_LONG,NFLAT_LS*sizedouble);
                         for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++)
-                                o_buf[i+BLOCK_LEN_LONG+NFLAT_LS] = transf_buf[i+BLOCK_LEN_LONG+NFLAT_LS] * fhg_window_short[BLOCK_LEN_SHORT-i-1];
+                                o_buf[i+BLOCK_LEN_LONG+NFLAT_LS] = transf_buf[i+BLOCK_LEN_LONG+NFLAT_LS] * second_window[BLOCK_LEN_SHORT-i-1];
                         memset(o_buf+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizedouble);
 		}
 		else { /* overlap_select == NON_OVERLAPPED */
                         for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++)
-                                transf_buf[i+BLOCK_LEN_LONG+NFLAT_LS] *= fhg_window_short[BLOCK_LEN_SHORT-i-1];
+                                transf_buf[i+BLOCK_LEN_LONG+NFLAT_LS] *= second_window[BLOCK_LEN_SHORT-i-1];
                         memset(transf_buf+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizedouble);
 		}
 		break;
@@ -355,18 +418,18 @@
                 memcpy(transf_buf, p_in_data,BLOCK_LEN_LONG*sizedouble);
 		IMDCT( transf_buf, 2*BLOCK_LEN_LONG );
                 for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++)
-                        transf_buf[i+NFLAT_LS] *= fhg_window_short[i];
+                        transf_buf[i+NFLAT_LS] *= first_window[i];
 		if (overlap_select != MNON_OVERLAPPED) {
                         for ( i = 0 ; i < BLOCK_LEN_SHORT; i++ )
                             o_buf[i+NFLAT_LS] += transf_buf[i+NFLAT_LS];
                         memcpy(o_buf+BLOCK_LEN_SHORT+NFLAT_LS,transf_buf+BLOCK_LEN_SHORT+NFLAT_LS,NFLAT_LS*sizedouble);
                         for ( i = 0 ; i < BLOCK_LEN_LONG ; i++)
-                                o_buf[i+BLOCK_LEN_LONG] = transf_buf[i+BLOCK_LEN_LONG] * fhg_window_long[BLOCK_LEN_LONG-i-1];
+                                o_buf[i+BLOCK_LEN_LONG] = transf_buf[i+BLOCK_LEN_LONG] * second_window[BLOCK_LEN_LONG-i-1];
 		}
 		else { /* overlap_select == NON_OVERLAPPED */
                         memset(transf_buf,0,NFLAT_LS*sizedouble);
                 for ( i = 0 ; i < BLOCK_LEN_LONG ; i++)
-                        transf_buf[i+BLOCK_LEN_LONG] *= fhg_window_long[BLOCK_LEN_LONG-i-1];
+                        transf_buf[i+BLOCK_LEN_LONG] *= second_window[BLOCK_LEN_LONG-i-1];
 		}
 		break;
 
@@ -383,20 +446,21 @@
 			p_in_data += BLOCK_LEN_SHORT;
 			if (overlap_select != MNON_OVERLAPPED) {
                                 for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++){
-                                        transf_buf[i] *= fhg_window_short[i];
+                                        transf_buf[i] *= first_window[i];
                                         fp[i] += transf_buf[i];
-                                        fp[i+BLOCK_LEN_SHORT] = transf_buf[i+BLOCK_LEN_SHORT] * fhg_window_short[BLOCK_LEN_SHORT-i-1];
+                                        fp[i+BLOCK_LEN_SHORT] = transf_buf[i+BLOCK_LEN_SHORT] * second_window[BLOCK_LEN_SHORT-i-1];
                                         }
 				fp    += BLOCK_LEN_SHORT;
 			}
 			else { /* overlap_select == NON_OVERLAPPED */
                                 for ( i = 0 ; i < BLOCK_LEN_SHORT ; i++){
-                                        fp[i] *= fhg_window_short[i];
-                                        fp[i+BLOCK_LEN_SHORT] *= fhg_window_short[BLOCK_LEN_SHORT-i-1];
+                                        fp[i] *= first_window[i];
+                                        fp[i+BLOCK_LEN_SHORT] *= second_window[BLOCK_LEN_SHORT-i-1];
                                         }
 				fp    += 2*BLOCK_LEN_SHORT;
 			}
-		}
+                        first_window = second_window;
+                }
                 memset(o_buf+BLOCK_LEN_LONG+NFLAT_LS+BLOCK_LEN_SHORT,0,NFLAT_LS*sizedouble);
 		break;
 	}