1 // Copyright 2020 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 use super::bindings; 6 use crate::error::*; 7 use crate::format::*; 8 9 /// Represents an input video format for VDA. 10 pub struct InputFormat { 11 pub profile: Profile, 12 pub min_width: u32, 13 pub min_height: u32, 14 pub max_width: u32, 15 pub max_height: u32, 16 } 17 18 impl InputFormat { new(f: &bindings::vda_input_format_t) -> Result<InputFormat>19 pub(crate) fn new(f: &bindings::vda_input_format_t) -> Result<InputFormat> { 20 let profile = Profile::n(f.profile).ok_or(Error::UnknownProfile(f.profile))?; 21 22 Ok(InputFormat { 23 profile, 24 min_width: f.min_width, 25 min_height: f.min_height, 26 max_width: f.max_width, 27 max_height: f.max_height, 28 }) 29 } 30 31 // The callers must guarantee that `data` is valid for |`len`| elements when 32 // both `data` and `len` are valid. from_raw_parts( data: *const bindings::vda_input_format_t, len: usize, ) -> Result<Vec<Self>>33 pub(crate) unsafe fn from_raw_parts( 34 data: *const bindings::vda_input_format_t, 35 len: usize, 36 ) -> Result<Vec<Self>> { 37 validate_formats(data, len, Self::new) 38 } 39 } 40