mp4_atom/moov/trak/mdia/minf/stbl/stsd/vp9/
vp08.rs

1use crate::*;
2
3// https://www.webmproject.org/vp9/mp4/
4#[derive(Debug, Clone, PartialEq, Eq, Default)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub struct Vp08 {
7    pub visual: Visual,
8    pub vpcc: VpcC,
9    pub btrt: Option<Btrt>,
10    pub colr: Option<Colr>,
11    pub pasp: Option<Pasp>,
12}
13
14impl Atom for Vp08 {
15    const KIND: FourCC = FourCC::new(b"vp08");
16
17    fn decode_body<B: Buf>(buf: &mut B) -> Result<Self> {
18        let visual = Visual::decode(buf)?;
19
20        let mut vpcc = None;
21        let mut btrt = None;
22        let mut colr = None;
23        let mut pasp = None;
24        while let Some(atom) = Any::decode_maybe(buf)? {
25            match atom {
26                Any::VpcC(atom) => vpcc = atom.into(),
27                Any::Btrt(atom) => btrt = atom.into(),
28                Any::Colr(atom) => colr = atom.into(),
29                Any::Pasp(atom) => pasp = atom.into(),
30                unknown => Self::decode_unknown(&unknown)?,
31            }
32        }
33
34        Ok(Self {
35            visual,
36            vpcc: vpcc.ok_or(Error::MissingBox(VpcC::KIND))?,
37            btrt,
38            colr,
39            pasp,
40        })
41    }
42
43    fn encode_body<B: BufMut>(&self, buf: &mut B) -> Result<()> {
44        self.visual.encode(buf)?;
45        self.vpcc.encode(buf)?;
46        self.btrt.encode(buf)?;
47        self.colr.encode(buf)?;
48        self.pasp.encode(buf)?;
49
50        Ok(())
51    }
52}