114 lines
3.1 KiB
TypeScript
114 lines
3.1 KiB
TypeScript
// Metro module 4756 (f4757).
|
|
import { CompressionQuality } from "../../Constants";
|
|
let c2909_1, c2909_2;
|
|
const getAdaptiveImageCompressionQuality = function getAdaptiveImageCompressionQuality(a0, a1) {
|
|
let r17;
|
|
if (a1.useAdaptiveCompression) {
|
|
if (a0.width != null && a0.height != null) {
|
|
const r12 = a0.width * a0.height;
|
|
if (r12 <= c2909_1.SMALL) {
|
|
let veryHighQuality = a1.veryHighQuality;
|
|
if (veryHighQuality == null) {
|
|
veryHighQuality = CompressionQuality.HIGH;
|
|
}
|
|
r17 = veryHighQuality;
|
|
} else if (r12 <= c2909_1.MEDIUM) {
|
|
let highQuality = a1.highQuality;
|
|
if (highQuality == null) {
|
|
highQuality = CompressionQuality.HIGH;
|
|
}
|
|
r17 = highQuality;
|
|
} else if (r12 <= c2909_1.LARGE) {
|
|
let mediumQuality = a1.mediumQuality;
|
|
if (mediumQuality == null) {
|
|
mediumQuality = CompressionQuality.HIGH;
|
|
}
|
|
r17 = mediumQuality;
|
|
} else if (r12 <= c2909_1.VERY_LARGE) {
|
|
let lowQuality = a1.lowQuality;
|
|
if (lowQuality == null) {
|
|
lowQuality = CompressionQuality.HIGH;
|
|
}
|
|
r17 = lowQuality;
|
|
} else {
|
|
r17 = a1.veryLowQuality;
|
|
if (r17 == null) {
|
|
r17 = CompressionQuality.HIGH;
|
|
}
|
|
}
|
|
return r17;
|
|
}
|
|
return CompressionQuality.HIGH;
|
|
}
|
|
return CompressionQuality.HIGH;
|
|
};
|
|
c2909_1 = {
|
|
SMALL: 921600,
|
|
MEDIUM: 2073600,
|
|
LARGE: 3686400,
|
|
VERY_LARGE: 8294400
|
|
};
|
|
c2909_2 = {
|
|
useAdaptiveCompression: true,
|
|
veryHighQuality: 0.8,
|
|
highQuality: 0.7,
|
|
mediumQuality: 0.6,
|
|
lowQuality: 0.5,
|
|
veryLowQuality: 0.4,
|
|
useOriginalIfSmaller: true
|
|
};
|
|
class ImageEncodingLadder {
|
|
constructor() {
|
|
return {
|
|
__proto__: new.target.prototype
|
|
};
|
|
}
|
|
static selectEncodingConfig(a0) {
|
|
let r21;
|
|
const r4 = ImageEncodingLadder.clampDimensions(a0.width, a0.height, 3840, 2160);
|
|
const { targetWidth, targetHeight } = r4;
|
|
if (a0.width === targetWidth && a0.height === targetHeight) {
|
|
r21 = {
|
|
compressionQuality: 100 * getAdaptiveImageCompressionQuality({
|
|
width: targetWidth,
|
|
height: targetHeight
|
|
}, c2909_2),
|
|
targetWidth,
|
|
targetHeight
|
|
};
|
|
} else {
|
|
let lowQuality = c2909_2.lowQuality;
|
|
if (lowQuality == null) {
|
|
lowQuality = 0.5;
|
|
}
|
|
r21 = {
|
|
compressionQuality: 100 * lowQuality,
|
|
targetWidth,
|
|
targetHeight
|
|
};
|
|
}
|
|
return r21;
|
|
}
|
|
static clampDimensions(a0, a1, a2, a3) {
|
|
const r9 = Math.max(a0, a1);
|
|
const r8 = Math.min(a0, a1);
|
|
const r15 = Math.max(a2, a3);
|
|
const r17 = Math.min(a2, a3);
|
|
if (r9 <= r15 && r8 <= r17) {
|
|
return {
|
|
targetWidth: a0,
|
|
targetHeight: a1
|
|
};
|
|
}
|
|
const r22 = Math.min(r15 / r9, r17 / r8);
|
|
return {
|
|
targetWidth: Math.max(1, Math.round(a0 * r22)),
|
|
targetHeight: Math.max(1, Math.round(a1 * r22))
|
|
};
|
|
}
|
|
}
|
|
export { c2909_1 as IMAGE_COMPRESSION_THRESHOLDS };
|
|
export { c2909_2 as ADAPTIVE_COMPRESSION_CONFIG };
|
|
export { getAdaptiveImageCompressionQuality };
|
|
export { ImageEncodingLadder };
|