Browse Source

fix compiling for 32-bit machines / machine without SSE2

master
Pandora 7 years ago
parent
commit
4318dbe051
No known key found for this signature in database GPG Key ID: 55DB77C2A03E1EF5
  1. 4
      blur.c
  2. 3
      blur.h
  3. 8
      blur_simd.c

4
blur.c

@ -121,8 +121,8 @@ void blur_impl_horizontal_pass_generic(uint32_t *src, uint32_t *dst, int width,
rgbaIn[i] = *(src - k); rgbaIn[i] = *(src - k);
} else { } else {
for (; i < KERNEL_SIZE; i++) { for (; i < KERNEL_SIZE; i++) {
if ((long long) ((src + 4*i - HALF_KERNEL) + 1) if ((uintptr_t) ((src + 4*i - HALF_KERNEL) + 1)
> (long long) (o_src + (height * width))) > (uintptr_t) (o_src + (height * width)))
break; break;
rgbaIn[i] = *(src + i - HALF_KERNEL); rgbaIn[i] = *(src + i - HALF_KERNEL);
} }

3
blur.h

@ -9,9 +9,10 @@
#define HALF_KERNEL KERNEL_SIZE / 2 #define HALF_KERNEL KERNEL_SIZE / 2
void blur_image_surface(cairo_surface_t *surface, int sigma); 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); 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); void blur_impl_horizontal_pass_generic(uint32_t *src, uint32_t *dst, int width, int height);
#endif #endif

8
blur_simd.c

@ -12,7 +12,7 @@
// number of xmm registers needed to store input pixels for given kernel size // number of xmm registers needed to store input pixels for given kernel size
#define REGISTERS_CNT (KERNEL_SIZE + 4/2) / 4 #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) { void blur_impl_horizontal_pass_sse2(uint32_t *src, uint32_t *dst, int width, int height) {
uint32_t* o_src = src; uint32_t* o_src = src;
for (int row = 0; row < height; row++) { 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)); rgbaIn[k] = _mm_load_si128((__m128i*)(_rgbaIn + 4*k));
} else { } else {
for (int k = 0; k < REGISTERS_CNT; k++) { for (int k = 0; k < REGISTERS_CNT; k++) {
if ((long long) (((__m128i*) src + 4*k - HALF_KERNEL) + 1) if ((uintptr_t) (((__m128i*) src + 4*k - HALF_KERNEL) + 1)
> (long long) (o_src + (height * width))) > (uintptr_t) (o_src + (height * width)))
break; break;
rgbaIn[k] = _mm_loadu_si128((__m128i*)(src + 4*k - HALF_KERNEL)); 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

Loading…
Cancel
Save