mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
Simplifying chroma subsample
This commit is contained in:
@@ -39,6 +39,9 @@ struct MozJpegOptions {
|
||||
bool trellis_opt_zero;
|
||||
bool trellis_opt_table;
|
||||
int trellis_loops;
|
||||
bool auto_subsample;
|
||||
int chroma_subsample;
|
||||
bool separate_chroma_quality;
|
||||
int chroma_quality;
|
||||
};
|
||||
```
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
trellis_opt_zero: false,
|
||||
trellis_opt_table: false,
|
||||
trellis_loops: 1,
|
||||
chroma_subsample: 0,
|
||||
auto_subsample: true,
|
||||
chroma_subsample: 2,
|
||||
separate_chroma_quality: false,
|
||||
chroma_quality: 75,
|
||||
});
|
||||
|
||||
@@ -29,6 +29,7 @@ struct MozJpegOptions {
|
||||
bool trellis_opt_zero;
|
||||
bool trellis_opt_table;
|
||||
int trellis_loops;
|
||||
bool auto_subsample;
|
||||
int chroma_subsample;
|
||||
bool separate_chroma_quality;
|
||||
int chroma_quality;
|
||||
@@ -152,7 +153,7 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
|
||||
set_quality_ratings(&cinfo, (char*) pqual, opts.baseline);
|
||||
|
||||
if (opts.chroma_subsample && opts.color_space == JCS_YCbCr) {
|
||||
if (!opts.auto_subsample && opts.color_space == JCS_YCbCr) {
|
||||
cinfo.comp_info[0].h_samp_factor = opts.chroma_subsample;
|
||||
cinfo.comp_info[0].v_samp_factor = opts.chroma_subsample;
|
||||
}
|
||||
@@ -220,6 +221,7 @@ EMSCRIPTEN_BINDINGS(my_module) {
|
||||
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
|
||||
.field("trellis_loops", &MozJpegOptions::trellis_loops)
|
||||
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
|
||||
.field("auto_subsample", &MozJpegOptions::auto_subsample)
|
||||
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
|
||||
.field("chroma_quality", &MozJpegOptions::chroma_quality)
|
||||
;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -17,6 +17,7 @@ export interface EncodeOptions {
|
||||
trellis_opt_zero: boolean;
|
||||
trellis_opt_table: boolean;
|
||||
trellis_loops: number;
|
||||
auto_subsample: boolean;
|
||||
chroma_subsample: number;
|
||||
separate_chroma_quality: boolean;
|
||||
chroma_quality: number;
|
||||
@@ -41,7 +42,8 @@ export const defaultOptions: EncodeOptions = {
|
||||
trellis_opt_zero: false,
|
||||
trellis_opt_table: false,
|
||||
trellis_loops: 1,
|
||||
chroma_subsample: 0,
|
||||
auto_subsample: true,
|
||||
chroma_subsample: 2,
|
||||
separate_chroma_quality: false,
|
||||
chroma_quality: 75,
|
||||
};
|
||||
|
||||
@@ -39,19 +39,17 @@ export default class MozJPEGEncoderOptions extends Component<Props, State> {
|
||||
trellis_multipass: inputFieldChecked(form.trellis_multipass, options.trellis_multipass),
|
||||
trellis_opt_zero: inputFieldChecked(form.trellis_opt_zero, options.trellis_opt_zero),
|
||||
trellis_opt_table: inputFieldChecked(form.trellis_opt_table, options.trellis_opt_table),
|
||||
auto_subsample: inputFieldChecked(form.auto_subsample, options.auto_subsample),
|
||||
separate_chroma_quality:
|
||||
inputFieldChecked(form.separate_chroma_quality, options.separate_chroma_quality),
|
||||
// .value
|
||||
quality: inputFieldValueAsNumber(form.quality, options.quality),
|
||||
chroma_quality: inputFieldValueAsNumber(form.chroma_quality, options.chroma_quality),
|
||||
chroma_subsample: inputFieldValueAsNumber(form.chroma_subsample, options.chroma_subsample),
|
||||
smoothing: inputFieldValueAsNumber(form.smoothing, options.smoothing),
|
||||
color_space: inputFieldValueAsNumber(form.color_space, options.color_space),
|
||||
quant_table: inputFieldValueAsNumber(form.quant_table, options.quant_table),
|
||||
trellis_loops: inputFieldValueAsNumber(form.trellis_loops, options.trellis_loops),
|
||||
// Other:
|
||||
chroma_subsample: (!form.auto_chroma_subsample) ? options.chroma_subsample :
|
||||
form.auto_chroma_subsample.checked ? 0 :
|
||||
inputFieldValueAsNumber(form.chroma_subsample, 2),
|
||||
};
|
||||
this.props.onChange(newOptions);
|
||||
}
|
||||
@@ -99,14 +97,14 @@ export default class MozJPEGEncoderOptions extends Component<Props, State> {
|
||||
<div>
|
||||
<label class={style.optionInputFirst}>
|
||||
<Checkbox
|
||||
name="auto_chroma_subsample"
|
||||
checked={options.chroma_subsample === 0}
|
||||
name="auto_subsample"
|
||||
checked={options.auto_subsample}
|
||||
onChange={this.onChange}
|
||||
/>
|
||||
Auto subsample chroma
|
||||
</label>
|
||||
<Expander>
|
||||
{options.chroma_subsample !== 0 ?
|
||||
{options.auto_subsample ? null :
|
||||
<div class={style.optionOneCell}>
|
||||
<Range
|
||||
name="chroma_subsample"
|
||||
@@ -118,7 +116,6 @@ export default class MozJPEGEncoderOptions extends Component<Props, State> {
|
||||
Subsample chroma by:
|
||||
</Range>
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
</Expander>
|
||||
<label class={style.optionInputFirst}>
|
||||
|
||||
Reference in New Issue
Block a user