huffenc.c 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <ogg/ogg.h>
  4. #include "huffenc.h"
  5. /*The default Huffman codes used for VP3.1.*/
  6. const th_huff_code TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]={
  7. {
  8. {0x002D, 6},{0x0026, 7},{0x0166, 9},{0x004E, 8},
  9. {0x02CE,10},{0x059E,11},{0x027D,11},{0x0008, 5},
  10. {0x04F9,12},{0x000F, 4},{0x000E, 4},{0x001B, 5},
  11. {0x0006, 4},{0x0008, 4},{0x0005, 4},{0x001A, 5},
  12. {0x0015, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
  13. {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x0029, 6},
  14. {0x0028, 6},{0x00B2, 8},{0x04F8,12},{0x059F,11},
  15. {0x009E, 9},{0x013F,10},{0x0012, 6},{0x0058, 7}
  16. },
  17. {
  18. {0x0010, 5},{0x0047, 7},{0x01FF, 9},{0x008C, 8},
  19. {0x03FC,10},{0x046A,11},{0x0469,11},{0x0022, 6},
  20. {0x11A1,13},{0x000E, 4},{0x000D, 4},{0x0004, 4},
  21. {0x0005, 4},{0x0009, 4},{0x0006, 4},{0x001E, 5},
  22. {0x0016, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
  23. {0x0000, 3},{0x000A, 4},{0x0017, 5},{0x007D, 7},
  24. {0x007E, 7},{0x011B, 9},{0x08D1,12},{0x03FD,10},
  25. {0x046B,11},{0x11A0,13},{0x007C, 7},{0x00FE, 8}
  26. },
  27. {
  28. {0x0016, 5},{0x0020, 6},{0x0086, 8},{0x0087, 8},
  29. {0x0367,10},{0x06CC,11},{0x06CB,11},{0x006E, 7},
  30. {0x366D,14},{0x000F, 4},{0x000E, 4},{0x0004, 4},
  31. {0x0005, 4},{0x000A, 4},{0x0006, 4},{0x001A, 5},
  32. {0x0011, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
  33. {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x006F, 7},
  34. {0x006D, 7},{0x0364,10},{0x0D9A,12},{0x06CA,11},
  35. {0x1B37,13},{0x366C,14},{0x0042, 7},{0x00D8, 8}
  36. },
  37. {
  38. {0x0000, 4},{0x002D, 6},{0x00F7, 8},{0x0058, 7},
  39. {0x0167, 9},{0x02CB,10},{0x02CA,10},{0x000E, 6},
  40. {0x1661,13},{0x0003, 3},{0x0002, 3},{0x0008, 4},
  41. {0x0009, 4},{0x000D, 4},{0x0002, 4},{0x001F, 5},
  42. {0x0017, 5},{0x0001, 4},{0x000C, 4},{0x000E, 4},
  43. {0x000A, 4},{0x0006, 5},{0x0078, 7},{0x000F, 6},
  44. {0x007A, 7},{0x0164, 9},{0x0599,11},{0x02CD,10},
  45. {0x0B31,12},{0x1660,13},{0x0079, 7},{0x00F6, 8}
  46. },
  47. {
  48. {0x0003, 4},{0x003C, 6},{0x000F, 7},{0x007A, 7},
  49. {0x001D, 8},{0x0020, 9},{0x0072,10},{0x0006, 6},
  50. {0x0399,13},{0x0004, 3},{0x0005, 3},{0x0005, 4},
  51. {0x0006, 4},{0x000E, 4},{0x0004, 4},{0x0000, 4},
  52. {0x0019, 5},{0x0002, 4},{0x000D, 4},{0x0007, 4},
  53. {0x001F, 5},{0x0030, 6},{0x0011, 8},{0x0031, 6},
  54. {0x0005, 6},{0x0021, 9},{0x00E7,11},{0x0038, 9},
  55. {0x01CD,12},{0x0398,13},{0x007B, 7},{0x0009, 7}
  56. },
  57. {
  58. {0x0009, 4},{0x0002, 5},{0x0074, 7},{0x0007, 6},
  59. {0x00EC, 8},{0x00D1, 9},{0x01A6,10},{0x0006, 6},
  60. {0x0D21,13},{0x0005, 3},{0x0006, 3},{0x0008, 4},
  61. {0x0007, 4},{0x000F, 4},{0x0004, 4},{0x0000, 4},
  62. {0x001C, 5},{0x0002, 4},{0x0005, 4},{0x0003, 4},
  63. {0x000C, 5},{0x0035, 7},{0x01A7,10},{0x001B, 6},
  64. {0x0077, 7},{0x01A5,10},{0x0349,11},{0x00D0, 9},
  65. {0x0691,12},{0x0D20,13},{0x0075, 7},{0x00ED, 8}
  66. },
  67. {
  68. {0x000A, 4},{0x000C, 5},{0x0012, 6},{0x001B, 6},
  69. {0x00B7, 8},{0x016C, 9},{0x0099, 9},{0x005A, 7},
  70. {0x16D8,13},{0x0007, 3},{0x0006, 3},{0x0009, 4},
  71. {0x0008, 4},{0x0000, 3},{0x0005, 4},{0x0017, 5},
  72. {0x000E, 5},{0x0002, 4},{0x0003, 4},{0x000F, 5},
  73. {0x001A, 6},{0x004D, 8},{0x2DB3,14},{0x002C, 6},
  74. {0x0011, 6},{0x02DA,10},{0x05B7,11},{0x0098, 9},
  75. {0x0B6D,12},{0x2DB2,14},{0x0010, 6},{0x0027, 7}
  76. },
  77. {
  78. {0x000D, 4},{0x000F, 5},{0x001D, 6},{0x0008, 5},
  79. {0x0051, 7},{0x0056, 8},{0x00AF, 9},{0x002A, 7},
  80. {0x148A,13},{0x0007, 3},{0x0000, 2},{0x0008, 4},
  81. {0x0009, 4},{0x000C, 4},{0x0006, 4},{0x0017, 5},
  82. {0x000B, 5},{0x0016, 5},{0x0015, 5},{0x0009, 5},
  83. {0x0050, 7},{0x00AE, 9},{0x2917,14},{0x001C, 6},
  84. {0x0014, 6},{0x0290,10},{0x0523,11},{0x0149, 9},
  85. {0x0A44,12},{0x2916,14},{0x0053, 7},{0x00A5, 8}
  86. },
  87. {
  88. {0x0001, 4},{0x001D, 6},{0x00F5, 8},{0x00F4, 8},
  89. {0x024D,10},{0x0499,11},{0x0498,11},{0x0001, 5},
  90. {0x0021, 6},{0x0006, 3},{0x0005, 3},{0x0006, 4},
  91. {0x0005, 4},{0x0002, 4},{0x0007, 5},{0x0025, 6},
  92. {0x007B, 7},{0x001C, 6},{0x0020, 6},{0x000D, 6},
  93. {0x0048, 7},{0x0092, 8},{0x0127, 9},{0x000E, 4},
  94. {0x0004, 4},{0x0011, 5},{0x000C, 6},{0x003C, 6},
  95. {0x000F, 5},{0x0000, 5},{0x001F, 5},{0x0013, 5}
  96. },
  97. {
  98. {0x0005, 4},{0x003C, 6},{0x0040, 7},{0x000D, 7},
  99. {0x0031, 9},{0x0061,10},{0x0060,10},{0x0002, 5},
  100. {0x00F5, 8},{0x0006, 3},{0x0005, 3},{0x0007, 4},
  101. {0x0006, 4},{0x0002, 4},{0x0009, 5},{0x0025, 6},
  102. {0x0007, 6},{0x0021, 6},{0x0024, 6},{0x0010, 6},
  103. {0x0041, 7},{0x00F4, 8},{0x0019, 8},{0x000E, 4},
  104. {0x0003, 4},{0x0011, 5},{0x0011, 6},{0x003F, 6},
  105. {0x003E, 6},{0x007B, 7},{0x0000, 4},{0x0013, 5}
  106. },
  107. {
  108. {0x000A, 4},{0x0007, 5},{0x0001, 6},{0x0009, 6},
  109. {0x0131, 9},{0x0261,10},{0x0260,10},{0x0015, 6},
  110. {0x0001, 7},{0x0007, 3},{0x0006, 3},{0x0008, 4},
  111. {0x0007, 4},{0x0006, 4},{0x0012, 5},{0x002F, 6},
  112. {0x0014, 6},{0x0027, 6},{0x002D, 6},{0x0016, 6},
  113. {0x004D, 7},{0x0099, 8},{0x0000, 7},{0x0004, 4},
  114. {0x0001, 4},{0x0005, 5},{0x0017, 6},{0x002E, 6},
  115. {0x002C, 6},{0x0008, 6},{0x0006, 5},{0x0001, 5}
  116. },
  117. {
  118. {0x0000, 3},{0x000E, 5},{0x0017, 6},{0x002A, 6},
  119. {0x0010, 7},{0x00F9,10},{0x00F8,10},{0x001E, 7},
  120. {0x003F, 8},{0x0007, 3},{0x0006, 3},{0x0009, 4},
  121. {0x0008, 4},{0x0006, 4},{0x000F, 5},{0x0005, 5},
  122. {0x0016, 6},{0x0029, 6},{0x002B, 6},{0x0015, 6},
  123. {0x0050, 7},{0x0011, 7},{0x007D, 9},{0x0004, 4},
  124. {0x0017, 5},{0x0006, 5},{0x0014, 6},{0x002C, 6},
  125. {0x002D, 6},{0x000E, 6},{0x0009, 6},{0x0051, 7}
  126. },
  127. {
  128. {0x0002, 3},{0x0018, 5},{0x002F, 6},{0x000D, 5},
  129. {0x0053, 7},{0x0295,10},{0x0294,10},{0x00A4, 8},
  130. {0x007C, 8},{0x0000, 2},{0x0007, 3},{0x0009, 4},
  131. {0x0008, 4},{0x001B, 5},{0x000C, 5},{0x0028, 6},
  132. {0x006A, 7},{0x001E, 6},{0x001D, 6},{0x0069, 7},
  133. {0x00D7, 8},{0x007D, 8},{0x014B, 9},{0x0019, 5},
  134. {0x0016, 5},{0x002E, 6},{0x001C, 6},{0x002B, 6},
  135. {0x002A, 6},{0x0068, 7},{0x003F, 7},{0x00D6, 8}
  136. },
  137. {
  138. {0x0002, 3},{0x001B, 5},{0x000C, 5},{0x0018, 5},
  139. {0x0029, 6},{0x007F, 8},{0x02F0,10},{0x0198, 9},
  140. {0x0179, 9},{0x0000, 2},{0x0007, 3},{0x0009, 4},
  141. {0x0008, 4},{0x001A, 5},{0x000D, 5},{0x002A, 6},
  142. {0x0064, 7},{0x001E, 6},{0x0067, 7},{0x005F, 7},
  143. {0x00CD, 8},{0x007E, 8},{0x02F1,10},{0x0016, 5},
  144. {0x000E, 5},{0x002E, 6},{0x0065, 7},{0x002B, 6},
  145. {0x0028, 6},{0x003E, 7},{0x00BD, 8},{0x0199, 9}
  146. },
  147. {
  148. {0x0002, 3},{0x0007, 4},{0x0016, 5},{0x0006, 4},
  149. {0x0036, 6},{0x005C, 7},{0x015D, 9},{0x015C, 9},
  150. {0x02BF,10},{0x0000, 2},{0x0007, 3},{0x0009, 4},
  151. {0x0008, 4},{0x0018, 5},{0x0034, 6},{0x002A, 6},
  152. {0x005E, 7},{0x006A, 7},{0x0064, 7},{0x005D, 7},
  153. {0x00CB, 8},{0x00AD, 8},{0x02BE,10},{0x0014, 5},
  154. {0x0033, 6},{0x006E, 7},{0x005F, 7},{0x006F, 7},
  155. {0x006B, 7},{0x00CA, 8},{0x00AC, 8},{0x015E, 9}
  156. },
  157. {
  158. {0x000F, 4},{0x001D, 5},{0x0018, 5},{0x000B, 4},
  159. {0x0019, 5},{0x0029, 6},{0x00D6, 8},{0x0551,11},
  160. {0x0AA1,12},{0x0001, 2},{0x0000, 2},{0x0009, 4},
  161. {0x0008, 4},{0x001B, 5},{0x0038, 6},{0x0028, 6},
  162. {0x0057, 7},{0x006A, 7},{0x0068, 7},{0x0056, 7},
  163. {0x00E5, 8},{0x0155, 9},{0x0AA0,12},{0x0073, 7},
  164. {0x0069, 7},{0x00D7, 8},{0x00AB, 8},{0x00E4, 8},
  165. {0x00A9, 8},{0x0151, 9},{0x0150, 9},{0x02A9,10}
  166. },
  167. {
  168. {0x0008, 5},{0x0025, 7},{0x017A, 9},{0x02F7,10},
  169. {0x0BDB,12},{0x17B4,13},{0x2F6B,14},{0x001D, 5},
  170. {0x2F6A,14},{0x0008, 4},{0x0007, 4},{0x0001, 4},
  171. {0x0002, 4},{0x000A, 4},{0x0006, 4},{0x0000, 4},
  172. {0x001C, 5},{0x0009, 4},{0x000D, 4},{0x000F, 4},
  173. {0x000C, 4},{0x0003, 4},{0x000A, 5},{0x0016, 5},
  174. {0x0013, 6},{0x005D, 7},{0x0024, 7},{0x00BC, 8},
  175. {0x005C, 7},{0x05EC,11},{0x000B, 5},{0x005F, 7}
  176. },
  177. {
  178. {0x000F, 5},{0x0010, 6},{0x004B, 8},{0x00C6, 8},
  179. {0x031D,10},{0x0C71,12},{0x0C70,12},{0x0001, 4},
  180. {0x0C73,12},{0x0008, 4},{0x0009, 4},{0x0002, 4},
  181. {0x0003, 4},{0x000B, 4},{0x0006, 4},{0x0000, 4},
  182. {0x001C, 5},{0x0005, 4},{0x000D, 4},{0x000F, 4},
  183. {0x000A, 4},{0x0019, 5},{0x0013, 6},{0x001D, 5},
  184. {0x0030, 6},{0x0062, 7},{0x0024, 7},{0x004A, 8},
  185. {0x018F, 9},{0x0C72,12},{0x000E, 5},{0x0011, 6}
  186. },
  187. {
  188. {0x001B, 5},{0x0003, 6},{0x008D, 8},{0x0040, 7},
  189. {0x0239,10},{0x0471,11},{0x08E0,12},{0x0003, 4},
  190. {0x11C3,13},{0x000A, 4},{0x0009, 4},{0x0004, 4},
  191. {0x0005, 4},{0x000E, 4},{0x0007, 4},{0x0001, 4},
  192. {0x001E, 5},{0x0006, 4},{0x000C, 4},{0x000B, 4},
  193. {0x0002, 4},{0x0000, 5},{0x0041, 7},{0x001F, 5},
  194. {0x0022, 6},{0x0002, 6},{0x008F, 8},{0x008C, 8},
  195. {0x011D, 9},{0x11C2,13},{0x001A, 5},{0x0021, 6}
  196. },
  197. {
  198. {0x001F, 5},{0x0003, 6},{0x0003, 7},{0x0043, 7},
  199. {0x000B, 9},{0x0015,10},{0x0051,12},{0x0003, 4},
  200. {0x0050,12},{0x000D, 4},{0x000C, 4},{0x0004, 4},
  201. {0x0006, 4},{0x000E, 4},{0x000A, 4},{0x0001, 4},
  202. {0x001E, 5},{0x0005, 4},{0x0009, 4},{0x0007, 4},
  203. {0x0011, 5},{0x0002, 6},{0x0004, 8},{0x0002, 4},
  204. {0x002D, 6},{0x0020, 6},{0x0042, 7},{0x0001, 7},
  205. {0x0000, 7},{0x0029,11},{0x0017, 5},{0x002C, 6}
  206. },
  207. {
  208. {0x0003, 4},{0x001F, 6},{0x003A, 7},{0x005D, 7},
  209. {0x0173, 9},{0x02E4,10},{0x172D,13},{0x0004, 4},
  210. {0x172C,13},{0x000F, 4},{0x000E, 4},{0x0009, 4},
  211. {0x0008, 4},{0x000C, 4},{0x000A, 4},{0x0001, 4},
  212. {0x0016, 5},{0x0002, 4},{0x0005, 4},{0x001A, 5},
  213. {0x002F, 6},{0x0038, 7},{0x05CA,11},{0x0006, 4},
  214. {0x0037, 6},{0x001E, 6},{0x003B, 7},{0x0039, 7},
  215. {0x00B8, 8},{0x0B97,12},{0x0000, 4},{0x0036, 6}
  216. },
  217. {
  218. {0x0006, 4},{0x0037, 6},{0x005D, 7},{0x000C, 6},
  219. {0x00B9, 8},{0x02E3,10},{0x05C4,11},{0x0004, 4},
  220. {0x1715,13},{0x0000, 3},{0x000F, 4},{0x0008, 4},
  221. {0x0007, 4},{0x000C, 4},{0x0009, 4},{0x001D, 5},
  222. {0x0016, 5},{0x001C, 5},{0x001A, 5},{0x000B, 5},
  223. {0x005E, 7},{0x0170, 9},{0x1714,13},{0x000A, 4},
  224. {0x000A, 5},{0x0036, 6},{0x005F, 7},{0x001B, 7},
  225. {0x001A, 7},{0x0B8B,12},{0x0002, 4},{0x0007, 5}
  226. },
  227. {
  228. {0x000C, 4},{0x000B, 5},{0x0079, 7},{0x0022, 6},
  229. {0x00F0, 8},{0x0119, 9},{0x0230,10},{0x001D, 5},
  230. {0x08C4,12},{0x0001, 3},{0x0000, 3},{0x000A, 4},
  231. {0x0009, 4},{0x000B, 4},{0x0007, 4},{0x001C, 5},
  232. {0x003D, 6},{0x000D, 5},{0x0008, 5},{0x0015, 6},
  233. {0x008D, 8},{0x118B,13},{0x118A,13},{0x000D, 4},
  234. {0x0010, 5},{0x0009, 5},{0x0014, 6},{0x0047, 7},
  235. {0x00F1, 8},{0x0463,11},{0x001F, 5},{0x000C, 5}
  236. },
  237. {
  238. {0x0000, 3},{0x001A, 5},{0x0033, 6},{0x000C, 5},
  239. {0x0046, 7},{0x01E3, 9},{0x03C5,10},{0x0017, 5},
  240. {0x1E21,13},{0x0002, 3},{0x0001, 3},{0x0009, 4},
  241. {0x000A, 4},{0x0007, 4},{0x001B, 5},{0x003D, 6},
  242. {0x001B, 6},{0x0022, 6},{0x0079, 7},{0x00F0, 8},
  243. {0x1E20,13},{0x1E23,13},{0x1E22,13},{0x000E, 4},
  244. {0x0016, 5},{0x0018, 5},{0x0032, 6},{0x001A, 6},
  245. {0x0047, 7},{0x0789,11},{0x001F, 5},{0x0010, 5}
  246. },
  247. {
  248. {0x001D, 5},{0x0061, 7},{0x004E, 8},{0x009E, 9},
  249. {0x027C,11},{0x09F5,13},{0x09F4,13},{0x0003, 4},
  250. {0x0060, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4},
  251. {0x000A, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5},
  252. {0x0031, 6},{0x0008, 5},{0x0038, 6},{0x0012, 6},
  253. {0x0026, 7},{0x013F,10},{0x04FB,12},{0x000D, 4},
  254. {0x0002, 4},{0x000C, 5},{0x0039, 6},{0x001C, 6},
  255. {0x000F, 5},{0x001D, 6},{0x0008, 4},{0x0019, 5}
  256. },
  257. {
  258. {0x0007, 4},{0x0019, 6},{0x00AB, 8},{0x00AA, 8},
  259. {0x0119,10},{0x0461,12},{0x0460,12},{0x001B, 5},
  260. {0x0047, 8},{0x0001, 3},{0x0000, 3},{0x000C, 4},
  261. {0x000B, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5},
  262. {0x0035, 6},{0x003D, 6},{0x003C, 6},{0x0018, 6},
  263. {0x0022, 7},{0x008D, 9},{0x0231,11},{0x000E, 4},
  264. {0x001F, 5},{0x0009, 5},{0x002B, 6},{0x0010, 6},
  265. {0x0034, 6},{0x0054, 7},{0x0008, 4},{0x0014, 5}
  266. },
  267. {
  268. {0x000C, 4},{0x0005, 5},{0x0008, 6},{0x005B, 7},
  269. {0x004D, 9},{0x0131,11},{0x0261,12},{0x001A, 5},
  270. {0x0012, 7},{0x0000, 3},{0x000F, 4},{0x000A, 4},
  271. {0x0009, 4},{0x0006, 4},{0x001B, 5},{0x0006, 5},
  272. {0x001C, 6},{0x002C, 6},{0x0015, 6},{0x005A, 7},
  273. {0x0027, 8},{0x0099,10},{0x0260,12},{0x000E, 4},
  274. {0x0004, 4},{0x000F, 5},{0x0007, 5},{0x001D, 6},
  275. {0x000B, 5},{0x0014, 6},{0x0008, 4},{0x0017, 5}
  276. },
  277. {
  278. {0x000F, 4},{0x0013, 5},{0x0075, 7},{0x0024, 6},
  279. {0x0095, 8},{0x0251,10},{0x04A0,11},{0x0010, 5},
  280. {0x00C8, 8},{0x0002, 3},{0x0001, 3},{0x0001, 4},
  281. {0x0000, 4},{0x001A, 5},{0x0011, 5},{0x002C, 6},
  282. {0x0065, 7},{0x0074, 7},{0x004B, 7},{0x00C9, 8},
  283. {0x0129, 9},{0x0943,12},{0x0942,12},{0x0003, 3},
  284. {0x000A, 4},{0x001C, 5},{0x0018, 5},{0x0033, 6},
  285. {0x0017, 5},{0x002D, 6},{0x001B, 5},{0x003B, 6}
  286. },
  287. {
  288. {0x0003, 3},{0x001A, 5},{0x002D, 6},{0x0038, 6},
  289. {0x0028, 7},{0x0395,10},{0x0E51,12},{0x0037, 6},
  290. {0x00E4, 8},{0x0001, 3},{0x0000, 3},{0x001F, 5},
  291. {0x001E, 5},{0x0017, 5},{0x003A, 6},{0x0073, 7},
  292. {0x002A, 7},{0x002B, 7},{0x0029, 7},{0x01CB, 9},
  293. {0x0729,11},{0x1CA1,13},{0x1CA0,13},{0x0004, 3},
  294. {0x000A, 4},{0x0004, 4},{0x0018, 5},{0x0036, 6},
  295. {0x000B, 5},{0x002C, 6},{0x0019, 5},{0x003B, 6}
  296. },
  297. {
  298. {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0017, 5},
  299. {0x0075, 7},{0x01F5, 9},{0x07D1,11},{0x0017, 6},
  300. {0x01F6, 9},{0x0001, 3},{0x0000, 3},{0x001B, 5},
  301. {0x001A, 5},{0x000A, 5},{0x0032, 6},{0x0074, 7},
  302. {0x00F8, 8},{0x00F9, 8},{0x01F7, 9},{0x03E9,10},
  303. {0x0FA0,12},{0x1F43,13},{0x1F42,13},{0x0003, 3},
  304. {0x000A, 4},{0x001E, 5},{0x001C, 5},{0x003B, 6},
  305. {0x0018, 5},{0x0016, 6},{0x0016, 5},{0x0033, 6}
  306. },
  307. {
  308. {0x0004, 3},{0x0007, 4},{0x0018, 5},{0x001E, 5},
  309. {0x0036, 6},{0x0031, 7},{0x0177, 9},{0x0077, 7},
  310. {0x0176, 9},{0x0001, 3},{0x0000, 3},{0x001A, 5},
  311. {0x0019, 5},{0x003A, 6},{0x0019, 6},{0x005C, 7},
  312. {0x00BA, 8},{0x0061, 8},{0x00C1, 9},{0x0180,10},
  313. {0x0302,11},{0x0607,12},{0x0606,12},{0x0002, 3},
  314. {0x000A, 4},{0x001F, 5},{0x001C, 5},{0x0037, 6},
  315. {0x0016, 5},{0x0076, 7},{0x000D, 5},{0x002F, 6}
  316. },
  317. {
  318. {0x0000, 3},{0x000A, 4},{0x001A, 5},{0x000C, 4},
  319. {0x001D, 5},{0x0039, 6},{0x0078, 7},{0x005E, 7},
  320. {0x0393,11},{0x0002, 3},{0x0001, 3},{0x0016, 5},
  321. {0x000F, 5},{0x002E, 6},{0x005F, 7},{0x0073, 8},
  322. {0x00E5, 9},{0x01C8,10},{0x0E4A,13},{0x1C97,14},
  323. {0x1C96,14},{0x0E49,13},{0x0E48,13},{0x0004, 3},
  324. {0x0006, 4},{0x001F, 5},{0x001B, 5},{0x001D, 6},
  325. {0x0038, 6},{0x0038, 7},{0x003D, 6},{0x0079, 7}
  326. },
  327. {
  328. {0x000B, 5},{0x002B, 7},{0x0054, 8},{0x01B7, 9},
  329. {0x06D9,11},{0x0DB1,12},{0x0DB0,12},{0x0002, 4},
  330. {0x00AB, 9},{0x0009, 4},{0x000A, 4},{0x0007, 4},
  331. {0x0008, 4},{0x000F, 4},{0x000C, 4},{0x0003, 4},
  332. {0x001D, 5},{0x0004, 4},{0x000B, 4},{0x0006, 4},
  333. {0x001A, 5},{0x0003, 6},{0x00AA, 9},{0x0001, 4},
  334. {0x0000, 5},{0x0014, 6},{0x006C, 7},{0x00DA, 8},
  335. {0x0002, 6},{0x036D,10},{0x001C, 5},{0x0037, 6}
  336. },
  337. {
  338. {0x001D, 5},{0x0004, 6},{0x00B6, 8},{0x006A, 8},
  339. {0x05B9,11},{0x16E1,13},{0x16E0,13},{0x0007, 4},
  340. {0x016F, 9},{0x000C, 4},{0x000D, 4},{0x0009, 4},
  341. {0x0008, 4},{0x000F, 4},{0x000A, 4},{0x0003, 4},
  342. {0x0017, 5},{0x0002, 4},{0x0004, 4},{0x001C, 5},
  343. {0x002C, 6},{0x006B, 8},{0x0B71,12},{0x0005, 4},
  344. {0x0003, 5},{0x001B, 6},{0x005A, 7},{0x0034, 7},
  345. {0x0005, 6},{0x02DD,10},{0x0000, 4},{0x000C, 5}
  346. },
  347. {
  348. {0x0003, 4},{0x007F, 7},{0x00A1, 8},{0x00A0, 8},
  349. {0x020C,10},{0x0834,12},{0x106B,13},{0x0007, 4},
  350. {0x0082, 8},{0x000E, 4},{0x000D, 4},{0x000B, 4},
  351. {0x000C, 4},{0x0000, 3},{0x0009, 4},{0x0002, 4},
  352. {0x0011, 5},{0x001E, 5},{0x0015, 5},{0x003E, 6},
  353. {0x0040, 7},{0x041B,11},{0x106A,13},{0x0006, 4},
  354. {0x000A, 5},{0x0029, 6},{0x007E, 7},{0x0051, 7},
  355. {0x0021, 6},{0x0107, 9},{0x0004, 4},{0x000B, 5}
  356. },
  357. {
  358. {0x0007, 4},{0x001B, 6},{0x00F6, 8},{0x00E9, 8},
  359. {0x03A1,10},{0x0740,11},{0x0E82,12},{0x001F, 5},
  360. {0x01EF, 9},{0x0001, 3},{0x0002, 3},{0x000B, 4},
  361. {0x000C, 4},{0x000D, 4},{0x0008, 4},{0x001C, 5},
  362. {0x0003, 5},{0x0012, 5},{0x0002, 5},{0x0075, 7},
  363. {0x01D1, 9},{0x1D07,13},{0x1D06,13},{0x000A, 4},
  364. {0x0013, 5},{0x003B, 6},{0x001A, 6},{0x007A, 7},
  365. {0x003C, 6},{0x01EE, 9},{0x0000, 4},{0x000C, 5}
  366. },
  367. {
  368. {0x000D, 4},{0x003D, 6},{0x0042, 7},{0x0037, 7},
  369. {0x00D9, 9},{0x0362,11},{0x06C6,12},{0x001F, 5},
  370. {0x0086, 8},{0x0001, 3},{0x0002, 3},{0x000C, 4},
  371. {0x000B, 4},{0x000A, 4},{0x0001, 4},{0x000F, 5},
  372. {0x0025, 6},{0x003C, 6},{0x001A, 6},{0x0087, 8},
  373. {0x01B0,10},{0x0D8F,13},{0x0D8E,13},{0x000E, 4},
  374. {0x0013, 5},{0x000C, 5},{0x0024, 6},{0x0020, 6},
  375. {0x0011, 5},{0x006D, 8},{0x0000, 4},{0x000E, 5}
  376. },
  377. {
  378. {0x0000, 3},{0x0012, 5},{0x0076, 7},{0x0077, 7},
  379. {0x014D, 9},{0x0533,11},{0x14C9,13},{0x0013, 5},
  380. {0x00A5, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4},
  381. {0x000C, 4},{0x0008, 4},{0x001A, 5},{0x002B, 6},
  382. {0x0075, 7},{0x0074, 7},{0x00A7, 8},{0x0298,10},
  383. {0x14C8,13},{0x14CB,13},{0x14CA,13},{0x000F, 4},
  384. {0x001C, 5},{0x0007, 5},{0x002A, 6},{0x0028, 6},
  385. {0x001B, 5},{0x00A4, 8},{0x0002, 4},{0x0006, 5}
  386. },
  387. {
  388. {0x0002, 3},{0x001A, 5},{0x002B, 6},{0x003A, 6},
  389. {0x00ED, 8},{0x0283,10},{0x0A0A,12},{0x0004, 5},
  390. {0x00A1, 8},{0x0004, 3},{0x0003, 3},{0x000B, 4},
  391. {0x000C, 4},{0x001F, 5},{0x0006, 5},{0x0077, 7},
  392. {0x00A3, 8},{0x00A2, 8},{0x0140, 9},{0x1417,13},
  393. {0x1416,13},{0x0A09,12},{0x0A08,12},{0x0000, 3},
  394. {0x001E, 5},{0x0007, 5},{0x002A, 6},{0x0029, 6},
  395. {0x001C, 5},{0x00EC, 8},{0x001B, 5},{0x0005, 5}
  396. },
  397. {
  398. {0x0002, 3},{0x0002, 4},{0x0018, 5},{0x001D, 5},
  399. {0x0035, 6},{0x00E4, 8},{0x01CF,11},{0x001D, 7},
  400. {0x0072, 9},{0x0004, 3},{0x0005, 3},{0x0006, 4},
  401. {0x0007, 4},{0x0006, 5},{0x0073, 7},{0x0038, 8},
  402. {0x01CE,11},{0x039B,12},{0x0398,12},{0x0733,13},
  403. {0x0732,13},{0x0735,13},{0x0734,13},{0x0000, 3},
  404. {0x001F, 5},{0x001B, 5},{0x0034, 6},{0x000F, 6},
  405. {0x001E, 5},{0x00E5, 8},{0x0019, 5},{0x0038, 6}
  406. },
  407. {
  408. {0x0016, 5},{0x0050, 7},{0x0172, 9},{0x02E7,10},
  409. {0x1732,13},{0x2E67,14},{0x2E66,14},{0x0006, 4},
  410. {0x0051, 7},{0x0001, 3},{0x0000, 3},{0x000D, 4},
  411. {0x000C, 4},{0x0009, 4},{0x001C, 5},{0x0009, 5},
  412. {0x001C, 6},{0x001D, 6},{0x005D, 7},{0x00B8, 8},
  413. {0x05CD,11},{0x1731,13},{0x1730,13},{0x000F, 4},
  414. {0x0005, 4},{0x000F, 5},{0x0008, 5},{0x0029, 6},
  415. {0x001D, 5},{0x002F, 6},{0x0008, 4},{0x0015, 5}
  416. },
  417. {
  418. {0x0009, 4},{0x0021, 6},{0x0040, 7},{0x00AD, 8},
  419. {0x02B0,10},{0x1589,13},{0x1588,13},{0x001C, 5},
  420. {0x005F, 7},{0x0000, 3},{0x000F, 4},{0x000D, 4},
  421. {0x000C, 4},{0x0006, 4},{0x0011, 5},{0x002A, 6},
  422. {0x0057, 7},{0x005E, 7},{0x0041, 7},{0x0159, 9},
  423. {0x0563,11},{0x158B,13},{0x158A,13},{0x0001, 3},
  424. {0x0005, 4},{0x0014, 5},{0x003B, 6},{0x002E, 6},
  425. {0x0004, 4},{0x003A, 6},{0x0007, 4},{0x0016, 5}
  426. },
  427. {
  428. {0x000E, 4},{0x0007, 5},{0x0046, 7},{0x0045, 7},
  429. {0x0064, 9},{0x032A,12},{0x0657,13},{0x0018, 5},
  430. {0x000D, 6},{0x0000, 3},{0x000F, 4},{0x000A, 4},
  431. {0x000B, 4},{0x001A, 5},{0x0036, 6},{0x0047, 7},
  432. {0x0044, 7},{0x0018, 7},{0x0033, 8},{0x00CB,10},
  433. {0x0656,13},{0x0329,12},{0x0328,12},{0x0002, 3},
  434. {0x0006, 4},{0x0019, 5},{0x000E, 5},{0x0037, 6},
  435. {0x0009, 4},{0x000F, 5},{0x0002, 4},{0x0010, 5}
  436. },
  437. {
  438. {0x0003, 3},{0x0018, 5},{0x0023, 6},{0x0077, 7},
  439. {0x0194, 9},{0x1956,13},{0x32AF,14},{0x003A, 6},
  440. {0x0076, 7},{0x0002, 3},{0x0001, 3},{0x001F, 5},
  441. {0x001E, 5},{0x0014, 5},{0x0022, 6},{0x0064, 7},
  442. {0x0197, 9},{0x0196, 9},{0x032B,10},{0x0654,11},
  443. {0x32AE,14},{0x1955,13},{0x1954,13},{0x0000, 3},
  444. {0x0009, 4},{0x001C, 5},{0x0015, 5},{0x0010, 5},
  445. {0x000D, 4},{0x0017, 5},{0x0016, 5},{0x0033, 6}
  446. },
  447. {
  448. {0x0005, 3},{0x0006, 4},{0x003E, 6},{0x0010, 5},
  449. {0x0048, 7},{0x093F,12},{0x24FA,14},{0x0032, 6},
  450. {0x0067, 7},{0x0002, 3},{0x0001, 3},{0x001B, 5},
  451. {0x001E, 5},{0x0034, 6},{0x0066, 7},{0x0092, 8},
  452. {0x0126, 9},{0x024E,10},{0x049E,11},{0x49F7,15},
  453. {0x49F6,15},{0x24F9,14},{0x24F8,14},{0x0000, 3},
  454. {0x0007, 4},{0x0018, 5},{0x0011, 5},{0x003F, 6},
  455. {0x000E, 4},{0x0013, 5},{0x0035, 6},{0x0025, 6}
  456. },
  457. {
  458. {0x0005, 3},{0x0008, 4},{0x0012, 5},{0x001C, 5},
  459. {0x001C, 6},{0x00EA, 9},{0x1D75,14},{0x001E, 6},
  460. {0x0066, 7},{0x0001, 3},{0x0002, 3},{0x001B, 5},
  461. {0x001A, 5},{0x001F, 6},{0x003B, 7},{0x0074, 8},
  462. {0x01D6,10},{0x03AF,11},{0x1D74,14},{0x1D77,14},
  463. {0x1D76,14},{0x0EB9,13},{0x0EB8,13},{0x000F, 4},
  464. {0x0006, 4},{0x0013, 5},{0x003B, 6},{0x003A, 6},
  465. {0x0000, 3},{0x0018, 5},{0x0032, 6},{0x0067, 7}
  466. },
  467. {
  468. {0x0004, 3},{0x000A, 4},{0x001B, 5},{0x000C, 4},
  469. {0x000D, 5},{0x00E6, 8},{0x0684,11},{0x0072, 7},
  470. {0x00E7, 8},{0x0002, 3},{0x0001, 3},{0x0017, 5},
  471. {0x0016, 5},{0x0018, 6},{0x00D1, 8},{0x01A0, 9},
  472. {0x0686,11},{0x0D0F,12},{0x0D0A,12},{0x1A17,13},
  473. {0x1A16,13},{0x1A1D,13},{0x1A1C,13},{0x000F, 4},
  474. {0x001D, 5},{0x000E, 5},{0x0035, 6},{0x0038, 6},
  475. {0x0000, 3},{0x000F, 5},{0x0019, 6},{0x0069, 7}
  476. },
  477. {
  478. {0x0003, 3},{0x000C, 4},{0x001B, 5},{0x0000, 3},
  479. {0x0003, 4},{0x002E, 6},{0x0051, 9},{0x00BC, 8},
  480. {0x0053, 9},{0x0004, 3},{0x0002, 3},{0x0016, 5},
  481. {0x0015, 5},{0x0015, 7},{0x0050, 9},{0x00A4,10},
  482. {0x0294,12},{0x052B,13},{0x052A,13},{0x052D,13},
  483. {0x052C,13},{0x052F,13},{0x052E,13},{0x000E, 4},
  484. {0x001A, 5},{0x0004, 5},{0x0028, 6},{0x0029, 6},
  485. {0x000F, 4},{0x000B, 6},{0x005F, 7},{0x00BD, 8}
  486. },
  487. {
  488. {0x0003, 4},{0x0009, 6},{0x00D0, 8},{0x01A3, 9},
  489. {0x0344,10},{0x0D14,12},{0x1A2B,13},{0x0004, 4},
  490. {0x0015, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4},
  491. {0x000C, 4},{0x000E, 4},{0x0009, 4},{0x001B, 5},
  492. {0x000A, 5},{0x0014, 5},{0x000D, 5},{0x002A, 6},
  493. {0x0014, 7},{0x068B,11},{0x1A2A,13},{0x0008, 4},
  494. {0x000B, 5},{0x002B, 6},{0x000B, 6},{0x0069, 7},
  495. {0x0035, 6},{0x0008, 6},{0x0007, 4},{0x000C, 5}
  496. },
  497. {
  498. {0x000A, 4},{0x003C, 6},{0x0032, 7},{0x0030, 7},
  499. {0x00C5, 9},{0x0621,12},{0x0620,12},{0x001F, 5},
  500. {0x0033, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4},
  501. {0x000D, 4},{0x000C, 4},{0x0004, 4},{0x000D, 5},
  502. {0x0026, 6},{0x0027, 6},{0x0014, 6},{0x0063, 8},
  503. {0x0189,10},{0x0623,12},{0x0622,12},{0x000B, 4},
  504. {0x0012, 5},{0x003D, 6},{0x0022, 6},{0x0015, 6},
  505. {0x000B, 5},{0x0023, 6},{0x0007, 4},{0x0010, 5}
  506. },
  507. {
  508. {0x000F, 4},{0x000C, 5},{0x0043, 7},{0x0010, 6},
  509. {0x0044, 8},{0x0114,10},{0x0455,12},{0x0018, 5},
  510. {0x0023, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4},
  511. {0x000D, 4},{0x0009, 4},{0x0019, 5},{0x0009, 5},
  512. {0x0017, 6},{0x0016, 6},{0x0042, 7},{0x008B, 9},
  513. {0x0454,12},{0x0457,12},{0x0456,12},{0x000B, 4},
  514. {0x0015, 5},{0x000A, 5},{0x0029, 6},{0x0020, 6},
  515. {0x000D, 5},{0x0028, 6},{0x0007, 4},{0x0011, 5}
  516. },
  517. {
  518. {0x0001, 3},{0x001A, 5},{0x0029, 6},{0x002A, 6},
  519. {0x00A0, 8},{0x0285,10},{0x1425,13},{0x0002, 5},
  520. {0x0000, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4},
  521. {0x000B, 4},{0x0008, 4},{0x0012, 5},{0x0001, 6},
  522. {0x0051, 7},{0x0001, 7},{0x0143, 9},{0x0508,11},
  523. {0x1424,13},{0x1427,13},{0x1426,13},{0x000F, 4},
  524. {0x001C, 5},{0x0003, 5},{0x0037, 6},{0x002B, 6},
  525. {0x0013, 5},{0x0036, 6},{0x001D, 5},{0x0001, 5}
  526. },
  527. {
  528. {0x0004, 3},{0x001F, 5},{0x003D, 6},{0x0006, 5},
  529. {0x0016, 7},{0x0053, 9},{0x014A,11},{0x0034, 6},
  530. {0x002A, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4},
  531. {0x000C, 4},{0x001C, 5},{0x0037, 6},{0x0017, 7},
  532. {0x002B, 8},{0x0028, 8},{0x00A4,10},{0x052D,13},
  533. {0x052C,13},{0x052F,13},{0x052E,13},{0x0000, 3},
  534. {0x001D, 5},{0x0007, 5},{0x0004, 5},{0x0035, 6},
  535. {0x0014, 5},{0x0036, 6},{0x0015, 5},{0x003C, 6}
  536. },
  537. {
  538. {0x0004, 3},{0x000A, 4},{0x0007, 5},{0x001D, 5},
  539. {0x0009, 6},{0x01F3, 9},{0x07C7,11},{0x0008, 6},
  540. {0x01F0, 9},{0x0003, 3},{0x0002, 3},{0x000D, 4},
  541. {0x000C, 4},{0x0017, 5},{0x007D, 7},{0x01F2, 9},
  542. {0x07C6,11},{0x07C5,11},{0x1F12,13},{0x3E27,14},
  543. {0x3E26,14},{0x1F11,13},{0x1F10,13},{0x0000, 3},
  544. {0x001E, 5},{0x0006, 5},{0x0039, 6},{0x0038, 6},
  545. {0x003F, 6},{0x002C, 6},{0x0005, 5},{0x002D, 6}
  546. },
  547. {
  548. {0x0002, 3},{0x0007, 4},{0x0018, 5},{0x0003, 4},
  549. {0x0005, 5},{0x0035, 7},{0x004F, 9},{0x0012, 7},
  550. {0x04E5,13},{0x0005, 3},{0x0004, 3},{0x000D, 4},
  551. {0x000E, 4},{0x0033, 6},{0x0026, 8},{0x009D,10},
  552. {0x04E4,13},{0x04E7,13},{0x04E6,13},{0x04E1,13},
  553. {0x04E0,13},{0x04E3,13},{0x04E2,13},{0x0000, 3},
  554. {0x001F, 5},{0x000C, 5},{0x003D, 6},{0x003C, 6},
  555. {0x0032, 6},{0x0034, 7},{0x001B, 6},{0x0008, 6}
  556. },
  557. {
  558. {0x0000, 3},{0x0004, 4},{0x001C, 5},{0x000F, 4},
  559. {0x0002, 4},{0x0007, 5},{0x0075, 7},{0x00E8, 8},
  560. {0x1D2A,13},{0x0005, 3},{0x0004, 3},{0x000D, 4},
  561. {0x000C, 4},{0x0077, 7},{0x0E96,12},{0x3A57,14},
  562. {0x3A56,14},{0x3A5D,14},{0x3A5C,14},{0x3A5F,14},
  563. {0x3A5E,14},{0x1D29,13},{0x1D28,13},{0x0003, 3},
  564. {0x0006, 5},{0x000A, 5},{0x002C, 7},{0x0017, 6},
  565. {0x0076, 7},{0x01D3, 9},{0x03A4,10},{0x002D, 7}
  566. },
  567. {
  568. {0x000A, 4},{0x0024, 6},{0x00BF, 8},{0x0085, 8},
  569. {0x0211,10},{0x0842,12},{0x1087,13},{0x0018, 5},
  570. {0x0020, 6},{0x0001, 3},{0x0002, 3},{0x000E, 4},
  571. {0x000D, 4},{0x0007, 4},{0x0013, 5},{0x0025, 6},
  572. {0x005E, 7},{0x0043, 7},{0x00BE, 8},{0x0109, 9},
  573. {0x1086,13},{0x0841,12},{0x0840,12},{0x000F, 4},
  574. {0x0001, 4},{0x0011, 5},{0x0000, 5},{0x002E, 6},
  575. {0x0019, 5},{0x0001, 5},{0x0006, 4},{0x0016, 5}
  576. },
  577. {
  578. {0x0002, 3},{0x000F, 5},{0x006F, 7},{0x0061, 7},
  579. {0x0374,10},{0x1BA8,13},{0x3753,14},{0x0012, 5},
  580. {0x0036, 6},{0x0000, 3},{0x0001, 3},{0x000A, 4},
  581. {0x000B, 4},{0x001A, 5},{0x0031, 6},{0x0060, 7},
  582. {0x00DC, 8},{0x01BB, 9},{0x06EB,11},{0x1BAB,13},
  583. {0x3752,14},{0x3755,14},{0x3754,14},{0x000E, 4},
  584. {0x0006, 4},{0x0013, 5},{0x000E, 5},{0x003E, 6},
  585. {0x0008, 4},{0x001E, 5},{0x0019, 5},{0x003F, 6}
  586. },
  587. {
  588. {0x0003, 3},{0x001C, 5},{0x0025, 6},{0x0024, 6},
  589. {0x01DA, 9},{0x1DBD,13},{0x3B7C,14},{0x003C, 6},
  590. {0x003D, 6},{0x0000, 3},{0x0001, 3},{0x000B, 4},
  591. {0x000A, 4},{0x000B, 5},{0x0077, 7},{0x00EC, 8},
  592. {0x03B6,10},{0x076E,11},{0x1DBF,13},{0x76FB,15},
  593. {0x76FA,15},{0x3B79,14},{0x3B78,14},{0x000D, 4},
  594. {0x001F, 5},{0x0013, 5},{0x000A, 5},{0x0008, 5},
  595. {0x000C, 4},{0x0008, 4},{0x0009, 5},{0x003A, 6}
  596. },
  597. {
  598. {0x0005, 3},{0x0003, 4},{0x0004, 5},{0x0010, 5},
  599. {0x008F, 8},{0x0475,11},{0x11D1,13},{0x0079, 7},
  600. {0x0027, 6},{0x0002, 3},{0x0003, 3},{0x0001, 4},
  601. {0x0000, 4},{0x0026, 6},{0x0046, 7},{0x011C, 9},
  602. {0x0477,11},{0x08ED,12},{0x11D0,13},{0x11D3,13},
  603. {0x11D2,13},{0x11D9,13},{0x11D8,13},{0x000D, 4},
  604. {0x001F, 5},{0x0012, 5},{0x0005, 5},{0x003D, 6},
  605. {0x000C, 4},{0x000E, 4},{0x0022, 6},{0x0078, 7}
  606. },
  607. {
  608. {0x0005, 3},{0x000C, 4},{0x001B, 5},{0x0000, 4},
  609. {0x0006, 6},{0x03E2,10},{0x3E3D,14},{0x000F, 7},
  610. {0x0034, 6},{0x0003, 3},{0x0002, 3},{0x001E, 5},
  611. {0x001D, 5},{0x007D, 7},{0x01F0, 9},{0x07C6,11},
  612. {0x3E3C,14},{0x3E3F,14},{0x3E3E,14},{0x3E39,14},
  613. {0x3E38,14},{0x3E3B,14},{0x3E3A,14},{0x0008, 4},
  614. {0x001C, 5},{0x0002, 5},{0x003F, 6},{0x0035, 6},
  615. {0x0009, 4},{0x0001, 3},{0x000E, 7},{0x00F9, 8}
  616. },
  617. {
  618. {0x0004, 3},{0x000B, 4},{0x0001, 4},{0x000A, 4},
  619. {0x001E, 6},{0x00E0, 9},{0x0E1E,13},{0x0071, 8},
  620. {0x0039, 7},{0x0007, 3},{0x0006, 3},{0x000D, 5},
  621. {0x000C, 5},{0x0020, 7},{0x01C2,10},{0x1C3F,14},
  622. {0x1C3E,14},{0x0E19,13},{0x0E18,13},{0x0E1B,13},
  623. {0x0E1A,13},{0x0E1D,13},{0x0E1C,13},{0x0000, 4},
  624. {0x0009, 5},{0x001D, 6},{0x001F, 6},{0x0011, 6},
  625. {0x0005, 4},{0x0001, 3},{0x0043, 8},{0x0042, 8}
  626. },
  627. {
  628. {0x0004, 3},{0x000D, 4},{0x0007, 4},{0x0002, 3},
  629. {0x0014, 5},{0x016C, 9},{0x16D1,13},{0x02DF,10},
  630. {0x016E, 9},{0x0000, 2},{0x0007, 3},{0x002C, 6},
  631. {0x002B, 6},{0x02DE,10},{0x16D0,13},{0x16D3,13},
  632. {0x16D2,13},{0x2DB5,14},{0x2DB4,14},{0x2DB7,14},
  633. {0x2DB6,14},{0x16D9,13},{0x16D8,13},{0x000C, 5},
  634. {0x002A, 6},{0x005A, 7},{0x001B, 6},{0x001A, 6},
  635. {0x0017, 5},{0x000C, 4},{0x05B7,11},{0x05B5,11}
  636. },
  637. {
  638. {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4},
  639. {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14},
  640. {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7},
  641. {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14},
  642. {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14},
  643. {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9},
  644. {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8},
  645. {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14}
  646. },
  647. {
  648. {0x0000, 3},{0x0010, 5},{0x0072, 7},{0x0071, 7},
  649. {0x0154, 9},{0x0AAB,12},{0x0AA8,12},{0x0014, 5},
  650. {0x0070, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4},
  651. {0x000B, 4},{0x0003, 4},{0x0011, 5},{0x0073, 7},
  652. {0x0054, 7},{0x00AB, 8},{0x02AB,10},{0x1553,13},
  653. {0x1552,13},{0x1555,13},{0x1554,13},{0x000D, 4},
  654. {0x001E, 5},{0x0012, 5},{0x003E, 6},{0x002B, 6},
  655. {0x0002, 4},{0x003F, 6},{0x001D, 5},{0x0013, 5}
  656. },
  657. {
  658. {0x0003, 3},{0x001F, 5},{0x0029, 6},{0x003D, 6},
  659. {0x000C, 7},{0x0069,10},{0x0345,13},{0x0002, 5},
  660. {0x0028, 6},{0x0002, 3},{0x0001, 3},{0x000E, 4},
  661. {0x000C, 4},{0x0015, 5},{0x0007, 6},{0x001B, 8},
  662. {0x006B,10},{0x006A,10},{0x0344,13},{0x0347,13},
  663. {0x0346,13},{0x01A1,12},{0x01A0,12},{0x000B, 4},
  664. {0x001A, 5},{0x0012, 5},{0x0000, 5},{0x003C, 6},
  665. {0x0008, 4},{0x001B, 5},{0x0013, 5},{0x0001, 5}
  666. },
  667. {
  668. {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0014, 5},
  669. {0x0056, 7},{0x015C, 9},{0x15D5,13},{0x003C, 6},
  670. {0x002A, 6},{0x0000, 3},{0x0001, 3},{0x000E, 4},
  671. {0x000D, 4},{0x000C, 5},{0x00AF, 8},{0x02BB,10},
  672. {0x15D4,13},{0x15D7,13},{0x15D6,13},{0x15D1,13},
  673. {0x15D0,13},{0x15D3,13},{0x15D2,13},{0x000B, 4},
  674. {0x0019, 5},{0x000D, 5},{0x003E, 6},{0x0031, 6},
  675. {0x0007, 4},{0x0005, 4},{0x003D, 6},{0x0030, 6}
  676. },
  677. {
  678. {0x0005, 3},{0x0008, 4},{0x001A, 5},{0x0000, 4},
  679. {0x0036, 6},{0x0011, 8},{0x0106,12},{0x000A, 7},
  680. {0x006E, 7},{0x0002, 3},{0x0003, 3},{0x0003, 4},
  681. {0x0002, 4},{0x006F, 7},{0x0021, 9},{0x020F,13},
  682. {0x020E,13},{0x0101,12},{0x0100,12},{0x0103,12},
  683. {0x0102,12},{0x0105,12},{0x0104,12},{0x000C, 4},
  684. {0x001E, 5},{0x0003, 5},{0x003E, 6},{0x003F, 6},
  685. {0x0009, 4},{0x000E, 4},{0x000B, 7},{0x0009, 7}
  686. },
  687. {
  688. {0x0002, 3},{0x000E, 4},{0x001E, 5},{0x000C, 4},
  689. {0x001F, 5},{0x006E, 7},{0x00AD,10},{0x00AF,10},
  690. {0x0014, 7},{0x0004, 3},{0x0003, 3},{0x001A, 5},
  691. {0x0017, 5},{0x002A, 8},{0x0576,13},{0x0AEF,14},
  692. {0x0AEE,14},{0x0571,13},{0x0570,13},{0x0573,13},
  693. {0x0572,13},{0x0575,13},{0x0574,13},{0x0003, 4},
  694. {0x0016, 5},{0x0004, 5},{0x0036, 6},{0x000B, 6},
  695. {0x000A, 4},{0x0000, 3},{0x006F, 7},{0x00AC,10}
  696. },
  697. {
  698. {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
  699. {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
  700. {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
  701. {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
  702. {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
  703. {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
  704. {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
  705. {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
  706. },
  707. {
  708. {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
  709. {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
  710. {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
  711. {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
  712. {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
  713. {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
  714. {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
  715. {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
  716. },
  717. {
  718. {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
  719. {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
  720. {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
  721. {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
  722. {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
  723. {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
  724. {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
  725. {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
  726. },
  727. {
  728. {0x0003, 3},{0x0011, 5},{0x0020, 6},{0x0074, 7},
  729. {0x010D, 9},{0x0863,12},{0x0860,12},{0x000A, 5},
  730. {0x0075, 7},{0x0001, 3},{0x0000, 3},{0x000B, 4},
  731. {0x000A, 4},{0x0018, 5},{0x0038, 6},{0x0042, 7},
  732. {0x010F, 9},{0x010E, 9},{0x0219,10},{0x10C3,13},
  733. {0x10C2,13},{0x10C5,13},{0x10C4,13},{0x000F, 4},
  734. {0x0004, 4},{0x0019, 5},{0x000B, 5},{0x0039, 6},
  735. {0x0009, 4},{0x001B, 5},{0x001A, 5},{0x003B, 6}
  736. },
  737. {
  738. {0x0005, 3},{0x0001, 4},{0x003E, 6},{0x0001, 5},
  739. {0x00E2, 8},{0x1C6F,13},{0x38D9,14},{0x0039, 6},
  740. {0x001F, 6},{0x0002, 3},{0x0001, 3},{0x0009, 4},
  741. {0x0008, 4},{0x0000, 5},{0x0070, 7},{0x01C7, 9},
  742. {0x038C,10},{0x071A,11},{0x38D8,14},{0x38DB,14},
  743. {0x38DA,14},{0x38DD,14},{0x38DC,14},{0x000D, 4},
  744. {0x001D, 5},{0x000E, 5},{0x003F, 6},{0x003C, 6},
  745. {0x000C, 4},{0x0006, 4},{0x003D, 6},{0x001E, 6}
  746. },
  747. {
  748. {0x0006, 3},{0x000B, 4},{0x0011, 5},{0x001E, 5},
  749. {0x0074, 7},{0x03AA,10},{0x1D5C,13},{0x0001, 6},
  750. {0x0021, 6},{0x0001, 3},{0x0002, 3},{0x0007, 4},
  751. {0x0006, 4},{0x003E, 6},{0x00EB, 8},{0x01D4, 9},
  752. {0x0EAF,12},{0x3ABB,14},{0x3ABA,14},{0x1D59,13},
  753. {0x1D58,13},{0x1D5B,13},{0x1D5A,13},{0x000A, 4},
  754. {0x001C, 5},{0x0001, 5},{0x003F, 6},{0x003B, 6},
  755. {0x0001, 4},{0x0009, 4},{0x0020, 6},{0x0000, 6}
  756. },
  757. {
  758. {0x0004, 3},{0x000A, 4},{0x0017, 5},{0x0004, 4},
  759. {0x0016, 6},{0x016A, 9},{0x16B1,13},{0x0017, 7},
  760. {0x005B, 7},{0x0006, 3},{0x0007, 3},{0x0001, 4},
  761. {0x0000, 4},{0x000A, 6},{0x02D7,10},{0x0B5A,12},
  762. {0x16B0,13},{0x16B3,13},{0x16B2,13},{0x2D6D,14},
  763. {0x2D6C,14},{0x2D6F,14},{0x2D6E,14},{0x0006, 4},
  764. {0x000A, 5},{0x0004, 5},{0x002C, 6},{0x0017, 6},
  765. {0x0003, 4},{0x0007, 4},{0x0016, 7},{0x00B4, 8}
  766. },
  767. {
  768. {0x0005, 3},{0x000D, 4},{0x0005, 4},{0x0009, 4},
  769. {0x0033, 6},{0x0193, 9},{0x192C,13},{0x0061, 8},
  770. {0x0031, 7},{0x0000, 2},{0x0007, 3},{0x0010, 5},
  771. {0x0011, 5},{0x00C8, 8},{0x192F,13},{0x325B,14},
  772. {0x325A,14},{0x1929,13},{0x1928,13},{0x192B,13},
  773. {0x192A,13},{0x325D,14},{0x325C,14},{0x0018, 5},
  774. {0x001A, 6},{0x001B, 6},{0x0065, 7},{0x0019, 6},
  775. {0x0004, 4},{0x0007, 4},{0x0060, 8},{0x0324,10}
  776. },
  777. {
  778. {0x0006, 3},{0x0000, 3},{0x0002, 4},{0x000F, 4},
  779. {0x0039, 6},{0x01D9, 9},{0x1D82,13},{0x0761,11},
  780. {0x03BE,10},{0x0001, 2},{0x0002, 2},{0x000F, 6},
  781. {0x000E, 6},{0x0762,11},{0x3B07,14},{0x3B06,14},
  782. {0x3B1D,14},{0x3B1C,14},{0x3B1F,14},{0x3B1E,14},
  783. {0x3B19,14},{0x3B18,14},{0x3B1B,14},{0x0038, 6},
  784. {0x01DE, 9},{0x00ED, 8},{0x03BF,10},{0x00EE, 8},
  785. {0x003A, 6},{0x0006, 5},{0x0EC0,12},{0x3B1A,14}
  786. },
  787. {
  788. {0x0000, 2},{0x0002, 3},{0x000F, 5},{0x0006, 4},
  789. {0x001C, 6},{0x01D0,10},{0x0E8C,13},{0x1D1B,14},
  790. {0x1D1A,14},{0x0003, 2},{0x0002, 2},{0x00EA, 9},
  791. {0x00E9, 9},{0x0E89,13},{0x0E88,13},{0x0E8B,13},
  792. {0x0E8A,13},{0x1D65,14},{0x1D64,14},{0x1D67,14},
  793. {0x1D66,14},{0x1D61,14},{0x1D60,14},{0x03AD,11},
  794. {0x1D63,14},{0x1D62,14},{0x1D1D,14},{0x1D1C,14},
  795. {0x003B, 7},{0x01D7,10},{0x1D1F,14},{0x1D1E,14}
  796. },
  797. {
  798. {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4},
  799. {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14},
  800. {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7},
  801. {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14},
  802. {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14},
  803. {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9},
  804. {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8},
  805. {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14}
  806. }
  807. };
  808. /*A description of a Huffman code value used when encoding the tree.*/
  809. typedef struct{
  810. /*The bit pattern, left-shifted so that the MSB of all patterns is
  811. aligned.*/
  812. ogg_uint32_t pattern;
  813. /*The amount the bit pattern was shifted.*/
  814. int shift;
  815. /*The token this bit pattern represents.*/
  816. int token;
  817. }oc_huff_entry;
  818. /*Compares two oc_huff_entry structures by their bit patterns.
  819. _c1: The first entry to compare.
  820. _c2: The second entry to compare.
  821. Return: <0 if _c1<_c2, >0 if _c1>_c2.*/
  822. static int huff_entry_cmp(const void *_c1,const void *_c2){
  823. ogg_uint32_t b1;
  824. ogg_uint32_t b2;
  825. b1=((const oc_huff_entry *)_c1)->pattern;
  826. b2=((const oc_huff_entry *)_c2)->pattern;
  827. return b1<b2?-1:b1>b2?1:0;
  828. }
  829. /*Encodes a description of the given Huffman tables.
  830. Although the codes are stored in the encoder as flat arrays, in the bit
  831. stream and in the decoder they are structured as a tree.
  832. This function recovers the tree structure from the flat array and then
  833. writes it out.
  834. Note that the codes MUST form a Huffman code, and not merely a prefix-free
  835. code, since the binary tree is assumed to be full.
  836. _opb: The buffer to store the tree in.
  837. _codes: The Huffman tables to pack.
  838. Return: 0 on success, or a negative value if one of the given Huffman tables
  839. does not form a full, prefix-free code.*/
  840. int oc_huff_codes_pack(oggpack_buffer *_opb,
  841. const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]){
  842. int i;
  843. for(i=0;i<TH_NHUFFMAN_TABLES;i++){
  844. oc_huff_entry entries[TH_NDCT_TOKENS];
  845. int bpos;
  846. int maxlen;
  847. int mask;
  848. int j;
  849. /*First, find the maximum code length so we can align all the bit
  850. patterns.*/
  851. maxlen=_codes[i][0].nbits;
  852. for(j=1;j<TH_NDCT_TOKENS;j++)maxlen=OC_MAXI(_codes[i][j].nbits,maxlen);
  853. /*It's improbable that a code with more than 32 bits could pass the
  854. validation below, but abort early in any case.*/
  855. if(maxlen>32)return TH_EINVAL;
  856. mask=(1<<(maxlen>>1)<<(maxlen+1>>1))-1;
  857. /*Copy over the codes into our temporary workspace.
  858. The bit patterns are aligned, and the original entry each code is from
  859. is stored as well.*/
  860. for(j=0;j<TH_NDCT_TOKENS;j++){
  861. entries[j].shift=maxlen-_codes[i][j].nbits;
  862. entries[j].pattern=_codes[i][j].pattern<<entries[j].shift&mask;
  863. entries[j].token=j;
  864. }
  865. /*Sort the codes into ascending order.
  866. This is the order the leaves of the tree will be traversed.*/
  867. qsort(entries,TH_NDCT_TOKENS,sizeof(entries[0]),huff_entry_cmp);
  868. /*For each leaf of the tree:*/
  869. bpos=maxlen;
  870. for(j=0;j<TH_NDCT_TOKENS;j++){
  871. ogg_uint32_t bit;
  872. /*Fail if this code has no bits at all.
  873. Technically a codebook with a single 0-bit entry is legal, but the
  874. encoder currently does not support codebooks which do not contain all
  875. the tokens.*/
  876. if(entries[j].shift>=maxlen)return TH_EINVAL;
  877. /*Descend into the tree, writing a bit for each branch.*/
  878. for(;bpos>entries[j].shift;bpos--)oggpackB_write(_opb,0,1);
  879. /*Mark this as a leaf node, and write its value.*/
  880. oggpackB_write(_opb,1,1);
  881. oggpackB_write(_opb,entries[j].token,5);
  882. /*For each 1 branch we've descended, back up the tree until we reach a
  883. 0 branch.*/
  884. bit=(ogg_uint32_t)1<<bpos;
  885. for(;entries[j].pattern&bit;bpos++)bit<<=1;
  886. /*Validate the code.*/
  887. if(j+1<TH_NDCT_TOKENS){
  888. mask=~(bit-1)<<1;
  889. /*The next entry should have a 1 bit where we had a 0, and should
  890. match our code above that bit.
  891. This verifies both fullness and prefix-freeness simultaneously.*/
  892. if(!(entries[j+1].pattern&bit)||
  893. (entries[j].pattern&mask)!=(entries[j+1].pattern&mask)){
  894. return TH_EINVAL;
  895. }
  896. }
  897. /*If there are no more codes, we should have ascended back to the top
  898. of the tree.*/
  899. else if(bpos<maxlen)return TH_EINVAL;
  900. }
  901. }
  902. return 0;
  903. }
  904. /*This is used to copy the configuration of an existing setup header for use by
  905. the encoder.
  906. The decoder uses a completely different data structure for the Huffman
  907. codebooks.*/
  908. int oc_huff_codes_unpack(oc_pack_buf *_opb,
  909. th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]){
  910. int i;
  911. for(i=0;i<TH_NHUFFMAN_TABLES;i++){
  912. ogg_uint32_t code;
  913. int len;
  914. int nleaves;
  915. code=0;
  916. len=nleaves=0;
  917. memset(_codes[i],0,TH_NDCT_TOKENS*sizeof(*_codes[i]));
  918. for(;;){
  919. long bits;
  920. bits=oc_pack_read1(_opb);
  921. /*Only process nodes so long as there's more bits in the buffer.*/
  922. if(oc_pack_bytes_left(_opb)<0)return TH_EBADHEADER;
  923. /*Read an internal node:*/
  924. if(!bits){
  925. len++;
  926. /*Don't allow codewords longer than 32 bits.*/
  927. if(len>32)return TH_EBADHEADER;
  928. }
  929. /*Read a leaf node:*/
  930. else{
  931. ogg_uint32_t code_bit;
  932. /*Don't allow more than 32 tokens per codebook.*/
  933. if(++nleaves>32)return TH_EBADHEADER;
  934. bits=oc_pack_read(_opb,OC_NDCT_TOKEN_BITS);
  935. /*The current encoder does not support codebooks that do not contain
  936. all of the tokens.*/
  937. if(_codes[i][bits].nbits>0)return TH_EINVAL;
  938. _codes[i][bits].pattern=code>>32-len;
  939. _codes[i][bits].nbits=len;
  940. code_bit=0x80000000U>>len-1;
  941. while(len>0&&(code&code_bit)){
  942. code^=code_bit;
  943. code_bit<<=1;
  944. len--;
  945. }
  946. if(len<=0)break;
  947. code|=code_bit;
  948. }
  949. }
  950. /*The current encoder does not support codebooks that do not contain all of
  951. the tokens.*/
  952. if(nleaves<32)return TH_EINVAL;
  953. }
  954. return 0;
  955. }