Adding GDISP_IMAGE_PNG_Z_BUFFER_SIZE configuration option
This commit is contained in:
parent
ffe01aef80
commit
d3fb6b2cb9
@ -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 ***
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user