📄 omxacmp3_huffmandecodesfbmbp_s32.c
字号:
/** * * File Name: omxACMP3_HuffmanDecodeSfbMbp_S32.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * Description: * This function is used to decode Huffman symbols as given in ISO/IEC 13818-3 */#include "omxtypes.h"#include "armOMX.h"#include "omxAC.h"#include "armCOMM_Bitstream.h"#include "armACMP3_Tables.h"#include "armACMP3_CommonTables.h"#include "armAC.h"#include "armCOMM.h"/** * Function: armRewindBits() * * Description: * This function is used to rewind N number of bits from bitstream * the allowed buffer area. * * Parameters: * [in] *ppBitStream * [in] *pOffset * [in] N=1..32 * [in] BitsRemain * * [out] *ppBitStream * [out] *pOffset * Returns Value */static OMX_U32 armRewindBits(const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_INT N){ OMX_INT Offset = *pOffset; /* Rewind bitstream pointer by N bits */ if (N < 0) { /* skip forwad */ /* return armSkipBits(ppBitStream, pOffset, N); */ return 0; } Offset -= N; if (Offset >= 0) { *pOffset = Offset; return N; } while (Offset < 0) { Offset += 8; (*ppBitStream)--; } *pOffset = Offset; return N;}/** * Function: omxACMP3_HuffmanDecodeSfbMbp_S32 (3.1.3.2.3) * * Description: * Decodes Huffman symbols for the 576 spectral coefficients associated with * one granule of one channel. References 1. [ISO11172-3], Table B.8 * ( MPEG-1 ) 2. [ISO13818-3], sub-clause 2.5.2.8 and Table B.2 ( MPEG-2 ) 3. * [ISO14496-3], sub-part 9, MPEG-1/2 Audio in MPEG-4 * * Input Arguments: * * ppBitStream - double pointer to the first bit stream byte that contains * the Huffman code words associated with the current granule and * channel * pOffset- pointer to the starting bit position in the bit stream byte * pointed by *ppBitStream; valid within the range of 0 to 7, where * 0 corresponds to the most significant bit, and 7 corresponds to * the least significant bit * pSideInfo - pointer to MP3 structure that contains the side information * associated with the current granule and channel * pFrameHeader - pointer to MP3 structure that contains the header * associated with the current frame * hufSize - the number of Huffman code bits associated with the current * granule and channel * 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. * pMbpTable - pointer to the mixed block partitioning table, formatted as * described in section 3.1.2.5. Table entries optionally may * follow the MPEG-1, MPEG-2, or MPEG-4 audio standards as shown in * Example 3-3. 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: * * pDstIs - pointer to the vector of decoded Huffman symbols used to * compute the quantized values of the 576 spectral coefficients * that are associated with the current granule and channel * pDstNonZeroBound - pointer to the spectral region above which all * coefficients are set equal to zero * ppBitStream - updated double pointer to the particular byte in the bit * stream that contains the first new bit following the decoded * block of Huffman codes * pOffset - updated pointer to the next bit position in the byte pointed * by *ppBitStream; valid within the range of 0 to 7, where 0 * corresponds to the most significant bit, and 7 corresponds to * the least significant bit * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - Bad arguments detected; at least one of the * following pointers is NULL: * - ppBitStream * - pOffset * - pDstIs * - pDstNonZeroBound * - pSideInfo * - pFrameHeader * - pSfbTableLong * - *ppBitStream * Or any one or more of the following conditions are true: * - *pOffset < 0, or *pOffset > 7. * - hufSize < 0 or hufSize > pSideInfo->part23Len * - pSideInfo-> bigVals * 2 > OMX_MP3_GRANULE_LEN * - pSideInfo->bigVals * 2 < 0 * - pSideInfo->winSwitch outside the range [0,1] * - pSideInfo->blockType outside the range [0,3] * - pSideInfo->winSwitch==1 when * pSideInfo->blockType==0 * - pSideInfo->cnt1TabSel outside the range [0,1] * - pSideInfo-> reg0Cnt < 0 when pSideInfo->blockType==0 * - pSideInfo-> reg1Cnt < 0 when pSideInfo->blockType==0 * - pSideInfo-> reg0Cnt + pSideInfo -> reg1Cnt + 2 > 22 * when pSideInfo->blockType==0 * - pSideInfo-> pTableSelect[0] outside the range [0,31] * - pSideInfo-> pTableSelect[1] outside the range [0,31] * - pSideInfo-> pTableSelect[2] outside the range [0,31] * when pSideInfo->blockType==0 * - pFrameHeader-> id outside the range [0,1] * - pFrameHeader-> idEX outside the range [0,1] * - pFrameHeader-> idEX == 0 when pFrameHeader->id==1 * - pFrameHeader->layer !=1 * - pFrameHeader->samplingFreq outside the range [0,2] * - hufSize outside the range [0, pSideInfo->part23Len] * OMX_Sts_Err - indicates that the number of remaining Huffman code bits * for <count1> partition is less than zero after decoding the * <big_values> partition. * */OMXResult omxACMP3_HuffmanDecodeSfbMbp_S32( const OMX_U8 **ppBitStream, OMX_INT *pOffset, OMX_S32 *pDstIs, OMX_INT *pDstNonZeroBound, OMXMP3SideInfo *pSideInfo, OMXMP3FrameHeader *pFrameHeader, OMX_INT hufSize, OMXMP3ScaleFactorBandTableLong pSfbTableLong, OMXMP3ScaleFactorBandTableShort pSfbTableShort, OMXMP3MixedBlockPartitionTable pMbpTable){ OMX_INT i; OMX_S32 BigVals, HuffIndex; OMX_U32 HuffTableNo; OMX_U32 Count1; OMX_U32 Offset, Temp1, Llines, Slines; OMX_U32 linbits, linbitsx, linbitsy; OMX_U32 signx = 0, signy = 0, signv = 0, signw = 0; OMX_U32 Reg0Count, Reg1Count; OMX_S32 x = 0, y = 0, v = 0, w = 0; const ARM_VLC32 *pCodeBook; const OMX_S16 (*ppHuffXY)[2]; const OMX_S16 *pSfbTableMixed = (OMX_S16 *) pMbpTable; /* Arguments check */ armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pOffset == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pDstIs == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pDstNonZeroBound == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pSfbTableLong == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pSfbTableShort == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(pSfbTableMixed == NULL, OMX_Sts_BadArgErr) armRetArgErrIf(*pOffset < 0, OMX_Sts_BadArgErr) armRetArgErrIf(*pOffset > 7, OMX_Sts_BadArgErr) /* Verify hufSize */ armRetArgErrIf(hufSize < 0, OMX_Sts_BadArgErr) armRetArgErrIf(hufSize > pSideInfo->part23Len, OMX_Sts_BadArgErr) BigVals = pSideInfo->bigVals * 2; /* Validate Big Values */ armRetArgErrIf(BigVals < 0, OMX_Sts_BadArgErr) armRetArgErrIf(BigVals > OMX_MP3_GRANULE_LEN, OMX_Sts_BadArgErr) /* Validate WinSwitch */ armRetArgErrIf(pSideInfo->winSwitch < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo->winSwitch > 1, OMX_Sts_BadArgErr) /* Validate MixedBlock */ armRetArgErrIf(pSideInfo->mixedBlock < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo->mixedBlock > 1, OMX_Sts_BadArgErr) /* Validate Block Type */ armRetArgErrIf(pSideInfo->blockType < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo->blockType > 3, OMX_Sts_BadArgErr) /* Win Switch case for value of Block type */ armRetArgErrIf(pSideInfo->winSwitch == 1 && pSideInfo->blockType == 0, OMX_Sts_BadArgErr) /* Validate Count1 Table */ armRetArgErrIf(pSideInfo->cnt1TabSel < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo->cnt1TabSel > 1, OMX_Sts_BadArgErr) /* Reg 0 Count for value of Block type */ armRetArgErrIf (pSideInfo->blockType == 0 && pSideInfo->reg0Cnt < 0, OMX_Sts_BadArgErr) /* Reg 1 Count for value of Block type */ armRetArgErrIf (pSideInfo->blockType == 0 && pSideInfo->reg1Cnt < 0, OMX_Sts_BadArgErr) /* Validate Block Type, reg 0 and reg 1 size */ armRetArgErrIf (pSideInfo->blockType == 0 && (pSideInfo->reg0Cnt + pSideInfo->reg1Cnt + 2) > 22, OMX_Sts_BadArgErr) /* Validate Block Type and table select */ armRetArgErrIf(pSideInfo->pTableSelect[0] < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo->pTableSelect[0] > 31, OMX_Sts_BadArgErr) /* Validate Block Type and table select */ armRetArgErrIf(pSideInfo->pTableSelect[1] < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo->pTableSelect[1] > 31, OMX_Sts_BadArgErr) /* Validate Block Type and table select */ if (pSideInfo->blockType == 0) { armRetArgErrIf(pSideInfo->pTableSelect[2] < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pSideInfo->pTableSelect[2] > 31, OMX_Sts_BadArgErr) } /* Verify header */ armRetArgErrIf(pFrameHeader->id < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->id > 1, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->idEx < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->idEx > 1, OMX_Sts_BadArgErr)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -