mirror of
https://github.com/encounter/rust-ffmpeg.git
synced 2026-07-10 21:18:39 -07:00
util::color: implement .name() for {Primaries, Range, TransferCharacteristic}
This commit is contained in:
@@ -23,6 +23,18 @@ pub enum Primaries {
|
||||
EBU3213,
|
||||
}
|
||||
|
||||
impl Primaries {
|
||||
pub fn name(&self) -> Option<&'static str> {
|
||||
if *self == Primaries::Unspecified {
|
||||
return None;
|
||||
}
|
||||
unsafe {
|
||||
let ptr = av_color_primaries_name((*self).into());
|
||||
ptr.as_ref().map(|ptr| from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AVColorPrimaries> for Primaries {
|
||||
fn from(value: AVColorPrimaries) -> Primaries {
|
||||
match value {
|
||||
|
||||
@@ -9,6 +9,18 @@ pub enum Range {
|
||||
JPEG,
|
||||
}
|
||||
|
||||
impl Range {
|
||||
pub fn name(&self) -> Option<&'static str> {
|
||||
if *self == Range::Unspecified {
|
||||
return None;
|
||||
}
|
||||
unsafe {
|
||||
let ptr = av_color_range_name((*self).into());
|
||||
ptr.as_ref().map(|ptr| from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AVColorRange> for Range {
|
||||
fn from(value: AVColorRange) -> Self {
|
||||
match value {
|
||||
|
||||
@@ -25,6 +25,18 @@ pub enum TransferCharacteristic {
|
||||
ARIB_STD_B67,
|
||||
}
|
||||
|
||||
impl TransferCharacteristic {
|
||||
pub fn name(&self) -> Option<&'static str> {
|
||||
if *self == TransferCharacteristic::Unspecified {
|
||||
return None;
|
||||
}
|
||||
unsafe {
|
||||
let ptr = av_color_transfer_name((*self).into());
|
||||
ptr.as_ref().map(|ptr| from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AVColorTransferCharacteristic> for TransferCharacteristic {
|
||||
fn from(value: AVColorTransferCharacteristic) -> TransferCharacteristic {
|
||||
match value {
|
||||
|
||||
Reference in New Issue
Block a user