📄 omxacmp3_huffmandecodesfbmbp_s32.c
字号:
armRetArgErrIf(pFrameHeader->idEx == 0 && pFrameHeader->id == 1, OMX_Sts_BadArgErr) /* If not Layer III */ armRetArgErrIf(pFrameHeader->layer != 1, OMX_Sts_BadArgErr) /* Verify Sampling Freq */ armRetArgErrIf(pFrameHeader->samplingFreq < 0, OMX_Sts_BadArgErr) armRetArgErrIf(pFrameHeader->samplingFreq > 2, OMX_Sts_BadArgErr) if (hufSize == 0) { pDstNonZeroBound [0] = 0; /* Fill the remaining Zero values */ for (i = 0; i < OMX_MP3_GRANULE_LEN; i++) { pDstIs [i] = 0; } return OMX_Sts_NoErr; } /* Decode Regions */ Offset = pFrameHeader->samplingFreq + pFrameHeader->id * 3; if (pSideInfo->winSwitch == 1) { if (pSideInfo->blockType == 2 && pSideInfo->mixedBlock == 0) { /* 3 == (8+1)/3 */ Reg0Count = 3 * pSfbTableShort [Offset * ARM_MP3_SHORT_SFB_TABLE_SZ + 3]; } else { if (pSideInfo->blockType == 2) { /* 8 = (7+1) */ Temp1 = pFrameHeader->samplingFreq * 2 + pFrameHeader->id * 6; Llines = pSfbTableMixed [Temp1]; Slines = pSfbTableMixed [Temp1 + 1]; Reg0Count = pSfbTableLong [Offset * ARM_MP3_LONG_SFB_TABLE_SZ + Llines]; Temp1 = pSfbTableShort [Offset * ARM_MP3_SHORT_SFB_TABLE_SZ + Slines + 3]; Reg0Count += (Temp1 - pSfbTableShort [Offset * ARM_MP3_SHORT_SFB_TABLE_SZ + 3]) * 3; } else { /* case of blocktype 1 and 3 */ Reg0Count = pSfbTableLong [Offset * ARM_MP3_LONG_SFB_TABLE_SZ + 8]; } } Reg1Count = OMX_MP3_GRANULE_LEN; } else { Offset *= ARM_MP3_LONG_SFB_TABLE_SZ; Reg0Count = pSfbTableLong [Offset + pSideInfo->reg0Cnt + 1]; Reg1Count = pSfbTableLong [Offset + pSideInfo->reg1Cnt + pSideInfo->reg0Cnt + 2]; } HuffTableNo = pSideInfo->pTableSelect [0]; /* Big values : includes Reg0, Reg1, and Reg2 */ for (i = 0; (i < BigVals) && ((hufSize > 0)||(HuffTableNo == 0)); i += 2) { /* Region 0*/ if (i < Reg0Count) { HuffTableNo = pSideInfo->pTableSelect [0]; pCodeBook = armACMP3_HuffCodeBook [HuffTableNo]; } /* Region 1*/ else if (i < Reg1Count) { HuffTableNo = pSideInfo->pTableSelect [1]; pCodeBook = armACMP3_HuffCodeBook [HuffTableNo]; } /* Region 2*/ else { HuffTableNo = pSideInfo->pTableSelect [2]; pCodeBook = armACMP3_HuffCodeBook [HuffTableNo]; } if (HuffTableNo == 0) { pDstIs [i] = 0; /* x */ pDstIs [i + 1] = 0; /* y */ continue; } else if (HuffTableNo == 4 || HuffTableNo == 14) { /* Not supported Error */ return OMX_Sts_Err; } /* Search code-words in table */ HuffIndex = armUnPackVLC32(ppBitStream, pOffset, pCodeBook); if (HuffIndex == -1) { return OMX_Sts_Err; } /* Update the available bits */ hufSize -= pCodeBook [HuffIndex].codeLen; ppHuffXY = armACMP3_HuffXYValues [HuffTableNo]; x = ppHuffXY[HuffIndex][0]; y = ppHuffXY[HuffIndex][1]; linbits = armACMP3_LinBits [HuffTableNo]; /* escape code for x */ if (x == ARM_MP3_HUFF_ESCAPE_CODE && linbits > 0) { linbitsx = armGetBits (ppBitStream, pOffset, linbits); hufSize -= linbits; x += linbitsx; } /* Decode sign */ if (x != 0) { signx = armGetBits (ppBitStream, pOffset, 1); hufSize -= 1; } /* escape code for y */ if (y == ARM_MP3_HUFF_ESCAPE_CODE && linbits > 0) { linbitsy = armGetBits (ppBitStream, pOffset, linbits); hufSize -= linbits; y += linbitsy; } /* Decode sign */ if (y != 0) { signy = armGetBits (ppBitStream, pOffset, 1); hufSize -= 1; } pDstIs [i] = signx ? -x : x; pDstIs [i + 1] = signy ? -y : y; } /* If Count1 is reached because hufSize became < 0 return error */ if (hufSize < 0) { armRewindBits(ppBitStream, pOffset, -hufSize); return OMX_Sts_Err; } /* Count1 values */ Count1 = OMX_MP3_GRANULE_LEN; for (; (i < Count1) && (hufSize > 0); i += 4) { if (pSideInfo->cnt1TabSel == 0) { /* Table A */ pCodeBook = armACMP3_HuffTable32; HuffIndex = armUnPackVLC32(ppBitStream, pOffset, pCodeBook); if (HuffIndex == -1) { return OMX_Sts_Err; } hufSize -= pCodeBook [HuffIndex].codeLen; v = (armACMP3_TableXY32 [HuffIndex][0] & 8)>>3; w = (armACMP3_TableXY32 [HuffIndex][0] & 4)>>2; x = (armACMP3_TableXY32 [HuffIndex][0] & 2)>>1; y = (armACMP3_TableXY32 [HuffIndex][0] & 1); /* Decode sign */ if (v != 0) { signv = armGetBits (ppBitStream, pOffset, 1); hufSize--; } if (w != 0) { signw = armGetBits (ppBitStream, pOffset, 1); hufSize--; } if (x != 0) { signx = armGetBits (ppBitStream, pOffset, 1); hufSize--; } if (y != 0) { signy = armGetBits (ppBitStream, pOffset, 1); hufSize--; } pDstIs [i + 0] = signv ? -v : v; pDstIs [i + 1] = signw ? -w : w; pDstIs [i + 2] = signx ? -x : x; pDstIs [i + 3] = signy ? -y : y; } else { /* Table B */ v = armGetBits (ppBitStream, pOffset, 1); hufSize--; w = armGetBits (ppBitStream, pOffset, 1); hufSize--; x = armGetBits (ppBitStream, pOffset, 1); hufSize--; y = armGetBits (ppBitStream, pOffset, 1); hufSize--; v = v ? 0 : 1; w = w ? 0 : 1; x = x ? 0 : 1; y = y ? 0 : 1; /* Decode sign */ if (v != 0) { signv = armGetBits (ppBitStream, pOffset, 1); hufSize--; } if (w != 0) { signw = armGetBits (ppBitStream, pOffset, 1); hufSize--; } if (x != 0) { signx = armGetBits (ppBitStream, pOffset, 1); hufSize--; } if (y != 0) { signy = armGetBits (ppBitStream, pOffset, 1); hufSize--; } pDstIs [i + 0] = signv ? -v : v; pDstIs [i + 1] = signw ? -w : w; pDstIs [i + 2] = signx ? -x : x; pDstIs [i + 3] = signy ? -y : y; } } if (hufSize < 0) { armRewindBits(ppBitStream, pOffset, -hufSize); } else { armSkipBits(ppBitStream, pOffset, hufSize); } /* Update zero bound */ pDstNonZeroBound [0] = i - 1; while (pDstIs [pDstNonZeroBound [0]] == 0) { --(pDstNonZeroBound [0]); } pDstNonZeroBound [0] += 1; return OMX_Sts_NoErr;}/***************************************************************************** * END OF FILE *****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -