Skip to main content

decode_progressive_scan

Function decode_progressive_scan 

Source
pub fn decode_progressive_scan(
    data: &[u8],
    scan_start: usize,
    frame: &FrameInfo,
    scan_components: &[ScanComponent],
    dc_specs: &[Option<HuffmanSpec>; 4],
    ac_specs: &[Option<HuffmanSpec>; 4],
    restart_interval: u16,
    params: &SosParams,
    grids: &mut [DctGrid],
) -> Result<usize>
Expand description

Decode a single progressive scan into existing DctGrids.

Progressive JPEG has multiple scans, each contributing partial coefficient data. This function decodes one scan (identified by its SOS parameters) and accumulates the results into the provided grids.

The four scan types are:

  • DC first (Ss=0, Se=0, Ah=0): Initial DC coefficients, shifted left by Al
  • DC refining (Ss=0, Se=0, Ah>0): One correction bit per DC coefficient
  • AC first (Ss>0, Ah=0): Initial AC coefficients for a spectral band
  • AC refining (Ss>0, Ah>0): Correction bits for previously-decoded AC coefficients

Returns the byte position after the scan data.