From 290f7658786a0809b72444af1b83be1e0db37460 Mon Sep 17 00:00:00 2001 From: Anton Dukhovnikov Date: Sat, 22 Nov 2025 09:29:57 +1300 Subject: [PATCH] a few small tweaks to the public API Signed-off-by: Anton Dukhovnikov --- include/rawtoaces/image_converter.h | 18 +++++++++--------- include/rawtoaces/spectral_data.h | 2 +- include/rawtoaces/usage_timer.h | 2 +- src/rawtoaces_core/spectral_data.cpp | 2 +- src/rawtoaces_util/image_converter.cpp | 20 +++++++++++--------- src/rawtoaces_util/usage_timer.cpp | 3 ++- tests/test_image_converter.cpp | 5 +++-- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/include/rawtoaces/image_converter.h b/include/rawtoaces/image_converter.h index 38888647..d050a272 100644 --- a/include/rawtoaces/image_converter.h +++ b/include/rawtoaces/image_converter.h @@ -147,11 +147,11 @@ class ImageConverter bool parse_parameters( const OIIO::ArgParse &arg_parser ); /// Collects all illuminants supported by this version. - std::vector supported_illuminants(); + std::vector get_supported_illuminants() const; /// Collects all camera models for which spectral sensitivity data is /// available in the database. - std::vector supported_cameras(); + std::vector get_supported_cameras() const; /// Configures the converter using the requested white balance and colour /// matrix method, and the metadata of the file provided in `input_file`. @@ -160,14 +160,14 @@ class ImageConverter /// decode the pixels. /// @param input_filename /// A file name of the raw image file to read the metadata from. - /// @param options + /// @param hints /// Conversion hints to be passed to OIIO when reading an image file. /// The list can be pre- or post- updated with other hints, unrelated to /// the rawtoaces conversion. /// @result /// `true` if configured successfully. bool configure( - const std::string &input_filename, OIIO::ParamValueList &options ); + const std::string &input_filename, const OIIO::ParamValueList &hints ); /// Configures the converter using the requested white balance and colour /// matrix method, and the metadata of the given OIIO::ImageSpec object. @@ -181,8 +181,8 @@ class ImageConverter /// the rawtoaces conversion. /// @result /// `true` if configured successfully. - bool - configure( const OIIO::ImageSpec &imageSpec, OIIO::ParamValueList &hints ); + bool configure( + const OIIO::ImageSpec &imageSpec, const OIIO::ParamValueList &hints ); /// Load an image from a given `path` into a `buffer` using the `hints` /// calculated by the `configure` method. The hints can be manually @@ -261,19 +261,19 @@ class ImageConverter /// image. The multipliers become available after calling either of the /// two `configure` methods. /// @result a reference to the multipliers vector. - const std::vector &get_WB_multipliers(); + const std::vector &get_WB_multipliers() const; /// Get the solved input transform matrix of the currently processed image. /// The multipliers become available after calling either of the two /// `configure` methods. /// @result a reference to the matrix. - const std::vector> &get_IDT_matrix(); + const std::vector> &get_IDT_matrix() const; /// Get the solved chromatic adaptation transform matrix of the currently /// processed image. The multipliers become available after calling either /// of the two `configure` methods. /// @result a reference to the matrix. - const std::vector> &get_CAT_matrix(); + const std::vector> &get_CAT_matrix() const; private: // Solved transform of the current image. diff --git a/include/rawtoaces/spectral_data.h b/include/rawtoaces/spectral_data.h index 3b8c583a..73bf3986 100644 --- a/include/rawtoaces/spectral_data.h +++ b/include/rawtoaces/spectral_data.h @@ -86,7 +86,7 @@ struct Spectrum /// Integrate the spectral curve. /// @result the sum of all elements in `values`. - double integrate(); + double integrate() const; /// Find the maximum element in `values` /// @result the maximum element in `values`. diff --git a/include/rawtoaces/usage_timer.h b/include/rawtoaces/usage_timer.h index 002235b6..2df6be1c 100644 --- a/include/rawtoaces/usage_timer.h +++ b/include/rawtoaces/usage_timer.h @@ -24,7 +24,7 @@ class UsageTimer /// passed since the last invocation of `reset()`. /// @param path The file math to print. /// @param message The message to print. - void print( const std::string &path, const std::string &message ); + void print( const std::string &path, const std::string &message ) const; private: double _start_time = 0.0; diff --git a/src/rawtoaces_core/spectral_data.cpp b/src/rawtoaces_core/spectral_data.cpp index 534cdfe7..5b693871 100644 --- a/src/rawtoaces_core/spectral_data.cpp +++ b/src/rawtoaces_core/spectral_data.cpp @@ -151,7 +151,7 @@ void Spectrum::reshape() shape = ReferenceShape; } -double Spectrum::integrate() +double Spectrum::integrate() const { double result = 0; for ( auto &v: values ) diff --git a/src/rawtoaces_util/image_converter.cpp b/src/rawtoaces_util/image_converter.cpp index 801dbb0f..fb4f3942 100644 --- a/src/rawtoaces_util/image_converter.cpp +++ b/src/rawtoaces_util/image_converter.cpp @@ -910,7 +910,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser ) if ( arg_parser["list-cameras"].get() ) { - auto cameras = supported_cameras(); + auto cameras = get_supported_cameras(); std::cout << std::endl << "Spectral sensitivity data is available for the following cameras:" @@ -921,7 +921,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser ) if ( arg_parser["list-illuminants"].get() ) { - auto illuminants = supported_illuminants(); + auto illuminants = get_supported_illuminants(); std::cout << std::endl << "The following illuminants are supported:" << std::endl << OIIO::Strutil::join( illuminants, "\n" ) << std::endl; @@ -1169,7 +1169,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser ) return true; } -std::vector ImageConverter::supported_illuminants() +std::vector ImageConverter::get_supported_illuminants() const { std::vector result; @@ -1190,7 +1190,7 @@ std::vector ImageConverter::supported_illuminants() return result; } -std::vector ImageConverter::supported_cameras() +std::vector ImageConverter::get_supported_cameras() const { std::vector result; @@ -1242,8 +1242,9 @@ void fix_metadata( OIIO::ImageSpec &spec ) } bool ImageConverter::configure( - const std::string &input_filename, OIIO::ParamValueList &options ) + const std::string &input_filename, const OIIO::ParamValueList &hints = {} ) { + OIIO::ParamValueList options = hints; options["raw:ColorSpace"] = "XYZ"; options["raw:use_camera_wb"] = 0; options["raw:use_auto_wb"] = 0; @@ -1277,8 +1278,9 @@ bool ImageConverter::configure( // -G - green_matching() filter bool ImageConverter::configure( - const OIIO::ImageSpec &image_spec, OIIO::ParamValueList &options ) + const OIIO::ImageSpec &image_spec, const OIIO::ParamValueList &hints = {} ) { + OIIO::ParamValueList options = hints; options["raw:use_camera_wb"] = 0; options["raw:use_auto_wb"] = 0; @@ -1977,17 +1979,17 @@ bool ImageConverter::process_image( const std::string &input_filename ) return ( true ); } -const std::vector &ImageConverter::get_WB_multipliers() +const std::vector &ImageConverter::get_WB_multipliers() const { return _wb_multipliers; } -const std::vector> &ImageConverter::get_IDT_matrix() +const std::vector> &ImageConverter::get_IDT_matrix() const { return _idt_matrix; } -const std::vector> &ImageConverter::get_CAT_matrix() +const std::vector> &ImageConverter::get_CAT_matrix() const { return _cat_matrix; } diff --git a/src/rawtoaces_util/usage_timer.cpp b/src/rawtoaces_util/usage_timer.cpp index e5db0cc2..ebeb99b9 100644 --- a/src/rawtoaces_util/usage_timer.cpp +++ b/src/rawtoaces_util/usage_timer.cpp @@ -38,7 +38,8 @@ void UsageTimer::reset() } } -void UsageTimer::print( const std::string &path, const std::string &message ) +void UsageTimer::print( + const std::string &path, const std::string &message ) const { if ( enabled && _initialized ) { diff --git a/tests/test_image_converter.cpp b/tests/test_image_converter.cpp index 8481136e..68a0b9f8 100644 --- a/tests/test_image_converter.cpp +++ b/tests/test_image_converter.cpp @@ -728,7 +728,7 @@ std::string run_rawtoaces_with_data_dir( } /// This test verifies that when --list-cameras is provided, the method -/// calls supported_cameras() and outputs the camera list, then exits +/// calls get_supported_cameras() and outputs the camera list, then exits void test_parse_parameters_list_cameras( bool use_dir_path_arg = false ) { std::cout << std::endl @@ -771,7 +771,8 @@ void test_parse_parameters_list_cameras( bool use_dir_path_arg = false ) } /// This test verifies that when --list-illuminants is provided, the method -/// calls supported_illuminants() and outputs the illuminant list, then exits +/// calls get_supported_illuminants() and outputs the illuminant list, +/// then exits void test_parse_parameters_list_illuminants( bool use_dir_path_arg = false ) { std::cout << std::endl