mpegaudiodata.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * MPEG Audio common tables
  3. * copyright (c) 2002 Fabrice Bellard
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg 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. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * mpeg audio layer common tables.
  24. */
  25. #include "mpegaudiodata.h"
  26. const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = {
  27. { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
  28. {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
  29. {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
  30. { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
  31. {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
  32. {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
  33. }
  34. };
  35. const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 };
  36. /*******************************************************/
  37. /* layer 2 tables */
  38. const int ff_mpa_sblimit_table[5] = { 27 , 30 , 8, 12 , 30 };
  39. const int ff_mpa_quant_steps[17] = {
  40. 3, 5, 7, 9, 15,
  41. 31, 63, 127, 255, 511,
  42. 1023, 2047, 4095, 8191, 16383,
  43. 32767, 65535
  44. };
  45. /* we use a negative value if grouped */
  46. const int ff_mpa_quant_bits[17] = {
  47. -5, -7, 3, -10, 4,
  48. 5, 6, 7, 8, 9,
  49. 10, 11, 12, 13, 14,
  50. 15, 16
  51. };
  52. /* encoding tables which give the quantization index. Note how it is
  53. possible to store them efficiently ! */
  54. static const unsigned char alloc_table_1[] = {
  55. 4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
  56. 4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
  57. 4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
  58. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  59. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  60. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  61. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  62. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  63. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  64. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  65. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
  66. 3, 0, 1, 2, 3, 4, 5, 16,
  67. 3, 0, 1, 2, 3, 4, 5, 16,
  68. 3, 0, 1, 2, 3, 4, 5, 16,
  69. 3, 0, 1, 2, 3, 4, 5, 16,
  70. 3, 0, 1, 2, 3, 4, 5, 16,
  71. 3, 0, 1, 2, 3, 4, 5, 16,
  72. 3, 0, 1, 2, 3, 4, 5, 16,
  73. 3, 0, 1, 2, 3, 4, 5, 16,
  74. 3, 0, 1, 2, 3, 4, 5, 16,
  75. 3, 0, 1, 2, 3, 4, 5, 16,
  76. 3, 0, 1, 2, 3, 4, 5, 16,
  77. 3, 0, 1, 2, 3, 4, 5, 16,
  78. 2, 0, 1, 16,
  79. 2, 0, 1, 16,
  80. 2, 0, 1, 16,
  81. 2, 0, 1, 16,
  82. 2, 0, 1, 16,
  83. 2, 0, 1, 16,
  84. 2, 0, 1, 16,
  85. };
  86. static const unsigned char alloc_table_3[] = {
  87. 4, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  88. 4, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  89. 3, 0, 1, 3, 4, 5, 6, 7,
  90. 3, 0, 1, 3, 4, 5, 6, 7,
  91. 3, 0, 1, 3, 4, 5, 6, 7,
  92. 3, 0, 1, 3, 4, 5, 6, 7,
  93. 3, 0, 1, 3, 4, 5, 6, 7,
  94. 3, 0, 1, 3, 4, 5, 6, 7,
  95. 3, 0, 1, 3, 4, 5, 6, 7,
  96. 3, 0, 1, 3, 4, 5, 6, 7,
  97. 3, 0, 1, 3, 4, 5, 6, 7,
  98. 3, 0, 1, 3, 4, 5, 6, 7,
  99. };
  100. static const unsigned char alloc_table_4[] = {
  101. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  102. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  103. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  104. 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  105. 3, 0, 1, 3, 4, 5, 6, 7,
  106. 3, 0, 1, 3, 4, 5, 6, 7,
  107. 3, 0, 1, 3, 4, 5, 6, 7,
  108. 3, 0, 1, 3, 4, 5, 6, 7,
  109. 3, 0, 1, 3, 4, 5, 6, 7,
  110. 3, 0, 1, 3, 4, 5, 6, 7,
  111. 3, 0, 1, 3, 4, 5, 6, 7,
  112. 2, 0, 1, 3,
  113. 2, 0, 1, 3,
  114. 2, 0, 1, 3,
  115. 2, 0, 1, 3,
  116. 2, 0, 1, 3,
  117. 2, 0, 1, 3,
  118. 2, 0, 1, 3,
  119. 2, 0, 1, 3,
  120. 2, 0, 1, 3,
  121. 2, 0, 1, 3,
  122. 2, 0, 1, 3,
  123. 2, 0, 1, 3,
  124. 2, 0, 1, 3,
  125. 2, 0, 1, 3,
  126. 2, 0, 1, 3,
  127. 2, 0, 1, 3,
  128. 2, 0, 1, 3,
  129. 2, 0, 1, 3,
  130. 2, 0, 1, 3,
  131. };
  132. const unsigned char * const ff_mpa_alloc_tables[5] =
  133. { alloc_table_1, alloc_table_1, alloc_table_3, alloc_table_3, alloc_table_4, };