The hotpixel feature is disabled by default and the helper function
shouldn't be used outside development so the patch below could go in 0.16
(not that it need to but it shouldn't harm).
The helper function has been useful to me for verifying performance
improvements when recoding/rewriting/replacing an algorithm. Perhaps
it is useful to others (using profilers can be a bit overkill).
diff --git a/ufraw.h b/ufraw.h
index 914dfa4..d50cdc7 100644
--- a/ufraw.h
+++ b/ufraw.h
@@ -371,6 +371,8 @@ char *curve_buffer(CurveData *cp);
int ptr_array_insert_sorted (GPtrArray *array, const void *item, GCompareFunc
compare);
int ptr_array_find_sorted (const GPtrArray *array, const void *item,
GCompareFunc compare);
void ptr_array_insert_index (GPtrArray *array, const void *item, int index);
+/* helper function for time measurement -- development only */
+void timer(const char *what);
/* prototypes for functions in ufraw_conf.c */
int conf_load(conf_data *c, const char *confFilename);
diff --git a/ufraw_routines.c b/ufraw_routines.c
index 399a88f..4862561 100644
--- a/ufraw_routines.c
+++ b/ufraw_routines.c
@@ -22,6 +22,7 @@
#include <locale.h>
#include <stdlib.h> /* needed for canonicalize_file_name() */
#include <string.h>
+#include <sys/time.h>
#include "uf_glib.h"
#include <glib/gi18n.h>
#include "ufraw.h"
@@ -593,3 +594,22 @@ void ptr_array_insert_index (
memmove (root + index + 1, root + index, (length - index) * sizeof (void
*));
root [index] = item;
}
+
+// timer() calls start time measurement. When given a string it will
+// print the elapsed time. This function is not thread safe and results
+// can be deceptive in the usual ways: low in-kernel HZ, cache warming,
+// other [UI] threads, etc.
+void timer(const char *what)
+{
+ static struct timeval last;
+ struct timeval now;
+ unsigned ms;
+
+ gettimeofday(&now, NULL);
+ if (last.tv_sec && what) {
+ ms = (now.tv_sec - last.tv_sec) * 1000 +
+ (now.tv_usec - last.tv_usec) / 1000;
+ printf("%s: %u ms\n", what, ms);
+ }
+ last = now;
+}
diff --git a/ufraw_ufraw.c b/ufraw_ufraw.c
index eb4bb8d..871889b 100644
--- a/ufraw_ufraw.c
+++ b/ufraw_ufraw.c
@@ -907,6 +907,13 @@ no_distortion:
* of its neighbours. For simplicity border pixels are not considered.
*
* Reasonable values for uf->conf->hotpixel are in the range 0.5-10.
+ *
+ * OpenMP notes
+ * ------------
+ * The hot pixel count is updated atomically but this is merely for proof
+ * of concept: objdump -Sd shows a "lock addl $0x1,0x1f4(%edx) sequence.
+ * The algorithm uses pixel values from previous and next row anyway and
+ * whether or not pixels are marked makes a difference already.
*/
static void ufraw_shave_hotpixels(ufraw_data *uf, dcraw_image_type *img,
int width, int height, int colors, unsigned rgbMax)
@@ -919,6 +926,11 @@ static void ufraw_shave_hotpixels(ufraw_data *uf,
dcraw_image_type *img,
if (uf->conf->hotpixel <= 0.0)
return;
delta = rgbMax / (uf->conf->hotpixel + 1.0);
+#ifdef _OPENMP
+#pragma omp parallel for schedule(static,64) default(none) \
+ shared(uf,img,width,height,colors,rgbMax,delta) \
+ private(h,p,w,c,t,v,hi,i)
+#endif
for (h = 1; h < height - 1; ++h) {
p = img + 1 + h * width;
for (w = 1; w < width - 1; ++w, ++p) {
@@ -958,6 +970,9 @@ static void ufraw_shave_hotpixels(ufraw_data *uf,
dcraw_image_type *img,
memcpy(p[i], p[0], sizeof (p[i]));
}
p[0][c] = hi;
+#ifdef _OPENMP
+#pragma omp atomic
+#endif
++uf->hotpixels;
}
}
--
Frank
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
ufraw-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ufraw-devel