From eacc0b41d888634202e4f37ab6275533be1ba81e Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 30 May 2016 16:29:32 +0300 Subject: [PATCH] Fix PlanarToDirect() optimization. --- od-win32/picasso96_win.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index b782fdd2..05efb248 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -3823,23 +3823,24 @@ static void PlanarToDirect (TrapContext *ctx, struct RenderInfo *ri, struct BitM // most operations use only low palette values // do not fetch and convert whole palette unless needed if (v > maxc) { - if (v < 4) - v = 4; - else if (v < 8) - v = 8; - else if (v < 16) - v = 16; - else if (v < 32) - v = 32; - else if (v < 64) - v = 64; + int vc = v; + if (vc < 3) + vc = 3; + else if (vc < 7) + vc = 7; + else if (vc < 15) + vc = 15; + else if (vc < 31) + vc = 32; + else if (vc < 63) + vc = 63; else - v = 256; - trap_get_longs(ctx, &cim[maxc + 1], acim + 4 + (maxc + 1) * 4, v - maxc); - for (int i = maxc + 1; i <= v; i++) { + vc = 255; + trap_get_longs(ctx, &cim[maxc + 1], acim + 4 + (maxc + 1) * 4, vc - maxc); + for (int i = maxc + 1; i <= vc; i++) { endianswap(&cim[i], bpp); } - maxc = v; + maxc = vc; } -- 2.47.3