WebPDecodeRGBA Does not work on solid color images (palette encoded)

86 views
Skip to first unread message

jdl0624

unread,
Apr 29, 2021, 4:52:04 PM4/29/21
to WebP Discussion
res = WebPDecodeRGBA(data, data_size, &width, &height);

This does not work if the encoding is the palette type.

WebPDecoderConfig config;
WebPDecBuffer* const output_buffer = &config.output;
WebPBitstreamFeatures* const bitstream = &config.input;
WebPGetFeatures(data, length, bitstream);
output_buffer->colorspace = MODE_RGBA;
VP8StatusCode status = WebPDecode(data, length, &config);

broke it down into pieces and the status code was 3 (VP8_STATUS_BITSTREAM_ERROR)

Pascal Massimino

unread,
Apr 30, 2021, 7:30:50 AM4/30/21
to WebP Discussion
Hi,

some recommendations:

On Thu, Apr 29, 2021 at 10:52 PM jdl0624 <neverwi...@gmail.com> wrote:
res = WebPDecodeRGBA(data, data_size, &width, &height);

This does not work if the encoding is the palette type.

WebPDecoderConfig config;

Don't forget to call WebPInitDecoderConfig(&config);
 
WebPDecBuffer* const output_buffer = &config.output;
WebPBitstreamFeatures* const bitstream = &config.input;
WebPGetFeatures(data, length, bitstream);

you should check the return value is equal to VP8_STATUS_OKjust to be sure...
 
output_buffer->colorspace = MODE_RGBA;
VP8StatusCode status = WebPDecode(data, length, &config);

broke it down into pieces and the status code was 3 (VP8_STATUS_BITSTREAM_ERROR)

hope it helps,
skal/
 

Pascal Massimino

unread,
May 1, 2021, 2:10:24 AM5/1/21
to jdl0624, WebP Discussion
Hi,

On Sat, May 1, 2021 at 5:18 AM jdl0624 <neverwi...@gmail.com> wrote:
AYE, thanks for the input but I finally figured it out:

I added some padding to the buffer (it was only 32 bytes) and it worked again!

ah! That's interesting, and could be an invalid check in the libwebp code.
Could you open a bug in the tracker, please? (or just send me the 32-byte bitstream)

Thanks!
skal/



For some reason if the input data is too small, the algorithm fails! You have to add padding.
ARGH! LOL. That was a lot of pain.

Pascal Massimino

unread,
May 1, 2021, 2:14:02 AM5/1/21
to jdl0624, WebP Discussion
On Sat, May 1, 2021 at 8:10 AM Pascal Massimino <pascal.m...@gmail.com> wrote:
Hi,

On Sat, May 1, 2021 at 5:18 AM jdl0624 <neverwi...@gmail.com> wrote:
AYE, thanks for the input but I finally figured it out:

I added some padding to the buffer (it was only 32 bytes) and it worked again!

ah! That's interesting, and could be an invalid check in the libwebp code.
Could you open a bug in the tracker, please? (or just send me the 32-byte bitstream)

Nevermind, i just saw you opened issue #519. Thanks for doing that!

skal/
Reply all
Reply to author
Forward
0 new messages