diff --git a/src/util/frame/video.rs b/src/util/frame/video.rs index cf5515c..f5891e8 100644 --- a/src/util/frame/video.rs +++ b/src/util/frame/video.rs @@ -245,6 +245,26 @@ impl Video { 8 } + #[inline] + pub fn plane_width(&self, index: usize) -> u32 { + if index >= self.planes() { + panic!("out of bounds"); + } + + // Logic taken from image_get_linesize(). + if index != 1 && index != 2 { + return self.width(); + } + + if let Some(desc) = self.format().descriptor() { + let s = desc.log2_chroma_w(); + (self.width() + (1 << s) - 1) >> s + } + else { + self.width() + } + } + #[inline] pub fn plane_height(&self, index: usize) -> u32 { if index >= self.planes() {