PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
kcenon::pacs::encoding::simd::detail Namespace Reference

Functions

void invert_monochrome_8bit_scalar (const uint8_t *src, uint8_t *dst, size_t pixel_count) noexcept
 Scalar 8-bit monochrome inversion (MONOCHROME1 <-> MONOCHROME2)
 
void invert_monochrome_16bit_scalar (const uint16_t *src, uint16_t *dst, size_t pixel_count, uint16_t max_value) noexcept
 Scalar 16-bit monochrome inversion.
 
void rgb_to_ycbcr_8bit_scalar (const uint8_t *src, uint8_t *dst, size_t pixel_count) noexcept
 Scalar RGB to YCbCr conversion (ITU-R BT.601)
 
void ycbcr_to_rgb_8bit_scalar (const uint8_t *src, uint8_t *dst, size_t pixel_count) noexcept
 Scalar YCbCr to RGB conversion (ITU-R BT.601)
 
void interleaved_to_planar_rgb8_scalar (const uint8_t *src, uint8_t *r, uint8_t *g, uint8_t *b, size_t pixel_count) noexcept
 
void planar_to_interleaved_rgb8_scalar (const uint8_t *r, const uint8_t *g, const uint8_t *b, uint8_t *dst, size_t pixel_count) noexcept
 
void split_16bit_to_planes_scalar (const uint8_t *src, uint8_t *high, uint8_t *low, size_t pixel_count) noexcept
 
void merge_planes_to_16bit_scalar (const uint8_t *high, const uint8_t *low, uint8_t *dst, size_t pixel_count) noexcept
 
void swap_bytes_16_scalar (const uint8_t *src, uint8_t *dst, size_t byte_count) noexcept
 
void swap_bytes_32_scalar (const uint8_t *src, uint8_t *dst, size_t byte_count) noexcept
 
void swap_bytes_64_scalar (const uint8_t *src, uint8_t *dst, size_t byte_count) noexcept
 
void apply_window_level_8bit_scalar (const uint8_t *src, uint8_t *dst, size_t pixel_count, const window_level_params &params) noexcept
 Scalar 8-bit window/level application.
 
void apply_window_level_16bit_scalar (const uint16_t *src, uint8_t *dst, size_t pixel_count, const window_level_params &params) noexcept
 Scalar 16-bit window/level application.
 
void apply_window_level_16bit_signed_scalar (const int16_t *src, uint8_t *dst, size_t pixel_count, const window_level_params &params) noexcept
 Scalar signed 16-bit window/level application.
 

Function Documentation

◆ apply_window_level_16bit_scalar()

void kcenon::pacs::encoding::simd::detail::apply_window_level_16bit_scalar ( const uint16_t * src,
uint8_t * dst,
size_t pixel_count,
const window_level_params & params )
inlinenoexcept

Scalar 16-bit window/level application.

Definition at line 197 of file simd_windowing.h.

199 {
200 const double min_val = params.center - params.width / 2.0;
201 const double scale = 255.0 / params.width;
202
203 for (size_t i = 0; i < pixel_count; ++i) {
204 double val = (src[i] - min_val) * scale;
205 val = std::clamp(val, 0.0, 255.0);
206 if (params.invert) {
207 val = 255.0 - val;
208 }
209 dst[i] = static_cast<uint8_t>(val);
210 }
211}
bool invert
Invert output (for MONOCHROME1)

Referenced by kcenon::pacs::encoding::simd::apply_window_level_16bit().

Here is the caller graph for this function:

◆ apply_window_level_16bit_signed_scalar()

void kcenon::pacs::encoding::simd::detail::apply_window_level_16bit_signed_scalar ( const int16_t * src,
uint8_t * dst,
size_t pixel_count,
const window_level_params & params )
inlinenoexcept

Scalar signed 16-bit window/level application.

Definition at line 216 of file simd_windowing.h.

218 {
219 const double min_val = params.center - params.width / 2.0;
220 const double scale = 255.0 / params.width;
221
222 for (size_t i = 0; i < pixel_count; ++i) {
223 double val = (src[i] - min_val) * scale;
224 val = std::clamp(val, 0.0, 255.0);
225 if (params.invert) {
226 val = 255.0 - val;
227 }
228 dst[i] = static_cast<uint8_t>(val);
229 }
230}

Referenced by kcenon::pacs::encoding::simd::apply_window_level_16bit_signed().

Here is the caller graph for this function:

◆ apply_window_level_8bit_scalar()

void kcenon::pacs::encoding::simd::detail::apply_window_level_8bit_scalar ( const uint8_t * src,
uint8_t * dst,
size_t pixel_count,
const window_level_params & params )
inlinenoexcept

Scalar 8-bit window/level application.

Definition at line 178 of file simd_windowing.h.

