grk::BitIO Class Reference

`#include <BitIO.h>`

Inheritance diagram for grk::BitIO:

## Public Member Functions

| BitIO (uint8_t *bp, uint64_t len, bool isCompressor)
| BitIO (BufferedStream *stream, bool isCompressor)
size_t | numBytes (void) override
| Number of bytes written.
bool | write (uint32_t v, uint32_t n) override
| Write bits.
bool | write (uint32_t v) override
void | read (uint32_t *bits, uint8_t n) override
| Read bits.
uint8_t | read (void) override
| Read bit.
bool | flush (void) override
| Flush bits.
void | inalign (void) override
| Passes the ending bits (coming from flushing)
bool | putcommacode (uint8_t n)
uint8_t | getcommacode (void)
bool | putnumpasses (uint32_t n)
void | getnumpasses (uint32_t *numpasses)
Public Member Functions inherited from grk::IBitIO
virtual | ~IBitIO ()

## Private Member Functions

bool | putbit (uint8_t b)
void | getbit (uint32_t *bits, uint8_t pos)
uint8_t | getbit (void)
bool | writeByte (void)
void | bytein (void)

## Private Attributes

uint8_t * | start
size_t | offset
size_t | buf_len
uint8_t | buf
uint8_t | ct
BufferedStream * | stream
bool | read0xFF

## Constructor & Destructor Documentation

## BitIO() [1/2]

grk::BitIO::BitIO | ( | uint8_t * | bp,
|  | uint64_t | len,
|  | bool | isCompressor
| ) |  |

References grk::grk_read().

## BitIO() [2/2]

grk::BitIO::BitIO | ( | BufferedStream * | stream,
|  | bool | isCompressor
| ) |  |

## Member Function Documentation

## bytein()

void grk::BitIO::bytein | ( | void |  | ) |

private

References buf, buf_len, ct, grk::grk_read(), grk::GRK_WARN(), grk::J2K_MS_EPH, grk::J2K_MS_SOP, offset, read0xFF, and start.

Referenced by getbit(), getbit(), and inalign().

## flush()

bool grk::BitIO::flush | ( | void |  | ) |

override virtual

Flush bits.

Returns
  true if successful, returns false otherwise

Implements grk::IBitIO.

References ct, and writeByte().

## getbit() [1/2]

void grk::BitIO::getbit | ( | uint32_t * | bits,
|  | uint8_t | pos
| ) |  |

private

References buf, bytein(), ct, and grk::grk_read().

## getbit() [2/2]

uint8_t grk::BitIO::getbit | ( | void |  | ) |

private

References buf, bytein(), ct, and grk::grk_read().

Referenced by read(), and read().

## getcommacode()

uint8_t grk::BitIO::getcommacode | ( | void |  | ) |

References grk::grk_read(), and read().

## getnumpasses()

void grk::BitIO::getnumpasses | ( | uint32_t * | numpasses | ) |

References grk::grk_read(), and read().

## inalign()

void grk::BitIO::inalign | ( | void |  | ) |

override virtual

Passes the ending bits (coming from flushing)

Implements grk::IBitIO.

References buf, bytein(), and ct.

## numBytes()

size_t grk::BitIO::numBytes | ( | void |  | ) |

override virtual

Number of bytes written.

Returns
  the number of bytes written

Implements grk::IBitIO.

References offset.

## putbit()

bool grk::BitIO::putbit | ( | uint8_t | b | ) |

private

References buf, ct, grk::grk_read(), and writeByte().

Referenced by write(), and write().

## putcommacode()

bool grk::BitIO::putcommacode | ( | uint8_t | n | ) |

References grk::grk_read(), and write().

## putnumpasses()

bool grk::BitIO::putnumpasses | ( | uint32_t | n | ) |

References grk::grk_read(), and write().

## read() [1/2]

void grk::BitIO::read | ( | uint32_t * | bits,
|  | uint8_t | n
| ) |  |

override virtual

Read bits.

Parameters

  bits | pointer to bits buffer
  n | Number of bits to read

Implements grk::IBitIO.

References getbit(), and grk::grk_read().

## read() [2/2]

uint8_t grk::BitIO::read | ( | void |  | ) |

override virtual

Read bit.

Parameters

  bits | pointer to bits buffer

Implements grk::IBitIO.

References getbit().

Referenced by getcommacode(), and getnumpasses().

## write() [1/2]

bool grk::BitIO::write | ( | uint32_t | v | ) |

override virtual

Implements grk::IBitIO.

References putbit().

## write() [2/2]

bool grk::BitIO::write | ( | uint32_t | v,
|  | uint32_t | n
| ) |  |

override virtual

Write bits.

Parameters

  v | Value of bits
  n | Number of bits to write

Implements grk::IBitIO.

References grk::grk_read(), and putbit().

Referenced by putcommacode(), and putnumpasses().

## writeByte()

bool grk::BitIO::writeByte | ( | void |  | ) |

private

References buf, buf_len, ct, offset, stream, and grk::BufferedStream::writeByte().

Referenced by flush(), and putbit().

## Member Data Documentation

## buf

uint8_t grk::BitIO::buf

private

Referenced by bytein(), getbit(), getbit(), inalign(), putbit(), and writeByte().

## buf_len

size_t grk::BitIO::buf_len

private

Referenced by bytein(), and writeByte().

## ct

uint8_t grk::BitIO::ct

private

Referenced by bytein(), flush(), getbit(), getbit(), inalign(), putbit(), and writeByte().

## offset

size_t grk::BitIO::offset

private

Referenced by bytein(), numBytes(), and writeByte().

## read0xFF

bool grk::BitIO::read0xFF

private

Referenced by bytein().

## start

uint8_t* grk::BitIO::start

private

Referenced by bytein().

## stream

BufferedStream* grk::BitIO::stream

private

Referenced by writeByte().

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

- BitIO.h
- BitIO.cpp