Skip to content

[vk-video] Add color metadata to decoded frames#1831

Merged
noituri merged 2 commits intomasterfrom
@noituri/vv-decoder-vui
Mar 20, 2026
Merged

[vk-video] Add color metadata to decoded frames#1831
noituri merged 2 commits intomasterfrom
@noituri/vv-decoder-vui

Conversation

@noituri
Copy link
Member

@noituri noituri commented Mar 19, 2026

No description provided.

@noituri noituri self-assigned this Mar 19, 2026
@noituri noituri force-pushed the @noituri/vv-decoder-vui branch from 87b8e70 to 587be97 Compare March 19, 2026 11:36
@noituri noituri requested a review from Copilot March 19, 2026 11:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends vk-video’s decode output to carry H.264 color information (color space + range) alongside frame data, and refactors the frame types to distinguish encoding inputs from decoding outputs.

Changes:

  • Split Frame<T> into InputFrame<T> (encoding) and OutputFrame<T> (decoding), adding FrameMetadata to decoded frames.
  • Derive decoded frame color metadata from the H.264 SPS (VUI) and propagate it through the decoder/sorter pipeline.
  • Update examples and downstream usage (smelter-core) to the new frame types; adjust crate feature defaults.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vk-video/src/wgpu_helpers.rs Doc comment tweak for NV12/RGBA conversion parameters.
vk-video/src/vulkan_video/wgpu_api.rs Update WGPU decode/encode API signatures to use InputFrame/OutputFrame.
vk-video/src/vulkan_video.rs Introduce InputFrame, OutputFrame, and decoded FrameMetadata in the public API.
vk-video/src/vulkan_transcoder.rs Update transcoder to accept OutputFrame where it previously used Frame.
vk-video/src/vulkan_encoder.rs Update encoder APIs to accept InputFrame instead of the old Frame.
vk-video/src/vulkan_decoder/frame_sorter.rs Emit OutputFrame and attach FrameMetadata when sorting/flushing frames.
vk-video/src/vulkan_decoder.rs Add color metadata to decode results by reading it from the SPS.
vk-video/src/device.rs Add From<&SeqParameterSet> conversions to map SPS VUI to ColorSpace/ColorRange.
vk-video/examples/player/player/decoder.rs Update example player to use OutputFrame.
vk-video/examples/encode_wgpu.rs Update WGPU encode example to use InputFrame.
vk-video/examples/encode.rs Update bytes encode example to use InputFrame.
vk-video/examples/decode_wgpu.rs Update WGPU decode example to use OutputFrame.
vk-video/examples/decode.rs Update bytes decode example to use OutputFrame.
vk-video/Cargo.toml Enable transcoder feature by default (in addition to wgpu).
vk-video/CHANGELOG.md Document the Frame<T> split and decoded color metadata addition.
smelter-core/src/pipeline/encoder/vulkan_h264.rs Update integration to construct vk_video::InputFrame.
smelter-core/src/pipeline/decoder/vulkan_h264.rs Update integration to consume vk_video::OutputFrame.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@noituri noituri force-pushed the @noituri/vv-decoder-vui branch from 587be97 to 3a20a51 Compare March 19, 2026 11:51
Comment on lines +157 to +168
fn from(sps: &h264_reader::nal::sps::SeqParameterSet) -> Self {
sps.vui_parameters
.as_ref()
.and_then(|v| v.video_signal_type.as_ref())
.map(|vst| {
if vst.video_full_range_flag {
ColorRange::Full
} else {
ColorRange::Limited
}
})
.unwrap_or(ColorRange::Limited)
Copy link
Member Author

@noituri noituri Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm defaulting here to the limited range because that's what's assumed when video_full_range_flag is not present but maybe returning None would be better here, or maybe adding ColorRange::Unspecified?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is what the spec says in h264. its correct

@noituri noituri force-pushed the @noituri/vv-decoder-vui branch from 3a20a51 to f4a74f9 Compare March 19, 2026 11:56
@noituri noituri force-pushed the @noituri/vv-decoder-vui branch from f4a74f9 to ef51690 Compare March 19, 2026 12:01
@noituri noituri requested a review from jerzywilczek March 19, 2026 12:15
Copy link
Collaborator

@jerzywilczek jerzywilczek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but remember how I said we should warn if a user tries to use our converter on the wrong color space? this makes it trivial for NV12 -> RGBA

Comment on lines +157 to +168
fn from(sps: &h264_reader::nal::sps::SeqParameterSet) -> Self {
sps.vui_parameters
.as_ref()
.and_then(|v| v.video_signal_type.as_ref())
.map(|vst| {
if vst.video_full_range_flag {
ColorRange::Full
} else {
ColorRange::Limited
}
})
.unwrap_or(ColorRange::Limited)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is what the spec says in h264. its correct

@noituri noituri enabled auto-merge (squash) March 20, 2026 15:21
@noituri noituri merged commit 5853e2d into master Mar 20, 2026
4 checks passed
@noituri noituri deleted the @noituri/vv-decoder-vui branch March 20, 2026 15:29
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.

3 participants