Fix decode bug for rgbA_4444/RGBA_4444 color-modes.

The WEBP_SWAP_16BIT_CSP flag needs to be honored while filling the Alpha (4 bits)
data in the destination buffer and while pre-multiplying the alpha to RGB colors.

Change-Id: I3b07307d60963db8d09c3b078888a839cefb35ba
This commit is contained in:
Vikas Arora
2014-02-03 09:19:22 -08:00
parent 939e70e7d3
commit 1d1cd3bbd6
2 changed files with 18 additions and 0 deletions

View File

@ -281,6 +281,15 @@ static void ApplyAlphaMultiply4444(uint8_t* rgba4444,
while (h-- > 0) {
int i;
for (i = 0; i < w; ++i) {
#ifdef WEBP_SWAP_16BIT_CSP
const uint8_t a = (rgba4444[2 * i + 0] & 0x0f);
const uint32_t mult = MULTIPLIER(a);
const uint8_t r = multiply(dither_hi(rgba4444[2 * i + 1]), mult);
const uint8_t g = multiply(dither_lo(rgba4444[2 * i + 1]), mult);
const uint8_t b = multiply(dither_hi(rgba4444[2 * i + 0]), mult);
rgba4444[2 * i + 1] = (r & 0xf0) | ((g >> 4) & 0x0f);
rgba4444[2 * i + 0] = (b & 0xf0) | a;
#else
const uint8_t a = (rgba4444[2 * i + 1] & 0x0f);
const uint32_t mult = MULTIPLIER(a);
const uint8_t r = multiply(dither_hi(rgba4444[2 * i + 0]), mult);
@ -288,6 +297,7 @@ static void ApplyAlphaMultiply4444(uint8_t* rgba4444,
const uint8_t b = multiply(dither_hi(rgba4444[2 * i + 1]), mult);
rgba4444[2 * i + 0] = (r & 0xf0) | ((g >> 4) & 0x0f);
rgba4444[2 * i + 1] = (b & 0xf0) | a;
#endif
}
rgba4444 += stride;
}