datablk.h

来自「jpeg 2000 压缩算法源代码 核心ebcot」· C头文件 代码 · 共 63 行

H
63
字号
ByteToBitInput(ByteInputBuffer *pIn)
{
	m_nBitPosition=-1;
	m_pIn=0;
	m_pIn=pIn;


}

int ByteToBitInput::ReadBit()
{
	 if (m_nBitPosition < 0)
	 {
            if ((m_BitBuffer&0xFF) != 0xFF)
			{ // Normal byte to read
                m_BitBuffer = m_pIn->Read();
                m_nBitPosition = 7;
            }
            else 
			{ // Previous byte is 0xFF => there was bit stuffing
                m_BitBuffer = m_pIn->Read();
                m_nBitPosition = 6;
            }
        }

	 int returnbit=(m_BitBuffer>>m_nBitPosition)&0x01;
    //    return (m_nBitBuffer>>m_nBitPosition--);
	 m_nBitPosition--;
	 
	 return returnbit;

}

void ByteToBitInput::SetBufferArray(BYTE *pByteBuffer, int nByteBufLength, int nOffset, int nLength)
{
	 m_pIn->SetBufferArray(pByteBuffer,nByteBufLength,nOffset,nLength);
        
	 m_BitBuffer = 0; // reset any bit stuffing state
     m_nBitPosition= -1;


}

/**
 * Flushes (i.e. empties) the bit buffer, without loading any new
 * bytes. This realigns the input at the next byte boundary, if not
 * already at one.
* */
void ByteToBitInput::Flush()
{
	 m_BitBuffer = 0; // reset any bit stuffing state
     m_nBitPosition = -1;


}

/**
     * Checks for past errors in the decoding process by verifying the byte
     * padding with an alternating sequence of 0's and 1's. If an error is
     * detected it means that the raw bit stream has been wrongly decoded or
     * that the raw terminated segment length is too long. If no errors are
     * detected it does not necessarily mean that the raw bit stream has been
     * corre

⌨️ 快捷键说明

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