You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

330 lines
13KB

  1. /*
  2. * Bluetooth low-complexity, subband codec (SBC)
  3. *
  4. * Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org>
  5. * Copyright (C) 2008-2010 Nokia Corporation
  6. * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
  7. * Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
  8. * Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
  9. *
  10. * This file is part of FFmpeg.
  11. *
  12. * FFmpeg is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2.1 of the License, or (at your option) any later version.
  16. *
  17. * FFmpeg is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with FFmpeg; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. */
  26. /**
  27. * @file
  28. * miscellaneous SBC tables
  29. */
  30. #include "sbcdsp_data.h"
  31. #define F_PROTO(x) ((int32_t) (((x) * 2) * ((int32_t) 1 << 15) + 0.5))
  32. #define F_COS(x) ((int32_t) (((x) ) * ((int32_t) 1 << 15) + 0.5))
  33. /*
  34. * Constant tables for the use in SIMD optimized analysis filters
  35. * Each table consists of two parts:
  36. * 1. reordered "proto" table
  37. * 2. reordered "cos" table
  38. *
  39. * Due to non-symmetrical reordering, separate tables for "even"
  40. * and "odd" cases are needed
  41. */
  42. DECLARE_ALIGNED(SBC_ALIGN, const int16_t, ff_sbcdsp_analysis_consts_fixed4_simd_even)[40 + 16] = {
  43. #define C0 1.0932568993
  44. #define C1 1.3056875580
  45. #define C2 1.3056875580
  46. #define C3 1.6772280856
  47. #define F(x) F_PROTO(x)
  48. F(0.00000000E+00 * C0), F(3.83720193E-03 * C0),
  49. F(5.36548976E-04 * C1), F(2.73370904E-03 * C1),
  50. F(3.06012286E-03 * C2), F(3.89205149E-03 * C2),
  51. F(0.00000000E+00 * C3), -F(1.49188357E-03 * C3),
  52. F(1.09137620E-02 * C0), F(2.58767811E-02 * C0),
  53. F(2.04385087E-02 * C1), F(3.21939290E-02 * C1),
  54. F(7.76463494E-02 * C2), F(6.13245186E-03 * C2),
  55. F(0.00000000E+00 * C3), -F(2.88757392E-02 * C3),
  56. F(1.35593274E-01 * C0), F(2.94315332E-01 * C0),
  57. F(1.94987841E-01 * C1), F(2.81828203E-01 * C1),
  58. -F(1.94987841E-01 * C2), F(2.81828203E-01 * C2),
  59. F(0.00000000E+00 * C3), -F(2.46636662E-01 * C3),
  60. -F(1.35593274E-01 * C0), F(2.58767811E-02 * C0),
  61. -F(7.76463494E-02 * C1), F(6.13245186E-03 * C1),
  62. -F(2.04385087E-02 * C2), F(3.21939290E-02 * C2),
  63. F(0.00000000E+00 * C3), F(2.88217274E-02 * C3),
  64. -F(1.09137620E-02 * C0), F(3.83720193E-03 * C0),
  65. -F(3.06012286E-03 * C1), F(3.89205149E-03 * C1),
  66. -F(5.36548976E-04 * C2), F(2.73370904E-03 * C2),
  67. F(0.00000000E+00 * C3), -F(1.86581691E-03 * C3),
  68. #undef F
  69. #define F(x) F_COS(x)
  70. F(0.7071067812 / C0), F(0.9238795325 / C1),
  71. -F(0.7071067812 / C0), F(0.3826834324 / C1),
  72. -F(0.7071067812 / C0), -F(0.3826834324 / C1),
  73. F(0.7071067812 / C0), -F(0.9238795325 / C1),
  74. F(0.3826834324 / C2), -F(1.0000000000 / C3),
  75. -F(0.9238795325 / C2), -F(1.0000000000 / C3),
  76. F(0.9238795325 / C2), -F(1.0000000000 / C3),
  77. -F(0.3826834324 / C2), -F(1.0000000000 / C3),
  78. #undef F
  79. #undef C0
  80. #undef C1
  81. #undef C2
  82. #undef C3
  83. };
  84. DECLARE_ALIGNED(SBC_ALIGN, const int16_t, ff_sbcdsp_analysis_consts_fixed4_simd_odd)[40 + 16] = {
  85. #define C0 1.3056875580
  86. #define C1 1.6772280856
  87. #define C2 1.0932568993
  88. #define C3 1.3056875580
  89. #define F(x) F_PROTO(x)
  90. F(2.73370904E-03 * C0), F(5.36548976E-04 * C0),
  91. -F(1.49188357E-03 * C1), F(0.00000000E+00 * C1),
  92. F(3.83720193E-03 * C2), F(1.09137620E-02 * C2),
  93. F(3.89205149E-03 * C3), F(3.06012286E-03 * C3),
  94. F(3.21939290E-02 * C0), F(2.04385087E-02 * C0),
  95. -F(2.88757392E-02 * C1), F(0.00000000E+00 * C1),
  96. F(2.58767811E-02 * C2), F(1.35593274E-01 * C2),
  97. F(6.13245186E-03 * C3), F(7.76463494E-02 * C3),
  98. F(2.81828203E-01 * C0), F(1.94987841E-01 * C0),
  99. -F(2.46636662E-01 * C1), F(0.00000000E+00 * C1),
  100. F(2.94315332E-01 * C2), -F(1.35593274E-01 * C2),
  101. F(2.81828203E-01 * C3), -F(1.94987841E-01 * C3),
  102. F(6.13245186E-03 * C0), -F(7.76463494E-02 * C0),
  103. F(2.88217274E-02 * C1), F(0.00000000E+00 * C1),
  104. F(2.58767811E-02 * C2), -F(1.09137620E-02 * C2),
  105. F(3.21939290E-02 * C3), -F(2.04385087E-02 * C3),
  106. F(3.89205149E-03 * C0), -F(3.06012286E-03 * C0),
  107. -F(1.86581691E-03 * C1), F(0.00000000E+00 * C1),
  108. F(3.83720193E-03 * C2), F(0.00000000E+00 * C2),
  109. F(2.73370904E-03 * C3), -F(5.36548976E-04 * C3),
  110. #undef F
  111. #define F(x) F_COS(x)
  112. F(0.9238795325 / C0), -F(1.0000000000 / C1),
  113. F(0.3826834324 / C0), -F(1.0000000000 / C1),
  114. -F(0.3826834324 / C0), -F(1.0000000000 / C1),
  115. -F(0.9238795325 / C0), -F(1.0000000000 / C1),
  116. F(0.7071067812 / C2), F(0.3826834324 / C3),
  117. -F(0.7071067812 / C2), -F(0.9238795325 / C3),
  118. -F(0.7071067812 / C2), F(0.9238795325 / C3),
  119. F(0.7071067812 / C2), -F(0.3826834324 / C3),
  120. #undef F
  121. #undef C0
  122. #undef C1
  123. #undef C2
  124. #undef C3
  125. };
  126. DECLARE_ALIGNED(SBC_ALIGN, const int16_t, ff_sbcdsp_analysis_consts_fixed8_simd_even)[80 + 64] = {
  127. #define C0 2.7906148894
  128. #define C1 2.4270044280
  129. #define C2 2.8015616024
  130. #define C3 3.1710363741
  131. #define C4 2.5377944043
  132. #define C5 2.4270044280
  133. #define C6 2.8015616024
  134. #define C7 3.1710363741
  135. #define F(x) F_PROTO(x)
  136. F(0.00000000E+00 * C0), F(2.01182542E-03 * C0),
  137. F(1.56575398E-04 * C1), F(1.78371725E-03 * C1),
  138. F(3.43256425E-04 * C2), F(1.47640169E-03 * C2),
  139. F(5.54620202E-04 * C3), F(1.13992507E-03 * C3),
  140. -F(8.23919506E-04 * C4), F(0.00000000E+00 * C4),
  141. F(2.10371989E-03 * C5), F(3.49717454E-03 * C5),
  142. F(1.99454554E-03 * C6), F(1.64973098E-03 * C6),
  143. F(1.61656283E-03 * C7), F(1.78805361E-04 * C7),
  144. F(5.65949473E-03 * C0), F(1.29371806E-02 * C0),
  145. F(8.02941163E-03 * C1), F(1.53184106E-02 * C1),
  146. F(1.04584443E-02 * C2), F(1.62208471E-02 * C2),
  147. F(1.27472335E-02 * C3), F(1.59045603E-02 * C3),
  148. -F(1.46525263E-02 * C4), F(0.00000000E+00 * C4),
  149. F(8.85757540E-03 * C5), F(5.31873032E-02 * C5),
  150. F(2.92408442E-03 * C6), F(3.90751381E-02 * C6),
  151. -F(4.91578024E-03 * C7), F(2.61098752E-02 * C7),
  152. F(6.79989431E-02 * C0), F(1.46955068E-01 * C0),
  153. F(8.29847578E-02 * C1), F(1.45389847E-01 * C1),
  154. F(9.75753918E-02 * C2), F(1.40753505E-01 * C2),
  155. F(1.11196689E-01 * C3), F(1.33264415E-01 * C3),
  156. -F(1.23264548E-01 * C4), F(0.00000000E+00 * C4),
  157. F(1.45389847E-01 * C5), -F(8.29847578E-02 * C5),
  158. F(1.40753505E-01 * C6), -F(9.75753918E-02 * C6),
  159. F(1.33264415E-01 * C7), -F(1.11196689E-01 * C7),
  160. -F(6.79989431E-02 * C0), F(1.29371806E-02 * C0),
  161. -F(5.31873032E-02 * C1), F(8.85757540E-03 * C1),
  162. -F(3.90751381E-02 * C2), F(2.92408442E-03 * C2),
  163. -F(2.61098752E-02 * C3), -F(4.91578024E-03 * C3),
  164. F(1.46404076E-02 * C4), F(0.00000000E+00 * C4),
  165. F(1.53184106E-02 * C5), -F(8.02941163E-03 * C5),
  166. F(1.62208471E-02 * C6), -F(1.04584443E-02 * C6),
  167. F(1.59045603E-02 * C7), -F(1.27472335E-02 * C7),
  168. -F(5.65949473E-03 * C0), F(2.01182542E-03 * C0),
  169. -F(3.49717454E-03 * C1), F(2.10371989E-03 * C1),
  170. -F(1.64973098E-03 * C2), F(1.99454554E-03 * C2),
  171. -F(1.78805361E-04 * C3), F(1.61656283E-03 * C3),
  172. -F(9.02154502E-04 * C4), F(0.00000000E+00 * C4),
  173. F(1.78371725E-03 * C5), -F(1.56575398E-04 * C5),
  174. F(1.47640169E-03 * C6), -F(3.43256425E-04 * C6),
  175. F(1.13992507E-03 * C7), -F(5.54620202E-04 * C7),
  176. #undef F
  177. #define F(x) F_COS(x)
  178. F(0.7071067812 / C0), F(0.8314696123 / C1),
  179. -F(0.7071067812 / C0), -F(0.1950903220 / C1),
  180. -F(0.7071067812 / C0), -F(0.9807852804 / C1),
  181. F(0.7071067812 / C0), -F(0.5555702330 / C1),
  182. F(0.7071067812 / C0), F(0.5555702330 / C1),
  183. -F(0.7071067812 / C0), F(0.9807852804 / C1),
  184. -F(0.7071067812 / C0), F(0.1950903220 / C1),
  185. F(0.7071067812 / C0), -F(0.8314696123 / C1),
  186. F(0.9238795325 / C2), F(0.9807852804 / C3),
  187. F(0.3826834324 / C2), F(0.8314696123 / C3),
  188. -F(0.3826834324 / C2), F(0.5555702330 / C3),
  189. -F(0.9238795325 / C2), F(0.1950903220 / C3),
  190. -F(0.9238795325 / C2), -F(0.1950903220 / C3),
  191. -F(0.3826834324 / C2), -F(0.5555702330 / C3),
  192. F(0.3826834324 / C2), -F(0.8314696123 / C3),
  193. F(0.9238795325 / C2), -F(0.9807852804 / C3),
  194. -F(1.0000000000 / C4), F(0.5555702330 / C5),
  195. -F(1.0000000000 / C4), -F(0.9807852804 / C5),
  196. -F(1.0000000000 / C4), F(0.1950903220 / C5),
  197. -F(1.0000000000 / C4), F(0.8314696123 / C5),
  198. -F(1.0000000000 / C4), -F(0.8314696123 / C5),
  199. -F(1.0000000000 / C4), -F(0.1950903220 / C5),
  200. -F(1.0000000000 / C4), F(0.9807852804 / C5),
  201. -F(1.0000000000 / C4), -F(0.5555702330 / C5),
  202. F(0.3826834324 / C6), F(0.1950903220 / C7),
  203. -F(0.9238795325 / C6), -F(0.5555702330 / C7),
  204. F(0.9238795325 / C6), F(0.8314696123 / C7),
  205. -F(0.3826834324 / C6), -F(0.9807852804 / C7),
  206. -F(0.3826834324 / C6), F(0.9807852804 / C7),
  207. F(0.9238795325 / C6), -F(0.8314696123 / C7),
  208. -F(0.9238795325 / C6), F(0.5555702330 / C7),
  209. F(0.3826834324 / C6), -F(0.1950903220 / C7),
  210. #undef F
  211. #undef C0
  212. #undef C1
  213. #undef C2
  214. #undef C3
  215. #undef C4
  216. #undef C5
  217. #undef C6
  218. #undef C7
  219. };
  220. DECLARE_ALIGNED(SBC_ALIGN, const int16_t, ff_sbcdsp_analysis_consts_fixed8_simd_odd)[80 + 64] = {
  221. #define C0 2.5377944043
  222. #define C1 2.4270044280
  223. #define C2 2.8015616024
  224. #define C3 3.1710363741
  225. #define C4 2.7906148894
  226. #define C5 2.4270044280
  227. #define C6 2.8015616024
  228. #define C7 3.1710363741
  229. #define F(x) F_PROTO(x)
  230. F(0.00000000E+00 * C0), -F(8.23919506E-04 * C0),
  231. F(1.56575398E-04 * C1), F(1.78371725E-03 * C1),
  232. F(3.43256425E-04 * C2), F(1.47640169E-03 * C2),
  233. F(5.54620202E-04 * C3), F(1.13992507E-03 * C3),
  234. F(2.01182542E-03 * C4), F(5.65949473E-03 * C4),
  235. F(2.10371989E-03 * C5), F(3.49717454E-03 * C5),
  236. F(1.99454554E-03 * C6), F(1.64973098E-03 * C6),
  237. F(1.61656283E-03 * C7), F(1.78805361E-04 * C7),
  238. F(0.00000000E+00 * C0), -F(1.46525263E-02 * C0),
  239. F(8.02941163E-03 * C1), F(1.53184106E-02 * C1),
  240. F(1.04584443E-02 * C2), F(1.62208471E-02 * C2),
  241. F(1.27472335E-02 * C3), F(1.59045603E-02 * C3),
  242. F(1.29371806E-02 * C4), F(6.79989431E-02 * C4),
  243. F(8.85757540E-03 * C5), F(5.31873032E-02 * C5),
  244. F(2.92408442E-03 * C6), F(3.90751381E-02 * C6),
  245. -F(4.91578024E-03 * C7), F(2.61098752E-02 * C7),
  246. F(0.00000000E+00 * C0), -F(1.23264548E-01 * C0),
  247. F(8.29847578E-02 * C1), F(1.45389847E-01 * C1),
  248. F(9.75753918E-02 * C2), F(1.40753505E-01 * C2),
  249. F(1.11196689E-01 * C3), F(1.33264415E-01 * C3),
  250. F(1.46955068E-01 * C4), -F(6.79989431E-02 * C4),
  251. F(1.45389847E-01 * C5), -F(8.29847578E-02 * C5),
  252. F(1.40753505E-01 * C6), -F(9.75753918E-02 * C6),
  253. F(1.33264415E-01 * C7), -F(1.11196689E-01 * C7),
  254. F(0.00000000E+00 * C0), F(1.46404076E-02 * C0),
  255. -F(5.31873032E-02 * C1), F(8.85757540E-03 * C1),
  256. -F(3.90751381E-02 * C2), F(2.92408442E-03 * C2),
  257. -F(2.61098752E-02 * C3), -F(4.91578024E-03 * C3),
  258. F(1.29371806E-02 * C4), -F(5.65949473E-03 * C4),
  259. F(1.53184106E-02 * C5), -F(8.02941163E-03 * C5),
  260. F(1.62208471E-02 * C6), -F(1.04584443E-02 * C6),
  261. F(1.59045603E-02 * C7), -F(1.27472335E-02 * C7),
  262. F(0.00000000E+00 * C0), -F(9.02154502E-04 * C0),
  263. -F(3.49717454E-03 * C1), F(2.10371989E-03 * C1),
  264. -F(1.64973098E-03 * C2), F(1.99454554E-03 * C2),
  265. -F(1.78805361E-04 * C3), F(1.61656283E-03 * C3),
  266. F(2.01182542E-03 * C4), F(0.00000000E+00 * C4),
  267. F(1.78371725E-03 * C5), -F(1.56575398E-04 * C5),
  268. F(1.47640169E-03 * C6), -F(3.43256425E-04 * C6),
  269. F(1.13992507E-03 * C7), -F(5.54620202E-04 * C7),
  270. #undef F
  271. #define F(x) F_COS(x)
  272. -F(1.0000000000 / C0), F(0.8314696123 / C1),
  273. -F(1.0000000000 / C0), -F(0.1950903220 / C1),
  274. -F(1.0000000000 / C0), -F(0.9807852804 / C1),
  275. -F(1.0000000000 / C0), -F(0.5555702330 / C1),
  276. -F(1.0000000000 / C0), F(0.5555702330 / C1),
  277. -F(1.0000000000 / C0), F(0.9807852804 / C1),
  278. -F(1.0000000000 / C0), F(0.1950903220 / C1),
  279. -F(1.0000000000 / C0), -F(0.8314696123 / C1),
  280. F(0.9238795325 / C2), F(0.9807852804 / C3),
  281. F(0.3826834324 / C2), F(0.8314696123 / C3),
  282. -F(0.3826834324 / C2), F(0.5555702330 / C3),
  283. -F(0.9238795325 / C2), F(0.1950903220 / C3),
  284. -F(0.9238795325 / C2), -F(0.1950903220 / C3),
  285. -F(0.3826834324 / C2), -F(0.5555702330 / C3),
  286. F(0.3826834324 / C2), -F(0.8314696123 / C3),
  287. F(0.9238795325 / C2), -F(0.9807852804 / C3),
  288. F(0.7071067812 / C4), F(0.5555702330 / C5),
  289. -F(0.7071067812 / C4), -F(0.9807852804 / C5),
  290. -F(0.7071067812 / C4), F(0.1950903220 / C5),
  291. F(0.7071067812 / C4), F(0.8314696123 / C5),
  292. F(0.7071067812 / C4), -F(0.8314696123 / C5),
  293. -F(0.7071067812 / C4), -F(0.1950903220 / C5),
  294. -F(0.7071067812 / C4), F(0.9807852804 / C5),
  295. F(0.7071067812 / C4), -F(0.5555702330 / C5),
  296. F(0.3826834324 / C6), F(0.1950903220 / C7),
  297. -F(0.9238795325 / C6), -F(0.5555702330 / C7),
  298. F(0.9238795325 / C6), F(0.8314696123 / C7),
  299. -F(0.3826834324 / C6), -F(0.9807852804 / C7),
  300. -F(0.3826834324 / C6), F(0.9807852804 / C7),
  301. F(0.9238795325 / C6), -F(0.8314696123 / C7),
  302. -F(0.9238795325 / C6), F(0.5555702330 / C7),
  303. F(0.3826834324 / C6), -F(0.1950903220 / C7),
  304. #undef F
  305. #undef C0
  306. #undef C1
  307. #undef C2
  308. #undef C3
  309. #undef C4
  310. #undef C5
  311. #undef C6
  312. #undef C7
  313. };