int mpeg3audio_dolayer2(mpeg3audio_t *audio) { int i, j, result = 0; int channels = audio->channels; float fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */ unsigned int bit_alloc[64]; int scale[192]; int single = audio->single; if(audio->error_protection) mpeg3bits_getbits(audio->astream, 16); mpeg3audio_II_select_table(audio); audio->jsbound = (audio->mode == MPG_MD_JOINT_STEREO) ? (audio->mode_ext << 2) + 4 : audio->II_sblimit; if(channels == 1 || single == 3) single = 0; result |= mpeg3audio_II_step_one(audio, bit_alloc, scale); for(i = 0; i < SCALE_BLOCK && !result; i++) { result |= mpeg3audio_II_step_two(audio, bit_alloc, fraction, scale, i >> 2); for(j = 0; j < 3; j++) { if(single >= 0) { /* Monaural */ mpeg3audio_synth_mono(audio, fraction[single][j], audio->pcm_sample, &(audio->pcm_point)); } else { /* Stereo */ int p1 = audio->pcm_point; mpeg3audio_synth_stereo(audio, fraction[0][j], 0, audio->pcm_sample, &p1); mpeg3audio_synth_stereo(audio, fraction[1][j], 1, audio->pcm_sample, &(audio->pcm_point)); } if(audio->pcm_point / audio->channels >= audio->pcm_allocated - MPEG3AUDIO_PADDING * audio->channels) { /* Need more room */ mpeg3audio_replace_buffer(audio, audio->pcm_allocated + MPEG3AUDIO_PADDING * audio->channels); } } } return result; }
int mpeg3audio_synth_mono(mpeg3audio_t *audio, float *bandPtr, float *samples, int *pnt) { float *samples_tmp = audio->synth_mono_buff; float *tmp1 = samples_tmp; int i, ret; int pnt1 = 0; ret = mpeg3audio_synth_stereo(audio, bandPtr, 0, samples_tmp, &pnt1); samples += *pnt; for(i = 0; i < 32; i++) { *samples = *tmp1; samples++; tmp1 += 2; } *pnt += 32; return ret; }