use crate::io::bitreader::BitReaderError;
use crate::io::codebook::CodebookError;
pub use crate::options::*;
+pub use std::str::FromStr;
/// A list specifying general decoding errors.
#[derive(Debug,Clone,Copy,PartialEq)]
}
}
+/// Frame skipping mode for decoders.
+#[derive(Clone,Copy,PartialEq,Debug)]
+pub enum FrameSkipMode {
+ /// Decode all frames.
+ None,
+ /// Decode all key frames.
+ KeyframesOnly,
+ /// Decode only intra frames.
+ IntraOnly,
+}
+
+impl Default for FrameSkipMode {
+ fn default() -> Self {
+ FrameSkipMode::None
+ }
+}
+
+impl FromStr for FrameSkipMode {
+ type Err = DecoderError;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ match s {
+ FRAME_SKIP_OPTION_VAL_NONE => Ok(FrameSkipMode::None),
+ FRAME_SKIP_OPTION_VAL_KEYFRAME => Ok(FrameSkipMode::KeyframesOnly),
+ FRAME_SKIP_OPTION_VAL_INTRA => Ok(FrameSkipMode::IntraOnly),
+ _ => Err(DecoderError::InvalidData),
+ }
+ }
+}
+
+impl ToString for FrameSkipMode {
+ fn to_string(&self) -> String {
+ match *self {
+ FrameSkipMode::None => FRAME_SKIP_OPTION_VAL_NONE.to_string(),
+ FrameSkipMode::KeyframesOnly => FRAME_SKIP_OPTION_VAL_KEYFRAME.to_string(),
+ FrameSkipMode::IntraOnly => FRAME_SKIP_OPTION_VAL_INTRA.to_string(),
+ }
+ }
+}
+
/// A list specifying general encoding errors.
#[derive(Debug,Clone,Copy,PartialEq)]
#[allow(dead_code)]
/// Common description for keyframe interval option.
pub const KEYFRAME_OPTION_DESC: &'static str = "Keyframe interval (0 - automatic)";
+/// Common name for frame skipping mode.
+pub const FRAME_SKIP_OPTION: &'static str = "frame_skip";
+/// Common description for frame skipping mode.
+pub const FRAME_SKIP_OPTION_DESC: &'static str = "Frame skipping mode";
+/// Frame skipping option value for no skipped frames.
+pub const FRAME_SKIP_OPTION_VAL_NONE: &'static str = "none";
+/// Frame skipping option value for decoding only keyframes.
+pub const FRAME_SKIP_OPTION_VAL_KEYFRAME: &'static str = "keyframes";
+/// Frame skipping option value for decoding only intra frames.
+pub const FRAME_SKIP_OPTION_VAL_INTRA: &'static str = "intra";
+
/// A list specifying option parsing and validating errors.
#[derive(Clone,Copy,Debug,PartialEq)]
pub enum OptionError {