Skip to content

Commit

Permalink
Fixed incorrect usage of int_fast_t
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Dec 27, 2023
1 parent 1d003dc commit 1aa3200
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/lgfx/utility/lgfx_tjpgd.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static inline int32_t BYTECLIP (
/*---------------------------------------------*/

#if JD_BAYER
static const int_fast8_t Bayer[16] = { 0, 4, 1, 5,-2, 2,-1, 3, 1, 5, 0, 4,-1, 3,-2, 2};
static const int8_t Bayer[16] = { 0, 4, 1, 5,-2, 2,-1, 3, 1, 5, 0, 4,-1, 3,-2, 2};
#endif


Expand Down Expand Up @@ -299,7 +299,7 @@ static int32_t huffext ( /* >=0: decoded data, <0: error code */
{
const uint8_t* hb_end = hb + 16 + 1;
uint_fast8_t msk = jd->dbit;
uint_fast16_t w = *jd->dptr & ((1ul << msk) - 1);
uint32_t w = *jd->dptr & ((1ul << msk) - 1);
for (;;) {
if (!msk) { /* Next byte? */
uint8_t *dp = jd->dptr;
Expand Down Expand Up @@ -584,7 +584,7 @@ static JRESULT mcu_output (
iy = 0;
do {
#if JD_BAYER
const int_fast8_t* btbl = &Bayer[(iy & 3) << 2];
const int8_t* btbl = &Bayer[(iy & 3) << 2];
#endif
py = &jd->mcubuf[((iy & 8) + iy) << 3];
pc = &jd->mcubuf[((mx << iyshift) + (iy >> iyshift)) << 3];
Expand All @@ -596,10 +596,10 @@ static JRESULT mcu_output (
++pc;

/* Convert CbCr to RGB */
uint_fast16_t rr = ((int32_t)(1.402 * (1<<FP_SHIFT)) * cr) >> FP_SHIFT;
uint_fast16_t gg = ((int32_t)(0.34414 * (1<<FP_SHIFT)) * cb
int32_t rr = ((int32_t)(1.402 * (1<<FP_SHIFT)) * cr) >> FP_SHIFT;
int32_t gg = ((int32_t)(0.34414 * (1<<FP_SHIFT)) * cb
+ (int32_t)(0.71414 * (1<<FP_SHIFT)) * cr) >> FP_SHIFT;
uint_fast16_t bb = ((int32_t)(1.772 * (1<<FP_SHIFT)) * cb) >> FP_SHIFT;
int32_t bb = ((int32_t)(1.772 * (1<<FP_SHIFT)) * cb) >> FP_SHIFT;
do {
#if JD_BAYER
yy = *py + btbl[ix & 3]; /* Get Y component */
Expand Down
12 changes: 6 additions & 6 deletions src/lgfx/utility/lgfx_tjpgd.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ struct lgfxJdec {
uint8_t* dptr; /* Current data read ptr */
uint8_t* dpend; /* data end ptr */
uint8_t* inbuf; /* Bit stream input buffer */
uint_fast8_t dbit; /* Current bit in the current read byte */
uint_fast8_t scale; /* Output scaling ratio */
uint_fast8_t msx, msy; /* MCU size in unit of block (width, height) */
uint_fast8_t qtid[3]; /* Quantization table ID of each component */
uint8_t dbit; /* Current bit in the current read byte */
uint8_t scale; /* Output scaling ratio */
uint8_t msx, msy; /* MCU size in unit of block (width, height) */
uint8_t qtid[3]; /* Quantization table ID of each component */
int32_t dcv[3]; /* Previous DC element of each component */
uint16_t nrst; /* Restart inverval */
uint_fast16_t width, height;/* Size of the input image (pixel) */
uint16_t width, height;/* Size of the input image (pixel) */
uint8_t* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
uint16_t* huffcode[2][2]; /* Huffman code word tables [id][dcac] */
uint8_t* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
int32_t* qttbl[4]; /* Dequantizer tables [id] */
void* workbuf; /* Working buffer for IDCT and RGB output */
int16_t* mcubuf; /* Working buffer for the MCU */
uint8_t* pool; /* Pointer to available memory pool */
uint_fast16_t sz_pool; /* Size of momory pool (bytes available) */
uint16_t sz_pool; /* Size of momory pool (bytes available) */
uint32_t (*infunc)(void*, uint8_t*, uint32_t);/* Pointer to jpeg stream input function */
void* device; /* Pointer to I/O device identifiler for the session */
uint8_t comps_in_frame; /* 1=Y(grayscale) 3=YCrCb */
Expand Down

0 comments on commit 1aa3200

Please sign in to comment.