diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/jpeg-xl/lib/jpegli/render.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/jpegli/render.cc')
-rw-r--r-- | third_party/jpeg-xl/lib/jpegli/render.cc | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/third_party/jpeg-xl/lib/jpegli/render.cc b/third_party/jpeg-xl/lib/jpegli/render.cc index 24e7e99618..c550f9a575 100644 --- a/third_party/jpeg-xl/lib/jpegli/render.cc +++ b/third_party/jpeg-xl/lib/jpegli/render.cc @@ -8,7 +8,6 @@ #include <string.h> #include <array> -#include <atomic> #include <cmath> #include <cstddef> #include <cstdint> @@ -203,12 +202,13 @@ void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], if (cinfo->quantize_colors && m->quant_pass_ == 1) { float* error_row[kMaxComponents]; float* next_error_row[kMaxComponents]; - if (cinfo->dither_mode == JDITHER_ORDERED) { + J_DITHER_MODE dither_mode = cinfo->dither_mode; + if (dither_mode == JDITHER_ORDERED) { for (size_t c = 0; c < num_channels; ++c) { DitherRow(cinfo, &rows[c][xoffset], c, cinfo->output_scanline, cinfo->output_width); } - } else if (cinfo->dither_mode == JDITHER_FS) { + } else if (dither_mode == JDITHER_FS) { for (size_t c = 0; c < num_channels; ++c) { if (cinfo->output_scanline % 2 == 0) { error_row[c] = m->error_row_[c]; @@ -221,12 +221,12 @@ void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], } } const float mul = 255.0f; - if (cinfo->dither_mode != JDITHER_FS) { + if (dither_mode != JDITHER_FS) { StoreUnsignedRow(rows, xoffset, len, num_channels, mul, scratch_space); } for (size_t i = 0; i < len; ++i) { uint8_t* pixel = &scratch_space[num_channels * i]; - if (cinfo->dither_mode == JDITHER_FS) { + if (dither_mode == JDITHER_FS) { for (size_t c = 0; c < num_channels; ++c) { float val = rows[c][i] * mul + LimitError(error_row[c][i]); pixel[c] = std::round(std::min(255.0f, std::max(0.0f, val))); @@ -234,7 +234,7 @@ void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], } int index = LookupColorIndex(cinfo, pixel); output[i] = index; - if (cinfo->dither_mode == JDITHER_FS) { + if (dither_mode == JDITHER_FS) { size_t prev_i = i > 0 ? i - 1 : 0; size_t next_i = i + 1 < len ? i + 1 : len - 1; for (size_t c = 0; c < num_channels; ++c) { @@ -293,19 +293,18 @@ HWY_EXPORT(DecenterRow); void GatherBlockStats(const int16_t* JXL_RESTRICT coeffs, const size_t coeffs_size, int32_t* JXL_RESTRICT nonzeros, int32_t* JXL_RESTRICT sumabs) { - return HWY_DYNAMIC_DISPATCH(GatherBlockStats)(coeffs, coeffs_size, nonzeros, - sumabs); + HWY_DYNAMIC_DISPATCH(GatherBlockStats)(coeffs, coeffs_size, nonzeros, sumabs); } void WriteToOutput(j_decompress_ptr cinfo, float* JXL_RESTRICT rows[], size_t xoffset, size_t len, size_t num_channels, uint8_t* JXL_RESTRICT output) { - return HWY_DYNAMIC_DISPATCH(WriteToOutput)(cinfo, rows, xoffset, len, - num_channels, output); + HWY_DYNAMIC_DISPATCH(WriteToOutput) + (cinfo, rows, xoffset, len, num_channels, output); } void DecenterRow(float* row, size_t xsize) { - return HWY_DYNAMIC_DISPATCH(DecenterRow)(row, xsize); + HWY_DYNAMIC_DISPATCH(DecenterRow)(row, xsize); } bool ShouldApplyDequantBiases(j_decompress_ptr cinfo, int ci) { @@ -360,8 +359,8 @@ bool do_smoothing(j_decompress_ptr cinfo) { if (!cinfo->progressive_mode || cinfo->coef_bits == nullptr) { return false; } - auto coef_bits_latch = m->coef_bits_latch; - auto prev_coef_bits_latch = m->prev_coef_bits_latch; + auto* coef_bits_latch = m->coef_bits_latch; + auto* prev_coef_bits_latch = m->prev_coef_bits_latch; for (int ci = 0; ci < cinfo->num_components; ci++) { jpeg_component_info* compptr = &cinfo->comp_info[ci]; @@ -468,6 +467,7 @@ void PredictSmooth(j_decompress_ptr cinfo, JBLOCKARRAY blocks, int component, return swap_indices ? dc_values[j][i] : dc_values[i][j]; }; Al = coef_bits[coef_index]; + JXL_ASSERT(coef_index >= 0 && coef_index < 10); switch (coef_index) { case 0: // set the DC @@ -520,6 +520,7 @@ void PredictSmooth(j_decompress_ptr cinfo, JBLOCKARRAY blocks, int component, break; case 7: case 8: + default: // set Q12 and Q21 num = (dc(1, 1) - 3 * dc(1, 2) + dc(1, 3) - dc(3, 1) + 3 * dc(3, 2) - dc(3, 3)); @@ -551,7 +552,7 @@ void PredictSmooth(j_decompress_ptr cinfo, JBLOCKARRAY blocks, int component, void PrepareForOutput(j_decompress_ptr cinfo) { jpeg_decomp_master* m = cinfo->master; bool smoothing = do_smoothing(cinfo); - m->apply_smoothing = smoothing && cinfo->do_block_smoothing; + m->apply_smoothing = smoothing && FROM_JXL_BOOL(cinfo->do_block_smoothing); size_t coeffs_per_block = cinfo->num_components * DCTSIZE2; memset(m->nonzeros_, 0, coeffs_per_block * sizeof(m->nonzeros_[0])); memset(m->sumabs_, 0, coeffs_per_block * sizeof(m->sumabs_[0])); @@ -584,7 +585,7 @@ void DecodeCurrentiMCURow(j_decompress_ptr cinfo) { int offset = m->streaming_mode_ ? 0 : by0; ba[c] = (*cinfo->mem->access_virt_barray)( reinterpret_cast<j_common_ptr>(cinfo), m->coef_arrays[c], offset, - max_block_rows, false); + max_block_rows, FALSE); } for (int c = 0; c < cinfo->num_components; ++c) { size_t k0 = c * DCTSIZE2; |