Skip to content

Add AV1 support through a separate av1_parser crate - #126

Open
sven-pke wants to merge 3 commits into
quietvoid:mainfrom
sven-pke:feat/av1-parser
Open

sven-pke wants to merge 3 commits into
quietvoid:mainfrom
sven-pke:feat/av1-parser

Conversation

@sven-pke

Copy link
Copy Markdown

Replaces #117.

Following your feedback on #116, AV1 now lives in a separate crate, av1_parser, built after hevc_parser. It parses OBUs, temporal units, the sequence header and metadata OBUs. With the av1_io feature it owns the I/O: raw OBU streams, IVF, Matroska and stdin, through Av1Processor and an IoProcessor trait with the same options (limit, Matroska track number). Units are written back in the container they came in.

In hdr10plus_tool, only src/core/av1.rs knows about AV1: it picks out the ST 2094-40 messages by the same test st2094_40_sei_msg applies to SEI messages, and encodes entries with Hdr10PlusMetadata::encode_with_opts. The hdr10plus library is unchanged.

Changes

  • extract, inject and remove accept AV1 as an OBU stream or IVF. extract and remove also take Matroska and piped input. inject refuses Matroska and pipes, as it does for HEVC.
  • Extraction goes through Parser, so gap filling, validation, --verify and the JSON output are the same as for HEVC.
  • Metadata OBUs end with trailing_bits() and go after the sequence header, right before the first frame. FFmpeg's CBS parser accepts the output.
  • The HEVC path is unchanged, except for stdin: its first bytes are read to tell AV1 from HEVC, so Parser and Remover take that reader instead of opening stdin again.
  • No new third-party dependencies, and no version bumps: av1_parser uses anyhow, bitvec_helpers and matroska-demuxer, and accepts the matroska-demuxer 0.7 that hevc_parser 0.6.11 brings.
  • README: AV1 input for extract, inject and remove.

Tests

The AV1 tests mirror the HEVC ones on the metadata of regular.hevc, in a 259 frame AV1 stream (64x64, ffmpeg testsrc2) stored as OBU stream, IVF and Matroska:

  • extract gives the SceneInfo of regular_metadata.json from all three and from stdin.
  • inject gives the stream back byte for byte, also when metadata is already in it.
  • remove gives the base layer back byte for byte.
  • --verify and a stream without metadata behave as for HEVC.

All CI steps pass on Linux: cargo fmt --all --check, cargo clippy --workspace --all-targets --tests -- --deny warnings, and the tests.

If you would rather maintain the crate yourself, I'm happy to transfer the repository to you.

🤖 Generated with Claude Code

Sven Perschke and others added 3 commits September 23, 2026 13:00
extract, inject and remove accept AV1: raw OBU streams and IVF files, and
for extract and remove also Matroska and piped input. Reading, placing and
writing the metadata OBUs is av1_parser's job, shaped after hevc_parser;
src/core/av1.rs only picks out the ST 2094-40 messages, by the same test
st2094_40_sei_msg applies to SEI messages, and encodes entries with
Hdr10PlusMetadata::encode_with_opts. The hdr10plus library is unchanged.

Extraction goes through Parser as for HEVC, so gap filling, validation,
--verify and the JSON output are shared. The HEVC path is unchanged apart
from stdin: its leading bytes are read to tell AV1 from HEVC, and Parser
and Remover now take that reader rather than opening stdin again.

Tests mirror the HEVC ones on the metadata of regular.hevc, in a 259 frame
AV1 stream stored raw, as IVF and in Matroska: extraction gives the
SceneInfo of regular_metadata.json, injection gives the stream it was made
from, removal gives the base layer back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant