[gimp] Bug 788394 - Crash (segmentation fault) when calculating a histogram ...
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 788394 - Crash (segmentation fault) when calculating a histogram ...
- Date: Tue, 7 Nov 2017 23:34:00 +0000 (UTC)
commit b2b6552f1fe60ad2f276c537ca4cede3d2a1c362
Author: Ell <ell_se yahoo com>
Date: Tue Nov 7 18:11:24 2017 -0500
Bug 788394 - Crash (segmentation fault) when calculating a histogram ...
... upon NaN values
Make the histogram bin calculation NaN-safe, by mapping NaNs to 0.
Ideally, NaNs should probably not be counted at all, but since we
already count negative values as 0, and > 1 values as 1, we might
as well not pessimize performance over it, at least until we add
support for unbounded histograms.
At the same time, improve rounding in the bin calculation, so that
the result is more accurate.
app/core/gimphistogram.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c
index 1f50e36..1cf92d8 100644
--- a/app/core/gimphistogram.c
+++ b/app/core/gimphistogram.c
@@ -237,6 +237,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
const Babl *format;
gint n_components;
gint n_bins;
+ gint temp;
g_return_if_fail (GIMP_IS_HISTOGRAM (histogram));
g_return_if_fail (GEGL_IS_BUFFER (buffer));
@@ -324,9 +325,9 @@ gimp_histogram_calculate (GimpHistogram *histogram,
babl_format ("Y float"),
GEGL_ACCESS_READ, GEGL_ABYSS_NONE);
-#define VALUE(c,i) (priv->values[(c) * priv->n_bins + \
- (gint) (CLAMP ((i), 0.0, 1.0) * \
- (priv->n_bins - 0.0001))])
+#define VALUE(c,i) (*(temp = SIGNED_ROUND ((i) * (priv->n_bins - 1)), \
+ &priv->values[(c) * priv->n_bins + \
+ CLAMP (temp, 0, priv->n_bins - 1)]))
while (gegl_buffer_iterator_next (iter))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]