📄 mp3dec_layer2_fp.c
字号:
/*////////////////////////////////////////////////////////////////////////////////// INTEL CORPORATION PROPRIETARY INFORMATION// This software is supplied under the terms of a license agreement or// nondisclosure agreement with Intel Corporation and may not be copied// or disclosed except in accordance with the terms of that agreement.// Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/#include "mp3dec_own_fp.h"static float C_quant[] = { 1.33333333333f, 1.60000000000f, 1.14285714286f, 1.77777777777f, 1.06666666666f, 1.03225806452f, 1.01587301587f, 1.00787401575f, 1.00392156863f, 1.00195694716f, 1.00097751711f, 1.00048851979f, 1.00024420024f, 1.00012208522f, 1.00006103888f, 1.00003051851f, 1.00001525902f};static float D_quant[] = { 16384, 16384, 8192, 16384, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1,};float mp3dec_scale_values[64] = { 2.00000000000000f, 1.58740105196820f, 1.25992104989487f, 1.00000000000000f, 0.79370052598410f, 0.62996052494744f, 0.50000000000000f, 0.39685026299205f, 0.31498026247372f, 0.25000000000000f, 0.19842513149602f, 0.15749013123686f, 0.12500000000000f, 0.09921256574801f, 0.07874506561843f, 0.06250000000000f, 0.04960628287401f, 0.03937253280921f, 0.03125000000000f, 0.02480314143700f, 0.01968626640461f, 0.01562500000000f, 0.01240157071850f, 0.00984313320230f, 0.00781250000000f, 0.00620078535925f, 0.00492156660115f, 0.00390625000000f, 0.00310039267963f, 0.00246078330058f, 0.00195312500000f, 0.00155019633981f, 0.00123039165029f, 0.00097656250000f, 0.00077509816991f, 0.00061519582514f, 0.00048828125000f, 0.00038754908495f, 0.00030759791257f, 0.00024414062500f, 0.00019377454248f, 0.00015379895629f, 0.00012207031250f, 0.00009688727124f, 0.00007689947814f, 0.00006103515625f, 0.00004844363562f, 0.00003844973907f, 0.00003051757813f, 0.00002422181781f, 0.00001922486954f, 0.00001525878906f, 0.00001211090890f, 0.00000961243477f, 0.00000762939453f, 0.00000605545445f, 0.00000480621738f, 0.00000381469727f, 0.00000302772723f, 0.00000240310869f, 0.00000190734863f, 0.00000151386361f, 0.00000120155435f, 1E-20f};int mp3dec_decode_data_LayerII(MP3Dec *state){ int i, ch, sb; float *pSampl[2]; float scale; int (*sample)[32][36] = state->com.sample; int sblimit = state->com.sblimit; short (*scalefactor)[3][32] = state->com.scalefactor; short (*allocation)[32] = state->com.allocation; samplefloatrw *smpl_rw = state->smpl_rw; // out of imdct samplefloat *smpl_sb = state->smpl_sb; // out of subband synth int stereo = state->com.stereo; short *m_pOutSamples = state->com.m_pOutSamples; unsigned char *alloc_table = state->com.alloc_table; pSampl[0] = (*smpl_sb)[0]; pSampl[1] = (*smpl_sb)[1]; for (ch = 0; ch < stereo; ch++) { for (sb = 0; sb < sblimit; sb++) { if (allocation[ch][sb] != 0) { int idx = alloc_table[sb * 16 + allocation[ch][sb]]; int x = mp3dec_numbits[idx]; int xor_coef; int *sample_ptr = &sample[ch][sb][0]; xor_coef = (1 << (x - 1)); scale = C_quant[idx] * mp3dec_scale_values[scalefactor[ch][0][sb]]; for (i = 0; i < 12; i++) { (*smpl_rw)[ch][i][sb] = ((float)((sample_ptr[i] ^ xor_coef) << (32 - x) >> 16)); // Dequantize the sample (*smpl_rw)[ch][i][sb] += D_quant[idx]; (*smpl_rw)[ch][i][sb] *= scale; } scale = C_quant[idx] * mp3dec_scale_values[scalefactor[ch][1][sb]]; for (i = 12; i < 18; i++) { (*smpl_rw)[ch][i][sb] = ((float)((sample_ptr[i] ^ xor_coef) << (32 - x) >> 16)); // Dequantize the sample (*smpl_rw)[ch][i][sb] += D_quant[idx]; (*smpl_rw)[ch][i][sb] *= scale; } } else { for (i = 0; i < 18; i++) { (*smpl_rw)[ch][i][sb] = 0; } } } // for sb for (sb = sblimit; sb < 32; sb++) { for (i = 0; i < 18; i++) { (*smpl_rw)[ch][i][sb] = 0; } } mp3dec_SubBandSynth(state, ch, 18); } // for ch ippsJoin_32f16s_D2L((const float **)pSampl, stereo, 576, m_pOutSamples); for (ch = 0; ch < stereo; ch++) { for (sb = 0; sb < sblimit; sb++) { if (allocation[ch][sb] != 0) { int idx = alloc_table[sb * 16 + allocation[ch][sb]]; int x = mp3dec_numbits[idx]; int xor_coef; int *sample_ptr = &sample[ch][sb][18]; xor_coef = (1 << (x - 1)); scale = C_quant[idx] * mp3dec_scale_values[scalefactor[ch][1][sb]]; for (i = 0; i < 6; i++) { (*smpl_rw)[ch][i][sb] = ((float)((sample_ptr[i] ^ xor_coef) << (32 - x) >> 16)); // Dequantize the sample (*smpl_rw)[ch][i][sb] += D_quant[idx]; (*smpl_rw)[ch][i][sb] *= scale; } scale = C_quant[idx] * mp3dec_scale_values[scalefactor[ch][2][sb]]; for (i = 6; i < 18; i++) { (*smpl_rw)[ch][i][sb] = ((float)((sample_ptr[i] ^ xor_coef) << (32 - x) >> 16)); // Dequantize the sample (*smpl_rw)[ch][i][sb] += D_quant[idx]; (*smpl_rw)[ch][i][sb] *= scale; } } else { for (i = 0; i < 18; i++) { (*smpl_rw)[ch][i][sb] = 0; } } } // for sb for (sb = sblimit; sb < 32; sb++) { for (i = 0; i < 18; i++) { (*smpl_rw)[ch][i][sb] = 0; } } mp3dec_SubBandSynth(state, ch, 18); } // for ch ippsJoin_32f16s_D2L((const float **)pSampl, stereo, 576, m_pOutSamples + 576 * stereo); return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -