KiCad PCB EDA Suite
Loading...
Searching...
No Matches
U3D::BIT_STREAM_WRITER Class Reference

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_BLOCKGetDataBlock ()
 

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_MANAGERm_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
 

Detailed Description

Implements the bit stream writer functionality.

  • All uncompressed writes are converted to unsigned integers and broken down into a sequence of U8 values that are written with the private method WriteSymbol in the static context Context8.
  • All compressed writes are for unsigned integers and are passed through to the private method WriteSymbol with the associated context.

Definition at line 42 of file bit_stream_writer.h.

Constructor & Destructor Documentation

◆ BIT_STREAM_WRITER()

BIT_STREAM_WRITER::BIT_STREAM_WRITER ( )

Member Function Documentation

◆ AlignTo4Byte()

◆ AlignToByte()

void BIT_STREAM_WRITER::AlignToByte ( )

Definition at line 176 of file bit_stream_writer.cpp.

References GetBitCount(), incrementPosition(), and m_dataBitOffset.

Referenced by GetDataBlock().

◆ checkPosition()

void BIT_STREAM_WRITER::checkPosition ( )
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().

◆ GetBitCount()

void BIT_STREAM_WRITER::GetBitCount ( int32_t & rCount)

Returns the number of bits written.

Parameters
rCountReference 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().

◆ GetDataBlock()

◆ incrementPosition()

void BIT_STREAM_WRITER::incrementPosition ( )
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().

◆ putLocal()

void BIT_STREAM_WRITER::putLocal ( )
private

Definition at line 245 of file bit_stream_writer.cpp.

References m_data, m_dataLocal, m_dataLocalNext, and m_dataPosition.

Referenced by GetDataBlock().

◆ swapBits8()

void BIT_STREAM_WRITER::swapBits8 ( uint32_t & rValue)
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().

◆ writeBit()

void BIT_STREAM_WRITER::writeBit ( uint32_t aBit)
private

Definition at line 329 of file bit_stream_writer.cpp.

References incrementPosition(), m_dataBitOffset, and m_dataLocal.

Referenced by writeSymbol().

◆ WriteCompressedU16()

void BIT_STREAM_WRITER::WriteCompressedU16 ( uint32_t aContext,
uint16_t uValue )

◆ WriteCompressedU32()

void BIT_STREAM_WRITER::WriteCompressedU32 ( uint32_t aContext,
uint32_t uValue )

◆ WriteCompressedU8()

void BIT_STREAM_WRITER::WriteCompressedU8 ( uint32_t aContext,
uint8_t uValue )

◆ WriteDataBlock()

void BIT_STREAM_WRITER::WriteDataBlock ( std::shared_ptr< DATA_BLOCK > b)

◆ WriteF32()

◆ WriteF64()

void BIT_STREAM_WRITER::WriteF64 ( double aValue)

Definition at line 90 of file bit_stream_writer.cpp.

References WriteU64().

Referenced by U3D::WRITER::getHeaderBlock().

◆ WriteI32()

void BIT_STREAM_WRITER::WriteI32 ( int32_t iValue)

Definition at line 76 of file bit_stream_writer.cpp.

References WriteU32().

◆ WriteString()

◆ writeSymbol()

void BIT_STREAM_WRITER::writeSymbol ( uint32_t aContext,
uint32_t aSymbol,
bool & rEscape )
private

◆ WriteU16()

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().

◆ WriteU32()

◆ 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().

◆ WriteU8()

void BIT_STREAM_WRITER::WriteU8 ( uint8_t aValue)

Member Data Documentation

◆ m_compressed

bool U3D::BIT_STREAM_WRITER::m_compressed
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().

◆ m_contextManager

std::unique_ptr<CONTEXT_MANAGER> U3D::BIT_STREAM_WRITER::m_contextManager
private

◆ m_data

std::vector<uint32_t> U3D::BIT_STREAM_WRITER::m_data
private

◆ m_dataBitOffset

int32_t U3D::BIT_STREAM_WRITER::m_dataBitOffset
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().

◆ m_dataLocal

uint32_t U3D::BIT_STREAM_WRITER::m_dataLocal
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().

◆ m_dataLocalNext

uint32_t U3D::BIT_STREAM_WRITER::m_dataLocalNext
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().

◆ m_dataPosition

int32_t U3D::BIT_STREAM_WRITER::m_dataPosition
private

◆ m_dataSizeIncrement

const int32_t U3D::BIT_STREAM_WRITER::m_dataSizeIncrement = 0x000023F8
private

Definition at line 159 of file bit_stream_writer.h.

Referenced by BIT_STREAM_WRITER(), and checkPosition().

◆ m_high

uint32_t U3D::BIT_STREAM_WRITER::m_high
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().

◆ m_low

uint32_t U3D::BIT_STREAM_WRITER::m_low
private

Definition at line 127 of file bit_stream_writer.h.

Referenced by BIT_STREAM_WRITER(), and writeSymbol().

◆ m_underflow

uint32_t U3D::BIT_STREAM_WRITER::m_underflow
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().


The documentation for this class was generated from the following files: