diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-04-01 11:26:22 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-04-09 15:20:57 +0100 |
commit | 5aa0fc3b008e976a0d61a55814666229f2da47c8 (patch) | |
tree | cb7702db27a216ddfd897af5d617edd56a97bce3 /apps/recorder/jpeg_load.h | |
parent | 7718b244011661a5273121d1b545a18f1a5cd497 (diff) | |
download | rockbox-5aa0fc3b008e976a0d61a55814666229f2da47c8.tar.gz rockbox-5aa0fc3b008e976a0d61a55814666229f2da47c8.zip |
jpeg: provide a rough estimate of decoder memory overhead
JPEG decoding requires additional space in the bitmap buffer beyond
what is needed for the decoded pixel data. Provide a way to estimate
how much overhead is needed.
The actual overhead is sizeof(struct jpeg) + decode_buf_size, where
the latter depends on the image size and JPEG encoding used. From my
testing decode_buf_size is normally pretty small (under 5 KiB) but
looking at the code it could be large in some cases, primarily with
large images, so 32 KiB seems to be a decent compromise. Someone who
knows better about JPEG should pick a better value if that's too big.
Using a constant is obviously not the most accurate but it seems to
be the simplest option for retrofitting to existing code.
Change-Id: I573b0abb8ca2d79e43f185010487f07226edb793
Diffstat (limited to 'apps/recorder/jpeg_load.h')
-rw-r--r-- | apps/recorder/jpeg_load.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/apps/recorder/jpeg_load.h b/apps/recorder/jpeg_load.h index 6ff96dabad..129b0fbf19 100644 --- a/apps/recorder/jpeg_load.h +++ b/apps/recorder/jpeg_load.h | |||
@@ -32,6 +32,13 @@ | |||
32 | #ifndef _JPEG_LOAD_H | 32 | #ifndef _JPEG_LOAD_H |
33 | #define _JPEG_LOAD_H | 33 | #define _JPEG_LOAD_H |
34 | 34 | ||
35 | /* Approximate memory overhead required for JPEG decoding. This memory is | ||
36 | * taken from the bitmap buffer so you must ensure the buffer is big enough | ||
37 | * to contain all decoded pixel data plus decoder overhead, otherwise the | ||
38 | * image cannot be loaded. After the image is loaded this extra memory can | ||
39 | * be freed. */ | ||
40 | extern const size_t JPEG_DECODE_OVERHEAD; | ||
41 | |||
35 | int read_jpeg_file(const char* filename, | 42 | int read_jpeg_file(const char* filename, |
36 | struct bitmap *bm, | 43 | struct bitmap *bm, |
37 | int maxsize, | 44 | int maxsize, |