summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jpegli/test_utils-inl.h')
-rw-r--r--third_party/jpeg-xl/lib/jpegli/test_utils-inl.h40
1 files changed, 21 insertions, 19 deletions
diff --git a/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h b/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h
index a454917187..4fbcb721e4 100644
--- a/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h
+++ b/third_party/jpeg-xl/lib/jpegli/test_utils-inl.h
@@ -8,20 +8,20 @@
// include paths for the jpeg headers.
// Sequential non-interleaved.
-static constexpr jpeg_scan_info kScript1[] = {
+constexpr jpeg_scan_info kScript1[] = {
{1, {0}, 0, 63, 0, 0},
{1, {1}, 0, 63, 0, 0},
{1, {2}, 0, 63, 0, 0},
};
// Sequential partially interleaved, chroma first.
-static constexpr jpeg_scan_info kScript2[] = {
+constexpr jpeg_scan_info kScript2[] = {
{2, {1, 2}, 0, 63, 0, 0},
{1, {0}, 0, 63, 0, 0},
};
// Rest of the scan scripts are progressive.
-static constexpr jpeg_scan_info kScript3[] = {
+constexpr jpeg_scan_info kScript3[] = {
// Interleaved full DC.
{3, {0, 1, 2}, 0, 0, 0, 0},
// Full AC scans.
@@ -29,7 +29,7 @@ static constexpr jpeg_scan_info kScript3[] = {
{1, {1}, 1, 63, 0, 0},
{1, {2}, 1, 63, 0, 0},
};
-static constexpr jpeg_scan_info kScript4[] = {
+constexpr jpeg_scan_info kScript4[] = {
// Non-interleaved full DC.
{1, {0}, 0, 0, 0, 0},
{1, {1}, 0, 0, 0, 0},
@@ -39,7 +39,7 @@ static constexpr jpeg_scan_info kScript4[] = {
{1, {1}, 1, 63, 0, 0},
{1, {2}, 1, 63, 0, 0},
};
-static constexpr jpeg_scan_info kScript5[] = {
+constexpr jpeg_scan_info kScript5[] = {
// Partially interleaved full DC, chroma first.
{2, {1, 2}, 0, 0, 0, 0},
{1, {0}, 0, 0, 0, 0},
@@ -52,7 +52,7 @@ static constexpr jpeg_scan_info kScript5[] = {
{1, {1}, 1, 63, 1, 0},
{1, {2}, 1, 63, 1, 0},
};
-static constexpr jpeg_scan_info kScript6[] = {
+constexpr jpeg_scan_info kScript6[] = {
// Interleaved DC shifted by 2 bits.
{3, {0, 1, 2}, 0, 0, 0, 2},
// Interleaved DC refinement scans.
@@ -64,7 +64,7 @@ static constexpr jpeg_scan_info kScript6[] = {
{1, {2}, 1, 63, 0, 0},
};
-static constexpr jpeg_scan_info kScript7[] = {
+constexpr jpeg_scan_info kScript7[] = {
// Non-interleaved DC shifted by 2 bits.
{1, {0}, 0, 0, 0, 2},
{1, {1}, 0, 0, 0, 2},
@@ -83,7 +83,7 @@ static constexpr jpeg_scan_info kScript7[] = {
{1, {2}, 1, 63, 0, 0},
};
-static constexpr jpeg_scan_info kScript8[] = {
+constexpr jpeg_scan_info kScript8[] = {
// Partially interleaved DC shifted by 2 bits, chroma first
{2, {1, 2}, 0, 0, 0, 2},
{1, {0}, 0, 0, 0, 2},
@@ -99,7 +99,7 @@ static constexpr jpeg_scan_info kScript8[] = {
{1, {2}, 1, 63, 0, 0},
};
-static constexpr jpeg_scan_info kScript9[] = {
+constexpr jpeg_scan_info kScript9[] = {
// Interleaved full DC.
{3, {0, 1, 2}, 0, 0, 0, 0},
// AC scans for component 0
@@ -123,7 +123,7 @@ static constexpr jpeg_scan_info kScript9[] = {
{1, {2}, 17, 63, 1, 0},
};
-static constexpr jpeg_scan_info kScript10[] = {
+constexpr jpeg_scan_info kScript10[] = {
// Interleaved full DC.
{3, {0, 1, 2}, 0, 0, 0, 0},
// AC scans for spectral range 1..16
@@ -156,14 +156,14 @@ struct ScanScript {
const jpeg_scan_info* scans;
};
-static constexpr ScanScript kTestScript[] = {
+constexpr ScanScript kTestScript[] = {
{ARRAY_SIZE(kScript1), kScript1}, {ARRAY_SIZE(kScript2), kScript2},
{ARRAY_SIZE(kScript3), kScript3}, {ARRAY_SIZE(kScript4), kScript4},
{ARRAY_SIZE(kScript5), kScript5}, {ARRAY_SIZE(kScript6), kScript6},
{ARRAY_SIZE(kScript7), kScript7}, {ARRAY_SIZE(kScript8), kScript8},
{ARRAY_SIZE(kScript9), kScript9}, {ARRAY_SIZE(kScript10), kScript10},
};
-static constexpr int kNumTestScripts = ARRAY_SIZE(kTestScript);
+constexpr int kNumTestScripts = ARRAY_SIZE(kTestScript);
void SetScanDecompressParams(const DecompressParams& dparams,
j_decompress_ptr cinfo, int scan_number) {
@@ -178,7 +178,7 @@ void SetScanDecompressParams(const DecompressParams& dparams,
return;
}
if (dparams.quantize_colors) {
- cinfo->dither_mode = (J_DITHER_MODE)sparams->dither_mode;
+ cinfo->dither_mode = static_cast<J_DITHER_MODE>(sparams->dither_mode);
if (sparams->color_quant_mode == CQUANT_1PASS) {
cinfo->two_pass_quantize = FALSE;
cinfo->colormap = nullptr;
@@ -194,7 +194,8 @@ void SetScanDecompressParams(const DecompressParams& dparams,
cinfo->colormap = (*cinfo->mem->alloc_sarray)(
reinterpret_cast<j_common_ptr>(cinfo), JPOOL_IMAGE,
cinfo->actual_number_of_colors, 3);
- jxl::msan::UnpoisonMemory(cinfo->colormap, 3 * sizeof(JSAMPROW));
+ jxl::msan::UnpoisonMemory(reinterpret_cast<void*>(cinfo->colormap),
+ 3 * sizeof(JSAMPLE*));
for (int i = 0; i < kTestColorMapNumColors; ++i) {
cinfo->colormap[0][i] = (kTestColorMap[i] >> 16) & 0xff;
cinfo->colormap[1][i] = (kTestColorMap[i] >> 8) & 0xff;
@@ -212,20 +213,21 @@ void SetScanDecompressParams(const DecompressParams& dparams,
void SetDecompressParams(const DecompressParams& dparams,
j_decompress_ptr cinfo) {
- cinfo->do_block_smoothing = dparams.do_block_smoothing;
- cinfo->do_fancy_upsampling = dparams.do_fancy_upsampling;
+ cinfo->do_block_smoothing = dparams.do_block_smoothing ? 1 : 0;
+ cinfo->do_fancy_upsampling = dparams.do_fancy_upsampling ? 1 : 0;
if (dparams.output_mode == RAW_DATA) {
cinfo->raw_data_out = TRUE;
}
if (dparams.set_out_color_space) {
- cinfo->out_color_space = (J_COLOR_SPACE)dparams.out_color_space;
+ cinfo->out_color_space =
+ static_cast<J_COLOR_SPACE>(dparams.out_color_space);
if (dparams.out_color_space == JCS_UNKNOWN) {
cinfo->jpeg_color_space = JCS_UNKNOWN;
}
}
cinfo->scale_num = dparams.scale_num;
cinfo->scale_denom = dparams.scale_denom;
- cinfo->quantize_colors = dparams.quantize_colors;
+ cinfo->quantize_colors = dparams.quantize_colors ? 1 : 0;
cinfo->desired_number_of_colors = dparams.desired_number_of_colors;
if (!dparams.scan_params.empty()) {
if (cinfo->buffered_image) {
@@ -420,7 +422,7 @@ void CopyCoefficients(j_decompress_ptr cinfo, jvirt_barray_ptr* coef_arrays,
DCTSIZE2);
for (size_t by = 0; by < comp->height_in_blocks; ++by) {
JBLOCKARRAY ba = (*cinfo->mem->access_virt_barray)(comptr, coef_arrays[c],
- by, 1, true);
+ by, 1, TRUE);
size_t stride = comp->width_in_blocks * sizeof(JBLOCK);
size_t offset = by * comp->width_in_blocks * DCTSIZE2;
memcpy(&coeffs[offset], ba[0], stride);