📄 bitstrm.c
字号:
DPRINTF2((M_TEXT("MPV4: ReadFileMP4() Got data: datasize=%d\n"), BufferInfo.uiDataSize)); /* BufferProcessed allows compbase to report buffer stats (i.e. for bitrate calculations) */ MAICompBase_BufferProcessed(g_hComp, BufferInfo.uiDataSize, BufferInfo.uiDataSize); if ((BufferInfo.dwFlags&MAICOMPBUF_FLAG_PTS) != 0) { // This flag is not defined as of now since the interpolation is not perfect. So, lets use this value (coming from the demux)#ifndef USE_INTERPOLATED_PTS g_nMP4VPTS = BufferInfo.tTimeStamp;#endif DPRINTF((M_TEXT("MPV4: ReadFileMP4() PTS received, g_nMP4VPTS = %d\n"),g_nMP4VPTS)); } nBytesAvailable += BufferInfo.uiDataSize; break; /* don't wait for more data, we've got some now */ } } } nTotalBytes = nBytesAvailable; #ifdef FAST_LUT_DECODE // If we haven't hit EOS yet and the demux returned less than 4 bytes of data, // ask for more (since we always need at least 4-bytes of data) if (!g_bEOFReached && nBytesAvailable < 5) ReadFileMP4();#endif DPRINTF2((M_TEXT("MPV4: ReadFileMP4() done: TotalBytes=%d\n"), nTotalBytes));}#endif#ifdef ENABLE_INTERLACINGINLINE UInt getSingleBit (){ UInt retval = 0; if (m_uNumOfBitsInBuffer) { if(m_chDecBuffer&0x80) retval = 1; m_chDecBuffer = m_chDecBuffer << 1; m_uNumOfBitsInBuffer --;// m_lCounter ++; } else { if(!nBytesAvailable) ReadFileMP4();#ifdef USE_MAI// if (nBytesAvailable) /* HWG:might be EOS, watch out for negative buffer index! */#endif { m_chDecBuffer = MyBuffer[nTotalBytes-nBytesAvailable]; nBytesAvailable--; m_uNumOfBitsInBuffer = 7; if(m_chDecBuffer&0x80) retval = 1; m_chDecBuffer = m_chDecBuffer << 1;// m_lCounter ++; } } return retval;}#endif INLINE UInt getBits (UInt numBits){ UInt nGetBitsData = 0; Int nLocalBit;#ifndef NO_ASSERTS assert (numBits <= 32);#endif while (numBits) { nGetBitsData <<= 1; MP4V_RETSINGLEBIT (&nLocalBit); nGetBitsData += nLocalBit; numBits--; } return nGetBitsData;}#ifdef FAST_LUT_DECODEINLINE Int peekBits (UInt numBits){ UInt iBitsToRet; Int nBitsToPeek, nlocalBytes,nBitsToLoad;#ifndef NO_ASSERTS assert (numBits <= 32);#endif nBitsToPeek = numBits - m_uNumOfBitsInBuffer; nlocalBytes = nBytesAvailable; if (nBytesAvailable < ((int)numBits>>3)) // JBN 050810 { /* not enough bytes for peek, fill up MyBuffer some more */ ReadFileMP4(); nlocalBytes = nBytesAvailable; } // limit number of bits loaded to min(numBits, m_uNumOfBitsInBuffer) JBN 050809 nBitsToLoad = (numBits < m_uNumOfBitsInBuffer) ? numBits : m_uNumOfBitsInBuffer; iBitsToRet = getbit (nBitsToLoad); MP4V_PEEKHELPER(nBitsToPeek, nlocalBytes, &iBitsToRet); return iBitsToRet; }INLINE Int peekBitsTillByteAlign (Int *nBitsToPeek) { *nBitsToPeek = (m_uNumOfBitsInBuffer % 8); if (*nBitsToPeek == 0) *nBitsToPeek = 8; return peekBits(*nBitsToPeek);}INLINE Int peekBitsFromByteAlign (Int nBitsToPeek) { UInt iBitsToRet = 0;#ifndef NO_ASSERTS assert (nBitsToPeek <= 32);#endif if (m_uNumOfBitsInBuffer > 8) { int iTmpBuff = m_chDecBuffer, iRemainder; iRemainder = (m_uNumOfBitsInBuffer % 8); if (iRemainder == 0) iRemainder = 8; iTmpBuff <<= iRemainder; iBitsToRet = ((iTmpBuff >> (32 - nBitsToPeek)) & ~(0xFFFFFFFF << nBitsToPeek)); nBitsToPeek -= (m_uNumOfBitsInBuffer - iRemainder); } if (nBitsToPeek > 0) { Int nlocalBytes = nBytesAvailable; UInt iBitsToRet1 = 0; if (nBytesAvailable < 4) { ReadFileMP4(); nlocalBytes = nBytesAvailable; } if (m_uNumOfBitsInBuffer==0) nlocalBytes--; MP4V_PEEKHELPER(nBitsToPeek, nlocalBytes, &iBitsToRet1); iBitsToRet |= iBitsToRet1; } return iBitsToRet;/* // CAUTION!!!! Do not change this condition (don't make it nBytesAvailable < 4) if (!nBytesAvailable) { ReadFileMP4(); nlocalBytes = nBytesAvailable; } if (m_uNumOfBitsInBuffer==0) nlocalBytes--; else if (m_uNumOfBitsInBuffer>7) { int iDiv = (m_uNumOfBitsInBuffer/8); if (m_uNumOfBitsInBuffer == 8) ; else if (m_uNumOfBitsInBuffer == 16) nlocalBytes+= 1; else if (m_uNumOfBitsInBuffer == 24) nlocalBytes+= 2; else nlocalBytes+= iDiv; } MP4V_PEEKHELPER(nBitsToPeek, nlocalBytes, &iBitsToRet); return iBitsToRet; */}#else // !FAST_LUT_DECODEINLINE Int peekBits (UInt numBits){ UInt iBitsToRet;#ifndef NO_ASSERTS assert (numBits <= 32);#endif iBitsToRet = getbit (m_uNumOfBitsInBuffer); if (m_uNumOfBitsInBuffer<numBits) { /* need more buffered data */ Int nBitsToPeek = numBits - m_uNumOfBitsInBuffer; Int nlocalBytes = nBytesAvailable; if (!nBytesAvailable) { ReadFileMP4(); nlocalBytes = nBytesAvailable; } iBitsToRet = getbit (m_uNumOfBitsInBuffer); MP4V_PEEKHELPER(nBitsToPeek, nlocalBytes, &iBitsToRet); } return iBitsToRet; }INLINE Int peekBitsTillByteAlign (Int *nBitsToPeek) {#ifndef NO_ASSERTS assert (m_uNumOfBitsInBuffer != 8);#endif *nBitsToPeek = (m_uNumOfBitsInBuffer == 0) ? 8 : m_uNumOfBitsInBuffer; return peekBits(*nBitsToPeek);}INLINE Int peekBitsFromByteAlign (Int nBitsToPeek) { UInt iBitsToRet = 0; Int nlocalBytes = nBytesAvailable;#ifndef NO_ASSERTS assert (nBitsToPeek <= 32);#endif if (!nBytesAvailable) { ReadFileMP4(); nlocalBytes = nBytesAvailable; } if (m_uNumOfBitsInBuffer==0) nlocalBytes--; MP4V_PEEKHELPER(nBitsToPeek, nlocalBytes, &iBitsToRet); return iBitsToRet; }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -