Ticket #8262: alignment.diff

File alignment.diff, 2.1 KB (added by eriktorbjorn, 18 years ago)

Experimental patch against a July 20 CVS snapshot

  • scummvm/common/scaler.cpp

    diff -ur ScummVM+orig/scummvm/common/scaler.cpp ScummVM+hack/scummvm/common/scaler.cpp
    old new  
    685685#if ASPECT_MODE == kFastAndNiceAspectMode
    686686template<int scale>
    687687static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) {
    688 
    689         // TODO: This code may not work correctly on architectures that require alignment.
    690         // And even on those which accept it, reading/writing 32 bits words from odd memory
    691         // locations usually has a speed penalty. Hence, it might be wise to first check
    692         // if the dst address is odd, in which case we blit one pixel first; then we
    693         // blit pixel pairs, till we get to the end, at which point we may have to blit
    694         // again a single seperate pixel. This would of course cause additional overhead
    695         // for each blitted line. Some of that overhead can be avoid by moving
    696         // this logic into stretch200To240, since whether dst is at an odd position, and
    697         // whether the last pixel has to be blitted seperately or not, is identical for
    698         // each blitted line.
    699         //
    700        
    701         if (width & 1) {
    702                 // For efficency reasons we normally blit two pixels at a time; but if the
    703                 // width is odd, we first blit a single pixel.
    704                 width--;
    705                 if (scale == 1) {
    706                         uint32 B = *srcB++;
    707                         *dst++ = (uint16)Q_INTERPOLATE(*srcA++, B, B, B);
    708                 } else {
    709                         *dst++ = (uint16)INTERPOLATE(*srcA++, *srcB++);
    710                 }
    711         }
     688        // For efficiency reasons we blit two pixels at a time, so it is
     689        // important that makeRectStretchable() guarantees that the width is
     690        // even and that the rect starts on a well-aligned address. (Even
     691        // where unaligned memory access is allowed there may be a speed
     692        // penalty for it.)
    712693
    713694        width /= 2;
    714695        const uint32 *sA = (const uint32 *)srcA;
     
    737718                y -= m;
    738719                h += m;
    739720        }
     721
     722#if ASPECT_MODE == kFastAndNiceAspectMode
     723        // FIXME: Is this enough to guarantee that memory access will be
     724        // well aligned?
     725
     726        if (x & 1) {
     727                x--;
     728                w++;
     729        }
     730
     731        if (w & 1)
     732                w++;
     733#endif
    740734}
    741735
    742736/**