diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d0efce29..edc55042 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,8 +106,6 @@ target_sources(charls "${CMAKE_CURRENT_LIST_DIR}/color_transform.h" "${CMAKE_CURRENT_LIST_DIR}/conditional_static_cast.h" "${CMAKE_CURRENT_LIST_DIR}/constants.h" - "${CMAKE_CURRENT_LIST_DIR}/context_regular_mode.h" - "${CMAKE_CURRENT_LIST_DIR}/context_run_mode.h" "${CMAKE_CURRENT_LIST_DIR}/default_traits.h" "${CMAKE_CURRENT_LIST_DIR}/golomb_lut.h" "${CMAKE_CURRENT_LIST_DIR}/golomb_lut.cpp" @@ -127,6 +125,8 @@ target_sources(charls "${CMAKE_CURRENT_LIST_DIR}/process_encoded_line.h" "${CMAKE_CURRENT_LIST_DIR}/quantization_lut.h" "${CMAKE_CURRENT_LIST_DIR}/quantization_lut.cpp" + "${CMAKE_CURRENT_LIST_DIR}/regular_mode_context.h" + "${CMAKE_CURRENT_LIST_DIR}/run_mode_context.h" "${CMAKE_CURRENT_LIST_DIR}/scan_codec.h" "${CMAKE_CURRENT_LIST_DIR}/scan_decoder.h" "${CMAKE_CURRENT_LIST_DIR}/scan_decoder_impl.h" diff --git a/src/CharLS.vcxproj b/src/CharLS.vcxproj index 4acae43b..07a1e80d 100644 --- a/src/CharLS.vcxproj +++ b/src/CharLS.vcxproj @@ -236,8 +236,8 @@ - - + + diff --git a/src/CharLS.vcxproj.filters b/src/CharLS.vcxproj.filters index e34791c1..3c66c89d 100644 --- a/src/CharLS.vcxproj.filters +++ b/src/CharLS.vcxproj.filters @@ -33,7 +33,7 @@ - + Header Files @@ -57,7 +57,7 @@ Header Files - + Header Files diff --git a/src/constants.h b/src/constants.h index 329e2c3f..2a6ef1f1 100644 --- a/src/constants.h +++ b/src/constants.h @@ -3,22 +3,15 @@ #pragma once -#include #include #include namespace charls { -// Default threshold values for JPEG-LS statistical modeling as defined in ISO/IEC 14495-1, table C.3 -// for the case MAXVAL = 255 and NEAR = 0. -// Can be overridden at compression time, however this is rarely done. -constexpr int default_threshold1{3}; // BASIC_T1 -constexpr int default_threshold2{7}; // BASIC_T2 -constexpr int default_threshold3{21}; // BASIC_T3 - -constexpr int default_reset_value{64}; // Default RESET value as defined in ISO/IEC 14495-1, table C.2 +constexpr int32_t default_reset_value{64}; // Default RESET value as defined in ISO/IEC 14495-1, table C.2 constexpr int32_t maximum_component_count{255}; +constexpr size_t maximum_component_count_in_scan{4}; constexpr int32_t minimum_component_index{}; constexpr int32_t maximum_component_index{maximum_component_count - 1}; constexpr int32_t minimum_bits_per_sample{2}; @@ -33,18 +26,7 @@ constexpr int32_t maximum_table_id{255}; constexpr int32_t minimum_entry_size{1}; constexpr int32_t maximum_entry_size{255}; -constexpr int max_k_value{16}; // This is an implementation limit (theoretical limit is 32) - -constexpr int compute_maximum_near_lossless(const int maximum_sample_value) noexcept -{ - return std::min(maximum_near_lossless, maximum_sample_value / 2); // As defined by ISO/IEC 14495-1, C.2.3 -} - -// Computes the initial value for A. See ISO/IEC 14495-1, A.8, step 1.d and A.2.1 -constexpr int32_t initialization_value_for_a(const int32_t range) noexcept -{ - return std::max(2, (range + 32) / 64); -} +constexpr int32_t max_k_value{16}; // This is an implementation limit (theoretical limit is 32) // ISO/IEC 14495-1, section 4.8.1 defines the SPIFF version numbers to be used for the SPIFF header in combination with // JPEG-LS. diff --git a/src/jpeg_stream_reader.cpp b/src/jpeg_stream_reader.cpp index 07f0f6d1..fa10d365 100644 --- a/src/jpeg_stream_reader.cpp +++ b/src/jpeg_stream_reader.cpp @@ -547,7 +547,7 @@ void jpeg_stream_reader::read_start_of_scan_segment() const size_t component_count_in_scan{read_uint8()}; // ISO 10918-1, B2.3. defines the limits for the number of image components parameter in an SOS. - if (UNLIKELY(component_count_in_scan < 1U || component_count_in_scan > 4U || + if (UNLIKELY(component_count_in_scan == 0U || component_count_in_scan > maximum_component_count_in_scan || component_count_in_scan > static_cast(frame_info_.component_count))) throw_jpegls_error(jpegls_errc::invalid_parameter_component_count); diff --git a/src/jpegls_algorithm.h b/src/jpegls_algorithm.h index 5de37069..9e3452de 100644 --- a/src/jpegls_algorithm.h +++ b/src/jpegls_algorithm.h @@ -8,6 +8,19 @@ namespace charls { +constexpr int compute_maximum_near_lossless(const int maximum_sample_value) noexcept +{ + return std::min(maximum_near_lossless, maximum_sample_value / 2); // As defined by ISO/IEC 14495-1, C.2.3 +} + + +// Computes the initial value for A. See ISO/IEC 14495-1, A.8, step 1.d and A.2.1 +constexpr int32_t initialization_value_for_a(const int32_t range) noexcept +{ + return std::max(2, (range + 32) / 64); +} + + /// /// This is the optimized inverse algorithm of ISO/IEC 14495-1, A.5.2, Code Segment A.11 (second else branch) /// It will map unsigned values back to signed values. diff --git a/src/jpegls_preset_coding_parameters.h b/src/jpegls_preset_coding_parameters.h index f0eac9af..35506249 100644 --- a/src/jpegls_preset_coding_parameters.h +++ b/src/jpegls_preset_coding_parameters.h @@ -4,7 +4,7 @@ #pragma once #include "charls/public_types.h" -#include "constants.h" +#include "jpegls_algorithm.h" #include "util.h" #include @@ -24,6 +24,12 @@ inline jpegls_pc_parameters compute_default(const int32_t maximum_sample_value, ASSERT(maximum_sample_value <= std::numeric_limits::max()); ASSERT(near_lossless >= 0 && near_lossless <= compute_maximum_near_lossless(maximum_sample_value)); + // Default threshold values for JPEG-LS statistical modeling as defined in ISO/IEC 14495-1, table C.3 + // for the case MAXVAL = 255 and NEAR = 0. + constexpr int default_threshold1{3}; // BASIC_T1 + constexpr int default_threshold2{7}; // BASIC_T2 + constexpr int default_threshold3{21}; // BASIC_T3 + if (maximum_sample_value >= 128) { const int32_t factor{(std::min(maximum_sample_value, 4095) + 128) / 256}; @@ -91,7 +97,8 @@ inline bool is_valid(const jpegls_pc_parameters& pc_parameters, const int32_t ma (pc_parameters.threshold1 < near_lossless + 1 || pc_parameters.threshold1 > maximum_sample_value)) return false; - const auto [_, d_threshold1, d_threshold2, d_threshold3, d_reset_value]{compute_default(maximum_sample_value, near_lossless)}; + const auto [_, d_threshold1, d_threshold2, d_threshold3, + d_reset_value]{compute_default(maximum_sample_value, near_lossless)}; if (const int32_t threshold1{pc_parameters.threshold1 != 0 ? pc_parameters.threshold1 : d_threshold1}; pc_parameters.threshold2 != 0 && (pc_parameters.threshold2 < threshold1 || pc_parameters.threshold2 > maximum_sample_value)) @@ -109,14 +116,10 @@ inline bool is_valid(const jpegls_pc_parameters& pc_parameters, const int32_t ma if (validated_parameters) { validated_parameters->maximum_sample_value = maximum_sample_value; - validated_parameters->threshold1 = - pc_parameters.threshold1 != 0 ? pc_parameters.threshold1 : d_threshold1; - validated_parameters->threshold2 = - pc_parameters.threshold2 != 0 ? pc_parameters.threshold2 : d_threshold2; - validated_parameters->threshold3 = - pc_parameters.threshold3 != 0 ? pc_parameters.threshold3 : d_threshold3; - validated_parameters->reset_value = - pc_parameters.reset_value != 0 ? pc_parameters.reset_value : d_reset_value; + validated_parameters->threshold1 = pc_parameters.threshold1 != 0 ? pc_parameters.threshold1 : d_threshold1; + validated_parameters->threshold2 = pc_parameters.threshold2 != 0 ? pc_parameters.threshold2 : d_threshold2; + validated_parameters->threshold3 = pc_parameters.threshold3 != 0 ? pc_parameters.threshold3 : d_threshold3; + validated_parameters->reset_value = pc_parameters.reset_value != 0 ? pc_parameters.reset_value : d_reset_value; } return true; diff --git a/src/context_regular_mode.h b/src/regular_mode_context.h similarity index 89% rename from src/context_regular_mode.h rename to src/regular_mode_context.h index a4e20c19..79cd9ab3 100644 --- a/src/context_regular_mode.h +++ b/src/regular_mode_context.h @@ -15,12 +15,12 @@ namespace charls { /// to maintain the statistic information for the context modeling. /// As the operations on these variables use the same index it is more efficient to combine A,B,C and N. /// -class context_regular_mode final +class regular_mode_context final { public: - context_regular_mode() = default; + regular_mode_context() = default; - explicit context_regular_mode(const int32_t range) noexcept : a_{initialization_value_for_a(range)} + explicit regular_mode_context(const int32_t range) noexcept : a_{initialization_value_for_a(range)} { } @@ -63,8 +63,8 @@ class context_regular_mode final ASSERT(n_ != 0); // This part is from: Code segment A.13 – Update of bias-related variables B[Q] and C[Q] - constexpr int32_t max_c{127}; // Minimum allowed value of c_[0..364]. ISO 14495-1, section 3.3 - constexpr int32_t min_c{-128}; // Minimum allowed value of c_[0..364]. ISO 14495-1, section 3.3 + constexpr int32_t max_c{127}; // MAX_C: maximum allowed value of C[0..364]. ISO 14495-1, section 3.3 + constexpr int32_t min_c{-128}; // MIN_C: Minimum allowed value of C[0..364]. ISO 14495-1, section 3.3 if (b_ + n_ <= 0) { b_ += n_; diff --git a/src/context_run_mode.h b/src/run_mode_context.h similarity index 94% rename from src/context_run_mode.h rename to src/run_mode_context.h index 387f8c0d..2669aba2 100644 --- a/src/context_run_mode.h +++ b/src/run_mode_context.h @@ -3,7 +3,7 @@ #pragma once -#include "constants.h" +#include "jpegls_algorithm.h" #include "util.h" #include @@ -16,12 +16,12 @@ namespace charls { /// to maintain the statistic information for the context modeling. /// Index 365 and 366 are used for run mode interruption contexts. /// -class context_run_mode final +class run_mode_context final { public: - context_run_mode() = default; + run_mode_context() = default; - context_run_mode(const int32_t run_interruption_type, const int32_t range) noexcept : + run_mode_context(const int32_t run_interruption_type, const int32_t range) noexcept : run_interruption_type_{run_interruption_type}, a_{initialization_value_for_a(range)} { } diff --git a/src/scan_codec.h b/src/scan_codec.h index 0c5b56d4..29f9dc4f 100644 --- a/src/scan_codec.h +++ b/src/scan_codec.h @@ -3,8 +3,8 @@ #pragma once -#include "context_regular_mode.h" -#include "context_run_mode.h" +#include "regular_mode_context.h" +#include "run_mode_context.h" #include "jpegls_algorithm.h" #include "quantization_lut.h" #include "coding_parameters.h" @@ -147,14 +147,14 @@ class scan_codec void reset_parameters(const int32_t range) noexcept { - const context_regular_mode context_initial_value(range); - for (auto& context : contexts_) + const regular_mode_context context_initial_value(range); + for (auto& context : regular_mode_contexts_) { context = context_initial_value; } - context_run_mode_[0] = context_run_mode(0, range); - context_run_mode_[1] = context_run_mode(1, range); + run_mode_contexts_[0] = run_mode_context(0, range); + run_mode_contexts_[1] = run_mode_context(1, range); run_index_ = 0; } @@ -174,8 +174,8 @@ class scan_codec int32_t t2_{}; int32_t t3_{}; int32_t run_index_{}; - std::array contexts_; - std::array context_run_mode_; + std::array regular_mode_contexts_; + std::array run_mode_contexts_; uint32_t width_; uint8_t reset_value_{}; diff --git a/src/scan_decoder.h b/src/scan_decoder.h index f2edd9ae..d03998d3 100644 --- a/src/scan_decoder.h +++ b/src/scan_decoder.h @@ -54,12 +54,12 @@ class scan_decoder : protected scan_codec fill_read_cache(); } - FORCE_INLINE void skip(const int32_t length) noexcept + FORCE_INLINE void skip_bits(const int32_t bit_count) noexcept { - ASSERT(length); + ASSERT(bit_count); - valid_bits_ -= length; // Note: valid_bits_ may become negative to indicate that extra bits are needed. - read_cache_ = read_cache_ << length; + valid_bits_ -= bit_count; // Note: valid_bits_ may become negative to indicate that extra bits are needed. + read_cache_ = read_cache_ << bit_count; } void on_line_end(const void* source, const size_t pixel_count, const size_t pixel_stride) const @@ -119,19 +119,20 @@ class scan_decoder : protected scan_codec return (high_bits << k) + read_value(k); } - FORCE_INLINE int32_t read_value(const int32_t length) + FORCE_INLINE int32_t read_value(const int32_t bit_count) { - if (valid_bits_ < length) + ASSERT(0 < bit_count && bit_count < 32); + + if (valid_bits_ < bit_count) { fill_read_cache(); - if (UNLIKELY(valid_bits_ < length)) + if (UNLIKELY(valid_bits_ < bit_count)) impl::throw_jpegls_error(jpegls_errc::invalid_encoded_data); } - ASSERT(length != 0 && length <= valid_bits_); - ASSERT(length < 32); - const auto result{static_cast(read_cache_ >> (cache_t_bit_count - length))}; - skip(length); + ASSERT(bit_count <= valid_bits_); + const auto result{static_cast(read_cache_ >> (cache_t_bit_count - bit_count))}; + skip_bits(bit_count); return result; } @@ -153,7 +154,7 @@ class scan_decoder : protected scan_codec } const bool set{(read_cache_ & (static_cast(1) << (cache_t_bit_count - 1))) != 0}; - skip(1); + skip_bits(1); return set; } @@ -185,10 +186,10 @@ class scan_decoder : protected scan_codec { if (const int32_t count{peek_0_bits()}; count >= 0) { - skip(count + 1); + skip_bits(count + 1); return count; } - skip(15); + skip_bits(15); for (int32_t high_bits_count{15};; ++high_bits_count) { @@ -293,9 +294,9 @@ class scan_decoder : protected scan_codec if (position_ < position_ff_ - (sizeof(cache_t) - 1)) { read_cache_ |= read_big_endian_unaligned(position_) >> valid_bits_; - const int bytes_to_read{(cache_t_bit_count - valid_bits_) / 8}; - position_ += bytes_to_read; - valid_bits_ += bytes_to_read * 8; + const int bytes_consumed{(cache_t_bit_count - valid_bits_) / 8}; + position_ += bytes_consumed; + valid_bits_ += bytes_consumed * 8; ASSERT(valid_bits_ >= max_readable_cache_bits); return true; } diff --git a/src/scan_decoder_impl.h b/src/scan_decoder_impl.h index 25d4c108..a03e306e 100644 --- a/src/scan_decoder_impl.h +++ b/src/scan_decoder_impl.h @@ -89,13 +89,13 @@ class scan_decoder_impl final : public scan_decoder // In ILV_NONE mode, do_scan is called for each component void decode_lines() { - const uint32_t pixel_stride{width_ + 4U}; + const uint32_t pixel_stride{width_ + 2U}; const size_t component_count{ parameters().interleave_mode == interleave_mode::line ? static_cast(frame_info().component_count) : 1U}; uint32_t restart_interval_counter{}; + std::array run_index{}; std::vector line_buffer(component_count * pixel_stride * 2); - std::vector run_index(component_count); for (uint32_t line{};;) { @@ -149,8 +149,8 @@ class scan_decoder_impl final : public scan_decoder // After a restart marker it is required to reset the decoder. reset(); - std::fill(line_buffer.begin(), line_buffer.end(), pixel_type{}); std::fill(run_index.begin(), run_index.end(), 0); + std::fill(line_buffer.begin(), line_buffer.end(), pixel_type{}); reset_parameters(traits_.range); } } @@ -278,14 +278,14 @@ class scan_decoder_impl final : public scan_decoder FORCE_INLINE sample_type decode_regular(const int32_t qs, const int32_t predicted) { const int32_t sign{bit_wise_sign(qs)}; - context_regular_mode& context{contexts_[apply_sign(qs, sign)]}; + regular_mode_context& context{regular_mode_contexts_[apply_sign(qs, sign)]}; const int32_t k{context.get_golomb_coding_parameter()}; const int32_t predicted_value{traits_.correct_prediction(predicted + apply_sign(context.c(), sign))}; int32_t error_value; if (const golomb_code& code = golomb_lut[k].get(peek_byte()); code.length() != 0) { - skip(code.length()); + skip_bits(code.length()); error_value = code.value(); ASSERT(std::abs(error_value) < 65535); } @@ -305,7 +305,7 @@ class scan_decoder_impl final : public scan_decoder } [[nodiscard]] - int32_t decode_run_interruption_error(context_run_mode& context) + int32_t decode_run_interruption_error(run_mode_context& context) { const int32_t k{context.get_golomb_code()}; const int32_t e_mapped_error_value{ @@ -318,9 +318,9 @@ class scan_decoder_impl final : public scan_decoder [[nodiscard]] triplet decode_run_interruption_pixel(triplet ra, triplet rb) { - const int32_t error_value1{decode_run_interruption_error(context_run_mode_[0])}; - const int32_t error_value2{decode_run_interruption_error(context_run_mode_[0])}; - const int32_t error_value3{decode_run_interruption_error(context_run_mode_[0])}; + const int32_t error_value1{decode_run_interruption_error(run_mode_contexts_[0])}; + const int32_t error_value2{decode_run_interruption_error(run_mode_contexts_[0])}; + const int32_t error_value3{decode_run_interruption_error(run_mode_contexts_[0])}; return {traits_.compute_reconstructed_sample(rb.v1, error_value1 * sign(rb.v1 - ra.v1)), traits_.compute_reconstructed_sample(rb.v2, error_value2 * sign(rb.v2 - ra.v2)), @@ -330,10 +330,10 @@ class scan_decoder_impl final : public scan_decoder [[nodiscard]] quad decode_run_interruption_pixel(quad ra, quad rb) { - const int32_t error_value1{decode_run_interruption_error(context_run_mode_[0])}; - const int32_t error_value2{decode_run_interruption_error(context_run_mode_[0])}; - const int32_t error_value3{decode_run_interruption_error(context_run_mode_[0])}; - const int32_t error_value4{decode_run_interruption_error(context_run_mode_[0])}; + const int32_t error_value1{decode_run_interruption_error(run_mode_contexts_[0])}; + const int32_t error_value2{decode_run_interruption_error(run_mode_contexts_[0])}; + const int32_t error_value3{decode_run_interruption_error(run_mode_contexts_[0])}; + const int32_t error_value4{decode_run_interruption_error(run_mode_contexts_[0])}; return {traits_.compute_reconstructed_sample(rb.v1, error_value1 * sign(rb.v1 - ra.v1)), traits_.compute_reconstructed_sample(rb.v2, error_value2 * sign(rb.v2 - ra.v2)), @@ -346,11 +346,11 @@ class scan_decoder_impl final : public scan_decoder { if (std::abs(ra - rb) <= traits_.near_lossless) { - const int32_t error_value{decode_run_interruption_error(context_run_mode_[1])}; + const int32_t error_value{decode_run_interruption_error(run_mode_contexts_[1])}; return static_cast(traits_.compute_reconstructed_sample(ra, error_value)); } - const int32_t error_value{decode_run_interruption_error(context_run_mode_[0])}; + const int32_t error_value{decode_run_interruption_error(run_mode_contexts_[0])}; return static_cast(traits_.compute_reconstructed_sample(rb, error_value * sign(rb - ra))); } diff --git a/src/scan_encoder_impl.h b/src/scan_encoder_impl.h index 09d0ef98..86493c71 100644 --- a/src/scan_encoder_impl.h +++ b/src/scan_encoder_impl.h @@ -88,12 +88,12 @@ class scan_encoder_impl final : public scan_encoder // In ILV_NONE mode, do_scan is called for each component void encode_lines() { - const uint32_t pixel_stride{width_ + 4U}; + const uint32_t pixel_stride{width_ + 2U}; const size_t component_count{ parameters().interleave_mode == interleave_mode::line ? static_cast(frame_info().component_count) : 1U}; + std::array run_index{}; std::vector line_buffer(component_count * pixel_stride * 2); - std::vector run_index(component_count); for (uint32_t line{}; line < frame_info().height; ++line) { @@ -269,7 +269,7 @@ class scan_encoder_impl final : public scan_encoder FORCE_INLINE sample_type encode_regular(const int32_t qs, const int32_t x, const int32_t predicted) { const int32_t sign{bit_wise_sign(qs)}; - context_regular_mode& context{contexts_[apply_sign(qs, sign)]}; + regular_mode_context& context{regular_mode_contexts_[apply_sign(qs, sign)]}; const int32_t k{context.get_golomb_coding_parameter()}; const int32_t predicted_value{traits_.correct_prediction(predicted + apply_sign(context.c(), sign))}; const int32_t error_value{traits_.compute_error_value(apply_sign(x - predicted_value, sign))}; @@ -309,7 +309,7 @@ class scan_encoder_impl final : public scan_encoder traits_.quantized_bits_per_pixel); } - void encode_run_interruption_error(context_run_mode& context, const int32_t error_value) + void encode_run_interruption_error(run_mode_context& context, const int32_t error_value) { const int32_t k{context.get_golomb_code()}; const bool map{context.compute_map(error_value, k)}; @@ -327,12 +327,12 @@ class scan_encoder_impl final : public scan_encoder if (std::abs(ra - rb) <= traits_.near_lossless) { const int32_t error_value{traits_.compute_error_value(x - ra)}; - encode_run_interruption_error(context_run_mode_[1], error_value); + encode_run_interruption_error(run_mode_contexts_[1], error_value); return static_cast(traits_.compute_reconstructed_sample(ra, error_value)); } const int32_t error_value{traits_.compute_error_value((x - rb) * sign(rb - ra))}; - encode_run_interruption_error(context_run_mode_[0], error_value); + encode_run_interruption_error(run_mode_contexts_[0], error_value); return static_cast(traits_.compute_reconstructed_sample(rb, error_value * sign(rb - ra))); } @@ -341,13 +341,13 @@ class scan_encoder_impl final : public scan_encoder const triplet rb) { const int32_t error_value1{traits_.compute_error_value(sign(rb.v1 - ra.v1) * (x.v1 - rb.v1))}; - encode_run_interruption_error(context_run_mode_[0], error_value1); + encode_run_interruption_error(run_mode_contexts_[0], error_value1); const int32_t error_value2{traits_.compute_error_value(sign(rb.v2 - ra.v2) * (x.v2 - rb.v2))}; - encode_run_interruption_error(context_run_mode_[0], error_value2); + encode_run_interruption_error(run_mode_contexts_[0], error_value2); const int32_t error_value3{traits_.compute_error_value(sign(rb.v3 - ra.v3) * (x.v3 - rb.v3))}; - encode_run_interruption_error(context_run_mode_[0], error_value3); + encode_run_interruption_error(run_mode_contexts_[0], error_value3); return {traits_.compute_reconstructed_sample(rb.v1, error_value1 * sign(rb.v1 - ra.v1)), traits_.compute_reconstructed_sample(rb.v2, error_value2 * sign(rb.v2 - ra.v2)), @@ -359,16 +359,16 @@ class scan_encoder_impl final : public scan_encoder const quad rb) { const int32_t error_value1{traits_.compute_error_value(sign(rb.v1 - ra.v1) * (x.v1 - rb.v1))}; - encode_run_interruption_error(context_run_mode_[0], error_value1); + encode_run_interruption_error(run_mode_contexts_[0], error_value1); const int32_t error_value2{traits_.compute_error_value(sign(rb.v2 - ra.v2) * (x.v2 - rb.v2))}; - encode_run_interruption_error(context_run_mode_[0], error_value2); + encode_run_interruption_error(run_mode_contexts_[0], error_value2); const int32_t error_value3{traits_.compute_error_value(sign(rb.v3 - ra.v3) * (x.v3 - rb.v3))}; - encode_run_interruption_error(context_run_mode_[0], error_value3); + encode_run_interruption_error(run_mode_contexts_[0], error_value3); const int32_t error_value4{traits_.compute_error_value(sign(rb.v4 - ra.v4) * (x.v4 - rb.v4))}; - encode_run_interruption_error(context_run_mode_[0], error_value4); + encode_run_interruption_error(run_mode_contexts_[0], error_value4); return {traits_.compute_reconstructed_sample(rb.v1, error_value1 * sign(rb.v1 - ra.v1)), traits_.compute_reconstructed_sample(rb.v2, error_value2 * sign(rb.v2 - ra.v2)), diff --git a/unittest/CharLSUnitTest.vcxproj b/unittest/CharLSUnitTest.vcxproj index ecd9b351..e4ee2cc2 100644 --- a/unittest/CharLSUnitTest.vcxproj +++ b/unittest/CharLSUnitTest.vcxproj @@ -79,7 +79,7 @@ - + diff --git a/unittest/CharLSUnitTest.vcxproj.filters b/unittest/CharLSUnitTest.vcxproj.filters index 7d967163..058179ac 100644 --- a/unittest/CharLSUnitTest.vcxproj.filters +++ b/unittest/CharLSUnitTest.vcxproj.filters @@ -98,7 +98,7 @@ Source Files - + Source Files diff --git a/unittest/context_run_mode_test.cpp b/unittest/run_mode_context_test.cpp similarity index 78% rename from unittest/context_run_mode_test.cpp rename to unittest/run_mode_context_test.cpp index 8ac5f998..0559fd3d 100644 --- a/unittest/context_run_mode_test.cpp +++ b/unittest/run_mode_context_test.cpp @@ -3,19 +3,19 @@ #include "pch.h" -#include "../src/context_run_mode.h" +#include "../src/run_mode_context.h" using Microsoft::VisualStudio::CppUnitTestFramework::Assert; namespace charls::test { -TEST_CLASS(context_run_mode_test) +TEST_CLASS(run_mode_context_test) { public: TEST_METHOD(update_variable) // NOLINT { - context_run_mode context; + run_mode_context context; context.update_variables(3, 27, 0); diff --git a/unittest/util.cpp b/unittest/util.cpp index b773bf3d..4685f342 100644 --- a/unittest/util.cpp +++ b/unittest/util.cpp @@ -234,13 +234,12 @@ void verify_decoded_bytes(const interleave_mode interleave_mode, const frame_inf void test_compliance(const vector& encoded_source, const vector& uncompressed_source, const bool check_encode) { - jpegls_decoder decoder{encoded_source, true}; - if (check_encode) { Assert::IsTrue(verify_encoded_bytes(uncompressed_source, encoded_source)); } + jpegls_decoder decoder{encoded_source, true}; const auto destination{decoder.decode>()}; if (decoder.near_lossless() == 0)