You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

651 lines
22KB

  1. /*
  2. * VC-1 and WMV3 decoder
  3. * copyright (c) 2006 Konstantin Shishkov
  4. * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file vc1data.h
  22. * VC-1 tables.
  23. */
  24. #ifndef VC1DATA_H
  25. #define VC1DATA_H
  26. #if 0 //original bfraction from vc9data.h, not conforming to standard
  27. /* Denominator used for vc1_bfraction_lut */
  28. #define B_FRACTION_DEN 840
  29. /* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
  30. const int16_t vc1_bfraction_lut[23] = {
  31. 420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
  32. 630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
  33. 504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
  34. 120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
  35. 600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
  36. 525 /*5/8*/, 735 /*7/8*/,
  37. -1 /*inv.*/, 0 /*BI fm*/
  38. };
  39. #else
  40. /* Denominator used for vc1_bfraction_lut */
  41. #define B_FRACTION_DEN 256
  42. /* pre-computed scales for all bfractions and base=256 */
  43. const int16_t vc1_bfraction_lut[23] = {
  44. 128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/,
  45. 192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/,
  46. 153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/,
  47. 37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/,
  48. 185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/,
  49. 160 /*5/8*/, 224 /*7/8*/,
  50. -1 /*inv.*/, 0 /*BI fm*/
  51. };
  52. #endif
  53. const uint8_t vc1_bfraction_bits[23] = {
  54. 3, 3, 3, 3,
  55. 3, 3, 3,
  56. 7, 7, 7, 7,
  57. 7, 7, 7, 7,
  58. 7, 7, 7, 7,
  59. 7, 7,
  60. 7, 7
  61. };
  62. const uint8_t vc1_bfraction_codes[23] = {
  63. 0, 1, 2, 3,
  64. 4, 5, 6,
  65. 112, 113, 114, 115,
  66. 116, 117, 118, 119,
  67. 120, 121, 122, 123,
  68. 124, 125,
  69. 126, 127
  70. };
  71. //Same as H.264
  72. static const AVRational vc1_pixel_aspect[16]={
  73. {0, 1},
  74. {1, 1},
  75. {12, 11},
  76. {10, 11},
  77. {16, 11},
  78. {40, 33},
  79. {24, 11},
  80. {20, 11},
  81. {32, 11},
  82. {80, 33},
  83. {18, 11},
  84. {15, 11},
  85. {64, 33},
  86. {160, 99},
  87. {0, 1},
  88. {0, 1}
  89. };
  90. /* BitPlane IMODE - such a small table... */
  91. static const uint8_t vc1_imode_codes[7] = {
  92. 0, 2, 1, 3, 1, 2, 3
  93. };
  94. static const uint8_t vc1_imode_bits[7] = {
  95. 4, 2, 3, 2, 4, 3, 3
  96. };
  97. /* Normal-2 imode */
  98. static const uint8_t vc1_norm2_codes[4] = {
  99. 0, 4, 5, 3
  100. };
  101. static const uint8_t vc1_norm2_bits[4] = {
  102. 1, 3, 3, 2
  103. };
  104. static const uint16_t vc1_norm6_codes[64] = {
  105. 0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E,
  106. 0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037,
  107. 0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036,
  108. 0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007,
  109. };
  110. static const uint8_t vc1_norm6_bits[64] = {
  111. 1, 4, 4, 8, 4, 8, 8, 10, 4, 8, 8, 10, 8, 10, 10, 13,
  112. 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
  113. 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
  114. 8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6,
  115. };
  116. /* Normal-6 imode */
  117. static const uint8_t vc1_norm6_spec[64][5] = {
  118. { 0, 1, 1 },
  119. { 1, 2, 4 },
  120. { 2, 3, 4 },
  121. { 3, 0, 8 },
  122. { 4, 4, 4 },
  123. { 5, 1, 8 },
  124. { 6, 2, 8 },
  125. { 7, 2, 5, 7, 5 },
  126. { 8, 5, 4 },
  127. { 9, 3, 8 },
  128. {10, 4, 8 },
  129. {11, 2, 5, 11, 5 },
  130. {12, 5, 8 },
  131. {13, 2, 5, 13, 5 },
  132. {14, 2, 5, 14, 5 },
  133. {15, 3, 5, 14, 8 },
  134. {16, 6, 4 },
  135. {17, 6, 8 },
  136. {18, 7, 8 },
  137. {19, 2, 5, 19, 5 },
  138. {20, 8, 8 },
  139. {21, 2, 5, 21, 5 },
  140. {22, 2, 5, 22, 5 },
  141. {23, 3, 5, 13, 8 },
  142. {24, 9, 8 },
  143. {25, 2, 5, 25, 5 },
  144. {26, 2, 5, 26, 5 },
  145. {27, 3, 5, 12, 8 },
  146. {28, 2, 5, 28, 5 },
  147. {29, 3, 5, 11, 8 },
  148. {30, 3, 5, 10, 8 },
  149. {31, 3, 5, 7, 4 },
  150. {32, 7, 4 },
  151. {33, 10, 8 },
  152. {34, 11, 8 },
  153. {35, 2, 5, 3, 5 },
  154. {36, 12, 8 },
  155. {37, 2, 5, 5, 5 },
  156. {38, 2, 5, 6, 5 },
  157. {39, 3, 5, 9, 8 },
  158. {40, 13, 8 },
  159. {41, 2, 5, 9, 5 },
  160. {42, 2, 5, 10, 5 },
  161. {43, 3, 5, 8, 8 },
  162. {44, 2, 5, 12, 5 },
  163. {45, 3, 5, 7, 8 },
  164. {46, 3, 5, 6, 8 },
  165. {47, 3, 5, 6, 4 },
  166. {48, 14, 8 },
  167. {49, 2, 5, 17, 5 },
  168. {50, 2, 5, 18, 5 },
  169. {51, 3, 5, 5, 8 },
  170. {52, 2, 5, 20, 5 },
  171. {53, 3, 5, 4, 8 },
  172. {54, 3, 5, 3, 8 },
  173. {55, 3, 5, 5, 4 },
  174. {56, 2, 5, 24, 5 },
  175. {57, 3, 5, 2, 8 },
  176. {58, 3, 5, 1, 8 },
  177. {59, 3, 5, 4, 4 },
  178. {60, 3, 5, 0, 8 },
  179. {61, 3, 5, 3, 4 },
  180. {62, 3, 5, 2, 4 },
  181. {63, 3, 5, 1, 1 },
  182. };
  183. /* 4MV Block pattern VLC tables */
  184. static const uint8_t vc1_4mv_block_pattern_codes[4][16] = {
  185. { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2},
  186. { 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0},
  187. { 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0},
  188. { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 19}
  189. };
  190. static const uint8_t vc1_4mv_block_pattern_bits[4][16] = {
  191. { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2},
  192. { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2},
  193. { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3},
  194. { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
  195. };
  196. const uint8_t wmv3_dc_scale_table[32]={
  197. 0, 2, 4, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21
  198. };
  199. /* P-Picture CBPCY VLC tables */
  200. #if 1 // Looks like original tables are not conforming to standard at all. Are they used for old WMV?
  201. static const uint16_t vc1_cbpcy_p_codes[4][64] = {
  202. {
  203. 0, 6, 15, 13, 13, 11, 3, 13, 5, 8, 49, 10, 12, 114, 102, 119,
  204. 1, 54, 96, 8, 10, 111, 5, 15, 12, 10, 2, 12, 13, 115, 53, 63,
  205. 1, 7, 1, 7, 14, 12, 4, 14, 1, 9, 97, 11, 7, 58, 52, 62,
  206. 4, 103, 1, 9, 11, 56, 101, 118, 4, 110, 100, 30, 2, 5, 4, 3
  207. },
  208. {
  209. 0, 9, 1, 18, 5, 14, 237, 26, 3, 121, 3, 22, 13, 16, 6, 30,
  210. 2, 10, 1, 20, 12, 241, 5, 28, 16, 12, 3, 24, 28, 124, 239, 247,
  211. 1, 240, 1, 19, 18, 15, 4, 27, 1, 122, 2, 23, 1, 17, 7, 31,
  212. 1, 11, 2, 21, 19, 246, 238, 29, 17, 13, 236, 25, 58, 63, 8, 125
  213. },
  214. {
  215. 0, 201, 25, 231, 5, 221, 1, 3, 2, 414, 2, 241, 16, 225, 195, 492,
  216. 2, 412, 1, 240, 7, 224, 98, 245, 1, 220, 96, 5, 9, 230, 101, 247,
  217. 1, 102, 1, 415, 24, 3, 2, 244, 3, 54, 3, 484, 17, 114, 200, 493,
  218. 3, 413, 1, 4, 13, 113, 99, 485, 4, 111, 194, 243, 5, 29, 26, 31
  219. },
  220. {
  221. 0, 28, 12, 44, 3, 36, 20, 52, 2, 32, 16, 48, 8, 40, 24, 28,
  222. 1, 30, 14, 46, 6, 38, 22, 54, 3, 34, 18, 50, 10, 42, 26, 30,
  223. 1, 29, 13, 45, 5, 37, 21, 53, 2, 33, 17, 49, 9, 41, 25, 29,
  224. 1, 31, 15, 47, 7, 39, 23, 55, 4, 35, 19, 51, 11, 43, 27, 31
  225. }
  226. };
  227. static const uint8_t vc1_cbpcy_p_bits[4][64] = {
  228. {
  229. 13, 13, 7, 13, 7, 13, 13, 12, 6, 13, 7, 12, 6, 8, 8, 8,
  230. 5, 7, 8, 12, 6, 8, 13, 12, 7, 13, 13, 12, 6, 8, 7, 7,
  231. 6, 13, 8, 12, 7, 13, 13, 12, 7, 13, 8, 12, 5, 7, 7, 7,
  232. 6, 8, 13, 12, 6, 7, 8, 8, 5, 8, 8, 6, 3, 3, 3, 2
  233. },
  234. {
  235. 14, 13, 8, 13, 3, 13, 8, 13, 3, 7, 8, 13, 4, 13, 13, 13,
  236. 3, 13, 13, 13, 4, 8, 13, 13, 5, 13, 13, 13, 5, 7, 8, 8,
  237. 3, 8, 14, 13, 5, 13, 13, 13, 4, 7, 13, 13, 6, 13, 13, 13,
  238. 5, 13, 8, 13, 5, 8, 8, 13, 5, 13, 8, 13, 6, 6, 13, 7
  239. },
  240. {
  241. 13, 8, 6, 8, 4, 8, 13, 12, 4, 9, 8, 8, 5, 8, 8, 9,
  242. 5, 9, 10, 8, 4, 8, 7, 8, 6, 8, 7, 13, 4, 8, 7, 8,
  243. 5, 7, 8, 9, 6, 13, 13, 8, 4, 6, 8, 9, 5, 7, 8, 9,
  244. 5, 9, 9, 13, 5, 7, 7, 9, 4, 7, 8, 8, 3, 5, 5, 5
  245. },
  246. {
  247. 9, 9, 9, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 8,
  248. 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
  249. 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
  250. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8
  251. }
  252. };
  253. #else
  254. static const uint16_t vc1_cbpcy_p_codes[4][64] = {
  255. {
  256. 0, 1, 1, 4, 5, 1, 12, 4, 13, 14, 10, 11, 12, 7, 13, 2,
  257. 15, 1, 96, 1, 49, 97, 2, 100, 3, 4, 5, 101, 102, 52, 53, 4,
  258. 6, 7, 54, 103, 8, 9, 10, 110, 11, 12, 111, 56, 114, 58, 115, 5,
  259. 13, 7, 8, 9, 10, 11, 12, 30, 13, 14, 15, 118, 119, 62, 63, 3
  260. },
  261. {
  262. 0, 1, 2, 1, 3, 1, 16, 17, 5, 18, 12, 19, 13, 1, 28, 58,
  263. 1, 1, 1, 2, 3, 2, 3, 236, 237, 4, 5, 238, 6, 7, 239, 8,
  264. 9, 240, 10, 11, 121, 122, 12, 13, 14, 15, 241, 246, 16, 17, 124, 63,
  265. 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 247, 125
  266. },
  267. {
  268. 0, 1, 2, 3, 2, 3, 1, 4, 5, 24, 7, 13, 16, 17, 9, 5,
  269. 25, 1, 1, 1, 2, 3, 96, 194, 1, 2, 98, 99, 195, 200, 101, 26,
  270. 201, 102, 412, 413, 414, 54, 220, 111, 221, 3, 224, 113, 225, 114, 230, 29,
  271. 231, 415, 240, 4, 241, 484, 5, 243, 3, 244, 245, 485, 492, 493, 247, 31
  272. },
  273. {
  274. 0, 1, 1, 1, 2, 2, 3, 4, 3, 5, 6, 7, 8, 9, 10, 11,
  275. 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
  276. 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
  277. 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 28, 29, 30, 31
  278. }
  279. };
  280. static const uint8_t vc1_cbpcy_p_bits[4][64] = {
  281. {
  282. 13, 6, 5, 6, 6, 7, 7, 5, 7, 7, 6, 6, 6, 5, 6, 3,
  283. 7, 8, 8, 13, 7, 8, 13, 8, 13, 13, 13, 8, 8, 7, 7, 3,
  284. 13, 13, 7, 8, 13, 13, 13, 8, 13, 13, 8, 7, 8, 7, 8, 3,
  285. 13, 12, 12, 12, 12, 12, 12, 6, 12, 12, 12, 8, 8, 7, 7, 2
  286. },
  287. {
  288. 14, 3, 3, 5, 3, 4, 5, 5, 3, 5, 4, 5, 4, 6, 5, 6,
  289. 8, 14, 13, 8, 8, 13, 13, 8, 8, 13, 13, 8, 13, 13, 8, 13,
  290. 13, 8, 13, 13, 7, 7, 13, 13, 13, 13, 8, 8, 13, 13, 7, 6,
  291. 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 8, 7
  292. },
  293. {
  294. 13, 5, 5, 5, 4, 4, 6, 4, 4, 6, 4, 5, 5, 5, 4, 3,
  295. 6, 8, 10, 9, 8, 8, 7, 8, 13, 13, 7, 7, 8, 8, 7, 5,
  296. 8, 7, 9, 9, 9, 6, 8, 7, 8, 13, 8, 7, 8, 7, 8, 5,
  297. 8, 9, 8, 13, 8, 9, 13, 8, 12, 8, 8, 9, 9, 9, 8, 5
  298. },
  299. {
  300. 9, 2, 3, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 9,
  301. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  302. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
  303. 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8
  304. }
  305. };
  306. #endif
  307. /* MacroBlock Transform Type: 7.1.3.11, p89
  308. * 8x8:B
  309. * 8x4:B:btm 8x4:B:top 8x4:B:both,
  310. * 4x8:B:right 4x8:B:left 4x8:B:both
  311. * 4x4:B 8x8:MB
  312. * 8x4:MB:btm 8x4:MB:top 8x4,MB,both
  313. * 4x8,MB,right 4x8,MB,left
  314. * 4x4,MB */
  315. static const uint16_t vc1_ttmb_codes[3][16] = {
  316. {
  317. 0x0003,
  318. 0x002E, 0x005F, 0x0000,
  319. 0x0016, 0x0015, 0x0001,
  320. 0x0004, 0x0014,
  321. 0x02F1, 0x0179, 0x017B,
  322. 0x0BC0, 0x0BC1, 0x05E1,
  323. 0x017A
  324. },
  325. {
  326. 0x0006,
  327. 0x0006, 0x0003, 0x0007,
  328. 0x000F, 0x000E, 0x0000,
  329. 0x0002, 0x0002,
  330. 0x0014, 0x0011, 0x000B,
  331. 0x0009, 0x0021, 0x0015,
  332. 0x0020
  333. },
  334. {
  335. 0x0006,
  336. 0x0000, 0x000E, 0x0005,
  337. 0x0002, 0x0003, 0x0003,
  338. 0x000F, 0x0002,
  339. 0x0081, 0x0021, 0x0009,
  340. 0x0101, 0x0041, 0x0011,
  341. 0x0100
  342. }
  343. };
  344. static const uint8_t vc1_ttmb_bits[3][16] = {
  345. {
  346. 2,
  347. 6, 7, 2,
  348. 5, 5, 2,
  349. 3, 5,
  350. 10, 9, 9,
  351. 12, 12, 11,
  352. 9
  353. },
  354. {
  355. 3,
  356. 4, 4, 4,
  357. 4, 4, 3,
  358. 3, 2,
  359. 7, 7, 6,
  360. 6, 8, 7,
  361. 8
  362. },
  363. {
  364. 3,
  365. 3, 4, 5,
  366. 3, 3, 4,
  367. 4, 2,
  368. 10, 8, 6,
  369. 11, 9, 7,
  370. 11
  371. }
  372. };
  373. /* TTBLK (Transform Type per Block) tables */
  374. static const uint8_t vc1_ttblk_codes[3][8] = {
  375. { 0, 1, 3, 5, 16, 17, 18, 19},
  376. { 3, 0, 1, 2, 3, 5, 8, 9},
  377. { 1, 0, 1, 4, 6, 7, 10, 11}
  378. };
  379. static const uint8_t vc1_ttblk_bits[3][8] = {
  380. { 2, 2, 2, 3, 5, 5, 5, 5},
  381. { 2, 3, 3, 3, 3, 3, 4, 4},
  382. { 2, 3, 3, 3, 3, 3, 4, 4}
  383. };
  384. /* SUBBLKPAT tables, p93-94, reordered */
  385. static const uint8_t vc1_subblkpat_codes[3][15] = {
  386. { 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1},
  387. { 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1},
  388. { 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15}
  389. };
  390. static const uint8_t vc1_subblkpat_bits[3][15] = {
  391. { 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1},
  392. { 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2},
  393. { 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4}
  394. };
  395. /* MV differential tables, p265 */
  396. static const uint16_t vc1_mv_diff_codes[4][73] = {
  397. {
  398. 0, 2, 3, 8, 576, 3, 2, 6,
  399. 5, 577, 578, 7, 8, 9, 40, 19,
  400. 37, 82, 21, 22, 23, 579, 580, 166,
  401. 96, 167, 49, 194, 195, 581, 582, 583,
  402. 292, 293, 294, 13, 2, 7, 24, 50,
  403. 102, 295, 13, 7, 8, 18, 50, 103,
  404. 38, 20, 21, 22, 39, 204, 103, 23,
  405. 24, 25, 104, 410, 105, 106, 107, 108,
  406. 109, 220, 411, 442, 222, 443, 446, 447,
  407. 7 /* 73 elements */
  408. },
  409. {
  410. 0, 4, 5, 3, 4, 3, 4, 5,
  411. 20, 6, 21, 44, 45, 46, 3008, 95,
  412. 112, 113, 57, 3009, 3010, 116, 117, 3011,
  413. 118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
  414. 3019, 3020, 3021, 3022, 1, 4, 15, 160,
  415. 161, 41, 6, 11, 42, 162, 43, 119,
  416. 56, 57, 58, 163, 236, 237, 3023, 119,
  417. 120, 242, 122, 486, 1512, 487, 246, 494,
  418. 1513, 495, 1514, 1515, 1516, 1517, 1518, 1519,
  419. 31 /* 73 elements */
  420. },
  421. {
  422. 0, 512, 513, 514, 515, 2, 3, 258,
  423. 259, 260, 261, 262, 263, 264, 265, 266,
  424. 267, 268, 269, 270, 271, 272, 273, 274,
  425. 275, 276, 277, 278, 279, 280, 281, 282,
  426. 283, 284, 285, 286, 1, 5, 287, 288,
  427. 289, 290, 6, 7, 291, 292, 293, 294,
  428. 295, 296, 297, 298, 299, 300, 301, 302,
  429. 303, 304, 305, 306, 307, 308, 309, 310,
  430. 311, 312, 313, 314, 315, 316, 317, 318,
  431. 319 /* 73 elements */
  432. },
  433. {
  434. 0, 1, 1, 2, 3, 4, 1, 5,
  435. 4, 3, 5, 8, 6, 9, 10, 11,
  436. 12, 7, 104, 14, 105, 4, 10, 15,
  437. 11, 6, 14, 8, 106, 107, 108, 15,
  438. 109, 9, 55, 10, 1, 2, 1, 2,
  439. 3, 12, 6, 2, 6, 7, 28, 7,
  440. 15, 8, 5, 18, 29, 152, 77, 24,
  441. 25, 26, 39, 108, 13, 109, 55, 56,
  442. 57, 116, 11, 153, 234, 235, 118, 119,
  443. 15 /* 73 elements */
  444. }
  445. };
  446. static const uint8_t vc1_mv_diff_bits[4][73] = {
  447. {
  448. 6, 7, 7, 8, 14, 6, 5, 6, 7, 14, 14, 6, 6, 6, 8, 9,
  449. 10, 9, 7, 7, 7, 14, 14, 10, 9, 10, 8, 10, 10, 14, 14, 14,
  450. 13, 13, 13, 6, 3, 5, 6, 8, 9, 13, 5, 4, 4, 5, 7, 9,
  451. 6, 5, 5, 5, 6, 9, 8, 5, 5, 5, 7, 10, 7, 7, 7, 7,
  452. 7, 8, 10, 9, 8, 9, 9, 9, 3 /* 73 elements */
  453. },
  454. {
  455. 5, 7, 7, 6, 6, 5, 5, 6, 7, 5, 7, 8, 8, 8, 14, 9,
  456. 9, 9, 8, 14, 14, 9, 9, 14, 9, 14, 14, 14, 14, 14, 14, 14,
  457. 14, 14, 14, 14, 2, 3, 6, 8, 8, 6, 3, 4, 6, 8, 6, 9,
  458. 6, 6, 6, 8, 8, 8, 14, 7, 7, 8, 7, 9, 13, 9, 8, 9,
  459. 13, 9, 13, 13, 13, 13, 13, 13, 5 /* 73 elements */
  460. },
  461. {
  462. 3, 12, 12, 12, 12, 3, 4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
  463. 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
  464. 11, 11, 11, 11, 1, 5, 11, 11, 11, 11, 4, 4, 11, 11, 11, 11,
  465. 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
  466. 11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
  467. },
  468. {
  469. 15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
  470. 12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
  471. 15, 10, 14, 10, 4, 4, 5, 7, 8, 9, 5, 3, 4, 5, 6, 8,
  472. 5, 4, 3, 5, 6, 8, 7, 5, 5, 5, 6, 7, 9, 7, 6, 6,
  473. 6, 7, 10, 8, 8, 8, 7, 7, 4 /* 73 elements */
  474. }
  475. };
  476. /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
  477. /* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
  478. static const int8_t vc1_normal_zz[64] = {
  479. 0, 8, 1, 2, 9, 16, 24, 17,
  480. 10, 3, 4, 11, 18, 25, 32, 40,
  481. 33, 48, 26, 19, 12, 5, 6, 13,
  482. 20, 27, 34, 41, 56, 49, 57, 42,
  483. 35, 28, 21, 14, 7, 15, 22, 29,
  484. 36, 43, 50, 58, 51, 59, 44, 37,
  485. 30, 23, 31, 38, 45, 52, 60, 53,
  486. 61, 46, 39, 47, 54, 62, 55, 63
  487. };
  488. static const int8_t vc1_horizontal_zz [64] = /* Table 227 */
  489. {
  490. 0, 1, 8, 2, 3, 9, 16, 24,
  491. 17, 10, 4, 5, 11, 18, 25, 32,
  492. 40, 48, 33, 26, 19, 12, 6, 7,
  493. 13, 20, 27, 34, 41, 56, 49, 57,
  494. 42, 35, 28, 21, 14, 15, 22, 29,
  495. 36, 43, 50, 58, 51, 44, 37, 30,
  496. 23, 31, 38, 45, 52, 59, 60, 53,
  497. 46, 39, 47, 54, 61, 62, 55, 63
  498. };
  499. static const int8_t vc1_vertical_zz [64] = /* Table 228 */
  500. {
  501. 0, 8, 16, 1, 24, 32, 40, 9,
  502. 2, 3, 10, 17, 25, 48, 56, 41,
  503. 33, 26, 18, 11, 4, 5, 12, 19,
  504. 27, 34, 49, 57, 50, 42, 35, 28,
  505. 20, 13, 6, 7, 14, 21, 29, 36,
  506. 43, 51, 58, 59, 52, 44, 37, 30,
  507. 22, 15, 23, 31, 38, 45, 60, 53,
  508. 46, 39, 47, 54, 61, 62, 55, 63
  509. };
  510. static const int8_t vc1_simple_progressive_8x8_zz [64] =
  511. /* Table 229 */
  512. {
  513. 0, 8, 1, 2, 9, 16, 24, 17,
  514. 10, 3, 4, 11, 18, 25, 32, 40,
  515. 48, 56, 41, 33, 26, 19, 12, 5,
  516. 6, 13, 20, 27, 34, 49, 57, 58,
  517. 50, 42, 35, 28, 21, 14, 7, 15,
  518. 22, 29, 36, 43, 51, 59, 60, 52,
  519. 44, 37, 30, 23, 31, 38, 45, 53,
  520. 61, 62, 54, 46, 39, 47, 55, 63
  521. };
  522. static const int8_t vc1_simple_progressive_8x4_zz [32] = /* Table 230 */
  523. {
  524. 0, 1, 2, 8, 3, 9, 10, 16,
  525. 4, 11, 17, 24, 18, 12, 5, 19,
  526. 25, 13, 20, 26, 27, 6, 21, 28,
  527. 14, 22, 29, 7, 30, 15, 23, 31
  528. };
  529. static const int8_t vc1_simple_progressive_4x8_zz [32] = /* Table 231 */
  530. {
  531. 0, 8, 1, 16,
  532. 9, 24, 17, 2,
  533. 32, 10, 25, 40,
  534. 18, 48, 33, 26,
  535. 56, 41, 34, 3,
  536. 49, 57, 11, 42,
  537. 19, 50, 27, 58,
  538. 35, 43, 51, 59
  539. };
  540. /* Table 232 */
  541. static const int8_t vc1_simple_progressive_4x4_zz [16] =
  542. {
  543. 0, 8, 16, 1,
  544. 9, 24, 17, 2,
  545. 10, 18, 25, 3,
  546. 11, 26, 19, 27
  547. };
  548. static const int8_t vc1_adv_progressive_8x4_zz [32] = /* Table 233 */
  549. {
  550. 0, 8, 1, 16, 2, 9, 10, 3,
  551. 24, 17, 4, 11, 18, 12, 5, 19,
  552. 25, 13, 20, 26, 27, 6, 21, 28,
  553. 14, 22, 29, 7, 30, 15, 23, 31
  554. };
  555. static const int8_t vc1_adv_progressive_4x8_zz [32] = /* Table 234 */
  556. {
  557. 0, 1, 8, 2,
  558. 9, 16, 17, 24,
  559. 10, 32, 25, 18,
  560. 40, 3, 33, 26,
  561. 48, 11, 56, 41,
  562. 34, 49, 57, 42,
  563. 19, 50, 27, 58,
  564. 35, 43, 51, 59
  565. };
  566. static const int8_t vc1_adv_interlaced_8x8_zz [64] = /* Table 235 */
  567. {
  568. 0, 8, 1, 16, 24, 9, 2, 32,
  569. 40, 48, 56, 17, 10, 3, 25, 18,
  570. 11, 4, 33, 41, 49, 57, 26, 34,
  571. 42, 50, 58, 19, 12, 5, 27, 20,
  572. 13, 6, 35, 28, 21, 14, 7, 15,
  573. 22, 29, 36, 43, 51, 59, 60, 52,
  574. 44, 37, 30, 23, 31, 38, 45, 53,
  575. 61, 62, 54, 46, 39, 47, 55, 63
  576. };
  577. static const int8_t vc1_adv_interlaced_8x4_zz [32] = /* Table 236 */
  578. {
  579. 0, 8, 16, 24, 1, 9, 2, 17,
  580. 25, 10, 3, 18, 26, 4, 11, 19,
  581. 12, 5, 13, 20, 27, 6, 21, 28,
  582. 14, 22, 29, 7, 30, 15, 23, 31
  583. };
  584. static const int8_t vc1_adv_interlaced_4x8_zz [32] = /* Table 237 */
  585. {
  586. 0, 1, 2, 8,
  587. 16, 9, 24, 17,
  588. 10, 3, 32, 40,
  589. 48, 56, 25, 18,
  590. 33, 26, 41, 34,
  591. 49, 57, 11, 42,
  592. 19, 50, 27, 58,
  593. 35, 43, 51, 59
  594. };
  595. static const int8_t vc1_adv_interlaced_4x4_zz [16] = /* Table 238 */
  596. {
  597. 0, 8, 16, 24,
  598. 1, 9, 17, 2,
  599. 25, 10, 18, 3,
  600. 26, 11, 19, 27
  601. };
  602. /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
  603. static const int32_t vc1_dqscale[63] = {
  604. 0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000,
  605. 0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000,
  606. 0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB,
  607. 0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000,
  608. 0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A,
  609. 0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555,
  610. 0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
  611. 0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000
  612. };
  613. #endif /* VC1DATA_H */