MODE_YUVA: set alpha to opaque if the image has none

this change avoids returning uninitialized alpha values when decoding
lossy with alpha to YUVA

Change-Id: I1e02459ac28b36f1f2b422063d057a5faba2f8f2
This commit is contained in:
James Zern 2012-08-03 10:43:51 -07:00
parent 52a87dd7ff
commit a06f802325

View File

@ -162,17 +162,24 @@ static int EmitFancyRGB(const VP8Io* const io, WebPDecParams* const p) {
static int EmitAlphaYUV(const VP8Io* const io, WebPDecParams* const p) { static int EmitAlphaYUV(const VP8Io* const io, WebPDecParams* const p) {
const uint8_t* alpha = io->a; const uint8_t* alpha = io->a;
const WebPYUVABuffer* const buf = &p->output->u.YUVA;
const int mb_w = io->mb_w;
const int mb_h = io->mb_h;
uint8_t* dst = buf->a + io->mb_y * buf->a_stride;
int j;
if (alpha != NULL) { if (alpha != NULL) {
int j;
const int mb_w = io->mb_w;
const int mb_h = io->mb_h;
const WebPYUVABuffer* const buf = &p->output->u.YUVA;
uint8_t* dst = buf->a + io->mb_y * buf->a_stride;
for (j = 0; j < mb_h; ++j) { for (j = 0; j < mb_h; ++j) {
memcpy(dst, alpha, mb_w * sizeof(*dst)); memcpy(dst, alpha, mb_w * sizeof(*dst));
alpha += io->width; alpha += io->width;
dst += buf->a_stride; dst += buf->a_stride;
} }
} else if (buf->a != NULL) {
// the user requested alpha, but there is none, set it to opaque.
for (j = 0; j < mb_h; ++j) {
memset(dst, 0xff, mb_w * sizeof(*dst));
dst += buf->a_stride;
}
} }
return 0; return 0;
} }