Fix issues related to duplicate enum variants

C enums allow duplicate variants, but Rust enums don't. At some point bindgen
switched to generating duplicate variants as associated constants instead of
module-level constants, so use SomeEnum::* broke. Here we switch to associated
constants in the native API as well.
This commit is contained in:
Zhiming Wang 2020-06-01 13:36:50 +08:00
parent 1cd6d0499b
commit 506f66ac51
No known key found for this signature in database
GPG Key ID: 5B58F95EC95965D8
2 changed files with 7 additions and 9 deletions

View File

@ -14,7 +14,6 @@ pub enum Space {
BT470BG,
SMPTE170M,
SMPTE240M,
YCOCG,
YCGCO,
BT2020NCL,
BT2020CL,
@ -26,6 +25,8 @@ pub enum Space {
}
impl Space {
pub const YCOCG: Space = Space::YCGCO;
pub fn name(&self) -> Option<&'static str> {
if *self == Space::Unspecified {
return None;
@ -48,7 +49,7 @@ impl From<AVColorSpace> for Space {
AVCOL_SPC_BT470BG => Space::BT470BG,
AVCOL_SPC_SMPTE170M => Space::SMPTE170M,
AVCOL_SPC_SMPTE240M => Space::SMPTE240M,
AVCOL_SPC_YCOCG => Space::YCOCG,
AVCOL_SPC_YCGCO => Space::YCGCO,
AVCOL_SPC_BT2020_NCL => Space::BT2020NCL,
AVCOL_SPC_BT2020_CL => Space::BT2020CL,
AVCOL_SPC_SMPTE2085 => Space::SMPTE2085,
@ -72,7 +73,6 @@ impl Into<AVColorSpace> for Space {
Space::BT470BG => AVCOL_SPC_BT470BG,
Space::SMPTE170M => AVCOL_SPC_SMPTE170M,
Space::SMPTE240M => AVCOL_SPC_SMPTE240M,
Space::YCOCG => AVCOL_SPC_YCOCG,
Space::YCGCO => AVCOL_SPC_YCGCO,
Space::BT2020NCL => AVCOL_SPC_BT2020_NCL,
Space::BT2020CL => AVCOL_SPC_BT2020_CL,

View File

@ -223,9 +223,6 @@ pub enum Pixel {
// --- defaults
XVMC,
Y400A,
GRAY8A,
GBR24P,
RGB32,
RGB32_1,
@ -324,6 +321,10 @@ unsafe impl Send for Descriptor {}
unsafe impl Sync for Descriptor {}
impl Pixel {
pub const Y400A: Pixel = Pixel::YA8;
pub const GRAY8A: Pixel = Pixel::YA8;
pub const GBR24P: Pixel = Pixel::GBRP;
pub fn descriptor(self) -> Option<Descriptor> {
unsafe {
let ptr = av_pix_fmt_desc_get(self.into());
@ -820,9 +821,6 @@ impl Into<AVPixelFormat> for Pixel {
// --- defaults
Pixel::XVMC => AV_PIX_FMT_XVMC,
Pixel::Y400A => AV_PIX_FMT_Y400A,
Pixel::GRAY8A => AV_PIX_FMT_GRAY8A,
Pixel::GBR24P => AV_PIX_FMT_GBR24P,
Pixel::RGB32 => AV_PIX_FMT_RGB32,
Pixel::RGB32_1 => AV_PIX_FMT_RGB32_1,