Commit 4fd21d58 authored by Pascal Massimino's avatar Pascal Massimino Committed by Michael Niedermayer

libavcodec/webp: treat out-of-bound palette index as translucent black

See https://code.google.com/p/webp/issues/detail?id=206
for a description of the problem/fix.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>

This patch makes the decoder follow the recommendation of the spec.
There is some disagreement (see "[FFmpeg-devel] [PATCH]: libavcodec/webp")
about what would be best to be written in the spec, so in case the spec
is changed again, this potentially would need to be amended or reverted
parent 59af5383
...@@ -1028,7 +1028,7 @@ static int apply_color_indexing_transform(WebPContext *s) ...@@ -1028,7 +1028,7 @@ static int apply_color_indexing_transform(WebPContext *s)
ImageContext *img; ImageContext *img;
ImageContext *pal; ImageContext *pal;
int i, x, y; int i, x, y;
uint8_t *p, *pi; uint8_t *p;
img = &s->image[IMAGE_ROLE_ARGB]; img = &s->image[IMAGE_ROLE_ARGB];
pal = &s->image[IMAGE_ROLE_COLOR_INDEXING]; pal = &s->image[IMAGE_ROLE_COLOR_INDEXING];
...@@ -1066,11 +1066,11 @@ static int apply_color_indexing_transform(WebPContext *s) ...@@ -1066,11 +1066,11 @@ static int apply_color_indexing_transform(WebPContext *s)
p = GET_PIXEL(img->frame, x, y); p = GET_PIXEL(img->frame, x, y);
i = p[2]; i = p[2];
if (i >= pal->frame->width) { if (i >= pal->frame->width) {
av_log(s->avctx, AV_LOG_ERROR, "invalid palette index %d\n", i); AV_WB32(p, 0xFF000000);
return AVERROR_INVALIDDATA; } else {
const uint8_t *pi = GET_PIXEL(pal->frame, i, 0);
AV_COPY32(p, pi);
} }
pi = GET_PIXEL(pal->frame, i, 0);
AV_COPY32(p, pi);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment