Skip to content

115 - Handle unsupported pixel formats properly #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["ffmpeg", "multimedia", "video", "audio"]
categories = ["multimedia"]

[features]
default = ["codec", "device", "filter", "format", "software-resampling", "software-scaling"]
default = ["codec", "device", "filter", "format", "software-resampling", "software-scaling", "non-exhaustive-enums"]

# ffmpeg<xy> are obsolete features kept for backward compatibility purposes and
# don't do anything anymore (equivalents are automatically specified through
Expand All @@ -29,6 +29,9 @@ ffmpeg4 = []
static = ["ffmpeg-sys-next/static"]
build = ["static", "ffmpeg-sys-next/build"]

# mark enums in generated bindings as #[non_exhaustive]
non-exhaustive-enums = ["ffmpeg-sys-next/non-exhaustive-enums"]

# licensing
build-license-gpl = ["ffmpeg-sys-next/build-license-gpl"]
build-license-nonfree = ["ffmpeg-sys-next/build-license-nonfree"]
Expand Down
3 changes: 3 additions & 0 deletions src/codec/audio_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ impl From<AVAudioServiceType> for AudioService {
AV_AUDIO_SERVICE_TYPE_VOICE_OVER => AudioService::VoiceOver,
AV_AUDIO_SERVICE_TYPE_KARAOKE => AudioService::Karaoke,
AV_AUDIO_SERVICE_TYPE_NB => AudioService::Main,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/codec/discard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ impl From<AVDiscard> for Discard {
AVDISCARD_NONINTRA => Discard::NonIntra,
AVDISCARD_NONKEY => Discard::NonKey,
AVDISCARD_ALL => Discard::All,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/codec/field_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ impl From<AVFieldOrder> for FieldOrder {
AV_FIELD_BB => FieldOrder::BB,
AV_FIELD_TB => FieldOrder::TB,
AV_FIELD_BT => FieldOrder::BT,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/codec/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,9 @@ impl From<AVCodecID> for Id {
AV_CODEC_ID_VNULL => Id::VNULL,
#[cfg(feature = "ffmpeg_6_0")]
AV_CODEC_ID_ANULL => Id::ANULL,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/codec/packet/side_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ impl From<AVPacketSideDataType> for Type {

#[cfg(feature = "ffmpeg_5_0")]
AV_PKT_DATA_DYNAMIC_HDR10_PLUS => Type::DYNAMIC_HDR10_PLUS,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/codec/subtitle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ impl From<AVSubtitleType> for Type {
SUBTITLE_BITMAP => Type::Bitmap,
SUBTITLE_TEXT => Type::Text,
SUBTITLE_ASS => Type::Ass,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/software/resampling/dither.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ impl From<SwrDitherType> for Dither {
SWR_DITHER_NS_LOW_SHIBATA => Dither::NoiseShapingLowShibata,
SWR_DITHER_NS_HIGH_SHIBATA => Dither::NoiseShapingHighShibata,
SWR_DITHER_NB => Dither::None,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/software/resampling/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ impl From<SwrEngine> for Engine {
SWR_ENGINE_SWR => Engine::Software,
SWR_ENGINE_SOXR => Engine::SoundExchange,
SWR_ENGINE_NB => Engine::Software,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/software/resampling/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ impl From<SwrFilterType> for Filter {
SWR_FILTER_TYPE_CUBIC => Filter::Cubic,
SWR_FILTER_TYPE_BLACKMAN_NUTTALL => Filter::BlackmanNuttall,
SWR_FILTER_TYPE_KAISER => Filter::Kaiser,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/chroma/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ impl From<AVChromaLocation> for Location {
AVCHROMA_LOC_BOTTOMLEFT => Location::BottomLeft,
AVCHROMA_LOC_BOTTOM => Location::Bottom,
AVCHROMA_LOC_NB => Location::Unspecified,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/color/primaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ impl From<AVColorPrimaries> for Primaries {
AVCOL_PRI_JEDEC_P22 => Primaries::JEDEC_P22,
#[cfg(feature = "ffmpeg_4_3")]
AVCOL_PRI_EBU3213 => Primaries::EBU3213,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/color/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ impl From<AVColorRange> for Range {
AVCOL_RANGE_MPEG => Range::MPEG,
AVCOL_RANGE_JPEG => Range::JPEG,
AVCOL_RANGE_NB => Range::Unspecified,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/color/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ impl From<AVColorSpace> for Space {
AVCOL_SPC_CHROMA_DERIVED_NCL => Space::ChromaDerivedNCL,
AVCOL_SPC_CHROMA_DERIVED_CL => Space::ChromaDerivedCL,
AVCOL_SPC_ICTCP => Space::ICTCP,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/color/transfer_characteristic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ impl From<AVColorTransferCharacteristic> for TransferCharacteristic {
AVCOL_TRC_SMPTE2084 => TransferCharacteristic::SMPTE2084,
AVCOL_TRC_SMPTE428 => TransferCharacteristic::SMPTE428,
AVCOL_TRC_ARIB_STD_B67 => TransferCharacteristic::ARIB_STD_B67,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/util/format/pixel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,13 @@ impl From<AVPixelFormat> for Pixel {
AV_PIX_FMT_RPI4_8 => Pixel::RPI4_8,
#[cfg(feature = "rpi")]
AV_PIX_FMT_RPI4_10 => Pixel::RPI4_10,
#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}

#[allow(unreachable_patterns)]
impl From<Pixel> for AVPixelFormat {
#[inline]
fn from(value: Pixel) -> AVPixelFormat {
Expand Down Expand Up @@ -1221,6 +1224,8 @@ impl From<Pixel> for AVPixelFormat {
Pixel::RPI4_8 => AV_PIX_FMT_RPI4_8,
#[cfg(feature = "rpi")]
Pixel::RPI4_10 => AV_PIX_FMT_RPI4_10,
#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!("Not all current or future pixel formats are supported yet"),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/format/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ impl From<AVSampleFormat> for Sample {
AV_SAMPLE_FMT_DBLP => Sample::F64(Type::Planar),

AV_SAMPLE_FMT_NB => Sample::None,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/util/frame/side_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ impl From<AVFrameSideDataType> for Type {

#[cfg(feature = "ffmpeg_6_0")]
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT => Type::AMBIENT_VIEWING_ENVIRONMENT,
#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/mathematics/rounding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ impl From<AVRounding> for Rounding {
AV_ROUND_UP => Rounding::Up,
AV_ROUND_NEAR_INF => Rounding::NearInfinity,
AV_ROUND_PASS_MINMAX => Rounding::PassMinMax,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ impl From<AVMediaType> for Type {
AVMEDIA_TYPE_SUBTITLE => Type::Subtitle,
AVMEDIA_TYPE_ATTACHMENT => Type::Attachment,
AVMEDIA_TYPE_NB => Type::Unknown,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/option/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ impl From<AVOptionType> for Type {
AV_OPT_TYPE_CHANNEL_LAYOUT => Type::ChannelLayout,
#[cfg(feature = "ffmpeg_5_1")]
AV_OPT_TYPE_CHLAYOUT => Type::ChannelLayout,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ impl From<AVPictureType> for Type {
AV_PICTURE_TYPE_SI => Type::SI,
AV_PICTURE_TYPE_SP => Type::SP,
AV_PICTURE_TYPE_BI => Type::BI,

#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
Expand Down