# HG changeset patch # User Min Chen <chenm...@163.com> # Date 1381840265 -28800 # Node ID edccd210d53260d0807bf7539d060262694b5561 # Parent 369ea551e0304070c137fa5c0122c80dfeff96f6 cabac: writeByte() for faster CABAC output
diff -r 369ea551e030 -r edccd210d532 source/Lib/TLibCommon/TComBitCounter.h --- a/source/Lib/TLibCommon/TComBitCounter.h Tue Oct 15 20:30:43 2013 +0800 +++ b/source/Lib/TLibCommon/TComBitCounter.h Tue Oct 15 20:31:05 2013 +0800 @@ -64,6 +64,7 @@ virtual ~TComBitCounter() {} void write(UInt /*uiBits*/, UInt uiNumberOfBits) { m_uiBitCounter += uiNumberOfBits; } + void writeByte(UInt /*val*/) { m_uiBitCounter += 8; } void resetBits() { m_uiBitCounter = 0; } diff -r 369ea551e030 -r edccd210d532 source/Lib/TLibCommon/TComBitStream.cpp --- a/source/Lib/TLibCommon/TComBitStream.cpp Tue Oct 15 20:30:43 2013 +0800 +++ b/source/Lib/TLibCommon/TComBitStream.cpp Tue Oct 15 20:31:05 2013 +0800 @@ -128,6 +128,14 @@ m_num_held_bits = next_num_held_bits; } +void TComOutputBitstream::writeByte(UInt val) +{ + // NOTE: we are here only in Cabac + assert(m_num_held_bits == 0); + + push_back(val); +} + void TComOutputBitstream::writeAlignOne() { UInt num_bits = getNumBitsUntilByteAligned(); diff -r 369ea551e030 -r edccd210d532 source/Lib/TLibCommon/TComBitStream.h --- a/source/Lib/TLibCommon/TComBitStream.h Tue Oct 15 20:30:43 2013 +0800 +++ b/source/Lib/TLibCommon/TComBitStream.h Tue Oct 15 20:31:05 2013 +0800 @@ -64,6 +64,7 @@ virtual void writeAlignZero() {} virtual void write(UInt uiBits, UInt uiNumberOfBits) = 0; + virtual void writeByte(UInt val) = 0; virtual void resetBits() = 0; virtual UInt getNumberOfWrittenBits() const = 0; virtual ~TComBitIf() {} @@ -103,6 +104,7 @@ * the current bitstream */ void write(UInt uiBits, UInt uiNumberOfBits); + void writeByte(UInt val); /** insert one bits until the bitstream is byte-aligned */ void writeAlignOne(); diff -r 369ea551e030 -r edccd210d532 source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp --- a/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp Tue Oct 15 20:30:43 2013 +0800 +++ b/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp Tue Oct 15 20:31:05 2013 +0800 @@ -85,10 +85,10 @@ { //assert( m_numBufferedBytes > 0 ); //assert( m_bufferedByte != 0xff ); - m_pcTComBitIf->write(m_bufferedByte + 1, 8); + m_pcTComBitIf->writeByte(m_bufferedByte + 1); while (m_numBufferedBytes > 1) { - m_pcTComBitIf->write(0x00, 8); + m_pcTComBitIf->writeByte(0x00); m_numBufferedBytes--; } @@ -98,11 +98,11 @@ { if (m_numBufferedBytes > 0) { - m_pcTComBitIf->write(m_bufferedByte, 8); + m_pcTComBitIf->writeByte(m_bufferedByte); } while (m_numBufferedBytes > 1) { - m_pcTComBitIf->write(0xff, 8); + m_pcTComBitIf->writeByte(0xff); m_numBufferedBytes--; } } @@ -361,12 +361,12 @@ UInt carry = leadByte >> 8; UInt byte = m_bufferedByte + carry; m_bufferedByte = leadByte & 0xff; - m_pcTComBitIf->write(byte, 8); + m_pcTComBitIf->writeByte(byte); byte = (0xff + carry) & 0xff; while (m_numBufferedBytes > 1) { - m_pcTComBitIf->write(byte, 8); + m_pcTComBitIf->writeByte(byte); m_numBufferedBytes--; } } _______________________________________________ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel