vp56data.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /**
  2. * @file libavcodec/vp56data.h
  3. * VP5 and VP6 compatible video decoder (common data)
  4. *
  5. * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVCODEC_VP56DATA_H
  24. #define AVCODEC_VP56DATA_H
  25. #include "libavutil/common.h"
  26. typedef enum {
  27. VP56_FRAME_NONE =-1,
  28. VP56_FRAME_CURRENT = 0,
  29. VP56_FRAME_PREVIOUS = 1,
  30. VP56_FRAME_GOLDEN = 2,
  31. VP56_FRAME_GOLDEN2 = 3,
  32. VP56_FRAME_UNUSED = 4,
  33. VP56_FRAME_UNUSED2 = 5,
  34. } VP56Frame;
  35. typedef enum {
  36. VP56_MB_INTER_NOVEC_PF = 0, /**< Inter MB, no vector, from previous frame */
  37. VP56_MB_INTRA = 1, /**< Intra MB */
  38. VP56_MB_INTER_DELTA_PF = 2, /**< Inter MB, above/left vector + delta, from previous frame */
  39. VP56_MB_INTER_V1_PF = 3, /**< Inter MB, first vector, from previous frame */
  40. VP56_MB_INTER_V2_PF = 4, /**< Inter MB, second vector, from previous frame */
  41. VP56_MB_INTER_NOVEC_GF = 5, /**< Inter MB, no vector, from golden frame */
  42. VP56_MB_INTER_DELTA_GF = 6, /**< Inter MB, above/left vector + delta, from golden frame */
  43. VP56_MB_INTER_4V = 7, /**< Inter MB, 4 vectors, from previous frame */
  44. VP56_MB_INTER_V1_GF = 8, /**< Inter MB, first vector, from golden frame */
  45. VP56_MB_INTER_V2_GF = 9, /**< Inter MB, second vector, from golden frame */
  46. } VP56mb;
  47. typedef struct {
  48. int8_t val;
  49. int8_t prob_idx;
  50. } VP56Tree;
  51. extern const uint8_t vp56_b2p[];
  52. extern const uint8_t vp56_b6to4[];
  53. extern const uint8_t vp56_coeff_parse_table[6][11];
  54. extern const uint8_t vp56_def_mb_types_stats[3][10][2];
  55. extern const VP56Tree vp56_pva_tree[];
  56. extern const VP56Tree vp56_pc_tree[];
  57. extern const uint8_t vp56_coeff_bias[];
  58. extern const uint8_t vp56_coeff_bit_length[];
  59. static const VP56Frame vp56_reference_frame[] = {
  60. VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_NOVEC_PF */
  61. VP56_FRAME_CURRENT, /* VP56_MB_INTRA */
  62. VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_DELTA_PF */
  63. VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_V1_PF */
  64. VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_V2_PF */
  65. VP56_FRAME_GOLDEN, /* VP56_MB_INTER_NOVEC_GF */
  66. VP56_FRAME_GOLDEN, /* VP56_MB_INTER_DELTA_GF */
  67. VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_4V */
  68. VP56_FRAME_GOLDEN, /* VP56_MB_INTER_V1_GF */
  69. VP56_FRAME_GOLDEN, /* VP56_MB_INTER_V2_GF */
  70. };
  71. static const uint8_t vp56_ac_dequant[64] = {
  72. 94, 92, 90, 88, 86, 82, 78, 74,
  73. 70, 66, 62, 58, 54, 53, 52, 51,
  74. 50, 49, 48, 47, 46, 45, 44, 43,
  75. 42, 40, 39, 37, 36, 35, 34, 33,
  76. 32, 31, 30, 29, 28, 27, 26, 25,
  77. 24, 23, 22, 21, 20, 19, 18, 17,
  78. 16, 15, 14, 13, 12, 11, 10, 9,
  79. 8, 7, 6, 5, 4, 3, 2, 1,
  80. };
  81. static const uint8_t vp56_dc_dequant[64] = {
  82. 47, 47, 47, 47, 45, 43, 43, 43,
  83. 43, 43, 42, 41, 41, 40, 40, 40,
  84. 40, 35, 35, 35, 35, 33, 33, 33,
  85. 33, 32, 32, 32, 27, 27, 26, 26,
  86. 25, 25, 24, 24, 23, 23, 19, 19,
  87. 19, 19, 18, 18, 17, 16, 16, 16,
  88. 16, 16, 15, 11, 11, 11, 10, 10,
  89. 9, 8, 7, 5, 3, 3, 2, 2,
  90. };
  91. static const uint8_t vp56_pre_def_mb_type_stats[16][3][10][2] = {
  92. { { { 9, 15 }, { 32, 25 }, { 7, 19 }, { 9, 21 }, { 1, 12 },
  93. { 14, 12 }, { 3, 18 }, { 14, 23 }, { 3, 10 }, { 0, 4 }, },
  94. { { 41, 22 }, { 1, 0 }, { 1, 31 }, { 0, 0 }, { 0, 0 },
  95. { 0, 1 }, { 1, 7 }, { 0, 1 }, { 98, 25 }, { 4, 10 }, },
  96. { { 2, 3 }, { 2, 3 }, { 0, 2 }, { 0, 2 }, { 0, 0 },
  97. { 11, 4 }, { 1, 4 }, { 0, 2 }, { 3, 2 }, { 0, 4 }, }, },
  98. { { { 48, 39 }, { 1, 2 }, { 11, 27 }, { 29, 44 }, { 7, 27 },
  99. { 1, 4 }, { 0, 3 }, { 1, 6 }, { 1, 2 }, { 0, 0 }, },
  100. { { 123, 37 }, { 6, 4 }, { 1, 27 }, { 0, 0 }, { 0, 0 },
  101. { 5, 8 }, { 1, 7 }, { 0, 1 }, { 12, 10 }, { 0, 2 }, },
  102. { { 49, 46 }, { 3, 4 }, { 7, 31 }, { 42, 41 }, { 0, 0 },
  103. { 2, 6 }, { 1, 7 }, { 1, 4 }, { 2, 4 }, { 0, 1 }, }, },
  104. { { { 21, 32 }, { 1, 2 }, { 4, 10 }, { 32, 43 }, { 6, 23 },
  105. { 2, 3 }, { 1, 19 }, { 1, 6 }, { 12, 21 }, { 0, 7 }, },
  106. { { 26, 14 }, { 14, 12 }, { 0, 24 }, { 0, 0 }, { 0, 0 },
  107. { 55, 17 }, { 1, 9 }, { 0, 36 }, { 5, 7 }, { 1, 3 }, },
  108. { { 26, 25 }, { 1, 1 }, { 2, 10 }, { 67, 39 }, { 0, 0 },
  109. { 1, 1 }, { 0, 14 }, { 0, 2 }, { 31, 26 }, { 1, 6 }, }, },
  110. { { { 69, 83 }, { 0, 0 }, { 0, 2 }, { 10, 29 }, { 3, 12 },
  111. { 0, 1 }, { 0, 3 }, { 0, 3 }, { 2, 2 }, { 0, 0 }, },
  112. { { 209, 5 }, { 0, 0 }, { 0, 27 }, { 0, 0 }, { 0, 0 },
  113. { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
  114. { { 103, 46 }, { 1, 2 }, { 2, 10 }, { 33, 42 }, { 0, 0 },
  115. { 1, 4 }, { 0, 3 }, { 0, 1 }, { 1, 3 }, { 0, 0 }, }, },
  116. { { { 11, 20 }, { 1, 4 }, { 18, 36 }, { 43, 48 }, { 13, 35 },
  117. { 0, 2 }, { 0, 5 }, { 3, 12 }, { 1, 2 }, { 0, 0 }, },
  118. { { 2, 5 }, { 4, 5 }, { 0, 121 }, { 0, 0 }, { 0, 0 },
  119. { 0, 3 }, { 2, 4 }, { 1, 4 }, { 2, 2 }, { 0, 1 }, },
  120. { { 14, 31 }, { 9, 13 }, { 14, 54 }, { 22, 29 }, { 0, 0 },
  121. { 2, 6 }, { 4, 18 }, { 6, 13 }, { 1, 5 }, { 0, 1 }, }, },
  122. { { { 70, 44 }, { 0, 1 }, { 2, 10 }, { 37, 46 }, { 8, 26 },
  123. { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, },
  124. { { 175, 5 }, { 0, 1 }, { 0, 48 }, { 0, 0 }, { 0, 0 },
  125. { 0, 2 }, { 0, 1 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, },
  126. { { 85, 39 }, { 0, 0 }, { 1, 9 }, { 69, 40 }, { 0, 0 },
  127. { 0, 1 }, { 0, 3 }, { 0, 1 }, { 2, 3 }, { 0, 0 }, }, },
  128. { { { 8, 15 }, { 0, 1 }, { 8, 21 }, { 74, 53 }, { 22, 42 },
  129. { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 2 }, { 0, 0 }, },
  130. { { 83, 5 }, { 2, 3 }, { 0, 102 }, { 0, 0 }, { 0, 0 },
  131. { 1, 3 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
  132. { { 31, 28 }, { 0, 0 }, { 3, 14 }, { 130, 34 }, { 0, 0 },
  133. { 0, 1 }, { 0, 3 }, { 0, 1 }, { 3, 3 }, { 0, 1 }, }, },
  134. { { { 141, 42 }, { 0, 0 }, { 1, 4 }, { 11, 24 }, { 1, 11 },
  135. { 0, 1 }, { 0, 1 }, { 0, 2 }, { 0, 0 }, { 0, 0 }, },
  136. { { 233, 6 }, { 0, 0 }, { 0, 8 }, { 0, 0 }, { 0, 0 },
  137. { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 1 }, { 0, 0 }, },
  138. { { 171, 25 }, { 0, 0 }, { 1, 5 }, { 25, 21 }, { 0, 0 },
  139. { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
  140. { { { 8, 19 }, { 4, 10 }, { 24, 45 }, { 21, 37 }, { 9, 29 },
  141. { 0, 3 }, { 1, 7 }, { 11, 25 }, { 0, 2 }, { 0, 1 }, },
  142. { { 34, 16 }, { 112, 21 }, { 1, 28 }, { 0, 0 }, { 0, 0 },
  143. { 6, 8 }, { 1, 7 }, { 0, 3 }, { 2, 5 }, { 0, 2 }, },
  144. { { 17, 21 }, { 68, 29 }, { 6, 15 }, { 13, 22 }, { 0, 0 },
  145. { 6, 12 }, { 3, 14 }, { 4, 10 }, { 1, 7 }, { 0, 3 }, }, },
  146. { { { 46, 42 }, { 0, 1 }, { 2, 10 }, { 54, 51 }, { 10, 30 },
  147. { 0, 2 }, { 0, 2 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, },
  148. { { 159, 35 }, { 2, 2 }, { 0, 25 }, { 0, 0 }, { 0, 0 },
  149. { 3, 6 }, { 0, 5 }, { 0, 1 }, { 4, 4 }, { 0, 1 }, },
  150. { { 51, 39 }, { 0, 1 }, { 2, 12 }, { 91, 44 }, { 0, 0 },
  151. { 0, 2 }, { 0, 3 }, { 0, 1 }, { 2, 3 }, { 0, 1 }, }, },
  152. { { { 28, 32 }, { 0, 0 }, { 3, 10 }, { 75, 51 }, { 14, 33 },
  153. { 0, 1 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 0 }, },
  154. { { 75, 39 }, { 5, 7 }, { 2, 48 }, { 0, 0 }, { 0, 0 },
  155. { 3, 11 }, { 2, 16 }, { 1, 4 }, { 7, 10 }, { 0, 2 }, },
  156. { { 81, 25 }, { 0, 0 }, { 2, 9 }, { 106, 26 }, { 0, 0 },
  157. { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, }, },
  158. { { { 100, 46 }, { 0, 1 }, { 3, 9 }, { 21, 37 }, { 5, 20 },
  159. { 0, 1 }, { 0, 2 }, { 1, 2 }, { 0, 1 }, { 0, 0 }, },
  160. { { 212, 21 }, { 0, 1 }, { 0, 9 }, { 0, 0 }, { 0, 0 },
  161. { 1, 2 }, { 0, 2 }, { 0, 0 }, { 2, 2 }, { 0, 0 }, },
  162. { { 140, 37 }, { 0, 1 }, { 1, 8 }, { 24, 33 }, { 0, 0 },
  163. { 1, 2 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 0 }, }, },
  164. { { { 27, 29 }, { 0, 1 }, { 9, 25 }, { 53, 51 }, { 12, 34 },
  165. { 0, 1 }, { 0, 3 }, { 1, 5 }, { 0, 2 }, { 0, 0 }, },
  166. { { 4, 2 }, { 0, 0 }, { 0, 172 }, { 0, 0 }, { 0, 0 },
  167. { 0, 1 }, { 0, 2 }, { 0, 0 }, { 2, 0 }, { 0, 0 }, },
  168. { { 14, 23 }, { 1, 3 }, { 11, 53 }, { 90, 31 }, { 0, 0 },
  169. { 0, 3 }, { 1, 5 }, { 2, 6 }, { 1, 2 }, { 0, 0 }, }, },
  170. { { { 80, 38 }, { 0, 0 }, { 1, 4 }, { 69, 33 }, { 5, 16 },
  171. { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 1 }, { 0, 0 }, },
  172. { { 187, 22 }, { 1, 1 }, { 0, 17 }, { 0, 0 }, { 0, 0 },
  173. { 3, 6 }, { 0, 4 }, { 0, 1 }, { 4, 4 }, { 0, 1 }, },
  174. { { 123, 29 }, { 0, 0 }, { 1, 7 }, { 57, 30 }, { 0, 0 },
  175. { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, }, },
  176. { { { 16, 20 }, { 0, 0 }, { 2, 8 }, { 104, 49 }, { 15, 33 },
  177. { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, },
  178. { { 133, 6 }, { 1, 2 }, { 1, 70 }, { 0, 0 }, { 0, 0 },
  179. { 0, 2 }, { 0, 4 }, { 0, 3 }, { 1, 1 }, { 0, 0 }, },
  180. { { 13, 14 }, { 0, 0 }, { 4, 20 }, { 175, 20 }, { 0, 0 },
  181. { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, }, },
  182. { { { 194, 16 }, { 0, 0 }, { 1, 1 }, { 1, 9 }, { 1, 3 },
  183. { 0, 0 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
  184. { { 251, 1 }, { 0, 0 }, { 0, 2 }, { 0, 0 }, { 0, 0 },
  185. { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, },
  186. { { 202, 23 }, { 0, 0 }, { 1, 3 }, { 2, 9 }, { 0, 0 },
  187. { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, }, },
  188. };
  189. static const uint8_t vp56_filter_threshold[] = {
  190. 14, 14, 13, 13, 12, 12, 10, 10,
  191. 10, 10, 8, 8, 8, 8, 8, 8,
  192. 8, 8, 8, 8, 8, 8, 8, 8,
  193. 8, 8, 8, 8, 8, 8, 8, 8,
  194. 8, 8, 8, 8, 7, 7, 7, 7,
  195. 7, 7, 6, 6, 6, 6, 6, 6,
  196. 5, 5, 5, 5, 4, 4, 4, 4,
  197. 4, 4, 4, 3, 3, 3, 3, 2,
  198. };
  199. static const uint8_t vp56_mb_type_model_model[] = {
  200. 171, 83, 199, 140, 125, 104,
  201. };
  202. static const VP56Tree vp56_pmbtm_tree[] = {
  203. { 4, 0},
  204. { 2, 1}, {-8}, {-4},
  205. { 8, 2},
  206. { 6, 3},
  207. { 4, 4},
  208. { 2, 5}, {-24}, {-20}, {-16}, {-12}, {-0},
  209. };
  210. static const VP56Tree vp56_pmbt_tree[] = {
  211. { 8, 1},
  212. { 4, 2},
  213. { 2, 4}, {-VP56_MB_INTER_NOVEC_PF}, {-VP56_MB_INTER_DELTA_PF},
  214. { 2, 5}, {-VP56_MB_INTER_V1_PF}, {-VP56_MB_INTER_V2_PF},
  215. { 4, 3},
  216. { 2, 6}, {-VP56_MB_INTRA}, {-VP56_MB_INTER_4V},
  217. { 4, 7},
  218. { 2, 8}, {-VP56_MB_INTER_NOVEC_GF}, {-VP56_MB_INTER_DELTA_GF},
  219. { 2, 9}, {-VP56_MB_INTER_V1_GF}, {-VP56_MB_INTER_V2_GF},
  220. };
  221. /* relative pos of surrounding blocks, from closest to farthest */
  222. static const int8_t vp56_candidate_predictor_pos[12][2] = {
  223. { 0, -1 },
  224. { -1, 0 },
  225. { -1, -1 },
  226. { 1, -1 },
  227. { 0, -2 },
  228. { -2, 0 },
  229. { -2, -1 },
  230. { -1, -2 },
  231. { 1, -2 },
  232. { 2, -1 },
  233. { -2, -2 },
  234. { 2, -2 },
  235. };
  236. #endif /* AVCODEC_VP56DATA_H */