Skip to content

Add AV1 bitstream support (extract-rpu, inject-rpu, remove, convert)#389

Open
sven-pke wants to merge 3 commits intoquietvoid:mainfrom
sven-pke:feat/av1-bitstream
Open

Add AV1 bitstream support (extract-rpu, inject-rpu, remove, convert)#389
sven-pke wants to merge 3 commits intoquietvoid:mainfrom
sven-pke:feat/av1-bitstream

Conversation

@sven-pke
Copy link
Copy Markdown

Summary

This PR adds AV1 bitstream support to dovi_tool alongside the existing HEVC pipeline — no HEVC code is removed or modified.

  • New av1_parser workspace crate owns all AV1 I/O: ObuReader, IvfWriter, ObuWriter, and frame-level read/write helpers
  • DoVi-specific AV1 helpers (is_dovi_rpu_obu, extract_dovi_t35_payload, build_dovi_obu) live in src/dovi/av1.rs
  • Format is detected by file extension (.av1 / .ivf); IVF vs. raw OBU stream is auto-detected at runtime via magic header

Commands extended

Command AV1 behaviour
extract-rpu Extracts DoVi RPU OBUs, writes standard RPU .bin
inject-rpu Injects RPU per temporal unit (right after OBU_TEMPORAL_DELIMITER), replaces existing DoVi OBUs
remove Strips all DoVi RPU OBUs, passes everything else through
convert Parses DoVi OBUs, applies conversion mode, re-encodes

Design

  • av1_parser crate is responsible for all AV1 I/O
  • All existing HEVC code paths and dependencies are fully preserved
  • Both raw AV1 and IVF container formats are supported

Relates to #387

Introduces an 'av1_parser' workspace crate that owns all generic AV1
OBU parsing and I/O (ObuReader, IvfWriter, ObuWriter, LEB128, IVF
container handling). All existing HEVC functionality is preserved.

Commands that process bitstreams (extract-rpu, inject-rpu, convert,
remove) now auto-detect the input format:
  .av1 / .ivf  -> new AV1 code path
  everything else  -> existing HEVC code path (unchanged)

DoVi-specific AV1 helpers (is_dovi_rpu_obu, extract_dovi_t35_payload,
build_dovi_obu) live in src/dovi/av1.rs and use the dolby_vision
crate's existing AV1/EMDF API.
The simplified OBU-by-OBU replacement only worked when the input
already contained existing DoVi OBUs. Replace it with the proven
temporal-unit-aware approach:

- IVF path: build_output_frame_av1 inserts RPU right after the
  OBU_TEMPORAL_DELIMITER and strips any pre-existing DoVi OBUs
- Raw AV1 path: accumulate OBUs per temporal unit, inject one RPU
  per unit regardless of whether an existing OBU is present
…remover

Switch inject_ivf_av1 to accept &mut IvfWriter<W> and call
write_frame() instead of raw write_ivf_frame_header + write_all,
making the IVF injection path consistent with how remover.rs uses
IvfWriter throughout.
@quietvoid
Copy link
Copy Markdown
Owner

I'll need to take some time to create a separate crate so that I can maintain it properly.
This isn't acceptable.

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.

2 participants