Skip to main content

codec_reduction_shift

Function codec_reduction_shift 

Source
pub fn codec_reduction_shift(
    drawn_width_units: f64,
    drawn_height_units: f64,
    source_width: i64,
    source_height: i64,
    target_pixels_per_unit: f64,
) -> u32
Expand description

docling-parse’s codec_reduction_shift: how many halvings a JPEG may be decoded at (libjpeg’s 1/2, 1/4, 1/8 reduced inverse DCT) and still hold at least the pixels it is drawn onto at target_pixels_per_unit — the renderer’s bitmap_target_pixels_per_unit, docling’s render_scale of 1.0 — so the rasterizer keeps minifying and never magnifies samples it once had. A 300 dpi scan drawn full-page decodes at a quarter for the 72 dpi hint and is blitted up onto the scale-2 canvas; matching that is what lines the Rust render of a scan up with the shim’s. Capped at three halvings and never below 64 samples a side (a thumbnail is not worth the resampling risk); drawn_*_units is the axis-aligned extent of the drawn quad in PDF units.