patch-libavcodec_aactab_h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. $OpenBSD: patch-libavcodec_aactab_h,v 1.2 2015/12/06 08:51:46 ajacoutot Exp $
  2. aactab: move ltp_coef[] from aacdectab to aactab
  3. avcodec/aac_tablegen: get rid of hardcoded tables entirely
  4. --- libavcodec/aactab.h.orig Thu Nov 12 02:08:28 2015
  5. +++ libavcodec/aactab.h Sun Nov 29 18:31:00 2015
  6. @@ -32,14 +32,69 @@
  7. #include "libavutil/mem.h"
  8. #include "aac.h"
  9. -#include "aac_tablegen_decl.h"
  10. #include <stdint.h>
  11. /* NOTE:
  12. - * Tables in this file are used by the AAC decoder and will be used by the AAC
  13. - * encoder.
  14. + * Tables in this file are shared by the AAC decoders and encoder
  15. */
  16. +
  17. +extern float ff_aac_pow2sf_tab[428];
  18. +extern float ff_aac_pow34sf_tab[428];
  19. +
  20. +static inline void ff_aac_tableinit(void)
  21. +{
  22. + int i;
  23. +
  24. + /* 2^(i/16) for 0 <= i <= 15 */
  25. + static const float exp2_lut[] = {
  26. + 1.00000000000000000000,
  27. + 1.04427378242741384032,
  28. + 1.09050773266525765921,
  29. + 1.13878863475669165370,
  30. + 1.18920711500272106672,
  31. + 1.24185781207348404859,
  32. + 1.29683955465100966593,
  33. + 1.35425554693689272830,
  34. + 1.41421356237309504880,
  35. + 1.47682614593949931139,
  36. + 1.54221082540794082361,
  37. + 1.61049033194925430818,
  38. + 1.68179283050742908606,
  39. + 1.75625216037329948311,
  40. + 1.83400808640934246349,
  41. + 1.91520656139714729387,
  42. + };
  43. + float t1 = 8.8817841970012523233890533447265625e-16; // 2^(-50)
  44. + float t2 = 3.63797880709171295166015625e-12; // 2^(-38)
  45. + int t1_inc_cur, t2_inc_cur;
  46. + int t1_inc_prev = 0;
  47. + int t2_inc_prev = 8;
  48. +
  49. + for (i = 0; i < 428; i++) {
  50. + t1_inc_cur = 4 * (i % 4);
  51. + t2_inc_cur = (8 + 3*i) % 16;
  52. + if (t1_inc_cur < t1_inc_prev)
  53. + t1 *= 2;
  54. + if (t2_inc_cur < t2_inc_prev)
  55. + t2 *= 2;
  56. + // A much more efficient and accurate way of doing:
  57. + // ff_aac_pow2sf_tab[i] = pow(2, (i - POW_SF2_ZERO) / 4.0);
  58. + // ff_aac_pow34sf_tab[i] = pow(ff_aac_pow2sf_tab[i], 3.0/4.0);
  59. + ff_aac_pow2sf_tab[i] = t1 * exp2_lut[t1_inc_cur];
  60. + ff_aac_pow34sf_tab[i] = t2 * exp2_lut[t2_inc_cur];
  61. + t1_inc_prev = t1_inc_cur;
  62. + t2_inc_prev = t2_inc_cur;
  63. + }
  64. +}
  65. +
  66. +/* @name ltp_coef
  67. + * Table of the LTP coefficients
  68. + */
  69. +static const INTFLOAT ltp_coef[8] = {
  70. + Q30(0.570829f), Q30(0.696616f), Q30(0.813004f), Q30(0.911304f),
  71. + Q30(0.984900f), Q30(1.067894f), Q30(1.194601f), Q30(1.369533f),
  72. +};
  73. /* @name tns_tmp2_map
  74. * Tables of the tmp2[] arrays of LPC coefficients used for TNS.