Issue 288 in webp: Image decoding uses too much memory with crop and and alpha channel

84 views
Skip to first unread message

nikola.mihaylov@gmail.com via Monorail

unread,
Feb 15, 2016, 11:54:42 PM2/15/16
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 288 by nikola.m...@gmail.com: Image decoding uses too much memory with crop and and alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=288

What steps will reproduce the problem?
1. Try decoding a small cropped region of a 4096x4096 image, encoded with lossy RGB and lossless alpha channel (default options for cwebp)
    WebPDecoderConfig config;
    WebPInitDecoderConfig(&config);

    config.output.colorspace = MODE_bgrA; // premultiplied alpha
    config.output.u.RGBA.rgba = (uint8_t*)toPtr;
    config.output.u.RGBA.stride = toScanlineSizeBytes;
    config.output.u.RGBA.size = toSizeBytes;
    config.output.is_external_memory = 1;

    config.options.use_cropping = true;
    config.options.crop_left = 0;
    config.options.crop_top = 0;
    config.options.crop_width = 100;
    config.options.crop_height = 100;

    config.options.no_fancy_upsampling = true;
    config.options.bypass_filtering = true;

    WebPDecode((uint8_t *)fromPtr, fromSizeBytes, &config);


What is the expected output? What do you see instead?
Expected: image decodes and uses small amount of memory (e.g. 40k, 100k)
Actual: phone application crashes with out of memory because alpha channel decoding allocates 67 MB of memory.


What version of the product are you using? On what operating system?
Any

Please provide any additional information below.
According to the Advanced Decoding API section here: https://developers.google.com/speed/webp/docs/api decoding should use only memory related to the output size, not decode the complete input when cropping is applied. I tried with lossy alpha to no effect.
The function doing the allocation is:
static int AllocateInternalBuffers32b(VP8LDecoder* const dec, int final_width) 
in libwebp\dec\vp8l.c



-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

nikola.mihaylov@gmail.com via Monorail

unread,
Feb 15, 2016, 11:57:03 PM2/15/16
to webp-d...@webmproject.org
Comment #1 on issue 288 by nikola.m...@gmail.com: Image decoding uses too much memory with crop and and alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=288#c1

I have a spritesheet encoded as .webp in order to reduce memory/storage size for thousands of files. I only need to load part of the sprites at runtime, thus using webp to achieve this. 

-- 
You received this message because:
  1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

pascal.massimino@gmail.com via Monorail

unread,
Mar 18, 2016, 10:50:36 AM3/18/16
to webp-d...@webmproject.org
Updates:
Status: Started

Comment #2 on issue 288 by pascal.m...@gmail.com: Image decoding uses too much memory with crop and and alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=288#c2

acknowledged, lossless decoding is using quite some memory (inherently). But it's not optimized for cropping and decoding only a sub-part of the initial image.
One difficulty is that the lossless format needs several passes when transforms are used (which is quite frequent).

However, they might be some improvements to try:
* use crop_bottom value to limit the decoding (could save some CPU and memory).
* for alpha in particular, only save the cropped alpha plane, and not the entire plane as is done right now.

I've started some code in that direction (patch #333712 for instance[1]).

One suggestion, meanwhile: you might be better off decoding the whole spritesheet once (and only once) and subsequently carve out the sprites from this sheet (instead of re-decoding the image every time you need to crop a new sprite).

[1] https://chromium-review.googlesource.com/333712

nikola.mihaylov@gmail.com via Monorail

unread,
Mar 22, 2016, 10:21:26 PM3/22/16
to webp-d...@webmproject.org

Comment #3 on issue 288 by nikola.m...@gmail.com: Image decoding uses too much memory with crop and and alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=288#c3

Thanks a lot for replying and working on it!
- re: crop_bottom: sounds good, however eventually I'll have to decode the sprite at the bottom and I'll run out of memory
- re: save cropped alpha plane - not sure what you mean?

Unfortunately, I can't decode the entire spritesheet once (not enough memory)
The decoded spritesheet takes more RAM than the amount of memory for the device that my app should run on.

hatchj1… via monorail

unread,
Jun 1, 2019, 12:48:05 AM6/1/19
to webp-d...@webmproject.org

Comment #5 on issue 288 by hatchj1...@gmail.com: Image decoding uses too much memory with crop and and alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=288#c5

Delete all my information and subscriptions the police are investigating and know I have been hacked- block me ASAP

Attachments:
A9F76B4D-E85C-44B4-933D-937FA400BC52.png 265 KB

asosu… via monorail

unread,
Jan 7, 2021, 3:39:43 AM1/7/21
to webp-d...@webmproject.org

Comment #6 on issue 288 by asosu...@gmail.com: Image decoding uses too much memory with crop and and alpha channel
https://bugs.chromium.org/p/webp/issues/detail?id=288#c6

i should not be in any projects. Is this how someone is remotely connecting to my phone and i can never connect to anything because i have a ton of outdated certificates in my laptop and phone that i didnt up load nor do i even know how to, get me off of all these projects i am not in any ones organisation
Reply all
Reply to author
Forward
0 new messages