aacps_tablegen_template.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Generate a header file for hardcoded Parametric Stereo tables
  3. *
  4. * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include <stdlib.h>
  23. #define CONFIG_HARDCODED_TABLES 0
  24. #include "aac_defines.h"
  25. #if USE_FIXED
  26. #define TYPE_NAME "int32_t"
  27. typedef int32_t INT32FLOAT;
  28. #define ARRAY_RENAME(x) write_int32_t_ ## x
  29. #define ARRAY_URENAME(x) write_uint32_t_ ## x
  30. #include "aacps_fixed_tablegen.h"
  31. #else
  32. #define TYPE_NAME "float"
  33. typedef float INT32FLOAT;
  34. #define ARRAY_RENAME(x) write_float_ ## x
  35. #define ARRAY_URENAME(x) write_float_ ## x
  36. #include "aacps_tablegen.h"
  37. #endif /* USE_FIXED */
  38. #include "tableprint.h"
  39. void ARRAY_RENAME(3d_array) (const void *p, int b, int c, int d)
  40. {
  41. int i;
  42. const INT32FLOAT *f = p;
  43. for (i = 0; i < b; i++) {
  44. printf("{\n");
  45. ARRAY_URENAME(2d_array)(f, c, d);
  46. printf("},\n");
  47. f += c * d;
  48. }
  49. }
  50. void ARRAY_RENAME(4d_array) (const void *p, int a, int b, int c, int d)
  51. {
  52. int i;
  53. const INT32FLOAT *f = p;
  54. for (i = 0; i < a; i++) {
  55. printf("{\n");
  56. ARRAY_RENAME(3d_array)(f, b, c, d);
  57. printf("},\n");
  58. f += b * c * d;
  59. }
  60. }
  61. int main(void)
  62. {
  63. ps_tableinit();
  64. write_fileheader();
  65. printf("static const %s pd_re_smooth[8*8*8] = {\n", TYPE_NAME);
  66. ARRAY_RENAME(array)(pd_re_smooth, 8*8*8);
  67. printf("};\n");
  68. printf("static const %s pd_im_smooth[8*8*8] = {\n", TYPE_NAME);
  69. ARRAY_RENAME(array)(pd_im_smooth, 8*8*8);
  70. printf("};\n");
  71. printf("static const %s HA[46][8][4] = {\n", TYPE_NAME);
  72. ARRAY_RENAME(3d_array)(HA, 46, 8, 4);
  73. printf("};\n");
  74. printf("static const %s HB[46][8][4] = {\n", TYPE_NAME);
  75. ARRAY_RENAME(3d_array)(HB, 46, 8, 4);
  76. printf("};\n");
  77. printf("static const DECLARE_ALIGNED(16, %s, f20_0_8)[8][8][2] = {\n", TYPE_NAME);
  78. ARRAY_RENAME(3d_array)(f20_0_8, 8, 8, 2);
  79. printf("};\n");
  80. printf("static const DECLARE_ALIGNED(16, %s, f34_0_12)[12][8][2] = {\n", TYPE_NAME);
  81. ARRAY_RENAME(3d_array)(f34_0_12, 12, 8, 2);
  82. printf("};\n");
  83. printf("static const DECLARE_ALIGNED(16, %s, f34_1_8)[8][8][2] = {\n", TYPE_NAME);
  84. ARRAY_RENAME(3d_array)(f34_1_8, 8, 8, 2);
  85. printf("};\n");
  86. printf("static const DECLARE_ALIGNED(16, %s, f34_2_4)[4][8][2] = {\n", TYPE_NAME);
  87. ARRAY_RENAME(3d_array)(f34_2_4, 4, 8, 2);
  88. printf("};\n");
  89. printf("static const DECLARE_ALIGNED(16, %s, Q_fract_allpass)[2][50][3][2] = {\n", TYPE_NAME);
  90. ARRAY_RENAME(4d_array)(Q_fract_allpass, 2, 50, 3, 2);
  91. printf("};\n");
  92. printf("static const DECLARE_ALIGNED(16, %s, phi_fract)[2][50][2] = {\n", TYPE_NAME);
  93. ARRAY_RENAME(3d_array)(phi_fract, 2, 50, 2);
  94. printf("};\n");
  95. return 0;
  96. }