Ticket #8353: Normal1o5x.patch

File Normal1o5x.patch, 1.8 KB (added by fingolfin, 20 years ago)

Slighly better 1.5x scaler (in theory, as it is untested)

  • scaler.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/scaler.cpp,v
    retrieving revision 1.63
    diff -u -d -r1.63 scaler.cpp
     
    103103        }
    104104}
    105105
     106#define INTERPOLATE             INTERPOLATE<bitFormat>
     107#define Q_INTERPOLATE   Q_INTERPOLATE<bitFormat>
     108
     109/**
     110 * Trivial nearest-neighbour 1.5x scaler.
     111 */
     112template<int bitFormat>
     113void Normal1o5xTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
     114                                                        int width, int height) {
     115        uint8 *r;
     116        const uint32 dstPitch2 = dstPitch * 2;
     117        const uint32 dstPitch3 = dstPitch * 3;
     118        const uint32 srcPitch2 = srcPitch * 2;
     119
     120        assert(((int)dstPtr & 1) == 0);
     121        while (height) {
     122                r = dstPtr;
     123                for (int i = 0; i < width; i += 2, r += 6) {
     124                        uint16 color0 = *(((const uint16 *)srcPtr) + i);
     125                        uint16 color1 = *(((const uint16 *)srcPtr) + i + 1);
     126                        uint16 color2 = *(((const uint16 *)(srcPtr + srcPitch)) + i);
     127                        uint16 color3 = *(((const uint16 *)(srcPtr + srcPitch)) + i + 1);
     128
     129                        *(uint16 *)(r + 0) = color0;
     130                        *(uint16 *)(r + 2) = INTERPOLATE(color0, color1);
     131                        *(uint16 *)(r + 4) = color1;
     132                        *(uint16 *)(r + 0 + dstPitch) = INTERPOLATE(color0, color2);
     133                        *(uint16 *)(r + 2 + dstPitch) = Q_INTERPOLATE(color0, color1, color2, color3);
     134                        *(uint16 *)(r + 4 + dstPitch) = INTERPOLATE(color1, color1);
     135                        *(uint16 *)(r + 0 + dstPitch2) = color2;
     136                        *(uint16 *)(r + 2 + dstPitch2) = INTERPOLATE(color2, color3);
     137                        *(uint16 *)(r + 4 + dstPitch2) = color3;
     138                }
     139                srcPtr += srcPitch2;
     140                dstPtr += dstPitch3;
     141                height -= 2;
     142        }
     143}
     144MAKE_WRAPPER(Normal1o5x)
     145
    106146/**
    107147 * Trivial 'scaler' - in fact it doesn't do any scaling but just copies the
    108148 * source to the destionation.