Adding GDISP_IMAGE_PNG_Z_BUFFER_SIZE configuration option

This commit is contained in:
Joel Bodenmann 2017-01-10 10:43:01 +01:00
parent ffe01aef80
commit d3fb6b2cb9
4 changed files with 21 additions and 16 deletions

View File

@ -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: Add gwinListItemSetText() to replace text in a GWIN list item
FEATURE: Added GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE configuration option 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_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 *** *** Release 2.7 ***

View File

@ -138,6 +138,7 @@
// #define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 TRUE // #define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 TRUE
// #define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32 // #define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32
// #define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8 // #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_IMAGE_ACCOUNTING FALSE
//#define GDISP_NEED_PIXMAP FALSE //#define GDISP_NEED_PIXMAP FALSE

View File

@ -11,14 +11,6 @@
#include "gdisp_image_support.h" #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 * Structure definitions
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
@ -113,7 +105,7 @@ typedef struct PNG_zinflate {
PNG_zTree ltree; // The dynamic length tree PNG_zTree ltree; // The dynamic length tree
PNG_zTree dtree; // The dynamic distance 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 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; } PNG_zinflate;
// Put all the decoding structures together. // 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) // Wrap the zInflate buffer position (after increment)
#if (PNG_Z_BUFFER_SIZE & ~(PNG_Z_BUFFER_SIZE-1)) == PNG_Z_BUFFER_SIZE #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 &= PNG_Z_BUFFER_SIZE-1; } #define WRAP_ZBUF(x) { x &= GDISP_IMAGE_PNG_Z_BUFFER_SIZE-1; }
#else #else
#warning "PNG: PNG_Z_BUFFER_SIZE is more efficient as a power of 2" #warning "PNG: GDISP_IMAGE_PNG_Z_BUFFER_SIZE is more efficient as a power of 2"
#define WRAP_ZBUF(x) { if (x >= PNG_Z_BUFFER_SIZE) x = 0; } #define WRAP_ZBUF(x) { if (x >= GDISP_IMAGE_PNG_Z_BUFFER_SIZE) x = 0; }
#endif #endif
// Initialize the inflate decompressor // Initialize the inflate decompressor
@ -553,7 +545,7 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) {
// Get more bits from length code // Get more bits from length code
length = PNG_zGetBits(d, lbits[symbol]) + lbase[symbol]; 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; goto iserror;
// Get the distance code // Get the distance code
@ -563,12 +555,12 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) {
// Get more bits from distance code // Get more bits from distance code
offset = PNG_zGetBits(d, dbits[dist]) + dbase[dist]; 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; goto iserror;
// Work out the source buffer position allowing for wrapping // Work out the source buffer position allowing for wrapping
if (offset > d->z.bufend) if (offset > d->z.bufend)
offset -= PNG_Z_BUFFER_SIZE; offset -= GDISP_IMAGE_PNG_Z_BUFFER_SIZE;
offset = d->z.bufend - offset; offset = d->z.bufend - offset;
// Copy the matching string // Copy the matching string

View File

@ -535,6 +535,16 @@
#ifndef GDISP_IMAGE_PNG_FILE_BUFFER_SIZE #ifndef GDISP_IMAGE_PNG_FILE_BUFFER_SIZE
#define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8 #define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8
#endif #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
/** /**
* @} * @}
* *