vc1data.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * VC-1 and WMV3 decoder
  3. * copyright (c) 2006 Konstantin Shishkov
  4. * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * VC-1 tables.
  25. */
  26. #ifndef AVCODEC_VC1DATA_H
  27. #define AVCODEC_VC1DATA_H
  28. #include <stdint.h>
  29. #include "libavutil/rational.h"
  30. #include "vlc.h"
  31. /** Table for conversion between TTBLK and TTMB */
  32. extern const int ff_vc1_ttblk_to_tt[3][8];
  33. extern const int ff_vc1_ttfrm_to_tt[4];
  34. /** MV P mode - the 5th element is only used for mode 1 */
  35. extern const uint8_t ff_vc1_mv_pmode_table[2][5];
  36. extern const uint8_t ff_vc1_mv_pmode_table2[2][4];
  37. extern const int ff_vc1_fps_nr[7], ff_vc1_fps_dr[2];
  38. extern const uint8_t ff_vc1_pquant_table[3][32];
  39. /* MBMODE table for interlaced frame P-picture */
  40. extern const uint8_t ff_vc1_mbmode_intfrp[2][15][4];
  41. /** @name VC-1 VLC tables and defines
  42. * @todo TODO move this into the context
  43. */
  44. //@{
  45. #define VC1_BFRACTION_VLC_BITS 7
  46. extern VLC ff_vc1_bfraction_vlc;
  47. #define VC1_IMODE_VLC_BITS 4
  48. extern VLC ff_vc1_imode_vlc;
  49. #define VC1_NORM2_VLC_BITS 3
  50. extern VLC ff_vc1_norm2_vlc;
  51. #define VC1_NORM6_VLC_BITS 9
  52. extern VLC ff_vc1_norm6_vlc;
  53. /* Could be optimized, one table only needs 8 bits */
  54. #define VC1_TTMB_VLC_BITS 9 //12
  55. extern VLC ff_vc1_ttmb_vlc[3];
  56. #define VC1_MV_DIFF_VLC_BITS 9 //15
  57. extern VLC ff_vc1_mv_diff_vlc[4];
  58. #define VC1_CBPCY_P_VLC_BITS 9 //14
  59. extern VLC ff_vc1_cbpcy_p_vlc[4];
  60. #define VC1_ICBPCY_VLC_BITS 9
  61. extern VLC ff_vc1_icbpcy_vlc[8];
  62. #define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
  63. extern VLC ff_vc1_4mv_block_pattern_vlc[4];
  64. #define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
  65. extern VLC ff_vc1_2mv_block_pattern_vlc[4];
  66. #define VC1_TTBLK_VLC_BITS 5
  67. extern VLC ff_vc1_ttblk_vlc[3];
  68. #define VC1_SUBBLKPAT_VLC_BITS 6
  69. extern VLC ff_vc1_subblkpat_vlc[3];
  70. #define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
  71. extern VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
  72. #define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
  73. extern VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
  74. #define VC1_IF_MMV_MBMODE_VLC_BITS 5
  75. extern VLC ff_vc1_if_mmv_mbmode_vlc[8];
  76. #define VC1_IF_1MV_MBMODE_VLC_BITS 5
  77. extern VLC ff_vc1_if_1mv_mbmode_vlc[8];
  78. #define VC1_1REF_MVDATA_VLC_BITS 9
  79. extern VLC ff_vc1_1ref_mvdata_vlc[4];
  80. #define VC1_2REF_MVDATA_VLC_BITS 9
  81. extern VLC ff_vc1_2ref_mvdata_vlc[8];
  82. extern VLC ff_vc1_ac_coeff_table[8];
  83. #define VC1_IF_MBMODE_VLC_BITS 5
  84. //@}
  85. #define B_FRACTION_DEN 256
  86. /* pre-computed scales for all bfractions and base=256 */
  87. extern const int16_t ff_vc1_bfraction_lut[23];
  88. extern const uint8_t ff_vc1_bfraction_bits[23];
  89. extern const uint8_t ff_vc1_bfraction_codes[23];
  90. //Same as H.264
  91. extern const AVRational ff_vc1_pixel_aspect[16];
  92. /* BitPlane IMODE - such a small table... */
  93. extern const uint8_t ff_vc1_imode_codes[7];
  94. extern const uint8_t ff_vc1_imode_bits[7];
  95. /* Normal-2 imode */
  96. extern const uint8_t ff_vc1_norm2_codes[4];
  97. extern const uint8_t ff_vc1_norm2_bits[4];
  98. extern const uint16_t ff_vc1_norm6_codes[64];
  99. extern const uint8_t ff_vc1_norm6_bits[64];
  100. /* Normal-6 imode */
  101. extern const uint8_t ff_vc1_norm6_spec[64][5];
  102. /* 4MV Block pattern VLC tables */
  103. extern const uint8_t ff_vc1_4mv_block_pattern_codes[4][16];
  104. extern const uint8_t ff_vc1_4mv_block_pattern_bits[4][16];
  105. /* 2MV Block pattern VLC tables */
  106. extern const uint8_t ff_vc1_2mv_block_pattern_codes[4][4];
  107. extern const uint8_t ff_vc1_2mv_block_pattern_bits[4][4];
  108. extern const uint8_t ff_wmv3_dc_scale_table[32];
  109. /* P-Picture CBPCY VLC tables */
  110. extern const uint16_t ff_vc1_cbpcy_p_codes[4][64];
  111. extern const uint8_t ff_vc1_cbpcy_p_bits[4][64];
  112. /* Interlaced CBPCY VLC tables (Table 124 - Table 131) */
  113. extern const uint16_t ff_vc1_icbpcy_p_codes[8][63];
  114. extern const uint8_t ff_vc1_icbpcy_p_bits[8][63];
  115. /* MacroBlock Transform Type: 7.1.3.11, p89
  116. * 8x8:B
  117. * 8x4:B:btm 8x4:B:top 8x4:B:both,
  118. * 4x8:B:right 4x8:B:left 4x8:B:both
  119. * 4x4:B 8x8:MB
  120. * 8x4:MB:btm 8x4:MB:top 8x4,MB,both
  121. * 4x8,MB,right 4x8,MB,left
  122. * 4x4,MB */
  123. extern const uint16_t ff_vc1_ttmb_codes[3][16];
  124. extern const uint8_t ff_vc1_ttmb_bits[3][16];
  125. /* TTBLK (Transform Type per Block) tables */
  126. extern const uint8_t ff_vc1_ttblk_codes[3][8];
  127. extern const uint8_t ff_vc1_ttblk_bits[3][8];
  128. /* SUBBLKPAT tables, p93-94, reordered */
  129. extern const uint8_t ff_vc1_subblkpat_codes[3][15];
  130. extern const uint8_t ff_vc1_subblkpat_bits[3][15];
  131. /* MV differential tables, p265 */
  132. extern const uint16_t ff_vc1_mv_diff_codes[4][73];
  133. extern const uint8_t ff_vc1_mv_diff_bits[4][73];
  134. /* Interlaced frame picture MBMODE VLC tables (p. 246, p. 360) */
  135. extern const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15];
  136. extern const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15];
  137. extern const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9];
  138. extern const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9];
  139. /* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
  140. extern const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8];
  141. extern const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8];
  142. extern const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6];
  143. extern const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6];
  144. /* Interlaced frame/field picture MVDATA VLC tables */
  145. /* 1-reference tables */
  146. extern const uint32_t ff_vc1_1ref_mvdata_codes[4][72];
  147. extern const uint8_t ff_vc1_1ref_mvdata_bits[4][72];
  148. /* 2-reference tables */
  149. extern const uint32_t ff_vc1_2ref_mvdata_codes[8][126];
  150. extern const uint8_t ff_vc1_2ref_mvdata_bits[8][126];
  151. /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
  152. /* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
  153. extern const uint8_t ff_vc1_simple_progressive_4x4_zz [16];
  154. extern const uint8_t ff_vc1_adv_progressive_8x4_zz [32];
  155. extern const uint8_t ff_vc1_adv_progressive_4x8_zz [32];
  156. extern const uint8_t ff_vc1_adv_interlaced_8x8_zz [64];
  157. extern const uint8_t ff_vc1_adv_interlaced_8x4_zz [32];
  158. extern const uint8_t ff_vc1_adv_interlaced_4x8_zz [32];
  159. extern const uint8_t ff_vc1_adv_interlaced_4x4_zz [16];
  160. extern const uint8_t ff_vc1_intra_horz_8x8_zz [64];
  161. extern const uint8_t ff_vc1_intra_vert_8x8_zz [64];
  162. /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
  163. extern const int32_t ff_vc1_dqscale[63];
  164. /* P Interlaced field picture MV predictor scaling values (Table 114) */
  165. extern const uint16_t ff_vc1_field_mvpred_scales[2][7][4];
  166. /* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
  167. extern const uint16_t ff_vc1_b_field_mvpred_scales[7][4];
  168. #define AC_MODES 8
  169. extern const int ff_vc1_ac_sizes[AC_MODES];
  170. #endif /* AVCODEC_VC1DATA_H */