diff --git a/src/dec/io.c b/src/dec/io.c index e718acf6..0f2c8d10 100644 --- a/src/dec/io.c +++ b/src/dec/io.c @@ -250,7 +250,11 @@ static int EmitAlphaRGBA4444(const VP8Io* const io, WebPDecParams* const p) { int num_rows; const int start_y = GetAlphaSourceRow(io, &alpha, &num_rows); uint8_t* const base_rgba = buf->rgba + start_y * buf->stride; +#ifdef WEBP_SWAP_16BIT_CSP + uint8_t* alpha_dst = base_rgba; +#else uint8_t* alpha_dst = base_rgba + 1; +#endif uint32_t alpha_mask = 0x0f; int i, j; @@ -435,7 +439,11 @@ static int ExportAlpha(WebPDecParams* const p, int y_pos) { static int ExportAlphaRGBA4444(WebPDecParams* const p, int y_pos) { const WebPRGBABuffer* const buf = &p->output->u.RGBA; uint8_t* const base_rgba = buf->rgba + (p->last_y + y_pos) * buf->stride; +#ifdef WEBP_SWAP_16BIT_CSP + uint8_t* alpha_dst = base_rgba; +#else uint8_t* alpha_dst = base_rgba + 1; +#endif int num_lines_out = 0; const WEBP_CSP_MODE colorspace = p->output->colorspace; const int width = p->scaler_a.dst_width; diff --git a/src/dsp/upsampling.c b/src/dsp/upsampling.c index e90310e8..5f1c1278 100644 --- a/src/dsp/upsampling.c +++ b/src/dsp/upsampling.c @@ -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; }