Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Mar 4, 2024
2 parents 310a243 + 7bb958b commit 7e45654
Show file tree
Hide file tree
Showing 94 changed files with 870 additions and 666 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -149,7 +149,7 @@ jobs:
mkdir build
pushd build
cmake -G"Unix Makefiles" -DWITH_JPEG8=1 \
-DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wpedantic -pedantic-errors -Wdouble-promotion -Wformat-overflow=2 -Wformat-security -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k -Wmissing-include-dirs -Wshift-overflow=2 -Wswitch-bool -Wno-unused-parameter -Wuninitialized -Wstrict-overflow=2 -Wstringop-overflow=4 -Wstringop-truncation -Wduplicated-branches -Wduplicated-cond -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wundef -Wcast-align -Wno-clobbered -Wjump-misses-init -Wno-sign-compare -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wdisabled-optimization -Wno-overlength-strings' \
-DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wpedantic -pedantic-errors -Wdouble-promotion -Wformat-overflow=2 -Wformat-security -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k -Wmissing-include-dirs -Wshift-overflow=2 -Wswitch-bool -Wno-unused-parameter -Wuninitialized -Wstrict-overflow=2 -Wstringop-overflow=4 -Wstringop-truncation -Wduplicated-branches -Wduplicated-cond -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wundef -Wcast-align -Wno-clobbered -Wjump-misses-init -Wno-sign-compare -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wdisabled-optimization -Wno-overlength-strings -fcf-protection' \
..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
Expand Down
2 changes: 2 additions & 0 deletions BUILDING.md
Expand Up @@ -14,6 +14,8 @@ Build Requirements
(if building x86 or x86-64 SIMD extensions)
* If using NASM, 2.13 or later is required.
* If using Yasm, 1.2.0 or later is required.
* NASM 2.15 or later is required if building libjpeg-turbo with Intel
Control-flow Enforcement Technology (CET) support.
* If building on macOS, NASM or Yasm can be obtained from
[MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
- NOTE: Currently, if it is desirable to hide the SIMD function symbols in
Expand Down
8 changes: 8 additions & 0 deletions ChangeLog.md
Expand Up @@ -20,6 +20,14 @@ libjpeg-turbo components to depend on the Visual C++ run-time DLL when built
with Visual C++ and CMake 3.15 or later, regardless of value of the
`WITH_CRT_DLL` CMake variable.

2. The x86-64 SIMD extensions now include support for Intel Control-flow
Enforcement Technology (CET), which is enabled automatically if CET is enabled
in the C compiler.

3. Fixed a regression introduced by 3.0 beta2[6] that made it impossible for
calling applications to supply custom Huffman tables when generating
12-bit-per-component lossy JPEG images using the libjpeg API.


3.0.2
=====
Expand Down
12 changes: 12 additions & 0 deletions simd/CMakeLists.txt
Expand Up @@ -96,6 +96,18 @@ if(NOT WIN32 AND (CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED))
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DPIC")
endif()

if(CPU_TYPE STREQUAL "x86_64" AND CMAKE_ASM_NASM_OBJECT_FORMAT MATCHES "^elf")
check_c_source_compiles("
#if (__CET__ & 3) == 0
#error \"CET not enabled\"
#endif
int main(void) { return 0; }" HAVE_CET)

if(HAVE_CET)
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -D__CET__")
endif()
endif()

string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
set(EFFECTIVE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} ${CMAKE_ASM_NASM_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
message(STATUS "CMAKE_ASM_NASM_FLAGS = ${EFFECTIVE_ASM_NASM_FLAGS}")
Expand Down
22 changes: 11 additions & 11 deletions simd/i386/jccolext-avx2.asm
Expand Up @@ -2,7 +2,7 @@
; jccolext.asm - colorspace conversion (AVX2)
;
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2016, D. R. Commander.
; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
Expand Down Expand Up @@ -49,15 +49,15 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
pushpic eax ; make a room for GOT address
PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi

get_GOT ebx ; get GOT address
movpic POINTER [gotptr], ebx ; save GOT address
GET_GOT ebx ; get GOT address
MOVPIC POINTER [gotptr], ebx ; save GOT address

mov ecx, JDIMENSION [img_width(eax)]
test ecx, ecx
Expand All @@ -80,9 +80,9 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
alignx 16, 7
ALIGNX 16, 7
.rowloop:
pushpic eax
PUSHPIC eax
push edx
push ebx
push edi
Expand All @@ -93,11 +93,11 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
mov edi, JSAMPROW [edi] ; outptr0
mov ebx, JSAMPROW [ebx] ; outptr1
mov edx, JSAMPROW [edx] ; outptr2
movpic eax, POINTER [gotptr] ; load GOT address (eax)
MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)

cmp ecx, byte SIZEOF_YMMWORD
jae near .columnloop
alignx 16, 7
ALIGNX 16, 7

%if RGB_PIXELSIZE == 3 ; ---------------

Expand Down Expand Up @@ -154,7 +154,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_ycc_cnv
alignx 16, 7
ALIGNX 16, 7

.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
Expand Down Expand Up @@ -278,7 +278,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_ycc_cnv
alignx 16, 7
ALIGNX 16, 7

.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
Expand Down Expand Up @@ -552,7 +552,7 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
pop edi
pop ebx
pop edx
poppic eax
POPPIC eax

add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
Expand Down
22 changes: 11 additions & 11 deletions simd/i386/jccolext-mmx.asm
Expand Up @@ -2,7 +2,7 @@
; jccolext.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright (C) 2016, D. R. Commander.
; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
Expand Down Expand Up @@ -49,15 +49,15 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
pushpic eax ; make a room for GOT address
PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi

get_GOT ebx ; get GOT address
movpic POINTER [gotptr], ebx ; save GOT address
GET_GOT ebx ; get GOT address
MOVPIC POINTER [gotptr], ebx ; save GOT address

mov ecx, JDIMENSION [img_width(eax)] ; num_cols
test ecx, ecx
Expand All @@ -80,9 +80,9 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
alignx 16, 7
ALIGNX 16, 7
.rowloop:
pushpic eax
PUSHPIC eax
push edx
push ebx
push edi
Expand All @@ -93,11 +93,11 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
mov edi, JSAMPROW [edi] ; outptr0
mov ebx, JSAMPROW [ebx] ; outptr1
mov edx, JSAMPROW [edx] ; outptr2
movpic eax, POINTER [gotptr] ; load GOT address (eax)
MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)

cmp ecx, byte SIZEOF_MMWORD
jae short .columnloop
alignx 16, 7
ALIGNX 16, 7

%if RGB_PIXELSIZE == 3 ; ---------------

Expand Down Expand Up @@ -143,7 +143,7 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_ycc_cnv
alignx 16, 7
ALIGNX 16, 7

.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
Expand Down Expand Up @@ -211,7 +211,7 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_ycc_cnv
alignx 16, 7
ALIGNX 16, 7

.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
Expand Down Expand Up @@ -449,7 +449,7 @@ EXTN(jsimd_rgb_ycc_convert_mmx):
pop edi
pop ebx
pop edx
poppic eax
POPPIC eax

add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
Expand Down
22 changes: 11 additions & 11 deletions simd/i386/jccolext-sse2.asm
@@ -1,7 +1,7 @@
;
; jccolext.asm - colorspace conversion (SSE2)
;
; Copyright (C) 2016, D. R. Commander.
; Copyright (C) 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
Expand Down Expand Up @@ -48,15 +48,15 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
pushpic eax ; make a room for GOT address
PUSHPIC eax ; make a room for GOT address
push ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi

get_GOT ebx ; get GOT address
movpic POINTER [gotptr], ebx ; save GOT address
GET_GOT ebx ; get GOT address
MOVPIC POINTER [gotptr], ebx ; save GOT address

mov ecx, JDIMENSION [img_width(eax)]
test ecx, ecx
Expand All @@ -79,9 +79,9 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
alignx 16, 7
ALIGNX 16, 7
.rowloop:
pushpic eax
PUSHPIC eax
push edx
push ebx
push edi
Expand All @@ -92,11 +92,11 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
mov edi, JSAMPROW [edi] ; outptr0
mov ebx, JSAMPROW [ebx] ; outptr1
mov edx, JSAMPROW [edx] ; outptr2
movpic eax, POINTER [gotptr] ; load GOT address (eax)
MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)