180 {
181 const double min_val = params.center - params.width / 2.0;
182 const double scale = 255.0 / params.width;
183
184 for (size_t i = 0; i < pixel_count; ++i) {
185 double val = (src[i] - min_val) * scale;
186 val = std::clamp(val, 0.0, 255.0);
187 if (params.invert) {
188 val = 255.0 - val;
189 }
190 dst[i] = static_cast<uint8_t>(val);
191 }
192}

Referenced by kcenon::pacs::encoding::simd::apply_window_level_8bit().

Here is the caller graph for this function:

◆ interleaved_to_planar_rgb8_scalar()

void kcenon::pacs::encoding::simd::detail::interleaved_to_planar_rgb8_scalar ( const uint8_t * src,
uint8_t * r,
uint8_t * g,
uint8_t * b,
size_t pixel_count )
inlinenoexcept

Definition at line 50 of file simd_rle.h.

52 {
53 for (size_t i = 0; i < pixel_count; ++i) {
54 r[i] = src[i * 3];
55 g[i] = src[i * 3 + 1];
56 b[i] = src[i * 3 + 2];
57 }
58}

Referenced by kcenon::pacs::encoding::simd::interleaved_to_planar_rgb8().

Here is the caller graph for this function:

◆ invert_monochrome_16bit_scalar()

void kcenon::pacs::encoding::simd::detail::invert_monochrome_16bit_scalar ( const uint16_t * src,
uint16_t * dst,
size_t pixel_count,
uint16_t max_value )
inlinenoexcept

Scalar 16-bit monochrome inversion.

Parameters
max_valueMaximum pixel value (e.g., 4095 for 12-bit, 65535 for 16-bit)

Definition at line 61 of file simd_photometric.h.

63 {
64 for (size_t i = 0; i < pixel_count; ++i) {
65 dst[i] = max_value - src[i];
66 }
67}

Referenced by kcenon::pacs::encoding::simd::invert_monochrome_16bit().

Here is the caller graph for this function:

◆ invert_monochrome_8bit_scalar()

void kcenon::pacs::encoding::simd::detail::invert_monochrome_8bit_scalar ( const uint8_t * src,
uint8_t * dst,
size_t pixel_count )
inlinenoexcept

Scalar 8-bit monochrome inversion (MONOCHROME1 <-> MONOCHROME2)

Definition at line 50 of file simd_photometric.h.

51 {
52 for (size_t i = 0; i < pixel_count; ++i) {
53 dst[i] = 255 - src[i];
54 }
55}

Referenced by kcenon::pacs::encoding::simd::invert_monochrome_8bit().

Here is the caller graph for this function:

◆ merge_planes_to_16bit_scalar()

void kcenon::pacs::encoding::simd::detail::merge_planes_to_16bit_scalar ( const uint8_t * high,
const uint8_t * low,
uint8_t * dst,
size_t pixel_count )
inlinenoexcept

Definition at line 79 of file simd_rle.h.

81 {
82 for (size_t i = 0; i < pixel_count; ++i) {
83 dst[i * 2] = low[i];
84 dst[i * 2 + 1] = high[i];
85 }
86}

Referenced by kcenon::pacs::encoding::simd::merge_planes_to_16bit().

Here is the caller graph for this function:

◆ planar_to_interleaved_rgb8_scalar()

void kcenon::pacs::encoding::simd::detail::planar_to_interleaved_rgb8_scalar ( const uint8_t * r,
const uint8_t * g,
const uint8_t * b,
uint8_t * dst,
size_t pixel_count )
inlinenoexcept

Definition at line 60 of file simd_rle.h.

62 {
63 for (size_t i = 0; i < pixel_count; ++i) {
64 dst[i * 3] = r[i];
65 dst[i * 3 + 1] = g[i];
66 dst[i * 3 + 2] = b[i];
67 }
68}

Referenced by kcenon::pacs::encoding::simd::planar_to_interleaved_rgb8().

Here is the caller graph for this function:

◆ rgb_to_ycbcr_8bit_scalar()

void kcenon::pacs::encoding::simd::detail::rgb_to_ycbcr_8bit_scalar ( const uint8_t * src,
uint8_t * dst,
size_t pixel_count )
inlinenoexcept

Scalar RGB to YCbCr conversion (ITU-R BT.601)

Y = 0.299*R + 0.587*G + 0.114*B Cb = -0.169*R - 0.331*G + 0.500*B + 128 Cr = 0.500*R - 0.419*G - 0.081*B + 128

Definition at line 76 of file simd_photometric.h.

77 {
78 for (size_t i = 0; i < pixel_count; ++i) {
79 const int r = src[i * 3];
80 const int g = src[i * 3 + 1];
81 const int b = src[i * 3 + 2];
82
83 // Fixed-point arithmetic (16.16 format for precision)
84 // Coefficients scaled by 65536
85 const int y = (19595 * r + 38470 * g + 7471 * b + 32768) >> 16;
86 const int cb = (-11056 * r - 21712 * g + 32768 * b + 32768) >> 16;
87 const int cr = (32768 * r - 27440 * g - 5328 * b + 32768) >> 16;
88
89 dst[i * 3] = static_cast<uint8_t>(y < 0 ? 0 : (y > 255 ? 255 : y));
90 dst[i * 3 + 1] = static_cast<uint8_t>(cb + 128);
91 dst[i * 3 + 2] = static_cast<uint8_t>(cr + 128);
92 }
93}

