From 867e42c6fa58c55da6e16f04db4741f2e821123e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 25 May 2003 21:54:01 +0000 Subject: optimized GetResult, based on code by Bertrand Augereau svn-id: r7974 --- common/scaler.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'common') diff --git a/common/scaler.cpp b/common/scaler.cpp index 8ad000d56a..ef9cc68cce 100644 --- a/common/scaler.cpp +++ b/common/scaler.cpp @@ -70,24 +70,23 @@ int Init_2xSaI(uint32 BitFormat) { return 1; } -static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D) { - int x = 0; - int y = 0; - int r = 0; - - if (A == C) - x += 1; - else if (B == C) - y += 1; - if (A == D) - x += 1; - else if (B == D) - y += 1; - if (x <= 1) - r += 1; - if (y <= 1) - r -= 1; - return r; +static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D) { + const bool ac = (A==C); + const bool bc = (B==C); + const int x1 = ac; + const int y1 = (bc && !ac); + const bool ad = (A==D); + const bool bd = (B==D); + const int x2 = ad; + const int y2 = (bd && !ad); + const int x = x1+x2; + const int y = y1+y2; + static const int rmap[3][3] = { + {0, 0, -1}, + {0, 0, -1}, + {1, 1, 0} + }; + return rmap[y][x]; } static inline uint32 INTERPOLATE(uint32 A, uint32 B) { -- cgit v1.2.3