richgel999 / picojpeg

picojpeg: Tiny JPEG decoder for 8/16-bit microcontrollers
78 stars 19 forks source link

Corrupted data in gCoeffBuf after calling idctCols() when mcuBlock==1 #1

Closed GoogleCodeExporter closed 2 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Compile on AVR target

What is the expected output? What do you see instead?

Corrupted data in gCoeffBuf after calling idctCols() when mcuBlock==1

Please provide any additional information below.

The issue is the DESCALE macro:

#define DESCALE(x)   (((x) + (1U << (DCT_SCALE_BITS - 1))) >> DCT_SCALE_BITS)

The "1U" causes the whole expression to be treated as unsigned. This breaks 
when compiling on the avr-gcc target compiler, and probably also on other 
compilers with native 16-bit ints.

The fix is to remove the "U" on the "1U" so it is just "1". Then everything 
works fine.

Original issue reported on code.google.com by andybrow...@gmail.com on 17 Aug 2012 at 8:38

richgel999 commented 2 years ago

See PJPG_RIGHT_SHIFT_IS_ALWAYS_UNSIGNED - should be fixed.