From 7b6b8b7d817a2c26f3e8ef9b7e763ac22174ec96 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 25 Dec 2009 02:23:36 -0800 Subject: slight tweaks. slightly faster --- src/scale.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/scale.c b/src/scale.c index 6555af3..92db4a8 100644 --- a/src/scale.c +++ b/src/scale.c @@ -46,8 +46,8 @@ static void superscale(struct image *img, unsigned int width, unsigned int heigh TDEBUG_START - int divx[bytesperline]; - int divy[bytesperline]; + unsigned int divx[bytesperline]; + unsigned int divy[bytesperline]; memset(divx, 0, sizeof divx); memset(divy, 0, sizeof divy); for(x = 0; x < img->bufwidth; x++){ @@ -57,27 +57,29 @@ static void superscale(struct image *img, unsigned int width, unsigned int heigh divy[y * height / img->bufheight]++; } - int xoff[img->bufwidth]; + unsigned int tmp[width * 4]; + + unsigned int *xoff[img->bufwidth]; for(x = 0; x < img->bufwidth; x++){ - xoff[x] = (x * width / img->bufwidth) * 3; + xoff[x] = tmp + (x * width / img->bufwidth) * 3; } - int tmp[width * 4]; unsigned int y0; + int * __restrict__ dest; for(y = 0; y < img->bufheight;){ - int ydiv = divy[y * height / img->bufheight]; + unsigned int ydiv = divy[y * height / img->bufheight]; char * __restrict__ ydest = &newBuf[bytesperline * (y * height / img->bufheight)]; memset(tmp, 0, sizeof tmp); ibuf = &img->buf[y * img->bufwidth * 3]; - for(y0 = y; y < y0 + ydiv; y++){ + for(y0 = y + ydiv; y < y0; y++){ for(x = 0; x < img->bufwidth; x++){ - int * __restrict__ dest = tmp + xoff[x]; + dest = xoff[x]; for(i = 0; i < 3; i++){ *dest++ += *ibuf++; } } } - int * __restrict__ src = tmp; + unsigned int * __restrict__ src = tmp; for(x = 0; x < width; x++){ ydest[2] = *src++ / ydiv / divx[x]; ydest[1] = *src++ / ydiv / divx[x]; -- cgit v1.2.3