qdm2data.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. /*
  2. * QDM2 compatible decoder
  3. * Copyright (c) 2003 Ewald Snel
  4. * Copyright (c) 2005 Benjamin Larsson
  5. * Copyright (c) 2005 Alex Beregszaszi
  6. * Copyright (c) 2005 Roberto Togni
  7. *
  8. * This file is part of FFmpeg.
  9. *
  10. * FFmpeg is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * FFmpeg is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with FFmpeg; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. /**
  25. * @file libavcodec/qdm2data.h
  26. * Various QDM2 tables.
  27. */
  28. #ifndef AVCODEC_QDM2DATA_H
  29. #define AVCODEC_QDM2DATA_H
  30. #include <stdint.h>
  31. /** VLC TABLES **/
  32. /* values in this table range from -1..23; adjust retrieved value by -1 */
  33. static const uint16_t vlc_tab_level_huffcodes[24] = {
  34. 0x037c, 0x0004, 0x003c, 0x004c, 0x003a, 0x002c, 0x001c, 0x001a,
  35. 0x0024, 0x0014, 0x0001, 0x0002, 0x0000, 0x0003, 0x0007, 0x0005,
  36. 0x0006, 0x0008, 0x0009, 0x000a, 0x000c, 0x00fc, 0x007c, 0x017c
  37. };
  38. static const uint8_t vlc_tab_level_huffbits[24] = {
  39. 10, 6, 7, 7, 6, 6, 6, 6, 6, 5, 4, 4, 4, 3, 3, 3, 3, 4, 4, 5, 7, 8, 9, 10
  40. };
  41. /* values in this table range from -1..36; adjust retrieved value by -1 */
  42. static const uint16_t vlc_tab_diff_huffcodes[37] = {
  43. 0x1c57, 0x0004, 0x0000, 0x0001, 0x0003, 0x0002, 0x000f, 0x000e,
  44. 0x0007, 0x0016, 0x0037, 0x0027, 0x0026, 0x0066, 0x0006, 0x0097,
  45. 0x0046, 0x01c6, 0x0017, 0x0786, 0x0086, 0x0257, 0x00d7, 0x0357,
  46. 0x00c6, 0x0386, 0x0186, 0x0000, 0x0157, 0x0c57, 0x0057, 0x0000,
  47. 0x0b86, 0x0000, 0x1457, 0x0000, 0x0457
  48. };
  49. static const uint8_t vlc_tab_diff_huffbits[37] = {
  50. 13, 3, 3, 2, 3, 3, 4, 4, 6, 5, 6, 6, 7, 7, 8, 8,
  51. 8, 9, 8, 11, 9, 10, 8, 10, 9, 12, 10, 0, 10, 13, 11, 0,
  52. 12, 0, 13, 0, 13
  53. };
  54. /* values in this table range from -1..5; adjust retrieved value by -1 */
  55. static const uint8_t vlc_tab_run_huffcodes[6] = {
  56. 0x1f, 0x00, 0x01, 0x03, 0x07, 0x0f
  57. };
  58. static const uint8_t vlc_tab_run_huffbits[6] = {
  59. 5, 1, 2, 3, 4, 5
  60. };
  61. /* values in this table range from -1..19; adjust retrieved value by -1 */
  62. static const uint16_t vlc_tab_tone_level_idx_hi1_huffcodes[20] = {
  63. 0x5714, 0x000c, 0x0002, 0x0001, 0x0000, 0x0004, 0x0034, 0x0054,
  64. 0x0094, 0x0014, 0x0114, 0x0214, 0x0314, 0x0614, 0x0e14, 0x0f14,
  65. 0x2714, 0x0714, 0x1714, 0x3714
  66. };
  67. static const uint8_t vlc_tab_tone_level_idx_hi1_huffbits[20] = {
  68. 15, 4, 2, 1, 3, 5, 6, 7, 8, 10, 10, 11, 11, 12, 12, 12, 14, 14, 15, 14
  69. };
  70. /* values in this table range from -1..23; adjust retrieved value by -1 */
  71. static const uint16_t vlc_tab_tone_level_idx_mid_huffcodes[24] = {
  72. 0x0fea, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  73. 0x0000, 0x0000, 0x0000, 0x0000, 0x03ea, 0x00ea, 0x002a, 0x001a,
  74. 0x0006, 0x0001, 0x0000, 0x0002, 0x000a, 0x006a, 0x01ea, 0x07ea
  75. };
  76. static const uint8_t vlc_tab_tone_level_idx_mid_huffbits[24] = {
  77. 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12
  78. };
  79. /* values in this table range from -1..23; adjust retrieved value by -1 */
  80. static const uint16_t vlc_tab_tone_level_idx_hi2_huffcodes[24] = {
  81. 0x0664, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0064, 0x00e4,
  82. 0x00a4, 0x0068, 0x0004, 0x0008, 0x0014, 0x0018, 0x0000, 0x0001,
  83. 0x0002, 0x0003, 0x000c, 0x0028, 0x0024, 0x0164, 0x0000, 0x0264
  84. };
  85. static const uint8_t vlc_tab_tone_level_idx_hi2_huffbits[24] = {
  86. 11, 0, 0, 0, 0, 0, 10, 8, 8, 7, 6, 6, 5, 5, 4, 2, 2, 2, 4, 7, 8, 9, 0, 11
  87. };
  88. /* values in this table range from -1..8; adjust retrieved value by -1 */
  89. static const uint8_t vlc_tab_type30_huffcodes[9] = {
  90. 0x3c, 0x06, 0x00, 0x01, 0x03, 0x02, 0x04, 0x0c, 0x1c
  91. };
  92. static const uint8_t vlc_tab_type30_huffbits[9] = {
  93. 6, 3, 3, 2, 2, 3, 4, 5, 6
  94. };
  95. /* values in this table range from -1..9; adjust retrieved value by -1 */
  96. static const uint8_t vlc_tab_type34_huffcodes[10] = {
  97. 0x18, 0x00, 0x01, 0x04, 0x05, 0x07, 0x03, 0x02, 0x06, 0x08
  98. };
  99. static const uint8_t vlc_tab_type34_huffbits[10] = {
  100. 5, 4, 3, 3, 3, 3, 3, 3, 3, 5
  101. };
  102. /* values in this table range from -1..22; adjust retrieved value by -1 */
  103. static const uint16_t vlc_tab_fft_tone_offset_0_huffcodes[23] = {
  104. 0x038e, 0x0001, 0x0000, 0x0022, 0x000a, 0x0006, 0x0012, 0x0002,
  105. 0x001e, 0x003e, 0x0056, 0x0016, 0x000e, 0x0032, 0x0072, 0x0042,
  106. 0x008e, 0x004e, 0x00f2, 0x002e, 0x0036, 0x00c2, 0x018e
  107. };
  108. static const uint8_t vlc_tab_fft_tone_offset_0_huffbits[23] = {
  109. 10, 1, 2, 6, 4, 5, 6, 7, 6, 6, 7, 7, 8, 7, 8, 8, 9, 7, 8, 6, 6, 8, 10
  110. };
  111. /* values in this table range from -1..27; adjust retrieved value by -1 */
  112. static const uint16_t vlc_tab_fft_tone_offset_1_huffcodes[28] = {
  113. 0x07a4, 0x0001, 0x0020, 0x0012, 0x001c, 0x0008, 0x0006, 0x0010,
  114. 0x0000, 0x0014, 0x0004, 0x0032, 0x0070, 0x000c, 0x0002, 0x003a,
  115. 0x001a, 0x002c, 0x002a, 0x0022, 0x0024, 0x000a, 0x0064, 0x0030,
  116. 0x0062, 0x00a4, 0x01a4, 0x03a4
  117. };
  118. static const uint8_t vlc_tab_fft_tone_offset_1_huffbits[28] = {
  119. 11, 1, 6, 6, 5, 4, 3, 6, 6, 5, 6, 6, 7, 6, 6, 6,
  120. 6, 6, 6, 7, 8, 6, 7, 7, 7, 9, 10, 11
  121. };
  122. /* values in this table range from -1..31; adjust retrieved value by -1 */
  123. static const uint16_t vlc_tab_fft_tone_offset_2_huffcodes[32] = {
  124. 0x1760, 0x0001, 0x0000, 0x0082, 0x000c, 0x0006, 0x0003, 0x0007,
  125. 0x0008, 0x0004, 0x0010, 0x0012, 0x0022, 0x001a, 0x0000, 0x0020,
  126. 0x000a, 0x0040, 0x004a, 0x006a, 0x002a, 0x0042, 0x0002, 0x0060,
  127. 0x00aa, 0x00e0, 0x00c2, 0x01c2, 0x0160, 0x0360, 0x0760, 0x0f60
  128. };
  129. static const uint8_t vlc_tab_fft_tone_offset_2_huffbits[32] = {
  130. 13, 2, 0, 8, 4, 3, 3, 3, 4, 4, 5, 5, 6, 5, 7, 7,
  131. 7, 7, 7, 7, 8, 8, 8, 9, 8, 8, 9, 9, 10, 11, 13, 12
  132. };
  133. /* values in this table range from -1..34; adjust retrieved value by -1 */
  134. static const uint16_t vlc_tab_fft_tone_offset_3_huffcodes[35] = {
  135. 0x33ea, 0x0005, 0x0000, 0x000c, 0x0000, 0x0006, 0x0003, 0x0008,
  136. 0x0002, 0x0001, 0x0004, 0x0007, 0x001a, 0x000f, 0x001c, 0x002c,
  137. 0x000a, 0x001d, 0x002d, 0x002a, 0x000d, 0x004c, 0x008c, 0x006a,
  138. 0x00cd, 0x004d, 0x00ea, 0x020c, 0x030c, 0x010c, 0x01ea, 0x07ea,
  139. 0x0bea, 0x03ea, 0x13ea
  140. };
  141. static const uint8_t vlc_tab_fft_tone_offset_3_huffbits[35] = {
  142. 14, 4, 0, 10, 4, 3, 3, 4, 4, 3, 4, 4, 5, 4, 5, 6,
  143. 6, 5, 6, 7, 7, 7, 8, 8, 8, 8, 9, 10, 10, 10, 10, 11,
  144. 12, 13, 14
  145. };
  146. /* values in this table range from -1..37; adjust retrieved value by -1 */
  147. static const uint16_t vlc_tab_fft_tone_offset_4_huffcodes[38] = {
  148. 0x5282, 0x0016, 0x0000, 0x0136, 0x0004, 0x0000, 0x0007, 0x000a,
  149. 0x000e, 0x0003, 0x0001, 0x000d, 0x0006, 0x0009, 0x0012, 0x0005,
  150. 0x0025, 0x0022, 0x0015, 0x0002, 0x0076, 0x0035, 0x0042, 0x00c2,
  151. 0x0182, 0x00b6, 0x0036, 0x03c2, 0x0482, 0x01c2, 0x0682, 0x0882,
  152. 0x0a82, 0x0082, 0x0282, 0x1282, 0x3282, 0x2282
  153. };
  154. static const uint8_t vlc_tab_fft_tone_offset_4_huffbits[38] = {
  155. 15, 6, 0, 9, 3, 3, 3, 4, 4, 3, 4, 4, 5, 4, 5, 6,
  156. 6, 6, 6, 8, 7, 6, 8, 9, 9, 8, 9, 10, 11, 10, 11, 12,
  157. 12, 12, 14, 15, 14, 14
  158. };
  159. /** FFT TABLES **/
  160. /* values in this table range from -1..27; adjust retrieved value by -1 */
  161. static const uint16_t fft_level_exp_alt_huffcodes[28] = {
  162. 0x1ec6, 0x0006, 0x00c2, 0x0142, 0x0242, 0x0246, 0x00c6, 0x0046,
  163. 0x0042, 0x0146, 0x00a2, 0x0062, 0x0026, 0x0016, 0x000e, 0x0005,
  164. 0x0004, 0x0003, 0x0000, 0x0001, 0x000a, 0x0012, 0x0002, 0x0022,
  165. 0x01c6, 0x02c6, 0x06c6, 0x0ec6
  166. };
  167. static const uint8_t fft_level_exp_alt_huffbits[28] = {
  168. 13, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3,
  169. 3, 2, 3, 3, 4, 5, 7, 8, 9, 11, 12, 13
  170. };
  171. /* values in this table range from -1..19; adjust retrieved value by -1 */
  172. static const uint16_t fft_level_exp_huffcodes[20] = {
  173. 0x0f24, 0x0001, 0x0002, 0x0000, 0x0006, 0x0005, 0x0007, 0x000c,
  174. 0x000b, 0x0014, 0x0013, 0x0004, 0x0003, 0x0023, 0x0064, 0x00a4,
  175. 0x0024, 0x0124, 0x0324, 0x0724
  176. };
  177. static const uint8_t fft_level_exp_huffbits[20] = {
  178. 12, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 9, 10, 11, 12
  179. };
  180. /* values in this table range from -1..6; adjust retrieved value by -1 */
  181. static const uint8_t fft_stereo_exp_huffcodes[7] = {
  182. 0x3e, 0x01, 0x00, 0x02, 0x06, 0x0e, 0x1e
  183. };
  184. static const uint8_t fft_stereo_exp_huffbits[7] = {
  185. 6, 1, 2, 3, 4, 5, 6
  186. };
  187. /* values in this table range from -1..8; adjust retrieved value by -1 */
  188. static const uint8_t fft_stereo_phase_huffcodes[9] = {
  189. 0x35, 0x02, 0x00, 0x01, 0x0d, 0x15, 0x05, 0x09, 0x03
  190. };
  191. static const uint8_t fft_stereo_phase_huffbits[9] = {
  192. 6, 2, 2, 4, 4, 6, 5, 4, 2
  193. };
  194. static const int fft_cutoff_index_table[4][2] = {
  195. { 1, 2 }, {-1, 0 }, {-1,-2 }, { 0, 0 }
  196. };
  197. static const int16_t fft_level_index_table[256] = {
  198. 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
  199. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  200. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  201. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  202. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  203. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  204. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  205. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  206. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  207. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  208. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  209. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  210. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  211. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  212. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  213. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  214. };
  215. static const uint8_t last_coeff[3] = {
  216. 4, 7, 10
  217. };
  218. static const uint8_t coeff_per_sb_for_avg[3][30] = {
  219. { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
  220. { 0, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
  221. { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9 }
  222. };
  223. static const uint32_t dequant_table[3][10][30] = {
  224. { { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  225. { 0, 256, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  226. { 0, 0, 0, 51, 102, 154, 205, 256, 238, 219, 201, 183, 165, 146, 128, 110, 91, 73, 55, 37, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  227. { 0, 0, 0, 0, 0, 0, 0, 0, 18, 37, 55, 73, 91, 110, 128, 146, 165, 183, 201, 219, 238, 256, 228, 199, 171, 142, 114, 85, 57, 28 },
  228. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  229. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  230. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  231. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  232. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  233. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
  234. { { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  235. { 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  236. { 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  237. { 0, 0, 0, 85, 171, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  238. { 0, 0, 0, 0, 0, 0, 85, 171, 256, 219, 183, 146, 110, 73, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  239. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 73, 110, 146, 183, 219, 256, 228, 199, 171, 142, 114, 85, 57, 28, 0, 0, 0, 0, 0, 0 },
  240. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 57, 85, 114, 142, 171, 199, 228, 256, 213, 171, 128, 85, 43 },
  241. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  242. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  243. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
  244. { { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  245. { 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  246. { 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  247. { 0, 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  248. { 0, 0, 0, 0, 256, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  249. { 0, 0, 0, 0, 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  250. { 0, 0, 0, 0, 0, 0, 0, 85, 171, 256, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  251. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  252. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 102, 154, 205, 256, 213, 171, 128, 85, 43, 0, 0, 0, 0, 0, 0 },
  253. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 85, 128, 171, 213, 256, 213, 171, 128, 85, 43 } }
  254. };
  255. static const uint8_t coeff_per_sb_for_dequant[3][30] = {
  256. { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
  257. { 0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
  258. { 0, 1, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9 }
  259. };
  260. /* first index is subband, 2nd index is 0, 1 or 3 (2 is unused) */
  261. static const int8_t tone_level_idx_offset_table[30][4] = {
  262. { -50, -50, 0, -50 },
  263. { -50, -50, 0, -50 },
  264. { -50, -9, 0, -19 },
  265. { -16, -6, 0, -12 },
  266. { -11, -4, 0, -8 },
  267. { -8, -3, 0, -6 },
  268. { -7, -3, 0, -5 },
  269. { -6, -2, 0, -4 },
  270. { -5, -2, 0, -3 },
  271. { -4, -1, 0, -3 },
  272. { -4, -1, 0, -2 },
  273. { -3, -1, 0, -2 },
  274. { -3, -1, 0, -2 },
  275. { -3, -1, 0, -2 },
  276. { -2, -1, 0, -1 },
  277. { -2, -1, 0, -1 },
  278. { -2, -1, 0, -1 },
  279. { -2, 0, 0, -1 },
  280. { -2, 0, 0, -1 },
  281. { -1, 0, 0, -1 },
  282. { -1, 0, 0, -1 },
  283. { -1, 0, 0, -1 },
  284. { -1, 0, 0, -1 },
  285. { -1, 0, 0, -1 },
  286. { -1, 0, 0, -1 },
  287. { -1, 0, 0, -1 },
  288. { -1, 0, 0, 0 },
  289. { -1, 0, 0, 0 },
  290. { -1, 0, 0, 0 },
  291. { -1, 0, 0, 0 }
  292. };
  293. /* all my samples have 1st index 0 or 1 */
  294. /* second index is subband, only indexes 0-29 seem to be used */
  295. static const int8_t coding_method_table[5][30] = {
  296. { 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
  297. 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
  298. },
  299. { 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
  300. 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
  301. },
  302. { 34, 30, 30, 30, 24, 24, 16, 16, 16, 16, 16, 16, 10, 10, 10,
  303. 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
  304. },
  305. { 34, 34, 30, 30, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16,
  306. 16, 16, 16, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10, 10
  307. },
  308. { 34, 34, 30, 30, 30, 30, 30, 30, 24, 24, 24, 24, 24, 24, 24,
  309. 24, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
  310. },
  311. };
  312. static const int vlc_stage3_values[60] = {
  313. 0, 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24,
  314. 28, 36, 44, 52, 60, 76, 92, 108, 124, 156, 188, 220,
  315. 252, 316, 380, 444, 508, 636, 764, 892, 1020, 1276, 1532, 1788,
  316. 2044, 2556, 3068, 3580, 4092, 5116, 6140, 7164, 8188, 10236, 12284, 14332,
  317. 16380, 20476, 24572, 28668, 32764, 40956, 49148, 57340, 65532, 81916, 98300,114684
  318. };
  319. static const float fft_tone_sample_table[4][16][5] = {
  320. { { .0100000000f,-.0037037037f,-.0020000000f,-.0069444444f,-.0018416207f },
  321. { .0416666667f, .0000000000f, .0000000000f,-.0208333333f,-.0123456791f },
  322. { .1250000000f, .0558035709f, .0330687836f,-.0164473690f,-.0097465888f },
  323. { .1562500000f, .0625000000f, .0370370370f,-.0062500000f,-.0037037037f },
  324. { .1996007860f, .0781250000f, .0462962948f, .0022727272f, .0013468013f },
  325. { .2000000000f, .0625000000f, .0370370373f, .0208333333f, .0074074073f },
  326. { .2127659619f, .0555555556f, .0329218097f, .0208333333f, .0123456791f },
  327. { .2173913121f, .0473484844f, .0280583613f, .0347222239f, .0205761325f },
  328. { .2173913121f, .0347222239f, .0205761325f, .0473484844f, .0280583613f },
  329. { .2127659619f, .0208333333f, .0123456791f, .0555555556f, .0329218097f },
  330. { .2000000000f, .0208333333f, .0074074073f, .0625000000f, .0370370370f },
  331. { .1996007860f, .0022727272f, .0013468013f, .0781250000f, .0462962948f },
  332. { .1562500000f,-.0062500000f,-.0037037037f, .0625000000f, .0370370370f },
  333. { .1250000000f,-.0164473690f,-.0097465888f, .0558035709f, .0330687836f },
  334. { .0416666667f,-.0208333333f,-.0123456791f, .0000000000f, .0000000000f },
  335. { .0100000000f,-.0069444444f,-.0018416207f,-.0037037037f,-.0020000000f } },
  336. { { .0050000000f,-.0200000000f, .0125000000f,-.3030303030f, .0020000000f },
  337. { .1041666642f, .0400000000f,-.0250000000f, .0333333333f,-.0200000000f },
  338. { .1250000000f, .0100000000f, .0142857144f,-.0500000007f,-.0200000000f },
  339. { .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
  340. { .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
  341. { .1250000000f,-.0500000000f,-.0200000000f, .0100000000f, .0142857144f },
  342. { .1041666667f, .0333333333f,-.0200000000f, .0400000000f,-.0250000000f },
  343. { .0050000000f,-.3030303030f, .0020000001f,-.0200000000f, .0125000000f },
  344. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  345. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  346. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  347. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  348. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  349. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  350. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  351. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
  352. { { .1428571492f, .1250000000f,-.0285714287f,-.0357142873f, .0208333333f },
  353. { .1818181818f, .0588235296f, .0333333333f, .0212765951f, .0100000000f },
  354. { .1818181818f, .0212765951f, .0100000000f, .0588235296f, .0333333333f },
  355. { .1428571492f,-.0357142873f, .0208333333f, .1250000000f,-.0285714287f },
  356. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  357. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  358. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  359. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  360. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  361. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  362. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  363. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  364. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  365. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  366. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  367. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
  368. { { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  369. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  370. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  371. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  372. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  373. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  374. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  375. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  376. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  377. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  378. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  379. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  380. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  381. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  382. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
  383. { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } }
  384. };
  385. static const float fft_tone_level_table[2][64] = { {
  386. /* pow ~ (i > 46) ? 0 : (((((i & 1) ? 431 : 304) << (i >> 1))) / 1024.0); */
  387. 0.17677669f, 0.42677650f, 0.60355347f, 0.85355347f,
  388. 1.20710683f, 1.68359375f, 2.37500000f, 3.36718750f,
  389. 4.75000000f, 6.73437500f, 9.50000000f, 13.4687500f,
  390. 19.0000000f, 26.9375000f, 38.0000000f, 53.8750000f,
  391. 76.0000000f, 107.750000f, 152.000000f, 215.500000f,
  392. 304.000000f, 431.000000f, 608.000000f, 862.000000f,
  393. 1216.00000f, 1724.00000f, 2432.00000f, 3448.00000f,
  394. 4864.00000f, 6896.00000f, 9728.00000f, 13792.0000f,
  395. 19456.0000f, 27584.0000f, 38912.0000f, 55168.0000f,
  396. 77824.0000f, 110336.000f, 155648.000f, 220672.000f,
  397. 311296.000f, 441344.000f, 622592.000f, 882688.000f,
  398. 1245184.00f, 1765376.00f, 2490368.00f, 0.00000000f,
  399. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
  400. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
  401. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
  402. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
  403. }, {
  404. /* pow = (i > 45) ? 0 : ((((i & 1) ? 431 : 304) << (i >> 1)) / 512.0); */
  405. 0.59375000f, 0.84179688f, 1.18750000f, 1.68359375f,
  406. 2.37500000f, 3.36718750f, 4.75000000f, 6.73437500f,
  407. 9.50000000f, 13.4687500f, 19.0000000f, 26.9375000f,
  408. 38.0000000f, 53.8750000f, 76.0000000f, 107.750000f,
  409. 152.000000f, 215.500000f, 304.000000f, 431.000000f,
  410. 608.000000f, 862.000000f, 1216.00000f, 1724.00000f,
  411. 2432.00000f, 3448.00000f, 4864.00000f, 6896.00000f,
  412. 9728.00000f, 13792.0000f, 19456.0000f, 27584.0000f,
  413. 38912.0000f, 55168.0000f, 77824.0000f, 110336.000f,
  414. 155648.000f, 220672.000f, 311296.000f, 441344.000f,
  415. 622592.000f, 882688.000f, 1245184.00f, 1765376.00f,
  416. 2490368.00f, 3530752.00f, 0.00000000f, 0.00000000f,
  417. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
  418. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
  419. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
  420. 0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f
  421. } };
  422. static const float fft_tone_envelope_table[4][31] = {
  423. { .009607375f, .038060248f, .084265202f, .146446645f, .222214907f, .308658302f,
  424. .402454883f, .500000060f, .597545207f, .691341758f, .777785182f, .853553414f,
  425. .915734828f, .961939812f, .990392685f, 1.00000000f, .990392625f, .961939752f,
  426. .915734768f, .853553295f, .777785063f, .691341639f, .597545087f, .500000000f,
  427. .402454853f, .308658272f, .222214878f, .146446615f, .084265172f, .038060218f,
  428. .009607345f },
  429. { .038060248f, .146446645f, .308658302f, .500000060f, .691341758f, .853553414f,
  430. .961939812f, 1.00000000f, .961939752f, .853553295f, .691341639f, .500000000f,
  431. .308658272f, .146446615f, .038060218f, .000000000f, .000000000f, .000000000f,
  432. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  433. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  434. .000000000f },
  435. { .146446645f, .500000060f, .853553414f, 1.00000000f, .853553295f, .500000000f,
  436. .146446615f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  437. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  438. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  439. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  440. .000000000f },
  441. { .500000060f, 1.00000000f, .500000000f, .000000000f, .000000000f, .000000000f,
  442. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  443. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  444. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  445. .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
  446. .000000000f }
  447. };
  448. static const float sb_noise_attenuation[32] = {
  449. 0.0f, 0.0f, 0.3f, 0.4f, 0.5f, 0.7f, 1.0f, 1.0f,
  450. 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
  451. 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
  452. 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
  453. };
  454. static const uint8_t fft_subpackets[32] = {
  455. 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0,
  456. 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0
  457. };
  458. /* first index is joined_stereo, second index is 0 or 2 (1 is unused) */
  459. static const float dequant_1bit[2][3] = {
  460. {-0.920000f, 0.000000f, 0.920000f },
  461. {-0.890000f, 0.000000f, 0.890000f }
  462. };
  463. static const float type30_dequant[8] = {
  464. -1.0f,-0.625f,-0.291666656732559f,0.0f,
  465. 0.25f,0.5f,0.75f,1.0f,
  466. };
  467. static const float type34_delta[10] = { // FIXME: covers 8 entries..
  468. -1.0f,-0.60947573184967f,-0.333333343267441f,-0.138071194291115f,0.0f,
  469. 0.138071194291115f,0.333333343267441f,0.60947573184967f,1.0f,0.0f,
  470. };
  471. #endif /* AVCODEC_QDM2DATA_H */