Fix 64-bit bilinear scaled image sampling

A constraint ensuring we do not sample beyond the current scan-line
was missing in the SSE2 optimized sampling.

Discovered with lancelot.

Change-Id: Ib0ece8f8bfaa034733873dc5b8baaaad5d4c0380
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
bb10
Allan Sandfeld Jensen 2016-08-03 14:20:54 +02:00 committed by Allan Sandfeld Jensen
parent bc4ce55fff
commit b643d6f347
1 changed files with 7 additions and 1 deletions

View File

@ -2815,10 +2815,16 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co
sbuf2[i * 2 + 1] = ((const uint*)s2)[x2];
fx += fdx;
}
int fastLen;
if (fdx > 0)
fastLen = qMin(len, int((image_x2 - (fx >> 16)) / data->m11));
else
fastLen = qMin(len, int((image_x1 - (fx >> 16)) / data->m11));
fastLen -= 3;
const __m128i v_fdx = _mm_set1_epi32(fdx*4);
__m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx);
for (; i < len-3; i+=4) {
for (; i < fastLen; i += 4) {
int offset = _mm_extract_epi16(v_fx, 1);
sbuf1[i * 2 + 0] = ((const uint*)s1)[offset];
sbuf1[i * 2 + 1] = ((const uint*)s1)[offset + 1];