#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum Encoding {
Rgb565,
Rgb555,
ReorderedRgb555,
Yuv422,
Ycbcr420,
Jpeg,
}
#[derive(Debug, Clone)]
#[allow(clippy::struct_excessive_bools)]
pub struct Profile {
pub prefix: i32,
pub width: i32,
pub height: i32,
pub encoding: Encoding,
pub frame_byte_length: i32,
pub swaps_dimensions: bool,
pub little_endian: bool,
pub is_padded: bool,
pub is_interlaced: bool,
pub clcl_chroma: bool,
pub swap_chroma_planes: bool,
pub cl_chroma: bool,
pub swap_rgb_channels: bool,
pub rotation: i32,
pub crop_x: i32,
pub crop_y: i32,
pub crop_width: i32,
pub crop_height: i32,
pub slot_size: i32,
pub use_mhni_dimensions: bool,
pub fallback_encodings: Option<Vec<Encoding>>,
}
impl Default for Profile {
fn default() -> Self {
Self {
prefix: 0,
width: 0,
height: 0,
encoding: Encoding::Rgb565,
frame_byte_length: 0,
swaps_dimensions: false,
little_endian: true,
is_padded: false,
is_interlaced: false,
clcl_chroma: false,
swap_chroma_planes: false,
cl_chroma: false,
swap_rgb_channels: false,
rotation: 0,
crop_x: 0,
crop_y: 0,
crop_width: 0,
crop_height: 0,
slot_size: 0,
use_mhni_dimensions: false,
fallback_encodings: None,
}
}
}
impl Profile {
#[must_use]
pub fn frame_size(&self) -> i32 {
if self.is_padded && self.slot_size > 0 {
self.slot_size
} else {
self.frame_byte_length
}
}
#[must_use]
pub fn display_width(&self) -> i32 {
if self.swaps_dimensions { self.height } else { self.width }
}
#[must_use]
pub fn display_height(&self) -> i32 {
if self.swaps_dimensions { self.width } else { self.height }
}
}
#[must_use]
pub fn built_in_profiles() -> Vec<Profile> {
match crate::profile_db::ProfileDb::load_builtin() {
Ok(db) => db.all().values().cloned().collect(),
Err(_) => vec![],
}
}