commit 4318dbe05142dd7229d4b44565b482ed50a7c381
parent 29251d61cd94e26caddc7fc03a1464fedf49309c
Author: Pandora <pandora@techfo.xyz>
Date: Thu, 7 Dec 2017 16:09:13 -0500
fix compiling for 32-bit machines / machine without SSE2
Diffstat:
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/blur.c b/blur.c
@@ -121,8 +121,8 @@ void blur_impl_horizontal_pass_generic(uint32_t *src, uint32_t *dst, int width,
rgbaIn[i] = *(src - k);
} else {
for (; i < KERNEL_SIZE; i++) {
- if ((long long) ((src + 4*i - HALF_KERNEL) + 1)
- > (long long) (o_src + (height * width)))
+ if ((uintptr_t) ((src + 4*i - HALF_KERNEL) + 1)
+ > (uintptr_t) (o_src + (height * width)))
break;
rgbaIn[i] = *(src + i - HALF_KERNEL);
}
diff --git a/blur.h b/blur.h
@@ -9,9 +9,10 @@
#define HALF_KERNEL KERNEL_SIZE / 2
void blur_image_surface(cairo_surface_t *surface, int sigma);
+#ifdef __SSE2__
void blur_impl_horizontal_pass_sse2(uint32_t *src, uint32_t *dst, int width, int height);
+#endif
void blur_impl_horizontal_pass_generic(uint32_t *src, uint32_t *dst, int width, int height);
-
#endif
diff --git a/blur_simd.c b/blur_simd.c
@@ -12,7 +12,7 @@
// number of xmm registers needed to store input pixels for given kernel size
#define REGISTERS_CNT (KERNEL_SIZE + 4/2) / 4
-
+#ifdef __SSE2__
void blur_impl_horizontal_pass_sse2(uint32_t *src, uint32_t *dst, int width, int height) {
uint32_t* o_src = src;
for (int row = 0; row < height; row++) {
@@ -46,8 +46,8 @@ void blur_impl_horizontal_pass_sse2(uint32_t *src, uint32_t *dst, int width, int
rgbaIn[k] = _mm_load_si128((__m128i*)(_rgbaIn + 4*k));
} else {
for (int k = 0; k < REGISTERS_CNT; k++) {
- if ((long long) (((__m128i*) src + 4*k - HALF_KERNEL) + 1)
- > (long long) (o_src + (height * width)))
+ if ((uintptr_t) (((__m128i*) src + 4*k - HALF_KERNEL) + 1)
+ > (uintptr_t) (o_src + (height * width)))
break;
rgbaIn[k] = _mm_loadu_si128((__m128i*)(src + 4*k - HALF_KERNEL));
}
@@ -76,4 +76,4 @@ void blur_impl_horizontal_pass_sse2(uint32_t *src, uint32_t *dst, int width, int
}
}
}
-
+#endif