mpc8huff.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. * Musepack SV8 decoder
  3. * Copyright (c) 2007 Konstantin Shishkov
  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. #ifndef AVCODEC_MPC8HUFF_H
  22. #define AVCODEC_MPC8HUFF_H
  23. #include <stdint.h>
  24. #define MPC8_BANDS_SIZE 33
  25. #define MPC8_BANDS_BITS 9
  26. static const uint8_t mpc8_bands_codes[MPC8_BANDS_SIZE] = {
  27. 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04,
  28. 0x05, 0x06, 0x01, 0x02, 0x03, 0x00, 0x04, 0x05,
  29. 0x06, 0x07, 0x08, 0x01, 0x09, 0x0A, 0x0B, 0x07,
  30. 0x08, 0x09, 0x06, 0x07, 0x05, 0x05, 0x03, 0x03,
  31. 0x01,
  32. };
  33. static const int8_t mpc8_bands_bits[MPC8_BANDS_SIZE] = {
  34. 1, 3, 5, 6, 7, 8, 8, 9,
  35. 10, 11, 12, 12, 12, 13, 12, 12,
  36. 12, 12, 12, 13, 12, 12, 12, 11,
  37. 11, 11, 10, 10, 9, 8, 6, 5,
  38. 2,
  39. };
  40. #define MPC8_SCFI0_SIZE 4
  41. #define MPC8_SCFI0_BITS 3
  42. static const uint8_t mpc8_scfi0_codes[MPC8_SCFI0_SIZE] = {
  43. 0x00, 0x01, 0x01, 0x01,
  44. };
  45. static const int8_t mpc8_scfi0_bits[MPC8_SCFI0_SIZE] = {
  46. 3, 3, 1, 2,
  47. };
  48. #define MPC8_SCFI1_SIZE 16
  49. #define MPC8_SCFI1_BITS 7
  50. static const uint8_t mpc8_scfi1_codes[MPC8_SCFI1_SIZE] = {
  51. 0x01, 0x00, 0x02, 0x03, 0x01, 0x03, 0x04, 0x05,
  52. 0x04, 0x06, 0x02, 0x02, 0x05, 0x07, 0x03, 0x03,
  53. };
  54. static const int8_t mpc8_scfi1_bits[MPC8_SCFI1_SIZE] = {
  55. 6, 7, 6, 6, 7, 5, 5, 5,
  56. 6, 5, 2, 3, 6, 5, 3, 2,
  57. };
  58. #define MPC8_DSCF0_SIZE 64
  59. #define MPC8_DSCF0_BITS 9
  60. static const uint8_t mpc8_dscf0_codes[MPC8_DSCF0_SIZE] = {
  61. 0x03, 0x04, 0x05, 0x04, 0x05, 0x06, 0x05, 0x06,
  62. 0x07, 0x08, 0x09, 0x07, 0x08, 0x09, 0x0A, 0x07,
  63. 0x08, 0x09, 0x0A, 0x07, 0x08, 0x09, 0x0A, 0x06,
  64. 0x07, 0x05, 0x04, 0x05, 0x06, 0x06, 0x07, 0x0A,
  65. 0x08, 0x05, 0x06, 0x07, 0x09, 0x07, 0x08, 0x09,
  66. 0x0B, 0x0B, 0x0C, 0x0D, 0x0B, 0x0C, 0x0D, 0x0B,
  67. 0x0C, 0x0D, 0x07, 0x08, 0x09, 0x06, 0x07, 0x03,
  68. 0x04, 0x05, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
  69. };
  70. static const int8_t mpc8_dscf0_bits[MPC8_DSCF0_SIZE] = {
  71. 12, 12, 12, 11, 11, 11, 10, 10,
  72. 10, 10, 10, 9, 9, 9, 9, 8,
  73. 8, 8, 8, 7, 7, 7, 7, 6,
  74. 6, 5, 4, 4, 5, 4, 4, 10,
  75. 4, 3, 3, 3, 4, 5, 6, 6,
  76. 7, 8, 8, 8, 9, 9, 9, 10,
  77. 10, 10, 11, 11, 11, 12, 12, 13,
  78. 13, 13, 14, 14, 14, 14, 14, 14,
  79. };
  80. #define MPC8_DSCF1_SIZE 65
  81. #define MPC8_DSCF1_BITS 9
  82. static const uint8_t mpc8_dscf1_codes[MPC8_DSCF1_SIZE] = {
  83. 0x00, 0x03, 0x04, 0x04, 0x05, 0x06, 0x05, 0x06,
  84. 0x07, 0x08, 0x07, 0x08, 0x09, 0x0A, 0x07, 0x08,
  85. 0x09, 0x0A, 0x07, 0x08, 0x09, 0x06, 0x07, 0x05,
  86. 0x06, 0x04, 0x03, 0x03, 0x04, 0x03, 0x04, 0x05,
  87. 0x06, 0x07, 0x05, 0x04, 0x05, 0x05, 0x07, 0x08,
  88. 0x09, 0x0A, 0x0B, 0x0B, 0x0C, 0x0D, 0x0B, 0x0C,
  89. 0x0D, 0x09, 0x0A, 0x0B, 0x0C, 0x07, 0x08, 0x09,
  90. 0x05, 0x06, 0x07, 0x01, 0x02, 0x03, 0x04, 0x05,
  91. 0x0D,
  92. };
  93. static const int8_t mpc8_dscf1_bits[MPC8_DSCF1_SIZE] = {
  94. 15, 14, 14, 13, 13, 13, 12, 12,
  95. 12, 12, 11, 11, 11, 11, 10, 10,
  96. 10, 10, 9, 9, 9, 8, 8, 7,
  97. 7, 6, 5, 4, 4, 3, 3, 3,
  98. 3, 3, 4, 5, 5, 6, 7, 8,
  99. 8, 9, 9, 10, 10, 10, 11, 11,
  100. 11, 12, 12, 12, 12, 13, 13, 13,
  101. 14, 14, 14, 15, 15, 15, 15, 15,
  102. 12,
  103. };
  104. #define MPC8_RES_SIZE 17
  105. #define MPC8_RES_BITS 9
  106. static const uint8_t mpc8_res_codes[2][MPC8_RES_SIZE] = {
  107. {
  108. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  109. 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01,
  110. 0x01,
  111. },
  112. {
  113. 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  114. 0x00, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01,
  115. 0x03,
  116. }
  117. };
  118. static const int8_t mpc8_res_bits[2][MPC8_RES_SIZE] = {
  119. {
  120. 1, 2, 4, 5, 6, 7, 9, 10,
  121. 11, 12, 13, 14, 15, 16, 16, 8,
  122. 3,
  123. },
  124. {
  125. 2, 2, 3, 5, 7, 8, 10, 12,
  126. 14, 14, 14, 14, 11, 9, 6, 4,
  127. 2,
  128. }
  129. };
  130. #define MPC8_Q1_SIZE 19
  131. #define MPC8_Q1_BITS 9
  132. static const uint8_t mpc8_q1_codes[MPC8_Q1_SIZE] = {
  133. 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  134. 0x03, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
  135. 0x01, 0x00, 0x01,
  136. };
  137. static const int8_t mpc8_q1_bits[MPC8_Q1_SIZE] = {
  138. 6, 4, 4, 3, 3, 3, 3, 3,
  139. 4, 4, 4, 5, 7, 8, 9, 10,
  140. 11, 12, 12,
  141. };
  142. #define MPC8_Q9UP_SIZE 256
  143. #define MPC8_Q9UP_BITS 9
  144. static const uint8_t mpc8_q9up_codes[MPC8_Q9UP_SIZE] = {
  145. 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06, 0x07,
  146. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  147. 0x10, 0x11, 0x12, 0x26, 0x27, 0x13, 0x14, 0x15,
  148. 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D,
  149. 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
  150. 0x28, 0x26, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,
  151. 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
  152. 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E,
  153. 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
  154. 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E,
  155. 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
  156. 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E,
  157. 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
  158. 0x67, 0x68, 0x69, 0x6A, 0x56, 0x57, 0x58, 0x59,
  159. 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61,
  160. 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x3E,
  161. 0x3F, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
  162. 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
  163. 0x78, 0x79, 0x7A, 0x6B, 0x7B, 0x6C, 0x6D, 0x6E,
  164. 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
  165. 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E,
  166. 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86,
  167. 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E,
  168. 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
  169. 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E,
  170. 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
  171. 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0x27, 0x28, 0x29,
  172. 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
  173. 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
  174. 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41,
  175. 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
  176. 0x4A, 0x4B, 0x06, 0x07, 0x08, 0x09, 0x00, 0x01,
  177. };
  178. static const int8_t mpc8_q9up_bits[MPC8_Q9UP_SIZE] = {
  179. 10, 10, 10, 10, 10, 9, 9, 9,
  180. 9, 9, 9, 9, 9, 9, 9, 9,
  181. 9, 9, 9, 8, 8, 9, 9, 9,
  182. 9, 9, 9, 9, 9, 9, 9, 9,
  183. 9, 9, 9, 9, 9, 9, 9, 9,
  184. 8, 9, 8, 8, 8, 8, 8, 8,
  185. 8, 8, 8, 8, 8, 8, 8, 8,
  186. 8, 8, 8, 8, 8, 8, 8, 8,
  187. 8, 8, 8, 8, 8, 8, 8, 8,
  188. 8, 8, 8, 8, 8, 8, 8, 8,
  189. 8, 8, 8, 8, 8, 8, 8, 8,
  190. 8, 8, 8, 8, 8, 8, 8, 8,
  191. 8, 8, 8, 8, 8, 8, 8, 8,
  192. 8, 8, 8, 8, 7, 7, 7, 7,
  193. 7, 7, 7, 7, 7, 7, 7, 7,
  194. 7, 7, 7, 7, 7, 7, 7, 6,
  195. 6, 7, 7, 7, 7, 7, 7, 7,
  196. 7, 7, 7, 7, 7, 7, 7, 7,
  197. 7, 7, 7, 8, 7, 8, 8, 8,
  198. 8, 8, 8, 8, 8, 8, 8, 8,
  199. 8, 8, 8, 8, 8, 8, 8, 8,
  200. 8, 8, 8, 8, 8, 8, 8, 8,
  201. 8, 8, 8, 8, 8, 8, 8, 8,
  202. 8, 8, 8, 8, 8, 8, 8, 8,
  203. 8, 8, 8, 8, 8, 8, 8, 8,
  204. 8, 8, 8, 8, 8, 8, 8, 8,
  205. 8, 8, 8, 8, 8, 9, 9, 9,
  206. 9, 9, 9, 9, 9, 9, 9, 9,
  207. 9, 9, 9, 9, 9, 9, 9, 9,
  208. 9, 9, 9, 9, 9, 9, 9, 9,
  209. 9, 9, 9, 9, 9, 9, 9, 9,
  210. 9, 9, 10, 10, 10, 10, 11, 11,
  211. };
  212. #define MPC8_Q2_SIZE 125
  213. #define MPC8_Q2_BITS 9
  214. static const uint8_t mpc8_q2_codes[2][MPC8_Q2_SIZE] = {
  215. {
  216. 0x02, 0x03, 0x0F, 0x04, 0x00, 0x05, 0x0C, 0x12,
  217. 0x0D, 0x06, 0x07, 0x13, 0x15, 0x14, 0x08, 0x09,
  218. 0x0E, 0x15, 0x0F, 0x0A, 0x03, 0x0B, 0x10, 0x0C,
  219. 0x01, 0x0D, 0x10, 0x16, 0x11, 0x0E, 0x12, 0x0F,
  220. 0x10, 0x16, 0x13, 0x17, 0x11, 0x08, 0x12, 0x18,
  221. 0x14, 0x13, 0x14, 0x17, 0x15, 0x0F, 0x16, 0x19,
  222. 0x17, 0x10, 0x11, 0x1A, 0x18, 0x1B, 0x12, 0x1C,
  223. 0x15, 0x09, 0x16, 0x1D, 0x19, 0x0A, 0x07, 0x0B,
  224. 0x1A, 0x1E, 0x17, 0x0C, 0x18, 0x1F, 0x13, 0x20,
  225. 0x1B, 0x21, 0x14, 0x11, 0x18, 0x22, 0x19, 0x12,
  226. 0x1A, 0x19, 0x1A, 0x1B, 0x1B, 0x23, 0x1C, 0x0D,
  227. 0x1D, 0x24, 0x1C, 0x1C, 0x1E, 0x1F, 0x1D, 0x13,
  228. 0x1E, 0x25, 0x1F, 0x14, 0x02, 0x15, 0x15, 0x16,
  229. 0x04, 0x17, 0x20, 0x26, 0x21, 0x18, 0x16, 0x27,
  230. 0x1D, 0x28, 0x19, 0x1A, 0x22, 0x29, 0x23, 0x1B,
  231. 0x03, 0x1C, 0x17, 0x1D, 0x05,
  232. },
  233. {
  234. 0x02, 0x03, 0x0F, 0x04, 0x00, 0x05, 0x0C, 0x0D,
  235. 0x0E, 0x06, 0x07, 0x0F, 0x1E, 0x10, 0x10, 0x08,
  236. 0x11, 0x12, 0x13, 0x09, 0x03, 0x0A, 0x11, 0x0B,
  237. 0x01, 0x0C, 0x14, 0x15, 0x16, 0x0D, 0x17, 0x12,
  238. 0x0E, 0x13, 0x18, 0x19, 0x14, 0x0F, 0x10, 0x1A,
  239. 0x1B, 0x15, 0x11, 0x16, 0x1C, 0x0E, 0x1D, 0x1E,
  240. 0x1F, 0x0F, 0x12, 0x20, 0x1F, 0x21, 0x13, 0x22,
  241. 0x12, 0x13, 0x14, 0x23, 0x20, 0x15, 0x0F, 0x16,
  242. 0x21, 0x24, 0x17, 0x18, 0x19, 0x25, 0x14, 0x26,
  243. 0x22, 0x27, 0x15, 0x10, 0x28, 0x29, 0x2A, 0x11,
  244. 0x2B, 0x17, 0x1A, 0x18, 0x2C, 0x2D, 0x1B, 0x1C,
  245. 0x19, 0x2E, 0x2F, 0x1A, 0x1D, 0x1B, 0x30, 0x12,
  246. 0x31, 0x32, 0x33, 0x13, 0x02, 0x14, 0x15, 0x16,
  247. 0x04, 0x17, 0x34, 0x35, 0x36, 0x18, 0x16, 0x37,
  248. 0x23, 0x38, 0x19, 0x1A, 0x39, 0x3A, 0x3B, 0x1B,
  249. 0x03, 0x1C, 0x17, 0x1D, 0x05,
  250. }
  251. };
  252. static const int8_t mpc8_q2_bits[2][MPC8_Q2_SIZE] = {
  253. {
  254. 12, 11, 10, 11, 13, 11, 9, 8,
  255. 9, 11, 11, 8, 7, 8, 11, 11,
  256. 9, 8, 9, 11, 12, 11, 10, 11,
  257. 13, 11, 9, 8, 9, 11, 9, 6,
  258. 6, 7, 9, 8, 6, 4, 6, 8,
  259. 9, 6, 6, 7, 9, 11, 9, 8,
  260. 9, 11, 10, 8, 7, 8, 10, 8,
  261. 6, 4, 6, 8, 7, 4, 3, 4,
  262. 7, 8, 6, 4, 6, 8, 10, 8,
  263. 7, 8, 10, 11, 9, 8, 9, 11,
  264. 9, 6, 6, 6, 9, 8, 6, 4,
  265. 6, 8, 9, 7, 6, 6, 9, 11,
  266. 9, 8, 9, 11, 13, 11, 10, 11,
  267. 12, 11, 9, 8, 9, 11, 10, 8,
  268. 7, 8, 11, 11, 9, 8, 9, 11,
  269. 13, 11, 10, 11, 12,
  270. },
  271. {
  272. 11, 10, 9, 10, 12, 10, 8, 8,
  273. 8, 10, 10, 8, 7, 8, 9, 10,
  274. 8, 8, 8, 10, 11, 10, 9, 10,
  275. 12, 10, 8, 8, 8, 10, 8, 6,
  276. 5, 6, 8, 8, 6, 5, 5, 8,
  277. 8, 6, 5, 6, 8, 10, 8, 8,
  278. 8, 10, 9, 8, 7, 8, 9, 8,
  279. 5, 5, 5, 8, 7, 5, 4, 5,
  280. 7, 8, 5, 5, 5, 8, 9, 8,
  281. 7, 8, 9, 10, 8, 8, 8, 10,
  282. 8, 6, 5, 6, 8, 8, 5, 5,
  283. 6, 8, 8, 6, 5, 6, 8, 10,
  284. 8, 8, 8, 10, 12, 10, 10, 10,
  285. 11, 10, 8, 8, 8, 10, 9, 8,
  286. 7, 8, 10, 10, 8, 8, 8, 10,
  287. 12, 10, 9, 10, 11,
  288. }
  289. };
  290. #define MPC8_Q3_SIZE 49
  291. #define MPC8_Q3_BITS 9
  292. #define MPC8_Q3_OFFSET -48
  293. static const uint8_t mpc8_q3_codes[MPC8_Q3_SIZE] = {
  294. 0x07, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x0F,
  295. 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x13, 0x12, 0x11,
  296. 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09,
  297. 0x11, 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A,
  298. 0x09, 0x08, 0x07, 0x06, 0x05, 0x09, 0x08, 0x07,
  299. 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x01,
  300. 0x00,
  301. };
  302. static const int8_t mpc8_q3_bits[MPC8_Q3_SIZE] = {
  303. 3, 4, 4, 4, 4, 4, 4, 5,
  304. 5, 5, 5, 5, 5, 6, 6, 6,
  305. 6, 6, 6, 6, 6, 6, 6, 6,
  306. 7, 7, 7, 7, 7, 7, 7, 7,
  307. 7, 7, 7, 7, 7, 8, 8, 8,
  308. 8, 8, 8, 8, 8, 9, 9, 9,
  309. 9,
  310. };
  311. static const int8_t mpc8_q3_syms[MPC8_Q3_SIZE] = {
  312. 48, 65, 64, 49, 63, 32, 47, 80,
  313. 79, 50, 62, 33, 16, 82, 81, 95,
  314. 94, 66, 78, 34, 46, 17, 31, 30,
  315. 97, 96, 111, 67, 77, 51, 61, 35,
  316. 45, 18, 1, 0, 15, 98, 110, 83,
  317. 93, 19, 29, 2, 14, 99, 109, 3,
  318. 13,
  319. };
  320. #define MPC8_Q4_SIZE 81
  321. #define MPC8_Q4_BITS 9
  322. #define MPC8_Q4_OFFSET -64
  323. static const uint8_t mpc8_q4_codes[MPC8_Q4_SIZE] = {
  324. 0x0F, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x17,
  325. 0x16, 0x15, 0x14, 0x13, 0x12, 0x23, 0x22, 0x21,
  326. 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19,
  327. 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11,
  328. 0x10, 0x0F, 0x0E, 0x0D, 0x19, 0x18, 0x17, 0x16,
  329. 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0F, 0x0E,
  330. 0x0D, 0x0C, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12,
  331. 0x11, 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A,
  332. 0x09, 0x08, 0x07, 0x06, 0x05, 0x09, 0x08, 0x07,
  333. 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x01,
  334. 0x00,
  335. };
  336. static const int8_t mpc8_q4_bits[MPC8_Q4_SIZE] = {
  337. 4, 5, 5, 5, 5, 5, 5, 5,
  338. 5, 5, 5, 5, 5, 6, 6, 6,
  339. 6, 6, 6, 6, 6, 6, 6, 6,
  340. 6, 6, 6, 6, 6, 6, 6, 6,
  341. 6, 6, 6, 6, 7, 7, 7, 7,
  342. 7, 7, 7, 7, 7, 7, 7, 7,
  343. 7, 7, 8, 8, 8, 8, 8, 8,
  344. 8, 8, 8, 8, 8, 8, 8, 8,
  345. 8, 8, 8, 8, 8, 9, 9, 9,
  346. 9, 9, 9, 9, 9, 10, 10, 10,
  347. 10,
  348. };
  349. static const int8_t mpc8_q4_syms[MPC8_Q4_SIZE] = {
  350. 64, 96, 81, 80, 95, 66, 65, 79,
  351. 78, 49, 48, 63, 32, 113, 112, 98,
  352. 97, 111, 110, 83, 82, 94, 93, 67,
  353. 77, 51, 50, 62, 61, 34, 33, 47,
  354. 46, 17, 16, 31, 128, 114, 127, 126,
  355. 99, 109, 68, 76, 35, 45, 18, 30,
  356. 0, 15, 130, 129, 143, 142, 115, 125,
  357. 100, 108, 84, 92, 52, 60, 36, 44,
  358. 19, 29, 2, 1, 14, 131, 141, 116,
  359. 124, 20, 28, 3, 13, 132, 140, 4,
  360. 12,
  361. };
  362. #define MPC8_Q5_SIZE 15
  363. #define MPC8_Q5_BITS 7
  364. #define MPC8_Q5_OFFSET -7
  365. static const uint8_t mpc8_q5_codes[2][MPC8_Q5_SIZE] = {
  366. {
  367. 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03,
  368. 0x04, 0x05, 0x03, 0x03, 0x03, 0x02, 0x03,
  369. },
  370. {
  371. 0x00, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x05,
  372. 0x06, 0x07, 0x04, 0x05, 0x03, 0x02, 0x03,
  373. }
  374. };
  375. static const int8_t mpc8_q5_bits[2][MPC8_Q5_SIZE] = {
  376. {
  377. 7, 7, 6, 5, 4, 3, 3, 2,
  378. 3, 3, 4, 5, 6, 7, 7,
  379. },
  380. {
  381. 6, 6, 5, 4, 4, 3, 3, 3,
  382. 3, 3, 4, 4, 5, 6, 6,
  383. }
  384. };
  385. #define MPC8_Q6_SIZE 31
  386. #define MPC8_Q6_BITS 9
  387. #define MPC8_Q6_OFFSET -15
  388. static const uint8_t mpc8_q6_codes[2][MPC8_Q6_SIZE] = {
  389. {
  390. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x04, 0x03,
  391. 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x04, 0x03,
  392. 0x05, 0x06, 0x07, 0x07, 0x06, 0x07, 0x08, 0x09,
  393. 0x05, 0x06, 0x07, 0x04, 0x05, 0x06, 0x07,
  394. },
  395. {
  396. 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x05, 0x04,
  397. 0x05, 0x06, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
  398. 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x07, 0x08, 0x09,
  399. 0x06, 0x07, 0x05, 0x06, 0x07, 0x02, 0x03,
  400. }
  401. };
  402. static const int8_t mpc8_q6_bits[2][MPC8_Q6_SIZE] = {
  403. {
  404. 9, 9, 9, 9, 8, 8, 7, 6,
  405. 6, 6, 5, 5, 4, 4, 3, 2,
  406. 3, 4, 4, 5, 6, 6, 6, 6,
  407. 7, 8, 8, 9, 9, 9, 9,
  408. },
  409. {
  410. 8, 8, 7, 7, 7, 6, 6, 5,
  411. 5, 5, 4, 4, 4, 4, 4, 4,
  412. 4, 4, 4, 4, 4, 5, 5, 5,
  413. 6, 6, 7, 7, 7, 8, 8,
  414. }
  415. };
  416. #define MPC8_Q7_SIZE 63
  417. #define MPC8_Q7_BITS 9
  418. #define MPC8_Q7_OFFSET -31
  419. static const uint8_t mpc8_q7_codes[2][MPC8_Q7_SIZE] = {
  420. {
  421. 0x00, 0x01, 0x02, 0x08, 0x09, 0x03, 0x04, 0x05,
  422. 0x06, 0x07, 0x0A, 0x0B, 0x0C, 0x0D, 0x0A, 0x0B,
  423. 0x0C, 0x0D, 0x0E, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
  424. 0x0A, 0x0B, 0x0C, 0x08, 0x09, 0x06, 0x04, 0x03,
  425. 0x05, 0x07, 0x0A, 0x0B, 0x0D, 0x0E, 0x0F, 0x0F,
  426. 0x10, 0x11, 0x12, 0x0F, 0x13, 0x10, 0x11, 0x12,
  427. 0x13, 0x0E, 0x0F, 0x10, 0x11, 0x08, 0x09, 0x0A,
  428. 0x0B, 0x0C, 0x12, 0x13, 0x0D, 0x0E, 0x0F,
  429. },
  430. {
  431. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  432. 0x08, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x09, 0x0A,
  433. 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x0C, 0x0D,
  434. 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
  435. 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D,
  436. 0x1E, 0x1F, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
  437. 0x17, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x09, 0x0A,
  438. 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x02, 0x03,
  439. }
  440. };
  441. static const int8_t mpc8_q7_bits[2][MPC8_Q7_SIZE] = {
  442. {
  443. 10, 10, 10, 9, 9, 10, 10, 10,
  444. 10, 10, 9, 9, 9, 9, 8, 8,
  445. 8, 8, 8, 7, 7, 7, 7, 7,
  446. 6, 6, 6, 5, 5, 4, 3, 2,
  447. 3, 4, 5, 5, 6, 6, 6, 7,
  448. 7, 7, 7, 8, 7, 8, 8, 8,
  449. 8, 9, 9, 9, 9, 10, 10, 10,
  450. 10, 10, 9, 9, 10, 10, 10,
  451. },
  452. {
  453. 9, 9, 8, 8, 8, 8, 8, 8,
  454. 8, 7, 7, 7, 7, 7, 6, 6,
  455. 6, 6, 6, 6, 6, 6, 5, 5,
  456. 5, 5, 5, 5, 5, 5, 5, 5,
  457. 5, 5, 5, 5, 5, 5, 5, 5,
  458. 5, 5, 6, 6, 6, 6, 6, 6,
  459. 6, 7, 7, 7, 7, 7, 8, 8,
  460. 8, 8, 8, 8, 8, 9, 9,
  461. }
  462. };
  463. #define MPC8_Q8_SIZE 127
  464. #define MPC8_Q8_BITS 9
  465. #define MPC8_Q8_OFFSET -63
  466. static const uint8_t mpc8_q8_codes[2][MPC8_Q8_SIZE] = {
  467. {
  468. 0x03, 0x04, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x1A,
  469. 0x0F, 0x1B, 0x10, 0x00, 0x01, 0x05, 0x06, 0x07,
  470. 0x08, 0x09, 0x0A, 0x0B, 0x11, 0x0C, 0x12, 0x13,
  471. 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1C, 0x1A,
  472. 0x1B, 0x1C, 0x1D, 0x1E, 0x1D, 0x1E, 0x1F, 0x20,
  473. 0x21, 0x22, 0x23, 0x24, 0x19, 0x25, 0x1A, 0x1B,
  474. 0x1C, 0x1D, 0x1E, 0x1F, 0x14, 0x15, 0x16, 0x17,
  475. 0x0E, 0x0F, 0x10, 0x11, 0x0B, 0x07, 0x04, 0x03,
  476. 0x05, 0x0C, 0x0D, 0x12, 0x13, 0x14, 0x15, 0x18,
  477. 0x19, 0x1A, 0x1B, 0x20, 0x21, 0x22, 0x23, 0x24,
  478. 0x25, 0x26, 0x27, 0x26, 0x27, 0x28, 0x29, 0x2A,
  479. 0x2B, 0x2C, 0x2D, 0x2E, 0x1F, 0x20, 0x2F, 0x21,
  480. 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
  481. 0x0D, 0x0E, 0x2A, 0x0F, 0x10, 0x11, 0x12, 0x02,
  482. 0x13, 0x03, 0x04, 0x05, 0x2B, 0x2C, 0x30, 0x31,
  483. 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
  484. },
  485. {
  486. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  487. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  488. 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 0x16,
  489. 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E,
  490. 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
  491. 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,
  492. 0x2F, 0x30, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
  493. 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33,
  494. 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
  495. 0x3C, 0x3D, 0x3E, 0x31, 0x3F, 0x32, 0x33, 0x34,
  496. 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
  497. 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44,
  498. 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x16,
  499. 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E,
  500. 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
  501. 0x27, 0x28, 0x29, 0x04, 0x05, 0x06, 0x07,
  502. }
  503. };
  504. static const int8_t mpc8_q8_bits[2][MPC8_Q8_SIZE] = {
  505. {
  506. 11, 11, 10, 10, 10, 10, 10, 9,
  507. 10, 9, 10, 12, 12, 11, 11, 11,
  508. 11, 11, 11, 11, 10, 11, 10, 10,
  509. 10, 10, 10, 10, 10, 10, 9, 10,
  510. 10, 10, 10, 10, 9, 9, 9, 9,
  511. 9, 9, 9, 9, 8, 9, 8, 8,
  512. 8, 8, 8, 8, 7, 7, 7, 7,
  513. 6, 6, 6, 6, 5, 4, 3, 2,
  514. 3, 5, 5, 6, 6, 6, 6, 7,
  515. 7, 7, 7, 8, 8, 8, 8, 8,
  516. 8, 8, 8, 9, 9, 9, 9, 9,
  517. 9, 9, 9, 9, 10, 10, 9, 10,
  518. 10, 10, 10, 10, 10, 10, 10, 10,
  519. 11, 11, 10, 11, 11, 11, 11, 12,
  520. 11, 12, 12, 12, 10, 10, 9, 9,
  521. 10, 10, 10, 10, 10, 10, 10,
  522. },
  523. {
  524. 9, 9, 9, 9, 8, 8, 8, 8,
  525. 8, 8, 8, 8, 8, 8, 8, 8,
  526. 8, 8, 8, 8, 8, 8, 7, 7,
  527. 7, 7, 7, 7, 7, 7, 7, 7,
  528. 7, 7, 7, 7, 7, 7, 7, 7,
  529. 7, 7, 7, 7, 7, 7, 7, 7,
  530. 7, 7, 6, 6, 6, 6, 6, 6,
  531. 6, 6, 6, 6, 6, 6, 6, 6,
  532. 6, 6, 6, 6, 6, 6, 6, 6,
  533. 6, 6, 6, 7, 6, 7, 7, 7,
  534. 7, 7, 7, 7, 7, 7, 7, 7,
  535. 7, 7, 7, 7, 7, 7, 7, 7,
  536. 7, 7, 7, 7, 7, 7, 7, 8,
  537. 8, 8, 8, 8, 8, 8, 8, 8,
  538. 8, 8, 8, 8, 8, 8, 8, 8,
  539. 8, 8, 8, 9, 9, 9, 9,
  540. }
  541. };
  542. #endif /* AVCODEC_MPC8HUFF_H */