diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-06-06 12:08:15 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-06-06 12:08:15 +1000 |
commit | 1a800b67d74c409fd2e4b6c11e04548b5bf5d999 (patch) | |
tree | 765634fbd5709cd48ccbc05c1852d4a9042fceb9 /source/core/StarImageProcessing.cpp | |
parent | bf79b358c0e0224fb06e35a0286ef10671f0d075 (diff) |
attempt at improving GCC ?saturation accuracy
[skip ci]
Diffstat (limited to 'source/core/StarImageProcessing.cpp')
-rw-r--r-- | source/core/StarImageProcessing.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/source/core/StarImageProcessing.cpp b/source/core/StarImageProcessing.cpp index 1cfd847..b18fcf1 100644 --- a/source/core/StarImageProcessing.cpp +++ b/source/core/StarImageProcessing.cpp @@ -354,6 +354,25 @@ StringList imageOperationReferences(List<ImageOperation> const& operations) { return references; } +#ifdef __GNUC__ +#pragma GCC push_options +#pragma GCC optimize("-fno-fast-math -fassociative-math -freciprocal-math") +#endif +static void processSaturationShift(Image& image, SaturationShiftImageOperation const* op) { + image.forEachPixel([&op](unsigned, unsigned, Vec4B& pixel) { + if (pixel[3] != 0) { + Color color = Color::rgba(pixel); + color.setSaturation(clamp(color.saturation() + op->saturationShiftAmount, 0.0f, 1.0f)); + pixel = color.toRgba(); + } + }); +} +#ifdef __GNUC__ +#pragma GCC pop_options +#endif + + + void processImageOperation(ImageOperation const& operation, Image& image, ImageReferenceCallback refCallback) { if (image.bytesPerPixel() == 3) { // Convert to an image format that has alpha so certain operations function properly @@ -365,13 +384,7 @@ void processImageOperation(ImageOperation const& operation, Image& image, ImageR pixel = Color::hueShiftVec4B(pixel, op->hueShiftAmount); }); } else if (auto op = operation.ptr<SaturationShiftImageOperation>()) { - image.forEachPixel([&op](unsigned, unsigned, Vec4B& pixel) { - if (pixel[3] != 0) { - Color color = Color::rgba(pixel); - color.setSaturation(clamp(color.saturation() + op->saturationShiftAmount, 0.0f, 1.0f)); - pixel = color.toRgba(); - } - }); + processSaturationShift(image, op); } else if (auto op = operation.ptr<BrightnessMultiplyImageOperation>()) { image.forEachPixel([&op](unsigned, unsigned, Vec4B& pixel) { if (pixel[3] != 0) { |