# Av1ObuUtil

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

*** ** * ** ***


```
@UnstableApi
public final class Av1ObuUtil
```

<br />

*** ** * ** ***

Utility methods for AV1 OBUs.

## Summary

| ### Public methods |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/Av1ObuUtil#extractHagcMetadataAndStripAllT35Metadata(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer.html buffer)` Extracts HAGC (ST 2094-50) metadata from the first valid HAGC ITU-T T.35 metadata OBU in the buffer. |
| `static void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/Av1ObuUtil#stripAllT35Metadata(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer.html buffer)` Rewrites all ITU-T T35 metadata OBUs from the buffer. |
| `static void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/Av1ObuUtil#stripNonHdr10PlusT35Metadata(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer.html buffer)` Rewrites all ITU-T T35 metadata OBUs from the buffer that are not HDR10+. |

## Public methods

### extractHagcMetadataAndStripAllT35Metadata

```
public static @Nullable byte[] extractHagcMetadataAndStripAllT35Metadata(ByteBuffer buffer)
```

Extracts HAGC (ST 2094-50) metadata from the first valid HAGC ITU-T T.35 metadata OBU in the buffer. If one is found, all ITU-T T.35 metadata OBUs in the buffer (including HAGC and HDR10+) are rewritten as unknown metadata OBUs so that the decoder does not prefer any in-band T.35 metadata over the returned HAGC metadata.

If no valid HAGC metadata OBU is found, `buffer` remains unchanged. In either case, the `position()` and `limit()` of `buffer` remain unchanged.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html buffer` | The `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing AV1 OBUs. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | The HAGC payload without the ITU-T T.35 header and the AV1 OBU trailing bits (` 0x80` followed by any zero padding bytes), or `null` if no valid HAGC metadata OBU is found. |

### stripAllT35Metadata

```
public static void stripAllT35Metadata(ByteBuffer buffer)
```

Rewrites all ITU-T T35 metadata OBUs from the buffer. This is done to prevent the decoder from prioritizing in-band T.35 metadata (like HDR10+, Dolby Vision, etc.) over out-of-band metadata. If a T.35 metadata OBU is found, `buffer` will be rewritten with that metadata OBU marked as an unknown metadata OBU. If no T.35 metadata OBUs are found, `buffer` will remain unchanged. In either case, the `position()` and `limit()` of the `buffer` remain unchanged.

### stripNonHdr10PlusT35Metadata

```
public static void stripNonHdr10PlusT35Metadata(ByteBuffer buffer)
```

Rewrites all ITU-T T35 metadata OBUs from the buffer that are not HDR10+. This is done to prevent the decoder on older SDK versions from misinterpreting them as HDR10+ metadata. If a non-HDR10+ metadata OBU is found, `buffer` will be rewritten with that metadata OBU marked as an unknown metadata OBU. If no non-HDR10+ metadata OBUs are found, `buffer` will remain unchanged. In either case, the `position()` and `limit()` of the `
buffer` remain unchanged. This function is needed only when using MediaCodec on older SDK versions and is not necessary for other AV1 decoders.