cmp ecx, byte SIZEOF_XMMWORD
jae near .columnloop
alignx 16, 7
ALIGNX 16, 7

%if RGB_PIXELSIZE == 3 ; ---------------

Expand Down Expand Up @@ -147,7 +147,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_ycc_cnv
alignx 16, 7
ALIGNX 16, 7

.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
Expand Down Expand Up @@ -232,7 +232,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_ycc_cnv
alignx 16, 7
ALIGNX 16, 7

.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
Expand Down Expand Up @@ -478,7 +478,7 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
pop edi
pop ebx
pop edx
poppic eax
POPPIC eax

add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
Expand Down
6 changes: 3 additions & 3 deletions simd/i386/jccolor-avx2.asm
@@ -1,7 +1,7 @@
;
; jccolor.asm - colorspace conversion (AVX2)
;
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
Expand Down Expand Up @@ -33,7 +33,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST

alignz 32
ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_avx2)

EXTN(jconst_rgb_ycc_convert_avx2):
Expand All @@ -46,7 +46,7 @@ PD_ONEHALFM1_CJ times 8 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))

alignz 32
ALIGNZ 32

; --------------------------------------------------------------------------
SECTION SEG_TEXT
Expand Down
6 changes: 3 additions & 3 deletions simd/i386/jccolor-mmx.asm
Expand Up @@ -2,7 +2,7 @@
; jccolor.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
Expand Down Expand Up @@ -33,7 +33,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST

alignz 32
ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_mmx)

EXTN(jconst_rgb_ycc_convert_mmx):
Expand All @@ -46,7 +46,7 @@ PD_ONEHALFM1_CJ times 2 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 2 dd (1 << (SCALEBITS - 1))

alignz 32
ALIGNZ 32

; --------------------------------------------------------------------------
SECTION SEG_TEXT
Expand Down
6 changes: 3 additions & 3 deletions simd/i386/jccolor-sse2.asm
@@ -1,7 +1,7 @@
;
; jccolor.asm - colorspace conversion (SSE2)
;
; Copyright (C) 2009, 2016, D. R. Commander.
; Copyright (C) 2009, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
Expand Down Expand Up @@ -32,7 +32,7 @@ F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000)
; --------------------------------------------------------------------------
SECTION SEG_CONST

alignz 32
ALIGNZ 32
GLOBAL_DATA(jconst_rgb_ycc_convert_sse2)

EXTN(jconst_rgb_ycc_convert_sse2):
Expand All @@ -45,7 +45,7 @@ PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS - 1)) - 1 + \
(CENTERJSAMPLE << SCALEBITS)
PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))

alignz 32
ALIGNZ 32

; --------------------------------------------------------------------------
SECTION SEG_TEXT
Expand Down

0 comments on commit 7e45654

Please sign in to comment.