frame/video: add plane_width()
This commit is contained in:
parent
403407bf2c
commit
27d1e7a3fa
@ -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() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user