Skip to main content

SideInfo

Struct SideInfo 

Source
pub struct SideInfo {
    pub blocks_wide: usize,
    pub blocks_tall: usize,
    /* private fields */
}
Expand description

Per-coefficient rounding errors from quantization.

Each error is in [-0.5, +0.5] and represents how far the continuous (unquantized) DCT coefficient was from its rounded integer value. Positive error means the pre-quantization value was above the integer; negative means below.

Stored as i8 [-127, +127] via error * 254, giving ~0.004 resolution. This is 8x smaller than f64 and 4x smaller than f32, saving 85 MB (12MP) or 341 MB (48MP) compared to the original f64 representation.

Fields§

§blocks_wide: usize

Number of 8x8 blocks horizontally.

§blocks_tall: usize

Number of 8x8 blocks vertically.

Implementations§

Source§

impl SideInfo

Source

pub fn compute( raw_rgb: &[u8], pixel_width: u32, pixel_height: u32, cover_grid: &DctGrid, qt_values: &[u16; 64], ) -> Self

Compute side information from raw RGB pixels and the cover JPEG.

For each Y-channel 8x8 block:

  1. Forward DCT on the original (pre-JPEG) pixels
  2. Divide by quantization table (without rounding)
  3. error = unquantized_value - cover_integer_coefficient

Errors are clamped to [-0.5, +0.5] for robustness against minor floating-point differences between the platform’s JPEG encoder and our forward DCT implementation.

Luma blocks are computed in strips of 50 block-rows to limit transient memory (~12.9 MB per strip instead of ~97.5 MB for all blocks at once on a 12MP image).

Source

pub fn error_at(&self, flat_idx: usize) -> f32

Get the rounding error at a flat index, decoded from i8 to f32.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V