diff --git a/crates/reims-vgpu-video/src/nvidia/annex_b.rs b/crates/reims-vgpu-video/src/nvidia/annex_b.rs index b4fd22562..111d92c44 100644 --- a/crates/reims-vgpu-video/src/nvidia/annex_b.rs +++ b/crates/reims-vgpu-video/src/nvidia/annex_b.rs @@ -28,8 +28,10 @@ //! it decode, as a Mac's hardware decoders hand them on. //! - **The range extensions' pictures** (HEVC's, where the caller lands //! them, [`AnnexBDecoder::lands_range_extensions`]): 4:2:0 ones as Main 10's, -//! and 4:4:4 ones into three planes, luma, Cb and Cr, each as large, which -//! it reads back; its writes, of two planes, refuse those. +//! 4:2:2 ones in two planes as well, the chroma as tall as the luma +//! ([`AnnexBPicture::chroma`]), and 4:4:4 ones into three planes, luma, Cb +//! and Cr, each as large, which it reads back; its writes, of two planes, +//! refuse those. //! - **An AV1 stream** is handed over as temporal units of OBUs, in the //! low-overhead format, after its record's `configOBUs` as its //! parameter sets (`nvdec::av1`); a picture NVDEC fails is followed by @@ -51,6 +53,7 @@ use crate::codec::av1::{Decoder as Av1Decoder, Limits as Av1Limits}; use crate::codec::h264::{Decoder as H264Decoder, nal::NalFormat}; use crate::codec::hevc::Decoder as HevcDecoder; use crate::codec::vp9::Decoder as Vp9Decoder; +use crate::core::backend::Chroma; use crate::core::device_memory::DeviceMemory; use crate::core::runtime::Runtime; use crate::core::surfaces::crop_within; @@ -59,6 +62,7 @@ use crate::nvidia::cuda::Gpu; use crate::nvidia::decode::Failures; use crate::nvidia::error::Error; use crate::nvidia::external::ImportedBuffer; +use crate::nvidia::nvdec::ChromaFormat; use crate::nvidia::nvdec::av1::NvdecAv1; use crate::nvidia::nvdec::decoder::{ Crop, Destination, InPlace, Memory, OnFailed, Picture, PictureReadBack, SPARE_SURFACES, @@ -73,8 +77,8 @@ use crate::nvidia::wait::Deadline; pub enum AnnexBCodec { /// H.264, of the profiles the codec crate decodes. H264, - /// HEVC, Main and Main 10, and the range extensions' 4:2:0 and 4:4:4 at - /// 8, 10 and 12 bits where the caller lands them + /// HEVC, Main and Main 10, and the range extensions' 4:2:0, 4:2:2 and + /// 4:4:4 at 8, 10 and 12 bits where the caller lands them /// ([`AnnexBDecoder::lands_range_extensions`]). Hevc, /// AV1's Main profile, 4:2:0 at 8 and 10 bits, of frames within the @@ -177,8 +181,9 @@ impl AnnexBDecoder { } /// Has an HEVC stream of the range extensions decoded: a 4:2:0 one's - /// pictures as Main 10's, a 4:4:4 one's each in three planes, which the - /// caller writes or reads back ([`AnnexBPicture::four_four_four`]); + /// pictures as Main 10's, a 4:2:2 one's in two planes, the chroma as tall + /// as the luma, a 4:4:4 one's each in three planes, which the caller + /// writes or reads back ([`AnnexBPicture::chroma`]); /// without it, a range extensions stream's decoder is refused when its SPS /// is taken. An H.264 decoder is left as it is. pub fn lands_range_extensions(&mut self) { @@ -419,9 +424,9 @@ pub struct ReadPlane<'a> { pub struct ReadBack<'a>(PictureReadBack<'a>); impl ReadBack<'_> { - /// The luma and the chroma (interleaved Cb and Cr, half as tall), or a - /// 4:4:4 picture's luma, Cb and Cr, each as large - /// ([`AnnexBPicture::four_four_four`]). + /// The luma and the chroma (interleaved Cb and Cr, half as tall, or as + /// tall for a 4:2:2 picture), or a 4:4:4 picture's luma, Cb and Cr, each + /// as large ([`AnnexBPicture::chroma`]). pub fn planes(&self) -> Vec> { (self.0.planes().into_iter()) .map(|(bytes, bytes_per_row, rows)| ReadPlane { @@ -447,8 +452,8 @@ pub struct AnnexBPicture { } impl AnnexBPicture { - /// Bytes a sample: 1 for NV12, 2 for P016 (10-bit samples in each - /// sample's high bits, as P010's). + /// Bytes a sample: 1 for NV12 and NV16, 2 for P016 and P216 (10-bit + /// samples in each sample's high bits, as P010's). pub fn bytes_per_sample(&self) -> usize { self.picture.bytes_per_sample() } @@ -461,6 +466,17 @@ impl AnnexBPicture { self.picture.plane_count() == 3 } + /// Its chroma format: 4:2:0 (NV12 and P016), 4:2:2 (NV16 and P216, two + /// planes laid out as 4:2:0's, the chroma as tall as the luma) or 4:4:4 + /// ([`Self::four_four_four`]). + pub fn chroma(&self) -> Chroma { + match self.picture.chroma() { + ChromaFormat::Yuv422 => Chroma::Yuv422, + ChromaFormat::Yuv444 => Chroma::Yuv444, + ChromaFormat::Yuv420 | ChromaFormat::Monochrome => Chroma::Yuv420, + } + } + /// The refusal of a write of two planes, where it is 4:4:4. fn refuse_two_planes(&self) -> Option { (self.four_four_four()).then(|| "a 4:4:4 picture's three planes into two".to_owned()) @@ -641,7 +657,8 @@ impl AnnexBPicture { hold: Box, ) -> Result, Error> { if !self.four_four_four() { - return Ok(Err("a 4:2:0 picture's two planes into three".to_owned())); + let chroma = self.chroma().name(); + return Ok(Err(format!("a {chroma} picture's two planes into three"))); } // SAFETY: the caller's planes and hold, as this function's contract says. unsafe { self.write_planes_into_device(size, planes.into(), hold) } diff --git a/crates/reims-vgpu-video/src/nvidia/nvdec/decoder.rs b/crates/reims-vgpu-video/src/nvidia/nvdec/decoder.rs index a8c65b03c..4cb91a0e9 100644 --- a/crates/reims-vgpu-video/src/nvidia/nvdec/decoder.rs +++ b/crates/reims-vgpu-video/src/nvidia/nvdec/decoder.rs @@ -149,8 +149,8 @@ impl Slices<'_> { #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(crate) struct DecoderSpec { pub(crate) codec: NvdecCodec, - /// 4:2:0, monochrome, which NVDEC writes as 4:2:0, or 4:4:4, which it writes in three - /// planes. + /// 4:2:0, monochrome, which NVDEC writes as 4:2:0, 4:2:2, which it writes as 4:2:0's + /// planes with the chroma as tall as the luma, or 4:4:4, which it writes in three planes. pub(crate) chroma: ChromaFormat, /// Bits a sample: 8, 10 or 12. pub(crate) bit_depth: u32, @@ -352,15 +352,16 @@ pub(crate) const KEPT_BYTES: u64 = 512 << 20; #[cfg(test)] pub(crate) static TAKEN: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); -/// The bytes of `spec`'s decode surfaces: 4:2:0's, or 4:4:4's three planes, at one byte a -/// sample, two past 8 bits. +/// The bytes of `spec`'s decode surfaces: 4:2:0's, 4:2:2's or 4:4:4's samples, at one byte +/// a sample, two past 8 bits. fn surface_bytes(spec: &DecoderSpec) -> u64 { - let planes = if spec.chroma == ChromaFormat::Yuv444 { - 6 - } else { - 3 + // Halves of the luma's samples a picture holds. + let halves = match spec.chroma { + ChromaFormat::Yuv444 => 6, + ChromaFormat::Yuv422 => 4, + ChromaFormat::Yuv420 | ChromaFormat::Monochrome => 3, }; - let samples = u64::from(spec.width) * u64::from(spec.height) * planes / 2; + let samples = u64::from(spec.width) * u64::from(spec.height) * halves / 2; let bytes = if spec.bit_depth > 8 { 2 } else { 1 }; u64::from(spec.surfaces) * samples * bytes } @@ -478,11 +479,14 @@ impl Decoder { ))); } // 8 bits decode into NV12; deeper into P016, whose samples are - // P010's for 10 bits: the value in the high bits. 4:4:4 into its - // three planes, of 8 bits or of 16 the same way. + // P010's for 10 bits: the value in the high bits. 4:2:2 into NV16 + // and P216, laid out as NV12 and P016 with the chroma as tall as the + // luma; 4:4:4 into its three planes, of 8 bits or of 16 the same way. let output = match (spec.chroma, spec.bit_depth > 8) { (ChromaFormat::Yuv444, false) => SurfaceFormat::Yuv444, (ChromaFormat::Yuv444, true) => SurfaceFormat::Yuv444_16Bit, + (ChromaFormat::Yuv422, false) => SurfaceFormat::Nv16, + (ChromaFormat::Yuv422, true) => SurfaceFormat::P216, (_, true) => SurfaceFormat::P016, (_, false) => SurfaceFormat::Nv12, }; @@ -940,7 +944,8 @@ impl Picture { *self.size.lock() } - /// Bytes a sample of the output: 1 for NV12 and 4:4:4's 8 bits, 2 for P016 and 4:4:4's 16. + /// Bytes a sample of the output: 1 for NV12, NV16 and 4:4:4's 8 bits, 2 for P016, P216 and + /// 4:4:4's 16. pub(crate) fn bytes_per_sample(&self) -> usize { match self.inner.output { SurfaceFormat::P016 | SurfaceFormat::Yuv444_16Bit | SurfaceFormat::P216 => 2, @@ -948,23 +953,29 @@ impl Picture { } } - /// The planes its output has: 2, luma then interleaved chroma (NV12, P016), or 3, luma, - /// Cb and Cr, each as large (4:4:4's). + /// The planes its output has: 2, luma then interleaved chroma (NV12, P016, NV16, P216), + /// or 3, luma, Cb and Cr, each as large (4:4:4's). pub(crate) fn plane_count(&self) -> usize { - if self.planar() { 3 } else { 2 } + if self.chroma() == ChromaFormat::Yuv444 { + 3 + } else { + 2 + } } - /// Whether its output is 4:4:4's three planes. - fn planar(&self) -> bool { - matches!( - self.inner.output, - SurfaceFormat::Yuv444 | SurfaceFormat::Yuv444_16Bit - ) + /// Its output's chroma format: 4:2:0 (NV12, P016), 4:2:2 (NV16, P216) or 4:4:4. + pub(crate) fn chroma(&self) -> ChromaFormat { + match self.inner.output { + SurfaceFormat::Nv12 | SurfaceFormat::P016 => ChromaFormat::Yuv420, + SurfaceFormat::Nv16 | SurfaceFormat::P216 => ChromaFormat::Yuv422, + SurfaceFormat::Yuv444 | SurfaceFormat::Yuv444_16Bit => ChromaFormat::Yuv444, + } } /// Waits for the picture's decode, and copies `crop` of it into the /// decoder's staging memory: luma, then chroma (interleaved Cb and Cr, - /// half as tall, or 4:4:4's Cb and Cr planes, [`Self::plane_count`]), + /// half as tall, or 4:2:2's as tall, or 4:4:4's Cb and Cr planes, + /// [`Self::plane_count`]), /// each row packed. Every call into the driver a copy /// needs is made here: the map, the copies and the unmap, each wait /// bounded (module docs). What it returns holds the crop for the CPU's @@ -1164,7 +1175,7 @@ impl Picture { size, crop, self.bytes_per_sample(), - self.planar(), + self.chroma(), )?; let (copies, planned) = plan(&mapped); let copied = match copies.pageable.then(|| inner.caller()).flatten() { @@ -1477,17 +1488,17 @@ impl Mapped { /// bytes: the crop cut to the picture, and each plane's rows to the /// pitch. A plane follows the one before's rows, their count rounded up /// to even, as NVDEC lays a mapped frame out: the chroma after the luma, - /// half as tall, where an odd width's last chroma pair covers its last - /// column; or, where `planar`, Cb after the luma and Cr after Cb, each - /// as large. `Err` is a surface past the address space, which no map - /// gives. + /// half as tall at 4:2:0 and as tall at 4:2:2 (`chroma`), where an odd + /// width's last chroma pair covers its last column; or, at 4:4:4, Cb + /// after the luma and Cr after Cb, each as large. `Err` is a surface past + /// the address space, which no map gives. fn of( address: c_ulonglong, pitch: u32, (width, height): (u32, u32), crop: Crop, bytes: usize, - planar: bool, + chroma: ChromaFormat, ) -> Result { let plane_at = |n: u64| { u64::from(height) @@ -1511,7 +1522,7 @@ impl Mapped { let x_bytes = samples(crop.x); let within = |row_bytes: usize| row_bytes.min(pitch.saturating_sub(x_bytes)); let y = usize::try_from(crop.y).unwrap_or(0); - if planar { + if chroma == ChromaFormat::Yuv444 { let row = within(samples(crop.width)); return Ok(Self { planes: vec![ @@ -1523,16 +1534,21 @@ impl Mapped { rows: vec![crop.height; 3], }); } + let (chroma_y, chroma_rows) = if chroma == ChromaFormat::Yuv422 { + (y, crop.height) + } else { + (y / 2, crop.height.div_ceil(2)) + }; Ok(Self { planes: vec![ (address, pitch, x_bytes, y), - (plane_at(1)?, pitch, x_bytes, y / 2), + (plane_at(1)?, pitch, x_bytes, chroma_y), ], row_bytes: vec![ within(samples(crop.width)), within(samples(crop.width).next_multiple_of(2 * bytes.max(1))), ], - rows: vec![crop.height, crop.height.div_ceil(2)], + rows: vec![crop.height, chroma_rows], }) } } @@ -1783,13 +1799,27 @@ pub(crate) mod tests { #[test] fn a_mapped_pictures_chroma_follows_its_luma_rows_rounded_to_even() -> Result<(), Error> { - let mapped = Mapped::of(0x1000, 2048, (641, 361), crop(0, 0, 641, 361), 1, false)?; + let mapped = Mapped::of( + 0x1000, + 2048, + (641, 361), + crop(0, 0, 641, 361), + 1, + ChromaFormat::Yuv420, + )?; assert_eq!(mapped.planes[0], (0x1000, 2048, 0, 0)); assert_eq!(mapped.planes[1], (0x1000 + 2048 * 362, 2048, 0, 0)); // An odd width's last chroma pair covers its last column. assert_eq!(mapped.row_bytes, [641, 642]); assert_eq!(mapped.rows, [361, 181]); - let deep = Mapped::of(0, 4096, (1920, 1080), crop(0, 0, 1920, 1080), 2, false)?; + let deep = Mapped::of( + 0, + 4096, + (1920, 1080), + crop(0, 0, 1920, 1080), + 2, + ChromaFormat::Yuv420, + )?; assert_eq!(deep.planes[1].0, 4096 * 1080); assert_eq!(deep.row_bytes, [3840, 3840]); Ok(()) @@ -1797,7 +1827,14 @@ pub(crate) mod tests { #[test] fn a_mapped_4_4_4_pictures_cb_and_cr_follow_its_luma_each_as_large() -> Result<(), Error> { - let mapped = Mapped::of(0x1000, 1024, (513, 361), crop(2, 4, 500, 300), 1, true)?; + let mapped = Mapped::of( + 0x1000, + 1024, + (513, 361), + crop(2, 4, 500, 300), + 1, + ChromaFormat::Yuv444, + )?; assert_eq!( mapped.planes, [ @@ -1811,19 +1848,69 @@ pub(crate) mod tests { Ok(()) } + #[test] + fn a_mapped_4_2_2_pictures_chroma_follows_its_luma_as_tall() -> Result<(), Error> { + let mapped = Mapped::of( + 0x1000, + 2048, + (641, 361), + crop(0, 0, 641, 361), + 1, + ChromaFormat::Yuv422, + )?; + assert_eq!(mapped.planes[0], (0x1000, 2048, 0, 0)); + assert_eq!(mapped.planes[1], (0x1000 + 2048 * 362, 2048, 0, 0)); + assert_eq!(mapped.row_bytes, [641, 642]); + assert_eq!(mapped.rows, [361, 361]); + // A crop from an odd row starts the chroma on that row too. + let deep = Mapped::of( + 0, + 4096, + (1920, 1088), + crop(2, 3, 1916, 1080), + 2, + ChromaFormat::Yuv422, + )?; + assert_eq!(deep.planes[1], (4096 * 1088, 4096, 4, 3)); + assert_eq!(deep.row_bytes, [3832, 3832]); + assert_eq!(deep.rows, [1080, 1080]); + Ok(()) + } + #[test] fn a_crop_is_cut_to_the_picture_and_its_rows_to_the_pitch() -> Result<(), Error> { // H.264's 1920x1088 coded picture shown as 1920x1080 from (0, 4). - let mapped = Mapped::of(0, 2048, (1920, 1088), crop(0, 4, 1920, 1080), 1, false)?; + let mapped = Mapped::of( + 0, + 2048, + (1920, 1088), + crop(0, 4, 1920, 1080), + 1, + ChromaFormat::Yuv420, + )?; assert_eq!((mapped.planes[0].3, mapped.planes[1].3), (4, 2)); assert_eq!(mapped.rows, [1080, 540]); // A crop past the picture keeps what is in it. - let mapped = Mapped::of(0, 64, (64, 32), crop(8, 30, 100, 100), 1, false)?; + let mapped = Mapped::of( + 0, + 64, + (64, 32), + crop(8, 30, 100, 100), + 1, + ChromaFormat::Yuv420, + )?; assert_eq!(mapped.planes[0].2, 8); assert_eq!(mapped.rows, [2, 1]); assert_eq!(mapped.row_bytes, [56, 56]); // A pitch shorter than the rows holds them to it. - let mapped = Mapped::of(0, 40, (64, 32), crop(16, 0, 64, 32), 1, false)?; + let mapped = Mapped::of( + 0, + 40, + (64, 32), + crop(16, 0, 64, 32), + 1, + ChromaFormat::Yuv420, + )?; assert_eq!(mapped.row_bytes, [24, 24]); Ok(()) } @@ -1921,7 +2008,17 @@ pub(crate) mod tests { #[test] fn a_surface_past_the_address_space_is_an_error_not_a_wrap() { - assert!(Mapped::of(u64::MAX - 10, 4096, (64, 64), crop(0, 0, 64, 64), 1, false).is_err()); + assert!( + Mapped::of( + u64::MAX - 10, + 4096, + (64, 64), + crop(0, 0, 64, 64), + 1, + ChromaFormat::Yuv420 + ) + .is_err() + ); assert!( Mapped::of( 0, @@ -1929,7 +2026,7 @@ pub(crate) mod tests { (u32::MAX, u32::MAX), crop(0, 0, 1, 1), 2, - false + ChromaFormat::Yuv420 ) .is_ok() ); @@ -2001,6 +2098,17 @@ pub(crate) mod tests { // Two 4K 10-bit decoders of 9 surfaces fit, a third does not. let ten = surface_bytes(&hevc_4k(10, 9)); assert_eq!(ten, 9 * 3840 * 2160 * 3); + // 4:2:2's chroma is as large as its luma, 4:4:4's twice. + for (chroma, bytes) in [ + (ChromaFormat::Yuv422, 9 * 3840 * 2160 * 4), + (ChromaFormat::Yuv444, 9 * 3840 * 2160 * 6), + ] { + let spec = DecoderSpec { + chroma, + ..hevc_4k(10, 9) + }; + assert_eq!(surface_bytes(&spec), bytes, "{chroma:?}"); + } assert_eq!(over_budget(&[ten, ten], KEPT_BYTES), 0); assert_eq!(over_budget(&[ten, ten, ten], KEPT_BYTES), 1); } diff --git a/crates/reims-vgpu-video/src/nvidia/nvdec/hevc.rs b/crates/reims-vgpu-video/src/nvidia/nvdec/hevc.rs index 17a387065..24be32af6 100644 --- a/crates/reims-vgpu-video/src/nvidia/nvdec/hevc.rs +++ b/crates/reims-vgpu-video/src/nvidia/nvdec/hevc.rs @@ -14,10 +14,9 @@ //! //! The range extensions' streams the codec crate decodes, where the caller //! lands them ([`NvdecHevc::range_extensions`]): 4:2:0 at 8, 10 and 12 bits -//! into NV12 and P016, and 4:4:4 at 8, 10 and 12 bits into NVDEC's three -//! planes, their tools and chroma QP offset lists in the picture parameters' -//! range extension fields. Their 4:2:2 streams decode into no format built -//! here, and are refused. +//! into NV12 and P016, 4:2:2 at 8, 10 and 12 bits into NV16 and P216, and +//! 4:4:4 at 8, 10 and 12 bits into NVDEC's three planes, their tools and +//! chroma QP offset lists in the picture parameters' range extension fields. use std::ffi::{c_int, c_ushort}; use std::sync::Arc; @@ -63,16 +62,15 @@ impl NvdecHevc { } } -/// The decoder `sps`'s pictures need, with a DPB of `dpb_size` pictures: 4:4:4 -/// where the SPS's `chroma_format_idc` is 3, else 4:2:0, the one other the -/// configure takes (it refuses 4:2:2). +/// The decoder `sps`'s pictures need, with a DPB of `dpb_size` pictures: 4:2:2 +/// where the SPS's `chroma_format_idc` is 2, 4:4:4 where it is 3, else 4:2:0. pub(crate) fn spec(sps: &Sps, dpb_size: usize) -> DecoderSpec { DecoderSpec { codec: NvdecCodec::Hevc, - chroma: if sps.chroma_format_idc == 3 { - ChromaFormat::Yuv444 - } else { - ChromaFormat::Yuv420 + chroma: match sps.chroma_format_idc { + 2 => ChromaFormat::Yuv422, + 3 => ChromaFormat::Yuv444, + _ => ChromaFormat::Yuv420, }, bit_depth: u32::from(sps.bit_depth_luma_minus8) + 8, width: sps.pic_width_in_luma_samples, @@ -94,11 +92,6 @@ impl Accelerator for NvdecHevc { .to_owned(), )); } - if sps.chroma_format_idc == 2 { - return Err(Error::Unsupported( - "HEVC 4:2:2: no NVDEC output of it is built here".to_owned(), - )); - } self.decoder = Some(Decoder::new(Arc::clone(&self.gpu), &spec)?); Ok(()) } diff --git a/docs/video/nvidia.md b/docs/video/nvidia.md index 7e23afc6e..7fbc67dfe 100644 --- a/docs/video/nvidia.md +++ b/docs/video/nvidia.md @@ -89,11 +89,13 @@ NVIDIA parser is used: the codec module parses every stream, as for VA-API. |---|---|---|---| | H.264 | 4:2:0 8-bit | 48x64 to 8192x8192 | NV12 | | HEVC | 4:2:0 8, 10, 12-bit | 144x144 to 8192x8192 | NV12; P016 above 8 | +| HEVC | 4:2:2 8, 10, 12-bit | 144x144 to 8192x8192 | NV16; P216 above 8, each alone | -Each has 2 decode engines. NVDEC also lists H.264 at 10 bits and 4:2:2, -and HEVC 4:2:2 and 4:4:4, which the device's caps do not offer; HEVC's -range extensions at 4:2:0 and 4:4:4 are decoded for VideoToolbox's -paravirtual decoders ([devices.md](devices.md)), and its 4:2:2 is not. A +The 4:2:2 row is `nvidia-probe`'s of 2026-11-27 (615.71.09, potluck job +m3-max-77563), 262,144 macroblocks. Each has 2 decode engines. NVDEC also +lists H.264 at 10 bits and 4:2:2, and HEVC 4:4:4, which the device's caps +do not offer; HEVC's range extensions are decoded for VideoToolbox's +paravirtual decoders ([devices.md](devices.md)). A paravirtual session of a stream outside the sizes of its codec, chroma format and depth is refused at its start, and the guest decodes it in software ([devices.md](devices.md), "A stream outside the host decoder's @@ -220,14 +222,17 @@ the model. `pSliceDataOffsets`; the scaling lists in raster order; the DPB by surface index with `FrameIdx` and both fields' order counts. - **HEVC's range extensions** (the codec module's streams of theirs at - 4:2:0 and 4:4:4, 8, 10 and 12 bits) decode at their chroma format and - depth: 4:2:0 into NV12 at 8 bits and P016 deeper, as Main 10's, the 12 - bits at the top of each sample; 4:4:4 at `cudaVideoChromaFormat_444` into + 4:2:0, 4:2:2 and 4:4:4, 8, 10 and 12 bits) decode at their chroma format + and depth: 4:2:0 into NV12 at 8 bits and P016 deeper, as Main 10's, the 12 + bits at the top of each sample; 4:2:2 at `cudaVideoChromaFormat_422` into + `cudaVideoSurfaceFormat_NV16` at 8 bits and `P216` deeper, laid out as + NV12 and P016 with the chroma as tall as the luma, its rows from the + crop's first (`Mapped::of`); 4:4:4 at `cudaVideoChromaFormat_444` into `cudaVideoSurfaceFormat_YUV444` at 8 bits and `YUV444_16Bit` deeper, three planes, luma, Cb and Cr, each the picture's size, the second after the luma's rows rounded up to even, as the 4:2:0 chroma lies, and the - third as far after the second (`Mapped::of`). Their 4:2:2 streams are - refused ("What it refuses"). The range extensions' fields of `CUVIDHEVCPICPARAMS` take + third as far after the second (`Mapped::of`). The range extensions' + fields of `CUVIDHEVCPICPARAMS` take the SPS's and PPS's range extensions, the chroma QP offset lists' entries among them. A picture of three planes reads back with three copies (`AnnexBPicture::read_back`), and is written within the GPU into @@ -319,11 +324,11 @@ DPB names it follows NVIDIA's parser, measured on 2026-10-24: caller lands Main and Main 10 pictures alone"), as a host video session's decoders do; VideoToolbox's paravirtual decoders land them (`AnnexBDecoder::lands_range_extensions`). -- An HEVC 4:2:2 stream, as unsupported ("HEVC 4:2:2: no NVDEC output of it - is built here"): NVDEC's 4:2:2 outputs are not mapped. The RTX 3090 - lists no HEVC 4:2:2 decode (`nvidia-probe`, 2026-11-22); the RTX 5080 - Laptop GPU lists one (above), and the guest's 4:2:2 streams decode in its - own software there. +- A stream of a chroma format and depth NVDEC's caps do not list, or not + into the output the decoder makes of it, as unsupported, at the + decoder's make: the RTX 3090 lists no HEVC 4:2:2 decode (`nvidia-probe`, + 2026-11-22), and a VideoToolbox session of such a stream is refused at + its start ([devices.md](devices.md)). - A stream past NVDEC's sizes, as unsupported, or under them, as too small (`Error::TooSmall`). The device's caps give the guest NVDEC's own sizes ([bugs.md](bugs.md), D14).