Repository navigation
feat(encode)!: H.265 Main encode beside H.264 - #10
Merged
Merged
Conversation
`Config::codec` picks the format. H.265 writes its own VPS, SPS, PPS, and slice headers and hands them to the driver packed, as ffmpeg's hevc_vaapi does. The coding tools follow what the driver reports, and a driver that predicts only from non-empty lists in both directions gets each P picture as a generalized B picture. The coded size rounds the frame up to whole minimum coding blocks and to the driver's surface alignment. radeonsi encodes at its own 64 by 16 alignment and rewrites the SPS at that size while keeping our conformance window, so a smaller coded size decodes at the wrong size there (1080p came out 1088 rows tall). `encode::probe` now takes the codec to probe for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VA's H.265 sequence parameters cannot carry the conformance window, and the VUI goes only in our packed SPS, so a driver writing its own SPS would decode at the padded size without the color labels. Refuse the session instead. Packed slice headers stay optional. The `Codec` docs drop the profile, which belongs to each direction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 6, 2026 09:25
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the moq-video VAAPI quest, moq-dev/moq#8013, which adds the H.265 path to moq-video's VAAPI encode backend.
Problem
The encoder writes H.264 only, so moq-video falls back to software or another backend for H.265 on Intel and AMD.
Approach
Config::codecpicksCodec::H264(the default fromConfig::new) orCodec::H265, Main profile. The render node search, the entrypoint pick, andencode::probeall go by codec.src/encode/h265.rswrites the VPS, SPS, PPS, and slice headers itself, with the VUI carrying the color space and timing as the H.264 path does. They go to the driver packed, the parameter sets as one sequence header and each slice header on its own, which is how ffmpeg'shevc_vaapifeeds the same drivers. The packed parameter sets are required: VA's H.265 sequence parameters have no conformance window, so an SPS the driver wrote would lose the crop and the color, and a driver that takes no packed sequence header fails the open. A driver that takes no packed slice header writes its own.VAConfigAttribEncHEVCFeaturesandVAConfigAttribEncHEVCBlockSizes: a tool the driver supports or requires is on, and one it requires that this writer does not emit fails the open with its name. A driver that predicts only from non-empty lists in both directions (VA_PREDICTION_DIRECTION_BI_NOT_EMPTY, which iHD reports) gets each P picture as a generalized B picture whose list 1 repeats list 0.VASurfaceAttribAlignmentSize. radeonsi encodes at its own 64 by 16 alignment and rewrites the VPS, SPS, and PPS at that size, keeping our conformance window. With only the minimum coding block, 1080p came out of the RX 9070 as 1920x1088, and 852x478 as 892x478.h264_buffersandpacked_parameter_setsso both codecs share the picture loop. It writes the same buffers as before.Impact
encode::probetakes the codec, andencode::Confighas a new public field,codec, so a struct literal without..no longer compiles.Codec,Config::codec.Validation
cargo test --lib(35 tests, all on the hardware), clippy, and fmt. Each encoder test runs for both codecs: ffmpeg round trip above 35 dB at 640x480 and at 852x478, the VUI color, IDRs carrying the VPS, SPS, and PPS at the group length, in-place and scaled DMA-BUFs, RGB and YUV conversion, a 1076-row buffer blitted, and a mid-stream bitrate drop.Alternatives
Follow-ups
Review
Codex (
quest review), two rounds. Round 1 found one issue: a driver without packed sequence headers would have written its own SPS, silently dropping the crop and the VUI. Fixed in91914d1by refusing such a driver. Round 2: no findings.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code