
<       for (s = 0; s < spp; s++)
---
>       #define MIN(a,b) ((a) < (b) ? (a) : (b))
>       for (s = 0; s < MIN(spp, MAX_SAMPLES); s++)
