diff options
author | Joel Bodenmann <joel@embedded.pro> | 2017-01-10 10:43:01 +0100 |
---|---|---|
committer | Joel Bodenmann <joel@embedded.pro> | 2017-01-10 10:43:01 +0100 |
commit | d3fb6b2cb9cf353630374ceeb7d6c550a3a942d9 (patch) | |
tree | 6171770f38b5789b91e3392fbaf8e22bcd21694d /src/gdisp | |
parent | ffe01aef80c5eddd650d037a80df76ca4932d135 (diff) | |
download | uGFX-d3fb6b2cb9cf353630374ceeb7d6c550a3a942d9.tar.gz uGFX-d3fb6b2cb9cf353630374ceeb7d6c550a3a942d9.tar.bz2 uGFX-d3fb6b2cb9cf353630374ceeb7d6c550a3a942d9.zip |
Adding GDISP_IMAGE_PNG_Z_BUFFER_SIZE configuration option
Diffstat (limited to 'src/gdisp')
-rw-r--r-- | src/gdisp/gdisp_image_png.c | 24 | ||||
-rw-r--r-- | src/gdisp/gdisp_options.h | 10 |
2 files changed, 18 insertions, 16 deletions
diff --git a/src/gdisp/gdisp_image_png.c b/src/gdisp/gdisp_image_png.c index 1b3c2469..f7389a29 100644 --- a/src/gdisp/gdisp_image_png.c +++ b/src/gdisp/gdisp_image_png.c @@ -11,14 +11,6 @@ #include "gdisp_image_support.h" -/** - * How big a byte array to use for inflate decompression - * Bigger is faster but uses more RAM. - * Must be >= 32768 due to the PNG 32K sliding window - * More efficient code is generated if it is a power of 2 - */ -#define PNG_Z_BUFFER_SIZE 32768 - /*----------------------------------------------------------------- * Structure definitions *---------------------------------------------------------------*/ @@ -113,7 +105,7 @@ typedef struct PNG_zinflate { PNG_zTree ltree; // The dynamic length tree PNG_zTree dtree; // The dynamic distance tree uint8_t tmp[288+32]; // Temporary space for decoding dynamic trees and other temporary uses - uint8_t buf[PNG_Z_BUFFER_SIZE]; // The decoding buffer and sliding window + uint8_t buf[GDISP_IMAGE_PNG_Z_BUFFER_SIZE]; // The decoding buffer and sliding window } PNG_zinflate; // Put all the decoding structures together. @@ -272,11 +264,11 @@ static void PNG_oColor(PNG_output *o, color_t c) { *---------------------------------------------------------------*/ // Wrap the zInflate buffer position (after increment) -#if (PNG_Z_BUFFER_SIZE & ~(PNG_Z_BUFFER_SIZE-1)) == PNG_Z_BUFFER_SIZE - #define WRAP_ZBUF(x) { x &= PNG_Z_BUFFER_SIZE-1; } +#if (GDISP_IMAGE_PNG_Z_BUFFER_SIZE & ~(GDISP_IMAGE_PNG_Z_BUFFER_SIZE-1)) == GDISP_IMAGE_PNG_Z_BUFFER_SIZE + #define WRAP_ZBUF(x) { x &= GDISP_IMAGE_PNG_Z_BUFFER_SIZE-1; } #else - #warning "PNG: PNG_Z_BUFFER_SIZE is more efficient as a power of 2" - #define WRAP_ZBUF(x) { if (x >= PNG_Z_BUFFER_SIZE) x = 0; } + #warning "PNG: GDISP_IMAGE_PNG_Z_BUFFER_SIZE is more efficient as a power of 2" + #define WRAP_ZBUF(x) { if (x >= GDISP_IMAGE_PNG_Z_BUFFER_SIZE) x = 0; } #endif // Initialize the inflate decompressor @@ -553,7 +545,7 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) { // Get more bits from length code length = PNG_zGetBits(d, lbits[symbol]) + lbase[symbol]; - if ((d->z.flags & PNG_ZFLG_EOF) || length >= PNG_Z_BUFFER_SIZE) // Bad length? + if ((d->z.flags & PNG_ZFLG_EOF) || length >= GDISP_IMAGE_PNG_Z_BUFFER_SIZE) // Bad length? goto iserror; // Get the distance code @@ -563,12 +555,12 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) { // Get more bits from distance code offset = PNG_zGetBits(d, dbits[dist]) + dbase[dist]; - if ((d->z.flags & PNG_ZFLG_EOF) || offset >= PNG_Z_BUFFER_SIZE) // Bad offset? + if ((d->z.flags & PNG_ZFLG_EOF) || offset >= GDISP_IMAGE_PNG_Z_BUFFER_SIZE) // Bad offset? goto iserror; // Work out the source buffer position allowing for wrapping if (offset > d->z.bufend) - offset -= PNG_Z_BUFFER_SIZE; + offset -= GDISP_IMAGE_PNG_Z_BUFFER_SIZE; offset = d->z.bufend - offset; // Copy the matching string diff --git a/src/gdisp/gdisp_options.h b/src/gdisp/gdisp_options.h index 32429cde..0b250cd9 100644 --- a/src/gdisp/gdisp_options.h +++ b/src/gdisp/gdisp_options.h @@ -535,6 +535,16 @@ #ifndef GDISP_IMAGE_PNG_FILE_BUFFER_SIZE #define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8 #endif + /** + * @brief The PNG inflate decompression buffer size in bytes. + * @details Defaults to 32768 + * @note Bigger is faster but requires more RAM. + * @note Must be >= 32768 due to the PNG 32K sliding window. + * @note More efficient code is generated if this value is a power of 2. + */ + #ifndef GDISP_IMAGE_PNG_Z_BUFFER_SIZE + #define GDISP_IMAGE_PNG_Z_BUFFER_SIZE 32768 + #endif /** * @} * |