ref: 5346aad4cf31ed56208283a3984698b9cc084777
parent: 0b18a49e85abd44fc98e7fcaabc8aae7b95ee283
author: lenox <lenox>
date: Mon Feb 14 03:22:02 EST 2000
new rft (reference to fftw removed, sorry :) )
--- a/enc_tf.c
+++ b/enc_tf.c
@@ -3,7 +3,7 @@
#include <memory.h>
#include "aacenc.h"
#include "bitstream.h"
-#include "interface.h"
+#include "interface.h"
#include "enc.h"
#include "block.h"
#include "tf_main.h"
@@ -16,7 +16,7 @@
#include "aac_se_enc.h"
#include "nok_ltp_enc.h"
#include "winswitch.h"
-#include "rdft.h"
+#include "transfo.h"
#define SQRT2 C_SQRT2
@@ -91,7 +91,6 @@
for (chanNum=0;chanNum<MAX_TIME_CHANNELS+2;chanNum++) {
if (DTimeSigLookAheadBuf[chanNum]) free(DTimeSigLookAheadBuf[chanNum]);
}
- fftw_destroy();
}
@@ -194,7 +193,7 @@
make_MDCT_windows();
make_FFT_order();
- fftw_init();
+ initrft();
}
/*****************************************************************************************
--- a/fastfft.c
+++ b/fastfft.c
@@ -1,8 +1,10 @@
#include "fastfft.h"
int unscambled64[64];
+int unscambled128[128];
int unscambled512[512];
-fftw_complex FFTarray[512]; /* the array for in-place FFT */
+int unscambled1024[1024];
+fftw_complex FFTarray[1024]; /* the array for in-place FFT */
fftw_real K980785280[1] =
{FFTW_KONST(+0.980785280403230449126182236134239036973933731)};
@@ -117,6 +119,135 @@
{ -0.995184726672197, 0.0980171403295608 },
};
+fftw_complex PFFTW(W_256)[126] = {
+{ 0.999698818696204, 0.0245412285229123 },
+{ 0.998795456205172, 0.049067674327418 },
+{ 0.998795456205172, 0.049067674327418 },
+{ 0.995184726672197, 0.0980171403295606 },
+{ 0.99729045667869, 0.0735645635996674 },
+{ 0.989176509964781, 0.146730474455362 },
+{ 0.995184726672197, 0.0980171403295606 },
+{ 0.98078528040323, 0.195090322016128 },
+{ 0.99247953459871, 0.122410675199216 },
+{ 0.970031253194544, 0.242980179903264 },
+{ 0.989176509964781, 0.146730474455362 },
+{ 0.956940335732209, 0.290284677254462 },
+{ 0.985277642388941, 0.170961888760301 },
+{ 0.941544065183021, 0.33688985339222 },
+{ 0.98078528040323, 0.195090322016128 },
+{ 0.923879532511287, 0.38268343236509 },
+{ 0.975702130038529, 0.21910124015687 },
+{ 0.903989293123443, 0.427555093430282 },
+{ 0.970031253194544, 0.242980179903264 },
+{ 0.881921264348355, 0.471396736825998 },
+{ 0.96377606579544, 0.266712757474898 },
+{ 0.857728610000272, 0.514102744193222 },
+{ 0.956940335732209, 0.290284677254462 },
+{ 0.831469612302545, 0.555570233019602 },
+{ 0.949528180593037, 0.313681740398892 },
+{ 0.803207531480645, 0.595699304492433 },
+{ 0.941544065183021, 0.33688985339222 },
+{ 0.773010453362737, 0.634393284163645 },
+{ 0.932992798834739, 0.359895036534988 },
+{ 0.740951125354959, 0.671558954847018 },
+{ 0.923879532511287, 0.38268343236509 },
+{ 0.707106781186548, 0.707106781186547 },
+{ 0.914209755703531, 0.40524131400499 },
+{ 0.671558954847018, 0.740951125354959 },
+{ 0.903989293123443, 0.427555093430282 },
+{ 0.634393284163645, 0.773010453362737 },
+{ 0.893224301195515, 0.449611329654607 },
+{ 0.595699304492433, 0.803207531480645 },
+{ 0.881921264348355, 0.471396736825998 },
+{ 0.555570233019602, 0.831469612302545 },
+{ 0.870086991108711, 0.492898192229784 },
+{ 0.514102744193222, 0.857728610000272 },
+{ 0.857728610000272, 0.514102744193222 },
+{ 0.471396736825998, 0.881921264348355 },
+{ 0.844853565249707, 0.534997619887097 },
+{ 0.427555093430282, 0.903989293123443 },
+{ 0.831469612302545, 0.555570233019602 },
+{ 0.38268343236509, 0.923879532511287 },
+{ 0.817584813151584, 0.575808191417845 },
+{ 0.33688985339222, 0.941544065183021 },
+{ 0.803207531480645, 0.595699304492433 },
+{ 0.290284677254462, 0.956940335732209 },
+{ 0.788346427626606, 0.615231590580627 },
+{ 0.242980179903264, 0.970031253194544 },
+{ 0.773010453362737, 0.634393284163645 },
+{ 0.195090322016128, 0.98078528040323 },
+{ 0.757208846506485, 0.653172842953777 },
+{ 0.146730474455362, 0.989176509964781 },
+{ 0.740951125354959, 0.671558954847018 },
+{ 0.0980171403295608, 0.995184726672197 },
+{ 0.724247082951467, 0.689540544737067 },
+{ 0.0490676743274181, 0.998795456205172 },
+{ 0.707106781186548, 0.707106781186547 },
+{ 6.12303176911189e-17, 1 },
+{ 0.689540544737067, 0.724247082951467 },
+{ -0.049067674327418, 0.998795456205172 },
+{ 0.671558954847018, 0.740951125354959 },
+{ -0.0980171403295606, 0.995184726672197 },
+{ 0.653172842953777, 0.757208846506484 },
+{ -0.146730474455362, 0.989176509964781 },
+{ 0.634393284163645, 0.773010453362737 },
+{ -0.195090322016128, 0.98078528040323 },
+{ 0.615231590580627, 0.788346427626606 },
+{ -0.242980179903264, 0.970031253194544 },
+{ 0.595699304492433, 0.803207531480645 },
+{ -0.290284677254462, 0.956940335732209 },
+{ 0.575808191417845, 0.817584813151584 },
+{ -0.33688985339222, 0.941544065183021 },
+{ 0.555570233019602, 0.831469612302545 },
+{ -0.38268343236509, 0.923879532511287 },
+{ 0.534997619887097, 0.844853565249707 },
+{ -0.427555093430282, 0.903989293123443 },
+{ 0.514102744193222, 0.857728610000272 },
+{ -0.471396736825998, 0.881921264348355 },
+{ 0.492898192229784, 0.870086991108711 },
+{ -0.514102744193222, 0.857728610000272 },
+{ 0.471396736825998, 0.881921264348355 },
+{ -0.555570233019602, 0.831469612302545 },
+{ 0.449611329654607, 0.893224301195515 },
+{ -0.595699304492433, 0.803207531480645 },
+{ 0.427555093430282, 0.903989293123443 },
+{ -0.634393284163645, 0.773010453362737 },
+{ 0.40524131400499, 0.914209755703531 },
+{ -0.671558954847018, 0.740951125354959 },
+{ 0.38268343236509, 0.923879532511287 },
+{ -0.707106781186547, 0.707106781186548 },
+{ 0.359895036534988, 0.932992798834739 },
+{ -0.740951125354959, 0.671558954847019 },
+{ 0.33688985339222, 0.941544065183021 },
+{ -0.773010453362737, 0.634393284163645 },
+{ 0.313681740398892, 0.949528180593037 },
+{ -0.803207531480645, 0.595699304492433 },
+{ 0.290284677254462, 0.956940335732209 },
+{ -0.831469612302545, 0.555570233019602 },
+{ 0.266712757474898, 0.96377606579544 },
+{ -0.857728610000272, 0.514102744193222 },
+{ 0.242980179903264, 0.970031253194544 },
+{ -0.881921264348355, 0.471396736825998 },
+{ 0.21910124015687, 0.975702130038529 },
+{ -0.903989293123443, 0.427555093430282 },
+{ 0.195090322016128, 0.98078528040323 },
+{ -0.923879532511287, 0.38268343236509 },
+{ 0.170961888760301, 0.985277642388941 },
+{ -0.941544065183021, 0.33688985339222 },
+{ 0.146730474455362, 0.989176509964781 },
+{ -0.956940335732209, 0.290284677254462 },
+{ 0.122410675199216, 0.99247953459871 },
+{ -0.970031253194544, 0.242980179903264 },
+{ 0.0980171403295608, 0.995184726672197 },
+{ -0.98078528040323, 0.195090322016129 },
+{ 0.0735645635996675, 0.99729045667869 },
+{ -0.989176509964781, 0.146730474455362 },
+{ 0.0490676743274181, 0.998795456205172 },
+{ -0.995184726672197, 0.0980171403295608 },
+{ 0.0245412285229123, 0.999698818696204 },
+{ -0.998795456205172, 0.049067674327418 },
+};
+
fftw_complex PFFTW(W_512)[254] = {
{ 0.999924701839145, 0.0122715382857199 },
{ 0.999698818696204, 0.0245412285229123 },
@@ -373,8 +504,522 @@
{ 0.0122715382857199, 0.999924701839145 },
{ -0.999698818696204, 0.0245412285229123 },
};
+
+fftw_complex PFFTW(W_1024)[510] = {
+{ 0.999981175282601, 0.00613588464915448 },
+{ 0.999924701839145, 0.0122715382857199 },
+{ 0.999924701839145, 0.0122715382857199 },
+{ 0.999698818696204, 0.0245412285229123 },
+{ 0.999830581795823, 0.0184067299058048 },
+{ 0.99932238458835, 0.0368072229413588 },
+{ 0.999698818696204, 0.0245412285229123 },
+{ 0.998795456205172, 0.049067674327418 },
+{ 0.999529417501093, 0.0306748031766366 },
+{ 0.998118112900149, 0.0613207363022086 },
+{ 0.99932238458835, 0.0368072229413588 },
+{ 0.99729045667869, 0.0735645635996674 },
+{ 0.999077727752645, 0.0429382569349408 },
+{ 0.996312612182778, 0.0857973123444399 },
+{ 0.998795456205172, 0.049067674327418 },
+{ 0.995184726672197, 0.0980171403295606 },
+{ 0.998475580573295, 0.0551952443496899 },
+{ 0.993906970002356, 0.110222207293883 },
+{ 0.998118112900149, 0.0613207363022086 },
+{ 0.99247953459871, 0.122410675199216 },
+{ 0.997723066644192, 0.0674439195636641 },
+{ 0.99090263542778, 0.134580708507126 },
+{ 0.99729045667869, 0.0735645635996674 },
+{ 0.989176509964781, 0.146730474455362 },
+{ 0.996820299291166, 0.0796824379714301 },
+{ 0.987301418157858, 0.158858143333861 },
+{ 0.996312612182778, 0.0857973123444399 },
+{ 0.985277642388941, 0.170961888760301 },
+{ 0.99576741446766, 0.0919089564971327 },
+{ 0.983105487431216, 0.183039887955141 },
+{ 0.995184726672197, 0.0980171403295606 },
+{ 0.98078528040323, 0.195090322016128 },
+{ 0.994564570734255, 0.104121633872055 },
+{ 0.978317370719628, 0.207111376192219 },
+{ 0.993906970002356, 0.110222207293883 },
+{ 0.975702130038529, 0.21910124015687 },
+{ 0.993211949234795, 0.116318630911905 },
+{ 0.97293995220556, 0.231058108280671 },
+{ 0.99247953459871, 0.122410675199216 },
+{ 0.970031253194544, 0.242980179903264 },
+{ 0.9917097536691, 0.128498110793793 },
+{ 0.966976471044852, 0.254865659604515 },
+{ 0.99090263542778, 0.134580708507126 },
+{ 0.96377606579544, 0.266712757474898 },
+{ 0.990058210262297, 0.140658239332849 },
+{ 0.960430519415566, 0.278519689385053 },
+{ 0.989176509964781, 0.146730474455362 },
+{ 0.956940335732209, 0.290284677254462 },
+{ 0.988257567730749, 0.152797185258443 },
+{ 0.953306040354194, 0.302005949319228 },
+{ 0.987301418157858, 0.158858143333861 },
+{ 0.949528180593037, 0.313681740398892 },
+{ 0.986308097244599, 0.16491312048997 },
+{ 0.945607325380521, 0.325310292162263 },
+{ 0.985277642388941, 0.170961888760301 },
+{ 0.941544065183021, 0.33688985339222 },
+{ 0.984210092386929, 0.177004220412149 },
+{ 0.937339011912575, 0.348418680249435 },
+{ 0.983105487431216, 0.183039887955141 },
+{ 0.932992798834739, 0.359895036534988 },
+{ 0.981963869109555, 0.189068664149806 },
+{ 0.928506080473216, 0.371317193951838 },
+{ 0.98078528040323, 0.195090322016128 },
+{ 0.923879532511287, 0.38268343236509 },
+{ 0.979569765685441, 0.201104634842092 },
+{ 0.919113851690058, 0.393992040061048 },
+{ 0.978317370719628, 0.207111376192219 },
+{ 0.914209755703531, 0.40524131400499 },
+{ 0.977028142657754, 0.213110319916091 },
+{ 0.909167983090522, 0.416429560097637 },
+{ 0.975702130038529, 0.21910124015687 },
+{ 0.903989293123443, 0.427555093430282 },
+{ 0.974339382785576, 0.225083911359793 },
+{ 0.898674465693954, 0.438616238538528 },
+{ 0.97293995220556, 0.231058108280671 },
+{ 0.893224301195515, 0.449611329654607 },
+{ 0.971503890986252, 0.237023605994367 },
+{ 0.887639620402854, 0.46053871095824 },
+{ 0.970031253194544, 0.242980179903264 },
+{ 0.881921264348355, 0.471396736825998 },
+{ 0.968522094274417, 0.24892760574572 },
+{ 0.876070094195407, 0.482183772079123 },
+{ 0.966976471044852, 0.254865659604515 },
+{ 0.870086991108711, 0.492898192229784 },
+{ 0.965394441697689, 0.260794117915276 },
+{ 0.863972856121587, 0.503538383725718 },
+{ 0.96377606579544, 0.266712757474898 },
+{ 0.857728610000272, 0.514102744193222 },
+{ 0.962121404269042, 0.272621355449949 },
+{ 0.851355193105265, 0.524589682678469 },
+{ 0.960430519415566, 0.278519689385053 },
+{ 0.844853565249707, 0.534997619887097 },
+{ 0.958703474895872, 0.284407537211272 },
+{ 0.838224705554838, 0.545324988422046 },
+{ 0.956940335732209, 0.290284677254462 },
+{ 0.831469612302545, 0.555570233019602 },
+{ 0.955141168305771, 0.296150888243624 },
+{ 0.824589302785025, 0.565731810783613 },
+{ 0.953306040354194, 0.302005949319228 },
+{ 0.817584813151584, 0.575808191417845 },
+{ 0.951435020969008, 0.307849640041535 },
+{ 0.810457198252595, 0.585797857456439 },
+{ 0.949528180593037, 0.313681740398892 },
+{ 0.803207531480645, 0.595699304492433 },
+{ 0.947585591017741, 0.319502030816016 },
+{ 0.795836904608884, 0.605511041404326 },
+{ 0.945607325380521, 0.325310292162263 },
+{ 0.788346427626606, 0.615231590580627 },
+{ 0.94359345816196, 0.331106305759876 },
+{ 0.780737228572094, 0.624859488142386 },
+{ 0.941544065183021, 0.33688985339222 },
+{ 0.773010453362737, 0.634393284163645 },
+{ 0.93945922360219, 0.342660717311994 },
+{ 0.765167265622459, 0.643831542889791 },
+{ 0.937339011912575, 0.348418680249435 },
+{ 0.757208846506485, 0.653172842953777 },
+{ 0.935183509938948, 0.35416352542049 },
+{ 0.749136394523459, 0.662415777590172 },
+{ 0.932992798834739, 0.359895036534988 },
+{ 0.740951125354959, 0.671558954847018 },
+{ 0.930766961078984, 0.365612997804774 },
+{ 0.732654271672413, 0.680600997795453 },
+{ 0.928506080473216, 0.371317193951838 },
+{ 0.724247082951467, 0.689540544737067 },
+{ 0.926210242138311, 0.377007410216418 },
+{ 0.715730825283819, 0.698376249408973 },
+{ 0.923879532511287, 0.38268343236509 },
+{ 0.707106781186548, 0.707106781186547 },
+{ 0.921514039342042, 0.388345046698826 },
+{ 0.698376249408973, 0.715730825283819 },
+{ 0.919113851690058, 0.393992040061048 },
+{ 0.689540544737067, 0.724247082951467 },
+{ 0.916679059921043, 0.399624199845647 },
+{ 0.680600997795453, 0.732654271672413 },
+{ 0.914209755703531, 0.40524131400499 },
+{ 0.671558954847018, 0.740951125354959 },
+{ 0.91170603200543, 0.410843171057904 },
+{ 0.662415777590172, 0.749136394523459 },
+{ 0.909167983090522, 0.416429560097637 },
+{ 0.653172842953777, 0.757208846506484 },
+{ 0.906595704514915, 0.4220002707998 },
+{ 0.643831542889791, 0.765167265622459 },
+{ 0.903989293123443, 0.427555093430282 },
+{ 0.634393284163645, 0.773010453362737 },
+{ 0.901348847046022, 0.433093818853152 },
+{ 0.624859488142386, 0.780737228572094 },
+{ 0.898674465693954, 0.438616238538528 },
+{ 0.615231590580627, 0.788346427626606 },
+{ 0.895966249756185, 0.444122144570429 },
+{ 0.605511041404326, 0.795836904608883 },
+{ 0.893224301195515, 0.449611329654607 },
+{ 0.595699304492433, 0.803207531480645 },
+{ 0.890448723244758, 0.455083587126344 },
+{ 0.585797857456439, 0.810457198252595 },
+{ 0.887639620402854, 0.46053871095824 },
+{ 0.575808191417845, 0.817584813151584 },
+{ 0.884797098430938, 0.465976495767966 },
+{ 0.565731810783613, 0.824589302785025 },
+{ 0.881921264348355, 0.471396736825998 },
+{ 0.555570233019602, 0.831469612302545 },
+{ 0.879012226428634, 0.476799230063322 },
+{ 0.545324988422046, 0.838224705554838 },
+{ 0.876070094195407, 0.482183772079123 },
+{ 0.534997619887097, 0.844853565249707 },
+{ 0.87309497841829, 0.487550160148436 },
+{ 0.524589682678469, 0.851355193105265 },
+{ 0.870086991108711, 0.492898192229784 },
+{ 0.514102744193222, 0.857728610000272 },
+{ 0.867046245515693, 0.498227666972782 },
+{ 0.503538383725718, 0.863972856121587 },
+{ 0.863972856121587, 0.503538383725718 },
+{ 0.492898192229784, 0.870086991108711 },
+{ 0.860866938637767, 0.508830142543107 },
+{ 0.482183772079123, 0.876070094195407 },
+{ 0.857728610000272, 0.514102744193222 },
+{ 0.471396736825998, 0.881921264348355 },
+{ 0.854557988365401, 0.51935599016559 },
+{ 0.46053871095824, 0.887639620402854 },
+{ 0.851355193105265, 0.524589682678469 },
+{ 0.449611329654607, 0.893224301195515 },
+{ 0.848120344803297, 0.529803624686295 },
+{ 0.438616238538528, 0.898674465693954 },
+{ 0.844853565249707, 0.534997619887097 },
+{ 0.427555093430282, 0.903989293123443 },
+{ 0.841554977436898, 0.540171472729893 },
+{ 0.416429560097637, 0.909167983090522 },
+{ 0.838224705554838, 0.545324988422046 },
+{ 0.40524131400499, 0.914209755703531 },
+{ 0.83486287498638, 0.550457972936605 },
+{ 0.393992040061048, 0.919113851690058 },
+{ 0.831469612302545, 0.555570233019602 },
+{ 0.38268343236509, 0.923879532511287 },
+{ 0.828045045257756, 0.560661576197336 },
+{ 0.371317193951838, 0.928506080473215 },
+{ 0.824589302785025, 0.565731810783613 },
+{ 0.359895036534988, 0.932992798834739 },
+{ 0.821102514991105, 0.570780745886967 },
+{ 0.348418680249435, 0.937339011912575 },
+{ 0.817584813151584, 0.575808191417845 },
+{ 0.33688985339222, 0.941544065183021 },
+{ 0.814036329705948, 0.580813958095765 },
+{ 0.325310292162263, 0.945607325380521 },
+{ 0.810457198252595, 0.585797857456439 },
+{ 0.313681740398892, 0.949528180593037 },
+{ 0.806847553543799, 0.590759701858874 },
+{ 0.302005949319228, 0.953306040354194 },
+{ 0.803207531480645, 0.595699304492433 },
+{ 0.290284677254462, 0.956940335732209 },
+{ 0.799537269107905, 0.600616479383869 },
+{ 0.278519689385053, 0.960430519415566 },
+{ 0.795836904608884, 0.605511041404326 },
+{ 0.266712757474898, 0.96377606579544 },
+{ 0.792106577300212, 0.610382806276309 },
+{ 0.254865659604515, 0.966976471044852 },
+{ 0.788346427626606, 0.615231590580627 },
+{ 0.242980179903264, 0.970031253194544 },
+{ 0.784556597155575, 0.620057211763289 },
+{ 0.231058108280671, 0.97293995220556 },
+{ 0.780737228572094, 0.624859488142386 },
+{ 0.21910124015687, 0.975702130038529 },
+{ 0.776888465673232, 0.629638238914927 },
+{ 0.207111376192219, 0.978317370719628 },
+{ 0.773010453362737, 0.634393284163645 },
+{ 0.195090322016128, 0.98078528040323 },
+{ 0.76910333764558, 0.639124444863776 },
+{ 0.183039887955141, 0.983105487431216 },
+{ 0.765167265622459, 0.643831542889791 },
+{ 0.170961888760301, 0.985277642388941 },
+{ 0.761202385484262, 0.648514401022112 },
+{ 0.158858143333861, 0.987301418157858 },
+{ 0.757208846506485, 0.653172842953777 },
+{ 0.146730474455362, 0.989176509964781 },
+{ 0.753186799043613, 0.657806693297079 },
+{ 0.134580708507126, 0.99090263542778 },
+{ 0.749136394523459, 0.662415777590172 },
+{ 0.122410675199216, 0.99247953459871 },
+{ 0.745057785441466, 0.666999922303637 },
+{ 0.110222207293883, 0.993906970002356 },
+{ 0.740951125354959, 0.671558954847018 },
+{ 0.0980171403295608, 0.995184726672197 },
+{ 0.73681656887737, 0.676092703575316 },
+{ 0.0857973123444399, 0.996312612182778 },
+{ 0.732654271672413, 0.680600997795453 },
+{ 0.0735645635996675, 0.99729045667869 },
+{ 0.728464390448225, 0.6850836677727 },
+{ 0.0613207363022086, 0.998118112900149 },
+{ 0.724247082951467, 0.689540544737067 },
+{ 0.0490676743274181, 0.998795456205172 },
+{ 0.720002507961382, 0.693971460889654 },
+{ 0.036807222941359, 0.99932238458835 },
+{ 0.715730825283819, 0.698376249408973 },
+{ 0.0245412285229123, 0.999698818696204 },
+{ 0.711432195745216, 0.702754744457225 },
+{ 0.0122715382857199, 0.999924701839145 },
+{ 0.707106781186548, 0.707106781186547 },
+{ 6.12303176911189e-17, 1 },
+{ 0.702754744457225, 0.711432195745216 },
+{ -0.0122715382857198, 0.999924701839145 },
+{ 0.698376249408973, 0.715730825283819 },
+{ -0.0245412285229121, 0.999698818696204 },
+{ 0.693971460889654, 0.720002507961382 },
+{ -0.0368072229413589, 0.99932238458835 },
+{ 0.689540544737067, 0.724247082951467 },
+{ -0.049067674327418, 0.998795456205172 },
+{ 0.6850836677727, 0.728464390448225 },
+{ -0.0613207363022085, 0.998118112900149 },
+{ 0.680600997795453, 0.732654271672413 },
+{ -0.0735645635996673, 0.99729045667869 },
+{ 0.676092703575316, 0.73681656887737 },
+{ -0.0857973123444398, 0.996312612182778 },
+{ 0.671558954847018, 0.740951125354959 },
+{ -0.0980171403295606, 0.995184726672197 },
+{ 0.666999922303637, 0.745057785441466 },
+{ -0.110222207293883, 0.993906970002356 },
+{ 0.662415777590172, 0.749136394523459 },
+{ -0.122410675199216, 0.99247953459871 },
+{ 0.657806693297079, 0.753186799043612 },
+{ -0.134580708507126, 0.99090263542778 },
+{ 0.653172842953777, 0.757208846506484 },
+{ -0.146730474455362, 0.989176509964781 },
+{ 0.648514401022113, 0.761202385484262 },
+{ -0.158858143333861, 0.987301418157858 },
+{ 0.643831542889791, 0.765167265622459 },
+{ -0.170961888760301, 0.985277642388941 },
+{ 0.639124444863776, 0.76910333764558 },
+{ -0.183039887955141, 0.983105487431216 },
+{ 0.634393284163645, 0.773010453362737 },
+{ -0.195090322016128, 0.98078528040323 },
+{ 0.629638238914927, 0.776888465673232 },
+{ -0.207111376192218, 0.978317370719628 },
+{ 0.624859488142386, 0.780737228572094 },
+{ -0.21910124015687, 0.975702130038529 },
+{ 0.620057211763289, 0.784556597155575 },
+{ -0.231058108280671, 0.97293995220556 },
+{ 0.615231590580627, 0.788346427626606 },
+{ -0.242980179903264, 0.970031253194544 },
+{ 0.610382806276309, 0.792106577300212 },
+{ -0.254865659604515, 0.966976471044852 },
+{ 0.605511041404326, 0.795836904608883 },
+{ -0.266712757474898, 0.96377606579544 },
+{ 0.600616479383869, 0.799537269107905 },
+{ -0.278519689385053, 0.960430519415566 },
+{ 0.595699304492433, 0.803207531480645 },
+{ -0.290284677254462, 0.956940335732209 },
+{ 0.590759701858874, 0.806847553543799 },
+{ -0.302005949319228, 0.953306040354194 },
+{ 0.585797857456439, 0.810457198252595 },
+{ -0.313681740398891, 0.949528180593037 },
+{ 0.580813958095765, 0.814036329705948 },
+{ -0.325310292162263, 0.945607325380521 },
+{ 0.575808191417845, 0.817584813151584 },
+{ -0.33688985339222, 0.941544065183021 },
+{ 0.570780745886967, 0.821102514991105 },
+{ -0.348418680249434, 0.937339011912575 },
+{ 0.565731810783613, 0.824589302785025 },
+{ -0.359895036534988, 0.932992798834739 },
+{ 0.560661576197336, 0.828045045257756 },
+{ -0.371317193951837, 0.928506080473216 },
+{ 0.555570233019602, 0.831469612302545 },
+{ -0.38268343236509, 0.923879532511287 },
+{ 0.550457972936605, 0.83486287498638 },
+{ -0.393992040061048, 0.919113851690058 },
+{ 0.545324988422046, 0.838224705554838 },
+{ -0.40524131400499, 0.914209755703531 },
+{ 0.540171472729893, 0.841554977436898 },
+{ -0.416429560097637, 0.909167983090522 },
+{ 0.534997619887097, 0.844853565249707 },
+{ -0.427555093430282, 0.903989293123443 },
+{ 0.529803624686295, 0.848120344803297 },
+{ -0.438616238538527, 0.898674465693954 },
+{ 0.524589682678469, 0.851355193105265 },
+{ -0.449611329654607, 0.893224301195515 },
+{ 0.51935599016559, 0.854557988365401 },
+{ -0.46053871095824, 0.887639620402854 },
+{ 0.514102744193222, 0.857728610000272 },
+{ -0.471396736825998, 0.881921264348355 },
+{ 0.508830142543107, 0.860866938637767 },
+{ -0.482183772079123, 0.876070094195407 },
+{ 0.503538383725718, 0.863972856121587 },
+{ -0.492898192229784, 0.870086991108711 },
+{ 0.498227666972782, 0.867046245515693 },
+{ -0.503538383725717, 0.863972856121587 },
+{ 0.492898192229784, 0.870086991108711 },
+{ -0.514102744193222, 0.857728610000272 },
+{ 0.487550160148436, 0.87309497841829 },
+{ -0.524589682678469, 0.851355193105265 },
+{ 0.482183772079123, 0.876070094195407 },
+{ -0.534997619887097, 0.844853565249707 },
+{ 0.476799230063322, 0.879012226428633 },
+{ -0.545324988422046, 0.838224705554838 },
+{ 0.471396736825998, 0.881921264348355 },
+{ -0.555570233019602, 0.831469612302545 },
+{ 0.465976495767966, 0.884797098430938 },
+{ -0.565731810783613, 0.824589302785025 },
+{ 0.46053871095824, 0.887639620402854 },
+{ -0.575808191417845, 0.817584813151584 },
+{ 0.455083587126344, 0.890448723244758 },
+{ -0.585797857456439, 0.810457198252595 },
+{ 0.449611329654607, 0.893224301195515 },
+{ -0.595699304492433, 0.803207531480645 },
+{ 0.444122144570429, 0.895966249756185 },
+{ -0.605511041404325, 0.795836904608884 },
+{ 0.438616238538528, 0.898674465693954 },
+{ -0.615231590580627, 0.788346427626606 },
+{ 0.433093818853152, 0.901348847046022 },
+{ -0.624859488142386, 0.780737228572095 },
+{ 0.427555093430282, 0.903989293123443 },
+{ -0.634393284163645, 0.773010453362737 },
+{ 0.4220002707998, 0.906595704514915 },
+{ -0.643831542889791, 0.765167265622459 },
+{ 0.416429560097637, 0.909167983090522 },
+{ -0.653172842953777, 0.757208846506485 },
+{ 0.410843171057904, 0.91170603200543 },
+{ -0.662415777590172, 0.749136394523459 },
+{ 0.40524131400499, 0.914209755703531 },
+{ -0.671558954847018, 0.740951125354959 },
+{ 0.399624199845647, 0.916679059921043 },
+{ -0.680600997795453, 0.732654271672413 },
+{ 0.393992040061048, 0.919113851690058 },
+{ -0.689540544737067, 0.724247082951467 },
+{ 0.388345046698826, 0.921514039342042 },
+{ -0.698376249408973, 0.715730825283819 },
+{ 0.38268343236509, 0.923879532511287 },
+{ -0.707106781186547, 0.707106781186548 },
+{ 0.377007410216418, 0.926210242138311 },
+{ -0.715730825283819, 0.698376249408973 },
+{ 0.371317193951838, 0.928506080473215 },
+{ -0.724247082951467, 0.689540544737067 },
+{ 0.365612997804774, 0.930766961078984 },
+{ -0.732654271672413, 0.680600997795453 },
+{ 0.359895036534988, 0.932992798834739 },
+{ -0.740951125354959, 0.671558954847019 },
+{ 0.354163525420491, 0.935183509938947 },
+{ -0.749136394523459, 0.662415777590172 },
+{ 0.348418680249435, 0.937339011912575 },
+{ -0.757208846506485, 0.653172842953777 },
+{ 0.342660717311994, 0.93945922360219 },
+{ -0.765167265622459, 0.643831542889791 },
+{ 0.33688985339222, 0.941544065183021 },
+{ -0.773010453362737, 0.634393284163645 },
+{ 0.331106305759876, 0.94359345816196 },
+{ -0.780737228572094, 0.624859488142386 },
+{ 0.325310292162263, 0.945607325380521 },
+{ -0.788346427626606, 0.615231590580627 },
+{ 0.319502030816016, 0.947585591017741 },
+{ -0.795836904608883, 0.605511041404326 },
+{ 0.313681740398892, 0.949528180593037 },
+{ -0.803207531480645, 0.595699304492433 },
+{ 0.307849640041535, 0.951435020969008 },
+{ -0.810457198252595, 0.585797857456439 },
+{ 0.302005949319228, 0.953306040354194 },
+{ -0.817584813151584, 0.575808191417845 },
+{ 0.296150888243624, 0.955141168305771 },
+{ -0.824589302785025, 0.565731810783613 },
+{ 0.290284677254462, 0.956940335732209 },
+{ -0.831469612302545, 0.555570233019602 },
+{ 0.284407537211272, 0.958703474895872 },
+{ -0.838224705554838, 0.545324988422046 },
+{ 0.278519689385053, 0.960430519415566 },
+{ -0.844853565249707, 0.534997619887097 },
+{ 0.272621355449949, 0.962121404269042 },
+{ -0.851355193105265, 0.524589682678469 },
+{ 0.266712757474898, 0.96377606579544 },
+{ -0.857728610000272, 0.514102744193222 },
+{ 0.260794117915276, 0.965394441697689 },
+{ -0.863972856121587, 0.503538383725718 },
+{ 0.254865659604515, 0.966976471044852 },
+{ -0.870086991108711, 0.492898192229784 },
+{ 0.24892760574572, 0.968522094274417 },
+{ -0.876070094195406, 0.482183772079123 },
+{ 0.242980179903264, 0.970031253194544 },
+{ -0.881921264348355, 0.471396736825998 },
+{ 0.237023605994367, 0.971503890986252 },
+{ -0.887639620402854, 0.46053871095824 },
+{ 0.231058108280671, 0.97293995220556 },
+{ -0.893224301195515, 0.449611329654607 },
+{ 0.225083911359793, 0.974339382785576 },
+{ -0.898674465693954, 0.438616238538528 },
+{ 0.21910124015687, 0.975702130038529 },
+{ -0.903989293123443, 0.427555093430282 },
+{ 0.213110319916091, 0.977028142657754 },
+{ -0.909167983090522, 0.416429560097637 },
+{ 0.207111376192219, 0.978317370719628 },
+{ -0.914209755703531, 0.40524131400499 },
+{ 0.201104634842092, 0.979569765685441 },
+{ -0.919113851690058, 0.393992040061048 },
+{ 0.195090322016128, 0.98078528040323 },
+{ -0.923879532511287, 0.38268343236509 },
+{ 0.189068664149806, 0.981963869109555 },
+{ -0.928506080473215, 0.371317193951838 },
+{ 0.183039887955141, 0.983105487431216 },
+{ -0.932992798834739, 0.359895036534988 },
+{ 0.177004220412149, 0.984210092386929 },
+{ -0.937339011912575, 0.348418680249435 },
+{ 0.170961888760301, 0.985277642388941 },
+{ -0.941544065183021, 0.33688985339222 },
+{ 0.16491312048997, 0.986308097244599 },
+{ -0.945607325380521, 0.325310292162263 },
+{ 0.158858143333861, 0.987301418157858 },
+{ -0.949528180593037, 0.313681740398891 },
+{ 0.152797185258443, 0.988257567730749 },
+{ -0.953306040354194, 0.302005949319228 },
+{ 0.146730474455362, 0.989176509964781 },
+{ -0.956940335732209, 0.290284677254462 },
+{ 0.140658239332849, 0.990058210262297 },
+{ -0.960430519415566, 0.278519689385053 },
+{ 0.134580708507126, 0.99090263542778 },
+{ -0.96377606579544, 0.266712757474898 },
+{ 0.128498110793793, 0.9917097536691 },
+{ -0.966976471044852, 0.254865659604515 },
+{ 0.122410675199216, 0.99247953459871 },
+{ -0.970031253194544, 0.242980179903264 },
+{ 0.116318630911905, 0.993211949234795 },
+{ -0.97293995220556, 0.231058108280671 },
+{ 0.110222207293883, 0.993906970002356 },
+{ -0.975702130038528, 0.21910124015687 },
+{ 0.104121633872055, 0.994564570734255 },
+{ -0.978317370719628, 0.207111376192219 },
+{ 0.0980171403295608, 0.995184726672197 },
+{ -0.98078528040323, 0.195090322016129 },
+{ 0.0919089564971327, 0.99576741446766 },
+{ -0.983105487431216, 0.183039887955141 },
+{ 0.0857973123444399, 0.996312612182778 },
+{ -0.985277642388941, 0.170961888760301 },
+{ 0.0796824379714301, 0.996820299291166 },
+{ -0.987301418157858, 0.158858143333861 },
+{ 0.0735645635996675, 0.99729045667869 },
+{ -0.989176509964781, 0.146730474455362 },
+{ 0.0674439195636641, 0.997723066644192 },
+{ -0.99090263542778, 0.134580708507126 },
+{ 0.0613207363022086, 0.998118112900149 },
+{ -0.99247953459871, 0.122410675199216 },
+{ 0.05519524434969, 0.998475580573295 },
+{ -0.993906970002356, 0.110222207293883 },
+{ 0.0490676743274181, 0.998795456205172 },
+{ -0.995184726672197, 0.0980171403295608 },
+{ 0.042938256934941, 0.999077727752645 },
+{ -0.996312612182778, 0.0857973123444402 },
+{ 0.036807222941359, 0.99932238458835 },
+{ -0.99729045667869, 0.0735645635996677 },
+{ 0.0306748031766366, 0.999529417501093 },
+{ -0.998118112900149, 0.0613207363022085 },
+{ 0.0245412285229123, 0.999698818696204 },
+{ -0.998795456205172, 0.049067674327418 },
+{ 0.0184067299058048, 0.999830581795823 },
+{ -0.99932238458835, 0.0368072229413588 },
+{ 0.0122715382857199, 0.999924701839145 },
+{ -0.999698818696204, 0.0245412285229123 },
+{ 0.00613588464915452, 0.999981175282601 },
+{ -0.999924701839145, 0.01227153828572 },
+};
///////////////////////////////////////////////////////////////
+
void PFFTW(16) (fftw_complex * input) {
fftw_real tmp332;
fftw_real tmp331;
@@ -1483,6 +2128,15 @@
PFFTW(32)(input + 96);
}
+void PFFTW(256)(fftw_complex *input)
+{
+ PFFTW(twiddle_4)(input, PFFTW(W_256), 64);
+ PFFTW(64)(input );
+ PFFTW(64)(input + 64);
+ PFFTW(64)(input + 128);
+ PFFTW(64)(input + 192);
+}
+
void PFFTW(512)(fftw_complex *input)
{
PFFTW(twiddle_4)(input, PFFTW(W_512), 128);
@@ -1491,6 +2145,17 @@
PFFTW(128)(input + 256);
PFFTW(128)(input + 384);
}
+
+void PFFTW(1024)(fftw_complex *input)
+{
+ extern fftw_complex PFFTW(W_1024)[];
+ PFFTW(twiddle_4)(input, PFFTW(W_1024), 256);
+ PFFTW(256)(input );
+ PFFTW(256)(input + 256);
+ PFFTW(256)(input + 512);
+ PFFTW(256)(input + 768);
+}
+
///////////////////////////////////////////////////////////////
void PFFTWI(16) (fftw_complex * input) {
fftw_real tmp333;
@@ -2584,7 +3249,7 @@
c_re(input[3]) = st1;
}
-void PFFTWI(64)(fftw_complex *input)
+void PFFTWI(64)(fftw_complex *input)
{
PFFTWI(16)(input );
PFFTWI(16)(input + 16);
@@ -2593,7 +3258,7 @@
PFFTWI(twiddle_4)(input, PFFTW(W_64), 16);
}
-void PFFTWI(128)(fftw_complex *input)
+void PFFTWI(128)(fftw_complex *input)
{
PFFTWI(32)(input );
PFFTWI(32)(input + 32);
@@ -2602,6 +3267,15 @@
PFFTWI(twiddle_4)(input, PFFTW(W_128), 32);
}
+void PFFTWI(256)(fftw_complex *input)
+{
+ PFFTWI(64)(input );
+ PFFTWI(64)(input + 64);
+ PFFTWI(64)(input + 128);
+ PFFTWI(64)(input + 192);
+ PFFTWI(twiddle_4)(input, PFFTW(W_256), 64);
+}
+
void PFFTWI(512)(fftw_complex *input)
{
PFFTWI(128)(input );
@@ -2610,6 +3284,17 @@
PFFTWI(128)(input + 384);
PFFTWI(twiddle_4)(input, PFFTW(W_512), 128);
}
+
+void PFFTWI(1024)(fftw_complex *input)
+{
+ extern fftw_complex PFFTW(W_1024)[];
+ PFFTWI(256)(input );
+ PFFTWI(256)(input + 256);
+ PFFTWI(256)(input + 512);
+ PFFTWI(256)(input + 768);
+ PFFTWI(twiddle_4)(input, PFFTW(W_1024), 256);
+}
+
///////////////////////////////////////////////////////////////////////////
void PFFTW(twiddle_4) (fftw_complex * A, const fftw_complex * W, int iostride) {
int i;
@@ -2861,6 +3546,16 @@
return (i1 * 32 + ((i2 + 1) % 32));
}
+int PFFTW(permutation_256)(int i)
+{
+ int i1 = i % 4;
+ int i2 = i / 4;
+ if (i1 <= 2)
+ return (i1 * 64 + PFFTW(permutation_64)(i2));
+ else
+ return (i1 * 64 + PFFTW(permutation_64)((i2 + 1) % 64));
+}
+
int PFFTW(permutation_512)(int i)
{
int i1 = i % 4;
@@ -2871,13 +3566,25 @@
return (i1 * 128 + PFFTW(permutation_128)((i2 + 1) % 128));
}
+int PFFTW(permutation_1024)(int i)
+{
+ int i1 = i % 4;
+ int i2 = i / 4;
+ if (i1 <= (4 / 2))
+ return (i1 * 256 + PFFTW(permutation_256)(i2));
+ else
+ return (i1 * 256 + PFFTW(permutation_256)((i2 + 1) % 256));
+}
+
/////////////////////////////////////////////////////////////////
void make_FFT_order(void)
{
int i;
-for (i=0 ; i < 512 ; i++){
+for (i=0 ; i < 1024 ; i++){
if (i < 64) unscambled64[i] = PFFTW(permutation_64)(i);
- unscambled512[i] = PFFTW(permutation_512)(i);
+ if (i < 128) unscambled128[i] = PFFTW(permutation_128)(i);
+ if (i < 512) unscambled512[i] = PFFTW(permutation_512)(i);
+ unscambled1024[i] = PFFTW(permutation_1024)(i);
}
}
--- a/psych.c
+++ b/psych.c
@@ -52,9 +52,9 @@
Source file:
-$Id: psych.c,v 1.45 2000/02/08 12:12:47 oxygene2000 Exp $
-$Id: psych.c,v 1.45 2000/02/08 12:12:47 oxygene2000 Exp $
-$Id: psych.c,v 1.45 2000/02/08 12:12:47 oxygene2000 Exp $
+$Id: psych.c,v 1.46 2000/02/14 08:22:02 lenox Exp $
+$Id: psych.c,v 1.46 2000/02/14 08:22:02 lenox Exp $
+$Id: psych.c,v 1.46 2000/02/14 08:22:02 lenox Exp $
**********************************************************************/
@@ -64,10 +64,10 @@
#include <memory.h>
#include "tf_main.h"
#include "psych.h"
+#include "transfo.h"
-void complspectrum( double *f, unsigned lg2n );
+double sqrt2048, sqrt256;
-
SR_INFO sr_info_aac[MAX_SAMPLING_RATES+1] =
{
{ 8000, 40, 15,
@@ -218,7 +218,7 @@
/* added by T. Okada (1997.07.10) end */
/*
- * This Function calculates the Frequency in Hertz given a
+ * This Function calculates the Frequency in Hertz given a
* Bark-value. It uses the Traunmueller-formula for bark>2
* and a linear inerpolation below.
* KAF
@@ -448,6 +448,8 @@
psy_stvar_short->last7_nb[i] = 90.0;
}
/* added by T. Araki (1997.10.16) end */
+sqrt2048 = 1/sqrt(2048);
+sqrt256 = 1/sqrt(256);
}
void psy_fill_lookahead(double *p_time_signal[], int no_of_chan)
@@ -553,7 +555,7 @@
psy_var_short.c[i][b] = psy_stvar_short[1].save_cw[i][b];
}
- psy_step5(&part_tbl_long, &part_tbl_short, &psy_stvar_long[no_of_chan], &psy_stvar_short[no_of_chan],
+ psy_step5(&part_tbl_long, &part_tbl_short, &psy_stvar_long[no_of_chan], &psy_stvar_short[no_of_chan],
&psy_var_long, &psy_var_short, ch);
psy_step6(&part_tbl_long, &part_tbl_short, &psy_stvar_long[no_of_chan], &psy_stvar_short[no_of_chan],
&psy_var_long, &psy_var_short);
@@ -607,7 +609,7 @@
}
}
-void psy_step1(double* p_time_signal[],
+void psy_step1(double* p_time_signal[],
double sample[][BLOCK_LEN_LONG*2],
int ch)
{
@@ -628,11 +630,8 @@
)
{
int w,l;
- double sqrtN;
- double data[2048+1024]; // +1024 becuase of problems in FFT
+ double data[2048],a,b;
- memset(data, 0, (2048+1024)*sizeof(double));
-
/* FFT for long */
psy_stvar_long->p_fft += BLOCK_LEN_LONG;
@@ -639,36 +638,69 @@
if(psy_stvar_long->p_fft == BLOCK_LEN_LONG * 3)
psy_stvar_long->p_fft = 0;
- sqrtN = 1/sqrt(2048);
-
/* windowing */
- for(w = 0; w < BLOCK_LEN_LONG*2; w++){
- data[w] = fft_tbl_long->hw[w] * sample[ch][w];
+ for(w = 0; w < BLOCK_LEN_LONG; w++){
+ FFTarray[w].re = fft_tbl_long->hw[(w<<1)] * sample[ch][w<<1];
+ FFTarray[w].im = fft_tbl_long->hw[(w<<1)+1] * sample[ch][(w<<1)+1];
}
- complspectrum(data, 11);
+ realft2048(data);
for(w = 0; w < BLOCK_LEN_LONG; w++){
- psy_stvar_long->fft_r[w+psy_stvar_long->p_fft] = data[w] * sqrtN;
- if (w < 420)
- psy_stvar_long->fft_f[w+psy_stvar_long->p_fft] = data[w+BLOCK_LEN_LONG];
- }
+ a = data[(w<<1)];
+ b = data[(w<<1)+1];
+ psy_stvar_long->fft_r[w+psy_stvar_long->p_fft] = sqrt(a*a + b*b) * sqrt2048;
- /* FFT for short */
- sqrtN = 1/sqrt(256);
+// if (w < 420)
+ if( a > 0.0 ){
+ if( b >= 0.0 )
+ psy_stvar_long->fft_f[w+psy_stvar_long->p_fft] = atan2( b, a );
+ else
+ psy_stvar_long->fft_f[w+psy_stvar_long->p_fft] = atan2( b, a )+ M_PI * 2.0;
+ } else if( a < 0.0 ) {
+ psy_stvar_long->fft_f[w+psy_stvar_long->p_fft] = atan2( b, a ) + M_PI;
+ } else {
+ if( b > 0.0 )
+ psy_stvar_long->fft_f[w+psy_stvar_long->p_fft] = M_PI * 0.5;
+ else if( b < 0.0 )
+ psy_stvar_long->fft_f[w+psy_stvar_long->p_fft] = M_PI * 1.5;
+ else
+ psy_stvar_long->fft_f[w+psy_stvar_long->p_fft] = 0.0;
+ }
+ }
+
+ /* FFT for short */
for(l = 0; l < MAX_SHORT_WINDOWS; l++){
/* windowing */
- for(w = 0; w < BLOCK_LEN_SHORT*2; w++){
- data[w] = fft_tbl_short->hw[w] * sample[ch][OFFSET_FOR_SHORT + (BLOCK_LEN_SHORT * l) + w];
+ for(w = 0; w < BLOCK_LEN_SHORT; w++){
+ FFTarray[w].re = fft_tbl_short->hw[w<<1] * sample[ch][OFFSET_FOR_SHORT + (BLOCK_LEN_SHORT * l) + (w<<1)];
+ FFTarray[w].im = fft_tbl_short->hw[(w<<1)+1] * sample[ch][OFFSET_FOR_SHORT + (BLOCK_LEN_SHORT * l) + (w<<1)+1];
}
- complspectrum(data, 8);
+ realft256(data);
for(w = 0; w < BLOCK_LEN_SHORT; w++){
- psy_stvar_short->fft_r[l][w] = data[w] * sqrtN;
- psy_stvar_short->fft_f[l][w] = data[w+BLOCK_LEN_SHORT];
+ a = data[(w<<1)];
+ b = data[(w<<1)+1];
+ psy_stvar_short->fft_r[l][w]= sqrt(a*a + b*b) * sqrt256;
+
+ if( a > 0.0 ){
+ if( b >= 0.0 )
+ psy_stvar_short->fft_f[l][w] = atan2( b, a );
+ else
+ psy_stvar_short->fft_f[l][w] = atan2( b, a )+ M_PI * 2.0;
+ } else if( a < 0.0 ) {
+ psy_stvar_short->fft_f[l][w] = atan2( b, a ) + M_PI;
+ } else {
+ if( b > 0.0 )
+ psy_stvar_short->fft_f[l][w] = M_PI * 0.5;
+ else if( b < 0.0 )
+ psy_stvar_short->fft_f[l][w] = M_PI * 1.5;
+ else
+ psy_stvar_short->fft_f[l][w] = 0.0;
+ }
}
}
}
--- a/transfo.c
+++ b/transfo.c
@@ -4,6 +4,8 @@
#include "transfo.h"
#include "shape_win.h"
+#define NFLAT_LS 448 // (BLOCK_LEN_LONG - BLOCK_LEN_SHORT) / 2
+
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
@@ -12,10 +14,10 @@
#define M_PI_2 1.57079632679489661923
#endif
-#define NFLAT_LS 448 // (BLOCK_LEN_LONG - BLOCK_LEN_SHORT) / 2
+int sizedouble;
+double wpi256,wpr256;
+double wpi2048,wpr2048;
-int sizedouble; // temp value
-
/*******************************************************************************
Fast MDCT & IMDCT Code
*******************************************************************************/
@@ -491,5 +493,94 @@
if( p_out != p_in ) memcpy(p_out,p_in,specLen*sizedouble);
memset(p_out+xlowpass,0,(specLen-xlowpass)*sizedouble);
+}
+
+void initrft(void)
+{
+double theta,wtemp;
+
+theta = -M_PI/128.0;
+wpi256 = sin(theta);
+wtemp = sin(0.5*theta);
+wpr256 = -2.0*wtemp*wtemp;
+
+theta = -M_PI/1024.0;
+wpi2048 = sin(theta);
+wtemp = sin(0.5*theta);
+wpr2048 = -2.0*wtemp*wtemp;
+}
+
+void realft256(double *data)
+{
+ int i,i1,i2,i3,i4;
+ double h1r,h1i,h2r,h2i,t1,t2,t3;
+ double wr,wi,wtemp;
+
+ pfftw_128(FFTarray);
+ for (i = 0; i < 128; i++){
+ data[(i<<1)] = FFTarray[unscambled128[i]].re;
+ data[(i<<1)+1]= FFTarray[unscambled128[i]].im;
+ }
+
+ wr=1.0+wpr256;
+ wi=wpi256;
+ for (i=1;i<64;i++) {
+ i4=1+(i3=257-(i2=1+(i1=i+i)));
+ h1r=0.5*(data[i1]+data[i3]);
+ h1i=0.5*(data[i2]-data[i4]);
+ h2r=0.5*(data[i2]+data[i4]);
+ h2i=-0.5*(data[i1]-data[i3]);
+ t1=wr*h2r;
+ t2=wi*h2i;
+ t3=wr*h2i+wi*h2r;
+
+ data[i1]=h1r+t1-t2;
+ data[i2]=h1i+t3;
+ data[i3]=h1r-t1+t2;
+ data[i4]=-h1i+t3;
+ wtemp=wr;
+ wr=wtemp*wpr256-wi*wpi256+wr;
+ wi=wi*wpr256+wtemp*wpi256+wi;
+ }
+ data[0] = data[0]+data[1];
+ data[1] = 0;
+ data[129] = -data[129]; // hack to emulate complex FFT
+}
+
+void realft2048(double *data)
+{
+ int i,i1,i2,i3,i4;
+ double h1r,h1i,h2r,h2i,t1,t2,t3;
+ double wr,wi,wtemp;
+
+ pfftw_1024(FFTarray);
+ for (i = 0; i < 1024; i++){
+ data[(i<<1)] = FFTarray[unscambled1024[i]].re;
+ data[(i<<1)+1]= FFTarray[unscambled1024[i]].im;
+ }
+
+ wr=1.0+wpr2048;
+ wi=wpi2048;
+ for (i=1;i<512;i++) {
+ i4=1+(i3=2049-(i2=1+(i1=i+i)));
+ h1r=0.5*(data[i1]+data[i3]);
+ h1i=0.5*(data[i2]-data[i4]);
+ h2r=0.5*(data[i2]+data[i4]);
+ h2i=-0.5*(data[i1]-data[i3]);
+ t1=wr*h2r;
+ t2=wi*h2i;
+ t3=wr*h2i+wi*h2r;
+
+ data[i1]=h1r+t1-t2;
+ data[i2]=h1i+t3;
+ data[i3]=h1r-t1+t2;
+ data[i4]=-h1i+t3;
+ wtemp=wr;
+ wr=wtemp*wpr2048-wi*wpi2048+wr;
+ wi=wi*wpr2048+wtemp*wpi2048+wi;
+ }
+ data[0] = data[0]+data[1];
+ data[1] = 0;
+ data[1025] = -data[1025]; // hack to emulate complex FFT
}
--- a/transfo.h
+++ b/transfo.h
@@ -23,15 +23,22 @@
DEFINE_PFFTW(32)
DEFINE_PFFTW(64)
DEFINE_PFFTW(128)
+DEFINE_PFFTW(256)
DEFINE_PFFTW(512)
+DEFINE_PFFTW(1024)
void make_FFT_order(void);
void make_MDCT_windows(void);
void IMDCT(fftw_real *data, int N);
void MDCT(fftw_real *data, int N);
+void realft2048(double *data);
+void realft256(double *data);
+void initrft(void);
-extern int unscambled64[64]; /* the permutation array for FFT64*/
-extern int unscambled512[512]; /* the permutation array for FFT512*/
-extern fftw_complex FFTarray[512]; /* the array for in-place FFT */
+extern int unscambled64[64]; /* the permutation array for FFT64*/
+extern int unscambled128[128]; /* the permutation array for FFT128*/
+extern int unscambled512[512]; /* the permutation array for FFT512*/
+extern int unscambled1024[1024]; /* the permutation array for FFT1024*/
+extern fftw_complex FFTarray[1024]; /* the array for in-place FFT */
#endif /* TRANSFORM_H */