format/pixel: add Descriptor::{name, log2_chroma_w}()

This commit is contained in:
Ivan Molodetskikh
2017-06-22 22:16:46 +02:00
committed by meh
parent 1095c8842e
commit 403407bf2c
+15
View File
@@ -1,3 +1,6 @@
use std::ffi::CStr;
use std::str::from_utf8_unchecked;
use ffi::*;
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
@@ -312,12 +315,24 @@ impl Descriptor {
self.ptr
}
pub fn name(self) -> &'static str {
unsafe {
from_utf8_unchecked(CStr::from_ptr((*self.as_ptr()).name).to_bytes())
}
}
pub fn nb_components(self) -> u8 {
unsafe {
(*self.as_ptr()).nb_components
}
}
pub fn log2_chroma_w(self) -> u8 {
unsafe {
(*self.as_ptr()).log2_chroma_w
}
}
pub fn log2_chroma_h(self) -> u8 {
unsafe {
(*self.as_ptr()).log2_chroma_h