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.

73 lines
2.3KB

  1. /*
  2. * Header file for hardcoded shared mpegaudiodec tables
  3. *
  4. * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
  5. * Copyright (c) 2020 Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVCODEC_MPEGAUDIODEC_COMMON_TABLEGEN_H
  24. #define AVCODEC_MPEGAUDIODEC_COMMON_TABLEGEN_H
  25. #include <stdint.h>
  26. #define TABLE_4_3_SIZE ((8191 + 16)*4)
  27. #if CONFIG_HARDCODED_TABLES
  28. #define mpegaudiodec_common_tableinit()
  29. #include "libavcodec/mpegaudiodec_common_tables.h"
  30. #else
  31. #include <math.h>
  32. #include "libavutil/attributes.h"
  33. int8_t ff_table_4_3_exp [TABLE_4_3_SIZE];
  34. uint32_t ff_table_4_3_value[TABLE_4_3_SIZE];
  35. #define FRAC_BITS 23
  36. #define IMDCT_SCALAR 1.759
  37. static av_cold void mpegaudiodec_common_tableinit(void)
  38. {
  39. static const double exp2_lut[4] = {
  40. 1.00000000000000000000, /* 2 ^ (0 * 0.25) */
  41. 1.18920711500272106672, /* 2 ^ (1 * 0.25) */
  42. M_SQRT2 , /* 2 ^ (2 * 0.25) */
  43. 1.68179283050742908606, /* 2 ^ (3 * 0.25) */
  44. };
  45. double pow43_val = 0;
  46. for (int i = 1; i < TABLE_4_3_SIZE; i++) {
  47. double f, fm;
  48. int e, m;
  49. double value = i / 4;
  50. if ((i & 3) == 0)
  51. pow43_val = value / IMDCT_SCALAR * cbrt(value);
  52. f = pow43_val * exp2_lut[i & 3];
  53. fm = frexp(f, &e);
  54. m = llrint(fm * (1LL << 31));
  55. e += FRAC_BITS - 31 + 5 - 100;
  56. /* normalized to FRAC_BITS */
  57. ff_table_4_3_value[i] = m;
  58. ff_table_4_3_exp [i] = -e;
  59. }
  60. }
  61. #endif /* CONFIG_HARDCODED_TABLES */
  62. #endif /* AVCODEC_MPEGAUDIODEC_COMMON_TABLEGEN_H */