Mercurial > libavcodec.hg
comparison imc.c @ 7250:b3c980b12aaa libavcodec
Use new style static VLC tables for IMC decoder.
Also fixes a memleak due to the previous in-context tables not being freed.
author | reimar |
---|---|
date | Sat, 12 Jul 2008 15:02:40 +0000 |
parents | b0820b8bd4dd |
children | 85ab7655ad4d |
comparison
equal
deleted
inserted
replaced
7249:4fa4dde521b0 | 7250:b3c980b12aaa |
---|---|
77 int skipFlagCount[BANDS]; ///< skipped coeffients per band | 77 int skipFlagCount[BANDS]; ///< skipped coeffients per band |
78 int skipFlags[COEFFS]; ///< skip coefficient decoding or not | 78 int skipFlags[COEFFS]; ///< skip coefficient decoding or not |
79 int codewords[COEFFS]; ///< raw codewords read from bitstream | 79 int codewords[COEFFS]; ///< raw codewords read from bitstream |
80 float sqrt_tab[30]; | 80 float sqrt_tab[30]; |
81 GetBitContext gb; | 81 GetBitContext gb; |
82 VLC huffman_vlc[4][4]; | |
83 int decoder_reset; | 82 int decoder_reset; |
84 float one_div_log2; | 83 float one_div_log2; |
85 | 84 |
86 DSPContext dsp; | 85 DSPContext dsp; |
87 FFTContext fft; | 86 FFTContext fft; |
88 DECLARE_ALIGNED_16(FFTComplex, samples[COEFFS/2]); | 87 DECLARE_ALIGNED_16(FFTComplex, samples[COEFFS/2]); |
89 DECLARE_ALIGNED_16(float, out_samples[COEFFS]); | 88 DECLARE_ALIGNED_16(float, out_samples[COEFFS]); |
90 } IMCContext; | 89 } IMCContext; |
91 | 90 |
91 static VLC huffman_vlc[4][4]; | |
92 | |
93 #define VLC_TABLES_SIZE 9512 | |
94 | |
95 static const int vlc_offsets[17] = { | |
96 0, 640, 1156, 1732, 2308, 2852, 3396, 3924, | |
97 4452, 5220, 5860, 6628, 7268, 7908, 8424, 8936, VLC_TABLES_SIZE}; | |
98 | |
99 static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2]; | |
92 | 100 |
93 static av_cold int imc_decode_init(AVCodecContext * avctx) | 101 static av_cold int imc_decode_init(AVCodecContext * avctx) |
94 { | 102 { |
95 int i, j; | 103 int i, j; |
96 IMCContext *q = avctx->priv_data; | 104 IMCContext *q = avctx->priv_data; |
133 } | 141 } |
134 | 142 |
135 /* initialize the VLC tables */ | 143 /* initialize the VLC tables */ |
136 for(i = 0; i < 4 ; i++) { | 144 for(i = 0; i < 4 ; i++) { |
137 for(j = 0; j < 4; j++) { | 145 for(j = 0; j < 4; j++) { |
138 init_vlc (&q->huffman_vlc[i][j], 9, imc_huffman_sizes[i], | 146 huffman_vlc[i][j].table = vlc_tables[vlc_offsets[i * 4 + j]]; |
147 huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j]; | |
148 init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i], | |
139 imc_huffman_lens[i][j], 1, 1, | 149 imc_huffman_lens[i][j], 1, 1, |
140 imc_huffman_bits[i][j], 2, 2, 1); | 150 imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC); |
141 } | 151 } |
142 } | 152 } |
143 q->one_div_log2 = 1/log(2); | 153 q->one_div_log2 = 1/log(2); |
144 | 154 |
145 ff_fft_init(&q->fft, 7, 1); | 155 ff_fft_init(&q->fft, 7, 1); |
208 int start = 0; | 218 int start = 0; |
209 const uint8_t *cb_sel; | 219 const uint8_t *cb_sel; |
210 int s; | 220 int s; |
211 | 221 |
212 s = stream_format_code >> 1; | 222 s = stream_format_code >> 1; |
213 hufftab[0] = &q->huffman_vlc[s][0]; | 223 hufftab[0] = &huffman_vlc[s][0]; |
214 hufftab[1] = &q->huffman_vlc[s][1]; | 224 hufftab[1] = &huffman_vlc[s][1]; |
215 hufftab[2] = &q->huffman_vlc[s][2]; | 225 hufftab[2] = &huffman_vlc[s][2]; |
216 hufftab[3] = &q->huffman_vlc[s][3]; | 226 hufftab[3] = &huffman_vlc[s][3]; |
217 cb_sel = imc_cb_select[s]; | 227 cb_sel = imc_cb_select[s]; |
218 | 228 |
219 if(stream_format_code & 4) | 229 if(stream_format_code & 4) |
220 start = 1; | 230 start = 1; |
221 if(start) | 231 if(start) |