newmdct.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. /*
  2. * MP3 window subband -> subband filtering -> mdct routine
  3. *
  4. * Copyright (c) 1999-2000 Takehiro Tominaga
  5. *
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. /*
  23. * Special Thanks to Patrick De Smet for your advices.
  24. */
  25. /* $Id: newmdct.c,v 1.39 2011/05/07 16:05:17 rbrito Exp $ */
  26. #ifdef HAVE_CONFIG_H
  27. # include <config.h>
  28. #endif
  29. #include "lame.h"
  30. #include "machine.h"
  31. #include "encoder.h"
  32. #include "util.h"
  33. #include "newmdct.h"
  34. #ifndef USE_GOGO_SUBBAND
  35. static const FLOAT enwindow[] = {
  36. -4.77e-07 * 0.740951125354959 / 2.384e-06, 1.03951e-04 * 0.740951125354959 / 2.384e-06,
  37. 9.53674e-04 * 0.740951125354959 / 2.384e-06, 2.841473e-03 * 0.740951125354959 / 2.384e-06,
  38. 3.5758972e-02 * 0.740951125354959 / 2.384e-06, 3.401756e-03 * 0.740951125354959 / 2.384e-06, 9.83715e-04 * 0.740951125354959 / 2.384e-06, 9.9182e-05 * 0.740951125354959 / 2.384e-06, /* 15 */
  39. 1.2398e-05 * 0.740951125354959 / 2.384e-06, 1.91212e-04 * 0.740951125354959 / 2.384e-06,
  40. 2.283096e-03 * 0.740951125354959 / 2.384e-06, 1.6994476e-02 * 0.740951125354959 / 2.384e-06,
  41. -1.8756866e-02 * 0.740951125354959 / 2.384e-06, -2.630711e-03 * 0.740951125354959 / 2.384e-06,
  42. -2.47478e-04 * 0.740951125354959 / 2.384e-06, -1.4782e-05 * 0.740951125354959 / 2.384e-06,
  43. 9.063471690191471e-01,
  44. 1.960342806591213e-01,
  45. -4.77e-07 * 0.773010453362737 / 2.384e-06, 1.05858e-04 * 0.773010453362737 / 2.384e-06,
  46. 9.30786e-04 * 0.773010453362737 / 2.384e-06, 2.521515e-03 * 0.773010453362737 / 2.384e-06,
  47. 3.5694122e-02 * 0.773010453362737 / 2.384e-06, 3.643036e-03 * 0.773010453362737 / 2.384e-06, 9.91821e-04 * 0.773010453362737 / 2.384e-06, 9.6321e-05 * 0.773010453362737 / 2.384e-06, /* 14 */
  48. 1.1444e-05 * 0.773010453362737 / 2.384e-06, 1.65462e-04 * 0.773010453362737 / 2.384e-06,
  49. 2.110004e-03 * 0.773010453362737 / 2.384e-06, 1.6112804e-02 * 0.773010453362737 / 2.384e-06,
  50. -1.9634247e-02 * 0.773010453362737 / 2.384e-06, -2.803326e-03 * 0.773010453362737 / 2.384e-06,
  51. -2.77042e-04 * 0.773010453362737 / 2.384e-06, -1.6689e-05 * 0.773010453362737 / 2.384e-06,
  52. 8.206787908286602e-01,
  53. 3.901806440322567e-01,
  54. -4.77e-07 * 0.803207531480645 / 2.384e-06, 1.07288e-04 * 0.803207531480645 / 2.384e-06,
  55. 9.02653e-04 * 0.803207531480645 / 2.384e-06, 2.174854e-03 * 0.803207531480645 / 2.384e-06,
  56. 3.5586357e-02 * 0.803207531480645 / 2.384e-06, 3.858566e-03 * 0.803207531480645 / 2.384e-06, 9.95159e-04 * 0.803207531480645 / 2.384e-06, 9.3460e-05 * 0.803207531480645 / 2.384e-06, /* 13 */
  57. 1.0014e-05 * 0.803207531480645 / 2.384e-06, 1.40190e-04 * 0.803207531480645 / 2.384e-06,
  58. 1.937389e-03 * 0.803207531480645 / 2.384e-06, 1.5233517e-02 * 0.803207531480645 / 2.384e-06,
  59. -2.0506859e-02 * 0.803207531480645 / 2.384e-06, -2.974033e-03 * 0.803207531480645 / 2.384e-06,
  60. -3.07560e-04 * 0.803207531480645 / 2.384e-06, -1.8120e-05 * 0.803207531480645 / 2.384e-06,
  61. 7.416505462720353e-01,
  62. 5.805693545089249e-01,
  63. -4.77e-07 * 0.831469612302545 / 2.384e-06, 1.08242e-04 * 0.831469612302545 / 2.384e-06,
  64. 8.68797e-04 * 0.831469612302545 / 2.384e-06, 1.800537e-03 * 0.831469612302545 / 2.384e-06,
  65. 3.5435200e-02 * 0.831469612302545 / 2.384e-06, 4.049301e-03 * 0.831469612302545 / 2.384e-06, 9.94205e-04 * 0.831469612302545 / 2.384e-06, 9.0599e-05 * 0.831469612302545 / 2.384e-06, /* 12 */
  66. 9.060e-06 * 0.831469612302545 / 2.384e-06, 1.16348e-04 * 0.831469612302545 / 2.384e-06,
  67. 1.766682e-03 * 0.831469612302545 / 2.384e-06, 1.4358521e-02 * 0.831469612302545 / 2.384e-06,
  68. -2.1372318e-02 * 0.831469612302545 / 2.384e-06, -3.14188e-03 * 0.831469612302545 / 2.384e-06,
  69. -3.39031e-04 * 0.831469612302545 / 2.384e-06, -1.9550e-05 * 0.831469612302545 / 2.384e-06,
  70. 6.681786379192989e-01,
  71. 7.653668647301797e-01,
  72. -4.77e-07 * 0.857728610000272 / 2.384e-06, 1.08719e-04 * 0.857728610000272 / 2.384e-06,
  73. 8.29220e-04 * 0.857728610000272 / 2.384e-06, 1.399517e-03 * 0.857728610000272 / 2.384e-06,
  74. 3.5242081e-02 * 0.857728610000272 / 2.384e-06, 4.215240e-03 * 0.857728610000272 / 2.384e-06, 9.89437e-04 * 0.857728610000272 / 2.384e-06, 8.7261e-05 * 0.857728610000272 / 2.384e-06, /* 11 */
  75. 8.106e-06 * 0.857728610000272 / 2.384e-06, 9.3937e-05 * 0.857728610000272 / 2.384e-06,
  76. 1.597881e-03 * 0.857728610000272 / 2.384e-06, 1.3489246e-02 * 0.857728610000272 / 2.384e-06,
  77. -2.2228718e-02 * 0.857728610000272 / 2.384e-06, -3.306866e-03 * 0.857728610000272 / 2.384e-06,
  78. -3.71456e-04 * 0.857728610000272 / 2.384e-06, -2.1458e-05 * 0.857728610000272 / 2.384e-06,
  79. 5.993769336819237e-01,
  80. 9.427934736519954e-01,
  81. -4.77e-07 * 0.881921264348355 / 2.384e-06, 1.08719e-04 * 0.881921264348355 / 2.384e-06,
  82. 7.8392e-04 * 0.881921264348355 / 2.384e-06, 9.71317e-04 * 0.881921264348355 / 2.384e-06,
  83. 3.5007000e-02 * 0.881921264348355 / 2.384e-06, 4.357815e-03 * 0.881921264348355 / 2.384e-06, 9.80854e-04 * 0.881921264348355 / 2.384e-06, 8.3923e-05 * 0.881921264348355 / 2.384e-06, /* 10 */
  84. 7.629e-06 * 0.881921264348355 / 2.384e-06, 7.2956e-05 * 0.881921264348355 / 2.384e-06,
  85. 1.432419e-03 * 0.881921264348355 / 2.384e-06, 1.2627602e-02 * 0.881921264348355 / 2.384e-06,
  86. -2.3074150e-02 * 0.881921264348355 / 2.384e-06, -3.467083e-03 * 0.881921264348355 / 2.384e-06,
  87. -4.04358e-04 * 0.881921264348355 / 2.384e-06, -2.3365e-05 * 0.881921264348355 / 2.384e-06,
  88. 5.345111359507916e-01,
  89. 1.111140466039205e+00,
  90. -9.54e-07 * 0.903989293123443 / 2.384e-06, 1.08242e-04 * 0.903989293123443 / 2.384e-06,
  91. 7.31945e-04 * 0.903989293123443 / 2.384e-06, 5.15938e-04 * 0.903989293123443 / 2.384e-06,
  92. 3.4730434e-02 * 0.903989293123443 / 2.384e-06, 4.477024e-03 * 0.903989293123443 / 2.384e-06, 9.68933e-04 * 0.903989293123443 / 2.384e-06, 8.0585e-05 * 0.903989293123443 / 2.384e-06, /* 9 */
  93. 6.676e-06 * 0.903989293123443 / 2.384e-06, 5.2929e-05 * 0.903989293123443 / 2.384e-06,
  94. 1.269817e-03 * 0.903989293123443 / 2.384e-06, 1.1775017e-02 * 0.903989293123443 / 2.384e-06,
  95. -2.3907185e-02 * 0.903989293123443 / 2.384e-06, -3.622532e-03 * 0.903989293123443 / 2.384e-06,
  96. -4.38213e-04 * 0.903989293123443 / 2.384e-06, -2.5272e-05 * 0.903989293123443 / 2.384e-06,
  97. 4.729647758913199e-01,
  98. 1.268786568327291e+00,
  99. -9.54e-07 * 0.92387953251128675613 / 2.384e-06,
  100. 1.06812e-04 * 0.92387953251128675613 / 2.384e-06,
  101. 6.74248e-04 * 0.92387953251128675613 / 2.384e-06,
  102. 3.3379e-05 * 0.92387953251128675613 / 2.384e-06,
  103. 3.4412861e-02 * 0.92387953251128675613 / 2.384e-06,
  104. 4.573822e-03 * 0.92387953251128675613 / 2.384e-06,
  105. 9.54151e-04 * 0.92387953251128675613 / 2.384e-06,
  106. 7.6771e-05 * 0.92387953251128675613 / 2.384e-06,
  107. 6.199e-06 * 0.92387953251128675613 / 2.384e-06, 3.4332e-05 * 0.92387953251128675613 / 2.384e-06,
  108. 1.111031e-03 * 0.92387953251128675613 / 2.384e-06,
  109. 1.0933399e-02 * 0.92387953251128675613 / 2.384e-06,
  110. -2.4725437e-02 * 0.92387953251128675613 / 2.384e-06,
  111. -3.771782e-03 * 0.92387953251128675613 / 2.384e-06,
  112. -4.72546e-04 * 0.92387953251128675613 / 2.384e-06,
  113. -2.7657e-05 * 0.92387953251128675613 / 2.384e-06,
  114. 4.1421356237309504879e-01, /* tan(PI/8) */
  115. 1.414213562373095e+00,
  116. -9.54e-07 * 0.941544065183021 / 2.384e-06, 1.05381e-04 * 0.941544065183021 / 2.384e-06,
  117. 6.10352e-04 * 0.941544065183021 / 2.384e-06, -4.75883e-04 * 0.941544065183021 / 2.384e-06,
  118. 3.4055710e-02 * 0.941544065183021 / 2.384e-06, 4.649162e-03 * 0.941544065183021 / 2.384e-06, 9.35555e-04 * 0.941544065183021 / 2.384e-06, 7.3433e-05 * 0.941544065183021 / 2.384e-06, /* 7 */
  119. 5.245e-06 * 0.941544065183021 / 2.384e-06, 1.7166e-05 * 0.941544065183021 / 2.384e-06,
  120. 9.56535e-04 * 0.941544065183021 / 2.384e-06, 1.0103703e-02 * 0.941544065183021 / 2.384e-06,
  121. -2.5527000e-02 * 0.941544065183021 / 2.384e-06, -3.914356e-03 * 0.941544065183021 / 2.384e-06,
  122. -5.07355e-04 * 0.941544065183021 / 2.384e-06, -3.0041e-05 * 0.941544065183021 / 2.384e-06,
  123. 3.578057213145241e-01,
  124. 1.546020906725474e+00,
  125. -9.54e-07 * 0.956940335732209 / 2.384e-06, 1.02520e-04 * 0.956940335732209 / 2.384e-06,
  126. 5.39303e-04 * 0.956940335732209 / 2.384e-06, -1.011848e-03 * 0.956940335732209 / 2.384e-06,
  127. 3.3659935e-02 * 0.956940335732209 / 2.384e-06, 4.703045e-03 * 0.956940335732209 / 2.384e-06, 9.15051e-04 * 0.956940335732209 / 2.384e-06, 7.0095e-05 * 0.956940335732209 / 2.384e-06, /* 6 */
  128. 4.768e-06 * 0.956940335732209 / 2.384e-06, 9.54e-07 * 0.956940335732209 / 2.384e-06,
  129. 8.06808e-04 * 0.956940335732209 / 2.384e-06, 9.287834e-03 * 0.956940335732209 / 2.384e-06,
  130. -2.6310921e-02 * 0.956940335732209 / 2.384e-06, -4.048824e-03 * 0.956940335732209 / 2.384e-06,
  131. -5.42164e-04 * 0.956940335732209 / 2.384e-06, -3.2425e-05 * 0.956940335732209 / 2.384e-06,
  132. 3.033466836073424e-01,
  133. 1.662939224605090e+00,
  134. -1.431e-06 * 0.970031253194544 / 2.384e-06, 9.9182e-05 * 0.970031253194544 / 2.384e-06,
  135. 4.62532e-04 * 0.970031253194544 / 2.384e-06, -1.573563e-03 * 0.970031253194544 / 2.384e-06,
  136. 3.3225536e-02 * 0.970031253194544 / 2.384e-06, 4.737377e-03 * 0.970031253194544 / 2.384e-06, 8.91685e-04 * 0.970031253194544 / 2.384e-06, 6.6280e-05 * 0.970031253194544 / 2.384e-06, /* 5 */
  137. 4.292e-06 * 0.970031253194544 / 2.384e-06, -1.3828e-05 * 0.970031253194544 / 2.384e-06,
  138. 6.61850e-04 * 0.970031253194544 / 2.384e-06, 8.487225e-03 * 0.970031253194544 / 2.384e-06,
  139. -2.7073860e-02 * 0.970031253194544 / 2.384e-06, -4.174709e-03 * 0.970031253194544 / 2.384e-06,
  140. -5.76973e-04 * 0.970031253194544 / 2.384e-06, -3.4809e-05 * 0.970031253194544 / 2.384e-06,
  141. 2.504869601913055e-01,
  142. 1.763842528696710e+00,
  143. -1.431e-06 * 0.98078528040323 / 2.384e-06, 9.5367e-05 * 0.98078528040323 / 2.384e-06,
  144. 3.78609e-04 * 0.98078528040323 / 2.384e-06, -2.161503e-03 * 0.98078528040323 / 2.384e-06,
  145. 3.2754898e-02 * 0.98078528040323 / 2.384e-06, 4.752159e-03 * 0.98078528040323 / 2.384e-06, 8.66413e-04 * 0.98078528040323 / 2.384e-06, 6.2943e-05 * 0.98078528040323 / 2.384e-06, /* 4 */
  146. 3.815e-06 * 0.98078528040323 / 2.384e-06, -2.718e-05 * 0.98078528040323 / 2.384e-06,
  147. 5.22137e-04 * 0.98078528040323 / 2.384e-06, 7.703304e-03 * 0.98078528040323 / 2.384e-06,
  148. -2.7815342e-02 * 0.98078528040323 / 2.384e-06, -4.290581e-03 * 0.98078528040323 / 2.384e-06,
  149. -6.11782e-04 * 0.98078528040323 / 2.384e-06, -3.7670e-05 * 0.98078528040323 / 2.384e-06,
  150. 1.989123673796580e-01,
  151. 1.847759065022573e+00,
  152. -1.907e-06 * 0.989176509964781 / 2.384e-06, 9.0122e-05 * 0.989176509964781 / 2.384e-06,
  153. 2.88486e-04 * 0.989176509964781 / 2.384e-06, -2.774239e-03 * 0.989176509964781 / 2.384e-06,
  154. 3.2248020e-02 * 0.989176509964781 / 2.384e-06, 4.748821e-03 * 0.989176509964781 / 2.384e-06, 8.38757e-04 * 0.989176509964781 / 2.384e-06, 5.9605e-05 * 0.989176509964781 / 2.384e-06, /* 3 */
  155. 3.338e-06 * 0.989176509964781 / 2.384e-06, -3.9577e-05 * 0.989176509964781 / 2.384e-06,
  156. 3.88145e-04 * 0.989176509964781 / 2.384e-06, 6.937027e-03 * 0.989176509964781 / 2.384e-06,
  157. -2.8532982e-02 * 0.989176509964781 / 2.384e-06, -4.395962e-03 * 0.989176509964781 / 2.384e-06,
  158. -6.46591e-04 * 0.989176509964781 / 2.384e-06, -4.0531e-05 * 0.989176509964781 / 2.384e-06,
  159. 1.483359875383474e-01,
  160. 1.913880671464418e+00,
  161. -1.907e-06 * 0.995184726672197 / 2.384e-06, 8.4400e-05 * 0.995184726672197 / 2.384e-06,
  162. 1.91689e-04 * 0.995184726672197 / 2.384e-06, -3.411293e-03 * 0.995184726672197 / 2.384e-06,
  163. 3.1706810e-02 * 0.995184726672197 / 2.384e-06, 4.728317e-03 * 0.995184726672197 / 2.384e-06,
  164. 8.09669e-04 * 0.995184726672197 / 2.384e-06, 5.579e-05 * 0.995184726672197 / 2.384e-06,
  165. 3.338e-06 * 0.995184726672197 / 2.384e-06, -5.0545e-05 * 0.995184726672197 / 2.384e-06,
  166. 2.59876e-04 * 0.995184726672197 / 2.384e-06, 6.189346e-03 * 0.995184726672197 / 2.384e-06,
  167. -2.9224873e-02 * 0.995184726672197 / 2.384e-06, -4.489899e-03 * 0.995184726672197 / 2.384e-06,
  168. -6.80923e-04 * 0.995184726672197 / 2.384e-06, -4.3392e-05 * 0.995184726672197 / 2.384e-06,
  169. 9.849140335716425e-02,
  170. 1.961570560806461e+00,
  171. -2.384e-06 * 0.998795456205172 / 2.384e-06, 7.7724e-05 * 0.998795456205172 / 2.384e-06,
  172. 8.8215e-05 * 0.998795456205172 / 2.384e-06, -4.072189e-03 * 0.998795456205172 / 2.384e-06,
  173. 3.1132698e-02 * 0.998795456205172 / 2.384e-06, 4.691124e-03 * 0.998795456205172 / 2.384e-06,
  174. 7.79152e-04 * 0.998795456205172 / 2.384e-06, 5.2929e-05 * 0.998795456205172 / 2.384e-06,
  175. 2.861e-06 * 0.998795456205172 / 2.384e-06, -6.0558e-05 * 0.998795456205172 / 2.384e-06,
  176. 1.37329e-04 * 0.998795456205172 / 2.384e-06, 5.462170e-03 * 0.998795456205172 / 2.384e-06,
  177. -2.9890060e-02 * 0.998795456205172 / 2.384e-06, -4.570484e-03 * 0.998795456205172 / 2.384e-06,
  178. -7.14302e-04 * 0.998795456205172 / 2.384e-06, -4.6253e-05 * 0.998795456205172 / 2.384e-06,
  179. 4.912684976946725e-02,
  180. 1.990369453344394e+00,
  181. 3.5780907e-02 * SQRT2 * 0.5 / 2.384e-06, 1.7876148e-02 * SQRT2 * 0.5 / 2.384e-06,
  182. 3.134727e-03 * SQRT2 * 0.5 / 2.384e-06, 2.457142e-03 * SQRT2 * 0.5 / 2.384e-06,
  183. 9.71317e-04 * SQRT2 * 0.5 / 2.384e-06, 2.18868e-04 * SQRT2 * 0.5 / 2.384e-06,
  184. 1.01566e-04 * SQRT2 * 0.5 / 2.384e-06, 1.3828e-05 * SQRT2 * 0.5 / 2.384e-06,
  185. 3.0526638e-02 / 2.384e-06, 4.638195e-03 / 2.384e-06, 7.47204e-04 / 2.384e-06,
  186. 4.9591e-05 / 2.384e-06,
  187. 4.756451e-03 / 2.384e-06, 2.1458e-05 / 2.384e-06, -6.9618e-05 / 2.384e-06, /* 2.384e-06/2.384e-06 */
  188. };
  189. #endif
  190. #define NS 12
  191. #define NL 36
  192. static const FLOAT win[4][NL] = {
  193. {
  194. 2.382191739347913e-13,
  195. 6.423305872147834e-13,
  196. 9.400849094049688e-13,
  197. 1.122435026096556e-12,
  198. 1.183840321267481e-12,
  199. 1.122435026096556e-12,
  200. 9.400849094049690e-13,
  201. 6.423305872147839e-13,
  202. 2.382191739347918e-13,
  203. 5.456116108943412e-12,
  204. 4.878985199565852e-12,
  205. 4.240448995017367e-12,
  206. 3.559909094758252e-12,
  207. 2.858043359288075e-12,
  208. 2.156177623817898e-12,
  209. 1.475637723558783e-12,
  210. 8.371015190102974e-13,
  211. 2.599706096327376e-13,
  212. -5.456116108943412e-12,
  213. -4.878985199565852e-12,
  214. -4.240448995017367e-12,
  215. -3.559909094758252e-12,
  216. -2.858043359288076e-12,
  217. -2.156177623817898e-12,
  218. -1.475637723558783e-12,
  219. -8.371015190102975e-13,
  220. -2.599706096327376e-13,
  221. -2.382191739347923e-13,
  222. -6.423305872147843e-13,
  223. -9.400849094049696e-13,
  224. -1.122435026096556e-12,
  225. -1.183840321267481e-12,
  226. -1.122435026096556e-12,
  227. -9.400849094049694e-13,
  228. -6.423305872147840e-13,
  229. -2.382191739347918e-13,
  230. },
  231. {
  232. 2.382191739347913e-13,
  233. 6.423305872147834e-13,
  234. 9.400849094049688e-13,
  235. 1.122435026096556e-12,
  236. 1.183840321267481e-12,
  237. 1.122435026096556e-12,
  238. 9.400849094049688e-13,
  239. 6.423305872147841e-13,
  240. 2.382191739347918e-13,
  241. 5.456116108943413e-12,
  242. 4.878985199565852e-12,
  243. 4.240448995017367e-12,
  244. 3.559909094758253e-12,
  245. 2.858043359288075e-12,
  246. 2.156177623817898e-12,
  247. 1.475637723558782e-12,
  248. 8.371015190102975e-13,
  249. 2.599706096327376e-13,
  250. -5.461314069809755e-12,
  251. -4.921085770524055e-12,
  252. -4.343405037091838e-12,
  253. -3.732668368707687e-12,
  254. -3.093523840190885e-12,
  255. -2.430835727329465e-12,
  256. -1.734679010007751e-12,
  257. -9.748253656609281e-13,
  258. -2.797435120168326e-13,
  259. 0.000000000000000e+00,
  260. 0.000000000000000e+00,
  261. 0.000000000000000e+00,
  262. 0.000000000000000e+00,
  263. 0.000000000000000e+00,
  264. 0.000000000000000e+00,
  265. -2.283748241799531e-13,
  266. -4.037858874020686e-13,
  267. -2.146547464825323e-13,
  268. },
  269. {
  270. 1.316524975873958e-01, /* win[SHORT_TYPE] */
  271. 4.142135623730950e-01,
  272. 7.673269879789602e-01,
  273. 1.091308501069271e+00, /* tantab_l */
  274. 1.303225372841206e+00,
  275. 1.569685577117490e+00,
  276. 1.920982126971166e+00,
  277. 2.414213562373094e+00,
  278. 3.171594802363212e+00,
  279. 4.510708503662055e+00,
  280. 7.595754112725146e+00,
  281. 2.290376554843115e+01,
  282. 0.98480775301220802032, /* cx */
  283. 0.64278760968653936292,
  284. 0.34202014332566882393,
  285. 0.93969262078590842791,
  286. -0.17364817766693030343,
  287. -0.76604444311897790243,
  288. 0.86602540378443870761,
  289. 0.500000000000000e+00,
  290. -5.144957554275265e-01, /* ca */
  291. -4.717319685649723e-01,
  292. -3.133774542039019e-01,
  293. -1.819131996109812e-01,
  294. -9.457419252642064e-02,
  295. -4.096558288530405e-02,
  296. -1.419856857247115e-02,
  297. -3.699974673760037e-03,
  298. 8.574929257125442e-01, /* cs */
  299. 8.817419973177052e-01,
  300. 9.496286491027329e-01,
  301. 9.833145924917901e-01,
  302. 9.955178160675857e-01,
  303. 9.991605581781475e-01,
  304. 9.998991952444470e-01,
  305. 9.999931550702802e-01,
  306. },
  307. {
  308. 0.000000000000000e+00,
  309. 0.000000000000000e+00,
  310. 0.000000000000000e+00,
  311. 0.000000000000000e+00,
  312. 0.000000000000000e+00,
  313. 0.000000000000000e+00,
  314. 2.283748241799531e-13,
  315. 4.037858874020686e-13,
  316. 2.146547464825323e-13,
  317. 5.461314069809755e-12,
  318. 4.921085770524055e-12,
  319. 4.343405037091838e-12,
  320. 3.732668368707687e-12,
  321. 3.093523840190885e-12,
  322. 2.430835727329466e-12,
  323. 1.734679010007751e-12,
  324. 9.748253656609281e-13,
  325. 2.797435120168326e-13,
  326. -5.456116108943413e-12,
  327. -4.878985199565852e-12,
  328. -4.240448995017367e-12,
  329. -3.559909094758253e-12,
  330. -2.858043359288075e-12,
  331. -2.156177623817898e-12,
  332. -1.475637723558782e-12,
  333. -8.371015190102975e-13,
  334. -2.599706096327376e-13,
  335. -2.382191739347913e-13,
  336. -6.423305872147834e-13,
  337. -9.400849094049688e-13,
  338. -1.122435026096556e-12,
  339. -1.183840321267481e-12,
  340. -1.122435026096556e-12,
  341. -9.400849094049688e-13,
  342. -6.423305872147841e-13,
  343. -2.382191739347918e-13,
  344. }
  345. };
  346. #define tantab_l (win[SHORT_TYPE]+3)
  347. #define cx (win[SHORT_TYPE]+12)
  348. #define ca (win[SHORT_TYPE]+20)
  349. #define cs (win[SHORT_TYPE]+28)
  350. /************************************************************************
  351. *
  352. * window_subband()
  353. *
  354. * PURPOSE: Overlapping window on PCM samples
  355. *
  356. * SEMANTICS:
  357. * 32 16-bit pcm samples are scaled to fractional 2's complement and
  358. * concatenated to the end of the window buffer #x#. The updated window
  359. * buffer #x# is then windowed by the analysis window #c# to produce the
  360. * windowed sample #z#
  361. *
  362. ************************************************************************/
  363. /*
  364. * new IDCT routine written by Takehiro TOMINAGA
  365. */
  366. static const int order[] = {
  367. 0, 1, 16, 17, 8, 9, 24, 25, 4, 5, 20, 21, 12, 13, 28, 29,
  368. 2, 3, 18, 19, 10, 11, 26, 27, 6, 7, 22, 23, 14, 15, 30, 31
  369. };
  370. /* returns sum_j=0^31 a[j]*cos(PI*j*(k+1/2)/32), 0<=k<32 */
  371. inline static void
  372. window_subband(const sample_t * x1, FLOAT a[SBLIMIT])
  373. {
  374. int i;
  375. FLOAT const *wp = enwindow + 10;
  376. const sample_t *x2 = &x1[238 - 14 - 286];
  377. for (i = -15; i < 0; i++) {
  378. FLOAT w, s, t;
  379. w = wp[-10];
  380. s = x2[-224] * w;
  381. t = x1[224] * w;
  382. w = wp[-9];
  383. s += x2[-160] * w;
  384. t += x1[160] * w;
  385. w = wp[-8];
  386. s += x2[-96] * w;
  387. t += x1[96] * w;
  388. w = wp[-7];
  389. s += x2[-32] * w;
  390. t += x1[32] * w;
  391. w = wp[-6];
  392. s += x2[32] * w;
  393. t += x1[-32] * w;
  394. w = wp[-5];
  395. s += x2[96] * w;
  396. t += x1[-96] * w;
  397. w = wp[-4];
  398. s += x2[160] * w;
  399. t += x1[-160] * w;
  400. w = wp[-3];
  401. s += x2[224] * w;
  402. t += x1[-224] * w;
  403. w = wp[-2];
  404. s += x1[-256] * w;
  405. t -= x2[256] * w;
  406. w = wp[-1];
  407. s += x1[-192] * w;
  408. t -= x2[192] * w;
  409. w = wp[0];
  410. s += x1[-128] * w;
  411. t -= x2[128] * w;
  412. w = wp[1];
  413. s += x1[-64] * w;
  414. t -= x2[64] * w;
  415. w = wp[2];
  416. s += x1[0] * w;
  417. t -= x2[0] * w;
  418. w = wp[3];
  419. s += x1[64] * w;
  420. t -= x2[-64] * w;
  421. w = wp[4];
  422. s += x1[128] * w;
  423. t -= x2[-128] * w;
  424. w = wp[5];
  425. s += x1[192] * w;
  426. t -= x2[-192] * w;
  427. /*
  428. * this multiplyer could be removed, but it needs more 256 FLOAT data.
  429. * thinking about the data cache performance, I think we should not
  430. * use such a huge table. tt 2000/Oct/25
  431. */
  432. s *= wp[6];
  433. w = t - s;
  434. a[30 + i * 2] = t + s;
  435. a[31 + i * 2] = wp[7] * w;
  436. wp += 18;
  437. x1--;
  438. x2++;
  439. }
  440. {
  441. FLOAT s, t, u, v;
  442. t = x1[-16] * wp[-10];
  443. s = x1[-32] * wp[-2];
  444. t += (x1[-48] - x1[16]) * wp[-9];
  445. s += x1[-96] * wp[-1];
  446. t += (x1[-80] + x1[48]) * wp[-8];
  447. s += x1[-160] * wp[0];
  448. t += (x1[-112] - x1[80]) * wp[-7];
  449. s += x1[-224] * wp[1];
  450. t += (x1[-144] + x1[112]) * wp[-6];
  451. s -= x1[32] * wp[2];
  452. t += (x1[-176] - x1[144]) * wp[-5];
  453. s -= x1[96] * wp[3];
  454. t += (x1[-208] + x1[176]) * wp[-4];
  455. s -= x1[160] * wp[4];
  456. t += (x1[-240] - x1[208]) * wp[-3];
  457. s -= x1[224];
  458. u = s - t;
  459. v = s + t;
  460. t = a[14];
  461. s = a[15] - t;
  462. a[31] = v + t; /* A0 */
  463. a[30] = u + s; /* A1 */
  464. a[15] = u - s; /* A2 */
  465. a[14] = v - t; /* A3 */
  466. }
  467. {
  468. FLOAT xr;
  469. xr = a[28] - a[0];
  470. a[0] += a[28];
  471. a[28] = xr * wp[-2 * 18 + 7];
  472. xr = a[29] - a[1];
  473. a[1] += a[29];
  474. a[29] = xr * wp[-2 * 18 + 7];
  475. xr = a[26] - a[2];
  476. a[2] += a[26];
  477. a[26] = xr * wp[-4 * 18 + 7];
  478. xr = a[27] - a[3];
  479. a[3] += a[27];
  480. a[27] = xr * wp[-4 * 18 + 7];
  481. xr = a[24] - a[4];
  482. a[4] += a[24];
  483. a[24] = xr * wp[-6 * 18 + 7];
  484. xr = a[25] - a[5];
  485. a[5] += a[25];
  486. a[25] = xr * wp[-6 * 18 + 7];
  487. xr = a[22] - a[6];
  488. a[6] += a[22];
  489. a[22] = xr * SQRT2;
  490. xr = a[23] - a[7];
  491. a[7] += a[23];
  492. a[23] = xr * SQRT2 - a[7];
  493. a[7] -= a[6];
  494. a[22] -= a[7];
  495. a[23] -= a[22];
  496. xr = a[6];
  497. a[6] = a[31] - xr;
  498. a[31] = a[31] + xr;
  499. xr = a[7];
  500. a[7] = a[30] - xr;
  501. a[30] = a[30] + xr;
  502. xr = a[22];
  503. a[22] = a[15] - xr;
  504. a[15] = a[15] + xr;
  505. xr = a[23];
  506. a[23] = a[14] - xr;
  507. a[14] = a[14] + xr;
  508. xr = a[20] - a[8];
  509. a[8] += a[20];
  510. a[20] = xr * wp[-10 * 18 + 7];
  511. xr = a[21] - a[9];
  512. a[9] += a[21];
  513. a[21] = xr * wp[-10 * 18 + 7];
  514. xr = a[18] - a[10];
  515. a[10] += a[18];
  516. a[18] = xr * wp[-12 * 18 + 7];
  517. xr = a[19] - a[11];
  518. a[11] += a[19];
  519. a[19] = xr * wp[-12 * 18 + 7];
  520. xr = a[16] - a[12];
  521. a[12] += a[16];
  522. a[16] = xr * wp[-14 * 18 + 7];
  523. xr = a[17] - a[13];
  524. a[13] += a[17];
  525. a[17] = xr * wp[-14 * 18 + 7];
  526. xr = -a[20] + a[24];
  527. a[20] += a[24];
  528. a[24] = xr * wp[-12 * 18 + 7];
  529. xr = -a[21] + a[25];
  530. a[21] += a[25];
  531. a[25] = xr * wp[-12 * 18 + 7];
  532. xr = a[4] - a[8];
  533. a[4] += a[8];
  534. a[8] = xr * wp[-12 * 18 + 7];
  535. xr = a[5] - a[9];
  536. a[5] += a[9];
  537. a[9] = xr * wp[-12 * 18 + 7];
  538. xr = a[0] - a[12];
  539. a[0] += a[12];
  540. a[12] = xr * wp[-4 * 18 + 7];
  541. xr = a[1] - a[13];
  542. a[1] += a[13];
  543. a[13] = xr * wp[-4 * 18 + 7];
  544. xr = a[16] - a[28];
  545. a[16] += a[28];
  546. a[28] = xr * wp[-4 * 18 + 7];
  547. xr = -a[17] + a[29];
  548. a[17] += a[29];
  549. a[29] = xr * wp[-4 * 18 + 7];
  550. xr = SQRT2 * (a[2] - a[10]);
  551. a[2] += a[10];
  552. a[10] = xr;
  553. xr = SQRT2 * (a[3] - a[11]);
  554. a[3] += a[11];
  555. a[11] = xr;
  556. xr = SQRT2 * (-a[18] + a[26]);
  557. a[18] += a[26];
  558. a[26] = xr - a[18];
  559. xr = SQRT2 * (-a[19] + a[27]);
  560. a[19] += a[27];
  561. a[27] = xr - a[19];
  562. xr = a[2];
  563. a[19] -= a[3];
  564. a[3] -= xr;
  565. a[2] = a[31] - xr;
  566. a[31] += xr;
  567. xr = a[3];
  568. a[11] -= a[19];
  569. a[18] -= xr;
  570. a[3] = a[30] - xr;
  571. a[30] += xr;
  572. xr = a[18];
  573. a[27] -= a[11];
  574. a[19] -= xr;
  575. a[18] = a[15] - xr;
  576. a[15] += xr;
  577. xr = a[19];
  578. a[10] -= xr;
  579. a[19] = a[14] - xr;
  580. a[14] += xr;
  581. xr = a[10];
  582. a[11] -= xr;
  583. a[10] = a[23] - xr;
  584. a[23] += xr;
  585. xr = a[11];
  586. a[26] -= xr;
  587. a[11] = a[22] - xr;
  588. a[22] += xr;
  589. xr = a[26];
  590. a[27] -= xr;
  591. a[26] = a[7] - xr;
  592. a[7] += xr;
  593. xr = a[27];
  594. a[27] = a[6] - xr;
  595. a[6] += xr;
  596. xr = SQRT2 * (a[0] - a[4]);
  597. a[0] += a[4];
  598. a[4] = xr;
  599. xr = SQRT2 * (a[1] - a[5]);
  600. a[1] += a[5];
  601. a[5] = xr;
  602. xr = SQRT2 * (a[16] - a[20]);
  603. a[16] += a[20];
  604. a[20] = xr;
  605. xr = SQRT2 * (a[17] - a[21]);
  606. a[17] += a[21];
  607. a[21] = xr;
  608. xr = -SQRT2 * (a[8] - a[12]);
  609. a[8] += a[12];
  610. a[12] = xr - a[8];
  611. xr = -SQRT2 * (a[9] - a[13]);
  612. a[9] += a[13];
  613. a[13] = xr - a[9];
  614. xr = -SQRT2 * (a[25] - a[29]);
  615. a[25] += a[29];
  616. a[29] = xr - a[25];
  617. xr = -SQRT2 * (a[24] + a[28]);
  618. a[24] -= a[28];
  619. a[28] = xr - a[24];
  620. xr = a[24] - a[16];
  621. a[24] = xr;
  622. xr = a[20] - xr;
  623. a[20] = xr;
  624. xr = a[28] - xr;
  625. a[28] = xr;
  626. xr = a[25] - a[17];
  627. a[25] = xr;
  628. xr = a[21] - xr;
  629. a[21] = xr;
  630. xr = a[29] - xr;
  631. a[29] = xr;
  632. xr = a[17] - a[1];
  633. a[17] = xr;
  634. xr = a[9] - xr;
  635. a[9] = xr;
  636. xr = a[25] - xr;
  637. a[25] = xr;
  638. xr = a[5] - xr;
  639. a[5] = xr;
  640. xr = a[21] - xr;
  641. a[21] = xr;
  642. xr = a[13] - xr;
  643. a[13] = xr;
  644. xr = a[29] - xr;
  645. a[29] = xr;
  646. xr = a[1] - a[0];
  647. a[1] = xr;
  648. xr = a[16] - xr;
  649. a[16] = xr;
  650. xr = a[17] - xr;
  651. a[17] = xr;
  652. xr = a[8] - xr;
  653. a[8] = xr;
  654. xr = a[9] - xr;
  655. a[9] = xr;
  656. xr = a[24] - xr;
  657. a[24] = xr;
  658. xr = a[25] - xr;
  659. a[25] = xr;
  660. xr = a[4] - xr;
  661. a[4] = xr;
  662. xr = a[5] - xr;
  663. a[5] = xr;
  664. xr = a[20] - xr;
  665. a[20] = xr;
  666. xr = a[21] - xr;
  667. a[21] = xr;
  668. xr = a[12] - xr;
  669. a[12] = xr;
  670. xr = a[13] - xr;
  671. a[13] = xr;
  672. xr = a[28] - xr;
  673. a[28] = xr;
  674. xr = a[29] - xr;
  675. a[29] = xr;
  676. xr = a[0];
  677. a[0] += a[31];
  678. a[31] -= xr;
  679. xr = a[1];
  680. a[1] += a[30];
  681. a[30] -= xr;
  682. xr = a[16];
  683. a[16] += a[15];
  684. a[15] -= xr;
  685. xr = a[17];
  686. a[17] += a[14];
  687. a[14] -= xr;
  688. xr = a[8];
  689. a[8] += a[23];
  690. a[23] -= xr;
  691. xr = a[9];
  692. a[9] += a[22];
  693. a[22] -= xr;
  694. xr = a[24];
  695. a[24] += a[7];
  696. a[7] -= xr;
  697. xr = a[25];
  698. a[25] += a[6];
  699. a[6] -= xr;
  700. xr = a[4];
  701. a[4] += a[27];
  702. a[27] -= xr;
  703. xr = a[5];
  704. a[5] += a[26];
  705. a[26] -= xr;
  706. xr = a[20];
  707. a[20] += a[11];
  708. a[11] -= xr;
  709. xr = a[21];
  710. a[21] += a[10];
  711. a[10] -= xr;
  712. xr = a[12];
  713. a[12] += a[19];
  714. a[19] -= xr;
  715. xr = a[13];
  716. a[13] += a[18];
  717. a[18] -= xr;
  718. xr = a[28];
  719. a[28] += a[3];
  720. a[3] -= xr;
  721. xr = a[29];
  722. a[29] += a[2];
  723. a[2] -= xr;
  724. }
  725. }
  726. /*-------------------------------------------------------------------*/
  727. /* */
  728. /* Function: Calculation of the MDCT */
  729. /* In the case of long blocks (type 0,1,3) there are */
  730. /* 36 coefficents in the time domain and 18 in the frequency */
  731. /* domain. */
  732. /* In the case of short blocks (type 2) there are 3 */
  733. /* transformations with short length. This leads to 12 coefficents */
  734. /* in the time and 6 in the frequency domain. In this case the */
  735. /* results are stored side by side in the vector out[]. */
  736. /* */
  737. /* New layer3 */
  738. /* */
  739. /*-------------------------------------------------------------------*/
  740. inline static void
  741. mdct_short(FLOAT * inout)
  742. {
  743. int l;
  744. for (l = 0; l < 3; l++) {
  745. FLOAT tc0, tc1, tc2, ts0, ts1, ts2;
  746. ts0 = inout[2 * 3] * win[SHORT_TYPE][0] - inout[5 * 3];
  747. tc0 = inout[0 * 3] * win[SHORT_TYPE][2] - inout[3 * 3];
  748. tc1 = ts0 + tc0;
  749. tc2 = ts0 - tc0;
  750. ts0 = inout[5 * 3] * win[SHORT_TYPE][0] + inout[2 * 3];
  751. tc0 = inout[3 * 3] * win[SHORT_TYPE][2] + inout[0 * 3];
  752. ts1 = ts0 + tc0;
  753. ts2 = -ts0 + tc0;
  754. tc0 = (inout[1 * 3] * win[SHORT_TYPE][1] - inout[4 * 3]) * 2.069978111953089e-11; /* tritab_s[1] */
  755. ts0 = (inout[4 * 3] * win[SHORT_TYPE][1] + inout[1 * 3]) * 2.069978111953089e-11; /* tritab_s[1] */
  756. inout[3 * 0] = tc1 * 1.907525191737280e-11 /* tritab_s[2] */ + tc0;
  757. inout[3 * 5] = -ts1 * 1.907525191737280e-11 /* tritab_s[0] */ + ts0;
  758. tc2 = tc2 * 0.86602540378443870761 * 1.907525191737281e-11 /* tritab_s[2] */ ;
  759. ts1 = ts1 * 0.5 * 1.907525191737281e-11 + ts0;
  760. inout[3 * 1] = tc2 - ts1;
  761. inout[3 * 2] = tc2 + ts1;
  762. tc1 = tc1 * 0.5 * 1.907525191737281e-11 - tc0;
  763. ts2 = ts2 * 0.86602540378443870761 * 1.907525191737281e-11 /* tritab_s[0] */ ;
  764. inout[3 * 3] = tc1 + ts2;
  765. inout[3 * 4] = tc1 - ts2;
  766. inout++;
  767. }
  768. }
  769. inline static void
  770. mdct_long(FLOAT * out, FLOAT const *in)
  771. {
  772. FLOAT ct, st;
  773. {
  774. FLOAT tc1, tc2, tc3, tc4, ts5, ts6, ts7, ts8;
  775. /* 1,2, 5,6, 9,10, 13,14, 17 */
  776. tc1 = in[17] - in[9];
  777. tc3 = in[15] - in[11];
  778. tc4 = in[14] - in[12];
  779. ts5 = in[0] + in[8];
  780. ts6 = in[1] + in[7];
  781. ts7 = in[2] + in[6];
  782. ts8 = in[3] + in[5];
  783. out[17] = (ts5 + ts7 - ts8) - (ts6 - in[4]);
  784. st = (ts5 + ts7 - ts8) * cx[7] + (ts6 - in[4]);
  785. ct = (tc1 - tc3 - tc4) * cx[6];
  786. out[5] = ct + st;
  787. out[6] = ct - st;
  788. tc2 = (in[16] - in[10]) * cx[6];
  789. ts6 = ts6 * cx[7] + in[4];
  790. ct = tc1 * cx[0] + tc2 + tc3 * cx[1] + tc4 * cx[2];
  791. st = -ts5 * cx[4] + ts6 - ts7 * cx[5] + ts8 * cx[3];
  792. out[1] = ct + st;
  793. out[2] = ct - st;
  794. ct = tc1 * cx[1] - tc2 - tc3 * cx[2] + tc4 * cx[0];
  795. st = -ts5 * cx[5] + ts6 - ts7 * cx[3] + ts8 * cx[4];
  796. out[9] = ct + st;
  797. out[10] = ct - st;
  798. ct = tc1 * cx[2] - tc2 + tc3 * cx[0] - tc4 * cx[1];
  799. st = ts5 * cx[3] - ts6 + ts7 * cx[4] - ts8 * cx[5];
  800. out[13] = ct + st;
  801. out[14] = ct - st;
  802. }
  803. {
  804. FLOAT ts1, ts2, ts3, ts4, tc5, tc6, tc7, tc8;
  805. ts1 = in[8] - in[0];
  806. ts3 = in[6] - in[2];
  807. ts4 = in[5] - in[3];
  808. tc5 = in[17] + in[9];
  809. tc6 = in[16] + in[10];
  810. tc7 = in[15] + in[11];
  811. tc8 = in[14] + in[12];
  812. out[0] = (tc5 + tc7 + tc8) + (tc6 + in[13]);
  813. ct = (tc5 + tc7 + tc8) * cx[7] - (tc6 + in[13]);
  814. st = (ts1 - ts3 + ts4) * cx[6];
  815. out[11] = ct + st;
  816. out[12] = ct - st;
  817. ts2 = (in[7] - in[1]) * cx[6];
  818. tc6 = in[13] - tc6 * cx[7];
  819. ct = tc5 * cx[3] - tc6 + tc7 * cx[4] + tc8 * cx[5];
  820. st = ts1 * cx[2] + ts2 + ts3 * cx[0] + ts4 * cx[1];
  821. out[3] = ct + st;
  822. out[4] = ct - st;
  823. ct = -tc5 * cx[5] + tc6 - tc7 * cx[3] - tc8 * cx[4];
  824. st = ts1 * cx[1] + ts2 - ts3 * cx[2] - ts4 * cx[0];
  825. out[7] = ct + st;
  826. out[8] = ct - st;
  827. ct = -tc5 * cx[4] + tc6 - tc7 * cx[5] - tc8 * cx[3];
  828. st = ts1 * cx[0] - ts2 + ts3 * cx[1] - ts4 * cx[2];
  829. out[15] = ct + st;
  830. out[16] = ct - st;
  831. }
  832. }
  833. void
  834. mdct_sub48(lame_internal_flags * gfc, const sample_t * w0, const sample_t * w1)
  835. {
  836. SessionConfig_t const *const cfg = &gfc->cfg;
  837. EncStateVar_t *const esv = &gfc->sv_enc;
  838. int gr, k, ch;
  839. const sample_t *wk;
  840. wk = w0 + 286;
  841. /* thinking cache performance, ch->gr loop is better than gr->ch loop */
  842. for (ch = 0; ch < cfg->channels_out; ch++) {
  843. for (gr = 0; gr < cfg->mode_gr; gr++) {
  844. int band;
  845. gr_info *const gi = &(gfc->l3_side.tt[gr][ch]);
  846. FLOAT *mdct_enc = gi->xr;
  847. FLOAT *samp = esv->sb_sample[ch][1 - gr][0];
  848. for (k = 0; k < 18 / 2; k++) {
  849. window_subband(wk, samp);
  850. window_subband(wk + 32, samp + 32);
  851. samp += 64;
  852. wk += 64;
  853. /*
  854. * Compensate for inversion in the analysis filter
  855. */
  856. for (band = 1; band < 32; band += 2) {
  857. samp[band - 32] *= -1;
  858. }
  859. }
  860. /*
  861. * Perform imdct of 18 previous subband samples
  862. * + 18 current subband samples
  863. */
  864. for (band = 0; band < 32; band++, mdct_enc += 18) {
  865. int type = gi->block_type;
  866. FLOAT const *const band0 = esv->sb_sample[ch][gr][0] + order[band];
  867. FLOAT *const band1 = esv->sb_sample[ch][1 - gr][0] + order[band];
  868. if (gi->mixed_block_flag && band < 2)
  869. type = 0;
  870. if (esv->amp_filter[band] < 1e-12) {
  871. memset(mdct_enc, 0, 18 * sizeof(FLOAT));
  872. }
  873. else {
  874. if (esv->amp_filter[band] < 1.0) {
  875. for (k = 0; k < 18; k++)
  876. band1[k * 32] *= esv->amp_filter[band];
  877. }
  878. if (type == SHORT_TYPE) {
  879. for (k = -NS / 4; k < 0; k++) {
  880. FLOAT const w = win[SHORT_TYPE][k + 3];
  881. mdct_enc[k * 3 + 9] = band0[(9 + k) * 32] * w - band0[(8 - k) * 32];
  882. mdct_enc[k * 3 + 18] = band0[(14 - k) * 32] * w + band0[(15 + k) * 32];
  883. mdct_enc[k * 3 + 10] = band0[(15 + k) * 32] * w - band0[(14 - k) * 32];
  884. mdct_enc[k * 3 + 19] = band1[(2 - k) * 32] * w + band1[(3 + k) * 32];
  885. mdct_enc[k * 3 + 11] = band1[(3 + k) * 32] * w - band1[(2 - k) * 32];
  886. mdct_enc[k * 3 + 20] = band1[(8 - k) * 32] * w + band1[(9 + k) * 32];
  887. }
  888. mdct_short(mdct_enc);
  889. }
  890. else {
  891. FLOAT work[18];
  892. for (k = -NL / 4; k < 0; k++) {
  893. FLOAT a, b;
  894. a = win[type][k + 27] * band1[(k + 9) * 32]
  895. + win[type][k + 36] * band1[(8 - k) * 32];
  896. b = win[type][k + 9] * band0[(k + 9) * 32]
  897. - win[type][k + 18] * band0[(8 - k) * 32];
  898. work[k + 9] = a - b * tantab_l[k + 9];
  899. work[k + 18] = a * tantab_l[k + 9] + b;
  900. }
  901. mdct_long(mdct_enc, work);
  902. }
  903. }
  904. /*
  905. * Perform aliasing reduction butterfly
  906. */
  907. if (type != SHORT_TYPE && band != 0) {
  908. for (k = 7; k >= 0; --k) {
  909. FLOAT bu, bd;
  910. bu = mdct_enc[k] * ca[k] + mdct_enc[-1 - k] * cs[k];
  911. bd = mdct_enc[k] * cs[k] - mdct_enc[-1 - k] * ca[k];
  912. mdct_enc[-1 - k] = bu;
  913. mdct_enc[k] = bd;
  914. }
  915. }
  916. }
  917. }
  918. wk = w1 + 286;
  919. if (cfg->mode_gr == 1) {
  920. memcpy(esv->sb_sample[ch][0], esv->sb_sample[ch][1], 576 * sizeof(FLOAT));
  921. }
  922. }
  923. }