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.

351 lines
12KB

  1. /*
  2. * Indeo Video Interactive 4 compatible decoder
  3. * Copyright (c) 2009-2010 Maxim Poliakovski
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * This file contains data needed for the Indeo 4 decoder.
  24. */
  25. #ifndef AVCODEC_INDEO4DATA_H
  26. #define AVCODEC_INDEO4DATA_H
  27. #include <stdint.h>
  28. #include "dsputil.h"
  29. #include "ivi_common.h"
  30. /**
  31. * standard picture dimensions
  32. */
  33. static const uint16_t ivi4_common_pic_sizes[14] = {
  34. 640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
  35. };
  36. /**
  37. * Indeo 4 8x8 scan (zigzag) patterns
  38. */
  39. static const uint8_t ivi4_alternate_scan_8x8[64] = {
  40. 0, 8, 1, 9, 16, 24, 2, 3, 17, 25, 10, 11, 32, 40, 48, 56,
  41. 4, 5, 6, 7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
  42. 34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
  43. 36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
  44. };
  45. static const uint8_t ivi4_alternate_scan_4x4[16] = {
  46. 0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
  47. };
  48. static const uint8_t ivi4_vertical_scan_4x4[16] = {
  49. 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
  50. };
  51. static const uint8_t ivi4_horizontal_scan_4x4[16] = {
  52. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
  53. };
  54. static const uint8_t *scan_index_to_tab[15] = {
  55. // for 8x8 transforms
  56. ff_zigzag_direct,
  57. ivi4_alternate_scan_8x8,
  58. ff_ivi_horizontal_scan_8x8,
  59. ff_ivi_vertical_scan_8x8,
  60. ff_zigzag_direct,
  61. // for 4x4 transforms
  62. ff_ivi_direct_scan_4x4,
  63. ivi4_alternate_scan_4x4,
  64. ivi4_vertical_scan_4x4,
  65. ivi4_horizontal_scan_4x4,
  66. ff_ivi_direct_scan_4x4,
  67. // TODO: check if those are needed
  68. ff_ivi_horizontal_scan_8x8,
  69. ff_ivi_horizontal_scan_8x8,
  70. ff_ivi_horizontal_scan_8x8,
  71. ff_ivi_horizontal_scan_8x8,
  72. ff_ivi_horizontal_scan_8x8
  73. };
  74. /**
  75. * Indeo 4 dequant tables
  76. */
  77. static const uint16_t ivi4_quant_8x8_intra[9][64] = {
  78. {
  79. 43, 342, 385, 470, 555, 555, 598, 726,
  80. 342, 342, 470, 513, 555, 598, 726, 769,
  81. 385, 470, 555, 555, 598, 726, 726, 811,
  82. 470, 470, 555, 555, 598, 726, 769, 854,
  83. 470, 555, 555, 598, 683, 726, 854, 1025,
  84. 555, 555, 598, 683, 726, 854, 1025, 1153,
  85. 555, 555, 598, 726, 811, 982, 1195, 1451,
  86. 555, 598, 726, 811, 982, 1195, 1451, 1793
  87. },
  88. {
  89. 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
  90. 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
  91. 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
  92. 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
  93. 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
  94. 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
  95. 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
  96. 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
  97. },
  98. {
  99. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  100. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  101. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  102. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  103. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  104. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  105. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  106. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
  107. },
  108. {
  109. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  110. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  111. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  112. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  113. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  114. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  115. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  116. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
  117. },
  118. {
  119. 897, 897, 897, 897, 897, 897, 897, 897,
  120. 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
  121. 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
  122. 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
  123. 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
  124. 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
  125. 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
  126. 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
  127. },
  128. {
  129. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  130. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  131. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  132. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  133. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  134. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  135. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  136. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
  137. },
  138. {
  139. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  140. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  141. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  142. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  143. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  144. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  145. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  146. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
  147. },
  148. {
  149. 22, 171, 214, 257, 257, 299, 299, 342,
  150. 171, 171, 257, 257, 299, 299, 342, 385,
  151. 214, 257, 257, 299, 299, 342, 342, 385,
  152. 257, 257, 257, 299, 299, 342, 385, 427,
  153. 257, 257, 299, 299, 342, 385, 427, 513,
  154. 257, 299, 299, 342, 385, 427, 513, 598,
  155. 299, 299, 299, 385, 385, 470, 598, 726,
  156. 299, 299, 385, 385, 470, 598, 726, 897
  157. },
  158. {
  159. 86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
  160. 598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
  161. 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
  162. 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
  163. 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
  164. 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
  165. 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
  166. 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
  167. }
  168. };
  169. static const uint16_t ivi4_quant_8x8_inter[9][64] = {
  170. {
  171. 427, 427, 470, 427, 427, 427, 470, 470,
  172. 427, 427, 470, 427, 427, 427, 470, 470,
  173. 470, 470, 470, 470, 470, 470, 470, 470,
  174. 427, 427, 470, 470, 427, 427, 470, 470,
  175. 427, 427, 470, 427, 427, 427, 470, 470,
  176. 427, 427, 470, 427, 427, 427, 470, 470,
  177. 470, 470, 470, 470, 470, 470, 470, 470,
  178. 470, 470, 470, 470, 470, 470, 470, 470
  179. },
  180. {
  181. 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
  182. 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
  183. 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
  184. 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
  185. 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
  186. 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
  187. 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
  188. 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
  189. },
  190. {
  191. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  192. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  193. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  194. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  195. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  196. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  197. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  198. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
  199. },
  200. {
  201. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  202. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  203. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  204. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  205. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  206. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  207. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  208. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
  209. },
  210. {
  211. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  212. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  213. 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
  214. 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
  215. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  216. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  217. 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
  218. 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
  219. },
  220. {
  221. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  222. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  223. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  224. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  225. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  226. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  227. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  228. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
  229. },
  230. {
  231. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  232. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  233. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  234. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  235. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  236. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  237. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  238. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
  239. },
  240. {
  241. 86, 171, 171, 214, 214, 214, 214, 257,
  242. 171, 171, 214, 214, 214, 214, 257, 257,
  243. 171, 214, 214, 214, 214, 257, 257, 257,
  244. 214, 214, 214, 214, 257, 257, 257, 299,
  245. 214, 214, 214, 257, 257, 257, 299, 299,
  246. 214, 214, 257, 257, 257, 299, 299, 299,
  247. 214, 257, 257, 257, 299, 299, 299, 342,
  248. 257, 257, 257, 299, 299, 299, 342, 342
  249. },
  250. {
  251. 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
  252. 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
  253. 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
  254. 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
  255. 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
  256. 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
  257. 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
  258. 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
  259. }
  260. };
  261. static const uint16_t ivi4_quant_4x4_intra[5][16] = {
  262. {
  263. 22, 214, 257, 299,
  264. 214, 257, 299, 342,
  265. 257, 299, 342, 427,
  266. 299, 342, 427, 513
  267. },
  268. {
  269. 129, 1025, 1451, 1451,
  270. 1025, 1025, 1451, 1451,
  271. 1451, 1451, 2049, 2049,
  272. 1451, 1451, 2049, 2049
  273. },
  274. {
  275. 43, 171, 171, 171,
  276. 43, 171, 171, 171,
  277. 43, 171, 171, 171,
  278. 43, 171, 171, 171
  279. },
  280. {
  281. 43, 43, 43, 43,
  282. 171, 171, 171, 171,
  283. 171, 171, 171, 171,
  284. 171, 171, 171, 171
  285. },
  286. {
  287. 43, 43, 43, 43,
  288. 43, 43, 43, 43,
  289. 43, 43, 43, 43,
  290. 43, 43, 43, 43
  291. }
  292. };
  293. static const uint16_t ivi4_quant_4x4_inter[5][16] = {
  294. {
  295. 107, 214, 257, 299,
  296. 214, 257, 299, 299,
  297. 257, 299, 299, 342,
  298. 299, 299, 342, 342
  299. },
  300. {
  301. 513, 1025, 1238, 1238,
  302. 1025, 1025, 1238, 1238,
  303. 1238, 1238, 1451, 1451,
  304. 1238, 1238, 1451, 1451
  305. },
  306. {
  307. 43, 171, 171, 171,
  308. 43, 171, 171, 171,
  309. 43, 171, 171, 171,
  310. 43, 171, 171, 171
  311. },
  312. {
  313. 43, 43, 43, 43,
  314. 171, 171, 171, 171,
  315. 171, 171, 171, 171,
  316. 171, 171, 171, 171
  317. },
  318. {
  319. 43, 43, 43, 43,
  320. 43, 43, 43, 43,
  321. 43, 43, 43, 43,
  322. 43, 43, 43, 43
  323. }
  324. };
  325. /**
  326. * Table for mapping quant matrix index from the bitstream
  327. * into internal quant table number.
  328. */
  329. static const uint8_t quant_index_to_tab[22] = {
  330. 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
  331. 0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes
  332. };
  333. #endif /* AVCODEC_INDEO4DATA_H */