87 if((t << 1) > size) mask = ~mask;
93 0, 640, 1184, 1748, 2298, 2426, 2554, 3066, 3578, 4106, 4618, 5196, 5708
101 static int vlc_initialized = 0;
109 static VLC_TYPE dscf0_table[560][2];
110 static VLC_TYPE dscf1_table[598][2];
113 static VLC_TYPE codes_table[5708][2];
141 if(vlc_initialized)
return 0;
144 band_vlc.
table = band_table;
150 q1_vlc.
table = q1_table;
155 q9up_vlc.
table = q9up_table;
161 scfi_vlc[0].
table = scfi0_table;
166 scfi_vlc[1].
table = scfi1_table;
172 dscf_vlc[0].
table = dscf0_table;
177 dscf_vlc[1].
table = dscf1_table;
183 q3_vlc[0].
table = q3_0_table;
189 q3_vlc[1].
table = q3_1_table;
196 for(i = 0; i < 2; i++){
203 q2_vlc[i].
table = &codes_table[vlc_offsets[2+i]];
209 quant_vlc[0][i].
table = &codes_table[vlc_offsets[4+i]];
214 quant_vlc[1][i].
table = &codes_table[vlc_offsets[6+i]];
219 quant_vlc[2][i].
table = &codes_table[vlc_offsets[8+i]];
224 quant_vlc[3][i].
table = &codes_table[vlc_offsets[10+i]];
225 quant_vlc[3][i].
table_allocated = vlc_offsets[11+i] - vlc_offsets[10+i];
239 int *got_frame_ptr,
AVPacket *avpkt)
241 const uint8_t *buf = avpkt->
data;
242 int buf_size = avpkt->
size;
245 int i, j, k, ch, cnt, res,
t;
248 int maxband, keyframe;
261 memset(c->
Q, 0,
sizeof(c->
Q));
271 if(maxband > 32) maxband -= 33;
279 last[0] = last[1] = 0;
280 for(i = maxband - 1; i >= 0; i--){
281 for(ch = 0; ch < 2; ch++){
283 if(last[ch] > 15) last[ch] -= 17;
284 bands[i].
res[ch] = last[ch];
291 for(i = 0; i < maxband; i++)
292 if(bands[i].res[0] || bands[i].res[1])
296 for(i = maxband - 1; i >= 0; i--)
297 if(bands[i].res[0] || bands[i].res[1]){
298 bands[i].
msf = mask & 1;
303 for(i = maxband; i < c->
maxbands; i++)
304 bands[i].res[0] = bands[i].res[1] = 0;
307 for(i = 0; i < 32; i++)
311 for(i = 0; i < maxband; i++){
312 if(bands[i].res[0] || bands[i].res[1]){
313 cnt = !!bands[i].
res[0] + !!bands[i].
res[1] - 1;
315 t =
get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].
bits, 1);
316 if(bands[i].res[0]) bands[i].
scfi[0] = t >> (2 * cnt);
317 if(bands[i].res[1]) bands[i].
scfi[1] = t & 3;
322 for(i = 0; i < maxband; i++){
323 for(ch = 0; ch < 2; ch++){
324 if(!bands[i].res[ch])
continue;
333 bands[i].
scf_idx[ch][0] = ((bands[i].
scf_idx[ch][2] + t - 25) & 0x7F) - 6;
335 for(j = 0; j < 2; j++){
336 if((bands[i].scfi[ch] << j) & 2)
337 bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];
342 bands[i].
scf_idx[ch][j + 1] = ((bands[i].
scf_idx[ch][j] + t - 25) & 0x7F) - 6;
349 for(ch = 0; ch < 2; ch++){
350 res = bands[i].
res[ch];
362 for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)
363 c->
Q[ch][off + j + k] = (t & 0x20000) ? (
get_bits1(gb) << 1) - 1 : 0;
380 c->
Q[ch][off + j + 1] = t >> 4;
381 c->
Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);
391 c->
Q[ch][off + j] =
t;
392 cnt = (cnt >> 1) +
FFABS(c->
Q[ch][off + j]);
399 c->
Q[ch][off + j] <<= res - 9;
400 c->
Q[ch][off + j] |=
get_bits(gb, res - 9);
402 c->
Q[ch][off + j] -= (1 << (res - 2)) - 1;