pub fn new(data: &[u8]) -> Result<Self> {
        let mut pos = 0;

        let mut features: HashMap<u8, u8> = HashMap::with_capacity(4);
        while pos < data.len() {
            let (id, value) = Self::read_feature(&mut pos, &data);
            let _ = features.insert(id, value);
        }

        let profile = *features.get(&1).ok_or(Vp9ParserError::InvalidMetadata)?;
        let level = *features.get(&2).ok_or(Vp9ParserError::InvalidMetadata)?;
        let color_depth = *features.get(&3).ok_or(Vp9ParserError::InvalidMetadata)?;
        let chroma_subsampling = *features.get(&1).ok_or(Vp9ParserError::InvalidMetadata)?;

        Ok(Self {
            profile: profile.into(),
            level: level.into(),
            color_depth: color_depth.into(),
            chroma_subsampling: chroma_subsampling.into(),
        })
    }
/// Creates the Vp9Metadata from the given `CodecPrivate` data.
Creates the Vp9Metadata from the given `CodecPrivate` data.
Creates the Vp9Metadata from the given ` CodecPrivate ` data .
pub fn new(data: &[u8]) -> Result<Self> {
        let mut pos = 0;
        let mut features: HashMap<u8, u8> = HashMap::with_capacity(4);
        while pos < data.len() {
            let (id, value) = Self::read_feature(&mut pos, &data);
            let _ = features.insert(id, value);
        }
        let profile = *features.get(&1).ok_or(Vp9ParserError::InvalidMetadata)?;
        let level = *features.get(&2).ok_or(Vp9ParserError::InvalidMetadata)?;
        let color_depth = *features.get(&3).ok_or(Vp9ParserError::InvalidMetadata)?;
        let chroma_subsampling = *features.get(&1).ok_or(Vp9ParserError::InvalidMetadata)?;
        Ok(Self {
            profile: profile.into(),
            level: level.into(),
            color_depth: color_depth.into(),
            chroma_subsampling: chroma_subsampling.into(),
        })
    }
pub fn new ( data : & [ u8 ] ) -> Result < Self > { let mut pos = 0 ; let mut features : HashMap < u8 , u8 > = HashMap :: with_capacity ( 4 ) ; while pos < data . len ( ) { let ( id , value ) = Self :: read_feature ( & mut pos , & data ) ; let _ = features . insert ( id , value ) ; } let profile = * features . get ( & 1 ) . ok_or ( Vp9ParserError :: InvalidMetadata ) ? ; let level = * features . get ( & 2 ) . ok_or ( Vp9ParserError :: InvalidMetadata ) ? ; let color_depth = * features . get ( & 3 ) . ok_or ( Vp9ParserError :: InvalidMetadata ) ? ; let chroma_subsampling = * features . get ( & 1 ) . ok_or ( Vp9ParserError :: InvalidMetadata ) ? ; Ok ( Self { profile : profile . into ( ) , level : level . into ( ) , color_depth : color_depth . into ( ) , chroma_subsampling : chroma_subsampling . into ( ) , } ) }
Creates the Vp9Metadata from the given `CodecPrivate` data.
Creates the Vp9Metadata from the given ` CodecPrivate ` data .
data
&[u8]
data
&[u8]