Referenced by kcenon::pacs::encoding::simd::rgb_to_ycbcr_8bit().

Here is the caller graph for this function:

◆ split_16bit_to_planes_scalar()

void kcenon::pacs::encoding::simd::detail::split_16bit_to_planes_scalar ( const uint8_t * src,
uint8_t * high,
uint8_t * low,
size_t pixel_count )
inlinenoexcept

Definition at line 70 of file simd_rle.h.

72 {
73 for (size_t i = 0; i < pixel_count; ++i) {
74 low[i] = src[i * 2];
75 high[i] = src[i * 2 + 1];
76 }
77}

Referenced by kcenon::pacs::encoding::simd::split_16bit_to_planes().

Here is the caller graph for this function:

◆ swap_bytes_16_scalar()

void kcenon::pacs::encoding::simd::detail::swap_bytes_16_scalar ( const uint8_t * src,
uint8_t * dst,
size_t byte_count )
inlinenoexcept

Definition at line 38 of file simd_utils.h.

39 {
40 for (size_t i = 0; i + 1 < byte_count; i += 2) {
41 dst[i] = src[i + 1];
42 dst[i + 1] = src[i];
43 }
44}

Referenced by kcenon::pacs::encoding::simd::swap_bytes_16_simd().

Here is the caller graph for this function:

◆ swap_bytes_32_scalar()

void kcenon::pacs::encoding::simd::detail::swap_bytes_32_scalar ( const uint8_t * src,
uint8_t * dst,
size_t byte_count )
inlinenoexcept

Definition at line 46 of file simd_utils.h.

47 {
48 for (size_t i = 0; i + 3 < byte_count; i += 4) {
49 dst[i] = src[i + 3];
50 dst[i + 1] = src[i + 2];
51 dst[i + 2] = src[i + 1];
52 dst[i + 3] = src[i];
53 }
54}

Referenced by kcenon::pacs::encoding::simd::swap_bytes_32_simd().

Here is the caller graph for this function:

◆ swap_bytes_64_scalar()

void kcenon::pacs::encoding::simd::detail::swap_bytes_64_scalar ( const uint8_t * src,
uint8_t * dst,
size_t byte_count )
inlinenoexcept

Definition at line 56 of file simd_utils.h.

57 {
58 for (size_t i = 0; i + 7 < byte_count; i += 8) {
59 dst[i] = src[i + 7];
60 dst[i + 1] = src[i + 6];
61 dst[i + 2] = src[i + 5];
62 dst[i + 3] = src[i + 4];
63 dst[i + 4] = src[i + 3];
64 dst[i + 5] = src[i + 2];
65 dst[i + 6] = src[i + 1];
66 dst[i + 7] = src[i];
67 }
68}

Referenced by kcenon::pacs::encoding::simd::swap_bytes_64_simd().

Here is the caller graph for this function:

◆ ycbcr_to_rgb_8bit_scalar()

void kcenon::pacs::encoding::simd::detail::ycbcr_to_rgb_8bit_scalar ( const uint8_t * src,
uint8_t * dst,
size_t pixel_count )
inlinenoexcept

Scalar YCbCr to RGB conversion (ITU-R BT.601)

R = Y + 1.402*(Cr-128) G = Y - 0.344*(Cb-128) - 0.714*(Cr-128) B = Y + 1.772*(Cb-128)

Definition at line 102 of file simd_photometric.h.

103 {
104 for (size_t i = 0; i < pixel_count; ++i) {
105 const int y = src[i * 3];
106 const int cb = src[i * 3 + 1] - 128;
107 const int cr = src[i * 3 + 2] - 128;
108
109 // Fixed-point arithmetic (coefficients scaled by 65536)
110 const int r = y + ((91881 * cr + 32768) >> 16);
111 const int g = y - ((22554 * cb + 46802 * cr + 32768) >> 16);
112 const int b = y + ((116130 * cb + 32768) >> 16);
113
114 dst[i * 3] = static_cast<uint8_t>(r < 0 ? 0 : (r > 255 ? 255 : r));
115 dst[i * 3 + 1] = static_cast<uint8_t>(g < 0 ? 0 : (g > 255 ? 255 : g));
116 dst[i * 3 + 2] = static_cast<uint8_t>(b < 0 ? 0 : (b > 255 ? 255 : b));
117 }
118}

Referenced by kcenon::pacs::encoding::simd::ycbcr_to_rgb_8bit().

Here is the caller graph for this function: