diff --git a/src/util/color/primaries.rs b/src/util/color/primaries.rs index 3b69b75..e94fa5f 100644 --- a/src/util/color/primaries.rs +++ b/src/util/color/primaries.rs @@ -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 for Primaries { fn from(value: AVColorPrimaries) -> Primaries { match value { diff --git a/src/util/color/range.rs b/src/util/color/range.rs index 2b97807..936fa26 100644 --- a/src/util/color/range.rs +++ b/src/util/color/range.rs @@ -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 for Range { fn from(value: AVColorRange) -> Self { match value { diff --git a/src/util/color/transfer_characteristic.rs b/src/util/color/transfer_characteristic.rs index ec48503..f736478 100644 --- a/src/util/color/transfer_characteristic.rs +++ b/src/util/color/transfer_characteristic.rs @@ -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 for TransferCharacteristic { fn from(value: AVColorTransferCharacteristic) -> TransferCharacteristic { match value {