PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
hevc_codec.cpp
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
7
9
10hevc_codec::hevc_codec(bool main10, int quality)
11 : main10_(main10),
12 quality_(quality) {}
13
14hevc_codec::~hevc_codec() = default;
15
16hevc_codec::hevc_codec(hevc_codec&&) noexcept = default;
17hevc_codec& hevc_codec::operator=(hevc_codec&&) noexcept = default;
18
19std::string_view hevc_codec::transfer_syntax_uid() const noexcept {
20 return main10_ ? kTransferSyntaxUIDMain10 : kTransferSyntaxUIDMain;
21}
22
23std::string_view hevc_codec::name() const noexcept {
24 return main10_ ? "HEVC/H.265 Main 10 Profile" : "HEVC/H.265 Main Profile";
25}
26
27bool hevc_codec::is_lossy() const noexcept {
28 return true;
29}
30
31bool hevc_codec::can_encode(const image_params& params) const noexcept {
32 if (params.width == 0 || params.height == 0) {
33 return false;
34 }
35
36 if (params.samples_per_pixel != 1 && params.samples_per_pixel != 3) {
37 return false;
38 }
39
40 if (main10_) {
41 // Main 10 Profile supports up to 10-bit
42 if (params.bits_stored < 1 || params.bits_stored > 10) {
43 return false;
44 }
45 } else {
46 // Main Profile supports up to 8-bit
47 if (params.bits_stored < 1 || params.bits_stored > 8) {
48 return false;
49 }
50 }
51
52 return true;
53}
54
55bool hevc_codec::can_decode(const image_params& params) const noexcept {
56 return can_encode(params);
57}
58
59bool hevc_codec::is_main10_profile() const noexcept {
60 return main10_;
61}
62
63int hevc_codec::quality() const noexcept {
64 return quality_;
65}
66
67// HEVC library not yet integrated -- return not-available errors
68
70 [[maybe_unused]] std::span<const uint8_t> pixel_data,
71 [[maybe_unused]] const image_params& params,
72 [[maybe_unused]] const compression_options& options) const {
75 "HEVC codec not available: HEVC library not found at build time. "
76 "Build with PACS_WITH_HEVC=ON to enable.");
77}
78
80 [[maybe_unused]] std::span<const uint8_t> compressed_data,
81 [[maybe_unused]] const image_params& params) const {
84 "HEVC codec not available: HEVC library not found at build time. "
85 "Build with PACS_WITH_HEVC=ON to enable.");
86}
87
88} // namespace kcenon::pacs::encoding::compression
HEVC/H.265 codec implementation for video-encoded multi-frame DICOM.
Definition hevc_codec.h:45
hevc_codec(bool main10=false, int quality=kDefaultQuality)
Constructs an HEVC codec instance.
bool is_lossy() const noexcept override
Checks if this codec produces lossy compression.
int quality() const noexcept
Gets the current quality setting (CRF).
std::string_view name() const noexcept override
Returns a human-readable name for the codec.
bool is_main10_profile() const noexcept
Checks if this codec is configured for Main 10 Profile.
bool can_decode(const image_params &params) const noexcept override
Checks if this codec can decode data with given parameters.
bool can_encode(const image_params &params) const noexcept override
Checks if this codec supports the given image parameters.
codec_result decode(std::span< const uint8_t > compressed_data, const image_params &params) const override
Decompresses compressed pixel data.
codec_result encode(std::span< const uint8_t > pixel_data, const image_params &params, const compression_options &options={}) const override
Compresses uncompressed pixel data.
constexpr int compression_error
Definition result.h:78
constexpr int decompression_error
Definition result.h:79
Result< T > pacs_error(int code, const std::string &message, const std::string &details="")
Create a PACS error result with module context.
Definition result.h:234
Result<T> type aliases and helpers for PACS system.
Compression quality settings for lossy codecs.
Parameters describing image pixel data.