util::color: implement .name() for {Primaries, Range, TransferCharacteristic}
This commit is contained in:
parent
b387e1de48
commit
bd35f013f8
@ -1,3 +1,6 @@
|
||||
use std::ffi::CStr;
|
||||
use std::str::from_utf8_unchecked;
|
||||
|
||||
use ffi::AVColorPrimaries::*;
|
||||
use ffi::*;
|
||||
|
||||
@ -21,6 +24,19 @@ pub enum Primaries {
|
||||
JEDEC_P22,
|
||||
}
|
||||
|
||||
impl Primaries {
|
||||
pub fn name(&self) -> Option<&'static str> {
|
||||
unsafe {
|
||||
let ptr = av_color_primaries_name((*self).into());
|
||||
if ptr.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AVColorPrimaries> for Primaries {
|
||||
fn from(value: AVColorPrimaries) -> Primaries {
|
||||
match value {
|
||||
|
@ -1,3 +1,6 @@
|
||||
use std::ffi::CStr;
|
||||
use std::str::from_utf8_unchecked;
|
||||
|
||||
use ffi::AVColorRange::*;
|
||||
use ffi::*;
|
||||
|
||||
@ -8,6 +11,19 @@ pub enum Range {
|
||||
JPEG,
|
||||
}
|
||||
|
||||
impl Range {
|
||||
pub fn name(&self) -> Option<&'static str> {
|
||||
unsafe {
|
||||
let ptr = av_color_range_name((*self).into());
|
||||
if ptr.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AVColorRange> for Range {
|
||||
fn from(value: AVColorRange) -> Self {
|
||||
match value {
|
||||
|
@ -1,3 +1,6 @@
|
||||
use std::ffi::CStr;
|
||||
use std::str::from_utf8_unchecked;
|
||||
|
||||
use ffi::AVColorTransferCharacteristic::*;
|
||||
use ffi::*;
|
||||
|
||||
@ -24,6 +27,19 @@ pub enum TransferCharacteristic {
|
||||
ARIB_STD_B67,
|
||||
}
|
||||
|
||||
impl TransferCharacteristic {
|
||||
pub fn name(&self) -> Option<&'static str> {
|
||||
unsafe {
|
||||
let ptr = av_color_transfer_name((*self).into());
|
||||
if ptr.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AVColorTransferCharacteristic> for TransferCharacteristic {
|
||||
fn from(value: AVColorTransferCharacteristic) -> TransferCharacteristic {
|
||||
match value {
|
||||
|
Loading…
x
Reference in New Issue
Block a user