www.pudn.com > bladeenc-0.90.0-src.zip > subs.c


/* 
			(c) Copyright 1998, 1999 - Tord Jansson 
			======================================= 
 
		This file is part of the BladeEnc MP3 Encoder, based on 
		ISO's reference code for MPEG Layer 3 compression, and might 
		contain smaller or larger sections that are directly taken 
		from ISO's reference code. 
 
		All changes to the ISO reference code herein are either 
		copyrighted by Tord Jansson (tord.jansson@swipnet.se) 
		or sublicensed to Tord Jansson by a third party. 
 
	BladeEnc is free software; you can redistribute this file 
	and/or modify it under the terms of the GNU Lesser General Public 
	License as published by the Free Software Foundation; either 
	version 2.1 of the License, or (at your option) any later version. 
 
*/ 
 
#include "common.h" 
#include "encoder.h" 
 
/***************************************************************************** 
 ************************** Start of Subroutines ***************************** 
 *****************************************************************************/ 
 
/***************************************************************************** 
 * FFT computes fast fourier transform of BLKSIZE samples of data            * 
 *   uses decimation-in-frequency algorithm described in "Digital            * 
 *   Signal Processing" by Oppenheim and Schafer, refer to pages 304         * 
 *   (flow graph) and 330-332 (Fortran program in problem 5)                 * 
 *   to get the inverse fft, change line 20 from                             * 
 *                 w_imag[L] = -sin(PI/le1);                                 * 
 *                          to                                               * 
 *                 w_imag[L] = sin(PI/le1);                                  * 
 *                                                                           * 
 *   required constants:                                                     * 
 *         #define      PI          3.14159265358979                         * 
 *         #define      BLKSIZE     1024                                     * 
 *         #define      LOGBLKSIZE  10                                       * 
 *         #define      BLKSIZE_S   256                                      * 
 *         #define      LOGBLKSIZE_S 8                                       * 
 *                                                                           * 
 *****************************************************************************/ 
#define      BLKSIZE_S   256 
#define      LOGBLKSIZE_S 8 
 
int fInit_fft; 
 
 
void fft(FLOAT x_real[BLKSIZE],float x_imag[BLKSIZE], float energy[BLKSIZE], float phi[BLKSIZE], int N) 
{ 
 int     M,MM1; 
 int     NV2, NM1, MP; 
 static double  w_real[2][LOGBLKSIZE], w_imag[2][LOGBLKSIZE]; 
 int            i,j,k,L; 
 int            ip, le,le1; 
 double         t_real, t_imag, u_real, u_imag; 
 
 if(fInit_fft==0)  
 { 
    memset((char *) w_real, 0, sizeof(w_real));  /* preset statics to 0 */ 
    memset((char *) w_imag, 0, sizeof(w_imag));  /* preset statics to 0 */ 
    M = LOGBLKSIZE; 
    for(L=0; L> 1; 
       w_real[0][L] = cos(PI/le1); 
       w_imag[0][L] = -sin(PI/le1); 
    }           
    M = LOGBLKSIZE_S; 
    for(L=0; L> 1; 
       w_real[1][L] = cos(PI/le1); 
       w_imag[1][L] = -sin(PI/le1); 
    }           
    fInit_fft++; 
 } 
	if( N == BLKSIZE ) 
	{ 
		M = LOGBLKSIZE; 
		MP = 0; 
	} 
	else		/* N == BLKSIZE_S */ 
	{ 
		M = LOGBLKSIZE_S; 
		MP = 1; 
	} 
 
	MM1 = M-1; 
	NV2 = N >> 1; 
	NM1 = N - 1; 
 
	for(L=0; L> 1; 
    u_real = 1; 
    u_imag = 0; 
 
    for(j=0; j> 1; 
    } 
    j = j+k; 
 } 
}