ParsableNalUnitBitArray


@UnstableApi
class ParsableNalUnitBitArray


Wraps a byte array, providing methods that allow it to be read as a NAL unit bitstream.

Whenever the byte sequence [0, 0, 3] appears in the wrapped byte array, it is treated as [0, 0] for all reading/skipping operations, which makes the bitstream appear to be unescaped.

Summary

Public constructors

ParsableNalUnitBitArray(data: ByteArray!, offset: Int, limit: Int)

Public functions

Unit

Skips bits until at a byte alignment; if already byte aligned, then simply returns.

Boolean
canReadBits(numBits: Int)

Returns whether it's possible to read n bits starting from the current offset.

Boolean

Returns whether it is possible to read an Exp-Golomb-coded integer starting from the current offset.

Boolean

Reads a single bit.

Int
readBits(numBits: Int)

Reads up to 32 bits.

Int

Reads an signed Exp-Golomb-coded format integer.

Int

Reads an unsigned Exp-Golomb-coded format integer.

Unit
reset(data: ByteArray!, offset: Int, limit: Int)

Resets the wrapped data, limit and offset.

Unit

Skips a single bit.

Unit
skipBits(numBits: Int)

Skips bits and moves current reading position forward.

Public constructors

ParsableNalUnitBitArray

ParsableNalUnitBitArray(data: ByteArray!, offset: Int, limit: Int)
Parameters
data: ByteArray!

The data to wrap.

offset: Int

The byte offset in data to start reading from.

limit: Int

The byte offset of the end of the bitstream in data.

Public functions

byteAlign

fun byteAlign(): Unit

Skips bits until at a byte alignment; if already byte aligned, then simply returns.

canReadBits

fun canReadBits(numBits: Int): Boolean

Returns whether it's possible to read n bits starting from the current offset. The offset is not modified.

Parameters
numBits: Int

The number of bits.

Returns
Boolean

Whether it is possible to read n bits.

canReadExpGolombCodedNum

fun canReadExpGolombCodedNum(): Boolean

Returns whether it is possible to read an Exp-Golomb-coded integer starting from the current offset. The offset is not modified.

Returns
Boolean

Whether it is possible to read an Exp-Golomb-coded integer.

readBit

fun readBit(): Boolean

Reads a single bit.

Returns
Boolean

Whether the bit is set.

readBits

fun readBits(numBits: Int): Int

Reads up to 32 bits.

Parameters
numBits: Int

The number of bits to read.

Returns
Int

An integer whose bottom n bits hold the read data.

readSignedExpGolombCodedInt

fun readSignedExpGolombCodedInt(): Int

Reads an signed Exp-Golomb-coded format integer.

Returns
Int

The value of the parsed Exp-Golomb-coded integer.

readUnsignedExpGolombCodedInt

fun readUnsignedExpGolombCodedInt(): Int

Reads an unsigned Exp-Golomb-coded format integer.

Returns
Int

The value of the parsed Exp-Golomb-coded integer.

reset

fun reset(data: ByteArray!, offset: Int, limit: Int): Unit

Resets the wrapped data, limit and offset.

Parameters
data: ByteArray!

The data to wrap.

offset: Int

The byte offset in data to start reading from.

limit: Int

The byte offset of the end of the bitstream in data.

skipBit

fun skipBit(): Unit

Skips a single bit.

skipBits

fun skipBits(numBits: Int): Unit

Skips bits and moves current reading position forward.

Parameters
numBits: Int

The number of bits to skip.