summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/jpegli/decode_api_test.cc')
-rw-r--r--third_party/jpeg-xl/lib/jpegli/decode_api_test.cc35
1 files changed, 20 insertions, 15 deletions
diff --git a/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc b/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc
index c48b9377c3..0cc5a194d7 100644
--- a/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc
+++ b/third_party/jpeg-xl/lib/jpegli/decode_api_test.cc
@@ -18,8 +18,8 @@
namespace jpegli {
namespace {
-static constexpr uint8_t kFakeEoiMarker[2] = {0xff, 0xd9};
-static constexpr size_t kNumSourceBuffers = 4;
+constexpr uint8_t kFakeEoiMarker[2] = {0xff, 0xd9};
+constexpr size_t kNumSourceBuffers = 4;
// Custom source manager that refills the input buffer in chunks, simulating
// a file reader with a fixed buffer size.
@@ -61,7 +61,7 @@ class SourceManager {
static void init_source(j_decompress_ptr cinfo) {}
static boolean fill_input_buffer(j_decompress_ptr cinfo) {
- auto src = reinterpret_cast<SourceManager*>(cinfo->src);
+ auto* src = reinterpret_cast<SourceManager*>(cinfo->src);
if (src->pos_ < src->len_) {
size_t chunk_size = std::min(src->len_ - src->pos_, src->max_chunk_size_);
size_t next_idx = ++src->chunk_idx_ % kNumSourceBuffers;
@@ -79,7 +79,7 @@ class SourceManager {
}
static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) {
- auto src = reinterpret_cast<SourceManager*>(cinfo->src);
+ auto* src = reinterpret_cast<SourceManager*>(cinfo->src);
if (num_bytes <= 0) {
return;
}
@@ -166,9 +166,9 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo,
rowdata[c][i] =
y0 + i < ysize ? &output->raw_data[c][(y0 + i) * xsize] : nullptr;
}
- data[c] = &rowdata[c][0];
+ data[c] = rowdata[c].data();
}
- num_output_lines = jpegli_read_raw_data(cinfo, &data[0], max_lines);
+ num_output_lines = jpegli_read_raw_data(cinfo, data.data(), max_lines);
} else {
size_t max_output_lines = dparams.max_output_lines;
if (max_output_lines == 0) max_output_lines = cinfo->output_height;
@@ -189,7 +189,7 @@ void ReadOutputImage(const DecompressParams& dparams, j_decompress_ptr cinfo,
scanlines[i] = &output->pixels[yidx * stride];
}
num_output_lines =
- jpegli_read_scanlines(cinfo, &scanlines[0], max_lines);
+ jpegli_read_scanlines(cinfo, scanlines.data(), max_lines);
if (cinfo->quantize_colors) {
for (size_t i = 0; i < num_output_lines; ++i) {
UnmapColors(scanlines[i], cinfo->output_width,
@@ -222,7 +222,7 @@ struct TestConfig {
std::vector<uint8_t> GetTestJpegData(TestConfig& config) {
std::vector<uint8_t> compressed;
if (!config.fn.empty()) {
- compressed = ReadTestData(config.fn.c_str());
+ compressed = ReadTestData(config.fn);
} else {
GeneratePixels(&config.input);
JXL_CHECK(EncodeWithJpegli(config.input, config.jparams, &compressed));
@@ -297,10 +297,10 @@ void TestAPIBuffered(const CompressParams& jparams,
SetDecompressParams(dparams, cinfo);
jpegli_set_output_format(cinfo, dparams.data_type, dparams.endianness);
VerifyHeader(jparams, cinfo);
+ bool has_multiple_scans = FROM_JXL_BOOL(jpegli_has_multiple_scans(cinfo));
EXPECT_TRUE(jpegli_start_decompress(cinfo));
// start decompress should not read the whole input in buffered image mode
EXPECT_FALSE(jpegli_input_complete(cinfo));
- bool has_multiple_scans = jpegli_has_multiple_scans(cinfo);
EXPECT_EQ(0, cinfo->output_scan_number);
int sos_marker_cnt = 1; // read_header reads the first SOS marker
while (!jpegli_input_complete(cinfo)) {
@@ -341,8 +341,11 @@ void TestAPIBuffered(const CompressParams& jparams,
}
TEST(DecodeAPITest, ReuseCinfo) {
- TestImage input, output, expected;
- std::vector<TestImage> output_progression, expected_output_progression;
+ TestImage input;
+ TestImage output;
+ TestImage expected;
+ std::vector<TestImage> output_progression;
+ std::vector<TestImage> expected_output_progression;
CompressParams jparams;
DecompressParams dparams;
std::vector<uint8_t> compressed;
@@ -383,8 +386,8 @@ TEST(DecodeAPITest, ReuseCinfo) {
expected.Clear();
DecodeWithLibjpeg(jparams, dparams, compressed, &expected);
output.Clear();
- cinfo.buffered_image = false;
- cinfo.raw_data_out = false;
+ cinfo.buffered_image = JXL_FALSE;
+ cinfo.raw_data_out = JXL_FALSE;
cinfo.scale_num = cinfo.scale_denom = 1;
SourceManager src(compressed.data(), compressed.size(),
1u << 12);
@@ -1245,7 +1248,8 @@ std::ostream& operator<<(std::ostream& os, const DecompressParams& dparams) {
}
os << IOMethodName(dparams.data_type, dparams.endianness);
if (dparams.set_out_color_space) {
- os << "OutColor" << ColorSpaceName((J_COLOR_SPACE)dparams.out_color_space);
+ os << "OutColor"
+ << ColorSpaceName(static_cast<J_COLOR_SPACE>(dparams.out_color_space));
}
if (dparams.crop_output) {
os << "Crop";
@@ -1265,7 +1269,8 @@ std::ostream& operator<<(std::ostream& os, const DecompressParams& dparams) {
if (i > 0) os << "_";
const auto& sparam = dparams.scan_params[i];
os << QuantMode(sparam.color_quant_mode);
- os << DitherMode((J_DITHER_MODE)sparam.dither_mode) << "Dither";
+ os << DitherMode(static_cast<J_DITHER_MODE>(sparam.dither_mode))
+ << "Dither";
}
}
if (dparams.skip_scans) {