mirror of
https://github.com/storytold/filmcraft.git
synced 2026-11-11 02:40:01 -06:00
New crate filmcraft-h264 (L0, depends only on filmcraft-bitstream): - SPS incl. VUI/HRD, scaling lists with fall-back rules A/B, frame cropping, high-profile chroma_format_idc / bit depth fields, DPB size from level - PPS incl. transform_8x8_mode, scaling lists, slice groups (parse only) - slice header: all fields incl. ref_pic_list_modification, pred_weight_table, dec_ref_pic_marking - POC types 0/1/2 (incl. MMCO5 handling and frame_num gap hooks) - default scaling / QPc / deblocking tables from the public ITU-T spec - ffmpeg/libx264 fixture generator for tests (skips when ffmpeg is absent) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
use filmcraft_bitstream::BitError;
|
|
|
|
/// Errors produced by the decoder.
|
|
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
|
|
pub enum Error {
|
|
/// The bitstream ended early or contained an invalid Exp-Golomb code.
|
|
#[error("bitstream error: {0}")]
|
|
Bitstream(#[from] BitError),
|
|
/// A syntax element had a value outside its legal range.
|
|
#[error("invalid bitstream: {0}")]
|
|
Invalid(String),
|
|
/// A valid feature this decoder does not implement (yet).
|
|
#[error("unsupported: {0}")]
|
|
Unsupported(String),
|
|
/// A slice referenced a parameter set that has not been received.
|
|
#[error("missing parameter set: {0}")]
|
|
MissingParameterSet(String),
|
|
}
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
pub(crate) fn invalid<T>(msg: impl Into<String>) -> Result<T> {
|
|
Err(Error::Invalid(msg.into()))
|
|
}
|
|
|
|
pub(crate) fn unsupported<T>(msg: impl Into<String>) -> Result<T> {
|
|
Err(Error::Unsupported(msg.into()))
|
|
}
|
|
|
|
/// `ensure!(cond, "message")` returns `Error::Invalid` when `cond` is false.
|
|
macro_rules! ensure {
|
|
($cond:expr, $($arg:tt)+) => {
|
|
if !$cond {
|
|
return Err($crate::error::Error::Invalid(format!($($arg)+)));
|
|
}
|
|
};
|
|
}
|
|
pub(crate) use ensure;
|