bitbank2/JPEGDEC

Building with both JPEGDEC and PNGDEC - compiler warnings

Closed this issue · 1 comments

KurtE commented

Describe the bug
Compiler warnings

To Reproduce
Create a sketch that includes both of your libraries.
Make sure the Arduino IDE is setup to show you all messages.
Note: I am building for a Teensy. In the current case for a variant of the Teensy Micromod.

In my current case, I am playing with an Image viewer which displays images that are contained on an SDCard onto the display,
currently it is using JPEGDEC (using your RGB8888), BMP files - using code in sketch, and PNG files. Currently playing with a WIP Parallel display library for the NT35510 display... I have been seeing this before but never got around to reporting, but the library that I am currently playing:
https://github.com/KurtE/NT35510_t4x_p

Sketch is in the example: nt35510_tft_picture_view_24bit

You will see a set of messages like:

In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:45:
c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src/PNGdec.h:208: warning: "INTELSHORT" redefined
  208 | #define INTELSHORT(p) ((*p) + (*(p+1)<<8))
      | 
In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:42:
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src/JPEGDEC.h:301: note: this is the location of the previous definition
  301 | #define INTELSHORT(p) (*(uint16_t *)p)
      | 
In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:45:
c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src/PNGdec.h:209: warning: "INTELLONG" redefined
  209 | #define INTELLONG(p) ((*p) + (*(p+1)<<8) + (*(p+2)<<16) + (*(p+3)<<24))
      | 
In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:42:
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src/JPEGDEC.h:302: note: this is the location of the previous definition
  302 | #define INTELLONG(p) (*(uint32_t *)p)
      | 
In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:45:
c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src/PNGdec.h:210: warning: "MOTOSHORT" redefined
  210 | #define MOTOSHORT(p) (((*(p))<<8) + (*(p+1)))
      | 
In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:42:
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src/JPEGDEC.h:303: note: this is the location of the previous definition
  303 | #define MOTOSHORT(p) __builtin_bswap16(*(uint16_t *)p)
      | 
In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:45:
c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src/PNGdec.h:211: warning: "MOTOLONG" redefined
  211 | #define MOTOLONG(p) (((*p)<<24) + ((*(p+1))<<16) + ((*(p+2))<<8) + (*(p+3)))
      | 
In file included from D:\github\NT35510_t4x_p\examples\nt35510_tft_picture_view_24bit\nt35510_tft_picture_view_24bit.ino:42:
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src/JPEGDEC.h:307: note: this is the location of the previous definition
  307 | #define MOTOLONG(p) __builtin_bswap32(*(uint32_t *)p)
      | 

Note: there are some other warnings as well:

In file included from c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src\JPEGDEC.cpp:36:
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src\jpeg.inl: In function 'int JPEGMakeHuffTables(JPEGIMAGE*, int)':
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src\jpeg.inl:1175:37: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
 1175 |             if (iTable * HUFF11SIZE >= sizeof(pJPEG->usHuffAC) / 2)
      |                 ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src\jpeg.inl: In function 'void JPEGIDCT(JPEGIMAGE*, int, int)':
c:\Users\kurte\Documents\Arduino\libraries\JPEGDEC\src\jpeg.inl:2263:19: warning: unused variable 'ucColMask' [-Wunused-variable]
 2263 |     unsigned char ucColMask;
      |                   ^~~~~~~~~

Expected behavior
No compiler warnings, except my own.

Additional context
There is also a warning in the PNGDEC as well, should probably be its own issue (or punted)

In file included from c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src\PNGdec.cpp:29:
c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src\png.inl: In member function 'void PNG::getLineAsRGB565(PNGDRAW*, uint16_t*, int, uint32_t)':
c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src\png.inl:411:27: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
  411 |                         c <<= 1;
      |                         ~~^~~~~
c:\Users\kurte\Documents\Arduino\libraries\PNGdec\src\png.inl:231:13: note: 'c' was declared here
  231 |     uint8_t c, a, *pPal, *s = pDraw->pPixels;
      |             ^

Side question (is there a 24 bit version of this library?)

Library/Sketch mentioned up on the PJRC forum in the thread:
https://forum.pjrc.com/index.php?threads/ili948x_t41_p-a-parallel-display-driver-for-teensy-4-1.72660/page-9#post-347467

If the warnings don't prevent you from building your project, then just ignore them. As far as 24-bit support - no. With both the JPEG and PNG libraries you can easily convert the pixel format in the DRAW callback functions. If you decode a 24-bit PNG image, you will get 24-bit pixels already. For JPEG, 24-bit output is a low priority since you can just use the RGBX32 output.