MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / III_decode

Function III_decode

modules/data/mp3/libmad/layer3.c:2421–2599  ·  view source on GitHub ↗

NAME: III_decode() DESCRIPTION: decode frame main_data */

Source from the content-addressed store, hash-verified

2419 DESCRIPTION: decode frame main_data
2420*/
2421static
2422enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
2423 struct sideinfo *si, unsigned int nch)
2424{
2425 struct mad_header *header = &frame->header;
2426 mad_fixed_t *xr[2]; // Moved from stack to dynheap
2427// mad_fixed_t *xr_raw; // [2][576]
2428 unsigned int sfreqi, ngr, gr;
2429// xr_raw = (mad_fixed_t*)malloc(sizeof(mad_fixed_t) * 2 * 576);
2430// if (!xr_raw)
2431// return MAD_ERROR_NOMEM;
2432 xr[0] = frame->xr_raw; //xr_raw;
2433 xr[1] = frame->xr_raw + 576; //xr_raw + 576;
2434
2435 stack(__FUNCTION__, __FILE__, __LINE__);
2436 {
2437 unsigned int sfreq;
2438
2439 sfreq = header->samplerate;
2440 if (header->flags & MAD_FLAG_MPEG_2_5_EXT)
2441 sfreq *= 2;
2442
2443 /* 48000 => 0, 44100 => 1, 32000 => 2,
2444 24000 => 3, 22050 => 4, 16000 => 5 */
2445 sfreqi = ((sfreq >> 7) & 0x000f) +
2446 ((sfreq >> 15) & 0x0001) - 8;
2447
2448 if (header->flags & MAD_FLAG_MPEG_2_5_EXT)
2449 sfreqi += 3;
2450 }
2451
2452 /* scalefactors, Huffman decoding, requantization */
2453
2454 ngr = (header->flags & MAD_FLAG_LSF_EXT) ? 1 : 2;
2455
2456 for (gr = 0; gr < ngr; ++gr) {
2457 struct granule *granule = &si->gr[gr];
2458 unsigned int const *sfbwidth[2];
2459 unsigned int ch;
2460 enum mad_error error;
2461
2462 for (ch = 0; ch < nch; ++ch) {
2463 struct channel *channel = &granule->ch[ch];
2464 unsigned int part2_length;
2465
2466 sfbwidth[ch] = sfbwidth_table[sfreqi].l;
2467 if (channel->block_type == 2) {
2468 sfbwidth[ch] = (channel->flags & mixed_block_flag) ?
2469 sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s;
2470 }
2471
2472 if (header->flags & MAD_FLAG_LSF_EXT) {
2473 part2_length = III_scalefactors_lsf(ptr, channel,
2474 ch == 0 ? 0 : &si->gr[1].ch[1],
2475 header->mode_extension);
2476 }
2477 else {
2478 part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch],

Callers 1

mad_layer_IIIFunction · 0.85

Calls 11

III_scalefactors_lsfFunction · 0.85
III_scalefactorsFunction · 0.85
III_huffdecodeFunction · 0.85
III_stereoFunction · 0.85
III_reorderFunction · 0.85
III_aliasreduceFunction · 0.85
III_imdct_lFunction · 0.85
III_overlapFunction · 0.85
III_imdct_sFunction · 0.85
III_freqinverFunction · 0.85
III_overlap_zFunction · 0.85

Tested by

no test coverage detected