MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decodeSpectrum

Function decodeSpectrum

libavcodec/atrac3.c:295–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293 */
294
295static int decodeSpectrum (GetBitContext *gb, float *pOut)
296{
297 int numSubbands, codingMode, cnt, first, last, subbWidth, *pIn;
298 int subband_vlc_index[32], SF_idxs[32];
299 int mantissas[128];
300 float SF;
301
302 numSubbands = get_bits(gb, 5); // number of coded subbands
303 codingMode = get_bits1(gb); // coding Mode: 0 - VLC/ 1-CLC
304
305 /* Get the VLC selector table for the subbands, 0 means not coded. */
306 for (cnt = 0; cnt <= numSubbands; cnt++)
307 subband_vlc_index[cnt] = get_bits(gb, 3);
308
309 /* Read the scale factor indexes from the stream. */
310 for (cnt = 0; cnt <= numSubbands; cnt++) {
311 if (subband_vlc_index[cnt] != 0)
312 SF_idxs[cnt] = get_bits(gb, 6);
313 }
314
315 for (cnt = 0; cnt <= numSubbands; cnt++) {
316 first = subbandTab[cnt];
317 last = subbandTab[cnt+1];
318
319 subbWidth = last - first;
320
321 if (subband_vlc_index[cnt] != 0) {
322 /* Decode spectral coefficients for this subband. */
323 /* TODO: This can be done faster is several blocks share the
324 * same VLC selector (subband_vlc_index) */
325 readQuantSpectralCoeffs (gb, subband_vlc_index[cnt], codingMode, mantissas, subbWidth);
326
327 /* Decode the scale factor for this subband. */
328 SF = sf_table[SF_idxs[cnt]] * iMaxQuant[subband_vlc_index[cnt]];
329
330 /* Inverse quantize the coefficients. */
331 for (pIn=mantissas ; first<last; first++, pIn++)
332 pOut[first] = *pIn * SF;
333 } else {
334 /* This subband was not coded, so zero the entire subband. */
335 memset(pOut+first, 0, subbWidth*sizeof(float));
336 }
337 }
338
339 /* Clear the subbands that were not coded. */
340 first = subbandTab[cnt];
341 memset(pOut+first, 0, (1024 - first) * sizeof(float));
342 return numSubbands;
343}
344
345/**
346 * Restore the quantized tonal components

Callers 1

decodeChannelSoundUnitFunction · 0.85

Calls 3

get_bitsFunction · 0.85
get_bits1Function · 0.85
readQuantSpectralCoeffsFunction · 0.85

Tested by

no test coverage detected