#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum AppMarkerType {
Unknown = 0,
Icc = 1,
Exif = 2,
Xmp = 3,
}
impl AppMarkerType {
pub(crate) fn from_u32(v: u32) -> Option<Self> {
match v {
0 => Some(Self::Unknown),
1 => Some(Self::Icc),
2 => Some(Self::Exif),
3 => Some(Self::Xmp),
_ => None,
}
}
}
#[derive(Debug, Clone)]
pub struct JpegQuantTable {
pub values: [i32; 64],
pub precision: u32,
pub index: u32,
pub is_last: bool,
}
#[derive(Debug, Clone)]
pub struct JpegHuffmanCode {
pub is_ac: bool,
pub id: u32,
pub is_last: bool,
pub counts: [u32; 16],
pub values: Vec<u8>,
}
#[derive(Debug, Clone)]
pub struct JpegComponent {
pub id: u32,
pub h_samp_factor: u32,
pub v_samp_factor: u32,
pub quant_idx: u32,
pub width_in_blocks: u32,
pub height_in_blocks: u32,
pub coeffs: Vec<i16>,
}
#[derive(Debug, Clone)]
pub struct JpegScanInfo {
pub num_components: u32,
pub component_indices: Vec<u32>,
pub dc_tbl_idx: Vec<u32>,
pub ac_tbl_idx: Vec<u32>,
pub ss: u32,
pub se: u32,
pub ah: u32,
pub al: u32,
pub reset_points: Vec<u32>,
pub extra_zero_runs: Vec<(u32, u32)>,
#[allow(dead_code)] pub last_needed_pass: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum JpegComponentType {
Gray = 0,
YCbCr = 1,
Rgb = 2,
Custom = 3,
}
impl JpegComponentType {
pub(crate) fn from_u32(v: u32) -> Option<Self> {
match v {
0 => Some(Self::Gray),
1 => Some(Self::YCbCr),
2 => Some(Self::Rgb),
3 => Some(Self::Custom),
_ => None,
}
}
}
#[derive(Debug, Clone)]
pub struct JpegData {
pub width: u32,
pub height: u32,
pub restart_interval: u32,
pub app_data: Vec<Vec<u8>>,
#[allow(dead_code)] pub app_marker_type: Vec<AppMarkerType>,
pub com_data: Vec<Vec<u8>>,
pub quant: Vec<JpegQuantTable>,
pub huffman_code: Vec<JpegHuffmanCode>,
pub components: Vec<JpegComponent>,
pub scan_info: Vec<JpegScanInfo>,
pub marker_order: Vec<u8>,
pub inter_marker_data: Vec<Vec<u8>>,
pub tail_data: Vec<u8>,
#[allow(dead_code)] pub has_zero_padding_bit: bool,
pub padding_bits: Vec<u8>,
pub component_type: JpegComponentType,
}