From c554c8541e6b30fc4cf9bf858184cac8a5c8df1b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 8 Mar 2010 20:11:44 +0000 Subject: WINCE: Rewrote SmartphoneLandscape scaler C version to match what the ARM assembler version does (untested) svn-id: r48198 --- backends/platform/wince/CEScaler.cpp | 32 +++++++++++++++++++++----------- backends/platform/wince/CEScaler.h | 7 ++----- 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'backends') diff --git a/backends/platform/wince/CEScaler.cpp b/backends/platform/wince/CEScaler.cpp index cb97907497..a8f5931e79 100644 --- a/backends/platform/wince/CEScaler.cpp +++ b/backends/platform/wince/CEScaler.cpp @@ -41,26 +41,36 @@ void SmartphoneLandscape(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, ui template void SmartphoneLandscapeTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint8 *work; int line = 0; - while (height--) { - work = dstPtr; + assert((width % 16) == 0); - for (int i = 0; i < width; i += 3) { - // Filter 2/3 - uint16 color1 = *(((const uint16 *)srcPtr) + i); - uint16 color2 = *(((const uint16 *)srcPtr) + (i + 1)); - uint16 color3 = *(((const uint16 *)srcPtr) + (i + 2)); + while (height--) { + uint16 *d = (uint16 *)dstPtr; - *(((uint16 *)work) + 0) = interpolate32_3_1(color1, color2); - *(((uint16 *)work) + 1) = interpolate32_3_1(color3, color2); + const uint16 *s = (const uint16 *)srcPtr; + for (int i = 0; i < width; i += 16) { + // Downscale horizontally to 11/16. + // See smartLandScale.s for an explanation of the scale pattern. + *d++ = interpolate32_3_1(s[0], s[1]); + *d++ = interpolate32_1_1(s[1], s[2]); + *d++ = interpolate32_3_1(s[3], s[2]); + *d++ = interpolate32_1_1(s[4], s[5]); + *d++ = interpolate32_3_1(s[6], s[7]); + *d++ = interpolate32_1_1(s[7], s[8]); + *d++ = interpolate32_3_1(s[9], s[8]); + *d++ = interpolate32_1_1(s[10], s[11]); + *d++ = interpolate32_3_1(s[12], s[13]); + *d++ = interpolate32_1_1(s[13], s[14]); + *d++ = interpolate32_3_1(s[15], s[14]); - work += 2 * sizeof(uint16); + s += 16; } srcPtr += srcPitch; dstPtr += dstPitch; line++; + + // Skip every 8th row if (line == 7) { line = 0; srcPtr += srcPitch; diff --git a/backends/platform/wince/CEScaler.h b/backends/platform/wince/CEScaler.h index a51cd5528c..c93e1c66ca 100644 --- a/backends/platform/wince/CEScaler.h +++ b/backends/platform/wince/CEScaler.h @@ -32,11 +32,8 @@ #include "graphics/scaler/intern.h" /** - * This filter (down)scales the source image horizontally by a factor of 2/3 - * and vertically by 7/8. For example, a 320x200 image is scaled to 213x175. - * - * @note The ARM asm version seems to work differently ?!? It apparently scales - * horizontally by 11/16. Thus a 320x200 image is scaled to 220x175. + * This filter (down)scales the source image horizontally by a factor of 11/16 + * and vertically by 7/8. For example, a 320x200 image is scaled to 220x175. */ DECLARE_SCALER(SmartphoneLandscape); -- cgit v1.2.3