mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 12:28:26 +01:00
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:
parent
52a87dd7ff
commit
a06f802325
13
src/dec/io.c
13
src/dec/io.c
@ -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;
|
||||||
if (alpha != NULL) {
|
const WebPYUVABuffer* const buf = &p->output->u.YUVA;
|
||||||
int j;
|
|
||||||
const int mb_w = io->mb_w;
|
const int mb_w = io->mb_w;
|
||||||
const int mb_h = io->mb_h;
|
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;
|
uint8_t* dst = buf->a + io->mb_y * buf->a_stride;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
if (alpha != NULL) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user