1
0
Fork 0
mirror of https://github.com/alfg/mp4-rust.git synced 2024-06-10 17:09:22 +00:00
mp4-rust/src/error.rs
james.baker@helsing.ai 773e9656fc
Support hvc1 box & enable simple access of hevc parameter sets
I have an HEVC mp4 file of the `hvc1` kind. In order to construct
the decoder (using Apple VideoToolbox) I need the PPS, SPS, VPS
parameter sets.

This PR does two things:
1. It adds parsing for the `hvc1` box. This appears similar to `hev1`
   at least at the 'trak' level. In my files, there are additional
   inner boxes, for example a `colr` box. I therefore skip nested
   boxes.
1. Enable hevc accessors for the vps, pps, sps properties that are
   required to initialise many decoders.

I should note here - I have no _particular_ video decoding knowledge,
but do have some experience with binary formats and software engineering
in general - have reverse engineered what I need in order to solve my
present problem by looking at output from the `MP4Box` tool.
2023-10-22 16:15:31 +02:00

30 lines
924 B
Rust

use thiserror::Error;
use crate::mp4box::BoxType;
#[derive(Error, Debug)]
pub enum Error {
#[error("{0}")]
IoError(#[from] std::io::Error),
#[error("{0}")]
InvalidData(&'static str),
#[error("{0} not found")]
BoxNotFound(BoxType),
#[error("{0} and {1} not found")]
Box2NotFound(BoxType, BoxType),
#[error("trak[{0}] not found")]
TrakNotFound(u32),
#[error("trak[{0}].{1} not found")]
BoxInTrakNotFound(u32, BoxType),
#[error("traf[{0}].{1} not found")]
BoxInTrafNotFound(u32, BoxType),
#[error("trak[{0}].stbl.{1:?} not found")]
BoxInStblNotFound(u32, Vec<BoxType>),
#[error("trak[{0}].stbl.{1}.entry[{2}] not found")]
EntryInStblNotFound(u32, BoxType, u32),
#[error("traf[{0}].trun.{1}.entry[{2}] not found")]
EntryInTrunNotFound(u32, BoxType, u32),
#[error("{0} version {1} is not supported")]
UnsupportedBoxVersion(BoxType, u8),
}