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/encode.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/encode.cc')
-rw-r--r-- | third_party/jpeg-xl/lib/jpegli/encode.cc | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/third_party/jpeg-xl/lib/jpegli/encode.cc b/third_party/jpeg-xl/lib/jpegli/encode.cc index 8a106e239a..5326f2cb0f 100644 --- a/third_party/jpeg-xl/lib/jpegli/encode.cc +++ b/third_party/jpeg-xl/lib/jpegli/encode.cc @@ -5,6 +5,8 @@ #include "lib/jpegli/encode.h" +#include <jxl/types.h> + #include <cmath> #include <initializer_list> #include <vector> @@ -323,8 +325,8 @@ void ProcessCompressionParams(j_compress_ptr cinfo) { if (cinfo->scan_info == nullptr) { SetDefaultScanScript(cinfo); } - cinfo->progressive_mode = - cinfo->scan_info->Ss != 0 || cinfo->scan_info->Se != DCTSIZE2 - 1; + cinfo->progressive_mode = TO_JXL_BOOL(cinfo->scan_info->Ss != 0 || + cinfo->scan_info->Se != DCTSIZE2 - 1); ValidateScanScript(cinfo); m->scan_token_info = Allocate<ScanTokenInfo>(cinfo, cinfo->num_scans, JPOOL_IMAGE); @@ -449,7 +451,7 @@ void AllocateBuffers(j_compress_ptr cinfo) { const size_t ysize_blocks = comp->height_in_blocks; m->coeff_buffers[c] = (*cinfo->mem->request_virt_barray)( reinterpret_cast<j_common_ptr>(cinfo), JPOOL_IMAGE, - /*pre_zero=*/false, xsize_blocks, ysize_blocks, comp->v_samp_factor); + /*pre_zero=*/FALSE, xsize_blocks, ysize_blocks, comp->v_samp_factor); } } if (m->use_adaptive_quantization) { @@ -663,8 +665,8 @@ void jpegli_CreateCompress(j_compress_ptr cinfo, int version, cinfo->num_components = 0; cinfo->jpeg_color_space = JCS_UNKNOWN; cinfo->comp_info = nullptr; - for (int i = 0; i < NUM_QUANT_TBLS; ++i) { - cinfo->quant_tbl_ptrs[i] = nullptr; + for (auto& quant_tbl_ptr : cinfo->quant_tbl_ptrs) { + quant_tbl_ptr = nullptr; } for (int i = 0; i < NUM_HUFF_TBLS; ++i) { cinfo->dc_huff_tbl_ptrs[i] = nullptr; @@ -673,7 +675,7 @@ void jpegli_CreateCompress(j_compress_ptr cinfo, int version, memset(cinfo->arith_dc_L, 0, sizeof(cinfo->arith_dc_L)); memset(cinfo->arith_dc_U, 0, sizeof(cinfo->arith_dc_U)); memset(cinfo->arith_ac_K, 0, sizeof(cinfo->arith_ac_K)); - cinfo->write_Adobe_marker = false; + cinfo->write_Adobe_marker = FALSE; cinfo->master = jpegli::Allocate<jpeg_comp_master>(cinfo, 1); jpegli::InitializeCompressParams(cinfo); cinfo->master->force_baseline = true; @@ -763,7 +765,7 @@ void jpegli_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace) { JPEGLI_ERROR("Unsupported jpeg colorspace %d", colorspace); } // Adobe marker is only needed to distinguish CMYK and YCCK JPEGs. - cinfo->write_Adobe_marker = (cinfo->jpeg_color_space == JCS_YCCK); + cinfo->write_Adobe_marker = TO_JXL_BOOL(cinfo->jpeg_color_space == JCS_YCCK); if (cinfo->comp_info == nullptr) { cinfo->comp_info = jpegli::Allocate<jpeg_component_info>(cinfo, MAX_COMPONENTS); @@ -810,7 +812,7 @@ void jpegli_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace) { void jpegli_set_distance(j_compress_ptr cinfo, float distance, boolean force_baseline) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->force_baseline = force_baseline; + cinfo->master->force_baseline = FROM_JXL_BOOL(force_baseline); float distances[NUM_QUANT_TBLS] = {distance, distance, distance}; jpegli::SetQuantMatrices(cinfo, distances, /*add_two_chroma_tables=*/true); } @@ -834,7 +836,7 @@ void jpegli_set_psnr(j_compress_ptr cinfo, float psnr, float tolerance, void jpegli_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->force_baseline = force_baseline; + cinfo->master->force_baseline = FROM_JXL_BOOL(force_baseline); float distance = jpegli_quality_to_distance(quality); float distances[NUM_QUANT_TBLS] = {distance, distance, distance}; jpegli::SetQuantMatrices(cinfo, distances, /*add_two_chroma_tables=*/false); @@ -843,7 +845,7 @@ void jpegli_set_quality(j_compress_ptr cinfo, int quality, void jpegli_set_linear_quality(j_compress_ptr cinfo, int scale_factor, boolean force_baseline) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->force_baseline = force_baseline; + cinfo->master->force_baseline = FROM_JXL_BOOL(force_baseline); float distance = jpegli::LinearQualityToDistance(scale_factor); float distances[NUM_QUANT_TBLS] = {distance, distance, distance}; jpegli::SetQuantMatrices(cinfo, distances, /*add_two_chroma_tables=*/false); @@ -894,7 +896,7 @@ void jpegli_add_quant_table(j_compress_ptr cinfo, int which_tbl, void jpegli_enable_adaptive_quantization(j_compress_ptr cinfo, boolean value) { CheckState(cinfo, jpegli::kEncStart); - cinfo->master->use_adaptive_quantization = value; + cinfo->master->use_adaptive_quantization = FROM_JXL_BOOL(value); } void jpegli_simple_progression(j_compress_ptr cinfo) { @@ -955,7 +957,7 @@ void jpegli_copy_critical_parameters(j_decompress_ptr srcinfo, jpegli_set_colorspace(dstinfo, srcinfo->jpeg_color_space); if (dstinfo->num_components != srcinfo->num_components) { const auto& cinfo = dstinfo; - return JPEGLI_ERROR("Mismatch between src colorspace and components"); + JPEGLI_ERROR("Mismatch between src colorspace and components"); } dstinfo->data_precision = srcinfo->data_precision; dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; @@ -1005,7 +1007,7 @@ void jpegli_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr* coef_arrays) { CheckState(cinfo, jpegli::kEncStart); cinfo->global_state = jpegli::kEncWriteCoeffs; - jpegli::InitCompress(cinfo, /*write_all_tables=*/true); + jpegli::InitCompress(cinfo, /*write_all_tables=*/TRUE); cinfo->master->coeff_buffers = coef_arrays; cinfo->next_scanline = cinfo->image_height; cinfo->master->next_input_row = cinfo->image_height; @@ -1047,7 +1049,7 @@ void jpegli_write_m_header(j_compress_ptr cinfo, int marker, marker_data[1] = marker; marker_data[2] = (datalen + 2) >> 8; marker_data[3] = (datalen + 2) & 0xff; - jpegli::WriteOutput(cinfo, &marker_data[0], 4); + jpegli::WriteOutput(cinfo, marker_data.data(), 4); } void jpegli_write_m_byte(j_compress_ptr cinfo, int val) { @@ -1213,7 +1215,8 @@ void jpegli_finish_compress(j_compress_ptr cinfo) { } const bool tokens_done = jpegli::IsStreamingSupported(cinfo); - const bool bitstream_done = tokens_done && !cinfo->optimize_coding; + const bool bitstream_done = + tokens_done && !FROM_JXL_BOOL(cinfo->optimize_coding); if (!tokens_done) { jpegli::TokenizeJpeg(cinfo); |