PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
jpeg_ls_codec.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
11#ifndef PACS_ENCODING_COMPRESSION_JPEG_LS_CODEC_HPP
12#define PACS_ENCODING_COMPRESSION_JPEG_LS_CODEC_HPP
13
15
17
50class jpeg_ls_codec final : public compression_codec {
51public:
53 static constexpr std::string_view kTransferSyntaxUIDLossless =
54 "1.2.840.10008.1.2.4.80";
55
57 static constexpr std::string_view kTransferSyntaxUIDNearLossless =
58 "1.2.840.10008.1.2.4.81";
59
61 static constexpr int kAutoNearValue = -1;
62
64 static constexpr int kLosslessNearValue = 0;
65
67 static constexpr int kDefaultNearLosslessValue = 2;
68
70 static constexpr int kMaxNearValue = 255;
71
83 explicit jpeg_ls_codec(bool lossless = true, int near_value = kAutoNearValue);
84
85 ~jpeg_ls_codec() override;
86
87 // Non-copyable but movable (internal state)
88 jpeg_ls_codec(const jpeg_ls_codec&) = delete;
91 jpeg_ls_codec& operator=(jpeg_ls_codec&&) noexcept;
92
95
96 [[nodiscard]] std::string_view transfer_syntax_uid() const noexcept override;
97 [[nodiscard]] std::string_view name() const noexcept override;
98 [[nodiscard]] bool is_lossy() const noexcept override;
99 [[nodiscard]] bool can_encode(const image_params& params) const noexcept override;
100 [[nodiscard]] bool can_decode(const image_params& params) const noexcept override;
101
103
106
111 [[nodiscard]] bool is_lossless_mode() const noexcept;
112
117 [[nodiscard]] int near_value() const noexcept;
118
120
123
143 [[nodiscard]] codec_result encode(
144 std::span<const uint8_t> pixel_data,
145 const image_params& params,
146 const compression_options& options = {}) const override;
147
159 [[nodiscard]] codec_result decode(
160 std::span<const uint8_t> compressed_data,
161 const image_params& params) const override;
162
164
165private:
166 class impl;
167 std::unique_ptr<impl> impl_;
168};
169
170} // namespace kcenon::pacs::encoding::compression
171
172#endif // PACS_ENCODING_COMPRESSION_JPEG_LS_CODEC_HPP
Abstract base class for image compression codecs.
JPEG-LS codec implementation supporting both lossless and near-lossless modes.
bool is_lossless_mode() const noexcept
Checks if this codec is configured for lossless mode.
static constexpr int kMaxNearValue
Maximum NEAR parameter value (higher = more compression, more loss)
std::string_view transfer_syntax_uid() const noexcept override
Returns the Transfer Syntax UID supported by this codec.
jpeg_ls_codec & operator=(const jpeg_ls_codec &)=delete
jpeg_ls_codec(bool lossless=true, int near_value=kAutoNearValue)
Constructs a JPEG-LS codec instance.
static constexpr std::string_view kTransferSyntaxUIDLossless
DICOM Transfer Syntax UID for JPEG-LS Lossless.
static constexpr int kLosslessNearValue
NEAR parameter for lossless mode.
codec_result encode(std::span< const uint8_t > pixel_data, const image_params &params, const compression_options &options={}) const override
Compresses pixel data to JPEG-LS format.
static constexpr int kDefaultNearLosslessValue
Default NEAR parameter for near-lossless mode (visually lossless quality)
int near_value() const noexcept
Gets the NEAR parameter value.
codec_result decode(std::span< const uint8_t > compressed_data, const image_params &params) const override
Decompresses JPEG-LS data.
std::string_view name() const noexcept override
Returns a human-readable name for the codec.
static constexpr int kAutoNearValue
Sentinel value indicating "auto-determine NEAR based on mode".
bool is_lossy() const noexcept override
Checks if this codec produces lossy compression.
bool can_encode(const image_params &params) const noexcept override
Checks if this codec supports the given image parameters.
static constexpr std::string_view kTransferSyntaxUIDNearLossless
DICOM Transfer Syntax UID for JPEG-LS Near-Lossless (Lossy)
bool can_decode(const image_params &params) const noexcept override
Checks if this codec can decode data with given parameters.
Compression quality settings for lossy codecs.
Parameters describing image pixel data.