+#define BLUR(w, h, pstep, sstep) \
+ for(i=0; i<h; i++) { \
+ int sum = sptr[0] * (rad + 1); \
+ int count = (rad * 2 + 1) << 8; \
+ int midsize = w - rad * 2; \
+ int firstpix = sptr[0]; \
+ int lastpix = sptr[pstep * (w - 1)]; \
+ /* add up the contributions for the -1 pixel */ \
+ for(j=0; j<rad; j++) { \
+ sum += sptr[pstep * j]; \
+ } \
+ /* first part adding sptr[rad] and subtracting sptr[0] */ \
+ for(j=0; j<=rad; j++) { \
+ sum += (int)sptr[pstep * rad] - firstpix; \
+ sptr += pstep; \
+ *dptr = scale * sum / count; \
+ dptr += pstep; \
+ } \
+ /* middle part adding sptr[rad] and subtracting sptr[-(rad+1)] */ \
+ for(j=1; j<midsize; j++) { \
+ sum += (int)sptr[pstep * rad] - (int)sptr[-(rad + 1) * pstep]; \
+ sptr += pstep; \
+ *dptr = scale * sum / count; \
+ dptr += pstep; \
+ } \
+ /* last part adding lastpix and subtracting sptr[-(rad+1)] */ \
+ for(j=0; j<rad; j++) { \
+ sum += lastpix - (int)sptr[-(rad + 1) * pstep]; \
+ sptr += pstep; \
+ *dptr = scale * sum / count; \
+ dptr += pstep; \
+ } \
+ sptr += sstep; \
+ dptr += sstep; \
+ }
+