summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/enc_group.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/enc_group.cc')
-rw-r--r--third_party/jpeg-xl/lib/jxl/enc_group.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/enc_group.cc b/third_party/jpeg-xl/lib/jxl/enc_group.cc
index 09bab534c9..1967fdaba9 100644
--- a/third_party/jpeg-xl/lib/jxl/enc_group.cc
+++ b/third_party/jpeg-xl/lib/jxl/enc_group.cc
@@ -286,10 +286,11 @@ void AdjustQuantBlockAC(const Quantizer& quantizer, size_t c,
{
// Reduce quant in highly active areas.
int32_t div = (xsize * ysize);
- int32_t activity = (hfNonZeros[0] + div / 2) / div;
+ int32_t activity = (static_cast<int32_t>(hfNonZeros[0]) + div / 2) / div;
int32_t orig_qp_limit = std::max(4, *quant / 2);
for (int i = 1; i < 4; ++i) {
- activity = std::min<int32_t>(activity, (hfNonZeros[i] + div / 2) / div);
+ activity = std::min(
+ activity, (static_cast<int32_t>(hfNonZeros[i]) + div / 2) / div);
}
if (activity >= 15) {
activity = 15;
@@ -316,7 +317,7 @@ void QuantizeRoundtripYBlockAC(PassesEncoderState* enc_state, const size_t size,
float* JXL_RESTRICT inout,
int32_t* JXL_RESTRICT quantized) {
float thres_y[4] = {0.58f, 0.64f, 0.64f, 0.64f};
- {
+ if (enc_state->cparams.speed_tier <= SpeedTier::kHare) {
int32_t max_quant = 0;
int quant_orig = *quant;
float val[3] = {enc_state->x_qm_multiplier, 1.0f,
@@ -337,6 +338,11 @@ void QuantizeRoundtripYBlockAC(PassesEncoderState* enc_state, const size_t size,
max_quant = std::max(*quant, max_quant);
}
*quant = max_quant;
+ } else {
+ thres_y[0] = 0.56;
+ thres_y[1] = 0.62;
+ thres_y[2] = 0.62;
+ thres_y[3] = 0.62;
}
QuantizeBlockAC(quantizer, error_diffusion, 1, 1.0f, quant_kind, xsize, ysize,
@@ -507,8 +513,8 @@ namespace jxl {
HWY_EXPORT(ComputeCoefficients);
void ComputeCoefficients(size_t group_idx, PassesEncoderState* enc_state,
const Image3F& opsin, const Rect& rect, Image3F* dc) {
- return HWY_DYNAMIC_DISPATCH(ComputeCoefficients)(group_idx, enc_state, opsin,
- rect, dc);
+ HWY_DYNAMIC_DISPATCH(ComputeCoefficients)
+ (group_idx, enc_state, opsin, rect, dc);
}
Status EncodeGroupTokenizedCoefficients(size_t group_idx, size_t pass_idx,