1 #pragma version(1) 2 #pragma rs_fp_relaxed 3 4 #include "ip.rsh" 5 6 void root(float4 *out, const void *usrData, uint32_t x, uint32_t y) { 7 const FilterStruct *fs = (const FilterStruct *)usrData; 8 float3 blurredPixel = 0; 9 const float *gPtr = fs->gaussian; 10 if ((x > fs->radius) && (x < (fs->width - fs->radius))) { 11 for (int r = -fs->radius; r <= fs->radius; r ++) { 12 const float4 *i = (const float4 *)rsGetElementAt(fs->ain, x + r, y); 13 blurredPixel += i->xyz * gPtr[0]; 14 gPtr++; 15 } 16 } else { 17 for (int r = -fs->radius; r <= fs->radius; r ++) { 18 // Stepping left and right away from the pixel 19 int validX = rsClamp((int)x + r, (int)0, (int)(fs->width - 1)); 20 const float4 *i = (const float4 *)rsGetElementAt(fs->ain, validX, y); 21 blurredPixel += i->xyz * gPtr[0]; 22 gPtr++; 23 } 24 } 25 26 out->xyz = blurredPixel; 27 } 28 29