Skip to content

Commit

Permalink
SSE2 SIMD: Fix prog Huffman enc. error if Sl%16==0
Browse files Browse the repository at this point in the history
(regression introduced by 5b177b3)

The SSE2 implementation of progressive Huffman encoding performed
extraneous iterations when the scan length was a multiple of 16.

Based on:
rouault/libjpeg-turbo@bb7f1ef

Fixes #335
Closes #367
  • Loading branch information
dcommander committed Aug 15, 2019
1 parent 02f7bcd commit a81a8c1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ if(WITH_12BIT)
set(MD5_JPEG_422_IFAST_OPT 7322e3bd2f127f7de4b40d4480ce60e4)
set(MD5_PPM_422_IFAST 79807fa552899e66a04708f533e16950)
set(MD5_PPM_422M_IFAST 07737bfe8a7c1c87aaa393a0098d16b0)
set(MD5_JPEG_420_IFAST_Q100_PROG a1da220b5604081863a504297ed59e55)
set(MD5_JPEG_420_IFAST_Q100_PROG 008ab68d6ddbba04a8f01deee4e0f9f8)
set(MD5_PPM_420_Q100_IFAST 1b3730122709f53d007255e8dfd3305e)
set(MD5_PPM_420M_Q100_IFAST 980a1a3c5bf9510022869d30b7d26566)
set(MD5_JPEG_GRAY_ISLOW 235c90707b16e2e069f37c888b2636d9)
Expand Down Expand Up @@ -732,7 +732,7 @@ else()
set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
set(MD5_JPEG_420_IFAST_Q100_PROG 990cbe0329c882420a2094da7e5adade)
set(MD5_JPEG_420_IFAST_Q100_PROG e59bb462016a8d9a748c330a3474bb55)
set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
Expand Down Expand Up @@ -1047,7 +1047,7 @@ foreach(libtype ${TEST_LIBTYPES})

# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
add_bittest(cjpeg 420-q100-ifast-prog
"-sample;2x2;-quality;100;-dct;fast;-prog"
"-sample;2x2;-quality;100;-dct;fast;-scans;${TESTIMAGES}/test.scan"
testout_420_q100_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
${MD5_JPEG_420_IFAST_Q100_PROG})

Expand Down
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ decompression (in the spatial domain.)
attempting to compress or decompress images with more than 1 billion pixels
using the TurboJPEG API.

5. Fixed a regression introduced by 2.0 beta1[15] whereby attempting to
generate a progressive JPEG image on an SSE2-capable CPU using a scan script
containing one or more scans with lengths divisible by 16 would result in an
error ("Missing Huffman code table entry") and an invalid JPEG image.


2.0.2
=====
Expand Down
2 changes: 2 additions & 0 deletions simd/i386/jcphuff-sse2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
add LUT, 16*SIZEOF_INT
dec K
jnz .BLOOP16
test LEN, 15
je .PADDING
.ELOOP16:
mov LENEND, LEN
and LENEND, 7
Expand Down
2 changes: 2 additions & 0 deletions simd/x86_64/jcphuff-sse2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
add LUT, 16*SIZEOF_INT
dec K
jnz .BLOOP16
test LEN, 15
je .PADDING
.ELOOP16:
test LEN, 8
jz .TRY7
Expand Down
5 changes: 5 additions & 0 deletions testimages/test.scan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0 1 2: 0 0 0 0;
0: 1 16 0 0;
0: 17 63 0 0;
1: 1 63 0 0;
2: 1 63 0 0;

0 comments on commit a81a8c1

Please sign in to comment.