📄 omxacmp3_requantizesfb_s32_i.c
字号:
pDst [i] = pSrc [i]; } } return OMX_Sts_NoErr;}/** * Function: omxACMP3_ReQuantizeSfb_S32_I (3.1.3.3.2) * * Description: * Requantizes the decoded Huffman symbols. Spectral samples for the * synthesis filter bank are derived from the decoded symbols using the * requantization equations given in the ISO standard. Stereophonic mid/side * (M/S) and/or intensity decoding is applied if necessary. Requantized * spectral samples are returned in the vector pSrcDstIsXr. The reordering * operation is applied for short blocks. Users must preallocate a workspace * buffer pointed to by pBuffer prior to calling the requantization function. * The value pointed by pNonZeroBound will be recalculated according to the * output data sequence. Special scalefactor values on the right channel of * intensity-coded scalefactor bands are used to indicate illegal intensity * positions. References 1. [ISO11172-3], Table B.8 ( MPEG-1 ) 2. * [ISO13818-3], sub-clause 2.5.3.2.2 and Table B.2 ( MPEG-2 ) 3. * [ISO14496-3], sub-part 9, MPEG-1/2 Audio in MPEG-4 * * Input Arguments: * * pSrcDstIsXr - pointer to the vector of decoded Huffman symbols; for * stereo and dual-channel modes, right channel data begins at the * address &(pSrcDstIsXr[576]). This pointer must be aligned on an * 8-byte boundary. * pNonZeroBound - (Inout/output argument) pointer to the spectral bound * above which all coefficients are set to zero; for stereo and * dual-channel modes, the left channel bound is pNonZeroBound [0], * and the right channel bound is pNonZeroBound [1] * pScaleFactor - pointer to the scalefactor buffer; for stereo and * dual-channel modes, the right channel scalefactors begin at * &(pScaleFactor[OMX_MP3_SF_BUF_LEN]). Special scalefactor values * on the right channel of intensity-coded scalefactor bands shall * be used to indicate an illegal intensity position as follows: i) * for MPEG-1 streams (pFrameHeader->id==1), the value 7 * [ISO11172-3, section 2.4.3.4.9.3], and ii) for MPEG-2 streams * (pFrameHeader->id==0), a negative value. * pSideInfo - pointer to the side information for the current granule * pFrameHeader - pointer to the frame header for the current frame * pBuffer - pointer to a workspace buffer. The buffer length must be 576 * samples, and the pointer must be 8-byte aligned. * pSfbTableLong - pointer to the long block scalefactor band table, * formatted as described in section 3.1.2.3. Table entries * optionally may follow the MPEG-1, MPEG-2, or MPEG-4 audio * standards as shown in Example 3-1. Alternatively the table * entries may be defined to suit a special purpose. References: * [ISO11172-3], Table B.8, [ISO13818-3], Table B.2, [ISO14496-3], * sub-part 9. * pSfbTableShort - pointer to the short block scalefactor band table, * formatted as described in section 3.1.2.4. Table entries * optionally may follow the MPEG-1, MPEG-2, or MPEG-4 audio * standards as shown in Example 3-2. Alternatively the table * entries may be defined to suit a special purpose. References: * [ISO11172-3], Table B.8, [ISO13818-3], Table B.2, [ISO14496-3], * sub-part 9. * * Output Arguments: * * pSrcDstIsXr - pointer to the vector of requantized spectral samples for * the synthesis filter bank, in Q5.26 format (Qm.n defined in * Introduction ). Only the first (pNonZeroBound[ch]+17)/18 * 18 point blocks are updated by the function. This pointer must * be aligned on an 8-byte boundary. * pNonZeroBound - (Inputinput/output argumentparameter) pointer to the * spectral bound above which all coefficients are set to zero; for * stereo and dual-channel modes, the left channel bound is * pNonZeroBound[0], and the right channel bound is * pNonZeroBound[1]. ** Return Value: * * OMX_Sts_NoErr - no errors * OMX_Sts_BadArgErr - bad arguments detected; either pSrcDstIsXr or * pBuffer are not 8-byte aligned, or one or more of the * following pointers is NULL: * - pSrcDstIsXr * - pNonZeroBound * - pScaleFactor * - pSideInfo * - pFrameHeader * - pBuffer, * Or one or more of the following input error conditions is * detected: * - pNonZeroBound[ch] outside the range [0,576] * - pFrameHeader->id outside the range [0,1] * - pFrameHeader->samplingFreq outside the range [0,2] * - pFrameHeader->mode outside the range [0,3] * - pSideInfo[ch].blockType outside the range [0,3] * - pFrameHeader->modeExt outside the range [0,3] * - pSideInfo[ch].mixedBlock outside the range [0,1] * - pSideInfo[ch].globGain outside the range [0,255] * - pSideInfo[ch].sfScale outside the range [0,1] * - pSideInfo [ch].preFlag outside the range [0,1] * - pSideInfo [ch].pSubBlkGain[w] outside the range [0,7] * - |pSrcDstIsXr[i]| > 8206 * - pScaleFactor[sfb] > 7 when pScaleFactor[sfb] is the * intensity position for an MPEG-1 stream * - pSideInfo[0].blockType != pSideInfo[1].blockType and * the bit stream is encoded in joint stereo mode * - pSideInfo[0].mixedBlock != pSideInfo[1].mixedBlock * and the bit stream is encoded in joint stereo mode. * * Note: In the above list of error conditions the range of * the parameter <ch> is from 0 to chNum-1, and the range on the * parameter <w> is from 0 to 2, where chNum is the number of * channels associated with value of the pFrameHeader ->mode. * If pFrameHeader->mode == 3 then chNum==1, otherwise chNum==2. * */OMXResult omxACMP3_ReQuantizeSfb_S32_I( OMX_S32 *pSrcDstIsXr, OMX_INT *pNonZeroBound, OMX_S8 *pScaleFactor, OMXMP3SideInfo *pSideInfo, OMXMP3FrameHeader *pFrameHeader, OMX_S32 *pBuffer, OMXMP3ScaleFactorBandTableLong pSfbTableLong, OMXMP3ScaleFactorBandTableShort pSfbTableShort ){ OMX_S32 i; OMX_U32 ch, NCh; OMX_F64 Buf1 [ARM_MP3_MAX_NUM_CHANNEL][OMX_MP3_GRANULE_LEN]; OMX_F64 Buf2 [ARM_MP3_MAX_NUM_CHANNEL][OMX_MP3_GRANULE_LEN]; OMXResult Result; /* Arguments check */ armRetArgErrIf(pSrcDstIsXr == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pNonZeroBound == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pScaleFactor == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pBuffer == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(armNot8ByteAligned(pBuffer), OMX_Sts_BadArgErr) armRetArgErrIf(armNot8ByteAligned(pSrcDstIsXr), OMX_Sts_BadArgErr) /* Validate input conditions */ /* Verify header */ armRetArgErrIf(pFrameHeader->id < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->id > 1, OMX_Sts_BadArgErr) /* Verify sampling frequency */ armRetArgErrIf(pFrameHeader->samplingFreq < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->samplingFreq > 2, OMX_Sts_BadArgErr) /* Verify mode */ armRetArgErrIf(pFrameHeader->mode < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->mode > 3, OMX_Sts_BadArgErr) /* Verify modeExt */ armRetArgErrIf(pFrameHeader->modeExt < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->modeExt > 3, OMX_Sts_BadArgErr) /* Total Number of channels */ NCh = (pFrameHeader->mode == ARM_MP3_SINGLE_CHANNEL_MODE) ? 1 : 2; for (ch = 0; ch < NCh; ch++) { OMX_INT i; for(i=0;i<OMX_MP3_GRANULE_LEN;i++) { Buf1[ch][i] = 0.0; Buf2[ch][i] = 0.0; } } for (ch = 0; ch < NCh; ch++) { /* Non-zero bound test*/ armRetArgErrIf(pNonZeroBound[ch] < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pNonZeroBound[ch] > 576, OMX_Sts_BadArgErr) /* gain value */ armRetArgErrIf(pSideInfo[ch].globGain < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].globGain > 255, OMX_Sts_BadArgErr) /* block type */ armRetArgErrIf(pSideInfo[ch].blockType < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].blockType > 3, OMX_Sts_BadArgErr) /* Mixed block */ armRetArgErrIf(pSideInfo[ch].mixedBlock < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].mixedBlock > 1, OMX_Sts_BadArgErr) /* scale factor scale */ armRetArgErrIf(pSideInfo[ch].sfScale < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].sfScale > 1, OMX_Sts_BadArgErr) /* preflag */ armRetArgErrIf(pSideInfo[ch].preFlag < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].preFlag > 1, OMX_Sts_BadArgErr) /* sub block gain */ armRetArgErrIf(pSideInfo[ch].pSubBlkGain[0] < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].pSubBlkGain[0] > 7, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].pSubBlkGain[1] < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].pSubBlkGain[1] > 7, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].pSubBlkGain[2] < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo[ch].pSubBlkGain[2] > 7, OMX_Sts_BadArgErr) /* input values and scalefactors */ for (i = 0; i < pNonZeroBound[ch]; i++) { armRetArgErrIf(pSrcDstIsXr [ch * OMX_MP3_GRANULE_LEN + i] < -8206, OMX_Sts_BadArgErr) armRetArgErrIf(pSrcDstIsXr [ch * OMX_MP3_GRANULE_LEN + i] > 8206, OMX_Sts_BadArgErr) } if (pFrameHeader->mode == ARM_MP3_JOINT_STEREO_MODE) { armRetArgErrIf(pSideInfo[0].blockType != pSideInfo[1].blockType, OMX_Sts_BadArgErr) armRetArgErrIf((pSideInfo[0].blockType == 2) && (pSideInfo[0].mixedBlock != pSideInfo[1].mixedBlock), OMX_Sts_BadArgErr) } /* * Requantization of huffman codes */ Result = armACMP3_Requant ( pSrcDstIsXr + ch * OMX_MP3_GRANULE_LEN, Buf1 [ch], pScaleFactor + ch * OMX_MP3_SF_BUF_LEN, &pNonZeroBound[ch], pFrameHeader->samplingFreq, pFrameHeader->id, pSideInfo[ch].globGain, pSideInfo[ch].sfScale, pSideInfo[ch].preFlag, pSideInfo[ch].pSubBlkGain, pSideInfo[ch].winSwitch, pSideInfo[ch].blockType, pSideInfo[ch].mixedBlock, pSfbTableLong, pSfbTableShort); } /* * Stereo Processing */ Result = armACMP3_Stereoprocessing ( Buf1, Buf2, pScaleFactor, pNonZeroBound, pFrameHeader->mode, pFrameHeader->modeExt, pFrameHeader->samplingFreq, pFrameHeader->id, pSideInfo[0].winSwitch, pSideInfo[0].blockType, pSideInfo[0].mixedBlock, pSideInfo[0].sfCompress, pSfbTableLong, pSfbTableShort); /* * Reorder */ for (ch = 0; ch < NCh; ch++) { Result = armACMP3_Reorder ( Buf2[ch], Buf1[ch], pSideInfo[ch].winSwitch, pSideInfo[ch].blockType, pSideInfo[ch].mixedBlock, pFrameHeader->samplingFreq, pFrameHeader->id, pSfbTableLong, pSfbTableShort); } /* for ch */ for (ch = 0; ch < NCh; ch++) { for (i = 0; i < OMX_MP3_GRANULE_LEN; i++) { /* Q5.26 */ pSrcDstIsXr [ch * OMX_MP3_GRANULE_LEN + i] = armSatRoundFloatToS32 (Buf1 [ch][i] * (1 << 26)); } } /* Update Non-zero variable */ for (ch = 0; ch < NCh; ch++) { i = OMX_MP3_GRANULE_LEN - 1; while ((i >= 0) && (pSrcDstIsXr [ch * OMX_MP3_GRANULE_LEN + i] == 0)) { i--; } pNonZeroBound[ch] = ++i; } return Result;}/****************************************************************************** END OF FILE*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -