Skip to content

Commit

Permalink
[i386/x86_64] Fix jsimd_encode_mcu_AC_first_prepare_sse2 when Sl is a…
Browse files Browse the repository at this point in the history
… multiple of 16 (fixes libjpeg-turbo#335)

The SSE2 optimized version did extra iterations when
Sl was a multiple of 16.
  • Loading branch information
rouault committed Aug 11, 2019
1 parent 5ced1f5 commit bb7f1ef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Expand Up @@ -720,6 +720,7 @@ if(WITH_12BIT)
set(MD5_PPM_444_ISLOW_SKIP1_6 ef63901f71ef7a75cd78253fc0914f84)
set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 15b173fb5872d9575572fbcc1b05956f)
set(MD5_JPEG_CROP cdb35ff4b4519392690ea040c56ea99c)
set(MD5_JPEG_SCANS_16 d4d6e03300262fb294948daec71f6be4)
else()
set(TESTORIG testorig.jpg)
set(MD5_JPEG_RGB_ISLOW 1d44a406f61da743b5fd31c0a9abdca3)
Expand Down Expand Up @@ -784,6 +785,7 @@ else()
set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 db87dc7ce26bcdc7a6b56239ce2b9d6c)
set(MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0 cb57b32bd6d03e35432362f7bf184b6d)
set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
set(MD5_JPEG_SCANS_16 bf1e87d7639f61186690ce912211d879)
endif()

if(WITH_JAVA)
Expand Down Expand Up @@ -1265,6 +1267,10 @@ foreach(libtype ${TEST_LIBTYPES})
testout_crop.jpg ${TESTIMAGES}/${TESTORIG}
${MD5_JPEG_CROP})

add_bittest(jpegtran scans_16 "-copy;all;-scans;${TESTIMAGES}/test_scans_16.scan"
testout_scans_16.jpg ${TESTIMAGES}/${TESTORIG}
${MD5_JPEG_SCANS_16})

endforeach()

add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
Expand Down
2 changes: 2 additions & 0 deletions simd/i386/jcphuff-sse2.asm
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
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_scans_16.scan
@@ -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 bb7f1ef

Please sign in to comment.