Mercurial > hg > dmlib
changeset 1444:5be4e2eec84f
Add dmSmoothMap() function to efu test.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 10 May 2018 04:39:34 +0300 |
parents | 57e97e58cbf3 |
children | 60337b31e427 |
files | tests/efu.c |
diffstat | 1 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/efu.c Thu May 10 04:36:03 2018 +0300 +++ b/tests/efu.c Thu May 10 04:39:34 2018 +0300 @@ -276,6 +276,36 @@ } } +#define Q_KERNEL(x, y, dist, coeff) ( \ + in[(y) - (dist)][(x)] * (coeff) + \ + in[(y) + (dist)][(x)] * (coeff) + \ + in[(y)][(x) - (dist)] * (coeff) + \ + in[(y)][(x) + (dist)] * (coeff) + \ + in[(y) - (dist)][(x) - (2)] * (coeff) + \ + in[(y) - (dist)][(x) + (2)] * (coeff) + \ + in[(y) + (dist)][(x) - (2)] * (coeff) + \ + in[(y) + (dist)][(x) + (2)] * (coeff)) + +#define Q_VALUES(coeff) (8 * (coeff)) + +void dmSmoothMap(DMBlockMap out, DMBlockMap in) +{ + int x, y; + + for (y = 0; y < QHEIGHT; y++) + for (x = 0; x < QWIDTH; x++) + { + if (y >= 3 && x >= 3 && y < QHEIGHT - 3 && x < QWIDTH - 3) + out[y][x] = ( + Q_KERNEL(x, y, 3, 1) + + Q_KERNEL(x, y, 2, 2) + + Q_KERNEL(x, y, 1, 4) + + in[y][x] * 16) / + (16 + Q_VALUES(1) + Q_VALUES(2) + Q_VALUES(4)); + else + out[y][x] = in[y][x]; + } +} int main(int argc, char *argv[]) {