Skip to content

Commit 5c35536

Browse files
authored
fix: remove c++ includes from tone_mapping.hpp (#279)
1 parent d0bcbbf commit 5c35536

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

opencv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func (f *Framebuffer) ApplyToneMapping(icc []byte) error {
316316
iccPtr = unsafe.Pointer(&icc[0])
317317
}
318318

319-
toneMappedMat := C.apply_tone_mapping_ffi(
319+
toneMappedMat := C.apply_tone_mapping(
320320
f.mat,
321321
(*C.uint8_t)(iccPtr),
322322
C.size_t(len(icc)))

tone_mapping.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "tone_mapping.hpp"
2+
#include <opencv2/opencv.hpp>
3+
#include <lcms2.h>
24
#include <cstring>
35
#include <memory>
46
#include <algorithm>
@@ -12,6 +14,18 @@ static inline float calculate_luminance(float r, float g, float b) {
1214
return 0.2126f * r + 0.7152f * g + 0.0722f * b;
1315
}
1416

17+
/**
18+
* Applies HDR to SDR tone mapping using Reinhard algorithm.
19+
*
20+
* This function detects PQ (Perceptual Quantizer) HDR profiles and applies
21+
* luminance-based tone mapping to reduce brightness while preserving color
22+
* relationships. Non-PQ images are returned unchanged (as a copy).
23+
*
24+
* @param src Source image (BGR or BGRA format, 8-bit)
25+
* @param icc_data ICC profile data from the source image
26+
* @param icc_len Length of ICC profile data in bytes
27+
* @return Tone-mapped image (caller owns the pointer), or nullptr on error
28+
*/
1529
cv::Mat* apply_hdr_to_sdr_tone_mapping(
1630
const cv::Mat* src,
1731
const uint8_t* icc_data,
@@ -146,7 +160,7 @@ cv::Mat* apply_hdr_to_sdr_tone_mapping(
146160
// C FFI wrapper for tone mapping
147161
extern "C" {
148162

149-
opencv_mat apply_tone_mapping_ffi(
163+
opencv_mat apply_tone_mapping(
150164
const opencv_mat src,
151165
const uint8_t* icc_data,
152166
size_t icc_len

tone_mapping.hpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern "C" {
1515
* Returns a new opencv_mat (caller must release with opencv_mat_release).
1616
* Returns NULL on error.
1717
*/
18-
opencv_mat apply_tone_mapping_ffi(
18+
opencv_mat apply_tone_mapping(
1919
const opencv_mat src,
2020
const uint8_t* icc_data,
2121
size_t icc_len
@@ -24,27 +24,3 @@ opencv_mat apply_tone_mapping_ffi(
2424
#ifdef __cplusplus
2525
}
2626
#endif
27-
28-
// C++ implementation details (not visible to C/FFI)
29-
#ifdef __cplusplus
30-
#include <opencv2/opencv.hpp>
31-
#include <lcms2.h>
32-
33-
/**
34-
* Applies HDR to SDR tone mapping using Reinhard algorithm.
35-
*
36-
* This function detects PQ (Perceptual Quantizer) HDR profiles and applies
37-
* luminance-based tone mapping to reduce brightness while preserving color
38-
* relationships. Non-PQ images are returned unchanged (as a copy).
39-
*
40-
* @param src Source image (BGR or BGRA format, 8-bit)
41-
* @param icc_data ICC profile data from the source image
42-
* @param icc_len Length of ICC profile data in bytes
43-
* @return Tone-mapped image (caller owns the pointer), or nullptr on error
44-
*/
45-
cv::Mat* apply_hdr_to_sdr_tone_mapping(
46-
const cv::Mat* src,
47-
const uint8_t* icc_data,
48-
size_t icc_len
49-
);
50-
#endif

0 commit comments

Comments
 (0)