hw: P010 (10-bit) DMA-BUF import for real HDR video
10/12-bit HDR decodes to P010-style VAAPI surfaces (16-bit planes), which the 8-bit NV12 import couldn't handle — real HDR clips fell back to software (losing the HDR). Import them as R16/Rg16 plane textures: - dmabuf::Nv12DmaBuf gains `ten_bit`; import_raw picks R16_UNORM/R16G16_UNORM (vk) + R16Unorm/Rg16Unorm (wgpu) when set, else the existing R8/Rg8. - hw_video.rs detects 10-bit from the hw frames context sw_format (P010/P012/P016) and sets it. The NV12→RGB shader is unchanged: it samples normalized floats, and the limited/full de-quant lands at the same values regardless of bit depth. - vk_device requests TEXTURE_FORMAT_16BIT_NORM when the adapter supports it (R16/ Rg16 need it); absent → 10-bit falls back to software, 8-bit unaffected. Pairs with the PQ/HLG/BT.2020 colour math so HDR10/HLG clips now reach the GPU path end-to-end. NV12 callers (encoder, decode primitive) pass ten_bit=false. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b76eefb404
commit
6c8cb5b9e0
@@ -36,6 +36,26 @@ impl HwVideoImporter for SharedHwImporter {
|
||||
let obj = &(*desc).objects[0];
|
||||
let width = (*frame).width as u32;
|
||||
let height = (*frame).height as u32;
|
||||
|
||||
// 10/12/16-bit content decodes to P010-style surfaces (16-bit planes). Detect via the hw
|
||||
// frames context's software format so the import builds R16/Rg16 textures.
|
||||
let ten_bit = {
|
||||
let hwfc = (*frame).hw_frames_ctx;
|
||||
if hwfc.is_null() {
|
||||
false
|
||||
} else {
|
||||
let ctx = (*hwfc).data as *const ff::AVHWFramesContext;
|
||||
matches!(
|
||||
(*ctx).sw_format,
|
||||
ff::AVPixelFormat::AV_PIX_FMT_P010LE
|
||||
| ff::AVPixelFormat::AV_PIX_FMT_P010BE
|
||||
| ff::AVPixelFormat::AV_PIX_FMT_P012LE
|
||||
| ff::AVPixelFormat::AV_PIX_FMT_P012BE
|
||||
| ff::AVPixelFormat::AV_PIX_FMT_P016LE
|
||||
| ff::AVPixelFormat::AV_PIX_FMT_P016BE
|
||||
)
|
||||
}
|
||||
};
|
||||
// NV12: Y then UV — two layers (one plane each) or one layer with two planes.
|
||||
let (y_pl, uv_pl) = if (*desc).nb_layers >= 2 {
|
||||
(&(*desc).layers[0].planes[0], &(*desc).layers[1].planes[0])
|
||||
@@ -52,6 +72,7 @@ impl HwVideoImporter for SharedHwImporter {
|
||||
y_pitch: y_pl.pitch as u64,
|
||||
uv_offset: uv_pl.offset as u64,
|
||||
uv_pitch: uv_pl.pitch as u64,
|
||||
ten_bit,
|
||||
};
|
||||
let full_range = (*frame).color_range == ff::AVColorRange::AVCOL_RANGE_JPEG;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user