KiCad PCB EDA Suite
|
Implements the bit stream writer functionality. More...
#include <bit_stream_writer.h>
Public Member Functions | |
BIT_STREAM_WRITER () | |
void | WriteU8 (uint8_t aValue) |
void | WriteU16 (uint16_t uValue) |
void | WriteU32 (uint32_t uValue) |
void | WriteU64 (uint64_t uValue) |
void | WriteI32 (int32_t iValue) |
void | WriteF32 (float fValue) |
void | WriteF64 (double aValue) |
void | WriteCompressedU32 (uint32_t aContext, uint32_t uValue) |
void | WriteCompressedU16 (uint32_t aContext, uint16_t uValue) |
void | WriteCompressedU8 (uint32_t aContext, uint8_t uValue) |
void | WriteString (const std::string &aStr) |
void | AlignToByte () |
void | AlignTo4Byte () |
void | GetBitCount (int32_t &rCount) |
Returns the number of bits written. | |
void | WriteDataBlock (std::shared_ptr< DATA_BLOCK > b) |
std::shared_ptr< DATA_BLOCK > | GetDataBlock () |
Private Member Functions | |
void | putLocal () |
void | writeSymbol (uint32_t aContext, uint32_t aSymbol, bool &rEscape) |
void | swapBits8 (uint32_t &rValue) |
changes the ordering of an 8 bit value so that the first 4 bits become the last 4 bits and the last 4 bits become the first 4. | |
void | writeBit (uint32_t aBit) |
void | incrementPosition () |
Updates the values of the datablock stored in dataLocal and dataLocalNext to the next values in the datablock. | |
void | checkPosition () |
Checks that the array allocated for writing is large enough. | |
Private Attributes | |
std::unique_ptr< CONTEXT_MANAGER > | m_contextManager |
uint32_t | m_high |
high and low are the upper and lower limits on the probability | |
uint32_t | m_low |
uint32_t | m_underflow |
stores the number of bits of underflow cause dby the limited range of high and low | |
bool | m_compressed |
Indicates if a compressed value was written. | |
std::vector< uint32_t > | m_data |
int32_t | m_dataPosition |
uint32_t | m_dataLocal |
The local value of the data corresponding to m_dataPosition. | |
uint32_t | m_dataLocalNext |
The value of the data after m_dataLocal. | |
int32_t | m_dataBitOffset |
The offset into data local that the next write occur. | |
const int32_t | m_dataSizeIncrement = 0x000023F8 |
Implements the bit stream writer functionality.
Definition at line 42 of file bit_stream_writer.h.
BIT_STREAM_WRITER::BIT_STREAM_WRITER | ( | ) |
Definition at line 29 of file bit_stream_writer.cpp.
References m_compressed, m_contextManager, m_data, m_dataBitOffset, m_dataLocal, m_dataLocalNext, m_dataPosition, m_dataSizeIncrement, m_high, m_low, and m_underflow.
void BIT_STREAM_WRITER::AlignTo4Byte | ( | ) |
Definition at line 191 of file bit_stream_writer.cpp.
References incrementPosition(), and m_dataBitOffset.
Referenced by U3D::WRITER::getGroupNodeModifierChain(), U3D::WRITER::getLightModifierChain(), U3D::WRITER::getModelResourceModifierChain(), and U3D::WRITER::getNodeModifierChain().
void BIT_STREAM_WRITER::AlignToByte | ( | ) |
Definition at line 176 of file bit_stream_writer.cpp.
References GetBitCount(), incrementPosition(), and m_dataBitOffset.
Referenced by GetDataBlock().
|
private |
Checks that the array allocated for writing is large enough.
Reallocates if necessary.
Definition at line 354 of file bit_stream_writer.cpp.
References m_data, m_dataPosition, and m_dataSizeIncrement.
Referenced by incrementPosition().
void BIT_STREAM_WRITER::GetBitCount | ( | int32_t & | rCount | ) |
Returns the number of bits written.
rCount | Reference to an integer where the bit count will be stored. |
Definition at line 200 of file bit_stream_writer.cpp.
References m_dataBitOffset, and m_dataPosition.
Referenced by AlignToByte().
std::shared_ptr< DATA_BLOCK > BIT_STREAM_WRITER::GetDataBlock | ( | ) |
Definition at line 228 of file bit_stream_writer.cpp.
References AlignToByte(), m_compressed, m_data, m_dataBitOffset, m_dataPosition, putLocal(), and WriteU32().
Referenced by U3D::WRITER::getGroupNodeBlock(), U3D::WRITER::getGroupNodeModifierChain(), U3D::WRITER::getHeaderBlock(), U3D::WRITER::getLightModifierChain(), U3D::WRITER::getLightNodeBlock(), U3D::WRITER::getLightResourceBlock(), U3D::WRITER::getLitTextureShaderBlock(), U3D::WRITER::getMaterialResourceBlock(), U3D::WRITER::getMeshContinuationBlock(), U3D::WRITER::getMeshDeclarationBlock(), U3D::WRITER::getModelNodeBlock(), U3D::WRITER::getModelResourceModifierChain(), U3D::WRITER::getNodeModifierChain(), and U3D::WRITER::getShadingModifierBlock().
|
private |
Updates the values of the datablock stored in dataLocal and dataLocalNext to the next values in the datablock.
Definition at line 344 of file bit_stream_writer.cpp.
References checkPosition(), m_data, m_dataLocal, m_dataLocalNext, and m_dataPosition.
Referenced by AlignTo4Byte(), AlignToByte(), and writeBit().
|
private |
Definition at line 245 of file bit_stream_writer.cpp.
References m_data, m_dataLocal, m_dataLocalNext, and m_dataPosition.
Referenced by GetDataBlock().
|
private |
changes the ordering of an 8 bit value so that the first 4 bits become the last 4 bits and the last 4 bits become the first 4.
E.g. abcdefgh -> efghabcd
Definition at line 323 of file bit_stream_writer.cpp.
References U3D::CONSTANTS::Swap8.
Referenced by WriteU8().
|
private |
Definition at line 329 of file bit_stream_writer.cpp.
References incrementPosition(), m_dataBitOffset, and m_dataLocal.
Referenced by writeSymbol().
void BIT_STREAM_WRITER::WriteCompressedU16 | ( | uint32_t | aContext, |
uint16_t | uValue ) |
Definition at line 121 of file bit_stream_writer.cpp.
References m_compressed, m_contextManager, U3D::CONSTANTS::MaxRange, writeSymbol(), and WriteU16().
void BIT_STREAM_WRITER::WriteCompressedU32 | ( | uint32_t | aContext, |
uint32_t | uValue ) |
Definition at line 98 of file bit_stream_writer.cpp.
References m_compressed, m_contextManager, U3D::CONSTANTS::MaxRange, writeSymbol(), and WriteU32().
Referenced by U3D::WRITER::getMeshContinuationBlock().
void BIT_STREAM_WRITER::WriteCompressedU8 | ( | uint32_t | aContext, |
uint8_t | uValue ) |
Definition at line 144 of file bit_stream_writer.cpp.
References m_compressed, m_contextManager, U3D::CONSTANTS::MaxRange, writeSymbol(), and WriteU8().
void BIT_STREAM_WRITER::WriteDataBlock | ( | std::shared_ptr< DATA_BLOCK > | b | ) |
Definition at line 206 of file bit_stream_writer.cpp.
References WriteU32().
Referenced by U3D::WRITER::getGroupNodeModifierChain(), U3D::WRITER::getLightModifierChain(), U3D::WRITER::getModelResourceModifierChain(), and U3D::WRITER::getNodeModifierChain().
void BIT_STREAM_WRITER::WriteF32 | ( | float | fValue | ) |
Definition at line 82 of file bit_stream_writer.cpp.
References WriteU32().
Referenced by U3D::WRITER::getLightResourceBlock(), U3D::WRITER::getLitTextureShaderBlock(), U3D::WRITER::getMaterialResourceBlock(), U3D::WRITER::getMeshContinuationBlock(), U3D::WRITER::getMeshDeclarationBlock(), and U3D::WRITER::writeMatrix().
void BIT_STREAM_WRITER::WriteF64 | ( | double | aValue | ) |
Definition at line 90 of file bit_stream_writer.cpp.
References WriteU64().
Referenced by U3D::WRITER::getHeaderBlock().
void BIT_STREAM_WRITER::WriteI32 | ( | int32_t | iValue | ) |
Definition at line 76 of file bit_stream_writer.cpp.
References WriteU32().
void BIT_STREAM_WRITER::WriteString | ( | const std::string & | aStr | ) |
Definition at line 167 of file bit_stream_writer.cpp.
References WriteU16(), and WriteU8().
Referenced by U3D::WRITER::getGroupNodeBlock(), U3D::WRITER::getGroupNodeModifierChain(), U3D::WRITER::getLightModifierChain(), U3D::WRITER::getLightNodeBlock(), U3D::WRITER::getLightResourceBlock(), U3D::WRITER::getLitTextureShaderBlock(), U3D::WRITER::getMaterialResourceBlock(), U3D::WRITER::getMeshContinuationBlock(), U3D::WRITER::getMeshDeclarationBlock(), U3D::WRITER::getModelNodeBlock(), U3D::WRITER::getModelResourceModifierChain(), U3D::WRITER::getNodeModifierChain(), and U3D::WRITER::getShadingModifierBlock().
|
private |
Definition at line 252 of file bit_stream_writer.cpp.
References U3D::CONSTANTS::HalfMask, m_contextManager, m_high, m_low, m_underflow, U3D::CONSTANTS::QuarterMask, and writeBit().
Referenced by WriteCompressedU16(), WriteCompressedU32(), WriteCompressedU8(), and WriteU8().
void BIT_STREAM_WRITER::WriteU16 | ( | uint16_t | uValue | ) |
Definition at line 55 of file bit_stream_writer.cpp.
References WriteU8().
Referenced by U3D::WRITER::getHeaderBlock(), WriteCompressedU16(), WriteString(), and WriteU32().
void BIT_STREAM_WRITER::WriteU32 | ( | uint32_t | uValue | ) |
Definition at line 62 of file bit_stream_writer.cpp.
References WriteU16().
Referenced by GetDataBlock(), U3D::WRITER::getGroupNodeBlock(), U3D::WRITER::getGroupNodeModifierChain(), U3D::WRITER::getHeaderBlock(), U3D::WRITER::getLightModifierChain(), U3D::WRITER::getLightNodeBlock(), U3D::WRITER::getLightResourceBlock(), U3D::WRITER::getLitTextureShaderBlock(), U3D::WRITER::getMaterialResourceBlock(), U3D::WRITER::getMeshContinuationBlock(), U3D::WRITER::getMeshDeclarationBlock(), U3D::WRITER::getModelNodeBlock(), U3D::WRITER::getModelResourceModifierChain(), U3D::WRITER::getNodeModifierChain(), U3D::WRITER::getShadingModifierBlock(), WriteCompressedU32(), WriteDataBlock(), WriteF32(), WriteI32(), and WriteU64().
void BIT_STREAM_WRITER::WriteU64 | ( | uint64_t | uValue | ) |
Definition at line 69 of file bit_stream_writer.cpp.
References WriteU32().
Referenced by U3D::WRITER::getHeaderBlock(), and WriteF64().
void BIT_STREAM_WRITER::WriteU8 | ( | uint8_t | aValue | ) |
Definition at line 46 of file bit_stream_writer.cpp.
References U3D::CONSTANTS::Context8, swapBits8(), and writeSymbol().
Referenced by U3D::WRITER::getLightResourceBlock(), WriteCompressedU8(), WriteString(), and WriteU16().
|
private |
Indicates if a compressed value was written.
When the datablock is retrieved, a 32-bit 0 is written to reset the values of high, low, and underflow.
Definition at line 139 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), GetDataBlock(), WriteCompressedU16(), WriteCompressedU32(), and WriteCompressedU8().
|
private |
Definition at line 121 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), WriteCompressedU16(), WriteCompressedU32(), WriteCompressedU8(), and writeSymbol().
|
private |
Definition at line 141 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), checkPosition(), GetDataBlock(), incrementPosition(), and putLocal().
|
private |
The offset into data local that the next write occur.
Definition at line 157 of file bit_stream_writer.h.
Referenced by AlignTo4Byte(), AlignToByte(), BIT_STREAM_WRITER(), GetBitCount(), GetDataBlock(), and writeBit().
|
private |
The local value of the data corresponding to m_dataPosition.
Definition at line 147 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), incrementPosition(), putLocal(), and writeBit().
|
private |
The value of the data after m_dataLocal.
Definition at line 152 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), incrementPosition(), and putLocal().
|
private |
Definition at line 142 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), checkPosition(), GetBitCount(), GetDataBlock(), incrementPosition(), and putLocal().
|
private |
Definition at line 159 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), and checkPosition().
|
private |
high and low are the upper and lower limits on the probability
Definition at line 126 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), and writeSymbol().
|
private |
Definition at line 127 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), and writeSymbol().
|
private |
stores the number of bits of underflow cause dby the limited range of high and low
Definition at line 132 of file bit_stream_writer.h.
Referenced by BIT_STREAM_WRITER(), and writeSymbol().