Resolve some spelling and ReSharper issues

This commit is contained in:
Victor Derks 2021-01-03 17:04:20 +01:00
parent 000ec1fc16
commit 0b910bc58f
No known key found for this signature in database
GPG Key ID: 3CAD1C98620F0A27
11 changed files with 40 additions and 52 deletions

View File

@ -41,6 +41,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002EDaemon_002ESettings_002EMigration_002ESwaWarningsModeSettingsMigrate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=alphatest/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=anymap/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=banny/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bgra/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bugprone/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=CHARLS/@EntryIndexedValue">True</s:Boolean>
@ -56,6 +57,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Endian/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=errc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=facto/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFMPEG/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=forceinline/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=foveon/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Golomb/@EntryIndexedValue">True</s:Boolean>

View File

@ -3,8 +3,6 @@
#pragma once
#include <charls/jpegls_error.h>
#include "coding_parameters.h"
#include "util.h"

View File

@ -516,13 +516,13 @@ private:
const size_t component_count{
parameters().interleave_mode == interleave_mode::line ? static_cast<size_t>(frame_info().component_count) : 1U};
std::vector<pixel_type> vectmp(static_cast<size_t>(2) * component_count * pixel_stride);
std::vector<pixel_type> line_buffer(static_cast<size_t>(2) * component_count * pixel_stride);
std::vector<int32_t> run_index(component_count);
for (uint32_t line{}; line < frame_info().height; ++line)
{
previous_line_ = &vectmp[1];
current_line_ = &vectmp[1 + static_cast<size_t>(component_count) * pixel_stride];
previous_line_ = &line_buffer[1];
current_line_ = &line_buffer[1 + static_cast<size_t>(component_count) * pixel_stride];
if ((line & 1) == 1)
{
std::swap(previous_line_, current_line_);
@ -784,7 +784,7 @@ private:
int32_t do_run_mode(const int32_t index, encoder_strategy*)
{
const int32_t ctypeRem = width_ - index;
const int32_t count_type_remain = width_ - index;
pixel_type* type_cur_x{current_line_ + index};
const pixel_type* type_prev_x{previous_line_ + index};
@ -796,13 +796,13 @@ private:
type_cur_x[run_length] = ra;
++run_length;
if (run_length == ctypeRem)
if (run_length == count_type_remain)
break;
}
encode_run_pixels(run_length, run_length == ctypeRem);
encode_run_pixels(run_length, run_length == count_type_remain);
if (run_length == ctypeRem)
if (run_length == count_type_remain)
return run_length;
type_cur_x[run_length] = encode_run_interruption_pixel(type_cur_x[run_length], ra, type_prev_x[run_length]);
@ -842,27 +842,27 @@ inline std::pair<int32_t, int32_t> create_encoded_value(const int32_t k, const i
inline golomb_code_table initialize_table(const int32_t k) noexcept
{
golomb_code_table table;
for (int16_t nerr{};; ++nerr)
for (int16_t error_value{};; ++error_value)
{
// Q is not used when k != 0
const int32_t mapped_error_value{get_mapped_error_value(nerr)};
const int32_t mapped_error_value{get_mapped_error_value(error_value)};
const std::pair<int32_t, int32_t> pair_code{create_encoded_value(k, mapped_error_value)};
if (static_cast<size_t>(pair_code.first) > golomb_code_table::byte_bit_count)
break;
const golomb_code code(nerr, static_cast<int16_t>(pair_code.first));
const golomb_code code(error_value, static_cast<int16_t>(pair_code.first));
table.add_entry(static_cast<uint8_t>(pair_code.second), code);
}
for (int16_t nerr{-1};; --nerr)
for (int16_t error_value{-1};; --error_value)
{
// Q is not used when k != 0
const int32_t mapped_error_value{get_mapped_error_value(nerr)};
const int32_t mapped_error_value{get_mapped_error_value(error_value)};
const std::pair<int32_t, int32_t> pair_code{create_encoded_value(k, mapped_error_value)};
if (static_cast<size_t>(pair_code.first) > golomb_code_table::byte_bit_count)
break;
const auto code{golomb_code(nerr, static_cast<int16_t>(pair_code.first))};
const auto code{golomb_code(error_value, static_cast<int16_t>(pair_code.first))};
table.add_entry(static_cast<uint8_t>(pair_code.second), code);
}

View File

@ -291,20 +291,6 @@ void test_too_small_output_buffer()
}
////void TestBadImage()
////{
//// vector<uint8_t> rgbyteCompressed;
//// if (!ReadFile("test/BadCompressedStream.jls", &rgbyteCompressed, 0))
//// return;
////
//// vector<uint8_t> rgbyteOut(2500 * 3000 * 2);
//// auto error = JpegLsDecode(&rgbyteOut[0], rgbyteOut.size(), &rgbyteCompressed[0], rgbyteCompressed.size(), nullptr,
///nullptr);
////
//// Assert::IsTrue(error == jpegls_errc::UncompressedBufferTooSmall);
////}
void test_decode_bit_stream_with_no_marker_start()
{
const array<uint8_t, 2> encoded_data{0x33, 0x33};
@ -724,7 +710,7 @@ int main(const int argc, const char* const argv[]) // NOLINT(bugprone-exception-
{
if (i != 1 || argc != 4)
{
cout << "Syntax: -decoderaw inputfile outputfile\n";
cout << "Syntax: -decoderaw input-file output-file\n";
return EXIT_FAILURE;
}
return decode_raw(argv[2], argv[3]) ? EXIT_SUCCESS : EXIT_FAILURE;
@ -734,7 +720,7 @@ int main(const int argc, const char* const argv[]) // NOLINT(bugprone-exception-
{
if (i != 1 || argc != 4)
{
cout << "Syntax: -decodetopnm inputfile outputfile\n";
cout << "Syntax: -decodetopnm input-file output-file\n";
return EXIT_FAILURE;
}
ofstream pnm_file(argv[3], mode_output);
@ -747,7 +733,7 @@ int main(const int argc, const char* const argv[]) // NOLINT(bugprone-exception-
{
if (i != 1 || argc != 4)
{
cout << "Syntax: -encodepnm inputfile outputfile\n";
cout << "Syntax: -encodepnm input-file output-file\n";
return EXIT_FAILURE;
}
ifstream pnm_file(argv[2], mode_input);
@ -760,7 +746,7 @@ int main(const int argc, const char* const argv[]) // NOLINT(bugprone-exception-
{
if (i != 1 || argc != 4)
{
cout << "Syntax: -encodepnm inputfile outputfile\n";
cout << "Syntax: -encodepnm input-file output-file\n";
return EXIT_FAILURE;
}
ifstream pnm_file1(argv[2], mode_input);

View File

@ -143,7 +143,7 @@ public:
{
const auto error = charls_jpegls_encoder_write_standard_spiff_header(
nullptr, charls_spiff_color_space::cie_lab, charls_spiff_resolution_units::dots_per_centimeter, 1, 1);
Assert::AreEqual(charls::jpegls_errc::invalid_argument, error);
Assert::AreEqual(jpegls_errc::invalid_argument, error);
}
TEST_METHOD(write_spiff_entry_nullptr) // NOLINT

View File

@ -36,7 +36,7 @@ std::vector<uint8_t> decode_simple_8_bit_monochrome(const std::vector<uint8_t>&
std::vector<uint8_t> decode_advanced(const std::vector<uint8_t>& source)
{
charls::jpegls_decoder decoder{source, true};
const charls::jpegls_decoder decoder{source, true};
// Standalone JPEG-LS files may have a SPIFF header (color space info, etc.)
if (decoder.spiff_header_has_value() && decoder.spiff_header().color_space != charls::spiff_color_space::grayscale)

View File

@ -49,10 +49,10 @@ public:
JlsParameters params{};
vector<uint8_t> encoded_source{read_file("DataFiles/t8c0e3.jls")};
auto error = JpegLsReadHeader(nullptr, encoded_source.size(), &params, nullptr);
Assert::AreEqual(charls::jpegls_errc::invalid_argument, error);
Assert::AreEqual(jpegls_errc::invalid_argument, error);
error = JpegLsReadHeader(encoded_source.data(), encoded_source.size(), nullptr, nullptr);
Assert::AreEqual(charls::jpegls_errc::invalid_argument, error);
Assert::AreEqual(jpegls_errc::invalid_argument, error);
}
TEST_METHOD(JpegLsReadHeader_empty_source) // NOLINT
@ -61,7 +61,7 @@ public:
JlsParameters params{};
array<uint8_t, 1> source{};
const auto error = JpegLsReadHeader(source.data(), 0, &params, error_message.data());
Assert::AreEqual(charls::jpegls_errc::source_buffer_too_small, error);
Assert::AreEqual(jpegls_errc::source_buffer_too_small, error);
Assert::IsTrue(strlen(error_message.data()) > 0);
}
@ -119,7 +119,7 @@ public:
vector<uint8_t> source(100);
const auto error =
JpegLsEncode(destination.data(), 0, &bytes_written, source.data(), source.size(), &params, error_message.data());
Assert::AreEqual(charls::jpegls_errc::destination_buffer_too_small, error);
Assert::AreEqual(jpegls_errc::destination_buffer_too_small, error);
Assert::IsTrue(strlen(error_message.data()) > 0);
}

View File

@ -52,7 +52,7 @@ public:
writer.write_start_of_frame_segment(1, 1, 2, 1);
writer.buffer.push_back(0xFF);
writer.write_start_of_scan_segment(0, 1, 128, charls::interleave_mode::none);
writer.write_start_of_scan_segment(0, 1, 128, interleave_mode::none);
jpeg_stream_reader reader({writer.buffer.data(), writer.buffer.size()});
@ -236,7 +236,7 @@ public:
writer.write_start_of_image();
writer.write_jpegls_preset_parameters_segment(preset_coding_parameters);
writer.write_start_of_frame_segment(512, 512, 8, 3);
writer.write_start_of_scan_segment(0, 1, 127, charls::interleave_mode::none);
writer.write_start_of_scan_segment(0, 1, 127, interleave_mode::none);
jpeg_stream_reader reader({writer.buffer.data(), writer.buffer.size()});
@ -386,7 +386,7 @@ public:
{
jpeg_test_stream_writer writer;
writer.write_start_of_image();
writer.write_start_of_scan_segment(0, 1, 128, charls::interleave_mode::none);
writer.write_start_of_scan_segment(0, 1, 128, interleave_mode::none);
jpeg_stream_reader reader({writer.buffer.data(), writer.buffer.size()});
@ -410,7 +410,7 @@ public:
jpeg_test_stream_writer writer;
writer.write_start_of_image();
writer.write_start_of_frame_segment(512, 512, 8, 3);
writer.write_start_of_scan_segment(0, 1, 128, charls::interleave_mode::none);
writer.write_start_of_scan_segment(0, 1, 128, interleave_mode::none);
jpeg_stream_reader reader({writer.buffer.data(), writer.buffer.size()});
reader.read_header();
@ -428,7 +428,7 @@ public:
writer.write_start_of_frame_segment(512, 512, 8, 3);
constexpr int bad_near_lossless = (200 / 2) + 1;
writer.write_start_of_scan_segment(0, 1, bad_near_lossless, charls::interleave_mode::none);
writer.write_start_of_scan_segment(0, 1, bad_near_lossless, interleave_mode::none);
jpeg_stream_reader reader({writer.buffer.data(), writer.buffer.size()});
reader.read_header();
@ -655,7 +655,7 @@ private:
writer.buffer.push_back(0x02);
writer.write_start_of_frame_segment(1, 1, 2, 1);
writer.write_start_of_scan_segment(0, 1, 128, charls::interleave_mode::none);
writer.write_start_of_scan_segment(0, 1, 128, interleave_mode::none);
jpeg_stream_reader reader({writer.buffer.data(), writer.buffer.size()});

View File

@ -43,14 +43,14 @@ public:
segment.push_back(0); // Tqi = Quantization table destination selector (reserved for JPEG-LS, should be set to 0)
}
write_segment(charls::jpeg_marker_code::start_of_frame_jpegls, segment.data(), segment.size());
write_segment(jpeg_marker_code::start_of_frame_jpegls, segment.data(), segment.size());
}
void write_jpegls_preset_parameters_segment(const jpegls_pc_parameters& preset_coding_parameters)
{
std::vector<uint8_t> segment;
segment.push_back(static_cast<uint8_t>(charls::jpegls_preset_parameters_type::preset_coding_parameters));
segment.push_back(static_cast<uint8_t>(jpegls_preset_parameters_type::preset_coding_parameters));
push_back(segment, static_cast<uint16_t>(preset_coding_parameters.maximum_sample_value));
push_back(segment, static_cast<uint16_t>(preset_coding_parameters.threshold1));
@ -58,7 +58,7 @@ public:
push_back(segment, static_cast<uint16_t>(preset_coding_parameters.threshold3));
push_back(segment, static_cast<uint16_t>(preset_coding_parameters.reset_value));
write_segment(charls::jpeg_marker_code::jpegls_preset_parameters, segment.data(), segment.size());
write_segment(jpeg_marker_code::jpegls_preset_parameters, segment.data(), segment.size());
}
void write_start_of_scan_segment(int component_id, const int component_count, const int near_lossless,

View File

@ -730,7 +730,7 @@ private:
static void test_by_decoding(const vector<uint8_t>& encoded_source, const frame_info& source_frame_info,
const void* expected_destination, const size_t expected_destination_size,
const charls::interleave_mode interleave_mode,
const charls::color_transformation color_transformation = color_transformation::none)
const color_transformation color_transformation = color_transformation::none)
{
jpegls_decoder decoder;
decoder.source(encoded_source);

View File

@ -45,9 +45,9 @@ namespace charls { namespace test {
std::vector<uint8_t> read_file(const char* filename);
charls_test::portable_anymap_file read_anymap_reference_file(const char* filename, charls::interleave_mode interleave_mode,
const charls::frame_info& frame_info);
charls_test::portable_anymap_file read_anymap_reference_file(const char* filename, charls::interleave_mode interleave_mode);
charls_test::portable_anymap_file read_anymap_reference_file(const char* filename, interleave_mode interleave_mode,
const frame_info& frame_info);
charls_test::portable_anymap_file read_anymap_reference_file(const char* filename, interleave_mode interleave_mode);
std::vector<uint8_t> create_test_spiff_header(uint8_t high_version = 2, uint8_t low_version = 0,
bool end_of_directory = true);
std::vector<uint8_t> create_noise_image_16_bit(size_t pixel_count, int bit_count, uint32_t seed);
@ -63,7 +63,9 @@ constexpr uint32_t bit_to_byte_count(const int32_t bit_count) noexcept
}} // namespace charls::test
// ReSharper disable CppInconsistentNaming
namespace Microsoft { namespace VisualStudio { namespace CppUnitTestFramework {
// ReSharper restore CppInconsistentNaming
template<>
inline std::wstring ToString<charls::jpegls_errc>(const charls::jpegls_errc& q)