indeo4data.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. /*
  2. * Indeo Video Interactive 4 compatible decoder
  3. * Copyright (c) 2009-2010 Maxim Poliakovski
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  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 "ivi.h"
  29. /**
  30. * standard picture dimensions
  31. */
  32. static const uint16_t ivi4_common_pic_sizes[14] = {
  33. 640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
  34. };
  35. /**
  36. * Indeo 4 8x8 scan (zigzag) patterns
  37. */
  38. static const uint8_t ivi4_alternate_scan_8x8[64] = {
  39. 0, 8, 1, 9, 16, 24, 2, 3, 17, 25, 10, 11, 32, 40, 48, 56,
  40. 4, 5, 6, 7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
  41. 34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
  42. 36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
  43. };
  44. static const uint8_t ivi4_alternate_scan_4x4[16] = {
  45. 0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
  46. };
  47. static const uint8_t ivi4_vertical_scan_4x4[16] = {
  48. 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
  49. };
  50. static const uint8_t ivi4_horizontal_scan_4x4[16] = {
  51. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
  52. };
  53. static const uint8_t * const scan_index_to_tab[15] = {
  54. // for 8x8 transforms
  55. ff_zigzag_direct,
  56. ivi4_alternate_scan_8x8,
  57. ff_ivi_horizontal_scan_8x8,
  58. ff_ivi_vertical_scan_8x8,
  59. ff_zigzag_direct,
  60. // for 4x4 transforms
  61. ff_ivi_direct_scan_4x4,
  62. ivi4_alternate_scan_4x4,
  63. ivi4_vertical_scan_4x4,
  64. ivi4_horizontal_scan_4x4,
  65. ff_ivi_direct_scan_4x4,
  66. // TODO: check if those are needed
  67. ff_ivi_horizontal_scan_8x8,
  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. };
  73. /**
  74. * Indeo 4 dequant tables
  75. */
  76. static const uint16_t ivi4_quant_8x8_intra[9][64] = {
  77. {
  78. 43, 342, 385, 470, 555, 555, 598, 726,
  79. 342, 342, 470, 513, 555, 598, 726, 769,
  80. 385, 470, 555, 555, 598, 726, 726, 811,
  81. 470, 470, 555, 555, 598, 726, 769, 854,
  82. 470, 555, 555, 598, 683, 726, 854, 1025,
  83. 555, 555, 598, 683, 726, 854, 1025, 1153,
  84. 555, 555, 598, 726, 811, 982, 1195, 1451,
  85. 555, 598, 726, 811, 982, 1195, 1451, 1793
  86. },
  87. {
  88. 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
  89. 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
  90. 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
  91. 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
  92. 4865, 4865, 6827, 6827, 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. },
  97. {
  98. 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
  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. },
  107. {
  108. 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
  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. },
  117. {
  118. 897, 897, 897, 897, 897, 897, 897, 897,
  119. 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
  120. 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
  121. 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
  122. 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
  123. 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
  124. 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
  125. 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
  126. },
  127. {
  128. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  129. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  130. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  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. },
  137. {
  138. 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
  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. },
  147. {
  148. 22, 171, 214, 257, 257, 299, 299, 342,
  149. 171, 171, 257, 257, 299, 299, 342, 385,
  150. 214, 257, 257, 299, 299, 342, 342, 385,
  151. 257, 257, 257, 299, 299, 342, 385, 427,
  152. 257, 257, 299, 299, 342, 385, 427, 513,
  153. 257, 299, 299, 342, 385, 427, 513, 598,
  154. 299, 299, 299, 385, 385, 470, 598, 726,
  155. 299, 299, 385, 385, 470, 598, 726, 897
  156. },
  157. {
  158. 86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
  159. 598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
  160. 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
  161. 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
  162. 2390, 2390, 3414, 3414, 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. }
  167. };
  168. static const uint16_t ivi4_quant_8x8_inter[9][64] = {
  169. {
  170. 427, 427, 470, 427, 427, 427, 470, 470,
  171. 427, 427, 470, 427, 427, 427, 470, 470,
  172. 470, 470, 470, 470, 470, 470, 470, 470,
  173. 427, 427, 470, 470, 427, 427, 470, 470,
  174. 427, 427, 470, 427, 427, 427, 470, 470,
  175. 427, 427, 470, 427, 427, 427, 470, 470,
  176. 470, 470, 470, 470, 470, 470, 470, 470,
  177. 470, 470, 470, 470, 470, 470, 470, 470
  178. },
  179. {
  180. 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
  181. 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
  182. 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
  183. 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
  184. 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
  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. },
  189. {
  190. 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
  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. },
  199. {
  200. 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
  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. },
  209. {
  210. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  211. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  212. 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
  213. 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
  214. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  215. 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
  216. 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
  217. 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
  218. },
  219. {
  220. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  221. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  222. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  223. 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
  224. 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
  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. },
  229. {
  230. 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
  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. },
  239. {
  240. 86, 171, 171, 214, 214, 214, 214, 257,
  241. 171, 171, 214, 214, 214, 214, 257, 257,
  242. 171, 214, 214, 214, 214, 257, 257, 257,
  243. 214, 214, 214, 214, 257, 257, 257, 299,
  244. 214, 214, 214, 257, 257, 257, 299, 299,
  245. 214, 214, 257, 257, 257, 299, 299, 299,
  246. 214, 257, 257, 257, 299, 299, 299, 342,
  247. 257, 257, 257, 299, 299, 299, 342, 342
  248. },
  249. {
  250. 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
  251. 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
  252. 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
  253. 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
  254. 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
  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. }
  259. };
  260. static const uint16_t ivi4_quant_4x4_intra[5][16] = {
  261. {
  262. 22, 214, 257, 299,
  263. 214, 257, 299, 342,
  264. 257, 299, 342, 427,
  265. 299, 342, 427, 513
  266. },
  267. {
  268. 129, 1025, 1451, 1451,
  269. 1025, 1025, 1451, 1451,
  270. 1451, 1451, 2049, 2049,
  271. 1451, 1451, 2049, 2049
  272. },
  273. {
  274. 43, 171, 171, 171,
  275. 43, 171, 171, 171,
  276. 43, 171, 171, 171,
  277. 43, 171, 171, 171
  278. },
  279. {
  280. 43, 43, 43, 43,
  281. 171, 171, 171, 171,
  282. 171, 171, 171, 171,
  283. 171, 171, 171, 171
  284. },
  285. {
  286. 43, 43, 43, 43,
  287. 43, 43, 43, 43,
  288. 43, 43, 43, 43,
  289. 43, 43, 43, 43
  290. }
  291. };
  292. static const uint16_t ivi4_quant_4x4_inter[5][16] = {
  293. {
  294. 107, 214, 257, 299,
  295. 214, 257, 299, 299,
  296. 257, 299, 299, 342,
  297. 299, 299, 342, 342
  298. },
  299. {
  300. 513, 1025, 1238, 1238,
  301. 1025, 1025, 1238, 1238,
  302. 1238, 1238, 1451, 1451,
  303. 1238, 1238, 1451, 1451
  304. },
  305. {
  306. 43, 171, 171, 171,
  307. 43, 171, 171, 171,
  308. 43, 171, 171, 171,
  309. 43, 171, 171, 171
  310. },
  311. {
  312. 43, 43, 43, 43,
  313. 171, 171, 171, 171,
  314. 171, 171, 171, 171,
  315. 171, 171, 171, 171
  316. },
  317. {
  318. 43, 43, 43, 43,
  319. 43, 43, 43, 43,
  320. 43, 43, 43, 43,
  321. 43, 43, 43, 43
  322. }
  323. };
  324. /**
  325. * Table for mapping quant matrix index from the bitstream
  326. * into internal quant table number.
  327. */
  328. static const uint8_t quant_index_to_tab[22] = {
  329. 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
  330. 0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes
  331. };
  332. #endif /* AVCODEC_INDEO4DATA_H */