frame/video: add plane_width()

This commit is contained in:
Ivan Molodetskikh 2017-06-21 01:39:29 +03:00 committed by meh
parent 403407bf2c
commit 27d1e7a3fa

View File

@ -245,6 +245,26 @@ impl Video {
8 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] #[inline]
pub fn plane_height(&self, index: usize) -> u32 { pub fn plane_height(&self, index: usize) -> u32 {
if index >= self.planes() { if index >= self.planes() {