byte* Decode_WEBP(const byte* dataIn, int length, int& width, int& height)
{
byte* image = 0;
WebPDecoderConfig config;
if (WebPInitDecoderConfig(&config))
{
WebPBitstreamFeatures* const bitstream = &config.input;
WebPDecBuffer* const outputBuffer = &config.output;
outputBuffer->colorspace = MODE_RGBA;
const uint8_t* data = (const uint8_t*)dataIn;
VP8StatusCode status = WebPGetFeatures(data, size_t(length), bitstream);
if (status == VP8_STATUS_OK)
{
status = ExUtilDecodeWebP(data, size_t(length), 0, &config);
if (status == VP8_STATUS_OK)
{
width = outputBuffer->width;
height = outputBuffer->height;
int renderWidth = NextHigherPOT(width, true);
int renderHeight = NextHigherPOT(height, true);
image = new byte[renderWidth * renderHeight * 4];
assert(outputBuffer->u.RGBA.size == width * height * 4);
const byte* rgb = (const byte*)outputBuffer->u.RGBA.rgba;
if (width == renderWidth && height == renderHeight) // NPOT textures support
memcpy(image, rgb, width * height * 4);
else // no NPOT textures support
{
memset(image, 0, renderWidth * renderHeight * 4 * sizeof(byte));
for (int i = 0; i < height; ++i)
memcpy(&image[i * renderWidth * 4], &rgb[i * width * 4], width * 4 * sizeof(byte));
}
WebPFreeDecBuffer(outputBuffer);
}
}
}
return image;
}
--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss+unsubscribe@webmproject.org.
To post to this group, send email to webp-d...@webmproject.org.
Visit this group at https://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.
Hello!
I use webp for storing images in my game and faced that webp decode is several times slower that png. :(
For example, on iPad3 (old hardware, but retina etxtures) 2048x2048 webp file with compression level 0.7 decodes 3.2 seconds with 0.5.1.sources ( it was 3.8 with 0.4.3), Png decode time is 0.8 second.
Is there ways to improve decode time? For example:
- Use never cwebp.exe encoder (I use rather old version from here: https://www.codeandweb.com/texturepacker)
- Change the compression level (how?)
- Check if the code below may be optimized (it just works, but I never thought of its optimization)
- Anything else?
--
I can't test right now on iPad3, but something seems off. On an x86_64, your webp file decodes 30% faster than PNG (with latest libwebp at HEAD), and that's the expected figure. You webp file uses 'mixed' mode, where the RGB is compressed lossily, and the alpha plane (transparency) with lossless compression. Using only lossless mode for all (cwebp -z 9 ... ) would result in a larger file (~1M). This file would be even faster to decompress (70% faster here).I'm not sure about your setup on the iPad, but you should check that optimizations are turned on if you compiled the library yourself.
Hi skal,
Can we return to the issue? Could you run the simple project I attached on XCode?
My results are (Simulator / iPad mini 1st gen/ iPhone 5s):
png: 69 / 388 / 197 ms
webp mixed mode: 86 / 613 / 219 ms
webp near lossless 40: 65 / 515 / 170 ms
webp lossless: 142 / 1090 / 372 ms
--
Hi Denis,
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
Hi skal,
Thank you for analyzing the test project, and sorry for a bug, which downperformed lossless packing!
But the original question still exists. No test shows us webp speed preference against png.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss+unsubscribe@webmproject.org.
Hi skal,
BTW, is there a way to know about stable releases? Mailing list or so?
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss+unsubscribe@webmproject.org.