aboutsummaryrefslogtreecommitdiffstats
path: root/libglitter_redistribute_energy_double.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglitter_redistribute_energy_double.c')
-rw-r--r--libglitter_redistribute_energy_double.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/libglitter_redistribute_energy_double.c b/libglitter_redistribute_energy_double.c
new file mode 100644
index 0000000..3eb39e0
--- /dev/null
+++ b/libglitter_redistribute_energy_double.c
@@ -0,0 +1,80 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+static void
+hselfconvolute(double *restrict raster, size_t rowsize, size_t width, size_t height, size_t kernelsize, const double *hkernel)
+{
+ /* TODO */
+}
+
+
+static void
+hconvolute(double *restrict output, const double *restrict input, size_t output_rowsize, size_t input_rowsize,
+ size_t width, size_t height, size_t kernelsize, const double *kernel)
+{
+ /* TODO */
+}
+
+
+static void
+vconvolute(double *restrict output, const double *restrict input, size_t output_rowsize, size_t input_rowsize,
+ size_t width, size_t height, size_t kernelsize, const double *kernel)
+{
+ /* TODO */
+}
+
+
+static void
+copyraster(double *restrict output, const double *restrict input, size_t output_rowsize,
+ size_t input_rowsize, size_t width, size_t height)
+{
+ size_t y;
+ for (y = 0; y < height; y++) {
+ memcpy(output, input, width * sizeof(double));
+ output = &output[output_rowsize];
+ input = &input[input_rowsize];
+ }
+}
+
+
+void
+libglitter_redistribute_energy_double(double *restrict output, const double *restrict input, /* TODO add man page */
+ size_t output_rowsize, size_t input_rowsize, size_t width,
+ size_t height, size_t hkernelsize, size_t vkernelsize,
+ const double *hkernel, const double *vkernel)
+{
+ /* TODO Can we allow output==input ? */
+ if (vkernelsize > 1) {
+ vconvolute(output, input, output_rowsize, input_rowsize, width, height, vkernelsize, vkernel);
+ if (hkernelsize > 1)
+ hselfconvolute(output, output_rowsize, width, height, hkernelsize, hkernel);
+ } else if (hkernelsize > 1) {
+ vconvolute(output, input, output_rowsize, input_rowsize, width, height, hkernelsize, hkernel);
+ } else {
+ copyraster(output, input, output_rowsize, input_rowsize, width, height);
+ }
+}
+
+
+#else
+
+
+#define TOLERANCE 0.0001
+
+static int
+eq(double a, double b)
+{
+ double r = a - b;
+ return (r < 0 ? -r : r) < TOLERANCE;
+}
+
+int
+main(void)
+{
+ return 0; /* TODO add test */
+}
+
+
+#endif