diff options
Diffstat (limited to 'third_party/jpeg-xl/lib/jpegli/streaming_test.cc')
-rw-r--r-- | third_party/jpeg-xl/lib/jpegli/streaming_test.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/third_party/jpeg-xl/lib/jpegli/streaming_test.cc b/third_party/jpeg-xl/lib/jpegli/streaming_test.cc index 8d2e3577f3..2e6f7029b0 100644 --- a/third_party/jpeg-xl/lib/jpegli/streaming_test.cc +++ b/third_party/jpeg-xl/lib/jpegli/streaming_test.cc @@ -36,13 +36,13 @@ struct SourceManager { // input buffer. The buffer size is kept short because empty_output_buffer() is // called only when the output buffer is full, and we want to update the decoder // input frequently to demonstrate that streaming works. -static constexpr size_t kOutputBufferSize = 1024; +constexpr size_t kOutputBufferSize = 1024; struct DestinationManager { jpeg_destination_mgr pub; std::vector<uint8_t> buffer; SourceManager* dest; - DestinationManager(SourceManager* src) + explicit DestinationManager(SourceManager* src) : buffer(kOutputBufferSize), dest(src) { pub.next_output_byte = buffer.data(); pub.free_in_buffer = buffer.size(); @@ -54,7 +54,7 @@ struct DestinationManager { static void init_destination(j_compress_ptr cinfo) {} static boolean empty_output_buffer(j_compress_ptr cinfo) { - auto us = reinterpret_cast<DestinationManager*>(cinfo->dest); + auto* us = reinterpret_cast<DestinationManager*>(cinfo->dest); jpeg_destination_mgr* src = &us->pub; jpeg_source_mgr* dst = &us->dest->pub; std::vector<uint8_t>& src_buf = us->buffer; @@ -69,7 +69,7 @@ struct DestinationManager { dst->bytes_in_buffer = dst_buf.size(); src->next_output_byte = src_buf.data(); src->free_in_buffer = src_buf.size(); - return true; + return TRUE; } static void term_destination(j_compress_ptr cinfo) { @@ -87,6 +87,7 @@ class StreamingTestParam : public ::testing::TestWithParam<TestConfig> {}; TEST_P(StreamingTestParam, TestStreaming) { jpeg_decompress_struct dinfo = {}; jpeg_compress_struct cinfo = {}; + SourceManager src; TestConfig config = GetParam(); TestImage& input = config.input; TestImage output; @@ -99,7 +100,6 @@ TEST_P(StreamingTestParam, TestStreaming) { // compressor's output is connected to the decompressor's input. jpegli_create_decompress(&dinfo); jpegli_create_compress(&cinfo); - SourceManager src; dinfo.src = reinterpret_cast<jpeg_source_mgr*>(&src); DestinationManager dest(&src); cinfo.dest = reinterpret_cast<jpeg_destination_mgr*>(&dest); @@ -107,7 +107,7 @@ TEST_P(StreamingTestParam, TestStreaming) { cinfo.image_width = input.xsize; cinfo.image_height = input.ysize; cinfo.input_components = input.components; - cinfo.in_color_space = (J_COLOR_SPACE)input.color_space; + cinfo.in_color_space = static_cast<J_COLOR_SPACE>(input.color_space); jpegli_set_defaults(&cinfo); cinfo.comp_info[0].v_samp_factor = config.jparams.v_sampling[0]; jpegli_set_progressive_level(&cinfo, 0); @@ -122,13 +122,13 @@ TEST_P(StreamingTestParam, TestStreaming) { while (yin < cinfo.image_height) { // Feed one iMCU row at a time to the compressor. size_t lines_in = std::min(iMCU_height, cinfo.image_height - yin); - memcpy(&row_bytes[0], &input.pixels[yin * stride], lines_in * stride); + memcpy(row_bytes.data(), &input.pixels[yin * stride], lines_in * stride); std::vector<JSAMPROW> rows_in(lines_in); for (size_t i = 0; i < lines_in; ++i) { rows_in[i] = &row_bytes[i * stride]; } EXPECT_EQ(lines_in, - jpegli_write_scanlines(&cinfo, &rows_in[0], lines_in)); + jpegli_write_scanlines(&cinfo, rows_in.data(), lines_in)); yin += lines_in; if (yin == cinfo.image_height) { jpegli_finish_compress(&cinfo); @@ -180,7 +180,7 @@ TEST_P(StreamingTestParam, TestStreaming) { reinterpret_cast<JSAMPLE*>(&output.pixels[(yout + i) * stride]); } EXPECT_EQ(lines_out, - jpegli_read_scanlines(&dinfo, &rows_out[0], lines_out)); + jpegli_read_scanlines(&dinfo, rows_out.data(), lines_out)); VerifyOutputImage(input, output, yout, lines_out, 3.8f); yout += lines_out; |