aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@embedded.pro>2017-01-10 10:43:01 +0100
committerJoel Bodenmann <joel@embedded.pro>2017-01-10 10:43:01 +0100
commitd3fb6b2cb9cf353630374ceeb7d6c550a3a942d9 (patch)
tree6171770f38b5789b91e3392fbaf8e22bcd21694d
parentffe01aef80c5eddd650d037a80df76ca4932d135 (diff)
downloaduGFX-d3fb6b2cb9cf353630374ceeb7d6c550a3a942d9.tar.gz
uGFX-d3fb6b2cb9cf353630374ceeb7d6c550a3a942d9.tar.bz2
uGFX-d3fb6b2cb9cf353630374ceeb7d6c550a3a942d9.zip
Adding GDISP_IMAGE_PNG_Z_BUFFER_SIZE configuration option
-rw-r--r--changelog.txt2
-rw-r--r--gfxconf.example.h1
-rw-r--r--src/gdisp/gdisp_image_png.c24
-rw-r--r--src/gdisp/gdisp_options.h10
4 files changed, 21 insertions, 16 deletions
diff --git a/changelog.txt b/changelog.txt
index 30d6c79e..339a95a2 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -11,6 +11,8 @@ FEATURE: Add support for a GFILE user provided file system
FEATURE: Add gwinListItemSetText() to replace text in a GWIN list item
FEATURE: Added GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE configuration option
FEATURE: Added GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE configuration option
+FEATURE: Added GDISP_IMAGE_PNG_FILE_BUFFER_SIZE configuration option
+FEATURE: Added GDISP_IMAGE_PNG_Z_BUFFER_SIZE configuration option
*** Release 2.7 ***
diff --git a/gfxconf.example.h b/gfxconf.example.h
index c7b836bf..67792d26 100644
--- a/gfxconf.example.h
+++ b/gfxconf.example.h
@@ -138,6 +138,7 @@
// #define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 TRUE
// #define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32
// #define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8
+// #define GDISP_IMAGE_PNG_Z_BUFFER_SIZE 32768
// #define GDISP_NEED_IMAGE_ACCOUNTING FALSE
//#define GDISP_NEED_PIXMAP FALSE
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
/**
* @}
*