bitno.tab 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*
  2. ********************************************************************************
  3. *
  4. * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
  5. * R99 Version 3.3.0
  6. * REL-4 Version 4.1.0
  7. *
  8. ********************************************************************************
  9. *
  10. * File : bitno.tab
  11. * Purpose : Tables for bit2prm and prm2bit
  12. *
  13. ********************************************************************************
  14. */
  15. #ifndef bitno_tab
  16. #define bitno_tab
  17. static const char bitno_id[] = "@(#)$Id $";
  18. #include "cnst.h" /* parameter sizes: MAX_PRM_SIZE */
  19. #include "mode.h" /* N_MODES */
  20. #define BIT_0 0
  21. #define BIT_1 1
  22. #define PRMNO_MR475 17
  23. #define PRMNO_MR515 19
  24. #define PRMNO_MR59 19
  25. #define PRMNO_MR67 19
  26. #define PRMNO_MR74 19
  27. #define PRMNO_MR795 23
  28. #define PRMNO_MR102 39
  29. #define PRMNO_MR122 57
  30. #define PRMNO_MRDTX 5
  31. /* number of parameters per modes (values must be <= MAX_PRM_SIZE!) */
  32. static const Word16 prmno[N_MODES] = {
  33. PRMNO_MR475,
  34. PRMNO_MR515,
  35. PRMNO_MR59,
  36. PRMNO_MR67,
  37. PRMNO_MR74,
  38. PRMNO_MR795,
  39. PRMNO_MR102,
  40. PRMNO_MR122,
  41. PRMNO_MRDTX
  42. };
  43. /* number of parameters to first subframe */
  44. #define PRMNOFSF_MR475 7
  45. #define PRMNOFSF_MR515 7
  46. #define PRMNOFSF_MR59 7
  47. #define PRMNOFSF_MR67 7
  48. #define PRMNOFSF_MR74 7
  49. #define PRMNOFSF_MR795 8
  50. #define PRMNOFSF_MR102 12
  51. #define PRMNOFSF_MR122 18
  52. /* number of parameters to first subframe per modes */
  53. static const Word16 prmnofsf[N_MODES - 1] = {
  54. PRMNOFSF_MR475,
  55. PRMNOFSF_MR515,
  56. PRMNOFSF_MR59,
  57. PRMNOFSF_MR67,
  58. PRMNOFSF_MR74,
  59. PRMNOFSF_MR795,
  60. PRMNOFSF_MR102,
  61. PRMNOFSF_MR122
  62. };
  63. /* parameter sizes (# of bits), one table per mode */
  64. static const Word16 bitno_MR475[PRMNO_MR475] = {
  65. 8, 8, 7, /* LSP VQ */
  66. 8, 7, 2, 8, /* first subframe */
  67. 4, 7, 2, /* second subframe */
  68. 4, 7, 2, 8, /* third subframe */
  69. 4, 7, 2, /* fourth subframe */
  70. };
  71. static const Word16 bitno_MR515[PRMNO_MR515] = {
  72. 8, 8, 7, /* LSP VQ */
  73. 8, 7, 2, 6, /* first subframe */
  74. 4, 7, 2, 6, /* second subframe */
  75. 4, 7, 2, 6, /* third subframe */
  76. 4, 7, 2, 6, /* fourth subframe */
  77. };
  78. static const Word16 bitno_MR59[PRMNO_MR59] = {
  79. 8, 9, 9, /* LSP VQ */
  80. 8, 9, 2, 6, /* first subframe */
  81. 4, 9, 2, 6, /* second subframe */
  82. 8, 9, 2, 6, /* third subframe */
  83. 4, 9, 2, 6, /* fourth subframe */
  84. };
  85. static const Word16 bitno_MR67[PRMNO_MR67] = {
  86. 8, 9, 9, /* LSP VQ */
  87. 8, 11, 3, 7, /* first subframe */
  88. 4, 11, 3, 7, /* second subframe */
  89. 8, 11, 3, 7, /* third subframe */
  90. 4, 11, 3, 7, /* fourth subframe */
  91. };
  92. static const Word16 bitno_MR74[PRMNO_MR74] = {
  93. 8, 9, 9, /* LSP VQ */
  94. 8, 13, 4, 7, /* first subframe */
  95. 5, 13, 4, 7, /* second subframe */
  96. 8, 13, 4, 7, /* third subframe */
  97. 5, 13, 4, 7, /* fourth subframe */
  98. };
  99. static const Word16 bitno_MR795[PRMNO_MR795] = {
  100. 9, 9, 9, /* LSP VQ */
  101. 8, 13, 4, 4, 5, /* first subframe */
  102. 6, 13, 4, 4, 5, /* second subframe */
  103. 8, 13, 4, 4, 5, /* third subframe */
  104. 6, 13, 4, 4, 5, /* fourth subframe */
  105. };
  106. static const Word16 bitno_MR102[PRMNO_MR102] = {
  107. 8, 9, 9, /* LSP VQ */
  108. 8, 1, 1, 1, 1, 10, 10, 7, 7, /* first subframe */
  109. 5, 1, 1, 1, 1, 10, 10, 7, 7, /* second subframe */
  110. 8, 1, 1, 1, 1, 10, 10, 7, 7, /* third subframe */
  111. 5, 1, 1, 1, 1, 10, 10, 7, 7, /* fourth subframe */
  112. };
  113. static const Word16 bitno_MR122[PRMNO_MR122] = {
  114. 7, 8, 9, 8, 6, /* LSP VQ */
  115. 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* first subframe */
  116. 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* second subframe */
  117. 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* third subframe */
  118. 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5 /* fourth subframe */
  119. };
  120. static const Word16 bitno_MRDTX[PRMNO_MRDTX] = {
  121. 3,
  122. 8, 9, 9,
  123. 6
  124. };
  125. /* overall table with all parameter sizes for all modes */
  126. static const Word16 *bitno[N_MODES] = {
  127. bitno_MR475,
  128. bitno_MR515,
  129. bitno_MR59,
  130. bitno_MR67,
  131. bitno_MR74,
  132. bitno_MR795,
  133. bitno_MR102,
  134. bitno_MR122,
  135. bitno_MRDTX
  136. };
  137. #ifdef MMS_IO
  138. /* table of contents byte for each mode index */
  139. static UWord8 toc_byte[16] = {0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C,
  140. 0x44, 0x4C, 0x54, 0x5C, 0x64, 0x6C, 0x74, 0x7C};
  141. /* number of speech bits for all modes */
  142. static Word16 unpacked_size[16] = {95, 103, 118, 134, 148, 159, 204, 244,
  143. 35, 0, 0, 0, 0, 0, 0, 0};
  144. /* size of packed frame for each mode */
  145. static Word16 packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32,
  146. 6, 0, 0, 0, 0, 0, 0, 1};
  147. /* number of unused speech bits in packed format for each mode */
  148. static Word16 unused_size[16] = {1, 1, 2, 2, 4, 1, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0};
  149. /* sorting tables for all modes */
  150. static Word16 sort_475[95] = {
  151. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  152. 10, 11, 12, 13, 14, 15, 23, 24, 25, 26,
  153. 27, 28, 48, 49, 61, 62, 82, 83, 47, 46,
  154. 45, 44, 81, 80, 79, 78, 17, 18, 20, 22,
  155. 77, 76, 75, 74, 29, 30, 43, 42, 41, 40,
  156. 38, 39, 16, 19, 21, 50, 51, 59, 60, 63,
  157. 64, 72, 73, 84, 85, 93, 94, 32, 33, 35,
  158. 36, 53, 54, 56, 57, 66, 67, 69, 70, 87,
  159. 88, 90, 91, 34, 55, 68, 89, 37, 58, 71,
  160. 92, 31, 52, 65, 86
  161. };
  162. static Word16 sort_515[103] = {
  163. 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
  164. 13, 12, 11, 10, 9, 8, 23, 24, 25, 26,
  165. 27, 46, 65, 84, 45, 44, 43, 64, 63, 62,
  166. 83, 82, 81, 102, 101, 100, 42, 61, 80, 99,
  167. 28, 47, 66, 85, 18, 41, 60, 79, 98, 29,
  168. 48, 67, 17, 20, 22, 40, 59, 78, 97, 21,
  169. 30, 49, 68, 86, 19, 16, 87, 39, 38, 58,
  170. 57, 77, 35, 54, 73, 92, 76, 96, 95, 36,
  171. 55, 74, 93, 32, 51, 33, 52, 70, 71, 89,
  172. 90, 31, 50, 69, 88, 37, 56, 75, 94, 34,
  173. 53, 72, 91
  174. };
  175. static Word16 sort_59[118] = {
  176. 0, 1, 4, 5, 3, 6, 7, 2, 13, 15,
  177. 8, 9, 11, 12, 14, 10, 16, 28, 74, 29,
  178. 75, 27, 73, 26, 72, 30, 76, 51, 97, 50,
  179. 71, 96, 117, 31, 77, 52, 98, 49, 70, 95,
  180. 116, 53, 99, 32, 78, 33, 79, 48, 69, 94,
  181. 115, 47, 68, 93, 114, 46, 67, 92, 113, 19,
  182. 21, 23, 22, 18, 17, 20, 24, 111, 43, 89,
  183. 110, 64, 65, 44, 90, 25, 45, 66, 91, 112,
  184. 54, 100, 40, 61, 86, 107, 39, 60, 85, 106,
  185. 36, 57, 82, 103, 35, 56, 81, 102, 34, 55,
  186. 80, 101, 42, 63, 88, 109, 41, 62, 87, 108,
  187. 38, 59, 84, 105, 37, 58, 83, 104
  188. };
  189. static Word16 sort_67[134] = {
  190. 0, 1, 4, 3, 5, 6, 13, 7, 2, 8,
  191. 9, 11, 15, 12, 14, 10, 28, 82, 29, 83,
  192. 27, 81, 26, 80, 30, 84, 16, 55, 109, 56,
  193. 110, 31, 85, 57, 111, 48, 73, 102, 127, 32,
  194. 86, 51, 76, 105, 130, 52, 77, 106, 131, 58,
  195. 112, 33, 87, 19, 23, 53, 78, 107, 132, 21,
  196. 22, 18, 17, 20, 24, 25, 50, 75, 104, 129,
  197. 47, 72, 101, 126, 54, 79, 108, 133, 46, 71,
  198. 100, 125, 128, 103, 74, 49, 45, 70, 99, 124,
  199. 42, 67, 96, 121, 39, 64, 93, 118, 38, 63,
  200. 92, 117, 35, 60, 89, 114, 34, 59, 88, 113,
  201. 44, 69, 98, 123, 43, 68, 97, 122, 41, 66,
  202. 95, 120, 40, 65, 94, 119, 37, 62, 91, 116,
  203. 36, 61, 90, 115
  204. };
  205. static Word16 sort_74[148] = {
  206. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  207. 10, 11, 12, 13, 14, 15, 16, 26, 87, 27,
  208. 88, 28, 89, 29, 90, 30, 91, 51, 80, 112,
  209. 141, 52, 81, 113, 142, 54, 83, 115, 144, 55,
  210. 84, 116, 145, 58, 119, 59, 120, 21, 22, 23,
  211. 17, 18, 19, 31, 60, 92, 121, 56, 85, 117,
  212. 146, 20, 24, 25, 50, 79, 111, 140, 57, 86,
  213. 118, 147, 49, 78, 110, 139, 48, 77, 53, 82,
  214. 114, 143, 109, 138, 47, 76, 108, 137, 32, 33,
  215. 61, 62, 93, 94, 122, 123, 41, 42, 43, 44,
  216. 45, 46, 70, 71, 72, 73, 74, 75, 102, 103,
  217. 104, 105, 106, 107, 131, 132, 133, 134, 135, 136,
  218. 34, 63, 95, 124, 35, 64, 96, 125, 36, 65,
  219. 97, 126, 37, 66, 98, 127, 38, 67, 99, 128,
  220. 39, 68, 100, 129, 40, 69, 101, 130
  221. };
  222. static Word16 sort_795[159] = {
  223. 8, 7, 6, 5, 4, 3, 2, 14, 16, 9,
  224. 10, 12, 13, 15, 11, 17, 20, 22, 24, 23,
  225. 19, 18, 21, 56, 88, 122, 154, 57, 89, 123,
  226. 155, 58, 90, 124, 156, 52, 84, 118, 150, 53,
  227. 85, 119, 151, 27, 93, 28, 94, 29, 95, 30,
  228. 96, 31, 97, 61, 127, 62, 128, 63, 129, 59,
  229. 91, 125, 157, 32, 98, 64, 130, 1, 0, 25,
  230. 26, 33, 99, 34, 100, 65, 131, 66, 132, 54,
  231. 86, 120, 152, 60, 92, 126, 158, 55, 87, 121,
  232. 153, 117, 116, 115, 46, 78, 112, 144, 43, 75,
  233. 109, 141, 40, 72, 106, 138, 36, 68, 102, 134,
  234. 114, 149, 148, 147, 146, 83, 82, 81, 80, 51,
  235. 50, 49, 48, 47, 45, 44, 42, 39, 35, 79,
  236. 77, 76, 74, 71, 67, 113, 111, 110, 108, 105,
  237. 101, 145, 143, 142, 140, 137, 133, 41, 73, 107,
  238. 139, 37, 69, 103, 135, 38, 70, 104, 136
  239. };
  240. static Word16 sort_102[204] = {
  241. 7, 6, 5, 4, 3, 2, 1, 0, 16, 15,
  242. 14, 13, 12, 11, 10, 9, 8, 26, 27, 28,
  243. 29, 30, 31, 115, 116, 117, 118, 119, 120, 72,
  244. 73, 161, 162, 65, 68, 69, 108, 111, 112, 154,
  245. 157, 158, 197, 200, 201, 32, 33, 121, 122, 74,
  246. 75, 163, 164, 66, 109, 155, 198, 19, 23, 21,
  247. 22, 18, 17, 20, 24, 25, 37, 36, 35, 34,
  248. 80, 79, 78, 77, 126, 125, 124, 123, 169, 168,
  249. 167, 166, 70, 67, 71, 113, 110, 114, 159, 156,
  250. 160, 202, 199, 203, 76, 165, 81, 82, 92, 91,
  251. 93, 83, 95, 85, 84, 94, 101, 102, 96, 104,
  252. 86, 103, 87, 97, 127, 128, 138, 137, 139, 129,
  253. 141, 131, 130, 140, 147, 148, 142, 150, 132, 149,
  254. 133, 143, 170, 171, 181, 180, 182, 172, 184, 174,
  255. 173, 183, 190, 191, 185, 193, 175, 192, 176, 186,
  256. 38, 39, 49, 48, 50, 40, 52, 42, 41, 51,
  257. 58, 59, 53, 61, 43, 60, 44, 54, 194, 179,
  258. 189, 196, 177, 195, 178, 187, 188, 151, 136, 146,
  259. 153, 134, 152, 135, 144, 145, 105, 90, 100, 107,
  260. 88, 106, 89, 98, 99, 62, 47, 57, 64, 45,
  261. 63, 46, 55, 56
  262. };
  263. static Word16 sort_122[244] = {
  264. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  265. 10, 11, 12, 13, 14, 23, 15, 16, 17, 18,
  266. 19, 20, 21, 22, 24, 25, 26, 27, 28, 38,
  267. 141, 39, 142, 40, 143, 41, 144, 42, 145, 43,
  268. 146, 44, 147, 45, 148, 46, 149, 47, 97, 150,
  269. 200, 48, 98, 151, 201, 49, 99, 152, 202, 86,
  270. 136, 189, 239, 87, 137, 190, 240, 88, 138, 191,
  271. 241, 91, 194, 92, 195, 93, 196, 94, 197, 95,
  272. 198, 29, 30, 31, 32, 33, 34, 35, 50, 100,
  273. 153, 203, 89, 139, 192, 242, 51, 101, 154, 204,
  274. 55, 105, 158, 208, 90, 140, 193, 243, 59, 109,
  275. 162, 212, 63, 113, 166, 216, 67, 117, 170, 220,
  276. 36, 37, 54, 53, 52, 58, 57, 56, 62, 61,
  277. 60, 66, 65, 64, 70, 69, 68, 104, 103, 102,
  278. 108, 107, 106, 112, 111, 110, 116, 115, 114, 120,
  279. 119, 118, 157, 156, 155, 161, 160, 159, 165, 164,
  280. 163, 169, 168, 167, 173, 172, 171, 207, 206, 205,
  281. 211, 210, 209, 215, 214, 213, 219, 218, 217, 223,
  282. 222, 221, 73, 72, 71, 76, 75, 74, 79, 78,
  283. 77, 82, 81, 80, 85, 84, 83, 123, 122, 121,
  284. 126, 125, 124, 129, 128, 127, 132, 131, 130, 135,
  285. 134, 133, 176, 175, 174, 179, 178, 177, 182, 181,
  286. 180, 185, 184, 183, 188, 187, 186, 226, 225, 224,
  287. 229, 228, 227, 232, 231, 230, 235, 234, 233, 238,
  288. 237, 236, 96, 199
  289. };
  290. static Word16 sort_SID[35] = {
  291. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  292. 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  293. 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  294. 30, 31, 32, 33, 34
  295. };
  296. /* pointer table for bit sorting tables */
  297. static Word16 *sort_ptr[16] = {sort_475, sort_515, sort_59, sort_67, sort_74, sort_795, sort_102, sort_122,
  298. sort_SID, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
  299. #endif
  300. #endif