use super::api::DecodeError;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub(crate) enum InternalDecodeError {
BitStreamError = 0,
HuffmanError = 1,
TransformError = 2,
InvalidColorCacheBits = 3,
#[allow(dead_code)]
LumaPredictionModeInvalid = 4,
#[allow(dead_code)]
IntraPredictionModeInvalid = 5,
#[allow(dead_code)]
ChromaPredictionModeInvalid = 6,
Cancelled = 7,
}
impl From<InternalDecodeError> for DecodeError {
fn from(e: InternalDecodeError) -> Self {
match e {
InternalDecodeError::BitStreamError => DecodeError::BitStreamError,
InternalDecodeError::HuffmanError => DecodeError::HuffmanError,
InternalDecodeError::TransformError => DecodeError::TransformError,
InternalDecodeError::InvalidColorCacheBits => {
DecodeError::BitStreamError
}
InternalDecodeError::LumaPredictionModeInvalid => {
DecodeError::LumaPredictionModeInvalid(0)
}
InternalDecodeError::IntraPredictionModeInvalid => {
DecodeError::IntraPredictionModeInvalid(0)
}
InternalDecodeError::ChromaPredictionModeInvalid => {
DecodeError::ChromaPredictionModeInvalid(0)
}
InternalDecodeError::Cancelled => DecodeError::Cancelled(enough::StopReason::Cancelled),
}
}
}
impl From<enough::StopReason> for InternalDecodeError {
fn from(_reason: enough::StopReason) -> Self {
Self::Cancelled
}
}