# ParsableNalUnitBitArray

Artifact: [androidx.media3:media3-container](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/container/ParsableNalUnitBitArray.java+class:androidx.media3.container.ParsableNalUnitBitArray)

*** ** * ** ***


```
@UnstableApi
public final class ParsableNalUnitBitArray
```

<br />

*** ** * ** ***

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 |
|---|
| `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#ParsableNalUnitBitArray(byte[],int,int)(byte[] data, int offset, int limit)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#byteAlign()()` Skips bits until at a byte alignment; if already byte aligned, then simply returns. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#canReadBits(int)(int numBits)` Returns whether it's possible to read `n` bits starting from the current offset. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#canReadExpGolombCodedNum()()` Returns whether it is possible to read an Exp-Golomb-coded integer starting from the current offset. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#readBit()()` Reads a single bit. |
| `int` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#readBits(int)(int numBits)` Reads up to 32 bits. |
| `int` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#readSignedExpGolombCodedInt()()` Reads an signed Exp-Golomb-coded format integer. |
| `int` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#readUnsignedExpGolombCodedInt()()` Reads an unsigned Exp-Golomb-coded format integer. |
| `void` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#reset(byte[],int,int)(byte[] data, int offset, int limit)` Resets the wrapped data, limit and offset. |
| `void` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#skipBit()()` Skips a single bit. |
| `void` | `https://developer.android.com/reference/androidx/media3/container/ParsableNalUnitBitArray#skipBits(int)(int numBits)` Skips bits and moves current reading position forward. |

## Public constructors

### ParsableNalUnitBitArray

```
public ParsableNalUnitBitArray(byte[] data, int offset, int limit)
```

| Parameters |
|---|---|
| `byte[] data` | The data to wrap. |
| `int offset` | The byte offset in `data` to start reading from. |
| `int limit` | The byte offset of the end of the bitstream in `data`. |

## Public methods

### byteAlign

```
public void byteAlign()
```

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

### canReadBits

```
public boolean canReadBits(int numBits)
```

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

| Parameters |
|---|---|
| `int numBits` | The number of bits. |

| Returns |
|---|---|
| `boolean` | Whether it is possible to read `n` bits. |

### canReadExpGolombCodedNum

```
public boolean canReadExpGolombCodedNum()
```

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

```
public boolean readBit()
```

Reads a single bit.

| Returns |
|---|---|
| `boolean` | Whether the bit is set. |

### readBits

```
public int readBits(int numBits)
```

Reads up to 32 bits.

| Parameters |
|---|---|
| `int numBits` | The number of bits to read. |

| Returns |
|---|---|
| `int` | An integer whose bottom n bits hold the read data. |

### readSignedExpGolombCodedInt

```
public int readSignedExpGolombCodedInt()
```

Reads an signed Exp-Golomb-coded format integer.

| Returns |
|---|---|
| `int` | The value of the parsed Exp-Golomb-coded integer. |

### readUnsignedExpGolombCodedInt

```
public int readUnsignedExpGolombCodedInt()
```

Reads an unsigned Exp-Golomb-coded format integer.

| Returns |
|---|---|
| `int` | The value of the parsed Exp-Golomb-coded integer. |

### reset

```
public void reset(byte[] data, int offset, int limit)
```

Resets the wrapped data, limit and offset.

| Parameters |
|---|---|
| `byte[] data` | The data to wrap. |
| `int offset` | The byte offset in `data` to start reading from. |
| `int limit` | The byte offset of the end of the bitstream in `data`. |

### skipBit

```
public void skipBit()
```

Skips a single bit.

### skipBits

```
public void skipBits(int numBits)
```

Skips bits and moves current reading position forward.

| Parameters |
|---|---|
| `int numBits` | The number of bits to skip. |