Mercurial > libavcodec.hg
comparison vc1.c @ 9537:654f5260a87d libavcodec
Switch VLC tables in WMV3/VC-1 decoder to new static init method
author | kostya |
---|---|
date | Wed, 22 Apr 2009 05:20:31 +0000 |
parents | bf81b6f776ea |
children | 7afd4f44c450 |
comparison
equal
deleted
inserted
replaced
9536:f522c8e05a29 | 9537:654f5260a87d |
---|---|
45 #define DC_VLC_BITS 9 | 45 #define DC_VLC_BITS 9 |
46 #define AC_VLC_BITS 9 | 46 #define AC_VLC_BITS 9 |
47 static const uint16_t table_mb_intra[64][2]; | 47 static const uint16_t table_mb_intra[64][2]; |
48 | 48 |
49 | 49 |
50 static const uint16_t vlc_offs[] = { | |
51 0, 520, 552, 616, 1128, 1160, 1224, 1740, 1772, 1836, 1900, 2436, | |
52 2986, 3050, 3610, 4154, 4218, 4746, 5326, 5390, 5902, 6554, 7658, 8620, | |
53 9262, 10202, 10756, 11310, 12228, 15078 | |
54 }; | |
55 | |
50 /** | 56 /** |
51 * Init VC-1 specific tables and VC1Context members | 57 * Init VC-1 specific tables and VC1Context members |
52 * @param v The VC1Context to initialize | 58 * @param v The VC1Context to initialize |
53 * @return Status | 59 * @return Status |
54 */ | 60 */ |
55 static int vc1_init_common(VC1Context *v) | 61 static int vc1_init_common(VC1Context *v) |
56 { | 62 { |
57 static int done = 0; | 63 static int done = 0; |
58 int i = 0; | 64 int i = 0; |
65 static VLC_TYPE vlc_table[15078][2]; | |
59 | 66 |
60 v->hrd_rate = v->hrd_buffer = NULL; | 67 v->hrd_rate = v->hrd_buffer = NULL; |
61 | 68 |
62 /* VLC tables */ | 69 /* VLC tables */ |
63 if(!done) | 70 if(!done) |
64 { | 71 { |
65 init_vlc(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23, | 72 INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23, |
66 ff_vc1_bfraction_bits, 1, 1, | 73 ff_vc1_bfraction_bits, 1, 1, |
67 ff_vc1_bfraction_codes, 1, 1, INIT_VLC_USE_STATIC); | 74 ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS); |
68 init_vlc(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4, | 75 INIT_VLC_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4, |
69 ff_vc1_norm2_bits, 1, 1, | 76 ff_vc1_norm2_bits, 1, 1, |
70 ff_vc1_norm2_codes, 1, 1, INIT_VLC_USE_STATIC); | 77 ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS); |
71 init_vlc(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64, | 78 INIT_VLC_STATIC(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64, |
72 ff_vc1_norm6_bits, 1, 1, | 79 ff_vc1_norm6_bits, 1, 1, |
73 ff_vc1_norm6_codes, 2, 2, INIT_VLC_USE_STATIC); | 80 ff_vc1_norm6_codes, 2, 2, 556); |
74 init_vlc(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7, | 81 INIT_VLC_STATIC(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7, |
75 ff_vc1_imode_bits, 1, 1, | 82 ff_vc1_imode_bits, 1, 1, |
76 ff_vc1_imode_codes, 1, 1, INIT_VLC_USE_STATIC); | 83 ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS); |
77 for (i=0; i<3; i++) | 84 for (i=0; i<3; i++) |
78 { | 85 { |
86 ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i*3+0]]; | |
87 ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i*3+1] - vlc_offs[i*3+0]; | |
79 init_vlc(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16, | 88 init_vlc(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16, |
80 ff_vc1_ttmb_bits[i], 1, 1, | 89 ff_vc1_ttmb_bits[i], 1, 1, |
81 ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_STATIC); | 90 ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
91 ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i*3+1]]; | |
92 ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i*3+2] - vlc_offs[i*3+1]; | |
82 init_vlc(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8, | 93 init_vlc(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8, |
83 ff_vc1_ttblk_bits[i], 1, 1, | 94 ff_vc1_ttblk_bits[i], 1, 1, |
84 ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_STATIC); | 95 ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); |
96 ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i*3+2]]; | |
97 ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i*3+3] - vlc_offs[i*3+2]; | |
85 init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, | 98 init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, |
86 ff_vc1_subblkpat_bits[i], 1, 1, | 99 ff_vc1_subblkpat_bits[i], 1, 1, |
87 ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_STATIC); | 100 ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); |
88 } | 101 } |
89 for(i=0; i<4; i++) | 102 for(i=0; i<4; i++) |
90 { | 103 { |
104 ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i*3+9]]; | |
105 ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i*3+10] - vlc_offs[i*3+9]; | |
91 init_vlc(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16, | 106 init_vlc(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16, |
92 ff_vc1_4mv_block_pattern_bits[i], 1, 1, | 107 ff_vc1_4mv_block_pattern_bits[i], 1, 1, |
93 ff_vc1_4mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_STATIC); | 108 ff_vc1_4mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); |
109 ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i*3+10]]; | |
110 ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i*3+11] - vlc_offs[i*3+10]; | |
94 init_vlc(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64, | 111 init_vlc(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64, |
95 ff_vc1_cbpcy_p_bits[i], 1, 1, | 112 ff_vc1_cbpcy_p_bits[i], 1, 1, |
96 ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_STATIC); | 113 ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
114 ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i*3+11]]; | |
115 ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i*3+12] - vlc_offs[i*3+11]; | |
97 init_vlc(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73, | 116 init_vlc(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73, |
98 ff_vc1_mv_diff_bits[i], 1, 1, | 117 ff_vc1_mv_diff_bits[i], 1, 1, |
99 ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_STATIC); | 118 ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
100 } | 119 } |
101 for(i=0; i<8; i++) | 120 for(i=0; i<8; i++){ |
121 ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i+21]]; | |
122 ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i+22] - vlc_offs[i+21]; | |
102 init_vlc(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, vc1_ac_sizes[i], | 123 init_vlc(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, vc1_ac_sizes[i], |
103 &vc1_ac_tables[i][0][1], 8, 4, | 124 &vc1_ac_tables[i][0][1], 8, 4, |
104 &vc1_ac_tables[i][0][0], 8, 4, INIT_VLC_USE_STATIC); | 125 &vc1_ac_tables[i][0][0], 8, 4, INIT_VLC_USE_NEW_STATIC); |
126 } | |
127 //FIXME: switching to INIT_VLC_STATIC() results in incorrect decoding | |
105 init_vlc(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64, | 128 init_vlc(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64, |
106 &ff_msmp4_mb_i_table[0][1], 4, 2, | 129 &ff_msmp4_mb_i_table[0][1], 4, 2, |
107 &ff_msmp4_mb_i_table[0][0], 4, 2, INIT_VLC_USE_STATIC); | 130 &ff_msmp4_mb_i_table[0][0], 4, 2, INIT_VLC_USE_STATIC); |
108 done = 1; | 131 done = 1; |
109 } | 132 } |