vp6data.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /*
  2. * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg 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.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * VP6 compatible video decoder
  23. */
  24. #ifndef AVCODEC_VP6DATA_H
  25. #define AVCODEC_VP6DATA_H
  26. #include <stdint.h>
  27. #include "vp56.h"
  28. static const uint8_t vp6_def_fdv_vector_model[2][8] = {
  29. { 247, 210, 135, 68, 138, 220, 239, 246 },
  30. { 244, 184, 201, 44, 173, 221, 239, 253 },
  31. };
  32. static const uint8_t vp6_def_pdv_vector_model[2][7] = {
  33. { 225, 146, 172, 147, 214, 39, 156 },
  34. { 204, 170, 119, 235, 140, 230, 228 },
  35. };
  36. static const uint8_t vp6_def_coeff_reorder[] = {
  37. 0, 0, 1, 1, 1, 2, 2, 2,
  38. 2, 2, 2, 3, 3, 4, 4, 4,
  39. 5, 5, 5, 5, 6, 6, 7, 7,
  40. 7, 7, 7, 8, 8, 9, 9, 9,
  41. 9, 9, 9, 10, 10, 11, 11, 11,
  42. 11, 11, 11, 12, 12, 12, 12, 12,
  43. 12, 13, 13, 13, 13, 13, 14, 14,
  44. 14, 14, 15, 15, 15, 15, 15, 15,
  45. };
  46. static const uint8_t vp6_def_runv_coeff_model[2][14] = {
  47. { 198, 197, 196, 146, 198, 204, 169, 142, 130, 136, 149, 149, 191, 249 },
  48. { 135, 201, 181, 154, 98, 117, 132, 126, 146, 169, 184, 240, 246, 254 },
  49. };
  50. static const uint8_t vp6_sig_dct_pct[2][2] = {
  51. { 237, 246 },
  52. { 231, 243 },
  53. };
  54. static const uint8_t vp6_pdv_pct[2][7] = {
  55. { 253, 253, 254, 254, 254, 254, 254 },
  56. { 245, 253, 254, 254, 254, 254, 254 },
  57. };
  58. static const uint8_t vp6_fdv_pct[2][8] = {
  59. { 254, 254, 254, 254, 254, 250, 250, 252 },
  60. { 254, 254, 254, 254, 254, 251, 251, 254 },
  61. };
  62. static const uint8_t vp6_dccv_pct[2][11] = {
  63. { 146, 255, 181, 207, 232, 243, 238, 251, 244, 250, 249 },
  64. { 179, 255, 214, 240, 250, 255, 244, 255, 255, 255, 255 },
  65. };
  66. static const uint8_t vp6_coeff_reorder_pct[] = {
  67. 255, 132, 132, 159, 153, 151, 161, 170,
  68. 164, 162, 136, 110, 103, 114, 129, 118,
  69. 124, 125, 132, 136, 114, 110, 142, 135,
  70. 134, 123, 143, 126, 153, 183, 166, 161,
  71. 171, 180, 179, 164, 203, 218, 225, 217,
  72. 215, 206, 203, 217, 229, 241, 248, 243,
  73. 253, 255, 253, 255, 255, 255, 255, 255,
  74. 255, 255, 255, 255, 255, 255, 255, 255,
  75. };
  76. static const uint8_t vp6_runv_pct[2][14] = {
  77. { 219, 246, 238, 249, 232, 239, 249, 255, 248, 253, 239, 244, 241, 248 },
  78. { 198, 232, 251, 253, 219, 241, 253, 255, 248, 249, 244, 238, 251, 255 },
  79. };
  80. static const uint8_t vp6_ract_pct[3][2][6][11] = {
  81. { { { 227, 246, 230, 247, 244, 255, 255, 255, 255, 255, 255 },
  82. { 255, 255, 209, 231, 231, 249, 249, 253, 255, 255, 255 },
  83. { 255, 255, 225, 242, 241, 251, 253, 255, 255, 255, 255 },
  84. { 255, 255, 241, 253, 252, 255, 255, 255, 255, 255, 255 },
  85. { 255, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
  86. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
  87. { { 240, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
  88. { 255, 255, 240, 253, 255, 255, 255, 255, 255, 255, 255 },
  89. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  90. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  91. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  92. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } },
  93. { { { 206, 203, 227, 239, 247, 255, 253, 255, 255, 255, 255 },
  94. { 207, 199, 220, 236, 243, 252, 252, 255, 255, 255, 255 },
  95. { 212, 219, 230, 243, 244, 253, 252, 255, 255, 255, 255 },
  96. { 236, 237, 247, 252, 253, 255, 255, 255, 255, 255, 255 },
  97. { 240, 240, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
  98. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
  99. { { 230, 233, 249, 255, 255, 255, 255, 255, 255, 255, 255 },
  100. { 238, 238, 250, 255, 255, 255, 255, 255, 255, 255, 255 },
  101. { 248, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  102. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  103. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  104. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } },
  105. { { { 225, 239, 227, 231, 244, 253, 243, 255, 255, 253, 255 },
  106. { 232, 234, 224, 228, 242, 249, 242, 252, 251, 251, 255 },
  107. { 235, 249, 238, 240, 251, 255, 249, 255, 253, 253, 255 },
  108. { 249, 253, 251, 250, 255, 255, 255, 255, 255, 255, 255 },
  109. { 251, 250, 249, 255, 255, 255, 255, 255, 255, 255, 255 },
  110. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
  111. { { 243, 244, 250, 250, 255, 255, 255, 255, 255, 255, 255 },
  112. { 249, 248, 250, 253, 255, 255, 255, 255, 255, 255, 255 },
  113. { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  114. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  115. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
  116. { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } }
  117. };
  118. static const int vp6_dccv_lc[3][5][2] = {
  119. { { 122, 133 }, { 0, 1 }, { 78, 171 }, { 139, 117 }, { 168, 79 } },
  120. { { 133, 51 }, { 0, 1 }, { 169, 71 }, { 214, 44 }, { 210, 38 } },
  121. { { 142, -16 }, { 0, 1 }, { 221, -30 }, { 246, -3 }, { 203, 17 } },
  122. };
  123. static const uint8_t vp6_coeff_groups[] = {
  124. 0, 0, 1, 1, 1, 2, 2, 2,
  125. 2, 2, 2, 3, 3, 3, 3, 3,
  126. 3, 3, 3, 3, 3, 3, 4, 4,
  127. 4, 4, 4, 4, 4, 4, 4, 4,
  128. 4, 4, 4, 4, 4, 5, 5, 5,
  129. 5, 5, 5, 5, 5, 5, 5, 5,
  130. 5, 5, 5, 5, 5, 5, 5, 5,
  131. 5, 5, 5, 5, 5, 5, 5, 5,
  132. };
  133. static const int16_t vp6_block_copy_filter[17][8][4] = {
  134. { { 0, 128, 0, 0 }, /* 0 */
  135. { -3, 122, 9, 0 },
  136. { -4, 109, 24, -1 },
  137. { -5, 91, 45, -3 },
  138. { -4, 68, 68, -4 },
  139. { -3, 45, 91, -5 },
  140. { -1, 24, 109, -4 },
  141. { 0, 9, 122, -3 } },
  142. { { 0, 128, 0, 0 }, /* 1 */
  143. { -4, 124, 9, -1 },
  144. { -5, 110, 25, -2 },
  145. { -6, 91, 46, -3 },
  146. { -5, 69, 69, -5 },
  147. { -3, 46, 91, -6 },
  148. { -2, 25, 110, -5 },
  149. { -1, 9, 124, -4 } },
  150. { { 0, 128, 0, 0 }, /* 2 */
  151. { -4, 123, 10, -1 },
  152. { -6, 110, 26, -2 },
  153. { -7, 92, 47, -4 },
  154. { -6, 70, 70, -6 },
  155. { -4, 47, 92, -7 },
  156. { -2, 26, 110, -6 },
  157. { -1, 10, 123, -4 } },
  158. { { 0, 128, 0, 0 }, /* 3 */
  159. { -5, 124, 10, -1 },
  160. { -7, 110, 27, -2 },
  161. { -7, 91, 48, -4 },
  162. { -6, 70, 70, -6 },
  163. { -4, 48, 92, -8 },
  164. { -2, 27, 110, -7 },
  165. { -1, 10, 124, -5 } },
  166. { { 0, 128, 0, 0 }, /* 4 */
  167. { -6, 124, 11, -1 },
  168. { -8, 111, 28, -3 },
  169. { -8, 92, 49, -5 },
  170. { -7, 71, 71, -7 },
  171. { -5, 49, 92, -8 },
  172. { -3, 28, 111, -8 },
  173. { -1, 11, 124, -6 } },
  174. { { 0, 128, 0, 0 }, /* 5 */
  175. { -6, 123, 12, -1 },
  176. { -9, 111, 29, -3 },
  177. { -9, 93, 50, -6 },
  178. { -8, 72, 72, -8 },
  179. { -6, 50, 93, -9 },
  180. { -3, 29, 111, -9 },
  181. { -1, 12, 123, -6 } },
  182. { { 0, 128, 0, 0 }, /* 6 */
  183. { -7, 124, 12, -1 },
  184. { -10, 111, 30, -3 },
  185. { -10, 93, 51, -6 },
  186. { -9, 73, 73, -9 },
  187. { -6, 51, 93, -10 },
  188. { -3, 30, 111, -10 },
  189. { -1, 12, 124, -7 } },
  190. { { 0, 128, 0, 0 }, /* 7 */
  191. { -7, 123, 13, -1 },
  192. { -11, 112, 31, -4 },
  193. { -11, 94, 52, -7 },
  194. { -10, 74, 74, -10 },
  195. { -7, 52, 94, -11 },
  196. { -4, 31, 112, -11 },
  197. { -1, 13, 123, -7 } },
  198. { { 0, 128, 0, 0 }, /* 8 */
  199. { -8, 124, 13, -1 },
  200. { -12, 112, 32, -4 },
  201. { -12, 94, 53, -7 },
  202. { -10, 74, 74, -10 },
  203. { -7, 53, 94, -12 },
  204. { -4, 32, 112, -12 },
  205. { -1, 13, 124, -8 } },
  206. { { 0, 128, 0, 0 }, /* 9 */
  207. { -9, 124, 14, -1 },
  208. { -13, 112, 33, -4 },
  209. { -13, 95, 54, -8 },
  210. { -11, 75, 75, -11 },
  211. { -8, 54, 95, -13 },
  212. { -4, 33, 112, -13 },
  213. { -1, 14, 124, -9 } },
  214. { { 0, 128, 0, 0 }, /* 10 */
  215. { -9, 123, 15, -1 },
  216. { -14, 113, 34, -5 },
  217. { -14, 95, 55, -8 },
  218. { -12, 76, 76, -12 },
  219. { -8, 55, 95, -14 },
  220. { -5, 34, 112, -13 },
  221. { -1, 15, 123, -9 } },
  222. { { 0, 128, 0, 0 }, /* 11 */
  223. { -10, 124, 15, -1 },
  224. { -14, 113, 34, -5 },
  225. { -15, 96, 56, -9 },
  226. { -13, 77, 77, -13 },
  227. { -9, 56, 96, -15 },
  228. { -5, 34, 113, -14 },
  229. { -1, 15, 124, -10 } },
  230. { { 0, 128, 0, 0 }, /* 12 */
  231. { -10, 123, 16, -1 },
  232. { -15, 113, 35, -5 },
  233. { -16, 98, 56, -10 },
  234. { -14, 78, 78, -14 },
  235. { -10, 56, 98, -16 },
  236. { -5, 35, 113, -15 },
  237. { -1, 16, 123, -10 } },
  238. { { 0, 128, 0, 0 }, /* 13 */
  239. { -11, 124, 17, -2 },
  240. { -16, 113, 36, -5 },
  241. { -17, 98, 57, -10 },
  242. { -14, 78, 78, -14 },
  243. { -10, 57, 98, -17 },
  244. { -5, 36, 113, -16 },
  245. { -2, 17, 124, -11 } },
  246. { { 0, 128, 0, 0 }, /* 14 */
  247. { -12, 125, 17, -2 },
  248. { -17, 114, 37, -6 },
  249. { -18, 99, 58, -11 },
  250. { -15, 79, 79, -15 },
  251. { -11, 58, 99, -18 },
  252. { -6, 37, 114, -17 },
  253. { -2, 17, 125, -12 } },
  254. { { 0, 128, 0, 0 }, /* 15 */
  255. { -12, 124, 18, -2 },
  256. { -18, 114, 38, -6 },
  257. { -19, 99, 59, -11 },
  258. { -16, 80, 80, -16 },
  259. { -11, 59, 99, -19 },
  260. { -6, 38, 114, -18 },
  261. { -2, 18, 124, -12 } },
  262. { { 0, 128, 0, 0 }, /* 16 */
  263. { -4, 118, 16, -2 },
  264. { -7, 106, 34, -5 },
  265. { -8, 90, 53, -7 },
  266. { -8, 72, 72, -8 },
  267. { -7, 53, 90, -8 },
  268. { -5, 34, 106, -7 },
  269. { -2, 16, 118, -4 } },
  270. };
  271. static const VP56Tree vp6_pcr_tree[] = {
  272. { 8, 0},
  273. { 4, 1},
  274. { 2, 2}, {-1}, {-2},
  275. { 2, 3}, {-3}, {-4},
  276. { 8, 4},
  277. { 4, 5},
  278. { 2, 6}, {-5}, {-6},
  279. { 2, 7}, {-7}, {-8},
  280. {-0},
  281. };
  282. static const uint8_t vp6_coord_div[] = { 4, 4, 4, 4, 8, 8 };
  283. static const uint8_t vp6_huff_coeff_map[] = {
  284. 13, 14, 11, 0, 1, 15, 16, 18, 2, 17, 3, 4, 19, 20, 5, 6, 21, 22, 7, 8, 9, 10
  285. };
  286. static const uint8_t vp6_huff_run_map[] = {
  287. 10, 13, 11, 12, 0, 1, 2, 3, 14, 8, 15, 16, 4, 5, 6, 7
  288. };
  289. #endif /* AVCODEC_VP6DATA_H */