PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
compression_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_COMPRESSION_CODEC_HPP
12#define PACS_ENCODING_COMPRESSION_COMPRESSION_CODEC_HPP
13
17
18#include <cstdint>
19#include <memory>
20#include <span>
21#include <string>
22#include <string_view>
23#include <vector>
24
26
36 int quality{75};
37
39 bool lossless{false};
40
42 bool progressive{false};
43
49};
50
58 std::vector<uint8_t> data;
59
62};
63
68
83public:
84 virtual ~compression_codec() = default;
85
88
93 [[nodiscard]] virtual std::string_view transfer_syntax_uid() const noexcept = 0;
94
99 [[nodiscard]] virtual std::string_view name() const noexcept = 0;
100
105 [[nodiscard]] virtual bool is_lossy() const noexcept = 0;
106
112 [[nodiscard]] virtual bool can_encode(const image_params& params) const noexcept = 0;
113
119 [[nodiscard]] virtual bool can_decode(const image_params& params) const noexcept = 0;
120
122
125
141 [[nodiscard]] virtual codec_result encode(
142 std::span<const uint8_t> pixel_data,
143 const image_params& params,
144 const compression_options& options = {}) const = 0;
145
155 [[nodiscard]] virtual codec_result decode(
156 std::span<const uint8_t> compressed_data,
157 const image_params& params) const = 0;
158
160
161protected:
162 compression_codec() = default;
167};
168
169} // namespace kcenon::pacs::encoding::compression
170
171#endif // PACS_ENCODING_COMPRESSION_COMPRESSION_CODEC_HPP
Abstract base class for image compression codecs.
virtual std::string_view transfer_syntax_uid() const noexcept=0
Returns the Transfer Syntax UID supported by this codec.
virtual codec_result decode(std::span< const uint8_t > compressed_data, const image_params &params) const =0
Decompresses compressed pixel data.
compression_codec & operator=(compression_codec &&)=default
virtual bool can_decode(const image_params &params) const noexcept=0
Checks if this codec can decode data with given parameters.
virtual codec_result encode(std::span< const uint8_t > pixel_data, const image_params &params, const compression_options &options={}) const =0
Compresses uncompressed pixel data.
virtual std::string_view name() const noexcept=0
Returns a human-readable name for the codec.
compression_codec(const compression_codec &)=default
virtual bool is_lossy() const noexcept=0
Checks if this codec produces lossy compression.
virtual bool can_encode(const image_params &params) const noexcept=0
Checks if this codec supports the given image parameters.
compression_codec & operator=(const compression_codec &)=default
Result<T> type aliases and helpers for PACS system.
Compression quality settings for lossy codecs.
int chroma_subsampling
Chroma subsampling for color images 0 = 4:4:4 (no subsampling) 1 = 4:2:2 (horizontal subsampling) 2 =...
bool progressive
Enable progressive encoding (JPEG only)
bool lossless
Enable lossless mode if supported by codec.
Successful result of a compression/decompression operation.
image_params output_params
Output image parameters (may differ from input for decompression)
std::vector< uint8_t > data
Processed pixel data.
Parameters describing image pixel data.