]> granicus.if.org Git - libjpeg-turbo/commitdiff
SSE2 SIMD: Fix prog Huffman enc. error if Sl%16==0
authorDRC <information@libjpeg-turbo.org>
Wed, 14 Aug 2019 18:17:11 +0000 (13:17 -0500)
committerDRC <information@libjpeg-turbo.org>
Thu, 15 Aug 2019 03:01:30 +0000 (22:01 -0500)
(regression introduced by 5b177b3cab5cfb661256c1e74df160158ec6c34e)

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

Based on:
https://github.com/rouault/libjpeg-turbo/commit/bb7f1ef98305da915e581b59bd0ec2ef7bdb8468

Fixes #335
Closes #367

CMakeLists.txt
ChangeLog.md
simd/i386/jcphuff-sse2.asm
simd/x86_64/jcphuff-sse2.asm
testimages/test.scan [new file with mode: 0644]

index ce04d55e683ebb2a0c7650d4cb4ac7bf2ab49443..ccd3f08888e51a5d9049b1ddf3c63b1744f587c5 100644 (file)
@@ -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)
@@ -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)
@@ -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})
 
index b646c939cfe87e4b11aca9d66cf4c572f3417e3f..317726c518705106656d0c5ab0100d4ae998ca8d 100644 (file)
@@ -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
 =====
index 25c63c7beff8c2502e63b51f4d646ef29ea69019..e35a7d8bbfb66358325045036c81566e33098690 100644 (file)
@@ -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
index b17488a768ef8222fc35d4b749f976efa4396f8d..a9446b7a96bcf57e9b214e298154f2b14554e09f 100644 (file)
@@ -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
diff --git a/testimages/test.scan b/testimages/test.scan
new file mode 100644 (file)
index 0000000..563446d
--- /dev/null
@@ -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;