⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp3dec_layer3_fp.c

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 C
📖 第 1 页 / 共 3 页
字号:
                            *scalefPtr = illegal;                        }                        scalefPtr++;                    }                } else {                    scalefPtr += num;                }            }        }    }    if (si_blockType[gr][1] == 2) {        isPos[numSfb - 1] = isPos[numSfb - 4];        isPos[numSfb - 2] = isPos[numSfb - 5];        isPos[numSfb - 3] = isPos[numSfb - 6];    } else {        isPos[numSfb - 1] = isPos[numSfb - 2];    }    ptrL = &((*smpl_xr)[0][0]);    ptrR = &((*smpl_xr)[1][0]);    for (sfb = 0; sfb < numSfb; sfb++) {        w = width[sfb];        if (isPos[sfb] == illegal) {            if (ms_stereo) {                for (i = 0; i < w; i++) {                    li = mult * (ptrL[0] + ptrR[0]);                    ri = mult * (ptrL[0] - ptrR[0]);                    ptrL[0] = li;                    ptrR[0] = ri;                    ptrL++; ptrR++;                }            } else {                ptrL += w;                ptrR += w;            }        } else {            if (header->id) {                if (isPos[sfb] > 6) {                    isPos[sfb] = 6;                }                k[0]  = mpeg1_intensity[isPos[sfb]];                k[1]  = mpeg1_intensity[6 - isPos[sfb]];            } else {                int tmp0, tmp1;                tmp0 = isPos[sfb] & 1;                tmp1 = (isPos[sfb] + 1) >> 1;                k[tmp0] = 1;                k[1-tmp0] = mpeg2_intensity[(si_sfCompress[0][1] & 1)][tmp1];            }            for (i = 0; i < w; i++) {                li = k[0] * ptrL[0];                ri = k[1] * ptrL[0];                ptrL[0] = li;                ptrR[0] = ri;                ptrL++; ptrR++;            }        }    }    return 1;}/******************************************************************************//  Name://    IMDCT////  Description://    inverse modifid cosine tranformation. overlaping and adding.//////  Input Arguments://    DC - point to sDecoderContext structure//    gr - number of granule//    ch - number of channel////  Output Arguments://    smpl_rw - prepared values for synthesis filterbank////  Returns://    1 - all ok//******************************************************************************/static int mp3dec_IMDCT(MP3Dec *state, int gr, int ch){    int     bt;    int     wnd, sb;    int     j;    float   rawout[36], tmp[36], tmpBuf[576];    float  *prev_ptr;    float  *in, *tmpBufPtr;    unsigned char *mdct_buffer = state->mdct_buffer;    IppsMDCTInvSpec_32f *pMDCTSpecShort = state->pMDCTSpecShort;    IppsMDCTInvSpec_32f *pMDCTSpecLong = state->pMDCTSpecLong;    float (*prevblk)[576] = state->prevblk;    unsigned int (*si_blockType)[2] = state->com.si_blockType;    unsigned int (*si_mixedBlock)[2] = state->com.si_mixedBlock;    unsigned int (*si_winSwitch)[2] = state->com.si_winSwitch;    samplefloat *smpl_re = state->smpl_re;       /* out of antialiasing */    samplefloatrw *smpl_rw = state->smpl_rw;     /* out of imdct */    int nz = state->com.non_zero[ch];    int nimdct = (nz + 17 + 9) * 3641 >> 16;    int maximdct;    if (nimdct > 32)        nimdct = 32;    maximdct = nimdct;    if (state->dctnum_prev[ch] > maximdct)        maximdct = state->dctnum_prev[ch];    state->dctnum_prev[ch] = nimdct;    prev_ptr = prevblk[ch];    in = (*smpl_re)[ch];    tmpBufPtr = tmpBuf;    for (sb = 0; sb < maximdct; sb++) {        bt = si_blockType[gr][ch];        if (si_winSwitch[gr][ch] && si_mixedBlock[gr][ch] && (sb < 2)) {            bt = 0;        }        if (bt != 2) {            if (sb < nimdct) {                ippsMDCTInv_32f(in, rawout, pMDCTSpecLong, mdct_buffer);                ippsMul_32f_I(mp3dec_imdct_table[bt], rawout, 18);                ippsAdd_32f(prev_ptr, rawout, tmpBufPtr, 18);                ippsMul_32f(mp3dec_imdct_table[bt] + 18, rawout + 18, prev_ptr, 18);            } else {                ippsCopy_32f(prev_ptr, tmpBufPtr, 18);                ippsZero_32f(prev_ptr, 18);            }            in += 18;        } else {            if (sb < nimdct) {                for (wnd = 0; wnd < 3; wnd++) {                    float ttt[6];                    int iii;                    for (iii = 0; iii < 6; iii++) {                        ttt[iii] = in[iii*3+wnd];                    }                    ippsMDCTInv_32f(ttt, tmp + wnd * 12,                        pMDCTSpecShort, mdct_buffer);                }                ippsMul_32f_I(mp3dec_imdct_table[2], tmp, 36);                ippsCopy_32f(prev_ptr, tmpBufPtr, 6);                ippsAdd_32f(prev_ptr + 6, tmp, tmpBufPtr + 6, 6);                ippsAdd_32f(tmp + 6, tmp + 12, rawout + 12, 6);                ippsAdd_32f(prev_ptr + 12, rawout + 12, tmpBufPtr + 12, 6);                ippsAdd_32f(tmp + 18, tmp + 24, prev_ptr, 6);                ippsCopy_32f(tmp + 30, prev_ptr + 6, 6);                ippsZero_32f(prev_ptr + 12, 6);            } else {                ippsCopy_32f(prev_ptr, tmpBufPtr, 18);                ippsZero_32f(prev_ptr, 18);            }            in += 18;        }        if (sb & 1) {            for (j = 1; j < 18; j += 2) {                tmpBufPtr[j] = -tmpBufPtr[j];            }        }        prev_ptr += 18;        tmpBufPtr += 18;    }    if (sb < 32)        ippsZero_32f(tmpBufPtr, 18 * (32 - sb));    for (j = 0; j < 18; j++) {        for (sb = 0; sb < 32; sb++) {            (*smpl_rw)[ch][j][sb] = tmpBuf[sb * 18 + j];        }    }    return 1;}/******************************************************************************//  Name://    decode_data_LayerIII////  Description://    decode one frame of mpeg 1 layer 3 bitstream and save decoded value//    to output buffer////  Input Arguments://    DC - point to sDecoderContext structure////  Output Arguments://    outsamples - decoded values of one frame////  Returns://******************************************************************************/MP3Status mp3dec_decode_data_LayerIII(MP3Dec *state){    int     main_data_bits;    int     gr, ch;    float  *pSampl[2];    IppMP3FrameHeader *header = &(state->com.header);    sBitsreamBuffer *m_MainData = &(state->com.m_MainData);    float   (*GlobalScaleFactor)[2] = state->GlobalScaleFactor;    short  *m_pOutSamples = state->com.m_pOutSamples;    unsigned int (*si_part23Len)[2] = state->com.si_part23Len;    short   (*si_globGain)[2] = state->com.si_globGain;    samplefloat *smpl_sb = state->smpl_sb;       // out of subband synth    int stereo = state->com.stereo;    int     part2_start;    pSampl[0] = (*smpl_sb)[0];    pSampl[1] = (*smpl_sb)[1];    // restores actual scalefactors to the values extracted from the bitstream.    // Four scalefactors in si_globGain (beginning at an offset of 210)    // are restored to the GlobalScaleFactor vector.    ippsCalcSF_16s32f((short *)(si_globGain), 210, (float *)GlobalScaleFactor,        4);    if (mp3dec_ReadMainData(&state->com))        return MP3_NOT_FIND_SYNCWORD;    main_data_bits =        (m_MainData->pCurrent_dword - m_MainData->pBuffer) * 32 + (32 -        m_MainData->        nBit_offset);    if (main_data_bits < 0)        return MP3_NOT_ENOUGH_DATA;    for (gr = 0; gr < header->id + 1; gr++) {        for (ch = 0; ch < stereo; ch++) {            int rested_bits;            // detect start point            m_MainData->pCurrent_dword = m_MainData->pBuffer + (main_data_bits >> 5);            m_MainData->dword = BSWAP(m_MainData->pCurrent_dword[0]);            m_MainData->nBit_offset = 32 - (main_data_bits % 32);            main_data_bits += si_part23Len[gr][ch];            part2_start =                (m_MainData->pCurrent_dword - m_MainData->pBuffer) * 32 + 32 -                m_MainData->nBit_offset;            state->com.part2_start = part2_start;            rested_bits =                (m_MainData->nDataLen -                (int)(m_MainData->pCurrent_dword - m_MainData->pBuffer) * 4) * 32 +                32 - m_MainData->nBit_offset;            if (rested_bits < (int)si_part23Len[gr][ch])                return MP3_BAD_STREAM;            if (header->id)                mp3dec_GetScaleFactorsL3(&state->com, gr, ch);            else                mp3dec_GetScaleFactorsL3_LSF(&state->com, ch);            mp3dec_Huffmancodebits(&state->com, gr, ch);            mp3dec_Dequant(state, gr, ch);        }        if ((header->mode == 0x01) && (header->modeExt != 0)) {            if (state->com.non_zero[0] < state->com.non_zero[1])                state->com.non_zero[0] = state->com.non_zero[1];            else                state->com.non_zero[1] = state->com.non_zero[0];            mp3dec_JointStereo(state, gr);        }        for (ch = 0; ch < stereo; ch++) {            mp3dec_Reordering(state, gr, ch);            mp3dec_Antialiasing(state, gr, ch);            mp3dec_IMDCT(state, gr, ch);            mp3dec_SubBandSynth(state, ch, 18);        }        // combines the data from all channels in the working array after the        // SubBandSynth phase        // into one joined vector.        // arguments:        // pSampl -- points to smpl_sb in global (the working array for the        // SubBandSynth phase)        // stereo -- number of channels        // 576 -- number of data elements in each channel        // outsamples + ... -- points to the joined (output) vector        ippsJoin_32f16s_D2L((const float **)pSampl, stereo, 576,            m_pOutSamples + gr * 576 * stereo);    }    return MP3_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -