Skip to content

Why does set_scan_optimization_mode() call jpeg_set_defaults()? #47

@lilith

Description

@lilith

I noticed set_scan_optimization_mode() calls jpeg_set_defaults() after setting the scan mode parameter. Is there a reason for this?

Looking at the mozjpeg C code, jpeg_c_set_int_param() for JINT_DC_SCAN_OPT_MODE just sets one field and doesn't call jpeg_set_defaults(). The official cjpeg tool also doesn't call it when setting this parameter.

The side effect is that jpeg_set_defaults() resets a bunch of other settings (subsampling, smoothing_factor, raw_data_in, pixel density, etc), which causes ordering-dependent behavior:

comp.set_smoothing_factor(50);
comp.set_scan_optimization_mode(ScanMode::Auto);
// smoothing_factor just got reset to 0

I tried removing the jpeg_set_defaults() call and tests still pass. Is there some mozjpeg-specific reason it needs to be there, or was this maybe copied from set_fastest_defaults() where it might make more sense?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions