mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-15 01:59:57 +00:00
Rename variables for readability
Changes `cqlevel` to `quality`, and `cqAlphaLevel` to `qualityAlpha`
This commit is contained in:
@@ -16,9 +16,9 @@ struct AvifOptions {
|
|||||||
// [0 - 100]
|
// [0 - 100]
|
||||||
// 0 = worst quality
|
// 0 = worst quality
|
||||||
// 100 = lossless
|
// 100 = lossless
|
||||||
int cqLevel;
|
int quality;
|
||||||
// As above, but -1 means 'use cqLevel'
|
// As above, but -1 means 'use quality'
|
||||||
int cqAlphaLevel;
|
int qualityAlpha;
|
||||||
// [0 - 6]
|
// [0 - 6]
|
||||||
// Creates 2^n tiles in that dimension
|
// Creates 2^n tiles in that dimension
|
||||||
int tileRowsLog2;
|
int tileRowsLog2;
|
||||||
@@ -67,8 +67,8 @@ val encode(std::string buffer, int width, int height, AvifOptions options) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lossless = options.cqLevel == AVIF_QUANTIZER_LOSSLESS &&
|
bool lossless = options.quality == AVIF_QUANTIZER_LOSSLESS &&
|
||||||
options.cqAlphaLevel <= AVIF_QUANTIZER_LOSSLESS &&
|
options.qualityAlpha <= AVIF_QUANTIZER_LOSSLESS &&
|
||||||
format == AVIF_PIXEL_FORMAT_YUV444;
|
format == AVIF_PIXEL_FORMAT_YUV444;
|
||||||
|
|
||||||
avifImage* image = avifImageCreate(width, height, depth, format);
|
avifImage* image = avifImageCreate(width, height, depth, format);
|
||||||
@@ -100,12 +100,12 @@ val encode(std::string buffer, int width, int height, AvifOptions options) {
|
|||||||
std::to_string(options.sharpness).c_str());
|
std::to_string(options.sharpness).c_str());
|
||||||
RETURN_NULL_IF_NOT_EQUALS(status, AVIF_RESULT_OK);
|
RETURN_NULL_IF_NOT_EQUALS(status, AVIF_RESULT_OK);
|
||||||
|
|
||||||
encoder->quality = options.cqLevel;
|
encoder->quality = options.quality;
|
||||||
if (options.cqAlphaLevel != -1) {
|
if (options.qualityAlpha != -1) {
|
||||||
encoder->qualityAlpha = options.cqAlphaLevel;
|
encoder->qualityAlpha = options.qualityAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.tune == 2 || (options.tune == 0 && options.cqLevel <= 32)) {
|
if (options.tune == 2 || (options.tune == 0 && options.quality <= 32)) {
|
||||||
status = avifEncoderSetCodecSpecificOption(encoder, "tune", "ssim");
|
status = avifEncoderSetCodecSpecificOption(encoder, "tune", "ssim");
|
||||||
RETURN_NULL_IF_NOT_EQUALS(status, AVIF_RESULT_OK);
|
RETURN_NULL_IF_NOT_EQUALS(status, AVIF_RESULT_OK);
|
||||||
}
|
}
|
||||||
@@ -139,8 +139,8 @@ val encode(std::string buffer, int width, int height, AvifOptions options) {
|
|||||||
|
|
||||||
EMSCRIPTEN_BINDINGS(my_module) {
|
EMSCRIPTEN_BINDINGS(my_module) {
|
||||||
value_object<AvifOptions>("AvifOptions")
|
value_object<AvifOptions>("AvifOptions")
|
||||||
.field("cqLevel", &AvifOptions::cqLevel)
|
.field("quality", &AvifOptions::quality)
|
||||||
.field("cqAlphaLevel", &AvifOptions::cqAlphaLevel)
|
.field("qualityAlpha", &AvifOptions::qualityAlpha)
|
||||||
.field("tileRowsLog2", &AvifOptions::tileRowsLog2)
|
.field("tileRowsLog2", &AvifOptions::tileRowsLog2)
|
||||||
.field("tileColsLog2", &AvifOptions::tileColsLog2)
|
.field("tileColsLog2", &AvifOptions::tileColsLog2)
|
||||||
.field("speed", &AvifOptions::speed)
|
.field("speed", &AvifOptions::speed)
|
||||||
|
|||||||
4
codecs/avif/enc/avif_enc.d.ts
vendored
4
codecs/avif/enc/avif_enc.d.ts
vendored
@@ -5,9 +5,9 @@ export const enum AVIFTune {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface EncodeOptions {
|
export interface EncodeOptions {
|
||||||
cqLevel: number;
|
quality: number;
|
||||||
|
qualityAlpha: number;
|
||||||
denoiseLevel: number;
|
denoiseLevel: number;
|
||||||
cqAlphaLevel: number;
|
|
||||||
tileRowsLog2: number;
|
tileRowsLog2: number;
|
||||||
tileColsLog2: number;
|
tileColsLog2: number;
|
||||||
speed: number;
|
speed: number;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -63,23 +63,23 @@ export class Options extends Component<Props, State> {
|
|||||||
const { options } = props;
|
const { options } = props;
|
||||||
|
|
||||||
const lossless =
|
const lossless =
|
||||||
options.cqLevel === 0 &&
|
options.quality === 0 &&
|
||||||
options.cqAlphaLevel <= 0 &&
|
options.qualityAlpha <= 0 &&
|
||||||
options.subsample == 3;
|
options.subsample == 3;
|
||||||
|
|
||||||
const separateAlpha = options.cqAlphaLevel !== -1;
|
const separateAlpha = options.qualityAlpha !== -1;
|
||||||
|
|
||||||
const cqLevel = lossless ? defaultOptions.cqLevel : options.cqLevel;
|
const quality = lossless ? defaultOptions.quality : options.quality;
|
||||||
|
|
||||||
// Create default form state from options
|
// Create default form state from options
|
||||||
return {
|
return {
|
||||||
options,
|
options,
|
||||||
lossless,
|
lossless,
|
||||||
quality: cqLevel,
|
quality: quality,
|
||||||
separateAlpha,
|
separateAlpha,
|
||||||
alphaQuality: separateAlpha
|
alphaQuality: separateAlpha
|
||||||
? options.cqAlphaLevel
|
? options.qualityAlpha
|
||||||
: defaultOptions.cqLevel,
|
: defaultOptions.quality,
|
||||||
subsample:
|
subsample:
|
||||||
options.subsample === 0 || lossless
|
options.subsample === 0 || lossless
|
||||||
? defaultOptions.subsample
|
? defaultOptions.subsample
|
||||||
@@ -128,8 +128,8 @@ export class Options extends Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const newOptions: EncodeOptions = {
|
const newOptions: EncodeOptions = {
|
||||||
cqLevel: optionState.lossless ? MAX_QUALITY : optionState.quality,
|
quality: optionState.lossless ? MAX_QUALITY : optionState.quality,
|
||||||
cqAlphaLevel:
|
qualityAlpha:
|
||||||
optionState.lossless || !optionState.separateAlpha
|
optionState.lossless || !optionState.separateAlpha
|
||||||
? -1 // default AVIF alphaLevel
|
? -1 // default AVIF alphaLevel
|
||||||
: optionState.alphaQuality,
|
: optionState.alphaQuality,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export const label = 'AVIF';
|
|||||||
export const mimeType = 'image/avif';
|
export const mimeType = 'image/avif';
|
||||||
export const extension = 'avif';
|
export const extension = 'avif';
|
||||||
export const defaultOptions: EncodeOptions = {
|
export const defaultOptions: EncodeOptions = {
|
||||||
cqLevel: 50,
|
quality: 50,
|
||||||
cqAlphaLevel: -1,
|
qualityAlpha: -1,
|
||||||
denoiseLevel: 0,
|
denoiseLevel: 0,
|
||||||
tileColsLog2: 0,
|
tileColsLog2: 0,
|
||||||
tileRowsLog2: 0,
|
tileRowsLog2: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user