summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-06-15 15:44:41 +0300
committerrobot-piglet <[email protected]>2025-06-15 15:55:30 +0300
commitea626d7b15346c0da649291483f80f1ae6e1d7e7 (patch)
tree24ae3c2aa7f259f3ba95af8450b5bce9a4bdb10d
parent726087f32fb38c191ff0c3ef8c6646aa940d987e (diff)
Intermediate changes
commit_hash:79edafb911368bba0a4d2f7f151a6c8a37c349f3
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py24
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report1943
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report654
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/issue817-add-wrappers.patch2128
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt1039
-rw-r--r--contrib/libs/libjpeg-turbo/.yandex_meta/override.nix8
-rw-r--r--contrib/libs/libjpeg-turbo/BUILDING.md89
-rw-r--r--contrib/libs/libjpeg-turbo/ChangeLog.md611
-rw-r--r--contrib/libs/libjpeg-turbo/LICENSE.md33
-rw-r--r--contrib/libs/libjpeg-turbo/README.ijg50
-rw-r--r--contrib/libs/libjpeg-turbo/README.md106
-rw-r--r--contrib/libs/libjpeg-turbo/cjpeg/ya.make9
-rw-r--r--contrib/libs/libjpeg-turbo/cmyk.h61
-rw-r--r--contrib/libs/libjpeg-turbo/djpeg/ya.make15
-rw-r--r--contrib/libs/libjpeg-turbo/jcinit.c80
-rw-r--r--contrib/libs/libjpeg-turbo/jconfig.h51
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-linux.h34
-rw-r--r--contrib/libs/libjpeg-turbo/jconfigint-x86.h4
-rw-r--r--contrib/libs/libjpeg-turbo/jdmaster.c726
-rw-r--r--contrib/libs/libjpeg-turbo/jerror.h332
-rw-r--r--contrib/libs/libjpeg-turbo/jmorecfg.h383
-rw-r--r--contrib/libs/libjpeg-turbo/jpegint.h376
-rw-r--r--contrib/libs/libjpeg-turbo/jpeglib.h1133
-rw-r--r--contrib/libs/libjpeg-turbo/jpegtran/ya.make5
-rw-r--r--contrib/libs/libjpeg-turbo/jsimd_none.c431
-rw-r--r--contrib/libs/libjpeg-turbo/jversion.h14
-rw-r--r--contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch61
-rw-r--r--contrib/libs/libjpeg-turbo/patches/no-INT32.patch4
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c11
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c197
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c13
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c13
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c13
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c13
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h10
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm23
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm6
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm20
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm26
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm26
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm26
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm26
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm26
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm26
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm64
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm64
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm64
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm22
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm22
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm22
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm18
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm22
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm18
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm28
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm44
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm44
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm20
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm32
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm20
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm22
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm18
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm16
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jsimd.c94
-rw-r--r--contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm6
-rw-r--r--contrib/libs/libjpeg-turbo/simd/jsimd.h12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h4
-rw-r--r--contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc66
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm78
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm48
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm20
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm20
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm12
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm36
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm36
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm62
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm52
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm34
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm34
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm30
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm34
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm54
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm36
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm34
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm36
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm42
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm20
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm24
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c90
-rw-r--r--contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm10
-rw-r--r--contrib/libs/libjpeg-turbo/src/cderror.h (renamed from contrib/libs/libjpeg-turbo/cderror.h)19
-rw-r--r--contrib/libs/libjpeg-turbo/src/cdjpeg.c (renamed from contrib/libs/libjpeg-turbo/cdjpeg.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/cdjpeg.h (renamed from contrib/libs/libjpeg-turbo/cdjpeg.h)26
-rw-r--r--contrib/libs/libjpeg-turbo/src/cjpeg.c (renamed from contrib/libs/libjpeg-turbo/cjpeg.c)118
-rw-r--r--contrib/libs/libjpeg-turbo/src/cmyk.h61
-rw-r--r--contrib/libs/libjpeg-turbo/src/djpeg.c (renamed from contrib/libs/libjpeg-turbo/djpeg.c)260
-rw-r--r--contrib/libs/libjpeg-turbo/src/jaricom.c (renamed from contrib/libs/libjpeg-turbo/jaricom.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcapimin.c (renamed from contrib/libs/libjpeg-turbo/jcapimin.c)35
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcapistd.c (renamed from contrib/libs/libjpeg-turbo/jcapistd.c)70
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcarith.c (renamed from contrib/libs/libjpeg-turbo/jcarith.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jccoefct.c (renamed from contrib/libs/libjpeg-turbo/jccoefct.c)48
-rw-r--r--contrib/libs/libjpeg-turbo/src/jccolext.c (renamed from contrib/libs/libjpeg-turbo/jccolext.c)64
-rw-r--r--contrib/libs/libjpeg-turbo/src/jccolor.c (renamed from contrib/libs/libjpeg-turbo/jccolor.c)263
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcdctmgr.c (renamed from contrib/libs/libjpeg-turbo/jcdctmgr.c)98
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcdiffct.c419
-rw-r--r--contrib/libs/libjpeg-turbo/src/jchuff.c (renamed from contrib/libs/libjpeg-turbo/jchuff.c)206
-rw-r--r--contrib/libs/libjpeg-turbo/src/jchuff.h (renamed from contrib/libs/libjpeg-turbo/jchuff.h)16
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcicc.c (renamed from contrib/libs/libjpeg-turbo/jcicc.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcinit.c149
-rw-r--r--contrib/libs/libjpeg-turbo/src/jclhuff.c587
-rw-r--r--contrib/libs/libjpeg-turbo/src/jclossls.c327
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcmainct.c (renamed from contrib/libs/libjpeg-turbo/jcmainct.c)59
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcmarker.c (renamed from contrib/libs/libjpeg-turbo/jcmarker.c)36
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcmaster.c (renamed from contrib/libs/libjpeg-turbo/jcmaster.c)325
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcmaster.h43
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcomapi.c (renamed from contrib/libs/libjpeg-turbo/jcomapi.c)5
-rw-r--r--contrib/libs/libjpeg-turbo/src/jconfig.h1
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcparam.c (renamed from contrib/libs/libjpeg-turbo/jcparam.c)59
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcphuff.c (renamed from contrib/libs/libjpeg-turbo/jcphuff.c)100
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcprepct.c (renamed from contrib/libs/libjpeg-turbo/jcprepct.c)103
-rw-r--r--contrib/libs/libjpeg-turbo/src/jcsample.c (renamed from contrib/libs/libjpeg-turbo/jcsample.c)116
-rw-r--r--contrib/libs/libjpeg-turbo/src/jctrans.c (renamed from contrib/libs/libjpeg-turbo/jctrans.c)16
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdapimin.c (renamed from contrib/libs/libjpeg-turbo/jdapimin.c)25
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdapistd.c (renamed from contrib/libs/libjpeg-turbo/jdapistd.c)180
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdarith.c (renamed from contrib/libs/libjpeg-turbo/jdarith.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdatadst-tj.c (renamed from contrib/libs/libjpeg-turbo/jdatadst-tj.c)15
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdatadst.c (renamed from contrib/libs/libjpeg-turbo/jdatadst.c)10
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdatasrc-tj.c (renamed from contrib/libs/libjpeg-turbo/jdatasrc-tj.c)8
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdatasrc.c (renamed from contrib/libs/libjpeg-turbo/jdatasrc.c)6
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdcoefct.c (renamed from contrib/libs/libjpeg-turbo/jdcoefct.c)76
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdcoefct.h (renamed from contrib/libs/libjpeg-turbo/jdcoefct.h)5
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdcol565.c (renamed from contrib/libs/libjpeg-turbo/jdcol565.c)62
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdcolext.c (renamed from contrib/libs/libjpeg-turbo/jdcolext.c)48
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdcolor.c (renamed from contrib/libs/libjpeg-turbo/jdcolor.c)214
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdct.h (renamed from contrib/libs/libjpeg-turbo/jdct.h)135
-rw-r--r--contrib/libs/libjpeg-turbo/src/jddctmgr.c (renamed from contrib/libs/libjpeg-turbo/jddctmgr.c)61
-rw-r--r--contrib/libs/libjpeg-turbo/src/jddiffct.c411
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdhuff.c (renamed from contrib/libs/libjpeg-turbo/jdhuff.c)20
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdhuff.h (renamed from contrib/libs/libjpeg-turbo/jdhuff.h)7
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdicc.c (renamed from contrib/libs/libjpeg-turbo/jdicc.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdinput.c (renamed from contrib/libs/libjpeg-turbo/jdinput.c)74
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdlhuff.c302
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdlossls.c297
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmainct.c (renamed from contrib/libs/libjpeg-turbo/jdmainct.c)126
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmainct.h (renamed from contrib/libs/libjpeg-turbo/jdmainct.h)15
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmarker.c (renamed from contrib/libs/libjpeg-turbo/jdmarker.c)44
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmaster.c893
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmaster.h (renamed from contrib/libs/libjpeg-turbo/jdmaster.h)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmerge.c (renamed from contrib/libs/libjpeg-turbo/jdmerge.c)72
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmerge.h (renamed from contrib/libs/libjpeg-turbo/jdmerge.h)9
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmrg565.c (renamed from contrib/libs/libjpeg-turbo/jdmrg565.c)43
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdmrgext.c (renamed from contrib/libs/libjpeg-turbo/jdmrgext.c)40
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdphuff.c (renamed from contrib/libs/libjpeg-turbo/jdphuff.c)4
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdpostct.c (renamed from contrib/libs/libjpeg-turbo/jdpostct.c)122
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdsample.c (renamed from contrib/libs/libjpeg-turbo/jdsample.c)141
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdsample.h (renamed from contrib/libs/libjpeg-turbo/jdsample.h)9
-rw-r--r--contrib/libs/libjpeg-turbo/src/jdtrans.c (renamed from contrib/libs/libjpeg-turbo/jdtrans.c)12
-rw-r--r--contrib/libs/libjpeg-turbo/src/jerror.c (renamed from contrib/libs/libjpeg-turbo/jerror.c)16
-rw-r--r--contrib/libs/libjpeg-turbo/src/jerror.h336
-rw-r--r--contrib/libs/libjpeg-turbo/src/jfdctflt.c (renamed from contrib/libs/libjpeg-turbo/jfdctflt.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jfdctfst.c (renamed from contrib/libs/libjpeg-turbo/jfdctfst.c)2
-rw-r--r--contrib/libs/libjpeg-turbo/src/jfdctint.c (renamed from contrib/libs/libjpeg-turbo/jfdctint.c)4
-rw-r--r--contrib/libs/libjpeg-turbo/src/jidctflt.c (renamed from contrib/libs/libjpeg-turbo/jidctflt.c)14
-rw-r--r--contrib/libs/libjpeg-turbo/src/jidctfst.c (renamed from contrib/libs/libjpeg-turbo/jidctfst.c)18
-rw-r--r--contrib/libs/libjpeg-turbo/src/jidctint.c (renamed from contrib/libs/libjpeg-turbo/jidctint.c)136
-rw-r--r--contrib/libs/libjpeg-turbo/src/jidctred.c (renamed from contrib/libs/libjpeg-turbo/jidctred.c)38
-rw-r--r--contrib/libs/libjpeg-turbo/src/jinclude.h (renamed from contrib/libs/libjpeg-turbo/jinclude.h)4
-rw-r--r--contrib/libs/libjpeg-turbo/src/jlossls.h101
-rw-r--r--contrib/libs/libjpeg-turbo/src/jmemmgr.c (renamed from contrib/libs/libjpeg-turbo/jmemmgr.c)184
-rw-r--r--contrib/libs/libjpeg-turbo/src/jmemnobs.c (renamed from contrib/libs/libjpeg-turbo/jmemnobs.c)6
-rw-r--r--contrib/libs/libjpeg-turbo/src/jmemsys.h (renamed from contrib/libs/libjpeg-turbo/jmemsys.h)31
-rw-r--r--contrib/libs/libjpeg-turbo/src/jmorecfg.h385
-rw-r--r--contrib/libs/libjpeg-turbo/src/jpeg_nbits.c (renamed from contrib/libs/libjpeg-turbo/jpeg_nbits_table.h)38
-rw-r--r--contrib/libs/libjpeg-turbo/src/jpeg_nbits.h43
-rw-r--r--contrib/libs/libjpeg-turbo/src/jpegapicomp.h (renamed from contrib/libs/libjpeg-turbo/jpegcomp.h)2
-rw-r--r--contrib/libs/libjpeg-turbo/src/jpegint.h600
-rw-r--r--contrib/libs/libjpeg-turbo/src/jpeglib.h1223
-rw-r--r--contrib/libs/libjpeg-turbo/src/jpegtran.c (renamed from contrib/libs/libjpeg-turbo/jpegtran.c)15
-rw-r--r--contrib/libs/libjpeg-turbo/src/jquant1.c (renamed from contrib/libs/libjpeg-turbo/jquant1.c)196
-rw-r--r--contrib/libs/libjpeg-turbo/src/jquant2.c (renamed from contrib/libs/libjpeg-turbo/jquant2.c)130
-rw-r--r--contrib/libs/libjpeg-turbo/src/jsamplecomp.h333
-rw-r--r--contrib/libs/libjpeg-turbo/src/jsimd.h (renamed from contrib/libs/libjpeg-turbo/jsimd.h)12
-rw-r--r--contrib/libs/libjpeg-turbo/src/jsimddct.h (renamed from contrib/libs/libjpeg-turbo/jsimddct.h)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/jstdhuff.c (renamed from contrib/libs/libjpeg-turbo/jstdhuff.c)4
-rw-r--r--contrib/libs/libjpeg-turbo/src/jutils.c (renamed from contrib/libs/libjpeg-turbo/jutils.c)25
-rw-r--r--contrib/libs/libjpeg-turbo/src/rdbmp.c (renamed from contrib/libs/libjpeg-turbo/rdbmp.c)17
-rw-r--r--contrib/libs/libjpeg-turbo/src/rdcolmap.c (renamed from contrib/libs/libjpeg-turbo/rdcolmap.c)34
-rw-r--r--contrib/libs/libjpeg-turbo/src/rdgif.c (renamed from contrib/libs/libjpeg-turbo/rdgif.c)15
-rw-r--r--contrib/libs/libjpeg-turbo/src/rdppm.c (renamed from contrib/libs/libjpeg-turbo/rdppm.c)343
-rw-r--r--contrib/libs/libjpeg-turbo/src/rdswitch.c (renamed from contrib/libs/libjpeg-turbo/rdswitch.c)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/rdtarga.c (renamed from contrib/libs/libjpeg-turbo/rdtarga.c)11
-rw-r--r--contrib/libs/libjpeg-turbo/src/tjutil.h (renamed from contrib/libs/libjpeg-turbo/tjutil.h)0
-rw-r--r--contrib/libs/libjpeg-turbo/src/transupp.c (renamed from contrib/libs/libjpeg-turbo/transupp.c)37
-rw-r--r--contrib/libs/libjpeg-turbo/src/transupp.h231
-rw-r--r--contrib/libs/libjpeg-turbo/src/turbojpeg-mapfile (renamed from contrib/libs/libjpeg-turbo/turbojpeg-mapfile)58
-rw-r--r--contrib/libs/libjpeg-turbo/src/turbojpeg-mp.c562
-rw-r--r--contrib/libs/libjpeg-turbo/src/turbojpeg.c3145
-rw-r--r--contrib/libs/libjpeg-turbo/src/turbojpeg.h2809
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jccolor-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jccolor-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jccolor-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jclossls-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jclossls-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jclossls-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcsample-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcsample-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jcsample-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdsample-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdsample-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jdsample-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctint-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctint-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctred-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jidctred-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jquant1-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jquant1-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jquant2-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jquant2-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jutils-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jutils-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/jutils-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/rdppm-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/rdppm-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/rdppm-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/wrgif-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/wrgif-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/wrppm-12.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/wrppm-16.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrapper/wrppm-8.c14
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrbmp.c (renamed from contrib/libs/libjpeg-turbo/wrbmp.c)7
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrgif.c (renamed from contrib/libs/libjpeg-turbo/wrgif.c)31
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrppm.c (renamed from contrib/libs/libjpeg-turbo/wrppm.c)73
-rw-r--r--contrib/libs/libjpeg-turbo/src/wrtarga.c (renamed from contrib/libs/libjpeg-turbo/wrtarga.c)3
-rw-r--r--contrib/libs/libjpeg-turbo/transupp.h232
-rw-r--r--contrib/libs/libjpeg-turbo/turbojpeg.c2248
-rw-r--r--contrib/libs/libjpeg-turbo/turbojpeg.h1768
-rw-r--r--contrib/libs/libjpeg-turbo/ya.make203
339 files changed, 24644 insertions, 12751 deletions
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py b/contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py
index d66f98af0a5..bf465b0473b 100644
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py
+++ b/contrib/libs/libjpeg-turbo/.yandex_meta/__init__.py
@@ -59,7 +59,6 @@ def post_install(self):
arm32 = list_simd_sources("arm/aarch32")
arm32_neon = list_simd_sources("arm")
arm64 = list_simd_sources("arm/aarch64")
- simd_none = ["jsimd_none.c"]
# This file contains the older GNU Assembler implementation of the Neon SIMD
# extensions for certain algorithms.
@@ -71,8 +70,7 @@ def post_install(self):
"SRCS",
Switch(
[
- ("OS_ANDROID", Linkable(SRCS=simd_none)),
- ("ARCH_I386", Linkable(SRCS=i386)),
+ ("ARCH_I386 AND NOT OS_ANDROID", Linkable(SRCS=i386)),
("ARCH_X86_64", Linkable(SRCS=amd64)),
(
"ARCH_ARM7_NEON AND NOT MSVC",
@@ -83,7 +81,10 @@ def post_install(self):
),
(
"ARCH_ARM7 AND NOT MSVC",
- Linkable(SRCS=arm32),
+ Linkable(
+ SRCS=arm32 + arm32_neon,
+ ADDINCL=[f"{self.arcdir}/simd/arm"],
+ ),
),
(
"ARCH_ARM64 AND NOT MSVC",
@@ -92,7 +93,6 @@ def post_install(self):
ADDINCL=[f"{self.arcdir}/simd/arm"],
),
),
- ("default", Linkable(SRCS=simd_none)),
]
),
)
@@ -122,8 +122,20 @@ libjpeg_turbo = CMakeNinjaNixProject(
"simd/i386/",
"simd/nasm/",
"simd/x86_64/",
- "jsimd_none.c",
],
+ inclink={
+ ".": [
+ "src/jpeglib.h",
+ "src/jmorecfg.h",
+ "src/jpegint.h",
+ "src/jerror.h",
+ "src/transupp.h",
+ "src/turbojpeg.h",
+ ],
+ "src": [
+ "jconfig.h",
+ ],
+ },
post_build=post_build,
post_install=post_install,
)
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report b/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report
index 6e4e26c725f..7a33ecaf74a 100644
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report
+++ b/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.copyrights.report
@@ -33,61 +33,50 @@
# FILE_INCLUDE - include all file data into licenses text file
# =======================
-KEEP COPYRIGHT_SERVICE_LABEL 001270d0986e016a64e4488c035ddac5
+KEEP COPYRIGHT_SERVICE_LABEL 001a887e8ab3ae7b989352695b3afd87
BELONGS ya.make
- License text:
- ; Copyright (C) 2011, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
+FILE_INCLUDE README.ijg found in files: src/rdtarga.c at line 9
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jcgray-avx2.asm [4:5]
- simd/i386/jcgray-mmx.asm [4:5]
- simd/i386/jcgray-sse2.asm [4:4]
- simd/i386/jcgryext-avx2.asm [4:5]
- simd/i386/jcgryext-mmx.asm [4:5]
- simd/i386/jcgryext-sse2.asm [4:4]
- simd/x86_64/jcgray-avx2.asm [4:5]
- simd/x86_64/jcgray-sse2.asm [4:4]
- simd/x86_64/jcgryext-avx2.asm [4:6]
- simd/x86_64/jcgryext-sse2.asm [4:5]
+ src/rdtarga.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL 03620b5e1cb0526b5c8fb74838b3a3ef
+KEEP COPYRIGHT_SERVICE_LABEL 03b8571b70e9345e88a4b5c470d861ae
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmainct.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jcdiffct.c at line 10, src/jddiffct.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdmainct.c [5:9]
+ src/jcdiffct.c [5:11]
+ src/jddiffct.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 048093befc4541c84a0b4aff0eb0e58a
+KEEP COPYRIGHT_SERVICE_LABEL 05117f6a64c717808d7abe982066f754
BELONGS ya.make
- License text:
- * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+FILE_INCLUDE README.ijg found in files: src/jddctmgr.c at line 11
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/x86_64/jsimd.c [4:6]
+ src/jddctmgr.c [5:12]
-KEEP COPYRIGHT_SERVICE_LABEL 05117f6a64c717808d7abe982066f754
+KEEP COPYRIGHT_SERVICE_LABEL 0541a81da4dde61b003817670d836267
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jddctmgr.c at line 11
+FILE_INCLUDE README.ijg found in files: src/jquant1.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jddctmgr.c [5:12]
+ src/jquant1.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL 07e12474a71a9c9264beced90941125c
BELONGS ya.make
@@ -104,67 +93,117 @@ FILE_INCLUDE README.ijg found in files: simd/arm/aarch64/jchuff-neon.c at line 9
simd/arm/jquanti-neon.c [4:4]
simd/arm/neon-compat.h [3:3]
-KEEP COPYRIGHT_SERVICE_LABEL 085866dc673ec19d97c4979b0d3203f8
+KEEP COPYRIGHT_SERVICE_LABEL 090deb413327d7c4ccdeb6f33c67502b
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jchuff.h at line 8, src/jclhuff.c at line 8, src/jdcoefct.h at line 8, src/jdlhuff.c at line 8, src/jdmainct.h at line 8, src/jdsample.h at line 8, src/jlossls.h at line 8, src/jsamplecomp.h at line 7, src/jutils.c at line 8, src/rdcolmap.c at line 8
+ License text:
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jchuff.h [5:9]
+ src/jclhuff.c [5:11]
+ src/jdcoefct.h [5:11]
+ src/jdlhuff.c [5:11]
+ src/jdmainct.h [5:9]
+ src/jdsample.h [5:9]
+ src/jlossls.h [5:11]
+ src/jsamplecomp.h [4:6]
+ src/jutils.c [5:9]
+ src/rdcolmap.c [5:9]
+
+KEEP COPYRIGHT_SERVICE_LABEL 091aff5add79bba2d915578002de5fbb
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jquant2.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jquant2.c [5:9]
+ jversion.h [39:53]
-KEEP COPYRIGHT_SERVICE_LABEL 090deb413327d7c4ccdeb6f33c67502b
+KEEP COPYRIGHT_SERVICE_LABEL 091d20e644e181ef6d43e970c0153f2c
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapimin.c at line 9, jcprepct.c at line 9, jerror.c at line 9, jinclude.h at line 9, jutils.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcapimin.c [5:10]
- jcprepct.c [5:9]
- jerror.c [5:9]
- jinclude.h [5:9]
- jutils.c [5:9]
+ simd/i386/jsimd.c [4:6]
-KEEP COPYRIGHT_SERVICE_LABEL 09adeb42ae4a6bea0b7aa5aaf65de91a
+KEEP COPYRIGHT_SERVICE_LABEL 0a2388305f986260897a9cef72004a37
BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2009, 2016, 2020, D. R. Commander.
+FILE_INCLUDE README.ijg found in files: src/jstdhuff.c at line 8
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jstdhuff.c [5:9]
+
+KEEP COPYRIGHT_SERVICE_LABEL 0a6b4f46b94dba174b5acc7622b52c81
+BELONGS ya.make
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/x86_64/jquanti-avx2.asm [4:7]
+
+KEEP COPYRIGHT_SERVICE_LABEL 0a9e2d8330eff722b30011904f8dbbb7
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/rdgif.c at line 9
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/x86_64/jfdctint-sse2.asm [4:5]
- simd/x86_64/jidctint-sse2.asm [4:6]
+ src/rdgif.c [5:10]
KEEP COPYRIGHT_SERVICE_LABEL 0ae009ac16fbacd31d4b77e95303858a
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cderror.h at line 9, cdjpeg.h at line 9, jccoefct.c at line 9, jcomapi.c at line 9, jdcoefct.c at line 9, jdcoefct.h at line 9, jerror.h at line 9
+FILE_INCLUDE README.ijg found in files: src/cderror.h at line 9, src/cdjpeg.h at line 9, src/jccoefct.c at line 9, src/jcomapi.c at line 9, src/jdcoefct.c at line 9, src/jdcoefct.h at line 9, src/jerror.h at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cderror.h [5:10]
- cdjpeg.h [5:10]
- jccoefct.c [5:8]
- jcomapi.c [5:8]
- jdcoefct.c [5:11]
- jdcoefct.h [5:10]
- jerror.h [5:10]
+ src/cderror.h [5:10]
+ src/cdjpeg.h [5:10]
+ src/jccoefct.c [5:9]
+ src/jcomapi.c [5:9]
+ src/jdcoefct.c [5:11]
+ src/jdcoefct.h [5:11]
+ src/jerror.h [5:12]
+
+KEEP COPYRIGHT_SERVICE_LABEL 0d0bb3c79a54d91c1597b0c7d63f162a
+BELONGS ya.make
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jsimd.h [4:7]
KEEP COPYRIGHT_SERVICE_LABEL 0d16e03bc8aea0727b77e84f46679705
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmaster.h at line 6
+FILE_INCLUDE README.ijg found in files: src/jcmaster.h at line 8, src/jdmaster.h at line 8
License text:
* Copyright (C) 1991-1995, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2016, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
Scancode info:
@@ -172,189 +211,197 @@ FILE_INCLUDE README.ijg found in files: jdmaster.h at line 6
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdmaster.h [5:7]
+ src/jcmaster.h [5:9]
+ src/jdmaster.h [5:7]
KEEP COPYRIGHT_SERVICE_LABEL 0f8337340bfc4fc39a2fe07a61afd6b0
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdarith.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jdarith.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdarith.c [5:9]
+ src/jdarith.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 0f897163c7037d3f0adbe0fe504532f8
+KEEP COPYRIGHT_SERVICE_LABEL 0ff49e46b4d6713fa662cb325e7b5c06
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcmarker.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdcolor.c at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcmarker.c [5:10]
+ src/jdcolor.c [5:12]
-KEEP COPYRIGHT_SERVICE_LABEL 10c71bcfc53b06ea8660c6ef781bbbe9
+KEEP COPYRIGHT_SERVICE_LABEL 118cad472f27d313e079bc76599be316
BELONGS ya.make
- License text:
- ; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2012, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
+FILE_INCLUDE README.ijg found in files: src/jdapistd.c at line 9
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jdcolext-avx2.asm [4:6]
- simd/i386/jdcolext-sse2.asm [4:5]
- simd/i386/jdmrgext-avx2.asm [4:6]
- simd/i386/jdmrgext-sse2.asm [4:5]
+ src/jdapistd.c [5:10]
KEEP COPYRIGHT_SERVICE_LABEL 11e733d6a587075ab68bcc53d29822a6
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: djpeg.c at line 10, jdapistd.c at line 10, jdinput.c at line 10, jdmaster.c at line 10, jdsample.c at line 10, jpegint.h at line 10, jpeglib.h at line 10
+FILE_INCLUDE README.ijg found in files: src/djpeg.c at line 10, src/jdapistd.c at line 10, src/jdinput.c at line 10, src/jdmaster.c at line 10, src/jdsample.c at line 10, src/jpegint.h at line 10, src/jpeglib.h at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- djpeg.c [5:11]
- jdapistd.c [5:10]
- jdinput.c [5:10]
- jdmaster.c [5:12]
- jdsample.c [5:13]
- jpegint.h [5:12]
- jpeglib.h [5:11]
+ src/djpeg.c [5:11]
+ src/jdapistd.c [5:10]
+ src/jdinput.c [5:12]
+ src/jdmaster.c [5:14]
+ src/jdsample.c [5:13]
+ src/jpegint.h [5:14]
+ src/jpeglib.h [5:14]
KEEP COPYRIGHT_SERVICE_LABEL 1249c3d3fb0e107f4cabda7b2efba8b8
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11, jdphuff.c at line 11, jdtrans.c at line 11
+FILE_INCLUDE README.ijg found in files: src/jdtrans.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcphuff.c [5:12]
- jdphuff.c [5:9]
- jdtrans.c [5:9]
+ src/jdtrans.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 152add89d1791fb293414e86b81304ef
+KEEP COPYRIGHT_SERVICE_LABEL 13010cb8c6cab093c8f6d215b932ef04
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdapimin.c at line 8
+FILE_INCLUDE README.ijg found in files: src/cjpeg.c at line 12, src/jcdiffct.c at line 12, src/jchuff.c at line 12, src/jcinit.c at line 12, src/jclhuff.c at line 12, src/jclossls.c at line 12, src/jcmainct.c at line 12, src/jcmarker.c at line 12, src/jcmaster.c at line 12, src/jcparam.c at line 12, src/jcphuff.c at line 12, src/jcprepct.c at line 12, src/jcsample.c at line 12, src/jdapimin.c at line 12, src/jddiffct.c at line 12, src/jdhuff.c at line 12, src/jdhuff.h at line 12, src/jdinput.c at line 12, src/jdlhuff.c at line 12, src/jdlossls.c at line 12, src/jdmarker.c at line 12, src/jdmaster.c at line 12, src/jdphuff.c at line 12, src/jerror.h at line 12, src/jlossls.h at line 12, src/jmorecfg.h at line 12, src/jpegint.h at line 12, src/jpeglib.h at line 12
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdapimin.c [5:9]
+ src/cjpeg.c [5:12]
+ src/jcdiffct.c [5:11]
+ src/jchuff.c [5:15]
+ src/jcinit.c [5:11]
+ src/jclhuff.c [5:11]
+ src/jclossls.c [5:11]
+ src/jcmainct.c [5:11]
+ src/jcmarker.c [5:12]
+ src/jcmaster.c [5:12]
+ src/jcparam.c [5:12]
+ src/jcphuff.c [5:14]
+ src/jcprepct.c [5:11]
+ src/jcsample.c [5:13]
+ src/jdapimin.c [5:11]
+ src/jddiffct.c [5:11]
+ src/jdhuff.c [5:12]
+ src/jdhuff.h [5:12]
+ src/jdinput.c [5:12]
+ src/jdlhuff.c [5:11]
+ src/jdlossls.c [5:11]
+ src/jdmarker.c [5:11]
+ src/jdmaster.c [5:14]
+ src/jdphuff.c [5:11]
+ src/jerror.h [5:12]
+ src/jlossls.h [5:11]
+ src/jmorecfg.h [5:12]
+ src/jpegint.h [5:14]
+ src/jpeglib.h [5:14]
-KEEP COPYRIGHT_SERVICE_LABEL 165527239955f985662e0f2fe1203f1b
+KEEP COPYRIGHT_SERVICE_LABEL 143ba446de26dcc2a95b3e675795bb10
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: transupp.c at line 8, transupp.h at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- transupp.c [5:9]
- transupp.h [5:9]
+ LICENSE.md [97:97]
+ jversion.h [39:53]
+ src/turbojpeg-mp.c [2:2]
+ src/turbojpeg.c [2:2]
-KEEP COPYRIGHT_SERVICE_LABEL 1acdcc86793fefc64c4fe4c565b2f14f
+KEEP COPYRIGHT_SERVICE_LABEL 165527239955f985662e0f2fe1203f1b
BELONGS ya.make
- License text:
- * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
+FILE_INCLUDE README.ijg found in files: src/transupp.c at line 8, src/transupp.h at line 8
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jsimd.h [4:7]
- jsimd_none.c [4:7]
- simd/arm/aarch32/jsimd.c [4:9]
- simd/arm/aarch32/jsimd_neon.S [10:10]
- simd/arm/aarch64/jsimd.c [4:8]
- simd/arm/aarch64/jsimd_neon.S [10:10]
- simd/i386/jsimd.c [4:6]
- simd/jsimd.h [4:10]
- simd/x86_64/jsimd.c [4:6]
+ src/transupp.c [5:9]
+ src/transupp.h [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 1ad7e944e1e9a46ed48b14a55138bda8
+KEEP COPYRIGHT_SERVICE_LABEL 1acdcc86793fefc64c4fe4c565b2f14f
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegint.h at line 11
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ * Copyright (C) 2015-2016, 2018, Matthieu Darbois. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jpegint.h [5:12]
+ simd/arm/aarch32/jsimd_neon.S [10:10]
+ simd/arm/aarch64/jsimd_neon.S [10:10]
-KEEP COPYRIGHT_SERVICE_LABEL 1afd790e43464ee897b6f4dad7e6ce6d
+KEEP COPYRIGHT_SERVICE_LABEL 1b892e92391ba1d018a5507c7b63228c
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdtarga.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jcarith.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- rdtarga.c [5:10]
+ src/jcarith.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 1b892e92391ba1d018a5507c7b63228c
+KEEP COPYRIGHT_SERVICE_LABEL 1bbbadfd105e774195bc459116383e34
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcarith.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jdhuff.c at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcarith.c [5:9]
+ src/jdhuff.c [5:12]
-KEEP COPYRIGHT_SERVICE_LABEL 1ba19ef1d18e94a36d48de79900507c6
+KEEP COPYRIGHT_SERVICE_LABEL 1e373e5d7c214caaf091c17519bd8315
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/cmyk.h at line 5
License text:
- ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2009, 2016, 2018, D. R. Commander.
- ; Copyright (C) 2016, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
+ * Copyright (C) 2017-2018, 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/x86_64/jquanti-avx2.asm [4:7]
+ src/cmyk.h [4:6]
KEEP COPYRIGHT_SERVICE_LABEL 1e45cf53e9734d2459db159d28f16e4b
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jinclude.h at line 8
- License text:
- * Copyright (C) 1991-1994, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
+FILE_INCLUDE README.ijg found in files: src/jinclude.h at line 8
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jinclude.h [5:9]
+ src/jinclude.h [5:9]
KEEP COPYRIGHT_SERVICE_LABEL 1e540cb130e098262d5aec64669768fd
BELONGS ya.make
License text:
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2016, 2018, D. R. Commander.
+ ; Copyright (C) 2016, 2018, 2024, D. R. Commander.
; Copyright (C) 2016, Matthieu Darbois.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
@@ -364,236 +411,255 @@ BELONGS ya.make
simd/i386/jquanti-avx2.asm [4:6]
simd/x86_64/jquanti-avx2.asm [4:7]
-KEEP COPYRIGHT_SERVICE_LABEL 1e9cc28e6b04389db80412d634fddb7e
+KEEP COPYRIGHT_SERVICE_LABEL 1f57de85739b7a14cfcd6ca84f7bfb7e
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdhuff.c at line 9
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ * Copyright (C) 2009-2011, Nokia Corporation and/or its subsidiary(-ies).
+ * All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdhuff.c [5:10]
+ simd/arm/aarch32/jsimd_neon.S [4:5]
+ simd/arm/aarch64/jsimd_neon.S [4:5]
-KEEP COPYRIGHT_SERVICE_LABEL 1f57de85739b7a14cfcd6ca84f7bfb7e
+KEEP COPYRIGHT_SERVICE_LABEL 200ee19517ce77ef6c893573353f1ebb
BELONGS ya.make
License text:
- * Copyright (C) 2009-2011, Nokia Corporation and/or its subsidiary(-ies).
- * All Rights Reserved.
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/arm/aarch32/jsimd_neon.S [4:5]
- simd/arm/aarch64/jsimd_neon.S [4:5]
+ simd/arm/jccolor-neon.c [5:5]
+ simd/arm/jdsample-neon.c [5:5]
+ simd/arm/jfdctint-neon.c [5:5]
+ simd/arm/jidctint-neon.c [5:5]
+ simd/arm/jidctred-neon.c [5:5]
+ simd/arm/neon-compat.h [2:2]
-KEEP COPYRIGHT_SERVICE_LABEL 1fb659a53f330f9569a89bd858ef3ce1
+KEEP COPYRIGHT_SERVICE_LABEL 212c71fc80caadb4a16b0e0298e0ca71
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcol565.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdcoefct.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdcol565.c [5:10]
+ src/jdcoefct.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 20b2a093ccd5225bc6fc55fe4031949c
+KEEP COPYRIGHT_SERVICE_LABEL 22a18d55dccda56d9cc221cd8a48bab8
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmrgext.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jdcol565.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdmrgext.c [5:9]
+ src/jdcol565.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL 212c71fc80caadb4a16b0e0298e0ca71
+KEEP COPYRIGHT_SERVICE_LABEL 22f1d7c5732ac02efd9bb275cb633b92
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcoefct.c at line 10
+FILE_INCLUDE README.ijg found in files: src/jdpostct.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdcoefct.c [5:11]
+ src/jdpostct.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL 23088d1c57488b04621001ac1f22cd37
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcoefct.h at line 9
+FILE_INCLUDE README.ijg found in files: src/jdcoefct.h at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdcoefct.h [5:10]
+ src/jdcoefct.h [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 233835017fd9ed43858ecd8787bb95f6
+KEEP COPYRIGHT_SERVICE_LABEL 24842b1335c13d4de45693097c32a1c3
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cderror.h at line 9
+FILE_INCLUDE README.ijg found in files: src/cderror.h at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cderror.h [5:10]
+ src/cderror.h [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL 25274b14836176e3a440bcf831a85954
+KEEP COPYRIGHT_SERVICE_LABEL 24bddd7ebee3a5424a8538fb19ec4dd5
BELONGS ya.make
- License text:
- * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
+FILE_INCLUDE README.ijg found in files: src/jcsample.c at line 12
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jsimd.h [4:7]
+ src/jcsample.c [5:13]
KEEP COPYRIGHT_SERVICE_LABEL 260db70ba88e7f60351667e8f9254026
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cjpeg.c at line 9, jcmarker.c at line 9, jcparam.c at line 9, jdmarker.c at line 9, jerror.c at line 9, jidctint.c at line 9, jpeglib.h at line 9, jstdhuff.c at line 9
+FILE_INCLUDE README.ijg found in files: src/cjpeg.c at line 12, src/jcmarker.c at line 12, src/jcparam.c at line 12, src/jerror.c at line 12, src/jidctint.c at line 12, src/jpeglib.h at line 12, src/jstdhuff.c at line 12
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cjpeg.c [5:10]
- jcmarker.c [5:10]
- jcparam.c [5:10]
- jdmarker.c [5:9]
- jerror.c [5:9]
- jidctint.c [5:10]
- jpeglib.h [5:11]
- jstdhuff.c [5:9]
+ src/cjpeg.c [5:12]
+ src/jcmarker.c [5:12]
+ src/jcparam.c [5:12]
+ src/jerror.c [5:9]
+ src/jidctint.c [5:10]
+ src/jpeglib.h [5:14]
+ src/jstdhuff.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 263caad4ba33bd3ef6290d6aeecbe970
+KEEP COPYRIGHT_SERVICE_LABEL 2870222b259e7ae538e6e763d9317be5
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ * Copyright (C) 2020, 2022, 2024, D. R. Commander. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jchuff.c [5:12]
+ simd/arm/aarch64/jchuff-neon.c [5:5]
+ src/jcinit.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 2672fb937e60710dec1b0b8a7906d209
+KEEP COPYRIGHT_SERVICE_LABEL 2e20febfc45f1f8ef6742ee1936089c4
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcparam.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcparam.c [5:10]
+ simd/jsimd.h [4:10]
-KEEP COPYRIGHT_SERVICE_LABEL 26eb00d97e3ef709d9a86754532ff978
+KEEP COPYRIGHT_SERVICE_LABEL 3256dbeb994e6b4ac351be827ae3c0a2
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jdmrg565.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- LICENSE.md [94:94]
- jversion.h [39:51]
- turbojpeg.c [2:2]
+ src/jdmrg565.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL 295e5b669dd969a48ac39f34bc8fd7d3
+KEEP COPYRIGHT_SERVICE_LABEL 32b610376fe997211b9614807b396e0a
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcolor.c at line 11
+FILE_INCLUDE README.ijg found in files: src/jdcoefct.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdcolor.c [5:12]
+ src/jdcoefct.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 29b99ba4246a9d3cc7b50e48a274da0d
+KEEP COPYRIGHT_SERVICE_LABEL 366e4b10a51306ff66614307ac53900d
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdbmp.c at line 10
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ ; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
+ ; Copyright (C) 2012, 2016, 2024, D. R. Commander.
+ ; Copyright (C) 2015, Intel Corporation.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- rdbmp.c [5:11]
+ simd/i386/jdcolext-avx2.asm [4:6]
+ simd/i386/jdcolext-sse2.asm [4:5]
+ simd/i386/jdmrgext-avx2.asm [4:6]
+ simd/i386/jdmrgext-sse2.asm [4:5]
+ simd/x86_64/jdcolext-avx2.asm [4:8]
+ simd/x86_64/jdcolext-sse2.asm [4:7]
+ simd/x86_64/jdmrgext-avx2.asm [4:8]
+ simd/x86_64/jdmrgext-sse2.asm [4:7]
-KEEP COPYRIGHT_SERVICE_LABEL 2abf650befa8dcfcd29490f514c687d3
+KEEP COPYRIGHT_SERVICE_LABEL 37cd0f481fff20f5d588c9096610f193
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdapistd.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jidctflt.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdapistd.c [5:10]
+ src/jidctflt.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL 2e20febfc45f1f8ef6742ee1936089c4
+KEEP COPYRIGHT_SERVICE_LABEL 38c62e15766b92959225434671d5f9ea
BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ ; Copyright (C) 2016, 2020, 2024, D. R. Commander.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/jsimd.h [4:10]
+ simd/i386/jfdctint-mmx.asm [4:5]
+ simd/i386/jfdctint-sse2.asm [4:5]
+ simd/i386/jidctint-mmx.asm [4:5]
+ simd/i386/jidctint-sse2.asm [4:5]
-KEEP COPYRIGHT_SERVICE_LABEL 366e4b10a51306ff66614307ac53900d
+KEEP COPYRIGHT_SERVICE_LABEL 39c134755a04f799cfbf116467767bc0
BELONGS ya.make
- License text:
- ; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2012, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
+FILE_INCLUDE README.ijg found in files: src/jdmrgext.c at line 8
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jdcolext-avx2.asm [4:6]
- simd/i386/jdcolext-sse2.asm [4:5]
- simd/i386/jdmrgext-avx2.asm [4:6]
- simd/i386/jdmrgext-sse2.asm [4:5]
- simd/x86_64/jdcolext-avx2.asm [4:7]
- simd/x86_64/jdcolext-sse2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdmrgext-sse2.asm [4:6]
+ src/jdmrgext.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 36e84c409abecc7cefe7cd5dfd105381
+KEEP COPYRIGHT_SERVICE_LABEL 3d3a87c635f1834fb097a2c158a581c7
BELONGS ya.make
- License text:
- * Copyright (C)2009-2015, 2017, 2020-2021 D. R. Commander.
- * All Rights Reserved.
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- turbojpeg.h [2:3]
+ simd/x86_64/jdcolext-avx2.asm [4:8]
+ simd/x86_64/jdcolext-sse2.asm [4:7]
+ simd/x86_64/jdmrgext-avx2.asm [4:8]
+ simd/x86_64/jdmrgext-sse2.asm [4:7]
-KEEP COPYRIGHT_SERVICE_LABEL 3d8a221d5e85eceaf22464a0b1bc72cd
+KEEP COPYRIGHT_SERVICE_LABEL 3d5f8ebe6fdc7782fd1a1dd36969c848
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdinput.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jpegint.h at line 13
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdinput.c [5:10]
+ src/jpegint.h [5:14]
+
+KEEP COPYRIGHT_SERVICE_LABEL 3f8bd016bf1d87514ec74f2f9a2120fb
+BELONGS ya.make
+ License text:
+ ; Copyright (C) 2009-2011, 2014-2017, 2019, 2024, D. R. Commander.
+ ; Copyright (C) 2015, Matthieu Darbois.
+ ; Copyright (C) 2018, Matthias Räncker.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/i386/jchuff-sse2.asm [4:6]
KEEP COPYRIGHT_SERVICE_LABEL 3ff1e15ee5c983f31a11845ba1303bdd
BELONGS ya.make
@@ -606,88 +672,89 @@ FILE_INCLUDE README.ijg found in files: simd/arm/jchuff.h at line 10
Files with this license:
simd/arm/jchuff.h [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 4292948c897bb7af094f64c57edbd8ef
+KEEP COPYRIGHT_SERVICE_LABEL 402e747f73ff1991b3433a9178fb3a35
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jerror.h at line 9
+FILE_INCLUDE README.ijg found in files: src/jccolor.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jerror.h [5:10]
+ src/jccolor.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 44be2ad22f421bfaf11c38a97ec194fa
+KEEP COPYRIGHT_SERVICE_LABEL 44c57ae8756c03a43cc49d652ea73313
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdatadst-tj.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jccolext.c at line 8, src/jccolor.c at line 8, src/jdsample.c at line 8, src/jdsample.h at line 8, src/jfdctint.c at line 8, src/jquant1.c at line 8, src/jquant2.c at line 8, src/jutils.c at line 8, src/rdswitch.c at line 8, src/rdtarga.c at line 8, src/wrppm.c at line 8, src/wrtarga.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdatadst-tj.c [5:10]
+ src/jccolext.c [5:9]
+ src/jccolor.c [5:11]
+ src/jdsample.c [5:13]
+ src/jdsample.h [5:9]
+ src/jfdctint.c [5:9]
+ src/jquant1.c [5:9]
+ src/jquant2.c [5:9]
+ src/jutils.c [5:9]
+ src/rdswitch.c [5:9]
+ src/rdtarga.c [5:10]
+ src/wrppm.c [5:10]
+ src/wrtarga.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 44c57ae8756c03a43cc49d652ea73313
+KEEP COPYRIGHT_SERVICE_LABEL 4636a62a8d91a4cbe9262bf83287b971
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolext.c at line 8, jccolor.c at line 8, jcsample.c at line 8, jdsample.c at line 8, jdsample.h at line 8, jfdctint.c at line 8, jquant1.c at line 8, jquant2.c at line 8, jutils.c at line 8, rdswitch.c at line 8, rdtarga.c at line 8, wrppm.c at line 8, wrtarga.c at line 8
- Note: matched license text is too long. Read it in the source files.
+FILE_INCLUDE README.ijg found in files: src/jcicc.c at line 6, src/jdicc.c at line 6
+ License text:
+ * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
+ * Copyright (C) 2017, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jccolext.c [5:9]
- jccolor.c [5:11]
- jcsample.c [5:11]
- jdsample.c [5:13]
- jdsample.h [5:7]
- jfdctint.c [5:9]
- jquant1.c [5:9]
- jquant2.c [5:9]
- jutils.c [5:9]
- rdswitch.c [5:9]
- rdtarga.c [5:10]
- wrppm.c [5:10]
- wrtarga.c [5:9]
+ src/jcicc.c [4:7]
+ src/jdicc.c [4:7]
-KEEP COPYRIGHT_SERVICE_LABEL 450015c7f57bc091445dc56f6b2cdfc0
+KEEP COPYRIGHT_SERVICE_LABEL 4680c0f004365095e326c17cb51c6201
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrppm.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdmainct.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- wrppm.c [5:10]
+ src/jdmainct.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 45dfad5b2ebfed97272719e6f1ef717c
+KEEP COPYRIGHT_SERVICE_LABEL 473be9b7b1577b58d7f5c445411cd215
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdgif.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdmaster.c at line 13
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- rdgif.c [5:10]
+ src/jdmaster.c [5:14]
-KEEP COPYRIGHT_SERVICE_LABEL 4636a62a8d91a4cbe9262bf83287b971
+KEEP COPYRIGHT_SERVICE_LABEL 4745f7542f4d4774799559824b14e0be
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcicc.c at line 6, jdicc.c at line 6
License text:
- * Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
- * Copyright (C) 2017, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
+ ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ ; Copyright (C) 2016, 2018, 2024, D. R. Commander.
+ ; Copyright (C) 2016, Matthieu Darbois.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcicc.c [4:7]
- jdicc.c [4:7]
+ simd/i386/jquanti-avx2.asm [4:6]
KEEP COPYRIGHT_SERVICE_LABEL 47fc44857c47b9fc7886e2d4af29d56d
BELONGS ya.make
@@ -697,37 +764,32 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ jversion.h [39:53]
KEEP COPYRIGHT_SERVICE_LABEL 480cafc45780df29ac6b7113176124d9
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmemnobs.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jmemnobs.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jmemnobs.c [5:9]
+ src/jmemnobs.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL 4855c5404dbb62841cec15bacf070c2e
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11, jcphuff.c at line 11, jsimd.h at line 10, jsimd_none.c at line 10, simd/arm/aarch32/jccolext-neon.c at line 10, simd/arm/aarch32/jchuff-neon.c at line 10, simd/arm/aarch32/jsimd.c at line 10, simd/arm/aarch64/jccolext-neon.c at line 10, simd/arm/aarch64/jsimd.c at line 10, simd/arm/align.h at line 8, simd/arm/jccolor-neon.c at line 10, simd/arm/jcgray-neon.c at line 10, simd/arm/jcgryext-neon.c at line 10, simd/arm/jcsample-neon.c at line 10, simd/arm/jdcolext-neon.c at line 10, simd/arm/jdcolor-neon.c at line 10, simd/arm/jdmerge-neon.c at line 10, simd/arm/jdmrgext-neon.c at line 10, simd/arm/jdsample-neon.c at line 10, simd/arm/jfdctfst-neon.c at line 10, simd/arm/jfdctint-neon.c at line 10, simd/arm/jidctfst-neon.c at line 10, simd/arm/jidctint-neon.c at line 10, simd/arm/jidctred-neon.c at line 10, simd/jsimd.h at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jchuff.c [5:12]
- jcphuff.c [5:12]
- jsimd.h [4:7]
- jsimd_none.c [4:7]
simd/arm/aarch32/jccolext-neon.c [4:4]
simd/arm/aarch32/jchuff-neon.c [4:4]
simd/arm/aarch32/jsimd.c [4:9]
simd/arm/aarch64/jccolext-neon.c [4:4]
- simd/arm/aarch64/jsimd.c [4:8]
+ simd/arm/aarch64/jsimd.c [4:9]
simd/arm/align.h [2:2]
simd/arm/jccolor-neon.c [4:4]
simd/arm/jcgray-neon.c [4:4]
@@ -744,6 +806,10 @@ FILE_INCLUDE README.ijg found in files: jchuff.c at line 11, jcphuff.c at line 1
simd/arm/jidctint-neon.c [4:4]
simd/arm/jidctred-neon.c [4:4]
simd/jsimd.h [4:10]
+ src/jchuff.c [5:15]
+ src/jcphuff.c [5:14]
+ src/jpeg_nbits.h [2:4]
+ src/jsimd.h [4:7]
KEEP COPYRIGHT_SERVICE_LABEL 4a3493336b28feee7d6c4e061d0a2d2b
BELONGS ya.make
@@ -757,76 +823,83 @@ BELONGS ya.make
Files with this license:
simd/arm/aarch64/jsimd_neon.S [6:7]
-KEEP COPYRIGHT_SERVICE_LABEL 4f6b6761b55823e2cea9a9046a1374b4
+KEEP COPYRIGHT_SERVICE_LABEL 4b3c97219276828ed14366b07f0aede2
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmrg565.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdmrg565.c [5:10]
+ simd/arm/aarch32/jsimd.c [4:9]
-KEEP COPYRIGHT_SERVICE_LABEL 501d9d9fd254b645bfdd5c1afeaf2b7b
+KEEP COPYRIGHT_SERVICE_LABEL 4c2163e51b9ed8090a26069dbdde61c2
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmemsys.h at line 8
+FILE_INCLUDE README.ijg found in files: src/wrppm.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jmemsys.h [5:8]
+ src/wrppm.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL 518ffe97c21503649bc9db24a865cf6b
+KEEP COPYRIGHT_SERVICE_LABEL 4c248b089801d682326ecc4cb1f391ee
BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
- ; Copyright (C) 2018, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
+FILE_INCLUDE README.ijg found in files: src/jcphuff.c at line 13
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/nasm/jsimdext.inc [4:7]
+ src/jcphuff.c [5:14]
-KEEP COPYRIGHT_SERVICE_LABEL 519b50edb8a80de408600b1899cfb023
+KEEP COPYRIGHT_SERVICE_LABEL 501d9d9fd254b645bfdd5c1afeaf2b7b
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jfdctint.c at line 8, jidctint.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jmemsys.h at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jfdctint.c [5:9]
- jidctint.c [5:10]
+ src/jmemsys.h [5:8]
-KEEP COPYRIGHT_SERVICE_LABEL 51bad5f487918501ea2be46512c58c6b
+KEEP COPYRIGHT_SERVICE_LABEL 50ea42652e559cc597bbb9ae3ecb4852
BELONGS ya.make
- License text:
- Copyright (c) 1991-2022 The libjpeg-turbo Project
+FILE_INCLUDE README.ijg found in files: src/jdapimin.c at line 10
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [53:54]
+ src/jdapimin.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 52ef6eff15e58ea7a30014a18522a0b8
+KEEP COPYRIGHT_SERVICE_LABEL 51fe983e8c48efc39f1eeacf5d16ab44
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/cdjpeg.h at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/jsimd.h [4:10]
+ src/cdjpeg.h [5:10]
+
+KEEP COPYRIGHT_SERVICE_LABEL 522d100a3ff80be6a2059ed5e2ff8060
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jcdctmgr.c at line 10
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jcdctmgr.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 55d69ef5c2827524a7c5cdd2ef41b997
+KEEP COPYRIGHT_SERVICE_LABEL 52ef6eff15e58ea7a30014a18522a0b8
BELONGS ya.make
Note: matched license text is too long. Read it in the source files.
Scancode info:
@@ -847,55 +920,55 @@ FILE_INCLUDE README.ijg found in files: jversion.h at line 8
Files with this license:
jversion.h [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 5aa53b258f764fbe51be48c4ab1f1d1f
+KEEP COPYRIGHT_SERVICE_LABEL 5942dca4c7f00924e5a7857157ce7c07
BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+FILE_INCLUDE README.ijg found in files: src/jcphuff.c at line 13
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jfdctint-avx2.asm [4:5]
- simd/i386/jidctint-avx2.asm [4:5]
- simd/x86_64/jfdctint-avx2.asm [4:5]
- simd/x86_64/jidctint-avx2.asm [4:6]
+ src/jcphuff.c [5:14]
-KEEP COPYRIGHT_SERVICE_LABEL 5b4d2ba74e51eb91bbd5aef822f9aae3
+KEEP COPYRIGHT_SERVICE_LABEL 59da30b54ba158e496b715ee3eac50ff
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegtran.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jmemmgr.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jpegtran.c [5:9]
+ src/jmemmgr.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 5be2bec78aaafa60d86afed2fe95055c
+KEEP COPYRIGHT_SERVICE_LABEL 5c71cfc1b39a982a71325ed95841ac87
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: djpeg.c at line 10
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ * Copyright (C) 2014, 2021, 2024, D. R. Commander.
+ * Copyright (C) 2014, Olle Liljenzin.
+ * Copyright (C) 2020, Arm Limited.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- djpeg.c [5:11]
+ src/jpeg_nbits.h [2:4]
-KEEP COPYRIGHT_SERVICE_LABEL 5f6a538b377c16ee13ee1496c713b176
+KEEP COPYRIGHT_SERVICE_LABEL 5cc27d8bf4d188df85aa70dfe3186b2a
BELONGS ya.make
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ ; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/x86_64/jdcolext-avx2.asm [4:7]
- simd/x86_64/jdcolext-sse2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdmrgext-sse2.asm [4:6]
+ simd/i386/jfdctint-avx2.asm [4:5]
+ simd/i386/jidctint-avx2.asm [4:5]
+ simd/x86_64/jfdctint-avx2.asm [4:5]
+ simd/x86_64/jidctint-avx2.asm [4:6]
KEEP COPYRIGHT_SERVICE_LABEL 600b52ef1b2e8a91bced51054f66f3b1
BELONGS ya.make
@@ -907,150 +980,198 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jchuff.c [583:584]
- jcphuff.c [521:522]
+ src/jchuff.c [581:582]
+ src/jcphuff.c [498:499]
KEEP COPYRIGHT_SERVICE_LABEL 60905578d76ff9b2e20929c31ca32f13
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdhuff.h at line 9
+FILE_INCLUDE README.ijg found in files: src/jdhuff.h at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdhuff.h [5:10]
+ src/jdhuff.h [5:12]
KEEP COPYRIGHT_SERVICE_LABEL 60bbb1946c5720a631b0e530309742ec
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11, simd/i386/jchuff-sse2.asm at line 10, simd/x86_64/jchuff-sse2.asm at line 10
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ ; Copyright (C) 2009-2011, 2014-2017, 2019, 2024, D. R. Commander.
+ ; Copyright (C) 2015, Matthieu Darbois.
+ ; Copyright (C) 2018, Matthias Räncker.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jchuff.c [5:12]
simd/i386/jchuff-sse2.asm [4:6]
- simd/x86_64/jchuff-sse2.asm [4:6]
+ simd/x86_64/jchuff-sse2.asm [4:7]
+ src/jchuff.c [5:15]
-KEEP COPYRIGHT_SERVICE_LABEL 660eca46c511999474ff8017e496f51c
+KEEP COPYRIGHT_SERVICE_LABEL 6363414eb2a9b1f11930b884e2f08af4
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jerror.h at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ src/jerror.h [5:12]
+
+KEEP COPYRIGHT_SERVICE_LABEL 63a479db7fe698014dbeba22194b04d5
+BELONGS ya.make
+ License text:
+ ; Copyright (C) 2009, 2016, 2024, D. R. Commander.
+ ; Copyright (C) 2015, Intel Corporation.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/i386/jccolor-avx2.asm [4:5]
+ simd/i386/jccolor-mmx.asm [4:5]
+ simd/i386/jccolor-sse2.asm [4:4]
+ simd/i386/jdcolor-mmx.asm [4:5]
+ simd/i386/jdcolor-sse2.asm [4:5]
+ simd/i386/jdmerge-avx2.asm [4:6]
+ simd/i386/jdmerge-mmx.asm [4:5]
+ simd/i386/jdmerge-sse2.asm [4:5]
+ simd/x86_64/jccolext-avx2.asm [4:7]
+ simd/x86_64/jccolext-sse2.asm [4:6]
+ simd/x86_64/jccolor-avx2.asm [4:5]
+ simd/x86_64/jccolor-sse2.asm [4:4]
+ simd/x86_64/jcsample-avx2.asm [4:7]
+ simd/x86_64/jcsample-sse2.asm [4:6]
+ simd/x86_64/jdcolor-avx2.asm [4:6]
+ simd/x86_64/jdcolor-sse2.asm [4:5]
+ simd/x86_64/jdmerge-avx2.asm [4:6]
+ simd/x86_64/jdmerge-sse2.asm [4:5]
+ simd/x86_64/jdsample-avx2.asm [4:8]
+ simd/x86_64/jdsample-sse2.asm [4:7]
+ simd/x86_64/jfdctflt-sse.asm [4:6]
+ simd/x86_64/jfdctfst-sse2.asm [4:6]
+ simd/x86_64/jidctflt-sse2.asm [4:7]
+ simd/x86_64/jidctfst-sse2.asm [4:7]
+ simd/x86_64/jidctred-sse2.asm [4:7]
+ simd/x86_64/jquantf-sse2.asm [4:6]
+ simd/x86_64/jquanti-sse2.asm [4:6]
-KEEP COPYRIGHT_SERVICE_LABEL 6671698e9a2a769e8f652725e0cd494a
+KEEP COPYRIGHT_SERVICE_LABEL 660eca46c511999474ff8017e496f51c
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cdjpeg.h at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cdjpeg.h [5:10]
+ jversion.h [39:53]
KEEP COPYRIGHT_SERVICE_LABEL 66e5c8e9af8d0ef7cf8741f0659c1e0c
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegtran.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jpegtran.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jpegtran.c [5:9]
+ src/jpegtran.c [5:9]
+
+KEEP COPYRIGHT_SERVICE_LABEL 67b26c4c62038ed9d521916ec59fa891
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jpeglib.h at line 13
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jpeglib.h [5:14]
KEEP COPYRIGHT_SERVICE_LABEL 6810534b9bd4aab0c6b7827b6c0f1fd9
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcinit.c at line 8, jdmerge.h at line 8, jdtrans.c at line 8, simd/arm/aarch32/jccolext-neon.c at line 8, simd/arm/jccolor-neon.c at line 8, simd/arm/jdcolext-neon.c at line 8, simd/arm/jdmrgext-neon.c at line 8, simd/arm/jdsample-neon.c at line 8, simd/arm/jfdctint-neon.c at line 8, simd/arm/jidctint-neon.c at line 8, simd/arm/jidctred-neon.c at line 8, simd/arm/neon-compat.h at line 5
License text:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
+ * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcinit.c [5:9]
- jdmerge.h [5:9]
- jdtrans.c [5:9]
simd/arm/aarch32/jccolext-neon.c [5:5]
- simd/arm/jccolor-neon.c [5:5]
simd/arm/jdcolext-neon.c [5:5]
simd/arm/jdmrgext-neon.c [5:5]
- simd/arm/jdsample-neon.c [5:5]
- simd/arm/jfdctint-neon.c [5:5]
- simd/arm/jidctint-neon.c [5:5]
- simd/arm/jidctred-neon.c [5:5]
- simd/arm/neon-compat.h [2:2]
-KEEP COPYRIGHT_SERVICE_LABEL 6813c2b6fb9997bdcb51ad621d1a371b
+KEEP COPYRIGHT_SERVICE_LABEL 6907b11c6726886d220d1f0eb4046ea0
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmarker.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jpegtran.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdmarker.c [5:9]
+ src/jpegtran.c [5:9]
+
+KEEP COPYRIGHT_SERVICE_LABEL 6a226d15ee49bc0c567717275b3183c4
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jcmaster.c at line 11
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jcmaster.c [5:12]
KEEP COPYRIGHT_SERVICE_LABEL 6aff4539cc564a76b36cfd2daf2e3833
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jchuff.c at line 11, jdhuff.c at line 11, jdhuff.h at line 11, simd/arm/jchuff.h at line 11, simd/i386/jchuff-sse2.asm at line 10, simd/nasm/jsimdext.inc at line 10, simd/x86_64/jccolext-avx2.asm at line 10, simd/x86_64/jccolext-sse2.asm at line 10, simd/x86_64/jcgryext-avx2.asm at line 10, simd/x86_64/jcgryext-sse2.asm at line 10, simd/x86_64/jchuff-sse2.asm at line 10, simd/x86_64/jcsample-avx2.asm at line 10, simd/x86_64/jcsample-sse2.asm at line 10, simd/x86_64/jdcolext-avx2.asm at line 10, simd/x86_64/jdcolext-sse2.asm at line 10, simd/x86_64/jdmrgext-avx2.asm at line 10, simd/x86_64/jdmrgext-sse2.asm at line 10, simd/x86_64/jdsample-avx2.asm at line 10, simd/x86_64/jdsample-sse2.asm at line 10, simd/x86_64/jidctflt-sse2.asm at line 10, simd/x86_64/jidctfst-sse2.asm at line 10, simd/x86_64/jidctint-avx2.asm at line 10, simd/x86_64/jidctint-sse2.asm at line 10, simd/x86_64/jidctred-sse2.asm at line 10, simd/x86_64/jquantf-sse2.asm at line 10, simd/x86_64/jquanti-avx2.asm at line 10, simd/x86_64/jquanti-sse2.asm at line 10
+FILE_INCLUDE README.ijg found in files: simd/arm/jchuff.h at line 10, simd/i386/jchuff-sse2.asm at line 9, simd/nasm/jsimdext.inc at line 9, simd/x86_64/jccolext-avx2.asm at line 9, simd/x86_64/jccolext-sse2.asm at line 9, simd/x86_64/jcgryext-avx2.asm at line 9, simd/x86_64/jcgryext-sse2.asm at line 9, simd/x86_64/jchuff-sse2.asm at line 9, simd/x86_64/jcsample-avx2.asm at line 9, simd/x86_64/jcsample-sse2.asm at line 9, simd/x86_64/jdcolext-avx2.asm at line 9, simd/x86_64/jdcolext-sse2.asm at line 9, simd/x86_64/jdmrgext-avx2.asm at line 9, simd/x86_64/jdmrgext-sse2.asm at line 9, simd/x86_64/jdsample-avx2.asm at line 9, simd/x86_64/jdsample-sse2.asm at line 9, simd/x86_64/jidctflt-sse2.asm at line 9, simd/x86_64/jidctfst-sse2.asm at line 9, simd/x86_64/jidctint-avx2.asm at line 9, simd/x86_64/jidctint-sse2.asm at line 9, simd/x86_64/jidctred-sse2.asm at line 9, simd/x86_64/jquantf-sse2.asm at line 9, simd/x86_64/jquanti-avx2.asm at line 9, simd/x86_64/jquanti-sse2.asm at line 9, src/jchuff.c at line 10, src/jdhuff.c at line 10, src/jdhuff.h at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jchuff.c [5:12]
- jdhuff.c [5:10]
- jdhuff.h [5:10]
simd/arm/jchuff.h [5:11]
simd/i386/jchuff-sse2.asm [4:6]
- simd/nasm/jsimdext.inc [4:7]
- simd/x86_64/jccolext-avx2.asm [4:6]
- simd/x86_64/jccolext-sse2.asm [4:5]
- simd/x86_64/jcgryext-avx2.asm [4:6]
- simd/x86_64/jcgryext-sse2.asm [4:5]
- simd/x86_64/jchuff-sse2.asm [4:6]
+ simd/nasm/jsimdext.inc [4:8]
+ simd/x86_64/jccolext-avx2.asm [4:7]
+ simd/x86_64/jccolext-sse2.asm [4:6]
+ simd/x86_64/jcgryext-avx2.asm [4:7]
+ simd/x86_64/jcgryext-sse2.asm [4:6]
+ simd/x86_64/jchuff-sse2.asm [4:7]
simd/x86_64/jcsample-avx2.asm [4:7]
simd/x86_64/jcsample-sse2.asm [4:6]
- simd/x86_64/jdcolext-avx2.asm [4:7]
- simd/x86_64/jdcolext-sse2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdmrgext-sse2.asm [4:6]
- simd/x86_64/jdsample-avx2.asm [4:7]
- simd/x86_64/jdsample-sse2.asm [4:6]
- simd/x86_64/jidctflt-sse2.asm [4:6]
- simd/x86_64/jidctfst-sse2.asm [4:6]
+ simd/x86_64/jdcolext-avx2.asm [4:8]
+ simd/x86_64/jdcolext-sse2.asm [4:7]
+ simd/x86_64/jdmrgext-avx2.asm [4:8]
+ simd/x86_64/jdmrgext-sse2.asm [4:7]
+ simd/x86_64/jdsample-avx2.asm [4:8]
+ simd/x86_64/jdsample-sse2.asm [4:7]
+ simd/x86_64/jidctflt-sse2.asm [4:7]
+ simd/x86_64/jidctfst-sse2.asm [4:7]
simd/x86_64/jidctint-avx2.asm [4:6]
- simd/x86_64/jidctint-sse2.asm [4:6]
- simd/x86_64/jidctred-sse2.asm [4:6]
+ simd/x86_64/jidctint-sse2.asm [4:7]
+ simd/x86_64/jidctred-sse2.asm [4:7]
simd/x86_64/jquantf-sse2.asm [4:6]
simd/x86_64/jquanti-avx2.asm [4:7]
simd/x86_64/jquanti-sse2.asm [4:6]
+ src/jchuff.c [5:15]
+ src/jdhuff.c [5:12]
+ src/jdhuff.h [5:12]
KEEP COPYRIGHT_SERVICE_LABEL 6b27b02a83f5acbedf97e2af93f106ce
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdswitch.c at line 8
+FILE_INCLUDE README.ijg found in files: src/rdswitch.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- rdswitch.c [5:9]
+ src/rdswitch.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL 6e387c76ad0c9566059a9f9d957682f1
BELONGS ya.make
@@ -1060,42 +1181,18 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
-
-KEEP COPYRIGHT_SERVICE_LABEL 6eb2b24499a14d2c8a22f88b12735a09
-BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2016, 2018, D. R. Commander.
- ; Copyright (C) 2016, Matthieu Darbois.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- simd/i386/jquanti-avx2.asm [4:6]
+ jversion.h [39:53]
KEEP COPYRIGHT_SERVICE_LABEL 6eb3d0c5f735d6c9284f341dc1236bed
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdphuff.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jdphuff.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdphuff.c [5:9]
-
-KEEP COPYRIGHT_SERVICE_LABEL 703a7a65a9b856b35aa7c7808a7287fc
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jquant1.c at line 8
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jquant1.c [5:9]
+ src/jdphuff.c [5:11]
KEEP COPYRIGHT_SERVICE_LABEL 70c1e29ed3f2dcad843e598653327b67
BELONGS ya.make
@@ -1118,84 +1215,74 @@ BELONGS ya.make
Files with this license:
simd/arm/aarch64/jsimd_neon.S [11:11]
-KEEP COPYRIGHT_SERVICE_LABEL 73b8c8c41571d643184b1c9d911eca42
+KEEP COPYRIGHT_SERVICE_LABEL 72d5fcfb41124f4802b06973321d05dc
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmaster.c at line 11
+FILE_INCLUDE README.ijg found in files: src/jcphuff.c at line 13, src/jdphuff.c at line 13
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdmaster.c [5:12]
+ src/jcphuff.c [5:14]
+ src/jdphuff.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 742c1fe44d959285f890f38257b78a56
+KEEP COPYRIGHT_SERVICE_LABEL 7368078051aa15ee967ba1109dd6af7e
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jdapimin.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/arm/aarch64/jsimd.c [4:8]
+ src/jdapimin.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 7620be1aff6ecbf9c6bdaeacf1b9cc57
+KEEP COPYRIGHT_SERVICE_LABEL 73b43db9033e7e818ebb5a650a5e9bab
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/transupp.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- rdgif.c [26:32]
+ src/transupp.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 77086af1369f22e7eb3a40f2c5a423e9
-BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11, simd/i386/jcphuff-sse2.asm at line 10, simd/x86_64/jcphuff-sse2.asm at line 11
- Note: matched license text is too long. Read it in the source files.
- Scancode info:
- Original SPDX id: COPYRIGHT_SERVICE_LABEL
- Score : 100.00
- Match type : COPYRIGHT
- Files with this license:
- jcphuff.c [5:12]
- simd/i386/jcphuff-sse2.asm [4:4]
- simd/x86_64/jcphuff-sse2.asm [5:5]
-
-KEEP COPYRIGHT_SERVICE_LABEL 7868e712d11159d5f95f6227307c9ea9
+KEEP COPYRIGHT_SERVICE_LABEL 7620be1aff6ecbf9c6bdaeacf1b9cc57
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolor.c at line 10, jcsample.c at line 10, jdsample.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jccolor.c [5:11]
- jcsample.c [5:11]
- jdsample.c [5:13]
+ src/rdgif.c [26:32]
-KEEP COPYRIGHT_SERVICE_LABEL 79ef6f7b35853561e461606aaf6f3d14
+KEEP COPYRIGHT_SERVICE_LABEL 77086af1369f22e7eb3a40f2c5a423e9
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jidctflt.c at line 9
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ ; Copyright (C) 2016, 2018, Matthieu Darbois
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jidctflt.c [5:10]
+ simd/i386/jcphuff-sse2.asm [4:4]
+ simd/x86_64/jcphuff-sse2.asm [5:7]
-KEEP COPYRIGHT_SERVICE_LABEL 7e31d53b19f09cda635bcecb2051e38c
+KEEP COPYRIGHT_SERVICE_LABEL 7868e712d11159d5f95f6227307c9ea9
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: rdppm.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jccolor.c at line 10, src/jcsample.c at line 10, src/jdsample.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- rdppm.c [5:10]
+ src/jccolor.c [5:11]
+ src/jcsample.c [5:13]
+ src/jdsample.c [5:13]
KEEP COPYRIGHT_SERVICE_LABEL 7e915a2a5af4ecd6601c584b49121ec7
BELONGS ya.make
@@ -1206,23 +1293,21 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- LICENSE.md [95:95]
+ LICENSE.md [98:98]
KEEP COPYRIGHT_SERVICE_LABEL 804ebbe411e8d8ad599ecb18d89742e7
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcdctmgr.c at line 10, jsimd.h at line 15, jsimd_none.c at line 15, jsimddct.h at line 12, simd/arm/aarch32/jsimd.c at line 17, simd/arm/aarch64/jsimd.c at line 16, simd/i386/jccolext-avx2.asm at line 13, simd/i386/jccolext-mmx.asm at line 13, simd/i386/jccolext-sse2.asm at line 12, simd/i386/jccolor-avx2.asm at line 13, simd/i386/jccolor-mmx.asm at line 13, simd/i386/jccolor-sse2.asm at line 12, simd/i386/jcgray-avx2.asm at line 13, simd/i386/jcgray-mmx.asm at line 13, simd/i386/jcgray-sse2.asm at line 12, simd/i386/jcgryext-avx2.asm at line 13, simd/i386/jcgryext-mmx.asm at line 13, simd/i386/jcgryext-sse2.asm at line 12, simd/i386/jchuff-sse2.asm at line 14, simd/i386/jcphuff-sse2.asm at line 12, simd/i386/jcsample-avx2.asm at line 14, simd/i386/jcsample-mmx.asm at line 13, simd/i386/jcsample-sse2.asm at line 13, simd/i386/jdcolext-avx2.asm at line 14, simd/i386/jdcolext-mmx.asm at line 13, simd/i386/jdcolext-sse2.asm at line 13, simd/i386/jdcolor-avx2.asm at line 14, simd/i386/jdcolor-mmx.asm at line 13, simd/i386/jdcolor-sse2.asm at line 13, simd/i386/jdmerge-avx2.asm at line 14, simd/i386/jdmerge-mmx.asm at line 13, simd/i386/jdmerge-sse2.asm at line 13, simd/i386/jdmrgext-avx2.asm at line 14, simd/i386/jdmrgext-mmx.asm at line 13, simd/i386/jdmrgext-sse2.asm at line 13, simd/i386/jdsample-avx2.asm at line 14, simd/i386/jdsample-mmx.asm at line 13, simd/i386/jdsample-sse2.asm at line 13, simd/i386/jfdctflt-3dn.asm at line 13, simd/i386/jfdctflt-sse.asm at line 13, simd/i386/jfdctfst-mmx.asm at line 13, simd/i386/jfdctfst-sse2.asm at line 13, simd/i386/jfdctint-avx2.asm at line 13, simd/i386/jfdctint-mmx.asm at line 13, simd/i386/jfdctint-sse2.asm at line 13, simd/i386/jidctflt-3dn.asm at line 13, simd/i386/jidctflt-sse.asm at line 13, simd/i386/jidctflt-sse2.asm at line 13, simd/i386/jidctfst-mmx.asm at line 13, simd/i386/jidctfst-sse2.asm at line 13, simd/i386/jidctint-avx2.asm at line 13, simd/i386/jidctint-mmx.asm at line 13, simd/i386/jidctint-sse2.asm at line 13, simd/i386/jidctred-mmx.asm at line 13, simd/i386/jidctred-sse2.asm at line 13, simd/i386/jquant-3dn.asm at line 13, simd/i386/jquant-mmx.asm at line 13, simd/i386/jquant-sse.asm at line 13, simd/i386/jquantf-sse2.asm at line 13, simd/i386/jquanti-avx2.asm at line 14, simd/i386/jquanti-sse2.asm at line 13, simd/i386/jsimd.c at line 14, simd/i386/jsimdcpu.asm at line 13, simd/jsimd.h at line 18, simd/nasm/jcolsamp.inc at line 13, simd/nasm/jdct.inc at line 13, simd/nasm/jsimdext.inc at line 16, simd/x86_64/jccolext-avx2.asm at line 14, simd/x86_64/jccolext-sse2.asm at line 13, simd/x86_64/jccolor-avx2.asm at line 13, simd/x86_64/jccolor-sse2.asm at line 12, simd/x86_64/jcgray-avx2.asm at line 13, simd/x86_64/jcgray-sse2.asm at line 12, simd/x86_64/jcgryext-avx2.asm at line 14, simd/x86_64/jcgryext-sse2.asm at line 13, simd/x86_64/jchuff-sse2.asm at line 14, simd/x86_64/jcphuff-sse2.asm at line 13, simd/x86_64/jcsample-avx2.asm at line 15, simd/x86_64/jcsample-sse2.asm at line 14, simd/x86_64/jdcolext-avx2.asm at line 15, simd/x86_64/jdcolext-sse2.asm at line 14, simd/x86_64/jdcolor-avx2.asm at line 14, simd/x86_64/jdcolor-sse2.asm at line 13, simd/x86_64/jdmerge-avx2.asm at line 14, simd/x86_64/jdmerge-sse2.asm at line 13, simd/x86_64/jdmrgext-avx2.asm at line 15, simd/x86_64/jdmrgext-sse2.asm at line 14, simd/x86_64/jdsample-avx2.asm at line 15, simd/x86_64/jdsample-sse2.asm at line 14, simd/x86_64/jfdctflt-sse.asm at line 13, simd/x86_64/jfdctfst-sse2.asm at line 13, simd/x86_64/jfdctint-avx2.asm at line 13, simd/x86_64/jfdctint-sse2.asm at line 13, simd/x86_64/jidctflt-sse2.asm at line 14, simd/x86_64/jidctfst-sse2.asm at line 14, simd/x86_64/jidctint-avx2.asm at line 14, simd/x86_64/jidctint-sse2.asm at line 14, simd/x86_64/jidctred-sse2.asm at line 14, simd/x86_64/jquantf-sse2.asm at line 14, simd/x86_64/jquanti-avx2.asm at line 15, simd/x86_64/jquanti-sse2.asm at line 14, simd/x86_64/jsimd.c at line 14, simd/x86_64/jsimdcpu.asm at line 14
- Note: matched license text is too long. Read it in the source files.
+FILE_INCLUDE simd/nasm/jsimdext.inc found in files: simd/arm/aarch32/jsimd.c at line 13, simd/arm/aarch64/jsimd.c at line 13, simd/i386/jccolext-avx2.asm at line 9, simd/i386/jccolext-mmx.asm at line 9, simd/i386/jccolext-sse2.asm at line 8, simd/i386/jccolor-avx2.asm at line 9, simd/i386/jccolor-mmx.asm at line 9, simd/i386/jccolor-sse2.asm at line 8, simd/i386/jcgray-avx2.asm at line 9, simd/i386/jcgray-mmx.asm at line 9, simd/i386/jcgray-sse2.asm at line 8, simd/i386/jcgryext-avx2.asm at line 9, simd/i386/jcgryext-mmx.asm at line 9, simd/i386/jcgryext-sse2.asm at line 8, simd/i386/jchuff-sse2.asm at line 10, simd/i386/jcphuff-sse2.asm at line 8, simd/i386/jcsample-avx2.asm at line 10, simd/i386/jcsample-mmx.asm at line 9, simd/i386/jcsample-sse2.asm at line 9, simd/i386/jdcolext-avx2.asm at line 10, simd/i386/jdcolext-mmx.asm at line 9, simd/i386/jdcolext-sse2.asm at line 9, simd/i386/jdcolor-avx2.asm at line 10, simd/i386/jdcolor-mmx.asm at line 9, simd/i386/jdcolor-sse2.asm at line 9, simd/i386/jdmerge-avx2.asm at line 10, simd/i386/jdmerge-mmx.asm at line 9, simd/i386/jdmerge-sse2.asm at line 9, simd/i386/jdmrgext-avx2.asm at line 10, simd/i386/jdmrgext-mmx.asm at line 9, simd/i386/jdmrgext-sse2.asm at line 9, simd/i386/jdsample-avx2.asm at line 10, simd/i386/jdsample-mmx.asm at line 9, simd/i386/jdsample-sse2.asm at line 9, simd/i386/jfdctflt-3dn.asm at line 9, simd/i386/jfdctflt-sse.asm at line 9, simd/i386/jfdctfst-mmx.asm at line 9, simd/i386/jfdctfst-sse2.asm at line 9, simd/i386/jfdctint-avx2.asm at line 9, simd/i386/jfdctint-mmx.asm at line 9, simd/i386/jfdctint-sse2.asm at line 9, simd/i386/jidctflt-3dn.asm at line 9, simd/i386/jidctflt-sse.asm at line 9, simd/i386/jidctflt-sse2.asm at line 9, simd/i386/jidctfst-mmx.asm at line 9, simd/i386/jidctfst-sse2.asm at line 9, simd/i386/jidctint-avx2.asm at line 9, simd/i386/jidctint-mmx.asm at line 9, simd/i386/jidctint-sse2.asm at line 9, simd/i386/jidctred-mmx.asm at line 9, simd/i386/jidctred-sse2.asm at line 9, simd/i386/jquant-3dn.asm at line 9, simd/i386/jquant-mmx.asm at line 9, simd/i386/jquant-sse.asm at line 9, simd/i386/jquantf-sse2.asm at line 9, simd/i386/jquanti-avx2.asm at line 10, simd/i386/jquanti-sse2.asm at line 9, simd/i386/jsimd.c at line 10, simd/i386/jsimdcpu.asm at line 9, simd/jsimd.h at line 14, simd/nasm/jcolsamp.inc at line 9, simd/nasm/jdct.inc at line 9, simd/nasm/jsimdext.inc at line 13, simd/x86_64/jccolext-avx2.asm at line 11, simd/x86_64/jccolext-sse2.asm at line 10, simd/x86_64/jccolor-avx2.asm at line 9, simd/x86_64/jccolor-sse2.asm at line 8, simd/x86_64/jcgray-avx2.asm at line 9, simd/x86_64/jcgray-sse2.asm at line 8, simd/x86_64/jcgryext-avx2.asm at line 11, simd/x86_64/jcgryext-sse2.asm at line 10, simd/x86_64/jchuff-sse2.asm at line 11, simd/x86_64/jcphuff-sse2.asm at line 11, simd/x86_64/jcsample-avx2.asm at line 11, simd/x86_64/jcsample-sse2.asm at line 10, simd/x86_64/jdcolext-avx2.asm at line 12, simd/x86_64/jdcolext-sse2.asm at line 11, simd/x86_64/jdcolor-avx2.asm at line 10, simd/x86_64/jdcolor-sse2.asm at line 9, simd/x86_64/jdmerge-avx2.asm at line 10, simd/x86_64/jdmerge-sse2.asm at line 9, simd/x86_64/jdmrgext-avx2.asm at line 12, simd/x86_64/jdmrgext-sse2.asm at line 11, simd/x86_64/jdsample-avx2.asm at line 12, simd/x86_64/jdsample-sse2.asm at line 11, simd/x86_64/jfdctflt-sse.asm at line 10, simd/x86_64/jfdctfst-sse2.asm at line 10, simd/x86_64/jfdctint-avx2.asm at line 9, simd/x86_64/jfdctint-sse2.asm at line 10, simd/x86_64/jidctflt-sse2.asm at line 11, simd/x86_64/jidctfst-sse2.asm at line 11, simd/x86_64/jidctint-avx2.asm at line 10, simd/x86_64/jidctint-sse2.asm at line 11, simd/x86_64/jidctred-sse2.asm at line 11, simd/x86_64/jquantf-sse2.asm at line 10, simd/x86_64/jquanti-avx2.asm at line 11, simd/x86_64/jquanti-sse2.asm at line 10, simd/x86_64/jsimd.c at line 10, simd/x86_64/jsimdcpu.asm at line 11, src/jcdctmgr.c at line 6, src/jsimd.h at line 11, src/jsimddct.h at line 8
+ License text:
+ * Copyright (C) 1999-2006, MIYASAKA Masaru.
+ * For conditions of distribution and use, see copyright notice in jsimdext.inc
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcdctmgr.c [5:11]
- jsimd.h [10:11]
- jsimd_none.c [10:11]
- jsimddct.h [7:8]
simd/arm/aarch32/jsimd.c [12:13]
- simd/arm/aarch64/jsimd.c [11:12]
+ simd/arm/aarch64/jsimd.c [12:13]
simd/i386/jccolext-avx2.asm [8:9]
simd/i386/jccolext-mmx.asm [8:9]
simd/i386/jccolext-sse2.asm [7:8]
@@ -1283,149 +1368,228 @@ FILE_INCLUDE README.ijg found in files: jcdctmgr.c at line 10, jsimd.h at line 1
simd/jsimd.h [13:14]
simd/nasm/jcolsamp.inc [8:9]
simd/nasm/jdct.inc [8:9]
- simd/nasm/jsimdext.inc [11:11]
- simd/x86_64/jccolext-avx2.asm [9:10]
- simd/x86_64/jccolext-sse2.asm [8:9]
+ simd/nasm/jsimdext.inc [12:12]
+ simd/x86_64/jccolext-avx2.asm [10:11]
+ simd/x86_64/jccolext-sse2.asm [9:10]
simd/x86_64/jccolor-avx2.asm [8:9]
simd/x86_64/jccolor-sse2.asm [7:8]
simd/x86_64/jcgray-avx2.asm [8:9]
simd/x86_64/jcgray-sse2.asm [7:8]
- simd/x86_64/jcgryext-avx2.asm [9:10]
- simd/x86_64/jcgryext-sse2.asm [8:9]
- simd/x86_64/jchuff-sse2.asm [9:10]
- simd/x86_64/jcphuff-sse2.asm [8:9]
+ simd/x86_64/jcgryext-avx2.asm [10:11]
+ simd/x86_64/jcgryext-sse2.asm [9:10]
+ simd/x86_64/jchuff-sse2.asm [10:11]
+ simd/x86_64/jcphuff-sse2.asm [10:11]
simd/x86_64/jcsample-avx2.asm [10:11]
simd/x86_64/jcsample-sse2.asm [9:10]
- simd/x86_64/jdcolext-avx2.asm [10:11]
- simd/x86_64/jdcolext-sse2.asm [9:10]
+ simd/x86_64/jdcolext-avx2.asm [11:12]
+ simd/x86_64/jdcolext-sse2.asm [10:11]
simd/x86_64/jdcolor-avx2.asm [9:10]
simd/x86_64/jdcolor-sse2.asm [8:9]
simd/x86_64/jdmerge-avx2.asm [9:10]
simd/x86_64/jdmerge-sse2.asm [8:9]
- simd/x86_64/jdmrgext-avx2.asm [10:11]
- simd/x86_64/jdmrgext-sse2.asm [9:10]
- simd/x86_64/jdsample-avx2.asm [10:11]
- simd/x86_64/jdsample-sse2.asm [9:10]
- simd/x86_64/jfdctflt-sse.asm [8:9]
- simd/x86_64/jfdctfst-sse2.asm [8:9]
+ simd/x86_64/jdmrgext-avx2.asm [11:12]
+ simd/x86_64/jdmrgext-sse2.asm [10:11]
+ simd/x86_64/jdsample-avx2.asm [11:12]
+ simd/x86_64/jdsample-sse2.asm [10:11]
+ simd/x86_64/jfdctflt-sse.asm [9:10]
+ simd/x86_64/jfdctfst-sse2.asm [9:10]
simd/x86_64/jfdctint-avx2.asm [8:9]
- simd/x86_64/jfdctint-sse2.asm [8:9]
- simd/x86_64/jidctflt-sse2.asm [9:10]
- simd/x86_64/jidctfst-sse2.asm [9:10]
+ simd/x86_64/jfdctint-sse2.asm [9:10]
+ simd/x86_64/jidctflt-sse2.asm [10:11]
+ simd/x86_64/jidctfst-sse2.asm [10:11]
simd/x86_64/jidctint-avx2.asm [9:10]
- simd/x86_64/jidctint-sse2.asm [9:10]
- simd/x86_64/jidctred-sse2.asm [9:10]
+ simd/x86_64/jidctint-sse2.asm [10:11]
+ simd/x86_64/jidctred-sse2.asm [10:11]
simd/x86_64/jquantf-sse2.asm [9:10]
simd/x86_64/jquanti-avx2.asm [10:11]
simd/x86_64/jquanti-sse2.asm [9:10]
simd/x86_64/jsimd.c [9:10]
- simd/x86_64/jsimdcpu.asm [9:10]
+ simd/x86_64/jsimdcpu.asm [10:11]
+ src/jcdctmgr.c [5:11]
+ src/jsimd.h [10:11]
+ src/jsimddct.h [7:8]
-KEEP COPYRIGHT_SERVICE_LABEL 841a525ae27626ed264dbe00d00a50d9
+KEEP COPYRIGHT_SERVICE_LABEL 81e5335855f8c69149fe38a96521a6d1
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrgif.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdmarker.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- wrgif.c [5:10]
+ src/jdmarker.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL 8a887c76bccbc11714f8d4f377b95b34
+KEEP COPYRIGHT_SERVICE_LABEL 8e155a3d6838b2df24b16bf96ec3e6d6
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cmyk.h at line 5, jmemnobs.c at line 6
License text:
- * Copyright (C) 2017-2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
+ * Copyright (C) 2014, 2021, 2024, D. R. Commander.
+ * Copyright (C) 2014, Olle Liljenzin.
+ * Copyright (C) 2020, Arm Limited.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cmyk.h [4:6]
- jmemnobs.c [5:9]
+ src/jpeg_nbits.h [2:4]
-KEEP COPYRIGHT_SERVICE_LABEL 8ec1376dfe31abfe479581e655244a78
+KEEP COPYRIGHT_SERVICE_LABEL 905ed171caae692bb173500a65f42d54
BELONGS ya.make
License text:
- ; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
- ; Copyright (C) 2015, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
+ ; Copyright (C) 2015, Intel Corporation.
+ ; Copyright (C) 2016, 2024, D. R. Commander.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/x86_64/jchuff-sse2.asm [4:6]
+ simd/i386/jccolext-avx2.asm [4:5]
+ simd/i386/jccolext-mmx.asm [4:5]
+ simd/i386/jccolext-sse2.asm [4:4]
+ simd/i386/jcsample-avx2.asm [4:6]
+ simd/i386/jcsample-mmx.asm [4:5]
+ simd/i386/jcsample-sse2.asm [4:5]
+ simd/i386/jdcolext-mmx.asm [4:5]
+ simd/i386/jdcolor-avx2.asm [4:6]
+ simd/i386/jdmrgext-mmx.asm [4:5]
+ simd/i386/jdsample-avx2.asm [4:6]
+ simd/i386/jdsample-mmx.asm [4:5]
+ simd/i386/jdsample-sse2.asm [4:5]
+ simd/i386/jfdctflt-3dn.asm [4:5]
+ simd/i386/jfdctflt-sse.asm [4:5]
+ simd/i386/jfdctfst-mmx.asm [4:5]
+ simd/i386/jfdctfst-sse2.asm [4:5]
+ simd/i386/jidctflt-3dn.asm [4:5]
+ simd/i386/jidctflt-sse.asm [4:5]
+ simd/i386/jidctflt-sse2.asm [4:5]
+ simd/i386/jidctfst-mmx.asm [4:5]
+ simd/i386/jidctfst-sse2.asm [4:5]
+ simd/i386/jidctred-mmx.asm [4:5]
+ simd/i386/jidctred-sse2.asm [4:5]
+ simd/i386/jquant-3dn.asm [4:5]
+ simd/i386/jquant-mmx.asm [4:5]
+ simd/i386/jquant-sse.asm [4:5]
+ simd/i386/jquantf-sse2.asm [4:5]
+ simd/i386/jquanti-sse2.asm [4:5]
-KEEP COPYRIGHT_SERVICE_LABEL 8ec859db1c818c3ffcdea4ac4c67cc71
+KEEP COPYRIGHT_SERVICE_LABEL 926e8d779dd919cc9d70763a7492881d
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcolext.c at line 8
+FILE_INCLUDE README.ijg found in files: src/rdbmp.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdcolext.c [5:9]
+ src/rdbmp.c [5:11]
KEEP COPYRIGHT_SERVICE_LABEL 9355530111ca8edfbad01e55c12ca46b
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cdjpeg.c at line 8
+FILE_INCLUDE README.ijg found in files: src/cdjpeg.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cdjpeg.c [5:9]
+ src/cdjpeg.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL 9493f64c85084bcb6137535faf2ccf64
+KEEP COPYRIGHT_SERVICE_LABEL 94347e409261be220abcbb43e2ca4b23
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jmorecfg.h at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ src/jmorecfg.h [5:12]
-KEEP COPYRIGHT_SERVICE_LABEL 950b3ffbdef23456bf92191ac52dde37
+KEEP COPYRIGHT_SERVICE_LABEL 9493f64c85084bcb6137535faf2ccf64
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcsample.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcsample.c [5:11]
+ jversion.h [39:53]
-KEEP COPYRIGHT_SERVICE_LABEL 9c0396a7c7f9feca6c67ec7d838f5e6a
+KEEP COPYRIGHT_SERVICE_LABEL 95e43e8a385db50e61c756ba5ad564b9
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jaricom.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jcsample.c at line 12
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jaricom.c [5:9]
+ src/jcsample.c [5:13]
-KEEP COPYRIGHT_SERVICE_LABEL 9c62a8ffaa91ca3d9db9dd6ce8d27046
+KEEP COPYRIGHT_SERVICE_LABEL 961509f53f19e4c6ae36c651f4a9bbbb
BELONGS ya.make
License text:
- ; Copyright (C) 2009-2011, 2014-2017, 2019, D. R. Commander.
- ; Copyright (C) 2015, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
+ ; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
+ ; Copyright (C) 2012, 2016, 2024, D. R. Commander.
+ ; Copyright (C) 2015, Intel Corporation.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jchuff-sse2.asm [4:6]
+ simd/i386/jdcolext-avx2.asm [4:6]
+ simd/i386/jdcolext-sse2.asm [4:5]
+ simd/i386/jdmrgext-avx2.asm [4:6]
+ simd/i386/jdmrgext-sse2.asm [4:5]
+
+KEEP COPYRIGHT_SERVICE_LABEL 9717f84a69f0db1617cf483debfdf8d7
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jccolext.c at line 8
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jccolext.c [5:9]
+
+KEEP COPYRIGHT_SERVICE_LABEL 97aa3c52267af7d25b28d8d2dfd978af
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jchuff.c at line 14, src/jcinit.c at line 14, src/jclhuff.c at line 14, src/jdhuff.c at line 14, src/jdhuff.h at line 14, src/jdinput.c at line 14, src/jdlhuff.c at line 14
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jchuff.c [5:15]
+ src/jcinit.c [5:11]
+ src/jclhuff.c [5:11]
+ src/jdhuff.c [5:12]
+ src/jdhuff.h [5:12]
+ src/jdinput.c [5:12]
+ src/jdlhuff.c [5:11]
+
+KEEP COPYRIGHT_SERVICE_LABEL 98e1c25dfeb42557923d39cab5488739
+BELONGS ya.make
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/nasm/jsimdext.inc [4:8]
+
+KEEP COPYRIGHT_SERVICE_LABEL 9c0396a7c7f9feca6c67ec7d838f5e6a
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jaricom.c at line 8
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jaricom.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL 9cdcdd341cb0968b2686cc191166f66d
BELONGS ya.make
@@ -1436,30 +1600,144 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- turbojpeg.c [3:3]
+ src/turbojpeg.c [3:3]
+
+KEEP COPYRIGHT_SERVICE_LABEL 9d1bec2ea4cbc32e242553906e581b36
+BELONGS ya.make
+ License text:
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/arm/aarch32/jchuff-neon.c [5:5]
+ simd/arm/jcgray-neon.c [5:5]
+ simd/arm/jcsample-neon.c [5:5]
+ simd/arm/jdcolor-neon.c [5:5]
+ simd/arm/jdmerge-neon.c [5:5]
+ simd/arm/jfdctfst-neon.c [5:5]
+ simd/arm/jidctfst-neon.c [5:5]
+ simd/arm/jquanti-neon.c [5:5]
+ simd/x86_64/jcphuff-sse2.asm [5:7]
+ src/jcomapi.c [5:9]
+ src/jpeg_nbits.c [2:2]
KEEP COPYRIGHT_SERVICE_LABEL 9e8576d91d041270c2093c39ed8552e2
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jctrans.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jctrans.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jctrans.c [5:10]
+ src/jctrans.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL a20f5da1eab75f941a731e130170bf39
+KEEP COPYRIGHT_SERVICE_LABEL a164bdd38e3472de18f8607d7c8f3767
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolext.c at line 8, jccolor.c at line 8
- Note: matched license text is too long. Read it in the source files.
+FILE_INCLUDE README.ijg found in files: src/wrapper/jcapistd-12.c at line 5, src/wrapper/jcapistd-16.c at line 5, src/wrapper/jcapistd-8.c at line 5, src/wrapper/jccoefct-12.c at line 5, src/wrapper/jccoefct-8.c at line 5, src/wrapper/jccolor-12.c at line 5, src/wrapper/jccolor-16.c at line 5, src/wrapper/jccolor-8.c at line 5, src/wrapper/jcdctmgr-12.c at line 5, src/wrapper/jcdctmgr-8.c at line 5, src/wrapper/jcdiffct-12.c at line 5, src/wrapper/jcdiffct-16.c at line 5, src/wrapper/jcdiffct-8.c at line 5, src/wrapper/jclossls-12.c at line 5, src/wrapper/jclossls-16.c at line 5, src/wrapper/jclossls-8.c at line 5, src/wrapper/jcmainct-12.c at line 5, src/wrapper/jcmainct-16.c at line 5, src/wrapper/jcmainct-8.c at line 5, src/wrapper/jcprepct-12.c at line 5, src/wrapper/jcprepct-16.c at line 5, src/wrapper/jcprepct-8.c at line 5, src/wrapper/jcsample-12.c at line 5, src/wrapper/jcsample-16.c at line 5, src/wrapper/jcsample-8.c at line 5, src/wrapper/jdapistd-12.c at line 5, src/wrapper/jdapistd-16.c at line 5, src/wrapper/jdapistd-8.c at line 5, src/wrapper/jdcoefct-12.c at line 5, src/wrapper/jdcoefct-8.c at line 5, src/wrapper/jdcolor-12.c at line 5, src/wrapper/jdcolor-16.c at line 5, src/wrapper/jdcolor-8.c at line 5, src/wrapper/jddctmgr-12.c at line 5, src/wrapper/jddctmgr-8.c at line 5, src/wrapper/jddiffct-12.c at line 5, src/wrapper/jddiffct-16.c at line 5, src/wrapper/jddiffct-8.c at line 5, src/wrapper/jdlossls-12.c at line 5, src/wrapper/jdlossls-16.c at line 5, src/wrapper/jdlossls-8.c at line 5, src/wrapper/jdmainct-12.c at line 5, src/wrapper/jdmainct-16.c at line 5, src/wrapper/jdmainct-8.c at line 5, src/wrapper/jdmerge-12.c at line 5, src/wrapper/jdmerge-8.c at line 5, src/wrapper/jdpostct-12.c at line 5, src/wrapper/jdpostct-16.c at line 5, src/wrapper/jdpostct-8.c at line 5, src/wrapper/jdsample-12.c at line 5, src/wrapper/jdsample-16.c at line 5, src/wrapper/jdsample-8.c at line 5, src/wrapper/jfdctfst-12.c at line 5, src/wrapper/jfdctfst-8.c at line 5, src/wrapper/jfdctint-12.c at line 5, src/wrapper/jfdctint-8.c at line 5, src/wrapper/jidctflt-12.c at line 5, src/wrapper/jidctflt-8.c at line 5, src/wrapper/jidctfst-12.c at line 5, src/wrapper/jidctfst-8.c at line 5, src/wrapper/jidctint-12.c at line 5, src/wrapper/jidctint-8.c at line 5, src/wrapper/jidctred-12.c at line 5, src/wrapper/jidctred-8.c at line 5, src/wrapper/jquant1-12.c at line 5, src/wrapper/jquant1-8.c at line 5, src/wrapper/jquant2-12.c at line 5, src/wrapper/jquant2-8.c at line 5, src/wrapper/jutils-12.c at line 5, src/wrapper/jutils-16.c at line 5, src/wrapper/jutils-8.c at line 5, src/wrapper/rdcolmap-12.c at line 5, src/wrapper/rdcolmap-8.c at line 5, src/wrapper/rdppm-12.c at line 5, src/wrapper/rdppm-16.c at line 5, src/wrapper/rdppm-8.c at line 5, src/wrapper/wrgif-12.c at line 5, src/wrapper/wrgif-8.c at line 5, src/wrapper/wrppm-12.c at line 5, src/wrapper/wrppm-16.c at line 5, src/wrapper/wrppm-8.c at line 5
+ License text:
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jccolext.c [5:9]
- jccolor.c [5:11]
+ src/wrapper/jcapistd-12.c [4:6]
+ src/wrapper/jcapistd-16.c [4:6]
+ src/wrapper/jcapistd-8.c [4:6]
+ src/wrapper/jccoefct-12.c [4:6]
+ src/wrapper/jccoefct-8.c [4:6]
+ src/wrapper/jccolor-12.c [4:6]
+ src/wrapper/jccolor-16.c [4:6]
+ src/wrapper/jccolor-8.c [4:6]
+ src/wrapper/jcdctmgr-12.c [4:6]
+ src/wrapper/jcdctmgr-8.c [4:6]
+ src/wrapper/jcdiffct-12.c [4:6]
+ src/wrapper/jcdiffct-16.c [4:6]
+ src/wrapper/jcdiffct-8.c [4:6]
+ src/wrapper/jclossls-12.c [4:6]
+ src/wrapper/jclossls-16.c [4:6]
+ src/wrapper/jclossls-8.c [4:6]
+ src/wrapper/jcmainct-12.c [4:6]
+ src/wrapper/jcmainct-16.c [4:6]
+ src/wrapper/jcmainct-8.c [4:6]
+ src/wrapper/jcprepct-12.c [4:6]
+ src/wrapper/jcprepct-16.c [4:6]
+ src/wrapper/jcprepct-8.c [4:6]
+ src/wrapper/jcsample-12.c [4:6]
+ src/wrapper/jcsample-16.c [4:6]
+ src/wrapper/jcsample-8.c [4:6]
+ src/wrapper/jdapistd-12.c [4:6]
+ src/wrapper/jdapistd-16.c [4:6]
+ src/wrapper/jdapistd-8.c [4:6]
+ src/wrapper/jdcoefct-12.c [4:6]
+ src/wrapper/jdcoefct-8.c [4:6]
+ src/wrapper/jdcolor-12.c [4:6]
+ src/wrapper/jdcolor-16.c [4:6]
+ src/wrapper/jdcolor-8.c [4:6]
+ src/wrapper/jddctmgr-12.c [4:6]
+ src/wrapper/jddctmgr-8.c [4:6]
+ src/wrapper/jddiffct-12.c [4:6]
+ src/wrapper/jddiffct-16.c [4:6]
+ src/wrapper/jddiffct-8.c [4:6]
+ src/wrapper/jdlossls-12.c [4:6]
+ src/wrapper/jdlossls-16.c [4:6]
+ src/wrapper/jdlossls-8.c [4:6]
+ src/wrapper/jdmainct-12.c [4:6]
+ src/wrapper/jdmainct-16.c [4:6]
+ src/wrapper/jdmainct-8.c [4:6]
+ src/wrapper/jdmerge-12.c [4:6]
+ src/wrapper/jdmerge-8.c [4:6]
+ src/wrapper/jdpostct-12.c [4:6]
+ src/wrapper/jdpostct-16.c [4:6]
+ src/wrapper/jdpostct-8.c [4:6]
+ src/wrapper/jdsample-12.c [4:6]
+ src/wrapper/jdsample-16.c [4:6]
+ src/wrapper/jdsample-8.c [4:6]
+ src/wrapper/jfdctfst-12.c [4:6]
+ src/wrapper/jfdctfst-8.c [4:6]
+ src/wrapper/jfdctint-12.c [4:6]
+ src/wrapper/jfdctint-8.c [4:6]
+ src/wrapper/jidctflt-12.c [4:6]
+ src/wrapper/jidctflt-8.c [4:6]
+ src/wrapper/jidctfst-12.c [4:6]
+ src/wrapper/jidctfst-8.c [4:6]
+ src/wrapper/jidctint-12.c [4:6]
+ src/wrapper/jidctint-8.c [4:6]
+ src/wrapper/jidctred-12.c [4:6]
+ src/wrapper/jidctred-8.c [4:6]
+ src/wrapper/jquant1-12.c [4:6]
+ src/wrapper/jquant1-8.c [4:6]
+ src/wrapper/jquant2-12.c [4:6]
+ src/wrapper/jquant2-8.c [4:6]
+ src/wrapper/jutils-12.c [4:6]
+ src/wrapper/jutils-16.c [4:6]
+ src/wrapper/jutils-8.c [4:6]
+ src/wrapper/rdcolmap-12.c [4:6]
+ src/wrapper/rdcolmap-8.c [4:6]
+ src/wrapper/rdppm-12.c [4:6]
+ src/wrapper/rdppm-16.c [4:6]
+ src/wrapper/rdppm-8.c [4:6]
+ src/wrapper/wrgif-12.c [4:6]
+ src/wrapper/wrgif-8.c [4:6]
+ src/wrapper/wrppm-12.c [4:6]
+ src/wrapper/wrppm-16.c [4:6]
+ src/wrapper/wrppm-8.c [4:6]
+
+KEEP COPYRIGHT_SERVICE_LABEL a2a92102614e26aac0f3cb9d3808f6ff
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jdmerge.c at line 10
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jdmerge.c [5:11]
KEEP COPYRIGHT_SERVICE_LABEL a445cd203767825e67800b0e187c4dcc
BELONGS ya.make
@@ -1483,18 +1761,39 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- README.ijg [131:132]
+ README.ijg [133:134]
+
+KEEP COPYRIGHT_SERVICE_LABEL a4f717ab8f5b550d617d70eefba07c8a
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jinclude.h at line 8
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jinclude.h [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL a700f333696ed15104933df52cf87650
+KEEP COPYRIGHT_SERVICE_LABEL a6783bc330a3f385399f7aab5b8e2ab1
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrbmp.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdatasrc-tj.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- wrbmp.c [5:10]
+ src/jdatasrc-tj.c [5:10]
+
+KEEP COPYRIGHT_SERVICE_LABEL a94c0b4b578115e7cd9fef04fcb5037d
+BELONGS ya.make
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/arm/aarch64/jsimd.c [4:9]
KEEP COPYRIGHT_SERVICE_LABEL aa77cee5a8d8195aa2fa1f0fa5c1ebf2
BELONGS ya.make
@@ -1504,11 +1803,11 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ jversion.h [39:53]
KEEP COPYRIGHT_SERVICE_LABEL aaa3eec797321b0f95bb1e9795f5f34e
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpegcomp.h at line 5
+FILE_INCLUDE README.ijg found in files: src/jpegapicomp.h at line 5
License text:
* Copyright (C) 2010, 2020, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -1518,139 +1817,177 @@ FILE_INCLUDE README.ijg found in files: jpegcomp.h at line 5
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jpegcomp.h [4:6]
+ src/jpegapicomp.h [4:6]
-KEEP COPYRIGHT_SERVICE_LABEL aacf1ca190af1314c3f58142073cff60
+KEEP COPYRIGHT_SERVICE_LABEL abf878d43b9b17d0a011b9f80bc0877b
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdmerge.c at line 10
+FILE_INCLUDE README.ijg found in files: src/jctrans.c at line 9, src/jdmerge.h at line 9, src/jdtrans.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdmerge.c [5:11]
+ src/jctrans.c [5:10]
+ src/jdmerge.h [5:9]
+ src/jdtrans.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL abf878d43b9b17d0a011b9f80bc0877b
+KEEP COPYRIGHT_SERVICE_LABEL ac3e7a3bb6a2deb63101c7131904439b
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jctrans.c at line 9, simd/arm/aarch64/jchuff-neon.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jddctmgr.c at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jctrans.c [5:10]
- simd/arm/aarch64/jchuff-neon.c [5:5]
+ src/jddctmgr.c [5:12]
-KEEP COPYRIGHT_SERVICE_LABEL ac3e7a3bb6a2deb63101c7131904439b
+KEEP COPYRIGHT_SERVICE_LABEL ada0032ea1af459292f235d45dd781ab
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jddctmgr.c at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jddctmgr.c [5:12]
+ jversion.h [39:53]
-KEEP COPYRIGHT_SERVICE_LABEL ada0032ea1af459292f235d45dd781ab
+KEEP COPYRIGHT_SERVICE_LABEL ae01080baf31245770997f76bc0c526b
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jclossls.c at line 10, src/jdlossls.c at line 10, src/jlossls.h at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ src/jclossls.c [5:11]
+ src/jdlossls.c [5:11]
+ src/jlossls.h [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL b03629274bce5be6f0f958bd8b73c07d
+KEEP COPYRIGHT_SERVICE_LABEL ae8202093f8c1f5cdf79105ccf015454
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcoefct.c at line 10
+FILE_INCLUDE README.ijg found in files: src/cjpeg.c at line 12
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdcoefct.c [5:11]
+ src/cjpeg.c [5:12]
-KEEP COPYRIGHT_SERVICE_LABEL b0db1bfcd800910a02844b4274371034
+KEEP COPYRIGHT_SERVICE_LABEL b3e70f7a6097bfd26df9355302310ed6
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmemmgr.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jmemmgr.c [5:9]
+ jversion.h [39:53]
-KEEP COPYRIGHT_SERVICE_LABEL b3b7c4fd496ec8e05dd719ced067a03d
+KEEP COPYRIGHT_SERVICE_LABEL b441984d0e96238fe18b18f11ab30548
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cjpeg.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cjpeg.c [5:10]
+ simd/arm/aarch32/jsimd.c [4:9]
+ simd/arm/aarch64/jsimd.c [4:9]
-KEEP COPYRIGHT_SERVICE_LABEL b3e70f7a6097bfd26df9355302310ed6
+KEEP COPYRIGHT_SERVICE_LABEL b4629da5b909ea766e7b89c13fbf25c3
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/wrtarga.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ src/wrtarga.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL b410f4fd6c5f864842fda8c62b52df9d
+KEEP COPYRIGHT_SERVICE_LABEL b46db839fb63c2710a25a86daad4bb99
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdsample.c at line 12
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdsample.c [5:13]
+ jversion.h [39:53]
-KEEP COPYRIGHT_SERVICE_LABEL b441984d0e96238fe18b18f11ab30548
+KEEP COPYRIGHT_SERVICE_LABEL b61841aa27d46c243bda65ad0340be8e
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jcparam.c at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/arm/aarch32/jsimd.c [4:9]
- simd/arm/aarch64/jsimd.c [4:8]
+ src/jcparam.c [5:12]
-KEEP COPYRIGHT_SERVICE_LABEL b4629da5b909ea766e7b89c13fbf25c3
+KEEP COPYRIGHT_SERVICE_LABEL b652794250b3d3004b695e681b62d031
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: wrtarga.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jmemnobs.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- wrtarga.c [5:9]
+ src/jmemnobs.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL b46db839fb63c2710a25a86daad4bb99
+KEEP COPYRIGHT_SERVICE_LABEL b6cca1a621188537cfd4d332efd0e075
BELONGS ya.make
+ License text:
+ ; Copyright (C) 2011, 2016, 2024, D. R. Commander.
+ ; Copyright (C) 2015, Intel Corporation.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/i386/jcgray-avx2.asm [4:5]
+ simd/i386/jcgray-mmx.asm [4:5]
+ simd/i386/jcgray-sse2.asm [4:4]
+ simd/i386/jcgryext-avx2.asm [4:5]
+ simd/i386/jcgryext-mmx.asm [4:5]
+ simd/i386/jcgryext-sse2.asm [4:4]
+ simd/x86_64/jcgray-avx2.asm [4:5]
+ simd/x86_64/jcgray-sse2.asm [4:4]
+ simd/x86_64/jcgryext-avx2.asm [4:7]
+ simd/x86_64/jcgryext-sse2.asm [4:6]
+
+KEEP COPYRIGHT_SERVICE_LABEL b753de319053b6f31eda0d48fd910c57
+BELONGS ya.make
+ License text:
+ * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022-2024, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/x86_64/jsimd.c [4:6]
+
+KEEP COPYRIGHT_SERVICE_LABEL b75684e7e7c0a25cf7b90b9b1bbdd119
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jcmainct.c at line 10, src/jcprepct.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ src/jcmainct.c [5:11]
+ src/jcprepct.c [5:11]
-KEEP COPYRIGHT_SERVICE_LABEL b6850ac833f644f5afb115dc21780dba
+KEEP COPYRIGHT_SERVICE_LABEL bb722d14e930daed4bb6e12657010f74
BELONGS ya.make
Note: matched license text is too long. Read it in the source files.
Scancode info:
@@ -1658,19 +1995,18 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/arm/aarch32/jsimd.c [4:9]
- simd/i386/jsimd.c [4:6]
+ simd/x86_64/jchuff-sse2.asm [4:7]
-KEEP COPYRIGHT_SERVICE_LABEL badd6e1fefe09e0efd808152660be992
+KEEP COPYRIGHT_SERVICE_LABEL bc94d516327ec00e9f91f13bfc2bbd3b
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jstdhuff.c at line 8
+FILE_INCLUDE README.ijg found in files: src/wrbmp.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jstdhuff.c [5:9]
+ src/wrbmp.c [5:10]
KEEP COPYRIGHT_SERVICE_LABEL bd72d4f6ff636a488895c66e5498d9e4
BELONGS ya.make
@@ -1683,47 +2019,70 @@ BELONGS ya.make
simd/arm/aarch32/jsimd_neon.S [8:8]
simd/jsimd.h [4:10]
-KEEP COPYRIGHT_SERVICE_LABEL c045da8003fea9b4c2d930832f2d1afc
+KEEP COPYRIGHT_SERVICE_LABEL be881d78ed6a6339dac60bc812dbef48
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jchuff.c at line 14
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jchuff.c [5:15]
+
+KEEP COPYRIGHT_SERVICE_LABEL c036f9ccfbc81a9973c4fcff916dbc98
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jfdctint.c at line 8, src/jidctint.c at line 8
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jfdctint.c [5:9]
+ src/jidctint.c [5:10]
+
+KEEP COPYRIGHT_SERVICE_LABEL c0ce31cb3a33b64d75aec1dccbeafc9f
BELONGS ya.make
License text:
- ; Copyright (C) 2009, 2016, D. R. Commander.
- ; Copyright (C) 2015, Intel Corporation.
+ ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ ; Copyright (C) 2009, 2016, 2020, 2024, D. R. Commander.
+ ; Copyright (C) 2023, Aliaksiej Kandracienka.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jccolor-avx2.asm [4:5]
- simd/i386/jccolor-mmx.asm [4:5]
- simd/i386/jccolor-sse2.asm [4:4]
- simd/i386/jdcolor-mmx.asm [4:5]
- simd/i386/jdcolor-sse2.asm [4:5]
- simd/i386/jdmerge-avx2.asm [4:6]
- simd/i386/jdmerge-mmx.asm [4:5]
- simd/i386/jdmerge-sse2.asm [4:5]
- simd/x86_64/jccolext-avx2.asm [4:6]
- simd/x86_64/jccolext-sse2.asm [4:5]
- simd/x86_64/jccolor-avx2.asm [4:5]
- simd/x86_64/jccolor-sse2.asm [4:4]
- simd/x86_64/jcsample-avx2.asm [4:7]
- simd/x86_64/jcsample-sse2.asm [4:6]
- simd/x86_64/jdcolor-avx2.asm [4:6]
- simd/x86_64/jdcolor-sse2.asm [4:5]
- simd/x86_64/jdmerge-avx2.asm [4:6]
- simd/x86_64/jdmerge-sse2.asm [4:5]
- simd/x86_64/jdsample-avx2.asm [4:7]
- simd/x86_64/jdsample-sse2.asm [4:6]
- simd/x86_64/jfdctflt-sse.asm [4:5]
- simd/x86_64/jfdctfst-sse2.asm [4:5]
- simd/x86_64/jidctflt-sse2.asm [4:6]
- simd/x86_64/jidctfst-sse2.asm [4:6]
- simd/x86_64/jidctred-sse2.asm [4:6]
- simd/x86_64/jquantf-sse2.asm [4:6]
- simd/x86_64/jquanti-sse2.asm [4:6]
+ simd/x86_64/jfdctint-sse2.asm [4:6]
+ simd/x86_64/jidctint-sse2.asm [4:7]
+
+KEEP COPYRIGHT_SERVICE_LABEL c690d1ab8657fc5120b6cf2eb69e4cd9
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jdct.h at line 8, src/jidctfst.c at line 8, src/jidctred.c at line 8
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jdct.h [5:9]
+ src/jidctfst.c [5:9]
+ src/jidctred.c [5:9]
+
+KEEP COPYRIGHT_SERVICE_LABEL c6d39cf638ecb2446f865e5235e14355
+BELONGS ya.make
+ License text:
+ Copyright (c) 1991-2024 The libjpeg-turbo Project
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ jversion.h [55:56]
KEEP COPYRIGHT_SERVICE_LABEL c9e55c94ede47423b60bd1b0381f63a3
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcicc.c at line 6, jdicc.c at line 6
+FILE_INCLUDE README.ijg found in files: src/jcicc.c at line 6, src/jdicc.c at line 6
License text:
* Copyright (C) 1997-1998, Thomas G. Lane, Todd Newman.
* Copyright (C) 2017, D. R. Commander.
@@ -1734,30 +2093,30 @@ FILE_INCLUDE README.ijg found in files: jcicc.c at line 6, jdicc.c at line 6
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcicc.c [4:7]
- jdicc.c [4:7]
+ src/jcicc.c [4:7]
+ src/jdicc.c [4:7]
-KEEP COPYRIGHT_SERVICE_LABEL caa45dec4c6ae6a1395050b3920a6223
+KEEP COPYRIGHT_SERVICE_LABEL cca2e965350198f9e77d99a7186169c6
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jmorecfg.h at line 9
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ * Copyright (C)2011, 2022 D. R. Commander. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jmorecfg.h [5:10]
+ src/tjutil.h [2:2]
-KEEP COPYRIGHT_SERVICE_LABEL cca2e965350198f9e77d99a7186169c6
+KEEP COPYRIGHT_SERVICE_LABEL ccdbc65b86408d4ef5a8a29f79e87a8c
BELONGS ya.make
- License text:
- * Copyright (C)2011, 2022 D. R. Commander. All Rights Reserved.
+FILE_INCLUDE README.ijg found in files: src/rdppm.c at line 9
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- tjutil.h [2:2]
+ src/rdppm.c [5:10]
KEEP COPYRIGHT_SERVICE_LABEL cd2a60027b7103634f7daee878afa300
BELONGS ya.make
@@ -1767,7 +2126,7 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ jversion.h [39:53]
KEEP COPYRIGHT_SERVICE_LABEL cd5311d9588f1f80a8f857322ae710df
BELONGS ya.make
@@ -1777,34 +2136,43 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ jversion.h [39:53]
+
+KEEP COPYRIGHT_SERVICE_LABEL cd58c76151af49827a83aae129e5301a
+BELONGS ya.make
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/jsimd.h [4:10]
KEEP COPYRIGHT_SERVICE_LABEL cf6108444471809417e1ff2e1ff10c66
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapimin.c at line 9, jdapimin.c at line 9, jidctflt.c at line 9, jidctfst.c at line 9, jidctred.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jcapimin.c at line 9, src/jidctflt.c at line 9, src/jidctfst.c at line 9, src/jidctred.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcapimin.c [5:10]
- jdapimin.c [5:9]
- jidctflt.c [5:10]
- jidctfst.c [5:9]
- jidctred.c [5:9]
+ src/jcapimin.c [5:10]
+ src/jidctflt.c [5:10]
+ src/jidctfst.c [5:9]
+ src/jidctred.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL cf74f8592696addc8b7f018fef34b4a3
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdatadst.c at line 9, jdatasrc.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdatadst.c at line 9, src/jdatasrc.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdatadst.c [5:10]
- jdatasrc.c [5:10]
+ src/jdatadst.c [5:10]
+ src/jdatasrc.c [5:10]
KEEP COPYRIGHT_SERVICE_LABEL d0282fea7b77a6dc36ff090a1ac5d3f4
BELONGS ya.make
@@ -1815,74 +2183,122 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- rdcolmap.c [31:31]
- rdppm.c [33:33]
+ src/rdcolmap.c [35:35]
+ src/rdppm.c [34:34]
+
+KEEP COPYRIGHT_SERVICE_LABEL d079d655f90d4e64fa49a87a12e294aa
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jcmarker.c at line 11
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jcmarker.c [5:12]
KEEP COPYRIGHT_SERVICE_LABEL d0fc83990d55b2f4c8030d020a836049
BELONGS ya.make
License text:
- ; Copyright (C) 2015, Intel Corporation.
+ ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
; Copyright (C) 2016, D. R. Commander.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jccolext-avx2.asm [4:5]
- simd/i386/jccolext-mmx.asm [4:5]
- simd/i386/jccolext-sse2.asm [4:4]
- simd/i386/jcsample-avx2.asm [4:6]
- simd/i386/jcsample-mmx.asm [4:5]
- simd/i386/jcsample-sse2.asm [4:5]
- simd/i386/jdcolext-mmx.asm [4:5]
- simd/i386/jdcolor-avx2.asm [4:6]
- simd/i386/jdmrgext-mmx.asm [4:5]
- simd/i386/jdsample-avx2.asm [4:6]
- simd/i386/jdsample-mmx.asm [4:5]
- simd/i386/jdsample-sse2.asm [4:5]
- simd/i386/jfdctflt-3dn.asm [4:5]
- simd/i386/jfdctflt-sse.asm [4:5]
- simd/i386/jfdctfst-mmx.asm [4:5]
- simd/i386/jfdctfst-sse2.asm [4:5]
- simd/i386/jidctflt-3dn.asm [4:5]
- simd/i386/jidctflt-sse.asm [4:5]
- simd/i386/jidctflt-sse2.asm [4:5]
- simd/i386/jidctfst-mmx.asm [4:5]
- simd/i386/jidctfst-sse2.asm [4:5]
- simd/i386/jidctred-mmx.asm [4:5]
- simd/i386/jidctred-sse2.asm [4:5]
- simd/i386/jquant-3dn.asm [4:5]
- simd/i386/jquant-mmx.asm [4:5]
- simd/i386/jquant-sse.asm [4:5]
- simd/i386/jquantf-sse2.asm [4:5]
- simd/i386/jquanti-sse2.asm [4:5]
simd/i386/jsimdcpu.asm [4:5]
- simd/x86_64/jsimdcpu.asm [4:5]
+ simd/x86_64/jsimdcpu.asm [4:6]
+ src/jcmaster.h [5:9]
+
+KEEP COPYRIGHT_SERVICE_LABEL d2e7983809ff321e3ff300a2164be196
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/djpeg.c at line 10
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/djpeg.c [5:11]
+
+KEEP COPYRIGHT_SERVICE_LABEL d40f7ac101f31f6496e8d66ded901035
+BELONGS ya.make
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/nasm/jsimdext.inc [4:8]
+ simd/x86_64/jccolext-avx2.asm [4:7]
+ simd/x86_64/jccolext-sse2.asm [4:6]
+ simd/x86_64/jcgryext-avx2.asm [4:7]
+ simd/x86_64/jcgryext-sse2.asm [4:6]
+ simd/x86_64/jchuff-sse2.asm [4:7]
+ simd/x86_64/jcphuff-sse2.asm [5:7]
+ simd/x86_64/jdcolext-avx2.asm [4:8]
+ simd/x86_64/jdcolext-sse2.asm [4:7]
+ simd/x86_64/jdmrgext-avx2.asm [4:8]
+ simd/x86_64/jdmrgext-sse2.asm [4:7]
+ simd/x86_64/jdsample-avx2.asm [4:8]
+ simd/x86_64/jdsample-sse2.asm [4:7]
+ simd/x86_64/jfdctflt-sse.asm [4:6]
+ simd/x86_64/jfdctfst-sse2.asm [4:6]
+ simd/x86_64/jfdctint-sse2.asm [4:6]
+ simd/x86_64/jidctflt-sse2.asm [4:7]
+ simd/x86_64/jidctfst-sse2.asm [4:7]
+ simd/x86_64/jidctint-sse2.asm [4:7]
+ simd/x86_64/jidctred-sse2.asm [4:7]
+ simd/x86_64/jsimdcpu.asm [4:6]
+
+KEEP COPYRIGHT_SERVICE_LABEL d49354f7f4ea663f3e3f447782416f9d
+BELONGS ya.make
+ License text:
+ * Copyright (C)2009-2015, 2017, 2020-2024 D. R. Commander.
+ * All Rights Reserved.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/turbojpeg.h [2:3]
+
+KEEP COPYRIGHT_SERVICE_LABEL d5c33c4f0ab9a5d6ea83127ef817b04e
+BELONGS ya.make
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ simd/arm/aarch32/jsimd.c [4:9]
+ simd/arm/aarch64/jsimd.c [4:9]
+ simd/i386/jsimd.c [4:6]
+ simd/jsimd.h [4:10]
+ simd/x86_64/jsimd.c [4:6]
+ src/jsimd.h [4:7]
KEEP COPYRIGHT_SERVICE_LABEL d5fdb3ce18ba6b39a74ec7cea4de37ab
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdsample.c at line 12
+FILE_INCLUDE README.ijg found in files: src/jdsample.c at line 12
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdsample.c [5:13]
+ src/jdsample.c [5:13]
KEEP COPYRIGHT_SERVICE_LABEL d6496c342f8b2770becfe0cd5be87a4e
BELONGS ya.make
- License text:
- ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
- ; Copyright (C) 2018, Matthieu Darbois.
- ; Copyright (C) 2018, Matthias Räncker.
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/nasm/jsimdext.inc [4:7]
+ simd/nasm/jsimdext.inc [4:8]
KEEP COPYRIGHT_SERVICE_LABEL d74e6a7613a45e0d47d696d49409e0de
BELONGS ya.make
@@ -1898,34 +2314,40 @@ BELONGS ya.make
KEEP COPYRIGHT_SERVICE_LABEL d790272c7994ded60847851f8d898fd3
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdcol565.c at line 9, jdcolor.c at line 9, jdmaster.c at line 9, jdmerge.c at line 9, jdmrg565.c at line 9, wrbmp.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jdcol565.c at line 9, src/jdcolor.c at line 9, src/jdmaster.c at line 9, src/jdmerge.c at line 9, src/jdmrg565.c at line 9, src/wrbmp.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdcol565.c [5:10]
- jdcolor.c [5:12]
- jdmaster.c [5:12]
- jdmerge.c [5:11]
- jdmrg565.c [5:10]
- wrbmp.c [5:10]
+ src/jdcol565.c [5:10]
+ src/jdcolor.c [5:12]
+ src/jdmaster.c [5:14]
+ src/jdmerge.c [5:11]
+ src/jdmrg565.c [5:10]
+ src/wrbmp.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL d7bcb9862eed9e8b3be25e9b9c3c4ee1
+KEEP COPYRIGHT_SERVICE_LABEL d79b9eac68da91e88b17e45875a123e0
BELONGS ya.make
License text:
- ; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- ; Copyright (C) 2016, 2020, D. R. Commander.
+ * Copyright (C) 2022, 2024, D. R. Commander. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- simd/i386/jfdctint-mmx.asm [4:5]
- simd/i386/jfdctint-sse2.asm [4:5]
- simd/i386/jidctint-mmx.asm [4:5]
- simd/i386/jidctint-sse2.asm [4:5]
+ simd/arm/jcphuff-neon.c [6:6]
+ src/jcapimin.c [5:10]
+ src/jcapistd.c [5:9]
+ src/jccoefct.c [5:9]
+ src/jcdiffct.c [5:11]
+ src/jclossls.c [5:11]
+ src/jcmainct.c [5:11]
+ src/jcprepct.c [5:11]
+ src/jddiffct.c [5:11]
+ src/jdlossls.c [5:11]
+ src/jerror.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL d7cbc4888488ae9309e299e88d442551
BELONGS ya.make
@@ -1935,96 +2357,84 @@ BELONGS ya.make
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [39:51]
+ jversion.h [39:53]
-KEEP COPYRIGHT_SERVICE_LABEL d8571b0bd95f27ba489c62714ff09a44
+KEEP COPYRIGHT_SERVICE_LABEL dfae29e3611ad1f497189a07143e6db8
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdatasrc-tj.c at line 9
+FILE_INCLUDE README.ijg found in files: src/jchuff.c at line 14
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdatasrc-tj.c [5:10]
+ src/jchuff.c [5:15]
-KEEP COPYRIGHT_SERVICE_LABEL dd41d14be2162054f1b10aa961d71da7
+KEEP COPYRIGHT_SERVICE_LABEL e0afbdf76d82e3455ece6a543e9d732e
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jpeglib.h at line 10
- Note: matched license text is too long. Read it in the source files.
+ License text:
+ * Copyright (C) 2022, Matthieu Darbois. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jpeglib.h [5:11]
+ simd/arm/jcphuff-neon.c [5:5]
-KEEP COPYRIGHT_SERVICE_LABEL e151cf32655a7d62804025b92dc0da5a
+KEEP COPYRIGHT_SERVICE_LABEL e1ad673e72aa36988fcd91d1ac237bc6
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jdcolext.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jsimd_none.c [4:7]
+ src/jdcolext.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL e395a64659058a5d7d2f78850dd6d40f
+KEEP COPYRIGHT_SERVICE_LABEL e3d3ca9031fbfe099bde93ca7031f014
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jversion.h at line 8
+FILE_INCLUDE README.ijg found in files: src/jdatadst-tj.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jversion.h [5:9]
+ src/jdatadst-tj.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL e6ec6317701aca001fa77e6537f8c99d
+KEEP COPYRIGHT_SERVICE_LABEL e8c5e2b9a96446e4397e3b7fd6095da7
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: transupp.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jquant2.c at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- transupp.c [5:9]
+ src/jquant2.c [5:9]
KEEP COPYRIGHT_SERVICE_LABEL ea6ca264cbf0bd46b9c85409e9a6108b
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: transupp.h at line 8
+FILE_INCLUDE README.ijg found in files: src/transupp.h at line 8
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- transupp.h [5:9]
+ src/transupp.h [5:9]
KEEP COPYRIGHT_SERVICE_LABEL eb22a1dc175d45a0ad730840e22ed3b4
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jccolor.c at line 10, jcdctmgr.c at line 10, jcsample.c at line 10, jdcoefct.c at line 10, jdcoefct.h at line 10, jdcolor.c at line 10, jddctmgr.c at line 10, jdmerge.c at line 10, jdsample.c at line 10, jsimd.h at line 9, jsimd_none.c at line 9, jsimddct.h at line 9, simd/arm/aarch32/jsimd.c at line 9, simd/arm/aarch64/jsimd.c at line 9, simd/i386/jccolext-mmx.asm at line 9, simd/i386/jccolor-mmx.asm at line 9, simd/i386/jcgray-mmx.asm at line 9, simd/i386/jcgryext-mmx.asm at line 9, simd/i386/jcsample-avx2.asm at line 9, simd/i386/jcsample-mmx.asm at line 9, simd/i386/jcsample-sse2.asm at line 9, simd/i386/jdcolext-mmx.asm at line 9, simd/i386/jdcolor-avx2.asm at line 9, simd/i386/jdcolor-mmx.asm at line 9, simd/i386/jdcolor-sse2.asm at line 9, simd/i386/jdmerge-avx2.asm at line 9, simd/i386/jdmerge-mmx.asm at line 9, simd/i386/jdmerge-sse2.asm at line 9, simd/i386/jdmrgext-mmx.asm at line 9, simd/i386/jdsample-avx2.asm at line 9, simd/i386/jdsample-mmx.asm at line 9, simd/i386/jdsample-sse2.asm at line 9, simd/i386/jfdctflt-3dn.asm at line 9, simd/i386/jfdctflt-sse.asm at line 9, simd/i386/jfdctfst-mmx.asm at line 9, simd/i386/jfdctfst-sse2.asm at line 9, simd/i386/jfdctint-avx2.asm at line 9, simd/i386/jfdctint-mmx.asm at line 9, simd/i386/jfdctint-sse2.asm at line 9, simd/i386/jidctflt-3dn.asm at line 9, simd/i386/jidctflt-sse.asm at line 9, simd/i386/jidctflt-sse2.asm at line 9, simd/i386/jidctfst-mmx.asm at line 9, simd/i386/jidctfst-sse2.asm at line 9, simd/i386/jidctint-avx2.asm at line 9, simd/i386/jidctint-mmx.asm at line 9, simd/i386/jidctint-sse2.asm at line 9, simd/i386/jidctred-mmx.asm at line 9, simd/i386/jidctred-sse2.asm at line 9, simd/i386/jquant-3dn.asm at line 9, simd/i386/jquant-mmx.asm at line 9, simd/i386/jquant-sse.asm at line 9, simd/i386/jquantf-sse2.asm at line 9, simd/i386/jquanti-avx2.asm at line 9, simd/i386/jquanti-sse2.asm at line 9, simd/i386/jsimd.c at line 9, simd/i386/jsimdcpu.asm at line 9, simd/jsimd.h at line 9, simd/nasm/jcolsamp.inc at line 9, simd/nasm/jdct.inc at line 9, simd/nasm/jsimdext.inc at line 9, simd/x86_64/jcsample-avx2.asm at line 9, simd/x86_64/jcsample-sse2.asm at line 9, simd/x86_64/jdcolor-avx2.asm at line 9, simd/x86_64/jdcolor-sse2.asm at line 9, simd/x86_64/jdmerge-avx2.asm at line 9, simd/x86_64/jdmerge-sse2.asm at line 9, simd/x86_64/jdsample-avx2.asm at line 9, simd/x86_64/jdsample-sse2.asm at line 9, simd/x86_64/jfdctflt-sse.asm at line 9, simd/x86_64/jfdctfst-sse2.asm at line 9, simd/x86_64/jfdctint-avx2.asm at line 9, simd/x86_64/jfdctint-sse2.asm at line 9, simd/x86_64/jidctflt-sse2.asm at line 9, simd/x86_64/jidctfst-sse2.asm at line 9, simd/x86_64/jidctint-avx2.asm at line 9, simd/x86_64/jidctint-sse2.asm at line 9, simd/x86_64/jidctred-sse2.asm at line 9, simd/x86_64/jquantf-sse2.asm at line 9, simd/x86_64/jquanti-avx2.asm at line 9, simd/x86_64/jquanti-sse2.asm at line 9, simd/x86_64/jsimd.c at line 9, simd/x86_64/jsimdcpu.asm at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jccolor.c [5:11]
- jcdctmgr.c [5:11]
- jcsample.c [5:11]
- jdcoefct.c [5:11]
- jdcoefct.h [5:10]
- jdcolor.c [5:12]
- jddctmgr.c [5:12]
- jdmerge.c [5:11]
- jdsample.c [5:13]
- jsimd.h [4:7]
- jsimd_none.c [4:7]
- jsimddct.h [4:4]
simd/arm/aarch32/jsimd.c [4:9]
- simd/arm/aarch64/jsimd.c [4:8]
+ simd/arm/aarch64/jsimd.c [4:9]
simd/i386/jccolext-mmx.asm [4:5]
simd/i386/jccolor-mmx.asm [4:5]
simd/i386/jcgray-mmx.asm [4:5]
@@ -2071,35 +2481,46 @@ FILE_INCLUDE README.ijg found in files: jccolor.c at line 10, jcdctmgr.c at line
simd/jsimd.h [4:10]
simd/nasm/jcolsamp.inc [4:5]
simd/nasm/jdct.inc [4:5]
- simd/nasm/jsimdext.inc [4:7]
+ simd/nasm/jsimdext.inc [4:8]
simd/x86_64/jcsample-avx2.asm [4:7]
simd/x86_64/jcsample-sse2.asm [4:6]
simd/x86_64/jdcolor-avx2.asm [4:6]
simd/x86_64/jdcolor-sse2.asm [4:5]
simd/x86_64/jdmerge-avx2.asm [4:6]
simd/x86_64/jdmerge-sse2.asm [4:5]
- simd/x86_64/jdsample-avx2.asm [4:7]
- simd/x86_64/jdsample-sse2.asm [4:6]
- simd/x86_64/jfdctflt-sse.asm [4:5]
- simd/x86_64/jfdctfst-sse2.asm [4:5]
+ simd/x86_64/jdsample-avx2.asm [4:8]
+ simd/x86_64/jdsample-sse2.asm [4:7]
+ simd/x86_64/jfdctflt-sse.asm [4:6]
+ simd/x86_64/jfdctfst-sse2.asm [4:6]
simd/x86_64/jfdctint-avx2.asm [4:5]
- simd/x86_64/jfdctint-sse2.asm [4:5]
- simd/x86_64/jidctflt-sse2.asm [4:6]
- simd/x86_64/jidctfst-sse2.asm [4:6]
+ simd/x86_64/jfdctint-sse2.asm [4:6]
+ simd/x86_64/jidctflt-sse2.asm [4:7]
+ simd/x86_64/jidctfst-sse2.asm [4:7]
simd/x86_64/jidctint-avx2.asm [4:6]
- simd/x86_64/jidctint-sse2.asm [4:6]
- simd/x86_64/jidctred-sse2.asm [4:6]
+ simd/x86_64/jidctint-sse2.asm [4:7]
+ simd/x86_64/jidctred-sse2.asm [4:7]
simd/x86_64/jquantf-sse2.asm [4:6]
simd/x86_64/jquanti-avx2.asm [4:7]
simd/x86_64/jquanti-sse2.asm [4:6]
simd/x86_64/jsimd.c [4:6]
- simd/x86_64/jsimdcpu.asm [4:5]
+ simd/x86_64/jsimdcpu.asm [4:6]
+ src/jccolor.c [5:11]
+ src/jcdctmgr.c [5:11]
+ src/jcsample.c [5:13]
+ src/jdcoefct.c [5:11]
+ src/jdcoefct.h [5:11]
+ src/jdcolor.c [5:12]
+ src/jddctmgr.c [5:12]
+ src/jdmerge.c [5:11]
+ src/jdsample.c [5:13]
+ src/jsimd.h [4:7]
+ src/jsimddct.h [4:4]
KEEP COPYRIGHT_SERVICE_LABEL ec0537a229e1880f54c1d10e8cd723c3
BELONGS ya.make
License text:
; Copyright (C) 2015, Intel Corporation.
- ; Copyright (C) 2016, D. R. Commander.
+ ; Copyright (C) 2016, 2024, D. R. Commander.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
@@ -2116,157 +2537,161 @@ BELONGS ya.make
simd/i386/jdmrgext-avx2.asm [4:6]
simd/i386/jdsample-avx2.asm [4:6]
simd/nasm/jcolsamp.inc [4:5]
- simd/x86_64/jccolext-avx2.asm [4:6]
+ simd/x86_64/jccolext-avx2.asm [4:7]
simd/x86_64/jccolor-avx2.asm [4:5]
simd/x86_64/jcgray-avx2.asm [4:5]
- simd/x86_64/jcgryext-avx2.asm [4:6]
+ simd/x86_64/jcgryext-avx2.asm [4:7]
simd/x86_64/jcsample-avx2.asm [4:7]
- simd/x86_64/jdcolext-avx2.asm [4:7]
+ simd/x86_64/jdcolext-avx2.asm [4:8]
simd/x86_64/jdcolor-avx2.asm [4:6]
simd/x86_64/jdmerge-avx2.asm [4:6]
- simd/x86_64/jdmrgext-avx2.asm [4:7]
- simd/x86_64/jdsample-avx2.asm [4:7]
+ simd/x86_64/jdmrgext-avx2.asm [4:8]
+ simd/x86_64/jdsample-avx2.asm [4:8]
KEEP COPYRIGHT_SERVICE_LABEL ec07749745840029e5c8b2f2f7870201
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jdct.h at line 8, jfdctfst.c at line 8, jidctfst.c at line 8, jidctred.c at line 8, simd/arm/aarch32/jsimd_neon.S at line 12
License text:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
+ * Copyright (C) 2015, D. R. Commander. All Rights Reserved.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jdct.h [5:9]
- jfdctfst.c [5:9]
- jidctfst.c [5:9]
- jidctred.c [5:9]
simd/arm/aarch32/jsimd_neon.S [9:9]
+ src/jfdctfst.c [5:9]
-KEEP COPYRIGHT_SERVICE_LABEL ec986a301f4f1cd97fd36cfe73b186b7
+KEEP COPYRIGHT_SERVICE_LABEL ef292409cf51b45110665ff46607bac2
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcdctmgr.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcdctmgr.c [5:11]
+ src/wrgif.c [21:30]
-KEEP COPYRIGHT_SERVICE_LABEL ef292409cf51b45110665ff46607bac2
+KEEP COPYRIGHT_SERVICE_LABEL eff640b6de522947d1ceb810123c6138
BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jdsample.c at line 12
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- wrgif.c [21:30]
+ src/jdsample.c [5:13]
-KEEP COPYRIGHT_SERVICE_LABEL f3ec844f0de8ce7cc9534e740161ff67
+KEEP COPYRIGHT_SERVICE_LABEL f30aa89c2842fa10230d983b361dc93a
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcmaster.c at line 9
+FILE_INCLUDE README.ijg found in files: src/wrgif.c at line 9
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcmaster.c [5:10]
+ src/wrgif.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL f45beec025a14f11290ad8d8146e8b44
+KEEP COPYRIGHT_SERVICE_LABEL f4d6b1166506be518b06a0d3ff4fb5a3
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11
+FILE_INCLUDE README.ijg found in files: simd/arm/jchuff.h at line 10, src/cdjpeg.c at line 10, src/djpeg.c at line 10, src/jchuff.h at line 10, src/jcmaster.c at line 10, src/jdcol565.c at line 10, src/jdcolext.c at line 10, src/jdcolor.c at line 10, src/jdmaster.c at line 10, src/jmemmgr.c at line 10, src/jmorecfg.h at line 10, src/jpegint.h at line 10, src/rdgif.c at line 10, src/rdppm.c at line 10, src/wrgif.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcphuff.c [5:12]
+ simd/arm/jchuff.h [5:11]
+ src/cdjpeg.c [5:9]
+ src/djpeg.c [5:11]
+ src/jchuff.h [5:9]
+ src/jcmaster.c [5:12]
+ src/jdcol565.c [5:10]
+ src/jdcolext.c [5:9]
+ src/jdcolor.c [5:12]
+ src/jdmaster.c [5:14]
+ src/jmemmgr.c [5:9]
+ src/jmorecfg.h [5:12]
+ src/jpegint.h [5:14]
+ src/rdgif.c [5:10]
+ src/rdppm.c [5:10]
+ src/wrgif.c [5:10]
-KEEP COPYRIGHT_SERVICE_LABEL f4d6b1166506be518b06a0d3ff4fb5a3
+KEEP COPYRIGHT_SERVICE_LABEL f8611e4db0d0f05eed5f94a6f6894019
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cdjpeg.c at line 8, djpeg.c at line 8, jchuff.c at line 8, jchuff.h at line 8, jcinit.c at line 8, jcmaster.c at line 8, jdcol565.c at line 8, jdcolext.c at line 8, jdcolor.c at line 8, jdhuff.c at line 8, jdhuff.h at line 8, jdinput.c at line 8, jdmaster.c at line 8, jmemmgr.c at line 8, jmorecfg.h at line 8, jpegint.h at line 8, rdgif.c at line 8, rdppm.c at line 8, simd/arm/jchuff.h at line 8, wrgif.c at line 8
+FILE_INCLUDE README.ijg found in files: src/jdmarker.c at line 10
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- cdjpeg.c [5:9]
- djpeg.c [5:11]
- jchuff.c [5:12]
- jchuff.h [5:8]
- jcinit.c [5:9]
- jcmaster.c [5:10]
- jdcol565.c [5:10]
- jdcolext.c [5:9]
- jdcolor.c [5:12]
- jdhuff.c [5:10]
- jdhuff.h [5:10]
- jdinput.c [5:10]
- jdmaster.c [5:12]
- jmemmgr.c [5:9]
- jmorecfg.h [5:10]
- jpegint.h [5:12]
- rdgif.c [5:10]
- rdppm.c [5:10]
- simd/arm/jchuff.h [5:11]
- wrgif.c [5:10]
+ src/jdmarker.c [5:11]
+
+KEEP COPYRIGHT_SERVICE_LABEL f89ccc45319059eecd21dfa1b88ec195
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: jversion.h at line 8
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ jversion.h [5:9]
KEEP COPYRIGHT_SERVICE_LABEL f992ae275ee011ff1e8c9f49c3ce89da
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapistd.c at line 6, jcdctmgr.c at line 7, jcmainct.c at line 7, jcprepct.c at line 7, jdapistd.c at line 7, jdatadst-tj.c at line 7, jdatadst.c at line 7, jdatasrc-tj.c at line 7, jdatasrc.c at line 7, jdct.h at line 7, jddctmgr.c at line 7, jdmainct.c at line 7, jdmainct.h at line 7, jdmerge.c at line 7, jdmerge.h at line 7, jdmrg565.c at line 7, jdmrgext.c at line 7, jdpostct.c at line 7, jfdctflt.c at line 6, jfdctfst.c at line 7, rdbmp.c at line 7, rdcolmap.c at line 6, wrbmp.c at line 7
- License text:
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README.ijg
+FILE_INCLUDE README.ijg found in files: src/jcapistd.c at line 8, src/jcdctmgr.c at line 8, src/jdapistd.c at line 8, src/jdatadst-tj.c at line 8, src/jdatadst.c at line 8, src/jdatasrc-tj.c at line 8, src/jdatasrc.c at line 8, src/jdct.h at line 8, src/jddctmgr.c at line 8, src/jdmainct.c at line 8, src/jdmainct.h at line 8, src/jdmerge.c at line 8, src/jdmerge.h at line 8, src/jdmrg565.c at line 8, src/jdmrgext.c at line 8, src/jdpostct.c at line 8, src/jfdctflt.c at line 7, src/jfdctfst.c at line 8, src/rdbmp.c at line 8, src/rdcolmap.c at line 8, src/wrbmp.c at line 8
+ Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcapistd.c [4:6]
- jcdctmgr.c [5:11]
- jcmainct.c [5:8]
- jcprepct.c [5:9]
- jdapistd.c [5:10]
- jdatadst-tj.c [5:10]
- jdatadst.c [5:10]
- jdatasrc-tj.c [5:10]
- jdatasrc.c [5:10]
- jdct.h [5:9]
- jddctmgr.c [5:12]
- jdmainct.c [5:9]
- jdmainct.h [5:7]
- jdmerge.c [5:11]
- jdmerge.h [5:9]
- jdmrg565.c [5:10]
- jdmrgext.c [5:9]
- jdpostct.c [5:8]
- jfdctflt.c [4:6]
- jfdctfst.c [5:9]
- rdbmp.c [5:11]
- rdcolmap.c [4:6]
- wrbmp.c [5:10]
+ src/jcapistd.c [5:9]
+ src/jcdctmgr.c [5:11]
+ src/jdapistd.c [5:10]
+ src/jdatadst-tj.c [5:10]
+ src/jdatadst.c [5:10]
+ src/jdatasrc-tj.c [5:10]
+ src/jdatasrc.c [5:10]
+ src/jdct.h [5:9]
+ src/jddctmgr.c [5:12]
+ src/jdmainct.c [5:9]
+ src/jdmainct.h [5:9]
+ src/jdmerge.c [5:11]
+ src/jdmerge.h [5:9]
+ src/jdmrg565.c [5:10]
+ src/jdmrgext.c [5:9]
+ src/jdpostct.c [5:9]
+ src/jfdctflt.c [4:6]
+ src/jfdctfst.c [5:9]
+ src/rdbmp.c [5:11]
+ src/rdcolmap.c [5:9]
+ src/wrbmp.c [5:10]
KEEP COPYRIGHT_SERVICE_LABEL fb1969d8022279f91786a49876542048
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcphuff.c at line 11, jpegint.h at line 11
+FILE_INCLUDE README.ijg found in files: src/jcphuff.c at line 13, src/jpegint.h at line 13
+ Note: matched license text is too long. Read it in the source files.
+ Scancode info:
+ Original SPDX id: COPYRIGHT_SERVICE_LABEL
+ Score : 100.00
+ Match type : COPYRIGHT
+ Files with this license:
+ src/jcphuff.c [5:14]
+ src/jpegint.h [5:14]
+
+KEEP COPYRIGHT_SERVICE_LABEL fea5f985eb4c254fa6d7beecabb519ce
+BELONGS ya.make
+FILE_INCLUDE README.ijg found in files: src/jdinput.c at line 11
Note: matched license text is too long. Read it in the source files.
Scancode info:
Original SPDX id: COPYRIGHT_SERVICE_LABEL
Score : 100.00
Match type : COPYRIGHT
Files with this license:
- jcphuff.c [5:12]
- jpegint.h [5:12]
+ src/jdinput.c [5:12]
KEEP COPYRIGHT_SERVICE_LABEL ff4f68c38d54f4ee28ddb06f4c22e5e5
BELONGS ya.make
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report b/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report
index b57be1a5044..77e0143f02f 100644
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report
+++ b/contrib/libs/libjpeg-turbo/.yandex_meta/devtools.licenses.report
@@ -31,7 +31,7 @@
SKIP Zlib 0b2c2142ae5163b2338d3444a664a4d2
BELONGS ya.make
-FILE_IGNORE simd/nasm/jsimdext.inc found in files: jsimd.h at line 11, jsimd_none.c at line 11, jsimddct.h at line 8, simd/arm/aarch32/jsimd.c at line 13, simd/arm/aarch64/jsimd.c at line 12, simd/i386/jsimd.c at line 10, simd/jsimd.h at line 14, simd/x86_64/jsimd.c at line 10
+FILE_IGNORE simd/nasm/jsimdext.inc found in files: simd/arm/aarch32/jsimd.c at line 13, simd/arm/aarch64/jsimd.c at line 13, simd/i386/jsimd.c at line 10, simd/jsimd.h at line 14, simd/x86_64/jsimd.c at line 10, src/jsimd.h at line 11, src/jsimddct.h at line 8
License text:
* For conditions of distribution and use, see copyright notice in jsimdext.inc
Scancode info:
@@ -40,14 +40,13 @@ FILE_IGNORE simd/nasm/jsimdext.inc found in files: jsimd.h at line 11, jsimd_non
Match type : REFERENCE
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- jsimd.h [11:11]
- jsimd_none.c [11:11]
- jsimddct.h [8:8]
simd/arm/aarch32/jsimd.c [13:13]
- simd/arm/aarch64/jsimd.c [12:12]
+ simd/arm/aarch64/jsimd.c [13:13]
simd/i386/jsimd.c [10:10]
simd/jsimd.h [14:14]
simd/x86_64/jsimd.c [10:10]
+ src/jsimd.h [11:11]
+ src/jsimddct.h [8:8]
KEEP BSD-3-Clause 11d698b5bde51c49edd95b88f640964c
BELONGS ya.make
@@ -59,7 +58,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- README.md [30:30]
+ README.md [49:49]
KEEP Zlib 1661ad60dffa54137d6416dfd7689e04
BELONGS ya.make
@@ -71,7 +70,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- LICENSE.md [47:47]
+ LICENSE.md [50:50]
KEEP BSD-3-Clause 215800e23d49e25c39ec19c06b3a4b7e
BELONGS ya.make
@@ -83,7 +82,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [12:12]
+ LICENSE.md [16:16]
KEEP BSD-3-Clause 23f26458908411db285fd7e9618d0400
BELONGS ya.make
@@ -95,32 +94,32 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [37:37]
+ LICENSE.md [40:40]
-KEEP BSD-3-Clause 2493102f4ead68ded4257981325eec7a
+KEEP BSD-3-Clause 2795fc0c0a7bc60174daf8e80fd02db8
BELONGS ya.make
License text:
- libjpeg-turbo is covered by three compatible BSD-style open source licenses:
+ - IJG License
+ - Modified BSD License
Scancode info:
Original SPDX id: BSD-3-Clause
- Score : 90.00
+ Score : 16.00
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [4:4]
+ LICENSE.md [89:90]
-KEEP BSD-3-Clause 2795fc0c0a7bc60174daf8e80fd02db8
+KEEP Zlib 370cc1c89505a373c6d4b6dcaa01930f
BELONGS ya.make
License text:
- - IJG License
- - Modified BSD License
+ the overall libjpeg API library, the terms of the zlib License are subsumed
Scancode info:
- Original SPDX id: BSD-3-Clause
- Score : 16.00
+ Original SPDX id: Zlib
+ Score : 100.00
Match type : REFERENCE
- Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
+ Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- LICENSE.md [86:87]
+ LICENSE.md [13:13]
KEEP BSD-3-Clause AND BSD-3-Clause 4694a148911c95fc84a45824e7b3c243
BELONGS ya.make
@@ -131,9 +130,10 @@ BELONGS ya.make
Match type : TEXT
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- tjutil.h [4:26]
- turbojpeg.c [5:27]
- turbojpeg.h [5:27]
+ src/tjutil.h [4:26]
+ src/turbojpeg-mp.c [4:26]
+ src/turbojpeg.c [5:27]
+ src/turbojpeg.h [5:27]
KEEP Zlib 49b2005eb74289158192a07e3d97f167
BELONGS ya.make
@@ -145,7 +145,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- LICENSE.md [38:38]
+ LICENSE.md [41:41]
KEEP IJG 49f21ef3a9ec8414db54cb3989614ee3
BELONGS ya.make
@@ -157,93 +157,104 @@ BELONGS ya.make
Match type : NOTICE
Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
Files with this license:
- cderror.h [4:4]
- cdjpeg.c [4:4]
- cdjpeg.h [4:4]
- cjpeg.c [4:4]
- djpeg.c [4:4]
- jaricom.c [4:4]
- jcapimin.c [4:4]
- jcarith.c [4:4]
- jccoefct.c [4:4]
- jccolext.c [4:4]
- jccolor.c [4:4]
- jcdctmgr.c [4:4]
- jchuff.c [4:4]
- jchuff.h [4:4]
- jcinit.c [4:4]
- jcmainct.c [4:4]
- jcmarker.c [4:4]
- jcmaster.c [4:4]
- jcomapi.c [4:4]
- jcparam.c [4:4]
- jcphuff.c [4:4]
- jcsample.c [4:4]
- jctrans.c [4:4]
- jdapimin.c [4:4]
- jdapistd.c [4:4]
- jdarith.c [4:4]
- jdatadst-tj.c [4:4]
- jdatadst.c [4:4]
- jdatasrc-tj.c [4:4]
- jdatasrc.c [4:4]
- jdcoefct.c [4:4]
- jdcoefct.h [4:4]
- jdcol565.c [4:4]
- jdcolext.c [4:4]
- jdcolor.c [4:4]
- jdct.h [4:4]
- jddctmgr.c [4:4]
- jdhuff.c [4:4]
- jdhuff.h [4:4]
- jdinput.c [4:4]
- jdmainct.c [4:4]
- jdmainct.h [4:4]
- jdmarker.c [4:4]
- jdmaster.c [4:4]
- jdmaster.h [4:4]
- jdmerge.c [4:4]
- jdmerge.h [4:4]
- jdmrg565.c [4:4]
- jdmrgext.c [4:4]
- jdphuff.c [4:4]
- jdpostct.c [4:4]
- jdsample.c [4:4]
- jdsample.h [4:4]
- jdtrans.c [4:4]
- jerror.c [4:4]
- jerror.h [4:4]
- jfdctfst.c [4:4]
- jfdctint.c [4:4]
- jidctflt.c [4:4]
- jidctfst.c [4:4]
- jidctint.c [4:4]
- jidctred.c [4:4]
- jinclude.h [4:4]
- jmemmgr.c [4:4]
- jmemnobs.c [4:4]
- jmemsys.h [4:4]
- jmorecfg.h [4:4]
- jpegint.h [4:4]
- jpeglib.h [4:4]
- jpegtran.c [4:4]
- jquant1.c [4:4]
- jquant2.c [4:4]
- jstdhuff.c [4:4]
- jutils.c [4:4]
jversion.h [4:4]
- rdbmp.c [4:4]
- rdgif.c [4:4]
- rdppm.c [4:4]
- rdswitch.c [4:4]
- rdtarga.c [4:4]
simd/arm/jchuff.h [4:4]
- transupp.c [4:4]
- transupp.h [4:4]
- wrbmp.c [4:4]
- wrgif.c [4:4]
- wrppm.c [4:4]
- wrtarga.c [4:4]
+ src/cderror.h [4:4]
+ src/cdjpeg.c [4:4]
+ src/cdjpeg.h [4:4]
+ src/cjpeg.c [4:4]
+ src/djpeg.c [4:4]
+ src/jaricom.c [4:4]
+ src/jcapimin.c [4:4]
+ src/jcapistd.c [4:4]
+ src/jcarith.c [4:4]
+ src/jccoefct.c [4:4]
+ src/jccolext.c [4:4]
+ src/jccolor.c [4:4]
+ src/jcdctmgr.c [4:4]
+ src/jcdiffct.c [4:4]
+ src/jchuff.c [4:4]
+ src/jchuff.h [4:4]
+ src/jcinit.c [4:4]
+ src/jclhuff.c [4:4]
+ src/jclossls.c [4:4]
+ src/jcmainct.c [4:4]
+ src/jcmarker.c [4:4]
+ src/jcmaster.c [4:4]
+ src/jcmaster.h [4:4]
+ src/jcomapi.c [4:4]
+ src/jcparam.c [4:4]
+ src/jcphuff.c [4:4]
+ src/jcprepct.c [4:4]
+ src/jcsample.c [4:4]
+ src/jctrans.c [4:4]
+ src/jdapimin.c [4:4]
+ src/jdapistd.c [4:4]
+ src/jdarith.c [4:4]
+ src/jdatadst-tj.c [4:4]
+ src/jdatadst.c [4:4]
+ src/jdatasrc-tj.c [4:4]
+ src/jdatasrc.c [4:4]
+ src/jdcoefct.c [4:4]
+ src/jdcoefct.h [4:4]
+ src/jdcol565.c [4:4]
+ src/jdcolext.c [4:4]
+ src/jdcolor.c [4:4]
+ src/jdct.h [4:4]
+ src/jddctmgr.c [4:4]
+ src/jddiffct.c [4:4]
+ src/jdhuff.c [4:4]
+ src/jdhuff.h [4:4]
+ src/jdinput.c [4:4]
+ src/jdlhuff.c [4:4]
+ src/jdlossls.c [4:4]
+ src/jdmainct.c [4:4]
+ src/jdmainct.h [4:4]
+ src/jdmarker.c [4:4]
+ src/jdmaster.c [4:4]
+ src/jdmaster.h [4:4]
+ src/jdmerge.c [4:4]
+ src/jdmerge.h [4:4]
+ src/jdmrg565.c [4:4]
+ src/jdmrgext.c [4:4]
+ src/jdphuff.c [4:4]
+ src/jdpostct.c [4:4]
+ src/jdsample.c [4:4]
+ src/jdsample.h [4:4]
+ src/jdtrans.c [4:4]
+ src/jerror.c [4:4]
+ src/jerror.h [4:4]
+ src/jfdctfst.c [4:4]
+ src/jfdctint.c [4:4]
+ src/jidctflt.c [4:4]
+ src/jidctfst.c [4:4]
+ src/jidctint.c [4:4]
+ src/jidctred.c [4:4]
+ src/jinclude.h [4:4]
+ src/jlossls.h [4:4]
+ src/jmemmgr.c [4:4]
+ src/jmemnobs.c [4:4]
+ src/jmemsys.h [4:4]
+ src/jmorecfg.h [4:4]
+ src/jpegint.h [4:4]
+ src/jpeglib.h [4:4]
+ src/jpegtran.c [4:4]
+ src/jquant1.c [4:4]
+ src/jquant2.c [4:4]
+ src/jstdhuff.c [4:4]
+ src/jutils.c [4:4]
+ src/rdbmp.c [4:4]
+ src/rdcolmap.c [4:4]
+ src/rdgif.c [4:4]
+ src/rdppm.c [4:4]
+ src/rdswitch.c [4:4]
+ src/rdtarga.c [4:4]
+ src/transupp.c [4:4]
+ src/transupp.h [4:4]
+ src/wrbmp.c [4:4]
+ src/wrgif.c [4:4]
+ src/wrppm.c [4:4]
+ src/wrtarga.c [4:4]
KEEP Zlib 5627c2f3c456186103c1295c24b27409
BELONGS ya.make
@@ -255,7 +266,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- LICENSE.md [127:127]
+ LICENSE.md [130:130]
KEEP BSD-3-Clause 67ada8383dd2efffa1e47a6970948655
BELONGS ya.make
@@ -267,7 +278,19 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [72:72]
+ LICENSE.md [75:75]
+
+KEEP BSD-3-Clause 738e8e69237a0b8ae0317e73ee006be2
+BELONGS ya.make
+ License text:
+ libjpeg-turbo is covered by two compatible BSD-style open source licenses:
+ Scancode info:
+ Original SPDX id: BSD-3-Clause
+ Score : 90.00
+ Match type : REFERENCE
+ Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
+ Files with this license:
+ LICENSE.md [4:4]
KEEP Zlib 758530b81bedb384e1d293db2dc592cf
BELONGS ya.make
@@ -278,11 +301,24 @@ BELONGS ya.make
Match type : TEXT
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- simd/nasm/jsimdext.inc [13:27]
+ simd/nasm/jsimdext.inc [14:28]
+
+KEEP BSD-3-Clause 78ca2039132b440c1f7a5473212df4e3
+BELONGS ya.make
+ License text:
+ both the terms of the IJG License and the terms of the Modified (3-clause)
+ BSD License apply.
+ Scancode info:
+ Original SPDX id: BSD-3-Clause
+ Score : 100.00
+ Match type : REFERENCE
+ Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
+ Files with this license:
+ LICENSE.md [21:22]
KEEP IJG 7aecae112681f0e63e5d5f9a9342893a
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: jcapistd.c at line 6, jfdctflt.c at line 6, rdcolmap.c at line 6
+FILE_INCLUDE README.ijg found in files: src/jfdctflt.c at line 6
License text:
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -292,9 +328,7 @@ FILE_INCLUDE README.ijg found in files: jcapistd.c at line 6, jfdctflt.c at line
Match type : REFERENCE
Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
Files with this license:
- jcapistd.c [5:6]
- jfdctflt.c [5:6]
- rdcolmap.c [5:6]
+ src/jfdctflt.c [5:6]
KEEP IJG 7e97c9e006fbb17d004858a2472e48cd
BELONGS ya.make
@@ -305,7 +339,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
Files with this license:
- README.ijg [112:122]
+ README.ijg [114:124]
KEEP BSD-3-Clause 8cfc9281adee4768f2232b6e22a82a6d
BELONGS ya.make
@@ -317,7 +351,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [91:91]
+ LICENSE.md [94:94]
KEEP BSD-3-Clause 9778dab78425d5cabd719681a55257aa
BELONGS ya.make
@@ -330,7 +364,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [125:126]
+ LICENSE.md [128:129]
KEEP BSD-3-Clause 98d00c840630f45af91f7f4204a1191c
BELONGS ya.make
@@ -342,11 +376,11 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [79:79]
+ LICENSE.md [82:82]
SKIP Unknown 9ceeef4406e152a852bacc703754696c
BELONGS ya.make
-FILE_INCLUDE README.ijg found in files: cderror.h at line 9, cdjpeg.c at line 8, cdjpeg.h at line 9, cjpeg.c at line 9, cmyk.h at line 5, djpeg.c at line 10, jaricom.c at line 8, jcapimin.c at line 9, jcarith.c at line 8, jccoefct.c at line 8, jccolext.c at line 8, jccolor.c at line 10, jcdctmgr.c at line 10, jchuff.c at line 11, jchuff.h at line 8, jcicc.c at line 6, jcinit.c at line 8, jcmainct.c at line 8, jcmarker.c at line 9, jcmaster.c at line 9, jcomapi.c at line 8, jcparam.c at line 9, jcphuff.c at line 11, jcprepct.c at line 8, jcsample.c at line 10, jctrans.c at line 9, jdapimin.c at line 8, jdapistd.c at line 9, jdarith.c at line 8, jdatadst-tj.c at line 9, jdatadst.c at line 9, jdatasrc-tj.c at line 9, jdatasrc.c at line 9, jdcoefct.c at line 10, jdcoefct.h at line 9, jdcol565.c at line 9, jdcolext.c at line 8, jdcolor.c at line 11, jdct.h at line 8, jddctmgr.c at line 11, jdhuff.c at line 9, jdhuff.h at line 9, jdicc.c at line 6, jdinput.c at line 9, jdmainct.c at line 8, jdmainct.h at line 6, jdmarker.c at line 8, jdmaster.c at line 11, jdmaster.h at line 6, jdmerge.c at line 10, jdmerge.h at line 8, jdmrg565.c at line 9, jdmrgext.c at line 8, jdphuff.c at line 8, jdpostct.c at line 8, jdsample.c at line 12, jdsample.h at line 6, jdtrans.c at line 8, jerror.c at line 8, jerror.h at line 9, jfdctfst.c at line 8, jfdctint.c at line 8, jidctflt.c at line 9, jidctfst.c at line 8, jidctint.c at line 9, jidctred.c at line 8, jinclude.h at line 8, jmemmgr.c at line 8, jmemnobs.c at line 8, jmemsys.h at line 8, jmorecfg.h at line 9, jpegcomp.h at line 5, jpegint.h at line 11, jpeglib.h at line 10, jpegtran.c at line 8, jquant1.c at line 8, jquant2.c at line 8, jstdhuff.c at line 8, jutils.c at line 8, jversion.h at line 8, rdbmp.c at line 10, rdppm.c at line 9, rdswitch.c at line 8, rdtarga.c at line 9, simd/arm/jchuff.h at line 10, transupp.c at line 8, transupp.h at line 8, wrbmp.c at line 9, wrppm.c at line 9, wrtarga.c at line 8
+FILE_INCLUDE README.ijg found in files: jversion.h at line 8, simd/arm/jchuff.h at line 10, src/cderror.h at line 9, src/cdjpeg.c at line 8, src/cdjpeg.h at line 9, src/cjpeg.c at line 12, src/cmyk.h at line 5, src/djpeg.c at line 10, src/jaricom.c at line 8, src/jcapimin.c at line 9, src/jcapistd.c at line 8, src/jcarith.c at line 8, src/jccoefct.c at line 8, src/jccolext.c at line 8, src/jccolor.c at line 10, src/jcdctmgr.c at line 10, src/jcdiffct.c at line 10, src/jchuff.c at line 14, src/jchuff.h at line 8, src/jcicc.c at line 6, src/jcinit.c at line 10, src/jclhuff.c at line 10, src/jclossls.c at line 10, src/jcmainct.c at line 10, src/jcmarker.c at line 11, src/jcmaster.c at line 11, src/jcmaster.h at line 8, src/jcomapi.c at line 8, src/jcparam.c at line 11, src/jcphuff.c at line 13, src/jcprepct.c at line 10, src/jcsample.c at line 12, src/jctrans.c at line 9, src/jdapimin.c at line 10, src/jdapistd.c at line 9, src/jdarith.c at line 8, src/jdatadst-tj.c at line 9, src/jdatadst.c at line 9, src/jdatasrc-tj.c at line 9, src/jdatasrc.c at line 9, src/jdcoefct.c at line 10, src/jdcoefct.h at line 10, src/jdcol565.c at line 9, src/jdcolext.c at line 8, src/jdcolor.c at line 11, src/jdct.h at line 8, src/jddctmgr.c at line 11, src/jddiffct.c at line 10, src/jdhuff.c at line 11, src/jdhuff.h at line 11, src/jdicc.c at line 6, src/jdinput.c at line 11, src/jdlhuff.c at line 10, src/jdlossls.c at line 10, src/jdmainct.c at line 8, src/jdmainct.h at line 8, src/jdmarker.c at line 10, src/jdmaster.c at line 13, src/jdmaster.h at line 6, src/jdmerge.c at line 10, src/jdmerge.h at line 8, src/jdmrg565.c at line 9, src/jdmrgext.c at line 8, src/jdphuff.c at line 10, src/jdpostct.c at line 8, src/jdsample.c at line 12, src/jdsample.h at line 8, src/jdtrans.c at line 8, src/jerror.c at line 8, src/jerror.h at line 11, src/jfdctfst.c at line 8, src/jfdctint.c at line 8, src/jidctflt.c at line 9, src/jidctfst.c at line 8, src/jidctint.c at line 9, src/jidctred.c at line 8, src/jinclude.h at line 8, src/jlossls.h at line 10, src/jmemmgr.c at line 8, src/jmemnobs.c at line 8, src/jmemsys.h at line 8, src/jmorecfg.h at line 11, src/jpeg_nbits.c at line 4, src/jpeg_nbits.h at line 6, src/jpegapicomp.h at line 5, src/jpegint.h at line 13, src/jpeglib.h at line 13, src/jpegtran.c at line 8, src/jquant1.c at line 8, src/jquant2.c at line 8, src/jsamplecomp.h at line 5, src/jstdhuff.c at line 8, src/jutils.c at line 8, src/rdbmp.c at line 10, src/rdswitch.c at line 8, src/rdtarga.c at line 9, src/transupp.c at line 8, src/transupp.h at line 8, src/wrapper/jcapistd-12.c at line 5, src/wrapper/jcapistd-16.c at line 5, src/wrapper/jcapistd-8.c at line 5, src/wrapper/jccoefct-12.c at line 5, src/wrapper/jccoefct-8.c at line 5, src/wrapper/jccolor-12.c at line 5, src/wrapper/jccolor-16.c at line 5, src/wrapper/jccolor-8.c at line 5, src/wrapper/jcdctmgr-12.c at line 5, src/wrapper/jcdctmgr-8.c at line 5, src/wrapper/jcdiffct-12.c at line 5, src/wrapper/jcdiffct-16.c at line 5, src/wrapper/jcdiffct-8.c at line 5, src/wrapper/jclossls-12.c at line 5, src/wrapper/jclossls-16.c at line 5, src/wrapper/jclossls-8.c at line 5, src/wrapper/jcmainct-12.c at line 5, src/wrapper/jcmainct-16.c at line 5, src/wrapper/jcmainct-8.c at line 5, src/wrapper/jcprepct-12.c at line 5, src/wrapper/jcprepct-16.c at line 5, src/wrapper/jcprepct-8.c at line 5, src/wrapper/jcsample-12.c at line 5, src/wrapper/jcsample-16.c at line 5, src/wrapper/jcsample-8.c at line 5, src/wrapper/jdapistd-12.c at line 5, src/wrapper/jdapistd-16.c at line 5, src/wrapper/jdapistd-8.c at line 5, src/wrapper/jdcoefct-12.c at line 5, src/wrapper/jdcoefct-8.c at line 5, src/wrapper/jdcolor-12.c at line 5, src/wrapper/jdcolor-16.c at line 5, src/wrapper/jdcolor-8.c at line 5, src/wrapper/jddctmgr-12.c at line 5, src/wrapper/jddctmgr-8.c at line 5, src/wrapper/jddiffct-12.c at line 5, src/wrapper/jddiffct-16.c at line 5, src/wrapper/jddiffct-8.c at line 5, src/wrapper/jdlossls-12.c at line 5, src/wrapper/jdlossls-16.c at line 5, src/wrapper/jdlossls-8.c at line 5, src/wrapper/jdmainct-12.c at line 5, src/wrapper/jdmainct-16.c at line 5, src/wrapper/jdmainct-8.c at line 5, src/wrapper/jdmerge-12.c at line 5, src/wrapper/jdmerge-8.c at line 5, src/wrapper/jdpostct-12.c at line 5, src/wrapper/jdpostct-16.c at line 5, src/wrapper/jdpostct-8.c at line 5, src/wrapper/jdsample-12.c at line 5, src/wrapper/jdsample-16.c at line 5, src/wrapper/jdsample-8.c at line 5, src/wrapper/jfdctfst-12.c at line 5, src/wrapper/jfdctfst-8.c at line 5, src/wrapper/jfdctint-12.c at line 5, src/wrapper/jfdctint-8.c at line 5, src/wrapper/jidctflt-12.c at line 5, src/wrapper/jidctflt-8.c at line 5, src/wrapper/jidctfst-12.c at line 5, src/wrapper/jidctfst-8.c at line 5, src/wrapper/jidctint-12.c at line 5, src/wrapper/jidctint-8.c at line 5, src/wrapper/jidctred-12.c at line 5, src/wrapper/jidctred-8.c at line 5, src/wrapper/jquant1-12.c at line 5, src/wrapper/jquant1-8.c at line 5, src/wrapper/jquant2-12.c at line 5, src/wrapper/jquant2-8.c at line 5, src/wrapper/jutils-12.c at line 5, src/wrapper/jutils-16.c at line 5, src/wrapper/jutils-8.c at line 5, src/wrapper/rdcolmap-12.c at line 5, src/wrapper/rdcolmap-8.c at line 5, src/wrapper/rdppm-12.c at line 5, src/wrapper/rdppm-16.c at line 5, src/wrapper/rdppm-8.c at line 5, src/wrapper/wrgif-12.c at line 5, src/wrapper/wrgif-8.c at line 5, src/wrapper/wrppm-12.c at line 5, src/wrapper/wrppm-16.c at line 5, src/wrapper/wrppm-8.c at line 5, src/wrbmp.c at line 9, src/wrppm.c at line 9, src/wrtarga.c at line 8
# whole file README.ijg allready included
License text:
* For conditions of distribution and use, see the accompanying README.ijg
@@ -356,96 +390,188 @@ FILE_INCLUDE README.ijg found in files: cderror.h at line 9, cdjpeg.c at line 8,
Match type : REFERENCE
Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
Files with this license:
- cderror.h [9:9]
- cdjpeg.c [8:8]
- cdjpeg.h [9:9]
- cjpeg.c [9:9]
- cmyk.h [5:5]
- djpeg.c [10:10]
- jaricom.c [8:8]
- jcapimin.c [9:9]
- jcarith.c [8:8]
- jccoefct.c [8:8]
- jccolext.c [8:8]
- jccolor.c [10:10]
- jcdctmgr.c [10:10]
- jchuff.c [11:11]
- jchuff.h [8:8]
- jcicc.c [6:6]
- jcinit.c [8:8]
- jcmainct.c [8:8]
- jcmarker.c [9:9]
- jcmaster.c [9:9]
- jcomapi.c [8:8]
- jcparam.c [9:9]
- jcphuff.c [11:11]
- jcprepct.c [8:8]
- jcsample.c [10:10]
- jctrans.c [9:9]
- jdapimin.c [8:8]
- jdapistd.c [9:9]
- jdarith.c [8:8]
- jdatadst-tj.c [9:9]
- jdatadst.c [9:9]
- jdatasrc-tj.c [9:9]
- jdatasrc.c [9:9]
- jdcoefct.c [10:10]
- jdcoefct.h [9:9]
- jdcol565.c [9:9]
- jdcolext.c [8:8]
- jdcolor.c [11:11]
- jdct.h [8:8]
- jddctmgr.c [11:11]
- jdhuff.c [9:9]
- jdhuff.h [9:9]
- jdicc.c [6:6]
- jdinput.c [9:9]
- jdmainct.c [8:8]
- jdmainct.h [6:6]
- jdmarker.c [8:8]
- jdmaster.c [11:11]
- jdmaster.h [6:6]
- jdmerge.c [10:10]
- jdmerge.h [8:8]
- jdmrg565.c [9:9]
- jdmrgext.c [8:8]
- jdphuff.c [8:8]
- jdpostct.c [8:8]
- jdsample.c [12:12]
- jdsample.h [6:6]
- jdtrans.c [8:8]
- jerror.c [8:8]
- jerror.h [9:9]
- jfdctfst.c [8:8]
- jfdctint.c [8:8]
- jidctflt.c [9:9]
- jidctfst.c [8:8]
- jidctint.c [9:9]
- jidctred.c [8:8]
- jinclude.h [8:8]
- jmemmgr.c [8:8]
- jmemnobs.c [8:8]
- jmemsys.h [8:8]
- jmorecfg.h [9:9]
- jpegcomp.h [5:5]
- jpegint.h [11:11]
- jpeglib.h [10:10]
- jpegtran.c [8:8]
- jquant1.c [8:8]
- jquant2.c [8:8]
- jstdhuff.c [8:8]
- jutils.c [8:8]
jversion.h [8:8]
- rdbmp.c [10:10]
- rdppm.c [9:9]
- rdswitch.c [8:8]
- rdtarga.c [9:9]
simd/arm/jchuff.h [10:10]
- transupp.c [8:8]
- transupp.h [8:8]
- wrbmp.c [9:9]
- wrppm.c [9:9]
- wrtarga.c [8:8]
+ src/cderror.h [9:9]
+ src/cdjpeg.c [8:8]
+ src/cdjpeg.h [9:9]
+ src/cjpeg.c [12:12]
+ src/cmyk.h [5:5]
+ src/djpeg.c [10:10]
+ src/jaricom.c [8:8]
+ src/jcapimin.c [9:9]
+ src/jcapistd.c [8:8]
+ src/jcarith.c [8:8]
+ src/jccoefct.c [8:8]
+ src/jccolext.c [8:8]
+ src/jccolor.c [10:10]
+ src/jcdctmgr.c [10:10]
+ src/jcdiffct.c [10:10]
+ src/jchuff.c [14:14]
+ src/jchuff.h [8:8]
+ src/jcicc.c [6:6]
+ src/jcinit.c [10:10]
+ src/jclhuff.c [10:10]
+ src/jclossls.c [10:10]
+ src/jcmainct.c [10:10]
+ src/jcmarker.c [11:11]
+ src/jcmaster.c [11:11]
+ src/jcmaster.h [8:8]
+ src/jcomapi.c [8:8]
+ src/jcparam.c [11:11]
+ src/jcphuff.c [13:13]
+ src/jcprepct.c [10:10]
+ src/jcsample.c [12:12]
+ src/jctrans.c [9:9]
+ src/jdapimin.c [10:10]
+ src/jdapistd.c [9:9]
+ src/jdarith.c [8:8]
+ src/jdatadst-tj.c [9:9]
+ src/jdatadst.c [9:9]
+ src/jdatasrc-tj.c [9:9]
+ src/jdatasrc.c [9:9]
+ src/jdcoefct.c [10:10]
+ src/jdcoefct.h [10:10]
+ src/jdcol565.c [9:9]
+ src/jdcolext.c [8:8]
+ src/jdcolor.c [11:11]
+ src/jdct.h [8:8]
+ src/jddctmgr.c [11:11]
+ src/jddiffct.c [10:10]
+ src/jdhuff.c [11:11]
+ src/jdhuff.h [11:11]
+ src/jdicc.c [6:6]
+ src/jdinput.c [11:11]
+ src/jdlhuff.c [10:10]
+ src/jdlossls.c [10:10]
+ src/jdmainct.c [8:8]
+ src/jdmainct.h [8:8]
+ src/jdmarker.c [10:10]
+ src/jdmaster.c [13:13]
+ src/jdmaster.h [6:6]
+ src/jdmerge.c [10:10]
+ src/jdmerge.h [8:8]
+ src/jdmrg565.c [9:9]
+ src/jdmrgext.c [8:8]
+ src/jdphuff.c [10:10]
+ src/jdpostct.c [8:8]
+ src/jdsample.c [12:12]
+ src/jdsample.h [8:8]
+ src/jdtrans.c [8:8]
+ src/jerror.c [8:8]
+ src/jerror.h [11:11]
+ src/jfdctfst.c [8:8]
+ src/jfdctint.c [8:8]
+ src/jidctflt.c [9:9]
+ src/jidctfst.c [8:8]
+ src/jidctint.c [9:9]
+ src/jidctred.c [8:8]
+ src/jinclude.h [8:8]
+ src/jlossls.h [10:10]
+ src/jmemmgr.c [8:8]
+ src/jmemnobs.c [8:8]
+ src/jmemsys.h [8:8]
+ src/jmorecfg.h [11:11]
+ src/jpeg_nbits.c [4:4]
+ src/jpeg_nbits.h [6:6]
+ src/jpegapicomp.h [5:5]
+ src/jpegint.h [13:13]
+ src/jpeglib.h [13:13]
+ src/jpegtran.c [8:8]
+ src/jquant1.c [8:8]
+ src/jquant2.c [8:8]
+ src/jsamplecomp.h [5:5]
+ src/jstdhuff.c [8:8]
+ src/jutils.c [8:8]
+ src/rdbmp.c [10:10]
+ src/rdswitch.c [8:8]
+ src/rdtarga.c [9:9]
+ src/transupp.c [8:8]
+ src/transupp.h [8:8]
+ src/wrapper/jcapistd-12.c [5:5]
+ src/wrapper/jcapistd-16.c [5:5]
+ src/wrapper/jcapistd-8.c [5:5]
+ src/wrapper/jccoefct-12.c [5:5]
+ src/wrapper/jccoefct-8.c [5:5]
+ src/wrapper/jccolor-12.c [5:5]
+ src/wrapper/jccolor-16.c [5:5]
+ src/wrapper/jccolor-8.c [5:5]
+ src/wrapper/jcdctmgr-12.c [5:5]
+ src/wrapper/jcdctmgr-8.c [5:5]
+ src/wrapper/jcdiffct-12.c [5:5]
+ src/wrapper/jcdiffct-16.c [5:5]
+ src/wrapper/jcdiffct-8.c [5:5]
+ src/wrapper/jclossls-12.c [5:5]
+ src/wrapper/jclossls-16.c [5:5]
+ src/wrapper/jclossls-8.c [5:5]
+ src/wrapper/jcmainct-12.c [5:5]
+ src/wrapper/jcmainct-16.c [5:5]
+ src/wrapper/jcmainct-8.c [5:5]
+ src/wrapper/jcprepct-12.c [5:5]
+ src/wrapper/jcprepct-16.c [5:5]
+ src/wrapper/jcprepct-8.c [5:5]
+ src/wrapper/jcsample-12.c [5:5]
+ src/wrapper/jcsample-16.c [5:5]
+ src/wrapper/jcsample-8.c [5:5]
+ src/wrapper/jdapistd-12.c [5:5]
+ src/wrapper/jdapistd-16.c [5:5]
+ src/wrapper/jdapistd-8.c [5:5]
+ src/wrapper/jdcoefct-12.c [5:5]
+ src/wrapper/jdcoefct-8.c [5:5]
+ src/wrapper/jdcolor-12.c [5:5]
+ src/wrapper/jdcolor-16.c [5:5]
+ src/wrapper/jdcolor-8.c [5:5]
+ src/wrapper/jddctmgr-12.c [5:5]
+ src/wrapper/jddctmgr-8.c [5:5]
+ src/wrapper/jddiffct-12.c [5:5]
+ src/wrapper/jddiffct-16.c [5:5]
+ src/wrapper/jddiffct-8.c [5:5]
+ src/wrapper/jdlossls-12.c [5:5]
+ src/wrapper/jdlossls-16.c [5:5]
+ src/wrapper/jdlossls-8.c [5:5]
+ src/wrapper/jdmainct-12.c [5:5]
+ src/wrapper/jdmainct-16.c [5:5]
+ src/wrapper/jdmainct-8.c [5:5]
+ src/wrapper/jdmerge-12.c [5:5]
+ src/wrapper/jdmerge-8.c [5:5]
+ src/wrapper/jdpostct-12.c [5:5]
+ src/wrapper/jdpostct-16.c [5:5]
+ src/wrapper/jdpostct-8.c [5:5]
+ src/wrapper/jdsample-12.c [5:5]
+ src/wrapper/jdsample-16.c [5:5]
+ src/wrapper/jdsample-8.c [5:5]
+ src/wrapper/jfdctfst-12.c [5:5]
+ src/wrapper/jfdctfst-8.c [5:5]
+ src/wrapper/jfdctint-12.c [5:5]
+ src/wrapper/jfdctint-8.c [5:5]
+ src/wrapper/jidctflt-12.c [5:5]
+ src/wrapper/jidctflt-8.c [5:5]
+ src/wrapper/jidctfst-12.c [5:5]
+ src/wrapper/jidctfst-8.c [5:5]
+ src/wrapper/jidctint-12.c [5:5]
+ src/wrapper/jidctint-8.c [5:5]
+ src/wrapper/jidctred-12.c [5:5]
+ src/wrapper/jidctred-8.c [5:5]
+ src/wrapper/jquant1-12.c [5:5]
+ src/wrapper/jquant1-8.c [5:5]
+ src/wrapper/jquant2-12.c [5:5]
+ src/wrapper/jquant2-8.c [5:5]
+ src/wrapper/jutils-12.c [5:5]
+ src/wrapper/jutils-16.c [5:5]
+ src/wrapper/jutils-8.c [5:5]
+ src/wrapper/rdcolmap-12.c [5:5]
+ src/wrapper/rdcolmap-8.c [5:5]
+ src/wrapper/rdppm-12.c [5:5]
+ src/wrapper/rdppm-16.c [5:5]
+ src/wrapper/rdppm-8.c [5:5]
+ src/wrapper/wrgif-12.c [5:5]
+ src/wrapper/wrgif-8.c [5:5]
+ src/wrapper/wrppm-12.c [5:5]
+ src/wrapper/wrppm-16.c [5:5]
+ src/wrapper/wrppm-8.c [5:5]
+ src/wrbmp.c [9:9]
+ src/wrppm.c [9:9]
+ src/wrtarga.c [8:8]
KEEP BSD-3-Clause a0b6446928d785cae9f3fe14c47db8ad
BELONGS ya.make
@@ -457,7 +583,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- simd/nasm/jsimdext.inc [104:104]
+ simd/nasm/jsimdext.inc [113:113]
KEEP Libpbm a8c59a0b9632a2c400a492ddc5396cdc
BELONGS ya.make
@@ -468,7 +594,7 @@ BELONGS ya.make
Match type : TEXT
Links : http://web.mit.edu/tex/fontutil/fontutils-0.6/pbm/libpbm1.c, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/libpbm.LICENSE
Files with this license:
- rdgif.c [27:32]
+ src/rdgif.c [27:32]
KEEP IJG b162017eb4edf0bae69328dcb47110fe
BELONGS ya.make
@@ -481,7 +607,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
Files with this license:
- LICENSE.md [61:62]
+ LICENSE.md [64:65]
KEEP IJG c0840233d37a3eb9fec3920f0bf1099a
BELONGS ya.make
@@ -492,7 +618,7 @@ BELONGS ya.make
Match type : TEXT
Links : http://fedoraproject.org/wiki/Licensing/IJG, https://spdx.org/licenses/IJG
Files with this license:
- README.ijg [124:159]
+ README.ijg [126:161]
SKIP LicenseRef-scancode-unknown-license-reference AND BSD-3-Clause c728e0ae174c1d6b24a9a96924a2e696
BELONGS ya.make
@@ -505,14 +631,14 @@ BELONGS ya.make
Match type : INTRO
Links : https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/unknown-license-reference.LICENSE
Files with this license:
- ChangeLog.md [1655:1655]
+ ChangeLog.md [2200:2200]
Scancode info:
Original SPDX id: BSD-3-Clause
Score : 90.00
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- ChangeLog.md [1655:1655]
+ ChangeLog.md [2200:2200]
KEEP Libpbm d0197b151ef3a1429e6ed9d61db1ebb9
BELONGS ya.make
@@ -523,7 +649,7 @@ BELONGS ya.make
Match type : TEXT
Links : http://web.mit.edu/tex/fontutil/fontutils-0.6/pbm/libpbm1.c, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/libpbm.LICENSE
Files with this license:
- wrgif.c [25:30]
+ src/wrgif.c [25:30]
KEEP BSD-3-Clause d9457e4e3957eac6bc3c63d753bb59e3
BELONGS ya.make
@@ -534,19 +660,7 @@ BELONGS ya.make
Match type : TEXT
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [97:119]
-
-KEEP Zlib d955ed8aa78d34e13a45d6a5c53a6a8b
-BELONGS ya.make
- License text:
- - The [zlib License](https://opensource.org/licenses/Zlib)
- Scancode info:
- Original SPDX id: Zlib
- Score : 100.00
- Match type : REFERENCE
- Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
- Files with this license:
- LICENSE.md [17:17]
+ LICENSE.md [100:122]
KEEP Zlib e016c8b3c4399311d17cf74e14e4c31b
BELONGS ya.make
@@ -558,28 +672,28 @@ BELONGS ya.make
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
simd/arm/aarch32/jccolext-neon.c [7:21]
- simd/arm/aarch32/jchuff-neon.c [6:20]
+ simd/arm/aarch32/jchuff-neon.c [7:21]
simd/arm/aarch32/jsimd_neon.S [12:26]
simd/arm/aarch64/jccolext-neon.c [6:20]
simd/arm/aarch64/jchuff-neon.c [7:21]
simd/arm/aarch64/jsimd_neon.S [13:27]
simd/arm/align.h [4:18]
simd/arm/jccolor-neon.c [7:21]
- simd/arm/jcgray-neon.c [6:20]
+ simd/arm/jcgray-neon.c [7:21]
simd/arm/jcgryext-neon.c [6:20]
- simd/arm/jcphuff-neon.c [6:20]
- simd/arm/jcsample-neon.c [6:20]
+ simd/arm/jcphuff-neon.c [8:22]
+ simd/arm/jcsample-neon.c [7:21]
simd/arm/jdcolext-neon.c [7:21]
- simd/arm/jdcolor-neon.c [6:20]
- simd/arm/jdmerge-neon.c [6:20]
+ simd/arm/jdcolor-neon.c [7:21]
+ simd/arm/jdmerge-neon.c [7:21]
simd/arm/jdmrgext-neon.c [7:21]
simd/arm/jdsample-neon.c [7:21]
- simd/arm/jfdctfst-neon.c [6:20]
+ simd/arm/jfdctfst-neon.c [7:21]
simd/arm/jfdctint-neon.c [7:21]
- simd/arm/jidctfst-neon.c [6:20]
+ simd/arm/jidctfst-neon.c [7:21]
simd/arm/jidctint-neon.c [7:21]
simd/arm/jidctred-neon.c [7:21]
- simd/arm/jquanti-neon.c [6:20]
+ simd/arm/jquanti-neon.c [7:21]
simd/arm/neon-compat.h [5:19]
KEEP Libpbm e450a16e6dcc10f1721ab5ee51897340
@@ -591,8 +705,8 @@ BELONGS ya.make
Match type : TEXT
Links : http://web.mit.edu/tex/fontutil/fontutils-0.6/pbm/libpbm1.c, https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/licenses/libpbm.LICENSE
Files with this license:
- rdcolmap.c [33:38]
- rdppm.c [35:40]
+ src/rdcolmap.c [37:42]
+ src/rdppm.c [36:41]
KEEP Zlib e4be14a7c287c27d28e8f07bf3795a43
BELONGS ya.make
@@ -604,7 +718,7 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- LICENSE.md [125:125]
+ LICENSE.md [128:128]
KEEP IJG eacab87ea58123f318c9a6b4b065125e
BELONGS ya.make
@@ -629,7 +743,7 @@ BELONGS ya.make
Match type : TAG
Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
Files with this license:
- LICENSE.md [87:88]
+ LICENSE.md [90:91]
KEEP BSD-3-Clause f3fe094edad919ad2298437096b480ef
BELONGS ya.make
@@ -642,11 +756,23 @@ BELONGS ya.make
Match type : REFERENCE
Links : http://www.opensource.org/licenses/BSD-3-Clause, https://spdx.org/licenses/BSD-3-Clause
Files with this license:
- LICENSE.md [68:69]
+ LICENSE.md [71:72]
+
+KEEP Zlib fe6914097b02050a3eed2bbcd16659ac
+BELONGS ya.make
+ License text:
+ [zlib License](https://opensource.org/licenses/Zlib), but in the context of
+ Scancode info:
+ Original SPDX id: Zlib
+ Score : 100.00
+ Match type : REFERENCE
+ Links : http://www.gzip.org/zlib/zlib_license.html, http://www.zlib.net/, https://spdx.org/licenses/Zlib
+ Files with this license:
+ LICENSE.md [12:12]
KEEP Zlib fe97964e6f5a4e0cdab61e2d6f2ba391
BELONGS ya.make
-FILE_IGNORE simd/nasm/jsimdext.inc found in files: simd/i386/jccolext-avx2.asm at line 9, simd/i386/jccolext-mmx.asm at line 9, simd/i386/jccolext-sse2.asm at line 8, simd/i386/jccolor-avx2.asm at line 9, simd/i386/jccolor-mmx.asm at line 9, simd/i386/jccolor-sse2.asm at line 8, simd/i386/jcgray-avx2.asm at line 9, simd/i386/jcgray-mmx.asm at line 9, simd/i386/jcgray-sse2.asm at line 8, simd/i386/jcgryext-avx2.asm at line 9, simd/i386/jcgryext-mmx.asm at line 9, simd/i386/jcgryext-sse2.asm at line 8, simd/i386/jchuff-sse2.asm at line 10, simd/i386/jcphuff-sse2.asm at line 8, simd/i386/jcsample-avx2.asm at line 10, simd/i386/jcsample-mmx.asm at line 9, simd/i386/jcsample-sse2.asm at line 9, simd/i386/jdcolext-avx2.asm at line 10, simd/i386/jdcolext-mmx.asm at line 9, simd/i386/jdcolext-sse2.asm at line 9, simd/i386/jdcolor-avx2.asm at line 10, simd/i386/jdcolor-mmx.asm at line 9, simd/i386/jdcolor-sse2.asm at line 9, simd/i386/jdmerge-avx2.asm at line 10, simd/i386/jdmerge-mmx.asm at line 9, simd/i386/jdmerge-sse2.asm at line 9, simd/i386/jdmrgext-avx2.asm at line 10, simd/i386/jdmrgext-mmx.asm at line 9, simd/i386/jdmrgext-sse2.asm at line 9, simd/i386/jdsample-avx2.asm at line 10, simd/i386/jdsample-mmx.asm at line 9, simd/i386/jdsample-sse2.asm at line 9, simd/i386/jfdctflt-3dn.asm at line 9, simd/i386/jfdctflt-sse.asm at line 9, simd/i386/jfdctfst-mmx.asm at line 9, simd/i386/jfdctfst-sse2.asm at line 9, simd/i386/jfdctint-avx2.asm at line 9, simd/i386/jfdctint-mmx.asm at line 9, simd/i386/jfdctint-sse2.asm at line 9, simd/i386/jidctflt-3dn.asm at line 9, simd/i386/jidctflt-sse.asm at line 9, simd/i386/jidctflt-sse2.asm at line 9, simd/i386/jidctfst-mmx.asm at line 9, simd/i386/jidctfst-sse2.asm at line 9, simd/i386/jidctint-avx2.asm at line 9, simd/i386/jidctint-mmx.asm at line 9, simd/i386/jidctint-sse2.asm at line 9, simd/i386/jidctred-mmx.asm at line 9, simd/i386/jidctred-sse2.asm at line 9, simd/i386/jquant-3dn.asm at line 9, simd/i386/jquant-mmx.asm at line 9, simd/i386/jquant-sse.asm at line 9, simd/i386/jquantf-sse2.asm at line 9, simd/i386/jquanti-avx2.asm at line 10, simd/i386/jquanti-sse2.asm at line 9, simd/i386/jsimdcpu.asm at line 9, simd/nasm/jcolsamp.inc at line 9, simd/nasm/jdct.inc at line 9, simd/x86_64/jccolext-avx2.asm at line 10, simd/x86_64/jccolext-sse2.asm at line 9, simd/x86_64/jccolor-avx2.asm at line 9, simd/x86_64/jccolor-sse2.asm at line 8, simd/x86_64/jcgray-avx2.asm at line 9, simd/x86_64/jcgray-sse2.asm at line 8, simd/x86_64/jcgryext-avx2.asm at line 10, simd/x86_64/jcgryext-sse2.asm at line 9, simd/x86_64/jchuff-sse2.asm at line 10, simd/x86_64/jcphuff-sse2.asm at line 9, simd/x86_64/jcsample-avx2.asm at line 11, simd/x86_64/jcsample-sse2.asm at line 10, simd/x86_64/jdcolext-avx2.asm at line 11, simd/x86_64/jdcolext-sse2.asm at line 10, simd/x86_64/jdcolor-avx2.asm at line 10, simd/x86_64/jdcolor-sse2.asm at line 9, simd/x86_64/jdmerge-avx2.asm at line 10, simd/x86_64/jdmerge-sse2.asm at line 9, simd/x86_64/jdmrgext-avx2.asm at line 11, simd/x86_64/jdmrgext-sse2.asm at line 10, simd/x86_64/jdsample-avx2.asm at line 11, simd/x86_64/jdsample-sse2.asm at line 10, simd/x86_64/jfdctflt-sse.asm at line 9, simd/x86_64/jfdctfst-sse2.asm at line 9, simd/x86_64/jfdctint-avx2.asm at line 9, simd/x86_64/jfdctint-sse2.asm at line 9, simd/x86_64/jidctflt-sse2.asm at line 10, simd/x86_64/jidctfst-sse2.asm at line 10, simd/x86_64/jidctint-avx2.asm at line 10, simd/x86_64/jidctint-sse2.asm at line 10, simd/x86_64/jidctred-sse2.asm at line 10, simd/x86_64/jquantf-sse2.asm at line 10, simd/x86_64/jquanti-avx2.asm at line 11, simd/x86_64/jquanti-sse2.asm at line 10, simd/x86_64/jsimdcpu.asm at line 10
+FILE_IGNORE simd/nasm/jsimdext.inc found in files: simd/i386/jccolext-avx2.asm at line 9, simd/i386/jccolext-mmx.asm at line 9, simd/i386/jccolext-sse2.asm at line 8, simd/i386/jccolor-avx2.asm at line 9, simd/i386/jccolor-mmx.asm at line 9, simd/i386/jccolor-sse2.asm at line 8, simd/i386/jcgray-avx2.asm at line 9, simd/i386/jcgray-mmx.asm at line 9, simd/i386/jcgray-sse2.asm at line 8, simd/i386/jcgryext-avx2.asm at line 9, simd/i386/jcgryext-mmx.asm at line 9, simd/i386/jcgryext-sse2.asm at line 8, simd/i386/jchuff-sse2.asm at line 10, simd/i386/jcphuff-sse2.asm at line 8, simd/i386/jcsample-avx2.asm at line 10, simd/i386/jcsample-mmx.asm at line 9, simd/i386/jcsample-sse2.asm at line 9, simd/i386/jdcolext-avx2.asm at line 10, simd/i386/jdcolext-mmx.asm at line 9, simd/i386/jdcolext-sse2.asm at line 9, simd/i386/jdcolor-avx2.asm at line 10, simd/i386/jdcolor-mmx.asm at line 9, simd/i386/jdcolor-sse2.asm at line 9, simd/i386/jdmerge-avx2.asm at line 10, simd/i386/jdmerge-mmx.asm at line 9, simd/i386/jdmerge-sse2.asm at line 9, simd/i386/jdmrgext-avx2.asm at line 10, simd/i386/jdmrgext-mmx.asm at line 9, simd/i386/jdmrgext-sse2.asm at line 9, simd/i386/jdsample-avx2.asm at line 10, simd/i386/jdsample-mmx.asm at line 9, simd/i386/jdsample-sse2.asm at line 9, simd/i386/jfdctflt-3dn.asm at line 9, simd/i386/jfdctflt-sse.asm at line 9, simd/i386/jfdctfst-mmx.asm at line 9, simd/i386/jfdctfst-sse2.asm at line 9, simd/i386/jfdctint-avx2.asm at line 9, simd/i386/jfdctint-mmx.asm at line 9, simd/i386/jfdctint-sse2.asm at line 9, simd/i386/jidctflt-3dn.asm at line 9, simd/i386/jidctflt-sse.asm at line 9, simd/i386/jidctflt-sse2.asm at line 9, simd/i386/jidctfst-mmx.asm at line 9, simd/i386/jidctfst-sse2.asm at line 9, simd/i386/jidctint-avx2.asm at line 9, simd/i386/jidctint-mmx.asm at line 9, simd/i386/jidctint-sse2.asm at line 9, simd/i386/jidctred-mmx.asm at line 9, simd/i386/jidctred-sse2.asm at line 9, simd/i386/jquant-3dn.asm at line 9, simd/i386/jquant-mmx.asm at line 9, simd/i386/jquant-sse.asm at line 9, simd/i386/jquantf-sse2.asm at line 9, simd/i386/jquanti-avx2.asm at line 10, simd/i386/jquanti-sse2.asm at line 9, simd/i386/jsimdcpu.asm at line 9, simd/nasm/jcolsamp.inc at line 9, simd/nasm/jdct.inc at line 9, simd/x86_64/jccolext-avx2.asm at line 11, simd/x86_64/jccolext-sse2.asm at line 10, simd/x86_64/jccolor-avx2.asm at line 9, simd/x86_64/jccolor-sse2.asm at line 8, simd/x86_64/jcgray-avx2.asm at line 9, simd/x86_64/jcgray-sse2.asm at line 8, simd/x86_64/jcgryext-avx2.asm at line 11, simd/x86_64/jcgryext-sse2.asm at line 10, simd/x86_64/jchuff-sse2.asm at line 11, simd/x86_64/jcphuff-sse2.asm at line 11, simd/x86_64/jcsample-avx2.asm at line 11, simd/x86_64/jcsample-sse2.asm at line 10, simd/x86_64/jdcolext-avx2.asm at line 12, simd/x86_64/jdcolext-sse2.asm at line 11, simd/x86_64/jdcolor-avx2.asm at line 10, simd/x86_64/jdcolor-sse2.asm at line 9, simd/x86_64/jdmerge-avx2.asm at line 10, simd/x86_64/jdmerge-sse2.asm at line 9, simd/x86_64/jdmrgext-avx2.asm at line 12, simd/x86_64/jdmrgext-sse2.asm at line 11, simd/x86_64/jdsample-avx2.asm at line 12, simd/x86_64/jdsample-sse2.asm at line 11, simd/x86_64/jfdctflt-sse.asm at line 10, simd/x86_64/jfdctfst-sse2.asm at line 10, simd/x86_64/jfdctint-avx2.asm at line 9, simd/x86_64/jfdctint-sse2.asm at line 10, simd/x86_64/jidctflt-sse2.asm at line 11, simd/x86_64/jidctfst-sse2.asm at line 11, simd/x86_64/jidctint-avx2.asm at line 10, simd/x86_64/jidctint-sse2.asm at line 11, simd/x86_64/jidctred-sse2.asm at line 11, simd/x86_64/jquantf-sse2.asm at line 10, simd/x86_64/jquanti-avx2.asm at line 11, simd/x86_64/jquanti-sse2.asm at line 10, simd/x86_64/jsimdcpu.asm at line 11
License text:
; For conditions of distribution and use, see copyright notice in jsimdext.inc
Scancode info:
@@ -713,38 +839,38 @@ FILE_IGNORE simd/nasm/jsimdext.inc found in files: simd/i386/jccolext-avx2.asm a
simd/i386/jsimdcpu.asm [9:9]
simd/nasm/jcolsamp.inc [9:9]
simd/nasm/jdct.inc [9:9]
- simd/x86_64/jccolext-avx2.asm [10:10]
- simd/x86_64/jccolext-sse2.asm [9:9]
+ simd/x86_64/jccolext-avx2.asm [11:11]
+ simd/x86_64/jccolext-sse2.asm [10:10]
simd/x86_64/jccolor-avx2.asm [9:9]
simd/x86_64/jccolor-sse2.asm [8:8]
simd/x86_64/jcgray-avx2.asm [9:9]
simd/x86_64/jcgray-sse2.asm [8:8]
- simd/x86_64/jcgryext-avx2.asm [10:10]
- simd/x86_64/jcgryext-sse2.asm [9:9]
- simd/x86_64/jchuff-sse2.asm [10:10]
- simd/x86_64/jcphuff-sse2.asm [9:9]
+ simd/x86_64/jcgryext-avx2.asm [11:11]
+ simd/x86_64/jcgryext-sse2.asm [10:10]
+ simd/x86_64/jchuff-sse2.asm [11:11]
+ simd/x86_64/jcphuff-sse2.asm [11:11]
simd/x86_64/jcsample-avx2.asm [11:11]
simd/x86_64/jcsample-sse2.asm [10:10]
- simd/x86_64/jdcolext-avx2.asm [11:11]
- simd/x86_64/jdcolext-sse2.asm [10:10]
+ simd/x86_64/jdcolext-avx2.asm [12:12]
+ simd/x86_64/jdcolext-sse2.asm [11:11]
simd/x86_64/jdcolor-avx2.asm [10:10]
simd/x86_64/jdcolor-sse2.asm [9:9]
simd/x86_64/jdmerge-avx2.asm [10:10]
simd/x86_64/jdmerge-sse2.asm [9:9]
- simd/x86_64/jdmrgext-avx2.asm [11:11]
- simd/x86_64/jdmrgext-sse2.asm [10:10]
- simd/x86_64/jdsample-avx2.asm [11:11]
- simd/x86_64/jdsample-sse2.asm [10:10]
- simd/x86_64/jfdctflt-sse.asm [9:9]
- simd/x86_64/jfdctfst-sse2.asm [9:9]
+ simd/x86_64/jdmrgext-avx2.asm [12:12]
+ simd/x86_64/jdmrgext-sse2.asm [11:11]
+ simd/x86_64/jdsample-avx2.asm [12:12]
+ simd/x86_64/jdsample-sse2.asm [11:11]
+ simd/x86_64/jfdctflt-sse.asm [10:10]
+ simd/x86_64/jfdctfst-sse2.asm [10:10]
simd/x86_64/jfdctint-avx2.asm [9:9]
- simd/x86_64/jfdctint-sse2.asm [9:9]
- simd/x86_64/jidctflt-sse2.asm [10:10]
- simd/x86_64/jidctfst-sse2.asm [10:10]
+ simd/x86_64/jfdctint-sse2.asm [10:10]
+ simd/x86_64/jidctflt-sse2.asm [11:11]
+ simd/x86_64/jidctfst-sse2.asm [11:11]
simd/x86_64/jidctint-avx2.asm [10:10]
- simd/x86_64/jidctint-sse2.asm [10:10]
- simd/x86_64/jidctred-sse2.asm [10:10]
+ simd/x86_64/jidctint-sse2.asm [11:11]
+ simd/x86_64/jidctred-sse2.asm [11:11]
simd/x86_64/jquantf-sse2.asm [10:10]
simd/x86_64/jquanti-avx2.asm [11:11]
simd/x86_64/jquanti-sse2.asm [10:10]
- simd/x86_64/jsimdcpu.asm [10:10]
+ simd/x86_64/jsimdcpu.asm [11:11]
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/issue817-add-wrappers.patch b/contrib/libs/libjpeg-turbo/.yandex_meta/issue817-add-wrappers.patch
new file mode 100644
index 00000000000..951535d6a94
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/.yandex_meta/issue817-add-wrappers.patch
@@ -0,0 +1,2128 @@
+From 51cee0362998ec6f1eabac1e795f3b6e3ee639ea Mon Sep 17 00:00:00 2001
+From: DRC <[email protected]>
+Date: Fri, 13 Jun 2025 14:52:09 -0400
+Subject: [PATCH] Build: Use wrappers rather than CMake object libs
+
+Some downstream projects need to adapt the libjpeg-turbo source code to
+non-CMake build systems, and the use of CMake object libraries made that
+difficult. Referring to #754, the use of CMake object libraries also
+caused the libjpeg-turbo libraries to contain duplicate object names,
+which caused problems with certain development tools. This commit
+modifies the build system so that it uses wrappers, rather than CMake
+object libraries, to compile source files for multiple data precisions.
+For convenience, the wrappers are included in the source tree, but they
+can be re-generated by building the "wrappers" target.
+
+In addition to facilitating downstream integration, using wrappers
+improves code readability, since multiple data precisions are now
+handled at the source code level instead of at the build system level.
+
+Since this will be pushed to a bug-fix release, the goal was to avoid
+changing any existing source code. A future major release of
+libjpeg-turbo may restructure the libjpeg API source code so that only
+the functions that need to be compiled for multiple data precisions are
+wrapped. (That is how the TurboJPEG API source code is structured.)
+
+Closes #817
+---
+ CMakeLists.txt | 138 ++++++++++++----------------
+ cmakescripts/GenerateWrappers.cmake | 37 ++++++++
+ sharedlib/CMakeLists.txt | 32 ++-----
+ src/wrapper/jcapistd-12.c | 14 +++
+ src/wrapper/jcapistd-16.c | 14 +++
+ src/wrapper/jcapistd-8.c | 14 +++
+ src/wrapper/jccoefct-12.c | 14 +++
+ src/wrapper/jccoefct-8.c | 14 +++
+ src/wrapper/jccolor-12.c | 14 +++
+ src/wrapper/jccolor-16.c | 14 +++
+ src/wrapper/jccolor-8.c | 14 +++
+ src/wrapper/jcdctmgr-12.c | 14 +++
+ src/wrapper/jcdctmgr-8.c | 14 +++
+ src/wrapper/jcdiffct-12.c | 14 +++
+ src/wrapper/jcdiffct-16.c | 14 +++
+ src/wrapper/jcdiffct-8.c | 14 +++
+ src/wrapper/jclossls-12.c | 14 +++
+ src/wrapper/jclossls-16.c | 14 +++
+ src/wrapper/jclossls-8.c | 14 +++
+ src/wrapper/jcmainct-12.c | 14 +++
+ src/wrapper/jcmainct-16.c | 14 +++
+ src/wrapper/jcmainct-8.c | 14 +++
+ src/wrapper/jcprepct-12.c | 14 +++
+ src/wrapper/jcprepct-16.c | 14 +++
+ src/wrapper/jcprepct-8.c | 14 +++
+ src/wrapper/jcsample-12.c | 14 +++
+ src/wrapper/jcsample-16.c | 14 +++
+ src/wrapper/jcsample-8.c | 14 +++
+ src/wrapper/jdapistd-12.c | 14 +++
+ src/wrapper/jdapistd-16.c | 14 +++
+ src/wrapper/jdapistd-8.c | 14 +++
+ src/wrapper/jdcoefct-12.c | 14 +++
+ src/wrapper/jdcoefct-8.c | 14 +++
+ src/wrapper/jdcolor-12.c | 14 +++
+ src/wrapper/jdcolor-16.c | 14 +++
+ src/wrapper/jdcolor-8.c | 14 +++
+ src/wrapper/jddctmgr-12.c | 14 +++
+ src/wrapper/jddctmgr-8.c | 14 +++
+ src/wrapper/jddiffct-12.c | 14 +++
+ src/wrapper/jddiffct-16.c | 14 +++
+ src/wrapper/jddiffct-8.c | 14 +++
+ src/wrapper/jdlossls-12.c | 14 +++
+ src/wrapper/jdlossls-16.c | 14 +++
+ src/wrapper/jdlossls-8.c | 14 +++
+ src/wrapper/jdmainct-12.c | 14 +++
+ src/wrapper/jdmainct-16.c | 14 +++
+ src/wrapper/jdmainct-8.c | 14 +++
+ src/wrapper/jdmerge-12.c | 14 +++
+ src/wrapper/jdmerge-8.c | 14 +++
+ src/wrapper/jdpostct-12.c | 14 +++
+ src/wrapper/jdpostct-16.c | 14 +++
+ src/wrapper/jdpostct-8.c | 14 +++
+ src/wrapper/jdsample-12.c | 14 +++
+ src/wrapper/jdsample-16.c | 14 +++
+ src/wrapper/jdsample-8.c | 14 +++
+ src/wrapper/jfdctfst-12.c | 14 +++
+ src/wrapper/jfdctfst-8.c | 14 +++
+ src/wrapper/jfdctint-12.c | 14 +++
+ src/wrapper/jfdctint-8.c | 14 +++
+ src/wrapper/jidctflt-12.c | 14 +++
+ src/wrapper/jidctflt-8.c | 14 +++
+ src/wrapper/jidctfst-12.c | 14 +++
+ src/wrapper/jidctfst-8.c | 14 +++
+ src/wrapper/jidctint-12.c | 14 +++
+ src/wrapper/jidctint-8.c | 14 +++
+ src/wrapper/jidctred-12.c | 14 +++
+ src/wrapper/jidctred-8.c | 14 +++
+ src/wrapper/jquant1-12.c | 14 +++
+ src/wrapper/jquant1-8.c | 14 +++
+ src/wrapper/jquant2-12.c | 14 +++
+ src/wrapper/jquant2-8.c | 14 +++
+ src/wrapper/jutils-12.c | 14 +++
+ src/wrapper/jutils-16.c | 14 +++
+ src/wrapper/jutils-8.c | 14 +++
+ src/wrapper/rdcolmap-12.c | 14 +++
+ src/wrapper/rdcolmap-8.c | 14 +++
+ src/wrapper/rdppm-12.c | 14 +++
+ src/wrapper/rdppm-16.c | 14 +++
+ src/wrapper/rdppm-8.c | 14 +++
+ src/wrapper/template.c | 14 +++
+ src/wrapper/wrgif-12.c | 14 +++
+ src/wrapper/wrgif-8.c | 14 +++
+ src/wrapper/wrppm-12.c | 14 +++
+ src/wrapper/wrppm-16.c | 14 +++
+ src/wrapper/wrppm-8.c | 14 +++
+ 86 files changed, 1259 insertions(+), 101 deletions(-)
+ create mode 100644 cmakescripts/GenerateWrappers.cmake
+ create mode 100644 src/wrapper/jcapistd-12.c
+ create mode 100644 src/wrapper/jcapistd-16.c
+ create mode 100644 src/wrapper/jcapistd-8.c
+ create mode 100644 src/wrapper/jccoefct-12.c
+ create mode 100644 src/wrapper/jccoefct-8.c
+ create mode 100644 src/wrapper/jccolor-12.c
+ create mode 100644 src/wrapper/jccolor-16.c
+ create mode 100644 src/wrapper/jccolor-8.c
+ create mode 100644 src/wrapper/jcdctmgr-12.c
+ create mode 100644 src/wrapper/jcdctmgr-8.c
+ create mode 100644 src/wrapper/jcdiffct-12.c
+ create mode 100644 src/wrapper/jcdiffct-16.c
+ create mode 100644 src/wrapper/jcdiffct-8.c
+ create mode 100644 src/wrapper/jclossls-12.c
+ create mode 100644 src/wrapper/jclossls-16.c
+ create mode 100644 src/wrapper/jclossls-8.c
+ create mode 100644 src/wrapper/jcmainct-12.c
+ create mode 100644 src/wrapper/jcmainct-16.c
+ create mode 100644 src/wrapper/jcmainct-8.c
+ create mode 100644 src/wrapper/jcprepct-12.c
+ create mode 100644 src/wrapper/jcprepct-16.c
+ create mode 100644 src/wrapper/jcprepct-8.c
+ create mode 100644 src/wrapper/jcsample-12.c
+ create mode 100644 src/wrapper/jcsample-16.c
+ create mode 100644 src/wrapper/jcsample-8.c
+ create mode 100644 src/wrapper/jdapistd-12.c
+ create mode 100644 src/wrapper/jdapistd-16.c
+ create mode 100644 src/wrapper/jdapistd-8.c
+ create mode 100644 src/wrapper/jdcoefct-12.c
+ create mode 100644 src/wrapper/jdcoefct-8.c
+ create mode 100644 src/wrapper/jdcolor-12.c
+ create mode 100644 src/wrapper/jdcolor-16.c
+ create mode 100644 src/wrapper/jdcolor-8.c
+ create mode 100644 src/wrapper/jddctmgr-12.c
+ create mode 100644 src/wrapper/jddctmgr-8.c
+ create mode 100644 src/wrapper/jddiffct-12.c
+ create mode 100644 src/wrapper/jddiffct-16.c
+ create mode 100644 src/wrapper/jddiffct-8.c
+ create mode 100644 src/wrapper/jdlossls-12.c
+ create mode 100644 src/wrapper/jdlossls-16.c
+ create mode 100644 src/wrapper/jdlossls-8.c
+ create mode 100644 src/wrapper/jdmainct-12.c
+ create mode 100644 src/wrapper/jdmainct-16.c
+ create mode 100644 src/wrapper/jdmainct-8.c
+ create mode 100644 src/wrapper/jdmerge-12.c
+ create mode 100644 src/wrapper/jdmerge-8.c
+ create mode 100644 src/wrapper/jdpostct-12.c
+ create mode 100644 src/wrapper/jdpostct-16.c
+ create mode 100644 src/wrapper/jdpostct-8.c
+ create mode 100644 src/wrapper/jdsample-12.c
+ create mode 100644 src/wrapper/jdsample-16.c
+ create mode 100644 src/wrapper/jdsample-8.c
+ create mode 100644 src/wrapper/jfdctfst-12.c
+ create mode 100644 src/wrapper/jfdctfst-8.c
+ create mode 100644 src/wrapper/jfdctint-12.c
+ create mode 100644 src/wrapper/jfdctint-8.c
+ create mode 100644 src/wrapper/jidctflt-12.c
+ create mode 100644 src/wrapper/jidctflt-8.c
+ create mode 100644 src/wrapper/jidctfst-12.c
+ create mode 100644 src/wrapper/jidctfst-8.c
+ create mode 100644 src/wrapper/jidctint-12.c
+ create mode 100644 src/wrapper/jidctint-8.c
+ create mode 100644 src/wrapper/jidctred-12.c
+ create mode 100644 src/wrapper/jidctred-8.c
+ create mode 100644 src/wrapper/jquant1-12.c
+ create mode 100644 src/wrapper/jquant1-8.c
+ create mode 100644 src/wrapper/jquant2-12.c
+ create mode 100644 src/wrapper/jquant2-8.c
+ create mode 100644 src/wrapper/jutils-12.c
+ create mode 100644 src/wrapper/jutils-16.c
+ create mode 100644 src/wrapper/jutils-8.c
+ create mode 100644 src/wrapper/rdcolmap-12.c
+ create mode 100644 src/wrapper/rdcolmap-8.c
+ create mode 100644 src/wrapper/rdppm-12.c
+ create mode 100644 src/wrapper/rdppm-16.c
+ create mode 100644 src/wrapper/rdppm-8.c
+ create mode 100644 src/wrapper/template.c
+ create mode 100644 src/wrapper/wrgif-12.c
+ create mode 100644 src/wrapper/wrgif-8.c
+ create mode 100644 src/wrapper/wrppm-12.c
+ create mode 100644 src/wrapper/wrppm-16.c
+ create mode 100644 src/wrapper/wrppm-8.c
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b8e76a59d..23aa2397b 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -617,20 +617,48 @@ if(CMAKE_EXECUTABLE_SUFFIX_TMP)
+ endif()
+ message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}")
+
+-set(JPEG16_SOURCES src/jcapistd.c src/jccolor.c src/jcdiffct.c src/jclossls.c
+- src/jcmainct.c src/jcprepct.c src/jcsample.c src/jdapistd.c src/jdcolor.c
+- src/jddiffct.c src/jdlossls.c src/jdmainct.c src/jdpostct.c src/jdsample.c
+- src/jutils.c)
+-set(JPEG12_SOURCES ${JPEG16_SOURCES} src/jccoefct.c src/jcdctmgr.c
+- src/jdcoefct.c src/jddctmgr.c src/jdmerge.c src/jfdctfst.c src/jfdctint.c
+- src/jidctflt.c src/jidctfst.c src/jidctint.c src/jidctred.c src/jquant1.c
+- src/jquant2.c)
+-set(JPEG_SOURCES ${JPEG12_SOURCES} src/jcapimin.c src/jchuff.c src/jcicc.c
+- src/jcinit.c src/jclhuff.c src/jcmarker.c src/jcmaster.c src/jcomapi.c
+- src/jcparam.c src/jcphuff.c src/jctrans.c src/jdapimin.c src/jdatadst.c
+- src/jdatasrc.c src/jdhuff.c src/jdicc.c src/jdinput.c src/jdlhuff.c
+- src/jdmarker.c src/jdmaster.c src/jdphuff.c src/jdtrans.c src/jerror.c
+- src/jfdctflt.c src/jmemmgr.c src/jmemnobs.c src/jpeg_nbits.c)
++add_custom_target(wrappers COMMAND ${CMAKE_COMMAND}
++ -DSOURCE_DIR=${CMAKE_SOURCE_DIR}/src/wrapper
++ -P ${CMAKE_CURRENT_SOURCE_DIR}/cmakescripts/GenerateWrappers.cmake)
++
++set(JPEG_SOURCES src/jcapimin.c
++ src/wrapper/jcapistd-8.c src/wrapper/jcapistd-12.c src/wrapper/jcapistd-16.c
++ src/wrapper/jccoefct-8.c src/wrapper/jccoefct-12.c
++ src/wrapper/jccolor-8.c src/wrapper/jccolor-12.c src/wrapper/jccolor-16.c
++ src/wrapper/jcdctmgr-8.c src/wrapper/jcdctmgr-12.c
++ src/wrapper/jcdiffct-8.c src/wrapper/jcdiffct-12.c src/wrapper/jcdiffct-16.c
++ src/jchuff.c src/jcicc.c src/jcinit.c src/jclhuff.c
++ src/wrapper/jclossls-8.c src/wrapper/jclossls-12.c src/wrapper/jclossls-16.c
++ src/wrapper/jcmainct-8.c src/wrapper/jcmainct-12.c src/wrapper/jcmainct-16.c
++ src/jcmarker.c src/jcmaster.c src/jcomapi.c src/jcparam.c src/jcphuff.c
++ src/wrapper/jcprepct-8.c src/wrapper/jcprepct-12.c src/wrapper/jcprepct-16.c
++ src/wrapper/jcsample-8.c src/wrapper/jcsample-12.c src/wrapper/jcsample-16.c
++ src/jctrans.c src/jdapimin.c
++ src/wrapper/jdapistd-8.c src/wrapper/jdapistd-12.c src/wrapper/jdapistd-16.c
++ src/jdatadst.c src/jdatasrc.c
++ src/wrapper/jdcoefct-8.c src/wrapper/jdcoefct-12.c
++ src/wrapper/jdcolor-8.c src/wrapper/jdcolor-12.c src/wrapper/jdcolor-16.c
++ src/wrapper/jddctmgr-8.c src/wrapper/jddctmgr-12.c
++ src/wrapper/jddiffct-8.c src/wrapper/jddiffct-12.c src/wrapper/jddiffct-16.c
++ src/jdhuff.c src/jdicc.c src/jdinput.c src/jdlhuff.c
++ src/wrapper/jdlossls-8.c src/wrapper/jdlossls-12.c src/wrapper/jdlossls-16.c
++ src/wrapper/jdmainct-8.c src/wrapper/jdmainct-12.c src/wrapper/jdmainct-16.c
++ src/jdmarker.c src/jdmaster.c
++ src/wrapper/jdmerge-8.c src/wrapper/jdmerge-12.c
++ src/jdphuff.c
++ src/wrapper/jdpostct-8.c src/wrapper/jdpostct-12.c src/wrapper/jdpostct-16.c
++ src/wrapper/jdsample-8.c src/wrapper/jdsample-12.c src/wrapper/jdsample-16.c
++ src/jdtrans.c src/jerror.c src/jfdctflt.c
++ src/wrapper/jfdctfst-8.c src/wrapper/jfdctfst-12.c
++ src/wrapper/jfdctint-8.c src/wrapper/jfdctint-12.c
++ src/wrapper/jidctflt-8.c src/wrapper/jidctflt-12.c
++ src/wrapper/jidctfst-8.c src/wrapper/jidctfst-12.c
++ src/wrapper/jidctint-8.c src/wrapper/jidctint-12.c
++ src/wrapper/jidctred-8.c src/wrapper/jidctred-12.c
++ src/jmemmgr.c src/jmemnobs.c src/jpeg_nbits.c
++ src/wrapper/jquant1-8.c src/wrapper/jquant1-12.c
++ src/wrapper/jquant2-8.c src/wrapper/jquant2-12.c
++ src/wrapper/jutils-8.c src/wrapper/jutils-12.c src/wrapper/jutils-16.c)
+
+ if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
+ set(JPEG_SOURCES ${JPEG_SOURCES} src/jaricom.c)
+@@ -671,40 +699,25 @@ if(WITH_JAVA)
+ endif()
+
+ if(ENABLE_SHARED)
+- # Compile a separate version of these source files with 12-bit and 16-bit
+- # data precision.
+- add_library(jpeg12 OBJECT ${JPEG12_SOURCES})
+- set_property(TARGET jpeg12 PROPERTY COMPILE_FLAGS "-DBITS_IN_JSAMPLE=12")
+- set_target_properties(jpeg12 PROPERTIES POSITION_INDEPENDENT_CODE 1)
+- add_library(jpeg16 OBJECT ${JPEG16_SOURCES})
+- set_property(TARGET jpeg16 PROPERTY COMPILE_FLAGS "-DBITS_IN_JSAMPLE=16")
+- set_target_properties(jpeg16 PROPERTIES POSITION_INDEPENDENT_CODE 1)
+ add_subdirectory(sharedlib)
+ endif()
+
+ if(ENABLE_STATIC)
+- # Compile a separate version of these source files with 12-bit and 16-bit
+- # data precision.
+- add_library(jpeg12-static OBJECT ${JPEG12_SOURCES})
+- set_property(TARGET jpeg12-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=12")
+- add_library(jpeg16-static OBJECT ${JPEG16_SOURCES})
+- set_property(TARGET jpeg16-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=16")
+ add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_TARGET_OBJECTS}
+- ${SIMD_OBJS} $<TARGET_OBJECTS:jpeg12-static>
+- $<TARGET_OBJECTS:jpeg16-static>)
++ ${SIMD_OBJS})
+ if(NOT MSVC_LIKE)
+ set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
+ endif()
+ endif()
+
+ if(WITH_TURBOJPEG)
++ set(TURBOJPEG_SOURCES ${JPEG_SOURCES} ${SIMD_TARGET_OBJECTS} ${SIMD_OBJS}
++ src/turbojpeg.c src/transupp.c src/jdatadst-tj.c src/jdatasrc-tj.c
++ src/rdbmp.c
++ src/wrapper/rdppm-8.c src/wrapper/rdppm-12.c src/wrapper/rdppm-16.c
++ src/wrbmp.c
++ src/wrapper/wrppm-8.c src/wrapper/wrppm-12.c src/wrapper/wrppm-16.c)
+ if(ENABLE_SHARED)
+- set(TURBOJPEG_SOURCES ${JPEG_SOURCES} ${SIMD_TARGET_OBJECTS} ${SIMD_OBJS}
+- src/turbojpeg.c src/transupp.c src/jdatadst-tj.c src/jdatasrc-tj.c
+- src/rdbmp.c src/rdppm.c src/wrbmp.c src/wrppm.c $<TARGET_OBJECTS:jpeg12>
+- $<TARGET_OBJECTS:jpeg16>)
+ set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/src/turbojpeg-mapfile)
+ if(WITH_JAVA)
+ set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} java/turbojpeg-jni.c)
+@@ -717,16 +730,7 @@ if(WITH_TURBOJPEG)
+ set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES}
+ ${CMAKE_BINARY_DIR}/win/turbojpeg.rc)
+ endif()
+- add_library(turbojpeg12 OBJECT src/rdppm.c src/wrppm.c)
+- set_property(TARGET turbojpeg12 PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=12 -DPPM_SUPPORTED")
+- set_target_properties(turbojpeg12 PROPERTIES POSITION_INDEPENDENT_CODE 1)
+- add_library(turbojpeg16 OBJECT src/rdppm.c src/wrppm.c)
+- set_property(TARGET turbojpeg16 PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=16 -DPPM_SUPPORTED")
+- set_target_properties(turbojpeg16 PROPERTIES POSITION_INDEPENDENT_CODE 1)
+- add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES}
+- $<TARGET_OBJECTS:turbojpeg12> $<TARGET_OBJECTS:turbojpeg16>)
++ add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
+ set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS
+ "-DBMP_SUPPORTED -DPPM_SUPPORTED")
+ if(WIN32)
+@@ -773,18 +777,7 @@ if(WITH_TURBOJPEG)
+ endif()
+
+ if(ENABLE_STATIC)
+- add_library(turbojpeg12-static OBJECT src/rdppm.c src/wrppm.c)
+- set_property(TARGET turbojpeg12-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=12 -DPPM_SUPPORTED")
+- add_library(turbojpeg16-static OBJECT src/rdppm.c src/wrppm.c)
+- set_property(TARGET turbojpeg16-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=16 -DPPM_SUPPORTED")
+- add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_TARGET_OBJECTS}
+- ${SIMD_OBJS} src/turbojpeg.c src/transupp.c src/jdatadst-tj.c
+- src/jdatasrc-tj.c src/rdbmp.c src/rdppm.c src/wrbmp.c src/wrppm.c
+- $<TARGET_OBJECTS:jpeg12-static> $<TARGET_OBJECTS:jpeg16-static>
+- $<TARGET_OBJECTS:turbojpeg12-static>
+- $<TARGET_OBJECTS:turbojpeg16-static>)
++ add_library(turbojpeg-static STATIC ${TURBOJPEG_SOURCES})
+ set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS
+ "-DBMP_SUPPORTED -DPPM_SUPPORTED")
+ if(NOT MSVC_LIKE)
+@@ -810,32 +803,19 @@ set(CDJPEG_COMPILE_FLAGS
+ "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
+
+ if(ENABLE_STATIC)
+- # Compile a separate version of these source files with 12-bit and 16-bit
+- # data precision.
+- add_library(cjpeg12-static OBJECT src/rdppm.c)
+- set_property(TARGET cjpeg12-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
+- add_library(cjpeg16-static OBJECT src/rdppm.c)
+- set_property(TARGET cjpeg16-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=16 -DGIF_SUPPORTED -DPPM_SUPPORTED")
+ add_executable(cjpeg-static src/cjpeg.c src/cdjpeg.c src/rdbmp.c src/rdgif.c
+- src/rdppm.c src/rdswitch.c src/rdtarga.c $<TARGET_OBJECTS:cjpeg12-static>
+- $<TARGET_OBJECTS:cjpeg16-static>)
++ src/wrapper/rdppm-8.c src/wrapper/rdppm-12.c src/wrapper/rdppm-16.c
++ src/rdswitch.c src/rdtarga.c)
+ set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
+ ${CDJPEG_COMPILE_FLAGS})
+ target_link_libraries(cjpeg-static jpeg-static)
+
+- # Compile a separate version of these source files with 12-bit and 16-bit
+- # data precision.
+- add_library(djpeg12-static OBJECT src/rdcolmap.c src/wrgif.c src/wrppm.c)
+- set_property(TARGET djpeg12-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
+- add_library(djpeg16-static OBJECT src/wrppm.c)
+- set_property(TARGET djpeg16-static PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=16 -DPPM_SUPPORTED")
+- add_executable(djpeg-static src/djpeg.c src/cdjpeg.c src/rdcolmap.c
+- src/rdswitch.c src/wrbmp.c src/wrgif.c src/wrppm.c src/wrtarga.c
+- $<TARGET_OBJECTS:djpeg12-static> $<TARGET_OBJECTS:djpeg16-static>)
++ add_executable(djpeg-static src/djpeg.c src/cdjpeg.c
++ src/wrapper/rdcolmap-8.c src/wrapper/rdcolmap-12.c
++ src/rdswitch.c src/wrbmp.c
++ src/wrapper/wrgif-8.c src/wrapper/wrgif-12.c
++ src/wrapper/wrppm-8.c src/wrapper/wrppm-12.c src/wrapper/wrppm-16.c
++ src/wrtarga.c)
+ set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
+ ${CDJPEG_COMPILE_FLAGS})
+ target_link_libraries(djpeg-static jpeg-static)
+diff --git a/cmakescripts/GenerateWrappers.cmake b/cmakescripts/GenerateWrappers.cmake
+new file mode 100644
+index 000000000..c698b80b9
+--- /dev/null
++++ b/cmakescripts/GenerateWrappers.cmake
+@@ -0,0 +1,37 @@
++if(NOT DEFINED SOURCE_DIR)
++ message(FATAL_ERROR "SOURCE_DIR must be specified")
++endif()
++
++foreach(FILE jcapistd.c jccolor.c jcdiffct.c jclossls.c jcmainct.c jcprepct.c
++ jcsample.c jdapistd.c jdcolor.c jddiffct.c jdlossls.c jdmainct.c jdpostct.c
++ jdsample.c jutils.c rdppm.c wrppm.c)
++
++ foreach(BITS 8 12 16)
++
++ string(REGEX REPLACE "\\.c" "-${BITS}.c" WRAPPER_FILE ${FILE})
++ if(BITS EQUAL 8)
++ set(BITS_RANGE "2 to 8")
++ elseif(BITS EQUAL 12)
++ set(BITS_RANGE "9 to 12")
++ else()
++ set(BITS_RANGE "13 to 16")
++ endif()
++
++ configure_file(${SOURCE_DIR}/template.c ${SOURCE_DIR}/${WRAPPER_FILE})
++
++ endforeach()
++endforeach()
++
++foreach(FILE jccoefct.c jcdctmgr.c jdcoefct.c jddctmgr.c jdmerge.c jfdctfst.c
++ jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c jquant2.c
++ rdcolmap.c wrgif.c)
++
++ foreach(BITS 8 12)
++
++ string(REGEX REPLACE "\\.c" "-${BITS}.c" WRAPPER_FILE ${FILE})
++ set(BITS_RANGE ${BITS})
++
++ configure_file(${SOURCE_DIR}/template.c ${SOURCE_DIR}/${WRAPPER_FILE})
++
++ endforeach()
++endforeach()
+diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt
+index c8c92996f..55a86b097 100644
+--- a/sharedlib/CMakeLists.txt
++++ b/sharedlib/CMakeLists.txt
+@@ -49,7 +49,7 @@ if(MSVC_LIKE)
+ set(JPEG_SRCS ${JPEG_SRCS} ${CMAKE_BINARY_DIR}/win/jpeg.rc)
+ endif()
+ add_library(jpeg SHARED ${JPEG_SRCS} ${DEFFILE} ${SIMD_TARGET_OBJECTS}
+- ${SIMD_OBJS} $<TARGET_OBJECTS:jpeg12> $<TARGET_OBJECTS:jpeg16>)
++ ${SIMD_OBJS})
+
+ set_target_properties(jpeg PROPERTIES SOVERSION ${SO_MAJOR_VERSION}
+ VERSION ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION})
+@@ -86,31 +86,19 @@ endif()
+ set(CDJPEG_COMPILE_FLAGS
+ "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
+
+-# Compile a separate version of these source files with 12-bit and 16-bit data
+-# precision.
+-add_library(cjpeg12 OBJECT ../src/rdppm.c)
+-set_property(TARGET cjpeg12 PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
+-add_library(cjpeg16 OBJECT ../src/rdppm.c)
+-set_property(TARGET cjpeg16 PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=16 -DGIF_SUPPORTED -DPPM_SUPPORTED")
+ add_executable(cjpeg ../src/cjpeg.c ../src/cdjpeg.c ../src/rdbmp.c
+- ../src/rdgif.c ../src/rdppm.c ../src/rdswitch.c ../src/rdtarga.c
+- $<TARGET_OBJECTS:cjpeg12> $<TARGET_OBJECTS:cjpeg16>)
++ ../src/rdgif.c
++ ../src/wrapper/rdppm-8.c ../src/wrapper/rdppm-12.c ../src/wrapper/rdppm-16.c
++ ../src/rdswitch.c ../src/rdtarga.c)
+ set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${CDJPEG_COMPILE_FLAGS})
+ target_link_libraries(cjpeg jpeg)
+
+-# Compile a separate version of these source files with 12-bit and 16-bit data
+-# precision.
+-add_library(djpeg12 OBJECT ../src/rdcolmap.c ../src/wrgif.c ../src/wrppm.c)
+-set_property(TARGET djpeg12 PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
+-add_library(djpeg16 OBJECT ../src/wrppm.c)
+-set_property(TARGET djpeg16 PROPERTY COMPILE_FLAGS
+- "-DBITS_IN_JSAMPLE=16 -DPPM_SUPPORTED")
+-add_executable(djpeg ../src/djpeg.c ../src/cdjpeg.c ../src/rdcolmap.c
+- ../src/rdswitch.c ../src/wrbmp.c ../src/wrgif.c ../src/wrppm.c
+- ../src/wrtarga.c $<TARGET_OBJECTS:djpeg12> $<TARGET_OBJECTS:djpeg16>)
++add_executable(djpeg ../src/djpeg.c ../src/cdjpeg.c
++ ../src/wrapper/rdcolmap-8.c ../src/wrapper/rdcolmap-12.c
++ ../src/rdswitch.c ../src/wrbmp.c
++ ../src/wrapper/wrgif-8.c ../src/wrapper/wrgif-12.c
++ ../src/wrapper/wrppm-8.c ../src/wrapper/wrppm-12.c ../src/wrapper/wrppm-16.c
++ ../src/wrtarga.c)
+ set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${CDJPEG_COMPILE_FLAGS})
+ target_link_libraries(djpeg jpeg)
+
+diff --git a/src/wrapper/jcapistd-12.c b/src/wrapper/jcapistd-12.c
+new file mode 100644
+index 000000000..4ec6e99d5
+--- /dev/null
++++ b/src/wrapper/jcapistd-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jcapistd-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcapistd.c to support 9 to 12 bits of
++ * data precision. jcapistd.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jcapistd.c"
+diff --git a/src/wrapper/jcapistd-16.c b/src/wrapper/jcapistd-16.c
+new file mode 100644
+index 000000000..3c0cc7916
+--- /dev/null
++++ b/src/wrapper/jcapistd-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jcapistd-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcapistd.c to support 13 to 16 bits of
++ * data precision. jcapistd.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jcapistd.c"
+diff --git a/src/wrapper/jcapistd-8.c b/src/wrapper/jcapistd-8.c
+new file mode 100644
+index 000000000..3fa69d9d0
+--- /dev/null
++++ b/src/wrapper/jcapistd-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jcapistd-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcapistd.c to support 2 to 8 bits of
++ * data precision. jcapistd.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jcapistd.c"
+diff --git a/src/wrapper/jccoefct-12.c b/src/wrapper/jccoefct-12.c
+new file mode 100644
+index 000000000..82405e3c3
+--- /dev/null
++++ b/src/wrapper/jccoefct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jccoefct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jccoefct.c to support 12 bits of
++ * data precision. jccoefct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jccoefct.c"
+diff --git a/src/wrapper/jccoefct-8.c b/src/wrapper/jccoefct-8.c
+new file mode 100644
+index 000000000..51d7554ab
+--- /dev/null
++++ b/src/wrapper/jccoefct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jccoefct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jccoefct.c to support 8 bits of
++ * data precision. jccoefct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jccoefct.c"
+diff --git a/src/wrapper/jccolor-12.c b/src/wrapper/jccolor-12.c
+new file mode 100644
+index 000000000..8b66c2321
+--- /dev/null
++++ b/src/wrapper/jccolor-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jccolor-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jccolor.c to support 9 to 12 bits of
++ * data precision. jccolor.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jccolor.c"
+diff --git a/src/wrapper/jccolor-16.c b/src/wrapper/jccolor-16.c
+new file mode 100644
+index 000000000..98db8eb50
+--- /dev/null
++++ b/src/wrapper/jccolor-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jccolor-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jccolor.c to support 13 to 16 bits of
++ * data precision. jccolor.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jccolor.c"
+diff --git a/src/wrapper/jccolor-8.c b/src/wrapper/jccolor-8.c
+new file mode 100644
+index 000000000..5403b2fe3
+--- /dev/null
++++ b/src/wrapper/jccolor-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jccolor-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jccolor.c to support 2 to 8 bits of
++ * data precision. jccolor.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jccolor.c"
+diff --git a/src/wrapper/jcdctmgr-12.c b/src/wrapper/jcdctmgr-12.c
+new file mode 100644
+index 000000000..6c5e5dfba
+--- /dev/null
++++ b/src/wrapper/jcdctmgr-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jcdctmgr-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcdctmgr.c to support 12 bits of
++ * data precision. jcdctmgr.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jcdctmgr.c"
+diff --git a/src/wrapper/jcdctmgr-8.c b/src/wrapper/jcdctmgr-8.c
+new file mode 100644
+index 000000000..a2e1dcede
+--- /dev/null
++++ b/src/wrapper/jcdctmgr-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jcdctmgr-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcdctmgr.c to support 8 bits of
++ * data precision. jcdctmgr.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jcdctmgr.c"
+diff --git a/src/wrapper/jcdiffct-12.c b/src/wrapper/jcdiffct-12.c
+new file mode 100644
+index 000000000..a32947481
+--- /dev/null
++++ b/src/wrapper/jcdiffct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jcdiffct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcdiffct.c to support 9 to 12 bits of
++ * data precision. jcdiffct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jcdiffct.c"
+diff --git a/src/wrapper/jcdiffct-16.c b/src/wrapper/jcdiffct-16.c
+new file mode 100644
+index 000000000..5d6a545b9
+--- /dev/null
++++ b/src/wrapper/jcdiffct-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jcdiffct-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcdiffct.c to support 13 to 16 bits of
++ * data precision. jcdiffct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jcdiffct.c"
+diff --git a/src/wrapper/jcdiffct-8.c b/src/wrapper/jcdiffct-8.c
+new file mode 100644
+index 000000000..dba423012
+--- /dev/null
++++ b/src/wrapper/jcdiffct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jcdiffct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcdiffct.c to support 2 to 8 bits of
++ * data precision. jcdiffct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jcdiffct.c"
+diff --git a/src/wrapper/jclossls-12.c b/src/wrapper/jclossls-12.c
+new file mode 100644
+index 000000000..f4ab9a361
+--- /dev/null
++++ b/src/wrapper/jclossls-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jclossls-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jclossls.c to support 9 to 12 bits of
++ * data precision. jclossls.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jclossls.c"
+diff --git a/src/wrapper/jclossls-16.c b/src/wrapper/jclossls-16.c
+new file mode 100644
+index 000000000..575666f61
+--- /dev/null
++++ b/src/wrapper/jclossls-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jclossls-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jclossls.c to support 13 to 16 bits of
++ * data precision. jclossls.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jclossls.c"
+diff --git a/src/wrapper/jclossls-8.c b/src/wrapper/jclossls-8.c
+new file mode 100644
+index 000000000..71354eec7
+--- /dev/null
++++ b/src/wrapper/jclossls-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jclossls-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jclossls.c to support 2 to 8 bits of
++ * data precision. jclossls.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jclossls.c"
+diff --git a/src/wrapper/jcmainct-12.c b/src/wrapper/jcmainct-12.c
+new file mode 100644
+index 000000000..c63cb4849
+--- /dev/null
++++ b/src/wrapper/jcmainct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jcmainct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcmainct.c to support 9 to 12 bits of
++ * data precision. jcmainct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jcmainct.c"
+diff --git a/src/wrapper/jcmainct-16.c b/src/wrapper/jcmainct-16.c
+new file mode 100644
+index 000000000..8256afb93
+--- /dev/null
++++ b/src/wrapper/jcmainct-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jcmainct-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcmainct.c to support 13 to 16 bits of
++ * data precision. jcmainct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jcmainct.c"
+diff --git a/src/wrapper/jcmainct-8.c b/src/wrapper/jcmainct-8.c
+new file mode 100644
+index 000000000..ffac92fde
+--- /dev/null
++++ b/src/wrapper/jcmainct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jcmainct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcmainct.c to support 2 to 8 bits of
++ * data precision. jcmainct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jcmainct.c"
+diff --git a/src/wrapper/jcprepct-12.c b/src/wrapper/jcprepct-12.c
+new file mode 100644
+index 000000000..0970afd80
+--- /dev/null
++++ b/src/wrapper/jcprepct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jcprepct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcprepct.c to support 9 to 12 bits of
++ * data precision. jcprepct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jcprepct.c"
+diff --git a/src/wrapper/jcprepct-16.c b/src/wrapper/jcprepct-16.c
+new file mode 100644
+index 000000000..92adbd8fa
+--- /dev/null
++++ b/src/wrapper/jcprepct-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jcprepct-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcprepct.c to support 13 to 16 bits of
++ * data precision. jcprepct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jcprepct.c"
+diff --git a/src/wrapper/jcprepct-8.c b/src/wrapper/jcprepct-8.c
+new file mode 100644
+index 000000000..3616d9c88
+--- /dev/null
++++ b/src/wrapper/jcprepct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jcprepct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcprepct.c to support 2 to 8 bits of
++ * data precision. jcprepct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jcprepct.c"
+diff --git a/src/wrapper/jcsample-12.c b/src/wrapper/jcsample-12.c
+new file mode 100644
+index 000000000..95110821a
+--- /dev/null
++++ b/src/wrapper/jcsample-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jcsample-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcsample.c to support 9 to 12 bits of
++ * data precision. jcsample.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jcsample.c"
+diff --git a/src/wrapper/jcsample-16.c b/src/wrapper/jcsample-16.c
+new file mode 100644
+index 000000000..87fe293b8
+--- /dev/null
++++ b/src/wrapper/jcsample-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jcsample-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcsample.c to support 13 to 16 bits of
++ * data precision. jcsample.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jcsample.c"
+diff --git a/src/wrapper/jcsample-8.c b/src/wrapper/jcsample-8.c
+new file mode 100644
+index 000000000..f3f6067e3
+--- /dev/null
++++ b/src/wrapper/jcsample-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jcsample-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jcsample.c to support 2 to 8 bits of
++ * data precision. jcsample.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jcsample.c"
+diff --git a/src/wrapper/jdapistd-12.c b/src/wrapper/jdapistd-12.c
+new file mode 100644
+index 000000000..7fe49219d
+--- /dev/null
++++ b/src/wrapper/jdapistd-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdapistd-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdapistd.c to support 9 to 12 bits of
++ * data precision. jdapistd.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdapistd.c"
+diff --git a/src/wrapper/jdapistd-16.c b/src/wrapper/jdapistd-16.c
+new file mode 100644
+index 000000000..31da5debd
+--- /dev/null
++++ b/src/wrapper/jdapistd-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jdapistd-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdapistd.c to support 13 to 16 bits of
++ * data precision. jdapistd.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jdapistd.c"
+diff --git a/src/wrapper/jdapistd-8.c b/src/wrapper/jdapistd-8.c
+new file mode 100644
+index 000000000..31b256934
+--- /dev/null
++++ b/src/wrapper/jdapistd-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdapistd-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdapistd.c to support 2 to 8 bits of
++ * data precision. jdapistd.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdapistd.c"
+diff --git a/src/wrapper/jdcoefct-12.c b/src/wrapper/jdcoefct-12.c
+new file mode 100644
+index 000000000..efeb53206
+--- /dev/null
++++ b/src/wrapper/jdcoefct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdcoefct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdcoefct.c to support 12 bits of
++ * data precision. jdcoefct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdcoefct.c"
+diff --git a/src/wrapper/jdcoefct-8.c b/src/wrapper/jdcoefct-8.c
+new file mode 100644
+index 000000000..446cefcee
+--- /dev/null
++++ b/src/wrapper/jdcoefct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdcoefct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdcoefct.c to support 8 bits of
++ * data precision. jdcoefct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdcoefct.c"
+diff --git a/src/wrapper/jdcolor-12.c b/src/wrapper/jdcolor-12.c
+new file mode 100644
+index 000000000..0054d22f2
+--- /dev/null
++++ b/src/wrapper/jdcolor-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdcolor-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdcolor.c to support 9 to 12 bits of
++ * data precision. jdcolor.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdcolor.c"
+diff --git a/src/wrapper/jdcolor-16.c b/src/wrapper/jdcolor-16.c
+new file mode 100644
+index 000000000..e65ffa1ec
+--- /dev/null
++++ b/src/wrapper/jdcolor-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jdcolor-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdcolor.c to support 13 to 16 bits of
++ * data precision. jdcolor.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jdcolor.c"
+diff --git a/src/wrapper/jdcolor-8.c b/src/wrapper/jdcolor-8.c
+new file mode 100644
+index 000000000..525e13e27
+--- /dev/null
++++ b/src/wrapper/jdcolor-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdcolor-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdcolor.c to support 2 to 8 bits of
++ * data precision. jdcolor.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdcolor.c"
+diff --git a/src/wrapper/jddctmgr-12.c b/src/wrapper/jddctmgr-12.c
+new file mode 100644
+index 000000000..a6503ea2d
+--- /dev/null
++++ b/src/wrapper/jddctmgr-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jddctmgr-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jddctmgr.c to support 12 bits of
++ * data precision. jddctmgr.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jddctmgr.c"
+diff --git a/src/wrapper/jddctmgr-8.c b/src/wrapper/jddctmgr-8.c
+new file mode 100644
+index 000000000..f61de79cd
+--- /dev/null
++++ b/src/wrapper/jddctmgr-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jddctmgr-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jddctmgr.c to support 8 bits of
++ * data precision. jddctmgr.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jddctmgr.c"
+diff --git a/src/wrapper/jddiffct-12.c b/src/wrapper/jddiffct-12.c
+new file mode 100644
+index 000000000..a8b60f004
+--- /dev/null
++++ b/src/wrapper/jddiffct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jddiffct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jddiffct.c to support 9 to 12 bits of
++ * data precision. jddiffct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jddiffct.c"
+diff --git a/src/wrapper/jddiffct-16.c b/src/wrapper/jddiffct-16.c
+new file mode 100644
+index 000000000..35277c828
+--- /dev/null
++++ b/src/wrapper/jddiffct-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jddiffct-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jddiffct.c to support 13 to 16 bits of
++ * data precision. jddiffct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jddiffct.c"
+diff --git a/src/wrapper/jddiffct-8.c b/src/wrapper/jddiffct-8.c
+new file mode 100644
+index 000000000..8ff0731d1
+--- /dev/null
++++ b/src/wrapper/jddiffct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jddiffct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jddiffct.c to support 2 to 8 bits of
++ * data precision. jddiffct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jddiffct.c"
+diff --git a/src/wrapper/jdlossls-12.c b/src/wrapper/jdlossls-12.c
+new file mode 100644
+index 000000000..436636867
+--- /dev/null
++++ b/src/wrapper/jdlossls-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdlossls-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdlossls.c to support 9 to 12 bits of
++ * data precision. jdlossls.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdlossls.c"
+diff --git a/src/wrapper/jdlossls-16.c b/src/wrapper/jdlossls-16.c
+new file mode 100644
+index 000000000..89697b26d
+--- /dev/null
++++ b/src/wrapper/jdlossls-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jdlossls-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdlossls.c to support 13 to 16 bits of
++ * data precision. jdlossls.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jdlossls.c"
+diff --git a/src/wrapper/jdlossls-8.c b/src/wrapper/jdlossls-8.c
+new file mode 100644
+index 000000000..0bce5f432
+--- /dev/null
++++ b/src/wrapper/jdlossls-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdlossls-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdlossls.c to support 2 to 8 bits of
++ * data precision. jdlossls.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdlossls.c"
+diff --git a/src/wrapper/jdmainct-12.c b/src/wrapper/jdmainct-12.c
+new file mode 100644
+index 000000000..99deae350
+--- /dev/null
++++ b/src/wrapper/jdmainct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdmainct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdmainct.c to support 9 to 12 bits of
++ * data precision. jdmainct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdmainct.c"
+diff --git a/src/wrapper/jdmainct-16.c b/src/wrapper/jdmainct-16.c
+new file mode 100644
+index 000000000..11164f5e5
+--- /dev/null
++++ b/src/wrapper/jdmainct-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jdmainct-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdmainct.c to support 13 to 16 bits of
++ * data precision. jdmainct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jdmainct.c"
+diff --git a/src/wrapper/jdmainct-8.c b/src/wrapper/jdmainct-8.c
+new file mode 100644
+index 000000000..5f1bb6bfa
+--- /dev/null
++++ b/src/wrapper/jdmainct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdmainct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdmainct.c to support 2 to 8 bits of
++ * data precision. jdmainct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdmainct.c"
+diff --git a/src/wrapper/jdmerge-12.c b/src/wrapper/jdmerge-12.c
+new file mode 100644
+index 000000000..bbf3c3723
+--- /dev/null
++++ b/src/wrapper/jdmerge-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdmerge-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdmerge.c to support 12 bits of
++ * data precision. jdmerge.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdmerge.c"
+diff --git a/src/wrapper/jdmerge-8.c b/src/wrapper/jdmerge-8.c
+new file mode 100644
+index 000000000..5faea11dd
+--- /dev/null
++++ b/src/wrapper/jdmerge-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdmerge-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdmerge.c to support 8 bits of
++ * data precision. jdmerge.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdmerge.c"
+diff --git a/src/wrapper/jdpostct-12.c b/src/wrapper/jdpostct-12.c
+new file mode 100644
+index 000000000..dadda1754
+--- /dev/null
++++ b/src/wrapper/jdpostct-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdpostct-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdpostct.c to support 9 to 12 bits of
++ * data precision. jdpostct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdpostct.c"
+diff --git a/src/wrapper/jdpostct-16.c b/src/wrapper/jdpostct-16.c
+new file mode 100644
+index 000000000..12db968c1
+--- /dev/null
++++ b/src/wrapper/jdpostct-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jdpostct-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdpostct.c to support 13 to 16 bits of
++ * data precision. jdpostct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jdpostct.c"
+diff --git a/src/wrapper/jdpostct-8.c b/src/wrapper/jdpostct-8.c
+new file mode 100644
+index 000000000..5227d363d
+--- /dev/null
++++ b/src/wrapper/jdpostct-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdpostct-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdpostct.c to support 2 to 8 bits of
++ * data precision. jdpostct.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdpostct.c"
+diff --git a/src/wrapper/jdsample-12.c b/src/wrapper/jdsample-12.c
+new file mode 100644
+index 000000000..910764d71
+--- /dev/null
++++ b/src/wrapper/jdsample-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jdsample-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdsample.c to support 9 to 12 bits of
++ * data precision. jdsample.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jdsample.c"
+diff --git a/src/wrapper/jdsample-16.c b/src/wrapper/jdsample-16.c
+new file mode 100644
+index 000000000..d39127a03
+--- /dev/null
++++ b/src/wrapper/jdsample-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jdsample-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdsample.c to support 13 to 16 bits of
++ * data precision. jdsample.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jdsample.c"
+diff --git a/src/wrapper/jdsample-8.c b/src/wrapper/jdsample-8.c
+new file mode 100644
+index 000000000..29ad67a21
+--- /dev/null
++++ b/src/wrapper/jdsample-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jdsample-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jdsample.c to support 2 to 8 bits of
++ * data precision. jdsample.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jdsample.c"
+diff --git a/src/wrapper/jfdctfst-12.c b/src/wrapper/jfdctfst-12.c
+new file mode 100644
+index 000000000..0b41d92b8
+--- /dev/null
++++ b/src/wrapper/jfdctfst-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jfdctfst-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jfdctfst.c to support 12 bits of
++ * data precision. jfdctfst.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jfdctfst.c"
+diff --git a/src/wrapper/jfdctfst-8.c b/src/wrapper/jfdctfst-8.c
+new file mode 100644
+index 000000000..0296ce0ec
+--- /dev/null
++++ b/src/wrapper/jfdctfst-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jfdctfst-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jfdctfst.c to support 8 bits of
++ * data precision. jfdctfst.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jfdctfst.c"
+diff --git a/src/wrapper/jfdctint-12.c b/src/wrapper/jfdctint-12.c
+new file mode 100644
+index 000000000..42ec3ef71
+--- /dev/null
++++ b/src/wrapper/jfdctint-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jfdctint-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jfdctint.c to support 12 bits of
++ * data precision. jfdctint.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jfdctint.c"
+diff --git a/src/wrapper/jfdctint-8.c b/src/wrapper/jfdctint-8.c
+new file mode 100644
+index 000000000..3de9390e7
+--- /dev/null
++++ b/src/wrapper/jfdctint-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jfdctint-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jfdctint.c to support 8 bits of
++ * data precision. jfdctint.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jfdctint.c"
+diff --git a/src/wrapper/jidctflt-12.c b/src/wrapper/jidctflt-12.c
+new file mode 100644
+index 000000000..f298d223f
+--- /dev/null
++++ b/src/wrapper/jidctflt-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctflt-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctflt.c to support 12 bits of
++ * data precision. jidctflt.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jidctflt.c"
+diff --git a/src/wrapper/jidctflt-8.c b/src/wrapper/jidctflt-8.c
+new file mode 100644
+index 000000000..23d915378
+--- /dev/null
++++ b/src/wrapper/jidctflt-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctflt-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctflt.c to support 8 bits of
++ * data precision. jidctflt.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jidctflt.c"
+diff --git a/src/wrapper/jidctfst-12.c b/src/wrapper/jidctfst-12.c
+new file mode 100644
+index 000000000..cb3fcd15a
+--- /dev/null
++++ b/src/wrapper/jidctfst-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctfst-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctfst.c to support 12 bits of
++ * data precision. jidctfst.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jidctfst.c"
+diff --git a/src/wrapper/jidctfst-8.c b/src/wrapper/jidctfst-8.c
+new file mode 100644
+index 000000000..26f668189
+--- /dev/null
++++ b/src/wrapper/jidctfst-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctfst-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctfst.c to support 8 bits of
++ * data precision. jidctfst.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jidctfst.c"
+diff --git a/src/wrapper/jidctint-12.c b/src/wrapper/jidctint-12.c
+new file mode 100644
+index 000000000..f985fc451
+--- /dev/null
++++ b/src/wrapper/jidctint-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctint-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctint.c to support 12 bits of
++ * data precision. jidctint.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jidctint.c"
+diff --git a/src/wrapper/jidctint-8.c b/src/wrapper/jidctint-8.c
+new file mode 100644
+index 000000000..fda7fe300
+--- /dev/null
++++ b/src/wrapper/jidctint-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctint-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctint.c to support 8 bits of
++ * data precision. jidctint.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jidctint.c"
+diff --git a/src/wrapper/jidctred-12.c b/src/wrapper/jidctred-12.c
+new file mode 100644
+index 000000000..832169afe
+--- /dev/null
++++ b/src/wrapper/jidctred-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctred-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctred.c to support 12 bits of
++ * data precision. jidctred.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jidctred.c"
+diff --git a/src/wrapper/jidctred-8.c b/src/wrapper/jidctred-8.c
+new file mode 100644
+index 000000000..0957b0d37
+--- /dev/null
++++ b/src/wrapper/jidctred-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jidctred-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jidctred.c to support 8 bits of
++ * data precision. jidctred.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jidctred.c"
+diff --git a/src/wrapper/jquant1-12.c b/src/wrapper/jquant1-12.c
+new file mode 100644
+index 000000000..7970c3d67
+--- /dev/null
++++ b/src/wrapper/jquant1-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jquant1-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jquant1.c to support 12 bits of
++ * data precision. jquant1.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jquant1.c"
+diff --git a/src/wrapper/jquant1-8.c b/src/wrapper/jquant1-8.c
+new file mode 100644
+index 000000000..211f92212
+--- /dev/null
++++ b/src/wrapper/jquant1-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jquant1-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jquant1.c to support 8 bits of
++ * data precision. jquant1.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jquant1.c"
+diff --git a/src/wrapper/jquant2-12.c b/src/wrapper/jquant2-12.c
+new file mode 100644
+index 000000000..566e16264
+--- /dev/null
++++ b/src/wrapper/jquant2-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jquant2-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jquant2.c to support 12 bits of
++ * data precision. jquant2.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jquant2.c"
+diff --git a/src/wrapper/jquant2-8.c b/src/wrapper/jquant2-8.c
+new file mode 100644
+index 000000000..30cfe17ce
+--- /dev/null
++++ b/src/wrapper/jquant2-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jquant2-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jquant2.c to support 8 bits of
++ * data precision. jquant2.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jquant2.c"
+diff --git a/src/wrapper/jutils-12.c b/src/wrapper/jutils-12.c
+new file mode 100644
+index 000000000..6620aa2d7
+--- /dev/null
++++ b/src/wrapper/jutils-12.c
+@@ -0,0 +1,14 @@
++/*
++ * jutils-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jutils.c to support 9 to 12 bits of
++ * data precision. jutils.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../jutils.c"
+diff --git a/src/wrapper/jutils-16.c b/src/wrapper/jutils-16.c
+new file mode 100644
+index 000000000..2df48891d
+--- /dev/null
++++ b/src/wrapper/jutils-16.c
+@@ -0,0 +1,14 @@
++/*
++ * jutils-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jutils.c to support 13 to 16 bits of
++ * data precision. jutils.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../jutils.c"
+diff --git a/src/wrapper/jutils-8.c b/src/wrapper/jutils-8.c
+new file mode 100644
+index 000000000..3c84956c3
+--- /dev/null
++++ b/src/wrapper/jutils-8.c
+@@ -0,0 +1,14 @@
++/*
++ * jutils-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling jutils.c to support 2 to 8 bits of
++ * data precision. jutils.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../jutils.c"
+diff --git a/src/wrapper/rdcolmap-12.c b/src/wrapper/rdcolmap-12.c
+new file mode 100644
+index 000000000..93d8b6c50
+--- /dev/null
++++ b/src/wrapper/rdcolmap-12.c
+@@ -0,0 +1,14 @@
++/*
++ * rdcolmap-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling rdcolmap.c to support 12 bits of
++ * data precision. rdcolmap.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../rdcolmap.c"
+diff --git a/src/wrapper/rdcolmap-8.c b/src/wrapper/rdcolmap-8.c
+new file mode 100644
+index 000000000..688cf256a
+--- /dev/null
++++ b/src/wrapper/rdcolmap-8.c
+@@ -0,0 +1,14 @@
++/*
++ * rdcolmap-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling rdcolmap.c to support 8 bits of
++ * data precision. rdcolmap.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../rdcolmap.c"
+diff --git a/src/wrapper/rdppm-12.c b/src/wrapper/rdppm-12.c
+new file mode 100644
+index 000000000..6ed96c090
+--- /dev/null
++++ b/src/wrapper/rdppm-12.c
+@@ -0,0 +1,14 @@
++/*
++ * rdppm-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling rdppm.c to support 9 to 12 bits of
++ * data precision. rdppm.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../rdppm.c"
+diff --git a/src/wrapper/rdppm-16.c b/src/wrapper/rdppm-16.c
+new file mode 100644
+index 000000000..710c08869
+--- /dev/null
++++ b/src/wrapper/rdppm-16.c
+@@ -0,0 +1,14 @@
++/*
++ * rdppm-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling rdppm.c to support 13 to 16 bits of
++ * data precision. rdppm.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../rdppm.c"
+diff --git a/src/wrapper/rdppm-8.c b/src/wrapper/rdppm-8.c
+new file mode 100644
+index 000000000..50ce3884c
+--- /dev/null
++++ b/src/wrapper/rdppm-8.c
+@@ -0,0 +1,14 @@
++/*
++ * rdppm-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling rdppm.c to support 2 to 8 bits of
++ * data precision. rdppm.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../rdppm.c"
+diff --git a/src/wrapper/template.c b/src/wrapper/template.c
+new file mode 100644
+index 000000000..df7f44633
+--- /dev/null
++++ b/src/wrapper/template.c
+@@ -0,0 +1,14 @@
++/*
++ * @WRAPPER_FILE@
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling @FILE@ to support @BITS_RANGE@ bits of
++ * data precision. @FILE@ should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE @BITS@
++
++#include "../@FILE@"
+diff --git a/src/wrapper/wrgif-12.c b/src/wrapper/wrgif-12.c
+new file mode 100644
+index 000000000..1e1ceeebc
+--- /dev/null
++++ b/src/wrapper/wrgif-12.c
+@@ -0,0 +1,14 @@
++/*
++ * wrgif-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling wrgif.c to support 12 bits of
++ * data precision. wrgif.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../wrgif.c"
+diff --git a/src/wrapper/wrgif-8.c b/src/wrapper/wrgif-8.c
+new file mode 100644
+index 000000000..a0045d726
+--- /dev/null
++++ b/src/wrapper/wrgif-8.c
+@@ -0,0 +1,14 @@
++/*
++ * wrgif-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling wrgif.c to support 8 bits of
++ * data precision. wrgif.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../wrgif.c"
+diff --git a/src/wrapper/wrppm-12.c b/src/wrapper/wrppm-12.c
+new file mode 100644
+index 000000000..8419c9770
+--- /dev/null
++++ b/src/wrapper/wrppm-12.c
+@@ -0,0 +1,14 @@
++/*
++ * wrppm-12.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling wrppm.c to support 9 to 12 bits of
++ * data precision. wrppm.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 12
++
++#include "../wrppm.c"
+diff --git a/src/wrapper/wrppm-16.c b/src/wrapper/wrppm-16.c
+new file mode 100644
+index 000000000..2b6c14ea9
+--- /dev/null
++++ b/src/wrapper/wrppm-16.c
+@@ -0,0 +1,14 @@
++/*
++ * wrppm-16.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling wrppm.c to support 13 to 16 bits of
++ * data precision. wrppm.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 16
++
++#include "../wrppm.c"
+diff --git a/src/wrapper/wrppm-8.c b/src/wrapper/wrppm-8.c
+new file mode 100644
+index 000000000..908dc3f80
+--- /dev/null
++++ b/src/wrapper/wrppm-8.c
+@@ -0,0 +1,14 @@
++/*
++ * wrppm-8.c
++ *
++ * Copyright (C) 2025, D. R. Commander.
++ * For conditions of distribution and use, see the accompanying README.ijg
++ * file.
++ *
++ * This file is a wrapper for compiling wrppm.c to support 2 to 8 bits of
++ * data precision. wrppm.c should not be compiled directly.
++ */
++
++#define BITS_IN_JSAMPLE 8
++
++#include "../wrppm.c"
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt b/contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt
index df2148df57e..20b684b1ca0 100644
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt
+++ b/contrib/libs/libjpeg-turbo/.yandex_meta/licenses.list.txt
@@ -21,6 +21,11 @@
====================BSD-3-Clause====================
+ both the terms of the IJG License and the terms of the Modified (3-clause)
+ BSD License apply.
+
+
+====================BSD-3-Clause====================
%define GOT_SYMBOL __GLOBAL_OFFSET_TABLE_ ; BSD-style a.out supports PIC
@@ -68,7 +73,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses.
====================BSD-3-Clause====================
-libjpeg-turbo is covered by three compatible BSD-style open source licenses:
+libjpeg-turbo is covered by two compatible BSD-style open source licenses:
====================BSD-3-Clause AND BSD-3-Clause====================
@@ -120,39 +125,45 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1994, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
+ * Copyright (C) 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1995, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2016, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019-2020, 2022, D. R. Commander.
+ * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ * Copyright (C) 2014, MIPS Technologies, Inc., California.
+ * Copyright (C) 2015, 2019, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
- * Modified 2017 by Guido Vollbeding.
+ * Modified 2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2018, 2021-2022, D. R. Commander.
+ * Copyright (C) 2017, 2019-2020, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
+ * Modified 2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2014-2015, 2020, D. R. Commander.
+ * Copyright (C) 2018, 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -160,7 +171,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2015, D. R. Commander.
+ * Copyright (C) 2009, 2014-2015, 2020, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -168,7 +179,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
+ * Copyright (C) 2009, 2015, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -176,7 +187,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2018, 2022, D. R. Commander.
+ * Copyright (C) 2009-2012, 2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -184,7 +195,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2020, D. R. Commander.
+ * Copyright (C) 2010, 2018, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -192,7 +203,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2022, D. R. Commander.
+ * Copyright (C) 2015, 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -200,9 +211,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
- * Copyright (C) 2014, MIPS Technologies, Inc., California.
+ * Copyright (C) 2017, 2019, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -211,10 +220,8 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2010, 2015-2016, D. R. Commander.
+ * Copyright (C) 2009-2012, 2015, 2022, 2024, D. R. Commander.
* Copyright (C) 2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2015, Google, Inc.
- * Copyright (C) 2019-2020, Arm Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -223,86 +230,102 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ * Copyright (C) 2010, 2015-2016, 2022, 2024, D. R. Commander.
* Copyright (C) 2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2015, 2019, D. R. Commander.
+ * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2019-2020, Arm Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, D. R. Commander.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2009-2011, 2014-2016, 2018-2024, D. R. Commander.
+ * Copyright (C) 2015, Matthieu Darbois.
+ * Copyright (C) 2018, Matthias Räncker.
+ * Copyright (C) 2020, Arm Limited.
+ * Copyright (C) 2022, Felix Hanau.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander.
+ * Copyright (C) 2009-2011, 2016, 2018-2019, 2022, D. R. Commander.
+ * Copyright (C) 2018, Matthias Räncker.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
+ * Copyright (C) 2010, 2016, 2018, 2022, 2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
- * Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2019, 2022, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2010-2011, 2015-2016, 2021, D. R. Commander.
+ * Copyright (C) 2018, Matthias Räncker.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, D. R. Commander.
+ * Modifications:
+ * Copyright (C) 2013, Linaro Limited.
+ * Copyright (C) 2014-2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2009 by Bill Allombert, Guido Vollbeding.
+ * Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015-2017, 2020-2022, D. R. Commander.
+ * Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2011 by Guido Vollbeding.
+ * Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009, 2011-2012, 2014-2015, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
+ * Copyright (C) 2015-2017, 2019, 2021-2022, 2024, D. R. Commander.
+ * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2013-2019 by Guido Vollbeding.
+ * Modified 2002-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022, D. R. Commander.
+ * Copyright (C) 2009-2011, 2016, 2019, 2022-2024, D. R. Commander.
+ * Copyright (C) 2013, Linaro Limited.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -310,56 +333,59 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2015-2019 by Guido Vollbeding.
+ * Modified 2003-2010 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2017, 2022, D. R. Commander.
+ * Copyright (C) 2010, 2016, 2018, 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2019 by Guido Vollbeding.
+ * Modified 2009 by Bill Allombert, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2021-2022, D. R. Commander.
+ * Copyright (C) 2015-2017, 2020-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2015, D. R. Commander.
+ * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ * Copyright (C) 2009, 2011-2012, 2014-2015, 2022, 2024, D. R. Commander.
+ * Copyright (C) 2013, Linaro Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2013-2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2018, 2021, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
- * Copyright (C) 2020-2021, Arm Limited.
+ * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022-2024, D. R. Commander.
+ * Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2015-2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2014-2016, 2018-2022, D. R. Commander.
- * Copyright (C) 2015, Matthieu Darbois.
- * Copyright (C) 2018, Matthias Räncker.
- * Copyright (C) 2020, Arm Limited.
+ * Copyright (C) 2015, 2017, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2018-2019, D. R. Commander.
- * Copyright (C) 2018, Matthias Räncker.
+ * Copyright (C) 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -367,8 +393,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2009, 2011, 2015, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -376,8 +401,9 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2015-2016, 2021, D. R. Commander.
+ * Copyright (C) 2009, 2018, 2021, D. R. Commander.
* Copyright (C) 2018, Matthias Räncker.
+ * Copyright (C) 2020-2021, Arm Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -385,7 +411,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2021-2022, D. R. Commander.
+ * Copyright (C) 2016, 2021-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -401,60 +427,71 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
+ * Copyright (C) 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2012, 2015, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2008 by Guido Vollbeding.
+ * Modified 2002-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2018, D. R. Commander.
+ * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, 2022-2024,
+ D. R. Commander.
+ * Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
+ * Modified 2003-2008 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, D. R. Commander.
+ * Copyright (C) 2009-2011, 2018, 2023-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2003-2011 by Guido Vollbeding.
+ * Modified 2003-2010 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, D. R. Commander.
+ * Copyright (C) 2010, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1991-1998, Thomas G. Lane.
+ * Modified 2003-2011 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2012, 2015, 2022, D. R. Commander.
+ * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, 2024-2025,
+ * D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
- * file.
====================COPYRIGHT====================
* Copyright (C) 1991-1998, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2013, 2022, D. R. Commander.
+ * Copyright (C) 2013, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -462,7 +499,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2012-2022, D. R. Commander.
+ * Copyright (C) 2010, 2012-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -470,7 +507,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1992-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017-2018, D. R. Commander.
+ * Copyright (C) 2017-2018, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -484,6 +521,16 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2002-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
@@ -497,7 +544,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2016, 2019, D. R. Commander.
+ * Copyright (C) 2011, 2016, 2019, 2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -506,7 +553,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2012 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2014, 2016, 2019, 2022, D. R. Commander.
+ * Copyright (C) 2011, 2014, 2016, 2019, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -525,23 +572,26 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Modified 2011 by Siarhei Siamashka.
- * Copyright (C) 2015, 2017-2018, 2021-2022, D. R. Commander.
+ * Copyright (C) 2015, 2017-2018, 2021-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 1999-2006, MIYASAKA Masaru.
+ * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+ * Copyright (C) 2011, 2014-2015, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
+ * file.
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014-2015, D. R. Commander.
+ * Copyright (C) 2010, 2015-2020, 2022-2024, D. R. Commander.
+ * Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -549,8 +599,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2015-2020, 2022, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2010, 2016, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -558,7 +607,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, D. R. Commander.
+ * Copyright (C) 2011, 2015, 2020, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -566,7 +615,8 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2020, D. R. Commander.
+ * Copyright (C) 2013, Linaro Limited.
+ * Copyright (C) 2014-2015, 2017, 2019, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -575,7 +625,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2017, 2019, 2022, D. R. Commander.
+ * Copyright (C) 2014-2015, 2018, 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -583,8 +633,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2018, 2020, D. R. Commander.
+ * Copyright (C) 2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -592,7 +641,15 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 1994-1996, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -601,7 +658,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander.
+ * Copyright (C) 2009, 2011, 2014-2015, 2020, 2022, D. R. Commander.
* Copyright (C) 2013, Linaro Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -609,9 +666,21 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1994-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2014, 2017, 2021-2022, D. R. Commander.
+ * Copyright (C) 2014, 2017, 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -620,7 +689,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2021, D. R. Commander.
+ * Copyright (C) 2021, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -629,7 +698,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2021, D. R. Commander.
+ * Copyright (C) 2017, 2019, 2021-2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -638,7 +707,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* Copyright (C) 1994-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2010, 2015-2016, 2019-2020, 2022, D. R. Commander.
+ * Copyright (C) 2010, 2015-2016, 2019-2020, 2022-2024, D. R. Commander.
* Copyright (C) 2015, 2020, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -649,41 +718,46 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
* Copyright (C) 2020, Google, Inc.
+ * Copyright (C) 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1994-1998, Thomas G. Lane.
- * Modified 2003-2010 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
+ * Copyright (C) 2016, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1994-1998, Thomas G. Lane.
- * Modified 2010 by Guido Vollbeding.
+ * Modified 2003-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2014, D. R. Commander.
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1994-1998, Thomas G. Lane.
+ * Modified 2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2022, D. R. Commander.
+ * Copyright (C) 2014, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
* Copyright (C) 1995-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2018, 2021-2022, D. R. Commander.
- * Copyright (C) 2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2011, 2015, 2018, 2021-2022, 2024, D. R. Commander.
+ * Copyright (C) 2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
* Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -692,6 +766,8 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1995-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2015-2016, 2018-2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -699,6 +775,14 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
+ * Copyright (C) 1995-1997, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2020, 2022, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+
+
+====================COPYRIGHT====================
* Copyright (C) 1995-1998, Thomas G. Lane.
* Modified 2000-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
@@ -710,7 +794,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2014, 2017, 2019-2022, D. R. Commander.
+ * Copyright (C) 2010, 2014, 2017, 2019-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -725,7 +809,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2017, 2021-2022, D. R. Commander.
+ * Copyright (C) 2010, 2017, 2021-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -739,6 +823,21 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
+ * Copyright (C) 1998, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 1999-2006, MIYASAKA Masaru.
+ * For conditions of distribution and use, see copyright notice in jsimdext.inc
+
+
+====================COPYRIGHT====================
* Copyright (C) 2009-2011, Nokia Corporation and/or its subsidiary(-ies).
* All Rights Reserved.
@@ -750,17 +849,61 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
+ * Copyright (C) 2014, 2021, 2024, D. R. Commander.
+ * Copyright (C) 2014, Olle Liljenzin.
+ * Copyright (C) 2020, Arm Limited.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2015, D. R. Commander. All Rights Reserved.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2015-2016, 2018, Matthieu Darbois. All Rights Reserved.
+
+
+====================COPYRIGHT====================
* Copyright (C) 2016, Siarhei Siamashka. All Rights Reserved.
====================COPYRIGHT====================
- * Copyright (C) 2017-2018, D. R. Commander.
+ * Copyright (C) 2017-2018, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
====================COPYRIGHT====================
- * Copyright (C)2009-2015, 2017, 2020-2021 D. R. Commander.
+ * Copyright (C) 2020, 2022, 2024, D. R. Commander. All Rights Reserved.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2022, 2024, D. R. Commander. All Rights Reserved.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2022, Matthieu Darbois. All Rights Reserved.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
+
+
+====================COPYRIGHT====================
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+
+
+====================COPYRIGHT====================
+ * Copyright (C)2009-2015, 2017, 2020-2024 D. R. Commander.
* All Rights Reserved.
@@ -774,30 +917,29 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022-2024, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
====================COPYRIGHT====================
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
+ * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022-2024, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
====================COPYRIGHT====================
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2011, 2014, 2022, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
====================COPYRIGHT====================
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014-2016, 2018, 2020, D. R. Commander.
+ * Copyright (C) 2011, 2014-2016, 2018, 2020, 2022, D. R. Commander.
* Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
* Copyright (C) 2014, Linaro Limited.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
* Copyright (C) 2020, Arm Limited.
@@ -805,16 +947,17 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2020, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2020, 2022, 2024,
+ * D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
====================COPYRIGHT====================
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, 2024, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2019, Google LLC.
* Copyright (C) 2020, Arm Limited.
@@ -867,19 +1010,21 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
-#define JCOPYRIGHT \
- "Copyright (C) 2009-2022 D. R. Commander\n" \
+#define JCOPYRIGHT1 \
+ "Copyright (C) 2009-2024 D. R. Commander\n" \
"Copyright (C) 2015, 2020 Google, Inc.\n" \
"Copyright (C) 2019-2020 Arm Limited\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
- "Copyright (C) 2015 Intel Corporation\n" \
+ "Copyright (C) 2015 Intel Corporation\n"
+#define JCOPYRIGHT2 \
"Copyright (C) 2013-2014 Linaro Limited\n" \
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
- "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
+ "Copyright (C) 1999 Ken Murchison\n" \
+ "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding\n"
====================COPYRIGHT====================
@@ -887,65 +1032,77 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
====================COPYRIGHT====================
-; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, 2023-2024, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
====================COPYRIGHT====================
-; Copyright (C) 2009-2011, 2014-2017, 2019, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2017, 2019, 2024, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
====================COPYRIGHT====================
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
====================COPYRIGHT====================
; Copyright (C) 2015, Intel Corporation.
-; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2016, 2024, D. R. Commander.
+
+
+====================COPYRIGHT====================
+; Copyright (C) 2016, 2018, Matthieu Darbois
====================COPYRIGHT====================
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
====================COPYRIGHT====================
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2024, D. R. Commander.
; Copyright (C) 2016, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
====================COPYRIGHT====================
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2020, 2024, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
====================COPYRIGHT====================
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
+; Copyright (C) 2010, 2016, 2018-2019, 2024, D. R. Commander.
; Copyright (C) 2018, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
====================COPYRIGHT====================
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2016, 2018, D. R. Commander.
+; Copyright (C) 2016, 2018, 2024, D. R. Commander.
; Copyright (C) 2016, Matthieu Darbois.
====================COPYRIGHT====================
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
+
+
+====================COPYRIGHT====================
+; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+; Copyright (C) 2016, D. R. Commander.
====================COPYRIGHT====================
@@ -955,14 +1112,15 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
====================COPYRIGHT====================
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
====================COPYRIGHT====================
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
@@ -971,7 +1129,7 @@ Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
====================COPYRIGHT====================
-Copyright (c) 1991-2022 The libjpeg-turbo Project
+Copyright (c) 1991-2024 The libjpeg-turbo Project
====================COPYRIGHT====================
This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
@@ -1017,16 +1175,18 @@ TO DO Plans for future IJG releases.
Other documentation files in the distribution are:
User documentation:
- usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
- rdjpgcom, and wrjpgcom.
- *.1 Unix-style man pages for programs (same info as usage.txt).
- wizard.txt Advanced usage instructions for JPEG wizards only.
- change.log Version-to-version change highlights.
+ doc/usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
+ rdjpgcom, and wrjpgcom.
+ doc/*.1 Unix-style man pages for programs (same info as
+ usage.txt).
+ doc/wizard.txt Advanced usage instructions for JPEG wizards only.
+ doc/change.log Version-to-version change highlights.
Programmer and internal documentation:
- libjpeg.txt How to use the JPEG library in your own programs.
- example.txt Sample code for calling the JPEG library.
- structure.txt Overview of the JPEG library's internal structure.
- coderules.txt Coding style rules --- please read if you contribute code.
+ doc/libjpeg.txt How to use the JPEG library in your own programs.
+ src/example.c Sample code for calling the JPEG library.
+ doc/structure.txt Overview of the JPEG library's internal structure.
+ doc/coderules.txt Coding style rules --- please read if you contribute
+ code.
Please read at least usage.txt. Some information can also be found in the JPEG
FAQ (Frequently Asked Questions) article. See ARCHIVE LOCATIONS below to find
@@ -1049,17 +1209,17 @@ other abrupt features may not compress well with JPEG, and a higher JPEG
quality may have to be used to avoid visible compression artifacts with such
images.
-JPEG is lossy, meaning that the output pixels are not necessarily identical to
-the input pixels. However, on photographic content and other "smooth" images,
-very good compression ratios can be obtained with no visible compression
-artifacts, and extremely high compression ratios are possible if you are
-willing to sacrifice image quality (by reducing the "quality" setting in the
-compressor.)
-
-This software implements JPEG baseline, extended-sequential, and progressive
-compression processes. Provision is made for supporting all variants of these
-processes, although some uncommon parameter settings aren't implemented yet.
-We have made no provision for supporting the hierarchical or lossless
+JPEG is normally lossy, meaning that the output pixels are not necessarily
+identical to the input pixels. However, on photographic content and other
+"smooth" images, very good compression ratios can be obtained with no visible
+compression artifacts, and extremely high compression ratios are possible if
+you are willing to sacrifice image quality (by reducing the "quality" setting
+in the compressor.)
+
+This software implements JPEG baseline, extended-sequential, progressive, and
+lossless compression processes. Provision is made for supporting all variants
+of these processes, although some uncommon parameter settings aren't
+implemented yet. We have made no provision for supporting the hierarchical
processes defined in the standard.
We provide a set of library routines for reading and writing JPEG image files,
@@ -1070,9 +1230,9 @@ The library is intended to be reused in other applications.
In order to support file conversion and viewing software, we have included
considerable functionality beyond the bare JPEG coding/decoding capability;
for example, the color quantization modules are not strictly part of JPEG
-decoding, but they are essential for output to colormapped file formats or
-colormapped displays. These extra functions can be compiled out of the
-library if not required for a particular application.
+decoding, but they are essential for output to colormapped file formats. These
+extra functions can be compiled out of the library if not required for a
+particular application.
We have also included "jpegtran", a utility for lossless transcoding between
different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
@@ -1222,7 +1382,7 @@ This software implements ITU T.81 | ISO/IEC 10918 with some extensions from
ITU T.871 | ISO/IEC 10918-5 (JPEG File Interchange Format-- see REFERENCES).
Informally, the term "JPEG image" or "JPEG file" most often refers to JFIF or
a subset thereof, but there are other formats containing the name "JPEG" that
-are incompatible with the DCT-based JPEG standard or with JFIF (for instance,
+are incompatible with the original JPEG standard or with JFIF (for instance,
JPEG 2000 and JPEG XR). This software therefore does not support these
formats. Indeed, one of the original reasons for developing this free software
was to help force convergence on a common, interoperable format standard for
@@ -1239,6 +1399,551 @@ TO DO
Please send bug reports, offers of help, etc. to [email protected].
+====================File: simd/nasm/jsimdext.inc====================
+;
+; jsimdext.inc - common declarations
+;
+; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
+; Copyright (C) 2010, 2016, 2018-2019, 2024, D. R. Commander.
+; Copyright (C) 2018, Matthieu Darbois.
+; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
+;
+; Based on the x86 SIMD extension for IJG JPEG library - version 1.02
+;
+; Copyright (C) 1999-2006, MIYASAKA Masaru.
+;
+; This software is provided 'as-is', without any express or implied
+; warranty. In no event will the authors be held liable for any damages
+; arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any purpose,
+; including commercial applications, and to alter it and redistribute it
+; freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must not
+; claim that you wrote the original software. If you use this software
+; in a product, an acknowledgment in the product documentation would be
+; appreciated but is not required.
+; 2. Altered source versions must be plainly marked as such, and must not be
+; misrepresented as being the original software.
+; 3. This notice may not be removed or altered from any source distribution.
+
+; ==========================================================================
+; System-dependent configurations
+
+%ifdef WIN32 ; ----(nasm -fwin32 -DWIN32 ...)--------
+; * Microsoft Visual C++
+; * MinGW (Minimalist GNU for Windows)
+; * CygWin
+; * LCC-Win32
+
+; -- segment definition --
+;
+%ifdef __YASM_VER__
+%define SEG_TEXT .text align=32
+%define SEG_CONST .rdata align=32
+%else
+%define SEG_TEXT .text align=32 public use32 class=CODE
+%define SEG_CONST .rdata align=32 public use32 class=CONST
+%endif
+
+%elifdef WIN64 ; ----(nasm -fwin64 -DWIN64 ...)--------
+; * Microsoft Visual C++
+
+; -- segment definition --
+;
+%ifdef __YASM_VER__
+%define SEG_TEXT .text align=32
+%define SEG_CONST .rdata align=32
+%else
+%define SEG_TEXT .text align=32 public use64 class=CODE
+%define SEG_CONST .rdata align=32 public use64 class=CONST
+%endif
+%define EXTN(name) name ; foo() -> foo
+
+%elifdef OBJ32 ; ----(nasm -fobj -DOBJ32 ...)----------
+; * Borland C++ (Win32)
+
+; -- segment definition --
+;
+%define SEG_TEXT _text align=32 public use32 class=CODE
+%define SEG_CONST _data align=32 public use32 class=DATA
+
+%elifdef UNIX ; ----(nasm -felf[64] -DUNIX ...)------------
+; * Linux
+; * *BSD family Unix using elf format
+; * Unix System V, including Solaris x86, UnixWare and SCO Unix
+
+; mark stack as non-executable
+section .note.GNU-stack noalloc noexec nowrite progbits
+
+%ifdef __CET__
+%ifdef __x86_64__
+section .note.gnu.property note alloc noexec align=8
+ dd 0x00000004, 0x00000010, 0x00000005, 0x00554e47
+ dd 0xc0000002, 0x00000004, 0x00000003, 0x00000000
+%endif
+%endif
+
+; -- segment definition --
+;
+%ifdef _x86_64_
+%define SEG_TEXT .text progbits align=32
+%define SEG_CONST .rodata progbits align=32
+%else
+%define SEG_TEXT .text progbits alloc exec nowrite align=32
+%define SEG_CONST .rodata progbits alloc noexec nowrite align=32
+%endif
+
+; To make the code position-independent, append -DPIC to the commandline
+;
+%define GOT_SYMBOL _GLOBAL_OFFSET_TABLE_ ; ELF supports PIC
+%define EXTN(name) name ; foo() -> foo
+
+%elifdef AOUT ; ----(nasm -faoutb/aout -DAOUT ...)----
+; * Older Linux using a.out format (nasm -f aout -DAOUT ...)
+; * *BSD family Unix using a.out format (nasm -f aoutb -DAOUT ...)
+
+; -- segment definition --
+;
+%define SEG_TEXT .text
+%define SEG_CONST .data
+
+; To make the code position-independent, append -DPIC to the commandline
+;
+%define GOT_SYMBOL __GLOBAL_OFFSET_TABLE_ ; BSD-style a.out supports PIC
+
+%elifdef MACHO ; ----(nasm -fmacho -DMACHO ...)--------
+; * NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (Mach-O format)
+
+; -- segment definition --
+;
+%define SEG_TEXT .text ;align=32 ; nasm doesn't accept align=32. why?
+%define SEG_CONST .rodata align=32
+
+; The generation of position-independent code (PIC) is the default on Darwin.
+;
+%define PIC
+%define GOT_SYMBOL _MACHO_PIC_ ; Mach-O style code-relative addressing
+
+%else ; ----(Other case)----------------------
+
+; -- segment definition --
+;
+%define SEG_TEXT .text
+%define SEG_CONST .data
+
+%endif ; ----------------------------------------------
+
+; ==========================================================================
+
+; --------------------------------------------------------------------------
+; Common types
+;
+%ifdef _x86_64_
+%ifnidn __OUTPUT_FORMAT__, elfx32
+%define POINTER qword ; general pointer type
+%define SIZEOF_POINTER SIZEOF_QWORD ; sizeof(POINTER)
+%define POINTER_BIT QWORD_BIT ; sizeof(POINTER)*BYTE_BIT
+%define resp resq
+%define dp dq
+%define raxp rax
+%define rbxp rbx
+%define rcxp rcx
+%define rdxp rdx
+%define rsip rsi
+%define rdip rdi
+%define rbpp rbp
+%define rspp rsp
+%define r8p r8
+%define r9p r9
+%define r10p r10
+%define r11p r11
+%define r12p r12
+%define r13p r13
+%define r14p r14
+%define r15p r15
+%endif
+%endif
+%ifndef raxp
+%define POINTER dword ; general pointer type
+%define SIZEOF_POINTER SIZEOF_DWORD ; sizeof(POINTER)
+%define POINTER_BIT DWORD_BIT ; sizeof(POINTER)*BYTE_BIT
+%define resp resd
+%define dp dd
+; x86_64 ILP32 ABI (x32)
+%define raxp eax
+%define rbxp ebx
+%define rcxp ecx
+%define rdxp edx
+%define rsip esi
+%define rdip edi
+%define rbpp ebp
+%define rspp esp
+%define r8p r8d
+%define r9p r9d
+%define r10p r10d
+%define r11p r11d
+%define r12p r12d
+%define r13p r13d
+%define r14p r14d
+%define r15p r15d
+%endif
+
+%define INT dword ; signed integer type
+%define SIZEOF_INT SIZEOF_DWORD ; sizeof(INT)
+%define INT_BIT DWORD_BIT ; sizeof(INT)*BYTE_BIT
+
+%define FP32 dword ; IEEE754 single
+%define SIZEOF_FP32 SIZEOF_DWORD ; sizeof(FP32)
+%define FP32_BIT DWORD_BIT ; sizeof(FP32)*BYTE_BIT
+
+%define MMWORD qword ; int64 (MMX register)
+%define SIZEOF_MMWORD SIZEOF_QWORD ; sizeof(MMWORD)
+%define MMWORD_BIT QWORD_BIT ; sizeof(MMWORD)*BYTE_BIT
+
+; NASM is buggy and doesn't properly handle operand sizes for SSE
+; instructions, so for now we have to define XMMWORD as blank.
+%define XMMWORD ; int128 (SSE register)
+%define SIZEOF_XMMWORD SIZEOF_OWORD ; sizeof(XMMWORD)
+%define XMMWORD_BIT OWORD_BIT ; sizeof(XMMWORD)*BYTE_BIT
+
+%define YMMWORD ; int256 (AVX register)
+%define SIZEOF_YMMWORD SIZEOF_YWORD ; sizeof(YMMWORD)
+%define YMMWORD_BIT YWORD_BIT ; sizeof(YMMWORD)*BYTE_BIT
+
+; Similar hacks for when we load a dword or MMWORD into an xmm# register
+%define XMM_DWORD
+%define XMM_MMWORD
+
+%define SIZEOF_BYTE 1 ; sizeof(byte)
+%define SIZEOF_WORD 2 ; sizeof(word)
+%define SIZEOF_DWORD 4 ; sizeof(dword)
+%define SIZEOF_QWORD 8 ; sizeof(qword)
+%define SIZEOF_OWORD 16 ; sizeof(oword)
+%define SIZEOF_YWORD 32 ; sizeof(yword)
+
+%define BYTE_BIT 8 ; CHAR_BIT in C
+%define WORD_BIT 16 ; sizeof(word)*BYTE_BIT
+%define DWORD_BIT 32 ; sizeof(dword)*BYTE_BIT
+%define QWORD_BIT 64 ; sizeof(qword)*BYTE_BIT
+%define OWORD_BIT 128 ; sizeof(oword)*BYTE_BIT
+%define YWORD_BIT 256 ; sizeof(yword)*BYTE_BIT
+
+; --------------------------------------------------------------------------
+; External Symbol Name
+;
+%ifndef EXTN
+%define EXTN(name) _ %+ name ; foo() -> _foo
+%endif
+
+; --------------------------------------------------------------------------
+; Hidden symbols
+;
+%ifdef UNIX ; ----(nasm -felf[64] -DUNIX ...)--------
+%define GLOBAL_FUNCTION(name) global EXTN(name):function hidden
+%define GLOBAL_DATA(name) global EXTN(name):data hidden
+%elifdef MACHO ; ----(nasm -fmacho -DMACHO ...)--------
+%ifdef __YASM_VER__
+%define GLOBAL_FUNCTION(name) global EXTN(name):private_extern
+%define GLOBAL_DATA(name) global EXTN(name):private_extern
+%else
+%if __NASM_VERSION_ID__ >= 0x020E0000
+%define GLOBAL_FUNCTION(name) global EXTN(name):private_extern
+%define GLOBAL_DATA(name) global EXTN(name):private_extern
+%endif
+%endif
+%endif
+
+%ifndef GLOBAL_FUNCTION
+%define GLOBAL_FUNCTION(name) global EXTN(name)
+%endif
+%ifndef GLOBAL_DATA
+%define GLOBAL_DATA(name) global EXTN(name)
+%endif
+
+; --------------------------------------------------------------------------
+; Macros for position-independent code (PIC) support
+;
+%ifndef GOT_SYMBOL
+%undef PIC
+%endif
+
+%ifdef PIC ; -------------------------------------------
+
+%ifidn GOT_SYMBOL, _MACHO_PIC_ ; --------------------
+
+; At present, nasm doesn't seem to support PIC generation for Mach-O.
+; The PIC support code below is a little tricky.
+
+ SECTION SEG_CONST
+const_base:
+
+%define GOTOFF(got, sym) (got) + (sym) - const_base
+
+%imacro GET_GOT 1
+ ; NOTE: this macro destroys ecx resister.
+ call %%geteip
+ add ecx, byte (%%ref - $)
+ jmp short %%adjust
+%%geteip:
+ mov ecx, POINTER [esp]
+ ret
+%%adjust:
+ push ebp
+ xor ebp, ebp ; ebp = 0
+%ifidni %1, ebx ; (%1 == ebx)
+ ; db 0x8D,0x9C + jmp near const_base =
+ ; lea ebx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,9C,E9,(offset32)
+ db 0x8D, 0x9C ; 8D,9C
+ jmp near const_base ; E9,(const_base-%%ref)
+%%ref:
+%else ; (%1 != ebx)
+ ; db 0x8D,0x8C + jmp near const_base =
+ ; lea ecx, [ecx+ebp*8+(const_base-%%ref)] ; 8D,8C,E9,(offset32)
+ db 0x8D, 0x8C ; 8D,8C
+ jmp near const_base ; E9,(const_base-%%ref)
+%%ref:
+ mov %1, ecx
+%endif ; (%1 == ebx)
+ pop ebp
+%endmacro
+
+%else ; GOT_SYMBOL != _MACHO_PIC_ ----------------
+
+%define GOTOFF(got, sym) (got) + (sym) wrt ..gotoff
+
+%imacro GET_GOT 1
+ extern GOT_SYMBOL
+ call %%geteip
+ add %1, GOT_SYMBOL + $$ - $ wrt ..gotpc
+ jmp short %%done
+%%geteip:
+ mov %1, POINTER [esp]
+ ret
+%%done:
+%endmacro
+
+%endif ; GOT_SYMBOL == _MACHO_PIC_ ----------------
+
+%imacro PUSHPIC 1.nolist
+ push %1
+%endmacro
+%imacro POPPIC 1.nolist
+ pop %1
+%endmacro
+%imacro MOVPIC 2.nolist
+ mov %1, %2
+%endmacro
+
+%else ; !PIC -----------------------------------------
+
+%define GOTOFF(got, sym) (sym)
+
+%imacro GET_GOT 1.nolist
+%endmacro
+%imacro PUSHPIC 1.nolist
+%endmacro
+%imacro POPPIC 1.nolist
+%endmacro
+%imacro MOVPIC 2.nolist
+%endmacro
+
+%endif ; PIC -----------------------------------------
+
+; --------------------------------------------------------------------------
+; Align the next instruction on {2,4,8,16,..}-byte boundary.
+; ".balign n,,m" in GNU as
+;
+%define MSKLE(x, y) (~(((y) & 0xFFFF) - ((x) & 0xFFFF)) >> 16)
+%define FILLB(b, n) (($$-(b)) & ((n)-1))
+
+%imacro ALIGNX 1-2.nolist 0xFFFF
+%%bs: \
+ times MSKLE(FILLB(%%bs, %1), %2) & MSKLE(16, FILLB($, %1)) & FILLB($, %1) \
+ db 0x90 ; nop
+ times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 9 \
+ db 0x8D, 0x9C, 0x23, 0x00, 0x00, 0x00, 0x00 ; lea ebx,[ebx+0x00000000]
+ times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 7 \
+ db 0x8D, 0xAC, 0x25, 0x00, 0x00, 0x00, 0x00 ; lea ebp,[ebp+0x00000000]
+ times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 6 \
+ db 0x8D, 0xAD, 0x00, 0x00, 0x00, 0x00 ; lea ebp,[ebp+0x00000000]
+ times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 4 \
+ db 0x8D, 0x6C, 0x25, 0x00 ; lea ebp,[ebp+0x00]
+ times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 3 \
+ db 0x8D, 0x6D, 0x00 ; lea ebp,[ebp+0x00]
+ times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 2 \
+ db 0x8B, 0xED ; mov ebp,ebp
+ times MSKLE(FILLB(%%bs, %1), %2) & FILLB($, %1) / 1 \
+ db 0x90 ; nop
+%endmacro
+
+; Align the next data on {2,4,8,16,..}-byte boundary.
+;
+%imacro ALIGNZ 1.nolist
+ align %1, db 0 ; filling zeros
+%endmacro
+
+%ifdef _x86_64_
+
+%ifdef WIN64
+
+%imacro COLLECT_ARGS 1
+ sub rsp, SIZEOF_XMMWORD
+ movaps XMMWORD [rsp], xmm6
+ sub rsp, SIZEOF_XMMWORD
+ movaps XMMWORD [rsp], xmm7
+ mov r10, rcx
+%if %1 > 1
+ mov r11, rdx
+%endif
+%if %1 > 2
+ push r12
+ mov r12, r8
+%endif
+%if %1 > 3
+ push r13
+ mov r13, r9
+%endif
+%if %1 > 4
+ push r14
+ mov r14, [rbp+48]
+%endif
+%if %1 > 5
+ push r15
+ mov r15, [rbp+56]
+%endif
+ push rsi
+ push rdi
+%endmacro
+
+%imacro UNCOLLECT_ARGS 1
+ pop rdi
+ pop rsi
+%if %1 > 5
+ pop r15
+%endif
+%if %1 > 4
+ pop r14
+%endif
+%if %1 > 3
+ pop r13
+%endif
+%if %1 > 2
+ pop r12
+%endif
+ movaps xmm7, XMMWORD [rsp]
+ add rsp, SIZEOF_XMMWORD
+ movaps xmm6, XMMWORD [rsp]
+ add rsp, SIZEOF_XMMWORD
+%endmacro
+
+%imacro PUSH_XMM 1
+ sub rsp, %1 * SIZEOF_XMMWORD
+ movaps XMMWORD [rsp+0*SIZEOF_XMMWORD], xmm8
+%if %1 > 1
+ movaps XMMWORD [rsp+1*SIZEOF_XMMWORD], xmm9
+%endif
+%if %1 > 2
+ movaps XMMWORD [rsp+2*SIZEOF_XMMWORD], xmm10
+%endif
+%if %1 > 3
+ movaps XMMWORD [rsp+3*SIZEOF_XMMWORD], xmm11
+%endif
+%endmacro
+
+%imacro POP_XMM 1
+ movaps xmm8, XMMWORD [rsp+0*SIZEOF_XMMWORD]
+%if %1 > 1
+ movaps xmm9, XMMWORD [rsp+1*SIZEOF_XMMWORD]
+%endif
+%if %1 > 2
+ movaps xmm10, XMMWORD [rsp+2*SIZEOF_XMMWORD]
+%endif
+%if %1 > 3
+ movaps xmm11, XMMWORD [rsp+3*SIZEOF_XMMWORD]
+%endif
+ add rsp, %1 * SIZEOF_XMMWORD
+%endmacro
+
+%else
+
+%imacro COLLECT_ARGS 1
+ push r10
+ mov r10, rdi
+%if %1 > 1
+ push r11
+ mov r11, rsi
+%endif
+%if %1 > 2
+ push r12
+ mov r12, rdx
+%endif
+%if %1 > 3
+ push r13
+ mov r13, rcx
+%endif
+%if %1 > 4
+ push r14
+ mov r14, r8
+%endif
+%if %1 > 5
+ push r15
+ mov r15, r9
+%endif
+%endmacro
+
+%imacro UNCOLLECT_ARGS 1
+%if %1 > 5
+ pop r15
+%endif
+%if %1 > 4
+ pop r14
+%endif
+%if %1 > 3
+ pop r13
+%endif
+%if %1 > 2
+ pop r12
+%endif
+%if %1 > 1
+ pop r11
+%endif
+ pop r10
+%endmacro
+
+%imacro PUSH_XMM 1
+%endmacro
+
+%imacro POP_XMM 1
+%endmacro
+
+%endif
+
+%endif
+
+%ifdef __CET__
+
+%imacro ENDBR64 0
+ dd 0xfa1e0ff3
+%endmacro
+
+%else
+
+%imacro ENDBR64 0
+%endmacro
+
+%endif
+
+; --------------------------------------------------------------------------
+; Defines picked up from the C headers
+;
+%include "jsimdcfg.inc"
+
+; --------------------------------------------------------------------------
+
+
====================IJG====================
This software is based in part on the work of the Independent JPEG
Group.
@@ -1351,6 +2056,14 @@ In plain English:
====================Zlib====================
+ [zlib License](https://opensource.org/licenses/Zlib), but in the context of
+
+
+====================Zlib====================
+ the overall libjpeg API library, the terms of the zlib License are subsumed
+
+
+====================Zlib====================
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
@@ -1369,10 +2082,6 @@ In plain English:
====================Zlib====================
-- The [zlib License](https://opensource.org/licenses/Zlib)
-
-
-====================Zlib====================
; For conditions of distribution and use, see copyright notice in jsimdext.inc
diff --git a/contrib/libs/libjpeg-turbo/.yandex_meta/override.nix b/contrib/libs/libjpeg-turbo/.yandex_meta/override.nix
index 7a009c2bedf..cd999576b23 100644
--- a/contrib/libs/libjpeg-turbo/.yandex_meta/override.nix
+++ b/contrib/libs/libjpeg-turbo/.yandex_meta/override.nix
@@ -1,12 +1,14 @@
pkgs: attrs: with pkgs; with attrs; rec {
- version = "2.1.4";
+ version = "3.1.1";
src = fetchFromGitHub {
owner = "libjpeg-turbo";
repo = "libjpeg-turbo";
rev = "${version}";
- hash = "sha256-1NRoVIL3zXX1D6iOf2FCrwBEcDW7TYFbdIbCTjY1m8Q=";
+ hash = "sha256-yGCMtAa0IjyeSBv3HxCQfYDSbNSbscj3choU6D2dlp8=";
};
- patches = [];
+ patches = [
+ ./issue817-add-wrappers.patch
+ ];
}
diff --git a/contrib/libs/libjpeg-turbo/BUILDING.md b/contrib/libs/libjpeg-turbo/BUILDING.md
index 2ce65d6177d..faec9c5bd52 100644
--- a/contrib/libs/libjpeg-turbo/BUILDING.md
+++ b/contrib/libs/libjpeg-turbo/BUILDING.md
@@ -8,14 +8,16 @@ Build Requirements
### All Systems
-- [CMake](http://www.cmake.org) v2.8.12 or later
+- [CMake](https://cmake.org) v2.8.12 or later
-- [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net)
+- [NASM](https://nasm.us) or [Yasm](https://yasm.tortall.net)
(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/).
+ [MacPorts](https://macports.org) or [Homebrew](https://brew.sh).
- NOTE: Currently, if it is desirable to hide the SIMD function symbols in
Mac executables or shared libraries that statically link with
libjpeg-turbo, then NASM 2.14 or later or Yasm must be used when
@@ -25,9 +27,9 @@ Build Requirements
variable or the `ASM_NASM` environment variable. On Windows, use forward
slashes rather than backslashes in the path (for example,
**c:/nasm/nasm.exe**).
- * NASM and Yasm are located in the CRB (Code Ready Builder) repository on
- Red Hat Enterprise Linux 8 and in the PowerTools repository on RHEL
- derivatives, which is not enabled by default.
+ * NASM and Yasm are located in the CRB (Code Ready Builder) or PowerTools
+ repository on Red Hat Enterprise Linux 8+ and derivatives, which is not
+ enabled by default.
### Un*x Platforms (including Linux, Mac, FreeBSD, Solaris, and Cygwin)
@@ -37,7 +39,7 @@ Build Requirements
required. Most modern Linux distributions, as well as Solaris 10 and later,
include JDK or OpenJDK. For other systems, you can obtain the Oracle Java
Development Kit from
- <http://www.oracle.com/technetwork/java/javase/downloads>.
+ <https://oracle.com/java/technologies/downloads>.
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
@@ -67,14 +69,14 @@ Build Requirements
- MinGW
- [MSYS2](http://msys2.github.io/) or [tdm-gcc](http://tdm-gcc.tdragon.net/)
+ [MSYS2](https://msys2.org) or [tdm-gcc](https://jmeubank.github.io/tdm-gcc)
recommended if building on a Windows machine. Both distributions install a
Start Menu link that can be used to launch a command prompt with the
appropriate compiler paths automatically set.
- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
can be downloaded from
- <http://www.oracle.com/technetwork/java/javase/downloads>.
+ <https://oracle.com/java/technologies/downloads>.
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
@@ -288,15 +290,6 @@ API/ABI-compatible with libjpeg v8. See [README.md](README.md) for more
information about libjpeg v7 and v8 emulation.
-### In-Memory Source/Destination Managers
-
-When using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to
-the CMake command line to build a version of libjpeg-turbo that lacks the
-`jpeg_mem_src()` and `jpeg_mem_dest()` functions. These functions were not
-part of the original libjpeg v6b and v7 APIs, so removing them ensures strict
-conformance with those APIs. See [README.md](README.md) for more information.
-
-
### Arithmetic Coding Support
Since the patent on arithmetic coding has expired, this functionality has been
@@ -372,9 +365,13 @@ located (usually **/usr/bin**.) Next, execute the following commands:
cd {build_directory}
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
+ -DCMAKE_INSTALL_PREFIX={install_path} \
[additional CMake flags] {source_directory}
make
+*{install\_path}* is the path under which the libjpeg-turbo binaries should be
+installed.
+
### 64-bit MinGW Build on Un*x (including Mac and Cygwin)
@@ -391,9 +388,13 @@ located (usually **/usr/bin**.) Next, execute the following commands:
cd {build_directory}
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
+ -DCMAKE_INSTALL_PREFIX={install_path} \
[additional CMake flags] {source_directory}
make
+*{install\_path}* is the path under which the libjpeg-turbo binaries should be
+installed.
+
Building libjpeg-turbo for iOS
------------------------------
@@ -414,27 +415,27 @@ iPhone 5S/iPad Mini 2/iPad Air and newer.
IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
- export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=8.0 -funwind-tables"
+ export CFLAGS="-Wall -miphoneos-version-min=8.0 -funwind-tables"
cd {build_directory}
- cat <<EOF >toolchain.cmake
- set(CMAKE_SYSTEM_NAME Darwin)
- set(CMAKE_SYSTEM_PROCESSOR aarch64)
- set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
- EOF
-
- cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
+ cmake -G"Unix Makefiles" \
+ -DCMAKE_C_COMPILER=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
+ -DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
[additional CMake flags] {source_directory}
make
+Replace `iPhoneOS` with `iPhoneSimulator` and `-miphoneos-version-min` with
+`-miphonesimulator-version-min` to build libjpeg-turbo for the iOS simulator on
+Macs with Apple silicon CPUs.
+
Building libjpeg-turbo for Android
----------------------------------
Building libjpeg-turbo for Android platforms requires v13b or later of the
-[Android NDK](https://developer.android.com/tools/sdk/ndk).
+[Android NDK](https://developer.android.com/ndk).
### Armv7 (32-bit)
@@ -602,15 +603,6 @@ brackets, then its final value will depend on the final value of that other
variable. For instance, the default value of `CMAKE_INSTALL_MANDIR` is
**\<CMAKE\_INSTALL\_DATAROOTDIR\>/man**.
-NOTE: If setting one of these directory variables to a relative path using the
-CMake command line, you must specify that the variable is of type `PATH`.
-For example:
-
- cmake -G"{generator type}" -DCMAKE_INSTALL_LIBDIR:PATH=lib {source_directory}
-
-Otherwise, CMake will assume that the path is relative to the build directory
-rather than the install directory.
-
Creating Distribution Packages
==============================
@@ -647,18 +639,19 @@ are installed by default on OS X/macOS 10.7 and later.
In order to create a Mac package/disk image that contains universal
x86-64/Arm binaries, set the following CMake variable:
-* `ARMV8_BUILD`: Directory containing an Armv8 (64-bit) iOS or macOS build of
- libjpeg-turbo to include in the universal binaries
+* `SECONDARY_BUILD`: Directory containing a cross-compiled x86-64 or Armv8
+ (64-bit) iOS or macOS build of libjpeg-turbo to include in the universal
+ binaries
-You should first use CMake to configure an Armv8 sub-build of libjpeg-turbo
-(see "Building libjpeg-turbo for iOS" above, if applicable) in a build
-directory that matches the one specified in the aforementioned CMake variable.
-Next, configure the primary (x86-64) build of libjpeg-turbo as an out-of-tree
-build, specifying the aforementioned CMake variable, and build it. Once the
-primary build has been built, run `make dmg` from the build directory. The
-packaging system will build the sub-build, use lipo to combine it with the
-primary build into a single set of universal binaries, then package the
-universal binaries.
+You should first use CMake to configure the cross-compiled x86-64 or Armv8
+secondary build of libjpeg-turbo (see "Building libjpeg-turbo for iOS" above,
+if applicable) in a build directory that matches the one specified in the
+aforementioned CMake variable. Next, configure the primary (native) build of
+libjpeg-turbo as an out-of-tree build, specifying the aforementioned CMake
+variable, and build it. Once the primary build has been built, run `make dmg`
+from the build directory. The packaging system will build the secondary build,
+use lipo to combine it with the primary build into a single set of universal
+binaries, then package the universal binaries.
Windows
@@ -683,7 +676,7 @@ as the configuration you built (such as *{build_directory}*\Debug\ or
*{build_directory}*\Release\).
Building a Windows installer requires the
-[Nullsoft Install System](http://nsis.sourceforge.net/). makensis.exe should
+[Nullsoft Install System](https://nsis.sourceforge.io). makensis.exe should
be in your `PATH`.
diff --git a/contrib/libs/libjpeg-turbo/ChangeLog.md b/contrib/libs/libjpeg-turbo/ChangeLog.md
index b0d166ea101..91367a6729e 100644
--- a/contrib/libs/libjpeg-turbo/ChangeLog.md
+++ b/contrib/libs/libjpeg-turbo/ChangeLog.md
@@ -1,7 +1,553 @@
+3.1.1
+=====
+
+### Significant changes relative to 3.1.0:
+
+1. Hardened the libjpeg API against hypothetical calling applications that may
+erroneously change the value of the `data_precision` field in
+`jpeg_compress_struct` or `jpeg_decompress_struct` after calling
+`jpeg_start_compress()` or `jpeg_start_decompress()`.
+
+
+3.1.0
+=====
+
+### Significant changes relative to 3.1 beta1:
+
+1. Fixed an issue in the TurboJPEG API whereby, when generating a
+lossless JPEG image with more than 8 bits per sample, specifying a point
+transform value greater than 7 resulted in an error ("Parameter value out of
+range") unless `TJPARAM_PRECISION`/`TJ.PARAM_PRECISION` was specified before
+`TJPARAM_LOSSLESSPT`/`TJ.PARAM_LOSSLESSPT`.
+
+2. Fixed a regression introduced by 1.4 beta1[3] that prevented
+`jpeg_set_defaults()` from resetting the Huffman tables to default (baseline)
+values if Huffman table optimization or progressive mode was previously enabled
+in the same libjpeg instance.
+
+3. Fixed an issue whereby lossless JPEG compression could not be disabled if it
+was previously enabled in a libjpeg or TurboJPEG instance.
+`jpeg_set_defaults()` now disables lossless JPEG compression in a libjpeg
+instance, and setting `TJPARAM_LOSSLESS`/`TJ.PARAM_LOSSLESS` to `0` now
+disables lossless JPEG compression in a TurboJPEG instance.
+
+
+3.1 beta1
+=========
+
+### Significant changes relative to 3.0.4:
+
+1. The libjpeg-turbo source tree has been reorganized to make it easier to find
+the README files, license information, and build instructions. The
+documentation for the libjpeg API library and associated programs has been
+moved into the **doc/** subdirectory, all C source code and headers have been
+moved into a new **src/** subdirectory, and test scripts have been moved into a
+new **test/** subdirectory.
+
+2. cjpeg no longer allows GIF input files to be converted into
+12-bit-per-sample JPEG files. That was never a useful feature, since GIF
+images have at most 256 colors referenced from a palette of 8-bit-per-component
+RGB values.
+
+3. Added support for lossless JPEG images with 2 to 15 bits per sample to the
+libjpeg and TurboJPEG APIs. When creating or decompressing a lossless JPEG
+image and when loading or saving a PBMPLUS image, functions/methods specific to
+8-bit samples now handle 8-bit samples with 2 to 8 bits of data precision
+(specified using the `data_precision` field in `jpeg_compress_struct` or
+`jpeg_decompress_struct` or using `TJPARAM_PRECISION`/`TJ.PARAM_PRECISION`),
+functions/methods specific to 12-bit samples now handle 12-bit samples with 9
+to 12 bits of data precision, and functions/methods specific to 16-bit samples
+now handle 16-bit samples with 13 to 16 bits of data precision. Refer to
+[libjpeg.txt](doc/libjpeg.txt), [usage.txt](doc/usage.txt), and the TurboJPEG
+API documentation for more details.
+
+4. All deprecated constants and methods in the TurboJPEG Java API have been
+removed.
+
+5. TJBench command-line arguments are now more consistent with those of cjpeg,
+djpeg, and jpegtran. More specifically:
+
+ - `-copynone` has been replaced with `-copy none`.
+ - `-fastdct` has been replaced with `-dct fast`.
+ - `-fastupsample` has been replaced with `-nosmooth`.
+ - `-hflip` and `-vflip` have been replaced with
+`-flip {horizontal|vertical}`.
+ - `-limitscans` has been replaced with `-maxscans`, which allows the scan
+limit to be specified.
+ - `-rgb`, `-bgr`, `-rgbx`, `-bgrx`, `-xbgr`, `-xrgb`, and `-cmyk` have
+been replaced with `-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|cmyk}`.
+ - `-rot90`, `-rot180`, and `-rot270` have been replaced with
+`-rotate {90|180|270}`.
+ - `-stoponwarning` has been replaced with `-strict`.
+ - British spellings for `gray` (`grey`) and `optimize` (`optimise`) are
+now allowed.
+
+ The old command-line arguments are deprecated and will be removed in a
+future release. TJBench command-line arguments can now be abbreviated as well.
+(Where possible, the abbreviations are the same as those supported by cjpeg,
+djpeg, and jpegtran.)
+
+6. Added a new TJBench option (`-pixelformat gray`) that can be used to test
+the performance of compressing/decompressing a grayscale JPEG image from/to a
+packed-pixel grayscale image.
+
+7. Fixed an issue whereby, if `TJPARAM_NOREALLOC` was set, TurboJPEG
+compression and lossless transformation functions ignored the JPEG buffer
+size(s) passed to them and assumed that the JPEG buffer(s) had been allocated
+to a worst-case size returned by `tj3JPEGBufSize()`. This behavior was never
+documented, although the documentation was unclear regarding whether the JPEG
+buffer size should be specified if a JPEG buffer is pre-allocated to a
+worst-case size.
+
+8. The TurboJPEG C and Java APIs have been improved in the following ways:
+
+ - New image I/O methods (`TJCompressor.loadSourceImage()` and
+`TJDecompressor.saveImage()`) have been added to the Java API. These methods
+work similarly to the `tj3LoadImage*()` and `tj3SaveImage*()` functions in the
+C API.
+ - The TurboJPEG lossless transformation function and methods now add
+restart markers to all destination images if
+`TJPARAM_RESTARTBLOCKS`/`TJ.PARAM_RESTARTBLOCKS` or
+`TJPARAM_RESTARTROWS`/`TJ.PARAM_RESTARTROWS` is set.
+ - New functions/methods (`tj3SetICCProfile()` /
+`TJCompressor.setICCProfile()` / `TJTransformer.setICCProfile()` and
+`tj3GetICCProfile()` / `TJDecompressor.getICCProfile()`) can be used to embed
+and retrieve ICC profiles.
+ - A new parameter (`TJPARAM_SAVEMARKERS`/`TJ.PARAM_SAVEMARKERS`) can be
+used to specify the types of markers that will be copied from the source image
+to the destination image during lossless transformation if
+`TJXOPT_COPYNONE`/`TJTransform.OPT_COPYNONE` is not specified.
+ - A new convenience function/method (`tj3TransformBufSize()` /
+`TJTransformer.bufSize()`) can be used to compute the worst-case destination
+buffer size for a given lossless transform, taking into account cropping,
+transposition of the width and height, grayscale conversion, and the embedded
+or extracted ICC profile.
+
+9. TJExample has been replaced with three programs (TJComp, TJDecomp, and
+TJTran) that demonstrate how to approximate the functionality of cjpeg, djpeg,
+and jpegtran using the TurboJPEG C and Java APIs.
+
+
+3.0.4
+=====
+
+### Significant changes relative to 3.0.3:
+
+1. Fixed an issue whereby the CPU usage of the default marker processor in the
+decompressor grew exponentially with the number of markers. This caused an
+unreasonable slow-down in `jpeg_read_header()` if an application called
+`jpeg_save_markers()` to save markers of a particular type and then attempted
+to decompress a JPEG image containing an excessive number of markers of that
+type.
+
+2. Hardened the default marker processor in the decompressor to guard against
+an issue (exposed by 3.0 beta2[6]) whereby attempting to decompress a
+specially-crafted malformed JPEG image (specifically an image with a complete
+12-bit-per-sample Start Of Frame segment followed by an incomplete
+8-bit-per-sample Start Of Frame segment) using buffered-image mode and input
+prefetching caused a segfault if the `fill_input_buffer()` method in the
+calling application's custom source manager incorrectly returned `FALSE` in
+response to a prematurely-terminated JPEG data stream.
+
+3. Fixed an issue in cjpeg whereby, when generating a 12-bit-per-sample or
+16-bit-per-sample lossless JPEG image, specifying a point transform value
+greater than 7 resulted in an error ("Invalid progressive/lossless parameters")
+unless the `-precision` option was specified before the `-lossless` option.
+
+4. Fixed a regression introduced by 3.0.3[3] that made it impossible for
+calling applications to generate 12-bit-per-sample arithmetic-coded lossy JPEG
+images using the TurboJPEG API.
+
+5. Fixed an error ("Destination buffer is not large enough") that occurred when
+attempting to generate a full-color lossless JPEG image using the TurboJPEG
+Java API's `byte[] TJCompressor.compress()` method if the value of
+`TJ.PARAM_SUBSAMP` was not `TJ.SAMP_444`.
+
+6. Fixed a segfault in djpeg that occurred if a negative width was specified
+with the `-crop` option. Since the cropping region width was read into an
+unsigned 32-bit integer, a negative width was interpreted as a very large
+value. With certain negative width and positive left boundary values, the
+bounds checks in djpeg and `jpeg_crop_scanline()` overflowed and did not detect
+the out-of-bounds width, which caused a buffer overrun in the upsampling or
+color conversion routine. Both bounds checks now use 64-bit integers to guard
+against overflow, and djpeg now checks for negative numbers when it parses the
+crop specification from the command line.
+
+7. Fixed an issue whereby the TurboJPEG lossless transformation function and
+methods checked the specified cropping region against the source image
+dimensions and level of chrominance subsampling rather than the destination
+image dimensions and level of chrominance subsampling, which caused some
+cropping regions to be unduly rejected when performing 90-degree rotation,
+270-degree rotation, transposition, transverse transposition, or grayscale
+conversion.
+
+8. Fixed a regression, introduced by 3.0 beta2[4], that prevented the
+`tjTransform()` backward compatibility function from copying extra markers from
+the source image to the destination image.
+
+9. Fixed an issue whereby the TurboJPEG lossless transformation function and
+methods did not honor `TJXOPT_COPYNONE`/`TJTransform.OPT_COPYNONE` unless it
+was specified for all lossless transforms.
+
+
+3.0.3
+=====
+
+### Significant changes relative to 3.0.2:
+
+1. Fixed an issue in the build system, introduced in 3.0.2, that caused all
+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.
+
+4. Fixed a segfault that occurred when attempting to use the jpegtran `-drop`
+option with a specially-crafted malformed input image or drop image
+(specifically an image in which all of the scans contain fewer components than
+the number of components specified in the Start Of Frame segment.)
+
+
+3.0.2
+=====
+
+### Significant changes relative to 3.0.1:
+
+1. Fixed a signed integer overflow in the `tj3CompressFromYUV8()`,
+`tj3DecodeYUV8()`, `tj3DecompressToYUV8()`, and `tj3EncodeYUV8()` functions,
+detected by the Clang and GCC undefined behavior sanitizers, that could be
+triggered by setting the `align` parameter to an unreasonably large value.
+This issue did not pose a security threat, but removing the warning made it
+easier to detect actual security issues, should they arise in the future.
+
+2. Introduced a new parameter (`TJPARAM_MAXMEMORY` in the TurboJPEG C API and
+`TJ.PARAM_MAXMEMORY` in the TurboJPEG Java API) and a corresponding TJBench
+option (`-maxmemory`) for specifying the maximum amount of memory (in
+megabytes) that will be allocated for intermediate buffers, which are used with
+progressive JPEG compression and decompression, Huffman table optimization,
+lossless JPEG compression, and lossless transformation. The new parameter and
+option serve the same purpose as the `max_memory_to_use` field in the
+`jpeg_memory_mgr` struct in the libjpeg API, the `JPEGMEM` environment
+variable, and the cjpeg/djpeg/jpegtran `-maxmemory` option.
+
+3. Introduced a new parameter (`TJPARAM_MAXPIXELS` in the TurboJPEG C API and
+`TJ.PARAM_MAXPIXELS` in the TurboJPEG Java API) and a corresponding TJBench
+option (`-maxpixels`) for specifying the maximum number of pixels that the
+decompression, lossless transformation, and packed-pixel image loading
+functions/methods will process.
+
+4. Fixed an error ("Unsupported color conversion request") that occurred when
+attempting to decompress a 3-component lossless JPEG image without an Adobe
+APP14 marker. The decompressor now assumes that a 3-component lossless JPEG
+image without an Adobe APP14 marker uses the RGB colorspace if its component
+IDs are 1, 2, and 3.
+
+
+3.0.1
+=====
+
+### Significant changes relative to 3.0.0:
+
+1. The x86-64 SIMD functions now use a standard stack frame, prologue, and
+epilogue so that debuggers and profilers can reliably capture backtraces from
+within the functions.
+
+2. Fixed two minor issues in the interblock smoothing algorithm that caused
+mathematical (but not necessarily perceptible) edge block errors when
+decompressing progressive JPEG images exactly two DCT blocks in width or that
+use vertical chrominance subsampling.
+
+3. Fixed a regression introduced by 3.0 beta2[6] that, in rare cases, caused
+the C Huffman encoder (which is not used by default on x86 and Arm CPUs) to
+generate incorrect results if the Neon SIMD extensions were explicitly disabled
+at build time (by setting the `WITH_SIMD` CMake variable to `0`) in an AArch64
+build of libjpeg-turbo.
+
+
+3.0.0
+=====
+
+### Significant changes relative to 3.0 beta2:
+
+1. The TurboJPEG API now supports 4:4:1 (transposed 4:1:1) chrominance
+subsampling, which allows losslessly transposed or rotated 4:1:1 JPEG images to
+be losslessly cropped, partially decompressed, or decompressed to planar YUV
+images.
+
+2. Fixed various segfaults and buffer overruns (CVE-2023-2804) that occurred
+when attempting to decompress various specially-crafted malformed
+12-bit-per-component and 16-bit-per-component lossless JPEG images using color
+quantization or merged chroma upsampling/color conversion. The underlying
+cause of these issues was that the color quantization and merged chroma
+upsampling/color conversion algorithms were not designed with lossless
+decompression in mind. Since libjpeg-turbo explicitly does not support color
+conversion when compressing or decompressing lossless JPEG images, merged
+chroma upsampling/color conversion never should have been enabled for such
+images. Color quantization is a legacy feature that serves little or no
+purpose with lossless JPEG images, so it is also now disabled when
+decompressing such images. (As a result, djpeg can no longer decompress a
+lossless JPEG image into a GIF image.)
+
+3. Fixed an oversight in 1.4 beta1[8] that caused various segfaults and buffer
+overruns when attempting to decompress various specially-crafted malformed
+12-bit-per-component JPEG images using djpeg with both color quantization and
+RGB565 color conversion enabled.
+
+4. Fixed an issue whereby `jpeg_crop_scanline()` sometimes miscalculated the
+downsampled width for components with 4x2 or 2x4 subsampling factors if
+decompression scaling was enabled. This caused the components to be upsampled
+incompletely, which caused the color converter to read from uninitialized
+memory. With 12-bit data precision, this caused a buffer overrun or underrun
+and subsequent segfault if the sample value read from uninitialized memory was
+outside of the valid sample range.
+
+5. Fixed a long-standing issue whereby the `tj3Transform()` function, when used
+with the `TJXOP_TRANSPOSE`, `TJXOP_TRANSVERSE`, `TJXOP_ROT90`, or
+`TJXOP_ROT270` transform operation and without automatic JPEG destination
+buffer (re)allocation or lossless cropping, computed the worst-case transformed
+JPEG image size based on the source image dimensions rather than the
+transformed image dimensions. If a calling program allocated the JPEG
+destination buffer based on the transformed image dimensions, as the API
+documentation instructs, and attempted to transform a specially-crafted 4:2:2,
+4:4:0, 4:1:1, or 4:4:1 JPEG source image containing a large amount of metadata,
+the issue caused `tj3Transform()` to overflow the JPEG destination buffer
+rather than fail gracefully. The issue could be worked around by setting
+`TJXOPT_COPYNONE`. Note that, irrespective of this issue, `tj3Transform()`
+cannot reliably transform JPEG source images that contain a large amount of
+metadata unless automatic JPEG destination buffer (re)allocation is used or
+`TJXOPT_COPYNONE` is set.
+
+6. Fixed a regression introduced by 3.0 beta2[6] that prevented the djpeg
+`-map` option from working when decompressing 12-bit-per-component lossy JPEG
+images.
+
+7. Fixed an issue that caused the C Huffman encoder (which is not used by
+default on x86 and Arm CPUs) to read from uninitialized memory when attempting
+to transform a specially-crafted malformed arithmetic-coded JPEG source image
+into a baseline Huffman-coded JPEG destination image.
+
+
+2.1.91 (3.0 beta2)
+==================
+
+### Significant changes relative to 2.1.5.1:
+
+1. Significantly sped up the computation of optimal Huffman tables. This
+speeds up the compression of tiny images by as much as 2x and provides a
+noticeable speedup for images as large as 256x256 when using optimal Huffman
+tables.
+
+2. All deprecated fields, constructors, and methods in the TurboJPEG Java API
+have been removed.
+
+3. Arithmetic entropy coding is now supported with 12-bit-per-component JPEG
+images.
+
+4. Overhauled the TurboJPEG API to address long-standing limitations and to
+make the API more extensible and intuitive:
+
+ - All C function names are now prefixed with `tj3`, and all version
+suffixes have been removed from the function names. Future API overhauls will
+increment the prefix to `tj4`, etc., thus retaining backward API/ABI
+compatibility without versioning each individual function.
+ - Stateless boolean flags have been replaced with stateful integer API
+parameters, the values of which persist between function calls. New
+functions/methods (`tj3Set()`/`TJCompressor.set()`/`TJDecompressor.set()` and
+`tj3Get()`/`TJCompressor.get()`/`TJDecompressor.get()`) can be used to set and
+query the value of a particular API parameter.
+ - The JPEG quality and subsampling are now implemented using API
+parameters rather than stateless function arguments (C) or dedicated set/get
+methods (Java.)
+ - `tj3DecompressHeader()` now stores all relevant information about the
+JPEG image, including the width, height, subsampling type, entropy coding
+algorithm, etc., in API parameters rather than returning that information
+through pointer arguments.
+ - `TJFLAG_LIMITSCANS`/`TJ.FLAG_LIMITSCANS` has been reimplemented as an
+API parameter (`TJPARAM_SCANLIMIT`/`TJ.PARAM_SCANLIMIT`) that allows the number
+of scans to be specified.
+ - Huffman table optimization can now be specified using a new API
+parameter (`TJPARAM_OPTIMIZE`/`TJ.PARAM_OPTIMIZE`), a new transform option
+(`TJXOPT_OPTIMIZE`/`TJTransform.OPT_OPTIMIZE`), and a new TJBench option
+(`-optimize`.)
+ - Arithmetic entropy coding can now be specified or queried, using a new
+API parameter (`TJPARAM_ARITHMETIC`/`TJ.PARAM_ARITHMETIC`), a new transform
+option (`TJXOPT_ARITHMETIC`/`TJTransform.OPT_ARITHMETIC`), and a new TJBench
+option (`-arithmetic`.)
+ - The restart marker interval can now be specified, using new API
+parameters (`TJPARAM_RESTARTROWS`/`TJ.PARAM_RESTARTROWS` and
+`TJPARAM_RESTARTBLOCKS`/`TJ.PARAM_RESTARTBLOCKS`) and a new TJBench option
+(`-restart`.)
+ - Pixel density can now be specified or queried, using new API parameters
+(`TJPARAM_XDENSITY`/`TJ.PARAM_XDENSITY`,
+`TJPARAM_YDENSITY`/`TJ.PARAM_YDENSITY`, and
+`TJPARAM_DENSITYUNITS`/`TJ.PARAM_DENSITYUNITS`.)
+ - The accurate DCT/IDCT algorithms are now the default for both
+compression and decompression, since the "fast" algorithms are considered to be
+a legacy feature. (The "fast" algorithms do not pass the ISO compliance tests,
+and those algorithms are not any faster than the accurate algorithms on modern
+x86 CPUs.)
+ - All C initialization functions have been combined into a single function
+(`tj3Init()`) that accepts an integer argument specifying the subsystems to
+initialize.
+ - All C functions now use the `const` keyword for pointer arguments that
+point to unmodified buffers (and for both dimensions of pointer arguments that
+point to sets of unmodified buffers.)
+ - All C functions now use `size_t` rather than `unsigned long` to
+represent buffer sizes, for compatibility with `malloc()` and to avoid
+disparities in the size of `unsigned long` between LP64 (Un*x) and LLP64
+(Windows) operating systems.
+ - All C buffer size functions now return 0 if an error occurs, rather than
+trying to awkwardly return -1 in an unsigned data type (which could easily be
+misinterpreted as a very large value.)
+ - Decompression scaling is now enabled explicitly, using a new
+function/method (`tj3SetScalingFactor()`/`TJDecompressor.setScalingFactor()`),
+rather than implicitly using awkward "desired width"/"desired height"
+arguments.
+ - Partial image decompression has been implemented, using a new
+function/method (`tj3SetCroppingRegion()`/`TJDecompressor.setCroppingRegion()`)
+and a new TJBench option (`-crop`.)
+ - The JPEG colorspace can now be specified explicitly when compressing,
+using a new API parameter (`TJPARAM_COLORSPACE`/`TJ.PARAM_COLORSPACE`.) This
+allows JPEG images with the RGB and CMYK colorspaces to be created.
+ - TJBench no longer generates error/difference images, since identical
+functionality is already available in ImageMagick.
+ - JPEG images with unknown subsampling configurations can now be
+fully decompressed into packed-pixel images or losslessly transformed (with the
+exception of lossless cropping.) They cannot currently be partially
+decompressed or decompressed into planar YUV images.
+ - `tj3Destroy()` now silently accepts a NULL handle.
+ - `tj3Alloc()` and `tj3Free()` now return/accept void pointers, as
+`malloc()` and `free()` do.
+ - The C image I/O functions now accept a TurboJPEG instance handle, which
+is used to transmit/receive API parameter values and to receive error
+information.
+
+5. Added support for 8-bit-per-component, 12-bit-per-component, and
+16-bit-per-component lossless JPEG images. A new libjpeg API function
+(`jpeg_enable_lossless()`), TurboJPEG API parameters
+(`TJPARAM_LOSSLESS`/`TJ.PARAM_LOSSLESS`,
+`TJPARAM_LOSSLESSPSV`/`TJ.PARAM_LOSSLESSPSV`, and
+`TJPARAM_LOSSLESSPT`/`TJ.PARAM_LOSSLESSPT`), and a cjpeg/TJBench option
+(`-lossless`) can be used to create a lossless JPEG image. (Decompression of
+lossless JPEG images is handled automatically.) Refer to
+[libjpeg.txt](doc/libjpeg.txt), [usage.txt](doc/usage.txt), and the TurboJPEG
+API documentation for more details.
+
+6. Added support for 12-bit-per-component (lossy and lossless) and
+16-bit-per-component (lossless) JPEG images to the libjpeg and TurboJPEG APIs:
+
+ - The existing `data_precision` field in `jpeg_compress_struct` and
+`jpeg_decompress_struct` has been repurposed to enable the creation of
+12-bit-per-component and 16-bit-per-component JPEG images or to detect whether
+a 12-bit-per-component or 16-bit-per-component JPEG image is being
+decompressed.
+ - New 12-bit-per-component and 16-bit-per-component versions of
+`jpeg_write_scanlines()` and `jpeg_read_scanlines()`, as well as new
+12-bit-per-component versions of `jpeg_write_raw_data()`,
+`jpeg_skip_scanlines()`, `jpeg_crop_scanline()`, and `jpeg_read_raw_data()`,
+provide interfaces for compressing from/decompressing to 12-bit-per-component
+and 16-bit-per-component packed-pixel and planar YUV image buffers.
+ - New 12-bit-per-component and 16-bit-per-component compression,
+decompression, and image I/O functions/methods have been added to the TurboJPEG
+API, and a new API parameter (`TJPARAM_PRECISION`/`TJ.PARAM_PRECISION`) can be
+used to query the data precision of a JPEG image. (YUV functions are currently
+limited to 8-bit data precision but can be expanded to accommodate 12-bit data
+precision in the future, if such is deemed beneficial.)
+ - A new cjpeg and TJBench command-line argument (`-precision`) can be used
+to create a 12-bit-per-component or 16-bit-per-component JPEG image.
+(Decompression and transformation of 12-bit-per-component and
+16-bit-per-component JPEG images is handled automatically.)
+
+ Refer to [libjpeg.txt](doc/libjpeg.txt), [usage.txt](doc/usage.txt), and
+the TurboJPEG API documentation for more details.
+
+
+2.1.5.1
+=======
+
+### Significant changes relative to 2.1.5:
+
+1. The SIMD dispatchers in libjpeg-turbo 2.1.4 and prior stored the list of
+supported SIMD instruction sets in a global variable, which caused an innocuous
+race condition whereby the variable could have been initialized multiple times
+if `jpeg_start_*compress()` was called simultaneously in multiple threads.
+libjpeg-turbo 2.1.5 included an undocumented attempt to fix this race condition
+by making the SIMD support variable thread-local. However, that caused another
+issue whereby, if `jpeg_start_*compress()` was called in one thread and
+`jpeg_read_*()` or `jpeg_write_*()` was called in a second thread, the SIMD
+support variable was never initialized in the second thread. On x86 systems,
+this led the second thread to incorrectly assume that AVX2 instructions were
+always available, and when it attempted to use those instructions on older x86
+CPUs that do not support them, an illegal instruction error occurred. The SIMD
+dispatchers now ensure that the SIMD support variable is initialized before
+dispatching based on its value.
+
+
+2.1.5
+=====
+
+### Significant changes relative to 2.1.4:
+
+1. Fixed issues in the build system whereby, when using the Ninja Multi-Config
+CMake generator, a static build of libjpeg-turbo (a build in which
+`ENABLE_SHARED` is `0`) could not be installed, a Windows installer could not
+be built, and the Java regression tests failed.
+
+2. Fixed a regression introduced by 2.0 beta1[15] that caused a buffer overrun
+in the progressive Huffman encoder when attempting to transform a
+specially-crafted malformed 12-bit-per-component JPEG image into a progressive
+12-bit-per-component JPEG image using a 12-bit-per-component build of
+libjpeg-turbo (`-DWITH_12BIT=1`.) Given that the buffer overrun was fully
+contained within the progressive Huffman encoder structure and did not cause a
+segfault or other user-visible errant behavior, given that the lossless
+transformer (unlike the decompressor) is not generally exposed to arbitrary
+data exploits, and given that 12-bit-per-component builds of libjpeg-turbo are
+uncommon, this issue did not likely pose a security risk.
+
+3. Fixed an issue whereby, when using a 12-bit-per-component build of
+libjpeg-turbo (`-DWITH_12BIT=1`), passing samples with values greater than 4095
+or less than 0 to `jpeg_write_scanlines()` caused a buffer overrun or underrun
+in the RGB-to-YCbCr color converter.
+
+4. Fixed a floating point exception that occurred when attempting to use the
+jpegtran `-drop` and `-trim` options to losslessly transform a
+specially-crafted malformed JPEG image.
+
+5. Fixed an issue in `tjBufSizeYUV2()` whereby it returned a bogus result,
+rather than throwing an error, if the `align` parameter was not a power of 2.
+Fixed a similar issue in `tjCompressFromYUV()` whereby it generated a corrupt
+JPEG image in certain cases, rather than throwing an error, if the `align`
+parameter was not a power of 2.
+
+6. Fixed an issue whereby `tjDecompressToYUV2()`, which is a wrapper for
+`tjDecompressToYUVPlanes()`, used the desired YUV image dimensions rather than
+the actual scaled image dimensions when computing the plane pointers and
+strides to pass to `tjDecompressToYUVPlanes()`. This caused a buffer overrun
+and subsequent segfault if the desired image dimensions exceeded the scaled
+image dimensions.
+
+7. Fixed an issue whereby, when decompressing a 12-bit-per-component JPEG image
+(`-DWITH_12BIT=1`) using an alpha-enabled output color space such as
+`JCS_EXT_RGBA`, the alpha channel was set to 255 rather than 4095.
+
+8. Fixed an issue whereby the Java version of TJBench did not accept a range of
+quality values.
+
+9. Fixed an issue whereby, when `-progressive` was passed to TJBench, the JPEG
+input image was not transformed into a progressive JPEG image prior to
+decompression.
+
+
2.1.4
=====
-### Significant changes relative to 2.1.3
+### Significant changes relative to 2.1.3:
1. Fixed a regression introduced in 2.1.3 that caused build failures with
Visual Studio 2010.
@@ -36,7 +582,7 @@ virtual array access") under certain circumstances.
2.1.3
=====
-### Significant changes relative to 2.1.2
+### Significant changes relative to 2.1.2:
1. Fixed a regression introduced by 2.0 beta1[7] whereby cjpeg compressed PGM
input files into full-color JPEG images unless the `-grayscale` option was
@@ -60,7 +606,7 @@ be reproduced using the libjpeg API, not using djpeg.
2.1.2
=====
-### Significant changes relative to 2.1.1
+### Significant changes relative to 2.1.1:
1. Fixed a regression introduced by 2.1 beta1[13] that caused the remaining
GAS implementations of AArch64 (Arm 64-bit) Neon SIMD functions (which are used
@@ -71,9 +617,9 @@ prevented libjpeg-turbo from working properly with other linkers and also
represented a potential security risk.
2. Fixed an issue whereby the `tjTransform()` function incorrectly computed the
-MCU block size for 4:4:4 JPEG images with non-unary sampling factors and thus
-unduly rejected some cropping regions, even though those regions aligned with
-8x8 MCU block boundaries.
+iMCU size for 4:4:4 JPEG images with non-unary sampling factors and thus unduly
+rejected some cropping regions, even though those regions aligned with 8x8 iMCU
+boundaries.
3. Fixed a regression introduced by 2.1 beta1[13] that caused the build system
to enable the Arm Neon SIMD extensions when targetting Armv6 and other legacy
@@ -92,7 +638,7 @@ image contains incomplete or corrupt image data.
2.1.1
=====
-### Significant changes relative to 2.1.0
+### Significant changes relative to 2.1.0:
1. Fixed a regression introduced in 2.1.0 that caused build failures with
non-GCC-compatible compilers for Un*x/Arm platforms.
@@ -121,11 +667,11 @@ transform a specially-crafted malformed JPEG image.
2.1.0
=====
-### Significant changes relative to 2.1 beta1
+### Significant changes relative to 2.1 beta1:
-1. Fixed a regression introduced by 2.1 beta1[6(b)] whereby attempting to
-decompress certain progressive JPEG images with one or more component planes of
-width 8 or less caused a buffer overrun.
+1. Fixed a regression (CVE-2021-29390) introduced by 2.1 beta1[6(b)] whereby
+attempting to decompress certain progressive JPEG images with one or more
+component planes of width 8 or less caused a buffer overrun.
2. Fixed a regression introduced by 2.1 beta1[6(b)] whereby attempting to
decompress a specially-crafted malformed progressive JPEG image caused the
@@ -156,10 +702,10 @@ progressive JPEG format described in the report
["Two Issues with the JPEG Standard"](https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
7. The PPM reader now throws an error, rather than segfaulting (due to a buffer
-overrun) or generating incorrect pixels, if an application attempts to use the
-`tjLoadImage()` function to load a 16-bit binary PPM file (a binary PPM file
-with a maximum value greater than 255) into a grayscale image buffer or to load
-a 16-bit binary PGM file into an RGB image buffer.
+overrun, CVE-2021-46822) or generating incorrect pixels, if an application
+attempts to use the `tjLoadImage()` function to load a 16-bit binary PPM file
+(a binary PPM file with a maximum value greater than 255) into a grayscale
+image buffer or to load a 16-bit binary PGM file into an RGB image buffer.
8. Fixed an issue in the PPM reader that caused incorrect pixels to be
generated when using the `tjLoadImage()` function to load a 16-bit binary PPM
@@ -325,11 +871,11 @@ methods in the TurboJPEG Java API.
2. Fixed or worked around multiple issues with `jpeg_skip_scanlines()`:
- - Fixed segfaults or "Corrupt JPEG data: premature end of data segment"
-errors in `jpeg_skip_scanlines()` that occurred when decompressing 4:2:2 or
-4:2:0 JPEG images using merged (non-fancy) upsampling/color conversion (that
-is, when setting `cinfo.do_fancy_upsampling` to `FALSE`.) 2.0.0[6] was a
-similar fix, but it did not cover all cases.
+ - Fixed segfaults (CVE-2020-35538) or "Corrupt JPEG data: premature end of
+data segment" errors in `jpeg_skip_scanlines()` that occurred when
+decompressing 4:2:2 or 4:2:0 JPEG images using merged (non-fancy)
+upsampling/color conversion (that is, when setting `cinfo.do_fancy_upsampling`
+to `FALSE`.) 2.0.0[6] was a similar fix, but it did not cover all cases.
- `jpeg_skip_scanlines()` now throws an error if two-pass color
quantization is enabled. Two-pass color quantization never worked properly
with `jpeg_skip_scanlines()`, and the issues could not readily be fixed.
@@ -655,16 +1201,15 @@ encounters a warning from the underlying libjpeg API (the default behavior is
to allow the operation to complete unless a fatal error is encountered.)
5. Introduced a new flag in the TurboJPEG C and Java APIs (`TJFLAG_PROGRESSIVE`
-and `TJ.FLAG_PROGRESSIVE`, respectively) that causes the library to use
-progressive entropy coding in JPEG images generated by compression and
-transform operations. Additionally, a new transform option
-(`TJXOPT_PROGRESSIVE` in the C API and `TJTransform.OPT_PROGRESSIVE` in the
-Java API) has been introduced, allowing progressive entropy coding to be
-enabled for selected transforms in a multi-transform operation.
+and `TJ.FLAG_PROGRESSIVE`, respectively) that causes compression and transform
+operations to generate progressive JPEG images. Additionally, a new transform
+option (`TJXOPT_PROGRESSIVE` in the C API and `TJTransform.OPT_PROGRESSIVE` in
+the Java API) has been introduced, allowing progressive JPEG images to be
+generated by selected transforms in a multi-transform operation.
6. Introduced a new transform option in the TurboJPEG API (`TJXOPT_COPYNONE` in
the C API and `TJTransform.OPT_COPYNONE` in the Java API) that allows the
-copying of markers (including EXIF and ICC profile data) to be disabled for a
+copying of markers (including Exif and ICC profile data) to be disabled for a
particular transform.
7. Added two functions to the TurboJPEG C API (`tjLoadImage()` and
@@ -795,13 +1340,13 @@ bug that has existed since the introduction of libjpeg v7/v8 API/ABI emulation
in libjpeg-turbo v1.1.
7. The lossless transform features in jpegtran and the TurboJPEG API will now
-always attempt to adjust the EXIF image width and height tags if the image size
+always attempt to adjust the Exif image width and height tags if the image size
changed as a result of the transform. This behavior has always existed when
using libjpeg v8 API/ABI emulation. It was supposed to be available with
libjpeg v7 API/ABI emulation as well but did not work properly due to a bug.
Furthermore, there was never any good reason not to enable it with libjpeg v6b
API/ABI emulation, since the behavior is entirely internal. Note that
-`-copy all` must be passed to jpegtran in order to transfer the EXIF tags from
+`-copy all` must be passed to jpegtran in order to transfer the Exif tags from
the source image to the destination image.
8. Fixed several memory leaks in the TurboJPEG API library that could occur
@@ -823,7 +1368,7 @@ for two reasons: it allows testers to more easily work around the 2 GB limit
in libFuzzer, and it allows developers of security-sensitive applications to
more easily defend against one of the progressive JPEG exploits (LJT-01-004)
identified in
-[this report](http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
+[this report](https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf).
10. TJBench will now run each benchmark for 1 second prior to starting the
timer, in order to improve the consistency of the results. Furthermore, the
@@ -981,7 +1526,7 @@ use of AltiVec instructions.
2. Added two new libjpeg API functions (`jpeg_skip_scanlines()` and
`jpeg_crop_scanline()`) that can be used to partially decode a JPEG image. See
-[libjpeg.txt](libjpeg.txt) for more details.
+[libjpeg.txt](doc/libjpeg.txt) for more details.
3. The TJCompressor and TJDecompressor classes in the TurboJPEG Java API now
implement the Closeable interface, so those classes can be used with a
@@ -1364,7 +1909,7 @@ features (such as the colorspace extensions), but in general, it performs no
faster than libjpeg v6b.
14. Added ARM 64-bit SIMD acceleration for the YCC-to-RGB color conversion
-and IDCT algorithms (both are used during JPEG decompression.) For unknown
+and IDCT algorithms (both are used during JPEG decompression.) For
reasons (probably related to clang), this code cannot currently be compiled for
iOS.
@@ -1850,7 +2395,7 @@ and unit tests now work on those architectures.
0.0.93
======
-### Significant changes since 0.0.91:
+### Significant changes relative to 0.0.91:
1. 2982659: Fixed x86-64 build on FreeBSD systems
diff --git a/contrib/libs/libjpeg-turbo/LICENSE.md b/contrib/libs/libjpeg-turbo/LICENSE.md
index d753e1d76aa..a785258bcda 100644
--- a/contrib/libs/libjpeg-turbo/LICENSE.md
+++ b/contrib/libs/libjpeg-turbo/LICENSE.md
@@ -1,30 +1,33 @@
libjpeg-turbo Licenses
======================
-libjpeg-turbo is covered by three compatible BSD-style open source licenses:
+libjpeg-turbo is covered by two compatible BSD-style open source licenses:
- The IJG (Independent JPEG Group) License, which is listed in
[README.ijg](README.ijg)
- This license applies to the libjpeg API library and associated programs
- (any code inherited from libjpeg, and any modifications to that code.)
+ This license applies to the libjpeg API library and associated programs,
+ including any code inherited from libjpeg and any modifications to that
+ code. Note that the libjpeg-turbo SIMD source code bears the
+ [zlib License](https://opensource.org/licenses/Zlib), but in the context of
+ the overall libjpeg API library, the terms of the zlib License are subsumed
+ by the terms of the IJG License.
- The Modified (3-clause) BSD License, which is listed below
- This license covers the TurboJPEG API library and associated programs, as
- well as the build system.
-
-- The [zlib License](https://opensource.org/licenses/Zlib)
-
- This license is a subset of the other two, and it covers the libjpeg-turbo
- SIMD extensions.
+ This license applies to the TurboJPEG API library and associated programs, as
+ well as the build system. Note that the TurboJPEG API library wraps the
+ libjpeg API library, so in the context of the overall TurboJPEG API library,
+ both the terms of the IJG License and the terms of the Modified (3-clause)
+ BSD License apply.
Complying with the libjpeg-turbo Licenses
=========================================
This section provides a roll-up of the libjpeg-turbo licensing terms, to the
-best of our understanding.
+best of our understanding. This is not a license in and of itself. It is
+intended solely for clarification.
1. If you are distributing a modified version of the libjpeg-turbo source,
then:
@@ -38,7 +41,7 @@ best of our understanding.
- Clauses 1 and 3 of the zlib License
2. You must add your own copyright notice to the header of each source
- file you modified, so others can tell that you modified that file (if
+ file you modified, so others can tell that you modified that file. (If
there is not an existing copyright header in that file, then you can
simply add a notice stating that you modified the file.)
@@ -91,7 +94,7 @@ best of our understanding.
The Modified (3-clause) BSD License
===================================
-Copyright (C)2009-2022 D. R. Commander. All Rights Reserved.<br>
+Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.<br>
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
@@ -119,8 +122,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-Why Three Licenses?
-===================
+Why Two Licenses?
+=================
The zlib License could have been used instead of the Modified (3-clause) BSD
License, and since the IJG License effectively subsumes the distribution
diff --git a/contrib/libs/libjpeg-turbo/README.ijg b/contrib/libs/libjpeg-turbo/README.ijg
index 9453c195010..dbf8070cac8 100644
--- a/contrib/libs/libjpeg-turbo/README.ijg
+++ b/contrib/libs/libjpeg-turbo/README.ijg
@@ -36,16 +36,18 @@ TO DO Plans for future IJG releases.
Other documentation files in the distribution are:
User documentation:
- usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
- rdjpgcom, and wrjpgcom.
- *.1 Unix-style man pages for programs (same info as usage.txt).
- wizard.txt Advanced usage instructions for JPEG wizards only.
- change.log Version-to-version change highlights.
+ doc/usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
+ rdjpgcom, and wrjpgcom.
+ doc/*.1 Unix-style man pages for programs (same info as
+ usage.txt).
+ doc/wizard.txt Advanced usage instructions for JPEG wizards only.
+ doc/change.log Version-to-version change highlights.
Programmer and internal documentation:
- libjpeg.txt How to use the JPEG library in your own programs.
- example.txt Sample code for calling the JPEG library.
- structure.txt Overview of the JPEG library's internal structure.
- coderules.txt Coding style rules --- please read if you contribute code.
+ doc/libjpeg.txt How to use the JPEG library in your own programs.
+ src/example.c Sample code for calling the JPEG library.
+ doc/structure.txt Overview of the JPEG library's internal structure.
+ doc/coderules.txt Coding style rules --- please read if you contribute
+ code.
Please read at least usage.txt. Some information can also be found in the JPEG
FAQ (Frequently Asked Questions) article. See ARCHIVE LOCATIONS below to find
@@ -68,17 +70,17 @@ other abrupt features may not compress well with JPEG, and a higher JPEG
quality may have to be used to avoid visible compression artifacts with such
images.
-JPEG is lossy, meaning that the output pixels are not necessarily identical to
-the input pixels. However, on photographic content and other "smooth" images,
-very good compression ratios can be obtained with no visible compression
-artifacts, and extremely high compression ratios are possible if you are
-willing to sacrifice image quality (by reducing the "quality" setting in the
-compressor.)
-
-This software implements JPEG baseline, extended-sequential, and progressive
-compression processes. Provision is made for supporting all variants of these
-processes, although some uncommon parameter settings aren't implemented yet.
-We have made no provision for supporting the hierarchical or lossless
+JPEG is normally lossy, meaning that the output pixels are not necessarily
+identical to the input pixels. However, on photographic content and other
+"smooth" images, very good compression ratios can be obtained with no visible
+compression artifacts, and extremely high compression ratios are possible if
+you are willing to sacrifice image quality (by reducing the "quality" setting
+in the compressor.)
+
+This software implements JPEG baseline, extended-sequential, progressive, and
+lossless compression processes. Provision is made for supporting all variants
+of these processes, although some uncommon parameter settings aren't
+implemented yet. We have made no provision for supporting the hierarchical
processes defined in the standard.
We provide a set of library routines for reading and writing JPEG image files,
@@ -89,9 +91,9 @@ The library is intended to be reused in other applications.
In order to support file conversion and viewing software, we have included
considerable functionality beyond the bare JPEG coding/decoding capability;
for example, the color quantization modules are not strictly part of JPEG
-decoding, but they are essential for output to colormapped file formats or
-colormapped displays. These extra functions can be compiled out of the
-library if not required for a particular application.
+decoding, but they are essential for output to colormapped file formats. These
+extra functions can be compiled out of the library if not required for a
+particular application.
We have also included "jpegtran", a utility for lossless transcoding between
different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
@@ -241,7 +243,7 @@ This software implements ITU T.81 | ISO/IEC 10918 with some extensions from
ITU T.871 | ISO/IEC 10918-5 (JPEG File Interchange Format-- see REFERENCES).
Informally, the term "JPEG image" or "JPEG file" most often refers to JFIF or
a subset thereof, but there are other formats containing the name "JPEG" that
-are incompatible with the DCT-based JPEG standard or with JFIF (for instance,
+are incompatible with the original JPEG standard or with JFIF (for instance,
JPEG 2000 and JPEG XR). This software therefore does not support these
formats. Indeed, one of the original reasons for developing this free software
was to help force convergence on a common, interoperable format standard for
diff --git a/contrib/libs/libjpeg-turbo/README.md b/contrib/libs/libjpeg-turbo/README.md
index 01e391ea7c0..86b5ea676a3 100644
--- a/contrib/libs/libjpeg-turbo/README.md
+++ b/contrib/libs/libjpeg-turbo/README.md
@@ -21,7 +21,26 @@ derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
VirtualGL projects made numerous enhancements to the codec in 2009, and in
early 2010, libjpeg-turbo spun off into an independent project, with the goal
of making high-speed JPEG compression/decompression technology available to a
-broader range of users and developers.
+broader range of users and developers. libjpeg-turbo is an ISO/IEC and ITU-T
+reference implementation of the JPEG standard.
+
+More information about libjpeg-turbo can be found at
+<https://libjpeg-turbo.org>.
+
+
+Funding
+=======
+
+libjpeg-turbo is an independent open source project, but we rely on patronage
+and funded development in order to maintain that independence. The easiest way
+to ensure that libjpeg-turbo remains community-focused and free of any one
+organization's agenda is to
+[sponsor our project through GitHub](https://github.com/sponsors/libjpeg-turbo).
+All sponsorship money goes directly toward funding the labor necessary to
+maintain libjpeg-turbo, support the user community, and implement bug fixes and
+strategically important features.
+
+[![Sponsor libjpeg-turbo](https://img.shields.io/github/sponsors/libjpeg-turbo?label=Sponsor&logo=GitHub)](https://github.com/sponsors/libjpeg-turbo)
License
@@ -50,9 +69,12 @@ JPEG images:
generating planar YUV images and performing multiple simultaneous lossless
transforms on an image. The Java interface for libjpeg-turbo is written on
top of the TurboJPEG API. The TurboJPEG API is recommended for first-time
- users of libjpeg-turbo. Refer to [tjexample.c](tjexample.c) and
- [TJExample.java](java/TJExample.java) for examples of its usage and to
- <http://libjpeg-turbo.org/Documentation/Documentation> for API documentation.
+ users of libjpeg-turbo. Refer to [tjcomp.c](src/tjcomp.c),
+ [tjdecomp.c](src/tjdecomp.c), [tjtran.c](src/tjtran.c),
+ [TJComp.java](java/TJComp.java), [TJDecomp.java](java/TJDecomp.java), and
+ [TJTran.java](java/TJTran.java) for examples of its usage and to
+ <https://libjpeg-turbo.org/Documentation/Documentation> for API
+ documentation.
- **libjpeg API**<br>
This is the de facto industry-standard API for compressing and decompressing
@@ -60,8 +82,9 @@ JPEG images:
more powerful. The libjpeg API implementation in libjpeg-turbo is both
API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
- (see below.) Refer to [cjpeg.c](cjpeg.c) and [djpeg.c](djpeg.c) for examples
- of its usage and to [libjpeg.txt](libjpeg.txt) for API documentation.
+ (see below.) Refer to [cjpeg.c](src/cjpeg.c) and [djpeg.c](src/djpeg.c) for
+ examples of its usage and to [libjpeg.txt](doc/libjpeg.txt) for API
+ documentation.
There is no significant performance advantage to either API when both are used
to perform similar operations.
@@ -113,9 +136,9 @@ extensions at compile time with:
#ifdef JCS_ALPHA_EXTENSIONS
-[jcstest.c](jcstest.c), located in the libjpeg-turbo source tree, demonstrates
-how to check for the existence of the colorspace extensions at compile time and
-run time.
+[jcstest.c](src/jcstest.c), located in the libjpeg-turbo source tree,
+demonstrates how to check for the existence of the colorspace extensions at
+compile time and run time.
libjpeg v7 and v8 API/ABI Emulation
-----------------------------------
@@ -180,7 +203,7 @@ supported and which aren't.
NOTE: As of this writing, extensive research has been conducted into the
usefulness of DCT scaling as a means of data reduction and SmartScale as a
means of quality improvement. Readers are invited to peruse the research at
-<http://www.libjpeg-turbo.org/About/SmartScale> and draw their own conclusions,
+<https://libjpeg-turbo.org/About/SmartScale> and draw their own conclusions,
but it is the general belief of our project that these features have not
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
@@ -245,16 +268,6 @@ programs that need them, without breaking ABI compatibility for programs that
don't, and it allows those functions to be provided in the "official"
libjpeg-turbo binaries.
-Those who are concerned about maintaining strict conformance with the libjpeg
-v6b or v7 API can pass an argument of `-DWITH_MEM_SRCDST=0` to `cmake` prior to
-building libjpeg-turbo. This will restore the pre-1.3 behavior, in which
-`jpeg_mem_src()` and `jpeg_mem_dest()` are only included when emulating the
-libjpeg v8 API/ABI.
-
-On Un*x systems, including the in-memory source/destination managers changes
-the dynamic library version from 62.2.0 to 62.3.0 if using libjpeg v6b API/ABI
-emulation and from 7.2.0 to 7.3.0 if using libjpeg v7 API/ABI emulation.
-
Note that, on most Un*x systems, the dynamic linker will not look for a
function in a library until that function is actually used. Thus, if a program
is built against libjpeg-turbo 1.3+ and uses `jpeg_mem_src()` or
@@ -274,30 +287,35 @@ Mathematical Compatibility
==========================
For the most part, libjpeg-turbo should produce identical output to libjpeg
-v6b. The one exception to this is when using the floating point DCT/IDCT, in
-which case the outputs of libjpeg v6b and libjpeg-turbo can differ for the
-following reasons:
-
-- The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever so
- slightly more accurate than the implementation in libjpeg v6b, but not by
- any amount perceptible to human vision (generally in the range of 0.01 to
- 0.08 dB gain in PNSR.)
-
-- When not using the SIMD extensions, libjpeg-turbo uses the more accurate
- (and slightly faster) floating point IDCT algorithm introduced in libjpeg
- v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
- however, that this algorithm basically brings the accuracy of the floating
- point IDCT in line with the accuracy of the accurate integer IDCT. The
- floating point DCT/IDCT algorithms are mainly a legacy feature, and they do
- not produce significantly more accuracy than the accurate integer algorithms
- (to put numbers on this, the typical difference in PNSR between the two
- algorithms is less than 0.10 dB, whereas changing the quality level by 1 in
- the upper range of the quality scale is typically more like a 1.0 dB
- difference.)
-
-- If the floating point algorithms in libjpeg-turbo are not implemented using
- SIMD instructions on a particular platform, then the accuracy of the
- floating point DCT/IDCT can depend on the compiler settings.
+v6b. There are two exceptions:
+
+1. When decompressing a JPEG image that uses 4:4:0 chrominance subsampling, the
+outputs of libjpeg v6b and libjpeg-turbo can differ because libjpeg-turbo
+implements a "fancy" (smooth) 4:4:0 upsampling algorithm and libjpeg did not.
+
+2. When using the floating point DCT/IDCT, the outputs of libjpeg v6b and
+libjpeg-turbo can differ for the following reasons:
+
+ - The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever
+ so slightly more accurate than the implementation in libjpeg v6b, but not
+ by any amount perceptible to human vision (generally in the range of 0.01
+ to 0.08 dB gain in PNSR.)
+
+ - When not using the SIMD extensions, libjpeg-turbo uses the more accurate
+ (and slightly faster) floating point IDCT algorithm introduced in libjpeg
+ v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
+ however, that this algorithm basically brings the accuracy of the
+ floating point IDCT in line with the accuracy of the accurate integer
+ IDCT. The floating point DCT/IDCT algorithms are mainly a legacy
+ feature, and they do not produce significantly more accuracy than the
+ accurate integer algorithms. (To put numbers on this, the typical
+ difference in PNSR between the two algorithms is less than 0.10 dB,
+ whereas changing the quality level by 1 in the upper range of the quality
+ scale is typically more like a 1.0 dB difference.)
+
+ - If the floating point algorithms in libjpeg-turbo are not implemented
+ using SIMD instructions on a particular platform, then the accuracy of
+ the floating point DCT/IDCT can depend on the compiler settings.
While libjpeg-turbo does emulate the libjpeg v8 API/ABI, under the hood it is
still using the same algorithms as libjpeg v6b, so there are several specific
diff --git a/contrib/libs/libjpeg-turbo/cjpeg/ya.make b/contrib/libs/libjpeg-turbo/cjpeg/ya.make
index 75881b2ccf8..025c372ed83 100644
--- a/contrib/libs/libjpeg-turbo/cjpeg/ya.make
+++ b/contrib/libs/libjpeg-turbo/cjpeg/ya.make
@@ -4,7 +4,7 @@ PROGRAM()
WITHOUT_LICENSE_TEXTS()
-VERSION(2.1.4)
+VERSION(3.1.1)
PEERDIR(
contrib/libs/libjpeg-turbo
@@ -12,6 +12,7 @@ PEERDIR(
ADDINCL(
contrib/libs/libjpeg-turbo
+ contrib/libs/libjpeg-turbo/src
)
NO_COMPILER_WARNINGS()
@@ -25,16 +26,18 @@ CFLAGS(
-DTARGA_SUPPORTED
)
-SRCDIR(contrib/libs/libjpeg-turbo)
+SRCDIR(contrib/libs/libjpeg-turbo/src)
SRCS(
cdjpeg.c
cjpeg.c
rdbmp.c
rdgif.c
- rdppm.c
rdswitch.c
rdtarga.c
+ wrapper/rdppm-12.c
+ wrapper/rdppm-16.c
+ wrapper/rdppm-8.c
)
END()
diff --git a/contrib/libs/libjpeg-turbo/cmyk.h b/contrib/libs/libjpeg-turbo/cmyk.h
deleted file mode 100644
index 48187a8f5dc..00000000000
--- a/contrib/libs/libjpeg-turbo/cmyk.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * cmyk.h
- *
- * Copyright (C) 2017-2018, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains convenience functions for performing quick & dirty
- * CMYK<->RGB conversion. This algorithm is suitable for testing purposes
- * only. Properly converting between CMYK and RGB requires a color management
- * system.
- */
-
-#ifndef CMYK_H
-#define CMYK_H
-
-#include <jinclude.h>
-#define JPEG_INTERNALS
-#include <jpeglib.h>
-#include "jconfigint.h"
-
-
-/* Fully reversible */
-
-INLINE
-LOCAL(void)
-rgb_to_cmyk(JSAMPLE r, JSAMPLE g, JSAMPLE b, JSAMPLE *c, JSAMPLE *m,
- JSAMPLE *y, JSAMPLE *k)
-{
- double ctmp = 1.0 - ((double)r / 255.0);
- double mtmp = 1.0 - ((double)g / 255.0);
- double ytmp = 1.0 - ((double)b / 255.0);
- double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
-
- if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
- else {
- ctmp = (ctmp - ktmp) / (1.0 - ktmp);
- mtmp = (mtmp - ktmp) / (1.0 - ktmp);
- ytmp = (ytmp - ktmp) / (1.0 - ktmp);
- }
- *c = (JSAMPLE)(255.0 - ctmp * 255.0 + 0.5);
- *m = (JSAMPLE)(255.0 - mtmp * 255.0 + 0.5);
- *y = (JSAMPLE)(255.0 - ytmp * 255.0 + 0.5);
- *k = (JSAMPLE)(255.0 - ktmp * 255.0 + 0.5);
-}
-
-
-/* Fully reversible only for C/M/Y/K values generated with rgb_to_cmyk() */
-
-INLINE
-LOCAL(void)
-cmyk_to_rgb(JSAMPLE c, JSAMPLE m, JSAMPLE y, JSAMPLE k, JSAMPLE *r, JSAMPLE *g,
- JSAMPLE *b)
-{
- *r = (JSAMPLE)((double)c * (double)k / 255.0 + 0.5);
- *g = (JSAMPLE)((double)m * (double)k / 255.0 + 0.5);
- *b = (JSAMPLE)((double)y * (double)k / 255.0 + 0.5);
-}
-
-
-#endif /* CMYK_H */
diff --git a/contrib/libs/libjpeg-turbo/djpeg/ya.make b/contrib/libs/libjpeg-turbo/djpeg/ya.make
index e30290ecd41..5aa038c8420 100644
--- a/contrib/libs/libjpeg-turbo/djpeg/ya.make
+++ b/contrib/libs/libjpeg-turbo/djpeg/ya.make
@@ -4,7 +4,7 @@ PROGRAM()
WITHOUT_LICENSE_TEXTS()
-VERSION(2.1.4)
+VERSION(3.1.1)
PEERDIR(
contrib/libs/libjpeg-turbo
@@ -12,6 +12,7 @@ PEERDIR(
ADDINCL(
contrib/libs/libjpeg-turbo
+ contrib/libs/libjpeg-turbo/src
)
NO_COMPILER_WARNINGS()
@@ -25,16 +26,20 @@ CFLAGS(
-DTARGA_SUPPORTED
)
-SRCDIR(contrib/libs/libjpeg-turbo)
+SRCDIR(contrib/libs/libjpeg-turbo/src)
SRCS(
cdjpeg.c
djpeg.c
- rdcolmap.c
rdswitch.c
+ wrapper/rdcolmap-12.c
+ wrapper/rdcolmap-8.c
+ wrapper/wrgif-12.c
+ wrapper/wrgif-8.c
+ wrapper/wrppm-12.c
+ wrapper/wrppm-16.c
+ wrapper/wrppm-8.c
wrbmp.c
- wrgif.c
- wrppm.c
wrtarga.c
)
diff --git a/contrib/libs/libjpeg-turbo/jcinit.c b/contrib/libs/libjpeg-turbo/jcinit.c
deleted file mode 100644
index 157353a22e9..00000000000
--- a/contrib/libs/libjpeg-turbo/jcinit.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * jcinit.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains initialization logic for the JPEG compressor.
- * This routine is in charge of selecting the modules to be executed and
- * making an initialization call to each one.
- *
- * Logically, this code belongs in jcmaster.c. It's split out because
- * linking this routine implies linking the entire compression library.
- * For a transcoding-only application, we want to be able to use jcmaster.c
- * without linking in the whole library.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-
-
-/*
- * Master selection of compression modules.
- * This is done once at the start of processing an image. We determine
- * which modules will be used and give them appropriate initialization calls.
- */
-
-GLOBAL(void)
-jinit_compress_master(j_compress_ptr cinfo)
-{
- /* Initialize master control (includes parameter checking/processing) */
- jinit_c_master_control(cinfo, FALSE /* full compression */);
-
- /* Preprocessing */
- if (!cinfo->raw_data_in) {
- jinit_color_converter(cinfo);
- jinit_downsampler(cinfo);
- jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
- }
- /* Forward DCT */
- jinit_forward_dct(cinfo);
- /* Entropy encoding: either Huffman or arithmetic coding. */
- if (cinfo->arith_code) {
-#ifdef C_ARITH_CODING_SUPPORTED
- jinit_arith_encoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
-#endif
- } else {
- if (cinfo->progressive_mode) {
-#ifdef C_PROGRESSIVE_SUPPORTED
- jinit_phuff_encoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else
- jinit_huff_encoder(cinfo);
- }
-
- /* Need a full-image coefficient buffer in any multi-pass mode. */
- jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
- cinfo->optimize_coding));
- jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
-
- jinit_marker_writer(cinfo);
-
- /* We can now tell the memory manager to allocate virtual arrays. */
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- /* Write the datastream header (SOI) immediately.
- * Frame and scan headers are postponed till later.
- * This lets application insert special markers after the SOI.
- */
- (*cinfo->marker->write_file_header) (cinfo);
-}
diff --git a/contrib/libs/libjpeg-turbo/jconfig.h b/contrib/libs/libjpeg-turbo/jconfig.h
index 7dffead627a..47cb0e8c889 100644
--- a/contrib/libs/libjpeg-turbo/jconfig.h
+++ b/contrib/libs/libjpeg-turbo/jconfig.h
@@ -4,34 +4,57 @@
#define JPEG_LIB_VERSION 62
/* libjpeg-turbo version */
-#define LIBJPEG_TURBO_VERSION 2.1.4
+#define LIBJPEG_TURBO_VERSION 3.1.1
/* libjpeg-turbo version in integer form */
-#define LIBJPEG_TURBO_VERSION_NUMBER 2001004
+#define LIBJPEG_TURBO_VERSION_NUMBER 3001001
-/* Support arithmetic encoding */
+/* Support arithmetic encoding when using 8-bit samples */
#define C_ARITH_CODING_SUPPORTED 1
-/* Support arithmetic decoding */
+/* Support arithmetic decoding when using 8-bit samples */
#define D_ARITH_CODING_SUPPORTED 1
/* Support in-memory source/destination managers */
-#define MEM_SRCDST_SUPPORTED 1
+#define MEM_SRCDST_SUPPORTED 1
-/* Use accelerated SIMD routines. */
+/* Use accelerated SIMD routines when using 8-bit samples */
#define WITH_SIMD 1
-/*
- * Define BITS_IN_JSAMPLE as either
- * 8 for 8-bit sample values (the usual setting)
- * 12 for 12-bit sample values
- * Only 8 and 12 are legal data precisions for lossy JPEG according to the
- * JPEG standard, and the IJG code does not support anything else!
- * We do not support run-time selection of data precision, sorry.
+/* This version of libjpeg-turbo supports run-time selection of data precision,
+ * so BITS_IN_JSAMPLE is no longer used to specify the data precision at build
+ * time. However, some downstream software expects the macro to be defined.
+ * Since 12-bit data precision is an opt-in feature that requires explicitly
+ * calling 12-bit-specific libjpeg API functions and using 12-bit-specific data
+ * types, the unmodified portion of the libjpeg API still behaves as if it were
+ * built for 8-bit precision, and JSAMPLE is still literally an 8-bit data
+ * type. Thus, it is correct to define BITS_IN_JSAMPLE to 8 here.
*/
+#ifndef BITS_IN_JSAMPLE
+#define BITS_IN_JSAMPLE 8
+#endif
-#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
+#ifdef _WIN32
+
+#undef RIGHT_SHIFT_IS_UNSIGNED
+
+/* Define "boolean" as unsigned char, not int, per Windows custom */
+#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
+typedef unsigned char boolean;
+#endif
+#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
+
+/* Define "INT32" as int, not long, per Windows custom */
+#if !(defined(_BASETSD_H_) || defined(_BASETSD_H)) /* don't conflict if basetsd.h already read */
+typedef short INT16;
+typedef signed int INT32;
+#endif
+#define XMD_H /* prevent jmorecfg.h from redefining it */
+
+#else
/* Define if your (broken) compiler shifts signed values as if they were
unsigned. */
/* #undef RIGHT_SHIFT_IS_UNSIGNED */
+
+#endif
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-linux.h b/contrib/libs/libjpeg-turbo/jconfigint-linux.h
index 5dfd5568503..ea44899ba52 100644
--- a/contrib/libs/libjpeg-turbo/jconfigint-linux.h
+++ b/contrib/libs/libjpeg-turbo/jconfigint-linux.h
@@ -1,6 +1,9 @@
/* libjpeg-turbo build number */
#define BUILD "19800101"
+/* How to hide global symbols. */
+#define HIDDEN __attribute__((visibility("hidden")))
+
/* Compiler's inline keyword */
#undef inline
@@ -14,7 +17,7 @@
#define PACKAGE_NAME "libjpeg-turbo"
/* Version number of package */
-#define VERSION "2.1.4"
+#define VERSION "3.1.1"
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 8
@@ -42,3 +45,32 @@
#else
#define FALLTHROUGH
#endif
+
+/*
+ * Define BITS_IN_JSAMPLE as either
+ * 8 for 8-bit sample values (the usual setting)
+ * 12 for 12-bit sample values
+ * Only 8 and 12 are legal data precisions for lossy JPEG according to the
+ * JPEG standard, and the IJG code does not support anything else!
+ */
+
+#ifndef BITS_IN_JSAMPLE
+#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
+#endif
+
+#undef C_ARITH_CODING_SUPPORTED
+#undef D_ARITH_CODING_SUPPORTED
+#undef WITH_SIMD
+
+#if BITS_IN_JSAMPLE == 8
+
+/* Support arithmetic encoding */
+#define C_ARITH_CODING_SUPPORTED 1
+
+/* Support arithmetic decoding */
+#define D_ARITH_CODING_SUPPORTED 1
+
+/* Use accelerated SIMD routines. */
+#define WITH_SIMD 1
+
+#endif
diff --git a/contrib/libs/libjpeg-turbo/jconfigint-x86.h b/contrib/libs/libjpeg-turbo/jconfigint-x86.h
index ac296c7a3e7..a94200685a7 100644
--- a/contrib/libs/libjpeg-turbo/jconfigint-x86.h
+++ b/contrib/libs/libjpeg-turbo/jconfigint-x86.h
@@ -4,3 +4,7 @@
#undef SIZEOF_SIZE_T
#define SIZEOF_SIZE_T 4
+
+#ifdef __ANDROID__
+#undef WITH_SIMD
+#endif
diff --git a/contrib/libs/libjpeg-turbo/jdmaster.c b/contrib/libs/libjpeg-turbo/jdmaster.c
deleted file mode 100644
index a3690bf560b..00000000000
--- a/contrib/libs/libjpeg-turbo/jdmaster.c
+++ /dev/null
@@ -1,726 +0,0 @@
-/*
- * jdmaster.c
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2019, 2022, D. R. Commander.
- * Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains master control logic for the JPEG decompressor.
- * These routines are concerned with selecting the modules to be executed
- * and with determining the number of passes and the work to be done in each
- * pass.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jpegcomp.h"
-#include "jdmaster.h"
-
-
-/*
- * Determine whether merged upsample/color conversion should be used.
- * CRUCIAL: this must match the actual capabilities of jdmerge.c!
- */
-
-LOCAL(boolean)
-use_merged_upsample(j_decompress_ptr cinfo)
-{
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- /* Merging is the equivalent of plain box-filter upsampling */
- if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
- return FALSE;
- /* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */
- if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
- (cinfo->out_color_space != JCS_RGB &&
- cinfo->out_color_space != JCS_RGB565 &&
- cinfo->out_color_space != JCS_EXT_RGB &&
- cinfo->out_color_space != JCS_EXT_RGBX &&
- cinfo->out_color_space != JCS_EXT_BGR &&
- cinfo->out_color_space != JCS_EXT_BGRX &&
- cinfo->out_color_space != JCS_EXT_XBGR &&
- cinfo->out_color_space != JCS_EXT_XRGB &&
- cinfo->out_color_space != JCS_EXT_RGBA &&
- cinfo->out_color_space != JCS_EXT_BGRA &&
- cinfo->out_color_space != JCS_EXT_ABGR &&
- cinfo->out_color_space != JCS_EXT_ARGB))
- return FALSE;
- if ((cinfo->out_color_space == JCS_RGB565 &&
- cinfo->out_color_components != 3) ||
- (cinfo->out_color_space != JCS_RGB565 &&
- cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]))
- return FALSE;
- /* and it only handles 2h1v or 2h2v sampling ratios */
- if (cinfo->comp_info[0].h_samp_factor != 2 ||
- cinfo->comp_info[1].h_samp_factor != 1 ||
- cinfo->comp_info[2].h_samp_factor != 1 ||
- cinfo->comp_info[0].v_samp_factor > 2 ||
- cinfo->comp_info[1].v_samp_factor != 1 ||
- cinfo->comp_info[2].v_samp_factor != 1)
- return FALSE;
- /* furthermore, it doesn't work if we've scaled the IDCTs differently */
- if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
- cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
- cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
- return FALSE;
- /* ??? also need to test for upsample-time rescaling, when & if supported */
- return TRUE; /* by golly, it'll work... */
-#else
- return FALSE;
-#endif
-}
-
-
-/*
- * Compute output image dimensions and related values.
- * NOTE: this is exported for possible use by application.
- * Hence it mustn't do anything that can't be done twice.
- */
-
-#if JPEG_LIB_VERSION >= 80
-GLOBAL(void)
-#else
-LOCAL(void)
-#endif
-jpeg_core_output_dimensions(j_decompress_ptr cinfo)
-/* Do computations that are needed before master selection phase.
- * This function is used for transcoding and full decompression.
- */
-{
-#ifdef IDCT_SCALING_SUPPORTED
- int ci;
- jpeg_component_info *compptr;
-
- /* Compute actual output image dimensions and DCT scaling choices. */
- if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
- /* Provide 1/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 1;
- cinfo->_min_DCT_v_scaled_size = 1;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
- /* Provide 2/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 2L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 2;
- cinfo->_min_DCT_v_scaled_size = 2;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
- /* Provide 3/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 3L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 3;
- cinfo->_min_DCT_v_scaled_size = 3;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
- /* Provide 4/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 4L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 4;
- cinfo->_min_DCT_v_scaled_size = 4;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
- /* Provide 5/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 5L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 5L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 5;
- cinfo->_min_DCT_v_scaled_size = 5;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
- /* Provide 6/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 6L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 6L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 6;
- cinfo->_min_DCT_v_scaled_size = 6;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
- /* Provide 7/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 7L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 7L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 7;
- cinfo->_min_DCT_v_scaled_size = 7;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
- /* Provide 8/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 8;
- cinfo->_min_DCT_v_scaled_size = 8;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) {
- /* Provide 9/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 9L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 9L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 9;
- cinfo->_min_DCT_v_scaled_size = 9;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 10) {
- /* Provide 10/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 10L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 10L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 10;
- cinfo->_min_DCT_v_scaled_size = 10;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 11) {
- /* Provide 11/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 11L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 11L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 11;
- cinfo->_min_DCT_v_scaled_size = 11;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 12) {
- /* Provide 12/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 12L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 12L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 12;
- cinfo->_min_DCT_v_scaled_size = 12;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 13) {
- /* Provide 13/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 13L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 13L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 13;
- cinfo->_min_DCT_v_scaled_size = 13;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 14) {
- /* Provide 14/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 14L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 14L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 14;
- cinfo->_min_DCT_v_scaled_size = 14;
- } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 15) {
- /* Provide 15/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 15L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 15L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 15;
- cinfo->_min_DCT_v_scaled_size = 15;
- } else {
- /* Provide 16/block_size scaling */
- cinfo->output_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width * 16L, (long)DCTSIZE);
- cinfo->output_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE);
- cinfo->_min_DCT_h_scaled_size = 16;
- cinfo->_min_DCT_v_scaled_size = 16;
- }
-
- /* Recompute dimensions of components */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
- compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
- }
-
-#else /* !IDCT_SCALING_SUPPORTED */
-
- /* Hardwire it to "no scaling" */
- cinfo->output_width = cinfo->image_width;
- cinfo->output_height = cinfo->image_height;
- /* jdinput.c has already initialized DCT_scaled_size,
- * and has computed unscaled downsampled_width and downsampled_height.
- */
-
-#endif /* IDCT_SCALING_SUPPORTED */
-}
-
-
-/*
- * Compute output image dimensions and related values.
- * NOTE: this is exported for possible use by application.
- * Hence it mustn't do anything that can't be done twice.
- * Also note that it may be called before the master module is initialized!
- */
-
-GLOBAL(void)
-jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
-/* Do computations that are needed before master selection phase */
-{
-#ifdef IDCT_SCALING_SUPPORTED
- int ci;
- jpeg_component_info *compptr;
-#endif
-
- /* Prevent application from calling me at wrong times */
- if (cinfo->global_state != DSTATE_READY)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- /* Compute core output image dimensions and DCT scaling choices. */
- jpeg_core_output_dimensions(cinfo);
-
-#ifdef IDCT_SCALING_SUPPORTED
-
- /* In selecting the actual DCT scaling for each component, we try to
- * scale up the chroma components via IDCT scaling rather than upsampling.
- * This saves time if the upsampler gets to use 1:1 scaling.
- * Note this code adapts subsampling ratios which are powers of 2.
- */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- int ssize = cinfo->_min_DCT_scaled_size;
- while (ssize < DCTSIZE &&
- ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) %
- (compptr->h_samp_factor * ssize * 2) == 0) &&
- ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) %
- (compptr->v_samp_factor * ssize * 2) == 0)) {
- ssize = ssize * 2;
- }
-#if JPEG_LIB_VERSION >= 70
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
-#else
- compptr->DCT_scaled_size = ssize;
-#endif
- }
-
- /* Recompute downsampled dimensions of components;
- * application needs to know these if using raw downsampled data.
- */
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- /* Size in samples, after IDCT scaling */
- compptr->downsampled_width = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_width *
- (long)(compptr->h_samp_factor * compptr->_DCT_scaled_size),
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
- compptr->downsampled_height = (JDIMENSION)
- jdiv_round_up((long)cinfo->image_height *
- (long)(compptr->v_samp_factor * compptr->_DCT_scaled_size),
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
- }
-
-#else /* !IDCT_SCALING_SUPPORTED */
-
- /* Hardwire it to "no scaling" */
- cinfo->output_width = cinfo->image_width;
- cinfo->output_height = cinfo->image_height;
- /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
- * and has computed unscaled downsampled_width and downsampled_height.
- */
-
-#endif /* IDCT_SCALING_SUPPORTED */
-
- /* Report number of components in selected colorspace. */
- /* Probably this should be in the color conversion module... */
- switch (cinfo->out_color_space) {
- case JCS_GRAYSCALE:
- cinfo->out_color_components = 1;
- break;
- case JCS_RGB:
- case JCS_EXT_RGB:
- case JCS_EXT_RGBX:
- case JCS_EXT_BGR:
- case JCS_EXT_BGRX:
- case JCS_EXT_XBGR:
- case JCS_EXT_XRGB:
- case JCS_EXT_RGBA:
- case JCS_EXT_BGRA:
- case JCS_EXT_ABGR:
- case JCS_EXT_ARGB:
- cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
- break;
- case JCS_YCbCr:
- case JCS_RGB565:
- cinfo->out_color_components = 3;
- break;
- case JCS_CMYK:
- case JCS_YCCK:
- cinfo->out_color_components = 4;
- break;
- default: /* else must be same colorspace as in file */
- cinfo->out_color_components = cinfo->num_components;
- break;
- }
- cinfo->output_components = (cinfo->quantize_colors ? 1 :
- cinfo->out_color_components);
-
- /* See if upsampler will want to emit more than one row at a time */
- if (use_merged_upsample(cinfo))
- cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
- else
- cinfo->rec_outbuf_height = 1;
-}
-
-
-/*
- * Several decompression processes need to range-limit values to the range
- * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
- * due to noise introduced by quantization, roundoff error, etc. These
- * processes are inner loops and need to be as fast as possible. On most
- * machines, particularly CPUs with pipelines or instruction prefetch,
- * a (subscript-check-less) C table lookup
- * x = sample_range_limit[x];
- * is faster than explicit tests
- * if (x < 0) x = 0;
- * else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
- * These processes all use a common table prepared by the routine below.
- *
- * For most steps we can mathematically guarantee that the initial value
- * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
- * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
- * limiting step (just after the IDCT), a wildly out-of-range value is
- * possible if the input data is corrupt. To avoid any chance of indexing
- * off the end of memory and getting a bad-pointer trap, we perform the
- * post-IDCT limiting thus:
- * x = range_limit[x & MASK];
- * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
- * samples. Under normal circumstances this is more than enough range and
- * a correct output will be generated; with bogus input data the mask will
- * cause wraparound, and we will safely generate a bogus-but-in-range output.
- * For the post-IDCT step, we want to convert the data from signed to unsigned
- * representation by adding CENTERJSAMPLE at the same time that we limit it.
- * So the post-IDCT limiting table ends up looking like this:
- * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
- * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
- * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
- * 0,1,...,CENTERJSAMPLE-1
- * Negative inputs select values from the upper half of the table after
- * masking.
- *
- * We can save some space by overlapping the start of the post-IDCT table
- * with the simpler range limiting table. The post-IDCT table begins at
- * sample_range_limit + CENTERJSAMPLE.
- */
-
-LOCAL(void)
-prepare_range_limit_table(j_decompress_ptr cinfo)
-/* Allocate and fill in the sample_range_limit table */
-{
- JSAMPLE *table;
- int i;
-
- table = (JSAMPLE *)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
- table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
- cinfo->sample_range_limit = table;
- /* First segment of "simple" table: limit[x] = 0 for x < 0 */
- memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
- /* Main part of "simple" table: limit[x] = x */
- for (i = 0; i <= MAXJSAMPLE; i++)
- table[i] = (JSAMPLE)i;
- table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
- /* End of simple table, rest of first half of post-IDCT table */
- for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
- table[i] = MAXJSAMPLE;
- /* Second half of post-IDCT table */
- memset(table + (2 * (MAXJSAMPLE + 1)), 0,
- (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
- memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
- cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
-}
-
-
-/*
- * Master selection of decompression modules.
- * This is done once at jpeg_start_decompress time. We determine
- * which modules will be used and give them appropriate initialization calls.
- * We also initialize the decompressor input side to begin consuming data.
- *
- * Since jpeg_read_header has finished, we know what is in the SOF
- * and (first) SOS markers. We also have all the application parameter
- * settings.
- */
-
-LOCAL(void)
-master_selection(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
- boolean use_c_buffer;
- long samplesperrow;
- JDIMENSION jd_samplesperrow;
-
- /* Initialize dimensions and other stuff */
- jpeg_calc_output_dimensions(cinfo);
- prepare_range_limit_table(cinfo);
-
- /* Width of an output scanline must be representable as JDIMENSION. */
- samplesperrow = (long)cinfo->output_width *
- (long)cinfo->out_color_components;
- jd_samplesperrow = (JDIMENSION)samplesperrow;
- if ((long)jd_samplesperrow != samplesperrow)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-
- /* Initialize my private state */
- master->pass_number = 0;
- master->using_merged_upsample = use_merged_upsample(cinfo);
-
- /* Color quantizer selection */
- master->quantizer_1pass = NULL;
- master->quantizer_2pass = NULL;
- /* No mode changes if not using buffered-image mode. */
- if (!cinfo->quantize_colors || !cinfo->buffered_image) {
- cinfo->enable_1pass_quant = FALSE;
- cinfo->enable_external_quant = FALSE;
- cinfo->enable_2pass_quant = FALSE;
- }
- if (cinfo->quantize_colors) {
- if (cinfo->raw_data_out)
- ERREXIT(cinfo, JERR_NOTIMPL);
- /* 2-pass quantizer only works in 3-component color space. */
- if (cinfo->out_color_components != 3) {
- cinfo->enable_1pass_quant = TRUE;
- cinfo->enable_external_quant = FALSE;
- cinfo->enable_2pass_quant = FALSE;
- cinfo->colormap = NULL;
- } else if (cinfo->colormap != NULL) {
- cinfo->enable_external_quant = TRUE;
- } else if (cinfo->two_pass_quantize) {
- cinfo->enable_2pass_quant = TRUE;
- } else {
- cinfo->enable_1pass_quant = TRUE;
- }
-
- if (cinfo->enable_1pass_quant) {
-#ifdef QUANT_1PASS_SUPPORTED
- jinit_1pass_quantizer(cinfo);
- master->quantizer_1pass = cinfo->cquantize;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- }
-
- /* We use the 2-pass code to map to external colormaps. */
- if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
-#ifdef QUANT_2PASS_SUPPORTED
- jinit_2pass_quantizer(cinfo);
- master->quantizer_2pass = cinfo->cquantize;
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- }
- /* If both quantizers are initialized, the 2-pass one is left active;
- * this is necessary for starting with quantization to an external map.
- */
- }
-
- /* Post-processing: in particular, color conversion first */
- if (!cinfo->raw_data_out) {
- if (master->using_merged_upsample) {
-#ifdef UPSAMPLE_MERGING_SUPPORTED
- jinit_merged_upsampler(cinfo); /* does color conversion too */
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else {
- jinit_color_deconverter(cinfo);
- jinit_upsampler(cinfo);
- }
- jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
- }
- /* Inverse DCT */
- jinit_inverse_dct(cinfo);
- /* Entropy decoding: either Huffman or arithmetic coding. */
- if (cinfo->arith_code) {
-#ifdef D_ARITH_CODING_SUPPORTED
- jinit_arith_decoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
-#endif
- } else {
- if (cinfo->progressive_mode) {
-#ifdef D_PROGRESSIVE_SUPPORTED
- jinit_phuff_decoder(cinfo);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
- } else
- jinit_huff_decoder(cinfo);
- }
-
- /* Initialize principal buffer controllers. */
- use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
- jinit_d_coef_controller(cinfo, use_c_buffer);
-
- if (!cinfo->raw_data_out)
- jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
-
- /* We can now tell the memory manager to allocate virtual arrays. */
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- /* Initialize input side of decompressor to consume first scan. */
- (*cinfo->inputctl->start_input_pass) (cinfo);
-
- /* Set the first and last iMCU columns to decompress from single-scan images.
- * By default, decompress all of the iMCU columns.
- */
- cinfo->master->first_iMCU_col = 0;
- cinfo->master->last_iMCU_col = cinfo->MCUs_per_row - 1;
- cinfo->master->last_good_iMCU_row = 0;
-
-#ifdef D_MULTISCAN_FILES_SUPPORTED
- /* If jpeg_start_decompress will read the whole file, initialize
- * progress monitoring appropriately. The input step is counted
- * as one pass.
- */
- if (cinfo->progress != NULL && !cinfo->buffered_image &&
- cinfo->inputctl->has_multiple_scans) {
- int nscans;
- /* Estimate number of scans to set pass_limit. */
- if (cinfo->progressive_mode) {
- /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
- nscans = 2 + 3 * cinfo->num_components;
- } else {
- /* For a nonprogressive multiscan file, estimate 1 scan per component. */
- nscans = cinfo->num_components;
- }
- cinfo->progress->pass_counter = 0L;
- cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
- cinfo->progress->completed_passes = 0;
- cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
- /* Count the input pass as done */
- master->pass_number++;
- }
-#endif /* D_MULTISCAN_FILES_SUPPORTED */
-}
-
-
-/*
- * Per-pass setup.
- * This is called at the beginning of each output pass. We determine which
- * modules will be active during this pass and give them appropriate
- * start_pass calls. We also set is_dummy_pass to indicate whether this
- * is a "real" output pass or a dummy pass for color quantization.
- * (In the latter case, jdapistd.c will crank the pass to completion.)
- */
-
-METHODDEF(void)
-prepare_for_output_pass(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- if (master->pub.is_dummy_pass) {
-#ifdef QUANT_2PASS_SUPPORTED
- /* Final pass of 2-pass quantization */
- master->pub.is_dummy_pass = FALSE;
- (*cinfo->cquantize->start_pass) (cinfo, FALSE);
- (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
- (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
-#else
- ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif /* QUANT_2PASS_SUPPORTED */
- } else {
- if (cinfo->quantize_colors && cinfo->colormap == NULL) {
- /* Select new quantization method */
- if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
- cinfo->cquantize = master->quantizer_2pass;
- master->pub.is_dummy_pass = TRUE;
- } else if (cinfo->enable_1pass_quant) {
- cinfo->cquantize = master->quantizer_1pass;
- } else {
- ERREXIT(cinfo, JERR_MODE_CHANGE);
- }
- }
- (*cinfo->idct->start_pass) (cinfo);
- (*cinfo->coef->start_output_pass) (cinfo);
- if (!cinfo->raw_data_out) {
- if (!master->using_merged_upsample)
- (*cinfo->cconvert->start_pass) (cinfo);
- (*cinfo->upsample->start_pass) (cinfo);
- if (cinfo->quantize_colors)
- (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
- (*cinfo->post->start_pass) (cinfo,
- (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
- (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
- }
- }
-
- /* Set up progress monitor's pass info if present */
- if (cinfo->progress != NULL) {
- cinfo->progress->completed_passes = master->pass_number;
- cinfo->progress->total_passes = master->pass_number +
- (master->pub.is_dummy_pass ? 2 : 1);
- /* In buffered-image mode, we assume one more output pass if EOI not
- * yet reached, but no more passes if EOI has been reached.
- */
- if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached) {
- cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
- }
- }
-}
-
-
-/*
- * Finish up at end of an output pass.
- */
-
-METHODDEF(void)
-finish_output_pass(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- if (cinfo->quantize_colors)
- (*cinfo->cquantize->finish_pass) (cinfo);
- master->pass_number++;
-}
-
-
-#ifdef D_MULTISCAN_FILES_SUPPORTED
-
-/*
- * Switch to a new external colormap between output passes.
- */
-
-GLOBAL(void)
-jpeg_new_colormap(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- /* Prevent application from calling me at wrong times */
- if (cinfo->global_state != DSTATE_BUFIMAGE)
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-
- if (cinfo->quantize_colors && cinfo->enable_external_quant &&
- cinfo->colormap != NULL) {
- /* Select 2-pass quantizer for external colormap use */
- cinfo->cquantize = master->quantizer_2pass;
- /* Notify quantizer of colormap change */
- (*cinfo->cquantize->new_color_map) (cinfo);
- master->pub.is_dummy_pass = FALSE; /* just in case */
- } else
- ERREXIT(cinfo, JERR_MODE_CHANGE);
-}
-
-#endif /* D_MULTISCAN_FILES_SUPPORTED */
-
-
-/*
- * Initialize master decompression control and select active modules.
- * This is performed at the start of jpeg_start_decompress.
- */
-
-GLOBAL(void)
-jinit_master_decompress(j_decompress_ptr cinfo)
-{
- my_master_ptr master = (my_master_ptr)cinfo->master;
-
- master->pub.prepare_for_output_pass = prepare_for_output_pass;
- master->pub.finish_output_pass = finish_output_pass;
-
- master->pub.is_dummy_pass = FALSE;
- master->pub.jinit_upsampler_no_alloc = FALSE;
-
- master_selection(cinfo);
-}
diff --git a/contrib/libs/libjpeg-turbo/jerror.h b/contrib/libs/libjpeg-turbo/jerror.h
index eb44a1140a2..9a676d56766 100644
--- a/contrib/libs/libjpeg-turbo/jerror.h
+++ b/contrib/libs/libjpeg-turbo/jerror.h
@@ -1,331 +1 @@
-/*
- * jerror.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1994-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2014, 2017, 2021-2022, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file defines the error and message codes for the JPEG library.
- * Edit this file to add new codes, or to translate the message strings to
- * some other language.
- * A set of error-reporting macros are defined too. Some applications using
- * the JPEG library may wish to include this file to get the error codes
- * and/or the macros.
- */
-
-/*
- * To define the enum list of message codes, include this file without
- * defining macro JMESSAGE. To create a message string table, include it
- * again with a suitable JMESSAGE definition (see jerror.c for an example).
- */
-#ifndef JMESSAGE
-#ifndef JERROR_H
-/* First time through, define the enum list */
-#define JMAKE_ENUM_LIST
-#else
-/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
-#define JMESSAGE(code, string)
-#endif /* JERROR_H */
-#endif /* JMESSAGE */
-
-#ifdef JMAKE_ENUM_LIST
-
-typedef enum {
-
-#define JMESSAGE(code, string) code,
-
-#endif /* JMAKE_ENUM_LIST */
-
-JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
-
-/* For maintenance convenience, list is alphabetical by message code name */
-#if JPEG_LIB_VERSION < 70
-JMESSAGE(JERR_ARITH_NOTIMPL, "Sorry, arithmetic coding is not implemented")
-#endif
-JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
-JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
-JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
-JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
-#endif
-JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
-JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JERR_BAD_DROP_SAMPLING,
- "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
-#endif
-JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
-JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
-JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
-JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
-JMESSAGE(JERR_BAD_LIB_VERSION,
- "Wrong JPEG library version: library is %d, caller expects %d")
-JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
-JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
-JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
-JMESSAGE(JERR_BAD_PROGRESSION,
- "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d")
-JMESSAGE(JERR_BAD_PROG_SCRIPT,
- "Invalid progressive parameters at scan script entry %d")
-JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
-JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
-JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
-JMESSAGE(JERR_BAD_STRUCT_SIZE,
- "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
-JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
-JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
-JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
-JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
-JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
-JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
-JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
-JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
-JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
-JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
-JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
-JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
-JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
-JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
-JMESSAGE(JERR_FILE_READ, "Input file read error")
-JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
-JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
-JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
-JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
-JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
-JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
-JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
-JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
- "Cannot transcode due to multiple use of quantization table %d")
-JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
-JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
-JMESSAGE(JERR_NOTIMPL, "Requested features are incompatible")
-JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
-#endif
-JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
-JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
-JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
-JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
-JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
-JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
-JMESSAGE(JERR_QUANT_COMPONENTS,
- "Cannot quantize more than %d color components")
-JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
-JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
-JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
-JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
-JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
-JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
-JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
-JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
-JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
-JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
-JMESSAGE(JERR_TFILE_WRITE,
- "Write failed on temporary file --- out of disk space?")
-JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
-JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
-JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
-JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
-JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
-JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
-JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT_SHORT)
-JMESSAGE(JMSG_VERSION, JVERSION)
-JMESSAGE(JTRC_16BIT_TABLES,
- "Caution: quantization tables are too coarse for baseline JPEG")
-JMESSAGE(JTRC_ADOBE,
- "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
-JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
-JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
-JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
-JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
-JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d")
-JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
-JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
-JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
-JMESSAGE(JTRC_EOI, "End Of Image")
-JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
-JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
-JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
- "Warning: thumbnail image size does not match data length %u")
-JMESSAGE(JTRC_JFIF_EXTENSION, "JFIF extension marker: type 0x%02x, length %u")
-JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
-JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
-JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
-JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u")
-JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
-JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
-JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
-JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
-JMESSAGE(JTRC_RST, "RST%d")
-JMESSAGE(JTRC_SMOOTH_NOTIMPL,
- "Smoothing not supported with nonstandard sampling ratios")
-JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
-JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d")
-JMESSAGE(JTRC_SOI, "Start of Image")
-JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
-JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d")
-JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d")
-JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
-JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
-JMESSAGE(JTRC_THUMB_JPEG,
- "JFIF extension marker: JPEG-compressed thumbnail image, length %u")
-JMESSAGE(JTRC_THUMB_PALETTE,
- "JFIF extension marker: palette thumbnail image, length %u")
-JMESSAGE(JTRC_THUMB_RGB,
- "JFIF extension marker: RGB thumbnail image, length %u")
-JMESSAGE(JTRC_UNKNOWN_IDS,
- "Unrecognized component IDs %d %d %d, assuming YCbCr")
-JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
-JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
-JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
-#if JPEG_LIB_VERSION >= 70
-JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
-#endif
-JMESSAGE(JWRN_BOGUS_PROGRESSION,
- "Inconsistent progression sequence for component %d coefficient %d")
-JMESSAGE(JWRN_EXTRANEOUS_DATA,
- "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
-JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
-JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
-JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
-JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
-JMESSAGE(JWRN_MUST_RESYNC,
- "Corrupt JPEG data: found marker 0x%02x instead of RST%d")
-JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
-JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
-#if JPEG_LIB_VERSION < 70
-JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
-#if defined(C_ARITH_CODING_SUPPORTED) || defined(D_ARITH_CODING_SUPPORTED)
-JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
-JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
-#endif
-#endif
-JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
-#if JPEG_LIB_VERSION < 70
-JMESSAGE(JERR_BAD_DROP_SAMPLING,
- "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
-#endif
-
-#ifdef JMAKE_ENUM_LIST
-
- JMSG_LASTMSGCODE
-} J_MESSAGE_CODE;
-
-#undef JMAKE_ENUM_LIST
-#endif /* JMAKE_ENUM_LIST */
-
-/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
-#undef JMESSAGE
-
-
-#ifndef JERROR_H
-#define JERROR_H
-
-/* Macros to simplify using the error and trace message stuff */
-/* The first parameter is either type of cinfo pointer */
-
-/* Fatal errors (print message and exit) */
-#define ERREXIT(cinfo, code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT1(cinfo, code, p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT2(cinfo, code, p1, p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT3(cinfo, code, p1, p2, p3) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT4(cinfo, code, p1, p2, p3, p4) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (cinfo)->err->msg_parm.i[3] = (p4), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXIT6(cinfo, code, p1, p2, p3, p4, p5, p6) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (cinfo)->err->msg_parm.i[2] = (p3), \
- (cinfo)->err->msg_parm.i[3] = (p4), \
- (cinfo)->err->msg_parm.i[4] = (p5), \
- (cinfo)->err->msg_parm.i[5] = (p6), \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-#define ERREXITS(cinfo, code, str) \
- ((cinfo)->err->msg_code = (code), \
- strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
- (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
- (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
-
-#define MAKESTMT(stuff) do { stuff } while (0)
-
-/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
-#define WARNMS(cinfo, code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
-#define WARNMS1(cinfo, code, p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
-#define WARNMS2(cinfo, code, p1, p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
-
-/* Informational/debugging messages */
-#define TRACEMS(cinfo, lvl, code) \
- ((cinfo)->err->msg_code = (code), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-#define TRACEMS1(cinfo, lvl, code, p1) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-#define TRACEMS2(cinfo, lvl, code, p1, p2) \
- ((cinfo)->err->msg_code = (code), \
- (cinfo)->err->msg_parm.i[0] = (p1), \
- (cinfo)->err->msg_parm.i[1] = (p2), \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-#define TRACEMS3(cinfo, lvl, code, p1, p2, p3) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- _mp[4] = (p5); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8) \
- MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
- _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
- _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
- (cinfo)->err->msg_code = (code); \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
-#define TRACEMSS(cinfo, lvl, code, str) \
- ((cinfo)->err->msg_code = (code), \
- strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
- (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
- (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
-
-#endif /* JERROR_H */
+#include "src/jerror.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libjpeg-turbo/jmorecfg.h b/contrib/libs/libjpeg-turbo/jmorecfg.h
index aabd91b9fcf..8fb4909e595 100644
--- a/contrib/libs/libjpeg-turbo/jmorecfg.h
+++ b/contrib/libs/libjpeg-turbo/jmorecfg.h
@@ -1,382 +1 @@
-/*
- * jmorecfg.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains additional configuration options that customize the
- * JPEG software for special applications or support machine-dependent
- * optimizations. Most users will not need to touch this file.
- */
-
-
-/*
- * Maximum number of components (color channels) allowed in JPEG image.
- * To meet the letter of Rec. ITU-T T.81 | ISO/IEC 10918-1, set this to 255.
- * However, darn few applications need more than 4 channels (maybe 5 for CMYK +
- * alpha mask). We recommend 10 as a reasonable compromise; use 4 if you are
- * really short on memory. (Each allowed component costs a hundred or so
- * bytes of storage, whether actually used in an image or not.)
- */
-
-#define MAX_COMPONENTS 10 /* maximum number of image components */
-
-
-/*
- * Basic data types.
- * You may need to change these if you have a machine with unusual data
- * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
- * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
- * but it had better be at least 16.
- */
-
-/* Representation of a single sample (pixel element value).
- * We frequently allocate large arrays of these, so it's important to keep
- * them small. But if you have memory to burn and access to char or short
- * arrays is very slow on your hardware, you might want to change these.
- */
-
-#if BITS_IN_JSAMPLE == 8
-/* JSAMPLE should be the smallest type that will hold the values 0..255.
- */
-
-typedef unsigned char JSAMPLE;
-#define GETJSAMPLE(value) ((int)(value))
-
-#define MAXJSAMPLE 255
-#define CENTERJSAMPLE 128
-
-#endif /* BITS_IN_JSAMPLE == 8 */
-
-
-#if BITS_IN_JSAMPLE == 12
-/* JSAMPLE should be the smallest type that will hold the values 0..4095.
- * On nearly all machines "short" will do nicely.
- */
-
-typedef short JSAMPLE;
-#define GETJSAMPLE(value) ((int)(value))
-
-#define MAXJSAMPLE 4095
-#define CENTERJSAMPLE 2048
-
-#endif /* BITS_IN_JSAMPLE == 12 */
-
-
-/* Representation of a DCT frequency coefficient.
- * This should be a signed value of at least 16 bits; "short" is usually OK.
- * Again, we allocate large arrays of these, but you can change to int
- * if you have memory to burn and "short" is really slow.
- */
-
-typedef short JCOEF;
-
-
-/* Compressed datastreams are represented as arrays of JOCTET.
- * These must be EXACTLY 8 bits wide, at least once they are written to
- * external storage. Note that when using the stdio data source/destination
- * managers, this is also the data type passed to fread/fwrite.
- */
-
-typedef unsigned char JOCTET;
-#define GETJOCTET(value) (value)
-
-
-/* These typedefs are used for various table entries and so forth.
- * They must be at least as wide as specified; but making them too big
- * won't cost a huge amount of memory, so we don't provide special
- * extraction code like we did for JSAMPLE. (In other words, these
- * typedefs live at a different point on the speed/space tradeoff curve.)
- */
-
-/* UINT8 must hold at least the values 0..255. */
-
-typedef unsigned char UINT8;
-
-/* UINT16 must hold at least the values 0..65535. */
-
-typedef unsigned short UINT16;
-
-/* INT16 must hold at least the values -32768..32767. */
-
-#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
-typedef short INT16;
-#endif
-
-/* INT32 must hold at least signed 32-bit values.
- *
- * NOTE: The INT32 typedef dates back to libjpeg v5 (1994.) Integers were
- * sometimes 16-bit back then (MS-DOS), which is why INT32 is typedef'd to
- * long. It also wasn't common (or at least as common) in 1994 for INT32 to be
- * defined by platform headers. Since then, however, INT32 is defined in
- * several other common places:
- *
- * Xmd.h (X11 header) typedefs INT32 to int on 64-bit platforms and long on
- * 32-bit platforms (i.e always a 32-bit signed type.)
- *
- * basetsd.h (Win32 header) typedefs INT32 to int (always a 32-bit signed type
- * on modern platforms.)
- *
- * qglobal.h (Qt header) typedefs INT32 to int (always a 32-bit signed type on
- * modern platforms.)
- *
- * This is a recipe for conflict, since "long" and "int" aren't always
- * compatible types. Since the definition of INT32 has technically been part
- * of the libjpeg API for more than 20 years, we can't remove it, but we do not
- * use it internally any longer. We instead define a separate type (JLONG)
- * for internal use, which ensures that internal behavior will always be the
- * same regardless of any external headers that may be included.
- */
-
-#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
-#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
-#ifndef _BASETSD_H /* MinGW is slightly different */
-#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
-//typedef long INT32;
-#endif
-#endif
-#endif
-#endif
-
-/* Datatype used for image dimensions. The JPEG standard only supports
- * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
- * "unsigned int" is sufficient on all machines. However, if you need to
- * handle larger images and you don't mind deviating from the spec, you
- * can change this datatype. (Note that changing this datatype will
- * potentially require modifying the SIMD code. The x86-64 SIMD extensions,
- * in particular, assume a 32-bit JDIMENSION.)
- */
-
-typedef unsigned int JDIMENSION;
-
-#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
-
-
-/* These macros are used in all function definitions and extern declarations.
- * You could modify them if you need to change function linkage conventions;
- * in particular, you'll need to do that to make the library a Windows DLL.
- * Another application is to make all functions global for use with debuggers
- * or code profilers that require it.
- */
-
-/* a function called through method pointers: */
-#define METHODDEF(type) static type
-/* a function used only in its module: */
-#define LOCAL(type) static type
-/* a function referenced thru EXTERNs: */
-#define GLOBAL(type) type
-/* a reference to a GLOBAL function: */
-#define EXTERN(type) extern type
-
-
-/* Originally, this macro was used as a way of defining function prototypes
- * for both modern compilers as well as older compilers that did not support
- * prototype parameters. libjpeg-turbo has never supported these older,
- * non-ANSI compilers, but the macro is still included because there is some
- * software out there that uses it.
- */
-
-#define JMETHOD(type, methodname, arglist) type (*methodname) arglist
-
-
-/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
- * but again, some software relies on this macro.
- */
-
-#undef FAR
-#define FAR
-
-
-/*
- * On a few systems, type boolean and/or its values FALSE, TRUE may appear
- * in standard header files. Or you may have conflicts with application-
- * specific header files that you want to include together with these files.
- * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
- */
-
-#ifndef HAVE_BOOLEAN
-typedef int boolean;
-#endif
-#ifndef FALSE /* in case these macros already exist */
-#define FALSE 0 /* values of boolean */
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-
-/*
- * The remaining options affect code selection within the JPEG library,
- * but they don't need to be visible to most applications using the library.
- * To minimize application namespace pollution, the symbols won't be
- * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
- */
-
-#ifdef JPEG_INTERNALS
-#define JPEG_INTERNAL_OPTIONS
-#endif
-
-#ifdef JPEG_INTERNAL_OPTIONS
-
-
-/*
- * These defines indicate whether to include various optional functions.
- * Undefining some of these symbols will produce a smaller but less capable
- * library. Note that you can leave certain source files out of the
- * compilation/linking process if you've #undef'd the corresponding symbols.
- * (You may HAVE to do that if your compiler doesn't like null source files.)
- */
-
-/* Capability options common to encoder and decoder: */
-
-#define DCT_ISLOW_SUPPORTED /* accurate integer method */
-#define DCT_IFAST_SUPPORTED /* less accurate int method [legacy feature] */
-#define DCT_FLOAT_SUPPORTED /* floating-point method [legacy feature] */
-
-/* Encoder capability options: */
-
-#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
-/* Note: if you selected 12-bit data precision, it is dangerous to turn off
- * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
- * precision, so jchuff.c normally uses entropy optimization to compute
- * usable tables for higher precision. If you don't want to do optimization,
- * you'll have to supply different default Huffman tables.
- * The exact same statements apply for progressive JPEG: the default tables
- * don't work for progressive mode. (This may get fixed, however.)
- */
-#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
-
-/* Decoder capability options: */
-
-#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
-#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
-#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
-#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
-#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
-#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
-#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
-#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
-
-/* more capability options later, no doubt */
-
-
-/*
- * The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
- * feature of libjpeg. The idea was that, if an application developer needed
- * to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
- * change these macros, rebuild libjpeg, and link their application statically
- * with it. In reality, few people ever did this, because there were some
- * severe restrictions involved (cjpeg and djpeg no longer worked properly,
- * compressing/decompressing RGB JPEGs no longer worked properly, and the color
- * quantizer wouldn't work with pixel sizes other than 3.) Furthermore, since
- * all of the O/S-supplied versions of libjpeg were built with the default
- * values of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications
- * have come to regard these values as immutable.
- *
- * The libjpeg-turbo colorspace extensions provide a much cleaner way of
- * compressing from/decompressing to buffers with arbitrary component orders
- * and pixel sizes. Thus, we do not support changing the values of RGB_RED,
- * RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE. In addition to the restrictions
- * listed above, changing these values will also break the SIMD extensions and
- * the regression tests.
- */
-
-#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
-#define RGB_GREEN 1 /* Offset of Green */
-#define RGB_BLUE 2 /* Offset of Blue */
-#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
-
-#define JPEG_NUMCS 17
-
-#define EXT_RGB_RED 0
-#define EXT_RGB_GREEN 1
-#define EXT_RGB_BLUE 2
-#define EXT_RGB_PIXELSIZE 3
-
-#define EXT_RGBX_RED 0
-#define EXT_RGBX_GREEN 1
-#define EXT_RGBX_BLUE 2
-#define EXT_RGBX_PIXELSIZE 4
-
-#define EXT_BGR_RED 2
-#define EXT_BGR_GREEN 1
-#define EXT_BGR_BLUE 0
-#define EXT_BGR_PIXELSIZE 3
-
-#define EXT_BGRX_RED 2
-#define EXT_BGRX_GREEN 1
-#define EXT_BGRX_BLUE 0
-#define EXT_BGRX_PIXELSIZE 4
-
-#define EXT_XBGR_RED 3
-#define EXT_XBGR_GREEN 2
-#define EXT_XBGR_BLUE 1
-#define EXT_XBGR_PIXELSIZE 4
-
-#define EXT_XRGB_RED 1
-#define EXT_XRGB_GREEN 2
-#define EXT_XRGB_BLUE 3
-#define EXT_XRGB_PIXELSIZE 4
-
-static const int rgb_red[JPEG_NUMCS] = {
- -1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
- EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
- EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
- -1
-};
-
-static const int rgb_green[JPEG_NUMCS] = {
- -1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
- EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
- EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
- -1
-};
-
-static const int rgb_blue[JPEG_NUMCS] = {
- -1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
- EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
- EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
- -1
-};
-
-static const int rgb_pixelsize[JPEG_NUMCS] = {
- -1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
- EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
- EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
- -1
-};
-
-/* Definitions for speed-related optimizations. */
-
-/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
- * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
- * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
- */
-
-#ifndef MULTIPLIER
-#ifndef WITH_SIMD
-#define MULTIPLIER int /* type for fastest integer multiply */
-#else
-#define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */
-#endif
-#endif
-
-
-/* FAST_FLOAT should be either float or double, whichever is done faster
- * by your compiler. (Note that this type is only used in the floating point
- * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
- */
-
-#ifndef FAST_FLOAT
-#define FAST_FLOAT float
-#endif
-
-#endif /* JPEG_INTERNAL_OPTIONS */
+#include "src/jmorecfg.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libjpeg-turbo/jpegint.h b/contrib/libs/libjpeg-turbo/jpegint.h
index 6af9e2a179e..8295cfa7d7c 100644
--- a/contrib/libs/libjpeg-turbo/jpegint.h
+++ b/contrib/libs/libjpeg-turbo/jpegint.h
@@ -1,375 +1 @@
-/*
- * jpegint.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1997, Thomas G. Lane.
- * Modified 1997-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * Copyright (C) 2021, Alex Richardson.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file provides common declarations for the various JPEG modules.
- * These declarations are considered internal to the JPEG library; most
- * applications using the library shouldn't need to include this file.
- */
-
-
-/* Declarations for both compression & decompression */
-
-typedef enum { /* Operating modes for buffer controllers */
- JBUF_PASS_THRU, /* Plain stripwise operation */
- /* Remaining modes require a full-image buffer to have been created */
- JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
- JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
- JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
-} J_BUF_MODE;
-
-/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
-#define CSTATE_START 100 /* after create_compress */
-#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
-#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
-#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
-#define DSTATE_START 200 /* after create_decompress */
-#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
-#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
-#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
-#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
-#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
-#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
-#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
-#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
-#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
-#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
-
-
-/* JLONG must hold at least signed 32-bit values. */
-typedef long JLONG;
-
-/* JUINTPTR must hold pointer values. */
-#ifdef __UINTPTR_TYPE__
-/*
- * __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+.
- * Fortunately, that is sufficient to support the few architectures for which
- * sizeof(void *) != sizeof(size_t). The only other options would require C99
- * or Clang-specific builtins.
- */
-typedef __UINTPTR_TYPE__ JUINTPTR;
-#else
-typedef size_t JUINTPTR;
-#endif
-
-/*
- * Left shift macro that handles a negative operand without causing any
- * sanitizer warnings
- */
-
-#define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b)))
-
-
-/* Declarations for compression modules */
-
-/* Master control module */
-struct jpeg_comp_master {
- void (*prepare_for_pass) (j_compress_ptr cinfo);
- void (*pass_startup) (j_compress_ptr cinfo);
- void (*finish_pass) (j_compress_ptr cinfo);
-
- /* State variables made visible to other modules */
- boolean call_pass_startup; /* True if pass_startup must be called */
- boolean is_last_pass; /* True during last pass */
-};
-
-/* Main buffer control (downsampled-data buffer) */
-struct jpeg_c_main_controller {
- void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
-};
-
-/* Compression preprocessing (downsampling input buffer control) */
-struct jpeg_c_prep_controller {
- void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*pre_process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf,
- JDIMENSION *out_row_group_ctr,
- JDIMENSION out_row_groups_avail);
-};
-
-/* Coefficient buffer control */
-struct jpeg_c_coef_controller {
- void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
- boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf);
-};
-
-/* Colorspace conversion */
-struct jpeg_color_converter {
- void (*start_pass) (j_compress_ptr cinfo);
- void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows);
-};
-
-/* Downsampling */
-struct jpeg_downsampler {
- void (*start_pass) (j_compress_ptr cinfo);
- void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_index, JSAMPIMAGE output_buf,
- JDIMENSION out_row_group_index);
-
- boolean need_context_rows; /* TRUE if need rows above & below */
-};
-
-/* Forward DCT (also controls coefficient quantization) */
-struct jpeg_forward_dct {
- void (*start_pass) (j_compress_ptr cinfo);
- /* perhaps this should be an array??? */
- void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
- JDIMENSION start_row, JDIMENSION start_col,
- JDIMENSION num_blocks);
-};
-
-/* Entropy encoding */
-struct jpeg_entropy_encoder {
- void (*start_pass) (j_compress_ptr cinfo, boolean gather_statistics);
- boolean (*encode_mcu) (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
- void (*finish_pass) (j_compress_ptr cinfo);
-};
-
-/* Marker writing */
-struct jpeg_marker_writer {
- void (*write_file_header) (j_compress_ptr cinfo);
- void (*write_frame_header) (j_compress_ptr cinfo);
- void (*write_scan_header) (j_compress_ptr cinfo);
- void (*write_file_trailer) (j_compress_ptr cinfo);
- void (*write_tables_only) (j_compress_ptr cinfo);
- /* These routines are exported to allow insertion of extra markers */
- /* Probably only COM and APPn markers should be written this way */
- void (*write_marker_header) (j_compress_ptr cinfo, int marker,
- unsigned int datalen);
- void (*write_marker_byte) (j_compress_ptr cinfo, int val);
-};
-
-
-/* Declarations for decompression modules */
-
-/* Master control module */
-struct jpeg_decomp_master {
- void (*prepare_for_output_pass) (j_decompress_ptr cinfo);
- void (*finish_output_pass) (j_decompress_ptr cinfo);
-
- /* State variables made visible to other modules */
- boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
-
- /* Partial decompression variables */
- JDIMENSION first_iMCU_col;
- JDIMENSION last_iMCU_col;
- JDIMENSION first_MCU_col[MAX_COMPONENTS];
- JDIMENSION last_MCU_col[MAX_COMPONENTS];
- boolean jinit_upsampler_no_alloc;
-
- /* Last iMCU row that was successfully decoded */
- JDIMENSION last_good_iMCU_row;
-};
-
-/* Input control module */
-struct jpeg_input_controller {
- int (*consume_input) (j_decompress_ptr cinfo);
- void (*reset_input_controller) (j_decompress_ptr cinfo);
- void (*start_input_pass) (j_decompress_ptr cinfo);
- void (*finish_input_pass) (j_decompress_ptr cinfo);
-
- /* State variables made visible to other modules */
- boolean has_multiple_scans; /* True if file has multiple scans */
- boolean eoi_reached; /* True when EOI has been consumed */
-};
-
-/* Main buffer control (downsampled-data buffer) */
-struct jpeg_d_main_controller {
- void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
-};
-
-/* Coefficient buffer control */
-struct jpeg_d_coef_controller {
- void (*start_input_pass) (j_decompress_ptr cinfo);
- int (*consume_data) (j_decompress_ptr cinfo);
- void (*start_output_pass) (j_decompress_ptr cinfo);
- int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
- /* Pointer to array of coefficient virtual arrays, or NULL if none */
- jvirt_barray_ptr *coef_arrays;
-};
-
-/* Decompression postprocessing (color quantization buffer control) */
-struct jpeg_d_post_controller {
- void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
- void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
- JDIMENSION out_rows_avail);
-};
-
-/* Marker reading & parsing */
-struct jpeg_marker_reader {
- void (*reset_marker_reader) (j_decompress_ptr cinfo);
- /* Read markers until SOS or EOI.
- * Returns same codes as are defined for jpeg_consume_input:
- * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
- */
- int (*read_markers) (j_decompress_ptr cinfo);
- /* Read a restart marker --- exported for use by entropy decoder only */
- jpeg_marker_parser_method read_restart_marker;
-
- /* State of marker reader --- nominally internal, but applications
- * supplying COM or APPn handlers might like to know the state.
- */
- boolean saw_SOI; /* found SOI? */
- boolean saw_SOF; /* found SOF? */
- int next_restart_num; /* next restart number expected (0-7) */
- unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
-};
-
-/* Entropy decoding */
-struct jpeg_entropy_decoder {
- void (*start_pass) (j_decompress_ptr cinfo);
- boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data);
-
- /* This is here to share code between baseline and progressive decoders; */
- /* other modules probably should not use it */
- boolean insufficient_data; /* set TRUE after emitting warning */
-};
-
-/* Inverse DCT (also performs dequantization) */
-typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
- jpeg_component_info *compptr,
- JCOEFPTR coef_block,
- JSAMPARRAY output_buf,
- JDIMENSION output_col);
-
-struct jpeg_inverse_dct {
- void (*start_pass) (j_decompress_ptr cinfo);
- /* It is useful to allow each component to have a separate IDCT method. */
- inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
-};
-
-/* Upsampling (note that upsampler must also call color converter) */
-struct jpeg_upsampler {
- void (*start_pass) (j_decompress_ptr cinfo);
- void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
- JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
-
- boolean need_context_rows; /* TRUE if need rows above & below */
-};
-
-/* Colorspace conversion */
-struct jpeg_color_deconverter {
- void (*start_pass) (j_decompress_ptr cinfo);
- void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows);
-};
-
-/* Color quantization or color precision reduction */
-struct jpeg_color_quantizer {
- void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
- void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows);
- void (*finish_pass) (j_decompress_ptr cinfo);
- void (*new_color_map) (j_decompress_ptr cinfo);
-};
-
-
-/* Miscellaneous useful macros */
-
-#undef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#undef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-
-/* We assume that right shift corresponds to signed division by 2 with
- * rounding towards minus infinity. This is correct for typical "arithmetic
- * shift" instructions that shift in copies of the sign bit. But some
- * C compilers implement >> with an unsigned shift. For these machines you
- * must define RIGHT_SHIFT_IS_UNSIGNED.
- * RIGHT_SHIFT provides a proper signed right shift of a JLONG quantity.
- * It is only applied with constant shift counts. SHIFT_TEMPS must be
- * included in the variables of any routine using RIGHT_SHIFT.
- */
-
-#ifdef RIGHT_SHIFT_IS_UNSIGNED
-#define SHIFT_TEMPS JLONG shift_temp;
-#define RIGHT_SHIFT(x, shft) \
- ((shift_temp = (x)) < 0 ? \
- (shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
- (shift_temp >> (shft)))
-#else
-#define SHIFT_TEMPS
-#define RIGHT_SHIFT(x, shft) ((x) >> (shft))
-#endif
-
-
-/* Compression module initialization routines */
-EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
-EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
- boolean transcode_only);
-EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
-EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
-EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
-EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
-EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
-EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
-EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
-/* Decompression module initialization routines */
-EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
-EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
- boolean need_full_buffer);
-EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
-EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
-EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
-EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
-EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
-EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
-EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
-EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
-EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
-EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
-EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
-/* Memory manager initialization */
-EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
-
-/* Utility routines in jutils.c */
-EXTERN(long) jdiv_round_up(long a, long b);
-EXTERN(long) jround_up(long a, long b);
-EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
- JSAMPARRAY output_array, int dest_row,
- int num_rows, JDIMENSION num_cols);
-EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
- JDIMENSION num_blocks);
-EXTERN(void) jzero_far(void *target, size_t bytestozero);
-/* Constant tables in jutils.c */
-#if 0 /* This table is not actually needed in v6a */
-extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
-#endif
-extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
-
-/* Arithmetic coding probability estimation tables in jaricom.c */
-extern const JLONG jpeg_aritab[];
+#include "src/jpegint.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libjpeg-turbo/jpeglib.h b/contrib/libs/libjpeg-turbo/jpeglib.h
index d7664f06309..535c5832039 100644
--- a/contrib/libs/libjpeg-turbo/jpeglib.h
+++ b/contrib/libs/libjpeg-turbo/jpeglib.h
@@ -1,1132 +1 @@
-/*
- * jpeglib.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1991-1998, Thomas G. Lane.
- * Modified 2002-2009 by Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, D. R. Commander.
- * Copyright (C) 2015, Google, Inc.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file defines the application interface for the JPEG library.
- * Most applications using the library need only include this file,
- * and perhaps jerror.h if they want to know the exact error codes.
- */
-
-#ifndef JPEGLIB_H
-#define JPEGLIB_H
-
-/*
- * First we include the configuration files that record how this
- * installation of the JPEG library is set up. jconfig.h can be
- * generated automatically for many systems. jmorecfg.h contains
- * manual configuration options that most people need not worry about.
- */
-
-#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
-#include "jconfig.h" /* widely used configuration options */
-#endif
-#include "jmorecfg.h" /* seldom changed options */
-
-
-#ifdef __cplusplus
-#ifndef DONT_USE_EXTERN_C
-extern "C" {
-#endif
-#endif
-
-
-/* Various constants determining the sizes of things.
- * All of these are specified by the JPEG standard, so don't change them
- * if you want to be compatible.
- */
-
-#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
-#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
-#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
-#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
-#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
-#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
-#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
-/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
- * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
- * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
- * to handle it. We even let you do this from the jconfig.h file. However,
- * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
- * sometimes emits noncompliant files doesn't mean you should too.
- */
-#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */
-#ifndef D_MAX_BLOCKS_IN_MCU
-#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */
-#endif
-
-
-/* Data structures for images (arrays of samples and of DCT coefficients).
- */
-
-typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
-typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
-typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
-
-typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
-typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
-typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
-typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
-
-typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
-
-
-/* Types for JPEG compression parameters and working tables. */
-
-
-/* DCT coefficient quantization tables. */
-
-typedef struct {
- /* This array gives the coefficient quantizers in natural array order
- * (not the zigzag order in which they are stored in a JPEG DQT marker).
- * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
- */
- UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
- /* This field is used only during compression. It's initialized FALSE when
- * the table is created, and set TRUE when it's been output to the file.
- * You could suppress output of a table by setting this to TRUE.
- * (See jpeg_suppress_tables for an example.)
- */
- boolean sent_table; /* TRUE when table has been output */
-} JQUANT_TBL;
-
-
-/* Huffman coding tables. */
-
-typedef struct {
- /* These two fields directly represent the contents of a JPEG DHT marker */
- UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
- /* length k bits; bits[0] is unused */
- UINT8 huffval[256]; /* The symbols, in order of incr code length */
- /* This field is used only during compression. It's initialized FALSE when
- * the table is created, and set TRUE when it's been output to the file.
- * You could suppress output of a table by setting this to TRUE.
- * (See jpeg_suppress_tables for an example.)
- */
- boolean sent_table; /* TRUE when table has been output */
-} JHUFF_TBL;
-
-
-/* Basic info about one component (color channel). */
-
-typedef struct {
- /* These values are fixed over the whole image. */
- /* For compression, they must be supplied by parameter setup; */
- /* for decompression, they are read from the SOF marker. */
- int component_id; /* identifier for this component (0..255) */
- int component_index; /* its index in SOF or cinfo->comp_info[] */
- int h_samp_factor; /* horizontal sampling factor (1..4) */
- int v_samp_factor; /* vertical sampling factor (1..4) */
- int quant_tbl_no; /* quantization table selector (0..3) */
- /* These values may vary between scans. */
- /* For compression, they must be supplied by parameter setup; */
- /* for decompression, they are read from the SOS marker. */
- /* The decompressor output side may not use these variables. */
- int dc_tbl_no; /* DC entropy table selector (0..3) */
- int ac_tbl_no; /* AC entropy table selector (0..3) */
-
- /* Remaining fields should be treated as private by applications. */
-
- /* These values are computed during compression or decompression startup: */
- /* Component's size in DCT blocks.
- * Any dummy blocks added to complete an MCU are not counted; therefore
- * these values do not depend on whether a scan is interleaved or not.
- */
- JDIMENSION width_in_blocks;
- JDIMENSION height_in_blocks;
- /* Size of a DCT block in samples. Always DCTSIZE for compression.
- * For decompression this is the size of the output from one DCT block,
- * reflecting any scaling we choose to apply during the IDCT step.
- * Values from 1 to 16 are supported.
- * Note that different components may receive different IDCT scalings.
- */
-#if JPEG_LIB_VERSION >= 70
- int DCT_h_scaled_size;
- int DCT_v_scaled_size;
-#else
- int DCT_scaled_size;
-#endif
- /* The downsampled dimensions are the component's actual, unpadded number
- * of samples at the main buffer (preprocessing/compression interface), thus
- * downsampled_width = ceil(image_width * Hi/Hmax)
- * and similarly for height. For decompression, IDCT scaling is included, so
- * downsampled_width = ceil(image_width * Hi/Hmax * DCT_[h_]scaled_size/DCTSIZE)
- */
- JDIMENSION downsampled_width; /* actual width in samples */
- JDIMENSION downsampled_height; /* actual height in samples */
- /* This flag is used only for decompression. In cases where some of the
- * components will be ignored (eg grayscale output from YCbCr image),
- * we can skip most computations for the unused components.
- */
- boolean component_needed; /* do we need the value of this component? */
-
- /* These values are computed before starting a scan of the component. */
- /* The decompressor output side may not use these variables. */
- int MCU_width; /* number of blocks per MCU, horizontally */
- int MCU_height; /* number of blocks per MCU, vertically */
- int MCU_blocks; /* MCU_width * MCU_height */
- int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
- int last_col_width; /* # of non-dummy blocks across in last MCU */
- int last_row_height; /* # of non-dummy blocks down in last MCU */
-
- /* Saved quantization table for component; NULL if none yet saved.
- * See jdinput.c comments about the need for this information.
- * This field is currently used only for decompression.
- */
- JQUANT_TBL *quant_table;
-
- /* Private per-component storage for DCT or IDCT subsystem. */
- void *dct_table;
-} jpeg_component_info;
-
-
-/* The script for encoding a multiple-scan file is an array of these: */
-
-typedef struct {
- int comps_in_scan; /* number of components encoded in this scan */
- int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
- int Ss, Se; /* progressive JPEG spectral selection parms */
- int Ah, Al; /* progressive JPEG successive approx. parms */
-} jpeg_scan_info;
-
-/* The decompressor can save APPn and COM markers in a list of these: */
-
-typedef struct jpeg_marker_struct *jpeg_saved_marker_ptr;
-
-struct jpeg_marker_struct {
- jpeg_saved_marker_ptr next; /* next in list, or NULL */
- UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
- unsigned int original_length; /* # bytes of data in the file */
- unsigned int data_length; /* # bytes of data saved at data[] */
- JOCTET *data; /* the data contained in the marker */
- /* the marker length word is not counted in data_length or original_length */
-};
-
-/* Known color spaces. */
-
-#define JCS_EXTENSIONS 1
-#define JCS_ALPHA_EXTENSIONS 1
-
-typedef enum {
- JCS_UNKNOWN, /* error/unspecified */
- JCS_GRAYSCALE, /* monochrome */
- JCS_RGB, /* red/green/blue as specified by the RGB_RED,
- RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros */
- JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
- JCS_CMYK, /* C/M/Y/K */
- JCS_YCCK, /* Y/Cb/Cr/K */
- JCS_EXT_RGB, /* red/green/blue */
- JCS_EXT_RGBX, /* red/green/blue/x */
- JCS_EXT_BGR, /* blue/green/red */
- JCS_EXT_BGRX, /* blue/green/red/x */
- JCS_EXT_XBGR, /* x/blue/green/red */
- JCS_EXT_XRGB, /* x/red/green/blue */
- /* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
- or JCS_EXT_XRGB during decompression, the X byte is undefined, and in
- order to ensure the best performance, libjpeg-turbo can set that byte to
- whatever value it wishes. Use the following colorspace constants to
- ensure that the X byte is set to 0xFF, so that it can be interpreted as an
- opaque alpha channel. */
- JCS_EXT_RGBA, /* red/green/blue/alpha */
- JCS_EXT_BGRA, /* blue/green/red/alpha */
- JCS_EXT_ABGR, /* alpha/blue/green/red */
- JCS_EXT_ARGB, /* alpha/red/green/blue */
- JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
-} J_COLOR_SPACE;
-
-/* DCT/IDCT algorithm options. */
-
-typedef enum {
- JDCT_ISLOW, /* accurate integer method */
- JDCT_IFAST, /* less accurate integer method [legacy feature] */
- JDCT_FLOAT /* floating-point method [legacy feature] */
-} J_DCT_METHOD;
-
-#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
-#define JDCT_DEFAULT JDCT_ISLOW
-#endif
-#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
-#define JDCT_FASTEST JDCT_IFAST
-#endif
-
-/* Dithering options for decompression. */
-
-typedef enum {
- JDITHER_NONE, /* no dithering */
- JDITHER_ORDERED, /* simple ordered dither */
- JDITHER_FS /* Floyd-Steinberg error diffusion dither */
-} J_DITHER_MODE;
-
-
-/* Common fields between JPEG compression and decompression master structs. */
-
-#define jpeg_common_fields \
- struct jpeg_error_mgr *err; /* Error handler module */ \
- struct jpeg_memory_mgr *mem; /* Memory manager module */ \
- struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */ \
- void *client_data; /* Available for use by application */ \
- boolean is_decompressor; /* So common code can tell which is which */ \
- int global_state /* For checking call sequence validity */
-
-/* Routines that are to be used by both halves of the library are declared
- * to receive a pointer to this structure. There are no actual instances of
- * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
- */
-struct jpeg_common_struct {
- jpeg_common_fields; /* Fields common to both master struct types */
- /* Additional fields follow in an actual jpeg_compress_struct or
- * jpeg_decompress_struct. All three structs must agree on these
- * initial fields! (This would be a lot cleaner in C++.)
- */
-};
-
-typedef struct jpeg_common_struct *j_common_ptr;
-typedef struct jpeg_compress_struct *j_compress_ptr;
-typedef struct jpeg_decompress_struct *j_decompress_ptr;
-
-
-/* Master record for a compression instance */
-
-struct jpeg_compress_struct {
- jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
-
- /* Destination for compressed data */
- struct jpeg_destination_mgr *dest;
-
- /* Description of source image --- these fields must be filled in by
- * outer application before starting compression. in_color_space must
- * be correct before you can even call jpeg_set_defaults().
- */
-
- JDIMENSION image_width; /* input image width */
- JDIMENSION image_height; /* input image height */
- int input_components; /* # of color components in input image */
- J_COLOR_SPACE in_color_space; /* colorspace of input image */
-
- double input_gamma; /* image gamma of input image */
-
- /* Compression parameters --- these fields must be set before calling
- * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
- * initialize everything to reasonable defaults, then changing anything
- * the application specifically wants to change. That way you won't get
- * burnt when new parameters are added. Also note that there are several
- * helper routines to simplify changing parameters.
- */
-
-#if JPEG_LIB_VERSION >= 70
- unsigned int scale_num, scale_denom; /* fraction by which to scale image */
-
- JDIMENSION jpeg_width; /* scaled JPEG image width */
- JDIMENSION jpeg_height; /* scaled JPEG image height */
- /* Dimensions of actual JPEG image that will be written to file,
- * derived from input dimensions by scaling factors above.
- * These fields are computed by jpeg_start_compress().
- * You can also use jpeg_calc_jpeg_dimensions() to determine these values
- * in advance of calling jpeg_start_compress().
- */
-#endif
-
- int data_precision; /* bits of precision in image data */
-
- int num_components; /* # of color components in JPEG image */
- J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
-
- jpeg_component_info *comp_info;
- /* comp_info[i] describes component that appears i'th in SOF */
-
- JQUANT_TBL *quant_tbl_ptrs[NUM_QUANT_TBLS];
-#if JPEG_LIB_VERSION >= 70
- int q_scale_factor[NUM_QUANT_TBLS];
-#endif
- /* ptrs to coefficient quantization tables, or NULL if not defined,
- * and corresponding scale factors (percentage, initialized 100).
- */
-
- JHUFF_TBL *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
- JHUFF_TBL *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
- /* ptrs to Huffman coding tables, or NULL if not defined */
-
- UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
- UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
- UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
-
- int num_scans; /* # of entries in scan_info array */
- const jpeg_scan_info *scan_info; /* script for multi-scan file, or NULL */
- /* The default value of scan_info is NULL, which causes a single-scan
- * sequential JPEG file to be emitted. To create a multi-scan file,
- * set num_scans and scan_info to point to an array of scan definitions.
- */
-
- boolean raw_data_in; /* TRUE=caller supplies downsampled data */
- boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
- boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
- boolean CCIR601_sampling; /* TRUE=first samples are cosited */
-#if JPEG_LIB_VERSION >= 70
- boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
-#endif
- int smoothing_factor; /* 1..100, or 0 for no input smoothing */
- J_DCT_METHOD dct_method; /* DCT algorithm selector */
-
- /* The restart interval can be specified in absolute MCUs by setting
- * restart_interval, or in MCU rows by setting restart_in_rows
- * (in which case the correct restart_interval will be figured
- * for each scan).
- */
- unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
- int restart_in_rows; /* if > 0, MCU rows per restart interval */
-
- /* Parameters controlling emission of special markers. */
-
- boolean write_JFIF_header; /* should a JFIF marker be written? */
- UINT8 JFIF_major_version; /* What to write for the JFIF version number */
- UINT8 JFIF_minor_version;
- /* These three values are not used by the JPEG code, merely copied */
- /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
- /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */
- /* ratio is defined by X_density/Y_density even when density_unit=0. */
- UINT8 density_unit; /* JFIF code for pixel size units */
- UINT16 X_density; /* Horizontal pixel density */
- UINT16 Y_density; /* Vertical pixel density */
- boolean write_Adobe_marker; /* should an Adobe marker be written? */
-
- /* State variable: index of next scanline to be written to
- * jpeg_write_scanlines(). Application may use this to control its
- * processing loop, e.g., "while (next_scanline < image_height)".
- */
-
- JDIMENSION next_scanline; /* 0 .. image_height-1 */
-
- /* Remaining fields are known throughout compressor, but generally
- * should not be touched by a surrounding application.
- */
-
- /*
- * These fields are computed during compression startup
- */
- boolean progressive_mode; /* TRUE if scan script uses progressive mode */
- int max_h_samp_factor; /* largest h_samp_factor */
- int max_v_samp_factor; /* largest v_samp_factor */
-
-#if JPEG_LIB_VERSION >= 70
- int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
- int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
-#endif
-
- JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
- /* The coefficient controller receives data in units of MCU rows as defined
- * for fully interleaved scans (whether the JPEG file is interleaved or not).
- * There are v_samp_factor * DCTSIZE sample rows of each component in an
- * "iMCU" (interleaved MCU) row.
- */
-
- /*
- * These fields are valid during any one scan.
- * They describe the components and MCUs actually appearing in the scan.
- */
- int comps_in_scan; /* # of JPEG components in this scan */
- jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
- /* *cur_comp_info[i] describes component that appears i'th in SOS */
-
- JDIMENSION MCUs_per_row; /* # of MCUs across the image */
- JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
-
- int blocks_in_MCU; /* # of DCT blocks per MCU */
- int MCU_membership[C_MAX_BLOCKS_IN_MCU];
- /* MCU_membership[i] is index in cur_comp_info of component owning */
- /* i'th block in an MCU */
-
- int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
-
-#if JPEG_LIB_VERSION >= 80
- int block_size; /* the basic DCT block size: 1..16 */
- const int *natural_order; /* natural-order position array */
- int lim_Se; /* min( Se, DCTSIZE2-1 ) */
-#endif
-
- /*
- * Links to compression subobjects (methods and private variables of modules)
- */
- struct jpeg_comp_master *master;
- struct jpeg_c_main_controller *main;
- struct jpeg_c_prep_controller *prep;
- struct jpeg_c_coef_controller *coef;
- struct jpeg_marker_writer *marker;
- struct jpeg_color_converter *cconvert;
- struct jpeg_downsampler *downsample;
- struct jpeg_forward_dct *fdct;
- struct jpeg_entropy_encoder *entropy;
- jpeg_scan_info *script_space; /* workspace for jpeg_simple_progression */
- int script_space_size;
-};
-
-
-/* Master record for a decompression instance */
-
-struct jpeg_decompress_struct {
- jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
-
- /* Source of compressed data */
- struct jpeg_source_mgr *src;
-
- /* Basic description of image --- filled in by jpeg_read_header(). */
- /* Application may inspect these values to decide how to process image. */
-
- JDIMENSION image_width; /* nominal image width (from SOF marker) */
- JDIMENSION image_height; /* nominal image height */
- int num_components; /* # of color components in JPEG image */
- J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
-
- /* Decompression processing parameters --- these fields must be set before
- * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes
- * them to default values.
- */
-
- J_COLOR_SPACE out_color_space; /* colorspace for output */
-
- unsigned int scale_num, scale_denom; /* fraction by which to scale image */
-
- double output_gamma; /* image gamma wanted in output */
-
- boolean buffered_image; /* TRUE=multiple output passes */
- boolean raw_data_out; /* TRUE=downsampled data wanted */
-
- J_DCT_METHOD dct_method; /* IDCT algorithm selector */
- boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
- boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
-
- boolean quantize_colors; /* TRUE=colormapped output wanted */
- /* the following are ignored if not quantize_colors: */
- J_DITHER_MODE dither_mode; /* type of color dithering to use */
- boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
- int desired_number_of_colors; /* max # colors to use in created colormap */
- /* these are significant only in buffered-image mode: */
- boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
- boolean enable_external_quant;/* enable future use of external colormap */
- boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
-
- /* Description of actual output image that will be returned to application.
- * These fields are computed by jpeg_start_decompress().
- * You can also use jpeg_calc_output_dimensions() to determine these values
- * in advance of calling jpeg_start_decompress().
- */
-
- JDIMENSION output_width; /* scaled image width */
- JDIMENSION output_height; /* scaled image height */
- int out_color_components; /* # of color components in out_color_space */
- int output_components; /* # of color components returned */
- /* output_components is 1 (a colormap index) when quantizing colors;
- * otherwise it equals out_color_components.
- */
- int rec_outbuf_height; /* min recommended height of scanline buffer */
- /* If the buffer passed to jpeg_read_scanlines() is less than this many rows
- * high, space and time will be wasted due to unnecessary data copying.
- * Usually rec_outbuf_height will be 1 or 2, at most 4.
- */
-
- /* When quantizing colors, the output colormap is described by these fields.
- * The application can supply a colormap by setting colormap non-NULL before
- * calling jpeg_start_decompress; otherwise a colormap is created during
- * jpeg_start_decompress or jpeg_start_output.
- * The map has out_color_components rows and actual_number_of_colors columns.
- */
- int actual_number_of_colors; /* number of entries in use */
- JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
-
- /* State variables: these variables indicate the progress of decompression.
- * The application may examine these but must not modify them.
- */
-
- /* Row index of next scanline to be read from jpeg_read_scanlines().
- * Application may use this to control its processing loop, e.g.,
- * "while (output_scanline < output_height)".
- */
- JDIMENSION output_scanline; /* 0 .. output_height-1 */
-
- /* Current input scan number and number of iMCU rows completed in scan.
- * These indicate the progress of the decompressor input side.
- */
- int input_scan_number; /* Number of SOS markers seen so far */
- JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
-
- /* The "output scan number" is the notional scan being displayed by the
- * output side. The decompressor will not allow output scan/row number
- * to get ahead of input scan/row, but it can fall arbitrarily far behind.
- */
- int output_scan_number; /* Nominal scan number being displayed */
- JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
-
- /* Current progression status. coef_bits[c][i] indicates the precision
- * with which component c's DCT coefficient i (in zigzag order) is known.
- * It is -1 when no data has yet been received, otherwise it is the point
- * transform (shift) value for the most recent scan of the coefficient
- * (thus, 0 at completion of the progression).
- * This pointer is NULL when reading a non-progressive file.
- */
- int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
-
- /* Internal JPEG parameters --- the application usually need not look at
- * these fields. Note that the decompressor output side may not use
- * any parameters that can change between scans.
- */
-
- /* Quantization and Huffman tables are carried forward across input
- * datastreams when processing abbreviated JPEG datastreams.
- */
-
- JQUANT_TBL *quant_tbl_ptrs[NUM_QUANT_TBLS];
- /* ptrs to coefficient quantization tables, or NULL if not defined */
-
- JHUFF_TBL *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
- JHUFF_TBL *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
- /* ptrs to Huffman coding tables, or NULL if not defined */
-
- /* These parameters are never carried across datastreams, since they
- * are given in SOF/SOS markers or defined to be reset by SOI.
- */
-
- int data_precision; /* bits of precision in image data */
-
- jpeg_component_info *comp_info;
- /* comp_info[i] describes component that appears i'th in SOF */
-
-#if JPEG_LIB_VERSION >= 80
- boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
-#endif
- boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
- boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
-
- UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
- UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
- UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
-
- unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
-
- /* These fields record data obtained from optional markers recognized by
- * the JPEG library.
- */
- boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
- /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
- UINT8 JFIF_major_version; /* JFIF version number */
- UINT8 JFIF_minor_version;
- UINT8 density_unit; /* JFIF code for pixel size units */
- UINT16 X_density; /* Horizontal pixel density */
- UINT16 Y_density; /* Vertical pixel density */
- boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
- UINT8 Adobe_transform; /* Color transform code from Adobe marker */
-
- boolean CCIR601_sampling; /* TRUE=first samples are cosited */
-
- /* Aside from the specific data retained from APPn markers known to the
- * library, the uninterpreted contents of any or all APPn and COM markers
- * can be saved in a list for examination by the application.
- */
- jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
-
- /* Remaining fields are known throughout decompressor, but generally
- * should not be touched by a surrounding application.
- */
-
- /*
- * These fields are computed during decompression startup
- */
- int max_h_samp_factor; /* largest h_samp_factor */
- int max_v_samp_factor; /* largest v_samp_factor */
-
-#if JPEG_LIB_VERSION >= 70
- int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
- int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
-#else
- int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
-#endif
-
- JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
- /* The coefficient controller's input and output progress is measured in
- * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
- * in fully interleaved JPEG scans, but are used whether the scan is
- * interleaved or not. We define an iMCU row as v_samp_factor DCT block
- * rows of each component. Therefore, the IDCT output contains
- * v_samp_factor*DCT_[v_]scaled_size sample rows of a component per iMCU row.
- */
-
- JSAMPLE *sample_range_limit; /* table for fast range-limiting */
-
- /*
- * These fields are valid during any one scan.
- * They describe the components and MCUs actually appearing in the scan.
- * Note that the decompressor output side must not use these fields.
- */
- int comps_in_scan; /* # of JPEG components in this scan */
- jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
- /* *cur_comp_info[i] describes component that appears i'th in SOS */
-
- JDIMENSION MCUs_per_row; /* # of MCUs across the image */
- JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
-
- int blocks_in_MCU; /* # of DCT blocks per MCU */
- int MCU_membership[D_MAX_BLOCKS_IN_MCU];
- /* MCU_membership[i] is index in cur_comp_info of component owning */
- /* i'th block in an MCU */
-
- int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
-
-#if JPEG_LIB_VERSION >= 80
- /* These fields are derived from Se of first SOS marker.
- */
- int block_size; /* the basic DCT block size: 1..16 */
- const int *natural_order; /* natural-order position array for entropy decode */
- int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
-#endif
-
- /* This field is shared between entropy decoder and marker parser.
- * It is either zero or the code of a JPEG marker that has been
- * read from the data source, but has not yet been processed.
- */
- int unread_marker;
-
- /*
- * Links to decompression subobjects (methods, private variables of modules)
- */
- struct jpeg_decomp_master *master;
- struct jpeg_d_main_controller *main;
- struct jpeg_d_coef_controller *coef;
- struct jpeg_d_post_controller *post;
- struct jpeg_input_controller *inputctl;
- struct jpeg_marker_reader *marker;
- struct jpeg_entropy_decoder *entropy;
- struct jpeg_inverse_dct *idct;
- struct jpeg_upsampler *upsample;
- struct jpeg_color_deconverter *cconvert;
- struct jpeg_color_quantizer *cquantize;
-};
-
-
-/* "Object" declarations for JPEG modules that may be supplied or called
- * directly by the surrounding application.
- * As with all objects in the JPEG library, these structs only define the
- * publicly visible methods and state variables of a module. Additional
- * private fields may exist after the public ones.
- */
-
-
-/* Error handler object */
-
-struct jpeg_error_mgr {
- /* Error exit handler: does not return to caller */
- void (*error_exit) (j_common_ptr cinfo);
- /* Conditionally emit a trace or warning message */
- void (*emit_message) (j_common_ptr cinfo, int msg_level);
- /* Routine that actually outputs a trace or error message */
- void (*output_message) (j_common_ptr cinfo);
- /* Format a message string for the most recent JPEG error or message */
- void (*format_message) (j_common_ptr cinfo, char *buffer);
-#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
- /* Reset error state variables at start of a new image */
- void (*reset_error_mgr) (j_common_ptr cinfo);
-
- /* The message ID code and any parameters are saved here.
- * A message can have one string parameter or up to 8 int parameters.
- */
- int msg_code;
-#define JMSG_STR_PARM_MAX 80
- union {
- int i[8];
- char s[JMSG_STR_PARM_MAX];
- } msg_parm;
-
- /* Standard state variables for error facility */
-
- int trace_level; /* max msg_level that will be displayed */
-
- /* For recoverable corrupt-data errors, we emit a warning message,
- * but keep going unless emit_message chooses to abort. emit_message
- * should count warnings in num_warnings. The surrounding application
- * can check for bad data by seeing if num_warnings is nonzero at the
- * end of processing.
- */
- long num_warnings; /* number of corrupt-data warnings */
-
- /* These fields point to the table(s) of error message strings.
- * An application can change the table pointer to switch to a different
- * message list (typically, to change the language in which errors are
- * reported). Some applications may wish to add additional error codes
- * that will be handled by the JPEG library error mechanism; the second
- * table pointer is used for this purpose.
- *
- * First table includes all errors generated by JPEG library itself.
- * Error code 0 is reserved for a "no such error string" message.
- */
- const char * const *jpeg_message_table; /* Library errors */
- int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
- /* Second table can be added by application (see cjpeg/djpeg for example).
- * It contains strings numbered first_addon_message..last_addon_message.
- */
- const char * const *addon_message_table; /* Non-library errors */
- int first_addon_message; /* code for first string in addon table */
- int last_addon_message; /* code for last string in addon table */
-};
-
-
-/* Progress monitor object */
-
-struct jpeg_progress_mgr {
- void (*progress_monitor) (j_common_ptr cinfo);
-
- long pass_counter; /* work units completed in this pass */
- long pass_limit; /* total number of work units in this pass */
- int completed_passes; /* passes completed so far */
- int total_passes; /* total number of passes expected */
-};
-
-
-/* Data destination object for compression */
-
-struct jpeg_destination_mgr {
- JOCTET *next_output_byte; /* => next byte to write in buffer */
- size_t free_in_buffer; /* # of byte spaces remaining in buffer */
-
- void (*init_destination) (j_compress_ptr cinfo);
- boolean (*empty_output_buffer) (j_compress_ptr cinfo);
- void (*term_destination) (j_compress_ptr cinfo);
-};
-
-
-/* Data source object for decompression */
-
-struct jpeg_source_mgr {
- const JOCTET *next_input_byte; /* => next byte to read from buffer */
- size_t bytes_in_buffer; /* # of bytes remaining in buffer */
-
- void (*init_source) (j_decompress_ptr cinfo);
- boolean (*fill_input_buffer) (j_decompress_ptr cinfo);
- void (*skip_input_data) (j_decompress_ptr cinfo, long num_bytes);
- boolean (*resync_to_restart) (j_decompress_ptr cinfo, int desired);
- void (*term_source) (j_decompress_ptr cinfo);
-};
-
-
-/* Memory manager object.
- * Allocates "small" objects (a few K total), "large" objects (tens of K),
- * and "really big" objects (virtual arrays with backing store if needed).
- * The memory manager does not allow individual objects to be freed; rather,
- * each created object is assigned to a pool, and whole pools can be freed
- * at once. This is faster and more convenient than remembering exactly what
- * to free, especially where malloc()/free() are not too speedy.
- * NB: alloc routines never return NULL. They exit to error_exit if not
- * successful.
- */
-
-#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
-#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
-#define JPOOL_NUMPOOLS 2
-
-typedef struct jvirt_sarray_control *jvirt_sarray_ptr;
-typedef struct jvirt_barray_control *jvirt_barray_ptr;
-
-
-struct jpeg_memory_mgr {
- /* Method pointers */
- void *(*alloc_small) (j_common_ptr cinfo, int pool_id, size_t sizeofobject);
- void *(*alloc_large) (j_common_ptr cinfo, int pool_id,
- size_t sizeofobject);
- JSAMPARRAY (*alloc_sarray) (j_common_ptr cinfo, int pool_id,
- JDIMENSION samplesperrow, JDIMENSION numrows);
- JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id,
- JDIMENSION blocksperrow, JDIMENSION numrows);
- jvirt_sarray_ptr (*request_virt_sarray) (j_common_ptr cinfo, int pool_id,
- boolean pre_zero,
- JDIMENSION samplesperrow,
- JDIMENSION numrows,
- JDIMENSION maxaccess);
- jvirt_barray_ptr (*request_virt_barray) (j_common_ptr cinfo, int pool_id,
- boolean pre_zero,
- JDIMENSION blocksperrow,
- JDIMENSION numrows,
- JDIMENSION maxaccess);
- void (*realize_virt_arrays) (j_common_ptr cinfo);
- JSAMPARRAY (*access_virt_sarray) (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
- JDIMENSION start_row, JDIMENSION num_rows,
- boolean writable);
- JBLOCKARRAY (*access_virt_barray) (j_common_ptr cinfo, jvirt_barray_ptr ptr,
- JDIMENSION start_row, JDIMENSION num_rows,
- boolean writable);
- void (*free_pool) (j_common_ptr cinfo, int pool_id);
- void (*self_destruct) (j_common_ptr cinfo);
-
- /* Limit on memory allocation for this JPEG object. (Note that this is
- * merely advisory, not a guaranteed maximum; it only affects the space
- * used for virtual-array buffers.) May be changed by outer application
- * after creating the JPEG object.
- */
- long max_memory_to_use;
-
- /* Maximum allocation request accepted by alloc_large. */
- long max_alloc_chunk;
-};
-
-
-/* Routine signature for application-supplied marker processing methods.
- * Need not pass marker code since it is stored in cinfo->unread_marker.
- */
-typedef boolean (*jpeg_marker_parser_method) (j_decompress_ptr cinfo);
-
-
-/* Originally, this macro was used as a way of defining function prototypes
- * for both modern compilers as well as older compilers that did not support
- * prototype parameters. libjpeg-turbo has never supported these older,
- * non-ANSI compilers, but the macro is still included because there is some
- * software out there that uses it.
- */
-
-#define JPP(arglist) arglist
-
-
-/* Default error-management setup */
-EXTERN(struct jpeg_error_mgr *) jpeg_std_error(struct jpeg_error_mgr *err);
-
-/* Initialization of JPEG compression objects.
- * jpeg_create_compress() and jpeg_create_decompress() are the exported
- * names that applications should call. These expand to calls on
- * jpeg_CreateCompress and jpeg_CreateDecompress with additional information
- * passed for version mismatch checking.
- * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
- */
-#define jpeg_create_compress(cinfo) \
- jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
- (size_t)sizeof(struct jpeg_compress_struct))
-#define jpeg_create_decompress(cinfo) \
- jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
- (size_t)sizeof(struct jpeg_decompress_struct))
-EXTERN(void) jpeg_CreateCompress(j_compress_ptr cinfo, int version,
- size_t structsize);
-EXTERN(void) jpeg_CreateDecompress(j_decompress_ptr cinfo, int version,
- size_t structsize);
-/* Destruction of JPEG compression objects */
-EXTERN(void) jpeg_destroy_compress(j_compress_ptr cinfo);
-EXTERN(void) jpeg_destroy_decompress(j_decompress_ptr cinfo);
-
-/* Standard data source and destination managers: stdio streams. */
-/* Caller is responsible for opening the file before and closing after. */
-EXTERN(void) jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile);
-EXTERN(void) jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile);
-
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
-/* Data source and destination managers: memory buffers. */
-EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
- unsigned long *outsize);
-EXTERN(void) jpeg_mem_src(j_decompress_ptr cinfo,
- const unsigned char *inbuffer, unsigned long insize);
-#endif
-
-/* Default parameter setup for compression */
-EXTERN(void) jpeg_set_defaults(j_compress_ptr cinfo);
-/* Compression parameter setup aids */
-EXTERN(void) jpeg_set_colorspace(j_compress_ptr cinfo,
- J_COLOR_SPACE colorspace);
-EXTERN(void) jpeg_default_colorspace(j_compress_ptr cinfo);
-EXTERN(void) jpeg_set_quality(j_compress_ptr cinfo, int quality,
- boolean force_baseline);
-EXTERN(void) jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
- boolean force_baseline);
-#if JPEG_LIB_VERSION >= 70
-EXTERN(void) jpeg_default_qtables(j_compress_ptr cinfo,
- boolean force_baseline);
-#endif
-EXTERN(void) jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
- const unsigned int *basic_table,
- int scale_factor, boolean force_baseline);
-EXTERN(int) jpeg_quality_scaling(int quality);
-EXTERN(void) jpeg_simple_progression(j_compress_ptr cinfo);
-EXTERN(void) jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress);
-EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table(j_common_ptr cinfo);
-EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table(j_common_ptr cinfo);
-
-/* Main entry points for compression */
-EXTERN(void) jpeg_start_compress(j_compress_ptr cinfo,
- boolean write_all_tables);
-EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
- JSAMPARRAY scanlines,
- JDIMENSION num_lines);
-EXTERN(void) jpeg_finish_compress(j_compress_ptr cinfo);
-
-#if JPEG_LIB_VERSION >= 70
-/* Precalculate JPEG dimensions for current compression parameters. */
-EXTERN(void) jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo);
-#endif
-
-/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
-EXTERN(JDIMENSION) jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION num_lines);
-
-/* Write a special marker. See libjpeg.txt concerning safe usage. */
-EXTERN(void) jpeg_write_marker(j_compress_ptr cinfo, int marker,
- const JOCTET *dataptr, unsigned int datalen);
-/* Same, but piecemeal. */
-EXTERN(void) jpeg_write_m_header(j_compress_ptr cinfo, int marker,
- unsigned int datalen);
-EXTERN(void) jpeg_write_m_byte(j_compress_ptr cinfo, int val);
-
-/* Alternate compression function: just write an abbreviated table file */
-EXTERN(void) jpeg_write_tables(j_compress_ptr cinfo);
-
-/* Write ICC profile. See libjpeg.txt for usage information. */
-EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
- const JOCTET *icc_data_ptr,
- unsigned int icc_data_len);
-
-
-/* Decompression startup: read start of JPEG datastream to see what's there */
-EXTERN(int) jpeg_read_header(j_decompress_ptr cinfo, boolean require_image);
-/* Return value is one of: */
-#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
-#define JPEG_HEADER_OK 1 /* Found valid image datastream */
-#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
-/* If you pass require_image = TRUE (normal case), you need not check for
- * a TABLES_ONLY return code; an abbreviated file will cause an error exit.
- * JPEG_SUSPENDED is only possible if you use a data source module that can
- * give a suspension return (the stdio source module doesn't).
- */
-
-/* Main entry points for decompression */
-EXTERN(boolean) jpeg_start_decompress(j_decompress_ptr cinfo);
-EXTERN(JDIMENSION) jpeg_read_scanlines(j_decompress_ptr cinfo,
- JSAMPARRAY scanlines,
- JDIMENSION max_lines);
-EXTERN(JDIMENSION) jpeg_skip_scanlines(j_decompress_ptr cinfo,
- JDIMENSION num_lines);
-EXTERN(void) jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
- JDIMENSION *width);
-EXTERN(boolean) jpeg_finish_decompress(j_decompress_ptr cinfo);
-
-/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
-EXTERN(JDIMENSION) jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION max_lines);
-
-/* Additional entry points for buffered-image mode. */
-EXTERN(boolean) jpeg_has_multiple_scans(j_decompress_ptr cinfo);
-EXTERN(boolean) jpeg_start_output(j_decompress_ptr cinfo, int scan_number);
-EXTERN(boolean) jpeg_finish_output(j_decompress_ptr cinfo);
-EXTERN(boolean) jpeg_input_complete(j_decompress_ptr cinfo);
-EXTERN(void) jpeg_new_colormap(j_decompress_ptr cinfo);
-EXTERN(int) jpeg_consume_input(j_decompress_ptr cinfo);
-/* Return value is one of: */
-/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
-#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
-#define JPEG_REACHED_EOI 2 /* Reached end of image */
-#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
-#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
-
-/* Precalculate output dimensions for current decompression parameters. */
-#if JPEG_LIB_VERSION >= 80
-EXTERN(void) jpeg_core_output_dimensions(j_decompress_ptr cinfo);
-#endif
-EXTERN(void) jpeg_calc_output_dimensions(j_decompress_ptr cinfo);
-
-/* Control saving of COM and APPn markers into marker_list. */
-EXTERN(void) jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
- unsigned int length_limit);
-
-/* Install a special processing method for COM or APPn markers. */
-EXTERN(void) jpeg_set_marker_processor(j_decompress_ptr cinfo,
- int marker_code,
- jpeg_marker_parser_method routine);
-
-/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
-EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients(j_decompress_ptr cinfo);
-EXTERN(void) jpeg_write_coefficients(j_compress_ptr cinfo,
- jvirt_barray_ptr *coef_arrays);
-EXTERN(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo,
- j_compress_ptr dstinfo);
-
-/* If you choose to abort compression or decompression before completing
- * jpeg_finish_(de)compress, then you need to clean up to release memory,
- * temporary files, etc. You can just call jpeg_destroy_(de)compress
- * if you're done with the JPEG object, but if you want to clean it up and
- * reuse it, call this:
- */
-EXTERN(void) jpeg_abort_compress(j_compress_ptr cinfo);
-EXTERN(void) jpeg_abort_decompress(j_decompress_ptr cinfo);
-
-/* Generic versions of jpeg_abort and jpeg_destroy that work on either
- * flavor of JPEG object. These may be more convenient in some places.
- */
-EXTERN(void) jpeg_abort(j_common_ptr cinfo);
-EXTERN(void) jpeg_destroy(j_common_ptr cinfo);
-
-/* Default restart-marker-resync procedure for use by data source modules */
-EXTERN(boolean) jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired);
-
-/* Read ICC profile. See libjpeg.txt for usage information. */
-EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
- JOCTET **icc_data_ptr,
- unsigned int *icc_data_len);
-
-
-/* These marker codes are exported since applications and data source modules
- * are likely to want to use them.
- */
-
-#define JPEG_RST0 0xD0 /* RST0 marker code */
-#define JPEG_EOI 0xD9 /* EOI marker code */
-#define JPEG_APP0 0xE0 /* APP0 marker code */
-#define JPEG_COM 0xFE /* COM marker code */
-
-
-/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
- * for structure definitions that are never filled in, keep it quiet by
- * supplying dummy definitions for the various substructures.
- */
-
-#ifdef INCOMPLETE_TYPES_BROKEN
-#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
-struct jvirt_sarray_control { long dummy; };
-struct jvirt_barray_control { long dummy; };
-struct jpeg_comp_master { long dummy; };
-struct jpeg_c_main_controller { long dummy; };
-struct jpeg_c_prep_controller { long dummy; };
-struct jpeg_c_coef_controller { long dummy; };
-struct jpeg_marker_writer { long dummy; };
-struct jpeg_color_converter { long dummy; };
-struct jpeg_downsampler { long dummy; };
-struct jpeg_forward_dct { long dummy; };
-struct jpeg_entropy_encoder { long dummy; };
-struct jpeg_decomp_master { long dummy; };
-struct jpeg_d_main_controller { long dummy; };
-struct jpeg_d_coef_controller { long dummy; };
-struct jpeg_d_post_controller { long dummy; };
-struct jpeg_input_controller { long dummy; };
-struct jpeg_marker_reader { long dummy; };
-struct jpeg_entropy_decoder { long dummy; };
-struct jpeg_inverse_dct { long dummy; };
-struct jpeg_upsampler { long dummy; };
-struct jpeg_color_deconverter { long dummy; };
-struct jpeg_color_quantizer { long dummy; };
-#endif /* JPEG_INTERNALS */
-#endif /* INCOMPLETE_TYPES_BROKEN */
-
-
-/*
- * The JPEG library modules define JPEG_INTERNALS before including this file.
- * The internal structure declarations are read only when that is true.
- * Applications using the library should not include jpegint.h, but may wish
- * to include jerror.h.
- */
-
-#ifdef JPEG_INTERNALS
-#include "jpegint.h" /* fetch private declarations */
-#include "jerror.h" /* fetch error codes too */
-#endif
-
-#ifdef __cplusplus
-#ifndef DONT_USE_EXTERN_C
-}
-#endif
-#endif
-
-#endif /* JPEGLIB_H */
+#include "src/jpeglib.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libjpeg-turbo/jpegtran/ya.make b/contrib/libs/libjpeg-turbo/jpegtran/ya.make
index 2ce1441619e..3d0e94618a8 100644
--- a/contrib/libs/libjpeg-turbo/jpegtran/ya.make
+++ b/contrib/libs/libjpeg-turbo/jpegtran/ya.make
@@ -4,7 +4,7 @@ PROGRAM()
WITHOUT_LICENSE_TEXTS()
-VERSION(2.1.4)
+VERSION(3.1.1)
PEERDIR(
contrib/libs/libjpeg-turbo
@@ -12,13 +12,14 @@ PEERDIR(
ADDINCL(
contrib/libs/libjpeg-turbo
+ contrib/libs/libjpeg-turbo/src
)
NO_COMPILER_WARNINGS()
NO_RUNTIME()
-SRCDIR(contrib/libs/libjpeg-turbo)
+SRCDIR(contrib/libs/libjpeg-turbo/src)
SRCS(
cdjpeg.c
diff --git a/contrib/libs/libjpeg-turbo/jsimd_none.c b/contrib/libs/libjpeg-turbo/jsimd_none.c
deleted file mode 100644
index 5b38a9fb5c9..00000000000
--- a/contrib/libs/libjpeg-turbo/jsimd_none.c
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * jsimd_none.c
- *
- * Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
- * Copyright (C) 2020, Arm Limited.
- *
- * Based on the x86 SIMD extension for IJG JPEG library,
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
- * For conditions of distribution and use, see copyright notice in jsimdext.inc
- *
- * This file contains stubs for when there is no SIMD support available.
- */
-
-#define JPEG_INTERNALS
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jsimd.h"
-#include "jdct.h"
-#include "jsimddct.h"
-
-GLOBAL(int)
-jsimd_can_rgb_ycc(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_rgb_gray(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_ycc_rgb565(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_c_can_null_convert(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
- int num_rows)
-{
-}
-
-GLOBAL(void)
-jsimd_c_null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
- int num_rows)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_downsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_downsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_smooth_downsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v2_smooth_downsample(j_compress_ptr cinfo,
- jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_int_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_fancy_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_fancy_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h1v2_fancy_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(void)
-jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
-{
-}
-
-GLOBAL(int)
-jsimd_can_h2v2_merged_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_h2v1_merged_upsample(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
-}
-
-GLOBAL(void)
-jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
-{
-}
-
-GLOBAL(int)
-jsimd_can_convsamp(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_convsamp_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
- DCTELEM *workspace)
-{
-}
-
-GLOBAL(void)
-jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_fdct_islow(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_ifast(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_fdct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_fdct_islow(DCTELEM *data)
-{
-}
-
-GLOBAL(void)
-jsimd_fdct_ifast(DCTELEM *data)
-{
-}
-
-GLOBAL(void)
-jsimd_fdct_float(FAST_FLOAT *data)
-{
-}
-
-GLOBAL(int)
-jsimd_can_quantize(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_quantize_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
-{
-}
-
-GLOBAL(void)
-jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
- FAST_FLOAT *workspace)
-{
-}
-
-GLOBAL(int)
-jsimd_can_idct_2x2(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_4x4(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_6x6(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_12x12(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(int)
-jsimd_can_idct_islow(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_ifast(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_can_idct_float(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(void)
-jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
-{
-}
-
-GLOBAL(int)
-jsimd_can_huff_encode_one_block(void)
-{
- return 0;
-}
-
-GLOBAL(JOCTET *)
-jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block,
- int last_dc_val, c_derived_tbl *dctbl,
- c_derived_tbl *actbl)
-{
- return NULL;
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_first_prepare(void)
-{
- return 0;
-}
-
-GLOBAL(void)
-jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
-{
-}
-
-GLOBAL(int)
-jsimd_can_encode_mcu_AC_refine_prepare(void)
-{
- return 0;
-}
-
-GLOBAL(int)
-jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
- const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
-{
- return 0;
-}
diff --git a/contrib/libs/libjpeg-turbo/jversion.h b/contrib/libs/libjpeg-turbo/jversion.h
index 63db95b99b5..3b21737362a 100644
--- a/contrib/libs/libjpeg-turbo/jversion.h
+++ b/contrib/libs/libjpeg-turbo/jversion.h
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2012-2022, D. R. Commander.
+ * Copyright (C) 2010, 2012-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -36,19 +36,21 @@
* their code
*/
-#define JCOPYRIGHT \
- "Copyright (C) 2009-2022 D. R. Commander\n" \
+#define JCOPYRIGHT1 \
+ "Copyright (C) 2009-2024 D. R. Commander\n" \
"Copyright (C) 2015, 2020 Google, Inc.\n" \
"Copyright (C) 2019-2020 Arm Limited\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
- "Copyright (C) 2015 Intel Corporation\n" \
+ "Copyright (C) 2015 Intel Corporation\n"
+#define JCOPYRIGHT2 \
"Copyright (C) 2013-2014 Linaro Limited\n" \
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
- "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
+ "Copyright (C) 1999 Ken Murchison\n" \
+ "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding\n"
#define JCOPYRIGHT_SHORT \
- "Copyright (C) 1991-2022 The libjpeg-turbo Project and many others"
+ "Copyright (C) 1991-2024 The libjpeg-turbo Project and many others"
diff --git a/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch b/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch
index b219fe93d23..2ab19f07cf7 100644
--- a/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch
+++ b/contrib/libs/libjpeg-turbo/patches/02-sanitizer.patch
@@ -9,8 +9,8 @@ For more info see:
* https://github.com/libjpeg-turbo/libjpeg-turbo#memory-debugger-pitfalls
* http://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code
---- b/jinclude.h
-+++ a/jinclude.h
+--- b/src/jinclude.h
++++ a/src/jinclude.h
@@ -130,6 +130,10 @@
#endif /* _WIN32 */
@@ -24,68 +24,43 @@ For more info see:
#endif /* JINCLUDE_H */
--- b/simd/x86_64/jsimd.c
+++ a/simd/x86_64/jsimd.c
-@@ -116,6 +116,7 @@ jsimd_can_ycc_rgb(void)
+@@ -116,6 +116,9 @@ jsimd_can_ycc_rgb(void)
{
init_simd();
-+#ifndef WITH_SANITIZER
++#ifdef WITH_SANITIZER
++ return 0;
++#endif
/* The code is optimised for these values only */
if (BITS_IN_JSAMPLE != 8)
return 0;
-@@ -130,6 +131,7 @@ jsimd_can_ycc_rgb(void)
- if ((simd_support & JSIMD_SSE2) &&
- IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
- return 1;
-+#endif
-
- return 0;
- }
-@@ -997,6 +999,7 @@ jsimd_can_huff_encode_one_block(void)
+@@ -997,6 +999,9 @@ jsimd_can_huff_encode_one_block(void)
{
init_simd();
-+#ifndef WITH_SANITIZER
++#ifdef WITH_SANITIZER
++ return 0;
++#endif
if (DCTSIZE != 8)
return 0;
if (sizeof(JCOEF) != 2)
-@@ -1005,6 +1008,7 @@ jsimd_can_huff_encode_one_block(void)
- if ((simd_support & JSIMD_SSE2) && simd_huffman &&
- IS_ALIGNED_SSE(jconst_huff_encode_one_block))
- return 1;
-+#endif
-
- return 0;
- }
-@@ -1023,6 +1027,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
+@@ -1023,6 +1027,9 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
{
init_simd();
-+#ifndef WITH_SANITIZER
++#ifdef WITH_SANITIZER
++ return 0;
++#endif
if (DCTSIZE != 8)
return 0;
if (sizeof(JCOEF) != 2)
-@@ -1029,6 +1034,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-+#endif
-
- return 0;
- }
-@@ -1047,6 +1053,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
+@@ -1047,6 +1053,9 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
{
init_simd();
-+#ifndef WITH_SANITIZER
++#ifdef WITH_SANITIZER
++ return 0;
++#endif
if (DCTSIZE != 8)
return 0;
if (sizeof(JCOEF) != 2)
-@@ -1053,6 +1060,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
- return 0;
- if (simd_support & JSIMD_SSE2)
- return 1;
-+#endif
-
- return 0;
- }
-
diff --git a/contrib/libs/libjpeg-turbo/patches/no-INT32.patch b/contrib/libs/libjpeg-turbo/patches/no-INT32.patch
index 9571ed48e3e..b9c3a19d539 100644
--- a/contrib/libs/libjpeg-turbo/patches/no-INT32.patch
+++ b/contrib/libs/libjpeg-turbo/patches/no-INT32.patch
@@ -1,5 +1,5 @@
---- a/jmorecfg.h
-+++ b/jmorecfg.h
+--- a/src/jmorecfg.h
++++ b/src/jmorecfg.h
@@ -140 +140 @@ typedef short INT16;
-typedef long INT32;
+//typedef long INT32;
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c
index 19d94f720da..153da1f1c11 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c
@@ -2,6 +2,7 @@
* jchuff-neon.c - Huffman entropy encoding (32-bit Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -24,11 +25,11 @@
*/
#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
+#include "../../../src/jinclude.h"
+#include "../../../src/jpeglib.h"
+#include "../../../src/jsimd.h"
+#include "../../../src/jdct.h"
+#include "../../../src/jsimddct.h"
#include "../../jsimd.h"
#include "../jchuff.h"
#include "neon-compat.h"
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c
index 920f7656ebf..7c8ea306bd1 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/aarch32/jsimd.c
@@ -3,8 +3,8 @@
*
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, 2024, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2019, Google LLC.
* Copyright (C) 2020, Arm Limited.
*
@@ -18,17 +18,17 @@
*/
#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
+#include "../../../src/jinclude.h"
+#include "../../../src/jpeglib.h"
+#include "../../../src/jsimd.h"
+#include "../../../src/jdct.h"
+#include "../../../src/jsimddct.h"
#include "../../jsimd.h"
#include <ctype.h>
-static unsigned int simd_support = ~0;
-static unsigned int simd_huffman = 1;
+static THREAD_LOCAL unsigned int simd_support = ~0;
+static THREAD_LOCAL unsigned int simd_huffman = 1;
#if !defined(__ARM_NEON__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
@@ -96,8 +96,6 @@ parse_proc_cpuinfo(int bufsize)
/*
* Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
*/
LOCAL(void)
init_simd(void)
@@ -945,7 +943,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
GLOBAL(void)
jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
+ int Al, UJCOEF *values, size_t *zerobits)
{
jsimd_encode_mcu_AC_first_prepare_neon(block, jpeg_natural_order_start,
Sl, Al, values, zerobits);
@@ -970,7 +968,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
GLOBAL(int)
jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
+ int Al, UJCOEF *absvalues, size_t *bits)
{
return jsimd_encode_mcu_AC_refine_prepare_neon(block,
jpeg_natural_order_start, Sl,
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c
index 607a116070c..11bf6dab130 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c
@@ -2,7 +2,7 @@
* jchuff-neon.c - Huffman entropy encoding (64-bit Arm Neon)
*
* Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, 2022, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2020, 2022, 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -25,11 +25,11 @@
*/
#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
+#include "../../../src/jinclude.h"
+#include "../../../src/jpeglib.h"
+#include "../../../src/jsimd.h"
+#include "../../../src/jdct.h"
+#include "../../../src/jsimddct.h"
#include "../../jsimd.h"
#include "../align.h"
#include "../jchuff.h"
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c
index 41c06d31801..8a6f30a1a89 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/aarch64/jsimd.c
@@ -3,8 +3,9 @@
*
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
* Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2020, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2020, 2022, 2024,
+ * D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
*
* Based on the x86 SIMD extension for IJG JPEG library,
@@ -17,13 +18,12 @@
*/
#define JPEG_INTERNALS
-#include "../../../jinclude.h"
-#include "../../../jpeglib.h"
-#include "../../../jsimd.h"
-#include "../../../jdct.h"
-#include "../../../jsimddct.h"
+#include "../../../src/jinclude.h"
+#include "../../../src/jpeglib.h"
+#include "../../../src/jsimd.h"
+#include "../../../src/jdct.h"
+#include "../../../src/jsimddct.h"
#include "../../jsimd.h"
-#include "jconfigint.h"
#include <ctype.h>
@@ -31,10 +31,10 @@
#define JSIMD_FASTST3 2
#define JSIMD_FASTTBL 4
-static unsigned int simd_support = ~0;
-static unsigned int simd_huffman = 1;
-static unsigned int simd_features = JSIMD_FASTLD3 | JSIMD_FASTST3 |
- JSIMD_FASTTBL;
+static THREAD_LOCAL unsigned int simd_support = ~0;
+static THREAD_LOCAL unsigned int simd_huffman = 1;
+static THREAD_LOCAL unsigned int simd_features = JSIMD_FASTLD3 |
+ JSIMD_FASTST3 | JSIMD_FASTTBL;
#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
@@ -109,8 +109,6 @@ parse_proc_cpuinfo(int bufsize)
/*
* Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
*/
/*
@@ -1021,7 +1019,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
GLOBAL(void)
jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
+ int Al, UJCOEF *values, size_t *zerobits)
{
jsimd_encode_mcu_AC_first_prepare_neon(block, jpeg_natural_order_start,
Sl, Al, values, zerobits);
@@ -1048,7 +1046,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
GLOBAL(int)
jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
+ int Al, UJCOEF *absvalues, size_t *bits)
{
return jsimd_encode_mcu_AC_refine_prepare_neon(block,
jpeg_natural_order_start,
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c
index 9fcc62dd25c..d14a7bf5018 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jccolor-neon.c
@@ -2,7 +2,7 @@
* jccolor-neon.c - colorspace conversion (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -22,11 +22,11 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
#include "neon-compat.h"
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c
index 71c7b2de218..fbcf8214057 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jcgray-neon.c
@@ -2,6 +2,7 @@
* jcgray-neon.c - grayscale colorspace conversion (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,13 +22,14 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c
index b91c5db478a..435f96ee968 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jcphuff-neon.c
@@ -2,6 +2,8 @@
* jcphuff-neon.c - prepare data for progressive Huffman encoding (Arm Neon)
*
* Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2022, Matthieu Darbois. All Rights Reserved.
+ * Copyright (C) 2022, 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,12 +23,11 @@
*/
#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "neon-compat.h"
@@ -41,10 +42,10 @@
void jsimd_encode_mcu_AC_first_prepare_neon
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits)
+ UJCOEF *values, size_t *zerobits)
{
- JCOEF *values_ptr = values;
- JCOEF *diff_values_ptr = values + DCTSIZE2;
+ UJCOEF *values_ptr = values;
+ UJCOEF *diff_values_ptr = values + DCTSIZE2;
/* Rows of coefficients to zero (since they haven't been processed) */
int i, rows_to_zero = 8;
@@ -68,23 +69,23 @@ void jsimd_encode_mcu_AC_first_prepare_neon
coefs2 = vld1q_lane_s16(block + jpeg_natural_order_start[15], coefs2, 7);
/* Isolate sign of coefficients. */
- int16x8_t sign_coefs1 = vshrq_n_s16(coefs1, 15);
- int16x8_t sign_coefs2 = vshrq_n_s16(coefs2, 15);
+ uint16x8_t sign_coefs1 = vreinterpretq_u16_s16(vshrq_n_s16(coefs1, 15));
+ uint16x8_t sign_coefs2 = vreinterpretq_u16_s16(vshrq_n_s16(coefs2, 15));
/* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
+ uint16x8_t abs_coefs1 = vreinterpretq_u16_s16(vabsq_s16(coefs1));
+ uint16x8_t abs_coefs2 = vreinterpretq_u16_s16(vabsq_s16(coefs2));
+ abs_coefs1 = vshlq_u16(abs_coefs1, vdupq_n_s16(-Al));
+ abs_coefs2 = vshlq_u16(abs_coefs2, vdupq_n_s16(-Al));
/* Compute diff values. */
- int16x8_t diff1 = veorq_s16(coefs1, sign_coefs1);
- int16x8_t diff2 = veorq_s16(coefs2, sign_coefs2);
+ uint16x8_t diff1 = veorq_u16(abs_coefs1, sign_coefs1);
+ uint16x8_t diff2 = veorq_u16(abs_coefs2, sign_coefs2);
/* Store transformed coefficients and diff values. */
- vst1q_s16(values_ptr, coefs1);
- vst1q_s16(values_ptr + DCTSIZE, coefs2);
- vst1q_s16(diff_values_ptr, diff1);
- vst1q_s16(diff_values_ptr + DCTSIZE, diff2);
+ vst1q_u16(values_ptr, abs_coefs1);
+ vst1q_u16(values_ptr + DCTSIZE, abs_coefs2);
+ vst1q_u16(diff_values_ptr, diff1);
+ vst1q_u16(diff_values_ptr + DCTSIZE, diff2);
values_ptr += 16;
diff_values_ptr += 16;
jpeg_natural_order_start += 16;
@@ -130,23 +131,23 @@ void jsimd_encode_mcu_AC_first_prepare_neon
}
/* Isolate sign of coefficients. */
- int16x8_t sign_coefs1 = vshrq_n_s16(coefs1, 15);
- int16x8_t sign_coefs2 = vshrq_n_s16(coefs2, 15);
+ uint16x8_t sign_coefs1 = vreinterpretq_u16_s16(vshrq_n_s16(coefs1, 15));
+ uint16x8_t sign_coefs2 = vreinterpretq_u16_s16(vshrq_n_s16(coefs2, 15));
/* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
+ uint16x8_t abs_coefs1 = vreinterpretq_u16_s16(vabsq_s16(coefs1));
+ uint16x8_t abs_coefs2 = vreinterpretq_u16_s16(vabsq_s16(coefs2));
+ abs_coefs1 = vshlq_u16(abs_coefs1, vdupq_n_s16(-Al));
+ abs_coefs2 = vshlq_u16(abs_coefs2, vdupq_n_s16(-Al));
/* Compute diff values. */
- int16x8_t diff1 = veorq_s16(coefs1, sign_coefs1);
- int16x8_t diff2 = veorq_s16(coefs2, sign_coefs2);
+ uint16x8_t diff1 = veorq_u16(abs_coefs1, sign_coefs1);
+ uint16x8_t diff2 = veorq_u16(abs_coefs2, sign_coefs2);
/* Store transformed coefficients and diff values. */
- vst1q_s16(values_ptr, coefs1);
- vst1q_s16(values_ptr + DCTSIZE, coefs2);
- vst1q_s16(diff_values_ptr, diff1);
- vst1q_s16(diff_values_ptr + DCTSIZE, diff2);
+ vst1q_u16(values_ptr, abs_coefs1);
+ vst1q_u16(values_ptr + DCTSIZE, abs_coefs2);
+ vst1q_u16(diff_values_ptr, diff1);
+ vst1q_u16(diff_values_ptr + DCTSIZE, diff2);
values_ptr += 16;
diff_values_ptr += 16;
rows_to_zero -= 2;
@@ -184,17 +185,17 @@ void jsimd_encode_mcu_AC_first_prepare_neon
}
/* Isolate sign of coefficients. */
- int16x8_t sign_coefs = vshrq_n_s16(coefs, 15);
+ uint16x8_t sign_coefs = vreinterpretq_u16_s16(vshrq_n_s16(coefs, 15));
/* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs = vabsq_s16(coefs);
- coefs = vshlq_s16(abs_coefs, vdupq_n_s16(-Al));
+ uint16x8_t abs_coefs = vreinterpretq_u16_s16(vabsq_s16(coefs));
+ abs_coefs = vshlq_u16(abs_coefs, vdupq_n_s16(-Al));
/* Compute diff values. */
- int16x8_t diff = veorq_s16(coefs, sign_coefs);
+ uint16x8_t diff = veorq_u16(abs_coefs, sign_coefs);
/* Store transformed coefficients and diff values. */
- vst1q_s16(values_ptr, coefs);
- vst1q_s16(diff_values_ptr, diff);
+ vst1q_u16(values_ptr, abs_coefs);
+ vst1q_u16(diff_values_ptr, diff);
values_ptr += 8;
diff_values_ptr += 8;
rows_to_zero--;
@@ -202,8 +203,8 @@ void jsimd_encode_mcu_AC_first_prepare_neon
/* Zero remaining memory in the values and diff_values blocks. */
for (i = 0; i < rows_to_zero; i++) {
- vst1q_s16(values_ptr, vdupq_n_s16(0));
- vst1q_s16(diff_values_ptr, vdupq_n_s16(0));
+ vst1q_u16(values_ptr, vdupq_n_u16(0));
+ vst1q_u16(diff_values_ptr, vdupq_n_u16(0));
values_ptr += 8;
diff_values_ptr += 8;
}
@@ -211,23 +212,23 @@ void jsimd_encode_mcu_AC_first_prepare_neon
/* Construct zerobits bitmap. A set bit means that the corresponding
* coefficient != 0.
*/
- int16x8_t row0 = vld1q_s16(values + 0 * DCTSIZE);
- int16x8_t row1 = vld1q_s16(values + 1 * DCTSIZE);
- int16x8_t row2 = vld1q_s16(values + 2 * DCTSIZE);
- int16x8_t row3 = vld1q_s16(values + 3 * DCTSIZE);
- int16x8_t row4 = vld1q_s16(values + 4 * DCTSIZE);
- int16x8_t row5 = vld1q_s16(values + 5 * DCTSIZE);
- int16x8_t row6 = vld1q_s16(values + 6 * DCTSIZE);
- int16x8_t row7 = vld1q_s16(values + 7 * DCTSIZE);
-
- uint8x8_t row0_eq0 = vmovn_u16(vceqq_s16(row0, vdupq_n_s16(0)));
- uint8x8_t row1_eq0 = vmovn_u16(vceqq_s16(row1, vdupq_n_s16(0)));
- uint8x8_t row2_eq0 = vmovn_u16(vceqq_s16(row2, vdupq_n_s16(0)));
- uint8x8_t row3_eq0 = vmovn_u16(vceqq_s16(row3, vdupq_n_s16(0)));
- uint8x8_t row4_eq0 = vmovn_u16(vceqq_s16(row4, vdupq_n_s16(0)));
- uint8x8_t row5_eq0 = vmovn_u16(vceqq_s16(row5, vdupq_n_s16(0)));
- uint8x8_t row6_eq0 = vmovn_u16(vceqq_s16(row6, vdupq_n_s16(0)));
- uint8x8_t row7_eq0 = vmovn_u16(vceqq_s16(row7, vdupq_n_s16(0)));
+ uint16x8_t row0 = vld1q_u16(values + 0 * DCTSIZE);
+ uint16x8_t row1 = vld1q_u16(values + 1 * DCTSIZE);
+ uint16x8_t row2 = vld1q_u16(values + 2 * DCTSIZE);
+ uint16x8_t row3 = vld1q_u16(values + 3 * DCTSIZE);
+ uint16x8_t row4 = vld1q_u16(values + 4 * DCTSIZE);
+ uint16x8_t row5 = vld1q_u16(values + 5 * DCTSIZE);
+ uint16x8_t row6 = vld1q_u16(values + 6 * DCTSIZE);
+ uint16x8_t row7 = vld1q_u16(values + 7 * DCTSIZE);
+
+ uint8x8_t row0_eq0 = vmovn_u16(vceqq_u16(row0, vdupq_n_u16(0)));
+ uint8x8_t row1_eq0 = vmovn_u16(vceqq_u16(row1, vdupq_n_u16(0)));
+ uint8x8_t row2_eq0 = vmovn_u16(vceqq_u16(row2, vdupq_n_u16(0)));
+ uint8x8_t row3_eq0 = vmovn_u16(vceqq_u16(row3, vdupq_n_u16(0)));
+ uint8x8_t row4_eq0 = vmovn_u16(vceqq_u16(row4, vdupq_n_u16(0)));
+ uint8x8_t row5_eq0 = vmovn_u16(vceqq_u16(row5, vdupq_n_u16(0)));
+ uint8x8_t row6_eq0 = vmovn_u16(vceqq_u16(row6, vdupq_n_u16(0)));
+ uint8x8_t row7_eq0 = vmovn_u16(vceqq_u16(row7, vdupq_n_u16(0)));
/* { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 } */
const uint8x8_t bitmap_mask =
@@ -274,7 +275,7 @@ void jsimd_encode_mcu_AC_first_prepare_neon
int jsimd_encode_mcu_AC_refine_prepare_neon
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits)
+ UJCOEF *absvalues, size_t *bits)
{
/* Temporary storage buffers for data used to compute the signbits bitmap and
* the end-of-block (EOB) position
@@ -282,7 +283,7 @@ int jsimd_encode_mcu_AC_refine_prepare_neon
uint8_t coef_sign_bits[64];
uint8_t coef_eq1_bits[64];
- JCOEF *absvalues_ptr = absvalues;
+ UJCOEF *absvalues_ptr = absvalues;
uint8_t *coef_sign_bits_ptr = coef_sign_bits;
uint8_t *eq1_bits_ptr = coef_eq1_bits;
@@ -316,18 +317,18 @@ int jsimd_encode_mcu_AC_refine_prepare_neon
vst1_u8(coef_sign_bits_ptr + DCTSIZE, sign_coefs2);
/* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
- vst1q_s16(absvalues_ptr, coefs1);
- vst1q_s16(absvalues_ptr + DCTSIZE, coefs2);
+ uint16x8_t abs_coefs1 = vreinterpretq_u16_s16(vabsq_s16(coefs1));
+ uint16x8_t abs_coefs2 = vreinterpretq_u16_s16(vabsq_s16(coefs2));
+ abs_coefs1 = vshlq_u16(abs_coefs1, vdupq_n_s16(-Al));
+ abs_coefs2 = vshlq_u16(abs_coefs2, vdupq_n_s16(-Al));
+ vst1q_u16(absvalues_ptr, abs_coefs1);
+ vst1q_u16(absvalues_ptr + DCTSIZE, abs_coefs2);
/* Test whether transformed coefficient values == 1 (used to find EOB
* position.)
*/
- uint8x8_t coefs_eq11 = vmovn_u16(vceqq_s16(coefs1, vdupq_n_s16(1)));
- uint8x8_t coefs_eq12 = vmovn_u16(vceqq_s16(coefs2, vdupq_n_s16(1)));
+ uint8x8_t coefs_eq11 = vmovn_u16(vceqq_u16(abs_coefs1, vdupq_n_u16(1)));
+ uint8x8_t coefs_eq12 = vmovn_u16(vceqq_u16(abs_coefs2, vdupq_n_u16(1)));
vst1_u8(eq1_bits_ptr, coefs_eq11);
vst1_u8(eq1_bits_ptr + DCTSIZE, coefs_eq12);
@@ -385,18 +386,18 @@ int jsimd_encode_mcu_AC_refine_prepare_neon
vst1_u8(coef_sign_bits_ptr + DCTSIZE, sign_coefs2);
/* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs1 = vabsq_s16(coefs1);
- int16x8_t abs_coefs2 = vabsq_s16(coefs2);
- coefs1 = vshlq_s16(abs_coefs1, vdupq_n_s16(-Al));
- coefs2 = vshlq_s16(abs_coefs2, vdupq_n_s16(-Al));
- vst1q_s16(absvalues_ptr, coefs1);
- vst1q_s16(absvalues_ptr + DCTSIZE, coefs2);
+ uint16x8_t abs_coefs1 = vreinterpretq_u16_s16(vabsq_s16(coefs1));
+ uint16x8_t abs_coefs2 = vreinterpretq_u16_s16(vabsq_s16(coefs2));
+ abs_coefs1 = vshlq_u16(abs_coefs1, vdupq_n_s16(-Al));
+ abs_coefs2 = vshlq_u16(abs_coefs2, vdupq_n_s16(-Al));
+ vst1q_u16(absvalues_ptr, abs_coefs1);
+ vst1q_u16(absvalues_ptr + DCTSIZE, abs_coefs2);
/* Test whether transformed coefficient values == 1 (used to find EOB
* position.)
*/
- uint8x8_t coefs_eq11 = vmovn_u16(vceqq_s16(coefs1, vdupq_n_s16(1)));
- uint8x8_t coefs_eq12 = vmovn_u16(vceqq_s16(coefs2, vdupq_n_s16(1)));
+ uint8x8_t coefs_eq11 = vmovn_u16(vceqq_u16(abs_coefs1, vdupq_n_u16(1)));
+ uint8x8_t coefs_eq12 = vmovn_u16(vceqq_u16(abs_coefs2, vdupq_n_u16(1)));
vst1_u8(eq1_bits_ptr, coefs_eq11);
vst1_u8(eq1_bits_ptr + DCTSIZE, coefs_eq12);
@@ -444,14 +445,14 @@ int jsimd_encode_mcu_AC_refine_prepare_neon
vst1_u8(coef_sign_bits_ptr, sign_coefs);
/* Compute absolute value of coefficients and apply point transform Al. */
- int16x8_t abs_coefs = vabsq_s16(coefs);
- coefs = vshlq_s16(abs_coefs, vdupq_n_s16(-Al));
- vst1q_s16(absvalues_ptr, coefs);
+ uint16x8_t abs_coefs = vreinterpretq_u16_s16(vabsq_s16(coefs));
+ abs_coefs = vshlq_u16(abs_coefs, vdupq_n_s16(-Al));
+ vst1q_u16(absvalues_ptr, abs_coefs);
/* Test whether transformed coefficient values == 1 (used to find EOB
* position.)
*/
- uint8x8_t coefs_eq1 = vmovn_u16(vceqq_s16(coefs, vdupq_n_s16(1)));
+ uint8x8_t coefs_eq1 = vmovn_u16(vceqq_u16(abs_coefs, vdupq_n_u16(1)));
vst1_u8(eq1_bits_ptr, coefs_eq1);
absvalues_ptr += 8;
@@ -462,7 +463,7 @@ int jsimd_encode_mcu_AC_refine_prepare_neon
/* Zero remaining memory in blocks. */
for (i = 0; i < rows_to_zero; i++) {
- vst1q_s16(absvalues_ptr, vdupq_n_s16(0));
+ vst1q_u16(absvalues_ptr, vdupq_n_u16(0));
vst1_u8(coef_sign_bits_ptr, vdup_n_u8(0));
vst1_u8(eq1_bits_ptr, vdup_n_u8(0));
absvalues_ptr += 8;
@@ -471,23 +472,23 @@ int jsimd_encode_mcu_AC_refine_prepare_neon
}
/* Construct zerobits bitmap. */
- int16x8_t abs_row0 = vld1q_s16(absvalues + 0 * DCTSIZE);
- int16x8_t abs_row1 = vld1q_s16(absvalues + 1 * DCTSIZE);
- int16x8_t abs_row2 = vld1q_s16(absvalues + 2 * DCTSIZE);
- int16x8_t abs_row3 = vld1q_s16(absvalues + 3 * DCTSIZE);
- int16x8_t abs_row4 = vld1q_s16(absvalues + 4 * DCTSIZE);
- int16x8_t abs_row5 = vld1q_s16(absvalues + 5 * DCTSIZE);
- int16x8_t abs_row6 = vld1q_s16(absvalues + 6 * DCTSIZE);
- int16x8_t abs_row7 = vld1q_s16(absvalues + 7 * DCTSIZE);
-
- uint8x8_t abs_row0_eq0 = vmovn_u16(vceqq_s16(abs_row0, vdupq_n_s16(0)));
- uint8x8_t abs_row1_eq0 = vmovn_u16(vceqq_s16(abs_row1, vdupq_n_s16(0)));
- uint8x8_t abs_row2_eq0 = vmovn_u16(vceqq_s16(abs_row2, vdupq_n_s16(0)));
- uint8x8_t abs_row3_eq0 = vmovn_u16(vceqq_s16(abs_row3, vdupq_n_s16(0)));
- uint8x8_t abs_row4_eq0 = vmovn_u16(vceqq_s16(abs_row4, vdupq_n_s16(0)));
- uint8x8_t abs_row5_eq0 = vmovn_u16(vceqq_s16(abs_row5, vdupq_n_s16(0)));
- uint8x8_t abs_row6_eq0 = vmovn_u16(vceqq_s16(abs_row6, vdupq_n_s16(0)));
- uint8x8_t abs_row7_eq0 = vmovn_u16(vceqq_s16(abs_row7, vdupq_n_s16(0)));
+ uint16x8_t abs_row0 = vld1q_u16(absvalues + 0 * DCTSIZE);
+ uint16x8_t abs_row1 = vld1q_u16(absvalues + 1 * DCTSIZE);
+ uint16x8_t abs_row2 = vld1q_u16(absvalues + 2 * DCTSIZE);
+ uint16x8_t abs_row3 = vld1q_u16(absvalues + 3 * DCTSIZE);
+ uint16x8_t abs_row4 = vld1q_u16(absvalues + 4 * DCTSIZE);
+ uint16x8_t abs_row5 = vld1q_u16(absvalues + 5 * DCTSIZE);
+ uint16x8_t abs_row6 = vld1q_u16(absvalues + 6 * DCTSIZE);
+ uint16x8_t abs_row7 = vld1q_u16(absvalues + 7 * DCTSIZE);
+
+ uint8x8_t abs_row0_eq0 = vmovn_u16(vceqq_u16(abs_row0, vdupq_n_u16(0)));
+ uint8x8_t abs_row1_eq0 = vmovn_u16(vceqq_u16(abs_row1, vdupq_n_u16(0)));
+ uint8x8_t abs_row2_eq0 = vmovn_u16(vceqq_u16(abs_row2, vdupq_n_u16(0)));
+ uint8x8_t abs_row3_eq0 = vmovn_u16(vceqq_u16(abs_row3, vdupq_n_u16(0)));
+ uint8x8_t abs_row4_eq0 = vmovn_u16(vceqq_u16(abs_row4, vdupq_n_u16(0)));
+ uint8x8_t abs_row5_eq0 = vmovn_u16(vceqq_u16(abs_row5, vdupq_n_u16(0)));
+ uint8x8_t abs_row6_eq0 = vmovn_u16(vceqq_u16(abs_row6, vdupq_n_u16(0)));
+ uint8x8_t abs_row7_eq0 = vmovn_u16(vceqq_u16(abs_row7, vdupq_n_u16(0)));
/* { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 } */
const uint8x8_t bitmap_mask =
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c
index 8a3e237838e..fd8a93e520b 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jcsample-neon.c
@@ -2,6 +2,7 @@
* jcsample-neon.c - downsampling (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,13 +22,14 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c
index ea4668f1d30..97bb02a1ed7 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jdcolor-neon.c
@@ -2,6 +2,7 @@
* jdcolor-neon.c - colorspace conversion (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,14 +22,14 @@
*/
#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c
index e4f91fdc0ef..95e6d32830c 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jdmerge-neon.c
@@ -2,6 +2,7 @@
* jdmerge-neon.c - merged upsampling/color conversion (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,14 +22,14 @@
*/
#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c
index 90ec6782c47..a130b1a9581 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jdsample-neon.c
@@ -2,7 +2,7 @@
* jdsample-neon.c - upsampling (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -22,12 +22,13 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c
index bb371be3999..d6109f11d34 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jfdctfst-neon.c
@@ -2,6 +2,7 @@
* jfdctfst-neon.c - fast integer FDCT (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,13 +22,14 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c
index ccfc07b15d9..bb290ea45d2 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jfdctint-neon.c
@@ -2,7 +2,7 @@
* jfdctint-neon.c - accurate integer FDCT (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -22,11 +22,11 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
#include "neon-compat.h"
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c
index a91be5362eb..e789125344a 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jidctfst-neon.c
@@ -2,6 +2,7 @@
* jidctfst-neon.c - fast integer IDCT (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,13 +22,14 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c
index 043b652e6c5..709e0eaf4e9 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jidctint-neon.c
@@ -2,7 +2,7 @@
* jidctint-neon.c - accurate integer IDCT (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -22,12 +22,11 @@
*/
#define JPEG_INTERNALS
-#include "jconfigint.h"
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
#include "neon-compat.h"
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c
index be9627e61d4..25b1addc6a9 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jidctred-neon.c
@@ -2,7 +2,7 @@
* jidctred-neon.c - reduced-size IDCT (Arm Neon)
*
* Copyright (C) 2020, Arm Limited. All Rights Reserved.
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -22,11 +22,11 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
#include "align.h"
#include "neon-compat.h"
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c b/contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c
index d5d95d89f67..e44fb3d4131 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c
+++ b/contrib/libs/libjpeg-turbo/simd/arm/jquanti-neon.c
@@ -2,6 +2,7 @@
* jquanti-neon.c - sample data conversion and quantization (Arm Neon)
*
* Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
+ * Copyright (C) 2024, D. R. Commander. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
@@ -21,12 +22,13 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
+#include "neon-compat.h"
#include <arm_neon.h>
diff --git a/contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h b/contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h
index 069c62d8290..992aa5a4f97 100644
--- a/contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h
+++ b/contrib/libs/libjpeg-turbo/simd/arm/neon-compat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
+ * Copyright (C) 2020, 2024, D. R. Commander. All Rights Reserved.
* Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
*
* This software is provided 'as-is', without any express or implied
@@ -35,3 +35,11 @@
#else
#error "Unknown compiler"
#endif
+
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wdeclaration-after-statement"
+#pragma clang diagnostic ignored "-Wc99-extensions"
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm
index c46d684436d..28ac9528079 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-avx2.asm
@@ -2,17 +2,13 @@
; 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -49,15 +45,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
@@ -80,9 +76,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
@@ -93,11 +89,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 ; ---------------
@@ -154,7 +150,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]
@@ -278,7 +274,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]
@@ -552,7 +548,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
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm
index 6357a42b2cf..44b62512e91 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-mmx.asm
@@ -2,17 +2,13 @@
; jccolext.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -49,15 +45,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
@@ -80,9 +76,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
@@ -93,11 +89,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 ; ---------------
@@ -143,7 +139,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]
@@ -211,7 +207,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]
@@ -449,7 +445,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
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm
index c6c80852ac5..1d8d5f5a205 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jccolext-sse2.asm
@@ -1,17 +1,13 @@
;
; 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -48,15 +44,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
@@ -79,9 +75,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
@@ -92,11 +88,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 ; ---------------
@@ -147,7 +143,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]
@@ -232,7 +228,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]
@@ -478,7 +474,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
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm
index 14944e952f1..9ad5ea95f80 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-avx2.asm
@@ -1,18 +1,14 @@
;
; 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
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -33,7 +29,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):
@@ -46,7 +42,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
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm
index 8cb399bdc43..0dbec54817e 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-mmx.asm
@@ -2,17 +2,13 @@
; jccolor.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -33,7 +29,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):
@@ -46,7 +42,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
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm
index 686d222ff70..678306a10c3 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jccolor-sse2.asm
@@ -1,17 +1,13 @@
;
; 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -32,7 +28,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):
@@ -45,7 +41,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
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm
index 560ee0c71e2..ded39567df2 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-avx2.asm
@@ -1,18 +1,14 @@
;
; jcgray.asm - grayscale colorspace conversion (AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -29,7 +25,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_gray_convert_avx2)
EXTN(jconst_rgb_gray_convert_avx2):
@@ -38,7 +34,7 @@ PW_F0299_F0337 times 8 dw F_0_299, F_0_337
PW_F0114_F0250 times 8 dw F_0_114, F_0_250
PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm
index 79fdf082a84..d6f031869a0 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-mmx.asm
@@ -2,17 +2,13 @@
; jcgray.asm - grayscale colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -29,7 +25,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_gray_convert_mmx)
EXTN(jconst_rgb_gray_convert_mmx):
@@ -38,7 +34,7 @@ PW_F0299_F0337 times 2 dw F_0_299, F_0_337
PW_F0114_F0250 times 2 dw F_0_114, F_0_250
PD_ONEHALF times 2 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm
index cb4b28e8f49..ecc7fa08abb 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcgray-sse2.asm
@@ -1,17 +1,13 @@
;
; jcgray.asm - grayscale colorspace conversion (SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -28,7 +24,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_gray_convert_sse2)
EXTN(jconst_rgb_gray_convert_sse2):
@@ -37,7 +33,7 @@ PW_F0299_F0337 times 4 dw F_0_299, F_0_337
PW_F0114_F0250 times 4 dw F_0_114, F_0_250
PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm
index 3fa7973d72b..70df8f80ba4 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-avx2.asm
@@ -1,18 +1,14 @@
;
; jcgryext.asm - grayscale colorspace conversion (AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -49,15 +45,15 @@ EXTN(jsimd_rgb_gray_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
@@ -76,20 +72,20 @@ EXTN(jsimd_rgb_gray_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 edi
push esi
push ecx ; col
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr0
- 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 ; ---------------
@@ -146,7 +142,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -270,7 +266,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
vmovdqu ymmF, YMMWORD [esi+1*SIZEOF_YMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymmA, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -433,7 +429,7 @@ EXTN(jsimd_rgb_gray_convert_avx2):
pop ecx ; col
pop esi
pop edi
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm
index 8af42e5a332..dd90c3dfb08 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-mmx.asm
@@ -2,17 +2,13 @@
; jcgryext.asm - grayscale colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -49,15 +45,15 @@ EXTN(jsimd_rgb_gray_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
@@ -76,20 +72,20 @@ EXTN(jsimd_rgb_gray_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 edi
push esi
push ecx ; col
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr0
- 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 ; ---------------
@@ -135,7 +131,7 @@ EXTN(jsimd_rgb_gray_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmG, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -203,7 +199,7 @@ EXTN(jsimd_rgb_gray_convert_mmx):
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
movq mmF, MMWORD [esi+1*SIZEOF_MMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mmA, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -330,7 +326,7 @@ EXTN(jsimd_rgb_gray_convert_mmx):
pop ecx ; col
pop esi
pop edi
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm
index c9d6ff1e351..227295f3072 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcgryext-sse2.asm
@@ -1,17 +1,13 @@
;
; jcgryext.asm - grayscale colorspace conversion (SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -48,15 +44,15 @@ EXTN(jsimd_rgb_gray_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
@@ -75,20 +71,20 @@ EXTN(jsimd_rgb_gray_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 edi
push esi
push ecx ; col
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr0
- 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 ; ---------------
@@ -139,7 +135,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmF, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -224,7 +220,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
movdqu xmmE, XMMWORD [esi+1*SIZEOF_XMMWORD]
jmp short .rgb_gray_cnv
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqu xmmA, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -359,7 +355,7 @@ EXTN(jsimd_rgb_gray_convert_sse2):
pop ecx ; col
pop esi
pop edi
- poppic eax
+ POPPIC eax
add esi, byte SIZEOF_JSAMPROW ; input_buf
add edi, byte SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm
index 278cf5e83af..ed194dd383d 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jchuff-sse2.asm
@@ -1,7 +1,7 @@
;
; jchuff-sse2.asm - Huffman entropy encoding (SSE2)
;
-; Copyright (C) 2009-2011, 2014-2017, 2019, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2017, 2019, 2024, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
;
@@ -9,11 +9,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation for Huffman coding of one block.
; The following code is based on jchuff.c; see jchuff.c for more details.
@@ -42,7 +38,7 @@ endstruc
EXTN(jconst_huff_encode_one_block):
- alignz 32
+ ALIGNZ 32
jpeg_mask_bits dq 0x0000, 0x0001, 0x0003, 0x0007
dq 0x000f, 0x001f, 0x003f, 0x007f
@@ -65,7 +61,8 @@ times 1 << 2 db 3
times 1 << 1 db 2
times 1 << 0 db 1
times 1 db 0
-jpeg_nbits_table:
+GLOBAL_DATA(jpeg_nbits_table)
+EXTN(jpeg_nbits_table):
times 1 db 0
times 1 << 0 db 1
times 1 << 1 db 2
@@ -83,14 +80,14 @@ times 1 << 12 db 13
times 1 << 13 db 14
times 1 << 14 db 15
- alignz 32
+ ALIGNZ 32
%ifdef PIC
%define NBITS(x) nbits_base + x
%else
-%define NBITS(x) jpeg_nbits_table + x
+%define NBITS(x) EXTN(jpeg_nbits_table) + x
%endif
-%define MASK_BITS(x) NBITS((x) * 8) + (jpeg_mask_bits - jpeg_nbits_table)
+%define MASK_BITS(x) NBITS((x) * 8) + (jpeg_mask_bits - EXTN(jpeg_nbits_table))
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -235,7 +232,7 @@ times 1 << 14 db 15
; If PIC is defined, load the address of a symbol defined in this file into a
; register. Equivalent to
-; get_GOT %1
+; GET_GOT %1
; lea %1, [GOTOFF(%1, %2)]
; without using the GOT.
;
@@ -469,7 +466,7 @@ EXTN(jsimd_huff_encode_one_block_sse2):
pcmpeqw mm_all_0xff, mm_all_0xff ;Z: all_0xff[i] = 0xFF;
%endmacro
- GET_SYM nbits_base, jpeg_nbits_table, GET_SYM_BEFORE, GET_SYM_AFTER
+ GET_SYM nbits_base, EXTN(jpeg_nbits_table), GET_SYM_BEFORE, GET_SYM_AFTER
psrldq xmm4, 1 * SIZEOF_WORD ;G: w4 = 37 44 45 38 39 46 47 --
shufpd xmm1, xmm5, 10b ;F: w1 = 36 37 44 45 50 51 58 59
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm
index c26b48a47d8..19a183fcd83 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcphuff-sse2.asm
@@ -7,11 +7,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation of data preparation for progressive
; Huffman encoding. See jcphuff.c for more details.
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm
index 0a20802dd89..5019829c9ae 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-avx2.asm
@@ -3,17 +3,13 @@
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
; 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -70,7 +66,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -106,7 +102,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -117,7 +113,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
cmp ecx, byte SIZEOF_YMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r24:
; ecx can possibly be 8, 16, 24
@@ -141,7 +137,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
vpxor ymm1, ymm1, ymm1
mov ecx, SIZEOF_YMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm0, YMMWORD [esi+0*SIZEOF_YMMWORD]
@@ -243,7 +239,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -279,7 +275,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -291,7 +287,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
cmp ecx, byte SIZEOF_YMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r24:
cmp ecx, 24
@@ -320,7 +316,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
vpxor ymm3, ymm3, ymm3
mov ecx, SIZEOF_YMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm0, YMMWORD [edx+0*SIZEOF_YMMWORD]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm
index 2c223eebe81..94dd88870a3 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-mmx.asm
@@ -2,17 +2,13 @@
; jcsample.asm - downsampling (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -69,7 +65,7 @@ EXTN(jsimd_h2v1_downsample_mmx):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -104,7 +100,7 @@ EXTN(jsimd_h2v1_downsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -112,7 +108,7 @@ EXTN(jsimd_h2v1_downsample_mmx):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -212,7 +208,7 @@ EXTN(jsimd_h2v2_downsample_mmx):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -247,7 +243,7 @@ EXTN(jsimd_h2v2_downsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -256,7 +252,7 @@ EXTN(jsimd_h2v2_downsample_mmx):
mov edx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; inptr0
mov esi, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; inptr1
mov edi, JSAMPROW [edi] ; outptr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [edx+0*SIZEOF_MMWORD]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm
index 4fea60d2e21..eb8808bea84 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jcsample-sse2.asm
@@ -2,17 +2,13 @@
; jcsample.asm - downsampling (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -69,7 +65,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -104,7 +100,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -115,14 +111,14 @@ EXTN(jsimd_h2v1_downsample_sse2):
cmp ecx, byte SIZEOF_XMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r8:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
pxor xmm1, xmm1
mov ecx, SIZEOF_XMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -225,7 +221,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
cld
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
- alignx 16, 7
+ ALIGNX 16, 7
.expandloop:
push eax
push ecx
@@ -260,7 +256,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, JSAMPARRAY [output_data(ebp)] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push ecx
push edi
@@ -272,7 +268,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
cmp ecx, byte SIZEOF_XMMWORD
jae short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_r8:
movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
@@ -281,7 +277,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
pxor xmm3, xmm3
mov ecx, SIZEOF_XMMWORD
jmp short .downsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [edx+0*SIZEOF_XMMWORD]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm
index 015be0416c5..fd79b79568e 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-avx2.asm
@@ -2,18 +2,14 @@
; jdcolext.asm - colorspace conversion (AVX2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -50,15 +46,15 @@ EXTN(jsimd_ycc_rgb_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 [out_width(eax)] ; num_cols
test ecx, ecx
@@ -81,7 +77,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax
push edi
@@ -94,8 +90,8 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
mov ebx, JSAMPROW [ebx] ; inptr1
mov edx, JSAMPROW [edx] ; inptr2
mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm5, YMMWORD [ebx] ; ymm5=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
@@ -295,7 +291,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -436,7 +432,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
cmp ecx, byte SIZEOF_YMMWORD/2
@@ -479,7 +475,7 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
%endif ; RGB_PIXELSIZE ; ---------------
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop ecx
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm
index 5813cfcb66f..636bd6d3fdc 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-mmx.asm
@@ -2,17 +2,13 @@
; jdcolext.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -49,15 +45,15 @@ EXTN(jsimd_ycc_rgb_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 [out_width(eax)] ; num_cols
test ecx, ecx
@@ -80,7 +76,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax
push edi
@@ -93,8 +89,8 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
mov ebx, JSAMPROW [ebx] ; inptr1
mov edx, JSAMPROW [edx] ; inptr2
mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
+ ALIGNX 16, 7
.columnloop:
movq mm5, MMWORD [ebx] ; mm5=Cb(01234567)
@@ -255,7 +251,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
add edx, byte SIZEOF_MMWORD ; inptr2
add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -344,7 +340,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
add edx, byte SIZEOF_MMWORD ; inptr2
add edi, byte RGB_PIXELSIZE*SIZEOF_MMWORD ; outptr
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
cmp ecx, byte SIZEOF_MMWORD/2
@@ -369,7 +365,7 @@ EXTN(jsimd_ycc_rgb_convert_mmx):
%endif ; RGB_PIXELSIZE ; ---------------
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop ecx
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm
index d5572b32946..0150f2cb69c 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdcolext-sse2.asm
@@ -2,17 +2,13 @@
; jdcolext.asm - colorspace conversion (SSE2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -49,15 +45,15 @@ EXTN(jsimd_ycc_rgb_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 [out_width(eax)] ; num_cols
test ecx, ecx
@@ -80,7 +76,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
mov eax, INT [num_rows(eax)]
test eax, eax
jle near .return
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax
push edi
@@ -93,8 +89,8 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
mov ebx, JSAMPROW [ebx] ; inptr1
mov edx, JSAMPROW [edx] ; inptr2
mov edi, JSAMPROW [edi] ; outptr
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
- alignx 16, 7
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
+ ALIGNX 16, 7
.columnloop:
movdqa xmm5, XMMWORD [ebx] ; xmm5=Cb(0123456789ABCDEF)
@@ -275,7 +271,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -387,7 +383,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
cmp ecx, byte SIZEOF_XMMWORD/2
@@ -423,7 +419,7 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
%endif ; RGB_PIXELSIZE ; ---------------
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop ecx
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm
index e05b60d0017..d3a30d63a71 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-avx2.asm
@@ -3,17 +3,13 @@
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
; 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -32,7 +28,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_avx2)
EXTN(jconst_ycc_rgb_convert_avx2):
@@ -43,7 +39,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm
index fb7e7bcce4b..6e67e4b72ea 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-mmx.asm
@@ -2,17 +2,13 @@
; jdcolor.asm - colorspace conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -31,7 +27,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_mmx)
EXTN(jconst_ycc_rgb_convert_mmx):
@@ -42,7 +38,7 @@ PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285
PW_ONE times 4 dw 1
PD_ONEHALF times 2 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm
index b736255317e..79c9c6821a4 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdcolor-sse2.asm
@@ -2,17 +2,13 @@
; jdcolor.asm - colorspace conversion (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -31,7 +27,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_sse2)
EXTN(jconst_ycc_rgb_convert_sse2):
@@ -42,7 +38,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm
index 711e6792d0f..90493fd023b 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-avx2.asm
@@ -2,18 +2,14 @@
; jdmerge.asm - merged upsampling/color conversion (AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; 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
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -32,7 +28,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_avx2)
EXTN(jconst_merged_upsample_avx2):
@@ -43,7 +39,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm
index 6e8311d4081..0dc204aa8b4 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-mmx.asm
@@ -2,17 +2,13 @@
; jdmerge.asm - merged upsampling/color conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -31,7 +27,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_mmx)
EXTN(jconst_merged_upsample_mmx):
@@ -42,7 +38,7 @@ PW_MF0344_F0285 times 2 dw -F_0_344, F_0_285
PW_ONE times 4 dw 1
PD_ONEHALF times 2 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm
index e32f90aa177..06f07627421 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdmerge-sse2.asm
@@ -2,17 +2,13 @@
; jdmerge.asm - merged upsampling/color conversion (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -31,7 +27,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_sse2)
EXTN(jconst_merged_upsample_sse2):
@@ -42,7 +38,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm
index e35f7282bc4..a7aa930e346 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-avx2.asm
@@ -2,18 +2,14 @@
; jdmrgext.asm - merged upsampling/color conversion (AVX2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -50,15 +46,15 @@ EXTN(jsimd_h2v1_merged_upsample_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 [output_width(eax)] ; col
test ecx, ecx
@@ -79,9 +75,9 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
pop ecx ; col
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
vmovdqu ymm6, YMMWORD [ebx] ; ymm6=Cb(0123456789ABCDEFGHIJKLMNOPQRSTUV)
vmovdqu ymm7, YMMWORD [edx] ; ymm7=Cr(0123456789ABCDEFGHIJKLMNOPQRSTUV)
@@ -168,13 +164,13 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
mov al, 2 ; Yctr
jmp short .Yloop_1st
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_2nd:
vmovdqa ymm0, YMMWORD [wk(1)] ; ymm0=(R-Y)H
vmovdqa ymm2, YMMWORD [wk(2)] ; ymm2=(G-Y)H
vmovdqa ymm4, YMMWORD [wk(0)] ; ymm4=(B-Y)H
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_1st:
vmovdqu ymm7, YMMWORD [esi] ; ymm7=Y(0123456789ABCDEFGHIJKLMNOPQRSTUV)
@@ -301,7 +297,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -445,7 +441,7 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
add ebx, byte SIZEOF_YMMWORD ; inptr1
add edx, byte SIZEOF_YMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st64:
cmp ecx, byte SIZEOF_YMMWORD/2
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm
index eb3e36b4759..562758146c6 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-mmx.asm
@@ -2,17 +2,13 @@
; jdmrgext.asm - merged upsampling/color conversion (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -47,15 +43,15 @@ EXTN(jsimd_h2v1_merged_upsample_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 [output_width(eax)] ; col
test ecx, ecx
@@ -76,9 +72,9 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
pop ecx ; col
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
movq mm6, MMWORD [ebx] ; mm6=Cb(01234567)
movq mm7, MMWORD [edx] ; mm7=Cr(01234567)
@@ -171,13 +167,13 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
mov al, 2 ; Yctr
jmp short .Yloop_1st
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_2nd:
movq mm0, MMWORD [wk(1)] ; mm0=(R-Y)H
movq mm2, MMWORD [wk(2)] ; mm2=(G-Y)H
movq mm4, MMWORD [wk(0)] ; mm4=(B-Y)H
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_1st:
movq mm7, MMWORD [esi] ; mm7=Y(01234567)
@@ -258,7 +254,7 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
add ebx, byte SIZEOF_MMWORD ; inptr1
add edx, byte SIZEOF_MMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -350,7 +346,7 @@ EXTN(jsimd_h2v1_merged_upsample_mmx):
add ebx, byte SIZEOF_MMWORD ; inptr1
add edx, byte SIZEOF_MMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st16:
cmp ecx, byte SIZEOF_MMWORD/2
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm
index c113dc4d27e..13e7d980fa6 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdmrgext-sse2.asm
@@ -2,17 +2,13 @@
; jdmrgext.asm - merged upsampling/color conversion (SSE2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2012, 2016, D. R. Commander.
+; Copyright (C) 2012, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -49,15 +45,15 @@ EXTN(jsimd_h2v1_merged_upsample_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 [output_width(eax)] ; col
test ecx, ecx
@@ -78,9 +74,9 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
pop ecx ; col
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
- movpic eax, POINTER [gotptr] ; load GOT address (eax)
+ MOVPIC eax, POINTER [gotptr] ; load GOT address (eax)
movdqa xmm6, XMMWORD [ebx] ; xmm6=Cb(0123456789ABCDEF)
movdqa xmm7, XMMWORD [edx] ; xmm7=Cr(0123456789ABCDEF)
@@ -173,13 +169,13 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
mov al, 2 ; Yctr
jmp short .Yloop_1st
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_2nd:
movdqa xmm0, XMMWORD [wk(1)] ; xmm0=(R-Y)H
movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(G-Y)H
movdqa xmm4, XMMWORD [wk(0)] ; xmm4=(B-Y)H
- alignx 16, 7
+ ALIGNX 16, 7
.Yloop_1st:
movdqa xmm7, XMMWORD [esi] ; xmm7=Y(0123456789ABCDEF)
@@ -280,7 +276,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
lea ecx, [ecx+ecx*2] ; imul ecx, RGB_PIXELSIZE
@@ -395,7 +391,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
add ebx, byte SIZEOF_XMMWORD ; inptr1
add edx, byte SIZEOF_XMMWORD ; inptr2
jmp near .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.column_st32:
cmp ecx, byte SIZEOF_XMMWORD/2
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm
index a800c35e083..eba53ef7574 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-avx2.asm
@@ -3,24 +3,20 @@
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
; 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_avx2)
EXTN(jconst_fancy_upsample_avx2):
@@ -31,7 +27,7 @@ PW_THREE times 16 dw 3
PW_SEVEN times 16 dw 7
PW_EIGHT times 16 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -62,13 +58,13 @@ PW_EIGHT times 16 dw 8
EXTN(jsimd_h2v1_fancy_upsample_avx2):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
test eax, eax
@@ -81,7 +77,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push edi
@@ -104,7 +100,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
and eax, byte -SIZEOF_YMMWORD
cmp eax, byte SIZEOF_YMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
vpcmpeqb xmm6, xmm6, xmm6
@@ -112,7 +108,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
vperm2i128 ymm6, ymm6, ymm6, 1 ; (---- ---- ... ---- ---- ff) MSB is ff
vpand ymm6, ymm6, YMMWORD [esi+0*SIZEOF_YMMWORD]
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
vmovdqu ymm6, YMMWORD [esi+1*SIZEOF_YMMWORD]
@@ -196,7 +192,7 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
pop ebp
ret
@@ -234,15 +230,15 @@ EXTN(jsimd_h2v2_fancy_upsample_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 edx, eax ; edx = original ebp
mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
@@ -256,7 +252,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
mov esi, JSAMPARRAY [input_data(edx)] ; input_data
mov edi, POINTER [output_data_ptr(edx)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push ecx
@@ -286,8 +282,8 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqu ymm1, YMMWORD [ecx+0*SIZEOF_YMMWORD] ; ymm1=row[-1][0]
vmovdqu ymm2, YMMWORD [esi+0*SIZEOF_YMMWORD] ; ymm2=row[+1][0]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
vpxor ymm3, ymm3, ymm3 ; ymm3=(all 0's)
@@ -328,19 +324,19 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqa YMMWORD [wk(0)], ymm1
vmovdqa YMMWORD [wk(1)], ymm2
- poppic ebx
+ POPPIC ebx
add eax, byte SIZEOF_YMMWORD-1
and eax, byte -SIZEOF_YMMWORD
cmp eax, byte SIZEOF_YMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
; -- process the last column block
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
vpcmpeqb xmm1, xmm1, xmm1
vpslldq xmm1, xmm1, (SIZEOF_XMMWORD-2)
@@ -353,7 +349,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqa YMMWORD [wk(3)], ymm2 ; ymm2=(-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 31)
jmp near .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
; -- process the next column block
@@ -362,8 +358,8 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqu ymm1, YMMWORD [ecx+1*SIZEOF_YMMWORD] ; ymm1=row[-1][1]
vmovdqu ymm2, YMMWORD [esi+1*SIZEOF_YMMWORD] ; ymm2=row[+1][1]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
vpxor ymm3, ymm3, ymm3 ; ymm3=(all 0's)
@@ -516,7 +512,7 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
vmovdqu YMMWORD [edi+0*SIZEOF_YMMWORD], ymm1
vmovdqu YMMWORD [edi+1*SIZEOF_YMMWORD], ymm0
- poppic ebx
+ POPPIC ebx
sub eax, byte SIZEOF_YMMWORD
add ecx, byte 1*SIZEOF_YMMWORD ; inptr1(above)
@@ -590,7 +586,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -598,7 +594,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
cmp eax, byte SIZEOF_YMMWORD
@@ -629,7 +625,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
add esi, byte SIZEOF_YMMWORD ; inptr
add edi, byte 2*SIZEOF_YMMWORD ; outptr
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
@@ -689,7 +685,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -698,7 +694,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
cmp eax, byte SIZEOF_YMMWORD
@@ -734,7 +730,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
add ebx, 2*SIZEOF_YMMWORD ; outptr0
add edi, 2*SIZEOF_YMMWORD ; outptr1
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm
index 12c49f0eab5..01d09e62d10 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-mmx.asm
@@ -2,24 +2,20 @@
; jdsample.asm - upsampling (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_mmx)
EXTN(jconst_fancy_upsample_mmx):
@@ -30,7 +26,7 @@ PW_THREE times 4 dw 3
PW_SEVEN times 4 dw 7
PW_EIGHT times 4 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -61,13 +57,13 @@ PW_EIGHT times 4 dw 8
EXTN(jsimd_h2v1_fancy_upsample_mmx):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
test eax, eax
@@ -80,7 +76,7 @@ EXTN(jsimd_h2v1_fancy_upsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push edi
@@ -103,14 +99,14 @@ EXTN(jsimd_h2v1_fancy_upsample_mmx):
and eax, byte -SIZEOF_MMWORD
cmp eax, byte SIZEOF_MMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
pcmpeqb mm6, mm6
psllq mm6, (SIZEOF_MMWORD-1)*BYTE_BIT
pand mm6, MMWORD [esi+0*SIZEOF_MMWORD]
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm6, MMWORD [esi+1*SIZEOF_MMWORD]
@@ -187,7 +183,7 @@ EXTN(jsimd_h2v1_fancy_upsample_mmx):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
pop ebp
ret
@@ -224,15 +220,15 @@ EXTN(jsimd_h2v2_fancy_upsample_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 edx, eax ; edx = original ebp
mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
@@ -246,7 +242,7 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
mov esi, JSAMPARRAY [input_data(edx)] ; input_data
mov edi, POINTER [output_data_ptr(edx)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push ecx
@@ -276,8 +272,8 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq mm1, MMWORD [ecx+0*SIZEOF_MMWORD] ; mm1=row[-1][0]
movq mm2, MMWORD [esi+0*SIZEOF_MMWORD] ; mm2=row[+1][0]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor mm3, mm3 ; mm3=(all 0's)
movq mm4, mm0
@@ -312,19 +308,19 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq MMWORD [wk(0)], mm1
movq MMWORD [wk(1)], mm2
- poppic ebx
+ POPPIC ebx
add eax, byte SIZEOF_MMWORD-1
and eax, byte -SIZEOF_MMWORD
cmp eax, byte SIZEOF_MMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
; -- process the last column block
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pcmpeqb mm1, mm1
psllq mm1, (SIZEOF_MMWORD-2)*BYTE_BIT
@@ -337,7 +333,7 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq MMWORD [wk(3)], mm2
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
; -- process the next column block
@@ -346,8 +342,8 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq mm1, MMWORD [ecx+1*SIZEOF_MMWORD] ; mm1=row[-1][1]
movq mm2, MMWORD [esi+1*SIZEOF_MMWORD] ; mm2=row[+1][1]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor mm3, mm3 ; mm3=(all 0's)
movq mm4, mm0
@@ -486,7 +482,7 @@ EXTN(jsimd_h2v2_fancy_upsample_mmx):
movq MMWORD [edi+0*SIZEOF_MMWORD], mm1
movq MMWORD [edi+1*SIZEOF_MMWORD], mm0
- poppic ebx
+ POPPIC ebx
sub eax, byte SIZEOF_MMWORD
add ecx, byte 1*SIZEOF_MMWORD ; inptr1(above)
@@ -561,7 +557,7 @@ EXTN(jsimd_h2v1_upsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -569,7 +565,7 @@ EXTN(jsimd_h2v1_upsample_mmx):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -599,7 +595,7 @@ EXTN(jsimd_h2v1_upsample_mmx):
add esi, byte 2*SIZEOF_MMWORD ; inptr
add edi, byte 4*SIZEOF_MMWORD ; outptr
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
@@ -660,7 +656,7 @@ EXTN(jsimd_h2v2_upsample_mmx):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -669,7 +665,7 @@ EXTN(jsimd_h2v2_upsample_mmx):
mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [esi+0*SIZEOF_MMWORD]
@@ -704,7 +700,7 @@ EXTN(jsimd_h2v2_upsample_mmx):
add ebx, byte 4*SIZEOF_MMWORD ; outptr0
add edi, byte 4*SIZEOF_MMWORD ; outptr1
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm
index 4e28d2f4b80..b10d9227987 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jdsample-sse2.asm
@@ -2,24 +2,20 @@
; jdsample.asm - upsampling (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_sse2)
EXTN(jconst_fancy_upsample_sse2):
@@ -30,7 +26,7 @@ PW_THREE times 8 dw 3
PW_SEVEN times 8 dw 7
PW_EIGHT times 8 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -61,13 +57,13 @@ PW_EIGHT times 8 dw 8
EXTN(jsimd_h2v1_fancy_upsample_sse2):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
mov eax, JDIMENSION [downsamp_width(ebp)] ; colctr
test eax, eax
@@ -80,7 +76,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push edi
@@ -103,14 +99,14 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
and eax, byte -SIZEOF_XMMWORD
cmp eax, byte SIZEOF_XMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
pcmpeqb xmm6, xmm6
pslldq xmm6, (SIZEOF_XMMWORD-1)
pand xmm6, XMMWORD [esi+0*SIZEOF_XMMWORD]
jmp short .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm6, XMMWORD [esi+1*SIZEOF_XMMWORD]
@@ -185,7 +181,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
pop ebp
ret
@@ -223,15 +219,15 @@ EXTN(jsimd_h2v2_fancy_upsample_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 edx, eax ; edx = original ebp
mov eax, JDIMENSION [downsamp_width(edx)] ; colctr
@@ -245,7 +241,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
mov esi, JSAMPARRAY [input_data(edx)] ; input_data
mov edi, POINTER [output_data_ptr(edx)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push eax ; colctr
push ecx
@@ -275,8 +271,8 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa xmm1, XMMWORD [ecx+0*SIZEOF_XMMWORD] ; xmm1=row[-1][0]
movdqa xmm2, XMMWORD [esi+0*SIZEOF_XMMWORD] ; xmm2=row[+1][0]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor xmm3, xmm3 ; xmm3=(all 0's)
movdqa xmm4, xmm0
@@ -311,19 +307,19 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa XMMWORD [wk(0)], xmm1
movdqa XMMWORD [wk(1)], xmm2
- poppic ebx
+ POPPIC ebx
add eax, byte SIZEOF_XMMWORD-1
and eax, byte -SIZEOF_XMMWORD
cmp eax, byte SIZEOF_XMMWORD
ja short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop_last:
; -- process the last column block
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pcmpeqb xmm1, xmm1
pslldq xmm1, (SIZEOF_XMMWORD-2)
@@ -336,7 +332,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa XMMWORD [wk(3)], xmm2 ; xmm2=(-- -- -- -- -- -- -- 15)
jmp near .upsample
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
; -- process the next column block
@@ -345,8 +341,8 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa xmm1, XMMWORD [ecx+1*SIZEOF_XMMWORD] ; xmm1=row[-1][1]
movdqa xmm2, XMMWORD [esi+1*SIZEOF_XMMWORD] ; xmm2=row[+1][1]
- pushpic ebx
- movpic ebx, POINTER [gotptr] ; load GOT address
+ PUSHPIC ebx
+ MOVPIC ebx, POINTER [gotptr] ; load GOT address
pxor xmm3, xmm3 ; xmm3=(all 0's)
movdqa xmm4, xmm0
@@ -485,7 +481,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
movdqa XMMWORD [edi+0*SIZEOF_XMMWORD], xmm1
movdqa XMMWORD [edi+1*SIZEOF_XMMWORD], xmm0
- poppic ebx
+ POPPIC ebx
sub eax, byte SIZEOF_XMMWORD
add ecx, byte 1*SIZEOF_XMMWORD ; inptr1(above)
@@ -558,7 +554,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -566,7 +562,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
mov esi, JSAMPROW [esi] ; inptr
mov edi, JSAMPROW [edi] ; outptr
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -596,7 +592,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
add esi, byte 2*SIZEOF_XMMWORD ; inptr
add edi, byte 4*SIZEOF_XMMWORD ; outptr
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
@@ -655,7 +651,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
mov esi, JSAMPARRAY [input_data(ebp)] ; input_data
mov edi, POINTER [output_data_ptr(ebp)]
mov edi, JSAMPARRAY [edi] ; output_data
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
push edi
push esi
@@ -664,7 +660,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
mov ebx, JSAMPROW [edi+0*SIZEOF_JSAMPROW] ; outptr0
mov edi, JSAMPROW [edi+1*SIZEOF_JSAMPROW] ; outptr1
mov eax, edx ; colctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movdqa xmm0, XMMWORD [esi+0*SIZEOF_XMMWORD]
@@ -699,7 +695,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
add ebx, byte 4*SIZEOF_XMMWORD ; outptr0
add edi, byte 4*SIZEOF_XMMWORD ; outptr1
jmp short .columnloop
- alignx 16, 7
+ ALIGNX 16, 7
.nextrow:
pop esi
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm
index 322ab163252..0cedc6caf40 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-3dn.asm
@@ -2,17 +2,13 @@
; jfdctflt.asm - floating-point FDCT (3DNow!)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the forward DCT
; (Discrete Cosine Transform). The following code is based directly on
@@ -24,7 +20,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_float_3dnow)
EXTN(jconst_fdct_float_3dnow):
@@ -34,7 +30,7 @@ PD_0_707 times 2 dd 0.707106781186547524400844
PD_0_541 times 2 dd 0.541196100146196984399723
PD_1_306 times 2 dd 1.306562964876376527856643
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -63,19 +59,19 @@ EXTN(jsimd_fdct_float_3dnow):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
@@ -190,7 +186,7 @@ EXTN(jsimd_fdct_float_3dnow):
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [MMBLOCK(0,0,edx,SIZEOF_FAST_FLOAT)]
@@ -307,7 +303,7 @@ EXTN(jsimd_fdct_float_3dnow):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm
index 86952c6499c..2cb95335869 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jfdctflt-sse.asm
@@ -2,17 +2,13 @@
; jfdctflt.asm - floating-point FDCT (SSE)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the forward DCT
; (Discrete Cosine Transform). The following code is based directly on
@@ -34,7 +30,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_float_sse)
EXTN(jconst_fdct_float_sse):
@@ -44,7 +40,7 @@ PD_0_707 times 4 dd 0.707106781186547524400844
PD_0_541 times 4 dd 0.541196100146196984399723
PD_1_306 times 4 dd 1.306562964876376527856643
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -74,19 +70,19 @@ EXTN(jsimd_fdct_float_sse):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
@@ -222,7 +218,7 @@ EXTN(jsimd_fdct_float_sse):
mov edx, POINTER [data(eax)] ; (FAST_FLOAT *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movaps xmm0, XMMWORD [XMMBLOCK(2,0,edx,SIZEOF_FAST_FLOAT)]
@@ -358,7 +354,7 @@ EXTN(jsimd_fdct_float_sse):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm
index 80645a50d7e..fe16e83ee24 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-mmx.asm
@@ -2,17 +2,13 @@
; jfdctfst.asm - fast integer FDCT (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the forward DCT (Discrete Cosine Transform). The following code is
@@ -49,7 +45,7 @@ F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_ifast_mmx)
EXTN(jconst_fdct_ifast_mmx):
@@ -59,7 +55,7 @@ PW_F0382 times 4 dw F_0_382 << CONST_SHIFT
PW_F0541 times 4 dw F_0_541 << CONST_SHIFT
PW_F1306 times 4 dw F_1_306 << CONST_SHIFT
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -88,19 +84,19 @@ EXTN(jsimd_fdct_ifast_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -241,7 +237,7 @@ EXTN(jsimd_fdct_ifast_mmx):
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -384,7 +380,7 @@ EXTN(jsimd_fdct_ifast_mmx):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm
index 446fa7a68f7..890482e0067 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jfdctfst-sse2.asm
@@ -2,17 +2,13 @@
; jfdctfst.asm - fast integer FDCT (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the forward DCT (Discrete Cosine Transform). The following code is
@@ -49,7 +45,7 @@ F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_ifast_sse2)
EXTN(jconst_fdct_ifast_sse2):
@@ -59,7 +55,7 @@ PW_F0382 times 8 dw F_0_382 << CONST_SHIFT
PW_F0541 times 8 dw F_0_541 << CONST_SHIFT
PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -89,13 +85,13 @@ EXTN(jsimd_fdct_ifast_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
@@ -392,7 +388,7 @@ EXTN(jsimd_fdct_ifast_sse2):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm
index 23cf733135b..05ea8654850 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-avx2.asm
@@ -2,17 +2,13 @@
; jfdctint.asm - accurate integer FDCT (AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
@@ -65,7 +61,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
@@ -108,7 +104,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%8: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 9
+%macro DODCT 9
vpsubw %5, %1, %4 ; %5=data1_0-data6_7=tmp6_7
vpaddw %6, %1, %4 ; %6=data1_0+data6_7=tmp1_0
vpaddw %7, %2, %3 ; %7=data3_2+data4_5=tmp3_2
@@ -223,7 +219,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_avx2)
EXTN(jconst_fdct_islow_avx2):
@@ -242,7 +238,7 @@ PW_DESCALE_P2X times 16 dw 1 << (PASS1_BITS - 1)
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -262,13 +258,13 @@ PW_1_NEG1 times 8 dw 1
EXTN(jsimd_fdct_islow_avx2):
push ebp
mov ebp, esp
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
@@ -292,9 +288,9 @@ EXTN(jsimd_fdct_islow_avx2):
; ymm2=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
; ymm3=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm3=data7_5
; ---- Pass 2: process columns.
@@ -302,9 +298,9 @@ EXTN(jsimd_fdct_islow_avx2):
vperm2i128 ymm4, ymm1, ymm3, 0x20 ; ymm4=data3_7
vperm2i128 ymm1, ymm1, ymm3, 0x31 ; ymm1=data1_5
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm4=data7_5
vperm2i128 ymm3, ymm0, ymm1, 0x30 ; ymm3=data0_1
@@ -322,7 +318,7 @@ EXTN(jsimd_fdct_islow_avx2):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
pop ebp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm
index 34a43b9e5ef..7d4c61cd7d3 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-mmx.asm
@@ -2,17 +2,13 @@
; jfdctint.asm - accurate integer FDCT (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
@@ -63,7 +59,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_mmx)
EXTN(jconst_fdct_islow_mmx):
@@ -80,7 +76,7 @@ PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2 - 1)
PW_DESCALE_P2X times 4 dw 1 << (PASS1_BITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -109,19 +105,19 @@ EXTN(jsimd_fdct_islow_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -363,7 +359,7 @@ EXTN(jsimd_fdct_islow_mmx):
mov edx, POINTER [data(eax)] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
movq mm0, MMWORD [MMBLOCK(2,0,edx,SIZEOF_DCTELEM)]
@@ -609,7 +605,7 @@ EXTN(jsimd_fdct_islow_mmx):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm
index 6f8e18cb9d0..7ed5c9501ac 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jfdctint-sse2.asm
@@ -2,17 +2,13 @@
; jfdctint.asm - accurate integer FDCT (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
@@ -63,7 +59,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_sse2)
EXTN(jconst_fdct_islow_sse2):
@@ -80,7 +76,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -110,13 +106,13 @@ EXTN(jsimd_fdct_islow_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
; push esi ; unused
; push edi ; unused
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process rows.
@@ -622,7 +618,7 @@ EXTN(jsimd_fdct_islow_sse2):
; pop esi ; unused
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm
index 87951910d8e..8612eee3a5f 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-3dn.asm
@@ -2,17 +2,13 @@
; jidctflt.asm - floating-point IDCT (3DNow! & MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
@@ -24,7 +20,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_3dnow)
EXTN(jconst_idct_float_3dnow):
@@ -36,7 +32,7 @@ PD_2_613 times 2 dd 2.613125929752753055713286
PD_RNDINT_MAGIC times 2 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -78,7 +74,7 @@ EXTN(jsimd_idct_float_3dnow):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -87,21 +83,21 @@ EXTN(jsimd_idct_float_3dnow):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; FAST_FLOAT *wsptr
mov ecx, DCTSIZE/2 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_3DNOW
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
or eax, dword [DWBLOCK(2,0,esi,SIZEOF_JCOEF)]
jnz short .columnDCT
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov ebx, dword [DWBLOCK(3,0,esi,SIZEOF_JCOEF)]
mov eax, dword [DWBLOCK(4,0,esi,SIZEOF_JCOEF)]
or ebx, dword [DWBLOCK(5,0,esi,SIZEOF_JCOEF)]
or eax, dword [DWBLOCK(6,0,esi,SIZEOF_JCOEF)]
or ebx, dword [DWBLOCK(7,0,esi,SIZEOF_JCOEF)]
or eax, ebx
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
jnz short .columnDCT
; -- AC terms all zero
@@ -127,7 +123,7 @@ EXTN(jsimd_idct_float_3dnow):
movq MMWORD [MMBLOCK(1,2,edi,SIZEOF_FAST_FLOAT)], mm1
movq MMWORD [MMBLOCK(1,3,edi,SIZEOF_FAST_FLOAT)], mm1
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -293,7 +289,7 @@ EXTN(jsimd_idct_float_3dnow):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/2 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -420,14 +416,14 @@ EXTN(jsimd_idct_float_3dnow):
punpckldq mm6, mm4 ; mm6=(00 01 02 03 04 05 06 07)
punpckhdq mm7, mm4 ; mm7=(10 11 12 13 14 15 16 17)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm6
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm7
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 2*SIZEOF_FAST_FLOAT ; wsptr
add edi, byte 2*SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm
index b27ecfdf46a..caf636b5106 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse.asm
@@ -2,17 +2,13 @@
; jidctflt.asm - floating-point IDCT (SSE & MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
@@ -23,18 +19,18 @@
; --------------------------------------------------------------------------
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
+%macro UNPCKLPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1, %2, 0x44
%endmacro
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
+%macro UNPCKHPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1, %2, 0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_sse)
EXTN(jconst_idct_float_sse):
@@ -46,7 +42,7 @@ PD_M2_613 times 4 dd -2.613125929752753055713286
PD_0_125 times 4 dd 0.125 ; 1/8
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -88,7 +84,7 @@ EXTN(jsimd_idct_float_sse):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -97,7 +93,7 @@ EXTN(jsimd_idct_float_sse):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; FAST_FLOAT *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -149,7 +145,7 @@ EXTN(jsimd_idct_float_sse):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -325,11 +321,11 @@ EXTN(jsimd_idct_float_sse):
unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
+ UNPCKLPS2 xmm6, xmm7 ; xmm6=(00 10 20 30)
+ UNPCKHPS2 xmm3, xmm7 ; xmm3=(01 11 21 31)
movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
+ UNPCKLPS2 xmm1, xmm2 ; xmm1=(02 12 22 32)
+ UNPCKHPS2 xmm0, xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
@@ -340,11 +336,11 @@ EXTN(jsimd_idct_float_sse):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
+ UNPCKLPS2 xmm5, xmm7 ; xmm5=(40 50 60 70)
+ UNPCKHPS2 xmm6, xmm7 ; xmm6=(41 51 61 71)
movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
+ UNPCKLPS2 xmm4, xmm2 ; xmm4=(42 52 62 72)
+ UNPCKHPS2 xmm3, xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
@@ -372,7 +368,7 @@ EXTN(jsimd_idct_float_sse):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -536,7 +532,7 @@ EXTN(jsimd_idct_float_sse):
punpckldq mm5, mm6 ; mm5=(20 21 22 23 24 25 26 27)
punpckhdq mm4, mm6 ; mm4=(30 31 32 33 34 35 36 37)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
@@ -547,7 +543,7 @@ EXTN(jsimd_idct_float_sse):
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm
index c646eaef76e..42703a8efd7 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctflt-sse2.asm
@@ -2,17 +2,13 @@
; jidctflt.asm - floating-point IDCT (SSE & SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
@@ -23,18 +19,18 @@
; --------------------------------------------------------------------------
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
+%macro UNPCKLPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1, %2, 0x44
%endmacro
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
+%macro UNPCKHPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1, %2, 0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_sse2)
EXTN(jconst_idct_float_sse2):
@@ -46,7 +42,7 @@ PD_M2_613 times 4 dd -2.613125929752753055713286
PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -88,7 +84,7 @@ EXTN(jsimd_idct_float_sse2):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -97,7 +93,7 @@ EXTN(jsimd_idct_float_sse2):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; FAST_FLOAT *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_FLOAT_SSE
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -150,7 +146,7 @@ EXTN(jsimd_idct_float_sse2):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm3
movaps XMMWORD [XMMBLOCK(3,1,edi,SIZEOF_FAST_FLOAT)], xmm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -287,11 +283,11 @@ EXTN(jsimd_idct_float_sse2):
unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
+ UNPCKLPS2 xmm6, xmm7 ; xmm6=(00 10 20 30)
+ UNPCKHPS2 xmm3, xmm7 ; xmm3=(01 11 21 31)
movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
+ UNPCKLPS2 xmm1, xmm2 ; xmm1=(02 12 22 32)
+ UNPCKHPS2 xmm0, xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
@@ -302,11 +298,11 @@ EXTN(jsimd_idct_float_sse2):
movaps XMMWORD [XMMBLOCK(3,0,edi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
+ UNPCKLPS2 xmm5, xmm7 ; xmm5=(40 50 60 70)
+ UNPCKHPS2 xmm6, xmm7 ; xmm6=(41 51 61 71)
movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
+ UNPCKLPS2 xmm4, xmm2 ; xmm4=(42 52 62 72)
+ UNPCKHPS2 xmm3, xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,edi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,edi,SIZEOF_FAST_FLOAT)], xmm6
@@ -334,7 +330,7 @@ EXTN(jsimd_idct_float_sse2):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -464,7 +460,7 @@ EXTN(jsimd_idct_float_sse2):
pshufd xmm5, xmm6, 0x4E ; xmm5=(10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07)
pshufd xmm3, xmm7, 0x4E ; xmm3=(30 31 32 33 34 35 36 37 20 21 22 23 24 25 26 27)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+2*SIZEOF_JSAMPROW]
@@ -475,7 +471,7 @@ EXTN(jsimd_idct_float_sse2):
movq XMM_MMWORD [edx+eax*SIZEOF_JSAMPLE], xmm5
movq XMM_MMWORD [ebx+eax*SIZEOF_JSAMPLE], xmm3
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_FAST_FLOAT ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm
index 24622d43693..77d4613d23b 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-mmx.asm
@@ -2,17 +2,13 @@
; jidctfst.asm - fast integer IDCT (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the inverse DCT (Discrete Cosine Transform). The following code is
@@ -56,7 +52,7 @@ F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_ifast_mmx)
EXTN(jconst_idct_ifast_mmx):
@@ -67,7 +63,7 @@ PW_MF1613 times 4 dw -F_1_613 << CONST_SHIFT
PW_F1082 times 4 dw F_1_082 << CONST_SHIFT
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -109,7 +105,7 @@ EXTN(jsimd_idct_ifast_mmx):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -118,7 +114,7 @@ EXTN(jsimd_idct_ifast_mmx):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; JCOEF *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_IFAST_MMX
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -163,7 +159,7 @@ EXTN(jsimd_idct_ifast_mmx):
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -326,7 +322,7 @@ EXTN(jsimd_idct_ifast_mmx):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -464,7 +460,7 @@ EXTN(jsimd_idct_ifast_mmx):
punpckldq mm5, mm4 ; mm5=(20 21 22 23 24 25 26 27)
punpckhdq mm1, mm4 ; mm1=(30 31 32 33 34 35 36 37)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
@@ -475,7 +471,7 @@ EXTN(jsimd_idct_ifast_mmx):
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm5
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm1
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_JCOEF ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm
index 19704ffa48f..c2fe34ba8c6 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctfst-sse2.asm
@@ -2,17 +2,13 @@
; jidctfst.asm - fast integer IDCT (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the inverse DCT (Discrete Cosine Transform). The following code is
@@ -56,7 +52,7 @@ F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_ifast_sse2)
EXTN(jconst_idct_ifast_sse2):
@@ -67,7 +63,7 @@ PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -101,13 +97,13 @@ EXTN(jsimd_idct_ifast_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
@@ -155,7 +151,7 @@ EXTN(jsimd_idct_ifast_sse2):
movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=col1
movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=col3
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -490,7 +486,7 @@ EXTN(jsimd_idct_ifast_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm
index 199c7df3b69..cb119d3f06d 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-avx2.asm
@@ -2,17 +2,13 @@
; jidctint.asm - accurate integer IDCT (AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
@@ -65,7 +61,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %5=(00 10 20 30 40 50 60 70 01 11 21 31 41 51 61 71)
; %6=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
; %7=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
@@ -118,7 +114,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%12: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 13
+%macro DODCT 13
; -- Even part
; (Original)
@@ -250,7 +246,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_avx2)
EXTN(jconst_idct_islow_avx2):
@@ -269,7 +265,7 @@ PB_CENTERJSAMP times 32 db CENTERJSAMPLE
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -303,13 +299,13 @@ EXTN(jsimd_idct_islow_avx2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns.
@@ -353,7 +349,7 @@ EXTN(jsimd_idct_islow_avx2):
vpshufd ymm3, ymm4, 0xFF ; ymm3=col3_7=(03 03 03 03 03 03 03 03 07 07 07 07 07 07 07 07)
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -371,10 +367,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm2, ymm5, ymm7, 0x20 ; ymm2=in2_6
vperm2i128 ymm3, ymm7, ymm6, 0x31 ; ymm3=in7_5
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 1
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm3=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm3=data3_7
.column_end:
@@ -395,10 +391,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm4, ymm3, ymm1, 0x31 ; ymm3=in7_5
vperm2i128 ymm1, ymm3, ymm1, 0x20 ; ymm1=in3_1
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, XMMWORD [wk(0)], XMMWORD [wk(1)], XMMWORD [wk(2)], XMMWORD [wk(3)], 2
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm4=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm4=data3_7
vpacksswb ymm0, ymm0, ymm1 ; ymm0=data01_45
@@ -442,7 +438,7 @@ EXTN(jsimd_idct_islow_avx2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm
index f15c8d34bcb..c2c17f441b8 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-mmx.asm
@@ -2,17 +2,13 @@
; jidctint.asm - accurate integer IDCT (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
@@ -63,7 +59,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_mmx)
EXTN(jconst_idct_islow_mmx):
@@ -80,7 +76,7 @@ PD_DESCALE_P1 times 2 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 2 dd 1 << (DESCALE_P2 - 1)
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -122,7 +118,7 @@ EXTN(jsimd_idct_islow_mmx):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -131,7 +127,7 @@ EXTN(jsimd_idct_islow_mmx):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; JCOEF *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_ISLOW_MMX
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -178,7 +174,7 @@ EXTN(jsimd_idct_islow_mmx):
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
movq MMWORD [MMBLOCK(3,1,edi,SIZEOF_JCOEF)], mm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -513,7 +509,7 @@ EXTN(jsimd_idct_islow_mmx):
mov edi, JSAMPARRAY [output_buf(eax)] ; (JSAMPROW *)
mov eax, JDIMENSION [output_col(eax)]
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.rowloop:
; -- Even part
@@ -816,7 +812,7 @@ EXTN(jsimd_idct_islow_mmx):
punpckldq mm7, mm5 ; mm7=(20 21 22 23 24 25 26 27)
punpckhdq mm4, mm5 ; mm4=(30 31 32 33 34 35 36 37)
- pushpic ebx ; save GOT address
+ PUSHPIC ebx ; save GOT address
mov edx, JSAMPROW [edi+0*SIZEOF_JSAMPROW]
mov ebx, JSAMPROW [edi+1*SIZEOF_JSAMPROW]
@@ -827,7 +823,7 @@ EXTN(jsimd_idct_islow_mmx):
movq MMWORD [edx+eax*SIZEOF_JSAMPLE], mm7
movq MMWORD [ebx+eax*SIZEOF_JSAMPLE], mm4
- poppic ebx ; restore GOT address
+ POPPIC ebx ; restore GOT address
add esi, byte 4*SIZEOF_JCOEF ; wsptr
add edi, byte 4*SIZEOF_JSAMPROW
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm
index 43e320189b4..70516cadcef 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctint-sse2.asm
@@ -2,17 +2,13 @@
; jidctint.asm - accurate integer IDCT (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2016, 2020, D. R. Commander.
+; Copyright (C) 2016, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
@@ -63,7 +59,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_sse2)
EXTN(jconst_idct_islow_sse2):
@@ -80,7 +76,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -114,13 +110,13 @@ EXTN(jsimd_idct_islow_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
@@ -172,7 +168,7 @@ EXTN(jsimd_idct_islow_sse2):
movdqa XMMWORD [wk(10)], xmm3 ; wk(10)=col5
movdqa XMMWORD [wk(11)], xmm4 ; wk(11)=col7
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -847,7 +843,7 @@ EXTN(jsimd_idct_islow_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm
index e2307e1cb6c..96cda657133 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctred-mmx.asm
@@ -2,17 +2,13 @@
; jidctred.asm - reduced-size IDCT (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains inverse-DCT routines that produce reduced-size
; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
@@ -69,7 +65,7 @@ F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_red_mmx)
EXTN(jconst_idct_red_mmx):
@@ -87,7 +83,7 @@ PD_DESCALE_P1_2 times 2 dd 1 << (DESCALE_P1_2 - 1)
PD_DESCALE_P2_2 times 2 dd 1 << (DESCALE_P2_2 - 1)
PB_CENTERJSAMP times 8 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -124,13 +120,13 @@ EXTN(jsimd_idct_4x4_mmx):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [workspace]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; need not be preserved
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input, store into work array.
@@ -139,7 +135,7 @@ EXTN(jsimd_idct_4x4_mmx):
mov esi, JCOEFPTR [coef_block(eax)] ; inptr
lea edi, [workspace] ; JCOEF *wsptr
mov ecx, DCTSIZE/4 ; ctr
- alignx 16, 7
+ ALIGNX 16, 7
.columnloop:
%ifndef NO_ZERO_COLUMN_TEST_4X4_MMX
mov eax, dword [DWBLOCK(1,0,esi,SIZEOF_JCOEF)]
@@ -181,7 +177,7 @@ EXTN(jsimd_idct_4x4_mmx):
movq MMWORD [MMBLOCK(2,0,edi,SIZEOF_JCOEF)], mm2
movq MMWORD [MMBLOCK(3,0,edi,SIZEOF_JCOEF)], mm3
jmp near .nextcolumn
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -479,7 +475,7 @@ EXTN(jsimd_idct_4x4_mmx):
pop esi
; pop edx ; need not be preserved
; pop ecx ; need not be preserved
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
@@ -512,7 +508,7 @@ EXTN(jsimd_idct_2x2_mmx):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm
index 6e56494e975..1fe967db199 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jidctred-sse2.asm
@@ -2,17 +2,13 @@
; jidctred.asm - reduced-size IDCT (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains inverse-DCT routines that produce reduced-size
; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
@@ -69,7 +65,7 @@ F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_red_sse2)
EXTN(jconst_idct_red_sse2):
@@ -87,7 +83,7 @@ PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2 - 1)
PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -122,13 +118,13 @@ EXTN(jsimd_idct_4x4_sse2):
mov [esp], eax
mov ebp, esp ; ebp = aligned ebp
lea esp, [wk(0)]
- pushpic ebx
+ PUSHPIC ebx
; push ecx ; unused
; push edx ; need not be preserved
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
@@ -171,7 +167,7 @@ EXTN(jsimd_idct_4x4_sse2):
pshufd xmm3, xmm3, 0xFA ; xmm3=[col6 col7]=(06 06 06 06 07 07 07 07)
jmp near .column_end
- alignx 16, 7
+ ALIGNX 16, 7
%endif
.columnDCT:
@@ -400,7 +396,7 @@ EXTN(jsimd_idct_4x4_sse2):
pop esi
; pop edx ; need not be preserved
; pop ecx ; unused
- poppic ebx
+ POPPIC ebx
mov esp, ebp ; esp <- aligned ebp
pop esp ; esp <- original ebp
pop ebp
@@ -433,7 +429,7 @@ EXTN(jsimd_idct_2x2_sse2):
push esi
push edi
- get_GOT ebx ; get GOT address
+ GET_GOT ebx ; get GOT address
; ---- Pass 1: process columns from input.
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm
index 5cb60caa947..58e0011f70e 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jquant-3dn.asm
@@ -2,17 +2,13 @@
; jquant.asm - sample data conversion and quantization (3DNow! & MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -52,7 +48,7 @@ EXTN(jsimd_convsamp_float_3dnow):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -154,7 +150,7 @@ EXTN(jsimd_quantize_float_3dnow):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/16
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movq mm0, MMWORD [MMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
movq mm1, MMWORD [MMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm
index 61305c625de..4eda95ce12f 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jquant-mmx.asm
@@ -2,17 +2,13 @@
; jquant.asm - sample data conversion and quantization (MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -52,7 +48,7 @@ EXTN(jsimd_convsamp_mmx):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -120,8 +116,8 @@ EXTN(jsimd_convsamp_mmx):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_mmx(JCOEFPTR coef_block, DCTELEM *divisors,
@@ -157,10 +153,10 @@ EXTN(jsimd_quantize_mmx):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov ah, 2
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop1:
mov al, DCTSIZE2/8/2
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop2:
movq mm2, MMWORD [MMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
movq mm3, MMWORD [MMBLOCK(0,1,esi,SIZEOF_DCTELEM)]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm
index 218adc976f3..6cb5f79c215 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jquant-sse.asm
@@ -2,17 +2,13 @@
; jquant.asm - sample data conversion and quantization (SSE & MMX)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -52,7 +48,7 @@ EXTN(jsimd_convsamp_float_sse):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -150,7 +146,7 @@ EXTN(jsimd_quantize_float_sse):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/16
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm
index a881ab50f92..5668f8cb396 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jquantf-sse2.asm
@@ -2,17 +2,13 @@
; jquantf.asm - sample data conversion and quantization (SSE & SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -52,7 +48,7 @@ EXTN(jsimd_convsamp_float_sse2):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/2
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -127,7 +123,7 @@ EXTN(jsimd_quantize_float_sse2):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/16
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movaps xmm0, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_FAST_FLOAT)]
movaps xmm1, XMMWORD [XMMBLOCK(0,1,esi,SIZEOF_FAST_FLOAT)]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm
index 5ed6bec246c..60ae098e9c4 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jquanti-avx2.asm
@@ -2,18 +2,14 @@
; jquanti.asm - sample data conversion and quantization (AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2016, 2018, D. R. Commander.
+; Copyright (C) 2016, 2018, 2024, D. R. Commander.
; Copyright (C) 2016, Matthieu Darbois.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -107,8 +103,8 @@ EXTN(jsimd_convsamp_avx2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_avx2(JCOEFPTR coef_block, DCTELEM *divisors,
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm b/contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm
index 0a509408aa1..c1edde996e9 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jquanti-sse2.asm
@@ -2,17 +2,13 @@
; jquanti.asm - sample data conversion and quantization (SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -52,7 +48,7 @@ EXTN(jsimd_convsamp_sse2):
mov eax, JDIMENSION [start_col]
mov edi, POINTER [workspace] ; (DCTELEM *)
mov ecx, DCTSIZE/4
- alignx 16, 7
+ ALIGNX 16, 7
.convloop:
mov ebx, JSAMPROW [esi+0*SIZEOF_JSAMPROW] ; (JSAMPLE *)
mov edx, JSAMPROW [esi+1*SIZEOF_JSAMPROW] ; (JSAMPLE *)
@@ -98,8 +94,8 @@ EXTN(jsimd_convsamp_sse2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_sse2(JCOEFPTR coef_block, DCTELEM *divisors,
@@ -133,7 +129,7 @@ EXTN(jsimd_quantize_sse2):
mov edx, POINTER [divisors]
mov edi, JCOEFPTR [coef_block]
mov eax, DCTSIZE2/32
- alignx 16, 7
+ ALIGNX 16, 7
.quantloop:
movdqa xmm4, XMMWORD [XMMBLOCK(0,0,esi,SIZEOF_DCTELEM)]
movdqa xmm5, XMMWORD [XMMBLOCK(1,0,esi,SIZEOF_DCTELEM)]
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jsimd.c b/contrib/libs/libjpeg-turbo/simd/i386/jsimd.c
index 80bc821ff4e..d4786b155b7 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jsimd.c
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jsimd.c
@@ -2,8 +2,8 @@
* jsimd_i386.c
*
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2022-2024, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
*
* Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -15,13 +15,12 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
-#include "jconfigint.h"
/*
* In the PIC cases, we have no guarantee that constants will keep
@@ -32,13 +31,11 @@
#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
#define IS_ALIGNED_AVX(ptr) (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
-static unsigned int simd_support = (unsigned int)(~0);
-static unsigned int simd_huffman = 1;
+static THREAD_LOCAL unsigned int simd_support = (unsigned int)(~0);
+static THREAD_LOCAL unsigned int simd_huffman = 1;
/*
* Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
*/
LOCAL(void)
init_simd(void)
@@ -161,6 +158,9 @@ jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
void (*mmxfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->in_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_extrgb_ycc_convert_avx2;
@@ -220,6 +220,9 @@ jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
void (*mmxfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->in_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_extrgb_gray_convert_avx2;
@@ -279,6 +282,9 @@ jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
void (*mmxfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_ycc_extrgb_convert_avx2;
@@ -382,6 +388,9 @@ GLOBAL(void)
jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v2_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
compptr->v_samp_factor,
@@ -402,6 +411,9 @@ GLOBAL(void)
jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v1_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
compptr->v_samp_factor,
@@ -464,6 +476,9 @@ GLOBAL(void)
jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v2_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
input_data, output_data_ptr);
@@ -479,6 +494,9 @@ GLOBAL(void)
jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v1_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
input_data, output_data_ptr);
@@ -540,6 +558,9 @@ GLOBAL(void)
jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v2_fancy_upsample_avx2(cinfo->max_v_samp_factor,
compptr->downsampled_width, input_data,
@@ -558,6 +579,9 @@ GLOBAL(void)
jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v1_fancy_upsample_avx2(cinfo->max_v_samp_factor,
compptr->downsampled_width, input_data,
@@ -626,6 +650,9 @@ jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
void (*mmxfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_h2v2_extrgb_merged_upsample_avx2;
@@ -684,6 +711,9 @@ jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
void (*mmxfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_h2v1_extrgb_merged_upsample_avx2;
@@ -788,6 +818,9 @@ GLOBAL(void)
jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
DCTELEM *workspace)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_convsamp_avx2(sample_data, start_col, workspace);
else if (simd_support & JSIMD_SSE2)
@@ -800,6 +833,9 @@ GLOBAL(void)
jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
FAST_FLOAT *workspace)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_SSE2)
jsimd_convsamp_float_sse2(sample_data, start_col, workspace);
else if (simd_support & JSIMD_SSE)
@@ -870,6 +906,9 @@ jsimd_can_fdct_float(void)
GLOBAL(void)
jsimd_fdct_islow(DCTELEM *data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_fdct_islow_avx2(data);
else if (simd_support & JSIMD_SSE2)
@@ -881,6 +920,9 @@ jsimd_fdct_islow(DCTELEM *data)
GLOBAL(void)
jsimd_fdct_ifast(DCTELEM *data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
jsimd_fdct_ifast_sse2(data);
else
@@ -890,6 +932,9 @@ jsimd_fdct_ifast(DCTELEM *data)
GLOBAL(void)
jsimd_fdct_float(FAST_FLOAT *data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
jsimd_fdct_float_sse(data);
else if (simd_support & JSIMD_3DNOW)
@@ -945,6 +990,9 @@ jsimd_can_quantize_float(void)
GLOBAL(void)
jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_quantize_avx2(coef_block, divisors, workspace);
else if (simd_support & JSIMD_SSE2)
@@ -957,6 +1005,9 @@ GLOBAL(void)
jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
FAST_FLOAT *workspace)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_SSE2)
jsimd_quantize_float_sse2(coef_block, divisors, workspace);
else if (simd_support & JSIMD_SSE)
@@ -1020,6 +1071,9 @@ jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf,
output_col);
@@ -1032,6 +1086,9 @@ jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf,
output_col);
@@ -1126,6 +1183,9 @@ jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_idct_islow_avx2(compptr->dct_table, coef_block, output_buf,
output_col);
@@ -1142,6 +1202,9 @@ jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf,
output_col);
@@ -1155,6 +1218,9 @@ jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2))
jsimd_idct_float_sse2(compptr->dct_table, coef_block, output_buf,
output_col);
@@ -1212,7 +1278,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
GLOBAL(void)
jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
+ int Al, UJCOEF *values, size_t *zerobits)
{
jsimd_encode_mcu_AC_first_prepare_sse2(block, jpeg_natural_order_start,
Sl, Al, values, zerobits);
@@ -1238,7 +1304,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
GLOBAL(int)
jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
+ int Al, UJCOEF *absvalues, size_t *bits)
{
return jsimd_encode_mcu_AC_refine_prepare_sse2(block,
jpeg_natural_order_start,
diff --git a/contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm b/contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm
index ddcafa9e213..df80f17f5fa 100644
--- a/contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm
+++ b/contrib/libs/libjpeg-turbo/simd/i386/jsimdcpu.asm
@@ -8,11 +8,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
diff --git a/contrib/libs/libjpeg-turbo/simd/jsimd.h b/contrib/libs/libjpeg-turbo/simd/jsimd.h
index 64747c6360c..a28754adb9d 100644
--- a/contrib/libs/libjpeg-turbo/simd/jsimd.h
+++ b/contrib/libs/libjpeg-turbo/simd/jsimd.h
@@ -2,10 +2,10 @@
* simd/jsimd.h
*
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014-2016, 2018, 2020, D. R. Commander.
+ * Copyright (C) 2011, 2014-2016, 2018, 2020, 2022, D. R. Commander.
* Copyright (C) 2013-2014, MIPS Technologies, Inc., California.
* Copyright (C) 2014, Linaro Limited.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
* Copyright (C) 2020, Arm Limited.
*
@@ -1243,16 +1243,16 @@ EXTERN(JOCTET *) jsimd_huff_encode_one_block_neon_slowtbl
/* Progressive Huffman encoding */
EXTERN(void) jsimd_encode_mcu_AC_first_prepare_sse2
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
+ UJCOEF *values, size_t *zerobits);
EXTERN(void) jsimd_encode_mcu_AC_first_prepare_neon
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
+ UJCOEF *values, size_t *zerobits);
EXTERN(int) jsimd_encode_mcu_AC_refine_prepare_sse2
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
+ UJCOEF *absvalues, size_t *bits);
EXTERN(int) jsimd_encode_mcu_AC_refine_prepare_neon
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
+ UJCOEF *absvalues, size_t *bits);
diff --git a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h b/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h
index bf2a45ad50c..ed3f9c2a693 100644
--- a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h
+++ b/contrib/libs/libjpeg-turbo/simd/nasm/jsimdcfg.inc.h
@@ -12,9 +12,9 @@
#define JPEG_INTERNALS
-#include "../jpeglib.h"
+#include "../src/jpeglib.h"
#include "../jconfig.h"
-#include "../jmorecfg.h"
+#include "../src/jmorecfg.h"
#include "jsimd.h"
;
diff --git a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc b/contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc
index d8a50ed8e23..674dfb6464c 100644
--- a/contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc
+++ b/contrib/libs/libjpeg-turbo/simd/nasm/jsimdext.inc
@@ -2,9 +2,10 @@
; jsimdext.inc - common declarations
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2010, 2016, 2018-2019, D. R. Commander.
+; Copyright (C) 2010, 2016, 2018-2019, 2024, D. R. Commander.
; Copyright (C) 2018, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library - version 1.02
;
@@ -75,6 +76,14 @@
; mark stack as non-executable
section .note.GNU-stack noalloc noexec nowrite progbits
+%ifdef __CET__
+%ifdef __x86_64__
+section .note.gnu.property note alloc noexec align=8
+ dd 0x00000004, 0x00000010, 0x00000005, 0x00554e47
+ dd 0xc0000002, 0x00000004, 0x00000003, 0x00000000
+%endif
+%endif
+
; -- segment definition --
;
%ifdef _x86_64_
@@ -271,7 +280,7 @@ const_base:
%define GOTOFF(got, sym) (got) + (sym) - const_base
-%imacro get_GOT 1
+%imacro GET_GOT 1
; NOTE: this macro destroys ecx resister.
call %%geteip
add ecx, byte (%%ref - $)
@@ -303,7 +312,7 @@ const_base:
%define GOTOFF(got, sym) (got) + (sym) wrt ..gotoff
-%imacro get_GOT 1
+%imacro GET_GOT 1
extern GOT_SYMBOL
call %%geteip
add %1, GOT_SYMBOL + $$ - $ wrt ..gotpc
@@ -316,13 +325,13 @@ const_base:
%endif ; GOT_SYMBOL == _MACHO_PIC_ ----------------
-%imacro pushpic 1.nolist
+%imacro PUSHPIC 1.nolist
push %1
%endmacro
-%imacro poppic 1.nolist
+%imacro POPPIC 1.nolist
pop %1
%endmacro
-%imacro movpic 2.nolist
+%imacro MOVPIC 2.nolist
mov %1, %2
%endmacro
@@ -330,13 +339,13 @@ const_base:
%define GOTOFF(got, sym) (sym)
-%imacro get_GOT 1.nolist
+%imacro GET_GOT 1.nolist
%endmacro
-%imacro pushpic 1.nolist
+%imacro PUSHPIC 1.nolist
%endmacro
-%imacro poppic 1.nolist
+%imacro POPPIC 1.nolist
%endmacro
-%imacro movpic 2.nolist
+%imacro MOVPIC 2.nolist
%endmacro
%endif ; PIC -----------------------------------------
@@ -348,7 +357,7 @@ const_base:
%define MSKLE(x, y) (~(((y) & 0xFFFF) - ((x) & 0xFFFF)) >> 16)
%define FILLB(b, n) (($$-(b)) & ((n)-1))
-%imacro alignx 1-2.nolist 0xFFFF
+%imacro ALIGNX 1-2.nolist 0xFFFF
%%bs: \
times MSKLE(FILLB(%%bs, %1), %2) & MSKLE(16, FILLB($, %1)) & FILLB($, %1) \
db 0x90 ; nop
@@ -370,7 +379,7 @@ const_base:
; Align the next data on {2,4,8,16,..}-byte boundary.
;
-%imacro alignz 1.nolist
+%imacro ALIGNZ 1.nolist
align %1, db 0 ; filling zeros
%endmacro
@@ -378,7 +387,7 @@ const_base:
%ifdef WIN64
-%imacro collect_args 1
+%imacro COLLECT_ARGS 1
sub rsp, SIZEOF_XMMWORD
movaps XMMWORD [rsp], xmm6
sub rsp, SIZEOF_XMMWORD
@@ -397,17 +406,17 @@ const_base:
%endif
%if %1 > 4
push r14
- mov r14, [rax+48]
+ mov r14, [rbp+48]
%endif
%if %1 > 5
push r15
- mov r15, [rax+56]
+ mov r15, [rbp+56]
%endif
push rsi
push rdi
%endmacro
-%imacro uncollect_args 1
+%imacro UNCOLLECT_ARGS 1
pop rdi
pop rsi
%if %1 > 5
@@ -428,7 +437,7 @@ const_base:
add rsp, SIZEOF_XMMWORD
%endmacro
-%imacro push_xmm 1
+%imacro PUSH_XMM 1
sub rsp, %1 * SIZEOF_XMMWORD
movaps XMMWORD [rsp+0*SIZEOF_XMMWORD], xmm8
%if %1 > 1
@@ -442,7 +451,7 @@ const_base:
%endif
%endmacro
-%imacro pop_xmm 1
+%imacro POP_XMM 1
movaps xmm8, XMMWORD [rsp+0*SIZEOF_XMMWORD]
%if %1 > 1
movaps xmm9, XMMWORD [rsp+1*SIZEOF_XMMWORD]
@@ -458,7 +467,7 @@ const_base:
%else
-%imacro collect_args 1
+%imacro COLLECT_ARGS 1
push r10
mov r10, rdi
%if %1 > 1
@@ -483,7 +492,7 @@ const_base:
%endif
%endmacro
-%imacro uncollect_args 1
+%imacro UNCOLLECT_ARGS 1
%if %1 > 5
pop r15
%endif
@@ -502,16 +511,29 @@ const_base:
pop r10
%endmacro
-%imacro push_xmm 1
+%imacro PUSH_XMM 1
%endmacro
-%imacro pop_xmm 1
+%imacro POP_XMM 1
%endmacro
%endif
%endif
+%ifdef __CET__
+
+%imacro ENDBR64 0
+ dd 0xfa1e0ff3
+%endmacro
+
+%else
+
+%imacro ENDBR64 0
+%endmacro
+
+%endif
+
; --------------------------------------------------------------------------
; Defines picked up from the C headers
;
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm
index ffb527db00e..aeeda0a682f 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-avx2.asm
@@ -1,19 +1,16 @@
;
; jccolext.asm - colorspace conversion (64-bit AVX2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -33,21 +30,22 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 8
align 32
GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_avx2)
EXTN(jsimd_rgb_ycc_convert_avx2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_YMMWORD * WK_NUM)
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -548,9 +546,9 @@ EXTN(jsimd_rgb_ycc_convert_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 5
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm
index af70ed6010f..f3a1244903b 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolext-sse2.asm
@@ -1,18 +1,15 @@
;
; jccolext.asm - colorspace conversion (64-bit SSE2)
;
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -32,21 +29,22 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 8
align 32
GLOBAL_FUNCTION(jsimd_rgb_ycc_convert_sse2)
EXTN(jsimd_rgb_ycc_convert_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -473,9 +471,9 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
.return:
pop rbx
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 5
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm
index 16b78298dc4..e2628917336 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-avx2.asm
@@ -1,18 +1,14 @@
;
; jccolor.asm - colorspace conversion (64-bit 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
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -33,7 +29,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):
@@ -46,7 +42,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
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm
index e2955c21340..cc9edb4cebc 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jccolor-sse2.asm
@@ -1,17 +1,13 @@
;
; jccolor.asm - colorspace conversion (64-bit 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -32,7 +28,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):
@@ -45,7 +41,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
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm
index 591255bb112..267ec5142a4 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-avx2.asm
@@ -1,18 +1,14 @@
;
; jcgray.asm - grayscale colorspace conversion (64-bit AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -29,7 +25,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_gray_convert_avx2)
EXTN(jconst_rgb_gray_convert_avx2):
@@ -38,7 +34,7 @@ PW_F0299_F0337 times 8 dw F_0_299, F_0_337
PW_F0114_F0250 times 8 dw F_0_114, F_0_250
PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm
index e389904f2f8..4b94d7b8a28 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgray-sse2.asm
@@ -1,17 +1,13 @@
;
; jcgray.asm - grayscale colorspace conversion (64-bit SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -28,7 +24,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_gray_convert_sse2)
EXTN(jconst_rgb_gray_convert_sse2):
@@ -37,7 +33,7 @@ PW_F0299_F0337 times 4 dw F_0_299, F_0_337
PW_F0114_F0250 times 4 dw F_0_114, F_0_250
PD_ONEHALF times 4 dd (1 << (SCALEBITS - 1))
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm
index ddcc2c0a2fe..77e85f768f9 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-avx2.asm
@@ -1,19 +1,16 @@
;
; jcgryext.asm - grayscale colorspace conversion (64-bit AVX2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -33,21 +30,22 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 2
align 32
GLOBAL_FUNCTION(jsimd_rgb_gray_convert_avx2)
EXTN(jsimd_rgb_gray_convert_avx2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_YMMWORD * WK_NUM)
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -427,9 +425,9 @@ EXTN(jsimd_rgb_gray_convert_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 5
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm
index f1d399a63b8..3e8087c39bc 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jcgryext-sse2.asm
@@ -1,18 +1,15 @@
;
; jcgryext.asm - grayscale colorspace conversion (64-bit SSE2)
;
-; Copyright (C) 2011, 2016, D. R. Commander.
+; Copyright (C) 2011, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -32,21 +29,22 @@
; r13d = JDIMENSION output_row
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
GLOBAL_FUNCTION(jsimd_rgb_gray_convert_sse2)
EXTN(jsimd_rgb_gray_convert_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d
@@ -352,9 +350,9 @@ EXTN(jsimd_rgb_gray_convert_sse2):
.return:
pop rbx
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 5
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm
index 9ea6df946ef..b18b7f5d651 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jchuff-sse2.asm
@@ -1,19 +1,16 @@
;
; jchuff-sse2.asm - Huffman entropy encoding (64-bit SSE2)
;
-; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, D. R. Commander.
+; Copyright (C) 2009-2011, 2014-2016, 2019, 2021, 2023-2024, D. R. Commander.
; Copyright (C) 2015, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation for Huffman coding of one block.
; The following code is based on jchuff.c; see jchuff.c for more details.
@@ -38,7 +35,7 @@ endstruc
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_huff_encode_one_block)
EXTN(jconst_huff_encode_one_block):
@@ -48,7 +45,7 @@ jpeg_mask_bits dd 0x0000, 0x0001, 0x0003, 0x0007
dd 0x00ff, 0x01ff, 0x03ff, 0x07ff
dd 0x0fff, 0x1fff, 0x3fff, 0x7fff
- alignz 32
+ ALIGNZ 32
times 1 << 14 db 15
times 1 << 13 db 14
@@ -66,7 +63,8 @@ times 1 << 2 db 3
times 1 << 1 db 2
times 1 << 0 db 1
times 1 db 0
-jpeg_nbits_table:
+GLOBAL_DATA(jpeg_nbits_table)
+EXTN(jpeg_nbits_table):
times 1 db 0
times 1 << 0 db 1
times 1 << 1 db 2
@@ -85,10 +83,10 @@ times 1 << 13 db 14
times 1 << 14 db 15
times 1 << 15 db 16
- alignz 32
+ ALIGNZ 32
%define NBITS(x) nbits_base + x
-%define MASK_BITS(x) NBITS((x) * 4) + (jpeg_mask_bits - jpeg_nbits_table)
+%define MASK_BITS(x) NBITS((x) * 4) + (jpeg_mask_bits - EXTN(jpeg_nbits_table))
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -208,15 +206,15 @@ times 1 << 15 db 16
; rax - buffer
; rbx - temp
; rcx - nbits
-; rdx - block --> free_bits
+; rdx - code
; rsi - nbits_base
; rdi - t
-; rbp - code
; r8 - dctbl --> code_temp
; r9 - actbl
; r10 - state
; r11 - index
; r12 - put_buffer
+; r15 - block --> free_bits
%define buffer rax
%ifdef WIN64
@@ -231,12 +229,11 @@ times 1 << 15 db 16
%define nbitsq rcx
%define nbits ecx
%define nbitsb cl
-%define block rdx
+%define codeq rdx
+%define code edx
%define nbits_base rsi
%define t rdi
%define td edi
-%define codeq rbp
-%define code ebp
%define dctbl r8
%define actbl r9
%define state r10
@@ -244,6 +241,7 @@ times 1 << 15 db 16
%define indexd r11d
%define put_buffer r12
%define put_bufferd r12d
+%define block r15
; Step 1: Re-arrange input data according to jpeg_natural_order
; xx 01 02 03 04 05 06 07 xx 01 08 16 09 02 03 10
@@ -259,6 +257,9 @@ times 1 << 15 db 16
GLOBAL_FUNCTION(jsimd_huff_encode_one_block_sse2)
EXTN(jsimd_huff_encode_one_block_sse2):
+ ENDBR64
+ push rbp
+ mov rbp, rsp
%ifdef WIN64
@@ -266,15 +267,15 @@ EXTN(jsimd_huff_encode_one_block_sse2):
; rdx = JOCTET *buffer
; r8 = JCOEFPTR block
; r9 = int last_dc_val
-; [rax+48] = c_derived_tbl *dctbl
-; [rax+56] = c_derived_tbl *actbl
+; [rbp+48] = c_derived_tbl *dctbl
+; [rbp+56] = c_derived_tbl *actbl
;X: X = code stream
mov buffer, rdx
+ push r15
mov block, r8
movups xmm3, XMMWORD [block + 0 * SIZEOF_WORD] ;D: w3 = xx 01 02 03 04 05 06 07
push rbx
- push rbp
movdqa xmm0, xmm3 ;A: w0 = xx 01 02 03 04 05 06 07
push rsi
push rdi
@@ -284,12 +285,10 @@ EXTN(jsimd_huff_encode_one_block_sse2):
movsx code, word [block] ;Z: code = block[0];
pxor xmm4, xmm4 ;A: w4[i] = 0;
sub code, r9d ;Z: code -= last_dc_val;
- mov dctbl, POINTER [rsp+6*8+4*8]
- mov actbl, POINTER [rsp+6*8+5*8]
+ mov dctbl, POINTER [rbp+48]
+ mov actbl, POINTER [rbp+56]
punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
- lea nbits_base, [rel jpeg_nbits_table]
- add rsp, -DCTSIZE2 * SIZEOF_WORD
- mov t, rsp
+ lea nbits_base, [rel EXTN(jpeg_nbits_table)]
%else
@@ -301,23 +300,27 @@ EXTN(jsimd_huff_encode_one_block_sse2):
; r9 = c_derived_tbl *actbl
;X: X = code stream
+ push r15
+ mov block, rdx
movups xmm3, XMMWORD [block + 0 * SIZEOF_WORD] ;D: w3 = xx 01 02 03 04 05 06 07
push rbx
- push rbp
movdqa xmm0, xmm3 ;A: w0 = xx 01 02 03 04 05 06 07
push r12
mov state, rdi
mov buffer, rsi
movups xmm1, XMMWORD [block + 8 * SIZEOF_WORD] ;B: w1 = 08 09 10 11 12 13 14 15
movsx codeq, word [block] ;Z: code = block[0];
- lea nbits_base, [rel jpeg_nbits_table]
+ lea nbits_base, [rel EXTN(jpeg_nbits_table)]
pxor xmm4, xmm4 ;A: w4[i] = 0;
sub codeq, rcx ;Z: code -= last_dc_val;
punpckldq xmm0, xmm1 ;A: w0 = xx 01 08 09 02 03 10 11
- lea t, [rsp - DCTSIZE2 * SIZEOF_WORD] ; use red zone for t_
%endif
+ ; Allocate stack space for t array, and realign stack.
+ add rsp, -DCTSIZE2 * SIZEOF_WORD - 8
+ mov t, rsp
+
pshuflw xmm0, xmm0, 11001001b ;A: w0 = 01 08 xx 09 02 03 10 11
pinsrw xmm0, word [block + 16 * SIZEOF_WORD], 2 ;A: w0 = 01 08 16 09 02 03 10 11
punpckhdq xmm3, xmm1 ;D: w3 = 04 05 12 13 06 07 14 15
@@ -443,9 +446,9 @@ EXTN(jsimd_huff_encode_one_block_sse2):
pinsrw xmm5, word [block + 29 * SIZEOF_WORD], 7 ;E: w5 = 42 49 56 57 50 43 36 29
; (Row 4, offset 1)
%undef block
-%define free_bitsq rdx
-%define free_bitsd edx
-%define free_bitsb dl
+%define free_bitsq r15
+%define free_bitsd r15d
+%define free_bitsb r15b
pcmpeqw xmm1, xmm0 ;F: w1[i] = (w1[i] == 0 ? -1 : 0);
shl tempq, 48 ;Z: temp <<= 48;
pxor xmm2, xmm2 ;E: w2[i] = 0;
@@ -534,12 +537,8 @@ EXTN(jsimd_huff_encode_one_block_sse2):
test index, index
jnz .BLOOP ; } while (index != 0);
.ELOOP: ; } /* index != 0 */
- sub td, esp ; t -= (WIN64: &t_[0], UNIX: &t_[64]);
-%ifdef WIN64
+ sub td, esp ; t -= &t_[0];
cmp td, (DCTSIZE2 - 2) * SIZEOF_WORD ; if (t != 62)
-%else
- cmp td, -2 * SIZEOF_WORD ; if (t != -2)
-%endif
je .EFN ; {
movzx nbits, byte [actbl + c_derived_tbl.ehufsi + 0]
; nbits = actbl->ehufsi[0];
@@ -556,18 +555,17 @@ EXTN(jsimd_huff_encode_one_block_sse2):
; state->cur.put_buffer.simd = put_buffer;
mov byte [state + working_state.cur.free_bits], free_bitsb
; state->cur.free_bits = free_bits;
-%ifdef WIN64
- sub rsp, -DCTSIZE2 * SIZEOF_WORD
+ sub rsp, -DCTSIZE2 * SIZEOF_WORD - 8
pop r12
+%ifdef WIN64
pop rdi
pop rsi
- pop rbp
pop rbx
%else
- pop r12
- pop rbp
pop rbx
%endif
+ pop r15
+ pop rbp
ret
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm
index 01b5c0235fa..c9ac59f2f1c 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jcphuff-sse2.asm
@@ -3,16 +3,14 @@
; (64-bit SSE2)
;
; Copyright (C) 2016, 2018, Matthieu Darbois
+; Copyright (C) 2023, Aliaksiej Kandracienka.
+; Copyright (C) 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains an SSE2 implementation of data preparation for progressive
; Huffman encoding. See jcphuff.c for more details.
@@ -281,16 +279,13 @@
GLOBAL_FUNCTION(jsimd_encode_mcu_AC_first_prepare_sse2)
EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [rbp - 16]
- collect_args 6
-
- movdqa XMMWORD [rbp - 16], ZERO
+ sub rsp, SIZEOF_XMMWORD
+ movdqa XMMWORD [rsp], ZERO
+ COLLECT_ARGS 6
movd AL, r13d
pxor ZERO, ZERO
@@ -384,10 +379,9 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
REDUCE0
- movdqa ZERO, XMMWORD [rbp - 16]
- uncollect_args 6
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 6
+ movdqa ZERO, XMMWORD [rsp]
+ mov rsp, rbp
pop rbp
ret
@@ -449,16 +443,13 @@ EXTN(jsimd_encode_mcu_AC_first_prepare_sse2):
GLOBAL_FUNCTION(jsimd_encode_mcu_AC_refine_prepare_sse2)
EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [rbp - 16]
- collect_args 6
-
- movdqa XMMWORD [rbp - 16], ZERO
+ sub rsp, SIZEOF_XMMWORD
+ movdqa XMMWORD [rsp], ZERO
+ COLLECT_ARGS 6
xor SIGN, SIGN
xor EOB, EOB
@@ -606,10 +597,9 @@ EXTN(jsimd_encode_mcu_AC_refine_prepare_sse2):
REDUCE0
mov eax, EOB
- movdqa ZERO, XMMWORD [rbp - 16]
- uncollect_args 6
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 6
+ movdqa ZERO, XMMWORD [rsp]
+ mov rsp, rbp
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm
index b32527aebea..53afc7d77fa 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-avx2.asm
@@ -2,7 +2,7 @@
; jcsample.asm - downsampling (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
;
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -44,10 +40,10 @@
GLOBAL_FUNCTION(jsimd_h2v1_downsample_avx2)
EXTN(jsimd_h2v1_downsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -178,7 +174,7 @@ EXTN(jsimd_h2v1_downsample_avx2):
.return:
vzeroupper
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
@@ -206,10 +202,10 @@ EXTN(jsimd_h2v1_downsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v2_downsample_avx2)
EXTN(jsimd_h2v2_downsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -358,7 +354,7 @@ EXTN(jsimd_h2v2_downsample_avx2):
.return:
vzeroupper
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm
index 2fcfe4567ab..d7ffa930e82 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jcsample-sse2.asm
@@ -2,18 +2,14 @@
; jcsample.asm - downsampling (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -43,10 +39,10 @@
GLOBAL_FUNCTION(jsimd_h2v1_downsample_sse2)
EXTN(jsimd_h2v1_downsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -160,7 +156,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
jg near .rowloop
.return:
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
@@ -188,10 +184,10 @@ EXTN(jsimd_h2v1_downsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v2_downsample_sse2)
EXTN(jsimd_h2v2_downsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 6
+ COLLECT_ARGS 6
mov ecx, r13d
shl rcx, 3 ; imul rcx,DCTSIZE (rcx = output_cols)
@@ -321,7 +317,7 @@ EXTN(jsimd_h2v2_downsample_sse2):
jg near .rowloop
.return:
- uncollect_args 6
+ UNCOLLECT_ARGS 6
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm
index 2370fda6424..7b8a084398d 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-avx2.asm
@@ -2,19 +2,16 @@
; jdcolext.asm - colorspace conversion (64-bit AVX2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -34,21 +31,22 @@
; r13 = JSAMPARRAY output_buf
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 2
align 32
GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_avx2)
EXTN(jsimd_ycc_rgb_convert_avx2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (WK_NUM * SIZEOF_YMMWORD)
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d ; num_cols
@@ -485,9 +483,9 @@ EXTN(jsimd_ycc_rgb_convert_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 5
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm
index e07c8d75188..261f74da5d2 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolext-sse2.asm
@@ -2,18 +2,15 @@
; jdcolext.asm - colorspace conversion (64-bit SSE2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -33,21 +30,22 @@
; r13 = JSAMPARRAY output_buf
; r14d = int num_rows
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
GLOBAL_FUNCTION(jsimd_ycc_rgb_convert_sse2)
EXTN(jsimd_ycc_rgb_convert_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 5
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 5
push rbx
mov ecx, r10d ; num_cols
@@ -428,9 +426,9 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
.return:
pop rbx
- uncollect_args 5
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 5
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm
index 43de9db04dc..bd5aa00b95c 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-avx2.asm
@@ -2,18 +2,14 @@
; jdcolor.asm - colorspace conversion (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; 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
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -32,7 +28,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_avx2)
EXTN(jconst_ycc_rgb_convert_avx2):
@@ -43,7 +39,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm
index b3f1fec07eb..40343fe7895 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdcolor-sse2.asm
@@ -2,17 +2,13 @@
; jdcolor.asm - colorspace conversion (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -31,7 +27,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_ycc_rgb_convert_sse2)
EXTN(jconst_ycc_rgb_convert_sse2):
@@ -42,7 +38,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm
index 9515a17013d..6a5f1daba56 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-avx2.asm
@@ -2,18 +2,14 @@
; jdmerge.asm - merged upsampling/color conversion (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; 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
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -32,7 +28,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_avx2)
EXTN(jconst_merged_upsample_avx2):
@@ -43,7 +39,7 @@ PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285
PW_ONE times 16 dw 1
PD_ONEHALF times 8 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm
index aedccc20f6c..8c269b83d85 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmerge-sse2.asm
@@ -2,17 +2,13 @@
; jdmerge.asm - merged upsampling/color conversion (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> 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.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -31,7 +27,7 @@ F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_merged_upsample_sse2)
EXTN(jconst_merged_upsample_sse2):
@@ -42,7 +38,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
PW_ONE times 8 dw 1
PD_ONEHALF times 4 dd 1 << (SCALEBITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm
index 8b264b4f039..01826fb6abb 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-avx2.asm
@@ -2,19 +2,16 @@
; jdmrgext.asm - merged upsampling/color conversion (64-bit AVX2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -34,21 +31,22 @@
; r12d = JDIMENSION in_row_group_ctr
; r13 = JSAMPARRAY output_buf
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 3
align 32
GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_avx2)
EXTN(jsimd_h2v1_merged_upsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, SIZEOF_YMMWORD * WK_NUM
+ COLLECT_ARGS 4
push rbx
mov ecx, r10d ; col
@@ -479,9 +477,9 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -505,10 +503,10 @@ EXTN(jsimd_h2v1_merged_upsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_avx2)
EXTN(jsimd_h2v2_merged_upsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov eax, r10d
@@ -587,7 +585,7 @@ EXTN(jsimd_h2v2_merged_upsample_avx2):
add rsp, SIZEOF_JSAMPARRAY*4
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm
index eb3ab9dbd94..abd22e21a73 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdmrgext-sse2.asm
@@ -2,18 +2,15 @@
; jdmrgext.asm - merged upsampling/color conversion (64-bit SSE2)
;
; Copyright 2009, 2012 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2012, 2016, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jcolsamp.inc"
@@ -33,21 +30,22 @@
; r12d = JDIMENSION in_row_group_ctr
; r13 = JSAMPARRAY output_buf
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 3
align 32
GLOBAL_FUNCTION(jsimd_h2v1_merged_upsample_sse2)
EXTN(jsimd_h2v1_merged_upsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 4
push rbx
mov ecx, r10d ; col
@@ -421,9 +419,9 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
.return:
pop rbx
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -447,10 +445,10 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v2_merged_upsample_sse2)
EXTN(jsimd_h2v2_merged_upsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov eax, r10d
@@ -529,7 +527,7 @@ EXTN(jsimd_h2v2_merged_upsample_sse2):
add rsp, SIZEOF_JSAMPARRAY*4
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm
index 1e4979f933e..6ae4cf812a7 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-avx2.asm
@@ -2,26 +2,23 @@
; jdsample.asm - upsampling (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2015, Intel Corporation.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_avx2)
EXTN(jconst_fancy_upsample_avx2):
@@ -32,7 +29,7 @@ PW_THREE times 16 dw 3
PW_SEVEN times 16 dw 7
PW_EIGHT times 16 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -61,11 +58,11 @@ PW_EIGHT times 16 dw 8
GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_avx2)
EXTN(jsimd_h2v1_fancy_upsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- push_xmm 3
- collect_args 4
+ PUSH_XMM 3
+ COLLECT_ARGS 4
mov eax, r11d ; colctr
test rax, rax
@@ -186,8 +183,8 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
.return:
vzeroupper
- uncollect_args 4
- pop_xmm 3
+ UNCOLLECT_ARGS 4
+ POP_XMM 3
pop rbp
ret
@@ -208,22 +205,23 @@ EXTN(jsimd_h2v1_fancy_upsample_avx2):
; r12 = JSAMPARRAY input_data
; r13 = JSAMPARRAY *output_data_ptr
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM]
%define WK_NUM 4
align 32
GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_avx2)
EXTN(jsimd_h2v2_fancy_upsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
- and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- push_xmm 3
- collect_args 4
+ mov rbp, rsp
+ push r15
+ and rsp, byte (-SIZEOF_YMMWORD) ; align to 128 bits
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_YMMWORD * WK_NUM)
+ PUSH_XMM 3
+ COLLECT_ARGS 4
push rbx
mov eax, r11d ; colctr
@@ -498,10 +496,10 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 4
- pop_xmm 3
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ POP_XMM 3
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -524,10 +522,10 @@ EXTN(jsimd_h2v2_fancy_upsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v1_upsample_avx2)
EXTN(jsimd_h2v1_upsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
mov edx, r11d
add rdx, byte (SIZEOF_YMMWORD-1)
@@ -590,7 +588,7 @@ EXTN(jsimd_h2v1_upsample_avx2):
.return:
vzeroupper
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
@@ -613,10 +611,10 @@ EXTN(jsimd_h2v1_upsample_avx2):
GLOBAL_FUNCTION(jsimd_h2v2_upsample_avx2)
EXTN(jsimd_h2v2_upsample_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov edx, r11d
@@ -687,7 +685,7 @@ EXTN(jsimd_h2v2_upsample_avx2):
.return:
pop rbx
vzeroupper
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm
index 38dbceec269..54c560fc28e 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jdsample-sse2.asm
@@ -2,25 +2,22 @@
; jdsample.asm - upsampling (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fancy_upsample_sse2)
EXTN(jconst_fancy_upsample_sse2):
@@ -31,7 +28,7 @@ PW_THREE times 8 dw 3
PW_SEVEN times 8 dw 7
PW_EIGHT times 8 dw 8
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -60,10 +57,10 @@ PW_EIGHT times 8 dw 8
GLOBAL_FUNCTION(jsimd_h2v1_fancy_upsample_sse2)
EXTN(jsimd_h2v1_fancy_upsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
mov eax, r11d ; colctr
test rax, rax
@@ -174,7 +171,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
jg near .rowloop
.return:
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
@@ -195,21 +192,22 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
; r12 = JSAMPARRAY input_data
; r13 = JSAMPARRAY *output_data_ptr
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 4
align 32
GLOBAL_FUNCTION(jsimd_h2v2_fancy_upsample_sse2)
EXTN(jsimd_h2v2_fancy_upsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 4
push rbx
mov eax, r11d ; colctr
@@ -472,9 +470,9 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
.return:
pop rbx
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -497,10 +495,10 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v1_upsample_sse2)
EXTN(jsimd_h2v1_upsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
mov edx, r11d
add rdx, byte (2*SIZEOF_XMMWORD)-1
@@ -561,7 +559,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
jg short .rowloop
.return:
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
@@ -584,10 +582,10 @@ EXTN(jsimd_h2v1_upsample_sse2):
GLOBAL_FUNCTION(jsimd_h2v2_upsample_sse2)
EXTN(jsimd_h2v2_upsample_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
mov edx, r11d
@@ -656,7 +654,7 @@ EXTN(jsimd_h2v2_upsample_sse2):
.return:
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm
index ef2796649bc..58a1f5570d3 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctflt-sse.asm
@@ -2,17 +2,14 @@
; jfdctflt.asm - floating-point FDCT (64-bit SSE)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the forward DCT
; (Discrete Cosine Transform). The following code is based directly on
@@ -34,7 +31,7 @@
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_float_sse)
EXTN(jconst_fdct_float_sse):
@@ -44,7 +41,7 @@ PD_0_707 times 4 dd 0.707106781186547524400844
PD_0_541 times 4 dd 0.541196100146196984399723
PD_1_306 times 4 dd 1.306562964876376527856643
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -58,21 +55,22 @@ PD_1_306 times 4 dd 1.306562964876376527856643
; r10 = FAST_FLOAT *data
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
GLOBAL_FUNCTION(jsimd_fdct_float_sse)
EXTN(jsimd_fdct_float_sse):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 1
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -344,9 +342,9 @@ EXTN(jsimd_fdct_float_sse):
dec rcx
jnz near .columnloop
- uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 1
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm
index 2e1bfe6e8c2..3b92d4edaae 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctfst-sse2.asm
@@ -2,17 +2,14 @@
; jfdctfst.asm - fast integer FDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the forward DCT (Discrete Cosine Transform). The following code is
@@ -49,7 +46,7 @@ F_1_306 equ DESCALE(1402911301, 30 - CONST_BITS) ; FIX(1.306562965)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_ifast_sse2)
EXTN(jconst_fdct_ifast_sse2):
@@ -59,7 +56,7 @@ PW_F0382 times 8 dw F_0_382 << CONST_SHIFT
PW_F0541 times 8 dw F_0_541 << CONST_SHIFT
PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -73,21 +70,22 @@ PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
; r10 = DCTELEM *data
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 2
align 32
GLOBAL_FUNCTION(jsimd_fdct_ifast_sse2)
EXTN(jsimd_fdct_ifast_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 1
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -378,9 +376,9 @@ EXTN(jsimd_fdct_ifast_sse2):
movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm6
movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm2
- uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 1
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm
index e56258b48aa..0c4528612cd 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-avx2.asm
@@ -2,17 +2,13 @@
; jfdctint.asm - accurate integer FDCT (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
@@ -65,7 +61,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %1=(00 01 02 03 04 05 06 07 40 41 42 43 44 45 46 47)
; %2=(10 11 12 13 14 15 16 17 50 51 52 53 54 55 56 57)
; %3=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
@@ -108,7 +104,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%8: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 9
+%macro DODCT 9
vpsubw %5, %1, %4 ; %5=data1_0-data6_7=tmp6_7
vpaddw %6, %1, %4 ; %6=data1_0+data6_7=tmp1_0
vpaddw %7, %2, %3 ; %7=data3_2+data4_5=tmp3_2
@@ -223,7 +219,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_avx2)
EXTN(jconst_fdct_islow_avx2):
@@ -242,7 +238,7 @@ PW_DESCALE_P2X times 16 dw 1 << (PASS1_BITS - 1)
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -260,10 +256,10 @@ PW_1_NEG1 times 8 dw 1
GLOBAL_FUNCTION(jsimd_fdct_islow_avx2)
EXTN(jsimd_fdct_islow_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 1
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -285,9 +281,9 @@ EXTN(jsimd_fdct_islow_avx2):
; ymm2=(20 21 22 23 24 25 26 27 60 61 62 63 64 65 66 67)
; ymm3=(30 31 32 33 34 35 36 37 70 71 72 73 74 75 76 77)
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, 1
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm3=data7_5
; ---- Pass 2: process columns.
@@ -295,9 +291,9 @@ EXTN(jsimd_fdct_islow_avx2):
vperm2i128 ymm4, ymm1, ymm3, 0x20 ; ymm4=data3_7
vperm2i128 ymm1, ymm1, ymm3, 0x31 ; ymm1=data1_5
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, 2
; ymm0=data0_4, ymm1=data3_1, ymm2=data2_6, ymm4=data7_5
vperm2i128 ymm3, ymm0, ymm1, 0x30 ; ymm3=data0_1
@@ -311,7 +307,7 @@ EXTN(jsimd_fdct_islow_avx2):
vmovdqu YMMWORD [YMMBLOCK(6,0,r10,SIZEOF_DCTELEM)], ymm7
vzeroupper
- uncollect_args 1
+ UNCOLLECT_ARGS 1
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm
index ec1f383ccb7..3a6be020cd0 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jfdctint-sse2.asm
@@ -2,17 +2,14 @@
; jfdctint.asm - accurate integer FDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2020, 2024, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; forward DCT (Discrete Cosine Transform). The following code is based
@@ -63,7 +60,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_fdct_islow_sse2)
EXTN(jconst_fdct_islow_sse2):
@@ -80,7 +77,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -94,21 +91,22 @@ PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS - 1)
; r10 = DCTELEM *data
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD ; xmmword wk[WK_NUM]
%define WK_NUM 6
align 32
GLOBAL_FUNCTION(jsimd_fdct_islow_sse2)
EXTN(jsimd_fdct_islow_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 1
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 1
; ---- Pass 1: process rows.
@@ -608,9 +606,9 @@ EXTN(jsimd_fdct_islow_sse2):
movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm1
movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm3
- uncollect_args 1
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 1
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm
index 60bf9618961..14437340229 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctflt-sse2.asm
@@ -2,18 +2,15 @@
; jidctflt.asm - floating-point IDCT (64-bit SSE & SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a floating-point implementation of the inverse DCT
; (Discrete Cosine Transform). The following code is based directly on
@@ -24,18 +21,18 @@
; --------------------------------------------------------------------------
-%macro unpcklps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
+%macro UNPCKLPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(0 1 4 5)
shufps %1, %2, 0x44
%endmacro
-%macro unpckhps2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
+%macro UNPCKHPS2 2 ; %1=(0 1 2 3) / %2=(4 5 6 7) => %1=(2 3 6 7)
shufps %1, %2, 0xEE
%endmacro
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_float_sse2)
EXTN(jconst_idct_float_sse2):
@@ -47,7 +44,7 @@ PD_M2_613 times 4 dd -2.613125929752753055713286
PD_RNDINT_MAGIC times 4 dd 100663296.0 ; (float)(0x00C00000 << 3)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -65,8 +62,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
%define workspace wk(0) - DCTSIZE2 * SIZEOF_FAST_FLOAT
@@ -76,14 +72,15 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_float_sse2)
EXTN(jsimd_idct_float_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
lea rsp, [workspace]
- collect_args 4
+ COLLECT_ARGS 4
push rbx
; ---- Pass 1: process columns from input, store into work array.
@@ -280,11 +277,11 @@ EXTN(jsimd_idct_float_sse2):
unpckhps xmm4, xmm0 ; xmm4=(42 52 43 53)
movaps xmm3, xmm6 ; transpose coefficients(phase 2)
- unpcklps2 xmm6, xmm7 ; xmm6=(00 10 20 30)
- unpckhps2 xmm3, xmm7 ; xmm3=(01 11 21 31)
+ UNPCKLPS2 xmm6, xmm7 ; xmm6=(00 10 20 30)
+ UNPCKHPS2 xmm3, xmm7 ; xmm3=(01 11 21 31)
movaps xmm0, xmm1 ; transpose coefficients(phase 2)
- unpcklps2 xmm1, xmm2 ; xmm1=(02 12 22 32)
- unpckhps2 xmm0, xmm2 ; xmm0=(03 13 23 33)
+ UNPCKLPS2 xmm1, xmm2 ; xmm1=(02 12 22 32)
+ UNPCKHPS2 xmm0, xmm2 ; xmm0=(03 13 23 33)
movaps xmm7, XMMWORD [wk(0)] ; xmm7=(60 70 61 71)
movaps xmm2, XMMWORD [wk(1)] ; xmm2=(62 72 63 73)
@@ -295,11 +292,11 @@ EXTN(jsimd_idct_float_sse2):
movaps XMMWORD [XMMBLOCK(3,0,rdi,SIZEOF_FAST_FLOAT)], xmm0
movaps xmm6, xmm5 ; transpose coefficients(phase 2)
- unpcklps2 xmm5, xmm7 ; xmm5=(40 50 60 70)
- unpckhps2 xmm6, xmm7 ; xmm6=(41 51 61 71)
+ UNPCKLPS2 xmm5, xmm7 ; xmm5=(40 50 60 70)
+ UNPCKHPS2 xmm6, xmm7 ; xmm6=(41 51 61 71)
movaps xmm3, xmm4 ; transpose coefficients(phase 2)
- unpcklps2 xmm4, xmm2 ; xmm4=(42 52 62 72)
- unpckhps2 xmm3, xmm2 ; xmm3=(43 53 63 73)
+ UNPCKLPS2 xmm4, xmm2 ; xmm4=(42 52 62 72)
+ UNPCKHPS2 xmm3, xmm2 ; xmm3=(43 53 63 73)
movaps XMMWORD [XMMBLOCK(0,1,rdi,SIZEOF_FAST_FLOAT)], xmm5
movaps XMMWORD [XMMBLOCK(1,1,rdi,SIZEOF_FAST_FLOAT)], xmm6
@@ -322,7 +319,6 @@ EXTN(jsimd_idct_float_sse2):
; ---- Pass 2: process rows from work array, store into output array.
- mov rax, [original_rbp]
lea rsi, [workspace] ; FAST_FLOAT *wsptr
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -471,9 +467,9 @@ EXTN(jsimd_idct_float_sse2):
jnz near .rowloop
pop rbx
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm
index cb97fdfbb24..cffabb8378e 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctfst-sse2.asm
@@ -2,18 +2,15 @@
; jidctfst.asm - fast integer IDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a fast, not so accurate integer implementation of
; the inverse DCT (Discrete Cosine Transform). The following code is
@@ -57,7 +54,7 @@ F_1_613 equ (F_2_613 - (1 << CONST_BITS)) ; FIX(2.613125930) - FIX(1)
%define PRE_MULTIPLY_SCALE_BITS 2
%define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_ifast_sse2)
EXTN(jconst_idct_ifast_sse2):
@@ -68,7 +65,7 @@ PW_MF1613 times 8 dw -F_1_613 << CONST_SHIFT
PW_F1082 times 8 dw F_1_082 << CONST_SHIFT
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -86,8 +83,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
@@ -95,14 +91,15 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_ifast_sse2)
EXTN(jsimd_idct_ifast_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 4
; ---- Pass 1: process columns from input.
@@ -320,7 +317,6 @@ EXTN(jsimd_idct_ifast_sse2):
; ---- Pass 2: process rows from work array, store into output array.
- mov rax, [original_rbp]
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -479,9 +475,9 @@ EXTN(jsimd_idct_ifast_sse2):
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm2
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm
index ca7e317f6e1..be3b46888e5 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-avx2.asm
@@ -2,18 +2,14 @@
; jidctint.asm - accurate integer IDCT (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2020, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
@@ -66,7 +62,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %1-%4: Input/output registers
; %5-%8: Temp registers
-%macro dotranspose 8
+%macro DOTRANSPOSE 8
; %5=(00 10 20 30 40 50 60 70 01 11 21 31 41 51 61 71)
; %6=(03 13 23 33 43 53 63 73 02 12 22 32 42 52 62 72)
; %7=(04 14 24 34 44 54 64 74 05 15 25 35 45 55 65 75)
@@ -119,7 +115,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; %5-%12: Temp registers
; %9: Pass (1 or 2)
-%macro dodct 13
+%macro DODCT 13
; -- Even part
; (Original)
@@ -241,7 +237,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_avx2)
EXTN(jconst_idct_islow_avx2):
@@ -260,7 +256,7 @@ PB_CENTERJSAMP times 32 db CENTERJSAMPLE
PW_1_NEG1 times 8 dw 1
times 8 dw -1
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -282,11 +278,11 @@ PW_1_NEG1 times 8 dw 1
GLOBAL_FUNCTION(jsimd_idct_islow_avx2)
EXTN(jsimd_idct_islow_avx2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
mov rbp, rsp ; rbp = aligned rbp
- push_xmm 4
- collect_args 4
+ PUSH_XMM 4
+ COLLECT_ARGS 4
; ---- Pass 1: process columns.
@@ -343,10 +339,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm2, ymm5, ymm7, 0x20 ; ymm2=in2_6
vperm2i128 ymm3, ymm7, ymm6, 0x31 ; ymm3=in7_5
- dodct ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 1
+ DODCT ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 1
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm3=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm3, ymm4, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm3=data3_7
.column_end:
@@ -363,10 +359,10 @@ EXTN(jsimd_idct_islow_avx2):
vperm2i128 ymm4, ymm3, ymm1, 0x31 ; ymm3=in7_5
vperm2i128 ymm1, ymm3, ymm1, 0x20 ; ymm1=in3_1
- dodct ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 2
+ DODCT ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7, ymm8, ymm9, ymm10, ymm11, 2
; ymm0=data0_1, ymm1=data3_2, ymm2=data4_5, ymm4=data7_6
- dotranspose ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
+ DOTRANSPOSE ymm0, ymm1, ymm2, ymm4, ymm3, ymm5, ymm6, ymm7
; ymm0=data0_4, ymm1=data1_5, ymm2=data2_6, ymm4=data3_7
vpacksswb ymm0, ymm0, ymm1 ; ymm0=data01_45
@@ -408,8 +404,8 @@ EXTN(jsimd_idct_islow_avx2):
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm6
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm7
- uncollect_args 4
- pop_xmm 4
+ UNCOLLECT_ARGS 4
+ POP_XMM 4
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm
index 7aa869bc0b5..b186871ff2a 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctint-sse2.asm
@@ -2,18 +2,15 @@
; jidctint.asm - accurate integer IDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2020, D. R. Commander.
+; Copyright (C) 2009, 2016, 2020, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains a slower but more accurate integer implementation of the
; inverse DCT (Discrete Cosine Transform). The following code is based
@@ -64,7 +61,7 @@ F_3_072 equ DESCALE(3299298341, 30 - CONST_BITS) ; FIX(3.072711026)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_islow_sse2)
EXTN(jconst_idct_islow_sse2):
@@ -81,7 +78,7 @@ PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1 - 1)
PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -99,8 +96,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 12
@@ -108,14 +104,15 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_islow_sse2)
EXTN(jsimd_idct_islow_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 4
; ---- Pass 1: process columns from input.
@@ -512,7 +509,6 @@ EXTN(jsimd_idct_islow_sse2):
; ---- Pass 2: process rows from work array, store into output array.
- mov rax, [original_rbp]
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -836,9 +832,9 @@ EXTN(jsimd_idct_islow_sse2):
movq XMM_MMWORD [rdx+rax*SIZEOF_JSAMPLE], xmm2
movq XMM_MMWORD [rsi+rax*SIZEOF_JSAMPLE], xmm5
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm
index 4ece9d891cb..6fb7095612e 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jidctred-sse2.asm
@@ -2,18 +2,15 @@
; jidctred.asm - reduced-size IDCT (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
;
; This file contains inverse-DCT routines that produce reduced-size
; output: either 4x4 or 2x2 pixels from an 8x8 DCT block.
@@ -70,7 +67,7 @@ F_3_624 equ DESCALE(3891787747, 30 - CONST_BITS) ; FIX(3.624509785)
; --------------------------------------------------------------------------
SECTION SEG_CONST
- alignz 32
+ ALIGNZ 32
GLOBAL_DATA(jconst_idct_red_sse2)
EXTN(jconst_idct_red_sse2):
@@ -88,7 +85,7 @@ PD_DESCALE_P1_2 times 4 dd 1 << (DESCALE_P1_2 - 1)
PD_DESCALE_P2_2 times 4 dd 1 << (DESCALE_P2_2 - 1)
PB_CENTERJSAMP times 16 db CENTERJSAMPLE
- alignz 32
+ ALIGNZ 32
; --------------------------------------------------------------------------
SECTION SEG_TEXT
@@ -107,8 +104,7 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
; r12 = JSAMPARRAY output_buf
; r13d = JDIMENSION output_col
-%define original_rbp rbp + 0
-%define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_XMMWORD
+%define wk(i) r15 - (WK_NUM - (i)) * SIZEOF_XMMWORD
; xmmword wk[WK_NUM]
%define WK_NUM 2
@@ -116,14 +112,15 @@ PB_CENTERJSAMP times 16 db CENTERJSAMPLE
GLOBAL_FUNCTION(jsimd_idct_4x4_sse2)
EXTN(jsimd_idct_4x4_sse2):
+ ENDBR64
push rbp
- mov rax, rsp ; rax = original rbp
- sub rsp, byte 4
+ mov rbp, rsp
+ push r15
and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits
- mov [rsp], rax
- mov rbp, rsp ; rbp = aligned rbp
- lea rsp, [wk(0)]
- collect_args 4
+ ; Allocate stack space for wk array. r15 is used to access it.
+ mov r15, rsp
+ sub rsp, byte (SIZEOF_XMMWORD * WK_NUM)
+ COLLECT_ARGS 4
; ---- Pass 1: process columns from input.
@@ -309,7 +306,6 @@ EXTN(jsimd_idct_4x4_sse2):
; ---- Pass 2: process rows, store into output array.
- mov rax, [original_rbp]
mov rdi, r12 ; (JSAMPROW *)
mov eax, r13d
@@ -389,9 +385,9 @@ EXTN(jsimd_idct_4x4_sse2):
movd XMM_DWORD [rdx+rax*SIZEOF_JSAMPLE], xmm1
movd XMM_DWORD [rsi+rax*SIZEOF_JSAMPLE], xmm3
- uncollect_args 4
- mov rsp, rbp ; rsp <- aligned rbp
- pop rsp ; rsp <- original rbp
+ UNCOLLECT_ARGS 4
+ lea rsp, [rbp-8]
+ pop r15
pop rbp
ret
@@ -414,10 +410,10 @@ EXTN(jsimd_idct_4x4_sse2):
GLOBAL_FUNCTION(jsimd_idct_2x2_sse2)
EXTN(jsimd_idct_2x2_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 4
+ COLLECT_ARGS 4
push rbx
; ---- Pass 1: process columns from input.
@@ -565,7 +561,7 @@ EXTN(jsimd_idct_2x2_sse2):
mov word [rsi+rax*SIZEOF_JSAMPLE], cx
pop rbx
- uncollect_args 4
+ UNCOLLECT_ARGS 4
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm
index ab2e3954f63..64763338f2d 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jquantf-sse2.asm
@@ -2,18 +2,14 @@
; jquantf.asm - sample data conversion and quantization (64-bit SSE & SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -37,10 +33,10 @@
GLOBAL_FUNCTION(jsimd_convsamp_float_sse2)
EXTN(jsimd_convsamp_float_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
push rbx
pcmpeqw xmm7, xmm7
@@ -89,7 +85,7 @@ EXTN(jsimd_convsamp_float_sse2):
jnz short .convloop
pop rbx
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
@@ -110,10 +106,10 @@ EXTN(jsimd_convsamp_float_sse2):
GLOBAL_FUNCTION(jsimd_quantize_float_sse2)
EXTN(jsimd_quantize_float_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
mov rsi, r12
mov rdx, r11
@@ -146,7 +142,7 @@ EXTN(jsimd_quantize_float_sse2):
dec rax
jnz short .quantloop
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm
index 70fe81139cc..7e126e88a88 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-avx2.asm
@@ -2,7 +2,7 @@
; jquanti.asm - sample data conversion and quantization (64-bit AVX2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, 2018, D. R. Commander.
+; Copyright (C) 2009, 2016, 2018, 2024, D. R. Commander.
; Copyright (C) 2016, Matthieu Darbois.
; Copyright (C) 2018, Matthias Räncker.
;
@@ -10,11 +10,7 @@
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -38,10 +34,10 @@
GLOBAL_FUNCTION(jsimd_convsamp_avx2)
EXTN(jsimd_convsamp_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
mov eax, r11d
@@ -84,7 +80,7 @@ EXTN(jsimd_convsamp_avx2):
vmovdqu YMMWORD [YMMBLOCK(6,0,r12,SIZEOF_DCTELEM)], ymm3
vzeroupper
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
@@ -93,8 +89,8 @@ EXTN(jsimd_convsamp_avx2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_avx2(JCOEFPTR coef_block, DCTELEM *divisors,
@@ -116,10 +112,10 @@ EXTN(jsimd_convsamp_avx2):
GLOBAL_FUNCTION(jsimd_quantize_avx2)
EXTN(jsimd_quantize_avx2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
vmovdqu ymm4, [YMMBLOCK(0,0,r12,SIZEOF_DCTELEM)]
vmovdqu ymm5, [YMMBLOCK(2,0,r12,SIZEOF_DCTELEM)]
@@ -154,7 +150,7 @@ EXTN(jsimd_quantize_avx2):
vmovdqu [YMMBLOCK(6,0,r10,SIZEOF_DCTELEM)], ymm3
vzeroupper
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm
index 3ee442027a5..284b9fea71e 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jquanti-sse2.asm
@@ -2,18 +2,14 @@
; jquanti.asm - sample data conversion and quantization (64-bit SSE2)
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
-; Copyright (C) 2009, 2016, D. R. Commander.
+; Copyright (C) 2009, 2016, 2024, D. R. Commander.
; Copyright (C) 2018, Matthias Räncker.
;
; Based on the x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
%include "jdct.inc"
@@ -37,10 +33,10 @@
GLOBAL_FUNCTION(jsimd_convsamp_sse2)
EXTN(jsimd_convsamp_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
push rbx
pxor xmm6, xmm6 ; xmm6=(all 0's)
@@ -84,7 +80,7 @@ EXTN(jsimd_convsamp_sse2):
jnz short .convloop
pop rbx
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
@@ -93,8 +89,8 @@ EXTN(jsimd_convsamp_sse2):
; Quantize/descale the coefficients, and store into coef_block
;
; This implementation is based on an algorithm described in
-; "How to optimize for the Pentium family of microprocessors"
-; (http://www.agner.org/assem/).
+; "Optimizing subroutines in assembly language:
+; An optimization guide for x86 platforms" (https://agner.org/optimize).
;
; GLOBAL(void)
; jsimd_quantize_sse2(JCOEFPTR coef_block, DCTELEM *divisors,
@@ -116,10 +112,10 @@ EXTN(jsimd_convsamp_sse2):
GLOBAL_FUNCTION(jsimd_quantize_sse2)
EXTN(jsimd_quantize_sse2):
+ ENDBR64
push rbp
- mov rax, rsp
mov rbp, rsp
- collect_args 3
+ COLLECT_ARGS 3
mov rsi, r12
mov rdx, r11
@@ -179,7 +175,7 @@ EXTN(jsimd_quantize_sse2):
dec rax
jnz near .quantloop
- uncollect_args 3
+ UNCOLLECT_ARGS 3
pop rbp
ret
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c b/contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c
index d51962f3987..9f4e098fddc 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jsimd.c
@@ -2,8 +2,8 @@
* jsimd_x86_64.c
*
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2009-2011, 2014, 2016, 2018, 2022-2024, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
*
* Based on the x86 SIMD extension for IJG JPEG library,
* Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -15,13 +15,12 @@
*/
#define JPEG_INTERNALS
-#include "../../jinclude.h"
-#include "../../jpeglib.h"
-#include "../../jsimd.h"
-#include "../../jdct.h"
-#include "../../jsimddct.h"
+#include "../../src/jinclude.h"
+#include "../../src/jpeglib.h"
+#include "../../src/jsimd.h"
+#include "../../src/jdct.h"
+#include "../../src/jsimddct.h"
#include "../jsimd.h"
-#include "jconfigint.h"
/*
* In the PIC cases, we have no guarantee that constants will keep
@@ -32,13 +31,11 @@
#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
#define IS_ALIGNED_AVX(ptr) (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */
-static unsigned int simd_support = (unsigned int)(~0);
-static unsigned int simd_huffman = 1;
+static THREAD_LOCAL unsigned int simd_support = (unsigned int)(~0);
+static THREAD_LOCAL unsigned int simd_huffman = 1;
/*
* Check what SIMD accelerations are supported.
- *
- * FIXME: This code is racy under a multi-threaded environment.
*/
LOCAL(void)
init_simd(void)
@@ -116,7 +113,9 @@ jsimd_can_ycc_rgb(void)
{
init_simd();
-#ifndef WITH_SANITIZER
+#ifdef WITH_SANITIZER
+ return 0;
+#endif
/* The code is optimised for these values only */
if (BITS_IN_JSAMPLE != 8)
return 0;
@@ -131,7 +130,6 @@ jsimd_can_ycc_rgb(void)
if ((simd_support & JSIMD_SSE2) &&
IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
return 1;
-#endif
return 0;
}
@@ -150,6 +148,9 @@ jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
void (*avx2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->in_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_extrgb_ycc_convert_avx2;
@@ -199,6 +200,9 @@ jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
void (*avx2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
void (*sse2fct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->in_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_extrgb_gray_convert_avx2;
@@ -248,6 +252,9 @@ jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_ycc_extrgb_convert_avx2;
@@ -338,6 +345,9 @@ GLOBAL(void)
jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v2_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
compptr->v_samp_factor,
@@ -354,6 +364,9 @@ GLOBAL(void)
jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v1_downsample_avx2(cinfo->image_width, cinfo->max_v_samp_factor,
compptr->v_samp_factor,
@@ -408,6 +421,9 @@ GLOBAL(void)
jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v2_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
input_data, output_data_ptr);
@@ -420,6 +436,9 @@ GLOBAL(void)
jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v1_upsample_avx2(cinfo->max_v_samp_factor, cinfo->output_width,
input_data, output_data_ptr);
@@ -474,6 +493,9 @@ GLOBAL(void)
jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v2_fancy_upsample_avx2(cinfo->max_v_samp_factor,
compptr->downsampled_width, input_data,
@@ -488,6 +510,9 @@ GLOBAL(void)
jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_h2v1_fancy_upsample_avx2(cinfo->max_v_samp_factor,
compptr->downsampled_width, input_data,
@@ -547,6 +572,9 @@ jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_h2v2_extrgb_merged_upsample_avx2;
@@ -595,6 +623,9 @@ jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
void (*avx2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
void (*sse2fct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
+ if (simd_support == ~0U)
+ init_simd();
+
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
avx2fct = jsimd_h2v1_extrgb_merged_upsample_avx2;
@@ -684,6 +715,9 @@ GLOBAL(void)
jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col,
DCTELEM *workspace)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_convsamp_avx2(sample_data, start_col, workspace);
else
@@ -753,6 +787,9 @@ jsimd_can_fdct_float(void)
GLOBAL(void)
jsimd_fdct_islow(DCTELEM *data)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_fdct_islow_avx2(data);
else
@@ -814,6 +851,9 @@ jsimd_can_quantize_float(void)
GLOBAL(void)
jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_quantize_avx2(coef_block, divisors, workspace);
else
@@ -944,6 +984,9 @@ jsimd_can_idct_float(void)
{
init_simd();
+#ifdef WITH_SANITIZER
+ return 0;
+#endif
if (DCTSIZE != 8)
return 0;
if (sizeof(JCOEF) != 2)
@@ -968,6 +1011,9 @@ jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf,
JDIMENSION output_col)
{
+ if (simd_support == ~0U)
+ init_simd();
+
if (simd_support & JSIMD_AVX2)
jsimd_idct_islow_avx2(compptr->dct_table, coef_block, output_buf,
output_col);
@@ -999,7 +1045,9 @@ jsimd_can_huff_encode_one_block(void)
{
init_simd();
-#ifndef WITH_SANITIZER
+#ifdef WITH_SANITIZER
+ return 0;
+#endif
if (DCTSIZE != 8)
return 0;
if (sizeof(JCOEF) != 2)
@@ -1008,7 +1056,6 @@ jsimd_can_huff_encode_one_block(void)
if ((simd_support & JSIMD_SSE2) && simd_huffman &&
IS_ALIGNED_SSE(jconst_huff_encode_one_block))
return 1;
-#endif
return 0;
}
@@ -1027,14 +1074,15 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
{
init_simd();
-#ifndef WITH_SANITIZER
+#ifdef WITH_SANITIZER
+ return 0;
+#endif
if (DCTSIZE != 8)
return 0;
if (sizeof(JCOEF) != 2)
return 0;
if (simd_support & JSIMD_SSE2)
return 1;
-#endif
return 0;
}
@@ -1042,7 +1090,7 @@ jsimd_can_encode_mcu_AC_first_prepare(void)
GLOBAL(void)
jsimd_encode_mcu_AC_first_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits)
+ int Al, UJCOEF *values, size_t *zerobits)
{
jsimd_encode_mcu_AC_first_prepare_sse2(block, jpeg_natural_order_start,
Sl, Al, values, zerobits);
@@ -1053,14 +1101,12 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
{
init_simd();
-#ifndef WITH_SANITIZER
if (DCTSIZE != 8)
return 0;
if (sizeof(JCOEF) != 2)
return 0;
if (simd_support & JSIMD_SSE2)
return 1;
-#endif
return 0;
}
@@ -1068,7 +1114,7 @@ jsimd_can_encode_mcu_AC_refine_prepare(void)
GLOBAL(int)
jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
+ int Al, UJCOEF *absvalues, size_t *bits)
{
return jsimd_encode_mcu_AC_refine_prepare_sse2(block,
jpeg_natural_order_start,
diff --git a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm b/contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm
index 705f813d7da..b72f3b0b398 100644
--- a/contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm
+++ b/contrib/libs/libjpeg-turbo/simd/x86_64/jsimdcpu.asm
@@ -3,17 +3,14 @@
;
; Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
; Copyright (C) 2016, D. R. Commander.
+; Copyright (C) 2023, Aliaksiej Kandracienka.
;
; Based on
; x86 SIMD extension for IJG JPEG library
; Copyright (C) 1999-2006, MIYASAKA Masaru.
; For conditions of distribution and use, see copyright notice in jsimdext.inc
;
-; This file should be assembled with NASM (Netwide Assembler),
-; can *not* be assembled with Microsoft's MASM or any compatible
-; assembler (including Borland's Turbo Assembler).
-; NASM is available from http://nasm.sourceforge.net/ or
-; http://sourceforge.net/project/showfiles.php?group_id=6208
+; This file should be assembled with NASM (Netwide Assembler) or Yasm.
%include "jsimdext.inc"
@@ -31,6 +28,8 @@
GLOBAL_FUNCTION(jpeg_simd_cpu_support)
EXTN(jpeg_simd_cpu_support):
+ push rbp
+ mov rbp, rsp
push rbx
push rdi
@@ -79,6 +78,7 @@ EXTN(jpeg_simd_cpu_support):
pop rdi
pop rbx
+ pop rbp
ret
; For some reason, the OS X linker does not honor the request to align the
diff --git a/contrib/libs/libjpeg-turbo/cderror.h b/contrib/libs/libjpeg-turbo/src/cderror.h
index 2844346ee38..cd3e80646ff 100644
--- a/contrib/libs/libjpeg-turbo/cderror.h
+++ b/contrib/libs/libjpeg-turbo/src/cderror.h
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2021, D. R. Commander.
+ * Copyright (C) 2021, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -42,7 +42,6 @@ typedef enum {
JMESSAGE(JMSG_FIRSTADDONCODE = 1000, NULL) /* Must be first entry! */
-#ifdef BMP_SUPPORTED
JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
JMESSAGE(JERR_BMP_BADDEPTH, "Only 8-, 24-, and 32-bit BMP files are supported")
JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")
@@ -56,9 +55,7 @@ JMESSAGE(JTRC_BMP, "%ux%u %d-bit BMP image")
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
JMESSAGE(JTRC_BMP_OS2, "%ux%u %d-bit OS2 BMP image")
JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")
-#endif /* BMP_SUPPORTED */
-#ifdef GIF_SUPPORTED
JMESSAGE(JERR_GIF_BUG, "GIF output got confused")
JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d")
JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB")
@@ -74,29 +71,23 @@ JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file")
JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring")
JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image")
JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
-#endif /* GIF_SUPPORTED */
-#ifdef PPM_SUPPORTED
JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
-JMESSAGE(JTRC_PGM, "%ux%u PGM image")
-JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
-JMESSAGE(JTRC_PPM, "%ux%u PPM image")
-JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
-#endif /* PPM_SUPPORTED */
+JMESSAGE(JTRC_PGM, "%ux%u PGM image (maximum color value = %u)")
+JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image (maximum color value = %u)")
+JMESSAGE(JTRC_PPM, "%ux%u PPM image (maximum color value = %u)")
+JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image (maximum color value = %u)")
-#ifdef TARGA_SUPPORTED
JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB")
JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image")
JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image")
JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image")
-#else
JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled")
-#endif /* TARGA_SUPPORTED */
JMESSAGE(JERR_BAD_CMAP_FILE,
"Color map file is invalid or of unsupported format")
diff --git a/contrib/libs/libjpeg-turbo/cdjpeg.c b/contrib/libs/libjpeg-turbo/src/cdjpeg.c
index 304a6650179..304a6650179 100644
--- a/contrib/libs/libjpeg-turbo/cdjpeg.c
+++ b/contrib/libs/libjpeg-turbo/src/cdjpeg.c
diff --git a/contrib/libs/libjpeg-turbo/cdjpeg.h b/contrib/libs/libjpeg-turbo/src/cdjpeg.h
index 082687ce06d..dbe54a0922e 100644
--- a/contrib/libs/libjpeg-turbo/cdjpeg.h
+++ b/contrib/libs/libjpeg-turbo/src/cdjpeg.h
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019, 2021, D. R. Commander.
+ * Copyright (C) 2017, 2019, 2021-2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -35,10 +35,12 @@ struct cjpeg_source_struct {
FILE *input_file;
JSAMPARRAY buffer;
+ J12SAMPARRAY buffer12;
+#ifdef C_LOSSLESS_SUPPORTED
+ J16SAMPARRAY buffer16;
+#endif
JDIMENSION buffer_height;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
JDIMENSION max_pixels;
-#endif
};
@@ -75,6 +77,10 @@ struct djpeg_dest_struct {
* height is buffer_height.
*/
JSAMPARRAY buffer;
+ J12SAMPARRAY buffer12;
+#ifdef D_LOSSLESS_SUPPORTED
+ J16SAMPARRAY buffer16;
+#endif
JDIMENSION buffer_height;
};
@@ -109,8 +115,18 @@ EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
boolean use_inversion_array);
EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw);
+EXTERN(djpeg_dest_ptr) j12init_write_gif(j_decompress_ptr cinfo,
+ boolean is_lzw);
EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
+EXTERN(cjpeg_source_ptr) j12init_read_ppm(j_compress_ptr cinfo);
+#ifdef C_LOSSLESS_SUPPORTED
+EXTERN(cjpeg_source_ptr) j16init_read_ppm(j_compress_ptr cinfo);
+#endif
EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
+EXTERN(djpeg_dest_ptr) j12init_write_ppm(j_decompress_ptr cinfo);
+#ifdef D_LOSSLESS_SUPPORTED
+EXTERN(djpeg_dest_ptr) j16init_write_ppm(j_decompress_ptr cinfo);
+#endif
EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
@@ -127,6 +143,7 @@ EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
/* djpeg support routines (in rdcolmap.c) */
EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
+EXTERN(void) read_color_map_12(j_decompress_ptr cinfo, FILE *infile);
/* common support routines (in cdjpeg.c) */
@@ -156,6 +173,3 @@ EXTERN(FILE *) write_stdout(void);
#ifndef EXIT_WARNING
#define EXIT_WARNING 2
#endif
-
-#define IsExtRGB(cs) \
- (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
diff --git a/contrib/libs/libjpeg-turbo/cjpeg.c b/contrib/libs/libjpeg-turbo/src/cjpeg.c
index dae18a3fc11..22da5382e07 100644
--- a/contrib/libs/libjpeg-turbo/cjpeg.c
+++ b/contrib/libs/libjpeg-turbo/src/cjpeg.c
@@ -4,8 +4,11 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2011 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, D. R. Commander.
+ * Copyright (C) 2010, 2013-2014, 2017, 2019-2022, 2024-2025,
+ * D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -107,7 +110,18 @@ select_file_type(j_compress_ptr cinfo, FILE *infile)
#endif
#ifdef PPM_SUPPORTED
case 'P':
- return jinit_read_ppm(cinfo);
+ if (cinfo->data_precision <= 8)
+ return jinit_read_ppm(cinfo);
+ else if (cinfo->data_precision <= 12)
+ return j12init_read_ppm(cinfo);
+ else {
+#ifdef C_LOSSLESS_SUPPORTED
+ return j16init_read_ppm(cinfo);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ break;
+#endif
+ }
#endif
#ifdef TARGA_SUPPORTED
case 0x00:
@@ -134,9 +148,9 @@ select_file_type(j_compress_ptr cinfo, FILE *infile)
static const char *progname; /* program name for error messages */
static char *icc_filename; /* for -icc switch */
static char *outfilename; /* for -outfile switch */
-boolean memdst; /* for -memdst switch */
-boolean report; /* for -report switch */
-boolean strict; /* for -strict switch */
+static boolean memdst; /* for -memdst switch */
+static boolean report; /* for -report switch */
+static boolean strict; /* for -strict switch */
#ifdef CJPEG_FUZZER
@@ -172,6 +186,7 @@ static void my_emit_message_fuzzer(j_common_ptr cinfo, int msg_level)
fclose(input_file); \
if (memdst) \
free(outbuffer); \
+ free(icc_profile); \
return EXIT_FAILURE; \
}
@@ -204,6 +219,16 @@ usage(void)
fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n");
#endif
fprintf(stderr, "Switches for advanced users:\n");
+ fprintf(stderr, " -precision N Create JPEG file with N-bit data precision\n");
+#ifdef C_LOSSLESS_SUPPORTED
+ fprintf(stderr, " (N=2..16; default is 8; if N is not 8 or 12, then -lossless\n");
+ fprintf(stderr, " must also be specified)\n");
+#else
+ fprintf(stderr, " (N is 8 or 12; default is 8)\n");
+#endif
+#ifdef C_LOSSLESS_SUPPORTED
+ fprintf(stderr, " -lossless psv[,Pt] Create lossless JPEG file\n");
+#endif
#ifdef C_ARITH_CODING_SUPPORTED
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
#endif
@@ -226,9 +251,7 @@ usage(void)
#endif
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
fprintf(stderr, " -outfile name Specify name for output file\n");
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
fprintf(stderr, " -memdst Compress to memory instead of file (useful for benchmarking)\n");
-#endif
fprintf(stderr, " -report Report compression progress\n");
fprintf(stderr, " -strict Treat all warnings as fatal\n");
fprintf(stderr, " -verbose or -debug Emit debug output\n");
@@ -259,6 +282,9 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
{
int argn;
char *arg;
+#ifdef C_LOSSLESS_SUPPORTED
+ int psv = 0, pt = 0;
+#endif
boolean force_baseline;
boolean simple_progressive;
char *qualityarg = NULL; /* saves -quality parm if any */
@@ -328,7 +354,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
if (!printed_version) {
fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
+ fprintf(stderr, JCOPYRIGHT1);
+ fprintf(stderr, JCOPYRIGHT2 "\n");
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
JVERSION);
printed_version = TRUE;
@@ -355,6 +382,28 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
usage();
icc_filename = argv[argn];
+ } else if (keymatch(arg, "lossless", 1)) {
+ /* Enable lossless mode. */
+#ifdef C_LOSSLESS_SUPPORTED
+ char ch = ',', *ptr;
+
+ if (++argn >= argc) /* advance to next argument */
+ usage();
+ if (sscanf(argv[argn], "%d%c", &psv, &ch) < 1 || ch != ',')
+ usage();
+ ptr = argv[argn];
+ while (*ptr && *ptr++ != ','); /* advance to next segment of arg
+ string */
+ if (*ptr)
+ sscanf(ptr, "%d", &pt);
+
+ /* We must postpone execution until data_precision is known. */
+#else
+ fprintf(stderr, "%s: sorry, lossless output was not compiled\n",
+ progname);
+ exit(EXIT_FAILURE);
+#endif
+
} else if (keymatch(arg, "maxmemory", 3)) {
/* Maximum memory in Kb (or Mb with 'm'). */
long lval;
@@ -384,6 +433,22 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
usage();
outfilename = argv[argn]; /* save it away for later use */
+ } else if (keymatch(arg, "precision", 3)) {
+ /* Set data precision. */
+ int val;
+
+ if (++argn >= argc) /* advance to next argument */
+ usage();
+ if (sscanf(argv[argn], "%d", &val) != 1)
+ usage();
+#ifdef C_LOSSLESS_SUPPORTED
+ if (val < 2 || val > 16)
+#else
+ if (val != 8 && val != 12)
+#endif
+ usage();
+ cinfo->data_precision = val;
+
} else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
@@ -397,13 +462,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "memdst", 2)) {
/* Use in-memory destination manager */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
memdst = TRUE;
-#else
- fprintf(stderr, "%s: sorry, in-memory destination manager was not compiled in\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
} else if (keymatch(arg, "quality", 1)) {
/* Quality ratings (quantization table scaling factors). */
@@ -460,7 +519,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
* default sampling factors.
*/
- } else if (keymatch(arg, "scans", 4)) {
+ } else if (keymatch(arg, "scans", 2)) {
/* Set scan script. */
#ifdef C_MULTISCAN_FILES_SUPPORTED
if (++argn >= argc) /* advance to next argument */
@@ -524,6 +583,11 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
jpeg_simple_progression(cinfo);
#endif
+#ifdef C_LOSSLESS_SUPPORTED
+ if (psv != 0) /* process -lossless */
+ jpeg_enable_lossless(cinfo, psv, pt);
+#endif
+
#ifdef C_MULTISCAN_FILES_SUPPORTED
if (scansarg != NULL) /* process -scans if it was present */
if (!read_scan_script(cinfo, scansarg))
@@ -710,11 +774,9 @@ main(int argc, char **argv)
file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
/* Specify data destination for compression */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
if (memdst)
jpeg_mem_dest(&cinfo, &outbuffer, &outsize);
else
-#endif
jpeg_stdio_dest(&cinfo, output_file);
#ifdef CJPEG_FUZZER
@@ -729,9 +791,25 @@ main(int argc, char **argv)
jpeg_write_icc_profile(&cinfo, icc_profile, (unsigned int)icc_len);
/* Process data */
- while (cinfo.next_scanline < cinfo.image_height) {
- num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
- (void)jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
+ if (cinfo.data_precision <= 8) {
+ while (cinfo.next_scanline < cinfo.image_height) {
+ num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
+ (void)jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
+ }
+ } else if (cinfo.data_precision <= 12) {
+ while (cinfo.next_scanline < cinfo.image_height) {
+ num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
+ (void)jpeg12_write_scanlines(&cinfo, src_mgr->buffer12, num_scanlines);
+ }
+ } else {
+#ifdef C_LOSSLESS_SUPPORTED
+ while (cinfo.next_scanline < cinfo.image_height) {
+ num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
+ (void)jpeg16_write_scanlines(&cinfo, src_mgr->buffer16, num_scanlines);
+ }
+#else
+ ERREXIT1(&cinfo, JERR_BAD_PRECISION, cinfo.data_precision);
+#endif
}
/* Finish compression and release memory */
diff --git a/contrib/libs/libjpeg-turbo/src/cmyk.h b/contrib/libs/libjpeg-turbo/src/cmyk.h
new file mode 100644
index 00000000000..4127b14d4ed
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/cmyk.h
@@ -0,0 +1,61 @@
+/*
+ * cmyk.h
+ *
+ * Copyright (C) 2017-2018, 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains convenience functions for performing quick & dirty
+ * CMYK<->RGB conversion. This algorithm is suitable for testing purposes
+ * only. Properly converting between CMYK and RGB requires a color management
+ * system.
+ */
+
+#ifndef CMYK_H
+#define CMYK_H
+
+#include <jinclude.h>
+#define JPEG_INTERNALS
+#include <jpeglib.h>
+#include "jsamplecomp.h"
+
+
+/* Fully reversible */
+
+INLINE
+LOCAL(void)
+rgb_to_cmyk(int maxval, _JSAMPLE r, _JSAMPLE g, _JSAMPLE b,
+ _JSAMPLE *c, _JSAMPLE *m, _JSAMPLE *y, _JSAMPLE *k)
+{
+ double ctmp = 1.0 - ((double)r / (double)maxval);
+ double mtmp = 1.0 - ((double)g / (double)maxval);
+ double ytmp = 1.0 - ((double)b / (double)maxval);
+ double ktmp = MIN(MIN(ctmp, mtmp), ytmp);
+
+ if (ktmp == 1.0) ctmp = mtmp = ytmp = 0.0;
+ else {
+ ctmp = (ctmp - ktmp) / (1.0 - ktmp);
+ mtmp = (mtmp - ktmp) / (1.0 - ktmp);
+ ytmp = (ytmp - ktmp) / (1.0 - ktmp);
+ }
+ *c = (_JSAMPLE)((double)maxval - ctmp * (double)maxval + 0.5);
+ *m = (_JSAMPLE)((double)maxval - mtmp * (double)maxval + 0.5);
+ *y = (_JSAMPLE)((double)maxval - ytmp * (double)maxval + 0.5);
+ *k = (_JSAMPLE)((double)maxval - ktmp * (double)maxval + 0.5);
+}
+
+
+/* Fully reversible only for C/M/Y/K values generated with rgb_to_cmyk() */
+
+INLINE
+LOCAL(void)
+cmyk_to_rgb(int maxval, _JSAMPLE c, _JSAMPLE m, _JSAMPLE y, _JSAMPLE k,
+ _JSAMPLE *r, _JSAMPLE *g, _JSAMPLE *b)
+{
+ *r = (_JSAMPLE)((double)c * (double)k / (double)maxval + 0.5);
+ *g = (_JSAMPLE)((double)m * (double)k / (double)maxval + 0.5);
+ *b = (_JSAMPLE)((double)y * (double)k / (double)maxval + 0.5);
+}
+
+
+#endif /* CMYK_H */
diff --git a/contrib/libs/libjpeg-turbo/djpeg.c b/contrib/libs/libjpeg-turbo/src/djpeg.c
index 7666e3fec09..fe559faeb68 100644
--- a/contrib/libs/libjpeg-turbo/djpeg.c
+++ b/contrib/libs/libjpeg-turbo/src/djpeg.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2013-2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022, D. R. Commander.
+ * Copyright (C) 2010-2011, 2013-2017, 2019-2020, 2022-2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -84,14 +84,14 @@ static IMAGE_FORMATS requested_fmt;
static const char *progname; /* program name for error messages */
static char *icc_filename; /* for -icc switch */
-JDIMENSION max_scans; /* for -maxscans switch */
+static JDIMENSION max_scans; /* for -maxscans switch */
static char *outfilename; /* for -outfile switch */
-boolean memsrc; /* for -memsrc switch */
-boolean report; /* for -report switch */
-boolean skip, crop;
-JDIMENSION skip_start, skip_end;
-JDIMENSION crop_x, crop_y, crop_width, crop_height;
-boolean strict; /* for -strict switch */
+static boolean memsrc; /* for -memsrc switch */
+static boolean report; /* for -report switch */
+static boolean skip, crop;
+static JDIMENSION skip_start, skip_end;
+static JDIMENSION crop_x, crop_y, crop_width, crop_height;
+static boolean strict; /* for -strict switch */
#define INPUT_BUF_SIZE 4096
@@ -107,8 +107,8 @@ usage(void)
#endif
fprintf(stderr, "Switches (names may be abbreviated):\n");
- fprintf(stderr, " -colors N Reduce image to no more than N colors\n");
- fprintf(stderr, " -fast Fast, low-quality processing\n");
+ fprintf(stderr, " -colors N Reduce image to no more than N colors [legacy feature]\n");
+ fprintf(stderr, " -fast Low-quality processing [legacy feature]\n");
fprintf(stderr, " -grayscale Force grayscale output\n");
fprintf(stderr, " -rgb Force RGB output\n");
fprintf(stderr, " -rgb565 Force RGB565 output\n");
@@ -120,13 +120,13 @@ usage(void)
(DEFAULT_FMT == FMT_BMP ? " (default)" : ""));
#endif
#ifdef GIF_SUPPORTED
- fprintf(stderr, " -gif Select GIF output format (LZW-compressed)%s\n",
+ fprintf(stderr, " -gif Select GIF output format (LZW-compressed)%s [legacy feature]\n",
(DEFAULT_FMT == FMT_GIF ? " (default)" : ""));
- fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n",
+ fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s [legacy feature]\n",
(DEFAULT_FMT == FMT_GIF0 ? " (default)" : ""));
#endif
#ifdef BMP_SUPPORTED
- fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n",
+ fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s [legacy feature]\n",
(DEFAULT_FMT == FMT_OS2 ? " (default)" : ""));
#endif
#ifdef PPM_SUPPORTED
@@ -134,7 +134,7 @@ usage(void)
(DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
#endif
#ifdef TARGA_SUPPORTED
- fprintf(stderr, " -targa Select Targa output format%s\n",
+ fprintf(stderr, " -targa Select Targa output format%s [legacy feature]\n",
(DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
#endif
fprintf(stderr, "Switches for advanced users:\n");
@@ -150,23 +150,23 @@ usage(void)
fprintf(stderr, " -dct float Use floating-point DCT method [legacy feature]%s\n",
(JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
#endif
- fprintf(stderr, " -dither fs Use F-S dithering (default)\n");
- fprintf(stderr, " -dither none Don't use dithering in quantization\n");
- fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n");
+ fprintf(stderr, " -dither fs Use Floyd-Steinberg dithering when quantizing colors (default)\n");
+ fprintf(stderr, " [legacy feature]\n");
+ fprintf(stderr, " -dither none Don't use dithering when quantizing colors [legacy feature]\n");
+ fprintf(stderr, " -dither ordered Use ordered dithering when quantizing colors\n");
+ fprintf(stderr, " [legacy feature]\n");
fprintf(stderr, " -icc FILE Extract ICC profile to FILE\n");
#ifdef QUANT_2PASS_SUPPORTED
- fprintf(stderr, " -map FILE Map to colors used in named image file\n");
+ fprintf(stderr, " -map FILE Quantize to colors used in named image file [legacy feature]\n");
#endif
- fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n");
+ fprintf(stderr, " -nosmooth Use faster, lower-quality upsampling\n");
#ifdef QUANT_1PASS_SUPPORTED
- fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n");
+ fprintf(stderr, " -onepass Use 1-pass color quantization (low quality) [legacy feature]\n");
#endif
fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n");
fprintf(stderr, " -maxscans N Maximum number of scans to allow in input file\n");
fprintf(stderr, " -outfile name Specify name for output file\n");
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
fprintf(stderr, " -memsrc Load input file into memory before decompressing\n");
-#endif
fprintf(stderr, " -report Report decompression progress\n");
fprintf(stderr, " -skip Y0,Y1 Decompress all rows except those between Y0 and Y1 (inclusive)\n");
fprintf(stderr, " -crop WxH+X+Y Decompress only a rectangular subregion of the image\n");
@@ -269,7 +269,8 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
if (!printed_version) {
fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
+ fprintf(stderr, JCOPYRIGHT1);
+ fprintf(stderr, JCOPYRIGHT2 "\n");
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
JVERSION);
printed_version = TRUE;
@@ -316,7 +317,9 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
if (++argn >= argc) /* advance to next argument */
usage();
icc_filename = argv[argn];
+#ifdef SAVE_MARKERS_SUPPORTED
jpeg_save_markers(cinfo, JPEG_APP0 + 2, 0xFFFF);
+#endif
} else if (keymatch(arg, "map", 3)) {
/* Quantize to a color map taken from an input file. */
@@ -330,7 +333,10 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]);
exit(EXIT_FAILURE);
}
- read_color_map(cinfo, mapfile);
+ if (cinfo->data_precision == 12)
+ read_color_map_12(cinfo, mapfile);
+ else
+ read_color_map(cinfo, mapfile);
fclose(mapfile);
cinfo->quantize_colors = TRUE;
#else
@@ -377,13 +383,7 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "memsrc", 2)) {
/* Use in-memory source manager */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
memsrc = TRUE;
-#else
- fprintf(stderr, "%s: sorry, in-memory source manager was not compiled in\n",
- progname);
- exit(EXIT_FAILURE);
-#endif
} else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {
/* PPM/PGM output format. */
@@ -392,7 +392,7 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
} else if (keymatch(arg, "report", 2)) {
report = TRUE;
- } else if (keymatch(arg, "scale", 2)) {
+ } else if (keymatch(arg, "scale", 1)) {
/* Scale the output image by a fraction M/N. */
if (++argn >= argc) /* advance to next argument */
usage();
@@ -401,22 +401,31 @@ parse_switches(j_decompress_ptr cinfo, int argc, char **argv,
usage();
} else if (keymatch(arg, "skip", 2)) {
+ int temp_start = -1, temp_end = -1;
if (++argn >= argc)
usage();
- if (sscanf(argv[argn], "%u,%u", &skip_start, &skip_end) != 2 ||
- skip_start > skip_end)
+ if (sscanf(argv[argn], "%d,%d", &temp_start, &temp_end) != 2 ||
+ temp_start < 0 || temp_end < 0 || temp_start > temp_end)
usage();
skip = TRUE;
+ skip_start = temp_start;
+ skip_end = temp_end;
} else if (keymatch(arg, "crop", 2)) {
+ int temp_width = -1, temp_height = -1, temp_x = -1, temp_y = -1;
char c;
if (++argn >= argc)
usage();
- if (sscanf(argv[argn], "%u%c%u+%u+%u", &crop_width, &c, &crop_height,
- &crop_x, &crop_y) != 5 ||
- (c != 'X' && c != 'x') || crop_width < 1 || crop_height < 1)
+ if (sscanf(argv[argn], "%d%c%d+%d+%d", &temp_width, &c, &temp_height,
+ &temp_x, &temp_y) != 5 ||
+ (c != 'X' && c != 'x') || temp_width < 1 || temp_height < 1 ||
+ temp_x < 0 || temp_y < 0)
usage();
crop = TRUE;
+ crop_width = temp_width;
+ crop_height = temp_height;
+ crop_x = temp_x;
+ crop_y = temp_y;
} else if (keymatch(arg, "strict", 2)) {
strict = TRUE;
@@ -535,9 +544,7 @@ main(int argc, char **argv)
FILE *input_file;
FILE *output_file;
unsigned char *inbuffer = NULL;
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
unsigned long insize = 0;
-#endif
JDIMENSION num_scanlines;
progname = argv[0];
@@ -627,7 +634,6 @@ main(int argc, char **argv)
}
/* Specify data source for decompression */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
if (memsrc) {
size_t nbytes;
do {
@@ -649,7 +655,6 @@ main(int argc, char **argv)
fprintf(stderr, "Compressed size: %lu bytes\n", insize);
jpeg_mem_src(&cinfo, inbuffer, insize);
} else
-#endif
jpeg_stdio_src(&cinfo, input_file);
/* Read file header, set default decompression parameters */
@@ -672,7 +677,12 @@ main(int argc, char **argv)
#endif
#ifdef GIF_SUPPORTED
case FMT_GIF:
- dest_mgr = jinit_write_gif(&cinfo, TRUE);
+ if (cinfo.data_precision == 8)
+ dest_mgr = jinit_write_gif(&cinfo, TRUE);
+ else if (cinfo.data_precision == 12)
+ dest_mgr = j12init_write_gif(&cinfo, TRUE);
+ else
+ ERREXIT1(&cinfo, JERR_BAD_PRECISION, cinfo.data_precision);
break;
case FMT_GIF0:
dest_mgr = jinit_write_gif(&cinfo, FALSE);
@@ -680,7 +690,16 @@ main(int argc, char **argv)
#endif
#ifdef PPM_SUPPORTED
case FMT_PPM:
- dest_mgr = jinit_write_ppm(&cinfo);
+ if (cinfo.data_precision <= 8)
+ dest_mgr = jinit_write_ppm(&cinfo);
+ else if (cinfo.data_precision <= 12)
+ dest_mgr = j12init_write_ppm(&cinfo);
+ else
+#ifdef D_LOSSLESS_SUPPORTED
+ dest_mgr = j16init_write_ppm(&cinfo);
+#else
+ ERREXIT1(&cinfo, JERR_BAD_PRECISION, cinfo.data_precision);
+#endif
break;
#endif
#ifdef TARGA_SUPPORTED
@@ -719,23 +738,44 @@ main(int argc, char **argv)
(*dest_mgr->start_output) (&cinfo, dest_mgr);
cinfo.output_height = tmp;
- /* Process data */
- while (cinfo.output_scanline < skip_start) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
- }
- if ((tmp = jpeg_skip_scanlines(&cinfo, skip_end - skip_start + 1)) !=
- skip_end - skip_start + 1) {
- fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
- progname, tmp, skip_end - skip_start + 1);
- exit(EXIT_FAILURE);
- }
- while (cinfo.output_scanline < cinfo.output_height) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
- }
+ if (cinfo.data_precision == 8) {
+ /* Process data */
+ while (cinfo.output_scanline < skip_start) {
+ num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ if ((tmp = jpeg_skip_scanlines(&cinfo, skip_end - skip_start + 1)) !=
+ skip_end - skip_start + 1) {
+ fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
+ progname, tmp, skip_end - skip_start + 1);
+ exit(EXIT_FAILURE);
+ }
+ while (cinfo.output_scanline < cinfo.output_height) {
+ num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ } else if (cinfo.data_precision == 12) {
+ /* Process data */
+ while (cinfo.output_scanline < skip_start) {
+ num_scanlines = jpeg12_read_scanlines(&cinfo, dest_mgr->buffer12,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ if ((tmp = jpeg12_skip_scanlines(&cinfo, skip_end - skip_start + 1)) !=
+ skip_end - skip_start + 1) {
+ fprintf(stderr, "%s: jpeg12_skip_scanlines() returned %u rather than %u\n",
+ progname, tmp, skip_end - skip_start + 1);
+ exit(EXIT_FAILURE);
+ }
+ while (cinfo.output_scanline < cinfo.output_height) {
+ num_scanlines = jpeg12_read_scanlines(&cinfo, dest_mgr->buffer12,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ } else
+ ERREXIT(&cinfo, JERR_NOTIMPL);
/* Decompress a subregion */
} else if (crop) {
@@ -744,14 +784,19 @@ main(int argc, char **argv)
/* Check for valid crop dimensions. We cannot check these values until
* after jpeg_start_decompress() is called.
*/
- if (crop_x + crop_width > cinfo.output_width ||
- crop_y + crop_height > cinfo.output_height) {
+ if ((unsigned long long)crop_x + crop_width > cinfo.output_width ||
+ (unsigned long long)crop_y + crop_height > cinfo.output_height) {
fprintf(stderr, "%s: crop dimensions exceed image dimensions %u x %u\n",
progname, cinfo.output_width, cinfo.output_height);
exit(EXIT_FAILURE);
}
- jpeg_crop_scanline(&cinfo, &crop_x, &crop_width);
+ if (cinfo.data_precision == 8)
+ jpeg_crop_scanline(&cinfo, &crop_x, &crop_width);
+ else if (cinfo.data_precision == 12)
+ jpeg12_crop_scanline(&cinfo, &crop_x, &crop_width);
+ else
+ ERREXIT(&cinfo, JERR_NOTIMPL);
if (dest_mgr->calc_buffer_dimensions)
(*dest_mgr->calc_buffer_dimensions) (&cinfo, dest_mgr);
else
@@ -765,36 +810,79 @@ main(int argc, char **argv)
(*dest_mgr->start_output) (&cinfo, dest_mgr);
cinfo.output_height = tmp;
- /* Process data */
- if ((tmp = jpeg_skip_scanlines(&cinfo, crop_y)) != crop_y) {
- fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
- progname, tmp, crop_y);
- exit(EXIT_FAILURE);
- }
- while (cinfo.output_scanline < crop_y + crop_height) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
- }
- if ((tmp =
- jpeg_skip_scanlines(&cinfo,
- cinfo.output_height - crop_y - crop_height)) !=
- cinfo.output_height - crop_y - crop_height) {
- fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
- progname, tmp, cinfo.output_height - crop_y - crop_height);
- exit(EXIT_FAILURE);
- }
+ if (cinfo.data_precision == 8) {
+ /* Process data */
+ if ((tmp = jpeg_skip_scanlines(&cinfo, crop_y)) != crop_y) {
+ fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
+ progname, tmp, crop_y);
+ exit(EXIT_FAILURE);
+ }
+ while (cinfo.output_scanline < crop_y + crop_height) {
+ num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ if ((tmp =
+ jpeg_skip_scanlines(&cinfo,
+ cinfo.output_height - crop_y - crop_height)) !=
+ cinfo.output_height - crop_y - crop_height) {
+ fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
+ progname, tmp, cinfo.output_height - crop_y - crop_height);
+ exit(EXIT_FAILURE);
+ }
+ } else if (cinfo.data_precision == 12) {
+ /* Process data */
+ if ((tmp = jpeg12_skip_scanlines(&cinfo, crop_y)) != crop_y) {
+ fprintf(stderr, "%s: jpeg12_skip_scanlines() returned %u rather than %u\n",
+ progname, tmp, crop_y);
+ exit(EXIT_FAILURE);
+ }
+ while (cinfo.output_scanline < crop_y + crop_height) {
+ num_scanlines = jpeg12_read_scanlines(&cinfo, dest_mgr->buffer12,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ if ((tmp =
+ jpeg12_skip_scanlines(&cinfo, cinfo.output_height - crop_y -
+ crop_height)) !=
+ cinfo.output_height - crop_y - crop_height) {
+ fprintf(stderr, "%s: jpeg12_skip_scanlines() returned %u rather than %u\n",
+ progname, tmp, cinfo.output_height - crop_y - crop_height);
+ exit(EXIT_FAILURE);
+ }
+ } else
+ ERREXIT(&cinfo, JERR_NOTIMPL);
/* Normal full-image decompress */
} else {
/* Write output file header */
(*dest_mgr->start_output) (&cinfo, dest_mgr);
- /* Process data */
- while (cinfo.output_scanline < cinfo.output_height) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ if (cinfo.data_precision <= 8) {
+ /* Process data */
+ while (cinfo.output_scanline < cinfo.output_height) {
+ num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ } else if (cinfo.data_precision <= 12) {
+ /* Process data */
+ while (cinfo.output_scanline < cinfo.output_height) {
+ num_scanlines = jpeg12_read_scanlines(&cinfo, dest_mgr->buffer12,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ } else {
+#ifdef D_LOSSLESS_SUPPORTED
+ /* Process data */
+ while (cinfo.output_scanline < cinfo.output_height) {
+ num_scanlines = jpeg16_read_scanlines(&cinfo, dest_mgr->buffer16,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+#else
+ ERREXIT1(&cinfo, JERR_BAD_PRECISION, cinfo.data_precision);
+#endif
}
}
diff --git a/contrib/libs/libjpeg-turbo/jaricom.c b/contrib/libs/libjpeg-turbo/src/jaricom.c
index 215640cc446..215640cc446 100644
--- a/contrib/libs/libjpeg-turbo/jaricom.c
+++ b/contrib/libs/libjpeg-turbo/src/jaricom.c
diff --git a/contrib/libs/libjpeg-turbo/jcapimin.c b/contrib/libs/libjpeg-turbo/src/jcapimin.c
index 84e7ecc9a73..e99569035ba 100644
--- a/contrib/libs/libjpeg-turbo/jcapimin.c
+++ b/contrib/libs/libjpeg-turbo/src/jcapimin.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -23,6 +23,7 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jcmaster.h"
/*
@@ -90,8 +91,18 @@ jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
cinfo->input_gamma = 1.0; /* in case application forgets */
+ cinfo->data_precision = BITS_IN_JSAMPLE;
+
/* OK, I'm ready */
cinfo->global_state = CSTATE_START;
+
+ /* The master struct is used to store extension parameters, so we allocate it
+ * here.
+ */
+ cinfo->master = (struct jpeg_comp_master *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
+ sizeof(my_comp_master));
+ memset(cinfo->master, 0, sizeof(my_comp_master));
}
@@ -183,8 +194,26 @@ jpeg_finish_compress(j_compress_ptr cinfo)
/* We bypass the main controller and invoke coef controller directly;
* all work is being done from the coefficient buffer.
*/
- if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
- ERREXIT(cinfo, JERR_CANT_SUSPEND);
+ if (cinfo->data_precision <= 8) {
+ if (cinfo->coef->compress_data == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
+ ERREXIT(cinfo, JERR_CANT_SUSPEND);
+ } else if (cinfo->data_precision <= 12) {
+ if (cinfo->coef->compress_data_12 == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
+ ERREXIT(cinfo, JERR_CANT_SUSPEND);
+ } else {
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->coef->compress_data_16 == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ if (!(*cinfo->coef->compress_data_16) (cinfo, (J16SAMPIMAGE)NULL))
+ ERREXIT(cinfo, JERR_CANT_SUSPEND);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+ }
}
(*cinfo->master->finish_pass) (cinfo);
}
diff --git a/contrib/libs/libjpeg-turbo/jcapistd.c b/contrib/libs/libjpeg-turbo/src/jcapistd.c
index aa2aad9f66c..b61590df9df 100644
--- a/contrib/libs/libjpeg-turbo/jcapistd.c
+++ b/contrib/libs/libjpeg-turbo/src/jcapistd.c
@@ -1,8 +1,10 @@
/*
* jcapistd.c
*
+ * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -18,8 +20,11 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE == 8
+
/*
* Compression initialization.
* Before calling this, all parameters and a data destination must be set up.
@@ -51,13 +56,15 @@ jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
jinit_compress_master(cinfo);
/* Set up for the first pass */
(*cinfo->master->prepare_for_pass) (cinfo);
- /* Ready for application to drive first pass through jpeg_write_scanlines
- * or jpeg_write_raw_data.
+ /* Ready for application to drive first pass through _jpeg_write_scanlines
+ * or _jpeg_write_raw_data.
*/
cinfo->next_scanline = 0;
cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING);
}
+#endif
+
/*
* Write some scanlines of data to the JPEG compressor.
@@ -67,7 +74,7 @@ jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
* the data destination module has requested suspension of the compressor,
* or if more than image_height scanlines are passed in.
*
- * Note: we warn about excess calls to jpeg_write_scanlines() since
+ * Note: we warn about excess calls to _jpeg_write_scanlines() since
* this likely signals an application programmer error. However,
* excess scanlines passed in the last valid call are *silently* ignored,
* so that the application need not adjust num_lines for end-of-image
@@ -75,11 +82,28 @@ jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
*/
GLOBAL(JDIMENSION)
-jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines,
- JDIMENSION num_lines)
+_jpeg_write_scanlines(j_compress_ptr cinfo, _JSAMPARRAY scanlines,
+ JDIMENSION num_lines)
{
+#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
JDIMENSION row_ctr, rows_left;
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
if (cinfo->global_state != CSTATE_SCANNING)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
if (cinfo->next_scanline >= cinfo->image_height)
@@ -93,9 +117,9 @@ jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines,
}
/* Give master control module another chance if this is first call to
- * jpeg_write_scanlines. This lets output of the frame/scan headers be
+ * _jpeg_write_scanlines. This lets output of the frame/scan headers be
* delayed so that application can write COM, etc, markers between
- * jpeg_start_compress and jpeg_write_scanlines.
+ * jpeg_start_compress and _jpeg_write_scanlines.
*/
if (cinfo->master->call_pass_startup)
(*cinfo->master->pass_startup) (cinfo);
@@ -106,23 +130,37 @@ jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines,
num_lines = rows_left;
row_ctr = 0;
- (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines);
+ if (cinfo->main->_process_data == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ (*cinfo->main->_process_data) (cinfo, scanlines, &row_ctr, num_lines);
cinfo->next_scanline += row_ctr;
return row_ctr;
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ return 0;
+#endif
}
+#if BITS_IN_JSAMPLE != 16
+
/*
* Alternate entry point to write raw data.
* Processes exactly one iMCU row per call, unless suspended.
*/
GLOBAL(JDIMENSION)
-jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION num_lines)
+_jpeg_write_raw_data(j_compress_ptr cinfo, _JSAMPIMAGE data,
+ JDIMENSION num_lines)
{
JDIMENSION lines_per_iMCU_row;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+
if (cinfo->global_state != CSTATE_RAW_OK)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
if (cinfo->next_scanline >= cinfo->image_height) {
@@ -138,9 +176,9 @@ jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
}
/* Give master control module another chance if this is first call to
- * jpeg_write_raw_data. This lets output of the frame/scan headers be
+ * _jpeg_write_raw_data. This lets output of the frame/scan headers be
* delayed so that application can write COM, etc, markers between
- * jpeg_start_compress and jpeg_write_raw_data.
+ * jpeg_start_compress and _jpeg_write_raw_data.
*/
if (cinfo->master->call_pass_startup)
(*cinfo->master->pass_startup) (cinfo);
@@ -151,7 +189,9 @@ jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
ERREXIT(cinfo, JERR_BUFFER_SIZE);
/* Directly compress the row. */
- if (!(*cinfo->coef->compress_data) (cinfo, data)) {
+ if (cinfo->coef->_compress_data == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ if (!(*cinfo->coef->_compress_data) (cinfo, data)) {
/* If compressor did not consume the whole row, suspend processing. */
return 0;
}
@@ -160,3 +200,5 @@ jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
cinfo->next_scanline += lines_per_iMCU_row;
return lines_per_iMCU_row;
}
+
+#endif /* BITS_IN_JSAMPLE != 16 */
diff --git a/contrib/libs/libjpeg-turbo/jcarith.c b/contrib/libs/libjpeg-turbo/src/jcarith.c
index b1720521bf5..b1720521bf5 100644
--- a/contrib/libs/libjpeg-turbo/jcarith.c
+++ b/contrib/libs/libjpeg-turbo/src/jcarith.c
diff --git a/contrib/libs/libjpeg-turbo/jccoefct.c b/contrib/libs/libjpeg-turbo/src/jccoefct.c
index 068232a527d..4a47b3cbe5c 100644
--- a/contrib/libs/libjpeg-turbo/jccoefct.c
+++ b/contrib/libs/libjpeg-turbo/src/jccoefct.c
@@ -3,19 +3,20 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code and
- * information relevant to libjpeg-turbo.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains the coefficient buffer controller for compression.
- * This controller is the top level of the JPEG compressor proper.
+ * This controller is the top level of the lossy JPEG compressor proper.
* The coefficient buffer lies between forward-DCT and entropy encoding steps.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
/* We use a full-image coefficient buffer when doing Huffman optimization,
@@ -58,11 +59,12 @@ typedef my_coef_controller *my_coef_ptr;
/* Forward declarations */
-METHODDEF(boolean) compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
+METHODDEF(boolean) compress_data(j_compress_ptr cinfo, _JSAMPIMAGE input_buf);
#ifdef FULL_COEF_BUFFER_SUPPORTED
METHODDEF(boolean) compress_first_pass(j_compress_ptr cinfo,
- JSAMPIMAGE input_buf);
-METHODDEF(boolean) compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
+ _JSAMPIMAGE input_buf);
+METHODDEF(boolean) compress_output(j_compress_ptr cinfo,
+ _JSAMPIMAGE input_buf);
#endif
@@ -106,18 +108,18 @@ start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
case JBUF_PASS_THRU:
if (coef->whole_image[0] != NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- coef->pub.compress_data = compress_data;
+ coef->pub._compress_data = compress_data;
break;
#ifdef FULL_COEF_BUFFER_SUPPORTED
case JBUF_SAVE_AND_PASS:
if (coef->whole_image[0] == NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- coef->pub.compress_data = compress_first_pass;
+ coef->pub._compress_data = compress_first_pass;
break;
case JBUF_CRANK_DEST:
if (coef->whole_image[0] == NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- coef->pub.compress_data = compress_output;
+ coef->pub._compress_data = compress_output;
break;
#endif
default:
@@ -138,7 +140,7 @@ start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
*/
METHODDEF(boolean)
-compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
+compress_data(j_compress_ptr cinfo, _JSAMPIMAGE input_buf)
{
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
JDIMENSION MCU_col_num; /* index of current MCU within row */
@@ -172,10 +174,10 @@ compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
if (coef->iMCU_row_num < last_iMCU_row ||
yoffset + yindex < compptr->last_row_height) {
- (*cinfo->fdct->forward_DCT) (cinfo, compptr,
- input_buf[compptr->component_index],
- coef->MCU_buffer[blkn],
- ypos, xpos, (JDIMENSION)blockcnt);
+ (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
+ input_buf[compptr->component_index],
+ coef->MCU_buffer[blkn],
+ ypos, xpos, (JDIMENSION)blockcnt);
if (blockcnt < compptr->MCU_width) {
/* Create some dummy blocks at the right edge of the image. */
jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
@@ -242,7 +244,7 @@ compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
*/
METHODDEF(boolean)
-compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
+compress_first_pass(j_compress_ptr cinfo, _JSAMPIMAGE input_buf)
{
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
@@ -279,10 +281,10 @@ compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
*/
for (block_row = 0; block_row < block_rows; block_row++) {
thisblockrow = buffer[block_row];
- (*cinfo->fdct->forward_DCT) (cinfo, compptr,
- input_buf[ci], thisblockrow,
- (JDIMENSION)(block_row * DCTSIZE),
- (JDIMENSION)0, blocks_across);
+ (*cinfo->fdct->_forward_DCT) (cinfo, compptr,
+ input_buf[ci], thisblockrow,
+ (JDIMENSION)(block_row * DCTSIZE),
+ (JDIMENSION)0, blocks_across);
if (ndummy > 0) {
/* Create dummy blocks at the right edge of the image. */
thisblockrow += blocks_across; /* => first dummy block */
@@ -338,7 +340,7 @@ compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
*/
METHODDEF(boolean)
-compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
+compress_output(j_compress_ptr cinfo, _JSAMPIMAGE input_buf)
{
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
JDIMENSION MCU_col_num; /* index of current MCU within row */
@@ -402,13 +404,17 @@ compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
*/
GLOBAL(void)
-jinit_c_coef_controller(j_compress_ptr cinfo, boolean need_full_buffer)
+_jinit_c_coef_controller(j_compress_ptr cinfo, boolean need_full_buffer)
{
my_coef_ptr coef;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_coef_controller));
+ memset(coef, 0, sizeof(my_coef_controller));
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
coef->pub.start_pass = start_pass_coef;
diff --git a/contrib/libs/libjpeg-turbo/jccolext.c b/contrib/libs/libjpeg-turbo/src/jccolext.c
index 303b322ce67..8eba36c4dff 100644
--- a/contrib/libs/libjpeg-turbo/jccolext.c
+++ b/contrib/libs/libjpeg-turbo/src/jccolext.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
+ * Copyright (C) 2009-2012, 2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -29,15 +29,16 @@
INLINE
LOCAL(void)
-rgb_ycc_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
+rgb_ycc_convert_internal(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row,
int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int r, g, b;
register JLONG *ctab = cconvert->rgb_ycc_tab;
- register JSAMPROW inptr;
- register JSAMPROW outptr0, outptr1, outptr2;
+ register _JSAMPROW inptr;
+ register _JSAMPROW outptr0, outptr1, outptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
@@ -48,26 +49,29 @@ rgb_ycc_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
outptr2 = output_buf[2][output_row];
output_row++;
for (col = 0; col < num_cols; col++) {
- r = inptr[RGB_RED];
- g = inptr[RGB_GREEN];
- b = inptr[RGB_BLUE];
+ r = RANGE_LIMIT(inptr[RGB_RED]);
+ g = RANGE_LIMIT(inptr[RGB_GREEN]);
+ b = RANGE_LIMIT(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
- /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
+ /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
* must be too; we do not need an explicit range-limiting operation.
* Hence the value being shifted is never negative, and we don't
* need the general RIGHT_SHIFT macro.
*/
/* Y */
- outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
+ outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
+ ctab[b + B_Y_OFF]) >> SCALEBITS);
/* Cb */
- outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
- ctab[b + B_CB_OFF]) >> SCALEBITS);
+ outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
+ ctab[b + B_CB_OFF]) >> SCALEBITS);
/* Cr */
- outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
- ctab[b + B_CR_OFF]) >> SCALEBITS);
+ outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
+ ctab[b + B_CR_OFF]) >> SCALEBITS);
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -83,15 +87,16 @@ rgb_ycc_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
INLINE
LOCAL(void)
-rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
+rgb_gray_convert_internal(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row,
int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int r, g, b;
register JLONG *ctab = cconvert->rgb_ycc_tab;
- register JSAMPROW inptr;
- register JSAMPROW outptr;
+ register _JSAMPROW inptr;
+ register _JSAMPROW outptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
@@ -100,15 +105,18 @@ rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
outptr = output_buf[0][output_row];
output_row++;
for (col = 0; col < num_cols; col++) {
- r = inptr[RGB_RED];
- g = inptr[RGB_GREEN];
- b = inptr[RGB_BLUE];
+ r = RANGE_LIMIT(inptr[RGB_RED]);
+ g = RANGE_LIMIT(inptr[RGB_GREEN]);
+ b = RANGE_LIMIT(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
/* Y */
- outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
+ outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
+ ctab[b + B_Y_OFF]) >> SCALEBITS);
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -119,12 +127,12 @@ rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
INLINE
LOCAL(void)
-rgb_rgb_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row,
+rgb_rgb_convert_internal(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row,
int num_rows)
{
- register JSAMPROW inptr;
- register JSAMPROW outptr0, outptr1, outptr2;
+ register _JSAMPROW inptr;
+ register _JSAMPROW outptr0, outptr1, outptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
diff --git a/contrib/libs/libjpeg-turbo/jccolor.c b/contrib/libs/libjpeg-turbo/src/jccolor.c
index bdc563c723c..c19f6ff4e34 100644
--- a/contrib/libs/libjpeg-turbo/jccolor.c
+++ b/contrib/libs/libjpeg-turbo/src/jccolor.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
+ * Copyright (C) 2009-2012, 2015, 2022, 2024, D. R. Commander.
* Copyright (C) 2014, MIPS Technologies, Inc., California.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -17,16 +17,20 @@
#include "jinclude.h"
#include "jpeglib.h"
#include "jsimd.h"
-#include "jconfigint.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
+
/* Private subobject */
typedef struct {
struct jpeg_color_converter pub; /* public fields */
+#if BITS_IN_JSAMPLE != 16
/* Private state for RGB->YCC conversion */
JLONG *rgb_ycc_tab; /* => table for RGB to YCbCr conversion */
+#endif
} my_color_converter;
typedef my_color_converter *my_cconvert_ptr;
@@ -36,14 +40,14 @@ typedef my_color_converter *my_cconvert_ptr;
/*
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are
- * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
+ * normalized to the range 0.._MAXJSAMPLE rather than -0.5 .. 0.5.
* The conversion equations to be implemented are therefore
* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
- * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
- * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
+ * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + _CENTERJSAMPLE
+ * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + _CENTERJSAMPLE
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
- * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2,
- * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and
+ * Note: older versions of the IJG code used a zero offset of _MAXJSAMPLE/2,
+ * rather than _CENTERJSAMPLE, for Cb and Cr. This gave equal positive and
* negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0)
* were not represented exactly. Now we sacrifice exact representation of
* maximum red and maximum blue in order to get exact grayscales.
@@ -54,16 +58,16 @@ typedef my_color_converter *my_cconvert_ptr;
*
* For even more speed, we avoid doing any multiplications in the inner loop
* by precalculating the constants times R,G,B for all possible values.
- * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
+ * For 8-bit samples this is very reasonable (only 256 entries per table);
* for 12-bit samples it is still acceptable. It's not very reasonable for
* 16-bit samples, but if you want lossless storage you shouldn't be changing
* colorspace anyway.
- * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
+ * The _CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
* in the tables to save adding them separately in the inner loop.
*/
#define SCALEBITS 16 /* speediest right-shift on some machines */
-#define CBCR_OFFSET ((JLONG)CENTERJSAMPLE << SCALEBITS)
+#define CBCR_OFFSET ((JLONG)_CENTERJSAMPLE << SCALEBITS)
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
@@ -74,15 +78,27 @@ typedef my_color_converter *my_cconvert_ptr;
*/
#define R_Y_OFF 0 /* offset to R => Y section */
-#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
-#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
-#define R_CB_OFF (3 * (MAXJSAMPLE + 1))
-#define G_CB_OFF (4 * (MAXJSAMPLE + 1))
-#define B_CB_OFF (5 * (MAXJSAMPLE + 1))
+#define G_Y_OFF (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
+#define B_Y_OFF (2 * (_MAXJSAMPLE + 1)) /* etc. */
+#define R_CB_OFF (3 * (_MAXJSAMPLE + 1))
+#define G_CB_OFF (4 * (_MAXJSAMPLE + 1))
+#define B_CB_OFF (5 * (_MAXJSAMPLE + 1))
#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */
-#define G_CR_OFF (6 * (MAXJSAMPLE + 1))
-#define B_CR_OFF (7 * (MAXJSAMPLE + 1))
-#define TABLE_SIZE (8 * (MAXJSAMPLE + 1))
+#define G_CR_OFF (6 * (_MAXJSAMPLE + 1))
+#define B_CR_OFF (7 * (_MAXJSAMPLE + 1))
+#define TABLE_SIZE (8 * (_MAXJSAMPLE + 1))
+
+/* 12-bit samples use a 16-bit data type, so it is possible to pass
+ * out-of-range sample values (< 0 or > 4095) to jpeg_write_scanlines().
+ * Thus, we mask the incoming 12-bit samples to guard against overrunning
+ * or underrunning the conversion tables.
+ */
+
+#if BITS_IN_JSAMPLE == 12
+#define RANGE_LIMIT(value) ((value) & 0xFFF)
+#else
+#define RANGE_LIMIT(value) (value)
+#endif
/* Include inline routines for colorspace extensions */
@@ -197,6 +213,7 @@ typedef my_color_converter *my_cconvert_ptr;
METHODDEF(void)
rgb_ycc_start(j_compress_ptr cinfo)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
JLONG *rgb_ycc_tab;
JLONG i;
@@ -206,15 +223,15 @@ rgb_ycc_start(j_compress_ptr cinfo)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(TABLE_SIZE * sizeof(JLONG)));
- for (i = 0; i <= MAXJSAMPLE; i++) {
+ for (i = 0; i <= _MAXJSAMPLE; i++) {
rgb_ycc_tab[i + R_Y_OFF] = FIX(0.29900) * i;
rgb_ycc_tab[i + G_Y_OFF] = FIX(0.58700) * i;
rgb_ycc_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
rgb_ycc_tab[i + R_CB_OFF] = (-FIX(0.16874)) * i;
rgb_ycc_tab[i + G_CB_OFF] = (-FIX(0.33126)) * i;
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
- * This ensures that the maximum output will round to MAXJSAMPLE
- * not MAXJSAMPLE+1, and thus that we don't have to range-limit.
+ * This ensures that the maximum output will round to _MAXJSAMPLE
+ * not _MAXJSAMPLE+1, and thus that we don't have to range-limit.
*/
rgb_ycc_tab[i + B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF - 1;
/* B=>Cb and R=>Cr tables are the same
@@ -223,6 +240,9 @@ rgb_ycc_start(j_compress_ptr cinfo)
rgb_ycc_tab[i + G_CR_OFF] = (-FIX(0.41869)) * i;
rgb_ycc_tab[i + B_CR_OFF] = (-FIX(0.08131)) * i;
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -231,8 +251,8 @@ rgb_ycc_start(j_compress_ptr cinfo)
*/
METHODDEF(void)
-rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
+rgb_ycc_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
switch (cinfo->in_color_space) {
case JCS_EXT_RGB:
@@ -279,8 +299,8 @@ rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
*/
METHODDEF(void)
-rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
+rgb_gray_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
switch (cinfo->in_color_space) {
case JCS_EXT_RGB:
@@ -324,8 +344,8 @@ rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
*/
METHODDEF(void)
-rgb_rgb_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
+rgb_rgb_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
switch (cinfo->in_color_space) {
case JCS_EXT_RGB:
@@ -373,14 +393,15 @@ rgb_rgb_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
*/
METHODDEF(void)
-cmyk_ycck_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
+cmyk_ycck_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int r, g, b;
register JLONG *ctab = cconvert->rgb_ycc_tab;
- register JSAMPROW inptr;
- register JSAMPROW outptr0, outptr1, outptr2, outptr3;
+ register _JSAMPROW inptr;
+ register _JSAMPROW outptr0, outptr1, outptr2, outptr3;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
@@ -392,28 +413,31 @@ cmyk_ycck_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
outptr3 = output_buf[3][output_row];
output_row++;
for (col = 0; col < num_cols; col++) {
- r = MAXJSAMPLE - inptr[0];
- g = MAXJSAMPLE - inptr[1];
- b = MAXJSAMPLE - inptr[2];
+ r = _MAXJSAMPLE - RANGE_LIMIT(inptr[0]);
+ g = _MAXJSAMPLE - RANGE_LIMIT(inptr[1]);
+ b = _MAXJSAMPLE - RANGE_LIMIT(inptr[2]);
/* K passes through as-is */
outptr3[col] = inptr[3];
inptr += 4;
- /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
+ /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
* must be too; we do not need an explicit range-limiting operation.
* Hence the value being shifted is never negative, and we don't
* need the general RIGHT_SHIFT macro.
*/
/* Y */
- outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
+ outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
+ ctab[b + B_Y_OFF]) >> SCALEBITS);
/* Cb */
- outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
- ctab[b + B_CB_OFF]) >> SCALEBITS);
+ outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
+ ctab[b + B_CB_OFF]) >> SCALEBITS);
/* Cr */
- outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
- ctab[b + B_CR_OFF]) >> SCALEBITS);
+ outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
+ ctab[b + B_CR_OFF]) >> SCALEBITS);
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -424,11 +448,11 @@ cmyk_ycck_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
*/
METHODDEF(void)
-grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
+grayscale_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
- register JSAMPROW inptr;
- register JSAMPROW outptr;
+ register _JSAMPROW inptr;
+ register _JSAMPROW outptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
int instride = cinfo->input_components;
@@ -452,11 +476,11 @@ grayscale_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf,
*/
METHODDEF(void)
-null_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
- JDIMENSION output_row, int num_rows)
+null_convert(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows)
{
- register JSAMPROW inptr;
- register JSAMPROW outptr, outptr0, outptr1, outptr2, outptr3;
+ register _JSAMPROW inptr;
+ register _JSAMPROW outptr, outptr0, outptr1, outptr2, outptr3;
register JDIMENSION col;
register int ci;
int nc = cinfo->num_components;
@@ -524,10 +548,26 @@ null_method(j_compress_ptr cinfo)
*/
GLOBAL(void)
-jinit_color_converter(j_compress_ptr cinfo)
+_jinit_color_converter(j_compress_ptr cinfo)
{
my_cconvert_ptr cconvert;
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_color_converter));
@@ -574,123 +614,126 @@ jinit_color_converter(j_compress_ptr cinfo)
break;
}
- /* Check num_components, set conversion method based on requested space */
+ /* Check num_components, set conversion method based on requested space.
+ * NOTE: We do not allow any lossy color conversion algorithms in lossless
+ * mode.
+ */
switch (cinfo->jpeg_color_space) {
case JCS_GRAYSCALE:
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless &&
+ cinfo->in_color_space != cinfo->jpeg_color_space)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
if (cinfo->num_components != 1)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_GRAYSCALE)
- cconvert->pub.color_convert = grayscale_convert;
- else if (cinfo->in_color_space == JCS_RGB ||
- cinfo->in_color_space == JCS_EXT_RGB ||
- cinfo->in_color_space == JCS_EXT_RGBX ||
- cinfo->in_color_space == JCS_EXT_BGR ||
- cinfo->in_color_space == JCS_EXT_BGRX ||
- cinfo->in_color_space == JCS_EXT_XBGR ||
- cinfo->in_color_space == JCS_EXT_XRGB ||
- cinfo->in_color_space == JCS_EXT_RGBA ||
- cinfo->in_color_space == JCS_EXT_BGRA ||
- cinfo->in_color_space == JCS_EXT_ABGR ||
- cinfo->in_color_space == JCS_EXT_ARGB) {
+ cconvert->pub._color_convert = grayscale_convert;
+ else if (IsExtRGB(cinfo->in_color_space)) {
+#ifdef WITH_SIMD
if (jsimd_can_rgb_gray())
- cconvert->pub.color_convert = jsimd_rgb_gray_convert;
- else {
+ cconvert->pub._color_convert = jsimd_rgb_gray_convert;
+ else
+#endif
+ {
cconvert->pub.start_pass = rgb_ycc_start;
- cconvert->pub.color_convert = rgb_gray_convert;
+ cconvert->pub._color_convert = rgb_gray_convert;
}
} else if (cinfo->in_color_space == JCS_YCbCr)
- cconvert->pub.color_convert = grayscale_convert;
+ cconvert->pub._color_convert = grayscale_convert;
else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
case JCS_RGB:
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless && !IsExtRGB(cinfo->in_color_space))
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (rgb_red[cinfo->in_color_space] == 0 &&
rgb_green[cinfo->in_color_space] == 1 &&
rgb_blue[cinfo->in_color_space] == 2 &&
rgb_pixelsize[cinfo->in_color_space] == 3) {
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
+ cconvert->pub._color_convert = jsimd_c_null_convert;
else
#endif
- cconvert->pub.color_convert = null_convert;
- } else if (cinfo->in_color_space == JCS_RGB ||
- cinfo->in_color_space == JCS_EXT_RGB ||
- cinfo->in_color_space == JCS_EXT_RGBX ||
- cinfo->in_color_space == JCS_EXT_BGR ||
- cinfo->in_color_space == JCS_EXT_BGRX ||
- cinfo->in_color_space == JCS_EXT_XBGR ||
- cinfo->in_color_space == JCS_EXT_XRGB ||
- cinfo->in_color_space == JCS_EXT_RGBA ||
- cinfo->in_color_space == JCS_EXT_BGRA ||
- cinfo->in_color_space == JCS_EXT_ABGR ||
- cinfo->in_color_space == JCS_EXT_ARGB)
- cconvert->pub.color_convert = rgb_rgb_convert;
+ cconvert->pub._color_convert = null_convert;
+ } else if (IsExtRGB(cinfo->in_color_space))
+ cconvert->pub._color_convert = rgb_rgb_convert;
else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
case JCS_YCbCr:
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless &&
+ cinfo->in_color_space != cinfo->jpeg_color_space)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
- if (cinfo->in_color_space == JCS_RGB ||
- cinfo->in_color_space == JCS_EXT_RGB ||
- cinfo->in_color_space == JCS_EXT_RGBX ||
- cinfo->in_color_space == JCS_EXT_BGR ||
- cinfo->in_color_space == JCS_EXT_BGRX ||
- cinfo->in_color_space == JCS_EXT_XBGR ||
- cinfo->in_color_space == JCS_EXT_XRGB ||
- cinfo->in_color_space == JCS_EXT_RGBA ||
- cinfo->in_color_space == JCS_EXT_BGRA ||
- cinfo->in_color_space == JCS_EXT_ABGR ||
- cinfo->in_color_space == JCS_EXT_ARGB) {
+ if (IsExtRGB(cinfo->in_color_space)) {
+#ifdef WITH_SIMD
if (jsimd_can_rgb_ycc())
- cconvert->pub.color_convert = jsimd_rgb_ycc_convert;
- else {
+ cconvert->pub._color_convert = jsimd_rgb_ycc_convert;
+ else
+#endif
+ {
cconvert->pub.start_pass = rgb_ycc_start;
- cconvert->pub.color_convert = rgb_ycc_convert;
+ cconvert->pub._color_convert = rgb_ycc_convert;
}
} else if (cinfo->in_color_space == JCS_YCbCr) {
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
+ cconvert->pub._color_convert = jsimd_c_null_convert;
else
#endif
- cconvert->pub.color_convert = null_convert;
+ cconvert->pub._color_convert = null_convert;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
case JCS_CMYK:
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless &&
+ cinfo->in_color_space != cinfo->jpeg_color_space)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
if (cinfo->num_components != 4)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_CMYK) {
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
+ cconvert->pub._color_convert = jsimd_c_null_convert;
else
#endif
- cconvert->pub.color_convert = null_convert;
+ cconvert->pub._color_convert = null_convert;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
case JCS_YCCK:
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless &&
+ cinfo->in_color_space != cinfo->jpeg_color_space)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
if (cinfo->num_components != 4)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_CMYK) {
cconvert->pub.start_pass = rgb_ycc_start;
- cconvert->pub.color_convert = cmyk_ycck_convert;
+ cconvert->pub._color_convert = cmyk_ycck_convert;
} else if (cinfo->in_color_space == JCS_YCCK) {
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
+ cconvert->pub._color_convert = jsimd_c_null_convert;
else
#endif
- cconvert->pub.color_convert = null_convert;
+ cconvert->pub._color_convert = null_convert;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
@@ -699,12 +742,14 @@ jinit_color_converter(j_compress_ptr cinfo)
if (cinfo->jpeg_color_space != cinfo->in_color_space ||
cinfo->num_components != cinfo->input_components)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_c_can_null_convert())
- cconvert->pub.color_convert = jsimd_c_null_convert;
+ cconvert->pub._color_convert = jsimd_c_null_convert;
else
#endif
- cconvert->pub.color_convert = null_convert;
+ cconvert->pub._color_convert = null_convert;
break;
}
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jcdctmgr.c b/contrib/libs/libjpeg-turbo/src/jcdctmgr.c
index 7dae17a6e14..dbdbad6a28e 100644
--- a/contrib/libs/libjpeg-turbo/jcdctmgr.c
+++ b/contrib/libs/libjpeg-turbo/src/jcdctmgr.c
@@ -6,7 +6,7 @@
* libjpeg-turbo Modifications:
* Copyright (C) 1999-2006, MIYASAKA Masaru.
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014-2015, D. R. Commander.
+ * Copyright (C) 2011, 2014-2015, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -28,10 +28,10 @@
typedef void (*forward_DCT_method_ptr) (DCTELEM *data);
typedef void (*float_DCT_method_ptr) (FAST_FLOAT *data);
-typedef void (*convsamp_method_ptr) (JSAMPARRAY sample_data,
+typedef void (*convsamp_method_ptr) (_JSAMPARRAY sample_data,
JDIMENSION start_col,
DCTELEM *workspace);
-typedef void (*float_convsamp_method_ptr) (JSAMPARRAY sample_data,
+typedef void (*float_convsamp_method_ptr) (_JSAMPARRAY sample_data,
JDIMENSION start_col,
FAST_FLOAT *workspace);
@@ -114,8 +114,8 @@ flss(UINT16 val)
* Compute values to do a division using reciprocal.
*
* This implementation is based on an algorithm described in
- * "How to optimize for the Pentium family of microprocessors"
- * (http://www.agner.org/assem/).
+ * "Optimizing subroutines in assembly language:
+ * An optimization guide for x86 platforms" (https://agner.org/optimize).
* More information about the basic algorithm can be found in
* the paper "Integer Division Using Reciprocals" by Robert Alverson.
*
@@ -265,10 +265,14 @@ start_pass_fdctmgr(j_compress_ptr cinfo)
dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) {
#if BITS_IN_JSAMPLE == 8
+#ifdef WITH_SIMD
if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&
fdct->quantize == jsimd_quantize)
fdct->quantize = quantize;
#else
+ compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]);
+#endif
+#else
dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
#endif
}
@@ -305,6 +309,7 @@ start_pass_fdctmgr(j_compress_ptr cinfo)
dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) {
#if BITS_IN_JSAMPLE == 8
+#ifdef WITH_SIMD
if (!compute_reciprocal(
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
(JLONG)aanscales[i]),
@@ -312,6 +317,12 @@ start_pass_fdctmgr(j_compress_ptr cinfo)
fdct->quantize == jsimd_quantize)
fdct->quantize = quantize;
#else
+ compute_reciprocal(
+ DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
+ (JLONG)aanscales[i]),
+ CONST_BITS-3), &dtbl[i]);
+#endif
+#else
dtbl[i] = (DCTELEM)
DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
(JLONG)aanscales[i]),
@@ -370,10 +381,10 @@ start_pass_fdctmgr(j_compress_ptr cinfo)
*/
METHODDEF(void)
-convsamp(JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
+convsamp(_JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
{
register DCTELEM *workspaceptr;
- register JSAMPROW elemptr;
+ register _JSAMPROW elemptr;
register int elemr;
workspaceptr = workspace;
@@ -381,19 +392,19 @@ convsamp(JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
elemptr = sample_data[elemr] + start_col;
#if DCTSIZE == 8 /* unroll the inner loop */
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
#else
{
register int elemc;
for (elemc = DCTSIZE; elemc > 0; elemc--)
- *workspaceptr++ = (*elemptr++) - CENTERJSAMPLE;
+ *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
}
#endif
}
@@ -488,7 +499,7 @@ quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
METHODDEF(void)
forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
+ _JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks)
/* This version is used for integer DCT implementations. */
{
@@ -522,30 +533,30 @@ forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr,
#ifdef DCT_FLOAT_SUPPORTED
METHODDEF(void)
-convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col,
+convsamp_float(_JSAMPARRAY sample_data, JDIMENSION start_col,
FAST_FLOAT *workspace)
{
register FAST_FLOAT *workspaceptr;
- register JSAMPROW elemptr;
+ register _JSAMPROW elemptr;
register int elemr;
workspaceptr = workspace;
for (elemr = 0; elemr < DCTSIZE; elemr++) {
elemptr = sample_data[elemr] + start_col;
#if DCTSIZE == 8 /* unroll the inner loop */
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
#else
{
register int elemc;
for (elemc = DCTSIZE; elemc > 0; elemc--)
- *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - CENTERJSAMPLE);
+ *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
}
#endif
}
@@ -577,7 +588,7 @@ quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
METHODDEF(void)
forward_DCT_float(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
+ _JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks)
/* This version is used for floating-point DCT implementations. */
@@ -617,11 +628,14 @@ forward_DCT_float(j_compress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jinit_forward_dct(j_compress_ptr cinfo)
+_jinit_forward_dct(j_compress_ptr cinfo)
{
my_fdct_ptr fdct;
int i;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
fdct = (my_fdct_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_fdct_controller));
@@ -632,28 +646,34 @@ jinit_forward_dct(j_compress_ptr cinfo)
switch (cinfo->dct_method) {
#ifdef DCT_ISLOW_SUPPORTED
case JDCT_ISLOW:
- fdct->pub.forward_DCT = forward_DCT;
+ fdct->pub._forward_DCT = forward_DCT;
+#ifdef WITH_SIMD
if (jsimd_can_fdct_islow())
fdct->dct = jsimd_fdct_islow;
else
- fdct->dct = jpeg_fdct_islow;
+#endif
+ fdct->dct = _jpeg_fdct_islow;
break;
#endif
#ifdef DCT_IFAST_SUPPORTED
case JDCT_IFAST:
- fdct->pub.forward_DCT = forward_DCT;
+ fdct->pub._forward_DCT = forward_DCT;
+#ifdef WITH_SIMD
if (jsimd_can_fdct_ifast())
fdct->dct = jsimd_fdct_ifast;
else
- fdct->dct = jpeg_fdct_ifast;
+#endif
+ fdct->dct = _jpeg_fdct_ifast;
break;
#endif
#ifdef DCT_FLOAT_SUPPORTED
case JDCT_FLOAT:
- fdct->pub.forward_DCT = forward_DCT_float;
+ fdct->pub._forward_DCT = forward_DCT_float;
+#ifdef WITH_SIMD
if (jsimd_can_fdct_float())
fdct->float_dct = jsimd_fdct_float;
else
+#endif
fdct->float_dct = jpeg_fdct_float;
break;
#endif
@@ -671,25 +691,33 @@ jinit_forward_dct(j_compress_ptr cinfo)
case JDCT_IFAST:
#endif
#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
+#ifdef WITH_SIMD
if (jsimd_can_convsamp())
fdct->convsamp = jsimd_convsamp;
else
+#endif
fdct->convsamp = convsamp;
+#ifdef WITH_SIMD
if (jsimd_can_quantize())
fdct->quantize = jsimd_quantize;
else
+#endif
fdct->quantize = quantize;
break;
#endif
#ifdef DCT_FLOAT_SUPPORTED
case JDCT_FLOAT:
+#ifdef WITH_SIMD
if (jsimd_can_convsamp_float())
fdct->float_convsamp = jsimd_convsamp_float;
else
+#endif
fdct->float_convsamp = convsamp_float;
+#ifdef WITH_SIMD
if (jsimd_can_quantize_float())
fdct->float_quantize = jsimd_quantize_float;
else
+#endif
fdct->float_quantize = quantize_float;
break;
#endif
diff --git a/contrib/libs/libjpeg-turbo/src/jcdiffct.c b/contrib/libs/libjpeg-turbo/src/jcdiffct.c
new file mode 100644
index 00000000000..d378202b519
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jcdiffct.c
@@ -0,0 +1,419 @@
+/*
+ * jcdiffct.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1994-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains the difference buffer controller for compression.
+ * This controller is the top level of the lossless JPEG compressor proper.
+ * The difference buffer lies between the prediction/differencing and entropy
+ * encoding steps.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jlossls.h" /* Private declarations for lossless codec */
+
+
+#ifdef C_LOSSLESS_SUPPORTED
+
+/* We use a full-image sample buffer when doing Huffman optimization,
+ * and also for writing multiple-scan JPEG files. In all cases, the
+ * full-image buffer is filled during the first pass, and the scaling,
+ * prediction and differencing steps are run during subsequent passes.
+ */
+#ifdef ENTROPY_OPT_SUPPORTED
+#define FULL_SAMP_BUFFER_SUPPORTED
+#else
+#ifdef C_MULTISCAN_FILES_SUPPORTED
+#define FULL_SAMP_BUFFER_SUPPORTED
+#endif
+#endif
+
+
+/* Private buffer controller object */
+
+typedef struct {
+ struct jpeg_c_coef_controller pub; /* public fields */
+
+ JDIMENSION iMCU_row_num; /* iMCU row # within image */
+ JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
+ int MCU_vert_offset; /* counts MCU rows within iMCU row */
+ int MCU_rows_per_iMCU_row; /* number of such rows needed */
+
+ _JSAMPROW cur_row[MAX_COMPONENTS]; /* row of point-transformed samples */
+ _JSAMPROW prev_row[MAX_COMPONENTS]; /* previous row of Pt'd samples */
+ JDIFFARRAY diff_buf[MAX_COMPONENTS]; /* iMCU row of differences */
+
+ /* In multi-pass modes, we need a virtual sample array for each component. */
+ jvirt_sarray_ptr whole_image[MAX_COMPONENTS];
+} my_diff_controller;
+
+typedef my_diff_controller *my_diff_ptr;
+
+
+/* Forward declarations */
+METHODDEF(boolean) compress_data(j_compress_ptr cinfo, _JSAMPIMAGE input_buf);
+#ifdef FULL_SAMP_BUFFER_SUPPORTED
+METHODDEF(boolean) compress_first_pass(j_compress_ptr cinfo,
+ _JSAMPIMAGE input_buf);
+METHODDEF(boolean) compress_output(j_compress_ptr cinfo,
+ _JSAMPIMAGE input_buf);
+#endif
+
+
+LOCAL(void)
+start_iMCU_row(j_compress_ptr cinfo)
+/* Reset within-iMCU-row counters for a new row */
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+
+ /* In an interleaved scan, an MCU row is the same as an iMCU row.
+ * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
+ * But at the bottom of the image, process only what's left.
+ */
+ if (cinfo->comps_in_scan > 1) {
+ diff->MCU_rows_per_iMCU_row = 1;
+ } else {
+ if (diff->iMCU_row_num < (cinfo->total_iMCU_rows-1))
+ diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
+ else
+ diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
+ }
+
+ diff->mcu_ctr = 0;
+ diff->MCU_vert_offset = 0;
+}
+
+
+/*
+ * Initialize for a processing pass.
+ */
+
+METHODDEF(void)
+start_pass_diff(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+
+ /* Because it is hitching a ride on the jpeg_forward_dct struct,
+ * start_pass_lossless() will be called at the start of the initial pass.
+ * This ensures that it will be called at the start of the Huffman
+ * optimization and output passes as well.
+ */
+ if (pass_mode == JBUF_CRANK_DEST)
+ (*cinfo->fdct->start_pass) (cinfo);
+
+ diff->iMCU_row_num = 0;
+ start_iMCU_row(cinfo);
+
+ switch (pass_mode) {
+ case JBUF_PASS_THRU:
+ if (diff->whole_image[0] != NULL)
+ ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+ diff->pub._compress_data = compress_data;
+ break;
+#ifdef FULL_SAMP_BUFFER_SUPPORTED
+ case JBUF_SAVE_AND_PASS:
+ if (diff->whole_image[0] == NULL)
+ ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+ diff->pub._compress_data = compress_first_pass;
+ break;
+ case JBUF_CRANK_DEST:
+ if (diff->whole_image[0] == NULL)
+ ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+ diff->pub._compress_data = compress_output;
+ break;
+#endif
+ default:
+ ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+ break;
+ }
+}
+
+
+#define SWAP_ROWS(rowa, rowb) { \
+ _JSAMPROW temp = rowa; \
+ rowa = rowb; rowb = temp; \
+}
+
+/*
+ * Process some data in the single-pass case.
+ * We process the equivalent of one fully interleaved MCU row ("iMCU" row)
+ * per call, ie, v_samp_factor rows for each component in the image.
+ * Returns TRUE if the iMCU row is completed, FALSE if suspended.
+ *
+ * NB: input_buf contains a plane for each component in image,
+ * which we index according to the component's SOF position.
+ */
+
+METHODDEF(boolean)
+compress_data(j_compress_ptr cinfo, _JSAMPIMAGE input_buf)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+ lossless_comp_ptr losslessc = (lossless_comp_ptr)cinfo->fdct;
+ JDIMENSION MCU_col_num; /* index of current MCU within row */
+ JDIMENSION MCU_count; /* number of MCUs encoded */
+ JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
+ int ci, compi, yoffset, samp_row, samp_rows, samps_across;
+ jpeg_component_info *compptr;
+
+ /* Loop to write as much as one whole iMCU row */
+ for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row;
+ yoffset++) {
+
+ MCU_col_num = diff->mcu_ctr;
+
+ /* Scale and predict each scanline of the MCU row separately.
+ *
+ * Note: We only do this if we are at the start of an MCU row, ie,
+ * we don't want to reprocess a row suspended by the output.
+ */
+ if (MCU_col_num == 0) {
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ compi = compptr->component_index;
+ if (diff->iMCU_row_num < last_iMCU_row)
+ samp_rows = compptr->v_samp_factor;
+ else {
+ /* NB: can't use last_row_height here, since may not be set! */
+ samp_rows =
+ (int)(compptr->height_in_blocks % compptr->v_samp_factor);
+ if (samp_rows == 0) samp_rows = compptr->v_samp_factor;
+ else {
+ /* Fill dummy difference rows at the bottom edge with zeros, which
+ * will encode to the smallest amount of data.
+ */
+ for (samp_row = samp_rows; samp_row < compptr->v_samp_factor;
+ samp_row++)
+ memset(diff->diff_buf[compi][samp_row], 0,
+ jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor) * sizeof(JDIFF));
+ }
+ }
+ samps_across = compptr->width_in_blocks;
+
+ for (samp_row = 0; samp_row < samp_rows; samp_row++) {
+ (*losslessc->scaler_scale) (cinfo,
+ input_buf[compi][samp_row],
+ diff->cur_row[compi],
+ samps_across);
+ (*losslessc->predict_difference[compi])
+ (cinfo, compi, diff->cur_row[compi], diff->prev_row[compi],
+ diff->diff_buf[compi][samp_row], samps_across);
+ SWAP_ROWS(diff->cur_row[compi], diff->prev_row[compi]);
+ }
+ }
+ }
+ /* Try to write the MCU row (or remaining portion of suspended MCU row). */
+ MCU_count =
+ (*cinfo->entropy->encode_mcus) (cinfo,
+ diff->diff_buf, yoffset, MCU_col_num,
+ cinfo->MCUs_per_row - MCU_col_num);
+ if (MCU_count != cinfo->MCUs_per_row - MCU_col_num) {
+ /* Suspension forced; update state counters and exit */
+ diff->MCU_vert_offset = yoffset;
+ diff->mcu_ctr += MCU_col_num;
+ return FALSE;
+ }
+ /* Completed an MCU row, but perhaps not an iMCU row */
+ diff->mcu_ctr = 0;
+ }
+ /* Completed the iMCU row, advance counters for next one */
+ diff->iMCU_row_num++;
+ start_iMCU_row(cinfo);
+ return TRUE;
+}
+
+
+#ifdef FULL_SAMP_BUFFER_SUPPORTED
+
+/*
+ * Process some data in the first pass of a multi-pass case.
+ * We process the equivalent of one fully interleaved MCU row ("iMCU" row)
+ * per call, ie, v_samp_factor rows for each component in the image.
+ * This amount of data is read from the source buffer and saved into the
+ * virtual arrays.
+ *
+ * We must also emit the data to the compressor. This is conveniently
+ * done by calling compress_output() after we've loaded the current strip
+ * of the virtual arrays.
+ *
+ * NB: input_buf contains a plane for each component in image. All components
+ * are loaded into the virtual arrays in this pass. However, it may be that
+ * only a subset of the components are emitted to the compressor during
+ * this first pass; be careful about looking at the scan-dependent variables
+ * (MCU dimensions, etc).
+ */
+
+METHODDEF(boolean)
+compress_first_pass(j_compress_ptr cinfo, _JSAMPIMAGE input_buf)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+ JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
+ JDIMENSION samps_across;
+ int ci, samp_row, samp_rows;
+ _JSAMPARRAY buffer;
+ jpeg_component_info *compptr;
+
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ /* Align the virtual buffer for this component. */
+ buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
+ ((j_common_ptr)cinfo, diff->whole_image[ci],
+ diff->iMCU_row_num * compptr->v_samp_factor,
+ (JDIMENSION)compptr->v_samp_factor, TRUE);
+
+ /* Count non-dummy sample rows in this iMCU row. */
+ if (diff->iMCU_row_num < last_iMCU_row)
+ samp_rows = compptr->v_samp_factor;
+ else {
+ /* NB: can't use last_row_height here, since may not be set! */
+ samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
+ if (samp_rows == 0) samp_rows = compptr->v_samp_factor;
+ }
+ samps_across = compptr->width_in_blocks;
+
+ /* Perform point transform scaling and prediction/differencing for all
+ * non-dummy rows in this iMCU row. Each call on these functions
+ * processes a complete row of samples.
+ */
+ for (samp_row = 0; samp_row < samp_rows; samp_row++) {
+ memcpy(buffer[samp_row], input_buf[ci][samp_row],
+ samps_across * sizeof(_JSAMPLE));
+ }
+ }
+ /* NB: compress_output will increment iMCU_row_num if successful.
+ * A suspension return will result in redoing all the work above next time.
+ */
+
+ /* Emit data to the compressor, sharing code with subsequent passes */
+ return compress_output(cinfo, input_buf);
+}
+
+
+/*
+ * Process some data in subsequent passes of a multi-pass case.
+ * We process the equivalent of one fully interleaved MCU row ("iMCU" row)
+ * per call, ie, v_samp_factor rows for each component in the scan.
+ * The data is obtained from the virtual arrays and fed to the compressor.
+ * Returns TRUE if the iMCU row is completed, FALSE if suspended.
+ *
+ * NB: input_buf is ignored; it is likely to be a NULL pointer.
+ */
+
+METHODDEF(boolean)
+compress_output(j_compress_ptr cinfo, _JSAMPIMAGE input_buf)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+ int ci, compi;
+ _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN];
+ jpeg_component_info *compptr;
+
+ /* Align the virtual buffers for the components used in this scan.
+ * NB: during first pass, this is safe only because the buffers will
+ * already be aligned properly, so jmemmgr.c won't need to do any I/O.
+ */
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ compi = compptr->component_index;
+ buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
+ ((j_common_ptr)cinfo, diff->whole_image[compi],
+ diff->iMCU_row_num * compptr->v_samp_factor,
+ (JDIMENSION)compptr->v_samp_factor, FALSE);
+ }
+
+ return compress_data(cinfo, buffer);
+}
+
+#endif /* FULL_SAMP_BUFFER_SUPPORTED */
+
+
+/*
+ * Initialize difference buffer controller.
+ */
+
+GLOBAL(void)
+_jinit_c_diff_controller(j_compress_ptr cinfo, boolean need_full_buffer)
+{
+ my_diff_ptr diff;
+ int ci, row;
+ jpeg_component_info *compptr;
+
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ diff = (my_diff_ptr)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ sizeof(my_diff_controller));
+ cinfo->coef = (struct jpeg_c_coef_controller *)diff;
+ diff->pub.start_pass = start_pass_diff;
+
+ /* Create the prediction row buffers. */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ diff->cur_row[ci] = *(_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
+ ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ (JDIMENSION)jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor),
+ (JDIMENSION)1);
+ diff->prev_row[ci] = *(_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
+ ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ (JDIMENSION)jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor),
+ (JDIMENSION)1);
+ }
+
+ /* Create the difference buffer. */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ diff->diff_buf[ci] =
+ ALLOC_DARRAY(JPOOL_IMAGE,
+ (JDIMENSION)jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor),
+ (JDIMENSION)compptr->v_samp_factor);
+ /* Prefill difference rows with zeros. We do this because only actual
+ * data is placed in the buffers during prediction/differencing, leaving
+ * any dummy differences at the right edge as zeros, which will encode
+ * to the smallest amount of data.
+ */
+ for (row = 0; row < compptr->v_samp_factor; row++)
+ memset(diff->diff_buf[ci][row], 0,
+ jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor) * sizeof(JDIFF));
+ }
+
+ /* Create the sample buffer. */
+ if (need_full_buffer) {
+#ifdef FULL_SAMP_BUFFER_SUPPORTED
+ /* Allocate a full-image virtual array for each component, */
+ /* padded to a multiple of samp_factor differences in each direction. */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
+ ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
+ (JDIMENSION)jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor),
+ (JDIMENSION)jround_up((long)compptr->height_in_blocks,
+ (long)compptr->v_samp_factor),
+ (JDIMENSION)compptr->v_samp_factor);
+ }
+#else
+ ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+#endif
+ } else
+ diff->whole_image[0] = NULL; /* flag for no virtual arrays */
+}
+
+#endif /* C_LOSSLESS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jchuff.c b/contrib/libs/libjpeg-turbo/src/jchuff.c
index f4dfa1cb540..8cdd5bd35dc 100644
--- a/contrib/libs/libjpeg-turbo/jchuff.c
+++ b/contrib/libs/libjpeg-turbo/src/jchuff.c
@@ -3,11 +3,14 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2014-2016, 2018-2022, D. R. Commander.
+ * Copyright (C) 2009-2011, 2014-2016, 2018-2024, D. R. Commander.
* Copyright (C) 2015, Matthieu Darbois.
* Copyright (C) 2018, Matthias Räncker.
* Copyright (C) 2020, Arm Limited.
+ * Copyright (C) 2022, Felix Hanau.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -26,44 +29,13 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#ifdef WITH_SIMD
#include "jsimd.h"
-#include "jconfigint.h"
-#include <limits.h>
-
-/*
- * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
- * used for bit counting rather than the lookup table. This will reduce the
- * memory footprint by 64k, which is important for some mobile applications
- * that create many isolated instances of libjpeg-turbo (web browsers, for
- * instance.) This may improve performance on some mobile platforms as well.
- * This feature is enabled by default only on Arm processors, because some x86
- * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
- * shown to have a significant performance impact even on the x86 chips that
- * have a fast implementation of it. When building for Armv6, you can
- * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
- * flags (this defines __thumb__).
- */
-
-/* NOTE: Both GCC and Clang define __GNUC__ */
-#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
- defined(_M_ARM) || defined(_M_ARM64)
-#if !defined(__thumb__) || defined(__thumb2__)
-#define USE_CLZ_INTRINSIC
-#endif
-#endif
-
-#ifdef USE_CLZ_INTRINSIC
-#if defined(_MSC_VER) && !defined(__clang__)
-#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
#else
-#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
-#endif
-#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
-#else
-#include "jpeg_nbits_table.h"
-#define JPEG_NBITS(x) (jpeg_nbits_table[x])
-#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
+#include "jchuff.h" /* Declarations shared with jc*huff.c */
#endif
+#include <limits.h>
+#include "jpeg_nbits.h"
/* Expanded entropy encoder object for Huffman encoding.
@@ -102,7 +74,9 @@ typedef bit_buf_type simd_bit_buf_type;
typedef struct {
union {
bit_buf_type c;
+#ifdef WITH_SIMD
simd_bit_buf_type simd;
+#endif
} put_buffer; /* current bit accumulation buffer */
int free_bits; /* # of bits available in it */
/* (Neon GAS: # of bits now in it) */
@@ -127,7 +101,9 @@ typedef struct {
long *ac_count_ptrs[NUM_HUFF_TBLS];
#endif
+#ifdef WITH_SIMD
int simd;
+#endif
} huff_entropy_encoder;
typedef huff_entropy_encoder *huff_entropy_ptr;
@@ -141,7 +117,9 @@ typedef struct {
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
savable_state cur; /* Current bit buffer & DC state */
j_compress_ptr cinfo; /* dump_buffer needs access to this */
+#ifdef WITH_SIMD
int simd;
+#endif
} working_state;
@@ -180,7 +158,9 @@ start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
entropy->pub.finish_pass = finish_pass_huff;
}
+#ifdef WITH_SIMD
entropy->simd = jsimd_can_huff_encode_one_block();
+#endif
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
@@ -220,6 +200,7 @@ start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
}
/* Initialize bit buffer to empty */
+#ifdef WITH_SIMD
if (entropy->simd) {
entropy->saved.put_buffer.simd = 0;
#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
@@ -227,7 +208,9 @@ start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
#else
entropy->saved.free_bits = SIMD_BIT_BUF_SIZE;
#endif
- } else {
+ } else
+#endif
+ {
entropy->saved.put_buffer.c = 0;
entropy->saved.free_bits = BIT_BUF_SIZE;
}
@@ -242,7 +225,7 @@ start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
* Compute the derived values for a Huffman table.
* This routine also performs some validation checks on the table.
*
- * Note this is also used by jcphuff.c.
+ * Note this is also used by jcphuff.c and jclhuff.c.
*/
GLOBAL(void)
@@ -318,12 +301,12 @@ jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno,
memset(dtbl->ehufco, 0, sizeof(dtbl->ehufco));
memset(dtbl->ehufsi, 0, sizeof(dtbl->ehufsi));
- /* This is also a convenient place to check for out-of-range
- * and duplicated VAL entries. We allow 0..255 for AC symbols
- * but only 0..15 for DC. (We could constrain them further
- * based on data depth and mode, but this seems enough.)
+ /* This is also a convenient place to check for out-of-range and duplicated
+ * VAL entries. We allow 0..255 for AC symbols but only 0..15 for DC in
+ * lossy mode and 0..16 for DC in lossless mode. (We could constrain them
+ * further based on data depth and mode, but this seems enough.)
*/
- maxsymbol = isDC ? 15 : 255;
+ maxsymbol = isDC ? (cinfo->master->lossless ? 16 : 15) : 255;
for (p = 0; p < lastp; p++) {
i = htbl->huffval[p];
@@ -500,6 +483,7 @@ flush_bits(working_state *state)
simd_bit_buf_type put_buffer; int put_bits;
int localbuf = 0;
+#ifdef WITH_SIMD
if (state->simd) {
#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
put_bits = state->cur.free_bits;
@@ -507,7 +491,9 @@ flush_bits(working_state *state)
put_bits = SIMD_BIT_BUF_SIZE - state->cur.free_bits;
#endif
put_buffer = state->cur.put_buffer.simd;
- } else {
+ } else
+#endif
+ {
put_bits = BIT_BUF_SIZE - state->cur.free_bits;
put_buffer = state->cur.put_buffer.c;
}
@@ -525,6 +511,7 @@ flush_bits(working_state *state)
EMIT_BYTE(temp)
}
+#ifdef WITH_SIMD
if (state->simd) { /* and reset bit buffer to empty */
state->cur.put_buffer.simd = 0;
#if defined(__aarch64__) && !defined(NEON_INTRINSICS)
@@ -532,7 +519,9 @@ flush_bits(working_state *state)
#else
state->cur.free_bits = SIMD_BIT_BUF_SIZE;
#endif
- } else {
+ } else
+#endif
+ {
state->cur.put_buffer.c = 0;
state->cur.free_bits = BIT_BUF_SIZE;
}
@@ -542,6 +531,8 @@ flush_bits(working_state *state)
}
+#ifdef WITH_SIMD
+
/* Encode a single block's worth of coefficients */
LOCAL(boolean)
@@ -551,6 +542,10 @@ encode_one_block_simd(working_state *state, JCOEFPTR block, int last_dc_val,
JOCTET _buffer[BUFSIZE], *buffer;
int localbuf = 0;
+#ifdef ZERO_BUFFERS
+ memset(_buffer, 0, sizeof(_buffer));
+#endif
+
LOAD_BUFFER()
buffer = jsimd_huff_encode_one_block(state, buffer, block, last_dc_val,
@@ -561,6 +556,8 @@ encode_one_block_simd(working_state *state, JCOEFPTR block, int last_dc_val,
return TRUE;
}
+#endif
+
LOCAL(boolean)
encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val,
c_derived_tbl *dctbl, c_derived_tbl *actbl)
@@ -569,6 +566,7 @@ encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val,
bit_buf_type put_buffer;
JOCTET _buffer[BUFSIZE], *buffer;
int localbuf = 0;
+ int max_coef_bits = state->cinfo->data_precision + 2;
free_bits = state->cur.free_bits;
put_buffer = state->cur.put_buffer.c;
@@ -589,6 +587,11 @@ encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val,
/* Find the number of bits needed for the magnitude of the coefficient */
nbits = JPEG_NBITS(nbits);
+ /* Check for out-of-range coefficient values.
+ * Since we're encoding a difference, the range limit is twice as much.
+ */
+ if (nbits > max_coef_bits + 1)
+ ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
/* Emit the Huffman-coded symbol for the number of bits.
* Emit that number of bits of the value, if positive,
@@ -614,6 +617,9 @@ encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val,
temp += nbits; \
nbits ^= temp; \
nbits = JPEG_NBITS_NONZERO(nbits); \
+ /* Check for out-of-range coefficient values */ \
+ if (nbits > max_coef_bits) \
+ ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); \
/* if run length > 15, must emit special run-length-16 codes (0xF0) */ \
while (r >= 16 * 16) { \
r -= 16 * 16; \
@@ -695,7 +701,9 @@ encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
state.free_in_buffer = cinfo->dest->free_in_buffer;
state.cur = entropy->saved;
state.cinfo = cinfo;
+#ifdef WITH_SIMD
state.simd = entropy->simd;
+#endif
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
@@ -705,6 +713,7 @@ encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
}
/* Encode the MCU data blocks */
+#ifdef WITH_SIMD
if (entropy->simd) {
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
ci = cinfo->MCU_membership[blkn];
@@ -717,7 +726,9 @@ encode_mcu_huff(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
/* Update last_dc_val */
state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
}
- } else {
+ } else
+#endif
+ {
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
ci = cinfo->MCU_membership[blkn];
compptr = cinfo->cur_comp_info[ci];
@@ -765,7 +776,9 @@ finish_pass_huff(j_compress_ptr cinfo)
state.free_in_buffer = cinfo->dest->free_in_buffer;
state.cur = entropy->saved;
state.cinfo = cinfo;
+#ifdef WITH_SIMD
state.simd = entropy->simd;
+#endif
/* Flush out the last data */
if (!flush_bits(&state))
@@ -801,6 +814,7 @@ htest_one_block(j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
register int temp;
register int nbits;
register int k, r;
+ int max_coef_bits = cinfo->data_precision + 2;
/* Encode the DC coefficient difference per section F.1.2.1 */
@@ -817,7 +831,7 @@ htest_one_block(j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
/* Check for out-of-range coefficient values.
* Since we're encoding a difference, the range limit is twice as much.
*/
- if (nbits > MAX_COEF_BITS + 1)
+ if (nbits > max_coef_bits + 1)
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
/* Count the Huffman symbol for the number of bits */
@@ -846,7 +860,7 @@ htest_one_block(j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
while ((temp >>= 1))
nbits++;
/* Check for out-of-range coefficient values */
- if (nbits > MAX_COEF_BITS)
+ if (nbits > max_coef_bits)
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
/* Count Huffman symbol for run length / number of bits */
@@ -901,7 +915,7 @@ encode_mcu_gather(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
/*
* Generate the best Huffman code table for the given counts, fill htbl.
- * Note this is also used by jcphuff.c.
+ * Note this is also used by jcphuff.c and jclhuff.c.
*
* The JPEG standard requires that no symbol be assigned a codeword of all
* one bits (so that padding bits added at the end of a compressed segment
@@ -933,11 +947,15 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
{
#define MAX_CLEN 32 /* assumed maximum initial code length */
UINT8 bits[MAX_CLEN + 1]; /* bits[k] = # of symbols with code length k */
+ int bit_pos[MAX_CLEN + 1]; /* # of symbols with smaller code length */
int codesize[257]; /* codesize[k] = code length of symbol k */
+ int nz_index[257]; /* index of nonzero symbol in the original freq
+ array */
int others[257]; /* next symbol in current branch of tree */
int c1, c2;
int p, i, j;
- long v;
+ int num_nz_symbols;
+ long v, v2;
/* This algorithm is explained in section K.2 of the JPEG standard */
@@ -952,28 +970,41 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
* will be placed last in the largest codeword category.
*/
+ /* Group nonzero frequencies together so we can more easily find the
+ * smallest.
+ */
+ num_nz_symbols = 0;
+ for (i = 0; i < 257; i++) {
+ if (freq[i]) {
+ nz_index[num_nz_symbols] = i;
+ freq[num_nz_symbols] = freq[i];
+ num_nz_symbols++;
+ }
+ }
+
/* Huffman's basic algorithm to assign optimal code lengths to symbols */
for (;;) {
- /* Find the smallest nonzero frequency, set c1 = its symbol */
- /* In case of ties, take the larger symbol number */
+ /* Find the two smallest nonzero frequencies; set c1, c2 = their symbols */
+ /* In case of ties, take the larger symbol number. Since we have grouped
+ * the nonzero symbols together, checking for zero symbols is not
+ * necessary.
+ */
c1 = -1;
- v = 1000000000L;
- for (i = 0; i <= 256; i++) {
- if (freq[i] && freq[i] <= v) {
- v = freq[i];
- c1 = i;
- }
- }
-
- /* Find the next smallest nonzero frequency, set c2 = its symbol */
- /* In case of ties, take the larger symbol number */
c2 = -1;
v = 1000000000L;
- for (i = 0; i <= 256; i++) {
- if (freq[i] && freq[i] <= v && i != c1) {
- v = freq[i];
- c2 = i;
+ v2 = 1000000000L;
+ for (i = 0; i < num_nz_symbols; i++) {
+ if (freq[i] <= v2) {
+ if (freq[i] <= v) {
+ c2 = c1;
+ v2 = v;
+ v = freq[i];
+ c1 = i;
+ } else {
+ v2 = freq[i];
+ c2 = i;
+ }
}
}
@@ -983,7 +1014,10 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
/* Else merge the two counts/trees */
freq[c1] += freq[c2];
- freq[c2] = 0;
+ /* Set the frequency to a very high value instead of zero, so we don't have
+ * to check for zero values.
+ */
+ freq[c2] = 1000000001L;
/* Increment the codesize of everything in c1's tree branch */
codesize[c1]++;
@@ -1003,15 +1037,24 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
}
/* Now count the number of symbols of each code length */
- for (i = 0; i <= 256; i++) {
- if (codesize[i]) {
- /* The JPEG standard seems to think that this can't happen, */
- /* but I'm paranoid... */
- if (codesize[i] > MAX_CLEN)
- ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
-
- bits[codesize[i]]++;
- }
+ for (i = 0; i < num_nz_symbols; i++) {
+ /* The JPEG standard seems to think that this can't happen, */
+ /* but I'm paranoid... */
+ if (codesize[i] > MAX_CLEN)
+ ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
+
+ bits[codesize[i]]++;
+ }
+
+ /* Count the number of symbols with a length smaller than i bits, so we can
+ * construct the symbol table more efficiently. Note that this includes the
+ * pseudo-symbol 256, but since it is the last symbol, it will not affect the
+ * table.
+ */
+ p = 0;
+ for (i = 1; i <= MAX_CLEN; i++) {
+ bit_pos[i] = p;
+ p += bits[i];
}
/* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure
@@ -1051,14 +1094,9 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
* changes made above, but Rec. ITU-T T.81 | ISO/IEC 10918-1 seems to think
* this works.
*/
- p = 0;
- for (i = 1; i <= MAX_CLEN; i++) {
- for (j = 0; j <= 255; j++) {
- if (codesize[j] == i) {
- htbl->huffval[p] = (UINT8)j;
- p++;
- }
- }
+ for (i = 0; i < num_nz_symbols - 1; i++) {
+ htbl->huffval[bit_pos[codesize[i]]] = (UINT8)nz_index[i];
+ bit_pos[codesize[i]]++;
}
/* Set sent_table FALSE so updated table will be written to JPEG file. */
diff --git a/contrib/libs/libjpeg-turbo/jchuff.h b/contrib/libs/libjpeg-turbo/src/jchuff.h
index 314a2325c9e..21f17b89b09 100644
--- a/contrib/libs/libjpeg-turbo/jchuff.h
+++ b/contrib/libs/libjpeg-turbo/src/jchuff.h
@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -19,11 +19,13 @@
* Hence the magnitude should always fit in 10 or 14 bits respectively.
*/
-#if BITS_IN_JSAMPLE == 8
-#define MAX_COEF_BITS 10
-#else
-#define MAX_COEF_BITS 14
-#endif
+/* The progressive Huffman encoder uses an unsigned 16-bit data type to store
+ * absolute values of coefficients, because it is possible to inject a
+ * coefficient value of -32768 into the encoder by attempting to transform a
+ * malformed 12-bit JPEG image, and the absolute value of -32768 would overflow
+ * a signed 16-bit integer.
+ */
+typedef unsigned short UJCOEF;
/* Derived data constructed for each Huffman table */
diff --git a/contrib/libs/libjpeg-turbo/jcicc.c b/contrib/libs/libjpeg-turbo/src/jcicc.c
index 11037ff6941..11037ff6941 100644
--- a/contrib/libs/libjpeg-turbo/jcicc.c
+++ b/contrib/libs/libjpeg-turbo/src/jcicc.c
diff --git a/contrib/libs/libjpeg-turbo/src/jcinit.c b/contrib/libs/libjpeg-turbo/src/jcinit.c
new file mode 100644
index 00000000000..09ff6b3e43e
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jcinit.c
@@ -0,0 +1,149 @@
+/*
+ * jcinit.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2020, 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains initialization logic for the JPEG compressor.
+ * This routine is in charge of selecting the modules to be executed and
+ * making an initialization call to each one.
+ *
+ * Logically, this code belongs in jcmaster.c. It's split out because
+ * linking this routine implies linking the entire compression library.
+ * For a transcoding-only application, we want to be able to use jcmaster.c
+ * without linking in the whole library.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jpegapicomp.h"
+
+
+/*
+ * Master selection of compression modules.
+ * This is done once at the start of processing an image. We determine
+ * which modules will be used and give them appropriate initialization calls.
+ */
+
+GLOBAL(void)
+jinit_compress_master(j_compress_ptr cinfo)
+{
+ /* Initialize master control (includes parameter checking/processing) */
+ jinit_c_master_control(cinfo, FALSE /* full compression */);
+
+ /* Preprocessing */
+ if (!cinfo->raw_data_in) {
+ if (cinfo->data_precision <= 8) {
+ jinit_color_converter(cinfo);
+ jinit_downsampler(cinfo);
+ jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
+ } else if (cinfo->data_precision <= 12) {
+ j12init_color_converter(cinfo);
+ j12init_downsampler(cinfo);
+ j12init_c_prep_controller(cinfo,
+ FALSE /* never need full buffer here */);
+ } else {
+#ifdef C_LOSSLESS_SUPPORTED
+ j16init_color_converter(cinfo);
+ j16init_downsampler(cinfo);
+ j16init_c_prep_controller(cinfo,
+ FALSE /* never need full buffer here */);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+ }
+ }
+
+ if (cinfo->master->lossless) {
+#ifdef C_LOSSLESS_SUPPORTED
+ /* Prediction, sample differencing, and point transform */
+ if (cinfo->data_precision <= 8)
+ jinit_lossless_compressor(cinfo);
+ else if (cinfo->data_precision <= 12)
+ j12init_lossless_compressor(cinfo);
+ else
+ j16init_lossless_compressor(cinfo);
+ /* Entropy encoding: either Huffman or arithmetic coding. */
+ if (cinfo->arith_code) {
+ ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
+ } else {
+ jinit_lhuff_encoder(cinfo);
+ }
+
+ /* Need a full-image difference buffer in any multi-pass mode. */
+ if (cinfo->data_precision <= 8)
+ jinit_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
+ cinfo->optimize_coding));
+ else if (cinfo->data_precision <= 12)
+ j12init_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
+ cinfo->optimize_coding));
+ else
+ j16init_c_diff_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
+ cinfo->optimize_coding));
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ } else {
+ /* Forward DCT */
+ if (cinfo->data_precision == 8)
+ jinit_forward_dct(cinfo);
+ else if (cinfo->data_precision == 12)
+ j12init_forward_dct(cinfo);
+ else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ /* Entropy encoding: either Huffman or arithmetic coding. */
+ if (cinfo->arith_code) {
+#ifdef C_ARITH_CODING_SUPPORTED
+ jinit_arith_encoder(cinfo);
+#else
+ ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
+#endif
+ } else {
+ if (cinfo->progressive_mode) {
+#ifdef C_PROGRESSIVE_SUPPORTED
+ jinit_phuff_encoder(cinfo);
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ } else
+ jinit_huff_encoder(cinfo);
+ }
+
+ /* Need a full-image coefficient buffer in any multi-pass mode. */
+ if (cinfo->data_precision == 12)
+ j12init_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
+ cinfo->optimize_coding));
+ else
+ jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
+ cinfo->optimize_coding));
+ }
+
+ if (cinfo->data_precision <= 8)
+ jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
+ else if (cinfo->data_precision <= 12)
+ j12init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
+ else
+#ifdef C_LOSSLESS_SUPPORTED
+ j16init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+
+ jinit_marker_writer(cinfo);
+
+ /* We can now tell the memory manager to allocate virtual arrays. */
+ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
+
+ /* Write the datastream header (SOI) immediately.
+ * Frame and scan headers are postponed till later.
+ * This lets application insert special markers after the SOI.
+ */
+ (*cinfo->marker->write_file_header) (cinfo);
+}
diff --git a/contrib/libs/libjpeg-turbo/src/jclhuff.c b/contrib/libs/libjpeg-turbo/src/jclhuff.c
new file mode 100644
index 00000000000..ae4154532ed
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jclhuff.c
@@ -0,0 +1,587 @@
+/*
+ * jclhuff.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains Huffman entropy encoding routines for lossless JPEG.
+ *
+ * Much of the complexity here has to do with supporting output suspension.
+ * If the data destination module demands suspension, we want to be able to
+ * back up to the start of the current MCU. To do this, we copy state
+ * variables into local working storage, and update them back to the
+ * permanent JPEG objects only upon successful completion of an MCU.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jlossls.h" /* Private declarations for lossless codec */
+#include "jchuff.h" /* Declarations shared with jc*huff.c */
+
+
+#ifdef C_LOSSLESS_SUPPORTED
+
+/* The legal range of a spatial difference is
+ * -32767 .. +32768.
+ * Hence the magnitude should always fit in 16 bits.
+ */
+
+#define MAX_DIFF_BITS 16
+
+
+/* Expanded entropy encoder object for Huffman encoding in lossless mode.
+ *
+ * The savable_state subrecord contains fields that change within an MCU,
+ * but must not be updated permanently until we complete the MCU.
+ */
+
+typedef struct {
+ size_t put_buffer; /* current bit-accumulation buffer */
+ int put_bits; /* # of bits now in it */
+} savable_state;
+
+
+typedef struct {
+ int ci, yoffset, MCU_width;
+} lhe_input_ptr_info;
+
+
+typedef struct {
+ struct jpeg_entropy_encoder pub; /* public fields */
+
+ savable_state saved; /* Bit buffer at start of MCU */
+
+ /* These fields are NOT loaded into local working state. */
+ unsigned int restarts_to_go; /* MCUs left in this restart interval */
+ int next_restart_num; /* next restart number to write (0-7) */
+
+ /* Pointers to derived tables (these workspaces have image lifespan) */
+ c_derived_tbl *derived_tbls[NUM_HUFF_TBLS];
+
+ /* Pointers to derived tables to be used for each data unit within an MCU */
+ c_derived_tbl *cur_tbls[C_MAX_BLOCKS_IN_MCU];
+
+#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */
+ long *count_ptrs[NUM_HUFF_TBLS];
+
+ /* Pointers to stats tables to be used for each data unit within an MCU */
+ long *cur_counts[C_MAX_BLOCKS_IN_MCU];
+#endif
+
+ /* Pointers to the proper input difference row for each group of data units
+ * within an MCU. For each component, there are Vi groups of Hi data units.
+ */
+ JDIFFROW input_ptr[C_MAX_BLOCKS_IN_MCU];
+
+ /* Number of input pointers in use for the current MCU. This is the sum
+ * of all Vi in the MCU.
+ */
+ int num_input_ptrs;
+
+ /* Information used for positioning the input pointers within the input
+ * difference rows.
+ */
+ lhe_input_ptr_info input_ptr_info[C_MAX_BLOCKS_IN_MCU];
+
+ /* Index of the proper input pointer for each data unit within an MCU */
+ int input_ptr_index[C_MAX_BLOCKS_IN_MCU];
+
+} lhuff_entropy_encoder;
+
+typedef lhuff_entropy_encoder *lhuff_entropy_ptr;
+
+/* Working state while writing an MCU.
+ * This struct contains all the fields that are needed by subroutines.
+ */
+
+typedef struct {
+ JOCTET *next_output_byte; /* => next byte to write in buffer */
+ size_t free_in_buffer; /* # of byte spaces remaining in buffer */
+ savable_state cur; /* Current bit buffer & DC state */
+ j_compress_ptr cinfo; /* dump_buffer needs access to this */
+} working_state;
+
+
+/* Forward declarations */
+METHODDEF(JDIMENSION) encode_mcus_huff(j_compress_ptr cinfo,
+ JDIFFIMAGE diff_buf,
+ JDIMENSION MCU_row_num,
+ JDIMENSION MCU_col_num,
+ JDIMENSION nMCU);
+METHODDEF(void) finish_pass_huff(j_compress_ptr cinfo);
+#ifdef ENTROPY_OPT_SUPPORTED
+METHODDEF(JDIMENSION) encode_mcus_gather(j_compress_ptr cinfo,
+ JDIFFIMAGE diff_buf,
+ JDIMENSION MCU_row_num,
+ JDIMENSION MCU_col_num,
+ JDIMENSION nMCU);
+METHODDEF(void) finish_pass_gather(j_compress_ptr cinfo);
+#endif
+
+
+/*
+ * Initialize for a Huffman-compressed scan.
+ * If gather_statistics is TRUE, we do not output anything during the scan,
+ * just count the Huffman symbols used and generate Huffman code tables.
+ */
+
+METHODDEF(void)
+start_pass_lhuff(j_compress_ptr cinfo, boolean gather_statistics)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+ int ci, dctbl, sampn, ptrn, yoffset, xoffset;
+ jpeg_component_info *compptr;
+
+ if (gather_statistics) {
+#ifdef ENTROPY_OPT_SUPPORTED
+ entropy->pub.encode_mcus = encode_mcus_gather;
+ entropy->pub.finish_pass = finish_pass_gather;
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ } else {
+ entropy->pub.encode_mcus = encode_mcus_huff;
+ entropy->pub.finish_pass = finish_pass_huff;
+ }
+
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ dctbl = compptr->dc_tbl_no;
+ if (gather_statistics) {
+#ifdef ENTROPY_OPT_SUPPORTED
+ /* Check for invalid table indexes */
+ /* (make_c_derived_tbl does this in the other path) */
+ if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS)
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);
+ /* Allocate and zero the statistics tables */
+ /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
+ if (entropy->count_ptrs[dctbl] == NULL)
+ entropy->count_ptrs[dctbl] = (long *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ 257 * sizeof(long));
+ memset(entropy->count_ptrs[dctbl], 0, 257 * sizeof(long));
+#endif
+ } else {
+ /* Compute derived values for Huffman tables */
+ /* We may do this more than once for a table, but it's not expensive */
+ jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl,
+ &entropy->derived_tbls[dctbl]);
+ }
+ }
+
+ /* Precalculate encoding info for each sample in an MCU of this scan */
+ for (sampn = 0, ptrn = 0; sampn < cinfo->blocks_in_MCU;) {
+ compptr = cinfo->cur_comp_info[cinfo->MCU_membership[sampn]];
+ ci = compptr->component_index;
+ for (yoffset = 0; yoffset < compptr->MCU_height; yoffset++, ptrn++) {
+ /* Precalculate the setup info for each input pointer */
+ entropy->input_ptr_info[ptrn].ci = ci;
+ entropy->input_ptr_info[ptrn].yoffset = yoffset;
+ entropy->input_ptr_info[ptrn].MCU_width = compptr->MCU_width;
+ for (xoffset = 0; xoffset < compptr->MCU_width; xoffset++, sampn++) {
+ /* Precalculate the input pointer index for each sample */
+ entropy->input_ptr_index[sampn] = ptrn;
+ /* Precalculate which tables to use for each sample */
+ entropy->cur_tbls[sampn] = entropy->derived_tbls[compptr->dc_tbl_no];
+ entropy->cur_counts[sampn] = entropy->count_ptrs[compptr->dc_tbl_no];
+ }
+ }
+ }
+ entropy->num_input_ptrs = ptrn;
+
+ /* Initialize bit buffer to empty */
+ entropy->saved.put_buffer = 0;
+ entropy->saved.put_bits = 0;
+
+ /* Initialize restart stuff */
+ entropy->restarts_to_go = cinfo->restart_interval;
+ entropy->next_restart_num = 0;
+}
+
+
+/* Outputting bytes to the file */
+
+/* Emit a byte, taking 'action' if must suspend. */
+#define emit_byte(state, val, action) { \
+ *(state)->next_output_byte++ = (JOCTET)(val); \
+ if (--(state)->free_in_buffer == 0) \
+ if (!dump_buffer(state)) \
+ { action; } \
+}
+
+
+LOCAL(boolean)
+dump_buffer(working_state *state)
+/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */
+{
+ struct jpeg_destination_mgr *dest = state->cinfo->dest;
+
+ if (!(*dest->empty_output_buffer) (state->cinfo))
+ return FALSE;
+ /* After a successful buffer dump, must reset buffer pointers */
+ state->next_output_byte = dest->next_output_byte;
+ state->free_in_buffer = dest->free_in_buffer;
+ return TRUE;
+}
+
+
+/* Outputting bits to the file */
+
+/* Only the right 24 bits of put_buffer are used; the valid bits are
+ * left-justified in this part. At most 16 bits can be passed to emit_bits
+ * in one call, and we never retain more than 7 bits in put_buffer
+ * between calls, so 24 bits are sufficient.
+ */
+
+INLINE
+LOCAL(boolean)
+emit_bits(working_state *state, unsigned int code, int size)
+/* Emit some bits; return TRUE if successful, FALSE if must suspend */
+{
+ /* This routine is heavily used, so it's worth coding tightly. */
+ register size_t put_buffer = (size_t)code;
+ register int put_bits = state->cur.put_bits;
+
+ /* if size is 0, caller used an invalid Huffman table entry */
+ if (size == 0)
+ ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE);
+
+ put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
+
+ put_bits += size; /* new number of bits in buffer */
+
+ put_buffer <<= 24 - put_bits; /* align incoming bits */
+
+ put_buffer |= state->cur.put_buffer; /* and merge with old buffer contents */
+
+ while (put_bits >= 8) {
+ int c = (int)((put_buffer >> 16) & 0xFF);
+
+ emit_byte(state, c, return FALSE);
+ if (c == 0xFF) { /* need to stuff a zero byte? */
+ emit_byte(state, 0, return FALSE);
+ }
+ put_buffer <<= 8;
+ put_bits -= 8;
+ }
+
+ state->cur.put_buffer = put_buffer; /* update state variables */
+ state->cur.put_bits = put_bits;
+
+ return TRUE;
+}
+
+
+LOCAL(boolean)
+flush_bits(working_state *state)
+{
+ if (!emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */
+ return FALSE;
+ state->cur.put_buffer = 0; /* and reset bit-buffer to empty */
+ state->cur.put_bits = 0;
+ return TRUE;
+}
+
+
+/*
+ * Emit a restart marker & resynchronize predictions.
+ */
+
+LOCAL(boolean)
+emit_restart(working_state *state, int restart_num)
+{
+ if (!flush_bits(state))
+ return FALSE;
+
+ emit_byte(state, 0xFF, return FALSE);
+ emit_byte(state, JPEG_RST0 + restart_num, return FALSE);
+
+ /* The restart counter is not updated until we successfully write the MCU. */
+
+ return TRUE;
+}
+
+
+/*
+ * Encode and output nMCU MCUs' worth of Huffman-compressed differences.
+ */
+
+METHODDEF(JDIMENSION)
+encode_mcus_huff(j_compress_ptr cinfo, JDIFFIMAGE diff_buf,
+ JDIMENSION MCU_row_num, JDIMENSION MCU_col_num,
+ JDIMENSION nMCU)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+ working_state state;
+ int sampn, ci, yoffset, MCU_width, ptrn;
+ JDIMENSION mcu_num;
+
+ /* Load up working state */
+ state.next_output_byte = cinfo->dest->next_output_byte;
+ state.free_in_buffer = cinfo->dest->free_in_buffer;
+ state.cur = entropy->saved;
+ state.cinfo = cinfo;
+
+ /* Emit restart marker if needed */
+ if (cinfo->restart_interval) {
+ if (entropy->restarts_to_go == 0)
+ if (!emit_restart(&state, entropy->next_restart_num))
+ return 0;
+ }
+
+ /* Set input pointer locations based on MCU_col_num */
+ for (ptrn = 0; ptrn < entropy->num_input_ptrs; ptrn++) {
+ ci = entropy->input_ptr_info[ptrn].ci;
+ yoffset = entropy->input_ptr_info[ptrn].yoffset;
+ MCU_width = entropy->input_ptr_info[ptrn].MCU_width;
+ entropy->input_ptr[ptrn] =
+ diff_buf[ci][MCU_row_num + yoffset] + (MCU_col_num * MCU_width);
+ }
+
+ for (mcu_num = 0; mcu_num < nMCU; mcu_num++) {
+
+ /* Inner loop handles the samples in the MCU */
+ for (sampn = 0; sampn < cinfo->blocks_in_MCU; sampn++) {
+ register int temp, temp2;
+ register int nbits;
+ c_derived_tbl *dctbl = entropy->cur_tbls[sampn];
+
+ /* Encode the difference per section H.1.2.2 */
+
+ /* Input the sample difference */
+ temp = *entropy->input_ptr[entropy->input_ptr_index[sampn]]++;
+
+ if (temp & 0x8000) { /* instead of temp < 0 */
+ temp = (-temp) & 0x7FFF; /* absolute value, mod 2^16 */
+ if (temp == 0) /* special case: magnitude = 32768 */
+ temp2 = temp = 0x8000;
+ temp2 = ~temp; /* one's complement of magnitude */
+ } else {
+ temp &= 0x7FFF; /* abs value mod 2^16 */
+ temp2 = temp; /* magnitude */
+ }
+
+ /* Find the number of bits needed for the magnitude of the difference */
+ nbits = 0;
+ while (temp) {
+ nbits++;
+ temp >>= 1;
+ }
+ /* Check for out-of-range difference values.
+ */
+ if (nbits > MAX_DIFF_BITS)
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF);
+
+ /* Emit the Huffman-coded symbol for the number of bits */
+ if (!emit_bits(&state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits]))
+ return mcu_num;
+
+ /* Emit that number of bits of the value, if positive, */
+ /* or the complement of its magnitude, if negative. */
+ if (nbits && /* emit_bits rejects calls with size 0 */
+ nbits != 16) /* special case: no bits should be emitted */
+ if (!emit_bits(&state, (unsigned int)temp2, nbits))
+ return mcu_num;
+ }
+
+ /* Completed MCU, so update state */
+ cinfo->dest->next_output_byte = state.next_output_byte;
+ cinfo->dest->free_in_buffer = state.free_in_buffer;
+ entropy->saved = state.cur;
+
+ /* Update restart-interval state too */
+ if (cinfo->restart_interval) {
+ if (entropy->restarts_to_go == 0) {
+ entropy->restarts_to_go = cinfo->restart_interval;
+ entropy->next_restart_num++;
+ entropy->next_restart_num &= 7;
+ }
+ entropy->restarts_to_go--;
+ }
+
+ }
+
+ return nMCU;
+}
+
+
+/*
+ * Finish up at the end of a Huffman-compressed scan.
+ */
+
+METHODDEF(void)
+finish_pass_huff(j_compress_ptr cinfo)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+ working_state state;
+
+ /* Load up working state ... flush_bits needs it */
+ state.next_output_byte = cinfo->dest->next_output_byte;
+ state.free_in_buffer = cinfo->dest->free_in_buffer;
+ state.cur = entropy->saved;
+ state.cinfo = cinfo;
+
+ /* Flush out the last data */
+ if (!flush_bits(&state))
+ ERREXIT(cinfo, JERR_CANT_SUSPEND);
+
+ /* Update state */
+ cinfo->dest->next_output_byte = state.next_output_byte;
+ cinfo->dest->free_in_buffer = state.free_in_buffer;
+ entropy->saved = state.cur;
+}
+
+
+/*
+ * Huffman coding optimization.
+ *
+ * We first scan the supplied data and count the number of uses of each symbol
+ * that is to be Huffman-coded. (This process MUST agree with the code above.)
+ * Then we build a Huffman coding tree for the observed counts.
+ * Symbols which are not needed at all for the particular image are not
+ * assigned any code, which saves space in the DHT marker as well as in
+ * the compressed data.
+ */
+
+#ifdef ENTROPY_OPT_SUPPORTED
+
+/*
+ * Trial-encode nMCU MCUs' worth of Huffman-compressed differences.
+ * No data is actually output, so no suspension return is possible.
+ */
+
+METHODDEF(JDIMENSION)
+encode_mcus_gather(j_compress_ptr cinfo, JDIFFIMAGE diff_buf,
+ JDIMENSION MCU_row_num, JDIMENSION MCU_col_num,
+ JDIMENSION nMCU)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+ int sampn, ci, yoffset, MCU_width, ptrn;
+ JDIMENSION mcu_num;
+
+ /* Take care of restart intervals if needed */
+ if (cinfo->restart_interval) {
+ if (entropy->restarts_to_go == 0) {
+ /* Update restart state */
+ entropy->restarts_to_go = cinfo->restart_interval;
+ }
+ entropy->restarts_to_go--;
+ }
+
+ /* Set input pointer locations based on MCU_col_num */
+ for (ptrn = 0; ptrn < entropy->num_input_ptrs; ptrn++) {
+ ci = entropy->input_ptr_info[ptrn].ci;
+ yoffset = entropy->input_ptr_info[ptrn].yoffset;
+ MCU_width = entropy->input_ptr_info[ptrn].MCU_width;
+ entropy->input_ptr[ptrn] =
+ diff_buf[ci][MCU_row_num + yoffset] + (MCU_col_num * MCU_width);
+ }
+
+ for (mcu_num = 0; mcu_num < nMCU; mcu_num++) {
+
+ /* Inner loop handles the samples in the MCU */
+ for (sampn = 0; sampn < cinfo->blocks_in_MCU; sampn++) {
+ register int temp;
+ register int nbits;
+ long *counts = entropy->cur_counts[sampn];
+
+ /* Encode the difference per section H.1.2.2 */
+
+ /* Input the sample difference */
+ temp = *entropy->input_ptr[entropy->input_ptr_index[sampn]]++;
+
+ if (temp & 0x8000) { /* instead of temp < 0 */
+ temp = (-temp) & 0x7FFF; /* absolute value, mod 2^16 */
+ if (temp == 0) /* special case: magnitude = 32768 */
+ temp = 0x8000;
+ } else
+ temp &= 0x7FFF; /* abs value mod 2^16 */
+
+ /* Find the number of bits needed for the magnitude of the difference */
+ nbits = 0;
+ while (temp) {
+ nbits++;
+ temp >>= 1;
+ }
+ /* Check for out-of-range difference values.
+ */
+ if (nbits > MAX_DIFF_BITS)
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF);
+
+ /* Count the Huffman symbol for the number of bits */
+ counts[nbits]++;
+ }
+ }
+
+ return nMCU;
+}
+
+
+/*
+ * Finish up a statistics-gathering pass and create the new Huffman tables.
+ */
+
+METHODDEF(void)
+finish_pass_gather(j_compress_ptr cinfo)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+ int ci, dctbl;
+ jpeg_component_info *compptr;
+ JHUFF_TBL **htblptr;
+ boolean did_dc[NUM_HUFF_TBLS];
+
+ /* It's important not to apply jpeg_gen_optimal_table more than once
+ * per table, because it clobbers the input frequency counts!
+ */
+ memset(did_dc, 0, sizeof(did_dc));
+
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ dctbl = compptr->dc_tbl_no;
+ if (!did_dc[dctbl]) {
+ htblptr = &cinfo->dc_huff_tbl_ptrs[dctbl];
+ if (*htblptr == NULL)
+ *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
+ jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[dctbl]);
+ did_dc[dctbl] = TRUE;
+ }
+ }
+}
+
+
+#endif /* ENTROPY_OPT_SUPPORTED */
+
+
+/*
+ * Module initialization routine for Huffman entropy encoding.
+ */
+
+GLOBAL(void)
+jinit_lhuff_encoder(j_compress_ptr cinfo)
+{
+ lhuff_entropy_ptr entropy;
+ int i;
+
+ entropy = (lhuff_entropy_ptr)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ sizeof(lhuff_entropy_encoder));
+ cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
+ entropy->pub.start_pass = start_pass_lhuff;
+
+ /* Mark tables unallocated */
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
+ entropy->derived_tbls[i] = NULL;
+#ifdef ENTROPY_OPT_SUPPORTED
+ entropy->count_ptrs[i] = NULL;
+#endif
+ }
+}
+
+#endif /* C_LOSSLESS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/src/jclossls.c b/contrib/libs/libjpeg-turbo/src/jclossls.c
new file mode 100644
index 00000000000..295c3e2a2b0
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jclossls.c
@@ -0,0 +1,327 @@
+/*
+ * jclossls.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1998, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains prediction, sample differencing, and point transform
+ * routines for the lossless JPEG compressor.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jlossls.h"
+
+#ifdef C_LOSSLESS_SUPPORTED
+
+
+/************************** Sample differencing **************************/
+
+/*
+ * In order to avoid a performance penalty for checking which predictor is
+ * being used and which row is being processed for each call of the
+ * undifferencer, and to promote optimization, we have separate differencing
+ * functions for each predictor selection value.
+ *
+ * We are able to avoid duplicating source code by implementing the predictors
+ * and differencers as macros. Each of the differencing functions is simply a
+ * wrapper around a DIFFERENCE macro with the appropriate PREDICTOR macro
+ * passed as an argument.
+ */
+
+/* Forward declarations */
+LOCAL(void) reset_predictor(j_compress_ptr cinfo, int ci);
+
+
+/* Predictor for the first column of the first row: 2^(P-Pt-1) */
+#define INITIAL_PREDICTORx (1 << (cinfo->data_precision - cinfo->Al - 1))
+
+/* Predictor for the first column of the remaining rows: Rb */
+#define INITIAL_PREDICTOR2 prev_row[0]
+
+
+/*
+ * 1-Dimensional differencer routine.
+ *
+ * This macro implements the 1-D horizontal predictor (1). INITIAL_PREDICTOR
+ * is used as the special case predictor for the first column, which must be
+ * either INITIAL_PREDICTOR2 or INITIAL_PREDICTORx. The remaining samples
+ * use PREDICTOR1.
+ */
+
+#define DIFFERENCE_1D(INITIAL_PREDICTOR) \
+ lossless_comp_ptr losslessc = (lossless_comp_ptr)cinfo->fdct; \
+ boolean restart = FALSE; \
+ int samp, Ra; \
+ \
+ samp = *input_buf++; \
+ *diff_buf++ = samp - INITIAL_PREDICTOR; \
+ \
+ while (--width) { \
+ Ra = samp; \
+ samp = *input_buf++; \
+ *diff_buf++ = samp - PREDICTOR1; \
+ } \
+ \
+ /* Account for restart interval (no-op if not using restarts) */ \
+ if (cinfo->restart_interval) { \
+ if (--(losslessc->restart_rows_to_go[ci]) == 0) { \
+ reset_predictor(cinfo, ci); \
+ restart = TRUE; \
+ } \
+ }
+
+
+/*
+ * 2-Dimensional differencer routine.
+ *
+ * This macro implements the 2-D horizontal predictors (#2-7). PREDICTOR2 is
+ * used as the special case predictor for the first column. The remaining
+ * samples use PREDICTOR, which is a function of Ra, Rb, and Rc.
+ *
+ * Because prev_row and output_buf may point to the same storage area (in an
+ * interleaved image with Vi=1, for example), we must take care to buffer Rb/Rc
+ * before writing the current reconstructed sample value into output_buf.
+ */
+
+#define DIFFERENCE_2D(PREDICTOR) \
+ lossless_comp_ptr losslessc = (lossless_comp_ptr)cinfo->fdct; \
+ int samp, Ra, Rb, Rc; \
+ \
+ Rb = *prev_row++; \
+ samp = *input_buf++; \
+ *diff_buf++ = samp - PREDICTOR2; \
+ \
+ while (--width) { \
+ Rc = Rb; \
+ Rb = *prev_row++; \
+ Ra = samp; \
+ samp = *input_buf++; \
+ *diff_buf++ = samp - PREDICTOR; \
+ } \
+ \
+ /* Account for restart interval (no-op if not using restarts) */ \
+ if (cinfo->restart_interval) { \
+ if (--losslessc->restart_rows_to_go[ci] == 0) \
+ reset_predictor(cinfo, ci); \
+ }
+
+
+/*
+ * Differencers for the second and subsequent rows in a scan or restart
+ * interval. The first sample in the row is differenced using the vertical
+ * predictor (2). The rest of the samples are differenced using the predictor
+ * specified in the scan header.
+ */
+
+METHODDEF(void)
+jpeg_difference1(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_1D(INITIAL_PREDICTOR2);
+ (void)(restart);
+}
+
+METHODDEF(void)
+jpeg_difference2(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_2D(PREDICTOR2);
+ (void)(Ra);
+ (void)(Rc);
+}
+
+METHODDEF(void)
+jpeg_difference3(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_2D(PREDICTOR3);
+ (void)(Ra);
+}
+
+METHODDEF(void)
+jpeg_difference4(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_2D(PREDICTOR4);
+}
+
+METHODDEF(void)
+jpeg_difference5(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_2D(PREDICTOR5);
+}
+
+METHODDEF(void)
+jpeg_difference6(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_2D(PREDICTOR6);
+}
+
+METHODDEF(void)
+jpeg_difference7(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_2D(PREDICTOR7);
+ (void)(Rc);
+}
+
+
+/*
+ * Differencer for the first row in a scan or restart interval. The first
+ * sample in the row is differenced using the special predictor constant
+ * x = 2 ^ (P-Pt-1). The rest of the samples are differenced using the
+ * 1-D horizontal predictor (1).
+ */
+
+METHODDEF(void)
+jpeg_difference_first_row(j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf, _JSAMPROW prev_row,
+ JDIFFROW diff_buf, JDIMENSION width)
+{
+ DIFFERENCE_1D(INITIAL_PREDICTORx);
+
+ /*
+ * Now that we have differenced the first row, we want to use the
+ * differencer that corresponds to the predictor specified in the
+ * scan header.
+ *
+ * Note that we don't do this if we have just reset the predictor
+ * for a new restart interval.
+ */
+ if (!restart) {
+ switch (cinfo->Ss) {
+ case 1:
+ losslessc->predict_difference[ci] = jpeg_difference1;
+ break;
+ case 2:
+ losslessc->predict_difference[ci] = jpeg_difference2;
+ break;
+ case 3:
+ losslessc->predict_difference[ci] = jpeg_difference3;
+ break;
+ case 4:
+ losslessc->predict_difference[ci] = jpeg_difference4;
+ break;
+ case 5:
+ losslessc->predict_difference[ci] = jpeg_difference5;
+ break;
+ case 6:
+ losslessc->predict_difference[ci] = jpeg_difference6;
+ break;
+ case 7:
+ losslessc->predict_difference[ci] = jpeg_difference7;
+ break;
+ }
+ }
+}
+
+/*
+ * Reset predictor at the start of a pass or restart interval.
+ */
+
+LOCAL(void)
+reset_predictor(j_compress_ptr cinfo, int ci)
+{
+ lossless_comp_ptr losslessc = (lossless_comp_ptr)cinfo->fdct;
+
+ /* Initialize restart counter */
+ losslessc->restart_rows_to_go[ci] =
+ cinfo->restart_interval / cinfo->MCUs_per_row;
+
+ /* Set difference function to first row function */
+ losslessc->predict_difference[ci] = jpeg_difference_first_row;
+}
+
+
+/********************** Sample downscaling by 2^Pt ***********************/
+
+METHODDEF(void)
+simple_downscale(j_compress_ptr cinfo,
+ _JSAMPROW input_buf, _JSAMPROW output_buf, JDIMENSION width)
+{
+ do {
+ *output_buf++ = (_JSAMPLE)RIGHT_SHIFT(*input_buf++, cinfo->Al);
+ } while (--width);
+}
+
+
+METHODDEF(void)
+noscale(j_compress_ptr cinfo,
+ _JSAMPROW input_buf, _JSAMPROW output_buf, JDIMENSION width)
+{
+ memcpy(output_buf, input_buf, width * sizeof(_JSAMPLE));
+}
+
+
+/*
+ * Initialize for a processing pass.
+ */
+
+METHODDEF(void)
+start_pass_lossless(j_compress_ptr cinfo)
+{
+ lossless_comp_ptr losslessc = (lossless_comp_ptr)cinfo->fdct;
+ int ci;
+
+ /* Set scaler function based on Pt */
+ if (cinfo->Al)
+ losslessc->scaler_scale = simple_downscale;
+ else
+ losslessc->scaler_scale = noscale;
+
+ /* Check that the restart interval is an integer multiple of the number
+ * of MCUs in an MCU row.
+ */
+ if (cinfo->restart_interval % cinfo->MCUs_per_row != 0)
+ ERREXIT2(cinfo, JERR_BAD_RESTART,
+ cinfo->restart_interval, cinfo->MCUs_per_row);
+
+ /* Set predictors for start of pass */
+ for (ci = 0; ci < cinfo->num_components; ci++)
+ reset_predictor(cinfo, ci);
+}
+
+
+/*
+ * Initialize the lossless compressor.
+ */
+
+GLOBAL(void)
+_jinit_lossless_compressor(j_compress_ptr cinfo)
+{
+ lossless_comp_ptr losslessc;
+
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ /* Create subobject in permanent pool */
+ losslessc = (lossless_comp_ptr)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
+ sizeof(jpeg_lossless_compressor));
+ cinfo->fdct = (struct jpeg_forward_dct *)losslessc;
+ losslessc->pub.start_pass = start_pass_lossless;
+}
+
+#endif /* C_LOSSLESS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jcmainct.c b/contrib/libs/libjpeg-turbo/src/jcmainct.c
index 3f23028c467..b72f8deb6c9 100644
--- a/contrib/libs/libjpeg-turbo/jcmainct.c
+++ b/contrib/libs/libjpeg-turbo/src/jcmainct.c
@@ -3,8 +3,10 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -16,8 +18,11 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
+
/* Private buffer controller object */
typedef struct {
@@ -32,7 +37,7 @@ typedef struct {
* (we allocate one for each component). In the full-image case, this
* points to the currently accessible strips of the virtual arrays.
*/
- JSAMPARRAY buffer[MAX_COMPONENTS];
+ _JSAMPARRAY buffer[MAX_COMPONENTS];
} my_main_controller;
typedef my_main_controller *my_main_ptr;
@@ -40,7 +45,7 @@ typedef my_main_controller *my_main_ptr;
/* Forward declarations */
METHODDEF(void) process_data_simple_main(j_compress_ptr cinfo,
- JSAMPARRAY input_buf,
+ _JSAMPARRAY input_buf,
JDIMENSION *in_row_ctr,
JDIMENSION in_rows_avail);
@@ -65,7 +70,7 @@ start_pass_main(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
main_ptr->rowgroup_ctr = 0;
main_ptr->suspended = FALSE;
main_ptr->pass_mode = pass_mode; /* save mode for use by process_data */
- main_ptr->pub.process_data = process_data_simple_main;
+ main_ptr->pub._process_data = process_data_simple_main;
}
@@ -76,28 +81,28 @@ start_pass_main(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
*/
METHODDEF(void)
-process_data_simple_main(j_compress_ptr cinfo, JSAMPARRAY input_buf,
+process_data_simple_main(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
{
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
+ JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
/* Read input data if we haven't filled the main buffer yet */
- if (main_ptr->rowgroup_ctr < DCTSIZE)
- (*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr,
- in_rows_avail, main_ptr->buffer,
- &main_ptr->rowgroup_ctr,
- (JDIMENSION)DCTSIZE);
+ if (main_ptr->rowgroup_ctr < data_unit)
+ (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
+ in_rows_avail, main_ptr->buffer,
+ &main_ptr->rowgroup_ctr, data_unit);
/* If we don't have a full iMCU row buffered, return to application for
* more data. Note that preprocessor will always pad to fill the iMCU row
* at the bottom of the image.
*/
- if (main_ptr->rowgroup_ctr != DCTSIZE)
+ if (main_ptr->rowgroup_ctr != data_unit)
return;
/* Send the completed row to the compressor */
- if (!(*cinfo->coef->compress_data) (cinfo, main_ptr->buffer)) {
+ if (!(*cinfo->coef->_compress_data) (cinfo, main_ptr->buffer)) {
/* If compressor did not consume the whole row, then we must need to
* suspend processing and return to the application. In this situation
* we pretend we didn't yet consume the last input row; otherwise, if
@@ -128,15 +133,33 @@ process_data_simple_main(j_compress_ptr cinfo, JSAMPARRAY input_buf,
*/
GLOBAL(void)
-jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
+_jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
{
my_main_ptr main_ptr;
int ci;
jpeg_component_info *compptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
main_ptr = (my_main_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_main_controller));
+ memset(main_ptr, 0, sizeof(my_main_controller));
cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
main_ptr->pub.start_pass = start_pass_main;
@@ -153,10 +176,12 @@ jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
/* Allocate a strip buffer for each component */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
+ main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
- compptr->width_in_blocks * DCTSIZE,
- (JDIMENSION)(compptr->v_samp_factor * DCTSIZE));
+ compptr->width_in_blocks * data_unit,
+ (JDIMENSION)(compptr->v_samp_factor * data_unit));
}
}
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jcmarker.c b/contrib/libs/libjpeg-turbo/src/jcmarker.c
index 801fbab4ef0..a064d4dd9e7 100644
--- a/contrib/libs/libjpeg-turbo/jcmarker.c
+++ b/contrib/libs/libjpeg-turbo/src/jcmarker.c
@@ -4,8 +4,10 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, D. R. Commander.
+ * Copyright (C) 2010, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -15,7 +17,7 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
typedef enum { /* JPEG marker codes */
@@ -497,25 +499,26 @@ write_file_header(j_compress_ptr cinfo)
METHODDEF(void)
write_frame_header(j_compress_ptr cinfo)
{
- int ci, prec;
+ int ci, prec = 0;
boolean is_baseline;
jpeg_component_info *compptr;
- /* Emit DQT for each quantization table.
- * Note that emit_dqt() suppresses any duplicate tables.
- */
- prec = 0;
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
- ci++, compptr++) {
- prec += emit_dqt(cinfo, compptr->quant_tbl_no);
+ if (!cinfo->master->lossless) {
+ /* Emit DQT for each quantization table.
+ * Note that emit_dqt() suppresses any duplicate tables.
+ */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ prec += emit_dqt(cinfo, compptr->quant_tbl_no);
+ }
+ /* now prec is nonzero iff there are any 16-bit quant tables. */
}
- /* now prec is nonzero iff there are any 16-bit quant tables. */
/* Check for a non-baseline specification.
* Note we assume that Huffman table numbers won't be changed later.
*/
if (cinfo->arith_code || cinfo->progressive_mode ||
- cinfo->data_precision != 8) {
+ cinfo->master->lossless || cinfo->data_precision != 8) {
is_baseline = FALSE;
} else {
is_baseline = TRUE;
@@ -540,6 +543,8 @@ write_frame_header(j_compress_ptr cinfo)
} else {
if (cinfo->progressive_mode)
emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
+ else if (cinfo->master->lossless)
+ emit_sof(cinfo, M_SOF3); /* SOF code for lossless Huffman */
else if (is_baseline)
emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
else
@@ -574,10 +579,11 @@ write_scan_header(j_compress_ptr cinfo)
for (i = 0; i < cinfo->comps_in_scan; i++) {
compptr = cinfo->cur_comp_info[i];
/* DC needs no table for refinement scan */
- if (cinfo->Ss == 0 && cinfo->Ah == 0)
+ if ((cinfo->Ss == 0 && cinfo->Ah == 0) || cinfo->master->lossless)
emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
- /* AC needs no table when not present */
- if (cinfo->Se)
+ /* AC needs no table when not present, and lossless mode uses only DC
+ tables. */
+ if (cinfo->Se && !cinfo->master->lossless)
emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
}
}
diff --git a/contrib/libs/libjpeg-turbo/jcmaster.c b/contrib/libs/libjpeg-turbo/src/jcmaster.c
index c2b26000318..1dcd252b3c1 100644
--- a/contrib/libs/libjpeg-turbo/jcmaster.c
+++ b/contrib/libs/libjpeg-turbo/src/jcmaster.c
@@ -4,8 +4,10 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, D. R. Commander.
+ * Copyright (C) 2010, 2016, 2018, 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -18,40 +20,8 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
-#include "jpegcomp.h"
-#include "jconfigint.h"
-
-
-/* Private state */
-
-typedef enum {
- main_pass, /* input data, also do first output step */
- huff_opt_pass, /* Huffman code optimization pass */
- output_pass /* data output pass */
-} c_pass_type;
-
-typedef struct {
- struct jpeg_comp_master pub; /* public fields */
-
- c_pass_type pass_type; /* the type of the current pass */
-
- int pass_number; /* # of passes completed */
- int total_passes; /* total # of passes needed */
-
- int scan_number; /* current index in scan_info[] */
-
- /*
- * This is here so we can add libjpeg-turbo version/build information to the
- * global string table without introducing a new global symbol. Adding this
- * information to the global string table allows one to examine a binary
- * object and determine which version of libjpeg-turbo it was built from or
- * linked against.
- */
- const char *jpeg_version;
-
-} my_comp_master;
-
-typedef my_comp_master *my_master_ptr;
+#include "jpegapicomp.h"
+#include "jcmaster.h"
/*
@@ -69,15 +39,124 @@ GLOBAL(void)
jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo)
/* Do computations that are needed before master selection phase */
{
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+
/* Hardwire it to "no scaling" */
cinfo->jpeg_width = cinfo->image_width;
cinfo->jpeg_height = cinfo->image_height;
- cinfo->min_DCT_h_scaled_size = DCTSIZE;
- cinfo->min_DCT_v_scaled_size = DCTSIZE;
+ cinfo->min_DCT_h_scaled_size = data_unit;
+ cinfo->min_DCT_v_scaled_size = data_unit;
}
#endif
+LOCAL(boolean)
+using_std_huff_tables(j_compress_ptr cinfo)
+{
+ int i;
+
+ static const UINT8 bits_dc_luminance[17] = {
+ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0
+ };
+ static const UINT8 val_dc_luminance[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+ };
+
+ static const UINT8 bits_dc_chrominance[17] = {
+ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
+ };
+ static const UINT8 val_dc_chrominance[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+ };
+
+ static const UINT8 bits_ac_luminance[17] = {
+ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d
+ };
+ static const UINT8 val_ac_luminance[] = {
+ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
+ 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
+ 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
+ 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
+ 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
+ 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
+ 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+ 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
+ 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
+ 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
+ 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
+ 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
+ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+ };
+
+ static const UINT8 bits_ac_chrominance[17] = {
+ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77
+ };
+ static const UINT8 val_ac_chrominance[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
+ 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
+ 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
+ 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
+ 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
+ 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
+ 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
+ 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
+ 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
+ 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
+ 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
+ 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
+ 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
+ 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+ };
+
+ if (cinfo->dc_huff_tbl_ptrs[0] == NULL ||
+ cinfo->ac_huff_tbl_ptrs[0] == NULL ||
+ cinfo->dc_huff_tbl_ptrs[1] == NULL ||
+ cinfo->ac_huff_tbl_ptrs[1] == NULL)
+ return FALSE;
+
+ for (i = 2; i < NUM_HUFF_TBLS; i++) {
+ if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
+ cinfo->ac_huff_tbl_ptrs[i] != NULL)
+ return FALSE;
+ }
+
+ if (memcmp(cinfo->dc_huff_tbl_ptrs[0]->bits, bits_dc_luminance,
+ sizeof(bits_dc_luminance)) ||
+ memcmp(cinfo->dc_huff_tbl_ptrs[0]->huffval, val_dc_luminance,
+ sizeof(val_dc_luminance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[0]->bits, bits_ac_luminance,
+ sizeof(bits_ac_luminance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[0]->huffval, val_ac_luminance,
+ sizeof(val_ac_luminance)) ||
+ memcmp(cinfo->dc_huff_tbl_ptrs[1]->bits, bits_dc_chrominance,
+ sizeof(bits_dc_chrominance)) ||
+ memcmp(cinfo->dc_huff_tbl_ptrs[1]->huffval, val_dc_chrominance,
+ sizeof(val_dc_chrominance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[1]->bits, bits_ac_chrominance,
+ sizeof(bits_ac_chrominance)) ||
+ memcmp(cinfo->ac_huff_tbl_ptrs[1]->huffval, val_ac_chrominance,
+ sizeof(val_ac_chrominance)))
+ return FALSE;
+
+ return TRUE;
+}
+
+
LOCAL(void)
initial_setup(j_compress_ptr cinfo, boolean transcode_only)
/* Do computations that are needed before master selection phase */
@@ -86,6 +165,7 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
jpeg_component_info *compptr;
long samplesperrow;
JDIMENSION jd_samplesperrow;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
#if JPEG_LIB_VERSION >= 70
#if JPEG_LIB_VERSION >= 80
@@ -110,9 +190,19 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
if ((long)jd_samplesperrow != samplesperrow)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
- /* For now, precision must match compiled-in value... */
- if (cinfo->data_precision != BITS_IN_JSAMPLE)
- ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ /* Lossy JPEG images must have 8 or 12 bits per sample. Lossless JPEG images
+ * can have 2 to 16 bits per sample.
+ */
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+ if (cinfo->data_precision < 2 || cinfo->data_precision > 16)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
/* Check that number of components won't exceed internal array sizes */
if (cinfo->num_components > MAX_COMPONENTS)
@@ -142,17 +232,17 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
compptr->component_index = ci;
/* For compression, we never do DCT scaling. */
#if JPEG_LIB_VERSION >= 70
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
+ compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = data_unit;
#else
- compptr->DCT_scaled_size = DCTSIZE;
+ compptr->DCT_scaled_size = data_unit;
#endif
- /* Size in DCT blocks */
+ /* Size in data units */
compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
+ (long)(cinfo->max_h_samp_factor * data_unit));
compptr->height_in_blocks = (JDIMENSION)
jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
+ (long)(cinfo->max_v_samp_factor * data_unit));
/* Size in samples */
compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
@@ -165,15 +255,19 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
}
/* Compute number of fully interleaved MCU rows (number of times that
- * main controller will call coefficient controller).
+ * main controller will call coefficient or difference controller).
*/
cinfo->total_iMCU_rows = (JDIMENSION)
jdiv_round_up((long)cinfo->_jpeg_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
+ (long)(cinfo->max_v_samp_factor * data_unit));
}
-#ifdef C_MULTISCAN_FILES_SUPPORTED
+#if defined(C_MULTISCAN_FILES_SUPPORTED) || defined(C_LOSSLESS_SUPPORTED)
+#define NEED_SCAN_SCRIPT
+#endif
+
+#ifdef NEED_SCAN_SCRIPT
LOCAL(void)
validate_script(j_compress_ptr cinfo)
@@ -194,13 +288,29 @@ validate_script(j_compress_ptr cinfo)
if (cinfo->num_scans <= 0)
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);
+#ifndef C_MULTISCAN_FILES_SUPPORTED
+ if (cinfo->num_scans > 1)
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+
+ scanptr = cinfo->scan_info;
+ if (scanptr->Ss != 0 && scanptr->Se == 0) {
+#ifdef C_LOSSLESS_SUPPORTED
+ cinfo->master->lossless = TRUE;
+ cinfo->progressive_mode = FALSE;
+ for (ci = 0; ci < cinfo->num_components; ci++)
+ component_sent[ci] = FALSE;
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ }
/* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1;
* for progressive JPEG, no scan can have this.
*/
- scanptr = cinfo->scan_info;
- if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
+ else if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
#ifdef C_PROGRESSIVE_SUPPORTED
cinfo->progressive_mode = TRUE;
+ cinfo->master->lossless = FALSE;
last_bitpos_ptr = &last_bitpos[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (coefi = 0; coefi < DCTSIZE2; coefi++)
@@ -209,7 +319,7 @@ validate_script(j_compress_ptr cinfo)
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else {
- cinfo->progressive_mode = FALSE;
+ cinfo->progressive_mode = cinfo->master->lossless = FALSE;
for (ci = 0; ci < cinfo->num_components; ci++)
component_sent[ci] = FALSE;
}
@@ -241,13 +351,10 @@ validate_script(j_compress_ptr cinfo)
* out-of-range reconstructed DC values during the first DC scan,
* which might cause problems for some decoders.
*/
-#if BITS_IN_JSAMPLE == 8
-#define MAX_AH_AL 10
-#else
-#define MAX_AH_AL 13
-#endif
+ int max_Ah_Al = cinfo->data_precision == 12 ? 13 : 10;
+
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
- Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
+ Ah < 0 || Ah > max_Ah_Al || Al < 0 || Al > max_Ah_Al)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
if (Ss == 0) {
if (Se != 0) /* DC and AC together not OK */
@@ -275,9 +382,25 @@ validate_script(j_compress_ptr cinfo)
}
#endif
} else {
- /* For sequential JPEG, all progression parameters must be these: */
- if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
- ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+ /* The JPEG spec simply gives the range 0..15 for Al (Pt), but that
+ * seems wrong: the upper bound ought to depend on data precision.
+ * Perhaps they really meant 0..N-1 for N-bit precision, which is what
+ * we allow here. Values greater than or equal to the data precision
+ * will result in a blank image.
+ */
+ if (Ss < 1 || Ss > 7 || /* predictor selection value */
+ Se != 0 || Ah != 0 ||
+ Al < 0 || Al >= cinfo->data_precision) /* point transform */
+ ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
+ } else
+#endif
+ {
+ /* For sequential JPEG, all progression parameters must be these: */
+ if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
+ ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
+ }
/* Make sure components are not sent twice */
for (ci = 0; ci < ncomps; ci++) {
thisi = scanptr->component_index[ci];
@@ -309,7 +432,7 @@ validate_script(j_compress_ptr cinfo)
}
}
-#endif /* C_MULTISCAN_FILES_SUPPORTED */
+#endif /* NEED_SCAN_SCRIPT */
LOCAL(void)
@@ -318,7 +441,7 @@ select_scan_parameters(j_compress_ptr cinfo)
{
int ci;
-#ifdef C_MULTISCAN_FILES_SUPPORTED
+#ifdef NEED_SCAN_SCRIPT
if (cinfo->scan_info != NULL) {
/* Prepare for current scan --- the script is already validated */
my_master_ptr master = (my_master_ptr)cinfo->master;
@@ -344,10 +467,12 @@ select_scan_parameters(j_compress_ptr cinfo)
for (ci = 0; ci < cinfo->num_components; ci++) {
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
}
- cinfo->Ss = 0;
- cinfo->Se = DCTSIZE2 - 1;
- cinfo->Ah = 0;
- cinfo->Al = 0;
+ if (!cinfo->master->lossless) {
+ cinfo->Ss = 0;
+ cinfo->Se = DCTSIZE2 - 1;
+ cinfo->Ah = 0;
+ cinfo->Al = 0;
+ }
}
}
@@ -359,6 +484,7 @@ per_scan_setup(j_compress_ptr cinfo)
{
int ci, mcublks, tmp;
jpeg_component_info *compptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
if (cinfo->comps_in_scan == 1) {
@@ -373,7 +499,7 @@ per_scan_setup(j_compress_ptr cinfo)
compptr->MCU_width = 1;
compptr->MCU_height = 1;
compptr->MCU_blocks = 1;
- compptr->MCU_sample_width = DCTSIZE;
+ compptr->MCU_sample_width = data_unit;
compptr->last_col_width = 1;
/* For noninterleaved scans, it is convenient to define last_row_height
* as the number of block rows present in the last iMCU row.
@@ -396,10 +522,10 @@ per_scan_setup(j_compress_ptr cinfo)
/* Overall image size in MCUs */
cinfo->MCUs_per_row = (JDIMENSION)
jdiv_round_up((long)cinfo->_jpeg_width,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
+ (long)(cinfo->max_h_samp_factor * data_unit));
cinfo->MCU_rows_in_scan = (JDIMENSION)
jdiv_round_up((long)cinfo->_jpeg_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
+ (long)(cinfo->max_v_samp_factor * data_unit));
cinfo->blocks_in_MCU = 0;
@@ -409,7 +535,7 @@ per_scan_setup(j_compress_ptr cinfo)
compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
- compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;
+ compptr->MCU_sample_width = compptr->MCU_width * data_unit;
/* Figure number of non-dummy blocks in last MCU column & row */
tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width;
@@ -481,7 +607,8 @@ prepare_for_pass(j_compress_ptr cinfo)
/* Do Huffman optimization for a scan after the first one. */
select_scan_parameters(cinfo);
per_scan_setup(cinfo);
- if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) {
+ if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code ||
+ cinfo->master->lossless) {
(*cinfo->entropy->start_pass) (cinfo, TRUE);
(*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
master->pub.call_pass_startup = FALSE;
@@ -590,22 +717,17 @@ finish_pass_master(j_compress_ptr cinfo)
GLOBAL(void)
jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
{
- my_master_ptr master;
+ my_master_ptr master = (my_master_ptr)cinfo->master;
+ boolean empty_huff_tables = TRUE;
+ int i;
- master = (my_master_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- sizeof(my_comp_master));
- cinfo->master = (struct jpeg_comp_master *)master;
master->pub.prepare_for_pass = prepare_for_pass;
master->pub.pass_startup = pass_startup;
master->pub.finish_pass = finish_pass_master;
master->pub.is_last_pass = FALSE;
- /* Validate parameters, determine derived values */
- initial_setup(cinfo, transcode_only);
-
if (cinfo->scan_info != NULL) {
-#ifdef C_MULTISCAN_FILES_SUPPORTED
+#ifdef NEED_SCAN_SCRIPT
validate_script(cinfo);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
@@ -615,8 +737,47 @@ jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
cinfo->num_scans = 1;
}
- if (cinfo->progressive_mode && !cinfo->arith_code) /* TEMPORARY HACK ??? */
- cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */
+#ifdef C_LOSSLESS_SUPPORTED
+ /* Disable smoothing and subsampling in lossless mode, since those are lossy
+ * algorithms. Set the JPEG colorspace to the input colorspace. Disable raw
+ * (downsampled) data input, because it isn't particularly useful without
+ * subsampling and has not been tested in lossless mode.
+ */
+ if (cinfo->master->lossless) {
+ int ci;
+ jpeg_component_info *compptr;
+
+ cinfo->raw_data_in = FALSE;
+ cinfo->smoothing_factor = 0;
+ jpeg_default_colorspace(cinfo);
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++)
+ compptr->h_samp_factor = compptr->v_samp_factor = 1;
+ }
+#endif
+
+ /* Validate parameters, determine derived values */
+ initial_setup(cinfo, transcode_only);
+
+ if (cinfo->arith_code)
+ cinfo->optimize_coding = FALSE;
+ else {
+ if (cinfo->master->lossless || /* TEMPORARY HACK ??? */
+ cinfo->progressive_mode)
+ cinfo->optimize_coding = TRUE; /* assume default tables no good for
+ progressive mode or lossless mode */
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
+ if (cinfo->dc_huff_tbl_ptrs[i] != NULL ||
+ cinfo->ac_huff_tbl_ptrs[i] != NULL) {
+ empty_huff_tables = FALSE;
+ break;
+ }
+ }
+ if (cinfo->data_precision == 12 && !cinfo->optimize_coding &&
+ (empty_huff_tables || using_std_huff_tables(cinfo)))
+ cinfo->optimize_coding = TRUE; /* assume default tables no good for
+ 12-bit data precision */
+ }
/* Initialize my private state */
if (transcode_only) {
diff --git a/contrib/libs/libjpeg-turbo/src/jcmaster.h b/contrib/libs/libjpeg-turbo/src/jcmaster.h
new file mode 100644
index 00000000000..3b13289b691
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jcmaster.h
@@ -0,0 +1,43 @@
+/*
+ * jcmaster.h
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1995, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2016, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains master control structure for the JPEG compressor.
+ */
+
+/* Private state */
+
+typedef enum {
+ main_pass, /* input data, also do first output step */
+ huff_opt_pass, /* Huffman code optimization pass */
+ output_pass /* data output pass */
+} c_pass_type;
+
+typedef struct {
+ struct jpeg_comp_master pub; /* public fields */
+
+ c_pass_type pass_type; /* the type of the current pass */
+
+ int pass_number; /* # of passes completed */
+ int total_passes; /* total # of passes needed */
+
+ int scan_number; /* current index in scan_info[] */
+
+ /*
+ * This is here so we can add libjpeg-turbo version/build information to the
+ * global string table without introducing a new global symbol. Adding this
+ * information to the global string table allows one to examine a binary
+ * object and determine which version of libjpeg-turbo it was built from or
+ * linked against.
+ */
+ const char *jpeg_version;
+
+} my_comp_master;
+
+typedef my_comp_master *my_master_ptr;
diff --git a/contrib/libs/libjpeg-turbo/jcomapi.c b/contrib/libs/libjpeg-turbo/src/jcomapi.c
index efbb8357b0c..84f37e172ec 100644
--- a/contrib/libs/libjpeg-turbo/jcomapi.c
+++ b/contrib/libs/libjpeg-turbo/src/jcomapi.c
@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1997, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -51,6 +51,7 @@ jpeg_abort(j_common_ptr cinfo)
* A bit kludgy to do it here, but this is the most central place.
*/
((j_decompress_ptr)cinfo)->marker_list = NULL;
+ ((j_decompress_ptr)cinfo)->master->marker_list_end = NULL;
} else {
cinfo->global_state = CSTATE_START;
}
diff --git a/contrib/libs/libjpeg-turbo/src/jconfig.h b/contrib/libs/libjpeg-turbo/src/jconfig.h
new file mode 100644
index 00000000000..7450af2554f
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jconfig.h
@@ -0,0 +1 @@
+#include "../jconfig.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libjpeg-turbo/jcparam.c b/contrib/libs/libjpeg-turbo/src/jcparam.c
index 5bc7174dcb5..d74623c207c 100644
--- a/contrib/libs/libjpeg-turbo/jcparam.c
+++ b/contrib/libs/libjpeg-turbo/src/jcparam.c
@@ -4,8 +4,10 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2008 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2018, D. R. Commander.
+ * Copyright (C) 2009-2011, 2018, 2023-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -202,7 +204,6 @@ jpeg_set_defaults(j_compress_ptr cinfo)
cinfo->scale_num = 1; /* 1:1 scaling */
cinfo->scale_denom = 1;
#endif
- cinfo->data_precision = BITS_IN_JSAMPLE;
/* Set up two quantization tables using default quality of 75 */
jpeg_set_quality(cinfo, 75, TRUE);
/* Set up two Huffman tables */
@@ -219,6 +220,9 @@ jpeg_set_defaults(j_compress_ptr cinfo)
cinfo->scan_info = NULL;
cinfo->num_scans = 0;
+ /* Default is lossy output */
+ cinfo->master->lossless = FALSE;
+
/* Expect normal source image, not raw downsampled data */
cinfo->raw_data_in = FALSE;
@@ -232,7 +236,7 @@ jpeg_set_defaults(j_compress_ptr cinfo)
* tables will be computed. This test can be removed if default tables
* are supplied that are valid for the desired precision.
*/
- if (cinfo->data_precision > 8)
+ if (cinfo->data_precision == 12)
cinfo->optimize_coding = TRUE;
/* By default, use the simpler non-cosited sampling alignment */
@@ -296,7 +300,12 @@ jpeg_default_colorspace(j_compress_ptr cinfo)
case JCS_EXT_BGRA:
case JCS_EXT_ABGR:
case JCS_EXT_ARGB:
- jpeg_set_colorspace(cinfo, JCS_YCbCr);
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless)
+ jpeg_set_colorspace(cinfo, JCS_RGB);
+ else
+#endif
+ jpeg_set_colorspace(cinfo, JCS_YCbCr);
break;
case JCS_YCbCr:
jpeg_set_colorspace(cinfo, JCS_YCbCr);
@@ -475,6 +484,13 @@ jpeg_simple_progression(j_compress_ptr cinfo)
if (cinfo->global_state != CSTATE_START)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+ cinfo->master->lossless = FALSE;
+ jpeg_default_colorspace(cinfo);
+ }
+#endif
+
/* Figure space needed for script. Calculation must match code below! */
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
/* Custom script for YCbCr color images. */
@@ -539,3 +555,38 @@ jpeg_simple_progression(j_compress_ptr cinfo)
}
#endif /* C_PROGRESSIVE_SUPPORTED */
+
+
+#ifdef C_LOSSLESS_SUPPORTED
+
+/*
+ * Enable lossless mode.
+ */
+
+GLOBAL(void)
+jpeg_enable_lossless(j_compress_ptr cinfo, int predictor_selection_value,
+ int point_transform)
+{
+ /* Safety check to ensure start_compress not called yet. */
+ if (cinfo->global_state != CSTATE_START)
+ ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
+
+ cinfo->master->lossless = TRUE;
+ cinfo->Ss = predictor_selection_value;
+ cinfo->Se = 0;
+ cinfo->Ah = 0;
+ cinfo->Al = point_transform;
+
+ /* The JPEG spec simply gives the range 0..15 for Al (Pt), but that seems
+ * wrong: the upper bound ought to depend on data precision. Perhaps they
+ * really meant 0..N-1 for N-bit precision, which is what we allow here.
+ * Values greater than or equal to the data precision will result in a blank
+ * image.
+ */
+ if (cinfo->Ss < 1 || cinfo->Ss > 7 ||
+ cinfo->Al < 0 || cinfo->Al >= cinfo->data_precision)
+ ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
+ cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
+}
+
+#endif /* C_LOSSLESS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jcphuff.c b/contrib/libs/libjpeg-turbo/src/jcphuff.c
index 872e570bff0..58287328d2d 100644
--- a/contrib/libs/libjpeg-turbo/jcphuff.c
+++ b/contrib/libs/libjpeg-turbo/src/jcphuff.c
@@ -3,9 +3,11 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2018, 2021-2022, D. R. Commander.
- * Copyright (C) 2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2011, 2015, 2018, 2021-2022, 2024, D. R. Commander.
+ * Copyright (C) 2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
* Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -21,8 +23,11 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#ifdef WITH_SIMD
#include "jsimd.h"
-#include "jconfigint.h"
+#else
+#include "jchuff.h" /* Declarations shared with jc*huff.c */
+#endif
#include <limits.h>
#ifdef HAVE_INTRIN_H
@@ -39,40 +44,7 @@
#ifdef C_PROGRESSIVE_SUPPORTED
-/*
- * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
- * used for bit counting rather than the lookup table. This will reduce the
- * memory footprint by 64k, which is important for some mobile applications
- * that create many isolated instances of libjpeg-turbo (web browsers, for
- * instance.) This may improve performance on some mobile platforms as well.
- * This feature is enabled by default only on Arm processors, because some x86
- * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
- * shown to have a significant performance impact even on the x86 chips that
- * have a fast implementation of it. When building for Armv6, you can
- * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
- * flags (this defines __thumb__).
- */
-
-/* NOTE: Both GCC and Clang define __GNUC__ */
-#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
- defined(_M_ARM) || defined(_M_ARM64)
-#if !defined(__thumb__) || defined(__thumb2__)
-#define USE_CLZ_INTRINSIC
-#endif
-#endif
-
-#ifdef USE_CLZ_INTRINSIC
-#if defined(_MSC_VER) && !defined(__clang__)
-#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
-#else
-#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
-#endif
-#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
-#else
-#include "jpeg_nbits_table.h"
-#define JPEG_NBITS(x) (jpeg_nbits_table[x])
-#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
-#endif
+#include "jpeg_nbits.h"
/* Expanded entropy encoder object for progressive Huffman encoding. */
@@ -83,11 +55,11 @@ typedef struct {
/* Pointer to routine to prepare data for encode_mcu_AC_first() */
void (*AC_first_prepare) (const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *zerobits);
+ int Al, UJCOEF *values, size_t *zerobits);
/* Pointer to routine to prepare data for encode_mcu_AC_refine() */
int (*AC_refine_prepare) (const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits);
+ int Al, UJCOEF *absvalues, size_t *bits);
/* Mode flag: TRUE for optimization, FALSE for actual data output */
boolean gather_statistics;
@@ -157,14 +129,14 @@ METHODDEF(boolean) encode_mcu_DC_first(j_compress_ptr cinfo,
JBLOCKROW *MCU_data);
METHODDEF(void) encode_mcu_AC_first_prepare
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
+ UJCOEF *values, size_t *zerobits);
METHODDEF(boolean) encode_mcu_AC_first(j_compress_ptr cinfo,
JBLOCKROW *MCU_data);
METHODDEF(boolean) encode_mcu_DC_refine(j_compress_ptr cinfo,
JBLOCKROW *MCU_data);
METHODDEF(int) encode_mcu_AC_refine_prepare
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
+ UJCOEF *absvalues, size_t *bits);
METHODDEF(boolean) encode_mcu_AC_refine(j_compress_ptr cinfo,
JBLOCKROW *MCU_data);
METHODDEF(void) finish_pass_phuff(j_compress_ptr cinfo);
@@ -224,18 +196,22 @@ start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
entropy->pub.encode_mcu = encode_mcu_DC_first;
else
entropy->pub.encode_mcu = encode_mcu_AC_first;
+#ifdef WITH_SIMD
if (jsimd_can_encode_mcu_AC_first_prepare())
entropy->AC_first_prepare = jsimd_encode_mcu_AC_first_prepare;
else
+#endif
entropy->AC_first_prepare = encode_mcu_AC_first_prepare;
} else {
if (is_DC_band)
entropy->pub.encode_mcu = encode_mcu_DC_refine;
else {
entropy->pub.encode_mcu = encode_mcu_AC_refine;
+#ifdef WITH_SIMD
if (jsimd_can_encode_mcu_AC_refine_prepare())
entropy->AC_refine_prepare = jsimd_encode_mcu_AC_refine_prepare;
else
+#endif
entropy->AC_refine_prepare = encode_mcu_AC_refine_prepare;
/* AC refinement needs a correction bit buffer */
if (entropy->bit_buffer == NULL)
@@ -490,6 +466,7 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
JBLOCKROW block;
jpeg_component_info *compptr;
ISHIFT_TEMPS
+ int max_coef_bits = cinfo->data_precision + 2;
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
@@ -532,7 +509,7 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
/* Check for out-of-range coefficient values.
* Since we're encoding a difference, the range limit is twice as much.
*/
- if (nbits > MAX_COEF_BITS + 1)
+ if (nbits > max_coef_bits + 1)
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
/* Count/emit the Huffman-coded symbol for the number of bits */
@@ -584,8 +561,8 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
continue; \
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */ \
temp2 ^= temp; \
- values[k] = (JCOEF)temp; \
- values[k + DCTSIZE2] = (JCOEF)temp2; \
+ values[k] = (UJCOEF)temp; \
+ values[k + DCTSIZE2] = (UJCOEF)temp2; \
zerobits |= ((size_t)1U) << k; \
} \
}
@@ -593,7 +570,7 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
METHODDEF(void)
encode_mcu_AC_first_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *values, size_t *bits)
+ int Al, UJCOEF *values, size_t *bits)
{
register int k, temp, temp2;
size_t zerobits = 0U;
@@ -643,7 +620,7 @@ label \
/* Find the number of bits needed for the magnitude of the coefficient */ \
nbits = JPEG_NBITS_NONZERO(temp); /* there must be at least one 1 bit */ \
/* Check for out-of-range coefficient values */ \
- if (nbits > MAX_COEF_BITS) \
+ if (nbits > max_coef_bits) \
ERREXIT(cinfo, JERR_BAD_DCT_COEF); \
\
/* Count/emit Huffman symbol for run length / number of bits */ \
@@ -666,11 +643,17 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
register int nbits, r;
int Sl = cinfo->Se - cinfo->Ss + 1;
int Al = cinfo->Al;
- JCOEF values_unaligned[2 * DCTSIZE2 + 15];
- JCOEF *values;
- const JCOEF *cvalue;
+ UJCOEF values_unaligned[2 * DCTSIZE2 + 15];
+ UJCOEF *values;
+ const UJCOEF *cvalue;
size_t zerobits;
size_t bits[8 / SIZEOF_SIZE_T];
+ int max_coef_bits = cinfo->data_precision + 2;
+
+#ifdef ZERO_BUFFERS
+ memset(values_unaligned, 0, sizeof(values_unaligned));
+ memset(bits, 0, sizeof(bits));
+#endif
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
@@ -681,7 +664,7 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
emit_restart(entropy, entropy->next_restart_num);
#ifdef WITH_SIMD
- cvalue = values = (JCOEF *)PAD((JUINTPTR)values_unaligned, 16);
+ cvalue = values = (UJCOEF *)PAD((JUINTPTR)values_unaligned, 16);
#else
/* Not using SIMD, so alignment is not needed */
cvalue = values = values_unaligned;
@@ -815,7 +798,7 @@ encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
zerobits |= ((size_t)1U) << k; \
signbits |= ((size_t)(temp2 + 1)) << k; \
} \
- absvalues[k] = (JCOEF)temp; /* save abs value for main pass */ \
+ absvalues[k] = (UJCOEF)temp; /* save abs value for main pass */ \
if (temp == 1) \
EOB = k + koffset; /* EOB = index of last newly-nonzero coef */ \
} \
@@ -824,7 +807,7 @@ encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
METHODDEF(int)
encode_mcu_AC_refine_prepare(const JCOEF *block,
const int *jpeg_natural_order_start, int Sl,
- int Al, JCOEF *absvalues, size_t *bits)
+ int Al, UJCOEF *absvalues, size_t *bits)
{
register int k, temp, temp2;
int EOB = 0;
@@ -931,12 +914,17 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
unsigned int BR;
int Sl = cinfo->Se - cinfo->Ss + 1;
int Al = cinfo->Al;
- JCOEF absvalues_unaligned[DCTSIZE2 + 15];
- JCOEF *absvalues;
- const JCOEF *cabsvalue, *EOBPTR;
+ UJCOEF absvalues_unaligned[DCTSIZE2 + 15];
+ UJCOEF *absvalues;
+ const UJCOEF *cabsvalue, *EOBPTR;
size_t zerobits, signbits;
size_t bits[16 / SIZEOF_SIZE_T];
+#ifdef ZERO_BUFFERS
+ memset(absvalues_unaligned, 0, sizeof(absvalues_unaligned));
+ memset(bits, 0, sizeof(bits));
+#endif
+
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
@@ -946,7 +934,7 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
emit_restart(entropy, entropy->next_restart_num);
#ifdef WITH_SIMD
- cabsvalue = absvalues = (JCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
+ cabsvalue = absvalues = (UJCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
#else
/* Not using SIMD, so alignment is not needed */
cabsvalue = absvalues = absvalues_unaligned;
diff --git a/contrib/libs/libjpeg-turbo/jcprepct.c b/contrib/libs/libjpeg-turbo/src/jcprepct.c
index f27cc345079..725856d7383 100644
--- a/contrib/libs/libjpeg-turbo/jcprepct.c
+++ b/contrib/libs/libjpeg-turbo/src/jcprepct.c
@@ -1,10 +1,12 @@
/*
* jcprepct.c
*
- * This file is part of the Independent JPEG Group's software:
+ * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -20,8 +22,11 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
+
/* At present, jcsample.c can request context rows only for smoothing.
* In the future, we might also need context rows for CCIR601 sampling
* or other more-complex downsampling procedures. The code to support
@@ -59,7 +64,7 @@ typedef struct {
/* Downsampling input buffer. This buffer holds color-converted data
* until we have enough to do a downsample step.
*/
- JSAMPARRAY color_buf[MAX_COMPONENTS];
+ _JSAMPARRAY color_buf[MAX_COMPONENTS];
JDIMENSION rows_to_go; /* counts rows remaining in source image */
int next_buf_row; /* index of next row to store in color_buf */
@@ -106,14 +111,14 @@ start_pass_prep(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
*/
LOCAL(void)
-expand_bottom_edge(JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows,
+expand_bottom_edge(_JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows,
int output_rows)
{
register int row;
for (row = input_rows; row < output_rows; row++) {
- jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
- num_cols);
+ _jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
+ num_cols);
}
}
@@ -128,15 +133,16 @@ expand_bottom_edge(JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows,
*/
METHODDEF(void)
-pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
+pre_process_data(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
+ _JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
JDIMENSION out_row_groups_avail)
{
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
int numrows, ci;
JDIMENSION inrows;
jpeg_component_info *compptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
while (*in_row_ctr < in_rows_avail &&
*out_row_group_ctr < out_row_groups_avail) {
@@ -144,10 +150,10 @@ pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
inrows = in_rows_avail - *in_row_ctr;
numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
numrows = (int)MIN((JDIMENSION)numrows, inrows);
- (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
- prep->color_buf,
- (JDIMENSION)prep->next_buf_row,
- numrows);
+ (*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
+ prep->color_buf,
+ (JDIMENSION)prep->next_buf_row,
+ numrows);
*in_row_ctr += numrows;
prep->next_buf_row += numrows;
prep->rows_to_go -= numrows;
@@ -162,9 +168,9 @@ pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
}
/* If we've filled the conversion buffer, empty it. */
if (prep->next_buf_row == cinfo->max_v_samp_factor) {
- (*cinfo->downsample->downsample) (cinfo,
- prep->color_buf, (JDIMENSION)0,
- output_buf, *out_row_group_ctr);
+ (*cinfo->downsample->_downsample) (cinfo,
+ prep->color_buf, (JDIMENSION)0,
+ output_buf, *out_row_group_ctr);
prep->next_buf_row = 0;
(*out_row_group_ctr)++;
}
@@ -174,7 +180,8 @@ pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- expand_bottom_edge(output_buf[ci], compptr->width_in_blocks * DCTSIZE,
+ expand_bottom_edge(output_buf[ci],
+ compptr->width_in_blocks * data_unit,
(int)(*out_row_group_ctr * compptr->v_samp_factor),
(int)(out_row_groups_avail * compptr->v_samp_factor));
}
@@ -192,9 +199,9 @@ pre_process_data(j_compress_ptr cinfo, JSAMPARRAY input_buf,
*/
METHODDEF(void)
-pre_process_context(j_compress_ptr cinfo, JSAMPARRAY input_buf,
+pre_process_context(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
- JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
+ _JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
JDIMENSION out_row_groups_avail)
{
my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
@@ -208,17 +215,17 @@ pre_process_context(j_compress_ptr cinfo, JSAMPARRAY input_buf,
inrows = in_rows_avail - *in_row_ctr;
numrows = prep->next_buf_stop - prep->next_buf_row;
numrows = (int)MIN((JDIMENSION)numrows, inrows);
- (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr,
- prep->color_buf,
- (JDIMENSION)prep->next_buf_row,
- numrows);
+ (*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
+ prep->color_buf,
+ (JDIMENSION)prep->next_buf_row,
+ numrows);
/* Pad at top of image, if first time through */
if (prep->rows_to_go == cinfo->image_height) {
for (ci = 0; ci < cinfo->num_components; ci++) {
int row;
for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
- jcopy_sample_rows(prep->color_buf[ci], 0, prep->color_buf[ci],
- -row, 1, cinfo->image_width);
+ _jcopy_sample_rows(prep->color_buf[ci], 0, prep->color_buf[ci],
+ -row, 1, cinfo->image_width);
}
}
}
@@ -240,9 +247,9 @@ pre_process_context(j_compress_ptr cinfo, JSAMPARRAY input_buf,
}
/* If we've gotten enough data, downsample a row group. */
if (prep->next_buf_row == prep->next_buf_stop) {
- (*cinfo->downsample->downsample) (cinfo, prep->color_buf,
- (JDIMENSION)prep->this_row_group,
- output_buf, *out_row_group_ctr);
+ (*cinfo->downsample->_downsample) (cinfo, prep->color_buf,
+ (JDIMENSION)prep->this_row_group,
+ output_buf, *out_row_group_ctr);
(*out_row_group_ctr)++;
/* Advance pointers with wraparound as necessary. */
prep->this_row_group += cinfo->max_v_samp_factor;
@@ -267,15 +274,16 @@ create_context_buffer(j_compress_ptr cinfo)
int rgroup_height = cinfo->max_v_samp_factor;
int ci, i;
jpeg_component_info *compptr;
- JSAMPARRAY true_buffer, fake_buffer;
+ _JSAMPARRAY true_buffer, fake_buffer;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
/* Grab enough space for fake row pointers for all the components;
* we need five row groups' worth of pointers for each component.
*/
- fake_buffer = (JSAMPARRAY)
+ fake_buffer = (_JSAMPARRAY)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(cinfo->num_components * 5 * rgroup_height) *
- sizeof(JSAMPROW));
+ sizeof(_JSAMPROW));
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
@@ -283,14 +291,14 @@ create_context_buffer(j_compress_ptr cinfo)
* We make the buffer wide enough to allow the downsampler to edge-expand
* horizontally within the buffer, if it so chooses.
*/
- true_buffer = (*cinfo->mem->alloc_sarray)
+ true_buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
+ (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
cinfo->max_h_samp_factor) / compptr->h_samp_factor),
(JDIMENSION)(3 * rgroup_height));
/* Copy true buffer row pointers into the middle of the fake row array */
memcpy(fake_buffer + rgroup_height, true_buffer,
- 3 * rgroup_height * sizeof(JSAMPROW));
+ 3 * rgroup_height * sizeof(_JSAMPROW));
/* Fill in the above and below wraparound pointers */
for (i = 0; i < rgroup_height; i++) {
fake_buffer[i] = true_buffer[2 * rgroup_height + i];
@@ -309,11 +317,28 @@ create_context_buffer(j_compress_ptr cinfo)
*/
GLOBAL(void)
-jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
+_jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
{
my_prep_ptr prep;
int ci;
jpeg_component_info *compptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
if (need_full_buffer) /* safety check */
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
@@ -331,21 +356,23 @@ jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
if (cinfo->downsample->need_context_rows) {
/* Set up to provide context rows */
#ifdef CONTEXT_ROWS_SUPPORTED
- prep->pub.pre_process_data = pre_process_context;
+ prep->pub._pre_process_data = pre_process_context;
create_context_buffer(cinfo);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else {
/* No context, just make it tall enough for one row group */
- prep->pub.pre_process_data = pre_process_data;
+ prep->pub._pre_process_data = pre_process_data;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
- prep->color_buf[ci] = (*cinfo->mem->alloc_sarray)
+ prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(((long)compptr->width_in_blocks * DCTSIZE *
+ (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
cinfo->max_h_samp_factor) / compptr->h_samp_factor),
(JDIMENSION)cinfo->max_v_samp_factor);
}
}
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jcsample.c b/contrib/libs/libjpeg-turbo/src/jcsample.c
index e8515ebf0fc..ca3bea131f5 100644
--- a/contrib/libs/libjpeg-turbo/jcsample.c
+++ b/contrib/libs/libjpeg-turbo/src/jcsample.c
@@ -3,10 +3,12 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
* Copyright (C) 2014, MIPS Technologies, Inc., California.
- * Copyright (C) 2015, 2019, D. R. Commander.
+ * Copyright (C) 2015, 2019, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -54,13 +56,16 @@
#include "jinclude.h"
#include "jpeglib.h"
#include "jsimd.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
+
/* Pointer to routine to downsample a single component */
typedef void (*downsample1_ptr) (j_compress_ptr cinfo,
jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY output_data);
+ _JSAMPARRAY input_data,
+ _JSAMPARRAY output_data);
/* Private subobject */
@@ -91,11 +96,11 @@ start_pass_downsample(j_compress_ptr cinfo)
*/
LOCAL(void)
-expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols,
+expand_right_edge(_JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols,
JDIMENSION output_cols)
{
- register JSAMPROW ptr;
- register JSAMPLE pixval;
+ register _JSAMPROW ptr;
+ register _JSAMPLE pixval;
register int count;
int row;
int numcols = (int)(output_cols - input_cols);
@@ -118,14 +123,14 @@ expand_right_edge(JSAMPARRAY image_data, int num_rows, JDIMENSION input_cols,
*/
METHODDEF(void)
-sep_downsample(j_compress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_index, JSAMPIMAGE output_buf,
+sep_downsample(j_compress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_index, _JSAMPIMAGE output_buf,
JDIMENSION out_row_group_index)
{
my_downsample_ptr downsample = (my_downsample_ptr)cinfo->downsample;
int ci;
jpeg_component_info *compptr;
- JSAMPARRAY in_ptr, out_ptr;
+ _JSAMPARRAY in_ptr, out_ptr;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
@@ -145,12 +150,13 @@ sep_downsample(j_compress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
int_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
+ _JSAMPARRAY input_data, _JSAMPARRAY output_data)
{
int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- JSAMPROW inptr, outptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+ JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
+ _JSAMPROW inptr, outptr;
JLONG outvalue;
h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
@@ -177,7 +183,7 @@ int_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
outvalue += (JLONG)(*inptr++);
}
}
- *outptr++ = (JSAMPLE)((outvalue + numpix2) / numpix);
+ *outptr++ = (_JSAMPLE)((outvalue + numpix2) / numpix);
}
inrow += v_expand;
}
@@ -192,14 +198,16 @@ int_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
+ _JSAMPARRAY input_data, _JSAMPARRAY output_data)
{
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+
/* Copy the data */
- jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
- cinfo->image_width);
+ _jcopy_sample_rows(input_data, 0, output_data, 0, cinfo->max_v_samp_factor,
+ cinfo->image_width);
/* Edge-expand */
expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
- compptr->width_in_blocks * DCTSIZE);
+ compptr->width_in_blocks * data_unit);
}
@@ -217,12 +225,13 @@ fullsize_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
+ _JSAMPARRAY input_data, _JSAMPARRAY output_data)
{
int outrow;
JDIMENSION outcol;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr, outptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+ JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
+ register _JSAMPROW inptr, outptr;
register int bias;
/* Expand input data enough to let all the output samples be generated
@@ -237,7 +246,7 @@ h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
inptr = input_data[outrow];
bias = 0; /* bias = 0,1,0,1,... for successive samples */
for (outcol = 0; outcol < output_cols; outcol++) {
- *outptr++ = (JSAMPLE)((inptr[0] + inptr[1] + bias) >> 1);
+ *outptr++ = (_JSAMPLE)((inptr[0] + inptr[1] + bias) >> 1);
bias ^= 1; /* 0=>1, 1=>0 */
inptr += 2;
}
@@ -253,12 +262,13 @@ h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
+ _JSAMPARRAY input_data, _JSAMPARRAY output_data)
{
int inrow, outrow;
JDIMENSION outcol;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr0, inptr1, outptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+ JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
+ register _JSAMPROW inptr0, inptr1, outptr;
register int bias;
/* Expand input data enough to let all the output samples be generated
@@ -275,8 +285,8 @@ h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
inptr1 = input_data[inrow + 1];
bias = 1; /* bias = 1,2,1,2,... for successive samples */
for (outcol = 0; outcol < output_cols; outcol++) {
- *outptr++ =
- (JSAMPLE)((inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1] + bias) >> 2);
+ *outptr++ = (_JSAMPLE)
+ ((inptr0[0] + inptr0[1] + inptr1[0] + inptr1[1] + bias) >> 2);
bias ^= 3; /* 1=>2, 2=>1 */
inptr0 += 2; inptr1 += 2;
}
@@ -295,12 +305,13 @@ h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
+ _JSAMPARRAY input_data, _JSAMPARRAY output_data)
{
int inrow, outrow;
JDIMENSION colctr;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+ JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
+ register _JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
JLONG membersum, neighsum, memberscale, neighscale;
/* Expand input data enough to let all the output samples be generated
@@ -341,7 +352,7 @@ h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
neighsum += neighsum;
neighsum += above_ptr[0] + above_ptr[2] + below_ptr[0] + below_ptr[2];
membersum = membersum * memberscale + neighsum * neighscale;
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
+ *outptr++ = (_JSAMPLE)((membersum + 32768) >> 16);
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
for (colctr = output_cols - 2; colctr > 0; colctr--) {
@@ -357,7 +368,7 @@ h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
/* form final output scaled up by 2^16 */
membersum = membersum * memberscale + neighsum * neighscale;
/* round, descale and output it */
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
+ *outptr++ = (_JSAMPLE)((membersum + 32768) >> 16);
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
}
@@ -368,7 +379,7 @@ h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
neighsum += neighsum;
neighsum += above_ptr[-1] + above_ptr[1] + below_ptr[-1] + below_ptr[1];
membersum = membersum * memberscale + neighsum * neighscale;
- *outptr = (JSAMPLE)((membersum + 32768) >> 16);
+ *outptr = (_JSAMPLE)((membersum + 32768) >> 16);
inrow += 2;
}
@@ -383,12 +394,13 @@ h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY output_data)
+ _JSAMPARRAY input_data, _JSAMPARRAY output_data)
{
int outrow;
JDIMENSION colctr;
- JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
- register JSAMPROW inptr, above_ptr, below_ptr, outptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
+ JDIMENSION output_cols = compptr->width_in_blocks * data_unit;
+ register _JSAMPROW inptr, above_ptr, below_ptr, outptr;
JLONG membersum, neighsum, memberscale, neighscale;
int colsum, lastcolsum, nextcolsum;
@@ -420,7 +432,7 @@ fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
nextcolsum = above_ptr[0] + below_ptr[0] + inptr[0];
neighsum = colsum + (colsum - membersum) + nextcolsum;
membersum = membersum * memberscale + neighsum * neighscale;
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
+ *outptr++ = (_JSAMPLE)((membersum + 32768) >> 16);
lastcolsum = colsum; colsum = nextcolsum;
for (colctr = output_cols - 2; colctr > 0; colctr--) {
@@ -429,7 +441,7 @@ fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
nextcolsum = above_ptr[0] + below_ptr[0] + inptr[0];
neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
membersum = membersum * memberscale + neighsum * neighscale;
- *outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
+ *outptr++ = (_JSAMPLE)((membersum + 32768) >> 16);
lastcolsum = colsum; colsum = nextcolsum;
}
@@ -437,7 +449,7 @@ fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
membersum = *inptr;
neighsum = lastcolsum + (colsum - membersum) + colsum;
membersum = membersum * memberscale + neighsum * neighscale;
- *outptr = (JSAMPLE)((membersum + 32768) >> 16);
+ *outptr = (_JSAMPLE)((membersum + 32768) >> 16);
}
}
@@ -451,19 +463,35 @@ fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jinit_downsampler(j_compress_ptr cinfo)
+_jinit_downsampler(j_compress_ptr cinfo)
{
my_downsample_ptr downsample;
int ci;
jpeg_component_info *compptr;
boolean smoothok = TRUE;
+#ifdef C_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
downsample = (my_downsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_downsampler));
cinfo->downsample = (struct jpeg_downsampler *)downsample;
downsample->pub.start_pass = start_pass_downsample;
- downsample->pub.downsample = sep_downsample;
+ downsample->pub._downsample = sep_downsample;
downsample->pub.need_context_rows = FALSE;
if (cinfo->CCIR601_sampling)
@@ -484,15 +512,17 @@ jinit_downsampler(j_compress_ptr cinfo)
} else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
compptr->v_samp_factor == cinfo->max_v_samp_factor) {
smoothok = FALSE;
+#ifdef WITH_SIMD
if (jsimd_can_h2v1_downsample())
downsample->methods[ci] = jsimd_h2v1_downsample;
else
+#endif
downsample->methods[ci] = h2v1_downsample;
} else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
#ifdef INPUT_SMOOTHING_SUPPORTED
if (cinfo->smoothing_factor) {
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_can_h2v2_smooth_downsample())
downsample->methods[ci] = jsimd_h2v2_smooth_downsample;
else
@@ -502,9 +532,11 @@ jinit_downsampler(j_compress_ptr cinfo)
} else
#endif
{
+#ifdef WITH_SIMD
if (jsimd_can_h2v2_downsample())
downsample->methods[ci] = jsimd_h2v2_downsample;
else
+#endif
downsample->methods[ci] = h2v2_downsample;
}
} else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
@@ -520,3 +552,5 @@ jinit_downsampler(j_compress_ptr cinfo)
TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);
#endif
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jctrans.c b/contrib/libs/libjpeg-turbo/src/jctrans.c
index e121028ec70..ae52e3989ee 100644
--- a/contrib/libs/libjpeg-turbo/jctrans.c
+++ b/contrib/libs/libjpeg-turbo/src/jctrans.c
@@ -17,7 +17,7 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
/* Forward declarations */
@@ -42,6 +42,9 @@ LOCAL(void) transencode_coef_controller(j_compress_ptr cinfo,
GLOBAL(void)
jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
{
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+
if (cinfo->global_state != CSTATE_START)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Mark all tables to be written */
@@ -72,6 +75,9 @@ jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
JQUANT_TBL *c_quant, *slot_quant;
int tblno, ci, coefi;
+ if (srcinfo->master->lossless)
+ ERREXIT(dstinfo, JERR_NOTIMPL);
+
/* Safety check to ensure start_compress not called yet. */
if (dstinfo->global_state != CSTATE_START)
ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state);
@@ -364,6 +370,13 @@ compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
}
+METHODDEF(boolean)
+compress_output_12(j_compress_ptr cinfo, J12SAMPIMAGE input_buf)
+{
+ return compress_output(cinfo, (JSAMPIMAGE)input_buf);
+}
+
+
/*
* Initialize coefficient buffer controller.
*
@@ -386,6 +399,7 @@ transencode_coef_controller(j_compress_ptr cinfo,
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
coef->pub.start_pass = start_pass_coef;
coef->pub.compress_data = compress_output;
+ coef->pub.compress_data_12 = compress_output_12;
/* Save pointer to virtual arrays */
coef->whole_image = coef_arrays;
diff --git a/contrib/libs/libjpeg-turbo/jdapimin.c b/contrib/libs/libjpeg-turbo/src/jdapimin.c
index f50c27edc32..f2419f8adb6 100644
--- a/contrib/libs/libjpeg-turbo/jdapimin.c
+++ b/contrib/libs/libjpeg-turbo/src/jdapimin.c
@@ -3,8 +3,10 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1998, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2022, D. R. Commander.
+ * Copyright (C) 2016, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -23,7 +25,6 @@
#include "jinclude.h"
#include "jpeglib.h"
#include "jdmaster.h"
-#include "jconfigint.h"
/*
@@ -83,6 +84,8 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
/* And initialize the overall input controller. */
jinit_input_controller(cinfo);
+ cinfo->data_precision = BITS_IN_JSAMPLE;
+
/* OK, I'm ready */
cinfo->global_state = DSTATE_START;
@@ -157,13 +160,23 @@ default_decompress_parms(j_decompress_ptr cinfo)
int cid1 = cinfo->comp_info[1].component_id;
int cid2 = cinfo->comp_info[2].component_id;
- if (cid0 == 1 && cid1 == 2 && cid2 == 3)
- cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
- else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
+ if (cid0 == 1 && cid1 == 2 && cid2 == 3) {
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless)
+ cinfo->jpeg_color_space = JCS_RGB; /* assume RGB w/out marker */
+ else
+#endif
+ cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
+ } else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
else {
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
- cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless)
+ cinfo->jpeg_color_space = JCS_RGB; /* assume it's RGB */
+ else
+#endif
+ cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
}
}
/* Always guess RGB is proper output colorspace. */
diff --git a/contrib/libs/libjpeg-turbo/jdapistd.c b/contrib/libs/libjpeg-turbo/src/jdapistd.c
index 02cd0cb93a8..a53b86b1817 100644
--- a/contrib/libs/libjpeg-turbo/jdapistd.c
+++ b/contrib/libs/libjpeg-turbo/src/jdapistd.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2015-2020, 2022, D. R. Commander.
+ * Copyright (C) 2010, 2015-2020, 2022-2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -19,13 +19,20 @@
*/
#include "jinclude.h"
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
#include "jdmainct.h"
#include "jdcoefct.h"
+#else
+#define JPEG_INTERNALS
+#include "jpeglib.h"
+#endif
#include "jdmaster.h"
#include "jdmerge.h"
#include "jdsample.h"
#include "jmemsys.h"
+#if BITS_IN_JSAMPLE == 8
+
/* Forward declarations */
LOCAL(boolean) output_pass_setup(j_decompress_ptr cinfo);
@@ -121,8 +128,28 @@ output_pass_setup(j_decompress_ptr cinfo)
}
/* Process some data */
last_scanline = cinfo->output_scanline;
- (*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
- &cinfo->output_scanline, (JDIMENSION)0);
+ if (cinfo->data_precision <= 8) {
+ if (cinfo->main->process_data == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ (*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
+ &cinfo->output_scanline, (JDIMENSION)0);
+ } else if (cinfo->data_precision <= 12) {
+ if (cinfo->main->process_data_12 == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ (*cinfo->main->process_data_12) (cinfo, (J12SAMPARRAY)NULL,
+ &cinfo->output_scanline,
+ (JDIMENSION)0);
+ } else {
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->main->process_data_16 == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ (*cinfo->main->process_data_16) (cinfo, (J16SAMPARRAY)NULL,
+ &cinfo->output_scanline,
+ (JDIMENSION)0);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+ }
if (cinfo->output_scanline == last_scanline)
return FALSE; /* No progress made, must suspend */
}
@@ -135,25 +162,29 @@ output_pass_setup(j_decompress_ptr cinfo)
#endif /* QUANT_2PASS_SUPPORTED */
}
/* Ready for application to drive output pass through
- * jpeg_read_scanlines or jpeg_read_raw_data.
+ * _jpeg_read_scanlines or _jpeg_read_raw_data.
*/
cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
return TRUE;
}
+#endif /* BITS_IN_JSAMPLE == 8 */
+
+
+#if BITS_IN_JSAMPLE != 16
/*
* Enable partial scanline decompression
*
* Must be called after jpeg_start_decompress() and before any calls to
- * jpeg_read_scanlines() or jpeg_skip_scanlines().
+ * _jpeg_read_scanlines() or _jpeg_skip_scanlines().
*
* Refer to libjpeg.txt for more information.
*/
GLOBAL(void)
-jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
- JDIMENSION *width)
+_jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
+ JDIMENSION *width)
{
int ci, align, orig_downsampled_width;
JDIMENSION input_xoffset;
@@ -163,6 +194,12 @@ jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
my_master_ptr master = (my_master_ptr)cinfo->master;
#endif
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+
if ((cinfo->global_state != DSTATE_SCANNING &&
cinfo->global_state != DSTATE_BUFIMAGE) || cinfo->output_scanline != 0)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
@@ -171,7 +208,8 @@ jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
ERREXIT(cinfo, JERR_BAD_CROP_SPEC);
/* xoffset and width must fall within the output image dimensions. */
- if (*width == 0 || *xoffset + *width > cinfo->output_width)
+ if (*width == 0 ||
+ (unsigned long long)(*xoffset) + *width > cinfo->output_width)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
/* No need to do anything if the caller wants the entire width. */
@@ -236,9 +274,11 @@ jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
/* Set downsampled_width to the new output width. */
orig_downsampled_width = compptr->downsampled_width;
compptr->downsampled_width =
- (JDIMENSION)jdiv_round_up((long)(cinfo->output_width *
- compptr->h_samp_factor),
- (long)cinfo->max_h_samp_factor);
+ (JDIMENSION)jdiv_round_up((long)cinfo->output_width *
+ (long)(compptr->h_samp_factor *
+ compptr->_DCT_scaled_size),
+ (long)(cinfo->max_h_samp_factor *
+ cinfo->_min_DCT_scaled_size));
if (compptr->downsampled_width < 2 && orig_downsampled_width >= 2)
reinit_upsampler = TRUE;
@@ -254,11 +294,13 @@ jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
if (reinit_upsampler) {
cinfo->master->jinit_upsampler_no_alloc = TRUE;
- jinit_upsampler(cinfo);
+ _jinit_upsampler(cinfo);
cinfo->master->jinit_upsampler_no_alloc = FALSE;
}
}
+#endif /* BITS_IN_JSAMPLE != 16 */
+
/*
* Read some scanlines of data from the JPEG decompressor.
@@ -268,17 +310,34 @@ jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
* including bottom of image, data source suspension, and operating
* modes that emit multiple scanlines at a time.
*
- * Note: we warn about excess calls to jpeg_read_scanlines() since
+ * Note: we warn about excess calls to _jpeg_read_scanlines() since
* this likely signals an application programmer error. However,
* an oversize buffer (max_lines > scanlines remaining) is not an error.
*/
GLOBAL(JDIMENSION)
-jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines,
- JDIMENSION max_lines)
+_jpeg_read_scanlines(j_decompress_ptr cinfo, _JSAMPARRAY scanlines,
+ JDIMENSION max_lines)
{
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
JDIMENSION row_ctr;
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
if (cinfo->global_state != DSTATE_SCANNING)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
if (cinfo->output_scanline >= cinfo->output_height) {
@@ -295,30 +354,38 @@ jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines,
/* Process some data */
row_ctr = 0;
- (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);
+ if (cinfo->main->_process_data == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ (*cinfo->main->_process_data) (cinfo, scanlines, &row_ctr, max_lines);
cinfo->output_scanline += row_ctr;
return row_ctr;
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ return 0;
+#endif
}
-/* Dummy color convert function used by jpeg_skip_scanlines() */
+#if BITS_IN_JSAMPLE != 16
+
+/* Dummy color convert function used by _jpeg_skip_scanlines() */
LOCAL(void)
-noop_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+noop_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
}
-/* Dummy quantize function used by jpeg_skip_scanlines() */
+/* Dummy quantize function used by _jpeg_skip_scanlines() */
LOCAL(void)
-noop_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+noop_quantize(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
{
}
/*
- * In some cases, it is best to call jpeg_read_scanlines() and discard the
+ * In some cases, it is best to call _jpeg_read_scanlines() and discard the
* output, rather than skipping the scanlines, because this allows us to
* maintain the internal state of the context-based upsampler. In these cases,
* we set up and tear down a dummy color converter in order to avoid valgrind
@@ -332,27 +399,27 @@ read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
#ifdef UPSAMPLE_MERGING_SUPPORTED
my_master_ptr master = (my_master_ptr)cinfo->master;
#endif
- JSAMPLE dummy_sample[1] = { 0 };
- JSAMPROW dummy_row = dummy_sample;
- JSAMPARRAY scanlines = NULL;
- void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+ _JSAMPLE dummy_sample[1] = { 0 };
+ _JSAMPROW dummy_row = dummy_sample;
+ _JSAMPARRAY scanlines = NULL;
+ void (*color_convert) (j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows) = NULL;
- void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows) = NULL;
+ void (*color_quantize) (j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows) = NULL;
- if (cinfo->cconvert && cinfo->cconvert->color_convert) {
- color_convert = cinfo->cconvert->color_convert;
- cinfo->cconvert->color_convert = noop_convert;
+ if (cinfo->cconvert && cinfo->cconvert->_color_convert) {
+ color_convert = cinfo->cconvert->_color_convert;
+ cinfo->cconvert->_color_convert = noop_convert;
/* This just prevents UBSan from complaining about adding 0 to a NULL
* pointer. The pointer isn't actually used.
*/
scanlines = &dummy_row;
}
- if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
- color_quantize = cinfo->cquantize->color_quantize;
- cinfo->cquantize->color_quantize = noop_quantize;
+ if (cinfo->cquantize && cinfo->cquantize->_color_quantize) {
+ color_quantize = cinfo->cquantize->_color_quantize;
+ cinfo->cquantize->_color_quantize = noop_quantize;
}
#ifdef UPSAMPLE_MERGING_SUPPORTED
@@ -363,19 +430,19 @@ read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
#endif
for (n = 0; n < num_lines; n++)
- jpeg_read_scanlines(cinfo, scanlines, 1);
+ _jpeg_read_scanlines(cinfo, scanlines, 1);
if (color_convert)
- cinfo->cconvert->color_convert = color_convert;
+ cinfo->cconvert->_color_convert = color_convert;
if (color_quantize)
- cinfo->cquantize->color_quantize = color_quantize;
+ cinfo->cquantize->_color_quantize = color_quantize;
}
/*
- * Called by jpeg_skip_scanlines(). This partially skips a decompress block by
- * incrementing the rowgroup counter.
+ * Called by _jpeg_skip_scanlines(). This partially skips a decompress block
+ * by incrementing the rowgroup counter.
*/
LOCAL(void)
@@ -414,7 +481,7 @@ increment_simple_rowgroup_ctr(j_decompress_ptr cinfo, JDIMENSION rows)
*/
GLOBAL(JDIMENSION)
-jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
+_jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
{
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
@@ -425,6 +492,12 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
JDIMENSION lines_per_iMCU_row, lines_left_in_iMCU_row, lines_after_iMCU_row;
JDIMENSION lines_to_skip, lines_to_read;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+
/* Two-pass color quantization is not supported. */
if (cinfo->quantize_colors && cinfo->two_pass_quantize)
ERREXIT(cinfo, JERR_NOTIMPL);
@@ -433,7 +506,8 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Do not skip past the bottom of the image. */
- if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
+ if ((unsigned long long)cinfo->output_scanline + num_lines >=
+ cinfo->output_height) {
num_lines = cinfo->output_height - cinfo->output_scanline;
cinfo->output_scanline = cinfo->output_height;
(*cinfo->inputctl->finish_input_pass) (cinfo);
@@ -597,11 +671,17 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
*/
GLOBAL(JDIMENSION)
-jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
- JDIMENSION max_lines)
+_jpeg_read_raw_data(j_decompress_ptr cinfo, _JSAMPIMAGE data,
+ JDIMENSION max_lines)
{
JDIMENSION lines_per_iMCU_row;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+
if (cinfo->global_state != DSTATE_RAW_OK)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
if (cinfo->output_scanline >= cinfo->output_height) {
@@ -622,7 +702,9 @@ jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
ERREXIT(cinfo, JERR_BUFFER_SIZE);
/* Decompress directly into user's buffer. */
- if (!(*cinfo->coef->decompress_data) (cinfo, data))
+ if (cinfo->coef->_decompress_data == NULL)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ if (!(*cinfo->coef->_decompress_data) (cinfo, data))
return 0; /* suspension forced, can do nothing more */
/* OK, we processed one iMCU row. */
@@ -630,6 +712,10 @@ jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
return lines_per_iMCU_row;
}
+#endif /* BITS_IN_JSAMPLE != 16 */
+
+
+#if BITS_IN_JSAMPLE == 8
/* Additional entry points for buffered-image mode. */
@@ -687,3 +773,5 @@ jpeg_finish_output(j_decompress_ptr cinfo)
}
#endif /* D_MULTISCAN_FILES_SUPPORTED */
+
+#endif /* BITS_IN_JSAMPLE == 8 */
diff --git a/contrib/libs/libjpeg-turbo/jdarith.c b/contrib/libs/libjpeg-turbo/src/jdarith.c
index 21575e80c72..21575e80c72 100644
--- a/contrib/libs/libjpeg-turbo/jdarith.c
+++ b/contrib/libs/libjpeg-turbo/src/jdarith.c
diff --git a/contrib/libs/libjpeg-turbo/jdatadst-tj.c b/contrib/libs/libjpeg-turbo/src/jdatadst-tj.c
index e10d98127bf..270b2c2c3ea 100644
--- a/contrib/libs/libjpeg-turbo/jdatadst-tj.c
+++ b/contrib/libs/libjpeg-turbo/src/jdatadst-tj.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2012 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2014, 2016, 2019, 2022, D. R. Commander.
+ * Copyright (C) 2011, 2014, 2016, 2019, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -19,12 +19,13 @@
*/
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
+#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"
void jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
- unsigned long *outsize, boolean alloc);
+ size_t *outsize, boolean alloc);
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
@@ -36,7 +37,7 @@ typedef struct {
struct jpeg_destination_mgr pub; /* public fields */
unsigned char **outbuffer; /* target buffer */
- unsigned long *outsize;
+ size_t *outsize;
unsigned char *newbuffer; /* newly allocated buffer */
JOCTET *buffer; /* start of buffer */
size_t bufsize;
@@ -92,7 +93,7 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
/* Try to allocate new buffer with double size */
nextsize = dest->bufsize * 2;
- nextbuffer = (JOCTET *)malloc(nextsize);
+ nextbuffer = (JOCTET *)MALLOC(nextsize);
if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
@@ -128,7 +129,7 @@ term_mem_destination(j_compress_ptr cinfo)
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
if (dest->alloc) *dest->outbuffer = dest->buffer;
- *dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
+ *dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
}
@@ -145,7 +146,7 @@ term_mem_destination(j_compress_ptr cinfo)
GLOBAL(void)
jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
- unsigned long *outsize, boolean alloc)
+ size_t *outsize, boolean alloc)
{
boolean reused = FALSE;
my_mem_dest_ptr dest;
@@ -183,7 +184,7 @@ jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
if (*outbuffer == NULL || *outsize == 0) {
if (alloc) {
/* Allocate initial buffer */
- dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
+ dest->newbuffer = *outbuffer = (unsigned char *)MALLOC(OUTPUT_BUF_SIZE);
if (dest->newbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
*outsize = OUTPUT_BUF_SIZE;
diff --git a/contrib/libs/libjpeg-turbo/jdatadst.c b/contrib/libs/libjpeg-turbo/src/jdatadst.c
index 6b4fed23397..529f93b4904 100644
--- a/contrib/libs/libjpeg-turbo/jdatadst.c
+++ b/contrib/libs/libjpeg-turbo/src/jdatadst.c
@@ -38,7 +38,6 @@ typedef my_destination_mgr *my_dest_ptr;
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
/* Expanded data destination object for memory output */
typedef struct {
@@ -52,7 +51,6 @@ typedef struct {
} my_mem_destination_mgr;
typedef my_mem_destination_mgr *my_mem_dest_ptr;
-#endif
/*
@@ -74,13 +72,11 @@ init_destination(j_compress_ptr cinfo)
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
}
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
METHODDEF(void)
init_mem_destination(j_compress_ptr cinfo)
{
/* no work necessary here */
}
-#endif
/*
@@ -121,7 +117,6 @@ empty_output_buffer(j_compress_ptr cinfo)
return TRUE;
}
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
METHODDEF(boolean)
empty_mem_output_buffer(j_compress_ptr cinfo)
{
@@ -150,7 +145,6 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
return TRUE;
}
-#endif
/*
@@ -179,7 +173,6 @@ term_destination(j_compress_ptr cinfo)
ERREXIT(cinfo, JERR_FILE_WRITE);
}
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
METHODDEF(void)
term_mem_destination(j_compress_ptr cinfo)
{
@@ -188,7 +181,6 @@ term_mem_destination(j_compress_ptr cinfo)
*dest->outbuffer = dest->buffer;
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
}
-#endif
/*
@@ -227,7 +219,6 @@ jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
}
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
/*
* Prepare for output to a memory buffer.
* The caller may supply an own initial buffer with appropriate size.
@@ -284,4 +275,3 @@ jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
dest->pub.next_output_byte = dest->buffer = *outbuffer;
dest->pub.free_in_buffer = dest->bufsize = *outsize;
}
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jdatasrc-tj.c b/contrib/libs/libjpeg-turbo/src/jdatasrc-tj.c
index 69fb5eaacd2..a5970b53fe8 100644
--- a/contrib/libs/libjpeg-turbo/jdatasrc-tj.c
+++ b/contrib/libs/libjpeg-turbo/src/jdatasrc-tj.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2016, 2019, D. R. Commander.
+ * Copyright (C) 2011, 2016, 2019, 2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -24,7 +24,7 @@
#include "jerror.h"
void jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
- unsigned long insize);
+ size_t insize);
/*
@@ -161,7 +161,7 @@ term_source(j_decompress_ptr cinfo)
GLOBAL(void)
jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
- unsigned long insize)
+ size_t insize)
{
struct jpeg_source_mgr *src;
@@ -189,6 +189,6 @@ jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
src->skip_input_data = skip_input_data;
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
src->term_source = term_source;
- src->bytes_in_buffer = (size_t)insize;
+ src->bytes_in_buffer = insize;
src->next_input_byte = (const JOCTET *)inbuffer;
}
diff --git a/contrib/libs/libjpeg-turbo/jdatasrc.c b/contrib/libs/libjpeg-turbo/src/jdatasrc.c
index e36a30d8944..dc135f43a47 100644
--- a/contrib/libs/libjpeg-turbo/jdatasrc.c
+++ b/contrib/libs/libjpeg-turbo/src/jdatasrc.c
@@ -56,13 +56,11 @@ init_source(j_decompress_ptr cinfo)
src->start_of_file = TRUE;
}
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
METHODDEF(void)
init_mem_source(j_decompress_ptr cinfo)
{
/* no work necessary here */
}
-#endif
/*
@@ -123,7 +121,6 @@ fill_input_buffer(j_decompress_ptr cinfo)
return TRUE;
}
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
METHODDEF(boolean)
fill_mem_input_buffer(j_decompress_ptr cinfo)
{
@@ -144,7 +141,6 @@ fill_mem_input_buffer(j_decompress_ptr cinfo)
return TRUE;
}
-#endif
/*
@@ -253,7 +249,6 @@ jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
}
-#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
/*
* Prepare for input from a supplied memory buffer.
* The buffer must contain the whole JPEG data.
@@ -292,4 +287,3 @@ jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *inbuffer,
src->bytes_in_buffer = (size_t)insize;
src->next_input_byte = (const JOCTET *)inbuffer;
}
-#endif
diff --git a/contrib/libs/libjpeg-turbo/jdcoefct.c b/contrib/libs/libjpeg-turbo/src/jdcoefct.c
index 88e10c08cb6..194d5a5cb7b 100644
--- a/contrib/libs/libjpeg-turbo/jdcoefct.c
+++ b/contrib/libs/libjpeg-turbo/src/jdcoefct.c
@@ -5,13 +5,13 @@
* Copyright (C) 1994-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2010, 2015-2016, 2019-2020, 2022, D. R. Commander.
+ * Copyright (C) 2010, 2015-2016, 2019-2020, 2022-2024, D. R. Commander.
* Copyright (C) 2015, 2020, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains the coefficient buffer controller for decompression.
- * This controller is the top level of the JPEG decompressor proper.
+ * This controller is the top level of the lossy JPEG decompressor proper.
* The coefficient buffer lies between entropy decoding and inverse-DCT steps.
*
* In buffered-image mode, this controller is the interface between
@@ -21,19 +21,20 @@
#include "jinclude.h"
#include "jdcoefct.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
+#include "jsamplecomp.h"
/* Forward declarations */
METHODDEF(int) decompress_onepass(j_decompress_ptr cinfo,
- JSAMPIMAGE output_buf);
+ _JSAMPIMAGE output_buf);
#ifdef D_MULTISCAN_FILES_SUPPORTED
-METHODDEF(int) decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
+METHODDEF(int) decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf);
#endif
#ifdef BLOCK_SMOOTHING_SUPPORTED
LOCAL(boolean) smoothing_ok(j_decompress_ptr cinfo);
METHODDEF(int) decompress_smooth_data(j_decompress_ptr cinfo,
- JSAMPIMAGE output_buf);
+ _JSAMPIMAGE output_buf);
#endif
@@ -62,9 +63,9 @@ start_output_pass(j_decompress_ptr cinfo)
/* If multipass, check to see whether to use block smoothing on this pass */
if (coef->pub.coef_arrays != NULL) {
if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
- coef->pub.decompress_data = decompress_smooth_data;
+ coef->pub._decompress_data = decompress_smooth_data;
else
- coef->pub.decompress_data = decompress_data;
+ coef->pub._decompress_data = decompress_data;
}
#endif
cinfo->output_iMCU_row = 0;
@@ -82,17 +83,17 @@ start_output_pass(j_decompress_ptr cinfo)
*/
METHODDEF(int)
-decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
+decompress_onepass(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
{
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
JDIMENSION MCU_col_num; /* index of current MCU within row */
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
int blkn, ci, xindex, yindex, yoffset, useful_width;
- JSAMPARRAY output_ptr;
+ _JSAMPARRAY output_ptr;
JDIMENSION start_col, output_col;
jpeg_component_info *compptr;
- inverse_DCT_method_ptr inverse_DCT;
+ _inverse_DCT_method_ptr inverse_DCT;
/* Loop to process as much as one whole iMCU row */
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
@@ -129,7 +130,7 @@ decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
blkn += compptr->MCU_blocks;
continue;
}
- inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
+ inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
useful_width = (MCU_col_num < last_MCU_col) ?
compptr->MCU_width : compptr->last_col_width;
output_ptr = output_buf[compptr->component_index] +
@@ -262,7 +263,7 @@ consume_data(j_decompress_ptr cinfo)
*/
METHODDEF(int)
-decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
+decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
{
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
@@ -270,10 +271,10 @@ decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
int ci, block_row, block_rows;
JBLOCKARRAY buffer;
JBLOCKROW buffer_ptr;
- JSAMPARRAY output_ptr;
+ _JSAMPARRAY output_ptr;
JDIMENSION output_col;
jpeg_component_info *compptr;
- inverse_DCT_method_ptr inverse_DCT;
+ _inverse_DCT_method_ptr inverse_DCT;
/* Force some input to be done if we are getting ahead of the input. */
while (cinfo->input_scan_number < cinfo->output_scan_number ||
@@ -302,7 +303,7 @@ decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
if (block_rows == 0) block_rows = compptr->v_samp_factor;
}
- inverse_DCT = cinfo->idct->inverse_DCT[ci];
+ inverse_DCT = cinfo->idct->_inverse_DCT[ci];
output_ptr = output_buf[ci];
/* Loop over all DCT blocks to be processed. */
for (block_row = 0; block_row < block_rows; block_row++) {
@@ -425,19 +426,20 @@ smoothing_ok(j_decompress_ptr cinfo)
*/
METHODDEF(int)
-decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
+decompress_smooth_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
{
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
JDIMENSION block_num, last_block_column;
- int ci, block_row, block_rows, access_rows;
+ int ci, block_row, block_rows, access_rows, image_block_row,
+ image_block_rows;
JBLOCKARRAY buffer;
JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
JBLOCKROW next_block_row, next_next_block_row;
- JSAMPARRAY output_ptr;
+ _JSAMPARRAY output_ptr;
JDIMENSION output_col;
jpeg_component_info *compptr;
- inverse_DCT_method_ptr inverse_DCT;
+ _inverse_DCT_method_ptr inverse_DCT;
boolean change_dc;
JCOEF *workspace;
int *coef_bits;
@@ -496,6 +498,7 @@ decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
(JDIMENSION)access_rows, FALSE);
buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
} else if (cinfo->output_iMCU_row > 0) {
+ access_rows += compptr->v_samp_factor; /* prior iMCU row too */
buffer = (*cinfo->mem->access_virt_barray)
((j_common_ptr)cinfo, coef->whole_image[ci],
(cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
@@ -535,32 +538,33 @@ decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
Q21 = quanttbl->quantval[Q21_POS];
Q30 = quanttbl->quantval[Q30_POS];
}
- inverse_DCT = cinfo->idct->inverse_DCT[ci];
+ inverse_DCT = cinfo->idct->_inverse_DCT[ci];
output_ptr = output_buf[ci];
/* Loop over all DCT blocks to be processed. */
+ image_block_rows = block_rows * cinfo->total_iMCU_rows;
for (block_row = 0; block_row < block_rows; block_row++) {
+ image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
- if (block_row > 0 || cinfo->output_iMCU_row > 0)
+ if (image_block_row > 0)
prev_block_row =
buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
else
prev_block_row = buffer_ptr;
- if (block_row > 1 || cinfo->output_iMCU_row > 1)
+ if (image_block_row > 1)
prev_prev_block_row =
buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
else
prev_prev_block_row = prev_block_row;
- if (block_row < block_rows - 1 || cinfo->output_iMCU_row < last_iMCU_row)
+ if (image_block_row < image_block_rows - 1)
next_block_row =
buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
else
next_block_row = buffer_ptr;
- if (block_row < block_rows - 2 ||
- cinfo->output_iMCU_row + 1 < last_iMCU_row)
+ if (image_block_row < image_block_rows - 2)
next_next_block_row =
buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
else
@@ -583,11 +587,11 @@ decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
/* Update DC values */
if (block_num == cinfo->master->first_MCU_col[ci] &&
block_num < last_block_column) {
- DC04 = (int)prev_prev_block_row[1][0];
- DC09 = (int)prev_block_row[1][0];
- DC14 = (int)buffer_ptr[1][0];
- DC19 = (int)next_block_row[1][0];
- DC24 = (int)next_next_block_row[1][0];
+ DC04 = DC05 = (int)prev_prev_block_row[1][0];
+ DC09 = DC10 = (int)prev_block_row[1][0];
+ DC14 = DC15 = (int)buffer_ptr[1][0];
+ DC19 = DC20 = (int)next_block_row[1][0];
+ DC24 = DC25 = (int)next_next_block_row[1][0];
}
if (block_num + 1 < last_block_column) {
DC05 = (int)prev_prev_block_row[2][0];
@@ -810,13 +814,17 @@ decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
*/
GLOBAL(void)
-jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
+_jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
{
my_coef_ptr coef;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_coef_controller));
+ memset(coef, 0, sizeof(my_coef_controller));
cinfo->coef = (struct jpeg_d_coef_controller *)coef;
coef->pub.start_input_pass = start_input_pass;
coef->pub.start_output_pass = start_output_pass;
@@ -850,7 +858,7 @@ jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
(JDIMENSION)access_rows);
}
coef->pub.consume_data = consume_data;
- coef->pub.decompress_data = decompress_data;
+ coef->pub._decompress_data = decompress_data;
coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
@@ -867,7 +875,7 @@ jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
coef->MCU_buffer[i] = buffer + i;
}
coef->pub.consume_data = dummy_consume_data;
- coef->pub.decompress_data = decompress_onepass;
+ coef->pub._decompress_data = decompress_onepass;
coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
}
diff --git a/contrib/libs/libjpeg-turbo/jdcoefct.h b/contrib/libs/libjpeg-turbo/src/jdcoefct.h
index 9a0e7806636..bbe9e970515 100644
--- a/contrib/libs/libjpeg-turbo/jdcoefct.h
+++ b/contrib/libs/libjpeg-turbo/src/jdcoefct.h
@@ -6,6 +6,7 @@
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
* Copyright (C) 2020, Google, Inc.
+ * Copyright (C) 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*/
@@ -14,6 +15,8 @@
#include "jpeglib.h"
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
+
/* Block smoothing is only applicable for progressive JPEG, so: */
#ifndef D_PROGRESSIVE_SUPPORTED
#undef BLOCK_SMOOTHING_SUPPORTED
@@ -81,3 +84,5 @@ start_iMCU_row(j_decompress_ptr cinfo)
coef->MCU_ctr = 0;
coef->MCU_vert_offset = 0;
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jdcol565.c b/contrib/libs/libjpeg-turbo/src/jdcol565.c
index 53c7bd9187d..2172d98fdaa 100644
--- a/contrib/libs/libjpeg-turbo/jdcol565.c
+++ b/contrib/libs/libjpeg-turbo/src/jdcol565.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modifications:
* Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, D. R. Commander.
+ * Copyright (C) 2014-2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -17,18 +17,19 @@
INLINE
LOCAL(void)
-ycc_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+ycc_rgb565_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
register int *Crrtab = cconvert->Cr_r_tab;
register int *Cbbtab = cconvert->Cb_b_tab;
register JLONG *Crgtab = cconvert->Cr_g_tab;
@@ -91,23 +92,27 @@ ycc_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*(INT16 *)outptr = (INT16)rgb;
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
INLINE
LOCAL(void)
-ycc_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+ycc_rgb565D_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
register int *Crrtab = cconvert->Cr_r_tab;
register int *Cbbtab = cconvert->Cb_b_tab;
register JLONG *Crgtab = cconvert->Cr_g_tab;
@@ -177,17 +182,20 @@ ycc_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*(INT16 *)outptr = (INT16)rgb;
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
INLINE
LOCAL(void)
-rgb_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+rgb_rgb565_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
SHIFT_TEMPS
@@ -237,14 +245,14 @@ rgb_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
-rgb_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+rgb_rgb565D_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
JDIMENSION num_cols = cinfo->output_width;
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
SHIFT_TEMPS
@@ -296,11 +304,11 @@ rgb_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
-gray_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+gray_rgb565_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
- register JSAMPROW inptr, outptr;
+ register _JSAMPROW inptr, outptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
@@ -336,13 +344,13 @@ gray_rgb565_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
-gray_rgb565D_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+gray_rgb565D_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
- register JSAMPROW inptr, outptr;
+ register _JSAMPROW inptr, outptr;
register JDIMENSION col;
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
JDIMENSION num_cols = cinfo->output_width;
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
diff --git a/contrib/libs/libjpeg-turbo/jdcolext.c b/contrib/libs/libjpeg-turbo/src/jdcolext.c
index 863c7a2fbc7..f22e29d7224 100644
--- a/contrib/libs/libjpeg-turbo/jdcolext.c
+++ b/contrib/libs/libjpeg-turbo/src/jdcolext.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2011, 2015, D. R. Commander.
+ * Copyright (C) 2009, 2011, 2015, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -28,18 +28,19 @@
INLINE
LOCAL(void)
-ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+ycc_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
register int *Crrtab = cconvert->Cr_r_tab;
register int *Cbbtab = cconvert->Cb_b_tab;
register JLONG *Crgtab = cconvert->Cr_g_tab;
@@ -62,14 +63,17 @@ ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
SCALEBITS))];
outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
- /* Set unused byte to 0xFF so it can be interpreted as an opaque */
- /* alpha channel value */
+ /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
+ /* opaque alpha channel value */
#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
+ outptr[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr += RGB_PIXELSIZE;
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -81,11 +85,11 @@ ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
-gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+gray_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
- register JSAMPROW inptr, outptr;
+ register _JSAMPROW inptr, outptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
@@ -94,10 +98,10 @@ gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr = *output_buf++;
for (col = 0; col < num_cols; col++) {
outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
- /* Set unused byte to 0xFF so it can be interpreted as an opaque */
- /* alpha channel value */
+ /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
+ /* opaque alpha channel value */
#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
+ outptr[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr += RGB_PIXELSIZE;
}
@@ -111,12 +115,12 @@ gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
-rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf,
+rgb_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf,
int num_rows)
{
- register JSAMPROW inptr0, inptr1, inptr2;
- register JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
@@ -130,10 +134,10 @@ rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr[RGB_RED] = inptr0[col];
outptr[RGB_GREEN] = inptr1[col];
outptr[RGB_BLUE] = inptr2[col];
- /* Set unused byte to 0xFF so it can be interpreted as an opaque */
- /* alpha channel value */
+ /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
+ /* opaque alpha channel value */
#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
+ outptr[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr += RGB_PIXELSIZE;
}
diff --git a/contrib/libs/libjpeg-turbo/jdcolor.c b/contrib/libs/libjpeg-turbo/src/jdcolor.c
index 8da2b4eaf2e..aecbd9dcd36 100644
--- a/contrib/libs/libjpeg-turbo/jdcolor.c
+++ b/contrib/libs/libjpeg-turbo/src/jdcolor.c
@@ -6,7 +6,7 @@
* Modified 2011 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009, 2011-2012, 2014-2015, D. R. Commander.
+ * Copyright (C) 2009, 2011-2012, 2014-2015, 2022, 2024, D. R. Commander.
* Copyright (C) 2013, Linaro Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -18,14 +18,17 @@
#include "jinclude.h"
#include "jpeglib.h"
#include "jsimd.h"
-#include "jconfigint.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
+
/* Private subobject */
typedef struct {
struct jpeg_color_deconverter pub; /* public fields */
+#if BITS_IN_JSAMPLE != 16
/* Private state for YCC->RGB conversion */
int *Cr_r_tab; /* => table for Cr to R conversion */
int *Cb_b_tab; /* => table for Cb to B conversion */
@@ -34,6 +37,7 @@ typedef struct {
/* Private state for RGB->Y conversion */
JLONG *rgb_y_tab; /* => table for RGB to Y conversion */
+#endif
} my_color_deconverter;
typedef my_color_deconverter *my_cconvert_ptr;
@@ -44,7 +48,7 @@ typedef my_color_deconverter *my_cconvert_ptr;
/*
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are
- * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
+ * normalized to the range 0.._MAXJSAMPLE rather than -0.5 .. 0.5.
* The conversion equations to be implemented are therefore
*
* R = Y + 1.40200 * Cr
@@ -53,7 +57,7 @@ typedef my_color_deconverter *my_cconvert_ptr;
*
* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
*
- * where Cb and Cr represent the incoming values less CENTERJSAMPLE.
+ * where Cb and Cr represent the incoming values less _CENTERJSAMPLE.
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
*
* To avoid floating-point arithmetic, we represent the fractional constants
@@ -64,7 +68,7 @@ typedef my_color_deconverter *my_cconvert_ptr;
*
* For even more speed, we avoid doing any multiplications in the inner loop
* by precalculating the constants times Cb and Cr for all possible values.
- * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
+ * For 8-bit samples this is very reasonable (only 256 entries per table);
* for 12-bit samples it is still acceptable. It's not very reasonable for
* 16-bit samples, but if you want lossless storage you shouldn't be changing
* colorspace anyway.
@@ -85,9 +89,9 @@ typedef my_color_deconverter *my_cconvert_ptr;
*/
#define R_Y_OFF 0 /* offset to R => Y section */
-#define G_Y_OFF (1 * (MAXJSAMPLE + 1)) /* offset to G => Y section */
-#define B_Y_OFF (2 * (MAXJSAMPLE + 1)) /* etc. */
-#define TABLE_SIZE (3 * (MAXJSAMPLE + 1))
+#define G_Y_OFF (1 * (_MAXJSAMPLE + 1)) /* offset to G => Y section */
+#define B_Y_OFF (2 * (_MAXJSAMPLE + 1)) /* etc. */
+#define TABLE_SIZE (3 * (_MAXJSAMPLE + 1))
/* Include inline routines for colorspace extensions */
@@ -210,6 +214,7 @@ typedef my_color_deconverter *my_cconvert_ptr;
LOCAL(void)
build_ycc_rgb_table(j_decompress_ptr cinfo)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
int i;
JLONG x;
@@ -217,20 +222,20 @@ build_ycc_rgb_table(j_decompress_ptr cinfo)
cconvert->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
+ (_MAXJSAMPLE + 1) * sizeof(int));
cconvert->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
+ (_MAXJSAMPLE + 1) * sizeof(int));
cconvert->Cr_g_tab = (JLONG *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
+ (_MAXJSAMPLE + 1) * sizeof(JLONG));
cconvert->Cb_g_tab = (JLONG *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
+ (_MAXJSAMPLE + 1) * sizeof(JLONG));
- for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
- /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
- /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
+ for (i = 0, x = -_CENTERJSAMPLE; i <= _MAXJSAMPLE; i++, x++) {
+ /* i is the actual input pixel value, in the range 0.._MAXJSAMPLE */
+ /* The Cb or Cr value we are thinking of is x = i - _CENTERJSAMPLE */
/* Cr=>R value is nearest int to 1.40200 * x */
cconvert->Cr_r_tab[i] = (int)
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
@@ -243,6 +248,9 @@ build_ycc_rgb_table(j_decompress_ptr cinfo)
/* We also add in ONE_HALF so that need not do it in inner loop */
cconvert->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -251,8 +259,8 @@ build_ycc_rgb_table(j_decompress_ptr cinfo)
*/
METHODDEF(void)
-ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+ycc_rgb_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
@@ -301,6 +309,7 @@ ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
LOCAL(void)
build_rgb_y_table(j_decompress_ptr cinfo)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
JLONG *rgb_y_tab;
JLONG i;
@@ -310,11 +319,14 @@ build_rgb_y_table(j_decompress_ptr cinfo)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(TABLE_SIZE * sizeof(JLONG)));
- for (i = 0; i <= MAXJSAMPLE; i++) {
+ for (i = 0; i <= _MAXJSAMPLE; i++) {
rgb_y_tab[i + R_Y_OFF] = FIX(0.29900) * i;
rgb_y_tab[i + G_Y_OFF] = FIX(0.58700) * i;
rgb_y_tab[i + B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -323,14 +335,15 @@ build_rgb_y_table(j_decompress_ptr cinfo)
*/
METHODDEF(void)
-rgb_gray_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+rgb_gray_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int r, g, b;
register JLONG *ctab = cconvert->rgb_y_tab;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
@@ -345,10 +358,13 @@ rgb_gray_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
g = inptr1[col];
b = inptr2[col];
/* Y */
- outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
- ctab[b + B_Y_OFF]) >> SCALEBITS);
+ outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
+ ctab[b + B_Y_OFF]) >> SCALEBITS);
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -358,10 +374,10 @@ rgb_gray_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-null_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+null_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
- register JSAMPROW inptr, inptr0, inptr1, inptr2, inptr3, outptr;
+ register _JSAMPROW inptr, inptr0, inptr1, inptr2, inptr3, outptr;
register JDIMENSION col;
register int num_components = cinfo->num_components;
JDIMENSION num_cols = cinfo->output_width;
@@ -419,11 +435,11 @@ null_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-grayscale_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+grayscale_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
- jcopy_sample_rows(input_buf[0], (int)input_row, output_buf, 0, num_rows,
- cinfo->output_width);
+ _jcopy_sample_rows(input_buf[0], (int)input_row, output_buf, 0, num_rows,
+ cinfo->output_width);
}
@@ -432,8 +448,8 @@ grayscale_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-gray_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+gray_rgb_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
@@ -477,8 +493,8 @@ gray_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-rgb_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+rgb_rgb_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
@@ -525,17 +541,18 @@ rgb_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+ycck_cmyk_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
+#if BITS_IN_JSAMPLE != 16
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
register int y, cb, cr;
- register JSAMPROW outptr;
- register JSAMPROW inptr0, inptr1, inptr2, inptr3;
+ register _JSAMPROW outptr;
+ register _JSAMPROW inptr0, inptr1, inptr2, inptr3;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
register int *Crrtab = cconvert->Cr_r_tab;
register int *Cbbtab = cconvert->Cb_b_tab;
register JLONG *Crgtab = cconvert->Cr_g_tab;
@@ -554,16 +571,19 @@ ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
cb = inptr1[col];
cr = inptr2[col];
/* Range-limiting is essential due to noise introduced by DCT losses. */
- outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
- outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
+ outptr[0] = range_limit[_MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
+ outptr[1] = range_limit[_MAXJSAMPLE - (y + /* green */
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
SCALEBITS)))];
- outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */
+ outptr[2] = range_limit[_MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */
/* K passes through unchanged */
outptr[3] = inptr3[col];
outptr += 4;
}
}
+#else
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
}
@@ -653,8 +673,8 @@ static INLINE boolean is_big_endian(void)
METHODDEF(void)
-ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+ycc_rgb565_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
if (is_big_endian())
ycc_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
@@ -664,8 +684,8 @@ ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-ycc_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+ycc_rgb565D_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
if (is_big_endian())
ycc_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
@@ -675,8 +695,8 @@ ycc_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-rgb_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+rgb_rgb565_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
if (is_big_endian())
rgb_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
@@ -686,8 +706,8 @@ rgb_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-rgb_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+rgb_rgb565D_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
if (is_big_endian())
rgb_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
@@ -697,8 +717,8 @@ rgb_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-gray_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+gray_rgb565_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
if (is_big_endian())
gray_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
@@ -708,8 +728,8 @@ gray_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-gray_rgb565D_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows)
+gray_rgb565D_convert(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION input_row, _JSAMPARRAY output_buf, int num_rows)
{
if (is_big_endian())
gray_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
@@ -734,11 +754,27 @@ start_pass_dcolor(j_decompress_ptr cinfo)
*/
GLOBAL(void)
-jinit_color_deconverter(j_decompress_ptr cinfo)
+_jinit_color_deconverter(j_decompress_ptr cinfo)
{
my_cconvert_ptr cconvert;
int ci;
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_color_deconverter));
@@ -773,19 +809,26 @@ jinit_color_deconverter(j_decompress_ptr cinfo)
/* Set out_color_components and conversion method based on requested space.
* Also clear the component_needed flags for any unused components,
* so that earlier pipeline stages can avoid useless computation.
+ * NOTE: We do not allow any lossy color conversion algorithms in lossless
+ * mode.
*/
switch (cinfo->out_color_space) {
case JCS_GRAYSCALE:
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless &&
+ cinfo->jpeg_color_space != cinfo->out_color_space)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
cinfo->out_color_components = 1;
if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
cinfo->jpeg_color_space == JCS_YCbCr) {
- cconvert->pub.color_convert = grayscale_convert;
+ cconvert->pub._color_convert = grayscale_convert;
/* For color->grayscale conversion, only the Y (0) component is needed */
for (ci = 1; ci < cinfo->num_components; ci++)
cinfo->comp_info[ci].component_needed = FALSE;
} else if (cinfo->jpeg_color_space == JCS_RGB) {
- cconvert->pub.color_convert = rgb_gray_convert;
+ cconvert->pub._color_convert = rgb_gray_convert;
build_rgb_y_table(cinfo);
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
@@ -802,65 +845,84 @@ jinit_color_deconverter(j_decompress_ptr cinfo)
case JCS_EXT_BGRA:
case JCS_EXT_ABGR:
case JCS_EXT_ARGB:
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless && cinfo->jpeg_color_space != JCS_RGB)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
if (cinfo->jpeg_color_space == JCS_YCbCr) {
+#ifdef WITH_SIMD
if (jsimd_can_ycc_rgb())
- cconvert->pub.color_convert = jsimd_ycc_rgb_convert;
- else {
- cconvert->pub.color_convert = ycc_rgb_convert;
+ cconvert->pub._color_convert = jsimd_ycc_rgb_convert;
+ else
+#endif
+ {
+ cconvert->pub._color_convert = ycc_rgb_convert;
build_ycc_rgb_table(cinfo);
}
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
- cconvert->pub.color_convert = gray_rgb_convert;
+ cconvert->pub._color_convert = gray_rgb_convert;
} else if (cinfo->jpeg_color_space == JCS_RGB) {
if (rgb_red[cinfo->out_color_space] == 0 &&
rgb_green[cinfo->out_color_space] == 1 &&
rgb_blue[cinfo->out_color_space] == 2 &&
rgb_pixelsize[cinfo->out_color_space] == 3)
- cconvert->pub.color_convert = null_convert;
+ cconvert->pub._color_convert = null_convert;
else
- cconvert->pub.color_convert = rgb_rgb_convert;
+ cconvert->pub._color_convert = rgb_rgb_convert;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
case JCS_RGB565:
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
cinfo->out_color_components = 3;
if (cinfo->dither_mode == JDITHER_NONE) {
if (cinfo->jpeg_color_space == JCS_YCbCr) {
+#ifdef WITH_SIMD
if (jsimd_can_ycc_rgb565())
- cconvert->pub.color_convert = jsimd_ycc_rgb565_convert;
- else {
- cconvert->pub.color_convert = ycc_rgb565_convert;
+ cconvert->pub._color_convert = jsimd_ycc_rgb565_convert;
+ else
+#endif
+ {
+ cconvert->pub._color_convert = ycc_rgb565_convert;
build_ycc_rgb_table(cinfo);
}
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
- cconvert->pub.color_convert = gray_rgb565_convert;
+ cconvert->pub._color_convert = gray_rgb565_convert;
} else if (cinfo->jpeg_color_space == JCS_RGB) {
- cconvert->pub.color_convert = rgb_rgb565_convert;
+ cconvert->pub._color_convert = rgb_rgb565_convert;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
} else {
/* only ordered dithering is supported */
if (cinfo->jpeg_color_space == JCS_YCbCr) {
- cconvert->pub.color_convert = ycc_rgb565D_convert;
+ cconvert->pub._color_convert = ycc_rgb565D_convert;
build_ycc_rgb_table(cinfo);
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
- cconvert->pub.color_convert = gray_rgb565D_convert;
+ cconvert->pub._color_convert = gray_rgb565D_convert;
} else if (cinfo->jpeg_color_space == JCS_RGB) {
- cconvert->pub.color_convert = rgb_rgb565D_convert;
+ cconvert->pub._color_convert = rgb_rgb565D_convert;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break;
case JCS_CMYK:
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless &&
+ cinfo->jpeg_color_space != cinfo->out_color_space)
+ ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+#endif
cinfo->out_color_components = 4;
if (cinfo->jpeg_color_space == JCS_YCCK) {
- cconvert->pub.color_convert = ycck_cmyk_convert;
+ cconvert->pub._color_convert = ycck_cmyk_convert;
build_ycc_rgb_table(cinfo);
} else if (cinfo->jpeg_color_space == JCS_CMYK) {
- cconvert->pub.color_convert = null_convert;
+ cconvert->pub._color_convert = null_convert;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
@@ -869,7 +931,7 @@ jinit_color_deconverter(j_decompress_ptr cinfo)
/* Permit null conversion to same output space */
if (cinfo->out_color_space == cinfo->jpeg_color_space) {
cinfo->out_color_components = cinfo->num_components;
- cconvert->pub.color_convert = null_convert;
+ cconvert->pub._color_convert = null_convert;
} else /* unsupported non-null conversion */
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break;
@@ -880,3 +942,5 @@ jinit_color_deconverter(j_decompress_ptr cinfo)
else
cinfo->output_components = cinfo->out_color_components;
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jdct.h b/contrib/libs/libjpeg-turbo/src/jdct.h
index 66d1718b770..0411a79bc0b 100644
--- a/contrib/libs/libjpeg-turbo/jdct.h
+++ b/contrib/libs/libjpeg-turbo/src/jdct.h
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
+ * Copyright (C) 2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -15,13 +15,15 @@
* machine-dependent tuning (e.g., assembly coding).
*/
+#include "jsamplecomp.h"
+
/*
* A forward DCT routine is given a pointer to a work area of type DCTELEM[];
* the DCT is to be performed in-place in that buffer. Type DCTELEM is int
* for 8-bit samples, JLONG for 12-bit samples. (NOTE: Floating-point DCT
* implementations use an array of type FAST_FLOAT, instead.)
- * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).
+ * The DCT inputs are expected to be signed (range +-_CENTERJSAMPLE).
* The DCT outputs are returned scaled up by a factor of 8; they therefore
* have a range of +-8K for 8-bit data, +-128K for 12-bit data. This
* convention improves accuracy in integer implementations and saves some
@@ -76,78 +78,89 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
/*
* Each IDCT routine is responsible for range-limiting its results and
- * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
+ * converting them to unsigned form (0.._MAXJSAMPLE). The raw outputs could
* be quite far out of range if the input data is corrupt, so a bulletproof
* range-limiting step is required. We use a mask-and-table-lookup method
* to do the combined operations quickly. See the comments with
* prepare_range_limit_table (in jdmaster.c) for more info.
*/
-#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE)
+#define IDCT_range_limit(cinfo) \
+ ((_JSAMPLE *)((cinfo)->sample_range_limit) + _CENTERJSAMPLE)
-#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
+#define RANGE_MASK (_MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
/* Extern declarations for the forward and inverse DCT routines. */
-EXTERN(void) jpeg_fdct_islow(DCTELEM *data);
-EXTERN(void) jpeg_fdct_ifast(DCTELEM *data);
+EXTERN(void) _jpeg_fdct_islow(DCTELEM *data);
+EXTERN(void) _jpeg_fdct_ifast(DCTELEM *data);
EXTERN(void) jpeg_fdct_float(FAST_FLOAT *data);
-EXTERN(void) jpeg_idct_islow(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_ifast(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_float(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_7x7(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_6x6(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_5x5(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_4x4(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_3x3(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_2x2(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_1x1(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_9x9(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_10x10(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_11x11(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_12x12(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_13x13(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_14x14(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_15x15(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
-EXTERN(void) jpeg_idct_16x16(j_decompress_ptr cinfo,
- jpeg_component_info *compptr, JCOEFPTR coef_block,
- JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_islow(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_ifast(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_float(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_7x7(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_6x6(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_5x5(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_4x4(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_3x3(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_2x2(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_1x1(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_9x9(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr, JCOEFPTR coef_block,
+ _JSAMPARRAY output_buf, JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_10x10(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_11x11(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_12x12(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_13x13(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_14x14(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_15x15(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+EXTERN(void) _jpeg_idct_16x16(j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col);
/*
diff --git a/contrib/libs/libjpeg-turbo/jddctmgr.c b/contrib/libs/libjpeg-turbo/src/jddctmgr.c
index e78d7bebe28..0bd8c2b591d 100644
--- a/contrib/libs/libjpeg-turbo/jddctmgr.c
+++ b/contrib/libs/libjpeg-turbo/src/jddctmgr.c
@@ -26,7 +26,7 @@
#include "jpeglib.h"
#include "jdct.h" /* Private declarations for DCT subsystem */
#include "jsimddct.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
/*
@@ -100,7 +100,7 @@ start_pass(j_decompress_ptr cinfo)
int ci, i;
jpeg_component_info *compptr;
int method = 0;
- inverse_DCT_method_ptr method_ptr = NULL;
+ _inverse_DCT_method_ptr method_ptr = NULL;
JQUANT_TBL *qtbl;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
@@ -109,42 +109,46 @@ start_pass(j_decompress_ptr cinfo)
switch (compptr->_DCT_scaled_size) {
#ifdef IDCT_SCALING_SUPPORTED
case 1:
- method_ptr = jpeg_idct_1x1;
+ method_ptr = _jpeg_idct_1x1;
method = JDCT_ISLOW; /* jidctred uses islow-style table */
break;
case 2:
+#ifdef WITH_SIMD
if (jsimd_can_idct_2x2())
method_ptr = jsimd_idct_2x2;
else
- method_ptr = jpeg_idct_2x2;
+#endif
+ method_ptr = _jpeg_idct_2x2;
method = JDCT_ISLOW; /* jidctred uses islow-style table */
break;
case 3:
- method_ptr = jpeg_idct_3x3;
+ method_ptr = _jpeg_idct_3x3;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 4:
+#ifdef WITH_SIMD
if (jsimd_can_idct_4x4())
method_ptr = jsimd_idct_4x4;
else
- method_ptr = jpeg_idct_4x4;
+#endif
+ method_ptr = _jpeg_idct_4x4;
method = JDCT_ISLOW; /* jidctred uses islow-style table */
break;
case 5:
- method_ptr = jpeg_idct_5x5;
+ method_ptr = _jpeg_idct_5x5;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 6:
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_can_idct_6x6())
method_ptr = jsimd_idct_6x6;
else
#endif
- method_ptr = jpeg_idct_6x6;
+ method_ptr = _jpeg_idct_6x6;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 7:
- method_ptr = jpeg_idct_7x7;
+ method_ptr = _jpeg_idct_7x7;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
#endif
@@ -152,28 +156,34 @@ start_pass(j_decompress_ptr cinfo)
switch (cinfo->dct_method) {
#ifdef DCT_ISLOW_SUPPORTED
case JDCT_ISLOW:
+#ifdef WITH_SIMD
if (jsimd_can_idct_islow())
method_ptr = jsimd_idct_islow;
else
- method_ptr = jpeg_idct_islow;
+#endif
+ method_ptr = _jpeg_idct_islow;
method = JDCT_ISLOW;
break;
#endif
#ifdef DCT_IFAST_SUPPORTED
case JDCT_IFAST:
+#ifdef WITH_SIMD
if (jsimd_can_idct_ifast())
method_ptr = jsimd_idct_ifast;
else
- method_ptr = jpeg_idct_ifast;
+#endif
+ method_ptr = _jpeg_idct_ifast;
method = JDCT_IFAST;
break;
#endif
#ifdef DCT_FLOAT_SUPPORTED
case JDCT_FLOAT:
+#ifdef WITH_SIMD
if (jsimd_can_idct_float())
method_ptr = jsimd_idct_float;
else
- method_ptr = jpeg_idct_float;
+#endif
+ method_ptr = _jpeg_idct_float;
method = JDCT_FLOAT;
break;
#endif
@@ -184,40 +194,40 @@ start_pass(j_decompress_ptr cinfo)
break;
#ifdef IDCT_SCALING_SUPPORTED
case 9:
- method_ptr = jpeg_idct_9x9;
+ method_ptr = _jpeg_idct_9x9;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 10:
- method_ptr = jpeg_idct_10x10;
+ method_ptr = _jpeg_idct_10x10;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 11:
- method_ptr = jpeg_idct_11x11;
+ method_ptr = _jpeg_idct_11x11;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 12:
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_can_idct_12x12())
method_ptr = jsimd_idct_12x12;
else
#endif
- method_ptr = jpeg_idct_12x12;
+ method_ptr = _jpeg_idct_12x12;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 13:
- method_ptr = jpeg_idct_13x13;
+ method_ptr = _jpeg_idct_13x13;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 14:
- method_ptr = jpeg_idct_14x14;
+ method_ptr = _jpeg_idct_14x14;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 15:
- method_ptr = jpeg_idct_15x15;
+ method_ptr = _jpeg_idct_15x15;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case 16:
- method_ptr = jpeg_idct_16x16;
+ method_ptr = _jpeg_idct_16x16;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
#endif
@@ -225,7 +235,7 @@ start_pass(j_decompress_ptr cinfo)
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
break;
}
- idct->pub.inverse_DCT[ci] = method_ptr;
+ idct->pub._inverse_DCT[ci] = method_ptr;
/* Create multiplier table from quant table.
* However, we can skip this if the component is uninteresting
* or if we already built the table. Also, if no quant table
@@ -327,12 +337,15 @@ start_pass(j_decompress_ptr cinfo)
*/
GLOBAL(void)
-jinit_inverse_dct(j_decompress_ptr cinfo)
+_jinit_inverse_dct(j_decompress_ptr cinfo)
{
my_idct_ptr idct;
int ci;
jpeg_component_info *compptr;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
idct = (my_idct_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_idct_controller));
diff --git a/contrib/libs/libjpeg-turbo/src/jddiffct.c b/contrib/libs/libjpeg-turbo/src/jddiffct.c
new file mode 100644
index 00000000000..0a1ec5a9a83
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jddiffct.c
@@ -0,0 +1,411 @@
+/*
+ * jddiffct.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1994-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains the [un]difference buffer controller for decompression.
+ * This controller is the top level of the lossless JPEG decompressor proper.
+ * The difference buffer lies between the entropy decoding and
+ * prediction/undifferencing steps. The undifference buffer lies between the
+ * prediction/undifferencing and scaling steps.
+ *
+ * In buffered-image mode, this controller is the interface between
+ * input-oriented processing and output-oriented processing.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jlossls.h" /* Private declarations for lossless codec */
+
+
+#ifdef D_LOSSLESS_SUPPORTED
+
+/* Private buffer controller object */
+
+typedef struct {
+ struct jpeg_d_coef_controller pub; /* public fields */
+
+ /* These variables keep track of the current location of the input side. */
+ /* cinfo->input_iMCU_row is also used for this. */
+ JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
+ unsigned int restart_rows_to_go; /* MCU rows left in this restart
+ interval */
+ unsigned int MCU_vert_offset; /* counts MCU rows within iMCU row */
+ unsigned int MCU_rows_per_iMCU_row; /* number of such rows needed */
+
+ /* The output side's location is represented by cinfo->output_iMCU_row. */
+
+ JDIFFARRAY diff_buf[MAX_COMPONENTS]; /* iMCU row of differences */
+ JDIFFARRAY undiff_buf[MAX_COMPONENTS]; /* iMCU row of undiff'd samples */
+
+#ifdef D_MULTISCAN_FILES_SUPPORTED
+ /* In multi-pass modes, we need a virtual sample array for each component. */
+ jvirt_sarray_ptr whole_image[MAX_COMPONENTS];
+#endif
+} my_diff_controller;
+
+typedef my_diff_controller *my_diff_ptr;
+
+/* Forward declarations */
+METHODDEF(int) decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf);
+#ifdef D_MULTISCAN_FILES_SUPPORTED
+METHODDEF(int) output_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf);
+#endif
+
+
+LOCAL(void)
+start_iMCU_row(j_decompress_ptr cinfo)
+/* Reset within-iMCU-row counters for a new row (input side) */
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+
+ /* In an interleaved scan, an MCU row is the same as an iMCU row.
+ * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
+ * But at the bottom of the image, process only what's left.
+ */
+ if (cinfo->comps_in_scan > 1) {
+ diff->MCU_rows_per_iMCU_row = 1;
+ } else {
+ if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
+ diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
+ else
+ diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
+ }
+
+ diff->MCU_ctr = 0;
+ diff->MCU_vert_offset = 0;
+}
+
+
+/*
+ * Initialize for an input processing pass.
+ */
+
+METHODDEF(void)
+start_input_pass(j_decompress_ptr cinfo)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+
+ /* Because it is hitching a ride on the jpeg_inverse_dct struct,
+ * start_pass_lossless() will be called at the start of the output pass.
+ * This ensures that it will be called at the start of the input pass as
+ * well.
+ */
+ (*cinfo->idct->start_pass) (cinfo);
+
+ /* Check that the restart interval is an integer multiple of the number
+ * of MCUs in an MCU row.
+ */
+ if (cinfo->restart_interval % cinfo->MCUs_per_row != 0)
+ ERREXIT2(cinfo, JERR_BAD_RESTART,
+ cinfo->restart_interval, cinfo->MCUs_per_row);
+
+ /* Initialize restart counter */
+ diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row;
+
+ cinfo->input_iMCU_row = 0;
+ start_iMCU_row(cinfo);
+}
+
+
+/*
+ * Check for a restart marker & resynchronize decoder, undifferencer.
+ * Returns FALSE if must suspend.
+ */
+
+METHODDEF(boolean)
+process_restart(j_decompress_ptr cinfo)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+
+ if (!(*cinfo->entropy->process_restart) (cinfo))
+ return FALSE;
+
+ (*cinfo->idct->start_pass) (cinfo);
+
+ /* Reset restart counter */
+ diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row;
+
+ return TRUE;
+}
+
+
+/*
+ * Initialize for an output processing pass.
+ */
+
+METHODDEF(void)
+start_output_pass(j_decompress_ptr cinfo)
+{
+ cinfo->output_iMCU_row = 0;
+}
+
+
+/*
+ * Decompress and return some data in the supplied buffer.
+ * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
+ * Input and output must run in lockstep since we have only a one-MCU buffer.
+ * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
+ *
+ * NB: output_buf contains a plane for each component in image,
+ * which we index according to the component's SOF position.
+ */
+
+METHODDEF(int)
+decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+ lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct;
+ JDIMENSION MCU_col_num; /* index of current MCU within row */
+ JDIMENSION MCU_count; /* number of MCUs decoded */
+ JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
+ int ci, compi, row, prev_row;
+ unsigned int yoffset;
+ jpeg_component_info *compptr;
+
+ /* Loop to process as much as one whole iMCU row */
+ for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row;
+ yoffset++) {
+
+ /* Process restart marker if needed; may have to suspend */
+ if (cinfo->restart_interval) {
+ if (diff->restart_rows_to_go == 0)
+ if (!process_restart(cinfo))
+ return JPEG_SUSPENDED;
+ }
+
+ MCU_col_num = diff->MCU_ctr;
+ /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */
+ MCU_count =
+ (*cinfo->entropy->decode_mcus) (cinfo,
+ diff->diff_buf, yoffset, MCU_col_num,
+ cinfo->MCUs_per_row - MCU_col_num);
+ if (MCU_count != cinfo->MCUs_per_row - MCU_col_num) {
+ /* Suspension forced; update state counters and exit */
+ diff->MCU_vert_offset = yoffset;
+ diff->MCU_ctr += MCU_count;
+ return JPEG_SUSPENDED;
+ }
+
+ /* Account for restart interval (no-op if not using restarts) */
+ if (cinfo->restart_interval)
+ diff->restart_rows_to_go--;
+
+ /* Completed an MCU row, but perhaps not an iMCU row */
+ diff->MCU_ctr = 0;
+ }
+
+ /*
+ * Undifference and scale each scanline of the disassembled MCU row
+ * separately. We do not process dummy samples at the end of a scanline
+ * or dummy rows at the end of the image.
+ */
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ compi = compptr->component_index;
+ for (row = 0, prev_row = compptr->v_samp_factor - 1;
+ row < (cinfo->input_iMCU_row == last_iMCU_row ?
+ compptr->last_row_height : compptr->v_samp_factor);
+ prev_row = row, row++) {
+ (*losslessd->predict_undifference[compi])
+ (cinfo, compi, diff->diff_buf[compi][row],
+ diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row],
+ compptr->width_in_blocks);
+ (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row],
+ output_buf[compi][row],
+ compptr->width_in_blocks);
+ }
+ }
+
+ /* Completed the iMCU row, advance counters for next one.
+ *
+ * NB: output_data will increment output_iMCU_row.
+ * This counter is not needed for the single-pass case
+ * or the input side of the multi-pass case.
+ */
+ if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
+ start_iMCU_row(cinfo);
+ return JPEG_ROW_COMPLETED;
+ }
+ /* Completed the scan */
+ (*cinfo->inputctl->finish_input_pass) (cinfo);
+ return JPEG_SCAN_COMPLETED;
+}
+
+
+/*
+ * Dummy consume-input routine for single-pass operation.
+ */
+
+METHODDEF(int)
+dummy_consume_data(j_decompress_ptr cinfo)
+{
+ return JPEG_SUSPENDED; /* Always indicate nothing was done */
+}
+
+
+#ifdef D_MULTISCAN_FILES_SUPPORTED
+
+/*
+ * Consume input data and store it in the full-image sample buffer.
+ * We read as much as one fully interleaved MCU row ("iMCU" row) per call,
+ * ie, v_samp_factor rows for each component in the scan.
+ * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
+ */
+
+METHODDEF(int)
+consume_data(j_decompress_ptr cinfo)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+ int ci, compi;
+ _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN];
+ jpeg_component_info *compptr;
+
+ /* Align the virtual buffers for the components used in this scan. */
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ compi = compptr->component_index;
+ buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
+ ((j_common_ptr)cinfo, diff->whole_image[compi],
+ cinfo->input_iMCU_row * compptr->v_samp_factor,
+ (JDIMENSION)compptr->v_samp_factor, TRUE);
+ }
+
+ return decompress_data(cinfo, buffer);
+}
+
+
+/*
+ * Output some data from the full-image sample buffer in the multi-pass case.
+ * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
+ * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
+ *
+ * NB: output_buf contains a plane for each component in image.
+ */
+
+METHODDEF(int)
+output_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
+{
+ my_diff_ptr diff = (my_diff_ptr)cinfo->coef;
+ JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
+ int ci, samp_rows, row;
+ _JSAMPARRAY buffer;
+ jpeg_component_info *compptr;
+
+ /* Force some input to be done if we are getting ahead of the input. */
+ while (cinfo->input_scan_number < cinfo->output_scan_number ||
+ (cinfo->input_scan_number == cinfo->output_scan_number &&
+ cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
+ if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
+ return JPEG_SUSPENDED;
+ }
+
+ /* OK, output from the virtual arrays. */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ /* Align the virtual buffer for this component. */
+ buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
+ ((j_common_ptr)cinfo, diff->whole_image[ci],
+ cinfo->output_iMCU_row * compptr->v_samp_factor,
+ (JDIMENSION)compptr->v_samp_factor, FALSE);
+
+ if (cinfo->output_iMCU_row < last_iMCU_row)
+ samp_rows = compptr->v_samp_factor;
+ else {
+ /* NB: can't use last_row_height here; it is input-side-dependent! */
+ samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
+ if (samp_rows == 0) samp_rows = compptr->v_samp_factor;
+ }
+
+ for (row = 0; row < samp_rows; row++) {
+ memcpy(output_buf[ci][row], buffer[row],
+ compptr->width_in_blocks * sizeof(_JSAMPLE));
+ }
+ }
+
+ if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
+ return JPEG_ROW_COMPLETED;
+ return JPEG_SCAN_COMPLETED;
+}
+
+#endif /* D_MULTISCAN_FILES_SUPPORTED */
+
+
+/*
+ * Initialize difference buffer controller.
+ */
+
+GLOBAL(void)
+_jinit_d_diff_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
+{
+ my_diff_ptr diff;
+ int ci;
+ jpeg_component_info *compptr;
+
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ diff = (my_diff_ptr)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ sizeof(my_diff_controller));
+ cinfo->coef = (struct jpeg_d_coef_controller *)diff;
+ diff->pub.start_input_pass = start_input_pass;
+ diff->pub.start_output_pass = start_output_pass;
+
+ /* Create the [un]difference buffers. */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ diff->diff_buf[ci] =
+ ALLOC_DARRAY(JPOOL_IMAGE,
+ (JDIMENSION)jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor),
+ (JDIMENSION)compptr->v_samp_factor);
+ diff->undiff_buf[ci] =
+ ALLOC_DARRAY(JPOOL_IMAGE,
+ (JDIMENSION)jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor),
+ (JDIMENSION)compptr->v_samp_factor);
+ }
+
+ if (need_full_buffer) {
+#ifdef D_MULTISCAN_FILES_SUPPORTED
+ /* Allocate a full-image virtual array for each component. */
+ int access_rows;
+
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ access_rows = compptr->v_samp_factor;
+ diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
+ ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
+ (JDIMENSION)jround_up((long)compptr->width_in_blocks,
+ (long)compptr->h_samp_factor),
+ (JDIMENSION)jround_up((long)compptr->height_in_blocks,
+ (long)compptr->v_samp_factor),
+ (JDIMENSION)access_rows);
+ }
+ diff->pub.consume_data = consume_data;
+ diff->pub._decompress_data = output_data;
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ } else {
+ diff->pub.consume_data = dummy_consume_data;
+ diff->pub._decompress_data = decompress_data;
+ diff->whole_image[0] = NULL; /* flag for no virtual arrays */
+ }
+}
+
+#endif /* D_LOSSLESS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jdhuff.c b/contrib/libs/libjpeg-turbo/src/jdhuff.c
index 679d2216859..cd8c0847a22 100644
--- a/contrib/libs/libjpeg-turbo/jdhuff.c
+++ b/contrib/libs/libjpeg-turbo/src/jdhuff.c
@@ -3,8 +3,10 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2016, 2018-2019, D. R. Commander.
+ * Copyright (C) 2009-2011, 2016, 2018-2019, 2022, D. R. Commander.
* Copyright (C) 2018, Matthias Räncker.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -24,8 +26,8 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
-#include "jdhuff.h" /* Declarations shared with jdphuff.c */
-#include "jpegcomp.h"
+#include "jdhuff.h" /* Declarations shared with jd*huff.c */
+#include "jpegapicomp.h"
#include "jstdhuff.c"
@@ -134,7 +136,7 @@ start_pass_huff_decoder(j_decompress_ptr cinfo)
* Compute the derived values for a Huffman table.
* This routine also performs some validation checks on the table.
*
- * Note this is also used by jdphuff.c.
+ * Note this is also used by jdphuff.c and jdlhuff.c.
*/
GLOBAL(void)
@@ -245,14 +247,14 @@ jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno,
/* Validate symbols as being reasonable.
* For AC tables, we make no check, but accept all byte values 0..255.
- * For DC tables, we require the symbols to be in range 0..15.
- * (Tighter bounds could be applied depending on the data depth and mode,
- * but this is sufficient to ensure safe decoding.)
+ * For DC tables, we require the symbols to be in range 0..15 in lossy mode
+ * and 0..16 in lossless mode. (Tighter bounds could be applied depending on
+ * the data depth and mode, but this is sufficient to ensure safe decoding.)
*/
if (isDC) {
for (i = 0; i < numsymbols; i++) {
int sym = htbl->huffval[i];
- if (sym < 0 || sym > 15)
+ if (sym < 0 || sym > (cinfo->master->lossless ? 16 : 15))
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
}
}
@@ -260,7 +262,7 @@ jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno,
/*
- * Out-of-line code for bit fetching (shared with jdphuff.c).
+ * Out-of-line code for bit fetching (shared with jdphuff.c and jdlhuff.c).
* See jdhuff.h for info about usage.
* Note: current values of get_buffer and bits_left are passed as parameters,
* but are returned in the corresponding fields of the state struct.
diff --git a/contrib/libs/libjpeg-turbo/jdhuff.h b/contrib/libs/libjpeg-turbo/src/jdhuff.h
index cfa0b7f5588..3eee002c020 100644
--- a/contrib/libs/libjpeg-turbo/jdhuff.h
+++ b/contrib/libs/libjpeg-turbo/src/jdhuff.h
@@ -3,6 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2010-2011, 2015-2016, 2021, D. R. Commander.
* Copyright (C) 2018, Matthias Räncker.
@@ -10,8 +12,9 @@
* file.
*
* This file contains declarations for Huffman entropy decoding routines
- * that are shared between the sequential decoder (jdhuff.c) and the
- * progressive decoder (jdphuff.c). No other modules need to see these.
+ * that are shared between the sequential decoder (jdhuff.c), the progressive
+ * decoder (jdphuff.c), and the lossless decoder (jdlhuff.c). No other modules
+ * need to see these.
*/
#include "jconfigint.h"
diff --git a/contrib/libs/libjpeg-turbo/jdicc.c b/contrib/libs/libjpeg-turbo/src/jdicc.c
index 50aa9a96767..50aa9a96767 100644
--- a/contrib/libs/libjpeg-turbo/jdicc.c
+++ b/contrib/libs/libjpeg-turbo/src/jdicc.c
diff --git a/contrib/libs/libjpeg-turbo/jdinput.c b/contrib/libs/libjpeg-turbo/src/jdinput.c
index 1bc5aff1a70..33e3a820fd2 100644
--- a/contrib/libs/libjpeg-turbo/jdinput.c
+++ b/contrib/libs/libjpeg-turbo/src/jdinput.c
@@ -3,22 +3,25 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, 2018, 2022, D. R. Commander.
+ * Copyright (C) 2010, 2016, 2018, 2022, 2024, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
* This file contains input control logic for the JPEG decompressor.
* These routines are concerned with controlling the decompressor's input
- * processing (marker reading and coefficient decoding). The actual input
- * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c.
+ * processing (marker reading and coefficient/difference decoding).
+ * The actual input reading is done in jdmarker.c, jdhuff.c, jdphuff.c,
+ * and jdlhuff.c.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
/* Private state */
@@ -46,15 +49,26 @@ initial_setup(j_decompress_ptr cinfo)
{
int ci;
jpeg_component_info *compptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
/* Make sure image isn't bigger than I can handle */
if ((long)cinfo->image_height > (long)JPEG_MAX_DIMENSION ||
(long)cinfo->image_width > (long)JPEG_MAX_DIMENSION)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
- /* For now, precision must match compiled-in value... */
- if (cinfo->data_precision != BITS_IN_JSAMPLE)
- ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ /* Lossy JPEG images must have 8 or 12 bits per sample. Lossless JPEG images
+ * can have 2 to 16 bits per sample.
+ */
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+ if (cinfo->data_precision < 2 || cinfo->data_precision > 16)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != 8 && cinfo->data_precision != 12)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
/* Check that number of components won't exceed internal array sizes */
if (cinfo->num_components > MAX_COMPONENTS)
@@ -78,36 +92,36 @@ initial_setup(j_decompress_ptr cinfo)
}
#if JPEG_LIB_VERSION >= 80
- cinfo->block_size = DCTSIZE;
+ cinfo->block_size = data_unit;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2 - 1;
#endif
- /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
- * In the full decompressor, this will be overridden by jdmaster.c;
+ /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE in lossy
+ * mode. In the full decompressor, this will be overridden by jdmaster.c;
* but in the transcoder, jdmaster.c is not used, so we must do it here.
*/
#if JPEG_LIB_VERSION >= 70
- cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = DCTSIZE;
+ cinfo->min_DCT_h_scaled_size = cinfo->min_DCT_v_scaled_size = data_unit;
#else
- cinfo->min_DCT_scaled_size = DCTSIZE;
+ cinfo->min_DCT_scaled_size = data_unit;
#endif
/* Compute dimensions of components */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
#if JPEG_LIB_VERSION >= 70
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
+ compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = data_unit;
#else
- compptr->DCT_scaled_size = DCTSIZE;
+ compptr->DCT_scaled_size = data_unit;
#endif
- /* Size in DCT blocks */
+ /* Size in data units */
compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long)cinfo->image_width * (long)compptr->h_samp_factor,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
+ (long)(cinfo->max_h_samp_factor * data_unit));
compptr->height_in_blocks = (JDIMENSION)
jdiv_round_up((long)cinfo->image_height * (long)compptr->v_samp_factor,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
+ (long)(cinfo->max_v_samp_factor * data_unit));
/* Set the first and last MCU columns to decompress from multi-scan images.
* By default, decompress all of the MCU columns.
*/
@@ -133,7 +147,7 @@ initial_setup(j_decompress_ptr cinfo)
/* Compute number of fully interleaved MCU rows. */
cinfo->total_iMCU_rows = (JDIMENSION)
jdiv_round_up((long)cinfo->image_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
+ (long)(cinfo->max_v_samp_factor * data_unit));
/* Decide whether file contains multiple scans */
if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
@@ -150,6 +164,7 @@ per_scan_setup(j_decompress_ptr cinfo)
{
int ci, mcublks, tmp;
jpeg_component_info *compptr;
+ int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
if (cinfo->comps_in_scan == 1) {
@@ -160,14 +175,14 @@ per_scan_setup(j_decompress_ptr cinfo)
cinfo->MCUs_per_row = compptr->width_in_blocks;
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
- /* For noninterleaved scan, always one block per MCU */
+ /* For noninterleaved scan, always one data unit per MCU */
compptr->MCU_width = 1;
compptr->MCU_height = 1;
compptr->MCU_blocks = 1;
compptr->MCU_sample_width = compptr->_DCT_scaled_size;
compptr->last_col_width = 1;
/* For noninterleaved scans, it is convenient to define last_row_height
- * as the number of block rows present in the last iMCU row.
+ * as the number of data unit rows present in the last iMCU row.
*/
tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
if (tmp == 0) tmp = compptr->v_samp_factor;
@@ -187,22 +202,22 @@ per_scan_setup(j_decompress_ptr cinfo)
/* Overall image size in MCUs */
cinfo->MCUs_per_row = (JDIMENSION)
jdiv_round_up((long)cinfo->image_width,
- (long)(cinfo->max_h_samp_factor * DCTSIZE));
+ (long)(cinfo->max_h_samp_factor * data_unit));
cinfo->MCU_rows_in_scan = (JDIMENSION)
jdiv_round_up((long)cinfo->image_height,
- (long)(cinfo->max_v_samp_factor * DCTSIZE));
+ (long)(cinfo->max_v_samp_factor * data_unit));
cinfo->blocks_in_MCU = 0;
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
- /* Sampling factors give # of blocks of component in each MCU */
+ /* Sampling factors give # of data units of component in each MCU */
compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
compptr->MCU_sample_width = compptr->MCU_width *
compptr->_DCT_scaled_size;
- /* Figure number of non-dummy blocks in last MCU column & row */
+ /* Figure number of non-dummy data units in last MCU column & row */
tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width;
compptr->last_col_width = tmp;
@@ -281,7 +296,8 @@ METHODDEF(void)
start_input_pass(j_decompress_ptr cinfo)
{
per_scan_setup(cinfo);
- latch_quant_tables(cinfo);
+ if (!cinfo->master->lossless)
+ latch_quant_tables(cinfo);
(*cinfo->entropy->start_pass) (cinfo);
(*cinfo->coef->start_input_pass) (cinfo);
cinfo->inputctl->consume_input = cinfo->coef->consume_data;
@@ -290,8 +306,8 @@ start_input_pass(j_decompress_ptr cinfo)
/*
* Finish up after inputting a compressed-data scan.
- * This is called by the coefficient controller after it's read all
- * the expected data of the scan.
+ * This is called by the coefficient or difference controller after it's read
+ * all the expected data of the scan.
*/
METHODDEF(void)
@@ -307,8 +323,8 @@ finish_input_pass(j_decompress_ptr cinfo)
* Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
*
* The consume_input method pointer points either here or to the
- * coefficient controller's consume_data routine, depending on whether
- * we are reading a compressed data segment or inter-segment markers.
+ * coefficient or difference controller's consume_data routine, depending on
+ * whether we are reading a compressed data segment or inter-segment markers.
*/
METHODDEF(int)
diff --git a/contrib/libs/libjpeg-turbo/src/jdlhuff.c b/contrib/libs/libjpeg-turbo/src/jdlhuff.c
new file mode 100644
index 00000000000..9964830dba0
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jdlhuff.c
@@ -0,0 +1,302 @@
+/*
+ * jdlhuff.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains Huffman entropy decoding routines for lossless JPEG.
+ *
+ * Much of the complexity here has to do with supporting input suspension.
+ * If the data source module demands suspension, we want to be able to back
+ * up to the start of the current MCU. To do this, we copy state variables
+ * into local working storage, and update them back to the permanent
+ * storage only upon successful completion of an MCU.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jlossls.h" /* Private declarations for lossless codec */
+#include "jdhuff.h" /* Declarations shared with jd*huff.c */
+
+
+#ifdef D_LOSSLESS_SUPPORTED
+
+typedef struct {
+ int ci, yoffset, MCU_width;
+} lhd_output_ptr_info;
+
+/*
+ * Expanded entropy decoder object for Huffman decoding in lossless mode.
+ */
+
+typedef struct {
+ struct jpeg_entropy_decoder pub; /* public fields */
+
+ /* These fields are loaded into local variables at start of each MCU.
+ * In case of suspension, we exit WITHOUT updating them.
+ */
+ bitread_perm_state bitstate; /* Bit buffer at start of MCU */
+
+ /* Pointers to derived tables (these workspaces have image lifespan) */
+ d_derived_tbl *derived_tbls[NUM_HUFF_TBLS];
+
+ /* Precalculated info set up by start_pass for use in decode_mcus: */
+
+ /* Pointers to derived tables to be used for each data unit within an MCU */
+ d_derived_tbl *cur_tbls[D_MAX_BLOCKS_IN_MCU];
+
+ /* Pointers to the proper output difference row for each group of data units
+ * within an MCU. For each component, there are Vi groups of Hi data units.
+ */
+ JDIFFROW output_ptr[D_MAX_BLOCKS_IN_MCU];
+
+ /* Number of output pointers in use for the current MCU. This is the sum
+ * of all Vi in the MCU.
+ */
+ int num_output_ptrs;
+
+ /* Information used for positioning the output pointers within the output
+ * difference rows.
+ */
+ lhd_output_ptr_info output_ptr_info[D_MAX_BLOCKS_IN_MCU];
+
+ /* Index of the proper output pointer for each data unit within an MCU */
+ int output_ptr_index[D_MAX_BLOCKS_IN_MCU];
+
+} lhuff_entropy_decoder;
+
+typedef lhuff_entropy_decoder *lhuff_entropy_ptr;
+
+
+/*
+ * Initialize for a Huffman-compressed scan.
+ */
+
+METHODDEF(void)
+start_pass_lhuff_decoder(j_decompress_ptr cinfo)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+ int ci, dctbl, sampn, ptrn, yoffset, xoffset;
+ jpeg_component_info *compptr;
+
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
+ compptr = cinfo->cur_comp_info[ci];
+ dctbl = compptr->dc_tbl_no;
+ /* Make sure requested tables are present */
+ if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS ||
+ cinfo->dc_huff_tbl_ptrs[dctbl] == NULL)
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl);
+ /* Compute derived values for Huffman tables */
+ /* We may do this more than once for a table, but it's not expensive */
+ jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl,
+ &entropy->derived_tbls[dctbl]);
+ }
+
+ /* Precalculate decoding info for each sample in an MCU of this scan */
+ for (sampn = 0, ptrn = 0; sampn < cinfo->blocks_in_MCU;) {
+ compptr = cinfo->cur_comp_info[cinfo->MCU_membership[sampn]];
+ ci = compptr->component_index;
+ for (yoffset = 0; yoffset < compptr->MCU_height; yoffset++, ptrn++) {
+ /* Precalculate the setup info for each output pointer */
+ entropy->output_ptr_info[ptrn].ci = ci;
+ entropy->output_ptr_info[ptrn].yoffset = yoffset;
+ entropy->output_ptr_info[ptrn].MCU_width = compptr->MCU_width;
+ for (xoffset = 0; xoffset < compptr->MCU_width; xoffset++, sampn++) {
+ /* Precalculate the output pointer index for each sample */
+ entropy->output_ptr_index[sampn] = ptrn;
+ /* Precalculate which table to use for each sample */
+ entropy->cur_tbls[sampn] = entropy->derived_tbls[compptr->dc_tbl_no];
+ }
+ }
+ }
+ entropy->num_output_ptrs = ptrn;
+
+ /* Initialize bitread state variables */
+ entropy->bitstate.bits_left = 0;
+ entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
+ entropy->pub.insufficient_data = FALSE;
+}
+
+
+/*
+ * Figure F.12: extend sign bit.
+ * On some machines, a shift and add will be faster than a table lookup.
+ */
+
+#define AVOID_TABLES
+#ifdef AVOID_TABLES
+
+#define NEG_1 ((unsigned int)-1)
+#define HUFF_EXTEND(x, s) \
+ ((x) + ((((x) - (1 << ((s) - 1))) >> 31) & (((NEG_1) << (s)) + 1)))
+
+#else
+
+#define HUFF_EXTEND(x, s) \
+ ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
+
+static const int extend_test[16] = { /* entry n is 2**(n-1) */
+ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
+ 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
+};
+
+static const int extend_offset[16] = { /* entry n is (-1 << n) + 1 */
+ 0, ((-1) << 1) + 1, ((-1) << 2) + 1, ((-1) << 3) + 1, ((-1) << 4) + 1,
+ ((-1) << 5) + 1, ((-1) << 6) + 1, ((-1) << 7) + 1, ((-1) << 8) + 1,
+ ((-1) << 9) + 1, ((-1) << 10) + 1, ((-1) << 11) + 1, ((-1) << 12) + 1,
+ ((-1) << 13) + 1, ((-1) << 14) + 1, ((-1) << 15) + 1
+};
+
+#endif /* AVOID_TABLES */
+
+
+/*
+ * Check for a restart marker & resynchronize decoder.
+ * Returns FALSE if must suspend.
+ */
+
+LOCAL(boolean)
+process_restart(j_decompress_ptr cinfo)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+
+ /* Throw away any unused bits remaining in bit buffer; */
+ /* include any full bytes in next_marker's count of discarded bytes */
+ cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
+ entropy->bitstate.bits_left = 0;
+
+ /* Advance past the RSTn marker */
+ if (!(*cinfo->marker->read_restart_marker) (cinfo))
+ return FALSE;
+
+ /* Reset out-of-data flag, unless read_restart_marker left us smack up
+ * against a marker. In that case we will end up treating the next data
+ * segment as empty, and we can avoid producing bogus output pixels by
+ * leaving the flag set.
+ */
+ if (cinfo->unread_marker == 0)
+ entropy->pub.insufficient_data = FALSE;
+
+ return TRUE;
+}
+
+
+/*
+ * Decode and return nMCU MCUs' worth of Huffman-compressed differences.
+ * Each MCU is also disassembled and placed accordingly in diff_buf.
+ *
+ * MCU_col_num specifies the column of the first MCU being requested within
+ * the MCU row. This tells us where to position the output row pointers in
+ * diff_buf.
+ *
+ * Returns the number of MCUs decoded. This may be less than nMCU MCUs if
+ * data source requested suspension. In that case no changes have been made
+ * to permanent state. (Exception: some output differences may already have
+ * been assigned. This is harmless for this module, since we'll just
+ * re-assign them on the next call.)
+ */
+
+METHODDEF(JDIMENSION)
+decode_mcus(j_decompress_ptr cinfo, JDIFFIMAGE diff_buf,
+ JDIMENSION MCU_row_num, JDIMENSION MCU_col_num, JDIMENSION nMCU)
+{
+ lhuff_entropy_ptr entropy = (lhuff_entropy_ptr)cinfo->entropy;
+ int sampn, ci, yoffset, MCU_width, ptrn;
+ JDIMENSION mcu_num;
+ BITREAD_STATE_VARS;
+
+ /* Set output pointer locations based on MCU_col_num */
+ for (ptrn = 0; ptrn < entropy->num_output_ptrs; ptrn++) {
+ ci = entropy->output_ptr_info[ptrn].ci;
+ yoffset = entropy->output_ptr_info[ptrn].yoffset;
+ MCU_width = entropy->output_ptr_info[ptrn].MCU_width;
+ entropy->output_ptr[ptrn] =
+ diff_buf[ci][MCU_row_num + yoffset] + (MCU_col_num * MCU_width);
+ }
+
+ /*
+ * If we've run out of data, zero out the buffers and return.
+ * By resetting the undifferencer, the output samples will be CENTERJSAMPLE.
+ *
+ * NB: We should find a way to do this without interacting with the
+ * undifferencer module directly.
+ */
+ if (entropy->pub.insufficient_data) {
+ for (ptrn = 0; ptrn < entropy->num_output_ptrs; ptrn++)
+ jzero_far((void FAR *)entropy->output_ptr[ptrn],
+ nMCU * entropy->output_ptr_info[ptrn].MCU_width *
+ sizeof(JDIFF));
+
+ (*cinfo->idct->start_pass) (cinfo);
+
+ } else {
+
+ /* Load up working state */
+ BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
+
+ /* Outer loop handles the number of MCUs requested */
+
+ for (mcu_num = 0; mcu_num < nMCU; mcu_num++) {
+
+ /* Inner loop handles the samples in the MCU */
+ for (sampn = 0; sampn < cinfo->blocks_in_MCU; sampn++) {
+ d_derived_tbl *dctbl = entropy->cur_tbls[sampn];
+ register int s, r;
+
+ /* Section H.2.2: decode the sample difference */
+ HUFF_DECODE(s, br_state, dctbl, return mcu_num, label1);
+ if (s) {
+ if (s == 16) /* special case: always output 32768 */
+ s = 32768;
+ else { /* normal case: fetch subsequent bits */
+ CHECK_BIT_BUFFER(br_state, s, return mcu_num);
+ r = GET_BITS(s);
+ s = HUFF_EXTEND(r, s);
+ }
+ }
+
+ /* Output the sample difference */
+ *entropy->output_ptr[entropy->output_ptr_index[sampn]]++ = (JDIFF)s;
+ }
+
+ /* Completed MCU, so update state */
+ BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
+ }
+ }
+
+ return nMCU;
+}
+
+
+/*
+ * Module initialization routine for lossless mode Huffman entropy decoding.
+ */
+
+GLOBAL(void)
+jinit_lhuff_decoder(j_decompress_ptr cinfo)
+{
+ lhuff_entropy_ptr entropy;
+ int i;
+
+ entropy = (lhuff_entropy_ptr)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ sizeof(lhuff_entropy_decoder));
+ cinfo->entropy = (struct jpeg_entropy_decoder *)entropy;
+ entropy->pub.start_pass = start_pass_lhuff_decoder;
+ entropy->pub.decode_mcus = decode_mcus;
+ entropy->pub.process_restart = process_restart;
+
+ /* Mark tables unallocated */
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
+ entropy->derived_tbls[i] = NULL;
+ }
+}
+
+#endif /* D_LOSSLESS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/src/jdlossls.c b/contrib/libs/libjpeg-turbo/src/jdlossls.c
new file mode 100644
index 00000000000..520755adc3c
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jdlossls.c
@@ -0,0 +1,297 @@
+/*
+ * jdlossls.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1998, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, 2024, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains prediction, sample undifferencing, point transform, and
+ * sample scaling routines for the lossless JPEG decompressor.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jlossls.h"
+
+#ifdef D_LOSSLESS_SUPPORTED
+
+
+/**************** Sample undifferencing (reconstruction) *****************/
+
+/*
+ * In order to avoid a performance penalty for checking which predictor is
+ * being used and which row is being processed for each call of the
+ * undifferencer, and to promote optimization, we have separate undifferencing
+ * functions for each predictor selection value.
+ *
+ * We are able to avoid duplicating source code by implementing the predictors
+ * and undifferencers as macros. Each of the undifferencing functions is
+ * simply a wrapper around an UNDIFFERENCE macro with the appropriate PREDICTOR
+ * macro passed as an argument.
+ */
+
+/* Predictor for the first column of the first row: 2^(P-Pt-1) */
+#define INITIAL_PREDICTORx (1 << (cinfo->data_precision - cinfo->Al - 1))
+
+/* Predictor for the first column of the remaining rows: Rb */
+#define INITIAL_PREDICTOR2 prev_row[0]
+
+
+/*
+ * 1-Dimensional undifferencer routine.
+ *
+ * This macro implements the 1-D horizontal predictor (1). INITIAL_PREDICTOR
+ * is used as the special case predictor for the first column, which must be
+ * either INITIAL_PREDICTOR2 or INITIAL_PREDICTORx. The remaining samples
+ * use PREDICTOR1.
+ *
+ * The reconstructed sample is supposed to be calculated modulo 2^16, so we
+ * logically AND the result with 0xFFFF.
+ */
+
+#define UNDIFFERENCE_1D(INITIAL_PREDICTOR) \
+ int Ra; \
+ \
+ Ra = (*diff_buf++ + INITIAL_PREDICTOR) & 0xFFFF; \
+ *undiff_buf++ = Ra; \
+ \
+ while (--width) { \
+ Ra = (*diff_buf++ + PREDICTOR1) & 0xFFFF; \
+ *undiff_buf++ = Ra; \
+ }
+
+
+/*
+ * 2-Dimensional undifferencer routine.
+ *
+ * This macro implements the 2-D horizontal predictors (#2-7). PREDICTOR2 is
+ * used as the special case predictor for the first column. The remaining
+ * samples use PREDICTOR, which is a function of Ra, Rb, and Rc.
+ *
+ * Because prev_row and output_buf may point to the same storage area (in an
+ * interleaved image with Vi=1, for example), we must take care to buffer Rb/Rc
+ * before writing the current reconstructed sample value into output_buf.
+ *
+ * The reconstructed sample is supposed to be calculated modulo 2^16, so we
+ * logically AND the result with 0xFFFF.
+ */
+
+#define UNDIFFERENCE_2D(PREDICTOR) \
+ int Ra, Rb, Rc; \
+ \
+ Rb = *prev_row++; \
+ Ra = (*diff_buf++ + PREDICTOR2) & 0xFFFF; \
+ *undiff_buf++ = Ra; \
+ \
+ while (--width) { \
+ Rc = Rb; \
+ Rb = *prev_row++; \
+ Ra = (*diff_buf++ + PREDICTOR) & 0xFFFF; \
+ *undiff_buf++ = Ra; \
+ }
+
+
+/*
+ * Undifferencers for the second and subsequent rows in a scan or restart
+ * interval. The first sample in the row is undifferenced using the vertical
+ * predictor (2). The rest of the samples are undifferenced using the
+ * predictor specified in the scan header.
+ */
+
+METHODDEF(void)
+jpeg_undifference1(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ UNDIFFERENCE_1D(INITIAL_PREDICTOR2);
+}
+
+METHODDEF(void)
+jpeg_undifference2(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ UNDIFFERENCE_2D(PREDICTOR2);
+ (void)(Rc);
+}
+
+METHODDEF(void)
+jpeg_undifference3(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ UNDIFFERENCE_2D(PREDICTOR3);
+}
+
+METHODDEF(void)
+jpeg_undifference4(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ UNDIFFERENCE_2D(PREDICTOR4);
+}
+
+METHODDEF(void)
+jpeg_undifference5(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ UNDIFFERENCE_2D(PREDICTOR5);
+}
+
+METHODDEF(void)
+jpeg_undifference6(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ UNDIFFERENCE_2D(PREDICTOR6);
+}
+
+METHODDEF(void)
+jpeg_undifference7(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ UNDIFFERENCE_2D(PREDICTOR7);
+ (void)(Rc);
+}
+
+
+/*
+ * Undifferencer for the first row in a scan or restart interval. The first
+ * sample in the row is undifferenced using the special predictor constant
+ * x=2^(P-Pt-1). The rest of the samples are undifferenced using the
+ * 1-D horizontal predictor (1).
+ */
+
+METHODDEF(void)
+jpeg_undifference_first_row(j_decompress_ptr cinfo, int comp_index,
+ JDIFFROW diff_buf, JDIFFROW prev_row,
+ JDIFFROW undiff_buf, JDIMENSION width)
+{
+ lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct;
+
+ UNDIFFERENCE_1D(INITIAL_PREDICTORx);
+
+ /*
+ * Now that we have undifferenced the first row, we want to use the
+ * undifferencer that corresponds to the predictor specified in the
+ * scan header.
+ */
+ switch (cinfo->Ss) {
+ case 1:
+ losslessd->predict_undifference[comp_index] = jpeg_undifference1;
+ break;
+ case 2:
+ losslessd->predict_undifference[comp_index] = jpeg_undifference2;
+ break;
+ case 3:
+ losslessd->predict_undifference[comp_index] = jpeg_undifference3;
+ break;
+ case 4:
+ losslessd->predict_undifference[comp_index] = jpeg_undifference4;
+ break;
+ case 5:
+ losslessd->predict_undifference[comp_index] = jpeg_undifference5;
+ break;
+ case 6:
+ losslessd->predict_undifference[comp_index] = jpeg_undifference6;
+ break;
+ case 7:
+ losslessd->predict_undifference[comp_index] = jpeg_undifference7;
+ break;
+ }
+}
+
+
+/*********************** Sample upscaling by 2^Pt ************************/
+
+METHODDEF(void)
+simple_upscale(j_decompress_ptr cinfo,
+ JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width)
+{
+ do {
+ *output_buf++ = (_JSAMPLE)(*diff_buf++ << cinfo->Al);
+ } while (--width);
+}
+
+METHODDEF(void)
+noscale(j_decompress_ptr cinfo,
+ JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width)
+{
+ do {
+ *output_buf++ = (_JSAMPLE)(*diff_buf++);
+ } while (--width);
+}
+
+
+/*
+ * Initialize for an input processing pass.
+ */
+
+METHODDEF(void)
+start_pass_lossless(j_decompress_ptr cinfo)
+{
+ lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct;
+ int ci;
+
+ /* Check that the scan parameters Ss, Se, Ah, Al are OK for lossless JPEG.
+ *
+ * Ss is the predictor selection value (psv). Legal values for sequential
+ * lossless JPEG are: 1 <= psv <= 7.
+ *
+ * Se and Ah are not used and should be zero.
+ *
+ * Al specifies the point transform (Pt).
+ * Legal values are: 0 <= Pt <= (data precision - 1).
+ */
+ if (cinfo->Ss < 1 || cinfo->Ss > 7 ||
+ cinfo->Se != 0 || cinfo->Ah != 0 ||
+ cinfo->Al < 0 || cinfo->Al >= cinfo->data_precision)
+ ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
+ cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
+
+ /* Set undifference functions to first row function */
+ for (ci = 0; ci < cinfo->num_components; ci++)
+ losslessd->predict_undifference[ci] = jpeg_undifference_first_row;
+
+ /* Set scaler function based on Pt */
+ if (cinfo->Al)
+ losslessd->scaler_scale = simple_upscale;
+ else
+ losslessd->scaler_scale = noscale;
+}
+
+
+/*
+ * Initialize the lossless decompressor.
+ */
+
+GLOBAL(void)
+_jinit_lossless_decompressor(j_decompress_ptr cinfo)
+{
+ lossless_decomp_ptr losslessd;
+
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ /* Create subobject in permanent pool */
+ losslessd = (lossless_decomp_ptr)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
+ sizeof(jpeg_lossless_decompressor));
+ cinfo->idct = (struct jpeg_inverse_dct *)losslessd;
+ losslessd->pub.start_pass = start_pass_lossless;
+}
+
+#endif /* D_LOSSLESS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/jdmainct.c b/contrib/libs/libjpeg-turbo/src/jdmainct.c
index f466b259f0d..fc97073e3d8 100644
--- a/contrib/libs/libjpeg-turbo/jdmainct.c
+++ b/contrib/libs/libjpeg-turbo/src/jdmainct.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2016, D. R. Commander.
+ * Copyright (C) 2010, 2016, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -18,15 +18,17 @@
#include "jinclude.h"
#include "jdmainct.h"
-#include "jconfigint.h"
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
+
/*
* In the current system design, the main buffer need never be a full-image
- * buffer; any full-height buffers will be found inside the coefficient or
- * postprocessing controllers. Nonetheless, the main controller is not
- * trivial. Its responsibility is to provide context rows for upsampling/
- * rescaling, and doing this in an efficient fashion is a bit tricky.
+ * buffer; any full-height buffers will be found inside the coefficient,
+ * difference, or postprocessing controllers. Nonetheless, the main controller
+ * is not trivial. Its responsibility is to provide context rows for
+ * upsampling/rescaling, and doing this in an efficient fashion is a bit
+ * tricky.
*
* Postprocessor input data is counted in "row groups". A row group
* is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
@@ -38,20 +40,20 @@
* row group (times any additional scale factor that the upsampler is
* applying).
*
- * The coefficient controller will deliver data to us one iMCU row at a time;
- * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or
- * exactly min_DCT_scaled_size row groups. (This amount of data corresponds
- * to one row of MCUs when the image is fully interleaved.) Note that the
- * number of sample rows varies across components, but the number of row
- * groups does not. Some garbage sample rows may be included in the last iMCU
- * row at the bottom of the image.
+ * The coefficient or difference controller will deliver data to us one iMCU
+ * row at a time; each iMCU row contains v_samp_factor * DCT_scaled_size sample
+ * rows, or exactly min_DCT_scaled_size row groups. (This amount of data
+ * corresponds to one row of MCUs when the image is fully interleaved.) Note
+ * that the number of sample rows varies across components, but the number of
+ * row groups does not. Some garbage sample rows may be included in the last
+ * iMCU row at the bottom of the image.
*
* Depending on the vertical scaling algorithm used, the upsampler may need
* access to the sample row(s) above and below its current input row group.
* The upsampler is required to set need_context_rows TRUE at global selection
* time if so. When need_context_rows is FALSE, this controller can simply
- * obtain one iMCU row at a time from the coefficient controller and dole it
- * out as row groups to the postprocessor.
+ * obtain one iMCU row at a time from the coefficient or difference controller
+ * and dole it out as row groups to the postprocessor.
*
* When need_context_rows is TRUE, this controller guarantees that the buffer
* passed to postprocessing contains at least one row group's worth of samples
@@ -114,16 +116,16 @@
/* Forward declarations */
METHODDEF(void) process_data_simple_main(j_decompress_ptr cinfo,
- JSAMPARRAY output_buf,
+ _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
METHODDEF(void) process_data_context_main(j_decompress_ptr cinfo,
- JSAMPARRAY output_buf,
+ _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
#ifdef QUANT_2PASS_SUPPORTED
METHODDEF(void) process_data_crank_post(j_decompress_ptr cinfo,
- JSAMPARRAY output_buf,
+ _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
#endif
@@ -139,14 +141,15 @@ alloc_funny_pointers(j_decompress_ptr cinfo)
int ci, rgroup;
int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr;
- JSAMPARRAY xbuf;
+ _JSAMPARRAY xbuf;
/* Get top-level space for component array pointers.
* We alloc both arrays with one call to save a few cycles.
*/
- main_ptr->xbuffer[0] = (JSAMPIMAGE)
+ main_ptr->xbuffer[0] = (_JSAMPIMAGE)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- cinfo->num_components * 2 * sizeof(JSAMPARRAY));
+ cinfo->num_components * 2 *
+ sizeof(_JSAMPARRAY));
main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
@@ -156,9 +159,9 @@ alloc_funny_pointers(j_decompress_ptr cinfo)
/* Get space for pointer lists --- M+4 row groups in each list.
* We alloc both pointer lists with one call to save a few cycles.
*/
- xbuf = (JSAMPARRAY)
+ xbuf = (_JSAMPARRAY)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- 2 * (rgroup * (M + 4)) * sizeof(JSAMPROW));
+ 2 * (rgroup * (M + 4)) * sizeof(_JSAMPROW));
xbuf += rgroup; /* want one row group at negative offsets */
main_ptr->xbuffer[0][ci] = xbuf;
xbuf += rgroup * (M + 4);
@@ -180,7 +183,7 @@ make_funny_pointers(j_decompress_ptr cinfo)
int ci, i, rgroup;
int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr;
- JSAMPARRAY buf, xbuf0, xbuf1;
+ _JSAMPARRAY buf, xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
@@ -220,7 +223,7 @@ set_bottom_pointers(j_decompress_ptr cinfo)
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
int ci, i, rgroup, iMCUheight, rows_left;
jpeg_component_info *compptr;
- JSAMPARRAY xbuf;
+ _JSAMPARRAY xbuf;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
@@ -259,14 +262,14 @@ start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
switch (pass_mode) {
case JBUF_PASS_THRU:
if (cinfo->upsample->need_context_rows) {
- main_ptr->pub.process_data = process_data_context_main;
+ main_ptr->pub._process_data = process_data_context_main;
make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
main_ptr->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
main_ptr->iMCU_row_ctr = 0;
} else {
/* Simple case with no context needed */
- main_ptr->pub.process_data = process_data_simple_main;
+ main_ptr->pub._process_data = process_data_simple_main;
}
main_ptr->buffer_full = FALSE; /* Mark buffer empty */
main_ptr->rowgroup_ctr = 0;
@@ -274,7 +277,7 @@ start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
#ifdef QUANT_2PASS_SUPPORTED
case JBUF_CRANK_DEST:
/* For last pass of 2-pass quantization, just crank the postprocessor */
- main_ptr->pub.process_data = process_data_crank_post;
+ main_ptr->pub._process_data = process_data_crank_post;
break;
#endif
default:
@@ -290,7 +293,7 @@ start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
*/
METHODDEF(void)
-process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
+process_data_simple_main(j_decompress_ptr cinfo, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
{
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
@@ -298,7 +301,7 @@ process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
/* Read input data if we haven't filled the main buffer yet */
if (!main_ptr->buffer_full) {
- if (!(*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer))
+ if (!(*cinfo->coef->_decompress_data) (cinfo, main_ptr->buffer))
return; /* suspension forced, can do nothing more */
main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
}
@@ -311,9 +314,9 @@ process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
*/
/* Feed the postprocessor */
- (*cinfo->post->post_process_data) (cinfo, main_ptr->buffer,
- &main_ptr->rowgroup_ctr, rowgroups_avail,
- output_buf, out_row_ctr, out_rows_avail);
+ (*cinfo->post->_post_process_data) (cinfo, main_ptr->buffer,
+ &main_ptr->rowgroup_ctr, rowgroups_avail,
+ output_buf, out_row_ctr, out_rows_avail);
/* Has postprocessor consumed all the data yet? If so, mark buffer empty */
if (main_ptr->rowgroup_ctr >= rowgroups_avail) {
@@ -329,15 +332,15 @@ process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
*/
METHODDEF(void)
-process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
+process_data_context_main(j_decompress_ptr cinfo, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
{
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
/* Read input data if we haven't filled the main buffer yet */
if (!main_ptr->buffer_full) {
- if (!(*cinfo->coef->decompress_data) (cinfo,
- main_ptr->xbuffer[main_ptr->whichptr]))
+ if (!(*cinfo->coef->_decompress_data) (cinfo,
+ main_ptr->xbuffer[main_ptr->whichptr]))
return; /* suspension forced, can do nothing more */
main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
main_ptr->iMCU_row_ctr++; /* count rows received */
@@ -351,11 +354,11 @@ process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
switch (main_ptr->context_state) {
case CTX_POSTPONED_ROW:
/* Call postprocessor using previously set pointers for postponed row */
- (*cinfo->post->post_process_data) (cinfo,
- main_ptr->xbuffer[main_ptr->whichptr],
- &main_ptr->rowgroup_ctr,
- main_ptr->rowgroups_avail, output_buf,
- out_row_ctr, out_rows_avail);
+ (*cinfo->post->_post_process_data) (cinfo,
+ main_ptr->xbuffer[main_ptr->whichptr],
+ &main_ptr->rowgroup_ctr,
+ main_ptr->rowgroups_avail, output_buf,
+ out_row_ctr, out_rows_avail);
if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
return; /* Need to suspend */
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
@@ -375,11 +378,11 @@ process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
FALLTHROUGH /*FALLTHROUGH*/
case CTX_PROCESS_IMCU:
/* Call postprocessor using previously set pointers */
- (*cinfo->post->post_process_data) (cinfo,
- main_ptr->xbuffer[main_ptr->whichptr],
- &main_ptr->rowgroup_ctr,
- main_ptr->rowgroups_avail, output_buf,
- out_row_ctr, out_rows_avail);
+ (*cinfo->post->_post_process_data) (cinfo,
+ main_ptr->xbuffer[main_ptr->whichptr],
+ &main_ptr->rowgroup_ctr,
+ main_ptr->rowgroups_avail, output_buf,
+ out_row_ctr, out_rows_avail);
if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
return; /* Need to suspend */
/* After the first iMCU, change wraparound pointers to normal state */
@@ -406,12 +409,12 @@ process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
#ifdef QUANT_2PASS_SUPPORTED
METHODDEF(void)
-process_data_crank_post(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
+process_data_crank_post(j_decompress_ptr cinfo, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
{
- (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE)NULL,
- (JDIMENSION *)NULL, (JDIMENSION)0,
- output_buf, out_row_ctr, out_rows_avail);
+ (*cinfo->post->_post_process_data) (cinfo, (_JSAMPIMAGE)NULL,
+ (JDIMENSION *)NULL, (JDIMENSION)0,
+ output_buf, out_row_ctr, out_rows_avail);
}
#endif /* QUANT_2PASS_SUPPORTED */
@@ -422,15 +425,32 @@ process_data_crank_post(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
*/
GLOBAL(void)
-jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
+_jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
{
my_main_ptr main_ptr;
int ci, rgroup, ngroups;
jpeg_component_info *compptr;
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
main_ptr = (my_main_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_main_controller));
+ memset(main_ptr, 0, sizeof(my_main_controller));
cinfo->main = (struct jpeg_d_main_controller *)main_ptr;
main_ptr->pub.start_pass = start_pass_main;
@@ -453,9 +473,11 @@ jinit_d_main_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
- main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
+ main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
compptr->width_in_blocks * compptr->_DCT_scaled_size,
(JDIMENSION)(rgroup * ngroups));
}
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jdmainct.h b/contrib/libs/libjpeg-turbo/src/jdmainct.h
index 37b201ca882..914ad11f694 100644
--- a/contrib/libs/libjpeg-turbo/jdmainct.h
+++ b/contrib/libs/libjpeg-turbo/src/jdmainct.h
@@ -3,22 +3,27 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*/
#define JPEG_INTERNALS
#include "jpeglib.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
+
/* Private buffer controller object */
typedef struct {
struct jpeg_d_main_controller pub; /* public fields */
/* Pointer to allocated workspace (M or M+2 row groups). */
- JSAMPARRAY buffer[MAX_COMPONENTS];
+ _JSAMPARRAY buffer[MAX_COMPONENTS];
boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */
@@ -26,7 +31,7 @@ typedef struct {
/* Remaining fields are only used in the context case. */
/* These are the master pointers to the funny-order pointer lists. */
- JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
+ _JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
int whichptr; /* indicates which pointer set is now in use */
int context_state; /* process_data state machine status */
@@ -53,7 +58,7 @@ set_wraparound_pointers(j_decompress_ptr cinfo)
int ci, i, rgroup;
int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr;
- JSAMPARRAY xbuf0, xbuf1;
+ _JSAMPARRAY xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
@@ -69,3 +74,5 @@ set_wraparound_pointers(j_decompress_ptr cinfo)
}
}
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jdmarker.c b/contrib/libs/libjpeg-turbo/src/jdmarker.c
index f7eba615fd5..f918ee4db52 100644
--- a/contrib/libs/libjpeg-turbo/jdmarker.c
+++ b/contrib/libs/libjpeg-turbo/src/jdmarker.c
@@ -3,8 +3,10 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
- * Copyright (C) 2012, 2015, 2022, D. R. Commander.
+ * Copyright (C) 2012, 2015, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -237,7 +239,8 @@ get_soi(j_decompress_ptr cinfo)
LOCAL(boolean)
-get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
+get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_lossless,
+ boolean is_arith)
/* Process a SOFn marker */
{
JLONG length;
@@ -245,7 +248,11 @@ get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
jpeg_component_info *compptr;
INPUT_VARS(cinfo);
+ if (cinfo->marker->saw_SOF)
+ ERREXIT(cinfo, JERR_SOF_DUPLICATE);
+
cinfo->progressive_mode = is_prog;
+ cinfo->master->lossless = is_lossless;
cinfo->arith_code = is_arith;
INPUT_2BYTES(cinfo, length, return FALSE);
@@ -261,9 +268,6 @@ get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
(int)cinfo->image_width, (int)cinfo->image_height,
cinfo->num_components);
- if (cinfo->marker->saw_SOF)
- ERREXIT(cinfo, JERR_SOF_DUPLICATE);
-
/* We don't support files in which the image height is initially specified */
/* as 0 and is later redefined by DNL. As long as we have to check that, */
/* might as well have a general sanity check. */
@@ -815,13 +819,11 @@ save_marker(j_decompress_ptr cinfo)
/* Done reading what we want to read */
if (cur_marker != NULL) { /* will be NULL if bogus length word */
/* Add new marker to end of list */
- if (cinfo->marker_list == NULL) {
- cinfo->marker_list = cur_marker;
+ if (cinfo->marker_list == NULL || cinfo->master->marker_list_end == NULL) {
+ cinfo->marker_list = cinfo->master->marker_list_end = cur_marker;
} else {
- jpeg_saved_marker_ptr prev = cinfo->marker_list;
- while (prev->next != NULL)
- prev = prev->next;
- prev->next = cur_marker;
+ cinfo->master->marker_list_end->next = cur_marker;
+ cinfo->master->marker_list_end = cur_marker;
}
/* Reset pointer & calc remaining data length */
data = cur_marker->data;
@@ -990,32 +992,40 @@ read_markers(j_decompress_ptr cinfo)
case M_SOF0: /* Baseline */
case M_SOF1: /* Extended sequential, Huffman */
- if (!get_sof(cinfo, FALSE, FALSE))
+ if (!get_sof(cinfo, FALSE, FALSE, FALSE))
return JPEG_SUSPENDED;
break;
case M_SOF2: /* Progressive, Huffman */
- if (!get_sof(cinfo, TRUE, FALSE))
+ if (!get_sof(cinfo, TRUE, FALSE, FALSE))
+ return JPEG_SUSPENDED;
+ break;
+
+ case M_SOF3: /* Lossless, Huffman */
+ if (!get_sof(cinfo, FALSE, TRUE, FALSE))
return JPEG_SUSPENDED;
break;
case M_SOF9: /* Extended sequential, arithmetic */
- if (!get_sof(cinfo, FALSE, TRUE))
+ if (!get_sof(cinfo, FALSE, FALSE, TRUE))
return JPEG_SUSPENDED;
break;
case M_SOF10: /* Progressive, arithmetic */
- if (!get_sof(cinfo, TRUE, TRUE))
+ if (!get_sof(cinfo, TRUE, FALSE, TRUE))
+ return JPEG_SUSPENDED;
+ break;
+
+ case M_SOF11: /* Lossless, arithmetic */
+ if (!get_sof(cinfo, FALSE, TRUE, TRUE))
return JPEG_SUSPENDED;
break;
/* Currently unsupported SOFn types */
- case M_SOF3: /* Lossless, Huffman */
case M_SOF5: /* Differential sequential, Huffman */
case M_SOF6: /* Differential progressive, Huffman */
case M_SOF7: /* Differential lossless, Huffman */
case M_JPG: /* Reserved for JPEG extensions */
- case M_SOF11: /* Lossless, arithmetic */
case M_SOF13: /* Differential sequential, arithmetic */
case M_SOF14: /* Differential progressive, arithmetic */
case M_SOF15: /* Differential lossless, arithmetic */
diff --git a/contrib/libs/libjpeg-turbo/src/jdmaster.c b/contrib/libs/libjpeg-turbo/src/jdmaster.c
new file mode 100644
index 00000000000..4085c229186
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jdmaster.c
@@ -0,0 +1,893 @@
+/*
+ * jdmaster.c
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 2002-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2009-2011, 2016, 2019, 2022-2024, D. R. Commander.
+ * Copyright (C) 2013, Linaro Limited.
+ * Copyright (C) 2015, Google, Inc.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains master control logic for the JPEG decompressor.
+ * These routines are concerned with selecting the modules to be executed
+ * and with determining the number of passes and the work to be done in each
+ * pass.
+ */
+
+#define JPEG_INTERNALS
+#include "jinclude.h"
+#include "jpeglib.h"
+#include "jpegapicomp.h"
+#include "jdmaster.h"
+
+
+/*
+ * Determine whether merged upsample/color conversion should be used.
+ * CRUCIAL: this must match the actual capabilities of jdmerge.c!
+ */
+
+LOCAL(boolean)
+use_merged_upsample(j_decompress_ptr cinfo)
+{
+#ifdef UPSAMPLE_MERGING_SUPPORTED
+ /* Colorspace conversion is not supported with lossless JPEG images */
+ if (cinfo->master->lossless)
+ return FALSE;
+ /* Merging is the equivalent of plain box-filter upsampling */
+ if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
+ return FALSE;
+ /* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */
+ if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
+ (cinfo->out_color_space != JCS_RGB &&
+ cinfo->out_color_space != JCS_RGB565 &&
+ cinfo->out_color_space != JCS_EXT_RGB &&
+ cinfo->out_color_space != JCS_EXT_RGBX &&
+ cinfo->out_color_space != JCS_EXT_BGR &&
+ cinfo->out_color_space != JCS_EXT_BGRX &&
+ cinfo->out_color_space != JCS_EXT_XBGR &&
+ cinfo->out_color_space != JCS_EXT_XRGB &&
+ cinfo->out_color_space != JCS_EXT_RGBA &&
+ cinfo->out_color_space != JCS_EXT_BGRA &&
+ cinfo->out_color_space != JCS_EXT_ABGR &&
+ cinfo->out_color_space != JCS_EXT_ARGB))
+ return FALSE;
+ if ((cinfo->out_color_space == JCS_RGB565 &&
+ cinfo->out_color_components != 3) ||
+ (cinfo->out_color_space != JCS_RGB565 &&
+ cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]))
+ return FALSE;
+ /* and it only handles 2h1v or 2h2v sampling ratios */
+ if (cinfo->comp_info[0].h_samp_factor != 2 ||
+ cinfo->comp_info[1].h_samp_factor != 1 ||
+ cinfo->comp_info[2].h_samp_factor != 1 ||
+ cinfo->comp_info[0].v_samp_factor > 2 ||
+ cinfo->comp_info[1].v_samp_factor != 1 ||
+ cinfo->comp_info[2].v_samp_factor != 1)
+ return FALSE;
+ /* furthermore, it doesn't work if we've scaled the IDCTs differently */
+ if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
+ cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
+ cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
+ return FALSE;
+ /* ??? also need to test for upsample-time rescaling, when & if supported */
+ return TRUE; /* by golly, it'll work... */
+#else
+ return FALSE;
+#endif
+}
+
+
+/*
+ * Compute output image dimensions and related values.
+ * NOTE: this is exported for possible use by application.
+ * Hence it mustn't do anything that can't be done twice.
+ */
+
+#if JPEG_LIB_VERSION >= 80
+GLOBAL(void)
+#else
+LOCAL(void)
+#endif
+jpeg_core_output_dimensions(j_decompress_ptr cinfo)
+/* Do computations that are needed before master selection phase.
+ * This function is used for transcoding and full decompression.
+ */
+{
+#ifdef IDCT_SCALING_SUPPORTED
+ int ci;
+ jpeg_component_info *compptr;
+
+ if (!cinfo->master->lossless) {
+ /* Compute actual output image dimensions and DCT scaling choices. */
+ if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom) {
+ /* Provide 1/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 1;
+ cinfo->_min_DCT_v_scaled_size = 1;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 2) {
+ /* Provide 2/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 2L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 2;
+ cinfo->_min_DCT_v_scaled_size = 2;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) {
+ /* Provide 3/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 3L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 3;
+ cinfo->_min_DCT_v_scaled_size = 3;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) {
+ /* Provide 4/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 4L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 4;
+ cinfo->_min_DCT_v_scaled_size = 4;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) {
+ /* Provide 5/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 5L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 5L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 5;
+ cinfo->_min_DCT_v_scaled_size = 5;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 6) {
+ /* Provide 6/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 6L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 6L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 6;
+ cinfo->_min_DCT_v_scaled_size = 6;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 7) {
+ /* Provide 7/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 7L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 7L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 7;
+ cinfo->_min_DCT_v_scaled_size = 7;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) {
+ /* Provide 8/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 8;
+ cinfo->_min_DCT_v_scaled_size = 8;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) {
+ /* Provide 9/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 9L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 9L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 9;
+ cinfo->_min_DCT_v_scaled_size = 9;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 10) {
+ /* Provide 10/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 10L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 10L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 10;
+ cinfo->_min_DCT_v_scaled_size = 10;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 11) {
+ /* Provide 11/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 11L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 11L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 11;
+ cinfo->_min_DCT_v_scaled_size = 11;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 12) {
+ /* Provide 12/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 12L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 12L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 12;
+ cinfo->_min_DCT_v_scaled_size = 12;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 13) {
+ /* Provide 13/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 13L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 13L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 13;
+ cinfo->_min_DCT_v_scaled_size = 13;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 14) {
+ /* Provide 14/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 14L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 14L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 14;
+ cinfo->_min_DCT_v_scaled_size = 14;
+ } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 15) {
+ /* Provide 15/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 15L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 15L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 15;
+ cinfo->_min_DCT_v_scaled_size = 15;
+ } else {
+ /* Provide 16/block_size scaling */
+ cinfo->output_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width * 16L, (long)DCTSIZE);
+ cinfo->output_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE);
+ cinfo->_min_DCT_h_scaled_size = 16;
+ cinfo->_min_DCT_v_scaled_size = 16;
+ }
+
+ /* Recompute dimensions of components */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ compptr->_DCT_h_scaled_size = cinfo->_min_DCT_h_scaled_size;
+ compptr->_DCT_v_scaled_size = cinfo->_min_DCT_v_scaled_size;
+ }
+ } else
+#endif /* !IDCT_SCALING_SUPPORTED */
+ {
+ /* Hardwire it to "no scaling" */
+ cinfo->output_width = cinfo->image_width;
+ cinfo->output_height = cinfo->image_height;
+ /* jdinput.c has already initialized DCT_scaled_size,
+ * and has computed unscaled downsampled_width and downsampled_height.
+ */
+ }
+}
+
+
+/*
+ * Compute output image dimensions and related values.
+ * NOTE: this is exported for possible use by application.
+ * Hence it mustn't do anything that can't be done twice.
+ * Also note that it may be called before the master module is initialized!
+ */
+
+GLOBAL(void)
+jpeg_calc_output_dimensions(j_decompress_ptr cinfo)
+/* Do computations that are needed before master selection phase */
+{
+#ifdef IDCT_SCALING_SUPPORTED
+ int ci;
+ jpeg_component_info *compptr;
+#endif
+
+ /* Prevent application from calling me at wrong times */
+ if (cinfo->global_state != DSTATE_READY)
+ ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
+
+ /* Compute core output image dimensions and DCT scaling choices. */
+ jpeg_core_output_dimensions(cinfo);
+
+#ifdef IDCT_SCALING_SUPPORTED
+
+ if (!cinfo->master->lossless) {
+ /* In selecting the actual DCT scaling for each component, we try to
+ * scale up the chroma components via IDCT scaling rather than upsampling.
+ * This saves time if the upsampler gets to use 1:1 scaling.
+ * Note this code adapts subsampling ratios which are powers of 2.
+ */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ int ssize = cinfo->_min_DCT_scaled_size;
+ while (ssize < DCTSIZE &&
+ ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) %
+ (compptr->h_samp_factor * ssize * 2) == 0) &&
+ ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) %
+ (compptr->v_samp_factor * ssize * 2) == 0)) {
+ ssize = ssize * 2;
+ }
+#if JPEG_LIB_VERSION >= 70
+ compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
+#else
+ compptr->DCT_scaled_size = ssize;
+#endif
+ }
+
+ /* Recompute downsampled dimensions of components;
+ * application needs to know these if using raw downsampled data.
+ */
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
+ ci++, compptr++) {
+ /* Size in samples, after IDCT scaling */
+ compptr->downsampled_width = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_width *
+ (long)(compptr->h_samp_factor *
+ compptr->_DCT_scaled_size),
+ (long)(cinfo->max_h_samp_factor * DCTSIZE));
+ compptr->downsampled_height = (JDIMENSION)
+ jdiv_round_up((long)cinfo->image_height *
+ (long)(compptr->v_samp_factor *
+ compptr->_DCT_scaled_size),
+ (long)(cinfo->max_v_samp_factor * DCTSIZE));
+ }
+ } else
+#endif /* IDCT_SCALING_SUPPORTED */
+ {
+ /* Hardwire it to "no scaling" */
+ cinfo->output_width = cinfo->image_width;
+ cinfo->output_height = cinfo->image_height;
+ /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
+ * and has computed unscaled downsampled_width and downsampled_height.
+ */
+ }
+
+ /* Report number of components in selected colorspace. */
+ /* Probably this should be in the color conversion module... */
+ switch (cinfo->out_color_space) {
+ case JCS_GRAYSCALE:
+ cinfo->out_color_components = 1;
+ break;
+ case JCS_RGB:
+ case JCS_EXT_RGB:
+ case JCS_EXT_RGBX:
+ case JCS_EXT_BGR:
+ case JCS_EXT_BGRX:
+ case JCS_EXT_XBGR:
+ case JCS_EXT_XRGB:
+ case JCS_EXT_RGBA:
+ case JCS_EXT_BGRA:
+ case JCS_EXT_ABGR:
+ case JCS_EXT_ARGB:
+ cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
+ break;
+ case JCS_YCbCr:
+ case JCS_RGB565:
+ cinfo->out_color_components = 3;
+ break;
+ case JCS_CMYK:
+ case JCS_YCCK:
+ cinfo->out_color_components = 4;
+ break;
+ default: /* else must be same colorspace as in file */
+ cinfo->out_color_components = cinfo->num_components;
+ break;
+ }
+ cinfo->output_components = (cinfo->quantize_colors ? 1 :
+ cinfo->out_color_components);
+
+ /* See if upsampler will want to emit more than one row at a time */
+ if (use_merged_upsample(cinfo))
+ cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
+ else
+ cinfo->rec_outbuf_height = 1;
+}
+
+
+/*
+ * Several decompression processes need to range-limit values to the range
+ * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
+ * due to noise introduced by quantization, roundoff error, etc. These
+ * processes are inner loops and need to be as fast as possible. On most
+ * machines, particularly CPUs with pipelines or instruction prefetch,
+ * a (subscript-check-less) C table lookup
+ * x = sample_range_limit[x];
+ * is faster than explicit tests
+ * if (x < 0) x = 0;
+ * else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
+ * These processes all use a common table prepared by the routine below.
+ *
+ * For most steps we can mathematically guarantee that the initial value
+ * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
+ * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
+ * limiting step (just after the IDCT), a wildly out-of-range value is
+ * possible if the input data is corrupt. To avoid any chance of indexing
+ * off the end of memory and getting a bad-pointer trap, we perform the
+ * post-IDCT limiting thus:
+ * x = range_limit[x & MASK];
+ * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
+ * samples. Under normal circumstances this is more than enough range and
+ * a correct output will be generated; with bogus input data the mask will
+ * cause wraparound, and we will safely generate a bogus-but-in-range output.
+ * For the post-IDCT step, we want to convert the data from signed to unsigned
+ * representation by adding CENTERJSAMPLE at the same time that we limit it.
+ * So the post-IDCT limiting table ends up looking like this:
+ * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
+ * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
+ * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
+ * 0,1,...,CENTERJSAMPLE-1
+ * Negative inputs select values from the upper half of the table after
+ * masking.
+ *
+ * We can save some space by overlapping the start of the post-IDCT table
+ * with the simpler range limiting table. The post-IDCT table begins at
+ * sample_range_limit + CENTERJSAMPLE.
+ */
+
+LOCAL(void)
+prepare_range_limit_table(j_decompress_ptr cinfo)
+/* Allocate and fill in the sample_range_limit table */
+{
+ JSAMPLE *table;
+ J12SAMPLE *table12;
+#ifdef D_LOSSLESS_SUPPORTED
+ J16SAMPLE *table16;
+#endif
+ int i;
+
+ if (cinfo->data_precision <= 8) {
+ table = (JSAMPLE *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ (5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
+ table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
+ cinfo->sample_range_limit = table;
+ /* First segment of "simple" table: limit[x] = 0 for x < 0 */
+ memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
+ /* Main part of "simple" table: limit[x] = x */
+ for (i = 0; i <= MAXJSAMPLE; i++)
+ table[i] = (JSAMPLE)i;
+ table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
+ /* End of simple table, rest of first half of post-IDCT table */
+ for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
+ table[i] = MAXJSAMPLE;
+ /* Second half of post-IDCT table */
+ memset(table + (2 * (MAXJSAMPLE + 1)), 0,
+ (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
+ memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
+ cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
+ } else if (cinfo->data_precision <= 12) {
+ table12 = (J12SAMPLE *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ (5 * (MAXJ12SAMPLE + 1) + CENTERJ12SAMPLE) *
+ sizeof(J12SAMPLE));
+ table12 += (MAXJ12SAMPLE + 1); /* allow negative subscripts of simple
+ table */
+ cinfo->sample_range_limit = (JSAMPLE *)table12;
+ /* First segment of "simple" table: limit[x] = 0 for x < 0 */
+ memset(table12 - (MAXJ12SAMPLE + 1), 0,
+ (MAXJ12SAMPLE + 1) * sizeof(J12SAMPLE));
+ /* Main part of "simple" table: limit[x] = x */
+ for (i = 0; i <= MAXJ12SAMPLE; i++)
+ table12[i] = (J12SAMPLE)i;
+ table12 += CENTERJ12SAMPLE; /* Point to where post-IDCT table starts */
+ /* End of simple table, rest of first half of post-IDCT table */
+ for (i = CENTERJ12SAMPLE; i < 2 * (MAXJ12SAMPLE + 1); i++)
+ table12[i] = MAXJ12SAMPLE;
+ /* Second half of post-IDCT table */
+ memset(table12 + (2 * (MAXJ12SAMPLE + 1)), 0,
+ (2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
+ memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
+ cinfo->sample_range_limit, CENTERJ12SAMPLE * sizeof(J12SAMPLE));
+ } else {
+#ifdef D_LOSSLESS_SUPPORTED
+ table16 = (J16SAMPLE *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
+ (5 * (MAXJ16SAMPLE + 1) + CENTERJ16SAMPLE) *
+ sizeof(J16SAMPLE));
+ table16 += (MAXJ16SAMPLE + 1); /* allow negative subscripts of simple
+ table */
+ cinfo->sample_range_limit = (JSAMPLE *)table16;
+ /* First segment of "simple" table: limit[x] = 0 for x < 0 */
+ memset(table16 - (MAXJ16SAMPLE + 1), 0,
+ (MAXJ16SAMPLE + 1) * sizeof(J16SAMPLE));
+ /* Main part of "simple" table: limit[x] = x */
+ for (i = 0; i <= MAXJ16SAMPLE; i++)
+ table16[i] = (J16SAMPLE)i;
+ table16 += CENTERJ16SAMPLE; /* Point to where post-IDCT table starts */
+ /* End of simple table, rest of first half of post-IDCT table */
+ for (i = CENTERJ16SAMPLE; i < 2 * (MAXJ16SAMPLE + 1); i++)
+ table16[i] = MAXJ16SAMPLE;
+ /* Second half of post-IDCT table */
+ memset(table16 + (2 * (MAXJ16SAMPLE + 1)), 0,
+ (2 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE) * sizeof(J16SAMPLE));
+ memcpy(table16 + (4 * (MAXJ16SAMPLE + 1) - CENTERJ16SAMPLE),
+ cinfo->sample_range_limit, CENTERJ16SAMPLE * sizeof(J16SAMPLE));
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+ }
+}
+
+
+/*
+ * Master selection of decompression modules.
+ * This is done once at jpeg_start_decompress time. We determine
+ * which modules will be used and give them appropriate initialization calls.
+ * We also initialize the decompressor input side to begin consuming data.
+ *
+ * Since jpeg_read_header has finished, we know what is in the SOF
+ * and (first) SOS markers. We also have all the application parameter
+ * settings.
+ */
+
+LOCAL(void)
+master_selection(j_decompress_ptr cinfo)
+{
+ my_master_ptr master = (my_master_ptr)cinfo->master;
+ boolean use_c_buffer;
+ long samplesperrow;
+ JDIMENSION jd_samplesperrow;
+
+ /* Disable IDCT scaling and raw (downsampled) data output in lossless mode.
+ * IDCT scaling is not useful in lossless mode, and it must be disabled in
+ * order to properly calculate the output dimensions. Raw data output isn't
+ * particularly useful without subsampling and has not been tested in
+ * lossless mode.
+ */
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+ cinfo->raw_data_out = FALSE;
+ cinfo->scale_num = cinfo->scale_denom = 1;
+ }
+#endif
+
+ /* Initialize dimensions and other stuff */
+ jpeg_calc_output_dimensions(cinfo);
+ prepare_range_limit_table(cinfo);
+
+ /* Width of an output scanline must be representable as JDIMENSION. */
+ samplesperrow = (long)cinfo->output_width *
+ (long)cinfo->out_color_components;
+ jd_samplesperrow = (JDIMENSION)samplesperrow;
+ if ((long)jd_samplesperrow != samplesperrow)
+ ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
+
+ /* Initialize my private state */
+ master->pass_number = 0;
+ master->using_merged_upsample = use_merged_upsample(cinfo);
+
+ /* Color quantizer selection */
+ master->quantizer_1pass = NULL;
+ master->quantizer_2pass = NULL;
+ /* No mode changes if not using buffered-image mode. */
+ if (!cinfo->quantize_colors || !cinfo->buffered_image) {
+ cinfo->enable_1pass_quant = FALSE;
+ cinfo->enable_external_quant = FALSE;
+ cinfo->enable_2pass_quant = FALSE;
+ }
+ if (cinfo->quantize_colors) {
+ if (cinfo->raw_data_out)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+ /* 2-pass quantizer only works in 3-component color space. */
+ if (cinfo->out_color_components != 3 ||
+ cinfo->out_color_space == JCS_RGB565) {
+ cinfo->enable_1pass_quant = TRUE;
+ cinfo->enable_external_quant = FALSE;
+ cinfo->enable_2pass_quant = FALSE;
+ cinfo->colormap = NULL;
+ } else if (cinfo->colormap != NULL) {
+ cinfo->enable_external_quant = TRUE;
+ } else if (cinfo->two_pass_quantize) {
+ cinfo->enable_2pass_quant = TRUE;
+ } else {
+ cinfo->enable_1pass_quant = TRUE;
+ }
+
+ if (cinfo->enable_1pass_quant) {
+#ifdef QUANT_1PASS_SUPPORTED
+ if (cinfo->data_precision == 8)
+ jinit_1pass_quantizer(cinfo);
+ else if (cinfo->data_precision == 12)
+ j12init_1pass_quantizer(cinfo);
+ else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ master->quantizer_1pass = cinfo->cquantize;
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ }
+
+ /* We use the 2-pass code to map to external colormaps. */
+ if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
+#ifdef QUANT_2PASS_SUPPORTED
+ if (cinfo->data_precision == 8)
+ jinit_2pass_quantizer(cinfo);
+ else if (cinfo->data_precision == 12)
+ j12init_2pass_quantizer(cinfo);
+ else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ master->quantizer_2pass = cinfo->cquantize;
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ }
+ /* If both quantizers are initialized, the 2-pass one is left active;
+ * this is necessary for starting with quantization to an external map.
+ */
+ }
+
+ /* Post-processing: in particular, color conversion first */
+ if (!cinfo->raw_data_out) {
+ if (master->using_merged_upsample) {
+#ifdef UPSAMPLE_MERGING_SUPPORTED
+ if (cinfo->data_precision == 8)
+ jinit_merged_upsampler(cinfo); /* does color conversion too */
+ else if (cinfo->data_precision == 12)
+ j12init_merged_upsampler(cinfo); /* does color conversion too */
+ else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ } else {
+ if (cinfo->data_precision <= 8) {
+ jinit_color_deconverter(cinfo);
+ jinit_upsampler(cinfo);
+ } else if (cinfo->data_precision <= 12) {
+ j12init_color_deconverter(cinfo);
+ j12init_upsampler(cinfo);
+ } else {
+#ifdef D_LOSSLESS_SUPPORTED
+ j16init_color_deconverter(cinfo);
+ j16init_upsampler(cinfo);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+ }
+ }
+ if (cinfo->data_precision <= 8)
+ jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
+ else if (cinfo->data_precision <= 12)
+ j12init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
+ else
+#ifdef D_LOSSLESS_SUPPORTED
+ j16init_d_post_controller(cinfo, cinfo->enable_2pass_quant);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+ }
+
+ if (cinfo->master->lossless) {
+#ifdef D_LOSSLESS_SUPPORTED
+ /* Prediction, sample undifferencing, point transform, and sample size
+ * scaling
+ */
+ if (cinfo->data_precision <= 8)
+ jinit_lossless_decompressor(cinfo);
+ else if (cinfo->data_precision <= 12)
+ j12init_lossless_decompressor(cinfo);
+ else
+ j16init_lossless_decompressor(cinfo);
+ /* Entropy decoding: either Huffman or arithmetic coding. */
+ if (cinfo->arith_code) {
+ ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
+ } else {
+ jinit_lhuff_decoder(cinfo);
+ }
+
+ /* Initialize principal buffer controllers. */
+ use_c_buffer = cinfo->inputctl->has_multiple_scans ||
+ cinfo->buffered_image;
+ if (cinfo->data_precision <= 8)
+ jinit_d_diff_controller(cinfo, use_c_buffer);
+ else if (cinfo->data_precision <= 12)
+ j12init_d_diff_controller(cinfo, use_c_buffer);
+ else
+ j16init_d_diff_controller(cinfo, use_c_buffer);
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ } else {
+ /* Inverse DCT */
+ if (cinfo->data_precision == 8)
+ jinit_inverse_dct(cinfo);
+ else if (cinfo->data_precision == 12)
+ j12init_inverse_dct(cinfo);
+ else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ /* Entropy decoding: either Huffman or arithmetic coding. */
+ if (cinfo->arith_code) {
+#ifdef D_ARITH_CODING_SUPPORTED
+ jinit_arith_decoder(cinfo);
+#else
+ ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
+#endif
+ } else {
+ if (cinfo->progressive_mode) {
+#ifdef D_PROGRESSIVE_SUPPORTED
+ jinit_phuff_decoder(cinfo);
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif
+ } else
+ jinit_huff_decoder(cinfo);
+ }
+
+ /* Initialize principal buffer controllers. */
+ use_c_buffer = cinfo->inputctl->has_multiple_scans ||
+ cinfo->buffered_image;
+ if (cinfo->data_precision == 12)
+ j12init_d_coef_controller(cinfo, use_c_buffer);
+ else
+ jinit_d_coef_controller(cinfo, use_c_buffer);
+ }
+
+ if (!cinfo->raw_data_out) {
+ if (cinfo->data_precision <= 8)
+ jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
+ else if (cinfo->data_precision <= 12)
+ j12init_d_main_controller(cinfo,
+ FALSE /* never need full buffer here */);
+ else
+#ifdef D_LOSSLESS_SUPPORTED
+ j16init_d_main_controller(cinfo,
+ FALSE /* never need full buffer here */);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+#endif
+ }
+
+ /* We can now tell the memory manager to allocate virtual arrays. */
+ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
+
+ /* Initialize input side of decompressor to consume first scan. */
+ (*cinfo->inputctl->start_input_pass) (cinfo);
+
+ /* Set the first and last iMCU columns to decompress from single-scan images.
+ * By default, decompress all of the iMCU columns.
+ */
+ cinfo->master->first_iMCU_col = 0;
+ cinfo->master->last_iMCU_col = cinfo->MCUs_per_row - 1;
+ cinfo->master->last_good_iMCU_row = 0;
+
+#ifdef D_MULTISCAN_FILES_SUPPORTED
+ /* If jpeg_start_decompress will read the whole file, initialize
+ * progress monitoring appropriately. The input step is counted
+ * as one pass.
+ */
+ if (cinfo->progress != NULL && !cinfo->buffered_image &&
+ cinfo->inputctl->has_multiple_scans) {
+ int nscans;
+ /* Estimate number of scans to set pass_limit. */
+ if (cinfo->progressive_mode) {
+ /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
+ nscans = 2 + 3 * cinfo->num_components;
+ } else {
+ /* For a nonprogressive multiscan file, estimate 1 scan per component. */
+ nscans = cinfo->num_components;
+ }
+ cinfo->progress->pass_counter = 0L;
+ cinfo->progress->pass_limit = (long)cinfo->total_iMCU_rows * nscans;
+ cinfo->progress->completed_passes = 0;
+ cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
+ /* Count the input pass as done */
+ master->pass_number++;
+ }
+#endif /* D_MULTISCAN_FILES_SUPPORTED */
+}
+
+
+/*
+ * Per-pass setup.
+ * This is called at the beginning of each output pass. We determine which
+ * modules will be active during this pass and give them appropriate
+ * start_pass calls. We also set is_dummy_pass to indicate whether this
+ * is a "real" output pass or a dummy pass for color quantization.
+ * (In the latter case, jdapistd.c will crank the pass to completion.)
+ */
+
+METHODDEF(void)
+prepare_for_output_pass(j_decompress_ptr cinfo)
+{
+ my_master_ptr master = (my_master_ptr)cinfo->master;
+
+ if (master->pub.is_dummy_pass) {
+#ifdef QUANT_2PASS_SUPPORTED
+ /* Final pass of 2-pass quantization */
+ master->pub.is_dummy_pass = FALSE;
+ (*cinfo->cquantize->start_pass) (cinfo, FALSE);
+ (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
+ (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
+#else
+ ERREXIT(cinfo, JERR_NOT_COMPILED);
+#endif /* QUANT_2PASS_SUPPORTED */
+ } else {
+ if (cinfo->quantize_colors && cinfo->colormap == NULL) {
+ /* Select new quantization method */
+ if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
+ cinfo->cquantize = master->quantizer_2pass;
+ master->pub.is_dummy_pass = TRUE;
+ } else if (cinfo->enable_1pass_quant) {
+ cinfo->cquantize = master->quantizer_1pass;
+ } else {
+ ERREXIT(cinfo, JERR_MODE_CHANGE);
+ }
+ }
+ (*cinfo->idct->start_pass) (cinfo);
+ (*cinfo->coef->start_output_pass) (cinfo);
+ if (!cinfo->raw_data_out) {
+ if (!master->using_merged_upsample)
+ (*cinfo->cconvert->start_pass) (cinfo);
+ (*cinfo->upsample->start_pass) (cinfo);
+ if (cinfo->quantize_colors)
+ (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
+ (*cinfo->post->start_pass) (cinfo,
+ (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
+ (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
+ }
+ }
+
+ /* Set up progress monitor's pass info if present */
+ if (cinfo->progress != NULL) {
+ cinfo->progress->completed_passes = master->pass_number;
+ cinfo->progress->total_passes = master->pass_number +
+ (master->pub.is_dummy_pass ? 2 : 1);
+ /* In buffered-image mode, we assume one more output pass if EOI not
+ * yet reached, but no more passes if EOI has been reached.
+ */
+ if (cinfo->buffered_image && !cinfo->inputctl->eoi_reached) {
+ cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
+ }
+ }
+}
+
+
+/*
+ * Finish up at end of an output pass.
+ */
+
+METHODDEF(void)
+finish_output_pass(j_decompress_ptr cinfo)
+{
+ my_master_ptr master = (my_master_ptr)cinfo->master;
+
+ if (cinfo->quantize_colors)
+ (*cinfo->cquantize->finish_pass) (cinfo);
+ master->pass_number++;
+}
+
+
+#ifdef D_MULTISCAN_FILES_SUPPORTED
+
+/*
+ * Switch to a new external colormap between output passes.
+ */
+
+GLOBAL(void)
+jpeg_new_colormap(j_decompress_ptr cinfo)
+{
+ my_master_ptr master = (my_master_ptr)cinfo->master;
+
+ /* Prevent application from calling me at wrong times */
+ if (cinfo->global_state != DSTATE_BUFIMAGE)
+ ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
+
+ if (cinfo->quantize_colors && cinfo->enable_external_quant &&
+ cinfo->colormap != NULL) {
+ /* Select 2-pass quantizer for external colormap use */
+ cinfo->cquantize = master->quantizer_2pass;
+ /* Notify quantizer of colormap change */
+ (*cinfo->cquantize->new_color_map) (cinfo);
+ master->pub.is_dummy_pass = FALSE; /* just in case */
+ } else
+ ERREXIT(cinfo, JERR_MODE_CHANGE);
+}
+
+#endif /* D_MULTISCAN_FILES_SUPPORTED */
+
+
+/*
+ * Initialize master decompression control and select active modules.
+ * This is performed at the start of jpeg_start_decompress.
+ */
+
+GLOBAL(void)
+jinit_master_decompress(j_decompress_ptr cinfo)
+{
+ my_master_ptr master = (my_master_ptr)cinfo->master;
+
+ master->pub.prepare_for_output_pass = prepare_for_output_pass;
+ master->pub.finish_output_pass = finish_output_pass;
+
+ master->pub.is_dummy_pass = FALSE;
+ master->pub.jinit_upsampler_no_alloc = FALSE;
+
+ master_selection(cinfo);
+}
diff --git a/contrib/libs/libjpeg-turbo/jdmaster.h b/contrib/libs/libjpeg-turbo/src/jdmaster.h
index 76897e2820f..76897e2820f 100644
--- a/contrib/libs/libjpeg-turbo/jdmaster.h
+++ b/contrib/libs/libjpeg-turbo/src/jdmaster.h
diff --git a/contrib/libs/libjpeg-turbo/jdmerge.c b/contrib/libs/libjpeg-turbo/src/jdmerge.c
index 3a456d65812..49f2006fc02 100644
--- a/contrib/libs/libjpeg-turbo/jdmerge.c
+++ b/contrib/libs/libjpeg-turbo/src/jdmerge.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander.
+ * Copyright (C) 2009, 2011, 2014-2015, 2020, 2022, D. R. Commander.
* Copyright (C) 2013, Linaro Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
@@ -42,7 +42,6 @@
#include "jpeglib.h"
#include "jdmerge.h"
#include "jsimd.h"
-#include "jconfigint.h"
#ifdef UPSAMPLE_MERGING_SUPPORTED
@@ -168,20 +167,20 @@ build_ycc_rgb_table(j_decompress_ptr cinfo)
upsample->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
+ (_MAXJSAMPLE + 1) * sizeof(int));
upsample->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(int));
+ (_MAXJSAMPLE + 1) * sizeof(int));
upsample->Cr_g_tab = (JLONG *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
+ (_MAXJSAMPLE + 1) * sizeof(JLONG));
upsample->Cb_g_tab = (JLONG *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE + 1) * sizeof(JLONG));
+ (_MAXJSAMPLE + 1) * sizeof(JLONG));
- for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
- /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
- /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
+ for (i = 0, x = -_CENTERJSAMPLE; i <= _MAXJSAMPLE; i++, x++) {
+ /* i is the actual input pixel value, in the range 0.._MAXJSAMPLE */
+ /* The Cb or Cr value we are thinking of is x = i - _CENTERJSAMPLE */
/* Cr=>R value is nearest int to 1.40200 * x */
upsample->Cr_r_tab[i] = (int)
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
@@ -220,14 +219,14 @@ start_pass_merged_upsample(j_decompress_ptr cinfo)
*/
METHODDEF(void)
-merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+merged_2v_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
+ JDIMENSION in_row_groups_avail, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
/* 2:1 vertical sampling case: may need a spare row. */
{
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
- JSAMPROW work_ptrs[2];
+ _JSAMPROW work_ptrs[2];
JDIMENSION num_rows; /* number of rows returned to caller */
if (upsample->spare_full) {
@@ -235,8 +234,8 @@ merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION size = upsample->out_row_width;
if (cinfo->out_color_space == JCS_RGB565)
size = cinfo->output_width * 2;
- jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 1,
- size);
+ _jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0,
+ 1, size);
num_rows = 1;
upsample->spare_full = FALSE;
} else {
@@ -271,9 +270,9 @@ merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+merged_1v_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
+ JDIMENSION in_row_groups_avail, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
/* 1:1 vertical sampling case: much easier, never need a spare row. */
{
@@ -303,8 +302,8 @@ merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
+h2v1_merged_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf)
{
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
@@ -348,8 +347,8 @@ h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
+h2v2_merged_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf)
{
switch (cinfo->out_color_space) {
case JCS_EXT_RGB:
@@ -475,8 +474,8 @@ static INLINE boolean is_big_endian(void)
METHODDEF(void)
-h2v1_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
+h2v1_merged_upsample_565(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf)
{
if (is_big_endian())
h2v1_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
@@ -488,8 +487,8 @@ h2v1_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-h2v1_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
+h2v1_merged_upsample_565D(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf)
{
if (is_big_endian())
h2v1_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
@@ -501,8 +500,8 @@ h2v1_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-h2v2_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
+h2v2_merged_upsample_565(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf)
{
if (is_big_endian())
h2v2_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
@@ -514,8 +513,8 @@ h2v2_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
-h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
+h2v2_merged_upsample_565D(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf)
{
if (is_big_endian())
h2v2_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
@@ -535,10 +534,13 @@ h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
GLOBAL(void)
-jinit_merged_upsampler(j_decompress_ptr cinfo)
+_jinit_merged_upsampler(j_decompress_ptr cinfo)
{
my_merged_upsample_ptr upsample;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
upsample = (my_merged_upsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_merged_upsampler));
@@ -549,10 +551,12 @@ jinit_merged_upsampler(j_decompress_ptr cinfo)
upsample->out_row_width = cinfo->output_width * cinfo->out_color_components;
if (cinfo->max_v_samp_factor == 2) {
- upsample->pub.upsample = merged_2v_upsample;
+ upsample->pub._upsample = merged_2v_upsample;
+#ifdef WITH_SIMD
if (jsimd_can_h2v2_merged_upsample())
upsample->upmethod = jsimd_h2v2_merged_upsample;
else
+#endif
upsample->upmethod = h2v2_merged_upsample;
if (cinfo->out_color_space == JCS_RGB565) {
if (cinfo->dither_mode != JDITHER_NONE) {
@@ -562,14 +566,16 @@ jinit_merged_upsampler(j_decompress_ptr cinfo)
}
}
/* Allocate a spare row buffer */
- upsample->spare_row = (JSAMPROW)
+ upsample->spare_row = (_JSAMPROW)
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
- (size_t)(upsample->out_row_width * sizeof(JSAMPLE)));
+ (size_t)(upsample->out_row_width * sizeof(_JSAMPLE)));
} else {
- upsample->pub.upsample = merged_1v_upsample;
+ upsample->pub._upsample = merged_1v_upsample;
+#ifdef WITH_SIMD
if (jsimd_can_h2v1_merged_upsample())
upsample->upmethod = jsimd_h2v1_merged_upsample;
else
+#endif
upsample->upmethod = h2v1_merged_upsample;
if (cinfo->out_color_space == JCS_RGB565) {
if (cinfo->dither_mode != JDITHER_NONE) {
diff --git a/contrib/libs/libjpeg-turbo/jdmerge.h b/contrib/libs/libjpeg-turbo/src/jdmerge.h
index b583396b106..73cbd605495 100644
--- a/contrib/libs/libjpeg-turbo/jdmerge.h
+++ b/contrib/libs/libjpeg-turbo/src/jdmerge.h
@@ -4,13 +4,14 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
+ * Copyright (C) 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*/
#define JPEG_INTERNALS
#include "jpeglib.h"
+#include "jsamplecomp.h"
#ifdef UPSAMPLE_MERGING_SUPPORTED
@@ -21,8 +22,8 @@ typedef struct {
struct jpeg_upsampler pub; /* public fields */
/* Pointer to routine to do actual upsampling/conversion of one row group */
- void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
- JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
+ void (*upmethod) (j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
+ JDIMENSION in_row_group_ctr, _JSAMPARRAY output_buf);
/* Private state for YCC->RGB conversion */
int *Cr_r_tab; /* => table for Cr to R conversion */
@@ -35,7 +36,7 @@ typedef struct {
* application provides just a one-row buffer; we also use the spare
* to discard the dummy last row if the image height is odd.
*/
- JSAMPROW spare_row;
+ _JSAMPROW spare_row;
boolean spare_full; /* T if spare buffer is occupied */
JDIMENSION out_row_width; /* samples per output row */
diff --git a/contrib/libs/libjpeg-turbo/jdmrg565.c b/contrib/libs/libjpeg-turbo/src/jdmrg565.c
index 980a4e216e4..0c719b912ce 100644
--- a/contrib/libs/libjpeg-turbo/jdmrg565.c
+++ b/contrib/libs/libjpeg-turbo/src/jdmrg565.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2018, 2020, D. R. Commander.
+ * Copyright (C) 2014-2015, 2018, 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -15,18 +15,19 @@
INLINE
LOCAL(void)
-h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo,
+ _JSAMPIMAGE input_buf,
JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
+ _JSAMPARRAY output_buf)
{
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
register int y, cred, cgreen, cblue;
int cb, cr;
- register JSAMPROW outptr;
- JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ _JSAMPROW inptr0, inptr1, inptr2;
JDIMENSION col;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int *Crrtab = upsample->Cr_r_tab;
int *Cbbtab = upsample->Cb_b_tab;
JLONG *Crgtab = upsample->Cr_g_tab;
@@ -86,18 +87,18 @@ h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
+ _JSAMPIMAGE input_buf,
JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
+ _JSAMPARRAY output_buf)
{
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
register int y, cred, cgreen, cblue;
int cb, cr;
- register JSAMPROW outptr;
- JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ _JSAMPROW inptr0, inptr1, inptr2;
JDIMENSION col;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int *Crrtab = upsample->Cr_r_tab;
int *Cbbtab = upsample->Cb_b_tab;
JLONG *Crgtab = upsample->Cr_g_tab;
@@ -159,18 +160,18 @@ h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
INLINE
LOCAL(void)
-h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
+ _JSAMPARRAY output_buf)
{
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
register int y, cred, cgreen, cblue;
int cb, cr;
- register JSAMPROW outptr0, outptr1;
- JSAMPROW inptr00, inptr01, inptr1, inptr2;
+ register _JSAMPROW outptr0, outptr1;
+ _JSAMPROW inptr00, inptr01, inptr1, inptr2;
JDIMENSION col;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int *Crrtab = upsample->Cr_r_tab;
int *Cbbtab = upsample->Cb_b_tab;
JLONG *Crgtab = upsample->Cr_g_tab;
@@ -255,18 +256,18 @@ h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
+ _JSAMPIMAGE input_buf,
JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
+ _JSAMPARRAY output_buf)
{
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
register int y, cred, cgreen, cblue;
int cb, cr;
- register JSAMPROW outptr0, outptr1;
- JSAMPROW inptr00, inptr01, inptr1, inptr2;
+ register _JSAMPROW outptr0, outptr1;
+ _JSAMPROW inptr00, inptr01, inptr1, inptr2;
JDIMENSION col;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int *Crrtab = upsample->Cr_r_tab;
int *Cbbtab = upsample->Cb_b_tab;
JLONG *Crgtab = upsample->Cr_g_tab;
diff --git a/contrib/libs/libjpeg-turbo/jdmrgext.c b/contrib/libs/libjpeg-turbo/src/jdmrgext.c
index 9bf4f1a307f..8139e0a3ed6 100644
--- a/contrib/libs/libjpeg-turbo/jdmrgext.c
+++ b/contrib/libs/libjpeg-turbo/src/jdmrgext.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2015, 2020, D. R. Commander.
+ * Copyright (C) 2011, 2015, 2020, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -21,18 +21,18 @@
INLINE
LOCAL(void)
-h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+h2v1_merged_upsample_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
+ _JSAMPARRAY output_buf)
{
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
register int y, cred, cgreen, cblue;
int cb, cr;
- register JSAMPROW outptr;
- JSAMPROW inptr0, inptr1, inptr2;
+ register _JSAMPROW outptr;
+ _JSAMPROW inptr0, inptr1, inptr2;
JDIMENSION col;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int *Crrtab = upsample->Cr_r_tab;
int *Cbbtab = upsample->Cb_b_tab;
JLONG *Crgtab = upsample->Cr_g_tab;
@@ -57,7 +57,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr[RGB_GREEN] = range_limit[y + cgreen];
outptr[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
+ outptr[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr += RGB_PIXELSIZE;
y = *inptr0++;
@@ -65,7 +65,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr[RGB_GREEN] = range_limit[y + cgreen];
outptr[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
+ outptr[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr += RGB_PIXELSIZE;
}
@@ -81,7 +81,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr[RGB_GREEN] = range_limit[y + cgreen];
outptr[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr[RGB_ALPHA] = 0xFF;
+ outptr[RGB_ALPHA] = _MAXJSAMPLE;
#endif
}
}
@@ -93,18 +93,18 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
INLINE
LOCAL(void)
-h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+h2v2_merged_upsample_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION in_row_group_ctr,
- JSAMPARRAY output_buf)
+ _JSAMPARRAY output_buf)
{
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
register int y, cred, cgreen, cblue;
int cb, cr;
- register JSAMPROW outptr0, outptr1;
- JSAMPROW inptr00, inptr01, inptr1, inptr2;
+ register _JSAMPROW outptr0, outptr1;
+ _JSAMPROW inptr00, inptr01, inptr1, inptr2;
JDIMENSION col;
/* copy these pointers into registers if possible */
- register JSAMPLE *range_limit = cinfo->sample_range_limit;
+ register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int *Crrtab = upsample->Cr_r_tab;
int *Cbbtab = upsample->Cb_b_tab;
JLONG *Crgtab = upsample->Cr_g_tab;
@@ -131,7 +131,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr0[RGB_GREEN] = range_limit[y + cgreen];
outptr0[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr0[RGB_ALPHA] = 0xFF;
+ outptr0[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr0 += RGB_PIXELSIZE;
y = *inptr00++;
@@ -139,7 +139,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr0[RGB_GREEN] = range_limit[y + cgreen];
outptr0[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr0[RGB_ALPHA] = 0xFF;
+ outptr0[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr0 += RGB_PIXELSIZE;
y = *inptr01++;
@@ -147,7 +147,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr1[RGB_GREEN] = range_limit[y + cgreen];
outptr1[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr1[RGB_ALPHA] = 0xFF;
+ outptr1[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr1 += RGB_PIXELSIZE;
y = *inptr01++;
@@ -155,7 +155,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr1[RGB_GREEN] = range_limit[y + cgreen];
outptr1[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr1[RGB_ALPHA] = 0xFF;
+ outptr1[RGB_ALPHA] = _MAXJSAMPLE;
#endif
outptr1 += RGB_PIXELSIZE;
}
@@ -171,14 +171,14 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
outptr0[RGB_GREEN] = range_limit[y + cgreen];
outptr0[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr0[RGB_ALPHA] = 0xFF;
+ outptr0[RGB_ALPHA] = _MAXJSAMPLE;
#endif
y = *inptr01;
outptr1[RGB_RED] = range_limit[y + cred];
outptr1[RGB_GREEN] = range_limit[y + cgreen];
outptr1[RGB_BLUE] = range_limit[y + cblue];
#ifdef RGB_ALPHA
- outptr1[RGB_ALPHA] = 0xFF;
+ outptr1[RGB_ALPHA] = _MAXJSAMPLE;
#endif
}
}
diff --git a/contrib/libs/libjpeg-turbo/jdphuff.c b/contrib/libs/libjpeg-turbo/src/jdphuff.c
index 9680ebcbd06..bf97333a34c 100644
--- a/contrib/libs/libjpeg-turbo/jdphuff.c
+++ b/contrib/libs/libjpeg-turbo/src/jdphuff.c
@@ -3,6 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-1997, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2015-2016, 2018-2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
@@ -23,7 +25,7 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
-#include "jdhuff.h" /* Declarations shared with jdhuff.c */
+#include "jdhuff.h" /* Declarations shared with jd*huff.c */
#include <limits.h>
diff --git a/contrib/libs/libjpeg-turbo/jdpostct.c b/contrib/libs/libjpeg-turbo/src/jdpostct.c
index 6a2cf5c1b31..9bc6210d17e 100644
--- a/contrib/libs/libjpeg-turbo/jdpostct.c
+++ b/contrib/libs/libjpeg-turbo/src/jdpostct.c
@@ -3,8 +3,8 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
- * It was modified by The libjpeg-turbo Project to include only code relevant
- * to libjpeg-turbo.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -22,8 +22,11 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
+
/* Private buffer controller object */
typedef struct {
@@ -35,7 +38,7 @@ typedef struct {
* for one-pass operation, a strip buffer is sufficient.
*/
jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */
- JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */
+ _JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */
JDIMENSION strip_height; /* buffer size in rows */
/* for two-pass mode only: */
JDIMENSION starting_row; /* row # of first row in current strip */
@@ -46,26 +49,28 @@ typedef my_post_controller *my_post_ptr;
/* Forward declarations */
+#if BITS_IN_JSAMPLE != 16
METHODDEF(void) post_process_1pass(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
+ _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
+ _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
-#ifdef QUANT_2PASS_SUPPORTED
+#endif
+#if defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16
METHODDEF(void) post_process_prepass(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
+ _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
+ _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
METHODDEF(void) post_process_2pass(j_decompress_ptr cinfo,
- JSAMPIMAGE input_buf,
+ _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf,
+ _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
#endif
@@ -82,39 +87,42 @@ start_pass_dpost(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
switch (pass_mode) {
case JBUF_PASS_THRU:
+#if BITS_IN_JSAMPLE != 16
if (cinfo->quantize_colors) {
/* Single-pass processing with color quantization. */
- post->pub.post_process_data = post_process_1pass;
+ post->pub._post_process_data = post_process_1pass;
/* We could be doing buffered-image output before starting a 2-pass
* color quantization; in that case, jinit_d_post_controller did not
* allocate a strip buffer. Use the virtual-array buffer as workspace.
*/
if (post->buffer == NULL) {
- post->buffer = (*cinfo->mem->access_virt_sarray)
+ post->buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
((j_common_ptr)cinfo, post->whole_image,
(JDIMENSION)0, post->strip_height, TRUE);
}
- } else {
+ } else
+#endif
+ {
/* For single-pass processing without color quantization,
* I have no work to do; just call the upsampler directly.
*/
- post->pub.post_process_data = cinfo->upsample->upsample;
+ post->pub._post_process_data = cinfo->upsample->_upsample;
}
break;
-#ifdef QUANT_2PASS_SUPPORTED
+#if defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16
case JBUF_SAVE_AND_PASS:
/* First pass of 2-pass quantization */
if (post->whole_image == NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- post->pub.post_process_data = post_process_prepass;
+ post->pub._post_process_data = post_process_prepass;
break;
case JBUF_CRANK_DEST:
/* Second pass of 2-pass quantization */
if (post->whole_image == NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
- post->pub.post_process_data = post_process_2pass;
+ post->pub._post_process_data = post_process_2pass;
break;
-#endif /* QUANT_2PASS_SUPPORTED */
+#endif /* defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16 */
default:
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
break;
@@ -128,10 +136,12 @@ start_pass_dpost(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
* This is used for color precision reduction as well as one-pass quantization.
*/
+#if BITS_IN_JSAMPLE != 16
+
METHODDEF(void)
-post_process_1pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+post_process_1pass(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
+ JDIMENSION in_row_groups_avail, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
{
my_post_ptr post = (my_post_ptr)cinfo->post;
@@ -143,27 +153,29 @@ post_process_1pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
if (max_rows > post->strip_height)
max_rows = post->strip_height;
num_rows = 0;
- (*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
- in_row_groups_avail, post->buffer, &num_rows,
- max_rows);
+ (*cinfo->upsample->_upsample) (cinfo, input_buf, in_row_group_ctr,
+ in_row_groups_avail, post->buffer, &num_rows,
+ max_rows);
/* Quantize and emit data. */
- (*cinfo->cquantize->color_quantize) (cinfo, post->buffer,
- output_buf + *out_row_ctr,
- (int)num_rows);
+ (*cinfo->cquantize->_color_quantize) (cinfo, post->buffer,
+ output_buf + *out_row_ctr,
+ (int)num_rows);
*out_row_ctr += num_rows;
}
+#endif
-#ifdef QUANT_2PASS_SUPPORTED
+
+#if defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16
/*
* Process some data in the first pass of 2-pass quantization.
*/
METHODDEF(void)
-post_process_prepass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+post_process_prepass(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
+ JDIMENSION in_row_groups_avail, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
{
my_post_ptr post = (my_post_ptr)cinfo->post;
@@ -171,23 +183,23 @@ post_process_prepass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
/* Reposition virtual buffer if at start of strip. */
if (post->next_row == 0) {
- post->buffer = (*cinfo->mem->access_virt_sarray)
+ post->buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
((j_common_ptr)cinfo, post->whole_image,
post->starting_row, post->strip_height, TRUE);
}
/* Upsample some data (up to a strip height's worth). */
old_next_row = post->next_row;
- (*cinfo->upsample->upsample) (cinfo, input_buf, in_row_group_ctr,
- in_row_groups_avail, post->buffer,
- &post->next_row, post->strip_height);
+ (*cinfo->upsample->_upsample) (cinfo, input_buf, in_row_group_ctr,
+ in_row_groups_avail, post->buffer,
+ &post->next_row, post->strip_height);
/* Allow quantizer to scan new data. No data is emitted, */
/* but we advance out_row_ctr so outer loop can tell when we're done. */
if (post->next_row > old_next_row) {
num_rows = post->next_row - old_next_row;
- (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row,
- (JSAMPARRAY)NULL, (int)num_rows);
+ (*cinfo->cquantize->_color_quantize) (cinfo, post->buffer + old_next_row,
+ (_JSAMPARRAY)NULL, (int)num_rows);
*out_row_ctr += num_rows;
}
@@ -204,9 +216,9 @@ post_process_prepass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
METHODDEF(void)
-post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+post_process_2pass(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
- JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
+ JDIMENSION in_row_groups_avail, _JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
{
my_post_ptr post = (my_post_ptr)cinfo->post;
@@ -214,7 +226,7 @@ post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
/* Reposition virtual buffer if at start of strip. */
if (post->next_row == 0) {
- post->buffer = (*cinfo->mem->access_virt_sarray)
+ post->buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray)
((j_common_ptr)cinfo, post->whole_image,
post->starting_row, post->strip_height, FALSE);
}
@@ -230,9 +242,9 @@ post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
num_rows = max_rows;
/* Quantize and emit data. */
- (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + post->next_row,
- output_buf + *out_row_ctr,
- (int)num_rows);
+ (*cinfo->cquantize->_color_quantize) (cinfo, post->buffer + post->next_row,
+ output_buf + *out_row_ctr,
+ (int)num_rows);
*out_row_ctr += num_rows;
/* Advance if we filled the strip. */
@@ -243,7 +255,7 @@ post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
}
}
-#endif /* QUANT_2PASS_SUPPORTED */
+#endif /* defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16 */
/*
@@ -251,10 +263,26 @@ post_process_2pass(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
*/
GLOBAL(void)
-jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
+_jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
{
my_post_ptr post;
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
post = (my_post_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_post_controller));
@@ -265,6 +293,7 @@ jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
/* Create the quantization buffer, if needed */
if (cinfo->quantize_colors) {
+#if BITS_IN_JSAMPLE != 16
/* The buffer strip height is max_v_samp_factor, which is typically
* an efficient number of rows for upsampling to return.
* (In the presence of output rescaling, we might want to be smarter?)
@@ -285,10 +314,15 @@ jinit_d_post_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
#endif /* QUANT_2PASS_SUPPORTED */
} else {
/* One-pass color quantization: just make a strip buffer. */
- post->buffer = (*cinfo->mem->alloc_sarray)
+ post->buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
cinfo->output_width * cinfo->out_color_components,
post->strip_height);
}
+#else
+ ERREXIT(cinfo, JERR_NOTIMPL);
+#endif
}
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jdsample.c b/contrib/libs/libjpeg-turbo/src/jdsample.c
index eaad72a0308..e5a127de42b 100644
--- a/contrib/libs/libjpeg-turbo/jdsample.c
+++ b/contrib/libs/libjpeg-turbo/src/jdsample.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2010, 2015-2016, D. R. Commander.
+ * Copyright (C) 2010, 2015-2016, 2022, 2024, D. R. Commander.
* Copyright (C) 2014, MIPS Technologies, Inc., California.
* Copyright (C) 2015, Google, Inc.
* Copyright (C) 2019-2020, Arm Limited.
@@ -28,10 +28,12 @@
#include "jinclude.h"
#include "jdsample.h"
#include "jsimd.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
+
/*
* Initialize for an upsampling pass.
*/
@@ -57,9 +59,9 @@ start_pass_upsample(j_decompress_ptr cinfo)
*/
METHODDEF(void)
-sep_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+sep_upsample(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr, JDIMENSION in_row_groups_avail,
- JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
+ _JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail)
{
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
@@ -95,9 +97,10 @@ sep_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
if (num_rows > out_rows_avail)
num_rows = out_rows_avail;
- (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
- (JDIMENSION)upsample->next_row_out,
- output_buf + *out_row_ctr, (int)num_rows);
+ (*cinfo->cconvert->_color_convert) (cinfo, upsample->color_buf,
+ (JDIMENSION)upsample->next_row_out,
+ output_buf + *out_row_ctr,
+ (int)num_rows);
/* Adjust counts */
*out_row_ctr += num_rows;
@@ -124,7 +127,7 @@ sep_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
METHODDEF(void)
fullsize_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
*output_data_ptr = input_data;
}
@@ -137,7 +140,7 @@ fullsize_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
noop_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
*output_data_ptr = NULL; /* safety check */
}
@@ -156,14 +159,14 @@ noop_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
- register JSAMPLE invalue;
+ _JSAMPARRAY output_data = *output_data_ptr;
+ register _JSAMPROW inptr, outptr;
+ register _JSAMPLE invalue;
register int h;
- JSAMPROW outend;
+ _JSAMPROW outend;
int h_expand, v_expand;
int inrow, outrow;
@@ -184,8 +187,8 @@ int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
}
/* Generate any additional output rows by duplicating the first one */
if (v_expand > 1) {
- jcopy_sample_rows(output_data, outrow, output_data, outrow + 1,
- v_expand - 1, cinfo->output_width);
+ _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1,
+ v_expand - 1, cinfo->output_width);
}
inrow++;
outrow += v_expand;
@@ -200,12 +203,12 @@ int_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
- register JSAMPLE invalue;
- JSAMPROW outend;
+ _JSAMPARRAY output_data = *output_data_ptr;
+ register _JSAMPROW inptr, outptr;
+ register _JSAMPLE invalue;
+ _JSAMPROW outend;
int inrow;
for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
@@ -228,12 +231,12 @@ h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
- register JSAMPLE invalue;
- JSAMPROW outend;
+ _JSAMPARRAY output_data = *output_data_ptr;
+ register _JSAMPROW inptr, outptr;
+ register _JSAMPLE invalue;
+ _JSAMPROW outend;
int inrow, outrow;
inrow = outrow = 0;
@@ -246,8 +249,8 @@ h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*outptr++ = invalue;
*outptr++ = invalue;
}
- jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1,
- cinfo->output_width);
+ _jcopy_sample_rows(output_data, outrow, output_data, outrow + 1, 1,
+ cinfo->output_width);
inrow++;
outrow += 2;
}
@@ -271,10 +274,10 @@ h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr, outptr;
+ _JSAMPARRAY output_data = *output_data_ptr;
+ register _JSAMPROW inptr, outptr;
register int invalue;
register JDIMENSION colctr;
int inrow;
@@ -284,20 +287,20 @@ h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
outptr = output_data[inrow];
/* Special case for first column */
invalue = *inptr++;
- *outptr++ = (JSAMPLE)invalue;
- *outptr++ = (JSAMPLE)((invalue * 3 + inptr[0] + 2) >> 2);
+ *outptr++ = (_JSAMPLE)invalue;
+ *outptr++ = (_JSAMPLE)((invalue * 3 + inptr[0] + 2) >> 2);
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
/* General case: 3/4 * nearer pixel + 1/4 * further pixel */
invalue = (*inptr++) * 3;
- *outptr++ = (JSAMPLE)((invalue + inptr[-2] + 1) >> 2);
- *outptr++ = (JSAMPLE)((invalue + inptr[0] + 2) >> 2);
+ *outptr++ = (_JSAMPLE)((invalue + inptr[-2] + 1) >> 2);
+ *outptr++ = (_JSAMPLE)((invalue + inptr[0] + 2) >> 2);
}
/* Special case for last column */
invalue = *inptr;
- *outptr++ = (JSAMPLE)((invalue * 3 + inptr[-1] + 1) >> 2);
- *outptr++ = (JSAMPLE)invalue;
+ *outptr++ = (_JSAMPLE)((invalue * 3 + inptr[-1] + 1) >> 2);
+ *outptr++ = (_JSAMPLE)invalue;
}
}
@@ -311,10 +314,10 @@ h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
- JSAMPARRAY output_data = *output_data_ptr;
- JSAMPROW inptr0, inptr1, outptr;
+ _JSAMPARRAY output_data = *output_data_ptr;
+ _JSAMPROW inptr0, inptr1, outptr;
#if BITS_IN_JSAMPLE == 8
int thiscolsum, bias;
#else
@@ -339,7 +342,7 @@ h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
for (colctr = 0; colctr < compptr->downsampled_width; colctr++) {
thiscolsum = (*inptr0++) * 3 + (*inptr1++);
- *outptr++ = (JSAMPLE)((thiscolsum + bias) >> 2);
+ *outptr++ = (_JSAMPLE)((thiscolsum + bias) >> 2);
}
}
inrow++;
@@ -357,10 +360,10 @@ h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
METHODDEF(void)
h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
+ _JSAMPARRAY input_data, _JSAMPARRAY *output_data_ptr)
{
- JSAMPARRAY output_data = *output_data_ptr;
- register JSAMPROW inptr0, inptr1, outptr;
+ _JSAMPARRAY output_data = *output_data_ptr;
+ register _JSAMPROW inptr0, inptr1, outptr;
#if BITS_IN_JSAMPLE == 8
register int thiscolsum, lastcolsum, nextcolsum;
#else
@@ -383,22 +386,22 @@ h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Special case for first column */
thiscolsum = (*inptr0++) * 3 + (*inptr1++);
nextcolsum = (*inptr0++) * 3 + (*inptr1++);
- *outptr++ = (JSAMPLE)((thiscolsum * 4 + 8) >> 4);
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
+ *outptr++ = (_JSAMPLE)((thiscolsum * 4 + 8) >> 4);
+ *outptr++ = (_JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
nextcolsum = (*inptr0++) * 3 + (*inptr1++);
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
+ *outptr++ = (_JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
+ *outptr++ = (_JSAMPLE)((thiscolsum * 3 + nextcolsum + 7) >> 4);
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
}
/* Special case for last column */
- *outptr++ = (JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
- *outptr++ = (JSAMPLE)((thiscolsum * 4 + 7) >> 4);
+ *outptr++ = (_JSAMPLE)((thiscolsum * 3 + lastcolsum + 8) >> 4);
+ *outptr++ = (_JSAMPLE)((thiscolsum * 4 + 7) >> 4);
}
inrow++;
}
@@ -410,7 +413,7 @@ h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jinit_upsampler(j_decompress_ptr cinfo)
+_jinit_upsampler(j_decompress_ptr cinfo)
{
my_upsample_ptr upsample;
int ci;
@@ -418,13 +421,29 @@ jinit_upsampler(j_decompress_ptr cinfo)
boolean need_buffer, do_fancy;
int h_in_group, v_in_group, h_out_group, v_out_group;
+#ifdef D_LOSSLESS_SUPPORTED
+ if (cinfo->master->lossless) {
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ } else
+#endif
+ {
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+ }
+
if (!cinfo->master->jinit_upsampler_no_alloc) {
upsample = (my_upsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_upsampler));
cinfo->upsample = (struct jpeg_upsampler *)upsample;
upsample->pub.start_pass = start_pass_upsample;
- upsample->pub.upsample = sep_upsample;
+ upsample->pub._upsample = sep_upsample;
upsample->pub.need_context_rows = FALSE; /* until we find out differently */
} else
upsample = (my_upsample_ptr)cinfo->upsample;
@@ -464,21 +483,25 @@ jinit_upsampler(j_decompress_ptr cinfo)
} else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
/* Special cases for 2h1v upsampling */
if (do_fancy && compptr->downsampled_width > 2) {
+#ifdef WITH_SIMD
if (jsimd_can_h2v1_fancy_upsample())
upsample->methods[ci] = jsimd_h2v1_fancy_upsample;
else
+#endif
upsample->methods[ci] = h2v1_fancy_upsample;
} else {
+#ifdef WITH_SIMD
if (jsimd_can_h2v1_upsample())
upsample->methods[ci] = jsimd_h2v1_upsample;
else
+#endif
upsample->methods[ci] = h2v1_upsample;
}
} else if (h_in_group == h_out_group &&
v_in_group * 2 == v_out_group && do_fancy) {
/* Non-fancy upsampling is handled by the generic method */
-#if defined(__arm__) || defined(__aarch64__) || \
- defined(_M_ARM) || defined(_M_ARM64)
+#if defined(WITH_SIMD) && (defined(__arm__) || defined(__aarch64__) || \
+ defined(_M_ARM) || defined(_M_ARM64))
if (jsimd_can_h1v2_fancy_upsample())
upsample->methods[ci] = jsimd_h1v2_fancy_upsample;
else
@@ -489,21 +512,25 @@ jinit_upsampler(j_decompress_ptr cinfo)
v_in_group * 2 == v_out_group) {
/* Special cases for 2h2v upsampling */
if (do_fancy && compptr->downsampled_width > 2) {
+#ifdef WITH_SIMD
if (jsimd_can_h2v2_fancy_upsample())
upsample->methods[ci] = jsimd_h2v2_fancy_upsample;
else
+#endif
upsample->methods[ci] = h2v2_fancy_upsample;
upsample->pub.need_context_rows = TRUE;
} else {
+#ifdef WITH_SIMD
if (jsimd_can_h2v2_upsample())
upsample->methods[ci] = jsimd_h2v2_upsample;
else
+#endif
upsample->methods[ci] = h2v2_upsample;
}
} else if ((h_out_group % h_in_group) == 0 &&
(v_out_group % v_in_group) == 0) {
/* Generic integral-factors upsampling method */
-#if defined(__mips__)
+#if defined(WITH_SIMD) && defined(__mips__)
if (jsimd_can_int_upsample())
upsample->methods[ci] = jsimd_int_upsample;
else
@@ -514,7 +541,7 @@ jinit_upsampler(j_decompress_ptr cinfo)
} else
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
if (need_buffer && !cinfo->master->jinit_upsampler_no_alloc) {
- upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
+ upsample->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
(JDIMENSION)jround_up((long)cinfo->output_width,
(long)cinfo->max_h_samp_factor),
@@ -522,3 +549,5 @@ jinit_upsampler(j_decompress_ptr cinfo)
}
}
}
+
+#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
diff --git a/contrib/libs/libjpeg-turbo/jdsample.h b/contrib/libs/libjpeg-turbo/src/jdsample.h
index a6bf08a032a..a8a92980940 100644
--- a/contrib/libs/libjpeg-turbo/jdsample.h
+++ b/contrib/libs/libjpeg-turbo/src/jdsample.h
@@ -3,19 +3,22 @@
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*/
#define JPEG_INTERNALS
#include "jpeglib.h"
+#include "jsamplecomp.h"
/* Pointer to routine to upsample a single component */
typedef void (*upsample1_ptr) (j_decompress_ptr cinfo,
jpeg_component_info *compptr,
- JSAMPARRAY input_data,
- JSAMPARRAY *output_data_ptr);
+ _JSAMPARRAY input_data,
+ _JSAMPARRAY *output_data_ptr);
/* Private subobject */
@@ -29,7 +32,7 @@ typedef struct {
* ie do not need rescaling. The corresponding entry of color_buf[] is
* simply set to point to the input data array, thereby avoiding copying.
*/
- JSAMPARRAY color_buf[MAX_COMPONENTS];
+ _JSAMPARRAY color_buf[MAX_COMPONENTS];
/* Per-component upsampling method pointers */
upsample1_ptr methods[MAX_COMPONENTS];
diff --git a/contrib/libs/libjpeg-turbo/jdtrans.c b/contrib/libs/libjpeg-turbo/src/jdtrans.c
index d7ec4b83b3a..719813f6767 100644
--- a/contrib/libs/libjpeg-turbo/jdtrans.c
+++ b/contrib/libs/libjpeg-turbo/src/jdtrans.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2020, D. R. Commander.
+ * Copyright (C) 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -16,7 +16,7 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
/* Forward declarations */
@@ -48,6 +48,9 @@ LOCAL(void) transdecode_master_selection(j_decompress_ptr cinfo);
GLOBAL(jvirt_barray_ptr *)
jpeg_read_coefficients(j_decompress_ptr cinfo)
{
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+
if (cinfo->global_state == DSTATE_READY) {
/* First call: initialize active modules */
transdecode_master_selection(cinfo);
@@ -127,7 +130,10 @@ transdecode_master_selection(j_decompress_ptr cinfo)
}
/* Always get a full-image coefficient buffer. */
- jinit_d_coef_controller(cinfo, TRUE);
+ if (cinfo->data_precision == 12)
+ j12init_d_coef_controller(cinfo, TRUE);
+ else
+ jinit_d_coef_controller(cinfo, TRUE);
/* We can now tell the memory manager to allocate virtual arrays. */
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
diff --git a/contrib/libs/libjpeg-turbo/jerror.c b/contrib/libs/libjpeg-turbo/src/jerror.c
index d0ab5b88b0c..2133244f8ae 100644
--- a/contrib/libs/libjpeg-turbo/jerror.c
+++ b/contrib/libs/libjpeg-turbo/src/jerror.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
+ * Copyright (C) 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -40,13 +40,11 @@
* Create the message string table.
* We do this from the master message list in jerror.h by re-reading
* jerror.h with a suitable definition for macro JMESSAGE.
- * The message table is made an external symbol just in case any applications
- * want to refer to it directly.
*/
#define JMESSAGE(code, string) string,
-const char * const jpeg_std_message_table[] = {
+static const char * const jpeg_std_message_table[] = {
#include "jerror.h"
NULL
};
@@ -229,23 +227,17 @@ reset_error_mgr(j_common_ptr cinfo)
GLOBAL(struct jpeg_error_mgr *)
jpeg_std_error(struct jpeg_error_mgr *err)
{
+ memset(err, 0, sizeof(struct jpeg_error_mgr));
+
err->error_exit = error_exit;
err->emit_message = emit_message;
err->output_message = output_message;
err->format_message = format_message;
err->reset_error_mgr = reset_error_mgr;
- err->trace_level = 0; /* default = no tracing */
- err->num_warnings = 0; /* no warnings emitted yet */
- err->msg_code = 0; /* may be useful as a flag for "no error" */
-
/* Initialize message table pointers */
err->jpeg_message_table = jpeg_std_message_table;
err->last_jpeg_message = (int)JMSG_LASTMSGCODE - 1;
- err->addon_message_table = NULL;
- err->first_addon_message = 0; /* for safety */
- err->last_addon_message = 0;
-
return err;
}
diff --git a/contrib/libs/libjpeg-turbo/src/jerror.h b/contrib/libs/libjpeg-turbo/src/jerror.h
new file mode 100644
index 00000000000..71ba03e2a3e
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jerror.h
@@ -0,0 +1,336 @@
+/*
+ * jerror.h
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1994-1997, Thomas G. Lane.
+ * Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2014, 2017, 2021-2023, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file defines the error and message codes for the JPEG library.
+ * Edit this file to add new codes, or to translate the message strings to
+ * some other language.
+ * A set of error-reporting macros are defined too. Some applications using
+ * the JPEG library may wish to include this file to get the error codes
+ * and/or the macros.
+ */
+
+/*
+ * To define the enum list of message codes, include this file without
+ * defining macro JMESSAGE. To create a message string table, include it
+ * again with a suitable JMESSAGE definition (see jerror.c for an example).
+ */
+#ifndef JMESSAGE
+#ifndef JERROR_H
+/* First time through, define the enum list */
+#define JMAKE_ENUM_LIST
+#else
+/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
+#define JMESSAGE(code, string)
+#endif /* JERROR_H */
+#endif /* JMESSAGE */
+
+#ifdef JMAKE_ENUM_LIST
+
+typedef enum {
+
+#define JMESSAGE(code, string) code,
+
+#endif /* JMAKE_ENUM_LIST */
+
+JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
+
+/* For maintenance convenience, list is alphabetical by message code name */
+#if JPEG_LIB_VERSION < 70
+JMESSAGE(JERR_ARITH_NOTIMPL, "Sorry, arithmetic coding is not implemented")
+#endif
+JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
+JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
+JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
+JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
+#if JPEG_LIB_VERSION >= 70
+JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
+#endif
+JMESSAGE(JERR_BAD_DCT_COEF,
+ "DCT coefficient (lossy) or spatial difference (lossless) out of range")
+JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported")
+#if JPEG_LIB_VERSION >= 70
+JMESSAGE(JERR_BAD_DROP_SAMPLING,
+ "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
+#endif
+JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
+JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
+JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
+JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
+JMESSAGE(JERR_BAD_LIB_VERSION,
+ "Wrong JPEG library version: library is %d, caller expects %d")
+JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
+JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
+JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
+JMESSAGE(JERR_BAD_PROGRESSION,
+ "Invalid progressive/lossless parameters Ss=%d Se=%d Ah=%d Al=%d")
+JMESSAGE(JERR_BAD_PROG_SCRIPT,
+ "Invalid progressive/lossless parameters at scan script entry %d")
+JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
+JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
+JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
+JMESSAGE(JERR_BAD_STRUCT_SIZE,
+ "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
+JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
+JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
+JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
+JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
+JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
+JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
+JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
+JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
+JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
+JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
+JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
+JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
+JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
+JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
+JMESSAGE(JERR_FILE_READ, "Input file read error")
+JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
+JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
+JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
+JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
+JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
+JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
+JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
+JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
+ "Cannot transcode due to multiple use of quantization table %d")
+JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
+JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
+JMESSAGE(JERR_NOTIMPL, "Requested features are incompatible")
+JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
+#if JPEG_LIB_VERSION >= 70
+JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
+#endif
+JMESSAGE(JERR_NO_BACKING_STORE, "Memory limit exceeded")
+JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
+JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
+JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
+JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
+JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
+JMESSAGE(JERR_QUANT_COMPONENTS,
+ "Cannot quantize more than %d color components")
+JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
+JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
+JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
+JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
+JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
+JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
+JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
+JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
+JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
+JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
+JMESSAGE(JERR_TFILE_WRITE,
+ "Write failed on temporary file --- out of disk space?")
+JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
+JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
+JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
+JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
+JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
+JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
+JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT_SHORT)
+JMESSAGE(JMSG_VERSION, JVERSION)
+JMESSAGE(JTRC_16BIT_TABLES,
+ "Caution: quantization tables are too coarse for baseline JPEG")
+JMESSAGE(JTRC_ADOBE,
+ "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
+JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
+JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
+JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
+JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
+JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d")
+JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
+JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
+JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
+JMESSAGE(JTRC_EOI, "End Of Image")
+JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d")
+JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d")
+JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
+ "Warning: thumbnail image size does not match data length %u")
+JMESSAGE(JTRC_JFIF_EXTENSION, "JFIF extension marker: type 0x%02x, length %u")
+JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image")
+JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
+JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
+JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u")
+JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
+JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
+JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
+JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
+JMESSAGE(JTRC_RST, "RST%d")
+JMESSAGE(JTRC_SMOOTH_NOTIMPL,
+ "Smoothing not supported with nonstandard sampling ratios")
+JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
+JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d")
+JMESSAGE(JTRC_SOI, "Start of Image")
+JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
+JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d")
+JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d")
+JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
+JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
+JMESSAGE(JTRC_THUMB_JPEG,
+ "JFIF extension marker: JPEG-compressed thumbnail image, length %u")
+JMESSAGE(JTRC_THUMB_PALETTE,
+ "JFIF extension marker: palette thumbnail image, length %u")
+JMESSAGE(JTRC_THUMB_RGB,
+ "JFIF extension marker: RGB thumbnail image, length %u")
+JMESSAGE(JTRC_UNKNOWN_IDS,
+ "Unrecognized component IDs %d %d %d, assuming YCbCr (lossy) or RGB (lossless)")
+JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
+JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
+JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
+#if JPEG_LIB_VERSION >= 70
+JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
+#endif
+JMESSAGE(JWRN_BOGUS_PROGRESSION,
+ "Inconsistent progression sequence for component %d coefficient %d")
+JMESSAGE(JWRN_EXTRANEOUS_DATA,
+ "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
+JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
+JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
+JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
+JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
+JMESSAGE(JWRN_MUST_RESYNC,
+ "Corrupt JPEG data: found marker 0x%02x instead of RST%d")
+JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
+JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
+#if JPEG_LIB_VERSION < 70
+JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
+#if defined(C_ARITH_CODING_SUPPORTED) || defined(D_ARITH_CODING_SUPPORTED)
+JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
+JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
+#endif
+#endif
+JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
+#if JPEG_LIB_VERSION < 70
+JMESSAGE(JERR_BAD_DROP_SAMPLING,
+ "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
+#endif
+JMESSAGE(JERR_BAD_RESTART,
+ "Invalid restart interval %d; must be an integer multiple of the number of MCUs in an MCU row (%d)")
+
+#ifdef JMAKE_ENUM_LIST
+
+ JMSG_LASTMSGCODE
+} J_MESSAGE_CODE;
+
+#undef JMAKE_ENUM_LIST
+#endif /* JMAKE_ENUM_LIST */
+
+/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
+#undef JMESSAGE
+
+
+#ifndef JERROR_H
+#define JERROR_H
+
+/* Macros to simplify using the error and trace message stuff */
+/* The first parameter is either type of cinfo pointer */
+
+/* Fatal errors (print message and exit) */
+#define ERREXIT(cinfo, code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
+#define ERREXIT1(cinfo, code, p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
+#define ERREXIT2(cinfo, code, p1, p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
+#define ERREXIT3(cinfo, code, p1, p2, p3) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
+#define ERREXIT4(cinfo, code, p1, p2, p3, p4) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (cinfo)->err->msg_parm.i[3] = (p4), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
+#define ERREXIT6(cinfo, code, p1, p2, p3, p4, p5, p6) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (cinfo)->err->msg_parm.i[2] = (p3), \
+ (cinfo)->err->msg_parm.i[3] = (p4), \
+ (cinfo)->err->msg_parm.i[4] = (p5), \
+ (cinfo)->err->msg_parm.i[5] = (p6), \
+ (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
+#define ERREXITS(cinfo, code, str) \
+ ((cinfo)->err->msg_code = (code), \
+ strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+ (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
+ (*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
+
+#define MAKESTMT(stuff) do { stuff } while (0)
+
+/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
+#define WARNMS(cinfo, code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
+#define WARNMS1(cinfo, code, p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
+#define WARNMS2(cinfo, code, p1, p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
+
+/* Informational/debugging messages */
+#define TRACEMS(cinfo, lvl, code) \
+ ((cinfo)->err->msg_code = (code), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
+#define TRACEMS1(cinfo, lvl, code, p1) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
+#define TRACEMS2(cinfo, lvl, code, p1, p2) \
+ ((cinfo)->err->msg_code = (code), \
+ (cinfo)->err->msg_parm.i[0] = (p1), \
+ (cinfo)->err->msg_parm.i[1] = (p2), \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
+#define TRACEMS3(cinfo, lvl, code, p1, p2, p3) \
+ MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
+#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4) \
+ MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
+#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5) \
+ MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ _mp[4] = (p5); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
+#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8) \
+ MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
+ _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
+ _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
+ (cinfo)->err->msg_code = (code); \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
+#define TRACEMSS(cinfo, lvl, code, str) \
+ ((cinfo)->err->msg_code = (code), \
+ strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
+ (cinfo)->err->msg_parm.s[JMSG_STR_PARM_MAX - 1] = '\0', \
+ (*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
+
+#endif /* JERROR_H */
diff --git a/contrib/libs/libjpeg-turbo/jfdctflt.c b/contrib/libs/libjpeg-turbo/src/jfdctflt.c
index ab6f6d08253..ab6f6d08253 100644
--- a/contrib/libs/libjpeg-turbo/jfdctflt.c
+++ b/contrib/libs/libjpeg-turbo/src/jfdctflt.c
diff --git a/contrib/libs/libjpeg-turbo/jfdctfst.c b/contrib/libs/libjpeg-turbo/src/jfdctfst.c
index 4c9ce0de8fa..26070d19a62 100644
--- a/contrib/libs/libjpeg-turbo/jfdctfst.c
+++ b/contrib/libs/libjpeg-turbo/src/jfdctfst.c
@@ -114,7 +114,7 @@
*/
GLOBAL(void)
-jpeg_fdct_ifast(DCTELEM *data)
+_jpeg_fdct_ifast(DCTELEM *data)
{
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
DCTELEM tmp10, tmp11, tmp12, tmp13;
diff --git a/contrib/libs/libjpeg-turbo/jfdctint.c b/contrib/libs/libjpeg-turbo/src/jfdctint.c
index c95a3a7fb8a..974013fa409 100644
--- a/contrib/libs/libjpeg-turbo/jfdctint.c
+++ b/contrib/libs/libjpeg-turbo/src/jfdctint.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2020, D. R. Commander.
+ * Copyright (C) 2015, 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -140,7 +140,7 @@
*/
GLOBAL(void)
-jpeg_fdct_islow(DCTELEM *data)
+_jpeg_fdct_islow(DCTELEM *data)
{
JLONG tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
JLONG tmp10, tmp11, tmp12, tmp13;
diff --git a/contrib/libs/libjpeg-turbo/jidctflt.c b/contrib/libs/libjpeg-turbo/src/jidctflt.c
index 5aee74e2321..ee3a31a6168 100644
--- a/contrib/libs/libjpeg-turbo/jidctflt.c
+++ b/contrib/libs/libjpeg-turbo/src/jidctflt.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2014, D. R. Commander.
+ * Copyright (C) 2014, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -69,9 +69,9 @@
*/
GLOBAL(void)
-jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
@@ -79,8 +79,8 @@ jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
FLOAT_MULT_TYPE *quantptr;
FAST_FLOAT *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = cinfo->sample_range_limit;
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int ctr;
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
#define _0_125 ((FLOAT_MULT_TYPE)0.125)
@@ -192,7 +192,7 @@ jpeg_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr,
/* Even part */
/* Apply signed->unsigned and prepare float->int conversion */
- z5 = wsptr[0] + ((FAST_FLOAT)CENTERJSAMPLE + (FAST_FLOAT)0.5);
+ z5 = wsptr[0] + ((FAST_FLOAT)_CENTERJSAMPLE + (FAST_FLOAT)0.5);
tmp10 = z5 + wsptr[4];
tmp11 = z5 - wsptr[4];
diff --git a/contrib/libs/libjpeg-turbo/jidctfst.c b/contrib/libs/libjpeg-turbo/src/jidctfst.c
index 89a20c937bb..68119b9942b 100644
--- a/contrib/libs/libjpeg-turbo/jidctfst.c
+++ b/contrib/libs/libjpeg-turbo/src/jidctfst.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1998, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
+ * Copyright (C) 2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -64,10 +64,10 @@
* The dequantized coefficients are not integers because the AA&N scaling
* factors have been incorporated. We represent them scaled up by PASS1_BITS,
* so that the first and second IDCT rounds have the same input scaling.
- * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to
+ * For 8-bit samples, we choose IFAST_SCALE_BITS = PASS1_BITS so as to
* avoid a descaling shift; this compromises accuracy rather drastically
* for small quantization table entries, but it saves a lot of shifts.
- * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway,
+ * For 12-bit samples, there's no hope of using 16x16 multiplies anyway,
* so we use a much larger scaling factor to preserve accuracy.
*
* A final compromise is to represent the multiplicative constants to only
@@ -168,9 +168,9 @@
*/
GLOBAL(void)
-jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
DCTELEM tmp10, tmp11, tmp12, tmp13;
@@ -178,8 +178,8 @@ jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
IFAST_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[DCTSIZE2]; /* buffers data between passes */
SHIFT_TEMPS /* for DESCALE */
@@ -296,7 +296,7 @@ jpeg_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr,
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
- JSAMPLE dcval =
+ _JSAMPLE dcval =
range_limit[IDESCALE(wsptr[0], PASS1_BITS + 3) & RANGE_MASK];
outptr[0] = dcval;
diff --git a/contrib/libs/libjpeg-turbo/jidctint.c b/contrib/libs/libjpeg-turbo/src/jidctint.c
index bb087480192..c58592d626d 100644
--- a/contrib/libs/libjpeg-turbo/jidctint.c
+++ b/contrib/libs/libjpeg-turbo/src/jidctint.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modification developed 2002-2018 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2020, D. R. Commander.
+ * Copyright (C) 2015, 2020, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -170,9 +170,9 @@
*/
GLOBAL(void)
-jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp3;
JLONG tmp10, tmp11, tmp12, tmp13;
@@ -180,8 +180,8 @@ jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[DCTSIZE2]; /* buffers data between passes */
SHIFT_TEMPS
@@ -314,8 +314,8 @@ jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
- JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
- PASS1_BITS + 3) & RANGE_MASK];
+ _JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
+ PASS1_BITS + 3) & RANGE_MASK];
outptr[0] = dcval;
outptr[1] = dcval;
@@ -424,17 +424,17 @@ jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_7x7(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_7x7(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp10, tmp11, tmp12, tmp13;
JLONG z1, z2, z3;
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[7 * 7]; /* buffers data between passes */
SHIFT_TEMPS
@@ -573,17 +573,17 @@ jpeg_idct_7x7(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp10, tmp11, tmp12;
JLONG z1, z2, z3;
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[6 * 6]; /* buffers data between passes */
SHIFT_TEMPS
@@ -694,17 +694,17 @@ jpeg_idct_6x6(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_5x5(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_5x5(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp10, tmp11, tmp12;
JLONG z1, z2, z3;
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[5 * 5]; /* buffers data between passes */
SHIFT_TEMPS
@@ -809,16 +809,16 @@ jpeg_idct_5x5(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_3x3(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_3x3(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp2, tmp10, tmp12;
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[3 * 3]; /* buffers data between passes */
SHIFT_TEMPS
@@ -899,17 +899,17 @@ jpeg_idct_3x3(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_9x9(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_9x9(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13, tmp14;
JLONG z1, z2, z3, z4;
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 9]; /* buffers data between passes */
SHIFT_TEMPS
@@ -1070,9 +1070,9 @@ jpeg_idct_9x9(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_10x10(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_10x10(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24;
@@ -1080,8 +1080,8 @@ jpeg_idct_10x10(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 10]; /* buffers data between passes */
SHIFT_TEMPS
@@ -1265,9 +1265,9 @@ jpeg_idct_10x10(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_11x11(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_11x11(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25;
@@ -1275,8 +1275,8 @@ jpeg_idct_11x11(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 11]; /* buffers data between passes */
SHIFT_TEMPS
@@ -1459,9 +1459,9 @@ jpeg_idct_11x11(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25;
@@ -1469,8 +1469,8 @@ jpeg_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 12]; /* buffers data between passes */
SHIFT_TEMPS
@@ -1675,9 +1675,9 @@ jpeg_idct_12x12(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_13x13(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_13x13(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
@@ -1685,8 +1685,8 @@ jpeg_idct_13x13(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 13]; /* buffers data between passes */
SHIFT_TEMPS
@@ -1903,9 +1903,9 @@ jpeg_idct_13x13(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_14x14(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_14x14(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26;
@@ -1913,8 +1913,8 @@ jpeg_idct_14x14(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 14]; /* buffers data between passes */
SHIFT_TEMPS
@@ -2129,9 +2129,9 @@ jpeg_idct_14x14(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_15x15(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_15x15(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp10, tmp11, tmp12, tmp13, tmp14, tmp15, tmp16;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27;
@@ -2139,8 +2139,8 @@ jpeg_idct_15x15(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 15]; /* buffers data between passes */
SHIFT_TEMPS
@@ -2371,9 +2371,9 @@ jpeg_idct_15x15(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_16x16(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_16x16(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp1, tmp2, tmp3, tmp10, tmp11, tmp12, tmp13;
JLONG tmp20, tmp21, tmp22, tmp23, tmp24, tmp25, tmp26, tmp27;
@@ -2381,8 +2381,8 @@ jpeg_idct_16x16(j_decompress_ptr cinfo, jpeg_component_info *compptr,
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[8 * 16]; /* buffers data between passes */
SHIFT_TEMPS
diff --git a/contrib/libs/libjpeg-turbo/jidctred.c b/contrib/libs/libjpeg-turbo/src/jidctred.c
index 1dd65a94d97..6521e3ebbfc 100644
--- a/contrib/libs/libjpeg-turbo/jidctred.c
+++ b/contrib/libs/libjpeg-turbo/src/jidctred.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1998, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, D. R. Commander.
+ * Copyright (C) 2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -118,17 +118,17 @@
*/
GLOBAL(void)
-jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp2, tmp10, tmp12;
JLONG z1, z2, z3, z4;
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[DCTSIZE * 4]; /* buffers data between passes */
SHIFT_TEMPS
@@ -210,8 +210,8 @@ jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
- JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
- PASS1_BITS + 3) & RANGE_MASK];
+ _JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
+ PASS1_BITS + 3) & RANGE_MASK];
outptr[0] = dcval;
outptr[1] = dcval;
@@ -276,16 +276,16 @@ jpeg_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
JLONG tmp0, tmp10, z1;
JCOEFPTR inptr;
ISLOW_MULT_TYPE *quantptr;
int *wsptr;
- JSAMPROW outptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPROW outptr;
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[DCTSIZE * 2]; /* buffers data between passes */
SHIFT_TEMPS
@@ -345,8 +345,8 @@ jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
#ifndef NO_ZERO_ROW_TEST
if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
- JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
- PASS1_BITS + 3) & RANGE_MASK];
+ _JSAMPLE dcval = range_limit[(int)DESCALE((JLONG)wsptr[0],
+ PASS1_BITS + 3) & RANGE_MASK];
outptr[0] = dcval;
outptr[1] = dcval;
@@ -387,13 +387,13 @@ jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr,
*/
GLOBAL(void)
-jpeg_idct_1x1(j_decompress_ptr cinfo, jpeg_component_info *compptr,
- JCOEFPTR coef_block, JSAMPARRAY output_buf,
- JDIMENSION output_col)
+_jpeg_idct_1x1(j_decompress_ptr cinfo, jpeg_component_info *compptr,
+ JCOEFPTR coef_block, _JSAMPARRAY output_buf,
+ JDIMENSION output_col)
{
int dcval;
ISLOW_MULT_TYPE *quantptr;
- JSAMPLE *range_limit = IDCT_range_limit(cinfo);
+ _JSAMPLE *range_limit = IDCT_range_limit(cinfo);
SHIFT_TEMPS
/* We hardly need an inverse DCT routine for this: just take the
diff --git a/contrib/libs/libjpeg-turbo/jinclude.h b/contrib/libs/libjpeg-turbo/src/jinclude.h
index 8910e620f0c..d8ce41fc413 100644
--- a/contrib/libs/libjpeg-turbo/jinclude.h
+++ b/contrib/libs/libjpeg-turbo/src/jinclude.h
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1994, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2022, D. R. Commander.
+ * Copyright (C) 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -123,6 +123,8 @@ static INLINE int GETENV_S(char *buffer, size_t buffer_size, const char *name)
#else
+#include <errno.h>
+
/* This provides a similar interface to the Microsoft _putenv_s() function, but
* other than parameter validation, it has no advantages over setenv().
*/
diff --git a/contrib/libs/libjpeg-turbo/src/jlossls.h b/contrib/libs/libjpeg-turbo/src/jlossls.h
new file mode 100644
index 00000000000..ce417041345
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jlossls.h
@@ -0,0 +1,101 @@
+/*
+ * jlossls.h
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1998, Thomas G. Lane.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This include file contains common declarations for the lossless JPEG
+ * codec modules.
+ */
+
+#ifndef JLOSSLS_H
+#define JLOSSLS_H
+
+#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
+
+#define JPEG_INTERNALS
+#include "jpeglib.h"
+#include "jsamplecomp.h"
+
+
+#define ALLOC_DARRAY(pool_id, diffsperrow, numrows) \
+ (JDIFFARRAY)(*cinfo->mem->alloc_sarray) \
+ ((j_common_ptr)cinfo, pool_id, \
+ (diffsperrow) * sizeof(JDIFF) / sizeof(_JSAMPLE), numrows)
+
+
+/*
+ * Table H.1: Predictors for lossless coding.
+ */
+
+#define PREDICTOR1 Ra
+#define PREDICTOR2 Rb
+#define PREDICTOR3 Rc
+#define PREDICTOR4 (int)((JLONG)Ra + (JLONG)Rb - (JLONG)Rc)
+#define PREDICTOR5 (int)((JLONG)Ra + RIGHT_SHIFT((JLONG)Rb - (JLONG)Rc, 1))
+#define PREDICTOR6 (int)((JLONG)Rb + RIGHT_SHIFT((JLONG)Ra - (JLONG)Rc, 1))
+#define PREDICTOR7 (int)RIGHT_SHIFT((JLONG)Ra + (JLONG)Rb, 1)
+
+#endif
+
+
+#ifdef C_LOSSLESS_SUPPORTED
+
+typedef void (*predict_difference_method_ptr) (j_compress_ptr cinfo, int ci,
+ _JSAMPROW input_buf,
+ _JSAMPROW prev_row,
+ JDIFFROW diff_buf,
+ JDIMENSION width);
+
+/* Lossless compressor */
+typedef struct {
+ struct jpeg_forward_dct pub; /* public fields */
+
+ /* It is useful to allow each component to have a separate diff method. */
+ predict_difference_method_ptr predict_difference[MAX_COMPONENTS];
+
+ /* MCU rows left in the restart interval for each component */
+ unsigned int restart_rows_to_go[MAX_COMPONENTS];
+
+ /* Sample scaling */
+ void (*scaler_scale) (j_compress_ptr cinfo, _JSAMPROW input_buf,
+ _JSAMPROW output_buf, JDIMENSION width);
+} jpeg_lossless_compressor;
+
+typedef jpeg_lossless_compressor *lossless_comp_ptr;
+
+#endif /* C_LOSSLESS_SUPPORTED */
+
+
+#ifdef D_LOSSLESS_SUPPORTED
+
+typedef void (*predict_undifference_method_ptr) (j_decompress_ptr cinfo,
+ int comp_index,
+ JDIFFROW diff_buf,
+ JDIFFROW prev_row,
+ JDIFFROW undiff_buf,
+ JDIMENSION width);
+
+/* Lossless decompressor */
+typedef struct {
+ struct jpeg_inverse_dct pub; /* public fields */
+
+ /* It is useful to allow each component to have a separate undiff method. */
+ predict_undifference_method_ptr predict_undifference[MAX_COMPONENTS];
+
+ /* Sample scaling */
+ void (*scaler_scale) (j_decompress_ptr cinfo, JDIFFROW diff_buf,
+ _JSAMPROW output_buf, JDIMENSION width);
+} jpeg_lossless_decompressor;
+
+typedef jpeg_lossless_decompressor *lossless_decomp_ptr;
+
+#endif /* D_LOSSLESS_SUPPORTED */
+
+#endif /* JLOSSLS_H */
diff --git a/contrib/libs/libjpeg-turbo/jmemmgr.c b/contrib/libs/libjpeg-turbo/src/jmemmgr.c
index a40446f6ac3..eb199c8b3de 100644
--- a/contrib/libs/libjpeg-turbo/jmemmgr.c
+++ b/contrib/libs/libjpeg-turbo/src/jmemmgr.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2016, 2021-2022, D. R. Commander.
+ * Copyright (C) 2016, 2021-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -155,7 +155,10 @@ typedef my_memory_mgr *my_mem_ptr;
*/
struct jvirt_sarray_control {
- JSAMPARRAY mem_buffer; /* => the in-memory buffer */
+ JSAMPARRAY mem_buffer; /* => the in-memory buffer (if
+ cinfo->data_precision > 8, then this is
+ actually a J12SAMPARRAY or a
+ J16SAMPARRAY) */
JDIMENSION rows_in_array; /* total virtual array height */
JDIMENSION samplesperrow; /* width of array (and of memory buffer) */
JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */
@@ -351,9 +354,10 @@ alloc_small(j_common_ptr cinfo, int pool_id, size_t sizeofobject)
* request is large enough that it may as well be passed directly to
* jpeg_get_large; the pool management just links everything together
* so that we can free it all on demand.
- * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY
- * structures. The routines that create these structures (see below)
- * deliberately bunch rows together to ensure a large request size.
+ * Note: the major use of "large" objects is in
+ * JSAMPARRAY/J12SAMPARRAY/J16SAMPARRAY and JBLOCKARRAY structures. The
+ * routines that create these structures (see below) deliberately bunch rows
+ * together to ensure a large request size.
*/
METHODDEF(void *)
@@ -437,9 +441,22 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
JSAMPROW workspace;
JDIMENSION rowsperchunk, currow, i;
long ltemp;
+ J12SAMPARRAY result12;
+ J12SAMPROW workspace12;
+#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
+ J16SAMPARRAY result16;
+ J16SAMPROW workspace16;
+#endif
+ int data_precision = cinfo->is_decompressor ?
+ ((j_decompress_ptr)cinfo)->data_precision :
+ ((j_compress_ptr)cinfo)->data_precision;
+ size_t sample_size = data_precision > 12 ?
+ sizeof(J16SAMPLE) : (data_precision > 8 ?
+ sizeof(J12SAMPLE) :
+ sizeof(JSAMPLE));
/* Make sure each row is properly aligned */
- if ((ALIGN_SIZE % sizeof(JSAMPLE)) != 0)
+ if ((ALIGN_SIZE % sample_size) != 0)
out_of_memory(cinfo, 5); /* safety check */
if (samplesperrow > MAX_ALLOC_CHUNK) {
@@ -448,11 +465,11 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
out_of_memory(cinfo, 9);
}
samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) /
- sizeof(JSAMPLE));
+ sample_size);
/* Calculate max # of rows allowed in one allocation chunk */
ltemp = (MAX_ALLOC_CHUNK - sizeof(large_pool_hdr)) /
- ((long)samplesperrow * sizeof(JSAMPLE));
+ ((long)samplesperrow * (long)sample_size);
if (ltemp <= 0)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
if (ltemp < (long)numrows)
@@ -461,24 +478,68 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
rowsperchunk = numrows;
mem->last_rowsperchunk = rowsperchunk;
- /* Get space for row pointers (small object) */
- result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
- (size_t)(numrows * sizeof(JSAMPROW)));
+ if (data_precision <= 8) {
+ /* Get space for row pointers (small object) */
+ result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
+ (size_t)(numrows * sizeof(JSAMPROW)));
+
+ /* Get the rows themselves (large objects) */
+ currow = 0;
+ while (currow < numrows) {
+ rowsperchunk = MIN(rowsperchunk, numrows - currow);
+ workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
+ (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
+ for (i = rowsperchunk; i > 0; i--) {
+ result[currow++] = workspace;
+ workspace += samplesperrow;
+ }
+ }
- /* Get the rows themselves (large objects) */
- currow = 0;
- while (currow < numrows) {
- rowsperchunk = MIN(rowsperchunk, numrows - currow);
- workspace = (JSAMPROW)alloc_large(cinfo, pool_id,
- (size_t)((size_t)rowsperchunk * (size_t)samplesperrow *
- sizeof(JSAMPLE)));
- for (i = rowsperchunk; i > 0; i--) {
- result[currow++] = workspace;
- workspace += samplesperrow;
+ return result;
+ } else if (data_precision <= 12) {
+ /* Get space for row pointers (small object) */
+ result12 = (J12SAMPARRAY)alloc_small(cinfo, pool_id,
+ (size_t)(numrows *
+ sizeof(J12SAMPROW)));
+
+ /* Get the rows themselves (large objects) */
+ currow = 0;
+ while (currow < numrows) {
+ rowsperchunk = MIN(rowsperchunk, numrows - currow);
+ workspace12 = (J12SAMPROW)alloc_large(cinfo, pool_id,
+ (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
+ for (i = rowsperchunk; i > 0; i--) {
+ result12[currow++] = workspace12;
+ workspace12 += samplesperrow;
+ }
}
- }
- return result;
+ return (JSAMPARRAY)result12;
+ } else {
+#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
+ /* Get space for row pointers (small object) */
+ result16 = (J16SAMPARRAY)alloc_small(cinfo, pool_id,
+ (size_t)(numrows *
+ sizeof(J16SAMPROW)));
+
+ /* Get the rows themselves (large objects) */
+ currow = 0;
+ while (currow < numrows) {
+ rowsperchunk = MIN(rowsperchunk, numrows - currow);
+ workspace16 = (J16SAMPROW)alloc_large(cinfo, pool_id,
+ (size_t)((size_t)rowsperchunk * (size_t)samplesperrow * sample_size));
+ for (i = rowsperchunk; i > 0; i--) {
+ result16[currow++] = workspace16;
+ workspace16 += samplesperrow;
+ }
+ }
+
+ return (JSAMPARRAY)result16;
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, data_precision);
+ return NULL;
+#endif
+ }
}
@@ -640,6 +701,13 @@ realize_virt_arrays(j_common_ptr cinfo)
size_t minheights, max_minheights;
jvirt_sarray_ptr sptr;
jvirt_barray_ptr bptr;
+ int data_precision = cinfo->is_decompressor ?
+ ((j_decompress_ptr)cinfo)->data_precision :
+ ((j_compress_ptr)cinfo)->data_precision;
+ size_t sample_size = data_precision > 12 ?
+ sizeof(J16SAMPLE) : (data_precision > 8 ?
+ sizeof(J12SAMPLE) :
+ sizeof(JSAMPLE));
/* Compute the minimum space needed (maxaccess rows in each buffer)
* and the maximum space needed (full image height in each buffer).
@@ -650,10 +718,10 @@ realize_virt_arrays(j_common_ptr cinfo)
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
if (sptr->mem_buffer == NULL) { /* if not realized yet */
size_t new_space = (long)sptr->rows_in_array *
- (long)sptr->samplesperrow * sizeof(JSAMPLE);
+ (long)sptr->samplesperrow * sample_size;
space_per_minheight += (long)sptr->maxaccess *
- (long)sptr->samplesperrow * sizeof(JSAMPLE);
+ (long)sptr->samplesperrow * sample_size;
if (SIZE_MAX - maximum_space < new_space)
out_of_memory(cinfo, 10);
maximum_space += new_space;
@@ -708,7 +776,7 @@ realize_virt_arrays(j_common_ptr cinfo)
jpeg_open_backing_store(cinfo, &sptr->b_s_info,
(long)sptr->rows_in_array *
(long)sptr->samplesperrow *
- (long)sizeof(JSAMPLE));
+ (long)sample_size);
sptr->b_s_open = TRUE;
}
sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
@@ -751,8 +819,15 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
/* Do backing store read or write of a virtual sample array */
{
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
-
- bytesperrow = (long)ptr->samplesperrow * sizeof(JSAMPLE);
+ int data_precision = cinfo->is_decompressor ?
+ ((j_decompress_ptr)cinfo)->data_precision :
+ ((j_compress_ptr)cinfo)->data_precision;
+ size_t sample_size = data_precision > 12 ?
+ sizeof(J16SAMPLE) : (data_precision > 8 ?
+ sizeof(J12SAMPLE) :
+ sizeof(JSAMPLE));
+
+ bytesperrow = (long)ptr->samplesperrow * (long)sample_size;
file_offset = ptr->cur_start_row * bytesperrow;
/* Loop to read or write each allocation chunk in mem_buffer */
for (i = 0; i < (long)ptr->rows_in_mem; i += ptr->rowsperchunk) {
@@ -766,14 +841,42 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
if (rows <= 0) /* this chunk might be past end of file! */
break;
byte_count = rows * bytesperrow;
- if (writing)
- (*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
- (void *)ptr->mem_buffer[i],
- file_offset, byte_count);
- else
- (*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
- (void *)ptr->mem_buffer[i],
- file_offset, byte_count);
+ if (data_precision <= 8) {
+ if (writing)
+ (*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
+ (void *)ptr->mem_buffer[i],
+ file_offset, byte_count);
+ else
+ (*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
+ (void *)ptr->mem_buffer[i],
+ file_offset, byte_count);
+ } else if (data_precision <= 12) {
+ J12SAMPARRAY mem_buffer12 = (J12SAMPARRAY)ptr->mem_buffer;
+
+ if (writing)
+ (*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
+ (void *)mem_buffer12[i],
+ file_offset, byte_count);
+ else
+ (*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
+ (void *)mem_buffer12[i],
+ file_offset, byte_count);
+ } else {
+#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
+ J16SAMPARRAY mem_buffer16 = (J16SAMPARRAY)ptr->mem_buffer;
+
+ if (writing)
+ (*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
+ (void *)mem_buffer16[i],
+ file_offset, byte_count);
+ else
+ (*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
+ (void *)mem_buffer16[i],
+ file_offset, byte_count);
+#else
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, data_precision);
+#endif
+ }
file_offset += byte_count;
}
}
@@ -821,6 +924,13 @@ access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
{
JDIMENSION end_row = start_row + num_rows;
JDIMENSION undef_row;
+ int data_precision = cinfo->is_decompressor ?
+ ((j_decompress_ptr)cinfo)->data_precision :
+ ((j_compress_ptr)cinfo)->data_precision;
+ size_t sample_size = data_precision > 12 ?
+ sizeof(J16SAMPLE) : (data_precision > 8 ?
+ sizeof(J12SAMPLE) :
+ sizeof(JSAMPLE));
/* debugging check */
if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||
@@ -876,7 +986,7 @@ access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
if (writable)
ptr->first_undef_row = end_row;
if (ptr->pre_zero) {
- size_t bytesperrow = (size_t)ptr->samplesperrow * sizeof(JSAMPLE);
+ size_t bytesperrow = (size_t)ptr->samplesperrow * sample_size;
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
end_row -= ptr->cur_start_row;
while (undef_row < end_row) {
diff --git a/contrib/libs/libjpeg-turbo/jmemnobs.c b/contrib/libs/libjpeg-turbo/src/jmemnobs.c
index cd6571ba1c4..692775f5a85 100644
--- a/contrib/libs/libjpeg-turbo/jmemnobs.c
+++ b/contrib/libs/libjpeg-turbo/src/jmemnobs.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1992-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017-2018, D. R. Commander.
+ * Copyright (C) 2017-2018, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -31,7 +31,7 @@
GLOBAL(void *)
jpeg_get_small(j_common_ptr cinfo, size_t sizeofobject)
{
- return (void *)malloc(sizeofobject);
+ return (void *)MALLOC(sizeofobject);
}
GLOBAL(void)
@@ -48,7 +48,7 @@ jpeg_free_small(j_common_ptr cinfo, void *object, size_t sizeofobject)
GLOBAL(void *)
jpeg_get_large(j_common_ptr cinfo, size_t sizeofobject)
{
- return (void *)malloc(sizeofobject);
+ return (void *)MALLOC(sizeofobject);
}
GLOBAL(void)
diff --git a/contrib/libs/libjpeg-turbo/jmemsys.h b/contrib/libs/libjpeg-turbo/src/jmemsys.h
index 9229550afde..ac09ef4c36d 100644
--- a/contrib/libs/libjpeg-turbo/jmemsys.h
+++ b/contrib/libs/libjpeg-turbo/src/jmemsys.h
@@ -99,24 +99,6 @@ EXTERN(size_t) jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */
-#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */
-
-typedef unsigned short XMSH; /* type of extended-memory handles */
-typedef unsigned short EMSH; /* type of expanded-memory handles */
-
-typedef union {
- short file_handle; /* DOS file handle if it's a temp file */
- XMSH xms_handle; /* handle if it's a chunk of XMS */
- EMSH ems_handle; /* handle if it's a chunk of EMS */
-} handle_union;
-
-#endif /* USE_MSDOS_MEMMGR */
-
-#ifdef USE_MAC_MEMMGR /* Mac-specific junk */
-#include <Files.h>
-#endif /* USE_MAC_MEMMGR */
-
-
typedef struct backing_store_struct *backing_store_ptr;
typedef struct backing_store_struct {
@@ -130,22 +112,9 @@ typedef struct backing_store_struct {
void (*close_backing_store) (j_common_ptr cinfo, backing_store_ptr info);
/* Private fields for system-dependent backing-store management */
-#ifdef USE_MSDOS_MEMMGR
- /* For the MS-DOS manager (jmemdos.c), we need: */
- handle_union handle; /* reference to backing-store storage object */
- char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
-#else
-#ifdef USE_MAC_MEMMGR
- /* For the Mac manager (jmemmac.c), we need: */
- short temp_file; /* file reference number to temp file */
- FSSpec tempSpec; /* the FSSpec for the temp file */
- char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */
-#else
/* For a typical implementation with temp files, we need: */
FILE *temp_file; /* stdio reference to temp file */
char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */
-#endif
-#endif
} backing_store_info;
diff --git a/contrib/libs/libjpeg-turbo/src/jmorecfg.h b/contrib/libs/libjpeg-turbo/src/jmorecfg.h
new file mode 100644
index 00000000000..ebf346215cc
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jmorecfg.h
@@ -0,0 +1,385 @@
+/*
+ * jmorecfg.h
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, 2022, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains additional configuration options that customize the
+ * JPEG software for special applications or support machine-dependent
+ * optimizations. Most users will not need to touch this file.
+ */
+
+
+/*
+ * Maximum number of components (color channels) allowed in JPEG image.
+ * To meet the letter of Rec. ITU-T T.81 | ISO/IEC 10918-1, set this to 255.
+ * However, darn few applications need more than 4 channels (maybe 5 for CMYK +
+ * alpha mask). We recommend 10 as a reasonable compromise; use 4 if you are
+ * really short on memory. (Each allowed component costs a hundred or so
+ * bytes of storage, whether actually used in an image or not.)
+ */
+
+#define MAX_COMPONENTS 10 /* maximum number of image components */
+
+
+/*
+ * Basic data types.
+ * You may need to change these if you have a machine with unusual data
+ * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
+ * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
+ * but it had better be at least 16.
+ */
+
+/* Representation of a single sample (pixel element value).
+ * We frequently allocate large arrays of these, so it's important to keep
+ * them small. But if you have memory to burn and access to char or short
+ * arrays is very slow on your hardware, you might want to change these.
+ */
+
+/* JSAMPLE should be the smallest type that will hold the values 0..255. */
+
+typedef unsigned char JSAMPLE;
+#define GETJSAMPLE(value) ((int)(value))
+
+#define MAXJSAMPLE 255
+#define CENTERJSAMPLE 128
+
+
+/* J12SAMPLE should be the smallest type that will hold the values 0..4095. */
+
+typedef short J12SAMPLE;
+
+#define MAXJ12SAMPLE 4095
+#define CENTERJ12SAMPLE 2048
+
+
+/* J16SAMPLE should be the smallest type that will hold the values 0..65535. */
+
+typedef unsigned short J16SAMPLE;
+
+#define MAXJ16SAMPLE 65535
+#define CENTERJ16SAMPLE 32768
+
+
+/* Representation of a DCT frequency coefficient.
+ * This should be a signed value of at least 16 bits; "short" is usually OK.
+ * Again, we allocate large arrays of these, but you can change to int
+ * if you have memory to burn and "short" is really slow.
+ */
+
+typedef short JCOEF;
+
+
+/* Compressed datastreams are represented as arrays of JOCTET.
+ * These must be EXACTLY 8 bits wide, at least once they are written to
+ * external storage. Note that when using the stdio data source/destination
+ * managers, this is also the data type passed to fread/fwrite.
+ */
+
+typedef unsigned char JOCTET;
+#define GETJOCTET(value) (value)
+
+
+/* These typedefs are used for various table entries and so forth.
+ * They must be at least as wide as specified; but making them too big
+ * won't cost a huge amount of memory, so we don't provide special
+ * extraction code like we did for JSAMPLE. (In other words, these
+ * typedefs live at a different point on the speed/space tradeoff curve.)
+ */
+
+/* UINT8 must hold at least the values 0..255. */
+
+typedef unsigned char UINT8;
+
+/* UINT16 must hold at least the values 0..65535. */
+
+typedef unsigned short UINT16;
+
+/* INT16 must hold at least the values -32768..32767. */
+
+#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
+typedef short INT16;
+#endif
+
+/* INT32 must hold at least signed 32-bit values.
+ *
+ * NOTE: The INT32 typedef dates back to libjpeg v5 (1994.) Integers were
+ * sometimes 16-bit back then (MS-DOS), which is why INT32 is typedef'd to
+ * long. It also wasn't common (or at least as common) in 1994 for INT32 to be
+ * defined by platform headers. Since then, however, INT32 is defined in
+ * several other common places:
+ *
+ * Xmd.h (X11 header) typedefs INT32 to int on 64-bit platforms and long on
+ * 32-bit platforms (i.e always a 32-bit signed type.)
+ *
+ * basetsd.h (Win32 header) typedefs INT32 to int (always a 32-bit signed type
+ * on modern platforms.)
+ *
+ * qglobal.h (Qt header) typedefs INT32 to int (always a 32-bit signed type on
+ * modern platforms.)
+ *
+ * This is a recipe for conflict, since "long" and "int" aren't always
+ * compatible types. Since the definition of INT32 has technically been part
+ * of the libjpeg API for more than 20 years, we can't remove it, but we do not
+ * use it internally any longer. We instead define a separate type (JLONG)
+ * for internal use, which ensures that internal behavior will always be the
+ * same regardless of any external headers that may be included.
+ */
+
+#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
+#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
+#ifndef _BASETSD_H /* MinGW is slightly different */
+#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
+//typedef long INT32;
+#endif
+#endif
+#endif
+#endif
+
+/* Datatype used for image dimensions. The JPEG standard only supports
+ * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
+ * "unsigned int" is sufficient on all machines. However, if you need to
+ * handle larger images and you don't mind deviating from the spec, you
+ * can change this datatype. (Note that changing this datatype will
+ * potentially require modifying the SIMD code. The x86-64 SIMD extensions,
+ * in particular, assume a 32-bit JDIMENSION.)
+ */
+
+typedef unsigned int JDIMENSION;
+
+#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
+
+
+/* These macros are used in all function definitions and extern declarations.
+ * You could modify them if you need to change function linkage conventions;
+ * in particular, you'll need to do that to make the library a Windows DLL.
+ * Another application is to make all functions global for use with debuggers
+ * or code profilers that require it.
+ */
+
+/* a function called through method pointers: */
+#define METHODDEF(type) static type
+/* a function used only in its module: */
+#define LOCAL(type) static type
+/* a function referenced thru EXTERNs: */
+#define GLOBAL(type) type
+/* a reference to a GLOBAL function: */
+#define EXTERN(type) extern type
+
+
+/* Originally, this macro was used as a way of defining function prototypes
+ * for both modern compilers as well as older compilers that did not support
+ * prototype parameters. libjpeg-turbo has never supported these older,
+ * non-ANSI compilers, but the macro is still included because there is some
+ * software out there that uses it.
+ */
+
+#define JMETHOD(type, methodname, arglist) type (*methodname) arglist
+
+
+/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
+ * but again, some software relies on this macro.
+ */
+
+#undef FAR
+#define FAR
+
+
+/*
+ * On a few systems, type boolean and/or its values FALSE, TRUE may appear
+ * in standard header files. Or you may have conflicts with application-
+ * specific header files that you want to include together with these files.
+ * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
+ */
+
+#ifndef HAVE_BOOLEAN
+typedef int boolean;
+#endif
+#ifndef FALSE /* in case these macros already exist */
+#define FALSE 0 /* values of boolean */
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+
+/*
+ * The remaining options affect code selection within the JPEG library,
+ * but they don't need to be visible to most applications using the library.
+ * To minimize application namespace pollution, the symbols won't be
+ * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
+ */
+
+#ifdef JPEG_INTERNALS
+#define JPEG_INTERNAL_OPTIONS
+#endif
+
+#ifdef JPEG_INTERNAL_OPTIONS
+
+
+/*
+ * These defines indicate whether to include various optional functions.
+ * Undefining some of these symbols will produce a smaller but less capable
+ * library. Note that you can leave certain source files out of the
+ * compilation/linking process if you've #undef'd the corresponding symbols.
+ * (You may HAVE to do that if your compiler doesn't like null source files.)
+ */
+
+/* Capability options common to encoder and decoder: */
+
+#define DCT_ISLOW_SUPPORTED /* accurate integer method */
+#define DCT_IFAST_SUPPORTED /* less accurate int method [legacy feature] */
+#define DCT_FLOAT_SUPPORTED /* floating-point method [legacy feature] */
+
+/* Encoder capability options: */
+
+#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
+#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
+#define C_LOSSLESS_SUPPORTED /* Lossless JPEG? */
+#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
+/* Note: if you selected 12-bit data precision, it is dangerous to turn off
+ * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
+ * precision, so jchuff.c normally uses entropy optimization to compute
+ * usable tables for higher precision. If you don't want to do optimization,
+ * you'll have to supply different default Huffman tables.
+ * The exact same statements apply for progressive and lossless JPEG:
+ * the default tables don't work for progressive mode or lossless mode.
+ * (This may get fixed, however.)
+ */
+#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
+
+/* Decoder capability options: */
+
+#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
+#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
+#define D_LOSSLESS_SUPPORTED /* Lossless JPEG? */
+#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
+#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
+#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
+#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
+#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
+#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
+#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
+
+/* more capability options later, no doubt */
+
+
+/*
+ * The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
+ * feature of libjpeg. The idea was that, if an application developer needed
+ * to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
+ * change these macros, rebuild libjpeg, and link their application statically
+ * with it. In reality, few people ever did this, because there were some
+ * severe restrictions involved (cjpeg and djpeg no longer worked properly,
+ * compressing/decompressing RGB JPEGs no longer worked properly, and the color
+ * quantizer wouldn't work with pixel sizes other than 3.) Furthermore, since
+ * all of the O/S-supplied versions of libjpeg were built with the default
+ * values of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications
+ * have come to regard these values as immutable.
+ *
+ * The libjpeg-turbo colorspace extensions provide a much cleaner way of
+ * compressing from/decompressing to buffers with arbitrary component orders
+ * and pixel sizes. Thus, we do not support changing the values of RGB_RED,
+ * RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE. In addition to the restrictions
+ * listed above, changing these values will also break the SIMD extensions and
+ * the regression tests.
+ */
+
+#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
+#define RGB_GREEN 1 /* Offset of Green */
+#define RGB_BLUE 2 /* Offset of Blue */
+#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
+
+#define JPEG_NUMCS 17
+
+#define EXT_RGB_RED 0
+#define EXT_RGB_GREEN 1
+#define EXT_RGB_BLUE 2
+#define EXT_RGB_PIXELSIZE 3
+
+#define EXT_RGBX_RED 0
+#define EXT_RGBX_GREEN 1
+#define EXT_RGBX_BLUE 2
+#define EXT_RGBX_PIXELSIZE 4
+
+#define EXT_BGR_RED 2
+#define EXT_BGR_GREEN 1
+#define EXT_BGR_BLUE 0
+#define EXT_BGR_PIXELSIZE 3
+
+#define EXT_BGRX_RED 2
+#define EXT_BGRX_GREEN 1
+#define EXT_BGRX_BLUE 0
+#define EXT_BGRX_PIXELSIZE 4
+
+#define EXT_XBGR_RED 3
+#define EXT_XBGR_GREEN 2
+#define EXT_XBGR_BLUE 1
+#define EXT_XBGR_PIXELSIZE 4
+
+#define EXT_XRGB_RED 1
+#define EXT_XRGB_GREEN 2
+#define EXT_XRGB_BLUE 3
+#define EXT_XRGB_PIXELSIZE 4
+
+static const int rgb_red[JPEG_NUMCS] = {
+ -1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
+ EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
+ EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
+ -1
+};
+
+static const int rgb_green[JPEG_NUMCS] = {
+ -1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
+ EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
+ EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
+ -1
+};
+
+static const int rgb_blue[JPEG_NUMCS] = {
+ -1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
+ EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
+ EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
+ -1
+};
+
+static const int rgb_pixelsize[JPEG_NUMCS] = {
+ -1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
+ EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
+ EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
+ -1
+};
+
+/* Definitions for speed-related optimizations. */
+
+/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
+ * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
+ * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
+ */
+
+#ifndef MULTIPLIER
+#ifndef WITH_SIMD
+#define MULTIPLIER int /* type for fastest integer multiply */
+#else
+#define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */
+#endif
+#endif
+
+
+/* FAST_FLOAT should be either float or double, whichever is done faster
+ * by your compiler. (Note that this type is only used in the floating point
+ * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
+ */
+
+#ifndef FAST_FLOAT
+#define FAST_FLOAT float
+#endif
+
+#endif /* JPEG_INTERNAL_OPTIONS */
diff --git a/contrib/libs/libjpeg-turbo/jpeg_nbits_table.h b/contrib/libs/libjpeg-turbo/src/jpeg_nbits.c
index fcf73878c31..c8ee6b056cb 100644
--- a/contrib/libs/libjpeg-turbo/jpeg_nbits_table.h
+++ b/contrib/libs/libjpeg-turbo/src/jpeg_nbits.c
@@ -1,4 +1,32 @@
-static const unsigned char jpeg_nbits_table[65536] = {
+/*
+ * Copyright (C) 2024, D. R. Commander.
+ *
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ */
+
+#include "jpeg_nbits.h"
+#include "jconfigint.h"
+
+
+#ifndef USE_CLZ_INTRINSIC
+
+#define INCLUDE_JPEG_NBITS_TABLE
+
+/* When building for x86[-64] with the SIMD extensions enabled, the C Huffman
+ * encoders can reuse jpeg_nbits_table from the SSE2 baseline Huffman encoder.
+ */
+#if (defined(__x86_64__) || defined(__i386__) || defined(_M_IX86) || \
+ defined(_M_X64)) && defined(WITH_SIMD)
+#undef INCLUDE_JPEG_NBITS_TABLE
+#endif
+
+#endif
+
+
+#ifdef INCLUDE_JPEG_NBITS_TABLE
+
+const unsigned char HIDDEN jpeg_nbits_table[65536] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
@@ -4096,3 +4124,11 @@ static const unsigned char jpeg_nbits_table[65536] = {
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
};
+
+#else
+
+/* Suppress compiler warnings about empty translation unit. */
+
+typedef int dummy_jpeg_nbits_table;
+
+#endif
diff --git a/contrib/libs/libjpeg-turbo/src/jpeg_nbits.h b/contrib/libs/libjpeg-turbo/src/jpeg_nbits.h
new file mode 100644
index 00000000000..6481a1228d1
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jpeg_nbits.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014, 2021, 2024, D. R. Commander.
+ * Copyright (C) 2014, Olle Liljenzin.
+ * Copyright (C) 2020, Arm Limited.
+ *
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ */
+
+/*
+ * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
+ * used for bit counting rather than the lookup table. This will reduce the
+ * memory footprint by 64k, which is important for some mobile applications
+ * that create many isolated instances of libjpeg-turbo (web browsers, for
+ * instance.) This may improve performance on some mobile platforms as well.
+ * This feature is enabled by default only on Arm processors, because some x86
+ * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
+ * shown to have a significant performance impact even on the x86 chips that
+ * have a fast implementation of it. When building for Armv6, you can
+ * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
+ * flags (this defines __thumb__).
+ */
+
+/* NOTE: Both GCC and Clang define __GNUC__ */
+#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
+ defined(_M_ARM) || defined(_M_ARM64)
+#if !defined(__thumb__) || defined(__thumb2__)
+#define USE_CLZ_INTRINSIC
+#endif
+#endif
+
+#ifdef USE_CLZ_INTRINSIC
+#if defined(_MSC_VER) && !defined(__clang__)
+#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
+#else
+#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
+#endif
+#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
+#else
+extern const unsigned char jpeg_nbits_table[65536];
+#define JPEG_NBITS(x) (jpeg_nbits_table[x])
+#define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
+#endif
diff --git a/contrib/libs/libjpeg-turbo/jpegcomp.h b/contrib/libs/libjpeg-turbo/src/jpegapicomp.h
index c4834ac0df9..bb3912eb2f1 100644
--- a/contrib/libs/libjpeg-turbo/jpegcomp.h
+++ b/contrib/libs/libjpeg-turbo/src/jpegapicomp.h
@@ -1,5 +1,5 @@
/*
- * jpegcomp.h
+ * jpegapicomp.h
*
* Copyright (C) 2010, 2020, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
diff --git a/contrib/libs/libjpeg-turbo/src/jpegint.h b/contrib/libs/libjpeg-turbo/src/jpegint.h
new file mode 100644
index 00000000000..a90493f9e08
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jpegint.h
@@ -0,0 +1,600 @@
+/*
+ * jpegint.h
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1997, Thomas G. Lane.
+ * Modified 1997-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2015-2017, 2019, 2021-2022, 2024, D. R. Commander.
+ * Copyright (C) 2015, Google, Inc.
+ * Copyright (C) 2021, Alex Richardson.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file provides common declarations for the various JPEG modules.
+ * These declarations are considered internal to the JPEG library; most
+ * applications using the library shouldn't need to include this file.
+ */
+
+
+/* Representation of a spatial difference value.
+ * This should be a signed value of at least 16 bits; int is usually OK.
+ */
+
+typedef int JDIFF;
+
+typedef JDIFF FAR *JDIFFROW; /* pointer to one row of difference values */
+typedef JDIFFROW *JDIFFARRAY; /* ptr to some rows (a 2-D diff array) */
+typedef JDIFFARRAY *JDIFFIMAGE; /* a 3-D diff array: top index is color */
+
+
+/* Declarations for both compression & decompression */
+
+typedef enum { /* Operating modes for buffer controllers */
+ JBUF_PASS_THRU, /* Plain stripwise operation */
+ /* Remaining modes require a full-image buffer to have been created */
+ JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
+ JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
+ JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
+} J_BUF_MODE;
+
+/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
+#define CSTATE_START 100 /* after create_compress */
+#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
+#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
+#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
+#define DSTATE_START 200 /* after create_decompress */
+#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
+#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
+#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
+#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
+#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
+#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
+#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
+#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
+#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
+#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
+
+
+/* JLONG must hold at least signed 32-bit values. */
+typedef long JLONG;
+
+/* JUINTPTR must hold pointer values. */
+#ifdef __UINTPTR_TYPE__
+/*
+ * __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+.
+ * Fortunately, that is sufficient to support the few architectures for which
+ * sizeof(void *) != sizeof(size_t). The only other options would require C99
+ * or Clang-specific builtins.
+ */
+typedef __UINTPTR_TYPE__ JUINTPTR;
+#else
+typedef size_t JUINTPTR;
+#endif
+
+#define IsExtRGB(cs) \
+ (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
+
+/*
+ * Left shift macro that handles a negative operand without causing any
+ * sanitizer warnings
+ */
+
+#define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b)))
+
+
+/* Declarations for compression modules */
+
+/* Master control module */
+struct jpeg_comp_master {
+ void (*prepare_for_pass) (j_compress_ptr cinfo);
+ void (*pass_startup) (j_compress_ptr cinfo);
+ void (*finish_pass) (j_compress_ptr cinfo);
+
+ /* State variables made visible to other modules */
+ boolean call_pass_startup; /* True if pass_startup must be called */
+ boolean is_last_pass; /* True during last pass */
+ boolean lossless; /* True if lossless mode is enabled */
+};
+
+/* Main buffer control (downsampled-data buffer) */
+struct jpeg_c_main_controller {
+ void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
+ void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
+ JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
+ void (*process_data_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf,
+ JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
+#ifdef C_LOSSLESS_SUPPORTED
+ void (*process_data_16) (j_compress_ptr cinfo, J16SAMPARRAY input_buf,
+ JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
+#endif
+};
+
+/* Compression preprocessing (downsampling input buffer control) */
+struct jpeg_c_prep_controller {
+ void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
+ void (*pre_process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
+ JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
+ JSAMPIMAGE output_buf,
+ JDIMENSION *out_row_group_ctr,
+ JDIMENSION out_row_groups_avail);
+ void (*pre_process_data_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf,
+ JDIMENSION *in_row_ctr,
+ JDIMENSION in_rows_avail,
+ J12SAMPIMAGE output_buf,
+ JDIMENSION *out_row_group_ctr,
+ JDIMENSION out_row_groups_avail);
+#ifdef C_LOSSLESS_SUPPORTED
+ void (*pre_process_data_16) (j_compress_ptr cinfo, J16SAMPARRAY input_buf,
+ JDIMENSION *in_row_ctr,
+ JDIMENSION in_rows_avail,
+ J16SAMPIMAGE output_buf,
+ JDIMENSION *out_row_group_ctr,
+ JDIMENSION out_row_groups_avail);
+#endif
+};
+
+/* Lossy mode: Coefficient buffer control
+ * Lossless mode: Difference buffer control
+ */
+struct jpeg_c_coef_controller {
+ void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
+ boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf);
+ boolean (*compress_data_12) (j_compress_ptr cinfo, J12SAMPIMAGE input_buf);
+#ifdef C_LOSSLESS_SUPPORTED
+ boolean (*compress_data_16) (j_compress_ptr cinfo, J16SAMPIMAGE input_buf);
+#endif
+};
+
+/* Colorspace conversion */
+struct jpeg_color_converter {
+ void (*start_pass) (j_compress_ptr cinfo);
+ void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
+ JSAMPIMAGE output_buf, JDIMENSION output_row,
+ int num_rows);
+ void (*color_convert_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf,
+ J12SAMPIMAGE output_buf, JDIMENSION output_row,
+ int num_rows);
+#ifdef C_LOSSLESS_SUPPORTED
+ void (*color_convert_16) (j_compress_ptr cinfo, J16SAMPARRAY input_buf,
+ J16SAMPIMAGE output_buf, JDIMENSION output_row,
+ int num_rows);
+#endif
+};
+
+/* Downsampling */
+struct jpeg_downsampler {
+ void (*start_pass) (j_compress_ptr cinfo);
+ void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf,
+ JDIMENSION in_row_index, JSAMPIMAGE output_buf,
+ JDIMENSION out_row_group_index);
+ void (*downsample_12) (j_compress_ptr cinfo, J12SAMPIMAGE input_buf,
+ JDIMENSION in_row_index, J12SAMPIMAGE output_buf,
+ JDIMENSION out_row_group_index);
+#ifdef C_LOSSLESS_SUPPORTED
+ void (*downsample_16) (j_compress_ptr cinfo, J16SAMPIMAGE input_buf,
+ JDIMENSION in_row_index, J16SAMPIMAGE output_buf,
+ JDIMENSION out_row_group_index);
+#endif
+
+ boolean need_context_rows; /* TRUE if need rows above & below */
+};
+
+/* Lossy mode: Forward DCT (also controls coefficient quantization)
+ * Lossless mode: Prediction, sample differencing, and point transform
+ */
+struct jpeg_forward_dct {
+ void (*start_pass) (j_compress_ptr cinfo);
+
+ /* Lossy mode */
+ /* perhaps this should be an array??? */
+ void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
+ JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
+ JDIMENSION start_row, JDIMENSION start_col,
+ JDIMENSION num_blocks);
+ void (*forward_DCT_12) (j_compress_ptr cinfo, jpeg_component_info *compptr,
+ J12SAMPARRAY sample_data, JBLOCKROW coef_blocks,
+ JDIMENSION start_row, JDIMENSION start_col,
+ JDIMENSION num_blocks);
+};
+
+/* Entropy encoding */
+struct jpeg_entropy_encoder {
+ void (*start_pass) (j_compress_ptr cinfo, boolean gather_statistics);
+
+ /* Lossy mode */
+ boolean (*encode_mcu) (j_compress_ptr cinfo, JBLOCKROW *MCU_data);
+ /* Lossless mode */
+ JDIMENSION (*encode_mcus) (j_compress_ptr cinfo, JDIFFIMAGE diff_buf,
+ JDIMENSION MCU_row_num, JDIMENSION MCU_col_num,
+ JDIMENSION nMCU);
+
+ void (*finish_pass) (j_compress_ptr cinfo);
+};
+
+/* Marker writing */
+struct jpeg_marker_writer {
+ void (*write_file_header) (j_compress_ptr cinfo);
+ void (*write_frame_header) (j_compress_ptr cinfo);
+ void (*write_scan_header) (j_compress_ptr cinfo);
+ void (*write_file_trailer) (j_compress_ptr cinfo);
+ void (*write_tables_only) (j_compress_ptr cinfo);
+ /* These routines are exported to allow insertion of extra markers */
+ /* Probably only COM and APPn markers should be written this way */
+ void (*write_marker_header) (j_compress_ptr cinfo, int marker,
+ unsigned int datalen);
+ void (*write_marker_byte) (j_compress_ptr cinfo, int val);
+};
+
+
+/* Declarations for decompression modules */
+
+/* Master control module */
+struct jpeg_decomp_master {
+ void (*prepare_for_output_pass) (j_decompress_ptr cinfo);
+ void (*finish_output_pass) (j_decompress_ptr cinfo);
+
+ /* State variables made visible to other modules */
+ boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */
+ boolean lossless; /* True if decompressing a lossless image */
+
+ /* Partial decompression variables */
+ JDIMENSION first_iMCU_col;
+ JDIMENSION last_iMCU_col;
+ JDIMENSION first_MCU_col[MAX_COMPONENTS];
+ JDIMENSION last_MCU_col[MAX_COMPONENTS];
+ boolean jinit_upsampler_no_alloc;
+
+ /* Last iMCU row that was successfully decoded */
+ JDIMENSION last_good_iMCU_row;
+
+ /* Tail of list of saved markers */
+ jpeg_saved_marker_ptr marker_list_end;
+};
+
+/* Input control module */
+struct jpeg_input_controller {
+ int (*consume_input) (j_decompress_ptr cinfo);
+ void (*reset_input_controller) (j_decompress_ptr cinfo);
+ void (*start_input_pass) (j_decompress_ptr cinfo);
+ void (*finish_input_pass) (j_decompress_ptr cinfo);
+
+ /* State variables made visible to other modules */
+ boolean has_multiple_scans; /* True if file has multiple scans */
+ boolean eoi_reached; /* True when EOI has been consumed */
+};
+
+/* Main buffer control (downsampled-data buffer) */
+struct jpeg_d_main_controller {
+ void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
+ void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
+ void (*process_data_12) (j_decompress_ptr cinfo, J12SAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
+#ifdef D_LOSSLESS_SUPPORTED
+ void (*process_data_16) (j_decompress_ptr cinfo, J16SAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
+#endif
+};
+
+/* Lossy mode: Coefficient buffer control
+ * Lossless mode: Difference buffer control
+ */
+struct jpeg_d_coef_controller {
+ void (*start_input_pass) (j_decompress_ptr cinfo);
+ int (*consume_data) (j_decompress_ptr cinfo);
+ void (*start_output_pass) (j_decompress_ptr cinfo);
+ int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
+ int (*decompress_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE output_buf);
+#ifdef D_LOSSLESS_SUPPORTED
+ int (*decompress_data_16) (j_decompress_ptr cinfo, J16SAMPIMAGE output_buf);
+#endif
+
+ /* These variables keep track of the current location of the input side. */
+ /* cinfo->input_iMCU_row is also used for this. */
+ JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
+ int MCU_vert_offset; /* counts MCU rows within iMCU row */
+ int MCU_rows_per_iMCU_row; /* number of such rows needed */
+
+ /* The output side's location is represented by cinfo->output_iMCU_row. */
+
+ /* Lossy mode */
+ /* Pointer to array of coefficient virtual arrays, or NULL if none */
+ jvirt_barray_ptr *coef_arrays;
+};
+
+/* Decompression postprocessing (color quantization buffer control) */
+struct jpeg_d_post_controller {
+ void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
+ void (*post_process_data) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail,
+ JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
+ JDIMENSION out_rows_avail);
+ void (*post_process_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail,
+ J12SAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr,
+ JDIMENSION out_rows_avail);
+#ifdef D_LOSSLESS_SUPPORTED
+ void (*post_process_data_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail,
+ J16SAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr,
+ JDIMENSION out_rows_avail);
+#endif
+};
+
+/* Marker reading & parsing */
+struct jpeg_marker_reader {
+ void (*reset_marker_reader) (j_decompress_ptr cinfo);
+ /* Read markers until SOS or EOI.
+ * Returns same codes as are defined for jpeg_consume_input:
+ * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
+ */
+ int (*read_markers) (j_decompress_ptr cinfo);
+ /* Read a restart marker --- exported for use by entropy decoder only */
+ jpeg_marker_parser_method read_restart_marker;
+
+ /* State of marker reader --- nominally internal, but applications
+ * supplying COM or APPn handlers might like to know the state.
+ */
+ boolean saw_SOI; /* found SOI? */
+ boolean saw_SOF; /* found SOF? */
+ int next_restart_num; /* next restart number expected (0-7) */
+ unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
+};
+
+/* Entropy decoding */
+struct jpeg_entropy_decoder {
+ void (*start_pass) (j_decompress_ptr cinfo);
+
+ /* Lossy mode */
+ boolean (*decode_mcu) (j_decompress_ptr cinfo, JBLOCKROW *MCU_data);
+ /* Lossless mode */
+ JDIMENSION (*decode_mcus) (j_decompress_ptr cinfo, JDIFFIMAGE diff_buf,
+ JDIMENSION MCU_row_num, JDIMENSION MCU_col_num,
+ JDIMENSION nMCU);
+ boolean (*process_restart) (j_decompress_ptr cinfo);
+
+ /* This is here to share code between baseline and progressive decoders; */
+ /* other modules probably should not use it */
+ boolean insufficient_data; /* set TRUE after emitting warning */
+};
+
+/* Lossy mode: Inverse DCT (also performs dequantization)
+ * Lossless mode: Prediction, sample undifferencing, point transform, and
+ * sample size scaling
+ */
+typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block,
+ JSAMPARRAY output_buf,
+ JDIMENSION output_col);
+typedef void (*inverse_DCT_12_method_ptr) (j_decompress_ptr cinfo,
+ jpeg_component_info *compptr,
+ JCOEFPTR coef_block,
+ J12SAMPARRAY output_buf,
+ JDIMENSION output_col);
+
+struct jpeg_inverse_dct {
+ void (*start_pass) (j_decompress_ptr cinfo);
+
+ /* Lossy mode */
+ /* It is useful to allow each component to have a separate IDCT method. */
+ inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
+ inverse_DCT_12_method_ptr inverse_DCT_12[MAX_COMPONENTS];
+};
+
+/* Upsampling (note that upsampler must also call color converter) */
+struct jpeg_upsampler {
+ void (*start_pass) (j_decompress_ptr cinfo);
+ void (*upsample) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
+ void (*upsample_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail, J12SAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
+#ifdef D_LOSSLESS_SUPPORTED
+ void (*upsample_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf,
+ JDIMENSION *in_row_group_ctr,
+ JDIMENSION in_row_groups_avail, J16SAMPARRAY output_buf,
+ JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
+#endif
+
+ boolean need_context_rows; /* TRUE if need rows above & below */
+};
+
+/* Colorspace conversion */
+struct jpeg_color_deconverter {
+ void (*start_pass) (j_decompress_ptr cinfo);
+ void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
+ JDIMENSION input_row, JSAMPARRAY output_buf,
+ int num_rows);
+ void (*color_convert_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
+ JDIMENSION input_row, J12SAMPARRAY output_buf,
+ int num_rows);
+#ifdef D_LOSSLESS_SUPPORTED
+ void (*color_convert_16) (j_decompress_ptr cinfo, J16SAMPIMAGE input_buf,
+ JDIMENSION input_row, J16SAMPARRAY output_buf,
+ int num_rows);
+#endif
+};
+
+/* Color quantization or color precision reduction */
+struct jpeg_color_quantizer {
+ void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
+ void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
+ JSAMPARRAY output_buf, int num_rows);
+ void (*color_quantize_12) (j_decompress_ptr cinfo, J12SAMPARRAY input_buf,
+ J12SAMPARRAY output_buf, int num_rows);
+ void (*finish_pass) (j_decompress_ptr cinfo);
+ void (*new_color_map) (j_decompress_ptr cinfo);
+};
+
+
+/* Miscellaneous useful macros */
+
+#undef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#undef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+#ifdef ZERO_BUFFERS
+#define MALLOC(size) calloc(1, size)
+#else
+#define MALLOC(size) malloc(size)
+#endif
+
+
+/* We assume that right shift corresponds to signed division by 2 with
+ * rounding towards minus infinity. This is correct for typical "arithmetic
+ * shift" instructions that shift in copies of the sign bit. But some
+ * C compilers implement >> with an unsigned shift. For these machines you
+ * must define RIGHT_SHIFT_IS_UNSIGNED.
+ * RIGHT_SHIFT provides a proper signed right shift of a JLONG quantity.
+ * It is only applied with constant shift counts. SHIFT_TEMPS must be
+ * included in the variables of any routine using RIGHT_SHIFT.
+ */
+
+#ifdef RIGHT_SHIFT_IS_UNSIGNED
+#define SHIFT_TEMPS JLONG shift_temp;
+#define RIGHT_SHIFT(x, shft) \
+ ((shift_temp = (x)) < 0 ? \
+ (shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
+ (shift_temp >> (shft)))
+#else
+#define SHIFT_TEMPS
+#define RIGHT_SHIFT(x, shft) ((x) >> (shft))
+#endif
+
+
+/* Compression module initialization routines */
+EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
+EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
+ boolean transcode_only);
+EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_c_main_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_c_prep_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_c_coef_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
+EXTERN(void) j12init_color_converter(j_compress_ptr cinfo);
+EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
+EXTERN(void) j12init_downsampler(j_compress_ptr cinfo);
+EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
+EXTERN(void) j12init_forward_dct(j_compress_ptr cinfo);
+EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
+EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
+EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
+EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
+#ifdef C_LOSSLESS_SUPPORTED
+EXTERN(void) j16init_c_main_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j16init_c_prep_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j16init_color_converter(j_compress_ptr cinfo);
+EXTERN(void) j16init_downsampler(j_compress_ptr cinfo);
+EXTERN(void) jinit_c_diff_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_c_diff_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j16init_c_diff_controller(j_compress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_lhuff_encoder(j_compress_ptr cinfo);
+EXTERN(void) jinit_lossless_compressor(j_compress_ptr cinfo);
+EXTERN(void) j12init_lossless_compressor(j_compress_ptr cinfo);
+EXTERN(void) j16init_lossless_compressor(j_compress_ptr cinfo);
+#endif
+
+/* Decompression module initialization routines */
+EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
+EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_d_main_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_d_coef_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_d_post_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
+EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
+EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
+EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
+EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
+EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
+EXTERN(void) j12init_inverse_dct(j_decompress_ptr cinfo);
+EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
+EXTERN(void) j12init_upsampler(j_decompress_ptr cinfo);
+EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
+EXTERN(void) j12init_color_deconverter(j_decompress_ptr cinfo);
+EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
+EXTERN(void) j12init_1pass_quantizer(j_decompress_ptr cinfo);
+EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
+EXTERN(void) j12init_2pass_quantizer(j_decompress_ptr cinfo);
+EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
+EXTERN(void) j12init_merged_upsampler(j_decompress_ptr cinfo);
+#ifdef D_LOSSLESS_SUPPORTED
+EXTERN(void) j16init_d_main_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j16init_d_post_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j16init_upsampler(j_decompress_ptr cinfo);
+EXTERN(void) j16init_color_deconverter(j_decompress_ptr cinfo);
+EXTERN(void) jinit_d_diff_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j12init_d_diff_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) j16init_d_diff_controller(j_decompress_ptr cinfo,
+ boolean need_full_buffer);
+EXTERN(void) jinit_lhuff_decoder(j_decompress_ptr cinfo);
+EXTERN(void) jinit_lossless_decompressor(j_decompress_ptr cinfo);
+EXTERN(void) j12init_lossless_decompressor(j_decompress_ptr cinfo);
+EXTERN(void) j16init_lossless_decompressor(j_decompress_ptr cinfo);
+#endif
+
+/* Memory manager initialization */
+EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
+
+/* Utility routines in jutils.c */
+EXTERN(long) jdiv_round_up(long a, long b);
+EXTERN(long) jround_up(long a, long b);
+EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
+ JSAMPARRAY output_array, int dest_row,
+ int num_rows, JDIMENSION num_cols);
+EXTERN(void) j12copy_sample_rows(J12SAMPARRAY input_array, int source_row,
+ J12SAMPARRAY output_array, int dest_row,
+ int num_rows, JDIMENSION num_cols);
+#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
+EXTERN(void) j16copy_sample_rows(J16SAMPARRAY input_array, int source_row,
+ J16SAMPARRAY output_array, int dest_row,
+ int num_rows, JDIMENSION num_cols);
+#endif
+EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
+ JDIMENSION num_blocks);
+EXTERN(void) jzero_far(void *target, size_t bytestozero);
+/* Constant tables in jutils.c */
+#if 0 /* This table is not actually needed in v6a */
+extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
+#endif
+extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
+
+/* Arithmetic coding probability estimation tables in jaricom.c */
+extern const JLONG jpeg_aritab[];
diff --git a/contrib/libs/libjpeg-turbo/src/jpeglib.h b/contrib/libs/libjpeg-turbo/src/jpeglib.h
new file mode 100644
index 00000000000..f7076a18d01
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jpeglib.h
@@ -0,0 +1,1223 @@
+/*
+ * jpeglib.h
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1991-1998, Thomas G. Lane.
+ * Modified 2002-2009 by Guido Vollbeding.
+ * Lossless JPEG Modifications:
+ * Copyright (C) 1999, Ken Murchison.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, 2022-2024,
+ D. R. Commander.
+ * Copyright (C) 2015, Google, Inc.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file defines the application interface for the JPEG library.
+ * Most applications using the library need only include this file,
+ * and perhaps jerror.h if they want to know the exact error codes.
+ */
+
+/* NOTE: This header file does not include stdio.h, despite the fact that it
+ * uses FILE and size_t. That is by design, since the libjpeg API predates the
+ * widespread adoption of ANSI/ISO C. Referring to libjpeg.txt, it is a
+ * documented requirement that calling programs "include system headers that
+ * define at least the typedefs FILE and size_t" before including jpeglib.h.
+ * Technically speaking, changing that requirement by including stdio.h here
+ * would break backward API compatibility. Please do not file bug reports,
+ * feature requests, or pull requests regarding this.
+ */
+
+#ifndef JPEGLIB_H
+#define JPEGLIB_H
+
+/*
+ * First we include the configuration files that record how this
+ * installation of the JPEG library is set up. jconfig.h can be
+ * generated automatically for many systems. jmorecfg.h contains
+ * manual configuration options that most people need not worry about.
+ */
+
+#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
+#include "jconfig.h" /* widely used configuration options */
+#endif
+#include "jmorecfg.h" /* seldom changed options */
+
+
+#ifdef __cplusplus
+#ifndef DONT_USE_EXTERN_C
+extern "C" {
+#endif
+#endif
+
+
+/* Various constants determining the sizes of things.
+ * All of these are specified by the JPEG standard, so don't change them
+ * if you want to be compatible.
+ */
+
+/* NOTE: In lossless mode, an MCU contains one or more samples rather than one
+ * or more 8x8 DCT blocks, so the term "data unit" is used to generically
+ * describe a sample in lossless mode or an 8x8 DCT block in lossy mode. To
+ * preserve backward API/ABI compatibility, the field and macro names retain
+ * the "block" terminology.
+ */
+
+#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
+#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
+#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
+#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
+#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
+#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
+#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
+/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
+ * the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
+ * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
+ * to handle it. We even let you do this from the jconfig.h file. However,
+ * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe
+ * sometimes emits noncompliant files doesn't mean you should too.
+ */
+#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on data units/MCU */
+#ifndef D_MAX_BLOCKS_IN_MCU
+#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on data units/MCU */
+#endif
+
+
+/* Data structures for images (arrays of samples and of DCT coefficients).
+ */
+
+typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples with
+ 2-bit through 8-bit data precision. */
+typedef JSAMPROW *JSAMPARRAY; /* ptr to some JSAMPLE rows (a 2-D JSAMPLE
+ array) */
+typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D JSAMPLE array: top index is color */
+
+typedef J12SAMPLE *J12SAMPROW; /* ptr to one image row of pixel samples
+ with 9-bit through 12-bit data
+ precision. */
+typedef J12SAMPROW *J12SAMPARRAY; /* ptr to some J12SAMPLE rows (a 2-D
+ J12SAMPLE array) */
+typedef J12SAMPARRAY *J12SAMPIMAGE; /* a 3-D J12SAMPLE array: top index is
+ color */
+
+typedef J16SAMPLE *J16SAMPROW; /* ptr to one image row of pixel samples
+ with 13-bit through 16-bit data
+ precision. */
+typedef J16SAMPROW *J16SAMPARRAY; /* ptr to some J16SAMPLE rows (a 2-D
+ J16SAMPLE array) */
+typedef J16SAMPARRAY *J16SAMPIMAGE; /* a 3-D J16SAMPLE array: top index is
+ color */
+
+typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
+typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
+typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
+typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
+
+typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
+
+
+/* Types for JPEG compression parameters and working tables. */
+
+
+/* DCT coefficient quantization tables. */
+
+typedef struct {
+ /* This array gives the coefficient quantizers in natural array order
+ * (not the zigzag order in which they are stored in a JPEG DQT marker).
+ * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
+ */
+ UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
+ /* This field is used only during compression. It's initialized FALSE when
+ * the table is created, and set TRUE when it's been output to the file.
+ * You could suppress output of a table by setting this to TRUE.
+ * (See jpeg_suppress_tables for an example.)
+ */
+ boolean sent_table; /* TRUE when table has been output */
+} JQUANT_TBL;
+
+
+/* Huffman coding tables. */
+
+typedef struct {
+ /* These two fields directly represent the contents of a JPEG DHT marker */
+ UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
+ /* length k bits; bits[0] is unused */
+ UINT8 huffval[256]; /* The symbols, in order of incr code length */
+ /* This field is used only during compression. It's initialized FALSE when
+ * the table is created, and set TRUE when it's been output to the file.
+ * You could suppress output of a table by setting this to TRUE.
+ * (See jpeg_suppress_tables for an example.)
+ */
+ boolean sent_table; /* TRUE when table has been output */
+} JHUFF_TBL;
+
+
+/* Basic info about one component (color channel). */
+
+typedef struct {
+ /* These values are fixed over the whole image. */
+ /* For compression, they must be supplied by parameter setup; */
+ /* for decompression, they are read from the SOF marker. */
+ int component_id; /* identifier for this component (0..255) */
+ int component_index; /* its index in SOF or cinfo->comp_info[] */
+ int h_samp_factor; /* horizontal sampling factor (1..4) */
+ int v_samp_factor; /* vertical sampling factor (1..4) */
+ int quant_tbl_no; /* quantization table selector (0..3) */
+ /* These values may vary between scans. */
+ /* For compression, they must be supplied by parameter setup; */
+ /* for decompression, they are read from the SOS marker. */
+ /* The decompressor output side may not use these variables. */
+ int dc_tbl_no; /* DC entropy table selector (0..3) */
+ int ac_tbl_no; /* AC entropy table selector (0..3) */
+
+ /* Remaining fields should be treated as private by applications. */
+
+ /* These values are computed during compression or decompression startup: */
+ /* Component's size in data units.
+ * In lossy mode, any dummy blocks added to complete an MCU are not counted;
+ * therefore these values do not depend on whether a scan is interleaved or
+ * not. In lossless mode, these are always equal to the image width and
+ * height.
+ */
+ JDIMENSION width_in_blocks;
+ JDIMENSION height_in_blocks;
+ /* Size of a data unit in samples. Always DCTSIZE for lossy compression.
+ * For lossy decompression this is the size of the output from one DCT block,
+ * reflecting any scaling we choose to apply during the IDCT step.
+ * Values from 1 to 16 are supported. Note that different components may
+ * receive different IDCT scalings. In lossless mode, this is always equal
+ * to 1.
+ */
+#if JPEG_LIB_VERSION >= 70
+ int DCT_h_scaled_size;
+ int DCT_v_scaled_size;
+#else
+ int DCT_scaled_size;
+#endif
+ /* The downsampled dimensions are the component's actual, unpadded number
+ * of samples at the main buffer (preprocessing/compression interface), thus
+ * downsampled_width = ceil(image_width * Hi/Hmax)
+ * and similarly for height. For lossy decompression, IDCT scaling is
+ * included, so
+ * downsampled_width = ceil(image_width * Hi/Hmax * DCT_[h_]scaled_size/DCTSIZE)
+ * In lossless mode, these are always equal to the image width and height.
+ */
+ JDIMENSION downsampled_width; /* actual width in samples */
+ JDIMENSION downsampled_height; /* actual height in samples */
+ /* This flag is used only for decompression. In cases where some of the
+ * components will be ignored (eg grayscale output from YCbCr image),
+ * we can skip most computations for the unused components.
+ */
+ boolean component_needed; /* do we need the value of this component? */
+
+ /* These values are computed before starting a scan of the component. */
+ /* The decompressor output side may not use these variables. */
+ int MCU_width; /* number of data units per MCU, horizontally */
+ int MCU_height; /* number of data units per MCU, vertically */
+ int MCU_blocks; /* MCU_width * MCU_height */
+ int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
+ int last_col_width; /* # of non-dummy data units across in last MCU */
+ int last_row_height; /* # of non-dummy data units down in last MCU */
+
+ /* Saved quantization table for component; NULL if none yet saved.
+ * See jdinput.c comments about the need for this information.
+ * This field is currently used only for decompression.
+ */
+ JQUANT_TBL *quant_table;
+
+ /* Private per-component storage for DCT or IDCT subsystem. */
+ void *dct_table;
+} jpeg_component_info;
+
+
+/* The script for encoding a multiple-scan file is an array of these: */
+
+typedef struct {
+ int comps_in_scan; /* number of components encoded in this scan */
+ int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
+ int Ss, Se; /* progressive JPEG spectral selection parms
+ (Ss is the predictor selection value in
+ lossless mode) */
+ int Ah, Al; /* progressive JPEG successive approx. parms
+ (Al is the point transform value in lossless
+ mode) */
+} jpeg_scan_info;
+
+/* The decompressor can save APPn and COM markers in a list of these: */
+
+typedef struct jpeg_marker_struct *jpeg_saved_marker_ptr;
+
+struct jpeg_marker_struct {
+ jpeg_saved_marker_ptr next; /* next in list, or NULL */
+ UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
+ unsigned int original_length; /* # bytes of data in the file */
+ unsigned int data_length; /* # bytes of data saved at data[] */
+ JOCTET *data; /* the data contained in the marker */
+ /* the marker length word is not counted in data_length or original_length */
+};
+
+/* Known color spaces. */
+
+#define JCS_EXTENSIONS 1
+#define JCS_ALPHA_EXTENSIONS 1
+
+typedef enum {
+ JCS_UNKNOWN, /* error/unspecified */
+ JCS_GRAYSCALE, /* monochrome */
+ JCS_RGB, /* red/green/blue as specified by the RGB_RED,
+ RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros */
+ JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
+ JCS_CMYK, /* C/M/Y/K */
+ JCS_YCCK, /* Y/Cb/Cr/K */
+ JCS_EXT_RGB, /* red/green/blue */
+ JCS_EXT_RGBX, /* red/green/blue/x */
+ JCS_EXT_BGR, /* blue/green/red */
+ JCS_EXT_BGRX, /* blue/green/red/x */
+ JCS_EXT_XBGR, /* x/blue/green/red */
+ JCS_EXT_XRGB, /* x/red/green/blue */
+ /* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
+ or JCS_EXT_XRGB during decompression, the X byte is undefined, and in
+ order to ensure the best performance, libjpeg-turbo can set that byte to
+ whatever value it wishes. Use the following colorspace constants to
+ ensure that the X byte is set to 0xFF, so that it can be interpreted as an
+ opaque alpha channel. */
+ JCS_EXT_RGBA, /* red/green/blue/alpha */
+ JCS_EXT_BGRA, /* blue/green/red/alpha */
+ JCS_EXT_ABGR, /* alpha/blue/green/red */
+ JCS_EXT_ARGB, /* alpha/red/green/blue */
+ JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue
+ [decompression only] */
+} J_COLOR_SPACE;
+
+/* DCT/IDCT algorithm options. */
+
+typedef enum {
+ JDCT_ISLOW, /* accurate integer method */
+ JDCT_IFAST, /* less accurate integer method [legacy feature] */
+ JDCT_FLOAT /* floating-point method [legacy feature] */
+} J_DCT_METHOD;
+
+#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
+#define JDCT_DEFAULT JDCT_ISLOW
+#endif
+#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
+#define JDCT_FASTEST JDCT_IFAST
+#endif
+
+/* Dithering options for decompression. */
+
+typedef enum {
+ JDITHER_NONE, /* no dithering */
+ JDITHER_ORDERED, /* simple ordered dither */
+ JDITHER_FS /* Floyd-Steinberg error diffusion dither */
+} J_DITHER_MODE;
+
+
+/* Common fields between JPEG compression and decompression master structs. */
+
+#define jpeg_common_fields \
+ struct jpeg_error_mgr *err; /* Error handler module */ \
+ struct jpeg_memory_mgr *mem; /* Memory manager module */ \
+ struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */ \
+ void *client_data; /* Available for use by application */ \
+ boolean is_decompressor; /* So common code can tell which is which */ \
+ int global_state /* For checking call sequence validity */
+
+/* Routines that are to be used by both halves of the library are declared
+ * to receive a pointer to this structure. There are no actual instances of
+ * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.
+ */
+struct jpeg_common_struct {
+ jpeg_common_fields; /* Fields common to both master struct types */
+ /* Additional fields follow in an actual jpeg_compress_struct or
+ * jpeg_decompress_struct. All three structs must agree on these
+ * initial fields! (This would be a lot cleaner in C++.)
+ */
+};
+
+typedef struct jpeg_common_struct *j_common_ptr;
+typedef struct jpeg_compress_struct *j_compress_ptr;
+typedef struct jpeg_decompress_struct *j_decompress_ptr;
+
+
+/* Master record for a compression instance */
+
+struct jpeg_compress_struct {
+ jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
+
+ /* Destination for compressed data */
+ struct jpeg_destination_mgr *dest;
+
+ /* Description of source image --- these fields must be filled in by
+ * outer application before starting compression. in_color_space must
+ * be correct before you can even call jpeg_set_defaults().
+ */
+
+ JDIMENSION image_width; /* input image width */
+ JDIMENSION image_height; /* input image height */
+ int input_components; /* # of color components in input image */
+ J_COLOR_SPACE in_color_space; /* colorspace of input image */
+
+ double input_gamma; /* image gamma of input image */
+
+ /* Compression parameters --- these fields must be set before calling
+ * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
+ * initialize everything to reasonable defaults, then changing anything
+ * the application specifically wants to change. That way you won't get
+ * burnt when new parameters are added. Also note that there are several
+ * helper routines to simplify changing parameters.
+ */
+
+#if JPEG_LIB_VERSION >= 70
+ unsigned int scale_num, scale_denom; /* fraction by which to scale image */
+
+ JDIMENSION jpeg_width; /* scaled JPEG image width */
+ JDIMENSION jpeg_height; /* scaled JPEG image height */
+ /* Dimensions of actual JPEG image that will be written to file,
+ * derived from input dimensions by scaling factors above.
+ * These fields are computed by jpeg_start_compress().
+ * You can also use jpeg_calc_jpeg_dimensions() to determine these values
+ * in advance of calling jpeg_start_compress().
+ */
+#endif
+
+ int data_precision; /* bits of precision in image data */
+
+ int num_components; /* # of color components in JPEG image */
+ J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
+
+ jpeg_component_info *comp_info;
+ /* comp_info[i] describes component that appears i'th in SOF */
+
+ JQUANT_TBL *quant_tbl_ptrs[NUM_QUANT_TBLS];
+#if JPEG_LIB_VERSION >= 70
+ int q_scale_factor[NUM_QUANT_TBLS];
+#endif
+ /* ptrs to coefficient quantization tables, or NULL if not defined,
+ * and corresponding scale factors (percentage, initialized 100).
+ */
+
+ JHUFF_TBL *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ JHUFF_TBL *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ /* ptrs to Huffman coding tables, or NULL if not defined */
+
+ UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+ UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+ UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+ int num_scans; /* # of entries in scan_info array */
+ const jpeg_scan_info *scan_info; /* script for multi-scan file, or NULL */
+ /* The default value of scan_info is NULL, which causes a single-scan
+ * sequential JPEG file to be emitted. To create a multi-scan file,
+ * set num_scans and scan_info to point to an array of scan definitions.
+ */
+
+ boolean raw_data_in; /* TRUE=caller supplies downsampled data */
+ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
+ boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
+ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
+#if JPEG_LIB_VERSION >= 70
+ boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
+#endif
+ int smoothing_factor; /* 1..100, or 0 for no input smoothing */
+ J_DCT_METHOD dct_method; /* DCT algorithm selector */
+
+ /* The restart interval can be specified in absolute MCUs by setting
+ * restart_interval, or in MCU rows by setting restart_in_rows
+ * (in which case the correct restart_interval will be figured
+ * for each scan).
+ */
+ unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
+ int restart_in_rows; /* if > 0, MCU rows per restart interval */
+
+ /* Parameters controlling emission of special markers. */
+
+ boolean write_JFIF_header; /* should a JFIF marker be written? */
+ UINT8 JFIF_major_version; /* What to write for the JFIF version number */
+ UINT8 JFIF_minor_version;
+ /* These three values are not used by the JPEG code, merely copied */
+ /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
+ /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */
+ /* ratio is defined by X_density/Y_density even when density_unit=0. */
+ UINT8 density_unit; /* JFIF code for pixel size units */
+ UINT16 X_density; /* Horizontal pixel density */
+ UINT16 Y_density; /* Vertical pixel density */
+ boolean write_Adobe_marker; /* should an Adobe marker be written? */
+
+ /* State variable: index of next scanline to be written to
+ * jpeg_write_scanlines(). Application may use this to control its
+ * processing loop, e.g., "while (next_scanline < image_height)".
+ */
+
+ JDIMENSION next_scanline; /* 0 .. image_height-1 */
+
+ /* Remaining fields are known throughout compressor, but generally
+ * should not be touched by a surrounding application.
+ */
+
+ /*
+ * These fields are computed during compression startup
+ */
+ boolean progressive_mode; /* TRUE if scan script uses progressive mode */
+ int max_h_samp_factor; /* largest h_samp_factor */
+ int max_v_samp_factor; /* largest v_samp_factor */
+
+#if JPEG_LIB_VERSION >= 70
+ int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
+ int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
+#endif
+
+ JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coefficient or
+ difference controller */
+ /* The coefficient or difference controller receives data in units of MCU
+ * rows as defined for fully interleaved scans (whether the JPEG file is
+ * interleaved or not). In lossy mode, there are v_samp_factor * DCTSIZE
+ * sample rows of each component in an "iMCU" (interleaved MCU) row. In
+ * lossless mode, total_iMCU_rows is always equal to the image height.
+ */
+
+ /*
+ * These fields are valid during any one scan.
+ * They describe the components and MCUs actually appearing in the scan.
+ */
+ int comps_in_scan; /* # of JPEG components in this scan */
+ jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
+ /* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+ JDIMENSION MCUs_per_row; /* # of MCUs across the image */
+ JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
+
+ int blocks_in_MCU; /* # of data units per MCU */
+ int MCU_membership[C_MAX_BLOCKS_IN_MCU];
+ /* MCU_membership[i] is index in cur_comp_info of component owning */
+ /* i'th data unit in an MCU */
+
+ int Ss, Se, Ah, Al; /* progressive/lossless JPEG parameters for
+ scan */
+
+#if JPEG_LIB_VERSION >= 80
+ int block_size; /* the basic DCT block size: 1..16 */
+ const int *natural_order; /* natural-order position array */
+ int lim_Se; /* min( Se, DCTSIZE2-1 ) */
+#endif
+
+ /*
+ * Links to compression subobjects (methods and private variables of modules)
+ */
+ struct jpeg_comp_master *master;
+ struct jpeg_c_main_controller *main;
+ struct jpeg_c_prep_controller *prep;
+ struct jpeg_c_coef_controller *coef;
+ struct jpeg_marker_writer *marker;
+ struct jpeg_color_converter *cconvert;
+ struct jpeg_downsampler *downsample;
+ struct jpeg_forward_dct *fdct;
+ struct jpeg_entropy_encoder *entropy;
+ jpeg_scan_info *script_space; /* workspace for jpeg_simple_progression */
+ int script_space_size;
+};
+
+
+/* Master record for a decompression instance */
+
+struct jpeg_decompress_struct {
+ jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
+
+ /* Source of compressed data */
+ struct jpeg_source_mgr *src;
+
+ /* Basic description of image --- filled in by jpeg_read_header(). */
+ /* Application may inspect these values to decide how to process image. */
+
+ JDIMENSION image_width; /* nominal image width (from SOF marker) */
+ JDIMENSION image_height; /* nominal image height */
+ int num_components; /* # of color components in JPEG image */
+ J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
+
+ /* Decompression processing parameters --- these fields must be set before
+ * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes
+ * them to default values.
+ */
+
+ J_COLOR_SPACE out_color_space; /* colorspace for output */
+
+ unsigned int scale_num, scale_denom; /* fraction by which to scale image */
+
+ double output_gamma; /* image gamma wanted in output */
+
+ boolean buffered_image; /* TRUE=multiple output passes */
+ boolean raw_data_out; /* TRUE=downsampled data wanted */
+
+ J_DCT_METHOD dct_method; /* IDCT algorithm selector */
+ boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
+ boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
+
+ boolean quantize_colors; /* TRUE=colormapped output wanted */
+ /* the following are ignored if not quantize_colors: */
+ J_DITHER_MODE dither_mode; /* type of color dithering to use */
+ boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
+ int desired_number_of_colors; /* max # colors to use in created colormap */
+ /* these are significant only in buffered-image mode: */
+ boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
+ boolean enable_external_quant;/* enable future use of external colormap */
+ boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
+
+ /* Description of actual output image that will be returned to application.
+ * These fields are computed by jpeg_start_decompress().
+ * You can also use jpeg_calc_output_dimensions() to determine these values
+ * in advance of calling jpeg_start_decompress().
+ */
+
+ JDIMENSION output_width; /* scaled image width */
+ JDIMENSION output_height; /* scaled image height */
+ int out_color_components; /* # of color components in out_color_space */
+ int output_components; /* # of color components returned */
+ /* output_components is 1 (a colormap index) when quantizing colors;
+ * otherwise it equals out_color_components.
+ */
+ int rec_outbuf_height; /* min recommended height of scanline buffer */
+ /* If the buffer passed to jpeg_read_scanlines() is less than this many rows
+ * high, space and time will be wasted due to unnecessary data copying.
+ * Usually rec_outbuf_height will be 1 or 2, at most 4.
+ */
+
+ /* When quantizing colors, the output colormap is described by these fields.
+ * The application can supply a colormap by setting colormap non-NULL before
+ * calling jpeg_start_decompress; otherwise a colormap is created during
+ * jpeg_start_decompress or jpeg_start_output.
+ * The map has out_color_components rows and actual_number_of_colors columns.
+ */
+ int actual_number_of_colors; /* number of entries in use */
+ JSAMPARRAY colormap; /* The color map as a 2-D pixel array
+ If data_precision is 12, then this is
+ actually a J12SAMPARRAY, so callers must
+ type-cast it in order to read/write 12-bit
+ samples from/to the array. */
+
+ /* State variables: these variables indicate the progress of decompression.
+ * The application may examine these but must not modify them.
+ */
+
+ /* Row index of next scanline to be read from jpeg_read_scanlines().
+ * Application may use this to control its processing loop, e.g.,
+ * "while (output_scanline < output_height)".
+ */
+ JDIMENSION output_scanline; /* 0 .. output_height-1 */
+
+ /* Current input scan number and number of iMCU rows completed in scan.
+ * These indicate the progress of the decompressor input side.
+ */
+ int input_scan_number; /* Number of SOS markers seen so far */
+ JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
+
+ /* The "output scan number" is the notional scan being displayed by the
+ * output side. The decompressor will not allow output scan/row number
+ * to get ahead of input scan/row, but it can fall arbitrarily far behind.
+ */
+ int output_scan_number; /* Nominal scan number being displayed */
+ JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
+
+ /* Current progression status. coef_bits[c][i] indicates the precision
+ * with which component c's DCT coefficient i (in zigzag order) is known.
+ * It is -1 when no data has yet been received, otherwise it is the point
+ * transform (shift) value for the most recent scan of the coefficient
+ * (thus, 0 at completion of the progression).
+ * This pointer is NULL when reading a non-progressive file.
+ */
+ int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
+
+ /* Internal JPEG parameters --- the application usually need not look at
+ * these fields. Note that the decompressor output side may not use
+ * any parameters that can change between scans.
+ */
+
+ /* Quantization and Huffman tables are carried forward across input
+ * datastreams when processing abbreviated JPEG datastreams.
+ */
+
+ JQUANT_TBL *quant_tbl_ptrs[NUM_QUANT_TBLS];
+ /* ptrs to coefficient quantization tables, or NULL if not defined */
+
+ JHUFF_TBL *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ JHUFF_TBL *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
+ /* ptrs to Huffman coding tables, or NULL if not defined */
+
+ /* These parameters are never carried across datastreams, since they
+ * are given in SOF/SOS markers or defined to be reset by SOI.
+ */
+
+ int data_precision; /* bits of precision in image data */
+
+ jpeg_component_info *comp_info;
+ /* comp_info[i] describes component that appears i'th in SOF */
+
+#if JPEG_LIB_VERSION >= 80
+ boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
+#endif
+ boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
+ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
+
+ UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+ UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+ UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+ unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */
+
+ /* These fields record data obtained from optional markers recognized by
+ * the JPEG library.
+ */
+ boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
+ /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
+ UINT8 JFIF_major_version; /* JFIF version number */
+ UINT8 JFIF_minor_version;
+ UINT8 density_unit; /* JFIF code for pixel size units */
+ UINT16 X_density; /* Horizontal pixel density */
+ UINT16 Y_density; /* Vertical pixel density */
+ boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
+ UINT8 Adobe_transform; /* Color transform code from Adobe marker */
+
+ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
+
+ /* Aside from the specific data retained from APPn markers known to the
+ * library, the uninterpreted contents of any or all APPn and COM markers
+ * can be saved in a list for examination by the application.
+ */
+ jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */
+
+ /* Remaining fields are known throughout decompressor, but generally
+ * should not be touched by a surrounding application.
+ */
+
+ /*
+ * These fields are computed during decompression startup
+ */
+ int max_h_samp_factor; /* largest h_samp_factor */
+ int max_v_samp_factor; /* largest v_samp_factor */
+
+#if JPEG_LIB_VERSION >= 70
+ int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
+ int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
+#else
+ int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
+#endif
+
+ JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
+ /* The coefficient or difference controller's input and output progress is
+ * measured in units of "iMCU" (interleaved MCU) rows. These are the same as
+ * MCU rows in fully interleaved JPEG scans, but are used whether the scan is
+ * interleaved or not. In lossy mode, we define an iMCU row as v_samp_factor
+ * DCT block rows of each component. Therefore, the IDCT output contains
+ * v_samp_factor*DCT_[v_]scaled_size sample rows of a component per iMCU row.
+ * In lossless mode, total_iMCU_rows is always equal to the image height.
+ */
+
+ JSAMPLE *sample_range_limit; /* table for fast range-limiting
+ If data_precision is 9 to 12, then this is
+ actually a J12SAMPLE pointer, and if
+ data_precision is 13 to 16, then this is
+ actually a J16SAMPLE pointer, so callers
+ must type-cast it in order to read samples
+ from the array. */
+
+ /*
+ * These fields are valid during any one scan.
+ * They describe the components and MCUs actually appearing in the scan.
+ * Note that the decompressor output side must not use these fields.
+ */
+ int comps_in_scan; /* # of JPEG components in this scan */
+ jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
+ /* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+ JDIMENSION MCUs_per_row; /* # of MCUs across the image */
+ JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
+
+ int blocks_in_MCU; /* # of data units per MCU */
+ int MCU_membership[D_MAX_BLOCKS_IN_MCU];
+ /* MCU_membership[i] is index in cur_comp_info of component owning */
+ /* i'th data unit in an MCU */
+
+ int Ss, Se, Ah, Al; /* progressive/lossless JPEG parameters for
+ scan */
+
+#if JPEG_LIB_VERSION >= 80
+ /* These fields are derived from Se of first SOS marker.
+ */
+ int block_size; /* the basic DCT block size: 1..16 */
+ const int *natural_order; /* natural-order position array for entropy decode */
+ int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
+#endif
+
+ /* This field is shared between entropy decoder and marker parser.
+ * It is either zero or the code of a JPEG marker that has been
+ * read from the data source, but has not yet been processed.
+ */
+ int unread_marker;
+
+ /*
+ * Links to decompression subobjects (methods, private variables of modules)
+ */
+ struct jpeg_decomp_master *master;
+ struct jpeg_d_main_controller *main;
+ struct jpeg_d_coef_controller *coef;
+ struct jpeg_d_post_controller *post;
+ struct jpeg_input_controller *inputctl;
+ struct jpeg_marker_reader *marker;
+ struct jpeg_entropy_decoder *entropy;
+ struct jpeg_inverse_dct *idct;
+ struct jpeg_upsampler *upsample;
+ struct jpeg_color_deconverter *cconvert;
+ struct jpeg_color_quantizer *cquantize;
+};
+
+
+/* "Object" declarations for JPEG modules that may be supplied or called
+ * directly by the surrounding application.
+ * As with all objects in the JPEG library, these structs only define the
+ * publicly visible methods and state variables of a module. Additional
+ * private fields may exist after the public ones.
+ */
+
+
+/* Error handler object */
+
+struct jpeg_error_mgr {
+ /* Error exit handler: does not return to caller */
+ void (*error_exit) (j_common_ptr cinfo);
+ /* Conditionally emit a trace or warning message */
+ void (*emit_message) (j_common_ptr cinfo, int msg_level);
+ /* Routine that actually outputs a trace or error message */
+ void (*output_message) (j_common_ptr cinfo);
+ /* Format a message string for the most recent JPEG error or message */
+ void (*format_message) (j_common_ptr cinfo, char *buffer);
+#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
+ /* Reset error state variables at start of a new image */
+ void (*reset_error_mgr) (j_common_ptr cinfo);
+
+ /* The message ID code and any parameters are saved here.
+ * A message can have one string parameter or up to 8 int parameters.
+ */
+ int msg_code;
+#define JMSG_STR_PARM_MAX 80
+ union {
+ int i[8];
+ char s[JMSG_STR_PARM_MAX];
+ } msg_parm;
+
+ /* Standard state variables for error facility */
+
+ int trace_level; /* max msg_level that will be displayed */
+
+ /* For recoverable corrupt-data errors, we emit a warning message,
+ * but keep going unless emit_message chooses to abort. emit_message
+ * should count warnings in num_warnings. The surrounding application
+ * can check for bad data by seeing if num_warnings is nonzero at the
+ * end of processing.
+ */
+ long num_warnings; /* number of corrupt-data warnings */
+
+ /* These fields point to the table(s) of error message strings.
+ * An application can change the table pointer to switch to a different
+ * message list (typically, to change the language in which errors are
+ * reported). Some applications may wish to add additional error codes
+ * that will be handled by the JPEG library error mechanism; the second
+ * table pointer is used for this purpose.
+ *
+ * First table includes all errors generated by JPEG library itself.
+ * Error code 0 is reserved for a "no such error string" message.
+ */
+ const char * const *jpeg_message_table; /* Library errors */
+ int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
+ /* Second table can be added by application (see cjpeg/djpeg for example).
+ * It contains strings numbered first_addon_message..last_addon_message.
+ */
+ const char * const *addon_message_table; /* Non-library errors */
+ int first_addon_message; /* code for first string in addon table */
+ int last_addon_message; /* code for last string in addon table */
+};
+
+
+/* Progress monitor object */
+
+struct jpeg_progress_mgr {
+ void (*progress_monitor) (j_common_ptr cinfo);
+
+ long pass_counter; /* work units completed in this pass */
+ long pass_limit; /* total number of work units in this pass */
+ int completed_passes; /* passes completed so far */
+ int total_passes; /* total number of passes expected */
+};
+
+
+/* Data destination object for compression */
+
+struct jpeg_destination_mgr {
+ JOCTET *next_output_byte; /* => next byte to write in buffer */
+ size_t free_in_buffer; /* # of byte spaces remaining in buffer */
+
+ void (*init_destination) (j_compress_ptr cinfo);
+ boolean (*empty_output_buffer) (j_compress_ptr cinfo);
+ void (*term_destination) (j_compress_ptr cinfo);
+};
+
+
+/* Data source object for decompression */
+
+struct jpeg_source_mgr {
+ const JOCTET *next_input_byte; /* => next byte to read from buffer */
+ size_t bytes_in_buffer; /* # of bytes remaining in buffer */
+
+ void (*init_source) (j_decompress_ptr cinfo);
+ boolean (*fill_input_buffer) (j_decompress_ptr cinfo);
+ void (*skip_input_data) (j_decompress_ptr cinfo, long num_bytes);
+ boolean (*resync_to_restart) (j_decompress_ptr cinfo, int desired);
+ void (*term_source) (j_decompress_ptr cinfo);
+};
+
+
+/* Memory manager object.
+ * Allocates "small" objects (a few K total), "large" objects (tens of K),
+ * and "really big" objects (virtual arrays with backing store if needed).
+ * The memory manager does not allow individual objects to be freed; rather,
+ * each created object is assigned to a pool, and whole pools can be freed
+ * at once. This is faster and more convenient than remembering exactly what
+ * to free, especially where malloc()/free() are not too speedy.
+ * NB: alloc routines never return NULL. They exit to error_exit if not
+ * successful.
+ */
+
+#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
+#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
+#define JPOOL_NUMPOOLS 2
+
+typedef struct jvirt_sarray_control *jvirt_sarray_ptr;
+typedef struct jvirt_barray_control *jvirt_barray_ptr;
+
+
+struct jpeg_memory_mgr {
+ /* Method pointers */
+ void *(*alloc_small) (j_common_ptr cinfo, int pool_id, size_t sizeofobject);
+ void *(*alloc_large) (j_common_ptr cinfo, int pool_id,
+ size_t sizeofobject);
+ /* If cinfo->data_precision is 12 or 16, then this method and the
+ * access_virt_sarray method actually return a J12SAMPARRAY or a
+ * J16SAMPARRAY, so callers must type-cast the return value in order to
+ * read/write 12-bit or 16-bit samples from/to the array.
+ */
+ JSAMPARRAY (*alloc_sarray) (j_common_ptr cinfo, int pool_id,
+ JDIMENSION samplesperrow, JDIMENSION numrows);
+ JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id,
+ JDIMENSION blocksperrow, JDIMENSION numrows);
+ jvirt_sarray_ptr (*request_virt_sarray) (j_common_ptr cinfo, int pool_id,
+ boolean pre_zero,
+ JDIMENSION samplesperrow,
+ JDIMENSION numrows,
+ JDIMENSION maxaccess);
+ jvirt_barray_ptr (*request_virt_barray) (j_common_ptr cinfo, int pool_id,
+ boolean pre_zero,
+ JDIMENSION blocksperrow,
+ JDIMENSION numrows,
+ JDIMENSION maxaccess);
+ void (*realize_virt_arrays) (j_common_ptr cinfo);
+ JSAMPARRAY (*access_virt_sarray) (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
+ JDIMENSION start_row, JDIMENSION num_rows,
+ boolean writable);
+ JBLOCKARRAY (*access_virt_barray) (j_common_ptr cinfo, jvirt_barray_ptr ptr,
+ JDIMENSION start_row, JDIMENSION num_rows,
+ boolean writable);
+ void (*free_pool) (j_common_ptr cinfo, int pool_id);
+ void (*self_destruct) (j_common_ptr cinfo);
+
+ /* Limit on memory allocation for this JPEG object. (Note that this is
+ * merely advisory, not a guaranteed maximum; it only affects the space
+ * used for virtual-array buffers.) May be changed by outer application
+ * after creating the JPEG object.
+ */
+ long max_memory_to_use;
+
+ /* Maximum allocation request accepted by alloc_large. */
+ long max_alloc_chunk;
+};
+
+
+/* Routine signature for application-supplied marker processing methods.
+ * Need not pass marker code since it is stored in cinfo->unread_marker.
+ */
+typedef boolean (*jpeg_marker_parser_method) (j_decompress_ptr cinfo);
+
+
+/* Originally, this macro was used as a way of defining function prototypes
+ * for both modern compilers as well as older compilers that did not support
+ * prototype parameters. libjpeg-turbo has never supported these older,
+ * non-ANSI compilers, but the macro is still included because there is some
+ * software out there that uses it.
+ */
+
+#define JPP(arglist) arglist
+
+
+/* Default error-management setup */
+EXTERN(struct jpeg_error_mgr *) jpeg_std_error(struct jpeg_error_mgr *err);
+
+/* Initialization of JPEG compression objects.
+ * jpeg_create_compress() and jpeg_create_decompress() are the exported
+ * names that applications should call. These expand to calls on
+ * jpeg_CreateCompress and jpeg_CreateDecompress with additional information
+ * passed for version mismatch checking.
+ * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
+ */
+#define jpeg_create_compress(cinfo) \
+ jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
+ (size_t)sizeof(struct jpeg_compress_struct))
+#define jpeg_create_decompress(cinfo) \
+ jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
+ (size_t)sizeof(struct jpeg_decompress_struct))
+EXTERN(void) jpeg_CreateCompress(j_compress_ptr cinfo, int version,
+ size_t structsize);
+EXTERN(void) jpeg_CreateDecompress(j_decompress_ptr cinfo, int version,
+ size_t structsize);
+/* Destruction of JPEG compression objects */
+EXTERN(void) jpeg_destroy_compress(j_compress_ptr cinfo);
+EXTERN(void) jpeg_destroy_decompress(j_decompress_ptr cinfo);
+
+/* Standard data source and destination managers: stdio streams. */
+/* Caller is responsible for opening the file before and closing after. */
+EXTERN(void) jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile);
+EXTERN(void) jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile);
+
+/* Data source and destination managers: memory buffers. */
+EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
+ unsigned long *outsize);
+EXTERN(void) jpeg_mem_src(j_decompress_ptr cinfo,
+ const unsigned char *inbuffer, unsigned long insize);
+
+/* Default parameter setup for compression */
+EXTERN(void) jpeg_set_defaults(j_compress_ptr cinfo);
+/* Compression parameter setup aids */
+EXTERN(void) jpeg_set_colorspace(j_compress_ptr cinfo,
+ J_COLOR_SPACE colorspace);
+EXTERN(void) jpeg_default_colorspace(j_compress_ptr cinfo);
+EXTERN(void) jpeg_set_quality(j_compress_ptr cinfo, int quality,
+ boolean force_baseline);
+EXTERN(void) jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
+ boolean force_baseline);
+#if JPEG_LIB_VERSION >= 70
+EXTERN(void) jpeg_default_qtables(j_compress_ptr cinfo,
+ boolean force_baseline);
+#endif
+EXTERN(void) jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
+ const unsigned int *basic_table,
+ int scale_factor, boolean force_baseline);
+EXTERN(int) jpeg_quality_scaling(int quality);
+EXTERN(void) jpeg_enable_lossless(j_compress_ptr cinfo,
+ int predictor_selection_value,
+ int point_transform);
+EXTERN(void) jpeg_simple_progression(j_compress_ptr cinfo);
+EXTERN(void) jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress);
+EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table(j_common_ptr cinfo);
+EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table(j_common_ptr cinfo);
+
+/* Main entry points for compression */
+EXTERN(void) jpeg_start_compress(j_compress_ptr cinfo,
+ boolean write_all_tables);
+EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
+ JSAMPARRAY scanlines,
+ JDIMENSION num_lines);
+EXTERN(JDIMENSION) jpeg12_write_scanlines(j_compress_ptr cinfo,
+ J12SAMPARRAY scanlines,
+ JDIMENSION num_lines);
+EXTERN(JDIMENSION) jpeg16_write_scanlines(j_compress_ptr cinfo,
+ J16SAMPARRAY scanlines,
+ JDIMENSION num_lines);
+EXTERN(void) jpeg_finish_compress(j_compress_ptr cinfo);
+
+#if JPEG_LIB_VERSION >= 70
+/* Precalculate JPEG dimensions for current compression parameters. */
+EXTERN(void) jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo);
+#endif
+
+/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
+EXTERN(JDIMENSION) jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
+ JDIMENSION num_lines);
+EXTERN(JDIMENSION) jpeg12_write_raw_data(j_compress_ptr cinfo,
+ J12SAMPIMAGE data,
+ JDIMENSION num_lines);
+
+/* Write a special marker. See libjpeg.txt concerning safe usage. */
+EXTERN(void) jpeg_write_marker(j_compress_ptr cinfo, int marker,
+ const JOCTET *dataptr, unsigned int datalen);
+/* Same, but piecemeal. */
+EXTERN(void) jpeg_write_m_header(j_compress_ptr cinfo, int marker,
+ unsigned int datalen);
+EXTERN(void) jpeg_write_m_byte(j_compress_ptr cinfo, int val);
+
+/* Alternate compression function: just write an abbreviated table file */
+EXTERN(void) jpeg_write_tables(j_compress_ptr cinfo);
+
+/* Write ICC profile. See libjpeg.txt for usage information. */
+EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
+ const JOCTET *icc_data_ptr,
+ unsigned int icc_data_len);
+
+
+/* Decompression startup: read start of JPEG datastream to see what's there */
+EXTERN(int) jpeg_read_header(j_decompress_ptr cinfo, boolean require_image);
+/* Return value is one of: */
+#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
+#define JPEG_HEADER_OK 1 /* Found valid image datastream */
+#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
+/* If you pass require_image = TRUE (normal case), you need not check for
+ * a TABLES_ONLY return code; an abbreviated file will cause an error exit.
+ * JPEG_SUSPENDED is only possible if you use a data source module that can
+ * give a suspension return (the stdio source module doesn't).
+ */
+
+/* Main entry points for decompression */
+EXTERN(boolean) jpeg_start_decompress(j_decompress_ptr cinfo);
+EXTERN(JDIMENSION) jpeg_read_scanlines(j_decompress_ptr cinfo,
+ JSAMPARRAY scanlines,
+ JDIMENSION max_lines);
+EXTERN(JDIMENSION) jpeg12_read_scanlines(j_decompress_ptr cinfo,
+ J12SAMPARRAY scanlines,
+ JDIMENSION max_lines);
+EXTERN(JDIMENSION) jpeg16_read_scanlines(j_decompress_ptr cinfo,
+ J16SAMPARRAY scanlines,
+ JDIMENSION max_lines);
+EXTERN(JDIMENSION) jpeg_skip_scanlines(j_decompress_ptr cinfo,
+ JDIMENSION num_lines);
+EXTERN(JDIMENSION) jpeg12_skip_scanlines(j_decompress_ptr cinfo,
+ JDIMENSION num_lines);
+EXTERN(void) jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
+ JDIMENSION *width);
+EXTERN(void) jpeg12_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
+ JDIMENSION *width);
+EXTERN(boolean) jpeg_finish_decompress(j_decompress_ptr cinfo);
+
+/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
+EXTERN(JDIMENSION) jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
+ JDIMENSION max_lines);
+EXTERN(JDIMENSION) jpeg12_read_raw_data(j_decompress_ptr cinfo,
+ J12SAMPIMAGE data,
+ JDIMENSION max_lines);
+
+/* Additional entry points for buffered-image mode. */
+EXTERN(boolean) jpeg_has_multiple_scans(j_decompress_ptr cinfo);
+EXTERN(boolean) jpeg_start_output(j_decompress_ptr cinfo, int scan_number);
+EXTERN(boolean) jpeg_finish_output(j_decompress_ptr cinfo);
+EXTERN(boolean) jpeg_input_complete(j_decompress_ptr cinfo);
+EXTERN(void) jpeg_new_colormap(j_decompress_ptr cinfo);
+EXTERN(int) jpeg_consume_input(j_decompress_ptr cinfo);
+/* Return value is one of: */
+/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
+#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
+#define JPEG_REACHED_EOI 2 /* Reached end of image */
+#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
+#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
+
+/* Precalculate output dimensions for current decompression parameters. */
+#if JPEG_LIB_VERSION >= 80
+EXTERN(void) jpeg_core_output_dimensions(j_decompress_ptr cinfo);
+#endif
+EXTERN(void) jpeg_calc_output_dimensions(j_decompress_ptr cinfo);
+
+/* Control saving of COM and APPn markers into marker_list. */
+EXTERN(void) jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
+ unsigned int length_limit);
+
+/* Install a special processing method for COM or APPn markers. */
+EXTERN(void) jpeg_set_marker_processor(j_decompress_ptr cinfo,
+ int marker_code,
+ jpeg_marker_parser_method routine);
+
+/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
+EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients(j_decompress_ptr cinfo);
+EXTERN(void) jpeg_write_coefficients(j_compress_ptr cinfo,
+ jvirt_barray_ptr *coef_arrays);
+EXTERN(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo,
+ j_compress_ptr dstinfo);
+
+/* If you choose to abort compression or decompression before completing
+ * jpeg_finish_(de)compress, then you need to clean up to release memory,
+ * temporary files, etc. You can just call jpeg_destroy_(de)compress
+ * if you're done with the JPEG object, but if you want to clean it up and
+ * reuse it, call this:
+ */
+EXTERN(void) jpeg_abort_compress(j_compress_ptr cinfo);
+EXTERN(void) jpeg_abort_decompress(j_decompress_ptr cinfo);
+
+/* Generic versions of jpeg_abort and jpeg_destroy that work on either
+ * flavor of JPEG object. These may be more convenient in some places.
+ */
+EXTERN(void) jpeg_abort(j_common_ptr cinfo);
+EXTERN(void) jpeg_destroy(j_common_ptr cinfo);
+
+/* Default restart-marker-resync procedure for use by data source modules */
+EXTERN(boolean) jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired);
+
+/* Read ICC profile. See libjpeg.txt for usage information. */
+EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
+ JOCTET **icc_data_ptr,
+ unsigned int *icc_data_len);
+
+
+/* These marker codes are exported since applications and data source modules
+ * are likely to want to use them.
+ */
+
+#define JPEG_RST0 0xD0 /* RST0 marker code */
+#define JPEG_EOI 0xD9 /* EOI marker code */
+#define JPEG_APP0 0xE0 /* APP0 marker code */
+#define JPEG_COM 0xFE /* COM marker code */
+
+
+/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
+ * for structure definitions that are never filled in, keep it quiet by
+ * supplying dummy definitions for the various substructures.
+ */
+
+#ifdef INCOMPLETE_TYPES_BROKEN
+#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
+struct jvirt_sarray_control { long dummy; };
+struct jvirt_barray_control { long dummy; };
+struct jpeg_comp_master { long dummy; };
+struct jpeg_c_main_controller { long dummy; };
+struct jpeg_c_prep_controller { long dummy; };
+struct jpeg_c_coef_controller { long dummy; };
+struct jpeg_marker_writer { long dummy; };
+struct jpeg_color_converter { long dummy; };
+struct jpeg_downsampler { long dummy; };
+struct jpeg_forward_dct { long dummy; };
+struct jpeg_entropy_encoder { long dummy; };
+struct jpeg_decomp_master { long dummy; };
+struct jpeg_d_main_controller { long dummy; };
+struct jpeg_d_coef_controller { long dummy; };
+struct jpeg_d_post_controller { long dummy; };
+struct jpeg_input_controller { long dummy; };
+struct jpeg_marker_reader { long dummy; };
+struct jpeg_entropy_decoder { long dummy; };
+struct jpeg_inverse_dct { long dummy; };
+struct jpeg_upsampler { long dummy; };
+struct jpeg_color_deconverter { long dummy; };
+struct jpeg_color_quantizer { long dummy; };
+#endif /* JPEG_INTERNALS */
+#endif /* INCOMPLETE_TYPES_BROKEN */
+
+
+/*
+ * The JPEG library modules define JPEG_INTERNALS before including this file.
+ * The internal structure declarations are read only when that is true.
+ * Applications using the library should not include jpegint.h, but may wish
+ * to include jerror.h.
+ */
+
+#ifdef JPEG_INTERNALS
+#include "jpegint.h" /* fetch private declarations */
+#include "jerror.h" /* fetch error codes too */
+#endif
+
+#ifdef __cplusplus
+#ifndef DONT_USE_EXTERN_C
+}
+#endif
+#endif
+
+#endif /* JPEGLIB_H */
diff --git a/contrib/libs/libjpeg-turbo/jpegtran.c b/contrib/libs/libjpeg-turbo/src/jpegtran.c
index d1552ec7d5e..b7d7ebbeef7 100644
--- a/contrib/libs/libjpeg-turbo/jpegtran.c
+++ b/contrib/libs/libjpeg-turbo/src/jpegtran.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2014, 2017, 2019-2022, D. R. Commander.
+ * Copyright (C) 2010, 2014, 2017, 2019-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -35,11 +35,11 @@
static const char *progname; /* program name for error messages */
static char *icc_filename; /* for -icc switch */
-JDIMENSION max_scans; /* for -maxscans switch */
+static JDIMENSION max_scans; /* for -maxscans switch */
static char *outfilename; /* for -outfile switch */
static char *dropfilename; /* for -drop switch */
-boolean report; /* for -report switch */
-boolean strict; /* for -strict switch */
+static boolean report; /* for -report switch */
+static boolean strict; /* for -strict switch */
static JCOPY_OPTION copyoption; /* -copy switch */
static jpeg_transform_info transformoption; /* image transformation options */
@@ -183,7 +183,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
exit(EXIT_FAILURE);
#endif
- } else if (keymatch(arg, "copy", 2)) {
+ } else if (keymatch(arg, "copy", 1)) {
/* Select which extra markers to copy. */
if (++argn >= argc) /* advance to next argument */
usage();
@@ -241,7 +241,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
if (!printed_version) {
fprintf(stderr, "%s version %s (build %s)\n",
PACKAGE_NAME, VERSION, BUILD);
- fprintf(stderr, "%s\n\n", JCOPYRIGHT);
+ fprintf(stderr, JCOPYRIGHT1);
+ fprintf(stderr, JCOPYRIGHT2 "\n");
fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
JVERSION);
printed_version = TRUE;
@@ -319,7 +320,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
* handle. */
transformoption.perfect = TRUE;
- } else if (keymatch(arg, "progressive", 2)) {
+ } else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;
diff --git a/contrib/libs/libjpeg-turbo/jquant1.c b/contrib/libs/libjpeg-turbo/src/jquant1.c
index 73b83e16e5c..bd68dcb8c6a 100644
--- a/contrib/libs/libjpeg-turbo/jquant1.c
+++ b/contrib/libs/libjpeg-turbo/src/jquant1.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2015, D. R. Commander.
+ * Copyright (C) 2009, 2015, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -16,8 +16,9 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
-#ifdef QUANT_1PASS_SUPPORTED
+#if defined(QUANT_1PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16
/*
@@ -66,7 +67,7 @@
* worse, since the dither may be too much or too little at a given point.
*
* The normal calculation would be to form pixel value + dither, range-limit
- * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual.
+ * this to 0.._MAXJSAMPLE, and then index into the colorindex table as usual.
* We can skip the separate range-limiting step by extending the colorindex
* table in both directions.
*/
@@ -85,22 +86,22 @@ static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = {
* Stephen Hawley's article "Ordered Dithering" in Graphics Gems I.
* The values in this array must range from 0 to ODITHER_CELLS-1.
*/
- { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 },
- { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
- { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
- { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
- { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 },
- { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
- { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
- { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
- { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 },
- { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
- { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
- { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
- { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 },
- { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
- { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
- { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
+ { 0, 192, 48, 240, 12, 204, 60, 252, 3, 195, 51, 243, 15, 207, 63, 255 },
+ { 128, 64, 176, 112, 140, 76, 188, 124, 131, 67, 179, 115, 143, 79, 191, 127 },
+ { 32, 224, 16, 208, 44, 236, 28, 220, 35, 227, 19, 211, 47, 239, 31, 223 },
+ { 160, 96, 144, 80, 172, 108, 156, 92, 163, 99, 147, 83, 175, 111, 159, 95 },
+ { 8, 200, 56, 248, 4, 196, 52, 244, 11, 203, 59, 251, 7, 199, 55, 247 },
+ { 136, 72, 184, 120, 132, 68, 180, 116, 139, 75, 187, 123, 135, 71, 183, 119 },
+ { 40, 232, 24, 216, 36, 228, 20, 212, 43, 235, 27, 219, 39, 231, 23, 215 },
+ { 168, 104, 152, 88, 164, 100, 148, 84, 171, 107, 155, 91, 167, 103, 151, 87 },
+ { 2, 194, 50, 242, 14, 206, 62, 254, 1, 193, 49, 241, 13, 205, 61, 253 },
+ { 130, 66, 178, 114, 142, 78, 190, 126, 129, 65, 177, 113, 141, 77, 189, 125 },
+ { 34, 226, 18, 210, 46, 238, 30, 222, 33, 225, 17, 209, 45, 237, 29, 221 },
+ { 162, 98, 146, 82, 174, 110, 158, 94, 161, 97, 145, 81, 173, 109, 157, 93 },
+ { 10, 202, 58, 250, 6, 198, 54, 246, 9, 201, 57, 249, 5, 197, 53, 245 },
+ { 138, 74, 186, 122, 134, 70, 182, 118, 137, 73, 185, 121, 133, 69, 181, 117 },
+ { 42, 234, 26, 218, 38, 230, 22, 214, 41, 233, 25, 217, 37, 229, 21, 213 },
+ { 170, 106, 154, 90, 166, 102, 150, 86, 169, 105, 153, 89, 165, 101, 149, 85 }
};
@@ -144,13 +145,13 @@ typedef struct {
struct jpeg_color_quantizer pub; /* public fields */
/* Initially allocated colormap is saved here */
- JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */
+ _JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */
int sv_actual; /* number of entries in use */
- JSAMPARRAY colorindex; /* Precomputed mapping for speed */
+ _JSAMPARRAY colorindex; /* Precomputed mapping for speed */
/* colorindex[i][j] = index of color closest to pixel value j in component i,
* premultiplied as described above. Since colormap indexes must fit into
- * JSAMPLEs, the entries of this array will too.
+ * _JSAMPLEs, the entries of this array will too.
*/
boolean is_padded; /* is the colorindex padded for odither? */
@@ -248,24 +249,24 @@ select_ncolors(j_decompress_ptr cinfo, int Ncolors[])
LOCAL(int)
output_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
/* Return j'th output value, where j will range from 0 to maxj */
-/* The output values must fall in 0..MAXJSAMPLE in increasing order */
+/* The output values must fall in 0.._MAXJSAMPLE in increasing order */
{
- /* We always provide values 0 and MAXJSAMPLE for each component;
+ /* We always provide values 0 and _MAXJSAMPLE for each component;
* any additional values are equally spaced between these limits.
* (Forcing the upper and lower values to the limits ensures that
* dithering can't produce a color outside the selected gamut.)
*/
- return (int)(((JLONG)j * MAXJSAMPLE + maxj / 2) / maxj);
+ return (int)(((JLONG)j * _MAXJSAMPLE + maxj / 2) / maxj);
}
LOCAL(int)
largest_input_value(j_decompress_ptr cinfo, int ci, int j, int maxj)
/* Return largest input value that should map to j'th output value */
-/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */
+/* Must have largest(j=0) >= 0, and largest(j=maxj) >= _MAXJSAMPLE */
{
/* Breakpoints are halfway between values returned by output_value */
- return (int)(((JLONG)(2 * j + 1) * MAXJSAMPLE + maxj) / (2 * maxj));
+ return (int)(((JLONG)(2 * j + 1) * _MAXJSAMPLE + maxj) / (2 * maxj));
}
@@ -277,7 +278,7 @@ LOCAL(void)
create_colormap(j_decompress_ptr cinfo)
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- JSAMPARRAY colormap; /* Created colormap */
+ _JSAMPARRAY colormap; /* Created colormap */
int total_colors; /* Number of distinct output colors */
int i, j, k, nci, blksize, blkdist, ptr, val;
@@ -296,7 +297,7 @@ create_colormap(j_decompress_ptr cinfo)
/* The colors are ordered in the map in standard row-major order, */
/* i.e. rightmost (highest-indexed) color changes most rapidly. */
- colormap = (*cinfo->mem->alloc_sarray)
+ colormap = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
(JDIMENSION)total_colors, (JDIMENSION)cinfo->out_color_components);
@@ -315,7 +316,7 @@ create_colormap(j_decompress_ptr cinfo)
for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) {
/* fill in blksize entries beginning at ptr */
for (k = 0; k < blksize; k++)
- colormap[i][ptr + k] = (JSAMPLE)val;
+ colormap[i][ptr + k] = (_JSAMPLE)val;
}
}
blkdist = blksize; /* blksize of this color is blkdist of next */
@@ -337,25 +338,25 @@ LOCAL(void)
create_colorindex(j_decompress_ptr cinfo)
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- JSAMPROW indexptr;
+ _JSAMPROW indexptr;
int i, j, k, nci, blksize, val, pad;
- /* For ordered dither, we pad the color index tables by MAXJSAMPLE in
- * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE).
+ /* For ordered dither, we pad the color index tables by _MAXJSAMPLE in
+ * each direction (input index values can be -_MAXJSAMPLE .. 2*_MAXJSAMPLE).
* This is not necessary in the other dithering modes. However, we
* flag whether it was done in case user changes dithering mode.
*/
if (cinfo->dither_mode == JDITHER_ORDERED) {
- pad = MAXJSAMPLE * 2;
+ pad = _MAXJSAMPLE * 2;
cquantize->is_padded = TRUE;
} else {
pad = 0;
cquantize->is_padded = FALSE;
}
- cquantize->colorindex = (*cinfo->mem->alloc_sarray)
+ cquantize->colorindex = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(MAXJSAMPLE + 1 + pad),
+ (JDIMENSION)(_MAXJSAMPLE + 1 + pad),
(JDIMENSION)cinfo->out_color_components);
/* blksize is number of adjacent repeated entries for a component */
@@ -368,24 +369,24 @@ create_colorindex(j_decompress_ptr cinfo)
/* adjust colorindex pointers to provide padding at negative indexes. */
if (pad)
- cquantize->colorindex[i] += MAXJSAMPLE;
+ cquantize->colorindex[i] += _MAXJSAMPLE;
/* in loop, val = index of current output value, */
/* and k = largest j that maps to current val */
indexptr = cquantize->colorindex[i];
val = 0;
k = largest_input_value(cinfo, i, 0, nci - 1);
- for (j = 0; j <= MAXJSAMPLE; j++) {
+ for (j = 0; j <= _MAXJSAMPLE; j++) {
while (j > k) /* advance val if past boundary */
k = largest_input_value(cinfo, i, ++val, nci - 1);
/* premultiply so that no multiplication needed in main processing */
- indexptr[j] = (JSAMPLE)(val * blksize);
+ indexptr[j] = (_JSAMPLE)(val * blksize);
}
/* Pad at both ends if necessary */
if (pad)
- for (j = 1; j <= MAXJSAMPLE; j++) {
+ for (j = 1; j <= _MAXJSAMPLE; j++) {
indexptr[-j] = indexptr[0];
- indexptr[MAXJSAMPLE + j] = indexptr[MAXJSAMPLE];
+ indexptr[_MAXJSAMPLE + j] = indexptr[_MAXJSAMPLE];
}
}
}
@@ -406,16 +407,16 @@ make_odither_array(j_decompress_ptr cinfo, int ncolors)
odither = (ODITHER_MATRIX_PTR)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(ODITHER_MATRIX));
- /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
+ /* The inter-value distance for this color is _MAXJSAMPLE/(ncolors-1).
* Hence the dither value for the matrix cell with fill order f
- * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
+ * (f=0..N-1) should be (N-1-2*f)/(2*N) * _MAXJSAMPLE/(ncolors-1).
* On 16-bit-int machine, be careful to avoid overflow.
*/
den = 2 * ODITHER_CELLS * ((JLONG)(ncolors - 1));
for (j = 0; j < ODITHER_SIZE; j++) {
for (k = 0; k < ODITHER_SIZE; k++) {
num = ((JLONG)(ODITHER_CELLS - 1 -
- 2 * ((int)base_dither_matrix[j][k]))) * MAXJSAMPLE;
+ 2 * ((int)base_dither_matrix[j][k]))) * _MAXJSAMPLE;
/* Ensure round towards zero despite C's lack of consistency
* about rounding negative values in integer division...
*/
@@ -460,14 +461,14 @@ create_odither_tables(j_decompress_ptr cinfo)
*/
METHODDEF(void)
-color_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+color_quantize(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
/* General case, no dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- JSAMPARRAY colorindex = cquantize->colorindex;
+ _JSAMPARRAY colorindex = cquantize->colorindex;
register int pixcode, ci;
- register JSAMPROW ptrin, ptrout;
+ register _JSAMPROW ptrin, ptrout;
int row;
JDIMENSION col;
JDIMENSION width = cinfo->output_width;
@@ -481,23 +482,23 @@ color_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
for (ci = 0; ci < nc; ci++) {
pixcode += colorindex[ci][*ptrin++];
}
- *ptrout++ = (JSAMPLE)pixcode;
+ *ptrout++ = (_JSAMPLE)pixcode;
}
}
}
METHODDEF(void)
-color_quantize3(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+color_quantize3(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
/* Fast path for out_color_components==3, no dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
register int pixcode;
- register JSAMPROW ptrin, ptrout;
- JSAMPROW colorindex0 = cquantize->colorindex[0];
- JSAMPROW colorindex1 = cquantize->colorindex[1];
- JSAMPROW colorindex2 = cquantize->colorindex[2];
+ register _JSAMPROW ptrin, ptrout;
+ _JSAMPROW colorindex0 = cquantize->colorindex[0];
+ _JSAMPROW colorindex1 = cquantize->colorindex[1];
+ _JSAMPROW colorindex2 = cquantize->colorindex[2];
int row;
JDIMENSION col;
JDIMENSION width = cinfo->output_width;
@@ -509,21 +510,21 @@ color_quantize3(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
pixcode = colorindex0[*ptrin++];
pixcode += colorindex1[*ptrin++];
pixcode += colorindex2[*ptrin++];
- *ptrout++ = (JSAMPLE)pixcode;
+ *ptrout++ = (_JSAMPLE)pixcode;
}
}
}
METHODDEF(void)
-quantize_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+quantize_ord_dither(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
/* General case, with ordered dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- register JSAMPROW input_ptr;
- register JSAMPROW output_ptr;
- JSAMPROW colorindex_ci;
+ register _JSAMPROW input_ptr;
+ register _JSAMPROW output_ptr;
+ _JSAMPROW colorindex_ci;
int *dither; /* points to active row of dither matrix */
int row_index, col_index; /* current indexes into dither matrix */
int nc = cinfo->out_color_components;
@@ -534,7 +535,7 @@ quantize_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
for (row = 0; row < num_rows; row++) {
/* Initialize output values to 0 so can process components separately */
- jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
+ jzero_far((void *)output_buf[row], (size_t)(width * sizeof(_JSAMPLE)));
row_index = cquantize->row_index;
for (ci = 0; ci < nc; ci++) {
input_ptr = input_buf[row] + ci;
@@ -544,11 +545,11 @@ quantize_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
col_index = 0;
for (col = width; col > 0; col--) {
- /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE,
+ /* Form pixel value + dither, range-limit to 0.._MAXJSAMPLE,
* select output value, accumulate into output code for this pixel.
* Range-limiting need not be done explicitly, as we have extended
* the colorindex table to produce the right answers for out-of-range
- * inputs. The maximum dither is +- MAXJSAMPLE; this sets the
+ * inputs. The maximum dither is +- _MAXJSAMPLE; this sets the
* required amount of padding.
*/
*output_ptr +=
@@ -566,17 +567,17 @@ quantize_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
METHODDEF(void)
-quantize3_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+quantize3_ord_dither(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
/* Fast path for out_color_components==3, with ordered dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
register int pixcode;
- register JSAMPROW input_ptr;
- register JSAMPROW output_ptr;
- JSAMPROW colorindex0 = cquantize->colorindex[0];
- JSAMPROW colorindex1 = cquantize->colorindex[1];
- JSAMPROW colorindex2 = cquantize->colorindex[2];
+ register _JSAMPROW input_ptr;
+ register _JSAMPROW output_ptr;
+ _JSAMPROW colorindex0 = cquantize->colorindex[0];
+ _JSAMPROW colorindex1 = cquantize->colorindex[1];
+ _JSAMPROW colorindex2 = cquantize->colorindex[2];
int *dither0; /* points to active row of dither matrix */
int *dither1;
int *dither2;
@@ -598,7 +599,7 @@ quantize3_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
pixcode = colorindex0[(*input_ptr++) + dither0[col_index]];
pixcode += colorindex1[(*input_ptr++) + dither1[col_index]];
pixcode += colorindex2[(*input_ptr++) + dither2[col_index]];
- *output_ptr++ = (JSAMPLE)pixcode;
+ *output_ptr++ = (_JSAMPLE)pixcode;
col_index = (col_index + 1) & ODITHER_MASK;
}
row_index = (row_index + 1) & ODITHER_MASK;
@@ -608,8 +609,8 @@ quantize3_ord_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
METHODDEF(void)
-quantize_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+quantize_fs_dither(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
/* General case, with Floyd-Steinberg dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
@@ -619,10 +620,10 @@ quantize_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
LOCFSERROR bnexterr; /* error for below/next col */
LOCFSERROR delta;
register FSERRPTR errorptr; /* => fserrors[] at column before current */
- register JSAMPROW input_ptr;
- register JSAMPROW output_ptr;
- JSAMPROW colorindex_ci;
- JSAMPROW colormap_ci;
+ register _JSAMPROW input_ptr;
+ register _JSAMPROW output_ptr;
+ _JSAMPROW colorindex_ci;
+ _JSAMPROW colormap_ci;
int pixcode;
int nc = cinfo->out_color_components;
int dir; /* 1 for left-to-right, -1 for right-to-left */
@@ -631,12 +632,12 @@ quantize_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
int row;
JDIMENSION col;
JDIMENSION width = cinfo->output_width;
- JSAMPLE *range_limit = cinfo->sample_range_limit;
+ _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
SHIFT_TEMPS
for (row = 0; row < num_rows; row++) {
/* Initialize output values to 0 so can process components separately */
- jzero_far((void *)output_buf[row], (size_t)(width * sizeof(JSAMPLE)));
+ jzero_far((void *)output_buf[row], (size_t)(width * sizeof(_JSAMPLE)));
for (ci = 0; ci < nc; ci++) {
input_ptr = input_buf[row] + ci;
output_ptr = output_buf[row];
@@ -670,15 +671,15 @@ quantize_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
* Note: errorptr points to *previous* column's array entry.
*/
cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4);
- /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.
- * The maximum error is +- MAXJSAMPLE; this sets the required size
+ /* Form pixel value + error, and range-limit to 0.._MAXJSAMPLE.
+ * The maximum error is +- _MAXJSAMPLE; this sets the required size
* of the range_limit array.
*/
cur += *input_ptr;
cur = range_limit[cur];
/* Select output value, accumulate into output code for this pixel */
pixcode = colorindex_ci[cur];
- *output_ptr += (JSAMPLE)pixcode;
+ *output_ptr += (_JSAMPLE)pixcode;
/* Compute actual representation error at this pixel */
/* Note: we can do this even though we don't have the final */
/* pixel code, because the colormap is orthogonal. */
@@ -745,22 +746,22 @@ start_pass_1_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
int i;
/* Install my colormap. */
- cinfo->colormap = cquantize->sv_colormap;
+ cinfo->colormap = (JSAMPARRAY)cquantize->sv_colormap;
cinfo->actual_number_of_colors = cquantize->sv_actual;
/* Initialize for desired dithering mode. */
switch (cinfo->dither_mode) {
case JDITHER_NONE:
if (cinfo->out_color_components == 3)
- cquantize->pub.color_quantize = color_quantize3;
+ cquantize->pub._color_quantize = color_quantize3;
else
- cquantize->pub.color_quantize = color_quantize;
+ cquantize->pub._color_quantize = color_quantize;
break;
case JDITHER_ORDERED:
if (cinfo->out_color_components == 3)
- cquantize->pub.color_quantize = quantize3_ord_dither;
+ cquantize->pub._color_quantize = quantize3_ord_dither;
else
- cquantize->pub.color_quantize = quantize_ord_dither;
+ cquantize->pub._color_quantize = quantize_ord_dither;
cquantize->row_index = 0; /* initialize state for ordered dither */
/* If user changed to ordered dither from another mode,
* we must recreate the color index table with padding.
@@ -773,7 +774,7 @@ start_pass_1_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
create_odither_tables(cinfo);
break;
case JDITHER_FS:
- cquantize->pub.color_quantize = quantize_fs_dither;
+ cquantize->pub._color_quantize = quantize_fs_dither;
cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */
/* Allocate Floyd-Steinberg workspace if didn't already. */
if (cquantize->fserrors[0] == NULL)
@@ -818,10 +819,17 @@ new_color_map_1_quant(j_decompress_ptr cinfo)
*/
GLOBAL(void)
-jinit_1pass_quantizer(j_decompress_ptr cinfo)
+_jinit_1pass_quantizer(j_decompress_ptr cinfo)
{
my_cquantize_ptr cquantize;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
+ /* Color quantization is not supported with lossless JPEG images */
+ if (cinfo->master->lossless)
+ ERREXIT(cinfo, JERR_NOTIMPL);
+
cquantize = (my_cquantize_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_cquantizer));
@@ -835,9 +843,9 @@ jinit_1pass_quantizer(j_decompress_ptr cinfo)
/* Make sure my internal arrays won't overflow */
if (cinfo->out_color_components > MAX_Q_COMPS)
ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS);
- /* Make sure colormap indexes can be represented by JSAMPLEs */
- if (cinfo->desired_number_of_colors > (MAXJSAMPLE + 1))
- ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE + 1);
+ /* Make sure colormap indexes can be represented by _JSAMPLEs */
+ if (cinfo->desired_number_of_colors > (_MAXJSAMPLE + 1))
+ ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, _MAXJSAMPLE + 1);
/* Create the colormap and color index table. */
create_colormap(cinfo);
@@ -853,4 +861,4 @@ jinit_1pass_quantizer(j_decompress_ptr cinfo)
alloc_fs_workspace(cinfo);
}
-#endif /* QUANT_1PASS_SUPPORTED */
+#endif /* defined(QUANT_1PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16 */
diff --git a/contrib/libs/libjpeg-turbo/jquant2.c b/contrib/libs/libjpeg-turbo/src/jquant2.c
index 44efb18cadf..9ba51fa8872 100644
--- a/contrib/libs/libjpeg-turbo/jquant2.c
+++ b/contrib/libs/libjpeg-turbo/src/jquant2.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009, 2014-2015, 2020, D. R. Commander.
+ * Copyright (C) 2009, 2014-2015, 2020, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -23,8 +23,9 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
-#ifdef QUANT_2PASS_SUPPORTED
+#if defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16
/*
@@ -106,7 +107,7 @@ static const int c_scales[3] = { R_SCALE, G_SCALE, B_SCALE };
* each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries.
*/
-#define MAXNUMCOLORS (MAXJSAMPLE + 1) /* maximum size of colormap */
+#define MAXNUMCOLORS (_MAXJSAMPLE + 1) /* maximum size of colormap */
/* These will do the right thing for either R,G,B or B,G,R color order,
* but you may not like the results for other color orders.
@@ -173,7 +174,7 @@ typedef struct {
struct jpeg_color_quantizer pub; /* public fields */
/* Space for the eventually created colormap is stashed here */
- JSAMPARRAY sv_colormap; /* colormap allocated at init time */
+ _JSAMPARRAY sv_colormap; /* colormap allocated at init time */
int desired; /* desired # of colors = size of colormap */
/* Variables for accumulating image statistics */
@@ -200,11 +201,11 @@ typedef my_cquantizer *my_cquantize_ptr;
*/
METHODDEF(void)
-prescan_quantize(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+prescan_quantize(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register histptr histp;
register hist3d histogram = cquantize->histogram;
int row;
@@ -377,7 +378,7 @@ have_c2max:
* against making long narrow boxes, and it has the side benefit that
* a box is splittable iff norm > 0.
* Since the differences are expressed in histogram-cell units,
- * we have to shift back to JSAMPLE units to get consistent distances;
+ * we have to shift back to _JSAMPLE units to get consistent distances;
* after which, we scale according to the selected distance scale factors.
*/
dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE;
@@ -508,9 +509,12 @@ compute_color(j_decompress_ptr cinfo, boxptr boxp, int icolor)
}
}
- cinfo->colormap[0][icolor] = (JSAMPLE)((c0total + (total >> 1)) / total);
- cinfo->colormap[1][icolor] = (JSAMPLE)((c1total + (total >> 1)) / total);
- cinfo->colormap[2][icolor] = (JSAMPLE)((c2total + (total >> 1)) / total);
+ ((_JSAMPARRAY)cinfo->colormap)[0][icolor] =
+ (_JSAMPLE)((c0total + (total >> 1)) / total);
+ ((_JSAMPARRAY)cinfo->colormap)[1][icolor] =
+ (_JSAMPLE)((c1total + (total >> 1)) / total);
+ ((_JSAMPARRAY)cinfo->colormap)[2][icolor] =
+ (_JSAMPLE)((c2total + (total >> 1)) / total);
}
@@ -528,11 +532,11 @@ select_colors(j_decompress_ptr cinfo, int desired_colors)
/* Initialize one box containing whole space */
numboxes = 1;
boxlist[0].c0min = 0;
- boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT;
+ boxlist[0].c0max = _MAXJSAMPLE >> C0_SHIFT;
boxlist[0].c1min = 0;
- boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT;
+ boxlist[0].c1max = _MAXJSAMPLE >> C1_SHIFT;
boxlist[0].c2min = 0;
- boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT;
+ boxlist[0].c2max = _MAXJSAMPLE >> C2_SHIFT;
/* Shrink it to actually-used volume and set its statistics */
update_box(cinfo, &boxlist[0]);
/* Perform median-cut to produce final box list */
@@ -623,7 +627,7 @@ select_colors(j_decompress_ptr cinfo, int desired_colors)
LOCAL(int)
find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
- JSAMPLE colorlist[])
+ _JSAMPLE colorlist[])
/* Locate the colormap entries close enough to an update box to be candidates
* for the nearest entry to some cell(s) in the update box. The update box
* is specified by the center coordinates of its first cell. The number of
@@ -665,7 +669,7 @@ find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
for (i = 0; i < numcolors; i++) {
/* We compute the squared-c0-distance term, then add in the other two. */
- x = cinfo->colormap[0][i];
+ x = ((_JSAMPARRAY)cinfo->colormap)[0][i];
if (x < minc0) {
tdist = (x - minc0) * C0_SCALE;
min_dist = tdist * tdist;
@@ -688,7 +692,7 @@ find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
}
}
- x = cinfo->colormap[1][i];
+ x = ((_JSAMPARRAY)cinfo->colormap)[1][i];
if (x < minc1) {
tdist = (x - minc1) * C1_SCALE;
min_dist += tdist * tdist;
@@ -710,7 +714,7 @@ find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
}
}
- x = cinfo->colormap[2][i];
+ x = ((_JSAMPARRAY)cinfo->colormap)[2][i];
if (x < minc2) {
tdist = (x - minc2) * C2_SCALE;
min_dist += tdist * tdist;
@@ -744,7 +748,7 @@ find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
ncolors = 0;
for (i = 0; i < numcolors; i++) {
if (mindist[i] <= minmaxdist)
- colorlist[ncolors++] = (JSAMPLE)i;
+ colorlist[ncolors++] = (_JSAMPLE)i;
}
return ncolors;
}
@@ -752,7 +756,7 @@ find_nearby_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
LOCAL(void)
find_best_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
- int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[])
+ int numcolors, _JSAMPLE colorlist[], _JSAMPLE bestcolor[])
/* Find the closest colormap entry for each cell in the update box,
* given the list of candidate colors prepared by find_nearby_colors.
* Return the indexes of the closest entries in the bestcolor[] array.
@@ -763,7 +767,7 @@ find_best_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
int ic0, ic1, ic2;
int i, icolor;
register JLONG *bptr; /* pointer into bestdist[] array */
- JSAMPLE *cptr; /* pointer into bestcolor[] array */
+ _JSAMPLE *cptr; /* pointer into bestcolor[] array */
JLONG dist0, dist1; /* initial distance values */
register JLONG dist2; /* current distance in inner loop */
JLONG xx0, xx1; /* distance increments */
@@ -790,11 +794,11 @@ find_best_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
for (i = 0; i < numcolors; i++) {
icolor = colorlist[i];
/* Compute (square of) distance from minc0/c1/c2 to this color */
- inc0 = (minc0 - cinfo->colormap[0][icolor]) * C0_SCALE;
+ inc0 = (minc0 - ((_JSAMPARRAY)cinfo->colormap)[0][icolor]) * C0_SCALE;
dist0 = inc0 * inc0;
- inc1 = (minc1 - cinfo->colormap[1][icolor]) * C1_SCALE;
+ inc1 = (minc1 - ((_JSAMPARRAY)cinfo->colormap)[1][icolor]) * C1_SCALE;
dist0 += inc1 * inc1;
- inc2 = (minc2 - cinfo->colormap[2][icolor]) * C2_SCALE;
+ inc2 = (minc2 - ((_JSAMPARRAY)cinfo->colormap)[2][icolor]) * C2_SCALE;
dist0 += inc2 * inc2;
/* Form the initial difference increments */
inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0;
@@ -813,7 +817,7 @@ find_best_colors(j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
for (ic2 = BOX_C2_ELEMS - 1; ic2 >= 0; ic2--) {
if (dist2 < *bptr) {
*bptr = dist2;
- *cptr = (JSAMPLE)icolor;
+ *cptr = (_JSAMPLE)icolor;
}
dist2 += xx2;
xx2 += 2 * STEP_C2 * STEP_C2;
@@ -840,13 +844,13 @@ fill_inverse_cmap(j_decompress_ptr cinfo, int c0, int c1, int c2)
hist3d histogram = cquantize->histogram;
int minc0, minc1, minc2; /* lower left corner of update box */
int ic0, ic1, ic2;
- register JSAMPLE *cptr; /* pointer into bestcolor[] array */
+ register _JSAMPLE *cptr; /* pointer into bestcolor[] array */
register histptr cachep; /* pointer into main cache array */
/* This array lists the candidate colormap indexes. */
- JSAMPLE colorlist[MAXNUMCOLORS];
+ _JSAMPLE colorlist[MAXNUMCOLORS];
int numcolors; /* number of candidate colors */
/* This array holds the actually closest colormap index for each cell. */
- JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
+ _JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
/* Convert cell coordinates to update box ID */
c0 >>= BOX_C0_LOG;
@@ -891,13 +895,13 @@ fill_inverse_cmap(j_decompress_ptr cinfo, int c0, int c1, int c2)
*/
METHODDEF(void)
-pass2_no_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+pass2_no_dither(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
/* This version performs no dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
hist3d histogram = cquantize->histogram;
- register JSAMPROW inptr, outptr;
+ register _JSAMPROW inptr, outptr;
register histptr cachep;
register int c0, c1, c2;
int row;
@@ -918,15 +922,15 @@ pass2_no_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
if (*cachep == 0)
fill_inverse_cmap(cinfo, c0, c1, c2);
/* Now emit the colormap index for this cell */
- *outptr++ = (JSAMPLE)(*cachep - 1);
+ *outptr++ = (_JSAMPLE)(*cachep - 1);
}
}
}
METHODDEF(void)
-pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+pass2_fs_dither(j_decompress_ptr cinfo, _JSAMPARRAY input_buf,
+ _JSAMPARRAY output_buf, int num_rows)
/* This version performs Floyd-Steinberg dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
@@ -935,19 +939,19 @@ pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */
LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */
register FSERRPTR errorptr; /* => fserrors[] at column before current */
- JSAMPROW inptr; /* => current input pixel */
- JSAMPROW outptr; /* => current output pixel */
+ _JSAMPROW inptr; /* => current input pixel */
+ _JSAMPROW outptr; /* => current output pixel */
histptr cachep;
int dir; /* +1 or -1 depending on direction */
int dir3; /* 3*dir, for advancing inptr & errorptr */
int row;
JDIMENSION col;
JDIMENSION width = cinfo->output_width;
- JSAMPLE *range_limit = cinfo->sample_range_limit;
+ _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
int *error_limit = cquantize->error_limiter;
- JSAMPROW colormap0 = cinfo->colormap[0];
- JSAMPROW colormap1 = cinfo->colormap[1];
- JSAMPROW colormap2 = cinfo->colormap[2];
+ _JSAMPROW colormap0 = ((_JSAMPARRAY)cinfo->colormap)[0];
+ _JSAMPROW colormap1 = ((_JSAMPARRAY)cinfo->colormap)[1];
+ _JSAMPROW colormap2 = ((_JSAMPARRAY)cinfo->colormap)[2];
SHIFT_TEMPS
for (row = 0; row < num_rows; row++) {
@@ -992,8 +996,8 @@ pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
cur0 = error_limit[cur0];
cur1 = error_limit[cur1];
cur2 = error_limit[cur2];
- /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE.
- * The maximum error is +- MAXJSAMPLE (or less with error limiting);
+ /* Form pixel value + error, and range-limit to 0.._MAXJSAMPLE.
+ * The maximum error is +- _MAXJSAMPLE (or less with error limiting);
* this sets the required size of the range_limit array.
*/
cur0 += inptr[0];
@@ -1013,7 +1017,7 @@ pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
/* Now emit the colormap index for this cell */
{
register int pixcode = *cachep - 1;
- *outptr = (JSAMPLE)pixcode;
+ *outptr = (_JSAMPLE)pixcode;
/* Compute representation error for this pixel */
cur0 -= colormap0[pixcode];
cur1 -= colormap1[pixcode];
@@ -1064,7 +1068,7 @@ pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
/*
* Initialize the error-limiting transfer function (lookup table).
* The raw F-S error computation can potentially compute error values of up to
- * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be
+ * +- _MAXJSAMPLE. But we want the maximum correction applied to a pixel to be
* much less, otherwise obviously wrong pixels will be created. (Typical
* effects include weird fringes at color-area boundaries, isolated bright
* pixels in a dark area, etc.) The standard advice for avoiding this problem
@@ -1073,7 +1077,7 @@ pass2_fs_dither(j_decompress_ptr cinfo, JSAMPARRAY input_buf,
* error buildup. However, that only prevents the error from getting
* completely out of hand; Aaron Giles reports that error limiting improves
* the results even with corner colors allocated.
- * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty
+ * A simple clamping of the error values to about +- _MAXJSAMPLE/8 works pretty
* well, but the smoother transfer function used below is even better. Thanks
* to Aaron Giles for this idea.
*/
@@ -1087,22 +1091,22 @@ init_error_limit(j_decompress_ptr cinfo)
int in, out;
table = (int *)(*cinfo->mem->alloc_small)
- ((j_common_ptr)cinfo, JPOOL_IMAGE, (MAXJSAMPLE * 2 + 1) * sizeof(int));
- table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
+ ((j_common_ptr)cinfo, JPOOL_IMAGE, (_MAXJSAMPLE * 2 + 1) * sizeof(int));
+ table += _MAXJSAMPLE; /* so can index -_MAXJSAMPLE .. +_MAXJSAMPLE */
cquantize->error_limiter = table;
-#define STEPSIZE ((MAXJSAMPLE + 1) / 16)
- /* Map errors 1:1 up to +- MAXJSAMPLE/16 */
+#define STEPSIZE ((_MAXJSAMPLE + 1) / 16)
+ /* Map errors 1:1 up to +- _MAXJSAMPLE/16 */
out = 0;
for (in = 0; in < STEPSIZE; in++, out++) {
table[in] = out; table[-in] = -out;
}
- /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */
+ /* Map errors 1:2 up to +- 3*_MAXJSAMPLE/16 */
for (; in < STEPSIZE * 3; in++, out += (in & 1) ? 0 : 1) {
table[in] = out; table[-in] = -out;
}
- /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */
- for (; in <= MAXJSAMPLE; in++) {
+ /* Clamp the rest to final out value (which is (_MAXJSAMPLE+1)/8) */
+ for (; in <= _MAXJSAMPLE; in++) {
table[in] = out; table[-in] = -out;
}
#undef STEPSIZE
@@ -1119,7 +1123,7 @@ finish_pass1(j_decompress_ptr cinfo)
my_cquantize_ptr cquantize = (my_cquantize_ptr)cinfo->cquantize;
/* Select the representative colors and fill in cinfo->colormap */
- cinfo->colormap = cquantize->sv_colormap;
+ cinfo->colormap = (JSAMPARRAY)cquantize->sv_colormap;
select_colors(cinfo, cquantize->desired);
/* Force next pass to zero the color index table */
cquantize->needs_zeroed = TRUE;
@@ -1151,15 +1155,15 @@ start_pass_2_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
if (is_pre_scan) {
/* Set up method pointers */
- cquantize->pub.color_quantize = prescan_quantize;
+ cquantize->pub._color_quantize = prescan_quantize;
cquantize->pub.finish_pass = finish_pass1;
cquantize->needs_zeroed = TRUE; /* Always zero histogram */
} else {
/* Set up method pointers */
if (cinfo->dither_mode == JDITHER_FS)
- cquantize->pub.color_quantize = pass2_fs_dither;
+ cquantize->pub._color_quantize = pass2_fs_dither;
else
- cquantize->pub.color_quantize = pass2_no_dither;
+ cquantize->pub._color_quantize = pass2_no_dither;
cquantize->pub.finish_pass = finish_pass2;
/* Make sure color count is acceptable */
@@ -1215,11 +1219,14 @@ new_color_map_2_quant(j_decompress_ptr cinfo)
*/
GLOBAL(void)
-jinit_2pass_quantizer(j_decompress_ptr cinfo)
+_jinit_2pass_quantizer(j_decompress_ptr cinfo)
{
my_cquantize_ptr cquantize;
int i;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
cquantize = (my_cquantize_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(my_cquantizer));
@@ -1230,7 +1237,8 @@ jinit_2pass_quantizer(j_decompress_ptr cinfo)
cquantize->error_limiter = NULL;
/* Make sure jdmaster didn't give me a case I can't handle */
- if (cinfo->out_color_components != 3)
+ if (cinfo->out_color_components != 3 ||
+ cinfo->out_color_space == JCS_RGB565 || cinfo->master->lossless)
ERREXIT(cinfo, JERR_NOTIMPL);
/* Allocate the histogram/inverse colormap storage */
@@ -1253,10 +1261,10 @@ jinit_2pass_quantizer(j_decompress_ptr cinfo)
/* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */
if (desired < 8)
ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8);
- /* Make sure colormap indexes can be represented by JSAMPLEs */
+ /* Make sure colormap indexes can be represented by _JSAMPLEs */
if (desired > MAXNUMCOLORS)
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
- cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
+ cquantize->sv_colormap = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)desired, (JDIMENSION)3);
cquantize->desired = desired;
} else
@@ -1282,4 +1290,4 @@ jinit_2pass_quantizer(j_decompress_ptr cinfo)
}
}
-#endif /* QUANT_2PASS_SUPPORTED */
+#endif /* defined(QUANT_2PASS_SUPPORTED) && BITS_IN_JSAMPLE != 16 */
diff --git a/contrib/libs/libjpeg-turbo/src/jsamplecomp.h b/contrib/libs/libjpeg-turbo/src/jsamplecomp.h
new file mode 100644
index 00000000000..3a1f2960299
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/jsamplecomp.h
@@ -0,0 +1,333 @@
+/*
+ * jsamplecomp.h
+ *
+ * Copyright (C) 2022, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ */
+
+/* In source files that must be compiled for multiple data precisions, we
+ * prefix all precision-dependent data types, macros, methods, fields, and
+ * function names with an underscore. Including this file replaces those
+ * precision-independent tokens with their precision-dependent equivalents,
+ * based on the value of BITS_IN_JSAMPLE.
+ */
+
+#ifndef JSAMPLECOMP_H
+#define JSAMPLECOMP_H
+
+#if BITS_IN_JSAMPLE == 16
+
+/* Sample data types and macros (jmorecfg.h) */
+#define _JSAMPLE J16SAMPLE
+
+#define _MAXJSAMPLE MAXJ16SAMPLE
+#define _CENTERJSAMPLE CENTERJ16SAMPLE
+
+#define _JSAMPROW J16SAMPROW
+#define _JSAMPARRAY J16SAMPARRAY
+#define _JSAMPIMAGE J16SAMPIMAGE
+
+/* External functions (jpeglib.h) */
+#define _jpeg_write_scanlines jpeg16_write_scanlines
+#define _jpeg_read_scanlines jpeg16_read_scanlines
+
+/* Internal methods (jpegint.h) */
+
+#ifdef C_LOSSLESS_SUPPORTED
+/* Use the 16-bit method in the jpeg_c_main_controller structure. */
+#define _process_data process_data_16
+/* Use the 16-bit method in the jpeg_c_prep_controller structure. */
+#define _pre_process_data pre_process_data_16
+/* Use the 16-bit method in the jpeg_c_coef_controller structure. */
+#define _compress_data compress_data_16
+/* Use the 16-bit method in the jpeg_color_converter structure. */
+#define _color_convert color_convert_16
+/* Use the 16-bit method in the jpeg_downsampler structure. */
+#define _downsample downsample_16
+#endif
+#ifdef D_LOSSLESS_SUPPORTED
+/* Use the 16-bit method in the jpeg_d_main_controller structure. */
+#define _process_data process_data_16
+/* Use the 16-bit method in the jpeg_d_coef_controller structure. */
+#define _decompress_data decompress_data_16
+/* Use the 16-bit method in the jpeg_d_post_controller structure. */
+#define _post_process_data post_process_data_16
+/* Use the 16-bit method in the jpeg_upsampler structure. */
+#define _upsample upsample_16
+/* Use the 16-bit method in the jpeg_color_converter structure. */
+#define _color_convert color_convert_16
+#endif
+
+/* Global internal functions (jpegint.h) */
+#ifdef C_LOSSLESS_SUPPORTED
+#define _jinit_c_main_controller j16init_c_main_controller
+#define _jinit_c_prep_controller j16init_c_prep_controller
+#define _jinit_color_converter j16init_color_converter
+#define _jinit_downsampler j16init_downsampler
+#define _jinit_c_diff_controller j16init_c_diff_controller
+#define _jinit_lossless_compressor j16init_lossless_compressor
+#endif
+
+#ifdef D_LOSSLESS_SUPPORTED
+#define _jinit_d_main_controller j16init_d_main_controller
+#define _jinit_d_post_controller j16init_d_post_controller
+#define _jinit_upsampler j16init_upsampler
+#define _jinit_color_deconverter j16init_color_deconverter
+#define _jinit_merged_upsampler j16init_merged_upsampler
+#define _jinit_d_diff_controller j16init_d_diff_controller
+#define _jinit_lossless_decompressor j16init_lossless_decompressor
+#endif
+
+#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
+#define _jcopy_sample_rows j16copy_sample_rows
+#endif
+
+/* Internal fields (cdjpeg.h) */
+
+#if defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
+/* Use the 16-bit buffer in the cjpeg_source_struct and djpeg_dest_struct
+ structures. */
+#define _buffer buffer16
+#endif
+
+/* Image I/O functions (cdjpeg.h) */
+#ifdef C_LOSSLESS_SUPPORTED
+#define _jinit_read_ppm j16init_read_ppm
+#endif
+
+#ifdef D_LOSSLESS_SUPPORTED
+#define _jinit_write_ppm j16init_write_ppm
+#endif
+
+#elif BITS_IN_JSAMPLE == 12
+
+/* Sample data types and macros (jmorecfg.h) */
+#define _JSAMPLE J12SAMPLE
+
+#define _MAXJSAMPLE MAXJ12SAMPLE
+#define _CENTERJSAMPLE CENTERJ12SAMPLE
+
+#define _JSAMPROW J12SAMPROW
+#define _JSAMPARRAY J12SAMPARRAY
+#define _JSAMPIMAGE J12SAMPIMAGE
+
+/* External functions (jpeglib.h) */
+#define _jpeg_write_scanlines jpeg12_write_scanlines
+#define _jpeg_write_raw_data jpeg12_write_raw_data
+#define _jpeg_read_scanlines jpeg12_read_scanlines
+#define _jpeg_skip_scanlines jpeg12_skip_scanlines
+#define _jpeg_crop_scanline jpeg12_crop_scanline
+#define _jpeg_read_raw_data jpeg12_read_raw_data
+
+/* Internal methods (jpegint.h) */
+
+/* Use the 12-bit method in the jpeg_c_main_controller structure. */
+#define _process_data process_data_12
+/* Use the 12-bit method in the jpeg_c_prep_controller structure. */
+#define _pre_process_data pre_process_data_12
+/* Use the 12-bit method in the jpeg_c_coef_controller structure. */
+#define _compress_data compress_data_12
+/* Use the 12-bit method in the jpeg_color_converter structure. */
+#define _color_convert color_convert_12
+/* Use the 12-bit method in the jpeg_downsampler structure. */
+#define _downsample downsample_12
+/* Use the 12-bit method in the jpeg_forward_dct structure. */
+#define _forward_DCT forward_DCT_12
+/* Use the 12-bit method in the jpeg_d_main_controller structure. */
+#define _process_data process_data_12
+/* Use the 12-bit method in the jpeg_d_coef_controller structure. */
+#define _decompress_data decompress_data_12
+/* Use the 12-bit method in the jpeg_d_post_controller structure. */
+#define _post_process_data post_process_data_12
+/* Use the 12-bit method in the jpeg_inverse_dct structure. */
+#define _inverse_DCT_method_ptr inverse_DCT_12_method_ptr
+#define _inverse_DCT inverse_DCT_12
+/* Use the 12-bit method in the jpeg_upsampler structure. */
+#define _upsample upsample_12
+/* Use the 12-bit method in the jpeg_color_converter structure. */
+#define _color_convert color_convert_12
+/* Use the 12-bit method in the jpeg_color_quantizer structure. */
+#define _color_quantize color_quantize_12
+
+/* Global internal functions (jpegint.h) */
+#define _jinit_c_main_controller j12init_c_main_controller
+#define _jinit_c_prep_controller j12init_c_prep_controller
+#define _jinit_c_coef_controller j12init_c_coef_controller
+#define _jinit_color_converter j12init_color_converter
+#define _jinit_downsampler j12init_downsampler
+#define _jinit_forward_dct j12init_forward_dct
+#ifdef C_LOSSLESS_SUPPORTED
+#define _jinit_c_diff_controller j12init_c_diff_controller
+#define _jinit_lossless_compressor j12init_lossless_compressor
+#endif
+
+#define _jinit_d_main_controller j12init_d_main_controller
+#define _jinit_d_coef_controller j12init_d_coef_controller
+#define _jinit_d_post_controller j12init_d_post_controller
+#define _jinit_inverse_dct j12init_inverse_dct
+#define _jinit_upsampler j12init_upsampler
+#define _jinit_color_deconverter j12init_color_deconverter
+#define _jinit_1pass_quantizer j12init_1pass_quantizer
+#define _jinit_2pass_quantizer j12init_2pass_quantizer
+#define _jinit_merged_upsampler j12init_merged_upsampler
+#ifdef D_LOSSLESS_SUPPORTED
+#define _jinit_d_diff_controller j12init_d_diff_controller
+#define _jinit_lossless_decompressor j12init_lossless_decompressor
+#endif
+
+#define _jcopy_sample_rows j12copy_sample_rows
+
+/* Global internal functions (jdct.h) */
+#define _jpeg_fdct_islow jpeg12_fdct_islow
+#define _jpeg_fdct_ifast jpeg12_fdct_ifast
+
+#define _jpeg_idct_islow jpeg12_idct_islow
+#define _jpeg_idct_ifast jpeg12_idct_ifast
+#define _jpeg_idct_float jpeg12_idct_float
+#define _jpeg_idct_7x7 jpeg12_idct_7x7
+#define _jpeg_idct_6x6 jpeg12_idct_6x6
+#define _jpeg_idct_5x5 jpeg12_idct_5x5
+#define _jpeg_idct_4x4 jpeg12_idct_4x4
+#define _jpeg_idct_3x3 jpeg12_idct_3x3
+#define _jpeg_idct_2x2 jpeg12_idct_2x2
+#define _jpeg_idct_1x1 jpeg12_idct_1x1
+#define _jpeg_idct_9x9 jpeg12_idct_9x9
+#define _jpeg_idct_10x10 jpeg12_idct_10x10
+#define _jpeg_idct_11x11 jpeg12_idct_11x11
+#define _jpeg_idct_12x12 jpeg12_idct_12x12
+#define _jpeg_idct_13x13 jpeg12_idct_13x13
+#define _jpeg_idct_14x14 jpeg12_idct_14x14
+#define _jpeg_idct_15x15 jpeg12_idct_15x15
+#define _jpeg_idct_16x16 jpeg12_idct_16x16
+
+/* Internal fields (cdjpeg.h) */
+
+/* Use the 12-bit buffer in the cjpeg_source_struct and djpeg_dest_struct
+ structures. */
+#define _buffer buffer12
+
+/* Image I/O functions (cdjpeg.h) */
+#define _jinit_write_gif j12init_write_gif
+#define _jinit_read_ppm j12init_read_ppm
+#define _jinit_write_ppm j12init_write_ppm
+
+#define _read_color_map read_color_map_12
+
+#else /* BITS_IN_JSAMPLE */
+
+/* Sample data types and macros (jmorecfg.h) */
+#define _JSAMPLE JSAMPLE
+
+#define _MAXJSAMPLE MAXJSAMPLE
+#define _CENTERJSAMPLE CENTERJSAMPLE
+
+#define _JSAMPROW JSAMPROW
+#define _JSAMPARRAY JSAMPARRAY
+#define _JSAMPIMAGE JSAMPIMAGE
+
+/* External functions (jpeglib.h) */
+#define _jpeg_write_scanlines jpeg_write_scanlines
+#define _jpeg_write_raw_data jpeg_write_raw_data
+#define _jpeg_read_scanlines jpeg_read_scanlines
+#define _jpeg_skip_scanlines jpeg_skip_scanlines
+#define _jpeg_crop_scanline jpeg_crop_scanline
+#define _jpeg_read_raw_data jpeg_read_raw_data
+
+/* Internal methods (jpegint.h) */
+
+/* Use the 8-bit method in the jpeg_c_main_controller structure. */
+#define _process_data process_data
+/* Use the 8-bit method in the jpeg_c_prep_controller structure. */
+#define _pre_process_data pre_process_data
+/* Use the 8-bit method in the jpeg_c_coef_controller structure. */
+#define _compress_data compress_data
+/* Use the 8-bit method in the jpeg_color_converter structure. */
+#define _color_convert color_convert
+/* Use the 8-bit method in the jpeg_downsampler structure. */
+#define _downsample downsample
+/* Use the 8-bit method in the jpeg_forward_dct structure. */
+#define _forward_DCT forward_DCT
+/* Use the 8-bit method in the jpeg_d_main_controller structure. */
+#define _process_data process_data
+/* Use the 8-bit method in the jpeg_d_coef_controller structure. */
+#define _decompress_data decompress_data
+/* Use the 8-bit method in the jpeg_d_post_controller structure. */
+#define _post_process_data post_process_data
+/* Use the 8-bit method in the jpeg_inverse_dct structure. */
+#define _inverse_DCT_method_ptr inverse_DCT_method_ptr
+#define _inverse_DCT inverse_DCT
+/* Use the 8-bit method in the jpeg_upsampler structure. */
+#define _upsample upsample
+/* Use the 8-bit method in the jpeg_color_converter structure. */
+#define _color_convert color_convert
+/* Use the 8-bit method in the jpeg_color_quantizer structure. */
+#define _color_quantize color_quantize
+
+/* Global internal functions (jpegint.h) */
+#define _jinit_c_main_controller jinit_c_main_controller
+#define _jinit_c_prep_controller jinit_c_prep_controller
+#define _jinit_c_coef_controller jinit_c_coef_controller
+#define _jinit_color_converter jinit_color_converter
+#define _jinit_downsampler jinit_downsampler
+#define _jinit_forward_dct jinit_forward_dct
+#ifdef C_LOSSLESS_SUPPORTED
+#define _jinit_c_diff_controller jinit_c_diff_controller
+#define _jinit_lossless_compressor jinit_lossless_compressor
+#endif
+
+#define _jinit_d_main_controller jinit_d_main_controller
+#define _jinit_d_coef_controller jinit_d_coef_controller
+#define _jinit_d_post_controller jinit_d_post_controller
+#define _jinit_inverse_dct jinit_inverse_dct
+#define _jinit_upsampler jinit_upsampler
+#define _jinit_color_deconverter jinit_color_deconverter
+#define _jinit_1pass_quantizer jinit_1pass_quantizer
+#define _jinit_2pass_quantizer jinit_2pass_quantizer
+#define _jinit_merged_upsampler jinit_merged_upsampler
+#ifdef D_LOSSLESS_SUPPORTED
+#define _jinit_d_diff_controller jinit_d_diff_controller
+#define _jinit_lossless_decompressor jinit_lossless_decompressor
+#endif
+
+#define _jcopy_sample_rows jcopy_sample_rows
+
+/* Global internal functions (jdct.h) */
+#define _jpeg_fdct_islow jpeg_fdct_islow
+#define _jpeg_fdct_ifast jpeg_fdct_ifast
+
+#define _jpeg_idct_islow jpeg_idct_islow
+#define _jpeg_idct_ifast jpeg_idct_ifast
+#define _jpeg_idct_float jpeg_idct_float
+#define _jpeg_idct_7x7 jpeg_idct_7x7
+#define _jpeg_idct_6x6 jpeg_idct_6x6
+#define _jpeg_idct_5x5 jpeg_idct_5x5
+#define _jpeg_idct_4x4 jpeg_idct_4x4
+#define _jpeg_idct_3x3 jpeg_idct_3x3
+#define _jpeg_idct_2x2 jpeg_idct_2x2
+#define _jpeg_idct_1x1 jpeg_idct_1x1
+#define _jpeg_idct_9x9 jpeg_idct_9x9
+#define _jpeg_idct_10x10 jpeg_idct_10x10
+#define _jpeg_idct_11x11 jpeg_idct_11x11
+#define _jpeg_idct_12x12 jpeg_idct_12x12
+#define _jpeg_idct_13x13 jpeg_idct_13x13
+#define _jpeg_idct_14x14 jpeg_idct_14x14
+#define _jpeg_idct_15x15 jpeg_idct_15x15
+#define _jpeg_idct_16x16 jpeg_idct_16x16
+
+/* Internal fields (cdjpeg.h) */
+
+/* Use the 8-bit buffer in the cjpeg_source_struct and djpeg_dest_struct
+ structures. */
+#define _buffer buffer
+
+/* Image I/O functions (cdjpeg.h) */
+#define _jinit_write_gif jinit_write_gif
+#define _jinit_read_ppm jinit_read_ppm
+#define _jinit_write_ppm jinit_write_ppm
+
+#define _read_color_map read_color_map
+
+#endif /* BITS_IN_JSAMPLE */
+
+#endif /* JSAMPLECOMP_H */
diff --git a/contrib/libs/libjpeg-turbo/jsimd.h b/contrib/libs/libjpeg-turbo/src/jsimd.h
index 6c203655ef8..6ae021a651d 100644
--- a/contrib/libs/libjpeg-turbo/jsimd.h
+++ b/contrib/libs/libjpeg-turbo/src/jsimd.h
@@ -2,8 +2,8 @@
* jsimd.h
*
* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB
- * Copyright (C) 2011, 2014, D. R. Commander.
- * Copyright (C) 2015-2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2011, 2014, 2022, D. R. Commander.
+ * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited.
*
* Based on the x86 SIMD extension for IJG JPEG library,
@@ -12,6 +12,8 @@
*
*/
+#ifdef WITH_SIMD
+
#include "jchuff.h" /* Declarations shared with jcphuff.c */
EXTERN(int) jsimd_can_rgb_ycc(void);
@@ -114,10 +116,12 @@ EXTERN(int) jsimd_can_encode_mcu_AC_first_prepare(void);
EXTERN(void) jsimd_encode_mcu_AC_first_prepare
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *values, size_t *zerobits);
+ UJCOEF *values, size_t *zerobits);
EXTERN(int) jsimd_can_encode_mcu_AC_refine_prepare(void);
EXTERN(int) jsimd_encode_mcu_AC_refine_prepare
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
- JCOEF *absvalues, size_t *bits);
+ UJCOEF *absvalues, size_t *bits);
+
+#endif /* WITH_SIMD */
diff --git a/contrib/libs/libjpeg-turbo/jsimddct.h b/contrib/libs/libjpeg-turbo/src/jsimddct.h
index 55ee8cf67f5..55ee8cf67f5 100644
--- a/contrib/libs/libjpeg-turbo/jsimddct.h
+++ b/contrib/libs/libjpeg-turbo/src/jsimddct.h
diff --git a/contrib/libs/libjpeg-turbo/jstdhuff.c b/contrib/libs/libjpeg-turbo/src/jstdhuff.c
index 345b513d4dc..39459012055 100644
--- a/contrib/libs/libjpeg-turbo/jstdhuff.c
+++ b/contrib/libs/libjpeg-turbo/src/jstdhuff.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2013, 2022, D. R. Commander.
+ * Copyright (C) 2013, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -25,7 +25,7 @@ add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table(cinfo);
- else
+ else if (cinfo->is_decompressor)
return;
/* Copy the number-of-symbols-of-each-code-length counts */
diff --git a/contrib/libs/libjpeg-turbo/jutils.c b/contrib/libs/libjpeg-turbo/src/jutils.c
index d86271624a6..24caac19021 100644
--- a/contrib/libs/libjpeg-turbo/jutils.c
+++ b/contrib/libs/libjpeg-turbo/src/jutils.c
@@ -17,8 +17,11 @@
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
+#include "jsamplecomp.h"
+#if BITS_IN_JSAMPLE == 8
+
/*
* jpeg_zigzag_order[i] is the zigzag-order position of the i'th element
* of a DCT block read in natural order (left to right, top to bottom).
@@ -89,19 +92,24 @@ jround_up(long a, long b)
return a - (a % b);
}
+#endif /* BITS_IN_JSAMPLE == 8 */
+
+
+#if BITS_IN_JSAMPLE != 16 || \
+ defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED)
GLOBAL(void)
-jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
- JSAMPARRAY output_array, int dest_row, int num_rows,
- JDIMENSION num_cols)
+_jcopy_sample_rows(_JSAMPARRAY input_array, int source_row,
+ _JSAMPARRAY output_array, int dest_row, int num_rows,
+ JDIMENSION num_cols)
/* Copy some rows of samples from one place to another.
* num_rows rows are copied from input_array[source_row++]
* to output_array[dest_row++]; these areas may overlap for duplication.
* The source and destination arrays must be at least as wide as num_cols.
*/
{
- register JSAMPROW inptr, outptr;
- register size_t count = (size_t)(num_cols * sizeof(JSAMPLE));
+ register _JSAMPROW inptr, outptr;
+ register size_t count = (size_t)(num_cols * sizeof(_JSAMPLE));
register int row;
input_array += source_row;
@@ -114,6 +122,11 @@ jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
}
}
+#endif /* BITS_IN_JSAMPLE != 16 ||
+ defined(C_LOSSLESS_SUPPORTED) || defined(D_LOSSLESS_SUPPORTED) */
+
+
+#if BITS_IN_JSAMPLE == 8
GLOBAL(void)
jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
@@ -131,3 +144,5 @@ jzero_far(void *target, size_t bytestozero)
{
memset(target, 0, bytestozero);
}
+
+#endif /* BITS_IN_JSAMPLE == 8 */
diff --git a/contrib/libs/libjpeg-turbo/rdbmp.c b/contrib/libs/libjpeg-turbo/src/rdbmp.c
index 433ebe2e51f..613e932121a 100644
--- a/contrib/libs/libjpeg-turbo/rdbmp.c
+++ b/contrib/libs/libjpeg-turbo/src/rdbmp.c
@@ -6,7 +6,7 @@
* Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Modified 2011 by Siarhei Siamashka.
- * Copyright (C) 2015, 2017-2018, 2021-2022, D. R. Commander.
+ * Copyright (C) 2015, 2017-2018, 2021-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -180,7 +180,7 @@ get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
t = *inptr++;
if (t >= cmaplen)
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
- rgb_to_cmyk(colormap[0][t], colormap[1][t], colormap[2][t], outptr,
+ rgb_to_cmyk(255, colormap[0][t], colormap[1][t], colormap[2][t], outptr,
outptr + 1, outptr + 2, outptr + 3);
outptr += 4;
}
@@ -250,7 +250,7 @@ get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
} else if (cinfo->in_color_space == JCS_CMYK) {
for (col = cinfo->image_width; col > 0; col--) {
JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
- rgb_to_cmyk(r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
+ rgb_to_cmyk(255, r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
outptr += 4;
}
} else {
@@ -314,7 +314,7 @@ get_32bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
} else if (cinfo->in_color_space == JCS_CMYK) {
for (col = cinfo->image_width; col > 0; col--) {
JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
- rgb_to_cmyk(r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
+ rgb_to_cmyk(255, r, g, b, outptr, outptr + 1, outptr + 2, outptr + 3);
inptr++; /* skip the 4th byte (Alpha channel) */
outptr += 4;
}
@@ -523,11 +523,9 @@ start_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (biWidth <= 0 || biHeight <= 0)
ERREXIT(cinfo, JERR_BMP_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)biWidth * biHeight > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
if (biPlanes != 1)
ERREXIT(cinfo, JERR_BMP_BADPLANES);
@@ -670,6 +668,9 @@ jinit_read_bmp(j_compress_ptr cinfo, boolean use_inversion_array)
{
bmp_source_ptr source;
+ if (cinfo->data_precision != 8)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object */
source = (bmp_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@@ -678,9 +679,7 @@ jinit_read_bmp(j_compress_ptr cinfo, boolean use_inversion_array)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_bmp;
source->pub.finish_input = finish_input_bmp;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
source->use_inversion_array = use_inversion_array;
diff --git a/contrib/libs/libjpeg-turbo/rdcolmap.c b/contrib/libs/libjpeg-turbo/src/rdcolmap.c
index d2ed95cf804..836685e1b80 100644
--- a/contrib/libs/libjpeg-turbo/rdcolmap.c
+++ b/contrib/libs/libjpeg-turbo/src/rdcolmap.c
@@ -1,8 +1,10 @@
/*
* rdcolmap.c
*
+ * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -18,13 +20,15 @@
* of each desired color. Such a file can be extracted from an
* ordinary image PPM file with ppmtomap(1).
*
- * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not
+ * Rescaling a PPM that has a maxval unequal to _MAXJSAMPLE is not
* currently implemented.
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
+#include "jsamplecomp.h"
#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
/* Portions of this code are based on the PBMPLUS library, which is:
**
@@ -46,9 +50,9 @@
LOCAL(void)
add_map_entry(j_decompress_ptr cinfo, int R, int G, int B)
{
- JSAMPROW colormap0 = cinfo->colormap[0];
- JSAMPROW colormap1 = cinfo->colormap[1];
- JSAMPROW colormap2 = cinfo->colormap[2];
+ _JSAMPROW colormap0 = ((_JSAMPARRAY)cinfo->colormap)[0];
+ _JSAMPROW colormap1 = ((_JSAMPARRAY)cinfo->colormap)[1];
+ _JSAMPROW colormap2 = ((_JSAMPARRAY)cinfo->colormap)[2];
int ncolors = cinfo->actual_number_of_colors;
int index;
@@ -60,13 +64,13 @@ add_map_entry(j_decompress_ptr cinfo, int R, int G, int B)
}
/* Check for map overflow. */
- if (ncolors >= (MAXJSAMPLE + 1))
- ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE + 1));
+ if (ncolors >= (_MAXJSAMPLE + 1))
+ ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (_MAXJSAMPLE + 1));
/* OK, add color to map. */
- colormap0[ncolors] = (JSAMPLE)R;
- colormap1[ncolors] = (JSAMPLE)G;
- colormap2[ncolors] = (JSAMPLE)B;
+ colormap0[ncolors] = (_JSAMPLE)R;
+ colormap1[ncolors] = (_JSAMPLE)G;
+ colormap2[ncolors] = (_JSAMPLE)B;
cinfo->actual_number_of_colors++;
}
@@ -186,7 +190,7 @@ read_ppm_map(j_decompress_ptr cinfo, FILE *infile)
ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
/* For now, we don't support rescaling from an unusual maxval. */
- if (maxval != (unsigned int)MAXJSAMPLE)
+ if (maxval != (unsigned int)_MAXJSAMPLE)
ERREXIT(cinfo, JERR_BAD_CMAP_FILE);
switch (c) {
@@ -228,12 +232,15 @@ read_ppm_map(j_decompress_ptr cinfo, FILE *infile)
*/
GLOBAL(void)
-read_color_map(j_decompress_ptr cinfo, FILE *infile)
+_read_color_map(j_decompress_ptr cinfo, FILE *infile)
{
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Allocate space for a color map of maximum supported size. */
cinfo->colormap = (*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
- (JDIMENSION)(MAXJSAMPLE + 1), (JDIMENSION)3);
+ (JDIMENSION)(_MAXJSAMPLE + 1), (JDIMENSION)3);
cinfo->actual_number_of_colors = 0; /* initialize map to empty */
/* Read first byte to determine file format */
@@ -250,4 +257,5 @@ read_color_map(j_decompress_ptr cinfo, FILE *infile)
}
}
+#endif /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
#endif /* QUANT_2PASS_SUPPORTED */
diff --git a/contrib/libs/libjpeg-turbo/rdgif.c b/contrib/libs/libjpeg-turbo/src/rdgif.c
index bdf74012414..202d8233888 100644
--- a/contrib/libs/libjpeg-turbo/rdgif.c
+++ b/contrib/libs/libjpeg-turbo/src/rdgif.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2021-2022, D. R. Commander.
+ * Copyright (C) 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -416,11 +416,9 @@ start_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
height = LM_to_uint(hdrbuf, 2);
if (width == 0 || height == 0)
ERREXIT(cinfo, JERR_GIF_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
/* we ignore the color resolution, sort flag, and background color index */
aspectRatio = UCH(hdrbuf[6]);
if (aspectRatio != 0 && aspectRatio != 49)
@@ -465,11 +463,9 @@ start_input_gif(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
height = LM_to_uint(hdrbuf, 6);
if (width == 0 || height == 0)
ERREXIT(cinfo, JERR_GIF_EMPTY);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
source->is_interlaced = (BitSet(hdrbuf[8], INTERLACE) != 0);
/* Read local colormap if header indicates it is present */
@@ -702,6 +698,9 @@ jinit_read_gif(j_compress_ptr cinfo)
{
gif_source_ptr source;
+ if (cinfo->data_precision != 8)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object */
source = (gif_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@@ -710,9 +709,7 @@ jinit_read_gif(j_compress_ptr cinfo)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_gif;
source->pub.finish_input = finish_input_gif;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
return (cjpeg_source_ptr)source;
}
diff --git a/contrib/libs/libjpeg-turbo/rdppm.c b/contrib/libs/libjpeg-turbo/src/rdppm.c
index 294749a41c3..bab76d0e755 100644
--- a/contrib/libs/libjpeg-turbo/rdppm.c
+++ b/contrib/libs/libjpeg-turbo/src/rdppm.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2009 by Bill Allombert, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015-2017, 2020-2022, D. R. Commander.
+ * Copyright (C) 2015-2017, 2020-2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -25,7 +25,8 @@
#include "cmyk.h"
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#ifdef PPM_SUPPORTED
+#if defined(PPM_SUPPORTED) && \
+ (BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED))
/* Portions of this code are based on the PBMPLUS library, which is:
@@ -62,9 +63,9 @@ typedef struct {
/* Usually these two pointers point to the same place: */
U_CHAR *iobuffer; /* fread's I/O buffer */
- JSAMPROW pixrow; /* compressor input buffer */
+ _JSAMPROW pixrow; /* compressor input buffer */
size_t buffer_width; /* width of I/O buffer */
- JSAMPLE *rescale; /* => maxval-remapping array, or NULL */
+ _JSAMPLE *rescale; /* => maxval-remapping array, or NULL */
unsigned int maxval;
} ppm_source_struct;
@@ -124,10 +125,11 @@ read_pbm_integer(j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
* Read one row of pixels.
*
* We provide several different versions depending on input file format.
- * In all cases, input is scaled to the size of JSAMPLE.
+ * In all cases, input is scaled to cinfo->data_precision.
*
* A really fast path is provided for reading byte/sample raw files with
- * maxval = MAXJSAMPLE, which is the normal case for 8-bit data.
+ * maxval <= _MAXJSAMPLE and maxval == (1U << cinfo->data_precision) - 1U,
+ * which is the normal case for 8-bit data.
*/
@@ -137,12 +139,12 @@ get_text_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPROW ptr;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
for (col = cinfo->image_width; col > 0; col--) {
*ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
}
@@ -165,8 +167,8 @@ get_text_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPROW ptr;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
register int rindex = rgb_red[cinfo->in_color_space];
@@ -175,17 +177,17 @@ get_text_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
register int aindex = alpha_index[cinfo->in_color_space];
register int ps = rgb_pixelsize[cinfo->in_color_space];
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
+ ptr = source->pub._buffer[0];
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
if (aindex >= 0)
- GRAY_RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
- ptr[aindex] = 0xFF;)
+ GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
+ ptr[aindex] = (_JSAMPLE)maxval;)
else
- GRAY_RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
+ GRAY_RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
} else {
if (aindex >= 0)
GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
- ptr[aindex] = 0xFF;)
+ ptr[aindex] = (1 << cinfo->data_precision) - 1;)
else
GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
}
@@ -200,22 +202,22 @@ get_text_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPROW ptr;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
+ ptr = source->pub._buffer[0];
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE gray = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
+ rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
} else {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE gray = rescale[read_pbm_integer(cinfo, infile, maxval)];
+ rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
}
@@ -239,8 +241,8 @@ get_text_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPROW ptr;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
register int rindex = rgb_red[cinfo->in_color_space];
@@ -249,17 +251,17 @@ get_text_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
register int aindex = alpha_index[cinfo->in_color_space];
register int ps = rgb_pixelsize[cinfo->in_color_space];
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
+ ptr = source->pub._buffer[0];
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
if (aindex >= 0)
- RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
- ptr[aindex] = 0xFF;)
+ RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
+ ptr[aindex] = (_JSAMPLE)maxval;)
else
- RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
+ RGB_READ_LOOP((_JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
} else {
if (aindex >= 0)
RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
- ptr[aindex] = 0xFF;)
+ ptr[aindex] = (1 << cinfo->data_precision) - 1;)
else
RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
}
@@ -274,26 +276,26 @@ get_text_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
FILE *infile = source->pub.input_file;
- register JSAMPROW ptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPROW ptr;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
- ptr = source->pub.buffer[0];
- if (maxval == MAXJSAMPLE) {
+ ptr = source->pub._buffer[0];
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- JSAMPLE g = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- JSAMPLE b = (JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE r = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
+ _JSAMPLE g = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
+ _JSAMPLE b = (_JSAMPLE)read_pbm_integer(cinfo, infile, maxval);
+ rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
} else {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
- JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
- JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE r = rescale[read_pbm_integer(cinfo, infile, maxval)];
+ _JSAMPLE g = rescale[read_pbm_integer(cinfo, infile, maxval)];
+ _JSAMPLE b = rescale[read_pbm_integer(cinfo, infile, maxval)];
+ rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
}
@@ -306,14 +308,14 @@ get_scaled_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading raw-byte-format PGM files with any maxval */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
bufferptr = source->iobuffer;
for (col = cinfo->image_width; col > 0; col--) {
*ptr++ = rescale[UCH(*bufferptr++)];
@@ -328,9 +330,9 @@ get_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
and converting to extended RGB */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
register int rindex = rgb_red[cinfo->in_color_space];
@@ -341,16 +343,17 @@ get_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
if (aindex >= 0)
- GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = 0xFF;)
+ GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
else
GRAY_RGB_READ_LOOP(*bufferptr++, {})
} else {
if (aindex >= 0)
- GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = 0xFF;)
+ GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)],
+ ptr[aindex] = (1 << cinfo->data_precision) - 1;)
else
GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
}
@@ -364,26 +367,26 @@ get_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
and converting to CMYK */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = *bufferptr++;
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE gray = *bufferptr++;
+ rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
} else {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE gray = rescale[UCH(*bufferptr++)];
- rgb_to_cmyk(gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE gray = rescale[UCH(*bufferptr++)];
+ rgb_to_cmyk(maxval, gray, gray, gray, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
}
@@ -396,9 +399,9 @@ get_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading raw-byte-format PPM files with any maxval */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
register int rindex = rgb_red[cinfo->in_color_space];
@@ -409,16 +412,17 @@ get_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
if (aindex >= 0)
- RGB_READ_LOOP(*bufferptr++, ptr[aindex] = 0xFF;)
+ RGB_READ_LOOP(*bufferptr++, ptr[aindex] = (_JSAMPLE)maxval;)
else
RGB_READ_LOOP(*bufferptr++, {})
} else {
if (aindex >= 0)
- RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = 0xFF;)
+ RGB_READ_LOOP(rescale[UCH(*bufferptr++)],
+ ptr[aindex] = (1 << cinfo->data_precision) - 1;)
else
RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
}
@@ -432,30 +436,30 @@ get_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
converting to CMYK */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
bufferptr = source->iobuffer;
- if (maxval == MAXJSAMPLE) {
+ if (maxval == (1U << cinfo->data_precision) - 1U) {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = *bufferptr++;
- JSAMPLE g = *bufferptr++;
- JSAMPLE b = *bufferptr++;
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE r = *bufferptr++;
+ _JSAMPLE g = *bufferptr++;
+ _JSAMPLE b = *bufferptr++;
+ rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
} else {
for (col = cinfo->image_width; col > 0; col--) {
- JSAMPLE r = rescale[UCH(*bufferptr++)];
- JSAMPLE g = rescale[UCH(*bufferptr++)];
- JSAMPLE b = rescale[UCH(*bufferptr++)];
- rgb_to_cmyk(r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
+ _JSAMPLE r = rescale[UCH(*bufferptr++)];
+ _JSAMPLE g = rescale[UCH(*bufferptr++)];
+ _JSAMPLE b = rescale[UCH(*bufferptr++)];
+ rgb_to_cmyk(maxval, r, g, b, ptr, ptr + 1, ptr + 2, ptr + 3);
ptr += 4;
}
}
@@ -465,8 +469,9 @@ get_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
METHODDEF(JDIMENSION)
get_raw_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
-/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE.
- * In this case we just read right into the JSAMPLE buffer!
+/* This version is for reading raw-byte-format files with
+ * maxval <= _MAXJSAMPLE and maxval == (1U << cinfo->data_precision) - 1U.
+ * In this case we just read right into the _JSAMPLE buffer!
* Note that same code works for PPM and PGM files.
*/
{
@@ -483,15 +488,15 @@ get_word_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading raw-word-format PGM files with any maxval */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
bufferptr = source->iobuffer;
for (col = cinfo->image_width; col > 0; col--) {
register unsigned int temp;
@@ -506,13 +511,77 @@ get_word_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
METHODDEF(JDIMENSION)
+get_word_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+/* This version is for reading raw-word-format PGM files with any maxval */
+{
+ ppm_source_ptr source = (ppm_source_ptr)sinfo;
+ register _JSAMPROW ptr;
+ register U_CHAR *bufferptr;
+ register _JSAMPLE *rescale = source->rescale;
+ JDIMENSION col;
+ unsigned int maxval = source->maxval;
+ register int rindex = rgb_red[cinfo->in_color_space];
+ register int gindex = rgb_green[cinfo->in_color_space];
+ register int bindex = rgb_blue[cinfo->in_color_space];
+ register int aindex = alpha_index[cinfo->in_color_space];
+ register int ps = rgb_pixelsize[cinfo->in_color_space];
+
+ if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
+ ERREXIT(cinfo, JERR_INPUT_EOF);
+ ptr = source->pub._buffer[0];
+ bufferptr = source->iobuffer;
+ for (col = cinfo->image_width; col > 0; col--) {
+ register unsigned int temp;
+ temp = UCH(*bufferptr++) << 8;
+ temp |= UCH(*bufferptr++);
+ if (temp > maxval)
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
+ ptr[rindex] = ptr[gindex] = ptr[bindex] = rescale[temp];
+ if (aindex >= 0)
+ ptr[aindex] = (1 << cinfo->data_precision) - 1;
+ ptr += ps;
+ }
+ return 1;
+}
+
+
+METHODDEF(JDIMENSION)
+get_word_gray_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+/* This version is for reading raw-word-format PGM files with any maxval */
+{
+ ppm_source_ptr source = (ppm_source_ptr)sinfo;
+ register _JSAMPROW ptr;
+ register U_CHAR *bufferptr;
+ register _JSAMPLE *rescale = source->rescale;
+ JDIMENSION col;
+ unsigned int maxval = source->maxval;
+
+ if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
+ ERREXIT(cinfo, JERR_INPUT_EOF);
+ ptr = source->pub._buffer[0];
+ bufferptr = source->iobuffer;
+ for (col = cinfo->image_width; col > 0; col--) {
+ register unsigned int gray;
+ gray = UCH(*bufferptr++) << 8;
+ gray |= UCH(*bufferptr++);
+ if (gray > maxval)
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
+ rgb_to_cmyk(maxval, rescale[gray], rescale[gray], rescale[gray], ptr,
+ ptr + 1, ptr + 2, ptr + 3);
+ ptr += 4;
+ }
+ return 1;
+}
+
+
+METHODDEF(JDIMENSION)
get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading raw-word-format PPM files with any maxval */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register U_CHAR *bufferptr;
- register JSAMPLE *rescale = source->rescale;
+ register _JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
register int rindex = rgb_red[cinfo->in_color_space];
@@ -523,7 +592,7 @@ get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
- ptr = source->pub.buffer[0];
+ ptr = source->pub._buffer[0];
bufferptr = source->iobuffer;
for (col = cinfo->image_width; col > 0; col--) {
register unsigned int temp;
@@ -543,13 +612,50 @@ get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
ptr[bindex] = rescale[temp];
if (aindex >= 0)
- ptr[aindex] = 0xFF;
+ ptr[aindex] = (1 << cinfo->data_precision) - 1;
ptr += ps;
}
return 1;
}
+METHODDEF(JDIMENSION)
+get_word_rgb_cmyk_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
+/* This version is for reading raw-word-format PPM files with any maxval */
+{
+ ppm_source_ptr source = (ppm_source_ptr)sinfo;
+ register _JSAMPROW ptr;
+ register U_CHAR *bufferptr;
+ register _JSAMPLE *rescale = source->rescale;
+ JDIMENSION col;
+ unsigned int maxval = source->maxval;
+
+ if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
+ ERREXIT(cinfo, JERR_INPUT_EOF);
+ ptr = source->pub._buffer[0];
+ bufferptr = source->iobuffer;
+ for (col = cinfo->image_width; col > 0; col--) {
+ register unsigned int r, g, b;
+ r = UCH(*bufferptr++) << 8;
+ r |= UCH(*bufferptr++);
+ if (r > maxval)
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
+ g = UCH(*bufferptr++) << 8;
+ g |= UCH(*bufferptr++);
+ if (g > maxval)
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
+ b = UCH(*bufferptr++) << 8;
+ b |= UCH(*bufferptr++);
+ if (b > maxval)
+ ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
+ rgb_to_cmyk(maxval, rescale[r], rescale[g], rescale[b], ptr, ptr + 1,
+ ptr + 2, ptr + 3);
+ ptr += 4;
+ }
+ return 1;
+}
+
+
/*
* Read the file header; return image size and component count.
*/
@@ -586,12 +692,9 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (w <= 0 || h <= 0 || maxval <= 0) /* error check */
ERREXIT(cinfo, JERR_PPM_NOT);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels && (unsigned long long)w * h > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
- cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */
cinfo->image_width = (JDIMENSION)w;
cinfo->image_height = (JDIMENSION)h;
source->maxval = maxval;
@@ -606,7 +709,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (cinfo->in_color_space == JCS_UNKNOWN ||
cinfo->in_color_space == JCS_RGB)
cinfo->in_color_space = JCS_GRAYSCALE;
- TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PGM_TEXT, w, h, maxval);
if (cinfo->in_color_space == JCS_GRAYSCALE)
source->pub.get_pixel_rows = get_text_gray_row;
else if (IsExtRGB(cinfo->in_color_space))
@@ -621,7 +724,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
case '3': /* it's a text-format PPM file */
if (cinfo->in_color_space == JCS_UNKNOWN)
cinfo->in_color_space = JCS_EXT_RGB;
- TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PPM_TEXT, w, h, maxval);
if (IsExtRGB(cinfo->in_color_space))
source->pub.get_pixel_rows = get_text_rgb_row;
else if (cinfo->in_color_space == JCS_CMYK)
@@ -635,13 +738,18 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
if (cinfo->in_color_space == JCS_UNKNOWN ||
cinfo->in_color_space == JCS_RGB)
cinfo->in_color_space = JCS_GRAYSCALE;
- TRACEMS2(cinfo, 1, JTRC_PGM, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PGM, w, h, maxval);
if (maxval > 255) {
if (cinfo->in_color_space == JCS_GRAYSCALE)
source->pub.get_pixel_rows = get_word_gray_row;
+ else if (IsExtRGB(cinfo->in_color_space))
+ source->pub.get_pixel_rows = get_word_gray_rgb_row;
+ else if (cinfo->in_color_space == JCS_CMYK)
+ source->pub.get_pixel_rows = get_word_gray_cmyk_row;
else
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&
+ } else if (maxval <= _MAXJSAMPLE && sizeof(_JSAMPLE) == sizeof(U_CHAR) &&
+ maxval == ((1U << cinfo->data_precision) - 1U) &&
cinfo->in_color_space == JCS_GRAYSCALE) {
source->pub.get_pixel_rows = get_raw_row;
use_raw_buffer = TRUE;
@@ -661,13 +769,16 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
case '6': /* it's a raw-format PPM file */
if (cinfo->in_color_space == JCS_UNKNOWN)
cinfo->in_color_space = JCS_EXT_RGB;
- TRACEMS2(cinfo, 1, JTRC_PPM, w, h);
+ TRACEMS3(cinfo, 1, JTRC_PPM, w, h, maxval);
if (maxval > 255) {
if (IsExtRGB(cinfo->in_color_space))
source->pub.get_pixel_rows = get_word_rgb_row;
+ else if (cinfo->in_color_space == JCS_CMYK)
+ source->pub.get_pixel_rows = get_word_rgb_cmyk_row;
else
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
- } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR) &&
+ } else if (maxval <= _MAXJSAMPLE && sizeof(_JSAMPLE) == sizeof(U_CHAR) &&
+ maxval == ((1U << cinfo->data_precision) - 1U) &&
#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
(cinfo->in_color_space == JCS_EXT_RGB ||
cinfo->in_color_space == JCS_RGB)) {
@@ -711,13 +822,13 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* Create compressor input buffer. */
if (use_raw_buffer) {
/* For unscaled raw-input case, we can just map it onto the I/O buffer. */
- /* Synthesize a JSAMPARRAY pointer structure */
- source->pixrow = (JSAMPROW)source->iobuffer;
- source->pub.buffer = &source->pixrow;
+ /* Synthesize a _JSAMPARRAY pointer structure */
+ source->pixrow = (_JSAMPROW)source->iobuffer;
+ source->pub._buffer = &source->pixrow;
source->pub.buffer_height = 1;
} else {
/* Need to translate anyway, so make a separate sample buffer. */
- source->pub.buffer = (*cinfo->mem->alloc_sarray)
+ source->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
(JDIMENSION)w * cinfo->input_components, (JDIMENSION)1);
source->pub.buffer_height = 1;
@@ -728,17 +839,18 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
long val, half_maxval;
/* On 16-bit-int machines we have to be careful of maxval = 65535 */
- source->rescale = (JSAMPLE *)
+ source->rescale = (_JSAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(size_t)(((long)MAX(maxval, 255) + 1L) *
- sizeof(JSAMPLE)));
+ sizeof(_JSAMPLE)));
memset(source->rescale, 0, (size_t)(((long)MAX(maxval, 255) + 1L) *
- sizeof(JSAMPLE)));
+ sizeof(_JSAMPLE)));
half_maxval = maxval / 2;
for (val = 0; val <= (long)maxval; val++) {
/* The multiplication here must be done in 32 bits to avoid overflow */
- source->rescale[val] = (JSAMPLE)((val * MAXJSAMPLE + half_maxval) /
- maxval);
+ source->rescale[val] =
+ (_JSAMPLE)((val * ((1 << cinfo->data_precision) - 1) + half_maxval) /
+ maxval);
}
}
}
@@ -760,10 +872,18 @@ finish_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
*/
GLOBAL(cjpeg_source_ptr)
-jinit_read_ppm(j_compress_ptr cinfo)
+_jinit_read_ppm(j_compress_ptr cinfo)
{
ppm_source_ptr source;
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object */
source = (ppm_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@@ -771,11 +891,10 @@ jinit_read_ppm(j_compress_ptr cinfo)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_ppm;
source->pub.finish_input = finish_input_ppm;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
return (cjpeg_source_ptr)source;
}
-#endif /* PPM_SUPPORTED */
+#endif /* defined(PPM_SUPPORTED) &&
+ (BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)) */
diff --git a/contrib/libs/libjpeg-turbo/rdswitch.c b/contrib/libs/libjpeg-turbo/src/rdswitch.c
index 33449c86ba6..33449c86ba6 100644
--- a/contrib/libs/libjpeg-turbo/rdswitch.c
+++ b/contrib/libs/libjpeg-turbo/src/rdswitch.c
diff --git a/contrib/libs/libjpeg-turbo/rdtarga.c b/contrib/libs/libjpeg-turbo/src/rdtarga.c
index 3ed7eb34d8c..b78a16539e1 100644
--- a/contrib/libs/libjpeg-turbo/rdtarga.c
+++ b/contrib/libs/libjpeg-turbo/src/rdtarga.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2017 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2018, 2021-2022, D. R. Commander.
+ * Copyright (C) 2018, 2021-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -363,11 +363,9 @@ start_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
interlace_type != 0 || /* currently don't allow interlaced image */
width == 0 || height == 0) /* image width/height must be non-zero */
ERREXIT(cinfo, JERR_TGA_BADPARMS);
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if (sinfo->max_pixels &&
(unsigned long long)width * height > sinfo->max_pixels)
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
-#endif
+ ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, sinfo->max_pixels);
if (subtype > 8) {
/* It's an RLE-coded file */
@@ -490,6 +488,9 @@ jinit_read_targa(j_compress_ptr cinfo)
{
tga_source_ptr source;
+ if (cinfo->data_precision != 8)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object */
source = (tga_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@@ -498,9 +499,7 @@ jinit_read_targa(j_compress_ptr cinfo)
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
source->pub.start_input = start_input_tga;
source->pub.finish_input = finish_input_tga;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
source->pub.max_pixels = 0;
-#endif
return (cjpeg_source_ptr)source;
}
diff --git a/contrib/libs/libjpeg-turbo/tjutil.h b/contrib/libs/libjpeg-turbo/src/tjutil.h
index 10272e98867..10272e98867 100644
--- a/contrib/libs/libjpeg-turbo/tjutil.h
+++ b/contrib/libs/libjpeg-turbo/src/tjutil.h
diff --git a/contrib/libs/libjpeg-turbo/transupp.c b/contrib/libs/libjpeg-turbo/src/transupp.c
index a3d878cc735..0a92413a7f8 100644
--- a/contrib/libs/libjpeg-turbo/transupp.c
+++ b/contrib/libs/libjpeg-turbo/src/transupp.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2010, 2017, 2021-2022, D. R. Commander.
+ * Copyright (C) 2010, 2017, 2021-2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -23,7 +23,7 @@
#include "jinclude.h"
#include "jpeglib.h"
#include "transupp.h" /* My own external interface */
-#include "jpegcomp.h"
+#include "jpegapicomp.h"
#include <ctype.h> /* to declare isdigit() */
@@ -143,7 +143,7 @@ requant_comp(j_decompress_ptr cinfo, jpeg_component_info *compptr,
for (k = 0; k < DCTSIZE2; k++) {
temp = qtblptr->quantval[k];
qval = qtblptr1->quantval[k];
- if (temp != qval) {
+ if (temp != qval && qval != 0) {
temp *= ptr[k];
/* The following quantization code is copied from jcdctmgr.c */
#ifdef FAST_DIVIDE
@@ -201,7 +201,11 @@ adjust_quant(j_decompress_ptr srcinfo, jvirt_barray_ptr *src_coef_arrays,
compptr1 = srcinfo->comp_info + ci;
compptr2 = dropinfo->comp_info + ci;
qtblptr1 = compptr1->quant_table;
+ if (qtblptr1 == NULL)
+ ERREXIT1(srcinfo, JERR_NO_QUANT_TABLE, compptr1->quant_tbl_no);
qtblptr2 = compptr2->quant_table;
+ if (qtblptr2 == NULL)
+ ERREXIT1(dropinfo, JERR_NO_QUANT_TABLE, compptr2->quant_tbl_no);
for (k = 0; k < DCTSIZE2; k++) {
if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) {
if (trim)
@@ -2311,19 +2315,20 @@ jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
#ifdef SAVE_MARKERS_SUPPORTED
int m;
- /* Save comments except under NONE option */
+ /* Save comments unless JCOPYOPT_NONE or JCOPYOPT_ICC specified */
if (option != JCOPYOPT_NONE && option != JCOPYOPT_ICC) {
jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF);
}
- /* Save all types of APPn markers iff ALL option */
+ /* Save all APPn markers iff JCOPYOPT_ALL* specified ... */
if (option == JCOPYOPT_ALL || option == JCOPYOPT_ALL_EXCEPT_ICC) {
for (m = 0; m < 16; m++) {
+ /* ... except APP2 markers if JCOPYOPT_ALL_EXCEPT_ICC specified */
if (option == JCOPYOPT_ALL_EXCEPT_ICC && m == 2)
continue;
jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF);
}
}
- /* Save only APP2 markers if ICC option selected */
+ /* Save only APP2 markers if JCOPYOPT_ICC specified */
if (option == JCOPYOPT_ICC) {
jpeg_save_markers(srcinfo, JPEG_APP0 + 2, 0xFFFF);
}
@@ -2343,12 +2348,22 @@ jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
{
jpeg_saved_marker_ptr marker;
- /* In the current implementation, we don't actually need to examine the
- * option flag here; we just copy everything that got saved.
- * But to avoid confusion, we do not output JFIF and Adobe APP14 markers
- * if the encoder library already wrote one.
- */
for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {
+ if (option == JCOPYOPT_NONE)
+ continue;
+ else if (option == JCOPYOPT_COMMENTS) {
+ if (marker->marker != JPEG_COM)
+ continue;
+ } else if (option == JCOPYOPT_ALL_EXCEPT_ICC) {
+ if (marker->marker == JPEG_APP0 + 2)
+ continue;
+ } else if (option == JCOPYOPT_ICC) {
+ if (marker->marker != JPEG_APP0 + 2)
+ continue;
+ }
+ /* To avoid confusion, we do not output JFIF and Adobe APP14 markers if the
+ * encoder library already wrote one.
+ */
if (dstinfo->write_JFIF_header &&
marker->marker == JPEG_APP0 &&
marker->data_length >= 5 &&
diff --git a/contrib/libs/libjpeg-turbo/src/transupp.h b/contrib/libs/libjpeg-turbo/src/transupp.h
new file mode 100644
index 00000000000..cea1f409214
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/transupp.h
@@ -0,0 +1,231 @@
+/*
+ * transupp.h
+ *
+ * This file was part of the Independent JPEG Group's software:
+ * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
+ * libjpeg-turbo Modifications:
+ * Copyright (C) 2017, 2021, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file contains declarations for image transformation routines and
+ * other utility code used by the jpegtran sample application. These are
+ * NOT part of the core JPEG library. But we keep these routines separate
+ * from jpegtran.c to ease the task of maintaining jpegtran-like programs
+ * that have other user interfaces.
+ *
+ * NOTE: all the routines declared here have very specific requirements
+ * about when they are to be executed during the reading and writing of the
+ * source and destination files. See the comments in transupp.c, or see
+ * jpegtran.c for an example of correct usage.
+ */
+
+/* If you happen not to want the image transform support, disable it here */
+#ifndef TRANSFORMS_SUPPORTED
+#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */
+#endif
+
+/*
+ * Although rotating and flipping data expressed as DCT coefficients is not
+ * hard, there is an asymmetry in the JPEG format specification for images
+ * whose dimensions aren't multiples of the iMCU size. The right and bottom
+ * image edges are padded out to the next iMCU boundary with junk data; but
+ * no padding is possible at the top and left edges. If we were to flip
+ * the whole image including the pad data, then pad garbage would become
+ * visible at the top and/or left, and real pixels would disappear into the
+ * pad margins --- perhaps permanently, since encoders & decoders may not
+ * bother to preserve DCT blocks that appear to be completely outside the
+ * nominal image area. So, we have to exclude any partial iMCUs from the
+ * basic transformation.
+ *
+ * Transpose is the only transformation that can handle partial iMCUs at the
+ * right and bottom edges completely cleanly. flip_h can flip partial iMCUs
+ * at the bottom, but leaves any partial iMCUs at the right edge untouched.
+ * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
+ * The other transforms are defined as combinations of these basic transforms
+ * and process edge blocks in a way that preserves the equivalence.
+ *
+ * The "trim" option causes untransformable partial iMCUs to be dropped;
+ * this is not strictly lossless, but it usually gives the best-looking
+ * result for odd-size images. Note that when this option is active,
+ * the expected mathematical equivalences between the transforms may not hold.
+ * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
+ * followed by -rot 180 -trim trims both edges.)
+ *
+ * We also offer a lossless-crop option, which discards data outside a given
+ * image region but losslessly preserves what is inside. Like the rotate and
+ * flip transforms, lossless crop is restricted by the JPEG format: the upper
+ * left corner of the selected region must fall on an iMCU boundary. If this
+ * does not hold for the given crop parameters, we silently move the upper left
+ * corner up and/or left to make it so, simultaneously increasing the region
+ * dimensions to keep the lower right crop corner unchanged. (Thus, the
+ * output image covers at least the requested region, but may cover more.)
+ * The adjustment of the region dimensions may be optionally disabled.
+ *
+ * A complementary lossless wipe option is provided to discard (gray out) data
+ * inside a given image region while losslessly preserving what is outside.
+ * A lossless drop option is also provided, which allows another JPEG image to
+ * be inserted ("dropped") into the source image data at a given position,
+ * replacing the existing image data at that position. Both the source image
+ * and the drop image must have the same subsampling level. It is best if they
+ * also have the same quantization (quality.) Otherwise, the quantization of
+ * the output image will be adapted to accommodate the higher of the source
+ * image quality and the drop image quality. The trim option can be used with
+ * the drop option to requantize the drop image to match the source image.
+ *
+ * We also provide a lossless-resize option, which is kind of a lossless-crop
+ * operation in the DCT coefficient block domain - it discards higher-order
+ * coefficients and losslessly preserves lower-order coefficients of a
+ * sub-block.
+ *
+ * Rotate/flip transform, resize, and crop can be requested together in a
+ * single invocation. The crop is applied last --- that is, the crop region
+ * is specified in terms of the destination image after transform/resize.
+ *
+ * We also offer a "force to grayscale" option, which simply discards the
+ * chrominance channels of a YCbCr image. This is lossless in the sense that
+ * the luminance channel is preserved exactly. It's not the same kind of
+ * thing as the rotate/flip transformations, but it's convenient to handle it
+ * as part of this package, mainly because the transformation routines have to
+ * be aware of the option to know how many components to work on.
+ */
+
+
+/*
+ * Codes for supported types of image transformations.
+ */
+
+typedef enum {
+ JXFORM_NONE, /* no transformation */
+ JXFORM_FLIP_H, /* horizontal flip */
+ JXFORM_FLIP_V, /* vertical flip */
+ JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
+ JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
+ JXFORM_ROT_90, /* 90-degree clockwise rotation */
+ JXFORM_ROT_180, /* 180-degree rotation */
+ JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */
+ JXFORM_WIPE, /* wipe */
+ JXFORM_DROP /* drop */
+} JXFORM_CODE;
+
+/*
+ * Codes for crop parameters, which can individually be unspecified,
+ * positive or negative for xoffset or yoffset,
+ * positive or force or reflect for width or height.
+ */
+
+typedef enum {
+ JCROP_UNSET,
+ JCROP_POS,
+ JCROP_NEG,
+ JCROP_FORCE,
+ JCROP_REFLECT
+} JCROP_CODE;
+
+/*
+ * Transform parameters struct.
+ * NB: application must not change any elements of this struct after
+ * calling jtransform_request_workspace.
+ */
+
+typedef struct {
+ /* Options: set by caller */
+ JXFORM_CODE transform; /* image transform operator */
+ boolean perfect; /* if TRUE, fail if partial MCUs are requested */
+ boolean trim; /* if TRUE, trim partial MCUs as needed */
+ boolean force_grayscale; /* if TRUE, convert color image to grayscale */
+ boolean crop; /* if TRUE, crop or wipe source image, or drop */
+ boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform
+ normally modifies the source coefficients in place.
+ Setting this to TRUE will instead use a slower,
+ double-buffered algorithm, which leaves the source
+ coefficients in tact (necessary if other transformed
+ images must be generated from the same set of
+ coefficients. */
+
+ /* Crop parameters: application need not set these unless crop is TRUE.
+ * These can be filled in by jtransform_parse_crop_spec().
+ */
+ JDIMENSION crop_width; /* Width of selected region */
+ JCROP_CODE crop_width_set; /* (force-disables adjustment) */
+ JDIMENSION crop_height; /* Height of selected region */
+ JCROP_CODE crop_height_set; /* (force-disables adjustment) */
+ JDIMENSION crop_xoffset; /* X offset of selected region */
+ JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */
+ JDIMENSION crop_yoffset; /* Y offset of selected region */
+ JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */
+
+ /* Drop parameters: set by caller for drop request */
+ j_decompress_ptr drop_ptr;
+ jvirt_barray_ptr *drop_coef_arrays;
+
+ /* Internal workspace: caller should not touch these */
+ int num_components; /* # of components in workspace */
+ jvirt_barray_ptr *workspace_coef_arrays; /* workspace for transformations */
+ JDIMENSION output_width; /* cropped destination dimensions */
+ JDIMENSION output_height;
+ JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */
+ JDIMENSION y_crop_offset;
+ JDIMENSION drop_width; /* drop/wipe dimensions measured in iMCUs */
+ JDIMENSION drop_height;
+ int iMCU_sample_width; /* destination iMCU size */
+ int iMCU_sample_height;
+} jpeg_transform_info;
+
+
+#if TRANSFORMS_SUPPORTED
+
+/* Parse a crop specification (written in X11 geometry style) */
+EXTERN(boolean) jtransform_parse_crop_spec(jpeg_transform_info *info,
+ const char *spec);
+/* Request any required workspace */
+EXTERN(boolean) jtransform_request_workspace(j_decompress_ptr srcinfo,
+ jpeg_transform_info *info);
+/* Adjust output image parameters */
+EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
+ (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
+ jvirt_barray_ptr *src_coef_arrays, jpeg_transform_info *info);
+/* Execute the actual transformation, if any */
+EXTERN(void) jtransform_execute_transform(j_decompress_ptr srcinfo,
+ j_compress_ptr dstinfo,
+ jvirt_barray_ptr *src_coef_arrays,
+ jpeg_transform_info *info);
+/* Determine whether lossless transformation is perfectly
+ * possible for a specified image and transformation.
+ */
+EXTERN(boolean) jtransform_perfect_transform(JDIMENSION image_width,
+ JDIMENSION image_height,
+ int MCU_width, int MCU_height,
+ JXFORM_CODE transform);
+
+/* jtransform_execute_transform used to be called
+ * jtransform_execute_transformation, but some compilers complain about
+ * routine names that long. This macro is here to avoid breaking any
+ * old source code that uses the original name...
+ */
+#define jtransform_execute_transformation jtransform_execute_transform
+
+#endif /* TRANSFORMS_SUPPORTED */
+
+
+/*
+ * Support for copying optional markers from source to destination file.
+ */
+
+typedef enum {
+ JCOPYOPT_NONE, /* copy no optional markers */
+ JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
+ JCOPYOPT_ALL, /* copy all optional markers */
+ JCOPYOPT_ALL_EXCEPT_ICC, /* copy all optional markers except APP2 */
+ JCOPYOPT_ICC /* copy only ICC profile (APP2) markers */
+} JCOPY_OPTION;
+
+#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
+
+/* Setup decompression object to save desired markers in memory */
+EXTERN(void) jcopy_markers_setup(j_decompress_ptr srcinfo,
+ JCOPY_OPTION option);
+/* Copy markers saved in the given source object to the destination object */
+EXTERN(void) jcopy_markers_execute(j_decompress_ptr srcinfo,
+ j_compress_ptr dstinfo,
+ JCOPY_OPTION option);
diff --git a/contrib/libs/libjpeg-turbo/turbojpeg-mapfile b/contrib/libs/libjpeg-turbo/src/turbojpeg-mapfile
index 5477fed2c36..db310fb65ea 100644
--- a/contrib/libs/libjpeg-turbo/turbojpeg-mapfile
+++ b/contrib/libs/libjpeg-turbo/src/turbojpeg-mapfile
@@ -1,14 +1,14 @@
TURBOJPEG_1.0
{
global:
- tjInitCompress;
- tjCompress;
TJBUFSIZE;
- tjInitDecompress;
- tjDecompressHeader;
+ tjCompress;
tjDecompress;
+ tjDecompressHeader;
tjDestroy;
tjGetErrorStr;
+ tjInitCompress;
+ tjInitDecompress;
local:
*;
};
@@ -63,3 +63,53 @@ TURBOJPEG_2.0
tjLoadImage;
tjSaveImage;
} TURBOJPEG_1.4;
+
+TURBOJPEG_3
+{
+ global:
+ tj3Alloc;
+ tj3Compress8;
+ tj3Compress12;
+ tj3Compress16;
+ tj3CompressFromYUV8;
+ tj3CompressFromYUVPlanes8;
+ tj3DecodeYUV8;
+ tj3DecodeYUVPlanes8;
+ tj3Decompress8;
+ tj3Decompress12;
+ tj3Decompress16;
+ tj3DecompressHeader;
+ tj3DecompressToYUV8;
+ tj3DecompressToYUVPlanes8;
+ tj3Destroy;
+ tj3EncodeYUV8;
+ tj3EncodeYUVPlanes8;
+ tj3Free;
+ tj3Get;
+ tj3GetErrorCode;
+ tj3GetErrorStr;
+ tj3GetScalingFactors;
+ tj3Init;
+ tj3JPEGBufSize;
+ tj3LoadImage8;
+ tj3LoadImage12;
+ tj3LoadImage16;
+ tj3SaveImage8;
+ tj3SaveImage12;
+ tj3SaveImage16;
+ tj3Set;
+ tj3SetCroppingRegion;
+ tj3SetScalingFactor;
+ tj3Transform;
+ tj3YUVBufSize;
+ tj3YUVPlaneHeight;
+ tj3YUVPlaneSize;
+ tj3YUVPlaneWidth;
+} TURBOJPEG_2.0;
+
+TURBOJPEG_3.1
+{
+ tj3GetICCProfile;
+ tj3SetICCProfile;
+ tj3TransformBufSize;
+} TURBOJPEG_3;
diff --git a/contrib/libs/libjpeg-turbo/src/turbojpeg-mp.c b/contrib/libs/libjpeg-turbo/src/turbojpeg-mp.c
new file mode 100644
index 00000000000..1fa63b81852
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/turbojpeg-mp.c
@@ -0,0 +1,562 @@
+/*
+ * Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the libjpeg-turbo Project nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* TurboJPEG API functions that must be compiled for multiple data
+ precisions */
+
+#if BITS_IN_JSAMPLE == 8
+#define _JSAMPLE JSAMPLE
+#define _JSAMPROW JSAMPROW
+#define _buffer buffer
+#define _jinit_read_ppm jinit_read_ppm
+#define _jinit_write_ppm jinit_write_ppm
+#define _jpeg_crop_scanline jpeg_crop_scanline
+#define _jpeg_read_scanlines jpeg_read_scanlines
+#define _jpeg_skip_scanlines jpeg_skip_scanlines
+#define _jpeg_write_scanlines jpeg_write_scanlines
+#elif BITS_IN_JSAMPLE == 12
+#define _JSAMPLE J12SAMPLE
+#define _JSAMPROW J12SAMPROW
+#define _buffer buffer12
+#define _jinit_read_ppm j12init_read_ppm
+#define _jinit_write_ppm j12init_write_ppm
+#define _jpeg_crop_scanline jpeg12_crop_scanline
+#define _jpeg_read_scanlines jpeg12_read_scanlines
+#define _jpeg_skip_scanlines jpeg12_skip_scanlines
+#define _jpeg_write_scanlines jpeg12_write_scanlines
+#elif BITS_IN_JSAMPLE == 16
+#define _JSAMPLE J16SAMPLE
+#define _JSAMPROW J16SAMPROW
+#define _buffer buffer16
+#define _jinit_read_ppm j16init_read_ppm
+#define _jinit_write_ppm j16init_write_ppm
+#define _jpeg_read_scanlines jpeg16_read_scanlines
+#define _jpeg_write_scanlines jpeg16_write_scanlines
+#endif
+
+#define _GET_NAME(name, suffix) name##suffix
+#define GET_NAME(name, suffix) _GET_NAME(name, suffix)
+#define _GET_STRING(name, suffix) #name #suffix
+#define GET_STRING(name, suffix) _GET_STRING(name, suffix)
+
+
+/******************************** Compressor *********************************/
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int GET_NAME(tj3Compress, BITS_IN_JSAMPLE)
+ (tjhandle handle, const _JSAMPLE *srcBuf, int width, int pitch, int height,
+ int pixelFormat, unsigned char **jpegBuf, size_t *jpegSize)
+{
+ static const char FUNCTION_NAME[] = GET_STRING(tj3Compress, BITS_IN_JSAMPLE);
+ int i, retval = 0;
+ boolean alloc = TRUE;
+ _JSAMPROW *row_pointer = NULL;
+
+ GET_CINSTANCE(handle)
+ if ((this->init & COMPRESS) == 0)
+ THROW("Instance has not been initialized for compression");
+
+ if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
+ pixelFormat < 0 || pixelFormat >= TJ_NUMPF || jpegBuf == NULL ||
+ jpegSize == NULL)
+ THROW("Invalid argument");
+
+ if (!this->lossless && this->quality == -1)
+ THROW("TJPARAM_QUALITY must be specified");
+ if (!this->lossless && this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
+
+ if ((row_pointer = (_JSAMPROW *)malloc(sizeof(_JSAMPROW) * height)) == NULL)
+ THROW("Memory allocation failure");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ cinfo->image_width = width;
+ cinfo->image_height = height;
+ cinfo->data_precision = BITS_IN_JSAMPLE;
+#if BITS_IN_JSAMPLE == 8
+ if (this->lossless && this->precision >= 2 &&
+ this->precision <= BITS_IN_JSAMPLE)
+#else
+ if (this->lossless && this->precision >= BITS_IN_JSAMPLE - 3 &&
+ this->precision <= BITS_IN_JSAMPLE)
+#endif
+ cinfo->data_precision = this->precision;
+
+ setCompDefaults(this, pixelFormat);
+ if (this->noRealloc) alloc = FALSE;
+ jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
+
+ jpeg_start_compress(cinfo, TRUE);
+ if (this->iccBuf != NULL && this->iccSize != 0)
+ jpeg_write_icc_profile(cinfo, this->iccBuf, (unsigned int)this->iccSize);
+ for (i = 0; i < height; i++) {
+ if (this->bottomUp)
+ row_pointer[i] = (_JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
+ else
+ row_pointer[i] = (_JSAMPROW)&srcBuf[i * (size_t)pitch];
+ }
+ while (cinfo->next_scanline < cinfo->image_height)
+ _jpeg_write_scanlines(cinfo, &row_pointer[cinfo->next_scanline],
+ cinfo->image_height - cinfo->next_scanline);
+ jpeg_finish_compress(cinfo);
+
+bailout:
+ if (cinfo->global_state > CSTATE_START && alloc)
+ (*cinfo->dest->term_destination) (cinfo);
+ if (cinfo->global_state > CSTATE_START || retval == -1)
+ jpeg_abort_compress(cinfo);
+ free(row_pointer);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+
+/******************************* Decompressor ********************************/
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int GET_NAME(tj3Decompress, BITS_IN_JSAMPLE)
+ (tjhandle handle, const unsigned char *jpegBuf, size_t jpegSize,
+ _JSAMPLE *dstBuf, int pitch, int pixelFormat)
+{
+ static const char FUNCTION_NAME[] =
+ GET_STRING(tj3Decompress, BITS_IN_JSAMPLE);
+ _JSAMPROW *row_pointer = NULL;
+ int croppedHeight, i, retval = 0;
+#if BITS_IN_JSAMPLE != 16
+ int scaledWidth;
+#endif
+ struct my_progress_mgr progress;
+
+ GET_DINSTANCE(handle);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (jpegBuf == NULL || jpegSize <= 0 || dstBuf == NULL || pitch < 0 ||
+ pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
+ THROW("Invalid argument");
+
+ if (this->scanLimit) {
+ memset(&progress, 0, sizeof(struct my_progress_mgr));
+ progress.pub.progress_monitor = my_progress_monitor;
+ progress.this = this;
+ dinfo->progress = &progress.pub;
+ } else
+ dinfo->progress = NULL;
+
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ if (dinfo->global_state <= DSTATE_INHEADER) {
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ }
+ setDecompParameters(this);
+ if (this->maxPixels &&
+ (unsigned long long)this->jpegWidth * this->jpegHeight >
+ (unsigned long long)this->maxPixels)
+ THROW("Image is too large");
+ this->dinfo.out_color_space = pf2cs[pixelFormat];
+#if BITS_IN_JSAMPLE != 16
+ scaledWidth = TJSCALED(dinfo->image_width, this->scalingFactor);
+#endif
+ dinfo->do_fancy_upsampling = !this->fastUpsample;
+ this->dinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
+
+ dinfo->scale_num = this->scalingFactor.num;
+ dinfo->scale_denom = this->scalingFactor.denom;
+
+ jpeg_start_decompress(dinfo);
+
+#if BITS_IN_JSAMPLE != 16
+ if (this->croppingRegion.x != 0 ||
+ (this->croppingRegion.w != 0 && this->croppingRegion.w != scaledWidth)) {
+ JDIMENSION crop_x = this->croppingRegion.x;
+ JDIMENSION crop_w = this->croppingRegion.w;
+
+ _jpeg_crop_scanline(dinfo, &crop_x, &crop_w);
+ if ((int)crop_x != this->croppingRegion.x)
+ THROWI("Unexplained mismatch between specified (%d) and\n"
+ "actual (%d) cropping region left boundary",
+ this->croppingRegion.x, (int)crop_x);
+ if ((int)crop_w != this->croppingRegion.w)
+ THROWI("Unexplained mismatch between specified (%d) and\n"
+ "actual (%d) cropping region width",
+ this->croppingRegion.w, (int)crop_w);
+ }
+#endif
+
+ if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
+
+ croppedHeight = dinfo->output_height;
+#if BITS_IN_JSAMPLE != 16
+ if (this->croppingRegion.y != 0 || this->croppingRegion.h != 0)
+ croppedHeight = this->croppingRegion.h;
+#endif
+ if ((row_pointer =
+ (_JSAMPROW *)malloc(sizeof(_JSAMPROW) * croppedHeight)) == NULL)
+ THROW("Memory allocation failure");
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+ for (i = 0; i < (int)croppedHeight; i++) {
+ if (this->bottomUp)
+ row_pointer[i] = &dstBuf[(croppedHeight - i - 1) * (size_t)pitch];
+ else
+ row_pointer[i] = &dstBuf[i * (size_t)pitch];
+ }
+
+#if BITS_IN_JSAMPLE != 16
+ if (this->croppingRegion.y != 0 || this->croppingRegion.h != 0) {
+ if (this->croppingRegion.y != 0) {
+ JDIMENSION lines = _jpeg_skip_scanlines(dinfo, this->croppingRegion.y);
+
+ if ((int)lines != this->croppingRegion.y)
+ THROWI("Unexplained mismatch between specified (%d) and\n"
+ "actual (%d) cropping region upper boundary",
+ this->croppingRegion.y, (int)lines);
+ }
+ while ((int)dinfo->output_scanline <
+ this->croppingRegion.y + this->croppingRegion.h)
+ _jpeg_read_scanlines(dinfo, &row_pointer[dinfo->output_scanline -
+ this->croppingRegion.y],
+ this->croppingRegion.y + this->croppingRegion.h -
+ dinfo->output_scanline);
+ if (this->croppingRegion.y + this->croppingRegion.h !=
+ (int)dinfo->output_height) {
+ JDIMENSION lines = _jpeg_skip_scanlines(dinfo, dinfo->output_height -
+ this->croppingRegion.y -
+ this->croppingRegion.h);
+
+ if (lines != dinfo->output_height - this->croppingRegion.y -
+ this->croppingRegion.h)
+ THROWI("Unexplained mismatch between specified (%d) and\n"
+ "actual (%d) cropping region lower boundary",
+ this->croppingRegion.y + this->croppingRegion.h,
+ (int)(dinfo->output_height - lines));
+ }
+ } else
+#endif
+ {
+ while (dinfo->output_scanline < dinfo->output_height)
+ _jpeg_read_scanlines(dinfo, &row_pointer[dinfo->output_scanline],
+ dinfo->output_height - dinfo->output_scanline);
+ }
+ jpeg_finish_decompress(dinfo);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ free(row_pointer);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+
+/*************************** Packed-Pixel Image I/O **************************/
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT _JSAMPLE *GET_NAME(tj3LoadImage, BITS_IN_JSAMPLE)
+ (tjhandle handle, const char *filename, int *width, int align, int *height,
+ int *pixelFormat)
+{
+ static const char FUNCTION_NAME[] =
+ GET_STRING(tj3LoadImage, BITS_IN_JSAMPLE);
+
+#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
+
+ int retval = 0, tempc;
+ size_t pitch;
+ tjhandle handle2 = NULL;
+ tjinstance *this2;
+ j_compress_ptr cinfo = NULL;
+ cjpeg_source_ptr src;
+ _JSAMPLE *dstBuf = NULL;
+ FILE *file = NULL;
+ boolean invert;
+
+ GET_TJINSTANCE(handle, NULL)
+
+ if (!filename || !width || align < 1 || !height || !pixelFormat ||
+ *pixelFormat < TJPF_UNKNOWN || *pixelFormat >= TJ_NUMPF)
+ THROW("Invalid argument");
+ if ((align & (align - 1)) != 0)
+ THROW("Alignment must be a power of 2");
+
+ /* The instance handle passed to this function is used only for parameter
+ retrieval. Create a new temporary instance to avoid interfering with the
+ libjpeg state of the primary instance. */
+ if ((handle2 = tj3Init(TJINIT_COMPRESS)) == NULL) return NULL;
+ this2 = (tjinstance *)handle2;
+ cinfo = &this2->cinfo;
+
+#ifdef _MSC_VER
+ if (fopen_s(&file, filename, "rb") || file == NULL)
+#else
+ if ((file = fopen(filename, "rb")) == NULL)
+#endif
+ THROW_UNIX("Cannot open input file");
+
+ if ((tempc = getc(file)) < 0 || ungetc(tempc, file) == EOF)
+ THROW_UNIX("Could not read input file")
+ else if (tempc == EOF)
+ THROW("Input file contains no data");
+
+ if (setjmp(this2->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ cinfo->data_precision = BITS_IN_JSAMPLE;
+ if (*pixelFormat == TJPF_UNKNOWN) cinfo->in_color_space = JCS_UNKNOWN;
+ else cinfo->in_color_space = pf2cs[*pixelFormat];
+ if (tempc == 'B') {
+ if ((src = jinit_read_bmp(cinfo, FALSE)) == NULL)
+ THROW("Could not initialize bitmap loader");
+ invert = !this->bottomUp;
+ } else if (tempc == 'P') {
+#if BITS_IN_JSAMPLE == 8
+ if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
+#else
+ if (this->precision >= BITS_IN_JSAMPLE - 3 &&
+ this->precision <= BITS_IN_JSAMPLE)
+#endif
+ cinfo->data_precision = this->precision;
+ if ((src = _jinit_read_ppm(cinfo)) == NULL)
+ THROW("Could not initialize PPM loader");
+ invert = this->bottomUp;
+ } else
+ THROW("Unsupported file type");
+
+ cinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
+ src->input_file = file;
+ /* Refuse to load images larger than the specified size. */
+ src->max_pixels = this->maxPixels;
+ (*src->start_input) (cinfo, src);
+ if (tempc == 'B') {
+ if (cinfo->X_density && cinfo->Y_density) {
+ this->xDensity = cinfo->X_density;
+ this->yDensity = cinfo->Y_density;
+ this->densityUnits = cinfo->density_unit;
+ }
+ }
+ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
+
+ *width = cinfo->image_width; *height = cinfo->image_height;
+ *pixelFormat = cs2pf[cinfo->in_color_space];
+
+ pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
+ if (
+#if ULLONG_MAX > SIZE_MAX
+ (unsigned long long)pitch * (unsigned long long)(*height) >
+ (unsigned long long)((size_t)-1) ||
+#endif
+ (dstBuf = (_JSAMPLE *)malloc(pitch * (*height) *
+ sizeof(_JSAMPLE))) == NULL)
+ THROW("Memory allocation failure");
+
+ if (setjmp(this2->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ while (cinfo->next_scanline < cinfo->image_height) {
+ int i, nlines = (*src->get_pixel_rows) (cinfo, src);
+
+ for (i = 0; i < nlines; i++) {
+ _JSAMPLE *dstptr;
+ int row;
+
+ row = cinfo->next_scanline + i;
+ if (invert) dstptr = &dstBuf[((*height) - row - 1) * pitch];
+ else dstptr = &dstBuf[row * pitch];
+ memcpy(dstptr, src->_buffer[i],
+ (*width) * tjPixelSize[*pixelFormat] * sizeof(_JSAMPLE));
+ }
+ cinfo->next_scanline += nlines;
+ }
+
+ (*src->finish_input) (cinfo, src);
+
+bailout:
+ tj3Destroy(handle2);
+ if (file) fclose(file);
+ if (retval < 0) { free(dstBuf); dstBuf = NULL; }
+ return dstBuf;
+
+#else /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */
+
+ static const char ERROR_MSG[] =
+ "16-bit data precision requires lossless JPEG,\n"
+ "which was disabled at build time.";
+ _JSAMPLE *retval = NULL;
+
+ GET_TJINSTANCE(handle, NULL)
+ SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME,
+ ERROR_MSG);
+ this->isInstanceError = TRUE; THROWG(ERROR_MSG, NULL)
+
+bailout:
+ return retval;
+
+#endif
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int GET_NAME(tj3SaveImage, BITS_IN_JSAMPLE)
+ (tjhandle handle, const char *filename, const _JSAMPLE *buffer, int width,
+ int pitch, int height, int pixelFormat)
+{
+ static const char FUNCTION_NAME[] =
+ GET_STRING(tj3SaveImage, BITS_IN_JSAMPLE);
+ int retval = 0;
+
+#if BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)
+
+ tjhandle handle2 = NULL;
+ tjinstance *this2;
+ j_decompress_ptr dinfo = NULL;
+ djpeg_dest_ptr dst;
+ FILE *file = NULL;
+ char *ptr = NULL;
+ boolean invert;
+
+ GET_TJINSTANCE(handle, -1)
+
+ if (!filename || !buffer || width < 1 || pitch < 0 || height < 1 ||
+ pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
+ THROW("Invalid argument");
+
+ /* The instance handle passed to this function is used only for parameter
+ retrieval. Create a new temporary instance to avoid interfering with the
+ libjpeg state of the primary instance. */
+ if ((handle2 = tj3Init(TJINIT_DECOMPRESS)) == NULL)
+ return -1;
+ this2 = (tjinstance *)handle2;
+ dinfo = &this2->dinfo;
+
+#ifdef _MSC_VER
+ if (fopen_s(&file, filename, "wb") || file == NULL)
+#else
+ if ((file = fopen(filename, "wb")) == NULL)
+#endif
+ THROW_UNIX("Cannot open output file");
+
+ if (setjmp(this2->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ this2->dinfo.out_color_space = pf2cs[pixelFormat];
+ dinfo->image_width = width; dinfo->image_height = height;
+ dinfo->global_state = DSTATE_READY;
+ dinfo->scale_num = dinfo->scale_denom = 1;
+ dinfo->data_precision = BITS_IN_JSAMPLE;
+
+ ptr = strrchr(filename, '.');
+ if (ptr && !strcasecmp(ptr, ".bmp")) {
+ if ((dst = jinit_write_bmp(dinfo, FALSE, FALSE)) == NULL)
+ THROW("Could not initialize bitmap writer");
+ invert = !this->bottomUp;
+ dinfo->X_density = (UINT16)this->xDensity;
+ dinfo->Y_density = (UINT16)this->yDensity;
+ dinfo->density_unit = (UINT8)this->densityUnits;
+ } else {
+#if BITS_IN_JSAMPLE == 8
+ if (this->precision >= 2 && this->precision <= BITS_IN_JSAMPLE)
+#else
+ if (this->precision >= BITS_IN_JSAMPLE - 3 &&
+ this->precision <= BITS_IN_JSAMPLE)
+#endif
+ dinfo->data_precision = this->precision;
+ if ((dst = _jinit_write_ppm(dinfo)) == NULL)
+ THROW("Could not initialize PPM writer");
+ invert = this->bottomUp;
+ }
+
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
+ dst->output_file = file;
+ (*dst->start_output) (dinfo, dst);
+ (*dinfo->mem->realize_virt_arrays) ((j_common_ptr)dinfo);
+
+ if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
+
+ while (dinfo->output_scanline < dinfo->output_height) {
+ _JSAMPLE *rowptr;
+
+ if (invert)
+ rowptr =
+ (_JSAMPLE *)&buffer[(height - dinfo->output_scanline - 1) * pitch];
+ else
+ rowptr = (_JSAMPLE *)&buffer[dinfo->output_scanline * pitch];
+ memcpy(dst->_buffer[0], rowptr,
+ width * tjPixelSize[pixelFormat] * sizeof(_JSAMPLE));
+ (*dst->put_pixel_rows) (dinfo, dst, 1);
+ dinfo->output_scanline++;
+ }
+
+ (*dst->finish_output) (dinfo, dst);
+
+bailout:
+ tj3Destroy(handle2);
+ if (file) fclose(file);
+ return retval;
+
+#else /* BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED) */
+
+ GET_TJINSTANCE(handle, -1)
+ THROW("16-bit data precision requires lossless JPEG,\n"
+ "which was disabled at build time.")
+bailout:
+ return retval;
+
+#endif
+}
+
+
+#undef _JSAMPLE
+#undef _JSAMPROW
+#undef _buffer
+#undef _jinit_read_ppm
+#undef _jinit_write_ppm
+#undef _jpeg_crop_scanline
+#undef _jpeg_read_scanlines
+#undef _jpeg_skip_scanlines
+#undef _jpeg_write_scanlines
diff --git a/contrib/libs/libjpeg-turbo/src/turbojpeg.c b/contrib/libs/libjpeg-turbo/src/turbojpeg.c
new file mode 100644
index 00000000000..389aea55d32
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/turbojpeg.c
@@ -0,0 +1,3145 @@
+/*
+ * Copyright (C)2009-2024 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2021 Alex Richardson. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the libjpeg-turbo Project nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* TurboJPEG/LJT: this implements the TurboJPEG API using libjpeg or
+ libjpeg-turbo */
+
+#include <ctype.h>
+#include <limits.h>
+#if !defined(_MSC_VER) || _MSC_VER > 1600
+#include <stdint.h>
+#endif
+#include <jinclude.h>
+#define JPEG_INTERNALS
+#include <jpeglib.h>
+#include <jerror.h>
+#include <setjmp.h>
+#include <errno.h>
+#include "./turbojpeg.h"
+#include "./tjutil.h"
+#include "transupp.h"
+#include "./jpegapicomp.h"
+#include "./cdjpeg.h"
+
+extern void jpeg_mem_dest_tj(j_compress_ptr, unsigned char **, size_t *,
+ boolean);
+extern void jpeg_mem_src_tj(j_decompress_ptr, const unsigned char *, size_t);
+
+#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
+#define IS_POW2(x) (((x) & (x - 1)) == 0)
+
+
+/* Error handling (based on example in example.c) */
+
+static THREAD_LOCAL char errStr[JMSG_LENGTH_MAX] = "No error";
+
+struct my_error_mgr {
+ struct jpeg_error_mgr pub;
+ jmp_buf setjmp_buffer;
+ void (*emit_message) (j_common_ptr, int);
+ boolean warning, stopOnWarning;
+};
+typedef struct my_error_mgr *my_error_ptr;
+
+#define JMESSAGE(code, string) string,
+static const char *turbojpeg_message_table[] = {
+#include "cderror.h"
+ NULL
+};
+
+static void my_error_exit(j_common_ptr cinfo)
+{
+ my_error_ptr myerr = (my_error_ptr)cinfo->err;
+
+ (*cinfo->err->output_message) (cinfo);
+ longjmp(myerr->setjmp_buffer, 1);
+}
+
+/* Based on output_message() in jerror.c */
+
+static void my_output_message(j_common_ptr cinfo)
+{
+ (*cinfo->err->format_message) (cinfo, errStr);
+}
+
+static void my_emit_message(j_common_ptr cinfo, int msg_level)
+{
+ my_error_ptr myerr = (my_error_ptr)cinfo->err;
+
+ myerr->emit_message(cinfo, msg_level);
+ if (msg_level < 0) {
+ myerr->warning = TRUE;
+ if (myerr->stopOnWarning) longjmp(myerr->setjmp_buffer, 1);
+ }
+}
+
+
+/********************** Global structures, macros, etc. **********************/
+
+enum { COMPRESS = 1, DECOMPRESS = 2 };
+
+typedef struct _tjinstance {
+ struct jpeg_compress_struct cinfo;
+ struct jpeg_decompress_struct dinfo;
+ struct my_error_mgr jerr;
+ int init;
+ char errStr[JMSG_LENGTH_MAX];
+ boolean isInstanceError;
+ /* Parameters */
+ boolean bottomUp;
+ boolean noRealloc;
+ int quality;
+ int subsamp;
+ int jpegWidth;
+ int jpegHeight;
+ int precision;
+ int colorspace;
+ boolean fastUpsample;
+ boolean fastDCT;
+ boolean optimize;
+ boolean progressive;
+ int scanLimit;
+ boolean arithmetic;
+ boolean lossless;
+ int losslessPSV;
+ int losslessPt;
+ int restartIntervalBlocks;
+ int restartIntervalRows;
+ int xDensity;
+ int yDensity;
+ int densityUnits;
+ tjscalingfactor scalingFactor;
+ tjregion croppingRegion;
+ int maxMemory;
+ int maxPixels;
+ int saveMarkers;
+ unsigned char *iccBuf, *tempICCBuf;
+ size_t iccSize, tempICCSize;
+} tjinstance;
+
+static tjhandle _tjInitCompress(tjinstance *this);
+static tjhandle _tjInitDecompress(tjinstance *this);
+
+struct my_progress_mgr {
+ struct jpeg_progress_mgr pub;
+ tjinstance *this;
+};
+typedef struct my_progress_mgr *my_progress_ptr;
+
+static void my_progress_monitor(j_common_ptr dinfo)
+{
+ my_error_ptr myerr = (my_error_ptr)dinfo->err;
+ my_progress_ptr myprog = (my_progress_ptr)dinfo->progress;
+
+ if (dinfo->is_decompressor) {
+ int scan_no = ((j_decompress_ptr)dinfo)->input_scan_number;
+
+ if (scan_no > myprog->this->scanLimit) {
+ SNPRINTF(myprog->this->errStr, JMSG_LENGTH_MAX,
+ "Progressive JPEG image has more than %d scans",
+ myprog->this->scanLimit);
+ SNPRINTF(errStr, JMSG_LENGTH_MAX,
+ "Progressive JPEG image has more than %d scans",
+ myprog->this->scanLimit);
+ myprog->this->isInstanceError = TRUE;
+ myerr->warning = FALSE;
+ longjmp(myerr->setjmp_buffer, 1);
+ }
+ }
+}
+
+static const JXFORM_CODE xformtypes[TJ_NUMXOP] = {
+ JXFORM_NONE, JXFORM_FLIP_H, JXFORM_FLIP_V, JXFORM_TRANSPOSE,
+ JXFORM_TRANSVERSE, JXFORM_ROT_90, JXFORM_ROT_180, JXFORM_ROT_270
+};
+
+#define NUMSF 16
+static const tjscalingfactor sf[NUMSF] = {
+ { 2, 1 },
+ { 15, 8 },
+ { 7, 4 },
+ { 13, 8 },
+ { 3, 2 },
+ { 11, 8 },
+ { 5, 4 },
+ { 9, 8 },
+ { 1, 1 },
+ { 7, 8 },
+ { 3, 4 },
+ { 5, 8 },
+ { 1, 2 },
+ { 3, 8 },
+ { 1, 4 },
+ { 1, 8 }
+};
+
+static J_COLOR_SPACE pf2cs[TJ_NUMPF] = {
+ JCS_EXT_RGB, JCS_EXT_BGR, JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
+ JCS_EXT_XRGB, JCS_GRAYSCALE, JCS_EXT_RGBA, JCS_EXT_BGRA, JCS_EXT_ABGR,
+ JCS_EXT_ARGB, JCS_CMYK
+};
+
+static int cs2pf[JPEG_NUMCS] = {
+ TJPF_UNKNOWN, TJPF_GRAY,
+#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
+ TJPF_RGB,
+#elif RGB_RED == 2 && RGB_GREEN == 1 && RGB_BLUE == 0 && RGB_PIXELSIZE == 3
+ TJPF_BGR,
+#elif RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 4
+ TJPF_RGBX,
+#elif RGB_RED == 2 && RGB_GREEN == 1 && RGB_BLUE == 0 && RGB_PIXELSIZE == 4
+ TJPF_BGRX,
+#elif RGB_RED == 3 && RGB_GREEN == 2 && RGB_BLUE == 1 && RGB_PIXELSIZE == 4
+ TJPF_XBGR,
+#elif RGB_RED == 1 && RGB_GREEN == 2 && RGB_BLUE == 3 && RGB_PIXELSIZE == 4
+ TJPF_XRGB,
+#endif
+ TJPF_UNKNOWN, TJPF_CMYK, TJPF_UNKNOWN, TJPF_RGB, TJPF_RGBX, TJPF_BGR,
+ TJPF_BGRX, TJPF_XBGR, TJPF_XRGB, TJPF_RGBA, TJPF_BGRA, TJPF_ABGR, TJPF_ARGB,
+ TJPF_UNKNOWN
+};
+
+#define THROWG(m, rv) { \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
+ retval = rv; goto bailout; \
+}
+#ifdef _MSC_VER
+#define THROW_UNIX(m) { \
+ char strerrorBuf[80] = { 0 }; \
+ strerror_s(strerrorBuf, 80, errno); \
+ SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
+ strerrorBuf); \
+ this->isInstanceError = TRUE; \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
+ strerrorBuf); \
+ retval = -1; goto bailout; \
+}
+#else
+#define THROW_UNIX(m) { \
+ SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
+ strerror(errno)); \
+ this->isInstanceError = TRUE; \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): %s\n%s", FUNCTION_NAME, m, \
+ strerror(errno)); \
+ retval = -1; goto bailout; \
+}
+#endif
+#define THROWRV(m, rv) { \
+ SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): %s", FUNCTION_NAME, m); \
+ this->isInstanceError = TRUE; THROWG(m, rv) \
+}
+#define THROW(m) THROWRV(m, -1)
+#define THROWI(format, val1, val2) { \
+ SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s(): " format, FUNCTION_NAME, \
+ val1, val2); \
+ this->isInstanceError = TRUE; \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): " format, FUNCTION_NAME, val1, \
+ val2); \
+ retval = -1; goto bailout; \
+}
+
+#define GET_INSTANCE(handle) \
+ tjinstance *this = (tjinstance *)handle; \
+ j_compress_ptr cinfo = NULL; \
+ j_decompress_ptr dinfo = NULL; \
+ \
+ if (!this) { \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
+ return -1; \
+ } \
+ cinfo = &this->cinfo; dinfo = &this->dinfo; \
+ this->jerr.warning = FALSE; \
+ this->isInstanceError = FALSE;
+
+#define GET_CINSTANCE(handle) \
+ tjinstance *this = (tjinstance *)handle; \
+ j_compress_ptr cinfo = NULL; \
+ \
+ if (!this) { \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
+ return -1; \
+ } \
+ cinfo = &this->cinfo; \
+ this->jerr.warning = FALSE; \
+ this->isInstanceError = FALSE;
+
+#define GET_DINSTANCE(handle) \
+ tjinstance *this = (tjinstance *)handle; \
+ j_decompress_ptr dinfo = NULL; \
+ \
+ if (!this) { \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
+ return -1; \
+ } \
+ dinfo = &this->dinfo; \
+ this->jerr.warning = FALSE; \
+ this->isInstanceError = FALSE;
+
+#define GET_TJINSTANCE(handle, errorReturn) \
+ tjinstance *this = (tjinstance *)handle; \
+ \
+ if (!this) { \
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s(): Invalid handle", FUNCTION_NAME); \
+ return errorReturn; \
+ } \
+ this->jerr.warning = FALSE; \
+ this->isInstanceError = FALSE;
+
+static int getPixelFormat(int pixelSize, int flags)
+{
+ if (pixelSize == 1) return TJPF_GRAY;
+ if (pixelSize == 3) {
+ if (flags & TJ_BGR) return TJPF_BGR;
+ else return TJPF_RGB;
+ }
+ if (pixelSize == 4) {
+ if (flags & TJ_ALPHAFIRST) {
+ if (flags & TJ_BGR) return TJPF_XBGR;
+ else return TJPF_XRGB;
+ } else {
+ if (flags & TJ_BGR) return TJPF_BGRX;
+ else return TJPF_RGBX;
+ }
+ }
+ return -1;
+}
+
+static void setCompDefaults(tjinstance *this, int pixelFormat)
+{
+ int subsamp = this->subsamp;
+
+ this->cinfo.in_color_space = pf2cs[pixelFormat];
+ this->cinfo.input_components = tjPixelSize[pixelFormat];
+ jpeg_set_defaults(&this->cinfo);
+
+ this->cinfo.restart_interval = this->restartIntervalBlocks;
+ this->cinfo.restart_in_rows = this->restartIntervalRows;
+ this->cinfo.X_density = (UINT16)this->xDensity;
+ this->cinfo.Y_density = (UINT16)this->yDensity;
+ this->cinfo.density_unit = (UINT8)this->densityUnits;
+ this->cinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
+ if (this->lossless) {
+#ifdef C_LOSSLESS_SUPPORTED
+ jpeg_enable_lossless(&this->cinfo, this->losslessPSV, this->losslessPt);
+#endif
+ if (pixelFormat == TJPF_GRAY)
+ subsamp = TJSAMP_GRAY;
+ else if (subsamp != TJSAMP_GRAY)
+ subsamp = TJSAMP_444;
+ return;
+ }
+
+ jpeg_set_quality(&this->cinfo, this->quality, TRUE);
+ this->cinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
+
+ switch (this->colorspace) {
+ case TJCS_RGB:
+ jpeg_set_colorspace(&this->cinfo, JCS_RGB); break;
+ case TJCS_YCbCr:
+ jpeg_set_colorspace(&this->cinfo, JCS_YCbCr); break;
+ case TJCS_GRAY:
+ jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE); break;
+ case TJCS_CMYK:
+ jpeg_set_colorspace(&this->cinfo, JCS_CMYK); break;
+ case TJCS_YCCK:
+ jpeg_set_colorspace(&this->cinfo, JCS_YCCK); break;
+ default:
+ if (subsamp == TJSAMP_GRAY)
+ jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);
+ else if (pixelFormat == TJPF_CMYK)
+ jpeg_set_colorspace(&this->cinfo, JCS_YCCK);
+ else
+ jpeg_set_colorspace(&this->cinfo, JCS_YCbCr);
+ }
+
+ if (this->cinfo.data_precision == 8)
+ this->cinfo.optimize_coding = this->optimize;
+#ifdef C_PROGRESSIVE_SUPPORTED
+ if (this->progressive) jpeg_simple_progression(&this->cinfo);
+#endif
+ this->cinfo.arith_code = this->arithmetic;
+
+ this->cinfo.comp_info[0].h_samp_factor = tjMCUWidth[subsamp] / 8;
+ this->cinfo.comp_info[1].h_samp_factor = 1;
+ this->cinfo.comp_info[2].h_samp_factor = 1;
+ if (this->cinfo.num_components > 3)
+ this->cinfo.comp_info[3].h_samp_factor = tjMCUWidth[subsamp] / 8;
+ this->cinfo.comp_info[0].v_samp_factor = tjMCUHeight[subsamp] / 8;
+ this->cinfo.comp_info[1].v_samp_factor = 1;
+ this->cinfo.comp_info[2].v_samp_factor = 1;
+ if (this->cinfo.num_components > 3)
+ this->cinfo.comp_info[3].v_samp_factor = tjMCUHeight[subsamp] / 8;
+}
+
+
+static int getSubsamp(j_decompress_ptr dinfo)
+{
+ int retval = TJSAMP_UNKNOWN, i, k;
+
+ /* The sampling factors actually have no meaning with grayscale JPEG files,
+ and in fact it's possible to generate grayscale JPEGs with sampling
+ factors > 1 (even though those sampling factors are ignored by the
+ decompressor.) Thus, we need to treat grayscale as a special case. */
+ if (dinfo->num_components == 1 && dinfo->jpeg_color_space == JCS_GRAYSCALE)
+ return TJSAMP_GRAY;
+
+ for (i = 0; i < TJ_NUMSAMP; i++) {
+ if (i == TJSAMP_GRAY) continue;
+
+ if (dinfo->num_components == 3 ||
+ ((dinfo->jpeg_color_space == JCS_YCCK ||
+ dinfo->jpeg_color_space == JCS_CMYK) &&
+ dinfo->num_components == 4)) {
+ if (dinfo->comp_info[0].h_samp_factor == tjMCUWidth[i] / 8 &&
+ dinfo->comp_info[0].v_samp_factor == tjMCUHeight[i] / 8) {
+ int match = 0;
+
+ for (k = 1; k < dinfo->num_components; k++) {
+ int href = 1, vref = 1;
+
+ if ((dinfo->jpeg_color_space == JCS_YCCK ||
+ dinfo->jpeg_color_space == JCS_CMYK) && k == 3) {
+ href = tjMCUWidth[i] / 8; vref = tjMCUHeight[i] / 8;
+ }
+ if (dinfo->comp_info[k].h_samp_factor == href &&
+ dinfo->comp_info[k].v_samp_factor == vref)
+ match++;
+ }
+ if (match == dinfo->num_components - 1) {
+ retval = i; break;
+ }
+ }
+ /* Handle 4:2:2 and 4:4:0 images whose sampling factors are specified
+ in non-standard ways. */
+ if (dinfo->comp_info[0].h_samp_factor == 2 &&
+ dinfo->comp_info[0].v_samp_factor == 2 &&
+ (i == TJSAMP_422 || i == TJSAMP_440)) {
+ int match = 0;
+
+ for (k = 1; k < dinfo->num_components; k++) {
+ int href = tjMCUHeight[i] / 8, vref = tjMCUWidth[i] / 8;
+
+ if ((dinfo->jpeg_color_space == JCS_YCCK ||
+ dinfo->jpeg_color_space == JCS_CMYK) && k == 3) {
+ href = vref = 2;
+ }
+ if (dinfo->comp_info[k].h_samp_factor == href &&
+ dinfo->comp_info[k].v_samp_factor == vref)
+ match++;
+ }
+ if (match == dinfo->num_components - 1) {
+ retval = i; break;
+ }
+ }
+ /* Handle 4:4:4 images whose sampling factors are specified in
+ non-standard ways. */
+ if (dinfo->comp_info[0].h_samp_factor *
+ dinfo->comp_info[0].v_samp_factor <=
+ D_MAX_BLOCKS_IN_MCU / 3 && i == TJSAMP_444) {
+ int match = 0;
+ for (k = 1; k < dinfo->num_components; k++) {
+ if (dinfo->comp_info[k].h_samp_factor ==
+ dinfo->comp_info[0].h_samp_factor &&
+ dinfo->comp_info[k].v_samp_factor ==
+ dinfo->comp_info[0].v_samp_factor)
+ match++;
+ if (match == dinfo->num_components - 1) {
+ retval = i; break;
+ }
+ }
+ }
+ }
+ }
+ return retval;
+}
+
+
+static void setDecompParameters(tjinstance *this)
+{
+ this->subsamp = getSubsamp(&this->dinfo);
+ this->jpegWidth = this->dinfo.image_width;
+ this->jpegHeight = this->dinfo.image_height;
+ this->precision = this->dinfo.data_precision;
+ switch (this->dinfo.jpeg_color_space) {
+ case JCS_GRAYSCALE: this->colorspace = TJCS_GRAY; break;
+ case JCS_RGB: this->colorspace = TJCS_RGB; break;
+ case JCS_YCbCr: this->colorspace = TJCS_YCbCr; break;
+ case JCS_CMYK: this->colorspace = TJCS_CMYK; break;
+ case JCS_YCCK: this->colorspace = TJCS_YCCK; break;
+ default: this->colorspace = -1; break;
+ }
+ this->progressive = this->dinfo.progressive_mode;
+ this->arithmetic = this->dinfo.arith_code;
+ this->lossless = this->dinfo.master->lossless;
+ this->losslessPSV = this->dinfo.Ss;
+ this->losslessPt = this->dinfo.Al;
+ this->xDensity = this->dinfo.X_density;
+ this->yDensity = this->dinfo.Y_density;
+ this->densityUnits = this->dinfo.density_unit;
+}
+
+
+static void processFlags(tjhandle handle, int flags, int operation)
+{
+ tjinstance *this = (tjinstance *)handle;
+
+ this->bottomUp = !!(flags & TJFLAG_BOTTOMUP);
+
+#ifndef NO_PUTENV
+ if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
+ else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
+ else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
+#endif
+
+ this->fastUpsample = !!(flags & TJFLAG_FASTUPSAMPLE);
+ this->noRealloc = !!(flags & TJFLAG_NOREALLOC);
+
+ if (operation == COMPRESS) {
+ if (this->quality >= 96 || flags & TJFLAG_ACCURATEDCT)
+ this->fastDCT = FALSE;
+ else
+ this->fastDCT = TRUE;
+ } else
+ this->fastDCT = !!(flags & TJFLAG_FASTDCT);
+
+ this->jerr.stopOnWarning = !!(flags & TJFLAG_STOPONWARNING);
+ this->progressive = !!(flags & TJFLAG_PROGRESSIVE);
+
+ if (flags & TJFLAG_LIMITSCANS) this->scanLimit = 500;
+}
+
+
+/*************************** General API functions ***************************/
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT tjhandle tj3Init(int initType)
+{
+ static const char FUNCTION_NAME[] = "tj3Init";
+ tjinstance *this = NULL;
+ tjhandle retval = NULL;
+
+ if (initType < 0 || initType >= TJ_NUMINIT)
+ THROWG("Invalid argument", NULL);
+
+ if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL)
+ THROWG("Memory allocation failure", NULL);
+ memset(this, 0, sizeof(tjinstance));
+ SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
+
+ this->quality = -1;
+ this->subsamp = TJSAMP_UNKNOWN;
+ this->jpegWidth = -1;
+ this->jpegHeight = -1;
+ this->precision = 8;
+ this->colorspace = -1;
+ this->losslessPSV = 1;
+ this->xDensity = 1;
+ this->yDensity = 1;
+ this->scalingFactor = TJUNSCALED;
+ this->saveMarkers = 2;
+
+ switch (initType) {
+ case TJINIT_COMPRESS: return _tjInitCompress(this);
+ case TJINIT_DECOMPRESS: return _tjInitDecompress(this);
+ case TJINIT_TRANSFORM:
+ retval = _tjInitCompress(this);
+ if (!retval) return NULL;
+ retval = _tjInitDecompress(this);
+ return retval;
+ }
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT void tj3Destroy(tjhandle handle)
+{
+ tjinstance *this = (tjinstance *)handle;
+ j_compress_ptr cinfo = NULL;
+ j_decompress_ptr dinfo = NULL;
+
+ if (!this) return;
+
+ cinfo = &this->cinfo; dinfo = &this->dinfo;
+ this->jerr.warning = FALSE;
+ this->isInstanceError = FALSE;
+
+ if (setjmp(this->jerr.setjmp_buffer)) return;
+ if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
+ if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
+ free(this->iccBuf);
+ free(this->tempICCBuf);
+ free(this);
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT int tjDestroy(tjhandle handle)
+{
+ static const char FUNCTION_NAME[] = "tjDestroy";
+ int retval = 0;
+
+ if (!handle) THROWG("Invalid handle", -1);
+
+ SNPRINTF(errStr, JMSG_LENGTH_MAX, "No error");
+ tj3Destroy(handle);
+ if (strcmp(errStr, "No error")) retval = -1;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT char *tj3GetErrorStr(tjhandle handle)
+{
+ tjinstance *this = (tjinstance *)handle;
+
+ if (this && this->isInstanceError) {
+ this->isInstanceError = FALSE;
+ return this->errStr;
+ } else
+ return errStr;
+}
+
+/* TurboJPEG 2.0+ */
+DLLEXPORT char *tjGetErrorStr2(tjhandle handle)
+{
+ return tj3GetErrorStr(handle);
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT char *tjGetErrorStr(void)
+{
+ return errStr;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3GetErrorCode(tjhandle handle)
+{
+ tjinstance *this = (tjinstance *)handle;
+
+ if (this && this->jerr.warning) return TJERR_WARNING;
+ else return TJERR_FATAL;
+}
+
+/* TurboJPEG 2.0+ */
+DLLEXPORT int tjGetErrorCode(tjhandle handle)
+{
+ return tj3GetErrorCode(handle);
+}
+
+
+#define SET_PARAM(field, minValue, maxValue) { \
+ if (value < minValue || (maxValue > 0 && value > maxValue)) \
+ THROW("Parameter value out of range"); \
+ this->field = value; \
+}
+
+#define SET_BOOL_PARAM(field) { \
+ if (value < 0 || value > 1) \
+ THROW("Parameter value out of range"); \
+ this->field = (boolean)value; \
+}
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3Set(tjhandle handle, int param, int value)
+{
+ static const char FUNCTION_NAME[] = "tj3Set";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+
+ switch (param) {
+ case TJPARAM_STOPONWARNING:
+ SET_BOOL_PARAM(jerr.stopOnWarning);
+ break;
+ case TJPARAM_BOTTOMUP:
+ SET_BOOL_PARAM(bottomUp);
+ break;
+ case TJPARAM_NOREALLOC:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_NOREALLOC is not applicable to decompression instances.");
+ SET_BOOL_PARAM(noRealloc);
+ break;
+ case TJPARAM_QUALITY:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_QUALITY is not applicable to decompression instances.");
+ SET_PARAM(quality, 1, 100);
+ break;
+ case TJPARAM_SUBSAMP:
+ SET_PARAM(subsamp, 0, TJ_NUMSAMP - 1);
+ break;
+ case TJPARAM_JPEGWIDTH:
+ if (!(this->init & DECOMPRESS))
+ THROW("TJPARAM_JPEGWIDTH is not applicable to compression instances.");
+ THROW("TJPARAM_JPEGWIDTH is read-only in decompression instances.");
+ break;
+ case TJPARAM_JPEGHEIGHT:
+ if (!(this->init & DECOMPRESS))
+ THROW("TJPARAM_JPEGHEIGHT is not applicable to compression instances.");
+ THROW("TJPARAM_JPEGHEIGHT is read-only in decompression instances.");
+ break;
+ case TJPARAM_PRECISION:
+ SET_PARAM(precision, 2, 16);
+ break;
+ case TJPARAM_COLORSPACE:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_COLORSPACE is read-only in decompression instances.");
+ SET_PARAM(colorspace, 0, TJ_NUMCS - 1);
+ break;
+ case TJPARAM_FASTUPSAMPLE:
+ if (!(this->init & DECOMPRESS))
+ THROW("TJPARAM_FASTUPSAMPLE is not applicable to compression instances.");
+ SET_BOOL_PARAM(fastUpsample);
+ break;
+ case TJPARAM_FASTDCT:
+ SET_BOOL_PARAM(fastDCT);
+ break;
+ case TJPARAM_OPTIMIZE:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_OPTIMIZE is not applicable to decompression instances.");
+ SET_BOOL_PARAM(optimize);
+ break;
+ case TJPARAM_PROGRESSIVE:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_PROGRESSIVE is read-only in decompression instances.");
+ SET_BOOL_PARAM(progressive);
+ break;
+ case TJPARAM_SCANLIMIT:
+ if (!(this->init & DECOMPRESS))
+ THROW("TJPARAM_SCANLIMIT is not applicable to compression instances.");
+ SET_PARAM(scanLimit, 0, -1);
+ break;
+ case TJPARAM_ARITHMETIC:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_ARITHMETIC is read-only in decompression instances.");
+ SET_BOOL_PARAM(arithmetic);
+ break;
+ case TJPARAM_LOSSLESS:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_LOSSLESS is read-only in decompression instances.");
+ SET_BOOL_PARAM(lossless);
+ break;
+ case TJPARAM_LOSSLESSPSV:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_LOSSLESSPSV is read-only in decompression instances.");
+ SET_PARAM(losslessPSV, 1, 7);
+ break;
+ case TJPARAM_LOSSLESSPT:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_LOSSLESSPT is read-only in decompression instances.");
+ SET_PARAM(losslessPt, 0, 15);
+ break;
+ case TJPARAM_RESTARTBLOCKS:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_RESTARTBLOCKS is not applicable to decompression instances.");
+ SET_PARAM(restartIntervalBlocks, 0, 65535);
+ if (value != 0) this->restartIntervalRows = 0;
+ break;
+ case TJPARAM_RESTARTROWS:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_RESTARTROWS is not applicable to decompression instances.");
+ SET_PARAM(restartIntervalRows, 0, 65535);
+ if (value != 0) this->restartIntervalBlocks = 0;
+ break;
+ case TJPARAM_XDENSITY:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_XDENSITY is read-only in decompression instances.");
+ SET_PARAM(xDensity, 1, 65535);
+ break;
+ case TJPARAM_YDENSITY:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_YDENSITY is read-only in decompression instances.");
+ SET_PARAM(yDensity, 1, 65535);
+ break;
+ case TJPARAM_DENSITYUNITS:
+ if (!(this->init & COMPRESS))
+ THROW("TJPARAM_DENSITYUNITS is read-only in decompression instances.");
+ SET_PARAM(densityUnits, 0, 2);
+ break;
+ case TJPARAM_MAXMEMORY:
+ SET_PARAM(maxMemory, 0, (int)(min(LONG_MAX / 1048576L, (long)INT_MAX)));
+ break;
+ case TJPARAM_MAXPIXELS:
+ SET_PARAM(maxPixels, 0, -1);
+ break;
+ case TJPARAM_SAVEMARKERS:
+ if (!(this->init & DECOMPRESS))
+ THROW("TJPARAM_SAVEMARKERS is not applicable to compression instances.");
+ SET_PARAM(saveMarkers, 0, 4);
+ break;
+ default:
+ THROW("Invalid parameter");
+ }
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3Get(tjhandle handle, int param)
+{
+ tjinstance *this = (tjinstance *)handle;
+ if (!this) return -1;
+
+ switch (param) {
+ case TJPARAM_STOPONWARNING:
+ return this->jerr.stopOnWarning;
+ case TJPARAM_BOTTOMUP:
+ return this->bottomUp;
+ case TJPARAM_NOREALLOC:
+ return this->noRealloc;
+ case TJPARAM_QUALITY:
+ return this->quality;
+ case TJPARAM_SUBSAMP:
+ return this->subsamp;
+ case TJPARAM_JPEGWIDTH:
+ return this->jpegWidth;
+ case TJPARAM_JPEGHEIGHT:
+ return this->jpegHeight;
+ case TJPARAM_PRECISION:
+ return this->precision;
+ case TJPARAM_COLORSPACE:
+ return this->colorspace;
+ case TJPARAM_FASTUPSAMPLE:
+ return this->fastUpsample;
+ case TJPARAM_FASTDCT:
+ return this->fastDCT;
+ case TJPARAM_OPTIMIZE:
+ return this->optimize;
+ case TJPARAM_PROGRESSIVE:
+ return this->progressive;
+ case TJPARAM_SCANLIMIT:
+ return this->scanLimit;
+ case TJPARAM_ARITHMETIC:
+ return this->arithmetic;
+ case TJPARAM_LOSSLESS:
+ return this->lossless;
+ case TJPARAM_LOSSLESSPSV:
+ return this->losslessPSV;
+ case TJPARAM_LOSSLESSPT:
+ return this->losslessPt;
+ case TJPARAM_RESTARTBLOCKS:
+ return this->restartIntervalBlocks;
+ case TJPARAM_RESTARTROWS:
+ return this->restartIntervalRows;
+ case TJPARAM_XDENSITY:
+ return this->xDensity;
+ case TJPARAM_YDENSITY:
+ return this->yDensity;
+ case TJPARAM_DENSITYUNITS:
+ return this->densityUnits;
+ case TJPARAM_MAXMEMORY:
+ return this->maxMemory;
+ case TJPARAM_MAXPIXELS:
+ return this->maxPixels;
+ case TJPARAM_SAVEMARKERS:
+ return this->saveMarkers;
+ }
+
+ return -1;
+}
+
+
+/* These are exposed mainly because Windows can't malloc() and free() across
+ DLL boundaries except when the CRT DLL is used, and we don't use the CRT DLL
+ with turbojpeg.dll for compatibility reasons. However, these functions
+ can potentially be used for other purposes by different implementations. */
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT void *tj3Alloc(size_t bytes)
+{
+ return MALLOC(bytes);
+}
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT unsigned char *tjAlloc(int bytes)
+{
+ return (unsigned char *)tj3Alloc((size_t)bytes);
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT void tj3Free(void *buf)
+{
+ free(buf);
+}
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT void tjFree(unsigned char *buf)
+{
+ tj3Free(buf);
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT size_t tj3JPEGBufSize(int width, int height, int jpegSubsamp)
+{
+ static const char FUNCTION_NAME[] = "tj3JPEGBufSize";
+ unsigned long long retval = 0;
+ int mcuw, mcuh, chromasf;
+
+ if (width < 1 || height < 1 || jpegSubsamp < TJSAMP_UNKNOWN ||
+ jpegSubsamp >= TJ_NUMSAMP)
+ THROWG("Invalid argument", 0);
+
+ if (jpegSubsamp == TJSAMP_UNKNOWN)
+ jpegSubsamp = TJSAMP_444;
+
+ /* This allows for rare corner cases in which a JPEG image can actually be
+ larger than the uncompressed input (we wouldn't mention it if it hadn't
+ happened before.) */
+ mcuw = tjMCUWidth[jpegSubsamp];
+ mcuh = tjMCUHeight[jpegSubsamp];
+ chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
+ retval = PAD(width, mcuw) * PAD(height, mcuh) * (2ULL + chromasf) + 2048ULL;
+#if ULLONG_MAX > ULONG_MAX
+ if (retval > (unsigned long long)((unsigned long)-1))
+ THROWG("Image is too large", 0);
+#endif
+
+bailout:
+ return (size_t)retval;
+}
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT unsigned long tjBufSize(int width, int height, int jpegSubsamp)
+{
+ static const char FUNCTION_NAME[] = "tjBufSize";
+ size_t retval;
+
+ if (jpegSubsamp < 0)
+ THROWG("Invalid argument", 0);
+
+ retval = tj3JPEGBufSize(width, height, jpegSubsamp);
+
+bailout:
+ return (retval == 0) ? (unsigned long)-1 : (unsigned long)retval;
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT unsigned long TJBUFSIZE(int width, int height)
+{
+ static const char FUNCTION_NAME[] = "TJBUFSIZE";
+ unsigned long long retval = 0;
+
+ if (width < 1 || height < 1)
+ THROWG("Invalid argument", (unsigned long)-1);
+
+ /* This allows for rare corner cases in which a JPEG image can actually be
+ larger than the uncompressed input (we wouldn't mention it if it hadn't
+ happened before.) */
+ retval = PAD(width, 16) * PAD(height, 16) * 6ULL + 2048ULL;
+#if ULLONG_MAX > ULONG_MAX
+ if (retval > (unsigned long long)((unsigned long)-1))
+ THROWG("Image is too large", (unsigned long)-1);
+#endif
+
+bailout:
+ return (unsigned long)retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT size_t tj3YUVBufSize(int width, int align, int height, int subsamp)
+{
+ static const char FUNCTION_NAME[] = "tj3YUVBufSize";
+ unsigned long long retval = 0;
+ int nc, i;
+
+ if (align < 1 || !IS_POW2(align) || subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROWG("Invalid argument", 0);
+
+ nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
+ for (i = 0; i < nc; i++) {
+ int pw = tj3YUVPlaneWidth(i, width, subsamp);
+ int stride = PAD(pw, align);
+ int ph = tj3YUVPlaneHeight(i, height, subsamp);
+
+ if (pw == 0 || ph == 0) return 0;
+ else retval += (unsigned long long)stride * ph;
+ }
+#if ULLONG_MAX > ULONG_MAX
+ if (retval > (unsigned long long)((unsigned long)-1))
+ THROWG("Image is too large", 0);
+#endif
+
+bailout:
+ return (size_t)retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT unsigned long tjBufSizeYUV2(int width, int align, int height,
+ int subsamp)
+{
+ size_t retval = tj3YUVBufSize(width, align, height, subsamp);
+ return (retval == 0) ? (unsigned long)-1 : (unsigned long)retval;
+}
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT unsigned long tjBufSizeYUV(int width, int height, int subsamp)
+{
+ return tjBufSizeYUV2(width, 4, height, subsamp);
+}
+
+/* TurboJPEG 1.1+ */
+DLLEXPORT unsigned long TJBUFSIZEYUV(int width, int height, int subsamp)
+{
+ return tjBufSizeYUV(width, height, subsamp);
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT size_t tj3YUVPlaneSize(int componentID, int width, int stride,
+ int height, int subsamp)
+{
+ static const char FUNCTION_NAME[] = "tj3YUVPlaneSize";
+ unsigned long long retval = 0;
+ int pw, ph;
+
+ if (width < 1 || height < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROWG("Invalid argument", 0);
+
+ pw = tj3YUVPlaneWidth(componentID, width, subsamp);
+ ph = tj3YUVPlaneHeight(componentID, height, subsamp);
+ if (pw == 0 || ph == 0) return 0;
+
+ if (stride == 0) stride = pw;
+ else stride = abs(stride);
+
+ retval = (unsigned long long)stride * (ph - 1) + pw;
+#if ULLONG_MAX > ULONG_MAX
+ if (retval > (unsigned long long)((unsigned long)-1))
+ THROWG("Image is too large", 0);
+#endif
+
+bailout:
+ return (size_t)retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
+ int height, int subsamp)
+{
+ size_t retval = tj3YUVPlaneSize(componentID, width, stride, height, subsamp);
+ return (retval == 0) ? -1 : (unsigned long)retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3YUVPlaneWidth(int componentID, int width, int subsamp)
+{
+ static const char FUNCTION_NAME[] = "tj3YUVPlaneWidth";
+ unsigned long long pw, retval = 0;
+ int nc;
+
+ if (width < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROWG("Invalid argument", 0);
+ nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
+ if (componentID < 0 || componentID >= nc)
+ THROWG("Invalid argument", 0);
+
+ pw = PAD((unsigned long long)width, tjMCUWidth[subsamp] / 8);
+ if (componentID == 0)
+ retval = pw;
+ else
+ retval = pw * 8 / tjMCUWidth[subsamp];
+
+ if (retval > (unsigned long long)INT_MAX)
+ THROWG("Width is too large", 0);
+
+bailout:
+ return (int)retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjPlaneWidth(int componentID, int width, int subsamp)
+{
+ int retval = tj3YUVPlaneWidth(componentID, width, subsamp);
+ return (retval == 0) ? -1 : retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3YUVPlaneHeight(int componentID, int height, int subsamp)
+{
+ static const char FUNCTION_NAME[] = "tj3YUVPlaneHeight";
+ unsigned long long ph, retval = 0;
+ int nc;
+
+ if (height < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROWG("Invalid argument", 0);
+ nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
+ if (componentID < 0 || componentID >= nc)
+ THROWG("Invalid argument", 0);
+
+ ph = PAD((unsigned long long)height, tjMCUHeight[subsamp] / 8);
+ if (componentID == 0)
+ retval = ph;
+ else
+ retval = ph * 8 / tjMCUHeight[subsamp];
+
+ if (retval > (unsigned long long)INT_MAX)
+ THROWG("Height is too large", 0);
+
+bailout:
+ return (int)retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp)
+{
+ int retval = tj3YUVPlaneHeight(componentID, height, subsamp);
+ return (retval == 0) ? -1 : retval;
+}
+
+
+/******************************** Compressor *********************************/
+
+static tjhandle _tjInitCompress(tjinstance *this)
+{
+ static unsigned char buffer[1];
+ unsigned char *buf = buffer;
+ size_t size = 1;
+
+ /* This is also straight out of example.c */
+ this->cinfo.err = jpeg_std_error(&this->jerr.pub);
+ this->jerr.pub.error_exit = my_error_exit;
+ this->jerr.pub.output_message = my_output_message;
+ this->jerr.emit_message = this->jerr.pub.emit_message;
+ this->jerr.pub.emit_message = my_emit_message;
+ this->jerr.pub.addon_message_table = turbojpeg_message_table;
+ this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
+ this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ free(this);
+ return NULL;
+ }
+
+ jpeg_create_compress(&this->cinfo);
+ /* Make an initial call so it will create the destination manager */
+ jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
+
+ this->init |= COMPRESS;
+ return (tjhandle)this;
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT tjhandle tjInitCompress(void)
+{
+ return tj3Init(TJINIT_COMPRESS);
+}
+
+
+/* TurboJPEG 3.1+ */
+DLLEXPORT int tj3SetICCProfile(tjhandle handle, unsigned char *iccBuf,
+ size_t iccSize)
+{
+ static const char FUNCTION_NAME[] = "tj3SetICCProfile";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1)
+ if ((this->init & COMPRESS) == 0)
+ THROW("Instance has not been initialized for compression");
+
+ if (iccBuf == this->iccBuf && iccSize == this->iccSize)
+ return 0;
+
+ free(this->iccBuf);
+ this->iccBuf = NULL;
+ this->iccSize = 0;
+ if (iccBuf && iccSize) {
+ if ((this->iccBuf = (unsigned char *)malloc(iccSize)) == NULL)
+ THROW("Memory allocation failure");
+ memcpy(this->iccBuf, iccBuf, iccSize);
+ this->iccSize = iccSize;
+ }
+
+bailout:
+ return retval;
+}
+
+
+/* tj3Compress*() is implemented in turbojpeg-mp.c */
+#define BITS_IN_JSAMPLE 8
+#include "turbojpeg-mp.c"
+#undef BITS_IN_JSAMPLE
+#define BITS_IN_JSAMPLE 12
+#include "turbojpeg-mp.c"
+#undef BITS_IN_JSAMPLE
+#define BITS_IN_JSAMPLE 16
+#include "turbojpeg-mp.c"
+#undef BITS_IN_JSAMPLE
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char **jpegBuf, unsigned long *jpegSize,
+ int jpegSubsamp, int jpegQual, int flags)
+{
+ static const char FUNCTION_NAME[] = "tjCompress2";
+ int retval = 0;
+ size_t size;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (jpegSize == NULL || jpegSubsamp < 0 || jpegSubsamp >= TJ_NUMSAMP ||
+ jpegQual < 0 || jpegQual > 100)
+ THROW("Invalid argument");
+
+ this->quality = jpegQual;
+ this->subsamp = jpegSubsamp;
+ processFlags(handle, flags, COMPRESS);
+
+ size = (size_t)(*jpegSize);
+ if (this->noRealloc)
+ size = tj3JPEGBufSize(width, height, this->subsamp);
+ retval = tj3Compress8(handle, srcBuf, width, pitch, height, pixelFormat,
+ jpegBuf, &size);
+ *jpegSize = (unsigned long)size;
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT int tjCompress(tjhandle handle, unsigned char *srcBuf, int width,
+ int pitch, int height, int pixelSize,
+ unsigned char *jpegBuf, unsigned long *jpegSize,
+ int jpegSubsamp, int jpegQual, int flags)
+{
+ int retval = 0;
+ unsigned long size = jpegSize ? *jpegSize : 0;
+
+ if (flags & TJ_YUV) {
+ size = tjBufSizeYUV(width, height, jpegSubsamp);
+ retval = tjEncodeYUV2(handle, srcBuf, width, pitch, height,
+ getPixelFormat(pixelSize, flags), jpegBuf,
+ jpegSubsamp, flags);
+ } else {
+ retval = tjCompress2(handle, srcBuf, width, pitch, height,
+ getPixelFormat(pixelSize, flags), &jpegBuf, &size,
+ jpegSubsamp, jpegQual, flags | TJFLAG_NOREALLOC);
+ }
+ *jpegSize = size;
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3CompressFromYUVPlanes8(tjhandle handle,
+ const unsigned char * const *srcPlanes,
+ int width, const int *strides,
+ int height, unsigned char **jpegBuf,
+ size_t *jpegSize)
+{
+ static const char FUNCTION_NAME[] = "tj3CompressFromYUVPlanes8";
+ int i, row, retval = 0;
+ boolean alloc = TRUE;
+ int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
+ tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
+ JSAMPLE *_tmpbuf = NULL, *ptr;
+ JSAMPROW *inbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
+
+ GET_CINSTANCE(handle)
+
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ tmpbuf[i] = NULL; inbuf[i] = NULL;
+ }
+
+ if ((this->init & COMPRESS) == 0)
+ THROW("Instance has not been initialized for compression");
+
+ if (!srcPlanes || !srcPlanes[0] || width <= 0 || height <= 0 ||
+ jpegBuf == NULL || jpegSize == NULL)
+ THROW("Invalid argument");
+ if (this->subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
+ THROW("Invalid argument");
+
+ if (this->quality == -1)
+ THROW("TJPARAM_QUALITY must be specified");
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ cinfo->image_width = width;
+ cinfo->image_height = height;
+ cinfo->data_precision = 8;
+
+ if (this->noRealloc) alloc = FALSE;
+ jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
+ setCompDefaults(this, TJPF_RGB);
+ cinfo->raw_data_in = TRUE;
+
+ jpeg_start_compress(cinfo, TRUE);
+ if (this->iccBuf != NULL && this->iccSize != 0)
+ jpeg_write_icc_profile(cinfo, this->iccBuf, (unsigned int)this->iccSize);
+ for (i = 0; i < cinfo->num_components; i++) {
+ jpeg_component_info *compptr = &cinfo->comp_info[i];
+ int ih;
+
+ iw[i] = compptr->width_in_blocks * DCTSIZE;
+ ih = compptr->height_in_blocks * DCTSIZE;
+ pw[i] = PAD(cinfo->image_width, cinfo->max_h_samp_factor) *
+ compptr->h_samp_factor / cinfo->max_h_samp_factor;
+ ph[i] = PAD(cinfo->image_height, cinfo->max_v_samp_factor) *
+ compptr->v_samp_factor / cinfo->max_v_samp_factor;
+ if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
+ th[i] = compptr->v_samp_factor * DCTSIZE;
+ tmpbufsize += iw[i] * th[i];
+ if ((inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
+ THROW("Memory allocation failure");
+ ptr = (JSAMPLE *)srcPlanes[i];
+ for (row = 0; row < ph[i]; row++) {
+ inbuf[i][row] = ptr;
+ ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
+ }
+ }
+ if (usetmpbuf) {
+ if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
+ THROW("Memory allocation failure");
+ ptr = _tmpbuf;
+ for (i = 0; i < cinfo->num_components; i++) {
+ if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
+ THROW("Memory allocation failure");
+ for (row = 0; row < th[i]; row++) {
+ tmpbuf[i][row] = ptr;
+ ptr += iw[i];
+ }
+ }
+ }
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ for (row = 0; row < (int)cinfo->image_height;
+ row += cinfo->max_v_samp_factor * DCTSIZE) {
+ JSAMPARRAY yuvptr[MAX_COMPONENTS];
+ int crow[MAX_COMPONENTS];
+
+ for (i = 0; i < cinfo->num_components; i++) {
+ jpeg_component_info *compptr = &cinfo->comp_info[i];
+
+ crow[i] = row * compptr->v_samp_factor / cinfo->max_v_samp_factor;
+ if (usetmpbuf) {
+ int j, k;
+
+ for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
+ memcpy(tmpbuf[i][j], inbuf[i][crow[i] + j], pw[i]);
+ /* Duplicate last sample in row to fill out MCU */
+ for (k = pw[i]; k < iw[i]; k++)
+ tmpbuf[i][j][k] = tmpbuf[i][j][pw[i] - 1];
+ }
+ /* Duplicate last row to fill out MCU */
+ for (j = ph[i] - crow[i]; j < th[i]; j++)
+ memcpy(tmpbuf[i][j], tmpbuf[i][ph[i] - crow[i] - 1], iw[i]);
+ yuvptr[i] = tmpbuf[i];
+ } else
+ yuvptr[i] = &inbuf[i][crow[i]];
+ }
+ jpeg_write_raw_data(cinfo, yuvptr, cinfo->max_v_samp_factor * DCTSIZE);
+ }
+ jpeg_finish_compress(cinfo);
+
+bailout:
+ if (cinfo->global_state > CSTATE_START && alloc)
+ (*cinfo->dest->term_destination) (cinfo);
+ if (cinfo->global_state > CSTATE_START || retval == -1)
+ jpeg_abort_compress(cinfo);
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ free(tmpbuf[i]);
+ free(inbuf[i]);
+ }
+ free(_tmpbuf);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
+ const unsigned char **srcPlanes,
+ int width, const int *strides,
+ int height, int subsamp,
+ unsigned char **jpegBuf,
+ unsigned long *jpegSize, int jpegQual,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjCompressFromYUVPlanes";
+ int retval = 0;
+ size_t size;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP || jpegSize == NULL ||
+ jpegQual < 0 || jpegQual > 100)
+ THROW("Invalid argument");
+
+ this->quality = jpegQual;
+ this->subsamp = subsamp;
+ processFlags(handle, flags, COMPRESS);
+
+ size = (size_t)(*jpegSize);
+ if (this->noRealloc)
+ size = tj3JPEGBufSize(width, height, this->subsamp);
+ retval = tj3CompressFromYUVPlanes8(handle, srcPlanes, width, strides, height,
+ jpegBuf, &size);
+ *jpegSize = (unsigned long)size;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
+ const unsigned char *srcBuf, int width,
+ int align, int height,
+ unsigned char **jpegBuf, size_t *jpegSize)
+{
+ static const char FUNCTION_NAME[] = "tj3CompressFromYUV8";
+ const unsigned char *srcPlanes[3];
+ int pw0, ph0, strides[3], retval = -1;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (srcBuf == NULL || width <= 0 || align < 1 || !IS_POW2(align) ||
+ height <= 0)
+ THROW("Invalid argument");
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
+ ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
+ srcPlanes[0] = srcBuf;
+ strides[0] = PAD(pw0, align);
+ if (this->subsamp == TJSAMP_GRAY) {
+ strides[1] = strides[2] = 0;
+ srcPlanes[1] = srcPlanes[2] = NULL;
+ } else {
+ int pw1 = tjPlaneWidth(1, width, this->subsamp);
+ int ph1 = tjPlaneHeight(1, height, this->subsamp);
+
+ strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
+ srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
+ srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
+ }
+
+ return tj3CompressFromYUVPlanes8(handle, srcPlanes, width, strides, height,
+ jpegBuf, jpegSize);
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
+ int width, int align, int height, int subsamp,
+ unsigned char **jpegBuf,
+ unsigned long *jpegSize, int jpegQual,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjCompressFromYUV";
+ int retval = -1;
+ size_t size;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->quality = jpegQual;
+ this->subsamp = subsamp;
+ processFlags(handle, flags, COMPRESS);
+
+ size = (size_t)(*jpegSize);
+ if (this->noRealloc)
+ size = tj3JPEGBufSize(width, height, this->subsamp);
+ retval = tj3CompressFromYUV8(handle, srcBuf, width, align, height, jpegBuf,
+ &size);
+ *jpegSize = (unsigned long)size;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3EncodeYUVPlanes8(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height,
+ int pixelFormat, unsigned char **dstPlanes,
+ int *strides)
+{
+ static const char FUNCTION_NAME[] = "tj3EncodeYUVPlanes8";
+ JSAMPROW *row_pointer = NULL;
+ JSAMPLE *_tmpbuf[MAX_COMPONENTS], *_tmpbuf2[MAX_COMPONENTS];
+ JSAMPROW *tmpbuf[MAX_COMPONENTS], *tmpbuf2[MAX_COMPONENTS];
+ JSAMPROW *outbuf[MAX_COMPONENTS];
+ int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
+ JSAMPLE *ptr;
+ jpeg_component_info *compptr;
+
+ GET_CINSTANCE(handle)
+
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ tmpbuf[i] = NULL; _tmpbuf[i] = NULL;
+ tmpbuf2[i] = NULL; _tmpbuf2[i] = NULL; outbuf[i] = NULL;
+ }
+
+ if ((this->init & COMPRESS) == 0)
+ THROW("Instance has not been initialized for compression");
+
+ if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
+ pixelFormat < 0 || pixelFormat >= TJ_NUMPF || !dstPlanes ||
+ !dstPlanes[0])
+ THROW("Invalid argument");
+ if (this->subsamp != TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
+ THROW("Invalid argument");
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+ if (pixelFormat == TJPF_CMYK)
+ THROW("Cannot generate YUV images from packed-pixel CMYK images");
+
+ if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ cinfo->image_width = width;
+ cinfo->image_height = height;
+ cinfo->data_precision = 8;
+
+ setCompDefaults(this, pixelFormat);
+
+ /* Execute only the parts of jpeg_start_compress() that we need. If we
+ were to call the whole jpeg_start_compress() function, then it would try
+ to write the file headers, which could overflow the output buffer if the
+ YUV image were very small. */
+ if (cinfo->global_state != CSTATE_START)
+ THROW("libjpeg API is in the wrong state");
+ (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
+ jinit_c_master_control(cinfo, FALSE);
+ jinit_color_converter(cinfo);
+ jinit_downsampler(cinfo);
+ (*cinfo->cconvert->start_pass) (cinfo);
+
+ pw0 = PAD(width, cinfo->max_h_samp_factor);
+ ph0 = PAD(height, cinfo->max_v_samp_factor);
+
+ if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
+ THROW("Memory allocation failure");
+ for (i = 0; i < height; i++) {
+ if (this->bottomUp)
+ row_pointer[i] = (JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
+ else
+ row_pointer[i] = (JSAMPROW)&srcBuf[i * (size_t)pitch];
+ }
+ if (height < ph0)
+ for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
+
+ for (i = 0; i < cinfo->num_components; i++) {
+ compptr = &cinfo->comp_info[i];
+ _tmpbuf[i] = (JSAMPLE *)MALLOC(
+ PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
+ compptr->h_samp_factor, 32) *
+ cinfo->max_v_samp_factor + 32);
+ if (!_tmpbuf[i])
+ THROW("Memory allocation failure");
+ tmpbuf[i] =
+ (JSAMPROW *)malloc(sizeof(JSAMPROW) * cinfo->max_v_samp_factor);
+ if (!tmpbuf[i])
+ THROW("Memory allocation failure");
+ for (row = 0; row < cinfo->max_v_samp_factor; row++) {
+ unsigned char *_tmpbuf_aligned =
+ (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
+
+ tmpbuf[i][row] = &_tmpbuf_aligned[
+ PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
+ compptr->h_samp_factor, 32) * row];
+ }
+ _tmpbuf2[i] =
+ (JSAMPLE *)MALLOC(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
+ compptr->v_samp_factor + 32);
+ if (!_tmpbuf2[i])
+ THROW("Memory allocation failure");
+ tmpbuf2[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
+ if (!tmpbuf2[i])
+ THROW("Memory allocation failure");
+ for (row = 0; row < compptr->v_samp_factor; row++) {
+ unsigned char *_tmpbuf2_aligned =
+ (unsigned char *)PAD((JUINTPTR)_tmpbuf2[i], 32);
+
+ tmpbuf2[i][row] =
+ &_tmpbuf2_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
+ }
+ pw[i] = pw0 * compptr->h_samp_factor / cinfo->max_h_samp_factor;
+ ph[i] = ph0 * compptr->v_samp_factor / cinfo->max_v_samp_factor;
+ outbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
+ if (!outbuf[i])
+ THROW("Memory allocation failure");
+ ptr = dstPlanes[i];
+ for (row = 0; row < ph[i]; row++) {
+ outbuf[i][row] = ptr;
+ ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
+ }
+ }
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ for (row = 0; row < ph0; row += cinfo->max_v_samp_factor) {
+ (*cinfo->cconvert->color_convert) (cinfo, &row_pointer[row], tmpbuf, 0,
+ cinfo->max_v_samp_factor);
+ (cinfo->downsample->downsample) (cinfo, tmpbuf, 0, tmpbuf2, 0);
+ for (i = 0, compptr = cinfo->comp_info; i < cinfo->num_components;
+ i++, compptr++)
+ jcopy_sample_rows(tmpbuf2[i], 0, outbuf[i],
+ row * compptr->v_samp_factor / cinfo->max_v_samp_factor,
+ compptr->v_samp_factor, pw[i]);
+ }
+ cinfo->next_scanline += height;
+ jpeg_abort_compress(cinfo);
+
+bailout:
+ if (cinfo->global_state > CSTATE_START) jpeg_abort_compress(cinfo);
+ free(row_pointer);
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ free(tmpbuf[i]);
+ free(_tmpbuf[i]);
+ free(tmpbuf2[i]);
+ free(_tmpbuf2[i]);
+ free(outbuf[i]);
+ }
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height,
+ int pixelFormat, unsigned char **dstPlanes,
+ int *strides, int subsamp, int flags)
+{
+ static const char FUNCTION_NAME[] = "tjEncodeYUVPlanes";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->subsamp = subsamp;
+ processFlags(handle, flags, COMPRESS);
+
+ return tj3EncodeYUVPlanes8(handle, srcBuf, width, pitch, height, pixelFormat,
+ dstPlanes, strides);
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3EncodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char *dstBuf, int align)
+{
+ static const char FUNCTION_NAME[] = "tj3EncodeYUV8";
+ unsigned char *dstPlanes[3];
+ int pw0, ph0, strides[3], retval = -1;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (width <= 0 || height <= 0 || dstBuf == NULL || align < 1 ||
+ !IS_POW2(align))
+ THROW("Invalid argument");
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
+ ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
+ dstPlanes[0] = dstBuf;
+ strides[0] = PAD(pw0, align);
+ if (this->subsamp == TJSAMP_GRAY) {
+ strides[1] = strides[2] = 0;
+ dstPlanes[1] = dstPlanes[2] = NULL;
+ } else {
+ int pw1 = tj3YUVPlaneWidth(1, width, this->subsamp);
+ int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
+
+ strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
+ dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
+ dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
+ }
+
+ return tj3EncodeYUVPlanes8(handle, srcBuf, width, pitch, height, pixelFormat,
+ dstPlanes, strides);
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjEncodeYUV3(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char *dstBuf, int align, int subsamp,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjEncodeYUV3";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->subsamp = subsamp;
+ processFlags(handle, flags, COMPRESS);
+
+ return tj3EncodeYUV8(handle, srcBuf, width, pitch, height, pixelFormat,
+ dstBuf, align);
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT int tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf, int width,
+ int pitch, int height, int pixelFormat,
+ unsigned char *dstBuf, int subsamp, int flags)
+{
+ return tjEncodeYUV3(handle, srcBuf, width, pitch, height, pixelFormat,
+ dstBuf, 4, subsamp, flags);
+}
+
+/* TurboJPEG 1.1+ */
+DLLEXPORT int tjEncodeYUV(tjhandle handle, unsigned char *srcBuf, int width,
+ int pitch, int height, int pixelSize,
+ unsigned char *dstBuf, int subsamp, int flags)
+{
+ return tjEncodeYUV2(handle, srcBuf, width, pitch, height,
+ getPixelFormat(pixelSize, flags), dstBuf, subsamp,
+ flags);
+}
+
+
+/******************************* Decompressor ********************************/
+
+static tjhandle _tjInitDecompress(tjinstance *this)
+{
+ static unsigned char buffer[1];
+
+ /* This is also straight out of example.c */
+ this->dinfo.err = jpeg_std_error(&this->jerr.pub);
+ this->jerr.pub.error_exit = my_error_exit;
+ this->jerr.pub.output_message = my_output_message;
+ this->jerr.emit_message = this->jerr.pub.emit_message;
+ this->jerr.pub.emit_message = my_emit_message;
+ this->jerr.pub.addon_message_table = turbojpeg_message_table;
+ this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
+ this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ free(this);
+ return NULL;
+ }
+
+ jpeg_create_decompress(&this->dinfo);
+ /* Make an initial call so it will create the source manager */
+ jpeg_mem_src_tj(&this->dinfo, buffer, 1);
+
+ this->init |= DECOMPRESS;
+ return (tjhandle)this;
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT tjhandle tjInitDecompress(void)
+{
+ return tj3Init(TJINIT_DECOMPRESS);
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3DecompressHeader(tjhandle handle,
+ const unsigned char *jpegBuf,
+ size_t jpegSize)
+{
+ static const char FUNCTION_NAME[] = "tj3DecompressHeader";
+ int retval = 0;
+ unsigned char *iccPtr = NULL;
+ unsigned int iccLen = 0;
+
+ GET_DINSTANCE(handle);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (jpegBuf == NULL || jpegSize <= 0)
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ return -1;
+ }
+
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+
+ /* Extract ICC profile if TJPARAM_SAVEMARKERS is 2 or 4. (We could
+ eventually reuse this mechanism to save other markers, if needed.)
+ Because ICC profiles can be large, we extract them by default but allow
+ the user to override that behavior. */
+ if (this->saveMarkers == 2 || this->saveMarkers == 4)
+ jpeg_save_markers(dinfo, JPEG_APP0 + 2, 0xFFFF);
+ /* jpeg_read_header() calls jpeg_abort() and returns JPEG_HEADER_TABLES_ONLY
+ if the datastream is a tables-only datastream. Since we aren't using a
+ suspending data source, the only other value it can return is
+ JPEG_HEADER_OK. */
+ if (jpeg_read_header(dinfo, FALSE) == JPEG_HEADER_TABLES_ONLY)
+ return 0;
+
+ setDecompParameters(this);
+
+ if (this->saveMarkers == 2 || this->saveMarkers == 4) {
+ if (jpeg_read_icc_profile(dinfo, &iccPtr, &iccLen)) {
+ free(this->tempICCBuf);
+ this->tempICCBuf = iccPtr;
+ this->tempICCSize = (size_t)iccLen;
+ }
+ }
+
+ jpeg_abort_decompress(dinfo);
+
+ if (this->colorspace < 0)
+ THROW("Could not determine colorspace of JPEG image");
+ if (this->jpegWidth < 1 || this->jpegHeight < 1)
+ THROW("Invalid data returned in header");
+
+bailout:
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjDecompressHeader3(tjhandle handle,
+ const unsigned char *jpegBuf,
+ unsigned long jpegSize, int *width,
+ int *height, int *jpegSubsamp,
+ int *jpegColorspace)
+{
+ static const char FUNCTION_NAME[] = "tjDecompressHeader3";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (width == NULL || height == NULL || jpegSubsamp == NULL ||
+ jpegColorspace == NULL)
+ THROW("Invalid argument");
+
+ retval = tj3DecompressHeader(handle, jpegBuf, jpegSize);
+
+ *width = tj3Get(handle, TJPARAM_JPEGWIDTH);
+ *height = tj3Get(handle, TJPARAM_JPEGHEIGHT);
+ *jpegSubsamp = tj3Get(handle, TJPARAM_SUBSAMP);
+ if (*jpegSubsamp == TJSAMP_UNKNOWN)
+ THROW("Could not determine subsampling level of JPEG image");
+ *jpegColorspace = tj3Get(handle, TJPARAM_COLORSPACE);
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.1+ */
+DLLEXPORT int tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, int *width,
+ int *height, int *jpegSubsamp)
+{
+ int jpegColorspace;
+
+ return tjDecompressHeader3(handle, jpegBuf, jpegSize, width, height,
+ jpegSubsamp, &jpegColorspace);
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT int tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, int *width,
+ int *height)
+{
+ int jpegSubsamp;
+
+ return tjDecompressHeader2(handle, jpegBuf, jpegSize, width, height,
+ &jpegSubsamp);
+}
+
+
+/* TurboJPEG 3.1+ */
+DLLEXPORT int tj3GetICCProfile(tjhandle handle, unsigned char **iccBuf,
+ size_t *iccSize)
+{
+ static const char FUNCTION_NAME[] = "tj3GetICCProfile";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (iccSize == NULL)
+ THROW("Invalid argument");
+
+ if (!this->tempICCBuf || !this->tempICCSize) {
+ if (iccBuf) *iccBuf = NULL;
+ *iccSize = 0;
+ this->jerr.warning = TRUE;
+ THROW("No ICC profile data has been extracted");
+ }
+
+ *iccSize = this->tempICCSize;
+ if (iccBuf == NULL)
+ return 0;
+ *iccBuf = this->tempICCBuf;
+ this->tempICCBuf = NULL;
+ this->tempICCSize = 0;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT tjscalingfactor *tj3GetScalingFactors(int *numScalingFactors)
+{
+ static const char FUNCTION_NAME[] = "tj3GetScalingFactors";
+ tjscalingfactor *retval = (tjscalingfactor *)sf;
+
+ if (numScalingFactors == NULL)
+ THROWG("Invalid argument", NULL);
+
+ *numScalingFactors = NUMSF;
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT tjscalingfactor *tjGetScalingFactors(int *numScalingFactors)
+{
+ return tj3GetScalingFactors(numScalingFactors);
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3SetScalingFactor(tjhandle handle,
+ tjscalingfactor scalingFactor)
+{
+ static const char FUNCTION_NAME[] = "tj3SetScalingFactor";
+ int i, retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ for (i = 0; i < NUMSF; i++) {
+ if (scalingFactor.num == sf[i].num && scalingFactor.denom == sf[i].denom)
+ break;
+ }
+ if (i >= NUMSF)
+ THROW("Unsupported scaling factor");
+
+ this->scalingFactor = scalingFactor;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3SetCroppingRegion(tjhandle handle, tjregion croppingRegion)
+{
+ static const char FUNCTION_NAME[] = "tj3SetCroppingRegion";
+ int retval = 0, scaledWidth, scaledHeight;
+
+ GET_TJINSTANCE(handle, -1);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (croppingRegion.x == 0 && croppingRegion.y == 0 &&
+ croppingRegion.w == 0 && croppingRegion.h == 0) {
+ this->croppingRegion = croppingRegion;
+ return 0;
+ }
+
+ if (croppingRegion.x < 0 || croppingRegion.y < 0 || croppingRegion.w < 0 ||
+ croppingRegion.h < 0)
+ THROW("Invalid cropping region");
+ if (this->jpegWidth < 0 || this->jpegHeight < 0)
+ THROW("JPEG header has not yet been read");
+ if ((this->precision != 8 && this->precision != 12) || this->lossless)
+ THROW("Cannot partially decompress lossless JPEG images");
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("Could not determine subsampling level of JPEG image");
+
+ scaledWidth = TJSCALED(this->jpegWidth, this->scalingFactor);
+ scaledHeight = TJSCALED(this->jpegHeight, this->scalingFactor);
+
+ if (croppingRegion.x %
+ TJSCALED(tjMCUWidth[this->subsamp], this->scalingFactor) != 0)
+ THROWI("The left boundary of the cropping region (%d) is not\n"
+ "divisible by the scaled iMCU width (%d)",
+ croppingRegion.x,
+ TJSCALED(tjMCUWidth[this->subsamp], this->scalingFactor));
+ if (croppingRegion.w == 0)
+ croppingRegion.w = scaledWidth - croppingRegion.x;
+ if (croppingRegion.h == 0)
+ croppingRegion.h = scaledHeight - croppingRegion.y;
+ if (croppingRegion.w <= 0 || croppingRegion.h <= 0 ||
+ croppingRegion.x + croppingRegion.w > scaledWidth ||
+ croppingRegion.y + croppingRegion.h > scaledHeight)
+ THROW("The cropping region exceeds the scaled image dimensions");
+
+ this->croppingRegion = croppingRegion;
+
+bailout:
+ return retval;
+}
+
+
+/* tj3Decompress*() is implemented in turbojpeg-mp.c */
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT int tjDecompress2(tjhandle handle, const unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelFormat,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjDecompress2";
+ int i, retval = 0, jpegwidth, jpegheight, scaledw, scaledh;
+
+ GET_DINSTANCE(handle);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (jpegBuf == NULL || jpegSize <= 0 || width < 0 || height < 0)
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
+ if (width == 0) width = jpegwidth;
+ if (height == 0) height = jpegheight;
+ for (i = 0; i < NUMSF; i++) {
+ scaledw = TJSCALED(jpegwidth, sf[i]);
+ scaledh = TJSCALED(jpegheight, sf[i]);
+ if (scaledw <= width && scaledh <= height)
+ break;
+ }
+ if (i >= NUMSF)
+ THROW("Could not scale down to desired image dimensions");
+
+ processFlags(handle, flags, DECOMPRESS);
+
+ if (tj3SetScalingFactor(handle, sf[i]) == -1)
+ return -1;
+ if (tj3SetCroppingRegion(handle, TJUNCROPPED) == -1)
+ return -1;
+ return tj3Decompress8(handle, jpegBuf, jpegSize, dstBuf, pitch, pixelFormat);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.0+ */
+DLLEXPORT int tjDecompress(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelSize,
+ int flags)
+{
+ if (flags & TJ_YUV)
+ return tjDecompressToYUV(handle, jpegBuf, jpegSize, dstBuf, flags);
+ else
+ return tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, width, pitch,
+ height, getPixelFormat(pixelSize, flags), flags);
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
+ const unsigned char *jpegBuf,
+ size_t jpegSize,
+ unsigned char **dstPlanes,
+ int *strides)
+{
+ static const char FUNCTION_NAME[] = "tj3DecompressToYUVPlanes8";
+ int i, row, retval = 0;
+ int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
+ tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
+ JSAMPLE *_tmpbuf = NULL, *ptr;
+ JSAMPROW *outbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
+ int dctsize;
+ struct my_progress_mgr progress;
+
+ GET_DINSTANCE(handle);
+
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ tmpbuf[i] = NULL; outbuf[i] = NULL;
+ }
+
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (jpegBuf == NULL || jpegSize <= 0 || !dstPlanes || !dstPlanes[0])
+ THROW("Invalid argument");
+
+ if (this->scanLimit) {
+ memset(&progress, 0, sizeof(struct my_progress_mgr));
+ progress.pub.progress_monitor = my_progress_monitor;
+ progress.this = this;
+ dinfo->progress = &progress.pub;
+ } else
+ dinfo->progress = NULL;
+
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ if (dinfo->global_state <= DSTATE_INHEADER) {
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ }
+ setDecompParameters(this);
+ if (this->maxPixels &&
+ (unsigned long long)this->jpegWidth * this->jpegHeight >
+ (unsigned long long)this->maxPixels)
+ THROW("Image is too large");
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("Could not determine subsampling level of JPEG image");
+
+ if (this->subsamp != TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
+ THROW("Invalid argument");
+
+ if (dinfo->num_components > 3)
+ THROW("JPEG image must have 3 or fewer components");
+
+ dinfo->scale_num = this->scalingFactor.num;
+ dinfo->scale_denom = this->scalingFactor.denom;
+ jpeg_calc_output_dimensions(dinfo);
+
+ dctsize = DCTSIZE * this->scalingFactor.num / this->scalingFactor.denom;
+
+ for (i = 0; i < dinfo->num_components; i++) {
+ jpeg_component_info *compptr = &dinfo->comp_info[i];
+ int ih;
+
+ iw[i] = compptr->width_in_blocks * dctsize;
+ ih = compptr->height_in_blocks * dctsize;
+ pw[i] = tj3YUVPlaneWidth(i, dinfo->output_width, this->subsamp);
+ ph[i] = tj3YUVPlaneHeight(i, dinfo->output_height, this->subsamp);
+ if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
+ th[i] = compptr->v_samp_factor * dctsize;
+ tmpbufsize += iw[i] * th[i];
+ if ((outbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
+ THROW("Memory allocation failure");
+ ptr = dstPlanes[i];
+ for (row = 0; row < ph[i]; row++) {
+ outbuf[i][row] = ptr;
+ ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
+ }
+ }
+ if (usetmpbuf) {
+ if ((_tmpbuf = (JSAMPLE *)MALLOC(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
+ THROW("Memory allocation failure");
+ ptr = _tmpbuf;
+ for (i = 0; i < dinfo->num_components; i++) {
+ if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
+ THROW("Memory allocation failure");
+ for (row = 0; row < th[i]; row++) {
+ tmpbuf[i][row] = ptr;
+ ptr += iw[i];
+ }
+ }
+ }
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ dinfo->do_fancy_upsampling = !this->fastUpsample;
+ dinfo->dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
+ dinfo->raw_data_out = TRUE;
+
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
+ jpeg_start_decompress(dinfo);
+ for (row = 0; row < (int)dinfo->output_height;
+ row += dinfo->max_v_samp_factor * dinfo->_min_DCT_scaled_size) {
+ JSAMPARRAY yuvptr[MAX_COMPONENTS];
+ int crow[MAX_COMPONENTS];
+
+ for (i = 0; i < dinfo->num_components; i++) {
+ jpeg_component_info *compptr = &dinfo->comp_info[i];
+
+ if (this->subsamp == TJSAMP_420) {
+ /* When 4:2:0 subsampling is used with IDCT scaling, libjpeg will try
+ to be clever and use the IDCT to perform upsampling on the U and V
+ planes. For instance, if the output image is to be scaled by 1/2
+ relative to the JPEG image, then the scaling factor and upsampling
+ effectively cancel each other, so a normal 8x8 IDCT can be used.
+ However, this is not desirable when using the decompress-to-YUV
+ functionality in TurboJPEG, since we want to output the U and V
+ planes in their subsampled form. Thus, we have to override some
+ internal libjpeg parameters to force it to use the "scaled" IDCT
+ functions on the U and V planes. */
+ compptr->_DCT_scaled_size = dctsize;
+ compptr->MCU_sample_width = tjMCUWidth[this->subsamp] *
+ this->scalingFactor.num / this->scalingFactor.denom *
+ compptr->v_samp_factor / dinfo->max_v_samp_factor;
+ dinfo->idct->inverse_DCT[i] = dinfo->idct->inverse_DCT[0];
+ }
+ crow[i] = row * compptr->v_samp_factor / dinfo->max_v_samp_factor;
+ if (usetmpbuf) yuvptr[i] = tmpbuf[i];
+ else yuvptr[i] = &outbuf[i][crow[i]];
+ }
+ jpeg_read_raw_data(dinfo, yuvptr,
+ dinfo->max_v_samp_factor * dinfo->_min_DCT_scaled_size);
+ if (usetmpbuf) {
+ int j;
+
+ for (i = 0; i < dinfo->num_components; i++) {
+ for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
+ memcpy(outbuf[i][crow[i] + j], tmpbuf[i][j], pw[i]);
+ }
+ }
+ }
+ }
+ jpeg_finish_decompress(dinfo);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ free(tmpbuf[i]);
+ free(outbuf[i]);
+ }
+ free(_tmpbuf);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjDecompressToYUVPlanes(tjhandle handle,
+ const unsigned char *jpegBuf,
+ unsigned long jpegSize,
+ unsigned char **dstPlanes, int width,
+ int *strides, int height, int flags)
+{
+ static const char FUNCTION_NAME[] = "tjDecompressToYUVPlanes";
+ int i, retval = 0, jpegwidth, jpegheight, scaledw, scaledh;
+
+ GET_DINSTANCE(handle);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (jpegBuf == NULL || jpegSize <= 0 || width < 0 || height < 0)
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
+ if (width == 0) width = jpegwidth;
+ if (height == 0) height = jpegheight;
+ for (i = 0; i < NUMSF; i++) {
+ scaledw = TJSCALED(jpegwidth, sf[i]);
+ scaledh = TJSCALED(jpegheight, sf[i]);
+ if (scaledw <= width && scaledh <= height)
+ break;
+ }
+ if (i >= NUMSF)
+ THROW("Could not scale down to desired image dimensions");
+
+ processFlags(handle, flags, DECOMPRESS);
+
+ if (tj3SetScalingFactor(handle, sf[i]) == -1)
+ return -1;
+ return tj3DecompressToYUVPlanes8(handle, jpegBuf, jpegSize, dstPlanes,
+ strides);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3DecompressToYUV8(tjhandle handle,
+ const unsigned char *jpegBuf,
+ size_t jpegSize,
+ unsigned char *dstBuf, int align)
+{
+ static const char FUNCTION_NAME[] = "tj3DecompressToYUV8";
+ unsigned char *dstPlanes[3];
+ int pw0, ph0, strides[3], retval = -1;
+ int width, height;
+
+ GET_DINSTANCE(handle);
+
+ if (jpegBuf == NULL || jpegSize <= 0 || dstBuf == NULL || align < 1 ||
+ !IS_POW2(align))
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ if (dinfo->global_state <= DSTATE_INHEADER) {
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ }
+ setDecompParameters(this);
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("Could not determine subsampling level of JPEG image");
+
+ width = TJSCALED(dinfo->image_width, this->scalingFactor);
+ height = TJSCALED(dinfo->image_height, this->scalingFactor);
+
+ pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
+ ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
+ dstPlanes[0] = dstBuf;
+ strides[0] = PAD(pw0, align);
+ if (this->subsamp == TJSAMP_GRAY) {
+ strides[1] = strides[2] = 0;
+ dstPlanes[1] = dstPlanes[2] = NULL;
+ } else {
+ int pw1 = tj3YUVPlaneWidth(1, width, this->subsamp);
+ int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
+
+ strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
+ dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
+ dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
+ }
+
+ return tj3DecompressToYUVPlanes8(handle, jpegBuf, jpegSize, dstPlanes,
+ strides);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int width, int align, int height, int flags)
+{
+ static const char FUNCTION_NAME[] = "tjDecompressToYUV2";
+ int i, retval = 0, jpegwidth, jpegheight, scaledw, scaledh;
+
+ GET_DINSTANCE(handle);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (jpegBuf == NULL || jpegSize <= 0 || width < 0 || height < 0)
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
+ if (width == 0) width = jpegwidth;
+ if (height == 0) height = jpegheight;
+ for (i = 0; i < NUMSF; i++) {
+ scaledw = TJSCALED(jpegwidth, sf[i]);
+ scaledh = TJSCALED(jpegheight, sf[i]);
+ if (scaledw <= width && scaledh <= height)
+ break;
+ }
+ if (i >= NUMSF)
+ THROW("Could not scale down to desired image dimensions");
+
+ width = scaledw; height = scaledh;
+
+ processFlags(handle, flags, DECOMPRESS);
+
+ if (tj3SetScalingFactor(handle, sf[i]) == -1)
+ return -1;
+ return tj3DecompressToYUV8(handle, jpegBuf, (size_t)jpegSize, dstBuf, align);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.1+ */
+DLLEXPORT int tjDecompressToYUV(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int flags)
+{
+ return tjDecompressToYUV2(handle, jpegBuf, jpegSize, dstBuf, 0, 4, 0, flags);
+}
+
+
+static void setDecodeDefaults(tjinstance *this, int pixelFormat)
+{
+ int i;
+
+ this->dinfo.scale_num = this->dinfo.scale_denom = 1;
+
+ if (this->subsamp == TJSAMP_GRAY) {
+ this->dinfo.num_components = this->dinfo.comps_in_scan = 1;
+ this->dinfo.jpeg_color_space = JCS_GRAYSCALE;
+ } else {
+ this->dinfo.num_components = this->dinfo.comps_in_scan = 3;
+ this->dinfo.jpeg_color_space = JCS_YCbCr;
+ }
+
+ this->dinfo.comp_info = (jpeg_component_info *)
+ (*this->dinfo.mem->alloc_small) ((j_common_ptr)&this->dinfo, JPOOL_IMAGE,
+ this->dinfo.num_components *
+ sizeof(jpeg_component_info));
+
+ for (i = 0; i < this->dinfo.num_components; i++) {
+ jpeg_component_info *compptr = &this->dinfo.comp_info[i];
+
+ compptr->h_samp_factor = (i == 0) ? tjMCUWidth[this->subsamp] / 8 : 1;
+ compptr->v_samp_factor = (i == 0) ? tjMCUHeight[this->subsamp] / 8 : 1;
+ compptr->component_index = i;
+ compptr->component_id = i + 1;
+ compptr->quant_tbl_no = compptr->dc_tbl_no =
+ compptr->ac_tbl_no = (i == 0) ? 0 : 1;
+ this->dinfo.cur_comp_info[i] = compptr;
+ }
+ this->dinfo.data_precision = 8;
+ for (i = 0; i < 2; i++) {
+ if (this->dinfo.quant_tbl_ptrs[i] == NULL)
+ this->dinfo.quant_tbl_ptrs[i] =
+ jpeg_alloc_quant_table((j_common_ptr)&this->dinfo);
+ }
+
+ this->dinfo.mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+}
+
+
+static int my_read_markers(j_decompress_ptr dinfo)
+{
+ return JPEG_REACHED_SOS;
+}
+
+static void my_reset_marker_reader(j_decompress_ptr dinfo)
+{
+}
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3DecodeYUVPlanes8(tjhandle handle,
+ const unsigned char * const *srcPlanes,
+ const int *strides, unsigned char *dstBuf,
+ int width, int pitch, int height,
+ int pixelFormat)
+{
+ static const char FUNCTION_NAME[] = "tj3DecodeYUVPlanes8";
+ JSAMPROW *row_pointer = NULL;
+ JSAMPLE *_tmpbuf[MAX_COMPONENTS];
+ JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS];
+ int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
+ JSAMPLE *ptr;
+ jpeg_component_info *compptr;
+ int (*old_read_markers) (j_decompress_ptr);
+ void (*old_reset_marker_reader) (j_decompress_ptr);
+
+ GET_DINSTANCE(handle);
+
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ tmpbuf[i] = NULL; _tmpbuf[i] = NULL; inbuf[i] = NULL;
+ }
+
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (!srcPlanes || !srcPlanes[0] || dstBuf == NULL || width <= 0 ||
+ pitch < 0 || height <= 0 || pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
+ THROW("Invalid argument");
+ if (this->subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+ if (pixelFormat == TJPF_CMYK)
+ THROW("Cannot decode YUV images into packed-pixel CMYK images.");
+
+ if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
+ dinfo->image_width = width;
+ dinfo->image_height = height;
+
+ dinfo->progressive_mode = dinfo->inputctl->has_multiple_scans = FALSE;
+ dinfo->Ss = dinfo->Ah = dinfo->Al = 0;
+ dinfo->Se = DCTSIZE2 - 1;
+ setDecodeDefaults(this, pixelFormat);
+ old_read_markers = dinfo->marker->read_markers;
+ dinfo->marker->read_markers = my_read_markers;
+ old_reset_marker_reader = dinfo->marker->reset_marker_reader;
+ dinfo->marker->reset_marker_reader = my_reset_marker_reader;
+ jpeg_read_header(dinfo, TRUE);
+ dinfo->marker->read_markers = old_read_markers;
+ dinfo->marker->reset_marker_reader = old_reset_marker_reader;
+
+ this->dinfo.out_color_space = pf2cs[pixelFormat];
+ this->dinfo.dct_method = this->fastDCT ? JDCT_FASTEST : JDCT_ISLOW;
+ dinfo->do_fancy_upsampling = FALSE;
+ dinfo->Se = DCTSIZE2 - 1;
+ jinit_master_decompress(dinfo);
+ (*dinfo->upsample->start_pass) (dinfo);
+
+ pw0 = PAD(width, dinfo->max_h_samp_factor);
+ ph0 = PAD(height, dinfo->max_v_samp_factor);
+
+ if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
+
+ if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
+ THROW("Memory allocation failure");
+ for (i = 0; i < height; i++) {
+ if (this->bottomUp)
+ row_pointer[i] = &dstBuf[(height - i - 1) * (size_t)pitch];
+ else
+ row_pointer[i] = &dstBuf[i * (size_t)pitch];
+ }
+ if (height < ph0)
+ for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
+
+ for (i = 0; i < dinfo->num_components; i++) {
+ compptr = &dinfo->comp_info[i];
+ _tmpbuf[i] =
+ (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
+ compptr->v_samp_factor + 32);
+ if (!_tmpbuf[i])
+ THROW("Memory allocation failure");
+ tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
+ if (!tmpbuf[i])
+ THROW("Memory allocation failure");
+ for (row = 0; row < compptr->v_samp_factor; row++) {
+ unsigned char *_tmpbuf_aligned =
+ (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
+
+ tmpbuf[i][row] =
+ &_tmpbuf_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
+ }
+ pw[i] = pw0 * compptr->h_samp_factor / dinfo->max_h_samp_factor;
+ ph[i] = ph0 * compptr->v_samp_factor / dinfo->max_v_samp_factor;
+ inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
+ if (!inbuf[i])
+ THROW("Memory allocation failure");
+ ptr = (JSAMPLE *)srcPlanes[i];
+ for (row = 0; row < ph[i]; row++) {
+ inbuf[i][row] = ptr;
+ ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
+ }
+ }
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ for (row = 0; row < ph0; row += dinfo->max_v_samp_factor) {
+ JDIMENSION inrow = 0, outrow = 0;
+
+ for (i = 0, compptr = dinfo->comp_info; i < dinfo->num_components;
+ i++, compptr++)
+ jcopy_sample_rows(inbuf[i],
+ row * compptr->v_samp_factor / dinfo->max_v_samp_factor, tmpbuf[i], 0,
+ compptr->v_samp_factor, pw[i]);
+ (dinfo->upsample->upsample) (dinfo, tmpbuf, &inrow,
+ dinfo->max_v_samp_factor, &row_pointer[row],
+ &outrow, dinfo->max_v_samp_factor);
+ }
+ jpeg_abort_decompress(dinfo);
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ free(row_pointer);
+ for (i = 0; i < MAX_COMPONENTS; i++) {
+ free(tmpbuf[i]);
+ free(_tmpbuf[i]);
+ free(inbuf[i]);
+ }
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
+ const unsigned char **srcPlanes,
+ const int *strides, int subsamp,
+ unsigned char *dstBuf, int width, int pitch,
+ int height, int pixelFormat, int flags)
+{
+ static const char FUNCTION_NAME[] = "tjDecodeYUVPlanes";
+ int retval = 0;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->subsamp = subsamp;
+ processFlags(handle, flags, DECOMPRESS);
+
+ return tj3DecodeYUVPlanes8(handle, srcPlanes, strides, dstBuf, width, pitch,
+ height, pixelFormat);
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+ int align, unsigned char *dstBuf, int width,
+ int pitch, int height, int pixelFormat)
+{
+ static const char FUNCTION_NAME[] = "tj3DecodeYUV8";
+ const unsigned char *srcPlanes[3];
+ int pw0, ph0, strides[3], retval = -1;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (srcBuf == NULL || align < 1 || !IS_POW2(align) || width <= 0 ||
+ height <= 0)
+ THROW("Invalid argument");
+
+ if (this->subsamp == TJSAMP_UNKNOWN)
+ THROW("TJPARAM_SUBSAMP must be specified");
+
+ pw0 = tj3YUVPlaneWidth(0, width, this->subsamp);
+ ph0 = tj3YUVPlaneHeight(0, height, this->subsamp);
+ srcPlanes[0] = srcBuf;
+ strides[0] = PAD(pw0, align);
+ if (this->subsamp == TJSAMP_GRAY) {
+ strides[1] = strides[2] = 0;
+ srcPlanes[1] = srcPlanes[2] = NULL;
+ } else {
+ int pw1 = tj3YUVPlaneWidth(1, width, this->subsamp);
+ int ph1 = tj3YUVPlaneHeight(1, height, this->subsamp);
+
+ strides[1] = strides[2] = PAD(pw1, align);
+ if ((unsigned long long)strides[0] * (unsigned long long)ph0 >
+ (unsigned long long)INT_MAX ||
+ (unsigned long long)strides[1] * (unsigned long long)ph1 >
+ (unsigned long long)INT_MAX)
+ THROW("Image or row alignment is too large");
+ srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
+ srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
+ }
+
+ return tj3DecodeYUVPlanes8(handle, srcPlanes, strides, dstBuf, width, pitch,
+ height, pixelFormat);
+
+bailout:
+ return retval;
+}
+
+/* TurboJPEG 1.4+ */
+DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
+ int align, int subsamp, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelFormat,
+ int flags)
+{
+ static const char FUNCTION_NAME[] = "tjDecodeYUV";
+ int retval = -1;
+
+ GET_TJINSTANCE(handle, -1);
+
+ if (subsamp < 0 || subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ this->subsamp = subsamp;
+ processFlags(handle, flags, DECOMPRESS);
+
+ return tj3DecodeYUV8(handle, srcBuf, align, dstBuf, width, pitch, height,
+ pixelFormat);
+
+bailout:
+ return retval;
+}
+
+
+/******************************** Transformer ********************************/
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT tjhandle tjInitTransform(void)
+{
+ return tj3Init(TJINIT_TRANSFORM);
+}
+
+
+static int getDstSubsamp(int srcSubsamp, const tjtransform *transform)
+{
+ int dstSubsamp;
+
+ if (!transform)
+ return srcSubsamp;
+
+ dstSubsamp = (transform->options & TJXOPT_GRAY) ? TJSAMP_GRAY : srcSubsamp;
+
+ if (transform->op == TJXOP_TRANSPOSE || transform->op == TJXOP_TRANSVERSE ||
+ transform->op == TJXOP_ROT90 || transform->op == TJXOP_ROT270) {
+ if (dstSubsamp == TJSAMP_422) dstSubsamp = TJSAMP_440;
+ else if (dstSubsamp == TJSAMP_440) dstSubsamp = TJSAMP_422;
+ else if (dstSubsamp == TJSAMP_411) dstSubsamp = TJSAMP_441;
+ else if (dstSubsamp == TJSAMP_441) dstSubsamp = TJSAMP_411;
+ }
+
+ return dstSubsamp;
+}
+
+static int getTransformedSpecs(tjhandle handle, int *width, int *height,
+ int *subsamp, const tjtransform *transform,
+ const char *FUNCTION_NAME)
+{
+ int retval = 0, dstWidth, dstHeight, dstSubsamp;
+
+ GET_TJINSTANCE(handle, -1);
+ if ((this->init & COMPRESS) == 0 || (this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for transformation");
+
+ if (!width || !height || !subsamp || !transform || *width < 1 ||
+ *height < 1 || *subsamp < TJSAMP_UNKNOWN || *subsamp >= TJ_NUMSAMP)
+ THROW("Invalid argument");
+
+ dstWidth = *width; dstHeight = *height;
+ if (transform->op == TJXOP_TRANSPOSE || transform->op == TJXOP_TRANSVERSE ||
+ transform->op == TJXOP_ROT90 || transform->op == TJXOP_ROT270) {
+ dstWidth = *height; dstHeight = *width;
+ }
+ dstSubsamp = getDstSubsamp(*subsamp, transform);
+
+ if (transform->options & TJXOPT_CROP) {
+ int croppedWidth, croppedHeight;
+
+ if (transform->r.x < 0 || transform->r.y < 0 || transform->r.w < 0 ||
+ transform->r.h < 0)
+ THROW("Invalid cropping region");
+ if (dstSubsamp == TJSAMP_UNKNOWN)
+ THROW("Could not determine subsampling level of JPEG image");
+ if ((transform->r.x % tjMCUWidth[dstSubsamp]) != 0 ||
+ (transform->r.y % tjMCUHeight[dstSubsamp]) != 0)
+ THROWI("To crop this JPEG image, x must be a multiple of %d\n"
+ "and y must be a multiple of %d.", tjMCUWidth[dstSubsamp],
+ tjMCUHeight[dstSubsamp]);
+ if (transform->r.x >= dstWidth || transform->r.y >= dstHeight)
+ THROW("The cropping region exceeds the destination image dimensions");
+ croppedWidth = transform->r.w == 0 ? dstWidth - transform->r.x :
+ transform->r.w;
+ croppedHeight = transform->r.h == 0 ? dstHeight - transform->r.y :
+ transform->r.h;
+ if (transform->r.x + croppedWidth > dstWidth ||
+ transform->r.y + croppedHeight > dstHeight)
+ THROW("The cropping region exceeds the destination image dimensions");
+ dstWidth = croppedWidth; dstHeight = croppedHeight;
+ }
+
+ *width = dstWidth; *height = dstHeight; *subsamp = dstSubsamp;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.1+ */
+DLLEXPORT size_t tj3TransformBufSize(tjhandle handle,
+ const tjtransform *transform)
+{
+ static const char FUNCTION_NAME[] = "tj3TransformBufSize";
+ size_t retval = 0;
+ int dstWidth, dstHeight, dstSubsamp;
+
+ GET_TJINSTANCE(handle, 0);
+ if ((this->init & COMPRESS) == 0 || (this->init & DECOMPRESS) == 0)
+ THROWRV("Instance has not been initialized for transformation", 0);
+
+ if (transform == NULL)
+ THROWRV("Invalid argument", 0)
+
+ if (this->jpegWidth < 0 || this->jpegHeight < 0)
+ THROWRV("JPEG header has not yet been read", 0);
+
+ dstWidth = this->jpegWidth;
+ dstHeight = this->jpegHeight;
+ dstSubsamp = this->subsamp;
+ if (getTransformedSpecs(handle, &dstWidth, &dstHeight, &dstSubsamp,
+ transform, FUNCTION_NAME) == -1) {
+ retval = 0;
+ goto bailout;
+ }
+
+ retval = tj3JPEGBufSize(dstWidth, dstHeight, dstSubsamp);
+ if ((this->saveMarkers == 2 || this->saveMarkers == 4) &&
+ !(transform->options & TJXOPT_COPYNONE))
+ retval += this->tempICCSize;
+ else
+ retval += this->iccSize;
+
+bailout:
+ return retval;
+}
+
+
+/* TurboJPEG 3.0+ */
+DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
+ size_t jpegSize, int n, unsigned char **dstBufs,
+ size_t *dstSizes, const tjtransform *t)
+{
+ static const char FUNCTION_NAME[] = "tj3Transform";
+ jpeg_transform_info *xinfo = NULL;
+ jvirt_barray_ptr *srccoefs, *dstcoefs;
+ int retval = 0, i, saveMarkers = 0, srcSubsamp;
+ boolean alloc = TRUE;
+ struct my_progress_mgr progress;
+
+ GET_INSTANCE(handle);
+ if ((this->init & COMPRESS) == 0 || (this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for transformation");
+
+ if (jpegBuf == NULL || jpegSize <= 0 || n < 1 || dstBufs == NULL ||
+ dstSizes == NULL || t == NULL)
+ THROW("Invalid argument");
+
+ if (this->scanLimit) {
+ memset(&progress, 0, sizeof(struct my_progress_mgr));
+ progress.pub.progress_monitor = my_progress_monitor;
+ progress.this = this;
+ dinfo->progress = &progress.pub;
+ } else
+ dinfo->progress = NULL;
+
+ dinfo->mem->max_memory_to_use = (long)this->maxMemory * 1048576L;
+
+ if ((xinfo =
+ (jpeg_transform_info *)malloc(sizeof(jpeg_transform_info) * n)) == NULL)
+ THROW("Memory allocation failure");
+ memset(xinfo, 0, sizeof(jpeg_transform_info) * n);
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ if (dinfo->global_state <= DSTATE_INHEADER)
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+
+ for (i = 0; i < n; i++) {
+ if (t[i].op < 0 || t[i].op >= TJ_NUMXOP)
+ THROW("Invalid transform operation");
+ xinfo[i].transform = xformtypes[t[i].op];
+ xinfo[i].perfect = (t[i].options & TJXOPT_PERFECT) ? 1 : 0;
+ xinfo[i].trim = (t[i].options & TJXOPT_TRIM) ? 1 : 0;
+ xinfo[i].force_grayscale = (t[i].options & TJXOPT_GRAY) ? 1 : 0;
+ xinfo[i].crop = (t[i].options & TJXOPT_CROP) ? 1 : 0;
+ if (n != 1 && t[i].op == TJXOP_HFLIP) xinfo[i].slow_hflip = 1;
+ else xinfo[i].slow_hflip = 0;
+
+ if (xinfo[i].crop) {
+ if (t[i].r.x < 0 || t[i].r.y < 0 || t[i].r.w < 0 || t[i].r.h < 0)
+ THROW("Invalid cropping region");
+ xinfo[i].crop_xoffset = t[i].r.x; xinfo[i].crop_xoffset_set = JCROP_POS;
+ xinfo[i].crop_yoffset = t[i].r.y; xinfo[i].crop_yoffset_set = JCROP_POS;
+ if (t[i].r.w != 0) {
+ xinfo[i].crop_width = t[i].r.w; xinfo[i].crop_width_set = JCROP_POS;
+ } else
+ xinfo[i].crop_width = JCROP_UNSET;
+ if (t[i].r.h != 0) {
+ xinfo[i].crop_height = t[i].r.h; xinfo[i].crop_height_set = JCROP_POS;
+ } else
+ xinfo[i].crop_height = JCROP_UNSET;
+ }
+ if (!(t[i].options & TJXOPT_COPYNONE)) saveMarkers = 1;
+ }
+
+ jcopy_markers_setup(dinfo, saveMarkers ?
+ (JCOPY_OPTION)this->saveMarkers : JCOPYOPT_NONE);
+ if (dinfo->global_state <= DSTATE_INHEADER)
+ jpeg_read_header(dinfo, TRUE);
+ if (this->maxPixels &&
+ (unsigned long long)dinfo->image_width * dinfo->image_height >
+ (unsigned long long)this->maxPixels)
+ THROW("Image is too large");
+ srcSubsamp = getSubsamp(&this->dinfo);
+
+ for (i = 0; i < n; i++) {
+ if (!jtransform_request_workspace(dinfo, &xinfo[i]))
+ THROW("Transform is not perfect");
+
+ if (xinfo[i].crop) {
+ int dstSubsamp = getDstSubsamp(srcSubsamp, &t[i]);
+
+ if (dstSubsamp == TJSAMP_UNKNOWN)
+ THROW("Could not determine subsampling level of destination image");
+ if ((t[i].r.x % tjMCUWidth[dstSubsamp]) != 0 ||
+ (t[i].r.y % tjMCUHeight[dstSubsamp]) != 0)
+ THROWI("To crop this JPEG image, x must be a multiple of %d\n"
+ "and y must be a multiple of %d.", tjMCUWidth[dstSubsamp],
+ tjMCUHeight[dstSubsamp]);
+ }
+ }
+
+ srccoefs = jpeg_read_coefficients(dinfo);
+
+ for (i = 0; i < n; i++) {
+ if (this->noRealloc) alloc = FALSE;
+ if (!(t[i].options & TJXOPT_NOOUTPUT))
+ jpeg_mem_dest_tj(cinfo, &dstBufs[i], &dstSizes[i], alloc);
+ jpeg_copy_critical_parameters(dinfo, cinfo);
+ dstcoefs = jtransform_adjust_parameters(dinfo, cinfo, srccoefs, &xinfo[i]);
+ if (this->optimize || t[i].options & TJXOPT_OPTIMIZE)
+ cinfo->optimize_coding = TRUE;
+#ifdef C_PROGRESSIVE_SUPPORTED
+ if (this->progressive || t[i].options & TJXOPT_PROGRESSIVE)
+ jpeg_simple_progression(cinfo);
+#endif
+ if (this->arithmetic || t[i].options & TJXOPT_ARITHMETIC) {
+ cinfo->arith_code = TRUE;
+ cinfo->optimize_coding = FALSE;
+ }
+ cinfo->restart_interval = this->restartIntervalBlocks;
+ cinfo->restart_in_rows = this->restartIntervalRows;
+ if (!(t[i].options & TJXOPT_NOOUTPUT)) {
+ jpeg_write_coefficients(cinfo, dstcoefs);
+ jcopy_markers_execute(dinfo, cinfo, t[i].options & TJXOPT_COPYNONE ?
+ JCOPYOPT_NONE :
+ (JCOPY_OPTION)this->saveMarkers);
+ if (this->iccBuf != NULL && this->iccSize != 0)
+ jpeg_write_icc_profile(cinfo, this->iccBuf,
+ (unsigned int)this->iccSize);
+ } else
+ jinit_c_master_control(cinfo, TRUE);
+ jtransform_execute_transformation(dinfo, cinfo, srccoefs, &xinfo[i]);
+ if (t[i].customFilter) {
+ int ci, y;
+ JDIMENSION by;
+
+ for (ci = 0; ci < cinfo->num_components; ci++) {
+ jpeg_component_info *compptr = &cinfo->comp_info[ci];
+ tjregion arrayRegion = { 0, 0, 0, 0 };
+ tjregion planeRegion = { 0, 0, 0, 0 };
+
+ arrayRegion.w = compptr->width_in_blocks * DCTSIZE;
+ arrayRegion.h = DCTSIZE;
+ planeRegion.w = compptr->width_in_blocks * DCTSIZE;
+ planeRegion.h = compptr->height_in_blocks * DCTSIZE;
+
+ for (by = 0; by < compptr->height_in_blocks;
+ by += compptr->v_samp_factor) {
+ JBLOCKARRAY barray = (dinfo->mem->access_virt_barray)
+ ((j_common_ptr)dinfo, dstcoefs[ci], by, compptr->v_samp_factor,
+ TRUE);
+
+ for (y = 0; y < compptr->v_samp_factor; y++) {
+ if (t[i].customFilter(barray[y][0], arrayRegion, planeRegion, ci,
+ i, (tjtransform *)&t[i]) == -1)
+ THROW("Error in custom filter");
+ arrayRegion.y += DCTSIZE;
+ }
+ }
+ }
+ }
+ if (!(t[i].options & TJXOPT_NOOUTPUT)) jpeg_finish_compress(cinfo);
+ }
+
+ jpeg_finish_decompress(dinfo);
+
+bailout:
+ if (cinfo->global_state > CSTATE_START) {
+ if (alloc) (*cinfo->dest->term_destination) (cinfo);
+ jpeg_abort_compress(cinfo);
+ }
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ free(xinfo);
+ if (this->jerr.warning) retval = -1;
+ return retval;
+}
+
+/* TurboJPEG 1.2+ */
+DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
+ unsigned long jpegSize, int n,
+ unsigned char **dstBufs, unsigned long *dstSizes,
+ tjtransform *t, int flags)
+{
+ static const char FUNCTION_NAME[] = "tjTransform";
+ int i, retval = 0, srcSubsamp = -1;
+ size_t *sizes = NULL;
+
+ GET_DINSTANCE(handle);
+ if ((this->init & DECOMPRESS) == 0)
+ THROW("Instance has not been initialized for decompression");
+
+ if (n < 1 || dstSizes == NULL)
+ THROW("Invalid argument");
+
+ if (setjmp(this->jerr.setjmp_buffer)) {
+ /* If we get here, the JPEG code has signaled an error. */
+ retval = -1; goto bailout;
+ }
+
+ processFlags(handle, flags, COMPRESS);
+
+ if (this->noRealloc) {
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ srcSubsamp = getSubsamp(dinfo);
+ }
+
+ if ((sizes = (size_t *)malloc(n * sizeof(size_t))) == NULL)
+ THROW("Memory allocation failure");
+ for (i = 0; i < n; i++) {
+ sizes[i] = (size_t)dstSizes[i];
+ if (this->noRealloc) {
+ int dstWidth = dinfo->image_width, dstHeight = dinfo->image_height;
+ int dstSubsamp = srcSubsamp;
+
+ if (getTransformedSpecs(handle, &dstWidth, &dstHeight, &dstSubsamp,
+ &t[i], FUNCTION_NAME) == -1) {
+ retval = -1;
+ goto bailout;
+ }
+ sizes[i] = tj3JPEGBufSize(dstWidth, dstHeight, dstSubsamp);
+ }
+ }
+ retval = tj3Transform(handle, jpegBuf, (size_t)jpegSize, n, dstBufs, sizes,
+ t);
+ for (i = 0; i < n; i++)
+ dstSizes[i] = (unsigned long)sizes[i];
+
+bailout:
+ if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
+ if (this->jerr.warning) retval = -1;
+ free(sizes);
+ return retval;
+}
+
+
+/*************************** Packed-Pixel Image I/O **************************/
+
+/* tj3LoadImage*() is implemented in turbojpeg-mp.c */
+
+/* TurboJPEG 2.0+ */
+DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
+ int align, int *height,
+ int *pixelFormat, int flags)
+{
+ tjhandle handle = NULL;
+ unsigned char *dstBuf = NULL;
+
+ if ((handle = tj3Init(TJINIT_COMPRESS)) == NULL) return NULL;
+
+ processFlags(handle, flags, COMPRESS);
+
+ dstBuf = tj3LoadImage8(handle, filename, width, align, height, pixelFormat);
+
+ tj3Destroy(handle);
+ return dstBuf;
+}
+
+
+/* tj3SaveImage*() is implemented in turbojpeg-mp.c */
+
+/* TurboJPEG 2.0+ */
+DLLEXPORT int tjSaveImage(const char *filename, unsigned char *buffer,
+ int width, int pitch, int height, int pixelFormat,
+ int flags)
+{
+ tjhandle handle = NULL;
+ int retval = -1;
+
+ if ((handle = tj3Init(TJINIT_DECOMPRESS)) == NULL) return -1;
+
+ processFlags(handle, flags, DECOMPRESS);
+
+ retval = tj3SaveImage8(handle, filename, buffer, width, pitch, height,
+ pixelFormat);
+
+ tj3Destroy(handle);
+ return retval;
+}
diff --git a/contrib/libs/libjpeg-turbo/src/turbojpeg.h b/contrib/libs/libjpeg-turbo/src/turbojpeg.h
new file mode 100644
index 00000000000..274eb7a3644
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/turbojpeg.h
@@ -0,0 +1,2809 @@
+/*
+ * Copyright (C)2009-2015, 2017, 2020-2024 D. R. Commander.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * - Neither the name of the libjpeg-turbo Project nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __TURBOJPEG_H__
+#define __TURBOJPEG_H__
+
+#include <stddef.h>
+
+#if defined(_WIN32) && defined(DLLDEFINE)
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT
+#endif
+#define DLLCALL
+
+
+/**
+ * @addtogroup TurboJPEG
+ * TurboJPEG API. This API provides an interface for generating, decoding, and
+ * transforming planar YUV and JPEG images in memory.
+ *
+ * @anchor YUVnotes
+ * YUV Image Format Notes
+ * ----------------------
+ * Technically, the JPEG format uses the YCbCr colorspace (which is technically
+ * not a colorspace but a color transform), but per the convention of the
+ * digital video community, the TurboJPEG API uses "YUV" to refer to an image
+ * format consisting of Y, Cb, and Cr image planes.
+ *
+ * Each plane is simply a 2D array of bytes, each byte representing the value
+ * of one of the components (Y, Cb, or Cr) at a particular location in the
+ * image. The width and height of each plane are determined by the image
+ * width, height, and level of chrominance subsampling. The luminance plane
+ * width is the image width padded to the nearest multiple of the horizontal
+ * subsampling factor (1 in the case of 4:4:4, grayscale, 4:4:0, or 4:4:1; 2 in
+ * the case of 4:2:2 or 4:2:0; 4 in the case of 4:1:1.) Similarly, the
+ * luminance plane height is the image height padded to the nearest multiple of
+ * the vertical subsampling factor (1 in the case of 4:4:4, 4:2:2, grayscale,
+ * or 4:1:1; 2 in the case of 4:2:0 or 4:4:0; 4 in the case of 4:4:1.) This is
+ * irrespective of any additional padding that may be specified as an argument
+ * to the various YUV functions. The chrominance plane width is equal to the
+ * luminance plane width divided by the horizontal subsampling factor, and the
+ * chrominance plane height is equal to the luminance plane height divided by
+ * the vertical subsampling factor.
+ *
+ * For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is
+ * used, then the luminance plane would be 36 x 35 bytes, and each of the
+ * chrominance planes would be 18 x 35 bytes. If you specify a row alignment
+ * of 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes,
+ * and each of the chrominance planes would be 20 x 35 bytes.
+ *
+ * @{
+ */
+
+
+/**
+ * The number of initialization options
+ */
+#define TJ_NUMINIT 3
+
+/**
+ * Initialization options
+ */
+enum TJINIT {
+ /**
+ * Initialize the TurboJPEG instance for compression.
+ */
+ TJINIT_COMPRESS,
+ /**
+ * Initialize the TurboJPEG instance for decompression.
+ */
+ TJINIT_DECOMPRESS,
+ /**
+ * Initialize the TurboJPEG instance for lossless transformation (both
+ * compression and decompression.)
+ */
+ TJINIT_TRANSFORM
+};
+
+
+/**
+ * The number of chrominance subsampling options
+ */
+#define TJ_NUMSAMP 7
+
+/**
+ * Chrominance subsampling options
+ *
+ * When pixels are converted from RGB to YCbCr (see #TJCS_YCbCr) or from CMYK
+ * to YCCK (see #TJCS_YCCK) as part of the JPEG compression process, some of
+ * the Cb and Cr (chrominance) components can be discarded or averaged together
+ * to produce a smaller image with little perceptible loss of image quality.
+ * (The human eye is more sensitive to small changes in brightness than to
+ * small changes in color.) This is called "chrominance subsampling".
+ */
+enum TJSAMP {
+ /**
+ * 4:4:4 chrominance subsampling (no chrominance subsampling)
+ *
+ * The JPEG or YUV image will contain one chrominance component for every
+ * pixel in the source image.
+ */
+ TJSAMP_444,
+ /**
+ * 4:2:2 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 2x1
+ * block of pixels in the source image.
+ */
+ TJSAMP_422,
+ /**
+ * 4:2:0 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 2x2
+ * block of pixels in the source image.
+ */
+ TJSAMP_420,
+ /**
+ * Grayscale
+ *
+ * The JPEG or YUV image will contain no chrominance components.
+ */
+ TJSAMP_GRAY,
+ /**
+ * 4:4:0 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 1x2
+ * block of pixels in the source image.
+ *
+ * @note 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
+ */
+ TJSAMP_440,
+ /**
+ * 4:1:1 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 4x1
+ * block of pixels in the source image. All else being equal, a JPEG image
+ * with 4:1:1 subsampling is almost exactly the same size as a JPEG image
+ * with 4:2:0 subsampling, and in the aggregate, both subsampling methods
+ * produce approximately the same perceptual quality. However, 4:1:1 is
+ * better able to reproduce sharp horizontal features.
+ *
+ * @note 4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
+ */
+ TJSAMP_411,
+ /**
+ * 4:4:1 chrominance subsampling
+ *
+ * The JPEG or YUV image will contain one chrominance component for every 1x4
+ * block of pixels in the source image. All else being equal, a JPEG image
+ * with 4:4:1 subsampling is almost exactly the same size as a JPEG image
+ * with 4:2:0 subsampling, and in the aggregate, both subsampling methods
+ * produce approximately the same perceptual quality. However, 4:4:1 is
+ * better able to reproduce sharp vertical features.
+ *
+ * @note 4:4:1 subsampling is not fully accelerated in libjpeg-turbo.
+ */
+ TJSAMP_441,
+ /**
+ * Unknown subsampling
+ *
+ * The JPEG image uses an unusual type of chrominance subsampling. Such
+ * images can be decompressed into packed-pixel images, but they cannot be
+ * - decompressed into planar YUV images,
+ * - losslessly transformed if #TJXOPT_CROP is specified and #TJXOPT_GRAY is
+ * not specified, or
+ * - partially decompressed using a cropping region.
+ */
+ TJSAMP_UNKNOWN = -1
+};
+
+/**
+ * iMCU width (in pixels) for a given level of chrominance subsampling
+ *
+ * In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ * component are interleaved in a single scan. If the image uses chrominance
+ * subsampling, then multiple luminance blocks are stored together, followed by
+ * a single block for each chrominance component. The minimum set of
+ * full-resolution luminance block(s) and corresponding (possibly subsampled)
+ * chrominance blocks necessary to represent at least one DCT block per
+ * component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ * in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ * two luminance blocks followed by one block for each chrominance component.)
+ * In a non-interleaved lossy JPEG image, each component is stored in a
+ * separate scan, and an MCU is a single DCT block, so we use the term "iMCU"
+ * (interleaved MCU) to refer to the equivalent of an MCU in an interleaved
+ * JPEG image. For the common case of interleaved JPEG images, an iMCU is the
+ * same as an MCU.
+ *
+ * iMCU sizes:
+ * - 8x8 for no subsampling or grayscale
+ * - 16x8 for 4:2:2
+ * - 8x16 for 4:4:0
+ * - 16x16 for 4:2:0
+ * - 32x8 for 4:1:1
+ * - 8x32 for 4:4:1
+ */
+static const int tjMCUWidth[TJ_NUMSAMP] = { 8, 16, 16, 8, 8, 32, 8 };
+
+/**
+ * iMCU height (in pixels) for a given level of chrominance subsampling
+ *
+ * In a typical lossy JPEG image, 8x8 blocks of DCT coefficients for each
+ * component are interleaved in a single scan. If the image uses chrominance
+ * subsampling, then multiple luminance blocks are stored together, followed by
+ * a single block for each chrominance component. The minimum set of
+ * full-resolution luminance block(s) and corresponding (possibly subsampled)
+ * chrominance blocks necessary to represent at least one DCT block per
+ * component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU
+ * in an interleaved lossy JPEG image that uses 4:2:2 subsampling consists of
+ * two luminance blocks followed by one block for each chrominance component.)
+ * In a non-interleaved lossy JPEG image, each component is stored in a
+ * separate scan, and an MCU is a single DCT block, so we use the term "iMCU"
+ * (interleaved MCU) to refer to the equivalent of an MCU in an interleaved
+ * JPEG image. For the common case of interleaved JPEG images, an iMCU is the
+ * same as an MCU.
+ *
+ * iMCU sizes:
+ * - 8x8 for no subsampling or grayscale
+ * - 16x8 for 4:2:2
+ * - 8x16 for 4:4:0
+ * - 16x16 for 4:2:0
+ * - 32x8 for 4:1:1
+ * - 8x32 for 4:4:1
+ */
+static const int tjMCUHeight[TJ_NUMSAMP] = { 8, 8, 16, 8, 16, 8, 32 };
+
+
+/**
+ * The number of pixel formats
+ */
+#define TJ_NUMPF 12
+
+/**
+ * Pixel formats
+ */
+enum TJPF {
+ /**
+ * RGB pixel format
+ *
+ * The red, green, and blue components in the image are stored in 3-sample
+ * pixels in the order R, G, B from lowest to highest memory address within
+ * each pixel.
+ */
+ TJPF_RGB,
+ /**
+ * BGR pixel format
+ *
+ * The red, green, and blue components in the image are stored in 3-sample
+ * pixels in the order B, G, R from lowest to highest memory address within
+ * each pixel.
+ */
+ TJPF_BGR,
+ /**
+ * RGBX pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order R, G, B from lowest to highest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
+ */
+ TJPF_RGBX,
+ /**
+ * BGRX pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order B, G, R from lowest to highest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
+ */
+ TJPF_BGRX,
+ /**
+ * XBGR pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order R, G, B from highest to lowest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
+ */
+ TJPF_XBGR,
+ /**
+ * XRGB pixel format
+ *
+ * The red, green, and blue components in the image are stored in 4-sample
+ * pixels in the order B, G, R from highest to lowest memory address within
+ * each pixel. The X component is ignored when compressing/encoding and
+ * undefined when decompressing/decoding.
+ */
+ TJPF_XRGB,
+ /**
+ * Grayscale pixel format
+ *
+ * Each 1-sample pixel represents a luminance (brightness) level from 0 to
+ * the maximum sample value (which is, for instance, 255 for 8-bit samples or
+ * 4095 for 12-bit samples or 65535 for 16-bit samples.)
+ */
+ TJPF_GRAY,
+ /**
+ * RGBA pixel format
+ *
+ * This is the same as @ref TJPF_RGBX, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
+ */
+ TJPF_RGBA,
+ /**
+ * BGRA pixel format
+ *
+ * This is the same as @ref TJPF_BGRX, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
+ */
+ TJPF_BGRA,
+ /**
+ * ABGR pixel format
+ *
+ * This is the same as @ref TJPF_XBGR, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
+ */
+ TJPF_ABGR,
+ /**
+ * ARGB pixel format
+ *
+ * This is the same as @ref TJPF_XRGB, except that when
+ * decompressing/decoding, the X component is guaranteed to be equal to the
+ * maximum sample value, which can be interpreted as an opaque alpha channel.
+ */
+ TJPF_ARGB,
+ /**
+ * CMYK pixel format
+ *
+ * Unlike RGB, which is an additive color model used primarily for display,
+ * CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used primarily
+ * for printing. In the CMYK color model, the value of each color component
+ * typically corresponds to an amount of cyan, magenta, yellow, or black ink
+ * that is applied to a white background. In order to convert between CMYK
+ * and RGB, it is necessary to use a color management system (CMS.) A CMS
+ * will attempt to map colors within the printer's gamut to perceptually
+ * similar colors in the display's gamut and vice versa, but the mapping is
+ * typically not 1:1 or reversible, nor can it be defined with a simple
+ * formula. Thus, such a conversion is out of scope for a codec library.
+ * However, the TurboJPEG API allows for compressing packed-pixel CMYK images
+ * into YCCK JPEG images (see #TJCS_YCCK) and decompressing YCCK JPEG images
+ * into packed-pixel CMYK images.
+ */
+ TJPF_CMYK,
+ /**
+ * Unknown pixel format
+ *
+ * Currently this is only used by #tj3LoadImage8(), #tj3LoadImage12(), and
+ * #tj3LoadImage16().
+ */
+ TJPF_UNKNOWN = -1
+};
+
+/**
+ * Red offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the red component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRX is stored in `unsigned char pixel[]`, then the red
+ * component is `pixel[tjRedOffset[TJPF_BGRX]]`. The offset is -1 if the pixel
+ * format does not have a red component.
+ */
+static const int tjRedOffset[TJ_NUMPF] = {
+ 0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1
+};
+/**
+ * Green offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the green component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRX is stored in `unsigned char pixel[]`, then the green
+ * component is `pixel[tjGreenOffset[TJPF_BGRX]]`. The offset is -1 if the
+ * pixel format does not have a green component.
+ */
+static const int tjGreenOffset[TJ_NUMPF] = {
+ 1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1
+};
+/**
+ * Blue offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the blue component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRX is stored in `unsigned char pixel[]`, then the blue
+ * component is `pixel[tjBlueOffset[TJPF_BGRX]]`. The offset is -1 if the
+ * pixel format does not have a blue component.
+ */
+static const int tjBlueOffset[TJ_NUMPF] = {
+ 2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
+};
+/**
+ * Alpha offset (in samples) for a given pixel format
+ *
+ * This specifies the number of samples that the alpha component is offset from
+ * the start of the pixel. For instance, if an 8-bit-per-component pixel of
+ * format TJPF_BGRA is stored in `unsigned char pixel[]`, then the alpha
+ * component is `pixel[tjAlphaOffset[TJPF_BGRA]]`. The offset is -1 if the
+ * pixel format does not have an alpha component.
+ */
+static const int tjAlphaOffset[TJ_NUMPF] = {
+ -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
+};
+/**
+ * Pixel size (in samples) for a given pixel format
+ */
+static const int tjPixelSize[TJ_NUMPF] = {
+ 3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
+};
+
+
+/**
+ * The number of JPEG colorspaces
+ */
+#define TJ_NUMCS 5
+
+/**
+ * JPEG colorspaces
+ */
+enum TJCS {
+ /**
+ * RGB colorspace
+ *
+ * When generating the JPEG image, the R, G, and B components in the source
+ * image are reordered into image planes, but no colorspace conversion or
+ * subsampling is performed. RGB JPEG images can be generated from and
+ * decompressed to packed-pixel images with any of the extended RGB or
+ * grayscale pixel formats, but they cannot be generated from or
+ * decompressed to planar YUV images.
+ */
+ TJCS_RGB,
+ /**
+ * YCbCr colorspace
+ *
+ * YCbCr is not an absolute colorspace but rather a mathematical
+ * transformation of RGB designed solely for storage and transmission. YCbCr
+ * images must be converted to RGB before they can be displayed. In the
+ * YCbCr colorspace, the Y (luminance) component represents the black & white
+ * portion of the original image, and the Cb and Cr (chrominance) components
+ * represent the color portion of the original image. Historically, the
+ * analog equivalent of this transformation allowed the same signal to be
+ * displayed to both black & white and color televisions, but JPEG images use
+ * YCbCr primarily because it allows the color data to be optionally
+ * subsampled in order to reduce network and disk usage. YCbCr is the most
+ * common JPEG colorspace, and YCbCr JPEG images can be generated from and
+ * decompressed to packed-pixel images with any of the extended RGB or
+ * grayscale pixel formats. YCbCr JPEG images can also be generated from
+ * and decompressed to planar YUV images.
+ */
+ TJCS_YCbCr,
+ /**
+ * Grayscale colorspace
+ *
+ * The JPEG image retains only the luminance data (Y component), and any
+ * color data from the source image is discarded. Grayscale JPEG images can
+ * be generated from and decompressed to packed-pixel images with any of the
+ * extended RGB or grayscale pixel formats, or they can be generated from
+ * and decompressed to planar YUV images.
+ */
+ TJCS_GRAY,
+ /**
+ * CMYK colorspace
+ *
+ * When generating the JPEG image, the C, M, Y, and K components in the
+ * source image are reordered into image planes, but no colorspace conversion
+ * or subsampling is performed. CMYK JPEG images can only be generated from
+ * and decompressed to packed-pixel images with the CMYK pixel format.
+ */
+ TJCS_CMYK,
+ /**
+ * YCCK colorspace
+ *
+ * YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a
+ * mathematical transformation of CMYK designed solely for storage and
+ * transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
+ * reversibly transformed into YCCK, and as with YCbCr, the chrominance
+ * components in the YCCK pixels can be subsampled without incurring major
+ * perceptual loss. YCCK JPEG images can only be generated from and
+ * decompressed to packed-pixel images with the CMYK pixel format.
+ */
+ TJCS_YCCK
+};
+
+
+/**
+ * Parameters
+ */
+enum TJPARAM {
+ /**
+ * Error handling behavior
+ *
+ * **Value**
+ * - `0` *[default]* Allow the current compression/decompression/transform
+ * operation to complete unless a fatal error is encountered.
+ * - `1` Immediately discontinue the current
+ * compression/decompression/transform operation if a warning (non-fatal
+ * error) occurs.
+ */
+ TJPARAM_STOPONWARNING,
+ /**
+ * Row order in packed-pixel source/destination images
+ *
+ * **Value**
+ * - `0` *[default]* top-down (X11) order
+ * - `1` bottom-up (Windows, OpenGL) order
+ */
+ TJPARAM_BOTTOMUP,
+ /**
+ * JPEG destination buffer (re)allocation [compression, lossless
+ * transformation]
+ *
+ * **Value**
+ * - `0` *[default]* Attempt to allocate or reallocate the JPEG destination
+ * buffer as needed.
+ * - `1` Generate an error if the JPEG destination buffer is invalid or too
+ * small.
+ */
+ TJPARAM_NOREALLOC,
+ /**
+ * Perceptual quality of lossy JPEG images [compression only]
+ *
+ * **Value**
+ * - `1`-`100` (`1` = worst quality but best compression, `100` = best
+ * quality but worst compression) *[no default; must be explicitly
+ * specified]*
+ */
+ TJPARAM_QUALITY,
+ /**
+ * Chrominance subsampling level
+ *
+ * The JPEG or YUV image uses (decompression, decoding) or will use (lossy
+ * compression, encoding) the specified level of chrominance subsampling.
+ *
+ * **Value**
+ * - One of the @ref TJSAMP "chrominance subsampling options" *[no default;
+ * must be explicitly specified for lossy compression, encoding, and
+ * decoding]*
+ */
+ TJPARAM_SUBSAMP,
+ /**
+ * JPEG width (in pixels) [decompression only, read-only]
+ */
+ TJPARAM_JPEGWIDTH,
+ /**
+ * JPEG height (in pixels) [decompression only, read-only]
+ */
+ TJPARAM_JPEGHEIGHT,
+ /**
+ * Data precision (bits per sample)
+ *
+ * The JPEG image uses (decompression) or will use (lossless compression) the
+ * specified number of bits per sample. This parameter also specifies the
+ * target data precision when loading a PBMPLUS file with #tj3LoadImage8(),
+ * #tj3LoadImage12(), or #tj3LoadImage16() and the source data precision when
+ * saving a PBMPLUS file with #tj3SaveImage8(), #tj3SaveImage12(), or
+ * #tj3SaveImage16().
+ *
+ * The data precision is the number of bits in the maximum sample value,
+ * which may not be the same as the width of the data type used to store the
+ * sample.
+ *
+ * **Value**
+ * - `8` or `12` for lossy JPEG images; `2` to `16` for lossless JPEG and
+ * PBMPLUS images
+ *
+ * 12-bit JPEG data precision implies #TJPARAM_OPTIMIZE unless
+ * #TJPARAM_ARITHMETIC is set.
+ */
+ TJPARAM_PRECISION,
+ /**
+ * JPEG colorspace
+ *
+ * The JPEG image uses (decompression) or will use (lossy compression) the
+ * specified colorspace.
+ *
+ * **Value**
+ * - One of the @ref TJCS "JPEG colorspaces" *[default for lossy compression:
+ * automatically selected based on the subsampling level and pixel format]*
+ */
+ TJPARAM_COLORSPACE,
+ /**
+ * Chrominance upsampling algorithm [lossy decompression only]
+ *
+ * **Value**
+ * - `0` *[default]* Use smooth upsampling when decompressing a JPEG image
+ * that was generated using chrominance subsampling. This creates a smooth
+ * transition between neighboring chrominance components in order to reduce
+ * upsampling artifacts in the decompressed image.
+ * - `1` Use the fastest chrominance upsampling algorithm available, which
+ * may combine upsampling with color conversion.
+ */
+ TJPARAM_FASTUPSAMPLE,
+ /**
+ * DCT/IDCT algorithm [lossy compression and decompression]
+ *
+ * **Value**
+ * - `0` *[default]* Use the most accurate DCT/IDCT algorithm available.
+ * - `1` Use the fastest DCT/IDCT algorithm available.
+ *
+ * This parameter is provided mainly for backward compatibility with libjpeg,
+ * which historically implemented several different DCT/IDCT algorithms
+ * because of performance limitations with 1990s CPUs. In the libjpeg-turbo
+ * implementation of the TurboJPEG API:
+ * - The "fast" and "accurate" DCT/IDCT algorithms perform similarly on
+ * modern x86/x86-64 CPUs that support AVX2 instructions.
+ * - The "fast" algorithm is generally only about 5-15% faster than the
+ * "accurate" algorithm on other types of CPUs.
+ * - The difference in accuracy between the "fast" and "accurate" algorithms
+ * is the most pronounced at JPEG quality levels above 90 and tends to be
+ * more pronounced with decompression than with compression.
+ * - For JPEG quality levels above 97, the "fast" algorithm degrades and is
+ * not fully accelerated, so it is slower than the "accurate" algorithm.
+ */
+ TJPARAM_FASTDCT,
+ /**
+ * Huffman table optimization [lossy compression, lossless transformation]
+ *
+ * **Value**
+ * - `0` *[default]* The JPEG image will use the default Huffman tables.
+ * - `1` Optimal Huffman tables will be computed for the JPEG image. For
+ * lossless transformation, this can also be specified using
+ * #TJXOPT_OPTIMIZE.
+ *
+ * Huffman table optimization improves compression slightly (generally 5% or
+ * less), but it reduces compression performance considerably.
+ */
+ TJPARAM_OPTIMIZE,
+ /**
+ * Progressive JPEG
+ *
+ * In a progressive JPEG image, the DCT coefficients are split across
+ * multiple "scans" of increasing quality. Thus, a low-quality scan
+ * containing the lowest-frequency DCT coefficients can be transmitted first
+ * and refined with subsequent higher-quality scans containing
+ * higher-frequency DCT coefficients. When using Huffman entropy coding, the
+ * progressive JPEG format also provides an "end-of-bands (EOB) run" feature
+ * that allows large groups of zeroes, potentially spanning multiple MCUs,
+ * to be represented using only a few bytes.
+ *
+ * **Value**
+ * - `0` *[default for compression, lossless transformation]* The lossy JPEG
+ * image is (decompression) or will be (compression, lossless transformation)
+ * single-scan.
+ * - `1` The lossy JPEG image is (decompression) or will be (compression,
+ * lossless transformation) progressive. For lossless transformation, this
+ * can also be specified using #TJXOPT_PROGRESSIVE.
+ *
+ * Progressive JPEG images generally have better compression ratios than
+ * single-scan JPEG images (much better if the image has large areas of solid
+ * color), but progressive JPEG compression and decompression is considerably
+ * slower than single-scan JPEG compression and decompression. Can be
+ * combined with #TJPARAM_ARITHMETIC. Implies #TJPARAM_OPTIMIZE unless
+ * #TJPARAM_ARITHMETIC is also set.
+ */
+ TJPARAM_PROGRESSIVE,
+ /**
+ * Progressive JPEG scan limit for lossy JPEG images [decompression, lossless
+ * transformation]
+ *
+ * Setting this parameter causes the decompression and transform functions to
+ * return an error if the number of scans in a progressive JPEG image exceeds
+ * the specified limit. The primary purpose of this is to allow
+ * security-critical applications to guard against an exploit of the
+ * progressive JPEG format described in
+ * <a href="https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf" target="_blank">this report</a>.
+ *
+ * **Value**
+ * - maximum number of progressive JPEG scans that the decompression and
+ * transform functions will process *[default: `0` (no limit)]*
+ *
+ * @see #TJPARAM_PROGRESSIVE
+ */
+ TJPARAM_SCANLIMIT,
+ /**
+ * Arithmetic entropy coding
+ *
+ * **Value**
+ * - `0` *[default for compression, lossless transformation]* The lossy JPEG
+ * image uses (decompression) or will use (compression, lossless
+ * transformation) Huffman entropy coding.
+ * - `1` The lossy JPEG image uses (decompression) or will use (compression,
+ * lossless transformation) arithmetic entropy coding. For lossless
+ * transformation, this can also be specified using #TJXOPT_ARITHMETIC.
+ *
+ * Arithmetic entropy coding generally improves compression relative to
+ * Huffman entropy coding, but it reduces compression and decompression
+ * performance considerably. Can be combined with #TJPARAM_PROGRESSIVE.
+ */
+ TJPARAM_ARITHMETIC,
+ /**
+ * Lossless JPEG
+ *
+ * **Value**
+ * - `0` *[default for compression]* The JPEG image is (decompression) or
+ * will be (compression) lossy/DCT-based.
+ * - `1` The JPEG image is (decompression) or will be (compression)
+ * lossless/predictive.
+ *
+ * In most cases, lossless JPEG compression and decompression is considerably
+ * slower than lossy JPEG compression and decompression, and lossless JPEG
+ * images are much larger than lossy JPEG images. Thus, lossless JPEG images
+ * are typically used only for applications that require mathematically
+ * lossless compression. Also note that the following features are not
+ * available with lossless JPEG images:
+ * - Colorspace conversion (lossless JPEG images always use #TJCS_RGB,
+ * #TJCS_GRAY, or #TJCS_CMYK, depending on the pixel format of the source
+ * image)
+ * - Chrominance subsampling (lossless JPEG images always use #TJSAMP_444)
+ * - JPEG quality selection
+ * - DCT/IDCT algorithm selection
+ * - Progressive JPEG
+ * - Arithmetic entropy coding
+ * - Compression from/decompression to planar YUV images
+ * - Decompression scaling
+ * - Lossless transformation
+ *
+ * @see #TJPARAM_LOSSLESSPSV, #TJPARAM_LOSSLESSPT
+ */
+ TJPARAM_LOSSLESS,
+ /**
+ * Lossless JPEG predictor selection value (PSV)
+ *
+ * **Value**
+ * - `1`-`7` *[default for compression: `1`]*
+ *
+ * Lossless JPEG compression shares no algorithms with lossy JPEG
+ * compression. Instead, it uses differential pulse-code modulation (DPCM),
+ * an algorithm whereby each sample is encoded as the difference between the
+ * sample's value and a "predictor", which is based on the values of
+ * neighboring samples. If Ra is the sample immediately to the left of the
+ * current sample, Rb is the sample immediately above the current sample, and
+ * Rc is the sample diagonally to the left and above the current sample, then
+ * the relationship between the predictor selection value and the predictor
+ * is as follows:
+ *
+ * PSV | Predictor
+ * ----|----------
+ * 1 | Ra
+ * 2 | Rb
+ * 3 | Rc
+ * 4 | Ra + Rb – Rc
+ * 5 | Ra + (Rb – Rc) / 2
+ * 6 | Rb + (Ra – Rc) / 2
+ * 7 | (Ra + Rb) / 2
+ *
+ * Predictors 1-3 are 1-dimensional predictors, whereas Predictors 4-7 are
+ * 2-dimensional predictors. The best predictor for a particular image
+ * depends on the image.
+ *
+ * @see #TJPARAM_LOSSLESS
+ */
+ TJPARAM_LOSSLESSPSV,
+ /**
+ * Lossless JPEG point transform (Pt)
+ *
+ * **Value**
+ * - `0` through ***precision*** *- 1*, where ***precision*** is the JPEG
+ * data precision in bits *[default for compression: `0`]*
+ *
+ * A point transform value of `0` is necessary in order to generate a fully
+ * lossless JPEG image. (A non-zero point transform value right-shifts the
+ * input samples by the specified number of bits, which is effectively a form
+ * of lossy color quantization.)
+ *
+ * @see #TJPARAM_LOSSLESS, #TJPARAM_PRECISION
+ */
+ TJPARAM_LOSSLESSPT,
+ /**
+ * JPEG restart marker interval in MCUs [lossy compression,
+ * lossless transformation]
+ *
+ * The nature of entropy coding is such that a corrupt JPEG image cannot
+ * be decompressed beyond the point of corruption unless it contains restart
+ * markers. A restart marker stops and restarts the entropy coding algorithm
+ * so that, if a JPEG image is corrupted, decompression can resume at the
+ * next marker. Thus, adding more restart markers improves the fault
+ * tolerance of the JPEG image, but adding too many restart markers can
+ * adversely affect the compression ratio and performance.
+ *
+ * In typical JPEG images, an MCU (Minimum Coded Unit) is the minimum set of
+ * interleaved "data units" (8x8 DCT blocks if the image is lossy or samples
+ * if the image is lossless) necessary to represent at least one data unit
+ * per component. (For example, an MCU in an interleaved lossy JPEG image
+ * that uses 4:2:2 subsampling consists of two luminance blocks followed by
+ * one block for each chrominance component.) In single-component or
+ * non-interleaved JPEG images, an MCU is the same as a data unit.
+ *
+ * **Value**
+ * - the number of MCUs between each restart marker *[default: `0` (no
+ * restart markers)]*
+ *
+ * Setting this parameter to a non-zero value sets #TJPARAM_RESTARTROWS to 0.
+ */
+ TJPARAM_RESTARTBLOCKS,
+ /**
+ * JPEG restart marker interval in MCU rows [compression,
+ * lossless transformation]
+ *
+ * See #TJPARAM_RESTARTBLOCKS for a description of restart markers and MCUs.
+ * An MCU row is a row of MCUs spanning the entire width of the image.
+ *
+ * **Value**
+ * - the number of MCU rows between each restart marker *[default: `0` (no
+ * restart markers)]*
+ *
+ * Setting this parameter to a non-zero value sets #TJPARAM_RESTARTBLOCKS to
+ * 0.
+ */
+ TJPARAM_RESTARTROWS,
+ /**
+ * JPEG horizontal pixel density
+ *
+ * **Value**
+ * - The JPEG image has (decompression) or will have (compression) the
+ * specified horizontal pixel density *[default for compression: `1`]*.
+ *
+ * This value is stored in or read from the JPEG header. It does not affect
+ * the contents of the JPEG image. Note that this parameter is set by
+ * #tj3LoadImage8() when loading a Windows BMP file that contains pixel
+ * density information, and the value of this parameter is stored to a
+ * Windows BMP file by #tj3SaveImage8() if the value of #TJPARAM_DENSITYUNITS
+ * is `2`.
+ *
+ * This parameter has no effect unless the JPEG colorspace (see
+ * #TJPARAM_COLORSPACE) is #TJCS_YCbCr or #TJCS_GRAY.
+ *
+ * @see TJPARAM_DENSITYUNITS
+ */
+ TJPARAM_XDENSITY,
+ /**
+ * JPEG vertical pixel density
+ *
+ * **Value**
+ * - The JPEG image has (decompression) or will have (compression) the
+ * specified vertical pixel density *[default for compression: `1`]*.
+ *
+ * This value is stored in or read from the JPEG header. It does not affect
+ * the contents of the JPEG image. Note that this parameter is set by
+ * #tj3LoadImage8() when loading a Windows BMP file that contains pixel
+ * density information, and the value of this parameter is stored to a
+ * Windows BMP file by #tj3SaveImage8() if the value of #TJPARAM_DENSITYUNITS
+ * is `2`.
+ *
+ * This parameter has no effect unless the JPEG colorspace (see
+ * #TJPARAM_COLORSPACE) is #TJCS_YCbCr or #TJCS_GRAY.
+ *
+ * @see TJPARAM_DENSITYUNITS
+ */
+ TJPARAM_YDENSITY,
+ /**
+ * JPEG pixel density units
+ *
+ * **Value**
+ * - `0` *[default for compression]* The pixel density of the JPEG image is
+ * expressed (decompression) or will be expressed (compression) in unknown
+ * units.
+ * - `1` The pixel density of the JPEG image is expressed (decompression) or
+ * will be expressed (compression) in units of pixels/inch.
+ * - `2` The pixel density of the JPEG image is expressed (decompression) or
+ * will be expressed (compression) in units of pixels/cm.
+ *
+ * This value is stored in or read from the JPEG header. It does not affect
+ * the contents of the JPEG image. Note that this parameter is set by
+ * #tj3LoadImage8() when loading a Windows BMP file that contains pixel
+ * density information, and the value of this parameter is stored to a
+ * Windows BMP file by #tj3SaveImage8() if the value is `2`.
+ *
+ * This parameter has no effect unless the JPEG colorspace (see
+ * #TJPARAM_COLORSPACE) is #TJCS_YCbCr or #TJCS_GRAY.
+ *
+ * @see TJPARAM_XDENSITY, TJPARAM_YDENSITY
+ */
+ TJPARAM_DENSITYUNITS,
+ /**
+ * Memory limit for intermediate buffers
+ *
+ * **Value**
+ * - the maximum amount of memory (in megabytes) that will be allocated for
+ * intermediate buffers, which are used with progressive JPEG compression and
+ * decompression, Huffman table optimization, lossless JPEG compression, and
+ * lossless transformation *[default: `0` (no limit)]*
+ */
+ TJPARAM_MAXMEMORY,
+ /**
+ * Image size limit [decompression, lossless transformation, packed-pixel
+ * image loading]
+ *
+ * Setting this parameter causes the decompression, transform, and image
+ * loading functions to return an error if the number of pixels in the source
+ * image exceeds the specified limit. This allows security-critical
+ * applications to guard against excessive memory consumption.
+ *
+ * **Value**
+ * - maximum number of pixels that the decompression, transform, and image
+ * loading functions will process *[default: `0` (no limit)]*
+ */
+ TJPARAM_MAXPIXELS,
+ /**
+ * Marker copying behavior [decompression, lossless transformation]
+ *
+ * **Value [lossless transformation]**
+ * - `0` Do not copy any extra markers (including comments, JFIF thumbnails,
+ * Exif data, and ICC profile data) from the source image to the destination
+ * image.
+ * - `1` Do not copy any extra markers, except comment (COM) markers, from
+ * the source image to the destination image.
+ * - `2` *[default]* Copy all extra markers from the source image to the
+ * destination image.
+ * - `3` Copy all extra markers, except ICC profile data (APP2 markers), from
+ * the source image to the destination image.
+ * - `4` Do not copy any extra markers, except ICC profile data (APP2
+ * markers), from the source image to the destination image.
+ *
+ * #TJXOPT_COPYNONE overrides this parameter for a particular transform.
+ * This parameter overrides any ICC profile that was previously associated
+ * with the TurboJPEG instance using #tj3SetICCProfile().
+ *
+ * When decompressing, #tj3DecompressHeader() extracts the ICC profile from a
+ * JPEG image if this parameter is set to `2` or `4`. #tj3GetICCProfile()
+ * can then be used to retrieve the profile.
+ */
+ TJPARAM_SAVEMARKERS
+};
+
+
+/**
+ * The number of error codes
+ */
+#define TJ_NUMERR 2
+
+/**
+ * Error codes
+ */
+enum TJERR {
+ /**
+ * The error was non-fatal and recoverable, but the destination image may
+ * still be corrupt.
+ */
+ TJERR_WARNING,
+ /**
+ * The error was fatal and non-recoverable.
+ */
+ TJERR_FATAL
+};
+
+
+/**
+ * The number of transform operations
+ */
+#define TJ_NUMXOP 8
+
+/**
+ * Transform operations for #tj3Transform()
+ */
+enum TJXOP {
+ /**
+ * Do not transform the position of the image pixels.
+ */
+ TJXOP_NONE,
+ /**
+ * Flip (mirror) image horizontally. This transform is imperfect if there
+ * are any partial iMCUs on the right edge (see #TJXOPT_PERFECT.)
+ */
+ TJXOP_HFLIP,
+ /**
+ * Flip (mirror) image vertically. This transform is imperfect if there are
+ * any partial iMCUs on the bottom edge (see #TJXOPT_PERFECT.)
+ */
+ TJXOP_VFLIP,
+ /**
+ * Transpose image (flip/mirror along upper left to lower right axis.) This
+ * transform is always perfect.
+ */
+ TJXOP_TRANSPOSE,
+ /**
+ * Transverse transpose image (flip/mirror along upper right to lower left
+ * axis.) This transform is imperfect if there are any partial iMCUs in the
+ * image (see #TJXOPT_PERFECT.)
+ */
+ TJXOP_TRANSVERSE,
+ /**
+ * Rotate image clockwise by 90 degrees. This transform is imperfect if
+ * there are any partial iMCUs on the bottom edge (see #TJXOPT_PERFECT.)
+ */
+ TJXOP_ROT90,
+ /**
+ * Rotate image 180 degrees. This transform is imperfect if there are any
+ * partial iMCUs in the image (see #TJXOPT_PERFECT.)
+ */
+ TJXOP_ROT180,
+ /**
+ * Rotate image counter-clockwise by 90 degrees. This transform is imperfect
+ * if there are any partial iMCUs on the right edge (see #TJXOPT_PERFECT.)
+ */
+ TJXOP_ROT270
+};
+
+
+/**
+ * This option causes #tj3Transform() to return an error if the transform is
+ * not perfect. Lossless transforms operate on iMCUs, the size of which
+ * depends on the level of chrominance subsampling used (see #tjMCUWidth and
+ * #tjMCUHeight.) If the image's width or height is not evenly divisible by
+ * the iMCU size, then there will be partial iMCUs on the right and/or bottom
+ * edges. It is not possible to move these partial iMCUs to the top or left of
+ * the image, so any transform that would require that is "imperfect." If this
+ * option is not specified, then any partial iMCUs that cannot be transformed
+ * will be left in place, which will create odd-looking strips on the right or
+ * bottom edge of the image.
+ */
+#define TJXOPT_PERFECT (1 << 0)
+/**
+ * Discard any partial iMCUs that cannot be transformed.
+ */
+#define TJXOPT_TRIM (1 << 1)
+/**
+ * Enable lossless cropping. See #tj3Transform() for more information.
+ */
+#define TJXOPT_CROP (1 << 2)
+/**
+ * Discard the color data in the source image, and generate a grayscale
+ * destination image.
+ */
+#define TJXOPT_GRAY (1 << 3)
+/**
+ * Do not generate a destination image. (This can be used in conjunction with
+ * a custom filter to capture the transformed DCT coefficients without
+ * transcoding them.)
+ */
+#define TJXOPT_NOOUTPUT (1 << 4)
+/**
+ * Generate a progressive destination image instead of a single-scan
+ * destination image. Progressive JPEG images generally have better
+ * compression ratios than single-scan JPEG images (much better if the image
+ * has large areas of solid color), but progressive JPEG decompression is
+ * considerably slower than single-scan JPEG decompression. Can be combined
+ * with #TJXOPT_ARITHMETIC. Implies #TJXOPT_OPTIMIZE unless #TJXOPT_ARITHMETIC
+ * is also specified.
+ */
+#define TJXOPT_PROGRESSIVE (1 << 5)
+/**
+ * Do not copy any extra markers (including Exif and ICC profile data) from the
+ * source image to the destination image.
+ */
+#define TJXOPT_COPYNONE (1 << 6)
+/**
+ * Enable arithmetic entropy coding in the destination image. Arithmetic
+ * entropy coding generally improves compression relative to Huffman entropy
+ * coding (the default), but it reduces decompression performance considerably.
+ * Can be combined with #TJXOPT_PROGRESSIVE.
+ */
+#define TJXOPT_ARITHMETIC (1 << 7)
+/**
+ * Enable Huffman table optimization for the destination image. Huffman table
+ * optimization improves compression slightly (generally 5% or less.)
+ */
+#define TJXOPT_OPTIMIZE (1 << 8)
+
+
+/**
+ * Scaling factor
+ */
+typedef struct {
+ /**
+ * Numerator
+ */
+ int num;
+ /**
+ * Denominator
+ */
+ int denom;
+} tjscalingfactor;
+
+/**
+ * Cropping region
+ */
+typedef struct {
+ /**
+ * The left boundary of the cropping region. For lossless transformation,
+ * this must be evenly divisible by the iMCU width (see #tjMCUWidth) of the
+ * destination image. For decompression, this must be evenly divisible by
+ * the scaled iMCU width of the source image.
+ */
+ int x;
+ /**
+ * The upper boundary of the cropping region. For lossless transformation,
+ * this must be evenly divisible by the iMCU height (see #tjMCUHeight) of the
+ * destination image.
+ */
+ int y;
+ /**
+ * The width of the cropping region. Setting this to 0 is the equivalent of
+ * setting it to the width of the source JPEG image - x.
+ */
+ int w;
+ /**
+ * The height of the cropping region. Setting this to 0 is the equivalent of
+ * setting it to the height of the source JPEG image - y.
+ */
+ int h;
+} tjregion;
+
+/**
+ * A #tjregion structure that specifies no cropping
+ */
+static const tjregion TJUNCROPPED = { 0, 0, 0, 0 };
+
+/**
+ * Lossless transform
+ */
+typedef struct tjtransform {
+ /**
+ * Cropping region
+ */
+ tjregion r;
+ /**
+ * One of the @ref TJXOP "transform operations"
+ */
+ int op;
+ /**
+ * The bitwise OR of one of more of the @ref TJXOPT_ARITHMETIC
+ * "transform options"
+ */
+ int options;
+ /**
+ * Arbitrary data that can be accessed within the body of the callback
+ * function
+ */
+ void *data;
+ /**
+ * A callback function that can be used to modify the DCT coefficients after
+ * they are losslessly transformed but before they are transcoded to a new
+ * JPEG image. This allows for custom filters or other transformations to be
+ * applied in the frequency domain.
+ *
+ * @param coeffs pointer to an array of transformed DCT coefficients. (NOTE:
+ * This pointer is not guaranteed to be valid once the callback returns, so
+ * applications wishing to hand off the DCT coefficients to another function
+ * or library should make a copy of them within the body of the callback.)
+ *
+ * @param arrayRegion #tjregion structure containing the width and height of
+ * the array pointed to by `coeffs` as well as its offset relative to the
+ * component plane. TurboJPEG implementations may choose to split each
+ * component plane into multiple DCT coefficient arrays and call the callback
+ * function once for each array.
+ *
+ * @param planeRegion #tjregion structure containing the width and height of
+ * the component plane to which `coeffs` belongs
+ *
+ * @param componentID ID number of the component plane to which `coeffs`
+ * belongs. (Y, Cb, and Cr have, respectively, ID's of 0, 1, and 2 in
+ * typical JPEG images.)
+ *
+ * @param transformID ID number of the transformed image to which `coeffs`
+ * belongs. This is the same as the index of the transform in the
+ * `transforms` array that was passed to #tj3Transform().
+ *
+ * @param transform a pointer to a #tjtransform structure that specifies the
+ * parameters and/or cropping region for this transform
+ *
+ * @return 0 if the callback was successful, or -1 if an error occurred.
+ */
+ int (*customFilter) (short *coeffs, tjregion arrayRegion,
+ tjregion planeRegion, int componentID, int transformID,
+ struct tjtransform *transform);
+} tjtransform;
+
+/**
+ * TurboJPEG instance handle
+ */
+typedef void *tjhandle;
+
+
+/**
+ * Compute the scaled value of `dimension` using the given scaling factor.
+ * This macro performs the integer equivalent of `ceil(dimension *
+ * scalingFactor)`.
+ */
+#define TJSCALED(dimension, scalingFactor) \
+ (((dimension) * scalingFactor.num + scalingFactor.denom - 1) / \
+ scalingFactor.denom)
+
+/**
+ * A #tjscalingfactor structure that specifies a scaling factor of 1/1 (no
+ * scaling)
+ */
+static const tjscalingfactor TJUNSCALED = { 1, 1 };
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Create a new TurboJPEG instance.
+ *
+ * @param initType one of the @ref TJINIT "initialization options"
+ *
+ * @return a handle to the newly-created instance, or NULL if an error occurred
+ * (see #tj3GetErrorStr().)
+ */
+DLLEXPORT tjhandle tj3Init(int initType);
+
+
+/**
+ * Destroy a TurboJPEG instance.
+ *
+ * @param handle handle to a TurboJPEG instance. If the handle is NULL, then
+ * this function has no effect.
+ */
+DLLEXPORT void tj3Destroy(tjhandle handle);
+
+
+/**
+ * Returns a descriptive error message explaining why the last command failed.
+ *
+ * @param handle handle to a TurboJPEG instance, or NULL if the error was
+ * generated by a global function (but note that retrieving the error message
+ * for a global function is thread-safe only on platforms that support
+ * thread-local storage.)
+ *
+ * @return a descriptive error message explaining why the last command failed.
+ */
+DLLEXPORT char *tj3GetErrorStr(tjhandle handle);
+
+
+/**
+ * Returns a code indicating the severity of the last error. See
+ * @ref TJERR "Error codes".
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @return a code indicating the severity of the last error. See
+ * @ref TJERR "Error codes".
+ */
+DLLEXPORT int tj3GetErrorCode(tjhandle handle);
+
+
+/**
+ * Set the value of a parameter.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param param one of the @ref TJPARAM "parameters"
+ *
+ * @param value value of the parameter (refer to @ref TJPARAM
+ * "parameter documentation")
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
+ */
+DLLEXPORT int tj3Set(tjhandle handle, int param, int value);
+
+
+/**
+ * Get the value of a parameter.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param param one of the @ref TJPARAM "parameters"
+ *
+ * @return the value of the specified parameter, or -1 if the value is unknown.
+ */
+DLLEXPORT int tj3Get(tjhandle handle, int param);
+
+
+/**
+ * Allocate a byte buffer for use with TurboJPEG. You should always use this
+ * function to allocate the JPEG destination buffer(s) for the compression and
+ * transform functions unless you are disabling automatic buffer (re)allocation
+ * (by setting #TJPARAM_NOREALLOC.)
+ *
+ * @param bytes the number of bytes to allocate
+ *
+ * @return a pointer to a newly-allocated buffer with the specified number of
+ * bytes.
+ *
+ * @see tj3Free()
+ */
+DLLEXPORT void *tj3Alloc(size_t bytes);
+
+
+/**
+ * Free a byte buffer previously allocated by TurboJPEG. You should always use
+ * this function to free JPEG destination buffer(s) that were automatically
+ * (re)allocated by the compression and transform functions or that were
+ * manually allocated using #tj3Alloc().
+ *
+ * @param buffer address of the buffer to free. If the address is NULL, then
+ * this function has no effect.
+ *
+ * @see tj3Alloc()
+ */
+DLLEXPORT void tj3Free(void *buffer);
+
+
+/**
+ * The maximum size of the buffer (in bytes) required to hold a JPEG image with
+ * the given parameters. The number of bytes returned by this function is
+ * larger than the size of the uncompressed source image. The reason for this
+ * is that the JPEG format uses 16-bit coefficients, so it is possible for a
+ * very high-quality source image with very high-frequency content to expand
+ * rather than compress when converted to the JPEG format. Such images
+ * represent very rare corner cases, but since there is no way to predict the
+ * size of a JPEG image prior to compression, the corner cases have to be
+ * handled.
+ *
+ * @param width width (in pixels) of the image
+ *
+ * @param height height (in pixels) of the image
+ *
+ * @param jpegSubsamp the level of chrominance subsampling to be used when
+ * generating the JPEG image (see @ref TJSAMP
+ * "Chrominance subsampling options".) #TJSAMP_UNKNOWN is treated like
+ * #TJSAMP_444, since a buffer large enough to hold a JPEG image with no
+ * subsampling should also be large enough to hold a JPEG image with an
+ * arbitrary level of subsampling. Note that lossless JPEG images always
+ * use #TJSAMP_444.
+ *
+ * @return the maximum size of the buffer (in bytes) required to hold the
+ * image, or 0 if the arguments are out of bounds.
+ */
+DLLEXPORT size_t tj3JPEGBufSize(int width, int height, int jpegSubsamp);
+
+
+/**
+ * The size of the buffer (in bytes) required to hold a unified planar YUV
+ * image with the given parameters.
+ *
+ * @param width width (in pixels) of the image
+ *
+ * @param align row alignment (in bytes) of the image (must be a power of 2.)
+ * Setting this parameter to n specifies that each row in each plane of the
+ * image will be padded to the nearest multiple of n bytes (1 = unpadded.)
+ *
+ * @param height height (in pixels) of the image
+ *
+ * @param subsamp level of chrominance subsampling in the image (see
+ * @ref TJSAMP "Chrominance subsampling options".)
+ *
+ * @return the size of the buffer (in bytes) required to hold the image, or 0
+ * if the arguments are out of bounds.
+ */
+DLLEXPORT size_t tj3YUVBufSize(int width, int align, int height, int subsamp);
+
+
+/**
+ * The size of the buffer (in bytes) required to hold a YUV image plane with
+ * the given parameters.
+ *
+ * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
+ *
+ * @param width width (in pixels) of the YUV image. NOTE: This is the width of
+ * the whole image, not the plane width.
+ *
+ * @param stride bytes per row in the image plane. Setting this to 0 is the
+ * equivalent of setting it to the plane width.
+ *
+ * @param height height (in pixels) of the YUV image. NOTE: This is the height
+ * of the whole image, not the plane height.
+ *
+ * @param subsamp level of chrominance subsampling in the image (see
+ * @ref TJSAMP "Chrominance subsampling options".)
+ *
+ * @return the size of the buffer (in bytes) required to hold the YUV image
+ * plane, or 0 if the arguments are out of bounds.
+ */
+DLLEXPORT size_t tj3YUVPlaneSize(int componentID, int width, int stride,
+ int height, int subsamp);
+
+
+/**
+ * The plane width of a YUV image plane with the given parameters. Refer to
+ * @ref YUVnotes "YUV Image Format Notes" for a description of plane width.
+ *
+ * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
+ *
+ * @param width width (in pixels) of the YUV image
+ *
+ * @param subsamp level of chrominance subsampling in the image (see
+ * @ref TJSAMP "Chrominance subsampling options".)
+ *
+ * @return the plane width of a YUV image plane with the given parameters, or 0
+ * if the arguments are out of bounds.
+ */
+DLLEXPORT int tj3YUVPlaneWidth(int componentID, int width, int subsamp);
+
+
+/**
+ * The plane height of a YUV image plane with the given parameters. Refer to
+ * @ref YUVnotes "YUV Image Format Notes" for a description of plane height.
+ *
+ * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
+ *
+ * @param height height (in pixels) of the YUV image
+ *
+ * @param subsamp level of chrominance subsampling in the image (see
+ * @ref TJSAMP "Chrominance subsampling options".)
+ *
+ * @return the plane height of a YUV image plane with the given parameters, or
+ * 0 if the arguments are out of bounds.
+ */
+DLLEXPORT int tj3YUVPlaneHeight(int componentID, int height, int subsamp);
+
+
+/**
+ * Embed an ICC (International Color Consortium) color management profile in
+ * JPEG images generated by subsequent compression and lossless transformation
+ * operations.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param iccBuf pointer to a byte buffer containing an ICC profile. A copy is
+ * made of the ICC profile, so this buffer can be freed or reused as soon as
+ * this function returns. Setting this parameter to NULL or setting `iccSize`
+ * to 0 removes any ICC profile that was previously associated with the
+ * TurboJPEG instance.
+ *
+ * @param iccSize size of the ICC profile (in bytes.) Setting this parameter
+ * to 0 or setting `iccBuf` to NULL removes any ICC profile that was previously
+ * associated with the TurboJPEG instance.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
+ */
+DLLEXPORT int tj3SetICCProfile(tjhandle handle, unsigned char *iccBuf,
+ size_t iccSize);
+
+
+/**
+ * Compress a packed-pixel RGB, grayscale, or CMYK image with 2 to 8 bits of
+ * data precision per sample into a JPEG image with the same data precision.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a packed-pixel RGB, grayscale,
+ * or CMYK source image to be compressed. This buffer should normally be
+ * `pitch * height` samples in size. However, you can also use this parameter
+ * to compress from a specific region of a larger buffer. The data precision
+ * of the source image (from 2 to 8 bits per sample) can be specified using
+ * #TJPARAM_PRECISION and defaults to 8 if #TJPARAM_PRECISION is unset or out
+ * of range.
+ *
+ * @param width width (in pixels) of the source image
+ *
+ * @param pitch samples per row in the source image. Normally this should be
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>, if the image is unpadded.
+ * (Setting this parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.) However, you can also use this
+ * parameter to specify the row alignment/padding of the source image, to skip
+ * rows, or to compress from a specific region of a larger buffer.
+ *
+ * @param height height (in pixels) of the source image
+ *
+ * @param pixelFormat pixel format of the source image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize() and adding the return value to the size of the ICC profile
+ * (if any) that was previously associated with the TurboJPEG instance (see
+ * #tj3SetICCProfile().) This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1 or 3, then `*jpegSize` should be set to the size of
+ * your pre-allocated buffer. In any case, unless you have set
+ * #TJPARAM_NOREALLOC, you should always check `*jpegBuf` upon return from this
+ * function, as it may have changed.
+ *
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3Compress8(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char **jpegBuf, size_t *jpegSize);
+
+/**
+ * Compress a packed-pixel RGB, grayscale, or CMYK image with 9 to 12 bits of
+ * data precision per sample into a JPEG image with the same data precision.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a packed-pixel RGB, grayscale,
+ * or CMYK source image to be compressed. This buffer should normally be
+ * `pitch * height` samples in size. However, you can also use this parameter
+ * to compress from a specific region of a larger buffer. The data precision
+ * of the source image (from 9 to 12 bits per sample) can be specified using
+ * #TJPARAM_PRECISION and defaults to 12 if #TJPARAM_PRECISION is unset or out
+ * of range.
+ *
+ * @param width width (in pixels) of the source image
+ *
+ * @param pitch samples per row in the source image. Normally this should be
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>, if the image is unpadded.
+ * (Setting this parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.) However, you can also use this
+ * parameter to specify the row alignment/padding of the source image, to skip
+ * rows, or to compress from a specific region of a larger buffer.
+ *
+ * @param height height (in pixels) of the source image
+ *
+ * @param pixelFormat pixel format of the source image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize() and adding the return value to the size of the ICC profile
+ * (if any) that was previously associated with the TurboJPEG instance (see
+ * #tj3SetICCProfile().) This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1 or 3, then `*jpegSize` should be set to the size of
+ * your pre-allocated buffer. In any case, unless you have set
+ * #TJPARAM_NOREALLOC, you should always check `*jpegBuf` upon return from this
+ * function, as it may have changed.
+ *
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3Compress12(tjhandle handle, const short *srcBuf, int width,
+ int pitch, int height, int pixelFormat,
+ unsigned char **jpegBuf, size_t *jpegSize);
+
+/**
+ * Compress a packed-pixel RGB, grayscale, or CMYK image with 13 to 16 bits of
+ * data precision per sample into a lossless JPEG image with the same data
+ * precision.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a packed-pixel RGB, grayscale,
+ * or CMYK source image to be compressed. This buffer should normally be
+ * `pitch * height` samples in size. However, you can also use this parameter
+ * to compress from a specific region of a larger buffer. The data precision
+ * of the source image (from 13 to 16 bits per sample) can be specified using
+ * #TJPARAM_PRECISION and defaults to 16 if #TJPARAM_PRECISION is unset or out
+ * of range.
+ *
+ * @param width width (in pixels) of the source image
+ *
+ * @param pitch samples per row in the source image. Normally this should be
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>, if the image is unpadded.
+ * (Setting this parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.) However, you can also use this
+ * parameter to specify the row alignment/padding of the source image, to skip
+ * rows, or to compress from a specific region of a larger buffer.
+ *
+ * @param height height (in pixels) of the source image
+ *
+ * @param pixelFormat pixel format of the source image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize() and adding the return value to the size of the ICC profile
+ * (if any) that was previously associated with the TurboJPEG instance (see
+ * #tj3SetICCProfile().) This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1 or 3, then `*jpegSize` should be set to the size of
+ * your pre-allocated buffer. In any case, unless you have set
+ * #TJPARAM_NOREALLOC, you should always check `*jpegBuf` upon return from this
+ * function, as it may have changed.
+ *
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3Compress16(tjhandle handle, const unsigned short *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char **jpegBuf, size_t *jpegSize);
+
+
+/**
+ * Compress a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into
+ * an 8-bit-per-sample JPEG image.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if compressing a grayscale image) that contain a YUV
+ * source image to be compressed. These planes can be contiguous or
+ * non-contiguous in memory. The size of each plane should match the value
+ * returned by #tj3YUVPlaneSize() for the given image width, height, strides,
+ * and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) Refer to
+ * @ref YUVnotes "YUV Image Format Notes" for more details.
+ *
+ * @param width width (in pixels) of the source image. If the width is not an
+ * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param strides an array of integers, each specifying the number of bytes per
+ * row in the corresponding plane of the YUV source image. Setting the stride
+ * for any plane to 0 is the same as setting it to the plane width (see
+ * @ref YUVnotes "YUV Image Format Notes".) If `strides` is NULL, then the
+ * strides for all planes will be set to their respective plane widths. You
+ * can adjust the strides in order to specify an arbitrary amount of row
+ * padding in each plane or to create a JPEG image from a subregion of a larger
+ * planar YUV image.
+ *
+ * @param height height (in pixels) of the source image. If the height is not
+ * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize() and adding the return value to the size of the ICC profile
+ * (if any) that was previously associated with the TurboJPEG instance (see
+ * #tj3SetICCProfile().) This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1 or 3, then `*jpegSize` should be set to the size of
+ * your pre-allocated buffer. In any case, unless you have set
+ * #TJPARAM_NOREALLOC, you should always check `*jpegBuf` upon return from this
+ * function, as it may have changed.
+ *
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3CompressFromYUVPlanes8(tjhandle handle,
+ const unsigned char * const *srcPlanes,
+ int width, const int *strides,
+ int height, unsigned char **jpegBuf,
+ size_t *jpegSize);
+
+
+/**
+ * Compress an 8-bit-per-sample unified planar YUV image into an
+ * 8-bit-per-sample JPEG image.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a unified planar YUV source
+ * image to be compressed. The size of this buffer should match the value
+ * returned by #tj3YUVBufSize() for the given image width, height, row
+ * alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
+ * Y, U (Cb), and V (Cr) image planes should be stored sequentially in the
+ * buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
+ *
+ * @param width width (in pixels) of the source image. If the width is not an
+ * even multiple of the iMCU width (see #tjMCUWidth), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param align row alignment (in bytes) of the source image (must be a power
+ * of 2.) Setting this parameter to n indicates that each row in each plane of
+ * the source image is padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
+ *
+ * @param height height (in pixels) of the source image. If the height is not
+ * an even multiple of the iMCU height (see #tjMCUHeight), then an intermediate
+ * buffer copy will be performed.
+ *
+ * @param jpegBuf address of a pointer to a byte buffer that will receive the
+ * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
+ * accommodate the size of the JPEG image. Thus, you can choose to:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
+ * let TurboJPEG grow the buffer as needed,
+ * -# set `*jpegBuf` to NULL to tell TurboJPEG to allocate the buffer for you,
+ * or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3JPEGBufSize() and adding the return value to the size of the ICC profile
+ * (if any) that was previously associated with the TurboJPEG instance (see
+ * #tj3SetICCProfile().) This should ensure that the buffer never has to be
+ * re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
+ * .
+ * If you choose option 1 or 3, then `*jpegSize` should be set to the size of
+ * your pre-allocated buffer. In any case, unless you have set
+ * #TJPARAM_NOREALLOC, you should always check `*jpegBuf` upon return from this
+ * function, as it may have changed.
+ *
+ * @param jpegSize pointer to a size_t variable that holds the size of the JPEG
+ * buffer. If `*jpegBuf` points to a pre-allocated buffer, then `*jpegSize`
+ * should be set to the size of the buffer. Upon return, `*jpegSize` will
+ * contain the size of the JPEG image (in bytes.) If `*jpegBuf` points to a
+ * JPEG buffer that is being reused from a previous call to one of the JPEG
+ * compression functions, then `*jpegSize` is ignored.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3CompressFromYUV8(tjhandle handle,
+ const unsigned char *srcBuf, int width,
+ int align, int height,
+ unsigned char **jpegBuf, size_t *jpegSize);
+
+
+/**
+ * Encode an 8-bit-per-sample packed-pixel RGB or grayscale image into separate
+ * 8-bit-per-sample Y, U (Cb), and V (Cr) image planes. This function performs
+ * color conversion (which is accelerated in the libjpeg-turbo implementation)
+ * but does not execute any of the other steps in the JPEG compression process.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a packed-pixel RGB or grayscale
+ * source image to be encoded. This buffer should normally be `pitch * height`
+ * bytes in size. However, you can also use this parameter to encode from a
+ * specific region of a larger buffer.
+ *
+ *
+ * @param width width (in pixels) of the source image
+ *
+ * @param pitch bytes per row in the source image. Normally this should be
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>, if the image is unpadded.
+ * (Setting this parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.) However, you can also use this
+ * parameter to specify the row alignment/padding of the source image, to skip
+ * rows, or to encode from a specific region of a larger packed-pixel image.
+ *
+ * @param height height (in pixels) of the source image
+ *
+ * @param pixelFormat pixel format of the source image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if generating a grayscale image) that will receive the
+ * encoded image. These planes can be contiguous or non-contiguous in memory.
+ * Use #tj3YUVPlaneSize() to determine the appropriate size for each plane
+ * based on the image width, height, strides, and level of chrominance
+ * subsampling (see #TJPARAM_SUBSAMP.) Refer to @ref YUVnotes
+ * "YUV Image Format Notes" for more details.
+ *
+ * @param strides an array of integers, each specifying the number of bytes per
+ * row in the corresponding plane of the YUV image. Setting the stride for any
+ * plane to 0 is the same as setting it to the plane width (see @ref YUVnotes
+ * "YUV Image Format Notes".) If `strides` is NULL, then the strides for all
+ * planes will be set to their respective plane widths. You can adjust the
+ * strides in order to add an arbitrary amount of row padding to each plane or
+ * to encode an RGB or grayscale image into a subregion of a larger planar YUV
+ * image.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3EncodeYUVPlanes8(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height,
+ int pixelFormat, unsigned char **dstPlanes,
+ int *strides);
+
+
+/**
+ * Encode an 8-bit-per-sample packed-pixel RGB or grayscale image into an
+ * 8-bit-per-sample unified planar YUV image. This function performs color
+ * conversion (which is accelerated in the libjpeg-turbo implementation) but
+ * does not execute any of the other steps in the JPEG compression process.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * compression
+ *
+ * @param srcBuf pointer to a buffer containing a packed-pixel RGB or grayscale
+ * source image to be encoded. This buffer should normally be `pitch * height`
+ * bytes in size. However, you can also use this parameter to encode from a
+ * specific region of a larger buffer.
+ *
+ * @param width width (in pixels) of the source image
+ *
+ * @param pitch bytes per row in the source image. Normally this should be
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>, if the image is unpadded.
+ * (Setting this parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.) However, you can also use this
+ * parameter to specify the row alignment/padding of the source image, to skip
+ * rows, or to encode from a specific region of a larger packed-pixel image.
+ *
+ * @param height height (in pixels) of the source image
+ *
+ * @param pixelFormat pixel format of the source image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @param dstBuf pointer to a buffer that will receive the unified planar YUV
+ * image. Use #tj3YUVBufSize() to determine the appropriate size for this
+ * buffer based on the image width, height, row alignment, and level of
+ * chrominance subsampling (see #TJPARAM_SUBSAMP.) The Y, U (Cb), and V (Cr)
+ * image planes will be stored sequentially in the buffer. (Refer to
+ * @ref YUVnotes "YUV Image Format Notes".)
+ *
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n will cause each row in each plane of the
+ * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
+ * To generate images suitable for X Video, `align` should be set to 4.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3EncodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char *dstBuf, int align);
+
+
+/**
+ * Retrieve information about a JPEG image without decompressing it, or prime
+ * the decompressor with quantization and Huffman tables. If a JPEG image is
+ * passed to this function, then the @ref TJPARAM "parameters" that describe
+ * the JPEG image will be set when the function returns. If a JPEG image is
+ * passed to this function and #TJPARAM_SAVEMARKERS is set to `2` or `4`, then
+ * the ICC profile (if any) will be extracted from the JPEG image.
+ * (#tj3GetICCProfile() can then be used to retrieve the profile.)
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param jpegBuf pointer to a byte buffer containing a JPEG image or an
+ * "abbreviated table specification" (AKA "tables-only") datastream. Passing a
+ * tables-only datastream to this function primes the decompressor with
+ * quantization and Huffman tables that can be used when decompressing
+ * subsequent "abbreviated image" datastreams. This is useful, for instance,
+ * when decompressing video streams in which all frames share the same
+ * quantization and Huffman tables.
+ *
+ * @param jpegSize size of the JPEG image or tables-only datastream (in bytes)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3DecompressHeader(tjhandle handle,
+ const unsigned char *jpegBuf,
+ size_t jpegSize);
+
+
+/**
+ * Retrieve the ICC (International Color Consortium) color management profile
+ * (if any) that was previously extracted from a JPEG image.
+ *
+ * @note To extract the ICC profile from a JPEG image, call
+ * #tj3DecompressHeader() with #TJPARAM_SAVEMARKERS set to `2` or `4`. Once
+ * the ICC profile is retrieved, it must be re-extracted before it can be
+ * retrieved again.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param iccBuf address of a pointer to a byte buffer. Upon return:
+ * - If `iccBuf` is not NULL and there is an ICC profile to retrieve, then
+ * `*iccBuf` will point to a byte buffer containing the ICC profile. This
+ * buffer should be freed using #tj3Free().
+ * - If `iccBuf` is not NULL and there is no ICC profile to retrieve, then
+ * `*iccBuf` will be NULL.
+ * - If `iccBuf` is NULL, then only the ICC profile size will be retrieved, and
+ * the ICC profile can be retrieved later.
+ *
+ * @param iccSize address of a size_t variable. Upon return, the variable will
+ * contain the ICC profile size (or 0 if there is no ICC profile to retrieve.)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3GetICCProfile(tjhandle handle, unsigned char **iccBuf,
+ size_t *iccSize);
+
+
+/**
+ * Returns a list of fractional scaling factors that the JPEG decompressor
+ * supports.
+ *
+ * @param numScalingFactors pointer to an integer variable that will receive
+ * the number of elements in the list
+ *
+ * @return a pointer to a list of fractional scaling factors, or NULL if an
+ * error is encountered (see #tj3GetErrorStr().)
+ */
+DLLEXPORT tjscalingfactor *tj3GetScalingFactors(int *numScalingFactors);
+
+
+/**
+ * Set the scaling factor for subsequent lossy decompression operations.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param scalingFactor #tjscalingfactor structure that specifies a fractional
+ * scaling factor that the decompressor supports (see #tj3GetScalingFactors()),
+ * or <tt>#TJUNSCALED</tt> for no scaling. Decompression scaling is a function
+ * of the IDCT algorithm, so scaling factors are generally limited to multiples
+ * of 1/8. If the entire JPEG image will be decompressed, then the width and
+ * height of the scaled destination image can be determined by calling
+ * #TJSCALED() with the JPEG width and height (see #TJPARAM_JPEGWIDTH and
+ * #TJPARAM_JPEGHEIGHT) and the specified scaling factor. When decompressing
+ * into a planar YUV image, an intermediate buffer copy will be performed if
+ * the width or height of the scaled destination image is not an even multiple
+ * of the iMCU size (see #tjMCUWidth and #tjMCUHeight.) Note that
+ * decompression scaling is not available (and the specified scaling factor is
+ * ignored) when decompressing lossless JPEG images (see #TJPARAM_LOSSLESS),
+ * since the IDCT algorithm is not used with those images. Note also that
+ * #TJPARAM_FASTDCT is ignored when decompression scaling is enabled.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
+ */
+DLLEXPORT int tj3SetScalingFactor(tjhandle handle,
+ tjscalingfactor scalingFactor);
+
+
+/**
+ * Set the cropping region for partially decompressing a lossy JPEG image into
+ * a packed-pixel image
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param croppingRegion #tjregion structure that specifies a subregion of the
+ * JPEG image to decompress, or <tt>#TJUNCROPPED</tt> for no cropping. The
+ * left boundary of the cropping region must be evenly divisible by the scaled
+ * iMCU width-- <tt>#TJSCALED(#tjMCUWidth[subsamp], scalingFactor)</tt>, where
+ * `subsamp` is the level of chrominance subsampling in the JPEG image (see
+ * #TJPARAM_SUBSAMP) and `scalingFactor` is the decompression scaling factor
+ * (see #tj3SetScalingFactor().) The cropping region should be specified
+ * relative to the scaled image dimensions. Unless `croppingRegion` is
+ * <tt>#TJUNCROPPED</tt>, the JPEG header must be read (see
+ * #tj3DecompressHeader()) prior to calling this function.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
+ */
+DLLEXPORT int tj3SetCroppingRegion(tjhandle handle, tjregion croppingRegion);
+
+
+/**
+ * Decompress a JPEG image with 2 to 8 bits of data precision per sample into a
+ * packed-pixel RGB, grayscale, or CMYK image with the same data precision.
+ * The @ref TJPARAM "parameters" that describe the JPEG image will be set when
+ * this function returns.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param jpegBuf pointer to a byte buffer containing the JPEG image to
+ * decompress
+ *
+ * @param jpegSize size of the JPEG image (in bytes)
+ *
+ * @param dstBuf pointer to a buffer that will receive the packed-pixel
+ * decompressed image. This buffer should normally be
+ * `pitch * destinationHeight` samples in size. However, you can also use this
+ * parameter to decompress into a specific region of a larger buffer. NOTE:
+ * If the JPEG image is lossy, then `destinationHeight` is either the scaled
+ * JPEG height (see #TJSCALED(), #TJPARAM_JPEGHEIGHT, and
+ * #tj3SetScalingFactor()) or the height of the cropping region (see
+ * #tj3SetCroppingRegion().) If the JPEG image is lossless, then
+ * `destinationHeight` is the JPEG height.
+ *
+ * @param pitch samples per row in the destination image. Normally this should
+ * be set to <tt>destinationWidth * #tjPixelSize[pixelFormat]</tt>, if the
+ * destination image should be unpadded. (Setting this parameter to 0 is the
+ * equivalent of setting it to
+ * <tt>destinationWidth * #tjPixelSize[pixelFormat]</tt>.) However, you can
+ * also use this parameter to specify the row alignment/padding of the
+ * destination image, to skip rows, or to decompress into a specific region of
+ * a larger buffer. NOTE: If the JPEG image is lossy, then `destinationWidth`
+ * is either the scaled JPEG width (see #TJSCALED(), #TJPARAM_JPEGWIDTH, and
+ * #tj3SetScalingFactor()) or the width of the cropping region (see
+ * #tj3SetCroppingRegion().) If the JPEG image is lossless, then
+ * `destinationWidth` is the JPEG width.
+ *
+ * @param pixelFormat pixel format of the destination image (see @ref
+ * TJPF "Pixel formats".)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3Decompress8(tjhandle handle, const unsigned char *jpegBuf,
+ size_t jpegSize, unsigned char *dstBuf, int pitch,
+ int pixelFormat);
+
+/**
+ * Decompress a JPEG image with 9 to 12 bits of data precision per sample into
+ * a packed-pixel RGB, grayscale, or CMYK image with the same data precision.
+ *
+ * \details \copydetails tj3Decompress8()
+ */
+DLLEXPORT int tj3Decompress12(tjhandle handle, const unsigned char *jpegBuf,
+ size_t jpegSize, short *dstBuf, int pitch,
+ int pixelFormat);
+
+/**
+ * Decompress a lossless JPEG image with 13 to 16 bits of data precision per
+ * sample into a packed-pixel RGB, grayscale, or CMYK image with the same
+ * data precision.
+ *
+ * \details \copydetails tj3Decompress8()
+ */
+DLLEXPORT int tj3Decompress16(tjhandle handle, const unsigned char *jpegBuf,
+ size_t jpegSize, unsigned short *dstBuf,
+ int pitch, int pixelFormat);
+
+
+/**
+ * Decompress an 8-bit-per-sample JPEG image into separate 8-bit-per-sample Y,
+ * U (Cb), and V (Cr) image planes. This function performs JPEG decompression
+ * but leaves out the color conversion step, so a planar YUV image is generated
+ * instead of a packed-pixel image. The @ref TJPARAM "parameters" that
+ * describe the JPEG image will be set when this function returns.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param jpegBuf pointer to a byte buffer containing the JPEG image to
+ * decompress
+ *
+ * @param jpegSize size of the JPEG image (in bytes)
+ *
+ * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if decompressing a grayscale image) that will receive
+ * the decompressed image. These planes can be contiguous or non-contiguous in
+ * memory. Use #tj3YUVPlaneSize() to determine the appropriate size for each
+ * plane based on the scaled JPEG width and height (see #TJSCALED(),
+ * #TJPARAM_JPEGWIDTH, #TJPARAM_JPEGHEIGHT, and #tj3SetScalingFactor()),
+ * strides, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) Refer
+ * to @ref YUVnotes "YUV Image Format Notes" for more details.
+ *
+ * @param strides an array of integers, each specifying the number of bytes per
+ * row in the corresponding plane of the YUV image. Setting the stride for any
+ * plane to 0 is the same as setting it to the scaled plane width (see
+ * @ref YUVnotes "YUV Image Format Notes".) If `strides` is NULL, then the
+ * strides for all planes will be set to their respective scaled plane widths.
+ * You can adjust the strides in order to add an arbitrary amount of row
+ * padding to each plane or to decompress the JPEG image into a subregion of a
+ * larger planar YUV image.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3DecompressToYUVPlanes8(tjhandle handle,
+ const unsigned char *jpegBuf,
+ size_t jpegSize,
+ unsigned char **dstPlanes,
+ int *strides);
+
+
+/**
+ * Decompress an 8-bit-per-sample JPEG image into an 8-bit-per-sample unified
+ * planar YUV image. This function performs JPEG decompression but leaves out
+ * the color conversion step, so a planar YUV image is generated instead of a
+ * packed-pixel image. The @ref TJPARAM "parameters" that describe the JPEG
+ * image will be set when this function returns.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param jpegBuf pointer to a byte buffer containing the JPEG image to
+ * decompress
+ *
+ * @param jpegSize size of the JPEG image (in bytes)
+ *
+ * @param dstBuf pointer to a buffer that will receive the unified planar YUV
+ * decompressed image. Use #tj3YUVBufSize() to determine the appropriate size
+ * for this buffer based on the scaled JPEG width and height (see #TJSCALED(),
+ * #TJPARAM_JPEGWIDTH, #TJPARAM_JPEGHEIGHT, and #tj3SetScalingFactor()), row
+ * alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
+ * Y, U (Cb), and V (Cr) image planes will be stored sequentially in the
+ * buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
+ *
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n will cause each row in each plane of the
+ * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
+ * To generate images suitable for X Video, `align` should be set to 4.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3DecompressToYUV8(tjhandle handle,
+ const unsigned char *jpegBuf,
+ size_t jpegSize,
+ unsigned char *dstBuf, int align);
+
+
+/**
+ * Decode a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into an
+ * 8-bit-per-sample packed-pixel RGB or grayscale image. This function
+ * performs color conversion (which is accelerated in the libjpeg-turbo
+ * implementation) but does not execute any of the other steps in the JPEG
+ * decompression process.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if decoding a grayscale image) that contain a YUV image
+ * to be decoded. These planes can be contiguous or non-contiguous in memory.
+ * The size of each plane should match the value returned by #tj3YUVPlaneSize()
+ * for the given image width, height, strides, and level of chrominance
+ * subsampling (see #TJPARAM_SUBSAMP.) Refer to @ref YUVnotes
+ * "YUV Image Format Notes" for more details.
+ *
+ * @param strides an array of integers, each specifying the number of bytes per
+ * row in the corresponding plane of the YUV source image. Setting the stride
+ * for any plane to 0 is the same as setting it to the plane width (see
+ * @ref YUVnotes "YUV Image Format Notes".) If `strides` is NULL, then the
+ * strides for all planes will be set to their respective plane widths. You
+ * can adjust the strides in order to specify an arbitrary amount of row
+ * padding in each plane or to decode a subregion of a larger planar YUV image.
+ *
+ * @param dstBuf pointer to a buffer that will receive the packed-pixel decoded
+ * image. This buffer should normally be `pitch * height` bytes in size.
+ * However, you can also use this parameter to decode into a specific region of
+ * a larger buffer.
+ *
+ * @param width width (in pixels) of the source and destination images
+ *
+ * @param pitch bytes per row in the destination image. Normally this should
+ * be set to <tt>width * #tjPixelSize[pixelFormat]</tt>, if the destination
+ * image should be unpadded. (Setting this parameter to 0 is the equivalent of
+ * setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>.) However, you can
+ * also use this parameter to specify the row alignment/padding of the
+ * destination image, to skip rows, or to decode into a specific region of a
+ * larger buffer.
+ *
+ * @param height height (in pixels) of the source and destination images
+ *
+ * @param pixelFormat pixel format of the destination image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3DecodeYUVPlanes8(tjhandle handle,
+ const unsigned char * const *srcPlanes,
+ const int *strides, unsigned char *dstBuf,
+ int width, int pitch, int height,
+ int pixelFormat);
+
+
+/**
+ * Decode an 8-bit-per-sample unified planar YUV image into an 8-bit-per-sample
+ * packed-pixel RGB or grayscale image. This function performs color
+ * conversion (which is accelerated in the libjpeg-turbo implementation) but
+ * does not execute any of the other steps in the JPEG decompression process.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * decompression
+ *
+ * @param srcBuf pointer to a buffer containing a unified planar YUV source
+ * image to be decoded. The size of this buffer should match the value
+ * returned by #tj3YUVBufSize() for the given image width, height, row
+ * alignment, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) The
+ * Y, U (Cb), and V (Cr) image planes should be stored sequentially in the
+ * source buffer. (Refer to @ref YUVnotes "YUV Image Format Notes".)
+ *
+ * @param align row alignment (in bytes) of the YUV source image (must be a
+ * power of 2.) Setting this parameter to n indicates that each row in each
+ * plane of the YUV source image is padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
+ *
+ * @param dstBuf pointer to a buffer that will receive the packed-pixel decoded
+ * image. This buffer should normally be `pitch * height` bytes in size.
+ * However, you can also use this parameter to decode into a specific region of
+ * a larger buffer.
+ *
+ * @param width width (in pixels) of the source and destination images
+ *
+ * @param pitch bytes per row in the destination image. Normally this should
+ * be set to <tt>width * #tjPixelSize[pixelFormat]</tt>, if the destination
+ * image should be unpadded. (Setting this parameter to 0 is the equivalent of
+ * setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>.) However, you can
+ * also use this parameter to specify the row alignment/padding of the
+ * destination image, to skip rows, or to decode into a specific region of a
+ * larger buffer.
+ *
+ * @param height height (in pixels) of the source and destination images
+ *
+ * @param pixelFormat pixel format of the destination image (see @ref TJPF
+ * "Pixel formats".)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
+ int align, unsigned char *dstBuf, int width,
+ int pitch, int height, int pixelFormat);
+
+
+/**
+ * The maximum size of the buffer (in bytes) required to hold a JPEG image
+ * transformed with the given transform parameters and/or cropping region.
+ * This function is a wrapper for #tj3JPEGBufSize() that takes into account
+ * cropping, transposition of the width and height (which affects the
+ * destination image dimensions and level of chrominance subsampling),
+ * grayscale conversion, and the ICC profile (if any) that was previously
+ * associated with the TurboJPEG instance (see #tj3SetICCProfile()) or
+ * extracted from the source image (see #tj3GetICCProfile() and
+ * #TJPARAM_SAVEMARKERS.) The JPEG header must be read (see
+ * tj3DecompressHeader()) prior to calling this function.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * lossless transformation
+ *
+ * @param transform pointer to a #tjtransform structure that specifies the
+ * transform parameters and/or cropping region for the JPEG image.
+ *
+ * @return the maximum size of the buffer (in bytes) required to hold the
+ * transformed image, or 0 if an error occurred (see #tj3GetErrorStr() and
+ * #tj3GetErrorCode().)
+ */
+DLLEXPORT size_t tj3TransformBufSize(tjhandle handle,
+ const tjtransform *transform);
+
+
+/**
+ * Losslessly transform a JPEG image into another JPEG image. Lossless
+ * transforms work by moving the raw DCT coefficients from one JPEG image
+ * structure to another without altering the values of the coefficients. While
+ * this is typically faster than decompressing the image, transforming it, and
+ * re-compressing it, lossless transforms are not free. Each lossless
+ * transform requires reading and performing entropy decoding on all of the
+ * coefficients in the source image, regardless of the size of the destination
+ * image. Thus, this function provides a means of generating multiple
+ * transformed images from the same source or applying multiple transformations
+ * simultaneously, in order to eliminate the need to read the source
+ * coefficients multiple times.
+ *
+ * @param handle handle to a TurboJPEG instance that has been initialized for
+ * lossless transformation
+ *
+ * @param jpegBuf pointer to a byte buffer containing the JPEG source image to
+ * transform
+ *
+ * @param jpegSize size of the JPEG source image (in bytes)
+ *
+ * @param n the number of transformed JPEG images to generate
+ *
+ * @param dstBufs pointer to an array of n byte buffers. `dstBufs[i]` will
+ * receive a JPEG image that has been transformed using the parameters in
+ * `transforms[i]`. TurboJPEG has the ability to reallocate the JPEG
+ * destination buffer to accommodate the size of the transformed JPEG image.
+ * Thus, you can choose to:
+ * -# pre-allocate the JPEG destination buffer with an arbitrary size using
+ * #tj3Alloc() and let TurboJPEG grow the buffer as needed,
+ * -# set `dstBufs[i]` to NULL to tell TurboJPEG to allocate the buffer for
+ * you, or
+ * -# pre-allocate the buffer to a "worst case" size determined by calling
+ * #tj3TransformBufSize(). Under normal circumstances, this should ensure that
+ * the buffer never has to be re-allocated. (Setting #TJPARAM_NOREALLOC
+ * guarantees that it won't be.) Note, however, that there are some rare cases
+ * (such as transforming images with a large amount of embedded Exif data) in
+ * which the transformed JPEG image will be larger than the worst-case size,
+ * and #TJPARAM_NOREALLOC cannot be used in those cases unless the embedded
+ * data is discarded using #TJXOPT_COPYNONE or #TJPARAM_SAVEMARKERS.
+ * .
+ * If you choose option 1 or 3, then `dstSizes[i]` should be set to the size of
+ * your pre-allocated buffer. In any case, unless you have set
+ * #TJPARAM_NOREALLOC, you should always check `dstBufs[i]` upon return from
+ * this function, as it may have changed.
+ *
+ * @param dstSizes pointer to an array of n size_t variables that will receive
+ * the actual sizes (in bytes) of each transformed JPEG image. If `dstBufs[i]`
+ * points to a pre-allocated buffer, then `dstSizes[i]` should be set to the
+ * size of the buffer. Upon return, `dstSizes[i]` will contain the size of the
+ * transformed JPEG image (in bytes.)
+ *
+ * @param transforms pointer to an array of n #tjtransform structures, each of
+ * which specifies the transform parameters and/or cropping region for the
+ * corresponding transformed JPEG image.
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr()
+ * and #tj3GetErrorCode().)
+ */
+DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
+ size_t jpegSize, int n, unsigned char **dstBufs,
+ size_t *dstSizes, const tjtransform *transforms);
+
+
+/**
+ * Load a packed-pixel image with 2 to 8 bits of data precision per sample from
+ * disk into memory.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param filename name of a file containing a packed-pixel image in Windows
+ * BMP or PBMPLUS (PPM/PGM) format. Windows BMP files require 8-bit-per-sample
+ * data precision. When loading a PBMPLUS file, the target data precision
+ * (from 2 to 8 bits per sample) can be specified using #TJPARAM_PRECISION and
+ * defaults to 8 if #TJPARAM_PRECISION is unset or out of range. If the data
+ * precision of the PBMPLUS file does not match the target data precision, then
+ * upconverting or downconverting will be performed.
+ *
+ * @param width pointer to an integer variable that will receive the width (in
+ * pixels) of the packed-pixel image
+ *
+ * @param align row alignment (in samples) of the packed-pixel buffer to be
+ * returned (must be a power of 2.) Setting this parameter to n will cause all
+ * rows in the buffer to be padded to the nearest multiple of n samples
+ * (1 = unpadded.)
+ *
+ * @param height pointer to an integer variable that will receive the height
+ * (in pixels) of the packed-pixel image
+ *
+ * @param pixelFormat pointer to an integer variable that specifies or will
+ * receive the pixel format of the packed-pixel buffer. The behavior of this
+ * function varies depending on the value of `*pixelFormat` passed to the
+ * function:
+ * - @ref TJPF_UNKNOWN : The packed-pixel buffer returned by this function will
+ * use the most optimal pixel format for the file type, and `*pixelFormat` will
+ * contain the ID of that pixel format upon successful return from this
+ * function.
+ * - @ref TJPF_GRAY : Only PGM files and 8-bit-per-pixel BMP files with a
+ * grayscale colormap can be loaded.
+ * - @ref TJPF_CMYK : The RGB or grayscale pixels stored in the file will be
+ * converted using a quick & dirty algorithm that is suitable only for testing
+ * purposes. (Proper conversion between CMYK and other formats requires a
+ * color management system.)
+ * - Other @ref TJPF "pixel formats" : The packed-pixel buffer will use the
+ * specified pixel format, and pixel format conversion will be performed if
+ * necessary.
+ *
+ * @return a pointer to a newly-allocated buffer containing the packed-pixel
+ * image, converted to the chosen pixel format and with the chosen row
+ * alignment, or NULL if an error occurred (see #tj3GetErrorStr().) This
+ * buffer should be freed using #tj3Free().
+ */
+DLLEXPORT unsigned char *tj3LoadImage8(tjhandle handle, const char *filename,
+ int *width, int align, int *height,
+ int *pixelFormat);
+
+/**
+ * Load a packed-pixel image with 9 to 12 bits of data precision per sample
+ * from disk into memory.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param filename name of a file containing a packed-pixel image in PBMPLUS
+ * (PPM/PGM) format. The target data precision (from 9 to 12 bits per sample)
+ * can be specified using #TJPARAM_PRECISION and defaults to 12 if
+ * #TJPARAM_PRECISION is unset or out of range. If the data precision of the
+ * PBMPLUS file does not match the target data precision, then upconverting or
+ * downconverting will be performed.
+ *
+ * @param width pointer to an integer variable that will receive the width (in
+ * pixels) of the packed-pixel image
+ *
+ * @param align row alignment (in samples) of the packed-pixel buffer to be
+ * returned (must be a power of 2.) Setting this parameter to n will cause all
+ * rows in the buffer to be padded to the nearest multiple of n samples
+ * (1 = unpadded.)
+ *
+ * @param height pointer to an integer variable that will receive the height
+ * (in pixels) of the packed-pixel image
+ *
+ * @param pixelFormat pointer to an integer variable that specifies or will
+ * receive the pixel format of the packed-pixel buffer. The behavior of this
+ * function will vary depending on the value of `*pixelFormat` passed to the
+ * function:
+ * - @ref TJPF_UNKNOWN : The packed-pixel buffer returned by this function will
+ * use the most optimal pixel format for the file type, and `*pixelFormat` will
+ * contain the ID of that pixel format upon successful return from this
+ * function.
+ * - @ref TJPF_GRAY : Only PGM files can be loaded.
+ * - @ref TJPF_CMYK : The RGB or grayscale pixels stored in the file will be
+ * converted using a quick & dirty algorithm that is suitable only for testing
+ * purposes. (Proper conversion between CMYK and other formats requires a
+ * color management system.)
+ * - Other @ref TJPF "pixel formats" : The packed-pixel buffer will use the
+ * specified pixel format, and pixel format conversion will be performed if
+ * necessary.
+ *
+ * @return a pointer to a newly-allocated buffer containing the packed-pixel
+ * image, converted to the chosen pixel format and with the chosen row
+ * alignment, or NULL if an error occurred (see #tj3GetErrorStr().) This
+ * buffer should be freed using #tj3Free().
+ */
+DLLEXPORT short *tj3LoadImage12(tjhandle handle, const char *filename,
+ int *width, int align, int *height,
+ int *pixelFormat);
+
+/**
+ * Load a packed-pixel image with 13 to 16 bits of data precision per sample
+ * from disk into memory.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param filename name of a file containing a packed-pixel image in PBMPLUS
+ * (PPM/PGM) format. The target data precision (from 13 to 16 bits per sample)
+ * can be specified using #TJPARAM_PRECISION and defaults to 16 if
+ * #TJPARAM_PRECISION is unset or out of range. If the data precision of the
+ * PBMPLUS file does not match the target data precision, then upconverting or
+ * downconverting will be performed.
+ *
+ * @param width pointer to an integer variable that will receive the width (in
+ * pixels) of the packed-pixel image
+ *
+ * @param align row alignment (in samples) of the packed-pixel buffer to be
+ * returned (must be a power of 2.) Setting this parameter to n will cause all
+ * rows in the buffer to be padded to the nearest multiple of n samples
+ * (1 = unpadded.)
+ *
+ * @param height pointer to an integer variable that will receive the height
+ * (in pixels) of the packed-pixel image
+ *
+ * @param pixelFormat pointer to an integer variable that specifies or will
+ * receive the pixel format of the packed-pixel buffer. The behavior of this
+ * function will vary depending on the value of `*pixelFormat` passed to the
+ * function:
+ * - @ref TJPF_UNKNOWN : The packed-pixel buffer returned by this function will
+ * use the most optimal pixel format for the file type, and `*pixelFormat` will
+ * contain the ID of that pixel format upon successful return from this
+ * function.
+ * - @ref TJPF_GRAY : Only PGM files can be loaded.
+ * - @ref TJPF_CMYK : The RGB or grayscale pixels stored in the file will be
+ * converted using a quick & dirty algorithm that is suitable only for testing
+ * purposes. (Proper conversion between CMYK and other formats requires a
+ * color management system.)
+ * - Other @ref TJPF "pixel formats" : The packed-pixel buffer will use the
+ * specified pixel format, and pixel format conversion will be performed if
+ * necessary.
+ *
+ * @return a pointer to a newly-allocated buffer containing the packed-pixel
+ * image, converted to the chosen pixel format and with the chosen row
+ * alignment, or NULL if an error occurred (see #tj3GetErrorStr().) This
+ * buffer should be freed using #tj3Free().
+ */
+DLLEXPORT unsigned short *tj3LoadImage16(tjhandle handle, const char *filename,
+ int *width, int align, int *height,
+ int *pixelFormat);
+
+
+/**
+ * Save a packed-pixel image with 2 to 8 bits of data precision per sample from
+ * memory to disk.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param filename name of a file to which to save the packed-pixel image. The
+ * image will be stored in Windows BMP or PBMPLUS (PPM/PGM) format, depending
+ * on the file extension. Windows BMP files require 8-bit-per-sample data
+ * precision. When saving a PBMPLUS file, the source data precision (from 2 to
+ * 8 bits per sample) can be specified using #TJPARAM_PRECISION and defaults to
+ * 8 if #TJPARAM_PRECISION is unset or out of range.
+ *
+ * @param buffer pointer to a buffer containing a packed-pixel RGB, grayscale,
+ * or CMYK image to be saved
+ *
+ * @param width width (in pixels) of the packed-pixel image
+ *
+ * @param pitch samples per row in the packed-pixel image. Setting this
+ * parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.
+ *
+ * @param height height (in pixels) of the packed-pixel image
+ *
+ * @param pixelFormat pixel format of the packed-pixel image (see @ref TJPF
+ * "Pixel formats".) If this parameter is set to @ref TJPF_GRAY, then the
+ * image will be stored in PGM or 8-bit-per-pixel (indexed color) BMP format.
+ * Otherwise, the image will be stored in PPM or 24-bit-per-pixel BMP format.
+ * If this parameter is set to @ref TJPF_CMYK, then the CMYK pixels will be
+ * converted to RGB using a quick & dirty algorithm that is suitable only for
+ * testing purposes. (Proper conversion between CMYK and other formats
+ * requires a color management system.)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
+ */
+DLLEXPORT int tj3SaveImage8(tjhandle handle, const char *filename,
+ const unsigned char *buffer, int width, int pitch,
+ int height, int pixelFormat);
+
+/**
+ * Save a packed-pixel image with 9 to 12 bits of data precision per sample
+ * from memory to disk.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param filename name of a file to which to save the packed-pixel image,
+ * which will be stored in PBMPLUS (PPM/PGM) format. The source data precision
+ * (from 9 to 12 bits per sample) can be specified using #TJPARAM_PRECISION and
+ * defaults to 12 if #TJPARAM_PRECISION is unset or out of range.
+ *
+ * @param buffer pointer to a buffer containing a packed-pixel RGB, grayscale,
+ * or CMYK image to be saved
+ *
+ * @param width width (in pixels) of the packed-pixel image
+ *
+ * @param pitch samples per row in the packed-pixel image. Setting this
+ * parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.
+ *
+ * @param height height (in pixels) of the packed-pixel image
+ *
+ * @param pixelFormat pixel format of the packed-pixel image (see @ref TJPF
+ * "Pixel formats".) If this parameter is set to @ref TJPF_GRAY, then the
+ * image will be stored in PGM format. Otherwise, the image will be stored in
+ * PPM format. If this parameter is set to @ref TJPF_CMYK, then the CMYK
+ * pixels will be converted to RGB using a quick & dirty algorithm that is
+ * suitable only for testing purposes. (Proper conversion between CMYK and
+ * other formats requires a color management system.)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
+ */
+DLLEXPORT int tj3SaveImage12(tjhandle handle, const char *filename,
+ const short *buffer, int width, int pitch,
+ int height, int pixelFormat);
+
+/**
+ * Save a packed-pixel image with 13 to 16 bits of data precision per sample
+ * from memory to disk.
+ *
+ * @param handle handle to a TurboJPEG instance
+ *
+ * @param filename name of a file to which to save the packed-pixel image,
+ * which will be stored in PBMPLUS (PPM/PGM) format. The source data precision
+ * (from 13 to 16 bits per sample) can be specified using #TJPARAM_PRECISION
+ * and defaults to 16 if #TJPARAM_PRECISION is unset or out of range.
+ *
+ * @param buffer pointer to a buffer containing a packed-pixel RGB, grayscale,
+ * or CMYK image to be saved
+ *
+ * @param width width (in pixels) of the packed-pixel image
+ *
+ * @param pitch samples per row in the packed-pixel image. Setting this
+ * parameter to 0 is the equivalent of setting it to
+ * <tt>width * #tjPixelSize[pixelFormat]</tt>.
+ *
+ * @param height height (in pixels) of the packed-pixel image
+ *
+ * @param pixelFormat pixel format of the packed-pixel image (see @ref TJPF
+ * "Pixel formats".) If this parameter is set to @ref TJPF_GRAY, then the
+ * image will be stored in PGM format. Otherwise, the image will be stored in
+ * PPM format. If this parameter is set to @ref TJPF_CMYK, then the CMYK
+ * pixels will be converted to RGB using a quick & dirty algorithm that is
+ * suitable only for testing purposes. (Proper conversion between CMYK and
+ * other formats requires a color management system.)
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr().)
+ */
+DLLEXPORT int tj3SaveImage16(tjhandle handle, const char *filename,
+ const unsigned short *buffer, int width,
+ int pitch, int height, int pixelFormat);
+
+
+/* Backward compatibility functions and macros (nothing to see here) */
+
+/* TurboJPEG 1.0+ */
+
+#define NUMSUBOPT TJ_NUMSAMP
+#define TJ_444 TJSAMP_444
+#define TJ_422 TJSAMP_422
+#define TJ_420 TJSAMP_420
+#define TJ_411 TJSAMP_420
+#define TJ_GRAYSCALE TJSAMP_GRAY
+
+#define TJ_BGR 1
+#define TJ_BOTTOMUP TJFLAG_BOTTOMUP
+#define TJ_FORCEMMX TJFLAG_FORCEMMX
+#define TJ_FORCESSE TJFLAG_FORCESSE
+#define TJ_FORCESSE2 TJFLAG_FORCESSE2
+#define TJ_ALPHAFIRST 64
+#define TJ_FORCESSE3 TJFLAG_FORCESSE3
+#define TJ_FASTUPSAMPLE TJFLAG_FASTUPSAMPLE
+
+#define TJPAD(width) (((width) + 3) & (~3))
+
+DLLEXPORT unsigned long TJBUFSIZE(int width, int height);
+
+DLLEXPORT int tjCompress(tjhandle handle, unsigned char *srcBuf, int width,
+ int pitch, int height, int pixelSize,
+ unsigned char *dstBuf, unsigned long *compressedSize,
+ int jpegSubsamp, int jpegQual, int flags);
+
+DLLEXPORT int tjDecompress(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelSize,
+ int flags);
+
+DLLEXPORT int tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, int *width,
+ int *height);
+
+DLLEXPORT int tjDestroy(tjhandle handle);
+
+DLLEXPORT char *tjGetErrorStr(void);
+
+DLLEXPORT tjhandle tjInitCompress(void);
+
+DLLEXPORT tjhandle tjInitDecompress(void);
+
+/* TurboJPEG 1.1+ */
+
+#define TJ_YUV 512
+
+DLLEXPORT unsigned long TJBUFSIZEYUV(int width, int height, int jpegSubsamp);
+
+DLLEXPORT int tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, int *width,
+ int *height, int *jpegSubsamp);
+
+DLLEXPORT int tjDecompressToYUV(tjhandle handle, unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int flags);
+
+DLLEXPORT int tjEncodeYUV(tjhandle handle, unsigned char *srcBuf, int width,
+ int pitch, int height, int pixelSize,
+ unsigned char *dstBuf, int subsamp, int flags);
+
+/* TurboJPEG 1.2+ */
+
+#define TJFLAG_BOTTOMUP 2
+#define TJFLAG_FORCEMMX 8
+#define TJFLAG_FORCESSE 16
+#define TJFLAG_FORCESSE2 32
+#define TJFLAG_FORCESSE3 128
+#define TJFLAG_FASTUPSAMPLE 256
+#define TJFLAG_NOREALLOC 1024
+
+DLLEXPORT unsigned char *tjAlloc(int bytes);
+
+DLLEXPORT unsigned long tjBufSize(int width, int height, int jpegSubsamp);
+
+DLLEXPORT unsigned long tjBufSizeYUV(int width, int height, int subsamp);
+
+DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char **jpegBuf, unsigned long *jpegSize,
+ int jpegSubsamp, int jpegQual, int flags);
+
+DLLEXPORT int tjDecompress2(tjhandle handle, const unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelFormat,
+ int flags);
+
+DLLEXPORT int tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf, int width,
+ int pitch, int height, int pixelFormat,
+ unsigned char *dstBuf, int subsamp, int flags);
+
+DLLEXPORT void tjFree(unsigned char *buffer);
+
+DLLEXPORT tjscalingfactor *tjGetScalingFactors(int *numscalingfactors);
+
+DLLEXPORT tjhandle tjInitTransform(void);
+
+DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
+ unsigned long jpegSize, int n,
+ unsigned char **dstBufs, unsigned long *dstSizes,
+ tjtransform *transforms, int flags);
+
+/* TurboJPEG 1.2.1+ */
+
+#define TJFLAG_FASTDCT 2048
+#define TJFLAG_ACCURATEDCT 4096
+
+/* TurboJPEG 1.4+ */
+
+DLLEXPORT unsigned long tjBufSizeYUV2(int width, int align, int height,
+ int subsamp);
+
+DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
+ int width, int align, int height, int subsamp,
+ unsigned char **jpegBuf,
+ unsigned long *jpegSize, int jpegQual,
+ int flags);
+
+DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
+ const unsigned char **srcPlanes,
+ int width, const int *strides,
+ int height, int subsamp,
+ unsigned char **jpegBuf,
+ unsigned long *jpegSize, int jpegQual,
+ int flags);
+
+DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
+ int align, int subsamp, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelFormat,
+ int flags);
+
+DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
+ const unsigned char **srcPlanes,
+ const int *strides, int subsamp,
+ unsigned char *dstBuf, int width, int pitch,
+ int height, int pixelFormat, int flags);
+
+DLLEXPORT int tjDecompressHeader3(tjhandle handle,
+ const unsigned char *jpegBuf,
+ unsigned long jpegSize, int *width,
+ int *height, int *jpegSubsamp,
+ int *jpegColorspace);
+
+DLLEXPORT int tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf,
+ unsigned long jpegSize, unsigned char *dstBuf,
+ int width, int align, int height, int flags);
+
+DLLEXPORT int tjDecompressToYUVPlanes(tjhandle handle,
+ const unsigned char *jpegBuf,
+ unsigned long jpegSize,
+ unsigned char **dstPlanes, int width,
+ int *strides, int height, int flags);
+
+DLLEXPORT int tjEncodeYUV3(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat,
+ unsigned char *dstBuf, int align, int subsamp,
+ int flags);
+
+DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
+ int width, int pitch, int height,
+ int pixelFormat, unsigned char **dstPlanes,
+ int *strides, int subsamp, int flags);
+
+DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp);
+
+DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
+ int height, int subsamp);
+
+DLLEXPORT int tjPlaneWidth(int componentID, int width, int subsamp);
+
+/* TurboJPEG 2.0+ */
+
+#define TJFLAG_STOPONWARNING 8192
+#define TJFLAG_PROGRESSIVE 16384
+
+DLLEXPORT int tjGetErrorCode(tjhandle handle);
+
+DLLEXPORT char *tjGetErrorStr2(tjhandle handle);
+
+DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
+ int align, int *height, int *pixelFormat,
+ int flags);
+
+DLLEXPORT int tjSaveImage(const char *filename, unsigned char *buffer,
+ int width, int pitch, int height, int pixelFormat,
+ int flags);
+
+/* TurboJPEG 2.1+ */
+
+#define TJFLAG_LIMITSCANS 32768
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-12.c
new file mode 100644
index 00000000000..4ec6e99d57d
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-12.c
@@ -0,0 +1,14 @@
+/*
+ * jcapistd-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcapistd.c to support 9 to 12 bits of
+ * data precision. jcapistd.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jcapistd.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-16.c
new file mode 100644
index 00000000000..3c0cc7916ef
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-16.c
@@ -0,0 +1,14 @@
+/*
+ * jcapistd-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcapistd.c to support 13 to 16 bits of
+ * data precision. jcapistd.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jcapistd.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-8.c
new file mode 100644
index 00000000000..3fa69d9d048
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcapistd-8.c
@@ -0,0 +1,14 @@
+/*
+ * jcapistd-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcapistd.c to support 2 to 8 bits of
+ * data precision. jcapistd.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jcapistd.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-12.c
new file mode 100644
index 00000000000..82405e3c335
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jccoefct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jccoefct.c to support 12 bits of
+ * data precision. jccoefct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jccoefct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-8.c
new file mode 100644
index 00000000000..51d7554aba0
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jccoefct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jccoefct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jccoefct.c to support 8 bits of
+ * data precision. jccoefct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jccoefct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-12.c
new file mode 100644
index 00000000000..8b66c232184
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-12.c
@@ -0,0 +1,14 @@
+/*
+ * jccolor-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jccolor.c to support 9 to 12 bits of
+ * data precision. jccolor.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jccolor.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-16.c
new file mode 100644
index 00000000000..98db8eb50a5
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-16.c
@@ -0,0 +1,14 @@
+/*
+ * jccolor-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jccolor.c to support 13 to 16 bits of
+ * data precision. jccolor.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jccolor.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-8.c
new file mode 100644
index 00000000000..5403b2fe3e2
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jccolor-8.c
@@ -0,0 +1,14 @@
+/*
+ * jccolor-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jccolor.c to support 2 to 8 bits of
+ * data precision. jccolor.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jccolor.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-12.c
new file mode 100644
index 00000000000..6c5e5dfbac9
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-12.c
@@ -0,0 +1,14 @@
+/*
+ * jcdctmgr-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcdctmgr.c to support 12 bits of
+ * data precision. jcdctmgr.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jcdctmgr.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-8.c
new file mode 100644
index 00000000000..a2e1dcedeba
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcdctmgr-8.c
@@ -0,0 +1,14 @@
+/*
+ * jcdctmgr-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcdctmgr.c to support 8 bits of
+ * data precision. jcdctmgr.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jcdctmgr.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-12.c
new file mode 100644
index 00000000000..a32947481c0
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jcdiffct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcdiffct.c to support 9 to 12 bits of
+ * data precision. jcdiffct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jcdiffct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-16.c
new file mode 100644
index 00000000000..5d6a545b9ae
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-16.c
@@ -0,0 +1,14 @@
+/*
+ * jcdiffct-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcdiffct.c to support 13 to 16 bits of
+ * data precision. jcdiffct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jcdiffct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-8.c
new file mode 100644
index 00000000000..dba42301245
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcdiffct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jcdiffct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcdiffct.c to support 2 to 8 bits of
+ * data precision. jcdiffct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jcdiffct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-12.c
new file mode 100644
index 00000000000..f4ab9a3618e
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-12.c
@@ -0,0 +1,14 @@
+/*
+ * jclossls-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jclossls.c to support 9 to 12 bits of
+ * data precision. jclossls.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jclossls.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-16.c
new file mode 100644
index 00000000000..575666f6132
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-16.c
@@ -0,0 +1,14 @@
+/*
+ * jclossls-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jclossls.c to support 13 to 16 bits of
+ * data precision. jclossls.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jclossls.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-8.c
new file mode 100644
index 00000000000..71354eec710
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jclossls-8.c
@@ -0,0 +1,14 @@
+/*
+ * jclossls-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jclossls.c to support 2 to 8 bits of
+ * data precision. jclossls.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jclossls.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-12.c
new file mode 100644
index 00000000000..c63cb484976
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jcmainct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcmainct.c to support 9 to 12 bits of
+ * data precision. jcmainct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jcmainct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-16.c
new file mode 100644
index 00000000000..8256afb9317
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-16.c
@@ -0,0 +1,14 @@
+/*
+ * jcmainct-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcmainct.c to support 13 to 16 bits of
+ * data precision. jcmainct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jcmainct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-8.c
new file mode 100644
index 00000000000..ffac92fde98
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcmainct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jcmainct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcmainct.c to support 2 to 8 bits of
+ * data precision. jcmainct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jcmainct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-12.c
new file mode 100644
index 00000000000..0970afd80cb
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jcprepct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcprepct.c to support 9 to 12 bits of
+ * data precision. jcprepct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jcprepct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-16.c
new file mode 100644
index 00000000000..92adbd8faa5
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-16.c
@@ -0,0 +1,14 @@
+/*
+ * jcprepct-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcprepct.c to support 13 to 16 bits of
+ * data precision. jcprepct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jcprepct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-8.c
new file mode 100644
index 00000000000..3616d9c8848
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcprepct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jcprepct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcprepct.c to support 2 to 8 bits of
+ * data precision. jcprepct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jcprepct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-12.c
new file mode 100644
index 00000000000..95110821a09
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-12.c
@@ -0,0 +1,14 @@
+/*
+ * jcsample-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcsample.c to support 9 to 12 bits of
+ * data precision. jcsample.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jcsample.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-16.c
new file mode 100644
index 00000000000..87fe293b82b
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-16.c
@@ -0,0 +1,14 @@
+/*
+ * jcsample-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcsample.c to support 13 to 16 bits of
+ * data precision. jcsample.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jcsample.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-8.c
new file mode 100644
index 00000000000..f3f6067e362
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jcsample-8.c
@@ -0,0 +1,14 @@
+/*
+ * jcsample-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jcsample.c to support 2 to 8 bits of
+ * data precision. jcsample.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jcsample.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-12.c
new file mode 100644
index 00000000000..7fe49219d82
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdapistd-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdapistd.c to support 9 to 12 bits of
+ * data precision. jdapistd.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdapistd.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-16.c
new file mode 100644
index 00000000000..31da5debdeb
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-16.c
@@ -0,0 +1,14 @@
+/*
+ * jdapistd-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdapistd.c to support 13 to 16 bits of
+ * data precision. jdapistd.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jdapistd.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-8.c
new file mode 100644
index 00000000000..31b25693413
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdapistd-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdapistd-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdapistd.c to support 2 to 8 bits of
+ * data precision. jdapistd.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdapistd.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-12.c
new file mode 100644
index 00000000000..efeb532066d
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdcoefct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdcoefct.c to support 12 bits of
+ * data precision. jdcoefct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdcoefct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-8.c
new file mode 100644
index 00000000000..446cefcee91
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdcoefct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdcoefct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdcoefct.c to support 8 bits of
+ * data precision. jdcoefct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdcoefct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-12.c
new file mode 100644
index 00000000000..0054d22f267
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdcolor-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdcolor.c to support 9 to 12 bits of
+ * data precision. jdcolor.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdcolor.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-16.c
new file mode 100644
index 00000000000..e65ffa1ecb8
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-16.c
@@ -0,0 +1,14 @@
+/*
+ * jdcolor-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdcolor.c to support 13 to 16 bits of
+ * data precision. jdcolor.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jdcolor.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-8.c
new file mode 100644
index 00000000000..525e13e270a
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdcolor-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdcolor-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdcolor.c to support 2 to 8 bits of
+ * data precision. jdcolor.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdcolor.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-12.c
new file mode 100644
index 00000000000..a6503ea2dcf
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-12.c
@@ -0,0 +1,14 @@
+/*
+ * jddctmgr-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jddctmgr.c to support 12 bits of
+ * data precision. jddctmgr.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jddctmgr.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-8.c
new file mode 100644
index 00000000000..f61de79cd1b
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jddctmgr-8.c
@@ -0,0 +1,14 @@
+/*
+ * jddctmgr-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jddctmgr.c to support 8 bits of
+ * data precision. jddctmgr.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jddctmgr.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-12.c
new file mode 100644
index 00000000000..a8b60f004b3
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jddiffct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jddiffct.c to support 9 to 12 bits of
+ * data precision. jddiffct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jddiffct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-16.c
new file mode 100644
index 00000000000..35277c82821
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-16.c
@@ -0,0 +1,14 @@
+/*
+ * jddiffct-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jddiffct.c to support 13 to 16 bits of
+ * data precision. jddiffct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jddiffct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-8.c
new file mode 100644
index 00000000000..8ff0731d196
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jddiffct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jddiffct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jddiffct.c to support 2 to 8 bits of
+ * data precision. jddiffct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jddiffct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-12.c
new file mode 100644
index 00000000000..4366368673c
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdlossls-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdlossls.c to support 9 to 12 bits of
+ * data precision. jdlossls.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdlossls.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-16.c
new file mode 100644
index 00000000000..89697b26d1f
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-16.c
@@ -0,0 +1,14 @@
+/*
+ * jdlossls-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdlossls.c to support 13 to 16 bits of
+ * data precision. jdlossls.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jdlossls.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-8.c
new file mode 100644
index 00000000000..0bce5f43238
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdlossls-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdlossls-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdlossls.c to support 2 to 8 bits of
+ * data precision. jdlossls.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdlossls.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-12.c
new file mode 100644
index 00000000000..99deae35069
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdmainct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdmainct.c to support 9 to 12 bits of
+ * data precision. jdmainct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdmainct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-16.c
new file mode 100644
index 00000000000..11164f5e50b
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-16.c
@@ -0,0 +1,14 @@
+/*
+ * jdmainct-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdmainct.c to support 13 to 16 bits of
+ * data precision. jdmainct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jdmainct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-8.c
new file mode 100644
index 00000000000..5f1bb6bfa7a
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdmainct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdmainct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdmainct.c to support 2 to 8 bits of
+ * data precision. jdmainct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdmainct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-12.c
new file mode 100644
index 00000000000..bbf3c3723bc
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdmerge-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdmerge.c to support 12 bits of
+ * data precision. jdmerge.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdmerge.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-8.c
new file mode 100644
index 00000000000..5faea11dd2a
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdmerge-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdmerge-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdmerge.c to support 8 bits of
+ * data precision. jdmerge.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdmerge.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-12.c
new file mode 100644
index 00000000000..dadda1754c8
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdpostct-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdpostct.c to support 9 to 12 bits of
+ * data precision. jdpostct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdpostct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-16.c
new file mode 100644
index 00000000000..12db968c1f6
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-16.c
@@ -0,0 +1,14 @@
+/*
+ * jdpostct-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdpostct.c to support 13 to 16 bits of
+ * data precision. jdpostct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jdpostct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-8.c
new file mode 100644
index 00000000000..5227d363d11
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdpostct-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdpostct-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdpostct.c to support 2 to 8 bits of
+ * data precision. jdpostct.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdpostct.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-12.c
new file mode 100644
index 00000000000..910764d711d
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-12.c
@@ -0,0 +1,14 @@
+/*
+ * jdsample-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdsample.c to support 9 to 12 bits of
+ * data precision. jdsample.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jdsample.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-16.c
new file mode 100644
index 00000000000..d39127a03d6
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-16.c
@@ -0,0 +1,14 @@
+/*
+ * jdsample-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdsample.c to support 13 to 16 bits of
+ * data precision. jdsample.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jdsample.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-8.c
new file mode 100644
index 00000000000..29ad67a21e0
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jdsample-8.c
@@ -0,0 +1,14 @@
+/*
+ * jdsample-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jdsample.c to support 2 to 8 bits of
+ * data precision. jdsample.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jdsample.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-12.c
new file mode 100644
index 00000000000..0b41d92b8ac
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-12.c
@@ -0,0 +1,14 @@
+/*
+ * jfdctfst-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jfdctfst.c to support 12 bits of
+ * data precision. jfdctfst.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jfdctfst.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-8.c
new file mode 100644
index 00000000000..0296ce0ecb6
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctfst-8.c
@@ -0,0 +1,14 @@
+/*
+ * jfdctfst-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jfdctfst.c to support 8 bits of
+ * data precision. jfdctfst.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jfdctfst.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-12.c
new file mode 100644
index 00000000000..42ec3ef7150
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-12.c
@@ -0,0 +1,14 @@
+/*
+ * jfdctint-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jfdctint.c to support 12 bits of
+ * data precision. jfdctint.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jfdctint.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-8.c
new file mode 100644
index 00000000000..3de9390e706
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jfdctint-8.c
@@ -0,0 +1,14 @@
+/*
+ * jfdctint-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jfdctint.c to support 8 bits of
+ * data precision. jfdctint.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jfdctint.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-12.c
new file mode 100644
index 00000000000..f298d223ff4
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-12.c
@@ -0,0 +1,14 @@
+/*
+ * jidctflt-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctflt.c to support 12 bits of
+ * data precision. jidctflt.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jidctflt.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-8.c
new file mode 100644
index 00000000000..23d91537890
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctflt-8.c
@@ -0,0 +1,14 @@
+/*
+ * jidctflt-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctflt.c to support 8 bits of
+ * data precision. jidctflt.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jidctflt.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-12.c
new file mode 100644
index 00000000000..cb3fcd15a4d
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-12.c
@@ -0,0 +1,14 @@
+/*
+ * jidctfst-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctfst.c to support 12 bits of
+ * data precision. jidctfst.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jidctfst.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-8.c
new file mode 100644
index 00000000000..26f6681890a
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctfst-8.c
@@ -0,0 +1,14 @@
+/*
+ * jidctfst-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctfst.c to support 8 bits of
+ * data precision. jidctfst.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jidctfst.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctint-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctint-12.c
new file mode 100644
index 00000000000..f985fc451aa
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctint-12.c
@@ -0,0 +1,14 @@
+/*
+ * jidctint-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctint.c to support 12 bits of
+ * data precision. jidctint.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jidctint.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctint-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctint-8.c
new file mode 100644
index 00000000000..fda7fe300bc
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctint-8.c
@@ -0,0 +1,14 @@
+/*
+ * jidctint-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctint.c to support 8 bits of
+ * data precision. jidctint.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jidctint.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctred-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctred-12.c
new file mode 100644
index 00000000000..832169afebb
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctred-12.c
@@ -0,0 +1,14 @@
+/*
+ * jidctred-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctred.c to support 12 bits of
+ * data precision. jidctred.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jidctred.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jidctred-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jidctred-8.c
new file mode 100644
index 00000000000..0957b0d37f1
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jidctred-8.c
@@ -0,0 +1,14 @@
+/*
+ * jidctred-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jidctred.c to support 8 bits of
+ * data precision. jidctred.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jidctred.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jquant1-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jquant1-12.c
new file mode 100644
index 00000000000..7970c3d6731
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jquant1-12.c
@@ -0,0 +1,14 @@
+/*
+ * jquant1-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jquant1.c to support 12 bits of
+ * data precision. jquant1.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jquant1.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jquant1-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jquant1-8.c
new file mode 100644
index 00000000000..211f92212d3
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jquant1-8.c
@@ -0,0 +1,14 @@
+/*
+ * jquant1-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jquant1.c to support 8 bits of
+ * data precision. jquant1.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jquant1.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jquant2-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jquant2-12.c
new file mode 100644
index 00000000000..566e1626442
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jquant2-12.c
@@ -0,0 +1,14 @@
+/*
+ * jquant2-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jquant2.c to support 12 bits of
+ * data precision. jquant2.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jquant2.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jquant2-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jquant2-8.c
new file mode 100644
index 00000000000..30cfe17ceb0
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jquant2-8.c
@@ -0,0 +1,14 @@
+/*
+ * jquant2-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jquant2.c to support 8 bits of
+ * data precision. jquant2.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jquant2.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jutils-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/jutils-12.c
new file mode 100644
index 00000000000..6620aa2d78a
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jutils-12.c
@@ -0,0 +1,14 @@
+/*
+ * jutils-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jutils.c to support 9 to 12 bits of
+ * data precision. jutils.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../jutils.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jutils-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/jutils-16.c
new file mode 100644
index 00000000000..2df48891d1d
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jutils-16.c
@@ -0,0 +1,14 @@
+/*
+ * jutils-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jutils.c to support 13 to 16 bits of
+ * data precision. jutils.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../jutils.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/jutils-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/jutils-8.c
new file mode 100644
index 00000000000..3c84956c3ca
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/jutils-8.c
@@ -0,0 +1,14 @@
+/*
+ * jutils-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling jutils.c to support 2 to 8 bits of
+ * data precision. jutils.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../jutils.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-12.c
new file mode 100644
index 00000000000..93d8b6c506e
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-12.c
@@ -0,0 +1,14 @@
+/*
+ * rdcolmap-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling rdcolmap.c to support 12 bits of
+ * data precision. rdcolmap.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../rdcolmap.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-8.c
new file mode 100644
index 00000000000..688cf256a31
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/rdcolmap-8.c
@@ -0,0 +1,14 @@
+/*
+ * rdcolmap-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling rdcolmap.c to support 8 bits of
+ * data precision. rdcolmap.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../rdcolmap.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-12.c
new file mode 100644
index 00000000000..6ed96c0901a
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-12.c
@@ -0,0 +1,14 @@
+/*
+ * rdppm-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling rdppm.c to support 9 to 12 bits of
+ * data precision. rdppm.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../rdppm.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-16.c
new file mode 100644
index 00000000000..710c08869ad
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-16.c
@@ -0,0 +1,14 @@
+/*
+ * rdppm-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling rdppm.c to support 13 to 16 bits of
+ * data precision. rdppm.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../rdppm.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-8.c
new file mode 100644
index 00000000000..50ce3884ce4
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/rdppm-8.c
@@ -0,0 +1,14 @@
+/*
+ * rdppm-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling rdppm.c to support 2 to 8 bits of
+ * data precision. rdppm.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../rdppm.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/wrgif-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/wrgif-12.c
new file mode 100644
index 00000000000..1e1ceeebca9
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/wrgif-12.c
@@ -0,0 +1,14 @@
+/*
+ * wrgif-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling wrgif.c to support 12 bits of
+ * data precision. wrgif.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../wrgif.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/wrgif-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/wrgif-8.c
new file mode 100644
index 00000000000..a0045d72639
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/wrgif-8.c
@@ -0,0 +1,14 @@
+/*
+ * wrgif-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling wrgif.c to support 8 bits of
+ * data precision. wrgif.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../wrgif.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-12.c b/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-12.c
new file mode 100644
index 00000000000..8419c977013
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-12.c
@@ -0,0 +1,14 @@
+/*
+ * wrppm-12.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling wrppm.c to support 9 to 12 bits of
+ * data precision. wrppm.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 12
+
+#include "../wrppm.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-16.c b/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-16.c
new file mode 100644
index 00000000000..2b6c14ea981
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-16.c
@@ -0,0 +1,14 @@
+/*
+ * wrppm-16.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling wrppm.c to support 13 to 16 bits of
+ * data precision. wrppm.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 16
+
+#include "../wrppm.c"
diff --git a/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-8.c b/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-8.c
new file mode 100644
index 00000000000..908dc3f801f
--- /dev/null
+++ b/contrib/libs/libjpeg-turbo/src/wrapper/wrppm-8.c
@@ -0,0 +1,14 @@
+/*
+ * wrppm-8.c
+ *
+ * Copyright (C) 2025, D. R. Commander.
+ * For conditions of distribution and use, see the accompanying README.ijg
+ * file.
+ *
+ * This file is a wrapper for compiling wrppm.c to support 2 to 8 bits of
+ * data precision. wrppm.c should not be compiled directly.
+ */
+
+#define BITS_IN_JSAMPLE 8
+
+#include "../wrppm.c"
diff --git a/contrib/libs/libjpeg-turbo/wrbmp.c b/contrib/libs/libjpeg-turbo/src/wrbmp.c
index 45fff684d82..0d2975ae427 100644
--- a/contrib/libs/libjpeg-turbo/wrbmp.c
+++ b/contrib/libs/libjpeg-turbo/src/wrbmp.c
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited.
- * Copyright (C) 2014-2015, 2017, 2019, 2022, D. R. Commander.
+ * Copyright (C) 2014-2015, 2017, 2019, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -142,7 +142,7 @@ put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
} else if (cinfo->out_color_space == JCS_CMYK) {
for (col = cinfo->output_width; col > 0; col--) {
JSAMPLE c = *inptr++, m = *inptr++, y = *inptr++, k = *inptr++;
- cmyk_to_rgb(c, m, y, k, outptr + 2, outptr + 1, outptr);
+ cmyk_to_rgb(255, c, m, y, k, outptr + 2, outptr + 1, outptr);
outptr += 3;
}
} else {
@@ -480,6 +480,9 @@ jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
bmp_dest_ptr dest;
JDIMENSION row_width;
+ if (cinfo->data_precision != 8)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object, fill in method pointers */
dest = (bmp_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
diff --git a/contrib/libs/libjpeg-turbo/wrgif.c b/contrib/libs/libjpeg-turbo/src/wrgif.c
index 620a3ba9177..23773573b3b 100644
--- a/contrib/libs/libjpeg-turbo/wrgif.c
+++ b/contrib/libs/libjpeg-turbo/src/wrgif.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2015-2019 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2015, 2017, 2022, D. R. Commander.
+ * Copyright (C) 2015, 2017, 2022-2023, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -31,8 +31,9 @@
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
+#include "jsamplecomp.h"
-#ifdef GIF_SUPPORTED
+#if defined(GIF_SUPPORTED) && BITS_IN_JSAMPLE != 16
#define MAX_LZW_BITS 12 /* maximum LZW code size (4096 symbols) */
@@ -249,7 +250,7 @@ put_3bytes(gif_dest_ptr dinfo, int val)
LOCAL(void)
-emit_header(gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap)
+emit_header(gif_dest_ptr dinfo, int num_colors, _JSAMPARRAY colormap)
/* Output the GIF file header, including color map */
/* If colormap == NULL, synthesize a grayscale colormap */
{
@@ -308,7 +309,7 @@ emit_header(gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap)
}
} else {
/* fill out the map to a power of 2 */
- put_3bytes(dinfo, CENTERJSAMPLE >> cshift);
+ put_3bytes(dinfo, _CENTERJSAMPLE >> cshift);
}
}
/* Write image separator and Image Descriptor */
@@ -337,9 +338,10 @@ start_output_gif(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
gif_dest_ptr dest = (gif_dest_ptr)dinfo;
if (cinfo->quantize_colors)
- emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap);
+ emit_header(dest, cinfo->actual_number_of_colors,
+ (_JSAMPARRAY)cinfo->colormap);
else
- emit_header(dest, 256, (JSAMPARRAY)NULL);
+ emit_header(dest, 256, (_JSAMPARRAY)NULL);
}
@@ -358,14 +360,14 @@ put_LZW_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
JDIMENSION rows_supplied)
{
gif_dest_ptr dest = (gif_dest_ptr)dinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register JDIMENSION col;
code_int c;
register hash_int i;
register hash_int disp;
register hash_entry probe_value;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pub._buffer[0];
for (col = cinfo->output_width; col > 0; col--) {
/* Accept and compress one 8-bit byte */
c = (code_int)(*ptr++);
@@ -459,11 +461,11 @@ put_raw_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
JDIMENSION rows_supplied)
{
gif_dest_ptr dest = (gif_dest_ptr)dinfo;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register JDIMENSION col;
code_int c;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pub._buffer[0];
for (col = cinfo->output_width; col > 0; col--) {
c = (code_int)(*ptr++);
/* Accept and output one pixel value.
@@ -522,10 +524,13 @@ calc_buffer_dimensions_gif(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
*/
GLOBAL(djpeg_dest_ptr)
-jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw)
+_jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw)
{
gif_dest_ptr dest;
+ if (cinfo->data_precision != BITS_IN_JSAMPLE)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object, fill in method pointers */
dest = (gif_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@@ -554,7 +559,7 @@ jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw)
ERREXIT(cinfo, JERR_GIF_BUG);
/* Create decompressor output buffer. */
- dest->pub.buffer = (*cinfo->mem->alloc_sarray)
+ dest->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION)1);
dest->pub.buffer_height = 1;
@@ -577,4 +582,4 @@ jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw)
return (djpeg_dest_ptr)dest;
}
-#endif /* GIF_SUPPORTED */
+#endif /* defined(GIF_SUPPORTED) && BITS_IN_JSAMPLE != 16 */
diff --git a/contrib/libs/libjpeg-turbo/wrppm.c b/contrib/libs/libjpeg-turbo/src/wrppm.c
index 57c8aaffacb..749febf1f3b 100644
--- a/contrib/libs/libjpeg-turbo/wrppm.c
+++ b/contrib/libs/libjpeg-turbo/src/wrppm.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2019-2020, 2022, D. R. Commander.
+ * Copyright (C) 2017, 2019-2020, 2022, 2024, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -22,7 +22,8 @@
#include "cmyk.h"
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
-#ifdef PPM_SUPPORTED
+#if defined(PPM_SUPPORTED) && \
+ (BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED))
/*
@@ -38,10 +39,11 @@
#if BITS_IN_JSAMPLE == 8
#define PUTPPMSAMPLE(ptr, v) *ptr++ = (char)(v)
#define BYTESPERSAMPLE 1
-#define PPM_MAXVAL 255
+#define PPM_MAXVAL ((1 << cinfo->data_precision) - 1)
#else
#ifdef PPM_NORAWWORD
-#define PUTPPMSAMPLE(ptr, v) *ptr++ = (char)((v) >> (BITS_IN_JSAMPLE - 8))
+#define PUTPPMSAMPLE(ptr, v) \
+ *ptr++ = (char)((v) >> (cinfo->data_precision - 8))
#define BYTESPERSAMPLE 1
#define PPM_MAXVAL 255
#else
@@ -52,13 +54,13 @@
*ptr++ = (char)(val_ & 0xFF); \
}
#define BYTESPERSAMPLE 2
-#define PPM_MAXVAL ((1 << BITS_IN_JSAMPLE) - 1)
+#define PPM_MAXVAL ((1 << cinfo->data_precision) - 1)
#endif
#endif
/*
- * When JSAMPLE is the same size as char, we can just fwrite() the
+ * When _JSAMPLE is the same size as char, we can just fwrite() the
* decompressed data to the PPM or PGM file.
*/
@@ -70,9 +72,9 @@ typedef struct {
/* Usually these two pointers point to the same place: */
char *iobuffer; /* fwrite's I/O buffer */
- JSAMPROW pixrow; /* decompressor output buffer */
+ _JSAMPROW pixrow; /* decompressor output buffer */
size_t buffer_width; /* width of I/O buffer */
- JDIMENSION samples_per_row; /* JSAMPLEs per output row */
+ JDIMENSION samples_per_row; /* _JSAMPLEs per output row */
} ppm_dest_struct;
typedef ppm_dest_struct *ppm_dest_ptr;
@@ -107,12 +109,12 @@ copy_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
{
ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
register char *bufferptr;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
#if BITS_IN_JSAMPLE != 8
register JDIMENSION col;
#endif
- ptr = dest->pub.buffer[0];
+ ptr = dest->pub._buffer[0];
bufferptr = dest->iobuffer;
#if BITS_IN_JSAMPLE == 8
memcpy(bufferptr, ptr, dest->samples_per_row);
@@ -134,14 +136,14 @@ put_rgb(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied)
{
ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
register char *bufferptr;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register JDIMENSION col;
register int rindex = rgb_red[cinfo->out_color_space];
register int gindex = rgb_green[cinfo->out_color_space];
register int bindex = rgb_blue[cinfo->out_color_space];
register int ps = rgb_pixelsize[cinfo->out_color_space];
- ptr = dest->pub.buffer[0];
+ ptr = dest->pub._buffer[0];
bufferptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
PUTPPMSAMPLE(bufferptr, ptr[rindex]);
@@ -163,14 +165,14 @@ put_cmyk(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
{
ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
register char *bufferptr;
- register JSAMPROW ptr;
+ register _JSAMPROW ptr;
register JDIMENSION col;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pub._buffer[0];
bufferptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
- JSAMPLE r, g, b, c = *ptr++, m = *ptr++, y = *ptr++, k = *ptr++;
- cmyk_to_rgb(c, m, y, k, &r, &g, &b);
+ _JSAMPLE r, g, b, c = *ptr++, m = *ptr++, y = *ptr++, k = *ptr++;
+ cmyk_to_rgb(PPM_MAXVAL, c, m, y, k, &r, &g, &b);
PUTPPMSAMPLE(bufferptr, r);
PUTPPMSAMPLE(bufferptr, g);
PUTPPMSAMPLE(bufferptr, b);
@@ -191,13 +193,13 @@ put_demapped_rgb(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
register char *bufferptr;
register int pixval;
- register JSAMPROW ptr;
- register JSAMPROW color_map0 = cinfo->colormap[0];
- register JSAMPROW color_map1 = cinfo->colormap[1];
- register JSAMPROW color_map2 = cinfo->colormap[2];
+ register _JSAMPROW ptr;
+ register _JSAMPROW color_map0 = ((_JSAMPARRAY)cinfo->colormap)[0];
+ register _JSAMPROW color_map1 = ((_JSAMPARRAY)cinfo->colormap)[1];
+ register _JSAMPROW color_map2 = ((_JSAMPARRAY)cinfo->colormap)[2];
register JDIMENSION col;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pub._buffer[0];
bufferptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
pixval = *ptr++;
@@ -215,11 +217,11 @@ put_demapped_gray(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
{
ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
register char *bufferptr;
- register JSAMPROW ptr;
- register JSAMPROW color_map = cinfo->colormap[0];
+ register _JSAMPROW ptr;
+ register _JSAMPROW color_map = ((_JSAMPARRAY)cinfo->colormap)[0];
register JDIMENSION col;
- ptr = dest->pub.buffer[0];
+ ptr = dest->pub._buffer[0];
bufferptr = dest->iobuffer;
for (col = cinfo->output_width; col > 0; col--) {
PUTPPMSAMPLE(bufferptr, color_map[*ptr++]);
@@ -304,10 +306,18 @@ calc_buffer_dimensions_ppm(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
*/
GLOBAL(djpeg_dest_ptr)
-jinit_write_ppm(j_decompress_ptr cinfo)
+_jinit_write_ppm(j_decompress_ptr cinfo)
{
ppm_dest_ptr dest;
+#if BITS_IN_JSAMPLE == 8
+ if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
+#else
+ if (cinfo->data_precision > BITS_IN_JSAMPLE ||
+ cinfo->data_precision < BITS_IN_JSAMPLE - 3)
+#endif
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object, fill in method pointers */
dest = (ppm_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@@ -325,7 +335,7 @@ jinit_write_ppm(j_decompress_ptr cinfo)
((j_common_ptr)cinfo, JPOOL_IMAGE, dest->buffer_width);
if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 ||
- sizeof(JSAMPLE) != sizeof(char) ||
+ sizeof(_JSAMPLE) != sizeof(char) ||
#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
(cinfo->out_color_space != JCS_EXT_RGB &&
cinfo->out_color_space != JCS_RGB)) {
@@ -336,7 +346,7 @@ jinit_write_ppm(j_decompress_ptr cinfo)
* that's separate from the physical I/O buffer. We also need a
* separate buffer if pixel format translation must take place.
*/
- dest->pub.buffer = (*cinfo->mem->alloc_sarray)
+ dest->pub._buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE,
cinfo->output_width * cinfo->output_components, (JDIMENSION)1);
dest->pub.buffer_height = 1;
@@ -353,9 +363,9 @@ jinit_write_ppm(j_decompress_ptr cinfo)
dest->pub.put_pixel_rows = put_demapped_rgb;
} else {
/* We will fwrite() directly from decompressor output buffer. */
- /* Synthesize a JSAMPARRAY pointer structure */
- dest->pixrow = (JSAMPROW)dest->iobuffer;
- dest->pub.buffer = &dest->pixrow;
+ /* Synthesize a _JSAMPARRAY pointer structure */
+ dest->pixrow = (_JSAMPROW)dest->iobuffer;
+ dest->pub._buffer = &dest->pixrow;
dest->pub.buffer_height = 1;
dest->pub.put_pixel_rows = put_pixel_rows;
}
@@ -363,4 +373,5 @@ jinit_write_ppm(j_decompress_ptr cinfo)
return (djpeg_dest_ptr)dest;
}
-#endif /* PPM_SUPPORTED */
+#endif /* defined(PPM_SUPPORTED) &&
+ (BITS_IN_JSAMPLE != 16 || defined(D_LOSSLESS_SUPPORTED)) */
diff --git a/contrib/libs/libjpeg-turbo/wrtarga.c b/contrib/libs/libjpeg-turbo/src/wrtarga.c
index 67ca1f00a48..110e421810f 100644
--- a/contrib/libs/libjpeg-turbo/wrtarga.c
+++ b/contrib/libs/libjpeg-turbo/src/wrtarga.c
@@ -230,6 +230,9 @@ jinit_write_targa(j_decompress_ptr cinfo)
{
tga_dest_ptr dest;
+ if (cinfo->data_precision != 8)
+ ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
+
/* Create module interface object, fill in method pointers */
dest = (tga_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
diff --git a/contrib/libs/libjpeg-turbo/transupp.h b/contrib/libs/libjpeg-turbo/transupp.h
index cea1f409214..0c6ce15cbe7 100644
--- a/contrib/libs/libjpeg-turbo/transupp.h
+++ b/contrib/libs/libjpeg-turbo/transupp.h
@@ -1,231 +1 @@
-/*
- * transupp.h
- *
- * This file was part of the Independent JPEG Group's software:
- * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
- * libjpeg-turbo Modifications:
- * Copyright (C) 2017, 2021, D. R. Commander.
- * For conditions of distribution and use, see the accompanying README.ijg
- * file.
- *
- * This file contains declarations for image transformation routines and
- * other utility code used by the jpegtran sample application. These are
- * NOT part of the core JPEG library. But we keep these routines separate
- * from jpegtran.c to ease the task of maintaining jpegtran-like programs
- * that have other user interfaces.
- *
- * NOTE: all the routines declared here have very specific requirements
- * about when they are to be executed during the reading and writing of the
- * source and destination files. See the comments in transupp.c, or see
- * jpegtran.c for an example of correct usage.
- */
-
-/* If you happen not to want the image transform support, disable it here */
-#ifndef TRANSFORMS_SUPPORTED
-#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */
-#endif
-
-/*
- * Although rotating and flipping data expressed as DCT coefficients is not
- * hard, there is an asymmetry in the JPEG format specification for images
- * whose dimensions aren't multiples of the iMCU size. The right and bottom
- * image edges are padded out to the next iMCU boundary with junk data; but
- * no padding is possible at the top and left edges. If we were to flip
- * the whole image including the pad data, then pad garbage would become
- * visible at the top and/or left, and real pixels would disappear into the
- * pad margins --- perhaps permanently, since encoders & decoders may not
- * bother to preserve DCT blocks that appear to be completely outside the
- * nominal image area. So, we have to exclude any partial iMCUs from the
- * basic transformation.
- *
- * Transpose is the only transformation that can handle partial iMCUs at the
- * right and bottom edges completely cleanly. flip_h can flip partial iMCUs
- * at the bottom, but leaves any partial iMCUs at the right edge untouched.
- * Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
- * The other transforms are defined as combinations of these basic transforms
- * and process edge blocks in a way that preserves the equivalence.
- *
- * The "trim" option causes untransformable partial iMCUs to be dropped;
- * this is not strictly lossless, but it usually gives the best-looking
- * result for odd-size images. Note that when this option is active,
- * the expected mathematical equivalences between the transforms may not hold.
- * (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
- * followed by -rot 180 -trim trims both edges.)
- *
- * We also offer a lossless-crop option, which discards data outside a given
- * image region but losslessly preserves what is inside. Like the rotate and
- * flip transforms, lossless crop is restricted by the JPEG format: the upper
- * left corner of the selected region must fall on an iMCU boundary. If this
- * does not hold for the given crop parameters, we silently move the upper left
- * corner up and/or left to make it so, simultaneously increasing the region
- * dimensions to keep the lower right crop corner unchanged. (Thus, the
- * output image covers at least the requested region, but may cover more.)
- * The adjustment of the region dimensions may be optionally disabled.
- *
- * A complementary lossless wipe option is provided to discard (gray out) data
- * inside a given image region while losslessly preserving what is outside.
- * A lossless drop option is also provided, which allows another JPEG image to
- * be inserted ("dropped") into the source image data at a given position,
- * replacing the existing image data at that position. Both the source image
- * and the drop image must have the same subsampling level. It is best if they
- * also have the same quantization (quality.) Otherwise, the quantization of
- * the output image will be adapted to accommodate the higher of the source
- * image quality and the drop image quality. The trim option can be used with
- * the drop option to requantize the drop image to match the source image.
- *
- * We also provide a lossless-resize option, which is kind of a lossless-crop
- * operation in the DCT coefficient block domain - it discards higher-order
- * coefficients and losslessly preserves lower-order coefficients of a
- * sub-block.
- *
- * Rotate/flip transform, resize, and crop can be requested together in a
- * single invocation. The crop is applied last --- that is, the crop region
- * is specified in terms of the destination image after transform/resize.
- *
- * We also offer a "force to grayscale" option, which simply discards the
- * chrominance channels of a YCbCr image. This is lossless in the sense that
- * the luminance channel is preserved exactly. It's not the same kind of
- * thing as the rotate/flip transformations, but it's convenient to handle it
- * as part of this package, mainly because the transformation routines have to
- * be aware of the option to know how many components to work on.
- */
-
-
-/*
- * Codes for supported types of image transformations.
- */
-
-typedef enum {
- JXFORM_NONE, /* no transformation */
- JXFORM_FLIP_H, /* horizontal flip */
- JXFORM_FLIP_V, /* vertical flip */
- JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
- JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
- JXFORM_ROT_90, /* 90-degree clockwise rotation */
- JXFORM_ROT_180, /* 180-degree rotation */
- JXFORM_ROT_270, /* 270-degree clockwise (or 90 ccw) */
- JXFORM_WIPE, /* wipe */
- JXFORM_DROP /* drop */
-} JXFORM_CODE;
-
-/*
- * Codes for crop parameters, which can individually be unspecified,
- * positive or negative for xoffset or yoffset,
- * positive or force or reflect for width or height.
- */
-
-typedef enum {
- JCROP_UNSET,
- JCROP_POS,
- JCROP_NEG,
- JCROP_FORCE,
- JCROP_REFLECT
-} JCROP_CODE;
-
-/*
- * Transform parameters struct.
- * NB: application must not change any elements of this struct after
- * calling jtransform_request_workspace.
- */
-
-typedef struct {
- /* Options: set by caller */
- JXFORM_CODE transform; /* image transform operator */
- boolean perfect; /* if TRUE, fail if partial MCUs are requested */
- boolean trim; /* if TRUE, trim partial MCUs as needed */
- boolean force_grayscale; /* if TRUE, convert color image to grayscale */
- boolean crop; /* if TRUE, crop or wipe source image, or drop */
- boolean slow_hflip; /* For best performance, the JXFORM_FLIP_H transform
- normally modifies the source coefficients in place.
- Setting this to TRUE will instead use a slower,
- double-buffered algorithm, which leaves the source
- coefficients in tact (necessary if other transformed
- images must be generated from the same set of
- coefficients. */
-
- /* Crop parameters: application need not set these unless crop is TRUE.
- * These can be filled in by jtransform_parse_crop_spec().
- */
- JDIMENSION crop_width; /* Width of selected region */
- JCROP_CODE crop_width_set; /* (force-disables adjustment) */
- JDIMENSION crop_height; /* Height of selected region */
- JCROP_CODE crop_height_set; /* (force-disables adjustment) */
- JDIMENSION crop_xoffset; /* X offset of selected region */
- JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */
- JDIMENSION crop_yoffset; /* Y offset of selected region */
- JCROP_CODE crop_yoffset_set; /* (negative measures from bottom edge) */
-
- /* Drop parameters: set by caller for drop request */
- j_decompress_ptr drop_ptr;
- jvirt_barray_ptr *drop_coef_arrays;
-
- /* Internal workspace: caller should not touch these */
- int num_components; /* # of components in workspace */
- jvirt_barray_ptr *workspace_coef_arrays; /* workspace for transformations */
- JDIMENSION output_width; /* cropped destination dimensions */
- JDIMENSION output_height;
- JDIMENSION x_crop_offset; /* destination crop offsets measured in iMCUs */
- JDIMENSION y_crop_offset;
- JDIMENSION drop_width; /* drop/wipe dimensions measured in iMCUs */
- JDIMENSION drop_height;
- int iMCU_sample_width; /* destination iMCU size */
- int iMCU_sample_height;
-} jpeg_transform_info;
-
-
-#if TRANSFORMS_SUPPORTED
-
-/* Parse a crop specification (written in X11 geometry style) */
-EXTERN(boolean) jtransform_parse_crop_spec(jpeg_transform_info *info,
- const char *spec);
-/* Request any required workspace */
-EXTERN(boolean) jtransform_request_workspace(j_decompress_ptr srcinfo,
- jpeg_transform_info *info);
-/* Adjust output image parameters */
-EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
- (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
- jvirt_barray_ptr *src_coef_arrays, jpeg_transform_info *info);
-/* Execute the actual transformation, if any */
-EXTERN(void) jtransform_execute_transform(j_decompress_ptr srcinfo,
- j_compress_ptr dstinfo,
- jvirt_barray_ptr *src_coef_arrays,
- jpeg_transform_info *info);
-/* Determine whether lossless transformation is perfectly
- * possible for a specified image and transformation.
- */
-EXTERN(boolean) jtransform_perfect_transform(JDIMENSION image_width,
- JDIMENSION image_height,
- int MCU_width, int MCU_height,
- JXFORM_CODE transform);
-
-/* jtransform_execute_transform used to be called
- * jtransform_execute_transformation, but some compilers complain about
- * routine names that long. This macro is here to avoid breaking any
- * old source code that uses the original name...
- */
-#define jtransform_execute_transformation jtransform_execute_transform
-
-#endif /* TRANSFORMS_SUPPORTED */
-
-
-/*
- * Support for copying optional markers from source to destination file.
- */
-
-typedef enum {
- JCOPYOPT_NONE, /* copy no optional markers */
- JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
- JCOPYOPT_ALL, /* copy all optional markers */
- JCOPYOPT_ALL_EXCEPT_ICC, /* copy all optional markers except APP2 */
- JCOPYOPT_ICC /* copy only ICC profile (APP2) markers */
-} JCOPY_OPTION;
-
-#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
-
-/* Setup decompression object to save desired markers in memory */
-EXTERN(void) jcopy_markers_setup(j_decompress_ptr srcinfo,
- JCOPY_OPTION option);
-/* Copy markers saved in the given source object to the destination object */
-EXTERN(void) jcopy_markers_execute(j_decompress_ptr srcinfo,
- j_compress_ptr dstinfo,
- JCOPY_OPTION option);
+#include "src/transupp.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libjpeg-turbo/turbojpeg.c b/contrib/libs/libjpeg-turbo/turbojpeg.c
deleted file mode 100644
index a1544f2431f..00000000000
--- a/contrib/libs/libjpeg-turbo/turbojpeg.c
+++ /dev/null
@@ -1,2248 +0,0 @@
-/*
- * Copyright (C)2009-2022 D. R. Commander. All Rights Reserved.
- * Copyright (C)2021 Alex Richardson. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* TurboJPEG/LJT: this implements the TurboJPEG API using libjpeg or
- libjpeg-turbo */
-
-#include <ctype.h>
-#include <jinclude.h>
-#define JPEG_INTERNALS
-#include <jpeglib.h>
-#include <jerror.h>
-#include <setjmp.h>
-#include <errno.h>
-#include "./turbojpeg.h"
-#include "./tjutil.h"
-#include "transupp.h"
-#include "./jpegcomp.h"
-#include "./cdjpeg.h"
-#include "jconfigint.h"
-
-extern void jpeg_mem_dest_tj(j_compress_ptr, unsigned char **, unsigned long *,
- boolean);
-extern void jpeg_mem_src_tj(j_decompress_ptr, const unsigned char *,
- unsigned long);
-
-#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
-#define IS_POW2(x) (((x) & (x - 1)) == 0)
-
-
-/* Error handling (based on example in example.txt) */
-
-static THREAD_LOCAL char errStr[JMSG_LENGTH_MAX] = "No error";
-
-struct my_error_mgr {
- struct jpeg_error_mgr pub;
- jmp_buf setjmp_buffer;
- void (*emit_message) (j_common_ptr, int);
- boolean warning, stopOnWarning;
-};
-typedef struct my_error_mgr *my_error_ptr;
-
-#define JMESSAGE(code, string) string,
-static const char *turbojpeg_message_table[] = {
-#include "cderror.h"
- NULL
-};
-
-static void my_error_exit(j_common_ptr cinfo)
-{
- my_error_ptr myerr = (my_error_ptr)cinfo->err;
-
- (*cinfo->err->output_message) (cinfo);
- longjmp(myerr->setjmp_buffer, 1);
-}
-
-/* Based on output_message() in jerror.c */
-
-static void my_output_message(j_common_ptr cinfo)
-{
- (*cinfo->err->format_message) (cinfo, errStr);
-}
-
-static void my_emit_message(j_common_ptr cinfo, int msg_level)
-{
- my_error_ptr myerr = (my_error_ptr)cinfo->err;
-
- myerr->emit_message(cinfo, msg_level);
- if (msg_level < 0) {
- myerr->warning = TRUE;
- if (myerr->stopOnWarning) longjmp(myerr->setjmp_buffer, 1);
- }
-}
-
-
-/* Global structures, macros, etc. */
-
-enum { COMPRESS = 1, DECOMPRESS = 2 };
-
-typedef struct _tjinstance {
- struct jpeg_compress_struct cinfo;
- struct jpeg_decompress_struct dinfo;
- struct my_error_mgr jerr;
- int init, headerRead;
- char errStr[JMSG_LENGTH_MAX];
- boolean isInstanceError;
-} tjinstance;
-
-struct my_progress_mgr {
- struct jpeg_progress_mgr pub;
- tjinstance *this;
-};
-typedef struct my_progress_mgr *my_progress_ptr;
-
-static void my_progress_monitor(j_common_ptr dinfo)
-{
- my_error_ptr myerr = (my_error_ptr)dinfo->err;
- my_progress_ptr myprog = (my_progress_ptr)dinfo->progress;
-
- if (dinfo->is_decompressor) {
- int scan_no = ((j_decompress_ptr)dinfo)->input_scan_number;
-
- if (scan_no > 500) {
- SNPRINTF(myprog->this->errStr, JMSG_LENGTH_MAX,
- "Progressive JPEG image has more than 500 scans");
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "Progressive JPEG image has more than 500 scans");
- myprog->this->isInstanceError = TRUE;
- myerr->warning = FALSE;
- longjmp(myerr->setjmp_buffer, 1);
- }
- }
-}
-
-static const int pixelsize[TJ_NUMSAMP] = { 3, 3, 3, 1, 3, 3 };
-
-static const JXFORM_CODE xformtypes[TJ_NUMXOP] = {
- JXFORM_NONE, JXFORM_FLIP_H, JXFORM_FLIP_V, JXFORM_TRANSPOSE,
- JXFORM_TRANSVERSE, JXFORM_ROT_90, JXFORM_ROT_180, JXFORM_ROT_270
-};
-
-#define NUMSF 16
-static const tjscalingfactor sf[NUMSF] = {
- { 2, 1 },
- { 15, 8 },
- { 7, 4 },
- { 13, 8 },
- { 3, 2 },
- { 11, 8 },
- { 5, 4 },
- { 9, 8 },
- { 1, 1 },
- { 7, 8 },
- { 3, 4 },
- { 5, 8 },
- { 1, 2 },
- { 3, 8 },
- { 1, 4 },
- { 1, 8 }
-};
-
-static J_COLOR_SPACE pf2cs[TJ_NUMPF] = {
- JCS_EXT_RGB, JCS_EXT_BGR, JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
- JCS_EXT_XRGB, JCS_GRAYSCALE, JCS_EXT_RGBA, JCS_EXT_BGRA, JCS_EXT_ABGR,
- JCS_EXT_ARGB, JCS_CMYK
-};
-
-static int cs2pf[JPEG_NUMCS] = {
- TJPF_UNKNOWN, TJPF_GRAY,
-#if RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 3
- TJPF_RGB,
-#elif RGB_RED == 2 && RGB_GREEN == 1 && RGB_BLUE == 0 && RGB_PIXELSIZE == 3
- TJPF_BGR,
-#elif RGB_RED == 0 && RGB_GREEN == 1 && RGB_BLUE == 2 && RGB_PIXELSIZE == 4
- TJPF_RGBX,
-#elif RGB_RED == 2 && RGB_GREEN == 1 && RGB_BLUE == 0 && RGB_PIXELSIZE == 4
- TJPF_BGRX,
-#elif RGB_RED == 3 && RGB_GREEN == 2 && RGB_BLUE == 1 && RGB_PIXELSIZE == 4
- TJPF_XBGR,
-#elif RGB_RED == 1 && RGB_GREEN == 2 && RGB_BLUE == 3 && RGB_PIXELSIZE == 4
- TJPF_XRGB,
-#endif
- TJPF_UNKNOWN, TJPF_CMYK, TJPF_UNKNOWN, TJPF_RGB, TJPF_RGBX, TJPF_BGR,
- TJPF_BGRX, TJPF_XBGR, TJPF_XRGB, TJPF_RGBA, TJPF_BGRA, TJPF_ABGR, TJPF_ARGB,
- TJPF_UNKNOWN
-};
-
-#define THROWG(m) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s", m); \
- retval = -1; goto bailout; \
-}
-#ifdef _MSC_VER
-#define THROW_UNIX(m) { \
- char strerrorBuf[80] = { 0 }; \
- strerror_s(strerrorBuf, 80, errno); \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s\n%s", m, strerrorBuf); \
- retval = -1; goto bailout; \
-}
-#else
-#define THROW_UNIX(m) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "%s\n%s", m, strerror(errno)); \
- retval = -1; goto bailout; \
-}
-#endif
-#define THROW(m) { \
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "%s", m); \
- this->isInstanceError = TRUE; THROWG(m) \
-}
-
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-/* Private flag that triggers different TurboJPEG API behavior when fuzzing */
-#define TJFLAG_FUZZING (1 << 30)
-#endif
-
-#define GET_INSTANCE(handle) \
- tjinstance *this = (tjinstance *)handle; \
- j_compress_ptr cinfo = NULL; \
- j_decompress_ptr dinfo = NULL; \
- \
- if (!this) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
- return -1; \
- } \
- cinfo = &this->cinfo; dinfo = &this->dinfo; \
- this->jerr.warning = FALSE; \
- this->isInstanceError = FALSE;
-
-#define GET_CINSTANCE(handle) \
- tjinstance *this = (tjinstance *)handle; \
- j_compress_ptr cinfo = NULL; \
- \
- if (!this) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
- return -1; \
- } \
- cinfo = &this->cinfo; \
- this->jerr.warning = FALSE; \
- this->isInstanceError = FALSE;
-
-#define GET_DINSTANCE(handle) \
- tjinstance *this = (tjinstance *)handle; \
- j_decompress_ptr dinfo = NULL; \
- \
- if (!this) { \
- SNPRINTF(errStr, JMSG_LENGTH_MAX, "Invalid handle"); \
- return -1; \
- } \
- dinfo = &this->dinfo; \
- this->jerr.warning = FALSE; \
- this->isInstanceError = FALSE;
-
-static int getPixelFormat(int pixelSize, int flags)
-{
- if (pixelSize == 1) return TJPF_GRAY;
- if (pixelSize == 3) {
- if (flags & TJ_BGR) return TJPF_BGR;
- else return TJPF_RGB;
- }
- if (pixelSize == 4) {
- if (flags & TJ_ALPHAFIRST) {
- if (flags & TJ_BGR) return TJPF_XBGR;
- else return TJPF_XRGB;
- } else {
- if (flags & TJ_BGR) return TJPF_BGRX;
- else return TJPF_RGBX;
- }
- }
- return -1;
-}
-
-static void setCompDefaults(struct jpeg_compress_struct *cinfo,
- int pixelFormat, int subsamp, int jpegQual,
- int flags)
-{
-#ifndef NO_GETENV
- char env[7] = { 0 };
-#endif
-
- cinfo->in_color_space = pf2cs[pixelFormat];
- cinfo->input_components = tjPixelSize[pixelFormat];
- jpeg_set_defaults(cinfo);
-
-#ifndef NO_GETENV
- if (!GETENV_S(env, 7, "TJ_OPTIMIZE") && !strcmp(env, "1"))
- cinfo->optimize_coding = TRUE;
- if (!GETENV_S(env, 7, "TJ_ARITHMETIC") && !strcmp(env, "1"))
- cinfo->arith_code = TRUE;
- if (!GETENV_S(env, 7, "TJ_RESTART") && strlen(env) > 0) {
- int temp = -1;
- char tempc = 0;
-
-#ifdef _MSC_VER
- if (sscanf_s(env, "%d%c", &temp, &tempc, 1) >= 1 && temp >= 0 &&
- temp <= 65535) {
-#else
- if (sscanf(env, "%d%c", &temp, &tempc) >= 1 && temp >= 0 &&
- temp <= 65535) {
-#endif
- if (toupper(tempc) == 'B') {
- cinfo->restart_interval = temp;
- cinfo->restart_in_rows = 0;
- } else
- cinfo->restart_in_rows = temp;
- }
- }
-#endif
-
- if (jpegQual >= 0) {
- jpeg_set_quality(cinfo, jpegQual, TRUE);
- if (jpegQual >= 96 || flags & TJFLAG_ACCURATEDCT)
- cinfo->dct_method = JDCT_ISLOW;
- else
- cinfo->dct_method = JDCT_FASTEST;
- }
- if (subsamp == TJSAMP_GRAY)
- jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
- else if (pixelFormat == TJPF_CMYK)
- jpeg_set_colorspace(cinfo, JCS_YCCK);
- else
- jpeg_set_colorspace(cinfo, JCS_YCbCr);
-
- if (flags & TJFLAG_PROGRESSIVE)
- jpeg_simple_progression(cinfo);
-#ifndef NO_GETENV
- else if (!GETENV_S(env, 7, "TJ_PROGRESSIVE") && !strcmp(env, "1"))
- jpeg_simple_progression(cinfo);
-#endif
-
- cinfo->comp_info[0].h_samp_factor = tjMCUWidth[subsamp] / 8;
- cinfo->comp_info[1].h_samp_factor = 1;
- cinfo->comp_info[2].h_samp_factor = 1;
- if (cinfo->num_components > 3)
- cinfo->comp_info[3].h_samp_factor = tjMCUWidth[subsamp] / 8;
- cinfo->comp_info[0].v_samp_factor = tjMCUHeight[subsamp] / 8;
- cinfo->comp_info[1].v_samp_factor = 1;
- cinfo->comp_info[2].v_samp_factor = 1;
- if (cinfo->num_components > 3)
- cinfo->comp_info[3].v_samp_factor = tjMCUHeight[subsamp] / 8;
-}
-
-
-static int getSubsamp(j_decompress_ptr dinfo)
-{
- int retval = -1, i, k;
-
- /* The sampling factors actually have no meaning with grayscale JPEG files,
- and in fact it's possible to generate grayscale JPEGs with sampling
- factors > 1 (even though those sampling factors are ignored by the
- decompressor.) Thus, we need to treat grayscale as a special case. */
- if (dinfo->num_components == 1 && dinfo->jpeg_color_space == JCS_GRAYSCALE)
- return TJSAMP_GRAY;
-
- for (i = 0; i < NUMSUBOPT; i++) {
- if (dinfo->num_components == pixelsize[i] ||
- ((dinfo->jpeg_color_space == JCS_YCCK ||
- dinfo->jpeg_color_space == JCS_CMYK) &&
- pixelsize[i] == 3 && dinfo->num_components == 4)) {
- if (dinfo->comp_info[0].h_samp_factor == tjMCUWidth[i] / 8 &&
- dinfo->comp_info[0].v_samp_factor == tjMCUHeight[i] / 8) {
- int match = 0;
-
- for (k = 1; k < dinfo->num_components; k++) {
- int href = 1, vref = 1;
-
- if ((dinfo->jpeg_color_space == JCS_YCCK ||
- dinfo->jpeg_color_space == JCS_CMYK) && k == 3) {
- href = tjMCUWidth[i] / 8; vref = tjMCUHeight[i] / 8;
- }
- if (dinfo->comp_info[k].h_samp_factor == href &&
- dinfo->comp_info[k].v_samp_factor == vref)
- match++;
- }
- if (match == dinfo->num_components - 1) {
- retval = i; break;
- }
- }
- /* Handle 4:2:2 and 4:4:0 images whose sampling factors are specified
- in non-standard ways. */
- if (dinfo->comp_info[0].h_samp_factor == 2 &&
- dinfo->comp_info[0].v_samp_factor == 2 &&
- (i == TJSAMP_422 || i == TJSAMP_440)) {
- int match = 0;
-
- for (k = 1; k < dinfo->num_components; k++) {
- int href = tjMCUHeight[i] / 8, vref = tjMCUWidth[i] / 8;
-
- if ((dinfo->jpeg_color_space == JCS_YCCK ||
- dinfo->jpeg_color_space == JCS_CMYK) && k == 3) {
- href = vref = 2;
- }
- if (dinfo->comp_info[k].h_samp_factor == href &&
- dinfo->comp_info[k].v_samp_factor == vref)
- match++;
- }
- if (match == dinfo->num_components - 1) {
- retval = i; break;
- }
- }
- /* Handle 4:4:4 images whose sampling factors are specified in
- non-standard ways. */
- if (dinfo->comp_info[0].h_samp_factor *
- dinfo->comp_info[0].v_samp_factor <=
- D_MAX_BLOCKS_IN_MCU / pixelsize[i] && i == TJSAMP_444) {
- int match = 0;
- for (k = 1; k < dinfo->num_components; k++) {
- if (dinfo->comp_info[k].h_samp_factor ==
- dinfo->comp_info[0].h_samp_factor &&
- dinfo->comp_info[k].v_samp_factor ==
- dinfo->comp_info[0].v_samp_factor)
- match++;
- if (match == dinfo->num_components - 1) {
- retval = i; break;
- }
- }
- }
- }
- }
- return retval;
-}
-
-
-/* General API functions */
-
-DLLEXPORT char *tjGetErrorStr2(tjhandle handle)
-{
- tjinstance *this = (tjinstance *)handle;
-
- if (this && this->isInstanceError) {
- this->isInstanceError = FALSE;
- return this->errStr;
- } else
- return errStr;
-}
-
-
-DLLEXPORT char *tjGetErrorStr(void)
-{
- return errStr;
-}
-
-
-DLLEXPORT int tjGetErrorCode(tjhandle handle)
-{
- tjinstance *this = (tjinstance *)handle;
-
- if (this && this->jerr.warning) return TJERR_WARNING;
- else return TJERR_FATAL;
-}
-
-
-DLLEXPORT int tjDestroy(tjhandle handle)
-{
- GET_INSTANCE(handle);
-
- if (setjmp(this->jerr.setjmp_buffer)) return -1;
- if (this->init & COMPRESS) jpeg_destroy_compress(cinfo);
- if (this->init & DECOMPRESS) jpeg_destroy_decompress(dinfo);
- free(this);
- return 0;
-}
-
-
-/* These are exposed mainly because Windows can't malloc() and free() across
- DLL boundaries except when the CRT DLL is used, and we don't use the CRT DLL
- with turbojpeg.dll for compatibility reasons. However, these functions
- can potentially be used for other purposes by different implementations. */
-
-DLLEXPORT void tjFree(unsigned char *buf)
-{
- free(buf);
-}
-
-
-DLLEXPORT unsigned char *tjAlloc(int bytes)
-{
- return (unsigned char *)malloc(bytes);
-}
-
-
-/* Compressor */
-
-static tjhandle _tjInitCompress(tjinstance *this)
-{
- static unsigned char buffer[1];
- unsigned char *buf = buffer;
- unsigned long size = 1;
-
- /* This is also straight out of example.txt */
- this->cinfo.err = jpeg_std_error(&this->jerr.pub);
- this->jerr.pub.error_exit = my_error_exit;
- this->jerr.pub.output_message = my_output_message;
- this->jerr.emit_message = this->jerr.pub.emit_message;
- this->jerr.pub.emit_message = my_emit_message;
- this->jerr.pub.addon_message_table = turbojpeg_message_table;
- this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
- this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- free(this);
- return NULL;
- }
-
- jpeg_create_compress(&this->cinfo);
- /* Make an initial call so it will create the destination manager */
- jpeg_mem_dest_tj(&this->cinfo, &buf, &size, 0);
-
- this->init |= COMPRESS;
- return (tjhandle)this;
-}
-
-DLLEXPORT tjhandle tjInitCompress(void)
-{
- tjinstance *this = NULL;
-
- if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjInitCompress(): Memory allocation failure");
- return NULL;
- }
- memset(this, 0, sizeof(tjinstance));
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
- return _tjInitCompress(this);
-}
-
-
-DLLEXPORT unsigned long tjBufSize(int width, int height, int jpegSubsamp)
-{
- unsigned long long retval = 0;
- int mcuw, mcuh, chromasf;
-
- if (width < 1 || height < 1 || jpegSubsamp < 0 || jpegSubsamp >= NUMSUBOPT)
- THROWG("tjBufSize(): Invalid argument");
-
- /* This allows for rare corner cases in which a JPEG image can actually be
- larger than the uncompressed input (we wouldn't mention it if it hadn't
- happened before.) */
- mcuw = tjMCUWidth[jpegSubsamp];
- mcuh = tjMCUHeight[jpegSubsamp];
- chromasf = jpegSubsamp == TJSAMP_GRAY ? 0 : 4 * 64 / (mcuw * mcuh);
- retval = PAD(width, mcuw) * PAD(height, mcuh) * (2ULL + chromasf) + 2048ULL;
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("tjBufSize(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-DLLEXPORT unsigned long TJBUFSIZE(int width, int height)
-{
- unsigned long long retval = 0;
-
- if (width < 1 || height < 1)
- THROWG("TJBUFSIZE(): Invalid argument");
-
- /* This allows for rare corner cases in which a JPEG image can actually be
- larger than the uncompressed input (we wouldn't mention it if it hadn't
- happened before.) */
- retval = PAD(width, 16) * PAD(height, 16) * 6ULL + 2048ULL;
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("TJBUFSIZE(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-
-DLLEXPORT unsigned long tjBufSizeYUV2(int width, int pad, int height,
- int subsamp)
-{
- unsigned long long retval = 0;
- int nc, i;
-
- if (subsamp < 0 || subsamp >= NUMSUBOPT)
- THROWG("tjBufSizeYUV2(): Invalid argument");
-
- nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
- for (i = 0; i < nc; i++) {
- int pw = tjPlaneWidth(i, width, subsamp);
- int stride = PAD(pw, pad);
- int ph = tjPlaneHeight(i, height, subsamp);
-
- if (pw < 0 || ph < 0) return -1;
- else retval += (unsigned long long)stride * ph;
- }
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("tjBufSizeYUV2(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-DLLEXPORT unsigned long tjBufSizeYUV(int width, int height, int subsamp)
-{
- return tjBufSizeYUV2(width, 4, height, subsamp);
-}
-
-DLLEXPORT unsigned long TJBUFSIZEYUV(int width, int height, int subsamp)
-{
- return tjBufSizeYUV(width, height, subsamp);
-}
-
-
-DLLEXPORT int tjPlaneWidth(int componentID, int width, int subsamp)
-{
- int pw, nc, retval = 0;
-
- if (width < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROWG("tjPlaneWidth(): Invalid argument");
- nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
- if (componentID < 0 || componentID >= nc)
- THROWG("tjPlaneWidth(): Invalid argument");
-
- pw = PAD(width, tjMCUWidth[subsamp] / 8);
- if (componentID == 0)
- retval = pw;
- else
- retval = pw * 8 / tjMCUWidth[subsamp];
-
-bailout:
- return retval;
-}
-
-
-DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp)
-{
- int ph, nc, retval = 0;
-
- if (height < 1 || subsamp < 0 || subsamp >= TJ_NUMSAMP)
- THROWG("tjPlaneHeight(): Invalid argument");
- nc = (subsamp == TJSAMP_GRAY ? 1 : 3);
- if (componentID < 0 || componentID >= nc)
- THROWG("tjPlaneHeight(): Invalid argument");
-
- ph = PAD(height, tjMCUHeight[subsamp] / 8);
- if (componentID == 0)
- retval = ph;
- else
- retval = ph * 8 / tjMCUHeight[subsamp];
-
-bailout:
- return retval;
-}
-
-
-DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
- int height, int subsamp)
-{
- unsigned long long retval = 0;
- int pw, ph;
-
- if (width < 1 || height < 1 || subsamp < 0 || subsamp >= NUMSUBOPT)
- THROWG("tjPlaneSizeYUV(): Invalid argument");
-
- pw = tjPlaneWidth(componentID, width, subsamp);
- ph = tjPlaneHeight(componentID, height, subsamp);
- if (pw < 0 || ph < 0) return -1;
-
- if (stride == 0) stride = pw;
- else stride = abs(stride);
-
- retval = (unsigned long long)stride * (ph - 1) + pw;
- if (retval > (unsigned long long)((unsigned long)-1))
- THROWG("tjPlaneSizeYUV(): Image is too large");
-
-bailout:
- return (unsigned long)retval;
-}
-
-
-DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char **jpegBuf, unsigned long *jpegSize,
- int jpegSubsamp, int jpegQual, int flags)
-{
- int i, retval = 0;
- boolean alloc = TRUE;
- JSAMPROW *row_pointer = NULL;
-
- GET_CINSTANCE(handle)
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
- if ((this->init & COMPRESS) == 0)
- THROW("tjCompress2(): Instance has not been initialized for compression");
-
- if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF || jpegBuf == NULL ||
- jpegSize == NULL || jpegSubsamp < 0 || jpegSubsamp >= NUMSUBOPT ||
- jpegQual < 0 || jpegQual > 100)
- THROW("tjCompress2(): Invalid argument");
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
-
- if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * height)) == NULL)
- THROW("tjCompress2(): Memory allocation failure");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- cinfo->image_width = width;
- cinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_NOREALLOC) {
- alloc = FALSE; *jpegSize = tjBufSize(width, height, jpegSubsamp);
- }
- jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
- setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual, flags);
-
- jpeg_start_compress(cinfo, TRUE);
- for (i = 0; i < height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = (JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = (JSAMPROW)&srcBuf[i * (size_t)pitch];
- }
- while (cinfo->next_scanline < cinfo->image_height)
- jpeg_write_scanlines(cinfo, &row_pointer[cinfo->next_scanline],
- cinfo->image_height - cinfo->next_scanline);
- jpeg_finish_compress(cinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
- jpeg_abort_compress(cinfo);
- }
- free(row_pointer);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjCompress(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *jpegBuf, unsigned long *jpegSize,
- int jpegSubsamp, int jpegQual, int flags)
-{
- int retval = 0;
- unsigned long size;
-
- if (flags & TJ_YUV) {
- size = tjBufSizeYUV(width, height, jpegSubsamp);
- retval = tjEncodeYUV2(handle, srcBuf, width, pitch, height,
- getPixelFormat(pixelSize, flags), jpegBuf,
- jpegSubsamp, flags);
- } else {
- retval = tjCompress2(handle, srcBuf, width, pitch, height,
- getPixelFormat(pixelSize, flags), &jpegBuf, &size,
- jpegSubsamp, jpegQual, flags | TJFLAG_NOREALLOC);
- }
- *jpegSize = size;
- return retval;
-}
-
-
-DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height,
- int pixelFormat, unsigned char **dstPlanes,
- int *strides, int subsamp, int flags)
-{
- JSAMPROW *row_pointer = NULL;
- JSAMPLE *_tmpbuf[MAX_COMPONENTS], *_tmpbuf2[MAX_COMPONENTS];
- JSAMPROW *tmpbuf[MAX_COMPONENTS], *tmpbuf2[MAX_COMPONENTS];
- JSAMPROW *outbuf[MAX_COMPONENTS];
- int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
- JSAMPLE *ptr;
- jpeg_component_info *compptr;
-
- GET_CINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; _tmpbuf[i] = NULL;
- tmpbuf2[i] = NULL; _tmpbuf2[i] = NULL; outbuf[i] = NULL;
- }
-
- if ((this->init & COMPRESS) == 0)
- THROW("tjEncodeYUVPlanes(): Instance has not been initialized for compression");
-
- if (srcBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF || !dstPlanes ||
- !dstPlanes[0] || subsamp < 0 || subsamp >= NUMSUBOPT)
- THROW("tjEncodeYUVPlanes(): Invalid argument");
- if (subsamp != TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
- THROW("tjEncodeYUVPlanes(): Invalid argument");
-
- if (pixelFormat == TJPF_CMYK)
- THROW("tjEncodeYUVPlanes(): Cannot generate YUV images from CMYK pixels");
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- cinfo->image_width = width;
- cinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- setCompDefaults(cinfo, pixelFormat, subsamp, -1, flags);
-
- /* Execute only the parts of jpeg_start_compress() that we need. If we
- were to call the whole jpeg_start_compress() function, then it would try
- to write the file headers, which could overflow the output buffer if the
- YUV image were very small. */
- if (cinfo->global_state != CSTATE_START)
- THROW("tjEncodeYUVPlanes(): libjpeg API is in the wrong state");
- (*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
- jinit_c_master_control(cinfo, FALSE);
- jinit_color_converter(cinfo);
- jinit_downsampler(cinfo);
- (*cinfo->cconvert->start_pass) (cinfo);
-
- pw0 = PAD(width, cinfo->max_h_samp_factor);
- ph0 = PAD(height, cinfo->max_v_samp_factor);
-
- if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- for (i = 0; i < height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = (JSAMPROW)&srcBuf[(height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = (JSAMPROW)&srcBuf[i * (size_t)pitch];
- }
- if (height < ph0)
- for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
-
- for (i = 0; i < cinfo->num_components; i++) {
- compptr = &cinfo->comp_info[i];
- _tmpbuf[i] = (JSAMPLE *)malloc(
- PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
- compptr->h_samp_factor, 32) *
- cinfo->max_v_samp_factor + 32);
- if (!_tmpbuf[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- tmpbuf[i] =
- (JSAMPROW *)malloc(sizeof(JSAMPROW) * cinfo->max_v_samp_factor);
- if (!tmpbuf[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- for (row = 0; row < cinfo->max_v_samp_factor; row++) {
- unsigned char *_tmpbuf_aligned =
- (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
-
- tmpbuf[i][row] = &_tmpbuf_aligned[
- PAD((compptr->width_in_blocks * cinfo->max_h_samp_factor * DCTSIZE) /
- compptr->h_samp_factor, 32) * row];
- }
- _tmpbuf2[i] =
- (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
- compptr->v_samp_factor + 32);
- if (!_tmpbuf2[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- tmpbuf2[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
- if (!tmpbuf2[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- for (row = 0; row < compptr->v_samp_factor; row++) {
- unsigned char *_tmpbuf2_aligned =
- (unsigned char *)PAD((JUINTPTR)_tmpbuf2[i], 32);
-
- tmpbuf2[i][row] =
- &_tmpbuf2_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
- }
- pw[i] = pw0 * compptr->h_samp_factor / cinfo->max_h_samp_factor;
- ph[i] = ph0 * compptr->v_samp_factor / cinfo->max_v_samp_factor;
- outbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
- if (!outbuf[i])
- THROW("tjEncodeYUVPlanes(): Memory allocation failure");
- ptr = dstPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- outbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < ph0; row += cinfo->max_v_samp_factor) {
- (*cinfo->cconvert->color_convert) (cinfo, &row_pointer[row], tmpbuf, 0,
- cinfo->max_v_samp_factor);
- (cinfo->downsample->downsample) (cinfo, tmpbuf, 0, tmpbuf2, 0);
- for (i = 0, compptr = cinfo->comp_info; i < cinfo->num_components;
- i++, compptr++)
- jcopy_sample_rows(tmpbuf2[i], 0, outbuf[i],
- row * compptr->v_samp_factor / cinfo->max_v_samp_factor,
- compptr->v_samp_factor, pw[i]);
- }
- cinfo->next_scanline += height;
- jpeg_abort_compress(cinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) jpeg_abort_compress(cinfo);
- free(row_pointer);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(_tmpbuf[i]);
- free(tmpbuf2[i]);
- free(_tmpbuf2[i]);
- free(outbuf[i]);
- }
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjEncodeYUV3(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int pad, int subsamp,
- int flags)
-{
- unsigned char *dstPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
- tjinstance *this = (tjinstance *)handle;
-
- if (!this) THROWG("tjEncodeYUV3(): Invalid handle");
- this->isInstanceError = FALSE;
-
- if (width <= 0 || height <= 0 || dstBuf == NULL || pad < 0 ||
- !IS_POW2(pad) || subsamp < 0 || subsamp >= NUMSUBOPT)
- THROW("tjEncodeYUV3(): Invalid argument");
-
- pw0 = tjPlaneWidth(0, width, subsamp);
- ph0 = tjPlaneHeight(0, height, subsamp);
- dstPlanes[0] = dstBuf;
- strides[0] = PAD(pw0, pad);
- if (subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- dstPlanes[1] = dstPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, subsamp);
- int ph1 = tjPlaneHeight(1, height, subsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
- dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
- }
-
- return tjEncodeYUVPlanes(handle, srcBuf, width, pitch, height, pixelFormat,
- dstPlanes, strides, subsamp, flags);
-
-bailout:
- return retval;
-}
-
-DLLEXPORT int tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int subsamp, int flags)
-{
- return tjEncodeYUV3(handle, srcBuf, width, pitch, height, pixelFormat,
- dstBuf, 4, subsamp, flags);
-}
-
-DLLEXPORT int tjEncodeYUV(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *dstBuf, int subsamp, int flags)
-{
- return tjEncodeYUV2(handle, srcBuf, width, pitch, height,
- getPixelFormat(pixelSize, flags), dstBuf, subsamp,
- flags);
-}
-
-
-DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- int width, const int *strides,
- int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags)
-{
- int i, row, retval = 0;
- boolean alloc = TRUE;
- int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
- tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
- JSAMPLE *_tmpbuf = NULL, *ptr;
- JSAMPROW *inbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
-
- GET_CINSTANCE(handle)
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; inbuf[i] = NULL;
- }
-
- if ((this->init & COMPRESS) == 0)
- THROW("tjCompressFromYUVPlanes(): Instance has not been initialized for compression");
-
- if (!srcPlanes || !srcPlanes[0] || width <= 0 || height <= 0 ||
- subsamp < 0 || subsamp >= NUMSUBOPT || jpegBuf == NULL ||
- jpegSize == NULL || jpegQual < 0 || jpegQual > 100)
- THROW("tjCompressFromYUVPlanes(): Invalid argument");
- if (subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
- THROW("tjCompressFromYUVPlanes(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- cinfo->image_width = width;
- cinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_NOREALLOC) {
- alloc = FALSE; *jpegSize = tjBufSize(width, height, subsamp);
- }
- jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
- setCompDefaults(cinfo, TJPF_RGB, subsamp, jpegQual, flags);
- cinfo->raw_data_in = TRUE;
-
- jpeg_start_compress(cinfo, TRUE);
- for (i = 0; i < cinfo->num_components; i++) {
- jpeg_component_info *compptr = &cinfo->comp_info[i];
- int ih;
-
- iw[i] = compptr->width_in_blocks * DCTSIZE;
- ih = compptr->height_in_blocks * DCTSIZE;
- pw[i] = PAD(cinfo->image_width, cinfo->max_h_samp_factor) *
- compptr->h_samp_factor / cinfo->max_h_samp_factor;
- ph[i] = PAD(cinfo->image_height, cinfo->max_v_samp_factor) *
- compptr->v_samp_factor / cinfo->max_v_samp_factor;
- if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
- th[i] = compptr->v_samp_factor * DCTSIZE;
- tmpbufsize += iw[i] * th[i];
- if ((inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
- THROW("tjCompressFromYUVPlanes(): Memory allocation failure");
- ptr = (JSAMPLE *)srcPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- inbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
- if (usetmpbuf) {
- if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
- THROW("tjCompressFromYUVPlanes(): Memory allocation failure");
- ptr = _tmpbuf;
- for (i = 0; i < cinfo->num_components; i++) {
- if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
- THROW("tjCompressFromYUVPlanes(): Memory allocation failure");
- for (row = 0; row < th[i]; row++) {
- tmpbuf[i][row] = ptr;
- ptr += iw[i];
- }
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < (int)cinfo->image_height;
- row += cinfo->max_v_samp_factor * DCTSIZE) {
- JSAMPARRAY yuvptr[MAX_COMPONENTS];
- int crow[MAX_COMPONENTS];
-
- for (i = 0; i < cinfo->num_components; i++) {
- jpeg_component_info *compptr = &cinfo->comp_info[i];
-
- crow[i] = row * compptr->v_samp_factor / cinfo->max_v_samp_factor;
- if (usetmpbuf) {
- int j, k;
-
- for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
- memcpy(tmpbuf[i][j], inbuf[i][crow[i] + j], pw[i]);
- /* Duplicate last sample in row to fill out MCU */
- for (k = pw[i]; k < iw[i]; k++)
- tmpbuf[i][j][k] = tmpbuf[i][j][pw[i] - 1];
- }
- /* Duplicate last row to fill out MCU */
- for (j = ph[i] - crow[i]; j < th[i]; j++)
- memcpy(tmpbuf[i][j], tmpbuf[i][ph[i] - crow[i] - 1], iw[i]);
- yuvptr[i] = tmpbuf[i];
- } else
- yuvptr[i] = &inbuf[i][crow[i]];
- }
- jpeg_write_raw_data(cinfo, yuvptr, cinfo->max_v_samp_factor * DCTSIZE);
- }
- jpeg_finish_compress(cinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
- jpeg_abort_compress(cinfo);
- }
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(inbuf[i]);
- }
- free(_tmpbuf);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
- int width, int pad, int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags)
-{
- const unsigned char *srcPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
- tjinstance *this = (tjinstance *)handle;
-
- if (!this) THROWG("tjCompressFromYUV(): Invalid handle");
- this->isInstanceError = FALSE;
-
- if (srcBuf == NULL || width <= 0 || pad < 1 || height <= 0 || subsamp < 0 ||
- subsamp >= NUMSUBOPT)
- THROW("tjCompressFromYUV(): Invalid argument");
-
- pw0 = tjPlaneWidth(0, width, subsamp);
- ph0 = tjPlaneHeight(0, height, subsamp);
- srcPlanes[0] = srcBuf;
- strides[0] = PAD(pw0, pad);
- if (subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- srcPlanes[1] = srcPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, subsamp);
- int ph1 = tjPlaneHeight(1, height, subsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
- srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
- }
-
- return tjCompressFromYUVPlanes(handle, srcPlanes, width, strides, height,
- subsamp, jpegBuf, jpegSize, jpegQual, flags);
-
-bailout:
- return retval;
-}
-
-
-/* Decompressor */
-
-static tjhandle _tjInitDecompress(tjinstance *this)
-{
- static unsigned char buffer[1];
-
- /* This is also straight out of example.txt */
- this->dinfo.err = jpeg_std_error(&this->jerr.pub);
- this->jerr.pub.error_exit = my_error_exit;
- this->jerr.pub.output_message = my_output_message;
- this->jerr.emit_message = this->jerr.pub.emit_message;
- this->jerr.pub.emit_message = my_emit_message;
- this->jerr.pub.addon_message_table = turbojpeg_message_table;
- this->jerr.pub.first_addon_message = JMSG_FIRSTADDONCODE;
- this->jerr.pub.last_addon_message = JMSG_LASTADDONCODE;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- free(this);
- return NULL;
- }
-
- jpeg_create_decompress(&this->dinfo);
- /* Make an initial call so it will create the source manager */
- jpeg_mem_src_tj(&this->dinfo, buffer, 1);
-
- this->init |= DECOMPRESS;
- return (tjhandle)this;
-}
-
-DLLEXPORT tjhandle tjInitDecompress(void)
-{
- tjinstance *this;
-
- if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjInitDecompress(): Memory allocation failure");
- return NULL;
- }
- memset(this, 0, sizeof(tjinstance));
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
- return _tjInitDecompress(this);
-}
-
-
-DLLEXPORT int tjDecompressHeader3(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp,
- int *jpegColorspace)
-{
- int retval = 0;
-
- GET_DINSTANCE(handle);
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecompressHeader3(): Instance has not been initialized for decompression");
-
- if (jpegBuf == NULL || jpegSize <= 0 || width == NULL || height == NULL ||
- jpegSubsamp == NULL || jpegColorspace == NULL)
- THROW("tjDecompressHeader3(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- return -1;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
-
- /* jpeg_read_header() calls jpeg_abort() and returns JPEG_HEADER_TABLES_ONLY
- if the datastream is a tables-only datastream. Since we aren't using a
- suspending data source, the only other value it can return is
- JPEG_HEADER_OK. */
- if (jpeg_read_header(dinfo, FALSE) == JPEG_HEADER_TABLES_ONLY)
- return 0;
-
- *width = dinfo->image_width;
- *height = dinfo->image_height;
- *jpegSubsamp = getSubsamp(dinfo);
- switch (dinfo->jpeg_color_space) {
- case JCS_GRAYSCALE: *jpegColorspace = TJCS_GRAY; break;
- case JCS_RGB: *jpegColorspace = TJCS_RGB; break;
- case JCS_YCbCr: *jpegColorspace = TJCS_YCbCr; break;
- case JCS_CMYK: *jpegColorspace = TJCS_CMYK; break;
- case JCS_YCCK: *jpegColorspace = TJCS_YCCK; break;
- default: *jpegColorspace = -1; break;
- }
-
- jpeg_abort_decompress(dinfo);
-
- if (*jpegSubsamp < 0)
- THROW("tjDecompressHeader3(): Could not determine subsampling type for JPEG image");
- if (*jpegColorspace < 0)
- THROW("tjDecompressHeader3(): Could not determine colorspace of JPEG image");
- if (*width < 1 || *height < 1)
- THROW("tjDecompressHeader3(): Invalid data returned in header");
-
-bailout:
- if (this->jerr.warning) retval = -1;
- return retval;
-}
-
-DLLEXPORT int tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp)
-{
- int jpegColorspace;
-
- return tjDecompressHeader3(handle, jpegBuf, jpegSize, width, height,
- jpegSubsamp, &jpegColorspace);
-}
-
-DLLEXPORT int tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height)
-{
- int jpegSubsamp;
-
- return tjDecompressHeader2(handle, jpegBuf, jpegSize, width, height,
- &jpegSubsamp);
-}
-
-
-DLLEXPORT tjscalingfactor *tjGetScalingFactors(int *numscalingfactors)
-{
- if (numscalingfactors == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjGetScalingFactors(): Invalid argument");
- return NULL;
- }
-
- *numscalingfactors = NUMSF;
- return (tjscalingfactor *)sf;
-}
-
-
-DLLEXPORT int tjDecompress2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags)
-{
- JSAMPROW *row_pointer = NULL;
- int i, retval = 0, jpegwidth, jpegheight, scaledw, scaledh;
- struct my_progress_mgr progress;
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecompress2(): Instance has not been initialized for decompression");
-
- if (jpegBuf == NULL || jpegSize <= 0 || dstBuf == NULL || width < 0 ||
- pitch < 0 || height < 0 || pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
- THROW("tjDecompress2(): Invalid argument");
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_LIMITSCANS) {
- memset(&progress, 0, sizeof(struct my_progress_mgr));
- progress.pub.progress_monitor = my_progress_monitor;
- progress.this = this;
- dinfo->progress = &progress.pub;
- } else
- dinfo->progress = NULL;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
- this->dinfo.out_color_space = pf2cs[pixelFormat];
- if (flags & TJFLAG_FASTDCT) this->dinfo.dct_method = JDCT_FASTEST;
- if (flags & TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling = FALSE;
-
- jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
- if (width == 0) width = jpegwidth;
- if (height == 0) height = jpegheight;
- for (i = 0; i < NUMSF; i++) {
- scaledw = TJSCALED(jpegwidth, sf[i]);
- scaledh = TJSCALED(jpegheight, sf[i]);
- if (scaledw <= width && scaledh <= height)
- break;
- }
- if (i >= NUMSF)
- THROW("tjDecompress2(): Could not scale down to desired image dimensions");
- width = scaledw; height = scaledh;
- dinfo->scale_num = sf[i].num;
- dinfo->scale_denom = sf[i].denom;
-
- jpeg_start_decompress(dinfo);
- if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
-
- if ((row_pointer =
- (JSAMPROW *)malloc(sizeof(JSAMPROW) * dinfo->output_height)) == NULL)
- THROW("tjDecompress2(): Memory allocation failure");
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
- for (i = 0; i < (int)dinfo->output_height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = &dstBuf[(dinfo->output_height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = &dstBuf[i * (size_t)pitch];
- }
- while (dinfo->output_scanline < dinfo->output_height)
- jpeg_read_scanlines(dinfo, &row_pointer[dinfo->output_scanline],
- dinfo->output_height - dinfo->output_scanline);
- jpeg_finish_decompress(dinfo);
-
-bailout:
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- free(row_pointer);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecompress(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelSize,
- int flags)
-{
- if (flags & TJ_YUV)
- return tjDecompressToYUV(handle, jpegBuf, jpegSize, dstBuf, flags);
- else
- return tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, width, pitch,
- height, getPixelFormat(pixelSize, flags), flags);
-}
-
-
-static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo,
- int pixelFormat, int subsamp, int flags)
-{
- int i;
-
- dinfo->scale_num = dinfo->scale_denom = 1;
-
- if (subsamp == TJSAMP_GRAY) {
- dinfo->num_components = dinfo->comps_in_scan = 1;
- dinfo->jpeg_color_space = JCS_GRAYSCALE;
- } else {
- dinfo->num_components = dinfo->comps_in_scan = 3;
- dinfo->jpeg_color_space = JCS_YCbCr;
- }
-
- dinfo->comp_info = (jpeg_component_info *)
- (*dinfo->mem->alloc_small) ((j_common_ptr)dinfo, JPOOL_IMAGE,
- dinfo->num_components *
- sizeof(jpeg_component_info));
-
- for (i = 0; i < dinfo->num_components; i++) {
- jpeg_component_info *compptr = &dinfo->comp_info[i];
-
- compptr->h_samp_factor = (i == 0) ? tjMCUWidth[subsamp] / 8 : 1;
- compptr->v_samp_factor = (i == 0) ? tjMCUHeight[subsamp] / 8 : 1;
- compptr->component_index = i;
- compptr->component_id = i + 1;
- compptr->quant_tbl_no = compptr->dc_tbl_no =
- compptr->ac_tbl_no = (i == 0) ? 0 : 1;
- dinfo->cur_comp_info[i] = compptr;
- }
- dinfo->data_precision = 8;
- for (i = 0; i < 2; i++) {
- if (dinfo->quant_tbl_ptrs[i] == NULL)
- dinfo->quant_tbl_ptrs[i] = jpeg_alloc_quant_table((j_common_ptr)dinfo);
- }
-
- return 0;
-}
-
-
-static int my_read_markers(j_decompress_ptr dinfo)
-{
- return JPEG_REACHED_SOS;
-}
-
-static void my_reset_marker_reader(j_decompress_ptr dinfo)
-{
-}
-
-DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- const int *strides, int subsamp,
- unsigned char *dstBuf, int width, int pitch,
- int height, int pixelFormat, int flags)
-{
- JSAMPROW *row_pointer = NULL;
- JSAMPLE *_tmpbuf[MAX_COMPONENTS];
- JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS];
- int i, retval = 0, row, pw0, ph0, pw[MAX_COMPONENTS], ph[MAX_COMPONENTS];
- JSAMPLE *ptr;
- jpeg_component_info *compptr;
- int (*old_read_markers) (j_decompress_ptr);
- void (*old_reset_marker_reader) (j_decompress_ptr);
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; _tmpbuf[i] = NULL; inbuf[i] = NULL;
- }
-
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecodeYUVPlanes(): Instance has not been initialized for decompression");
-
- if (!srcPlanes || !srcPlanes[0] || subsamp < 0 || subsamp >= NUMSUBOPT ||
- dstBuf == NULL || width <= 0 || pitch < 0 || height <= 0 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
- THROW("tjDecodeYUVPlanes(): Invalid argument");
- if (subsamp != TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
- THROW("tjDecodeYUVPlanes(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (pixelFormat == TJPF_CMYK)
- THROW("tjDecodeYUVPlanes(): Cannot decode YUV images into CMYK pixels.");
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
- dinfo->image_width = width;
- dinfo->image_height = height;
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- dinfo->progressive_mode = dinfo->inputctl->has_multiple_scans = FALSE;
- dinfo->Ss = dinfo->Ah = dinfo->Al = 0;
- dinfo->Se = DCTSIZE2 - 1;
- if (setDecodeDefaults(dinfo, pixelFormat, subsamp, flags) == -1) {
- retval = -1; goto bailout;
- }
- old_read_markers = dinfo->marker->read_markers;
- dinfo->marker->read_markers = my_read_markers;
- old_reset_marker_reader = dinfo->marker->reset_marker_reader;
- dinfo->marker->reset_marker_reader = my_reset_marker_reader;
- jpeg_read_header(dinfo, TRUE);
- dinfo->marker->read_markers = old_read_markers;
- dinfo->marker->reset_marker_reader = old_reset_marker_reader;
-
- this->dinfo.out_color_space = pf2cs[pixelFormat];
- if (flags & TJFLAG_FASTDCT) this->dinfo.dct_method = JDCT_FASTEST;
- dinfo->do_fancy_upsampling = FALSE;
- dinfo->Se = DCTSIZE2 - 1;
- jinit_master_decompress(dinfo);
- (*dinfo->upsample->start_pass) (dinfo);
-
- pw0 = PAD(width, dinfo->max_h_samp_factor);
- ph0 = PAD(height, dinfo->max_v_samp_factor);
-
- if (pitch == 0) pitch = dinfo->output_width * tjPixelSize[pixelFormat];
-
- if ((row_pointer = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph0)) == NULL)
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- for (i = 0; i < height; i++) {
- if (flags & TJFLAG_BOTTOMUP)
- row_pointer[i] = &dstBuf[(height - i - 1) * (size_t)pitch];
- else
- row_pointer[i] = &dstBuf[i * (size_t)pitch];
- }
- if (height < ph0)
- for (i = height; i < ph0; i++) row_pointer[i] = row_pointer[height - 1];
-
- for (i = 0; i < dinfo->num_components; i++) {
- compptr = &dinfo->comp_info[i];
- _tmpbuf[i] =
- (JSAMPLE *)malloc(PAD(compptr->width_in_blocks * DCTSIZE, 32) *
- compptr->v_samp_factor + 32);
- if (!_tmpbuf[i])
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * compptr->v_samp_factor);
- if (!tmpbuf[i])
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- for (row = 0; row < compptr->v_samp_factor; row++) {
- unsigned char *_tmpbuf_aligned =
- (unsigned char *)PAD((JUINTPTR)_tmpbuf[i], 32);
-
- tmpbuf[i][row] =
- &_tmpbuf_aligned[PAD(compptr->width_in_blocks * DCTSIZE, 32) * row];
- }
- pw[i] = pw0 * compptr->h_samp_factor / dinfo->max_h_samp_factor;
- ph[i] = ph0 * compptr->v_samp_factor / dinfo->max_v_samp_factor;
- inbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i]);
- if (!inbuf[i])
- THROW("tjDecodeYUVPlanes(): Memory allocation failure");
- ptr = (JSAMPLE *)srcPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- inbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- for (row = 0; row < ph0; row += dinfo->max_v_samp_factor) {
- JDIMENSION inrow = 0, outrow = 0;
-
- for (i = 0, compptr = dinfo->comp_info; i < dinfo->num_components;
- i++, compptr++)
- jcopy_sample_rows(inbuf[i],
- row * compptr->v_samp_factor / dinfo->max_v_samp_factor, tmpbuf[i], 0,
- compptr->v_samp_factor, pw[i]);
- (dinfo->upsample->upsample) (dinfo, tmpbuf, &inrow,
- dinfo->max_v_samp_factor, &row_pointer[row],
- &outrow, dinfo->max_v_samp_factor);
- }
- jpeg_abort_decompress(dinfo);
-
-bailout:
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- free(row_pointer);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(_tmpbuf[i]);
- free(inbuf[i]);
- }
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
- int pad, int subsamp, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags)
-{
- const unsigned char *srcPlanes[3];
- int pw0, ph0, strides[3], retval = -1;
- tjinstance *this = (tjinstance *)handle;
-
- if (!this) THROWG("tjDecodeYUV(): Invalid handle");
- this->isInstanceError = FALSE;
-
- if (srcBuf == NULL || pad < 0 || !IS_POW2(pad) || subsamp < 0 ||
- subsamp >= NUMSUBOPT || width <= 0 || height <= 0)
- THROW("tjDecodeYUV(): Invalid argument");
-
- pw0 = tjPlaneWidth(0, width, subsamp);
- ph0 = tjPlaneHeight(0, height, subsamp);
- srcPlanes[0] = srcBuf;
- strides[0] = PAD(pw0, pad);
- if (subsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- srcPlanes[1] = srcPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, subsamp);
- int ph1 = tjPlaneHeight(1, height, subsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- srcPlanes[1] = srcPlanes[0] + strides[0] * ph0;
- srcPlanes[2] = srcPlanes[1] + strides[1] * ph1;
- }
-
- return tjDecodeYUVPlanes(handle, srcPlanes, strides, subsamp, dstBuf, width,
- pitch, height, pixelFormat, flags);
-
-bailout:
- return retval;
-}
-
-DLLEXPORT int tjDecompressToYUVPlanes(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize,
- unsigned char **dstPlanes, int width,
- int *strides, int height, int flags)
-{
- int i, sfi, row, retval = 0;
- int jpegwidth, jpegheight, jpegSubsamp, scaledw, scaledh;
- int pw[MAX_COMPONENTS], ph[MAX_COMPONENTS], iw[MAX_COMPONENTS],
- tmpbufsize = 0, usetmpbuf = 0, th[MAX_COMPONENTS];
- JSAMPLE *_tmpbuf = NULL, *ptr;
- JSAMPROW *outbuf[MAX_COMPONENTS], *tmpbuf[MAX_COMPONENTS];
- int dctsize;
- struct my_progress_mgr progress;
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- for (i = 0; i < MAX_COMPONENTS; i++) {
- tmpbuf[i] = NULL; outbuf[i] = NULL;
- }
-
- if ((this->init & DECOMPRESS) == 0)
- THROW("tjDecompressToYUVPlanes(): Instance has not been initialized for decompression");
-
- if (jpegBuf == NULL || jpegSize <= 0 || !dstPlanes || !dstPlanes[0] ||
- width < 0 || height < 0)
- THROW("tjDecompressToYUVPlanes(): Invalid argument");
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_LIMITSCANS) {
- memset(&progress, 0, sizeof(struct my_progress_mgr));
- progress.pub.progress_monitor = my_progress_monitor;
- progress.this = this;
- dinfo->progress = &progress.pub;
- } else
- dinfo->progress = NULL;
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (!this->headerRead) {
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
- }
- this->headerRead = 0;
- jpegSubsamp = getSubsamp(dinfo);
- if (jpegSubsamp < 0)
- THROW("tjDecompressToYUVPlanes(): Could not determine subsampling type for JPEG image");
-
- if (jpegSubsamp != TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
- THROW("tjDecompressToYUVPlanes(): Invalid argument");
-
- jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
- if (width == 0) width = jpegwidth;
- if (height == 0) height = jpegheight;
- for (i = 0; i < NUMSF; i++) {
- scaledw = TJSCALED(jpegwidth, sf[i]);
- scaledh = TJSCALED(jpegheight, sf[i]);
- if (scaledw <= width && scaledh <= height)
- break;
- }
- if (i >= NUMSF)
- THROW("tjDecompressToYUVPlanes(): Could not scale down to desired image dimensions");
- if (dinfo->num_components > 3)
- THROW("tjDecompressToYUVPlanes(): JPEG image must have 3 or fewer components");
-
- width = scaledw; height = scaledh;
- dinfo->scale_num = sf[i].num;
- dinfo->scale_denom = sf[i].denom;
- sfi = i;
- jpeg_calc_output_dimensions(dinfo);
-
- dctsize = DCTSIZE * sf[sfi].num / sf[sfi].denom;
-
- for (i = 0; i < dinfo->num_components; i++) {
- jpeg_component_info *compptr = &dinfo->comp_info[i];
- int ih;
-
- iw[i] = compptr->width_in_blocks * dctsize;
- ih = compptr->height_in_blocks * dctsize;
- pw[i] = tjPlaneWidth(i, dinfo->output_width, jpegSubsamp);
- ph[i] = tjPlaneHeight(i, dinfo->output_height, jpegSubsamp);
- if (iw[i] != pw[i] || ih != ph[i]) usetmpbuf = 1;
- th[i] = compptr->v_samp_factor * dctsize;
- tmpbufsize += iw[i] * th[i];
- if ((outbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * ph[i])) == NULL)
- THROW("tjDecompressToYUVPlanes(): Memory allocation failure");
- ptr = dstPlanes[i];
- for (row = 0; row < ph[i]; row++) {
- outbuf[i][row] = ptr;
- ptr += (strides && strides[i] != 0) ? strides[i] : pw[i];
- }
- }
- if (usetmpbuf) {
- if ((_tmpbuf = (JSAMPLE *)malloc(sizeof(JSAMPLE) * tmpbufsize)) == NULL)
- THROW("tjDecompressToYUVPlanes(): Memory allocation failure");
- ptr = _tmpbuf;
- for (i = 0; i < dinfo->num_components; i++) {
- if ((tmpbuf[i] = (JSAMPROW *)malloc(sizeof(JSAMPROW) * th[i])) == NULL)
- THROW("tjDecompressToYUVPlanes(): Memory allocation failure");
- for (row = 0; row < th[i]; row++) {
- tmpbuf[i][row] = ptr;
- ptr += iw[i];
- }
- }
- }
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (flags & TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling = FALSE;
- if (flags & TJFLAG_FASTDCT) dinfo->dct_method = JDCT_FASTEST;
- dinfo->raw_data_out = TRUE;
-
- jpeg_start_decompress(dinfo);
- for (row = 0; row < (int)dinfo->output_height;
- row += dinfo->max_v_samp_factor * dinfo->_min_DCT_scaled_size) {
- JSAMPARRAY yuvptr[MAX_COMPONENTS];
- int crow[MAX_COMPONENTS];
-
- for (i = 0; i < dinfo->num_components; i++) {
- jpeg_component_info *compptr = &dinfo->comp_info[i];
-
- if (jpegSubsamp == TJ_420) {
- /* When 4:2:0 subsampling is used with IDCT scaling, libjpeg will try
- to be clever and use the IDCT to perform upsampling on the U and V
- planes. For instance, if the output image is to be scaled by 1/2
- relative to the JPEG image, then the scaling factor and upsampling
- effectively cancel each other, so a normal 8x8 IDCT can be used.
- However, this is not desirable when using the decompress-to-YUV
- functionality in TurboJPEG, since we want to output the U and V
- planes in their subsampled form. Thus, we have to override some
- internal libjpeg parameters to force it to use the "scaled" IDCT
- functions on the U and V planes. */
- compptr->_DCT_scaled_size = dctsize;
- compptr->MCU_sample_width = tjMCUWidth[jpegSubsamp] *
- sf[sfi].num / sf[sfi].denom *
- compptr->v_samp_factor / dinfo->max_v_samp_factor;
- dinfo->idct->inverse_DCT[i] = dinfo->idct->inverse_DCT[0];
- }
- crow[i] = row * compptr->v_samp_factor / dinfo->max_v_samp_factor;
- if (usetmpbuf) yuvptr[i] = tmpbuf[i];
- else yuvptr[i] = &outbuf[i][crow[i]];
- }
- jpeg_read_raw_data(dinfo, yuvptr,
- dinfo->max_v_samp_factor * dinfo->_min_DCT_scaled_size);
- if (usetmpbuf) {
- int j;
-
- for (i = 0; i < dinfo->num_components; i++) {
- for (j = 0; j < MIN(th[i], ph[i] - crow[i]); j++) {
- memcpy(outbuf[i][crow[i] + j], tmpbuf[i][j], pw[i]);
- }
- }
- }
- }
- jpeg_finish_decompress(dinfo);
-
-bailout:
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- for (i = 0; i < MAX_COMPONENTS; i++) {
- free(tmpbuf[i]);
- free(outbuf[i]);
- }
- free(_tmpbuf);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pad, int height, int flags)
-{
- unsigned char *dstPlanes[3];
- int pw0, ph0, strides[3], retval = -1, jpegSubsamp = -1;
- int i, jpegwidth, jpegheight, scaledw, scaledh;
-
- GET_DINSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
-
- if (jpegBuf == NULL || jpegSize <= 0 || dstBuf == NULL || width < 0 ||
- pad < 1 || !IS_POW2(pad) || height < 0)
- THROW("tjDecompressToYUV2(): Invalid argument");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- return -1;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
- jpegSubsamp = getSubsamp(dinfo);
- if (jpegSubsamp < 0)
- THROW("tjDecompressToYUV2(): Could not determine subsampling type for JPEG image");
-
- jpegwidth = dinfo->image_width; jpegheight = dinfo->image_height;
- if (width == 0) width = jpegwidth;
- if (height == 0) height = jpegheight;
-
- for (i = 0; i < NUMSF; i++) {
- scaledw = TJSCALED(jpegwidth, sf[i]);
- scaledh = TJSCALED(jpegheight, sf[i]);
- if (scaledw <= width && scaledh <= height)
- break;
- }
- if (i >= NUMSF)
- THROW("tjDecompressToYUV2(): Could not scale down to desired image dimensions");
-
- pw0 = tjPlaneWidth(0, width, jpegSubsamp);
- ph0 = tjPlaneHeight(0, height, jpegSubsamp);
- dstPlanes[0] = dstBuf;
- strides[0] = PAD(pw0, pad);
- if (jpegSubsamp == TJSAMP_GRAY) {
- strides[1] = strides[2] = 0;
- dstPlanes[1] = dstPlanes[2] = NULL;
- } else {
- int pw1 = tjPlaneWidth(1, width, jpegSubsamp);
- int ph1 = tjPlaneHeight(1, height, jpegSubsamp);
-
- strides[1] = strides[2] = PAD(pw1, pad);
- dstPlanes[1] = dstPlanes[0] + strides[0] * ph0;
- dstPlanes[2] = dstPlanes[1] + strides[1] * ph1;
- }
-
- this->headerRead = 1;
- return tjDecompressToYUVPlanes(handle, jpegBuf, jpegSize, dstPlanes, width,
- strides, height, flags);
-
-bailout:
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-DLLEXPORT int tjDecompressToYUV(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int flags)
-{
- return tjDecompressToYUV2(handle, jpegBuf, jpegSize, dstBuf, 0, 4, 0, flags);
-}
-
-
-/* Transformer */
-
-DLLEXPORT tjhandle tjInitTransform(void)
-{
- tjinstance *this = NULL;
- tjhandle handle = NULL;
-
- if ((this = (tjinstance *)malloc(sizeof(tjinstance))) == NULL) {
- SNPRINTF(errStr, JMSG_LENGTH_MAX,
- "tjInitTransform(): Memory allocation failure");
- return NULL;
- }
- memset(this, 0, sizeof(tjinstance));
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX, "No error");
- handle = _tjInitCompress(this);
- if (!handle) return NULL;
- handle = _tjInitDecompress(this);
- return handle;
-}
-
-
-DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, int n,
- unsigned char **dstBufs, unsigned long *dstSizes,
- tjtransform *t, int flags)
-{
- jpeg_transform_info *xinfo = NULL;
- jvirt_barray_ptr *srccoefs, *dstcoefs;
- int retval = 0, i, jpegSubsamp, saveMarkers = 0;
- boolean alloc = TRUE;
- struct my_progress_mgr progress;
-
- GET_INSTANCE(handle);
- this->jerr.stopOnWarning = (flags & TJFLAG_STOPONWARNING) ? TRUE : FALSE;
- if ((this->init & COMPRESS) == 0 || (this->init & DECOMPRESS) == 0)
- THROW("tjTransform(): Instance has not been initialized for transformation");
-
- if (jpegBuf == NULL || jpegSize <= 0 || n < 1 || dstBufs == NULL ||
- dstSizes == NULL || t == NULL || flags < 0)
- THROW("tjTransform(): Invalid argument");
-
-#ifndef NO_PUTENV
- if (flags & TJFLAG_FORCEMMX) PUTENV_S("JSIMD_FORCEMMX", "1");
- else if (flags & TJFLAG_FORCESSE) PUTENV_S("JSIMD_FORCESSE", "1");
- else if (flags & TJFLAG_FORCESSE2) PUTENV_S("JSIMD_FORCESSE2", "1");
-#endif
-
- if (flags & TJFLAG_LIMITSCANS) {
- memset(&progress, 0, sizeof(struct my_progress_mgr));
- progress.pub.progress_monitor = my_progress_monitor;
- progress.this = this;
- dinfo->progress = &progress.pub;
- } else
- dinfo->progress = NULL;
-
- if ((xinfo =
- (jpeg_transform_info *)malloc(sizeof(jpeg_transform_info) * n)) == NULL)
- THROW("tjTransform(): Memory allocation failure");
- memset(xinfo, 0, sizeof(jpeg_transform_info) * n);
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
-
- for (i = 0; i < n; i++) {
- xinfo[i].transform = xformtypes[t[i].op];
- xinfo[i].perfect = (t[i].options & TJXOPT_PERFECT) ? 1 : 0;
- xinfo[i].trim = (t[i].options & TJXOPT_TRIM) ? 1 : 0;
- xinfo[i].force_grayscale = (t[i].options & TJXOPT_GRAY) ? 1 : 0;
- xinfo[i].crop = (t[i].options & TJXOPT_CROP) ? 1 : 0;
- if (n != 1 && t[i].op == TJXOP_HFLIP) xinfo[i].slow_hflip = 1;
- else xinfo[i].slow_hflip = 0;
-
- if (xinfo[i].crop) {
- xinfo[i].crop_xoffset = t[i].r.x; xinfo[i].crop_xoffset_set = JCROP_POS;
- xinfo[i].crop_yoffset = t[i].r.y; xinfo[i].crop_yoffset_set = JCROP_POS;
- if (t[i].r.w != 0) {
- xinfo[i].crop_width = t[i].r.w; xinfo[i].crop_width_set = JCROP_POS;
- } else
- xinfo[i].crop_width = JCROP_UNSET;
- if (t[i].r.h != 0) {
- xinfo[i].crop_height = t[i].r.h; xinfo[i].crop_height_set = JCROP_POS;
- } else
- xinfo[i].crop_height = JCROP_UNSET;
- }
- if (!(t[i].options & TJXOPT_COPYNONE)) saveMarkers = 1;
- }
-
- jcopy_markers_setup(dinfo, saveMarkers ? JCOPYOPT_ALL : JCOPYOPT_NONE);
- jpeg_read_header(dinfo, TRUE);
- jpegSubsamp = getSubsamp(dinfo);
- if (jpegSubsamp < 0)
- THROW("tjTransform(): Could not determine subsampling type for JPEG image");
-
- for (i = 0; i < n; i++) {
- if (!jtransform_request_workspace(dinfo, &xinfo[i]))
- THROW("tjTransform(): Transform is not perfect");
-
- if (xinfo[i].crop) {
- if ((t[i].r.x % tjMCUWidth[jpegSubsamp]) != 0 ||
- (t[i].r.y % tjMCUHeight[jpegSubsamp]) != 0) {
- SNPRINTF(this->errStr, JMSG_LENGTH_MAX,
- "To crop this JPEG image, x must be a multiple of %d\n"
- "and y must be a multiple of %d.\n",
- tjMCUWidth[jpegSubsamp], tjMCUHeight[jpegSubsamp]);
- this->isInstanceError = TRUE;
- retval = -1; goto bailout;
- }
- }
- }
-
- srccoefs = jpeg_read_coefficients(dinfo);
-
- for (i = 0; i < n; i++) {
- int w, h;
-
- if (!xinfo[i].crop) {
- w = dinfo->image_width; h = dinfo->image_height;
- } else {
- w = xinfo[i].crop_width; h = xinfo[i].crop_height;
- }
- if (flags & TJFLAG_NOREALLOC) {
- alloc = FALSE; dstSizes[i] = tjBufSize(w, h, jpegSubsamp);
- }
- if (!(t[i].options & TJXOPT_NOOUTPUT))
- jpeg_mem_dest_tj(cinfo, &dstBufs[i], &dstSizes[i], alloc);
- jpeg_copy_critical_parameters(dinfo, cinfo);
- dstcoefs = jtransform_adjust_parameters(dinfo, cinfo, srccoefs, &xinfo[i]);
- if (flags & TJFLAG_PROGRESSIVE || t[i].options & TJXOPT_PROGRESSIVE)
- jpeg_simple_progression(cinfo);
- if (!(t[i].options & TJXOPT_NOOUTPUT)) {
- jpeg_write_coefficients(cinfo, dstcoefs);
- jcopy_markers_execute(dinfo, cinfo, t[i].options & TJXOPT_COPYNONE ?
- JCOPYOPT_NONE : JCOPYOPT_ALL);
- } else
- jinit_c_master_control(cinfo, TRUE);
- jtransform_execute_transformation(dinfo, cinfo, srccoefs, &xinfo[i]);
- if (t[i].customFilter) {
- int ci, y;
- JDIMENSION by;
-
- for (ci = 0; ci < cinfo->num_components; ci++) {
- jpeg_component_info *compptr = &cinfo->comp_info[ci];
- tjregion arrayRegion = { 0, 0, 0, 0 };
- tjregion planeRegion = { 0, 0, 0, 0 };
-
- arrayRegion.w = compptr->width_in_blocks * DCTSIZE;
- arrayRegion.h = DCTSIZE;
- planeRegion.w = compptr->width_in_blocks * DCTSIZE;
- planeRegion.h = compptr->height_in_blocks * DCTSIZE;
-
- for (by = 0; by < compptr->height_in_blocks;
- by += compptr->v_samp_factor) {
- JBLOCKARRAY barray = (dinfo->mem->access_virt_barray)
- ((j_common_ptr)dinfo, dstcoefs[ci], by, compptr->v_samp_factor,
- TRUE);
-
- for (y = 0; y < compptr->v_samp_factor; y++) {
- if (t[i].customFilter(barray[y][0], arrayRegion, planeRegion, ci,
- i, &t[i]) == -1)
- THROW("tjTransform(): Error in custom filter");
- arrayRegion.y += DCTSIZE;
- }
- }
- }
- }
- if (!(t[i].options & TJXOPT_NOOUTPUT)) jpeg_finish_compress(cinfo);
- }
-
- jpeg_finish_decompress(dinfo);
-
-bailout:
- if (cinfo->global_state > CSTATE_START) {
- if (alloc) (*cinfo->dest->term_destination) (cinfo);
- jpeg_abort_compress(cinfo);
- }
- if (dinfo->global_state > DSTATE_START) jpeg_abort_decompress(dinfo);
- free(xinfo);
- if (this->jerr.warning) retval = -1;
- this->jerr.stopOnWarning = FALSE;
- return retval;
-}
-
-
-DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
- int align, int *height, int *pixelFormat,
- int flags)
-{
- int retval = 0, tempc;
- size_t pitch;
- tjhandle handle = NULL;
- tjinstance *this;
- j_compress_ptr cinfo = NULL;
- cjpeg_source_ptr src;
- unsigned char *dstBuf = NULL;
- FILE *file = NULL;
- boolean invert;
-
- if (!filename || !width || align < 1 || !height || !pixelFormat ||
- *pixelFormat < TJPF_UNKNOWN || *pixelFormat >= TJ_NUMPF)
- THROWG("tjLoadImage(): Invalid argument");
- if ((align & (align - 1)) != 0)
- THROWG("tjLoadImage(): Alignment must be a power of 2");
-
- if ((handle = tjInitCompress()) == NULL) return NULL;
- this = (tjinstance *)handle;
- cinfo = &this->cinfo;
-
-#ifdef _MSC_VER
- if (fopen_s(&file, filename, "rb") || file == NULL)
-#else
- if ((file = fopen(filename, "rb")) == NULL)
-#endif
- THROW_UNIX("tjLoadImage(): Cannot open input file");
-
- if ((tempc = getc(file)) < 0 || ungetc(tempc, file) == EOF)
- THROW_UNIX("tjLoadImage(): Could not read input file")
- else if (tempc == EOF)
- THROWG("tjLoadImage(): Input file contains no data");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- if (*pixelFormat == TJPF_UNKNOWN) cinfo->in_color_space = JCS_UNKNOWN;
- else cinfo->in_color_space = pf2cs[*pixelFormat];
- if (tempc == 'B') {
- if ((src = jinit_read_bmp(cinfo, FALSE)) == NULL)
- THROWG("tjLoadImage(): Could not initialize bitmap loader");
- invert = (flags & TJFLAG_BOTTOMUP) == 0;
- } else if (tempc == 'P') {
- if ((src = jinit_read_ppm(cinfo)) == NULL)
- THROWG("tjLoadImage(): Could not initialize bitmap loader");
- invert = (flags & TJFLAG_BOTTOMUP) != 0;
- } else
- THROWG("tjLoadImage(): Unsupported file type");
-
- src->input_file = file;
-#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
- /* Refuse to load images larger than 1 Megapixel when fuzzing. */
- if (flags & TJFLAG_FUZZING)
- src->max_pixels = 1048576;
-#endif
- (*src->start_input) (cinfo, src);
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
-
- *width = cinfo->image_width; *height = cinfo->image_height;
- *pixelFormat = cs2pf[cinfo->in_color_space];
-
- pitch = PAD((*width) * tjPixelSize[*pixelFormat], align);
- if ((unsigned long long)pitch * (unsigned long long)(*height) >
- (unsigned long long)((size_t)-1) ||
- (dstBuf = (unsigned char *)malloc(pitch * (*height))) == NULL)
- THROWG("tjLoadImage(): Memory allocation failure");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- while (cinfo->next_scanline < cinfo->image_height) {
- int i, nlines = (*src->get_pixel_rows) (cinfo, src);
-
- for (i = 0; i < nlines; i++) {
- unsigned char *dstptr;
- int row;
-
- row = cinfo->next_scanline + i;
- if (invert) dstptr = &dstBuf[((*height) - row - 1) * pitch];
- else dstptr = &dstBuf[row * pitch];
- memcpy(dstptr, src->buffer[i], (*width) * tjPixelSize[*pixelFormat]);
- }
- cinfo->next_scanline += nlines;
- }
-
- (*src->finish_input) (cinfo, src);
-
-bailout:
- if (handle) tjDestroy(handle);
- if (file) fclose(file);
- if (retval < 0) { free(dstBuf); dstBuf = NULL; }
- return dstBuf;
-}
-
-
-DLLEXPORT int tjSaveImage(const char *filename, unsigned char *buffer,
- int width, int pitch, int height, int pixelFormat,
- int flags)
-{
- int retval = 0;
- tjhandle handle = NULL;
- tjinstance *this;
- j_decompress_ptr dinfo = NULL;
- djpeg_dest_ptr dst;
- FILE *file = NULL;
- char *ptr = NULL;
- boolean invert;
-
- if (!filename || !buffer || width < 1 || pitch < 0 || height < 1 ||
- pixelFormat < 0 || pixelFormat >= TJ_NUMPF)
- THROWG("tjSaveImage(): Invalid argument");
-
- if ((handle = tjInitDecompress()) == NULL)
- return -1;
- this = (tjinstance *)handle;
- dinfo = &this->dinfo;
-
-#ifdef _MSC_VER
- if (fopen_s(&file, filename, "wb") || file == NULL)
-#else
- if ((file = fopen(filename, "wb")) == NULL)
-#endif
- THROW_UNIX("tjSaveImage(): Cannot open output file");
-
- if (setjmp(this->jerr.setjmp_buffer)) {
- /* If we get here, the JPEG code has signaled an error. */
- retval = -1; goto bailout;
- }
-
- this->dinfo.out_color_space = pf2cs[pixelFormat];
- dinfo->image_width = width; dinfo->image_height = height;
- dinfo->global_state = DSTATE_READY;
- dinfo->scale_num = dinfo->scale_denom = 1;
-
- ptr = strrchr(filename, '.');
- if (ptr && !strcasecmp(ptr, ".bmp")) {
- if ((dst = jinit_write_bmp(dinfo, FALSE, FALSE)) == NULL)
- THROWG("tjSaveImage(): Could not initialize bitmap writer");
- invert = (flags & TJFLAG_BOTTOMUP) == 0;
- } else {
- if ((dst = jinit_write_ppm(dinfo)) == NULL)
- THROWG("tjSaveImage(): Could not initialize PPM writer");
- invert = (flags & TJFLAG_BOTTOMUP) != 0;
- }
-
- dst->output_file = file;
- (*dst->start_output) (dinfo, dst);
- (*dinfo->mem->realize_virt_arrays) ((j_common_ptr)dinfo);
-
- if (pitch == 0) pitch = width * tjPixelSize[pixelFormat];
-
- while (dinfo->output_scanline < dinfo->output_height) {
- unsigned char *rowptr;
-
- if (invert)
- rowptr = &buffer[(height - dinfo->output_scanline - 1) * pitch];
- else
- rowptr = &buffer[dinfo->output_scanline * pitch];
- memcpy(dst->buffer[0], rowptr, width * tjPixelSize[pixelFormat]);
- (*dst->put_pixel_rows) (dinfo, dst, 1);
- dinfo->output_scanline++;
- }
-
- (*dst->finish_output) (dinfo, dst);
-
-bailout:
- if (handle) tjDestroy(handle);
- if (file) fclose(file);
- return retval;
-}
diff --git a/contrib/libs/libjpeg-turbo/turbojpeg.h b/contrib/libs/libjpeg-turbo/turbojpeg.h
index 02b54ca99cc..8c99c05a59c 100644
--- a/contrib/libs/libjpeg-turbo/turbojpeg.h
+++ b/contrib/libs/libjpeg-turbo/turbojpeg.h
@@ -1,1767 +1 @@
-/*
- * Copyright (C)2009-2015, 2017, 2020-2021 D. R. Commander.
- * All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the libjpeg-turbo Project nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __TURBOJPEG_H__
-#define __TURBOJPEG_H__
-
-#if defined(_WIN32) && defined(DLLDEFINE)
-#define DLLEXPORT __declspec(dllexport)
-#else
-#define DLLEXPORT
-#endif
-#define DLLCALL
-
-
-/**
- * @addtogroup TurboJPEG
- * TurboJPEG API. This API provides an interface for generating, decoding, and
- * transforming planar YUV and JPEG images in memory.
- *
- * @anchor YUVnotes
- * YUV Image Format Notes
- * ----------------------
- * Technically, the JPEG format uses the YCbCr colorspace (which is technically
- * not a colorspace but a color transform), but per the convention of the
- * digital video community, the TurboJPEG API uses "YUV" to refer to an image
- * format consisting of Y, Cb, and Cr image planes.
- *
- * Each plane is simply a 2D array of bytes, each byte representing the value
- * of one of the components (Y, Cb, or Cr) at a particular location in the
- * image. The width and height of each plane are determined by the image
- * width, height, and level of chrominance subsampling. The luminance plane
- * width is the image width padded to the nearest multiple of the horizontal
- * subsampling factor (2 in the case of 4:2:0 and 4:2:2, 4 in the case of
- * 4:1:1, 1 in the case of 4:4:4 or grayscale.) Similarly, the luminance plane
- * height is the image height padded to the nearest multiple of the vertical
- * subsampling factor (2 in the case of 4:2:0 or 4:4:0, 1 in the case of 4:4:4
- * or grayscale.) This is irrespective of any additional padding that may be
- * specified as an argument to the various YUV functions. The chrominance
- * plane width is equal to the luminance plane width divided by the horizontal
- * subsampling factor, and the chrominance plane height is equal to the
- * luminance plane height divided by the vertical subsampling factor.
- *
- * For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is
- * used, then the luminance plane would be 36 x 35 bytes, and each of the
- * chrominance planes would be 18 x 35 bytes. If you specify a line padding of
- * 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes, and
- * each of the chrominance planes would be 20 x 35 bytes.
- *
- * @{
- */
-
-
-/**
- * The number of chrominance subsampling options
- */
-#define TJ_NUMSAMP 6
-
-/**
- * Chrominance subsampling options.
- * When pixels are converted from RGB to YCbCr (see #TJCS_YCbCr) or from CMYK
- * to YCCK (see #TJCS_YCCK) as part of the JPEG compression process, some of
- * the Cb and Cr (chrominance) components can be discarded or averaged together
- * to produce a smaller image with little perceptible loss of image clarity
- * (the human eye is more sensitive to small changes in brightness than to
- * small changes in color.) This is called "chrominance subsampling".
- */
-enum TJSAMP {
- /**
- * 4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG or
- * YUV image will contain one chrominance component for every pixel in the
- * source image.
- */
- TJSAMP_444 = 0,
- /**
- * 4:2:2 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x1 block of pixels in the source image.
- */
- TJSAMP_422,
- /**
- * 4:2:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 2x2 block of pixels in the source image.
- */
- TJSAMP_420,
- /**
- * Grayscale. The JPEG or YUV image will contain no chrominance components.
- */
- TJSAMP_GRAY,
- /**
- * 4:4:0 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 1x2 block of pixels in the source image.
- *
- * @note 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
- */
- TJSAMP_440,
- /**
- * 4:1:1 chrominance subsampling. The JPEG or YUV image will contain one
- * chrominance component for every 4x1 block of pixels in the source image.
- * JPEG images compressed with 4:1:1 subsampling will be almost exactly the
- * same size as those compressed with 4:2:0 subsampling, and in the
- * aggregate, both subsampling methods produce approximately the same
- * perceptual quality. However, 4:1:1 is better able to reproduce sharp
- * horizontal features.
- *
- * @note 4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
- */
- TJSAMP_411
-};
-
-/**
- * MCU block width (in pixels) for a given level of chrominance subsampling.
- * MCU block sizes:
- * - 8x8 for no subsampling or grayscale
- * - 16x8 for 4:2:2
- * - 8x16 for 4:4:0
- * - 16x16 for 4:2:0
- * - 32x8 for 4:1:1
- */
-static const int tjMCUWidth[TJ_NUMSAMP] = { 8, 16, 16, 8, 8, 32 };
-
-/**
- * MCU block height (in pixels) for a given level of chrominance subsampling.
- * MCU block sizes:
- * - 8x8 for no subsampling or grayscale
- * - 16x8 for 4:2:2
- * - 8x16 for 4:4:0
- * - 16x16 for 4:2:0
- * - 32x8 for 4:1:1
- */
-static const int tjMCUHeight[TJ_NUMSAMP] = { 8, 8, 16, 8, 16, 8 };
-
-
-/**
- * The number of pixel formats
- */
-#define TJ_NUMPF 12
-
-/**
- * Pixel formats
- */
-enum TJPF {
- /**
- * RGB pixel format. The red, green, and blue components in the image are
- * stored in 3-byte pixels in the order R, G, B from lowest to highest byte
- * address within each pixel.
- */
- TJPF_RGB = 0,
- /**
- * BGR pixel format. The red, green, and blue components in the image are
- * stored in 3-byte pixels in the order B, G, R from lowest to highest byte
- * address within each pixel.
- */
- TJPF_BGR,
- /**
- * RGBX pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order R, G, B from lowest to highest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_RGBX,
- /**
- * BGRX pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order B, G, R from lowest to highest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_BGRX,
- /**
- * XBGR pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order R, G, B from highest to lowest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_XBGR,
- /**
- * XRGB pixel format. The red, green, and blue components in the image are
- * stored in 4-byte pixels in the order B, G, R from highest to lowest byte
- * address within each pixel. The X component is ignored when compressing
- * and undefined when decompressing.
- */
- TJPF_XRGB,
- /**
- * Grayscale pixel format. Each 1-byte pixel represents a luminance
- * (brightness) level from 0 to 255.
- */
- TJPF_GRAY,
- /**
- * RGBA pixel format. This is the same as @ref TJPF_RGBX, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_RGBA,
- /**
- * BGRA pixel format. This is the same as @ref TJPF_BGRX, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_BGRA,
- /**
- * ABGR pixel format. This is the same as @ref TJPF_XBGR, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_ABGR,
- /**
- * ARGB pixel format. This is the same as @ref TJPF_XRGB, except that when
- * decompressing, the X component is guaranteed to be 0xFF, which can be
- * interpreted as an opaque alpha channel.
- */
- TJPF_ARGB,
- /**
- * CMYK pixel format. Unlike RGB, which is an additive color model used
- * primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive
- * color model used primarily for printing. In the CMYK color model, the
- * value of each color component typically corresponds to an amount of cyan,
- * magenta, yellow, or black ink that is applied to a white background. In
- * order to convert between CMYK and RGB, it is necessary to use a color
- * management system (CMS.) A CMS will attempt to map colors within the
- * printer's gamut to perceptually similar colors in the display's gamut and
- * vice versa, but the mapping is typically not 1:1 or reversible, nor can it
- * be defined with a simple formula. Thus, such a conversion is out of scope
- * for a codec library. However, the TurboJPEG API allows for compressing
- * CMYK pixels into a YCCK JPEG image (see #TJCS_YCCK) and decompressing YCCK
- * JPEG images into CMYK pixels.
- */
- TJPF_CMYK,
- /**
- * Unknown pixel format. Currently this is only used by #tjLoadImage().
- */
- TJPF_UNKNOWN = -1
-};
-
-/**
- * Red offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the red component is offset from the start of the pixel. For
- * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
- * then the red component will be <tt>pixel[tjRedOffset[TJ_BGRX]]</tt>. This
- * will be -1 if the pixel format does not have a red component.
- */
-static const int tjRedOffset[TJ_NUMPF] = {
- 0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1
-};
-/**
- * Green offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the green component is offset from the start of the pixel.
- * For instance, if a pixel of format TJ_BGRX is stored in
- * <tt>char pixel[]</tt>, then the green component will be
- * <tt>pixel[tjGreenOffset[TJ_BGRX]]</tt>. This will be -1 if the pixel format
- * does not have a green component.
- */
-static const int tjGreenOffset[TJ_NUMPF] = {
- 1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1
-};
-/**
- * Blue offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the Blue component is offset from the start of the pixel. For
- * instance, if a pixel of format TJ_BGRX is stored in <tt>char pixel[]</tt>,
- * then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>. This
- * will be -1 if the pixel format does not have a blue component.
- */
-static const int tjBlueOffset[TJ_NUMPF] = {
- 2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
-};
-/**
- * Alpha offset (in bytes) for a given pixel format. This specifies the number
- * of bytes that the Alpha component is offset from the start of the pixel.
- * For instance, if a pixel of format TJ_BGRA is stored in
- * <tt>char pixel[]</tt>, then the alpha component will be
- * <tt>pixel[tjAlphaOffset[TJ_BGRA]]</tt>. This will be -1 if the pixel format
- * does not have an alpha component.
- */
-static const int tjAlphaOffset[TJ_NUMPF] = {
- -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
-};
-/**
- * Pixel size (in bytes) for a given pixel format
- */
-static const int tjPixelSize[TJ_NUMPF] = {
- 3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
-};
-
-
-/**
- * The number of JPEG colorspaces
- */
-#define TJ_NUMCS 5
-
-/**
- * JPEG colorspaces
- */
-enum TJCS {
- /**
- * RGB colorspace. When compressing the JPEG image, the R, G, and B
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. RGB JPEG images can be
- * decompressed to any of the extended RGB pixel formats or grayscale, but
- * they cannot be decompressed to YUV images.
- */
- TJCS_RGB = 0,
- /**
- * YCbCr colorspace. YCbCr is not an absolute colorspace but rather a
- * mathematical transformation of RGB designed solely for storage and
- * transmission. YCbCr images must be converted to RGB before they can
- * actually be displayed. In the YCbCr colorspace, the Y (luminance)
- * component represents the black & white portion of the original image, and
- * the Cb and Cr (chrominance) components represent the color portion of the
- * original image. Originally, the analog equivalent of this transformation
- * allowed the same signal to drive both black & white and color televisions,
- * but JPEG images use YCbCr primarily because it allows the color data to be
- * optionally subsampled for the purposes of reducing bandwidth or disk
- * space. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images
- * can be compressed from and decompressed to any of the extended RGB pixel
- * formats or grayscale, or they can be decompressed to YUV planar images.
- */
- TJCS_YCbCr,
- /**
- * Grayscale colorspace. The JPEG image retains only the luminance data (Y
- * component), and any color data from the source image is discarded.
- * Grayscale JPEG images can be compressed from and decompressed to any of
- * the extended RGB pixel formats or grayscale, or they can be decompressed
- * to YUV planar images.
- */
- TJCS_GRAY,
- /**
- * CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
- * components in the source image are reordered into image planes, but no
- * colorspace conversion or subsampling is performed. CMYK JPEG images can
- * only be decompressed to CMYK pixels.
- */
- TJCS_CMYK,
- /**
- * YCCK colorspace. YCCK (AKA "YCbCrK") is not an absolute colorspace but
- * rather a mathematical transformation of CMYK designed solely for storage
- * and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be
- * reversibly transformed into YCCK, and as with YCbCr, the chrominance
- * components in the YCCK pixels can be subsampled without incurring major
- * perceptual loss. YCCK JPEG images can only be compressed from and
- * decompressed to CMYK pixels.
- */
- TJCS_YCCK
-};
-
-
-/**
- * The uncompressed source/destination image is stored in bottom-up (Windows,
- * OpenGL) order, not top-down (X11) order.
- */
-#define TJFLAG_BOTTOMUP 2
-/**
- * When decompressing an image that was compressed using chrominance
- * subsampling, use the fastest chrominance upsampling algorithm available in
- * the underlying codec. The default is to use smooth upsampling, which
- * creates a smooth transition between neighboring chrominance components in
- * order to reduce upsampling artifacts in the decompressed image.
- */
-#define TJFLAG_FASTUPSAMPLE 256
-/**
- * Disable buffer (re)allocation. If passed to one of the JPEG compression or
- * transform functions, this flag will cause those functions to generate an
- * error if the JPEG image buffer is invalid or too small rather than
- * attempting to allocate or reallocate that buffer. This reproduces the
- * behavior of earlier versions of TurboJPEG.
- */
-#define TJFLAG_NOREALLOC 1024
-/**
- * Use the fastest DCT/IDCT algorithm available in the underlying codec. The
- * default if this flag is not specified is implementation-specific. For
- * example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast
- * algorithm by default when compressing, because this has been shown to have
- * only a very slight effect on accuracy, but it uses the accurate algorithm
- * when decompressing, because this has been shown to have a larger effect.
- */
-#define TJFLAG_FASTDCT 2048
-/**
- * Use the most accurate DCT/IDCT algorithm available in the underlying codec.
- * The default if this flag is not specified is implementation-specific. For
- * example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast
- * algorithm by default when compressing, because this has been shown to have
- * only a very slight effect on accuracy, but it uses the accurate algorithm
- * when decompressing, because this has been shown to have a larger effect.
- */
-#define TJFLAG_ACCURATEDCT 4096
-/**
- * Immediately discontinue the current compression/decompression/transform
- * operation if the underlying codec throws a warning (non-fatal error). The
- * default behavior is to allow the operation to complete unless a fatal error
- * is encountered.
- */
-#define TJFLAG_STOPONWARNING 8192
-/**
- * Use progressive entropy coding in JPEG images generated by the compression
- * and transform functions. Progressive entropy coding will generally improve
- * compression relative to baseline entropy coding (the default), but it will
- * reduce compression and decompression performance considerably.
- */
-#define TJFLAG_PROGRESSIVE 16384
-/**
- * Limit the number of progressive JPEG scans that the decompression and
- * transform functions will process. If a progressive JPEG image contains an
- * unreasonably large number of scans, then this flag will cause the
- * decompression and transform functions to return an error. The primary
- * purpose of this is to allow security-critical applications to guard against
- * an exploit of the progressive JPEG format described in
- * <a href="https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf" target="_blank">this report</a>.
- */
-#define TJFLAG_LIMITSCANS 32768
-
-
-/**
- * The number of error codes
- */
-#define TJ_NUMERR 2
-
-/**
- * Error codes
- */
-enum TJERR {
- /**
- * The error was non-fatal and recoverable, but the image may still be
- * corrupt.
- */
- TJERR_WARNING = 0,
- /**
- * The error was fatal and non-recoverable.
- */
- TJERR_FATAL
-};
-
-
-/**
- * The number of transform operations
- */
-#define TJ_NUMXOP 8
-
-/**
- * Transform operations for #tjTransform()
- */
-enum TJXOP {
- /**
- * Do not transform the position of the image pixels
- */
- TJXOP_NONE = 0,
- /**
- * Flip (mirror) image horizontally. This transform is imperfect if there
- * are any partial MCU blocks on the right edge (see #TJXOPT_PERFECT.)
- */
- TJXOP_HFLIP,
- /**
- * Flip (mirror) image vertically. This transform is imperfect if there are
- * any partial MCU blocks on the bottom edge (see #TJXOPT_PERFECT.)
- */
- TJXOP_VFLIP,
- /**
- * Transpose image (flip/mirror along upper left to lower right axis.) This
- * transform is always perfect.
- */
- TJXOP_TRANSPOSE,
- /**
- * Transverse transpose image (flip/mirror along upper right to lower left
- * axis.) This transform is imperfect if there are any partial MCU blocks in
- * the image (see #TJXOPT_PERFECT.)
- */
- TJXOP_TRANSVERSE,
- /**
- * Rotate image clockwise by 90 degrees. This transform is imperfect if
- * there are any partial MCU blocks on the bottom edge (see
- * #TJXOPT_PERFECT.)
- */
- TJXOP_ROT90,
- /**
- * Rotate image 180 degrees. This transform is imperfect if there are any
- * partial MCU blocks in the image (see #TJXOPT_PERFECT.)
- */
- TJXOP_ROT180,
- /**
- * Rotate image counter-clockwise by 90 degrees. This transform is imperfect
- * if there are any partial MCU blocks on the right edge (see
- * #TJXOPT_PERFECT.)
- */
- TJXOP_ROT270
-};
-
-
-/**
- * This option will cause #tjTransform() to return an error if the transform is
- * not perfect. Lossless transforms operate on MCU blocks, whose size depends
- * on the level of chrominance subsampling used (see #tjMCUWidth
- * and #tjMCUHeight.) If the image's width or height is not evenly divisible
- * by the MCU block size, then there will be partial MCU blocks on the right
- * and/or bottom edges. It is not possible to move these partial MCU blocks to
- * the top or left of the image, so any transform that would require that is
- * "imperfect." If this option is not specified, then any partial MCU blocks
- * that cannot be transformed will be left in place, which will create
- * odd-looking strips on the right or bottom edge of the image.
- */
-#define TJXOPT_PERFECT 1
-/**
- * This option will cause #tjTransform() to discard any partial MCU blocks that
- * cannot be transformed.
- */
-#define TJXOPT_TRIM 2
-/**
- * This option will enable lossless cropping. See #tjTransform() for more
- * information.
- */
-#define TJXOPT_CROP 4
-/**
- * This option will discard the color data in the input image and produce
- * a grayscale output image.
- */
-#define TJXOPT_GRAY 8
-/**
- * This option will prevent #tjTransform() from outputting a JPEG image for
- * this particular transform (this can be used in conjunction with a custom
- * filter to capture the transformed DCT coefficients without transcoding
- * them.)
- */
-#define TJXOPT_NOOUTPUT 16
-/**
- * This option will enable progressive entropy coding in the output image
- * generated by this particular transform. Progressive entropy coding will
- * generally improve compression relative to baseline entropy coding (the
- * default), but it will reduce compression and decompression performance
- * considerably.
- */
-#define TJXOPT_PROGRESSIVE 32
-/**
- * This option will prevent #tjTransform() from copying any extra markers
- * (including EXIF and ICC profile data) from the source image to the output
- * image.
- */
-#define TJXOPT_COPYNONE 64
-
-
-/**
- * Scaling factor
- */
-typedef struct {
- /**
- * Numerator
- */
- int num;
- /**
- * Denominator
- */
- int denom;
-} tjscalingfactor;
-
-/**
- * Cropping region
- */
-typedef struct {
- /**
- * The left boundary of the cropping region. This must be evenly divisible
- * by the MCU block width (see #tjMCUWidth.)
- */
- int x;
- /**
- * The upper boundary of the cropping region. This must be evenly divisible
- * by the MCU block height (see #tjMCUHeight.)
- */
- int y;
- /**
- * The width of the cropping region. Setting this to 0 is the equivalent of
- * setting it to the width of the source JPEG image - x.
- */
- int w;
- /**
- * The height of the cropping region. Setting this to 0 is the equivalent of
- * setting it to the height of the source JPEG image - y.
- */
- int h;
-} tjregion;
-
-/**
- * Lossless transform
- */
-typedef struct tjtransform {
- /**
- * Cropping region
- */
- tjregion r;
- /**
- * One of the @ref TJXOP "transform operations"
- */
- int op;
- /**
- * The bitwise OR of one of more of the @ref TJXOPT_CROP "transform options"
- */
- int options;
- /**
- * Arbitrary data that can be accessed within the body of the callback
- * function
- */
- void *data;
- /**
- * A callback function that can be used to modify the DCT coefficients
- * after they are losslessly transformed but before they are transcoded to a
- * new JPEG image. This allows for custom filters or other transformations
- * to be applied in the frequency domain.
- *
- * @param coeffs pointer to an array of transformed DCT coefficients. (NOTE:
- * this pointer is not guaranteed to be valid once the callback returns, so
- * applications wishing to hand off the DCT coefficients to another function
- * or library should make a copy of them within the body of the callback.)
- *
- * @param arrayRegion #tjregion structure containing the width and height of
- * the array pointed to by <tt>coeffs</tt> as well as its offset relative to
- * the component plane. TurboJPEG implementations may choose to split each
- * component plane into multiple DCT coefficient arrays and call the callback
- * function once for each array.
- *
- * @param planeRegion #tjregion structure containing the width and height of
- * the component plane to which <tt>coeffs</tt> belongs
- *
- * @param componentID ID number of the component plane to which
- * <tt>coeffs</tt> belongs (Y, Cb, and Cr have, respectively, ID's of 0, 1,
- * and 2 in typical JPEG images.)
- *
- * @param transformID ID number of the transformed image to which
- * <tt>coeffs</tt> belongs. This is the same as the index of the transform
- * in the <tt>transforms</tt> array that was passed to #tjTransform().
- *
- * @param transform a pointer to a #tjtransform structure that specifies the
- * parameters and/or cropping region for this transform
- *
- * @return 0 if the callback was successful, or -1 if an error occurred.
- */
- int (*customFilter) (short *coeffs, tjregion arrayRegion,
- tjregion planeRegion, int componentIndex,
- int transformIndex, struct tjtransform *transform);
-} tjtransform;
-
-/**
- * TurboJPEG instance handle
- */
-typedef void *tjhandle;
-
-
-/**
- * Pad the given width to the nearest 32-bit boundary
- */
-#define TJPAD(width) (((width) + 3) & (~3))
-
-/**
- * Compute the scaled value of <tt>dimension</tt> using the given scaling
- * factor. This macro performs the integer equivalent of <tt>ceil(dimension *
- * scalingFactor)</tt>.
- */
-#define TJSCALED(dimension, scalingFactor) \
- (((dimension) * scalingFactor.num + scalingFactor.denom - 1) / \
- scalingFactor.denom)
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * Create a TurboJPEG compressor instance.
- *
- * @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT tjhandle tjInitCompress(void);
-
-
-/**
- * Compress an RGB, grayscale, or CMYK image into a JPEG image.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing RGB, grayscale, or
- * CMYK pixels to be compressed
- *
- * @param width width (in pixels) of the source image
- *
- * @param pitch bytes per line in the source image. Normally, this should be
- * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, or
- * <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of the image
- * is padded to the nearest 32-bit boundary, as is the case for Windows
- * bitmaps. You can also be clever and use this parameter to skip lines, etc.
- * Setting this parameter to 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param jpegBuf address of a pointer to an image buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer
- * to accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize(). This should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
- * you should always check <tt>*jpegBuf</tt> upon return from this function, as
- * it may have changed.
- *
- * @param jpegSize pointer to an unsigned long variable that holds the size of
- * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a pre-allocated
- * buffer, then <tt>*jpegSize</tt> should be set to the size of the buffer.
- * Upon return, <tt>*jpegSize</tt> will contain the size of the JPEG image (in
- * bytes.) If <tt>*jpegBuf</tt> points to a JPEG image buffer that is being
- * reused from a previous call to one of the JPEG compression functions, then
- * <tt>*jpegSize</tt> is ignored.
- *
- * @param jpegSubsamp the level of chrominance subsampling to be used when
- * generating the JPEG image (see @ref TJSAMP
- * "Chrominance subsampling options".)
- *
- * @param jpegQual the image quality of the generated JPEG image (1 = worst,
- * 100 = best)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjCompress2(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char **jpegBuf, unsigned long *jpegSize,
- int jpegSubsamp, int jpegQual, int flags);
-
-
-/**
- * Compress a YUV planar image into a JPEG image.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing a YUV planar image to be
- * compressed. The size of this buffer should match the value returned by
- * #tjBufSizeYUV2() for the given image width, height, padding, and level of
- * chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be
- * stored sequentially in the source buffer (refer to @ref YUVnotes
- * "YUV Image Format Notes".)
- *
- * @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
- * buffer copy will be performed within TurboJPEG.
- *
- * @param pad the line padding used in the source image. For instance, if each
- * line in each plane of the YUV image is padded to the nearest multiple of 4
- * bytes, then <tt>pad</tt> should be set to 4.
- *
- * @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the MCU block height (see #tjMCUHeight), then an
- * intermediate buffer copy will be performed within TurboJPEG.
- *
- * @param subsamp the level of chrominance subsampling used in the source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param jpegBuf address of a pointer to an image buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
- * accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize(). This should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
- * you should always check <tt>*jpegBuf</tt> upon return from this function, as
- * it may have changed.
- *
- * @param jpegSize pointer to an unsigned long variable that holds the size of
- * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a pre-allocated
- * buffer, then <tt>*jpegSize</tt> should be set to the size of the buffer.
- * Upon return, <tt>*jpegSize</tt> will contain the size of the JPEG image (in
- * bytes.) If <tt>*jpegBuf</tt> points to a JPEG image buffer that is being
- * reused from a previous call to one of the JPEG compression functions, then
- * <tt>*jpegSize</tt> is ignored.
- *
- * @param jpegQual the image quality of the generated JPEG image (1 = worst,
- * 100 = best)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf,
- int width, int pad, int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags);
-
-
-/**
- * Compress a set of Y, U (Cb), and V (Cr) image planes into a JPEG image.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if compressing a grayscale image) that contain a YUV
- * image to be compressed. These planes can be contiguous or non-contiguous in
- * memory. The size of each plane should match the value returned by
- * #tjPlaneSizeYUV() for the given image width, height, strides, and level of
- * chrominance subsampling. Refer to @ref YUVnotes "YUV Image Format Notes"
- * for more details.
- *
- * @param width width (in pixels) of the source image. If the width is not an
- * even multiple of the MCU block width (see #tjMCUWidth), then an intermediate
- * buffer copy will be performed within TurboJPEG.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the YUV source image. Setting the stride
- * for any plane to 0 is the same as setting it to the plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective plane widths.
- * You can adjust the strides in order to specify an arbitrary amount of line
- * padding in each plane or to create a JPEG image from a subregion of a larger
- * YUV planar image.
- *
- * @param height height (in pixels) of the source image. If the height is not
- * an even multiple of the MCU block height (see #tjMCUHeight), then an
- * intermediate buffer copy will be performed within TurboJPEG.
- *
- * @param subsamp the level of chrominance subsampling used in the source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param jpegBuf address of a pointer to an image buffer that will receive the
- * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
- * accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize(). This should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.)
- * .
- * If you choose option 1, <tt>*jpegSize</tt> should be set to the size of your
- * pre-allocated buffer. In any case, unless you have set #TJFLAG_NOREALLOC,
- * you should always check <tt>*jpegBuf</tt> upon return from this function, as
- * it may have changed.
- *
- * @param jpegSize pointer to an unsigned long variable that holds the size of
- * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a pre-allocated
- * buffer, then <tt>*jpegSize</tt> should be set to the size of the buffer.
- * Upon return, <tt>*jpegSize</tt> will contain the size of the JPEG image (in
- * bytes.) If <tt>*jpegBuf</tt> points to a JPEG image buffer that is being
- * reused from a previous call to one of the JPEG compression functions, then
- * <tt>*jpegSize</tt> is ignored.
- *
- * @param jpegQual the image quality of the generated JPEG image (1 = worst,
- * 100 = best)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjCompressFromYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- int width, const int *strides,
- int height, int subsamp,
- unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual,
- int flags);
-
-
-/**
- * The maximum size of the buffer (in bytes) required to hold a JPEG image with
- * the given parameters. The number of bytes returned by this function is
- * larger than the size of the uncompressed source image. The reason for this
- * is that the JPEG format uses 16-bit coefficients, and it is thus possible
- * for a very high-quality JPEG image with very high-frequency content to
- * expand rather than compress when converted to the JPEG format. Such images
- * represent a very rare corner case, but since there is no way to predict the
- * size of a JPEG image prior to compression, the corner case has to be
- * handled.
- *
- * @param width width (in pixels) of the image
- *
- * @param height height (in pixels) of the image
- *
- * @param jpegSubsamp the level of chrominance subsampling to be used when
- * generating the JPEG image (see @ref TJSAMP
- * "Chrominance subsampling options".)
- *
- * @return the maximum size of the buffer (in bytes) required to hold the
- * image, or -1 if the arguments are out of bounds.
- */
-DLLEXPORT unsigned long tjBufSize(int width, int height, int jpegSubsamp);
-
-
-/**
- * The size of the buffer (in bytes) required to hold a YUV planar image with
- * the given parameters.
- *
- * @param width width (in pixels) of the image
- *
- * @param pad the width of each line in each plane of the image is padded to
- * the nearest multiple of this number of bytes (must be a power of 2.)
- *
- * @param height height (in pixels) of the image
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the size of the buffer (in bytes) required to hold the image, or
- * -1 if the arguments are out of bounds.
- */
-DLLEXPORT unsigned long tjBufSizeYUV2(int width, int pad, int height,
- int subsamp);
-
-
-/**
- * The size of the buffer (in bytes) required to hold a YUV image plane with
- * the given parameters.
- *
- * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
- *
- * @param width width (in pixels) of the YUV image. NOTE: this is the width of
- * the whole image, not the plane width.
- *
- * @param stride bytes per line in the image plane. Setting this to 0 is the
- * equivalent of setting it to the plane width.
- *
- * @param height height (in pixels) of the YUV image. NOTE: this is the height
- * of the whole image, not the plane height.
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the size of the buffer (in bytes) required to hold the YUV image
- * plane, or -1 if the arguments are out of bounds.
- */
-DLLEXPORT unsigned long tjPlaneSizeYUV(int componentID, int width, int stride,
- int height, int subsamp);
-
-
-/**
- * The plane width of a YUV image plane with the given parameters. Refer to
- * @ref YUVnotes "YUV Image Format Notes" for a description of plane width.
- *
- * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
- *
- * @param width width (in pixels) of the YUV image
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the plane width of a YUV image plane with the given parameters, or
- * -1 if the arguments are out of bounds.
- */
-DLLEXPORT int tjPlaneWidth(int componentID, int width, int subsamp);
-
-
-/**
- * The plane height of a YUV image plane with the given parameters. Refer to
- * @ref YUVnotes "YUV Image Format Notes" for a description of plane height.
- *
- * @param componentID ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr)
- *
- * @param height height (in pixels) of the YUV image
- *
- * @param subsamp level of chrominance subsampling in the image (see
- * @ref TJSAMP "Chrominance subsampling options".)
- *
- * @return the plane height of a YUV image plane with the given parameters, or
- * -1 if the arguments are out of bounds.
- */
-DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp);
-
-
-/**
- * Encode an RGB or grayscale image into a YUV planar image. This function
- * uses the accelerated color conversion routines in the underlying
- * codec but does not execute any of the other steps in the JPEG compression
- * process.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels
- * to be encoded
- *
- * @param width width (in pixels) of the source image
- *
- * @param pitch bytes per line in the source image. Normally, this should be
- * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, or
- * <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of the image
- * is padded to the nearest 32-bit boundary, as is the case for Windows
- * bitmaps. You can also be clever and use this parameter to skip lines, etc.
- * Setting this parameter to 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param dstBuf pointer to an image buffer that will receive the YUV image.
- * Use #tjBufSizeYUV2() to determine the appropriate size for this buffer based
- * on the image width, height, padding, and level of chrominance subsampling.
- * The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the
- * buffer (refer to @ref YUVnotes "YUV Image Format Notes".)
- *
- * @param pad the width of each line in each plane of the YUV image will be
- * padded to the nearest multiple of this number of bytes (must be a power of
- * 2.) To generate images suitable for X Video, <tt>pad</tt> should be set to
- * 4.
- *
- * @param subsamp the level of chrominance subsampling to be used when
- * generating the YUV image (see @ref TJSAMP
- * "Chrominance subsampling options".) To generate images suitable for X
- * Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
- * image compatible with the I420 (AKA "YUV420P") format.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjEncodeYUV3(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int pad, int subsamp,
- int flags);
-
-
-/**
- * Encode an RGB or grayscale image into separate Y, U (Cb), and V (Cr) image
- * planes. This function uses the accelerated color conversion routines in the
- * underlying codec but does not execute any of the other steps in the JPEG
- * compression process.
- *
- * @param handle a handle to a TurboJPEG compressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels
- * to be encoded
- *
- * @param width width (in pixels) of the source image
- *
- * @param pitch bytes per line in the source image. Normally, this should be
- * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded, or
- * <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line of the image
- * is padded to the nearest 32-bit boundary, as is the case for Windows
- * bitmaps. You can also be clever and use this parameter to skip lines, etc.
- * Setting this parameter to 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source image
- *
- * @param pixelFormat pixel format of the source image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if generating a grayscale image) that will receive the
- * encoded image. These planes can be contiguous or non-contiguous in memory.
- * Use #tjPlaneSizeYUV() to determine the appropriate size for each plane based
- * on the image width, height, strides, and level of chrominance subsampling.
- * Refer to @ref YUVnotes "YUV Image Format Notes" for more details.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the output image. Setting the stride for
- * any plane to 0 is the same as setting it to the plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective plane widths.
- * You can adjust the strides in order to add an arbitrary amount of line
- * padding to each plane or to encode an RGB or grayscale image into a
- * subregion of a larger YUV planar image.
- *
- * @param subsamp the level of chrominance subsampling to be used when
- * generating the YUV image (see @ref TJSAMP
- * "Chrominance subsampling options".) To generate images suitable for X
- * Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
- * image compatible with the I420 (AKA "YUV420P") format.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf,
- int width, int pitch, int height,
- int pixelFormat, unsigned char **dstPlanes,
- int *strides, int subsamp, int flags);
-
-
-/**
- * Create a TurboJPEG decompressor instance.
- *
- * @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr2().)
-*/
-DLLEXPORT tjhandle tjInitDecompress(void);
-
-
-/**
- * Retrieve information about a JPEG image without decompressing it, or prime
- * the decompressor with quantization and Huffman tables.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing a JPEG image or an
- * "abbreviated table specification" (AKA "tables-only") datastream. Passing a
- * tables-only datastream to this function primes the decompressor with
- * quantization and Huffman tables that can be used when decompressing
- * subsequent "abbreviated image" datastreams. This is useful, for instance,
- * when decompressing video streams in which all frames share the same
- * quantization and Huffman tables.
- *
- * @param jpegSize size of the JPEG image or tables-only datastream (in bytes)
- *
- * @param width pointer to an integer variable that will receive the width (in
- * pixels) of the JPEG image. If <tt>jpegBuf</tt> points to a tables-only
- * datastream, then <tt>width</tt> is ignored.
- *
- * @param height pointer to an integer variable that will receive the height
- * (in pixels) of the JPEG image. If <tt>jpegBuf</tt> points to a tables-only
- * datastream, then <tt>height</tt> is ignored.
- *
- * @param jpegSubsamp pointer to an integer variable that will receive the
- * level of chrominance subsampling used when the JPEG image was compressed
- * (see @ref TJSAMP "Chrominance subsampling options".) If <tt>jpegBuf</tt>
- * points to a tables-only datastream, then <tt>jpegSubsamp</tt> is ignored.
- *
- * @param jpegColorspace pointer to an integer variable that will receive one
- * of the JPEG colorspace constants, indicating the colorspace of the JPEG
- * image (see @ref TJCS "JPEG colorspaces".) If <tt>jpegBuf</tt>
- * points to a tables-only datastream, then <tt>jpegColorspace</tt> is ignored.
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
-*/
-DLLEXPORT int tjDecompressHeader3(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp,
- int *jpegColorspace);
-
-
-/**
- * Returns a list of fractional scaling factors that the JPEG decompressor in
- * this implementation of TurboJPEG supports.
- *
- * @param numscalingfactors pointer to an integer variable that will receive
- * the number of elements in the list
- *
- * @return a pointer to a list of fractional scaling factors, or NULL if an
- * error is encountered (see #tjGetErrorStr2().)
-*/
-DLLEXPORT tjscalingfactor *tjGetScalingFactors(int *numscalingfactors);
-
-
-/**
- * Decompress a JPEG image to an RGB, grayscale, or CMYK image.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG image to decompress
- *
- * @param jpegSize size of the JPEG image (in bytes)
- *
- * @param dstBuf pointer to an image buffer that will receive the decompressed
- * image. This buffer should normally be <tt>pitch * scaledHeight</tt> bytes
- * in size, where <tt>scaledHeight</tt> can be determined by calling
- * #TJSCALED() with the JPEG image height and one of the scaling factors
- * returned by #tjGetScalingFactors(). The <tt>dstBuf</tt> pointer may also be
- * used to decompress into a specific region of a larger buffer.
- *
- * @param width desired width (in pixels) of the destination image. If this is
- * different than the width of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired width. If <tt>width</tt> is
- * set to 0, then only the height will be considered when determining the
- * scaled image size.
- *
- * @param pitch bytes per line in the destination image. Normally, this is
- * <tt>scaledWidth * #tjPixelSize[pixelFormat]</tt> if the decompressed image
- * is unpadded, else <tt>#TJPAD(scaledWidth * #tjPixelSize[pixelFormat])</tt>
- * if each line of the decompressed image is padded to the nearest 32-bit
- * boundary, as is the case for Windows bitmaps. (NOTE: <tt>scaledWidth</tt>
- * can be determined by calling #TJSCALED() with the JPEG image width and one
- * of the scaling factors returned by #tjGetScalingFactors().) You can also be
- * clever and use the pitch parameter to skip lines, etc. Setting this
- * parameter to 0 is the equivalent of setting it to
- * <tt>scaledWidth * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height desired height (in pixels) of the destination image. If this
- * is different than the height of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired height. If <tt>height</tt>
- * is set to 0, then only the width will be considered when determining the
- * scaled image size.
- *
- * @param pixelFormat pixel format of the destination image (see @ref
- * TJPF "Pixel formats".)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecompress2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags);
-
-
-/**
- * Decompress a JPEG image to a YUV planar image. This function performs JPEG
- * decompression but leaves out the color conversion step, so a planar YUV
- * image is generated instead of an RGB image.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG image to decompress
- *
- * @param jpegSize size of the JPEG image (in bytes)
- *
- * @param dstBuf pointer to an image buffer that will receive the YUV image.
- * Use #tjBufSizeYUV2() to determine the appropriate size for this buffer based
- * on the image width, height, padding, and level of subsampling. The Y,
- * U (Cb), and V (Cr) image planes will be stored sequentially in the buffer
- * (refer to @ref YUVnotes "YUV Image Format Notes".)
- *
- * @param width desired width (in pixels) of the YUV image. If this is
- * different than the width of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired width. If <tt>width</tt> is
- * set to 0, then only the height will be considered when determining the
- * scaled image size. If the scaled width is not an even multiple of the MCU
- * block width (see #tjMCUWidth), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param pad the width of each line in each plane of the YUV image will be
- * padded to the nearest multiple of this number of bytes (must be a power of
- * 2.) To generate images suitable for X Video, <tt>pad</tt> should be set to
- * 4.
- *
- * @param height desired height (in pixels) of the YUV image. If this is
- * different than the height of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired height. If <tt>height</tt>
- * is set to 0, then only the width will be considered when determining the
- * scaled image size. If the scaled height is not an even multiple of the MCU
- * block height (see #tjMCUHeight), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pad, int height, int flags);
-
-
-/**
- * Decompress a JPEG image into separate Y, U (Cb), and V (Cr) image
- * planes. This function performs JPEG decompression but leaves out the color
- * conversion step, so a planar YUV image is generated instead of an RGB image.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG image to decompress
- *
- * @param jpegSize size of the JPEG image (in bytes)
- *
- * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if decompressing a grayscale image) that will receive
- * the YUV image. These planes can be contiguous or non-contiguous in memory.
- * Use #tjPlaneSizeYUV() to determine the appropriate size for each plane based
- * on the scaled image width, scaled image height, strides, and level of
- * chrominance subsampling. Refer to @ref YUVnotes "YUV Image Format Notes"
- * for more details.
- *
- * @param width desired width (in pixels) of the YUV image. If this is
- * different than the width of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired width. If <tt>width</tt> is
- * set to 0, then only the height will be considered when determining the
- * scaled image size. If the scaled width is not an even multiple of the MCU
- * block width (see #tjMCUWidth), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the output image. Setting the stride for
- * any plane to 0 is the same as setting it to the scaled plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective scaled plane
- * widths. You can adjust the strides in order to add an arbitrary amount of
- * line padding to each plane or to decompress the JPEG image into a subregion
- * of a larger YUV planar image.
- *
- * @param height desired height (in pixels) of the YUV image. If this is
- * different than the height of the JPEG image being decompressed, then
- * TurboJPEG will use scaling in the JPEG decompressor to generate the largest
- * possible image that will fit within the desired height. If <tt>height</tt>
- * is set to 0, then only the width will be considered when determining the
- * scaled image size. If the scaled height is not an even multiple of the MCU
- * block height (see #tjMCUHeight), then an intermediate buffer copy will be
- * performed within TurboJPEG.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecompressToYUVPlanes(tjhandle handle,
- const unsigned char *jpegBuf,
- unsigned long jpegSize,
- unsigned char **dstPlanes, int width,
- int *strides, int height, int flags);
-
-
-/**
- * Decode a YUV planar image into an RGB or grayscale image. This function
- * uses the accelerated color conversion routines in the underlying
- * codec but does not execute any of the other steps in the JPEG decompression
- * process.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param srcBuf pointer to an image buffer containing a YUV planar image to be
- * decoded. The size of this buffer should match the value returned by
- * #tjBufSizeYUV2() for the given image width, height, padding, and level of
- * chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be
- * stored sequentially in the source buffer (refer to @ref YUVnotes
- * "YUV Image Format Notes".)
- *
- * @param pad Use this parameter to specify that the width of each line in each
- * plane of the YUV source image is padded to the nearest multiple of this
- * number of bytes (must be a power of 2.)
- *
- * @param subsamp the level of chrominance subsampling used in the YUV source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param dstBuf pointer to an image buffer that will receive the decoded
- * image. This buffer should normally be <tt>pitch * height</tt> bytes in
- * size, but the <tt>dstBuf</tt> pointer can also be used to decode into a
- * specific region of a larger buffer.
- *
- * @param width width (in pixels) of the source and destination images
- *
- * @param pitch bytes per line in the destination image. Normally, this should
- * be <tt>width * #tjPixelSize[pixelFormat]</tt> if the destination image is
- * unpadded, or <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line
- * of the destination image should be padded to the nearest 32-bit boundary, as
- * is the case for Windows bitmaps. You can also be clever and use the pitch
- * parameter to skip lines, etc. Setting this parameter to 0 is the equivalent
- * of setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source and destination images
- *
- * @param pixelFormat pixel format of the destination image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
- int pad, int subsamp, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelFormat,
- int flags);
-
-
-/**
- * Decode a set of Y, U (Cb), and V (Cr) image planes into an RGB or grayscale
- * image. This function uses the accelerated color conversion routines in the
- * underlying codec but does not execute any of the other steps in the JPEG
- * decompression process.
- *
- * @param handle a handle to a TurboJPEG decompressor or transformer instance
- *
- * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
- * (or just a Y plane, if decoding a grayscale image) that contain a YUV image
- * to be decoded. These planes can be contiguous or non-contiguous in memory.
- * The size of each plane should match the value returned by #tjPlaneSizeYUV()
- * for the given image width, height, strides, and level of chrominance
- * subsampling. Refer to @ref YUVnotes "YUV Image Format Notes" for more
- * details.
- *
- * @param strides an array of integers, each specifying the number of bytes per
- * line in the corresponding plane of the YUV source image. Setting the stride
- * for any plane to 0 is the same as setting it to the plane width (see
- * @ref YUVnotes "YUV Image Format Notes".) If <tt>strides</tt> is NULL, then
- * the strides for all planes will be set to their respective plane widths.
- * You can adjust the strides in order to specify an arbitrary amount of line
- * padding in each plane or to decode a subregion of a larger YUV planar image.
- *
- * @param subsamp the level of chrominance subsampling used in the YUV source
- * image (see @ref TJSAMP "Chrominance subsampling options".)
- *
- * @param dstBuf pointer to an image buffer that will receive the decoded
- * image. This buffer should normally be <tt>pitch * height</tt> bytes in
- * size, but the <tt>dstBuf</tt> pointer can also be used to decode into a
- * specific region of a larger buffer.
- *
- * @param width width (in pixels) of the source and destination images
- *
- * @param pitch bytes per line in the destination image. Normally, this should
- * be <tt>width * #tjPixelSize[pixelFormat]</tt> if the destination image is
- * unpadded, or <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> if each line
- * of the destination image should be padded to the nearest 32-bit boundary, as
- * is the case for Windows bitmaps. You can also be clever and use the pitch
- * parameter to skip lines, etc. Setting this parameter to 0 is the equivalent
- * of setting it to <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the source and destination images
- *
- * @param pixelFormat pixel format of the destination image (see @ref TJPF
- * "Pixel formats".)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjDecodeYUVPlanes(tjhandle handle,
- const unsigned char **srcPlanes,
- const int *strides, int subsamp,
- unsigned char *dstBuf, int width, int pitch,
- int height, int pixelFormat, int flags);
-
-
-/**
- * Create a new TurboJPEG transformer instance.
- *
- * @return a handle to the newly-created instance, or NULL if an error
- * occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT tjhandle tjInitTransform(void);
-
-
-/**
- * Losslessly transform a JPEG image into another JPEG image. Lossless
- * transforms work by moving the raw DCT coefficients from one JPEG image
- * structure to another without altering the values of the coefficients. While
- * this is typically faster than decompressing the image, transforming it, and
- * re-compressing it, lossless transforms are not free. Each lossless
- * transform requires reading and performing Huffman decoding on all of the
- * coefficients in the source image, regardless of the size of the destination
- * image. Thus, this function provides a means of generating multiple
- * transformed images from the same source or applying multiple
- * transformations simultaneously, in order to eliminate the need to read the
- * source coefficients multiple times.
- *
- * @param handle a handle to a TurboJPEG transformer instance
- *
- * @param jpegBuf pointer to a buffer containing the JPEG source image to
- * transform
- *
- * @param jpegSize size of the JPEG source image (in bytes)
- *
- * @param n the number of transformed JPEG images to generate
- *
- * @param dstBufs pointer to an array of n image buffers. <tt>dstBufs[i]</tt>
- * will receive a JPEG image that has been transformed using the parameters in
- * <tt>transforms[i]</tt>. TurboJPEG has the ability to reallocate the JPEG
- * buffer to accommodate the size of the JPEG image. Thus, you can choose to:
- * -# pre-allocate the JPEG buffer with an arbitrary size using #tjAlloc() and
- * let TurboJPEG grow the buffer as needed,
- * -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the buffer
- * for you, or
- * -# pre-allocate the buffer to a "worst case" size determined by calling
- * #tjBufSize() with the transformed or cropped width and height. Under normal
- * circumstances, this should ensure that the buffer never has to be
- * re-allocated (setting #TJFLAG_NOREALLOC guarantees that it won't be.) Note,
- * however, that there are some rare cases (such as transforming images with a
- * large amount of embedded EXIF or ICC profile data) in which the output image
- * will be larger than the worst-case size, and #TJFLAG_NOREALLOC cannot be
- * used in those cases.
- * .
- * If you choose option 1, <tt>dstSizes[i]</tt> should be set to the size of
- * your pre-allocated buffer. In any case, unless you have set
- * #TJFLAG_NOREALLOC, you should always check <tt>dstBufs[i]</tt> upon return
- * from this function, as it may have changed.
- *
- * @param dstSizes pointer to an array of n unsigned long variables that will
- * receive the actual sizes (in bytes) of each transformed JPEG image. If
- * <tt>dstBufs[i]</tt> points to a pre-allocated buffer, then
- * <tt>dstSizes[i]</tt> should be set to the size of the buffer. Upon return,
- * <tt>dstSizes[i]</tt> will contain the size of the JPEG image (in bytes.)
- *
- * @param transforms pointer to an array of n #tjtransform structures, each of
- * which specifies the transform parameters and/or cropping region for the
- * corresponding transformed output image.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
- * "flags"
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
- * and #tjGetErrorCode().)
- */
-DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
- unsigned long jpegSize, int n,
- unsigned char **dstBufs, unsigned long *dstSizes,
- tjtransform *transforms, int flags);
-
-
-/**
- * Destroy a TurboJPEG compressor, decompressor, or transformer instance.
- *
- * @param handle a handle to a TurboJPEG compressor, decompressor or
- * transformer instance
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT int tjDestroy(tjhandle handle);
-
-
-/**
- * Allocate an image buffer for use with TurboJPEG. You should always use
- * this function to allocate the JPEG destination buffer(s) for the compression
- * and transform functions unless you are disabling automatic buffer
- * (re)allocation (by setting #TJFLAG_NOREALLOC.)
- *
- * @param bytes the number of bytes to allocate
- *
- * @return a pointer to a newly-allocated buffer with the specified number of
- * bytes.
- *
- * @sa tjFree()
- */
-DLLEXPORT unsigned char *tjAlloc(int bytes);
-
-
-/**
- * Load an uncompressed image from disk into memory.
- *
- * @param filename name of a file containing an uncompressed image in Windows
- * BMP or PBMPLUS (PPM/PGM) format
- *
- * @param width pointer to an integer variable that will receive the width (in
- * pixels) of the uncompressed image
- *
- * @param align row alignment of the image buffer to be returned (must be a
- * power of 2.) For instance, setting this parameter to 4 will cause all rows
- * in the image buffer to be padded to the nearest 32-bit boundary, and setting
- * this parameter to 1 will cause all rows in the image buffer to be unpadded.
- *
- * @param height pointer to an integer variable that will receive the height
- * (in pixels) of the uncompressed image
- *
- * @param pixelFormat pointer to an integer variable that specifies or will
- * receive the pixel format of the uncompressed image buffer. The behavior of
- * #tjLoadImage() will vary depending on the value of <tt>*pixelFormat</tt>
- * passed to the function:
- * - @ref TJPF_UNKNOWN : The uncompressed image buffer returned by the function
- * will use the most optimal pixel format for the file type, and
- * <tt>*pixelFormat</tt> will contain the ID of this pixel format upon
- * successful return from the function.
- * - @ref TJPF_GRAY : Only PGM files and 8-bit BMP files with a grayscale
- * colormap can be loaded.
- * - @ref TJPF_CMYK : The RGB or grayscale pixels stored in the file will be
- * converted using a quick & dirty algorithm that is suitable only for testing
- * purposes (proper conversion between CMYK and other formats requires a color
- * management system.)
- * - Other @ref TJPF "pixel formats" : The uncompressed image buffer will use
- * the specified pixel format, and pixel format conversion will be performed if
- * necessary.
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
- * "flags".
- *
- * @return a pointer to a newly-allocated buffer containing the uncompressed
- * image, converted to the chosen pixel format and with the chosen row
- * alignment, or NULL if an error occurred (see #tjGetErrorStr2().) This
- * buffer should be freed using #tjFree().
- */
-DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
- int align, int *height, int *pixelFormat,
- int flags);
-
-
-/**
- * Save an uncompressed image from memory to disk.
- *
- * @param filename name of a file to which to save the uncompressed image.
- * The image will be stored in Windows BMP or PBMPLUS (PPM/PGM) format,
- * depending on the file extension.
- *
- * @param buffer pointer to an image buffer containing RGB, grayscale, or
- * CMYK pixels to be saved
- *
- * @param width width (in pixels) of the uncompressed image
- *
- * @param pitch bytes per line in the image buffer. Setting this parameter to
- * 0 is the equivalent of setting it to
- * <tt>width * #tjPixelSize[pixelFormat]</tt>.
- *
- * @param height height (in pixels) of the uncompressed image
- *
- * @param pixelFormat pixel format of the image buffer (see @ref TJPF
- * "Pixel formats".) If this parameter is set to @ref TJPF_GRAY, then the
- * image will be stored in PGM or 8-bit (indexed color) BMP format. Otherwise,
- * the image will be stored in PPM or 24-bit BMP format. If this parameter
- * is set to @ref TJPF_CMYK, then the CMYK pixels will be converted to RGB
- * using a quick & dirty algorithm that is suitable only for testing (proper
- * conversion between CMYK and other formats requires a color management
- * system.)
- *
- * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
- * "flags".
- *
- * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2().)
- */
-DLLEXPORT int tjSaveImage(const char *filename, unsigned char *buffer,
- int width, int pitch, int height, int pixelFormat,
- int flags);
-
-
-/**
- * Free an image buffer previously allocated by TurboJPEG. You should always
- * use this function to free JPEG destination buffer(s) that were automatically
- * (re)allocated by the compression and transform functions or that were
- * manually allocated using #tjAlloc().
- *
- * @param buffer address of the buffer to free. If the address is NULL, then
- * this function has no effect.
- *
- * @sa tjAlloc()
- */
-DLLEXPORT void tjFree(unsigned char *buffer);
-
-
-/**
- * Returns a descriptive error message explaining why the last command failed.
- *
- * @param handle a handle to a TurboJPEG compressor, decompressor, or
- * transformer instance, or NULL if the error was generated by a global
- * function (but note that retrieving the error message for a global function
- * is thread-safe only on platforms that support thread-local storage.)
- *
- * @return a descriptive error message explaining why the last command failed.
- */
-DLLEXPORT char *tjGetErrorStr2(tjhandle handle);
-
-
-/**
- * Returns a code indicating the severity of the last error. See
- * @ref TJERR "Error codes".
- *
- * @param handle a handle to a TurboJPEG compressor, decompressor or
- * transformer instance
- *
- * @return a code indicating the severity of the last error. See
- * @ref TJERR "Error codes".
- */
-DLLEXPORT int tjGetErrorCode(tjhandle handle);
-
-
-/* Deprecated functions and macros */
-#define TJFLAG_FORCEMMX 8
-#define TJFLAG_FORCESSE 16
-#define TJFLAG_FORCESSE2 32
-#define TJFLAG_FORCESSE3 128
-
-
-/* Backward compatibility functions and macros (nothing to see here) */
-#define NUMSUBOPT TJ_NUMSAMP
-#define TJ_444 TJSAMP_444
-#define TJ_422 TJSAMP_422
-#define TJ_420 TJSAMP_420
-#define TJ_411 TJSAMP_420
-#define TJ_GRAYSCALE TJSAMP_GRAY
-
-#define TJ_BGR 1
-#define TJ_BOTTOMUP TJFLAG_BOTTOMUP
-#define TJ_FORCEMMX TJFLAG_FORCEMMX
-#define TJ_FORCESSE TJFLAG_FORCESSE
-#define TJ_FORCESSE2 TJFLAG_FORCESSE2
-#define TJ_ALPHAFIRST 64
-#define TJ_FORCESSE3 TJFLAG_FORCESSE3
-#define TJ_FASTUPSAMPLE TJFLAG_FASTUPSAMPLE
-#define TJ_YUV 512
-
-DLLEXPORT unsigned long TJBUFSIZE(int width, int height);
-
-DLLEXPORT unsigned long TJBUFSIZEYUV(int width, int height, int jpegSubsamp);
-
-DLLEXPORT unsigned long tjBufSizeYUV(int width, int height, int subsamp);
-
-DLLEXPORT int tjCompress(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *dstBuf, unsigned long *compressedSize,
- int jpegSubsamp, int jpegQual, int flags);
-
-DLLEXPORT int tjEncodeYUV(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelSize,
- unsigned char *dstBuf, int subsamp, int flags);
-
-DLLEXPORT int tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf, int width,
- int pitch, int height, int pixelFormat,
- unsigned char *dstBuf, int subsamp, int flags);
-
-DLLEXPORT int tjDecompressHeader(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height);
-
-DLLEXPORT int tjDecompressHeader2(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, int *width,
- int *height, int *jpegSubsamp);
-
-DLLEXPORT int tjDecompress(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pitch, int height, int pixelSize,
- int flags);
-
-DLLEXPORT int tjDecompressToYUV(tjhandle handle, unsigned char *jpegBuf,
- unsigned long jpegSize, unsigned char *dstBuf,
- int flags);
-
-DLLEXPORT char *tjGetErrorStr(void);
-
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+#include "src/turbojpeg.h" /* inclink generated by yamaker */
diff --git a/contrib/libs/libjpeg-turbo/ya.make b/contrib/libs/libjpeg-turbo/ya.make
index 929245c0a1e..96201d83d04 100644
--- a/contrib/libs/libjpeg-turbo/ya.make
+++ b/contrib/libs/libjpeg-turbo/ya.make
@@ -11,12 +11,13 @@ LICENSE(
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-VERSION(2.1.4)
+VERSION(3.1.1)
-ORIGINAL_SOURCE(https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.1.4.tar.gz)
+ORIGINAL_SOURCE(https://github.com/libjpeg-turbo/libjpeg-turbo/archive/3.1.1.tar.gz)
ADDINCL(
contrib/libs/libjpeg-turbo
+ contrib/libs/libjpeg-turbo/src
FOR
asm
contrib/libs/libjpeg-turbo/simd/nasm
@@ -43,11 +44,7 @@ IF (SANITIZER_TYPE)
)
ENDIF()
-IF (OS_ANDROID)
- SRCS(
- jsimd_none.c
- )
-ELSEIF (ARCH_I386)
+IF (ARCH_I386 AND NOT OS_ANDROID)
SRCS(
simd/i386/jccolor-avx2.asm
simd/i386/jccolor-mmx.asm
@@ -149,10 +146,26 @@ ELSEIF (ARCH_ARM7_NEON AND NOT MSVC)
simd/arm/jquanti-neon.c
)
ELSEIF (ARCH_ARM7 AND NOT MSVC)
+ ADDINCL(
+ contrib/libs/libjpeg-turbo/simd/arm
+ )
SRCS(
simd/arm/aarch32/jchuff-neon.c
simd/arm/aarch32/jsimd.c
simd/arm/aarch32/jsimd_neon.S
+ simd/arm/jccolor-neon.c
+ simd/arm/jcgray-neon.c
+ simd/arm/jcphuff-neon.c
+ simd/arm/jcsample-neon.c
+ simd/arm/jdcolor-neon.c
+ simd/arm/jdmerge-neon.c
+ simd/arm/jdsample-neon.c
+ simd/arm/jfdctfst-neon.c
+ simd/arm/jfdctint-neon.c
+ simd/arm/jidctfst-neon.c
+ simd/arm/jidctint-neon.c
+ simd/arm/jidctred-neon.c
+ simd/arm/jquanti-neon.c
)
ELSEIF (ARCH_ARM64 AND NOT MSVC)
ADDINCL(
@@ -175,72 +188,122 @@ ELSEIF (ARCH_ARM64 AND NOT MSVC)
simd/arm/jidctred-neon.c
simd/arm/jquanti-neon.c
)
-ELSE()
- SRCS(
- jsimd_none.c
- )
ENDIF()
SRCS(
- jaricom.c
- jcapimin.c
- jcapistd.c
- jcarith.c
- jccoefct.c
- jccolor.c
- jcdctmgr.c
- jchuff.c
- jcicc.c
- jcinit.c
- jcmainct.c
- jcmarker.c
- jcmaster.c
- jcomapi.c
- jcparam.c
- jcphuff.c
- jcprepct.c
- jcsample.c
- jctrans.c
- jdapimin.c
- jdapistd.c
- jdarith.c
- jdatadst-tj.c
- jdatadst.c
- jdatasrc-tj.c
- jdatasrc.c
- jdcoefct.c
- jdcolor.c
- jddctmgr.c
- jdhuff.c
- jdicc.c
- jdinput.c
- jdmainct.c
- jdmarker.c
- jdmaster.c
- jdmerge.c
- jdphuff.c
- jdpostct.c
- jdsample.c
- jdtrans.c
- jerror.c
- jfdctflt.c
- jfdctfst.c
- jfdctint.c
- jidctflt.c
- jidctfst.c
- jidctint.c
- jidctred.c
- jmemmgr.c
- jmemnobs.c
- jquant1.c
- jquant2.c
- jutils.c
- rdbmp.c
- rdppm.c
- transupp.c
- turbojpeg.c
- wrbmp.c
- wrppm.c
+ src/jaricom.c
+ src/jcapimin.c
+ src/jcarith.c
+ src/jchuff.c
+ src/jcicc.c
+ src/jcinit.c
+ src/jclhuff.c
+ src/jcmarker.c
+ src/jcmaster.c
+ src/jcomapi.c
+ src/jcparam.c
+ src/jcphuff.c
+ src/jctrans.c
+ src/jdapimin.c
+ src/jdarith.c
+ src/jdatadst-tj.c
+ src/jdatadst.c
+ src/jdatasrc-tj.c
+ src/jdatasrc.c
+ src/jdhuff.c
+ src/jdicc.c
+ src/jdinput.c
+ src/jdlhuff.c
+ src/jdmarker.c
+ src/jdmaster.c
+ src/jdphuff.c
+ src/jdtrans.c
+ src/jerror.c
+ src/jfdctflt.c
+ src/jmemmgr.c
+ src/jmemnobs.c
+ src/jpeg_nbits.c
+ src/rdbmp.c
+ src/transupp.c
+ src/turbojpeg.c
+ src/wrapper/jcapistd-12.c
+ src/wrapper/jcapistd-16.c
+ src/wrapper/jcapistd-8.c
+ src/wrapper/jccoefct-12.c
+ src/wrapper/jccoefct-8.c
+ src/wrapper/jccolor-12.c
+ src/wrapper/jccolor-16.c
+ src/wrapper/jccolor-8.c
+ src/wrapper/jcdctmgr-12.c
+ src/wrapper/jcdctmgr-8.c
+ src/wrapper/jcdiffct-12.c
+ src/wrapper/jcdiffct-16.c
+ src/wrapper/jcdiffct-8.c
+ src/wrapper/jclossls-12.c
+ src/wrapper/jclossls-16.c
+ src/wrapper/jclossls-8.c
+ src/wrapper/jcmainct-12.c
+ src/wrapper/jcmainct-16.c
+ src/wrapper/jcmainct-8.c
+ src/wrapper/jcprepct-12.c
+ src/wrapper/jcprepct-16.c
+ src/wrapper/jcprepct-8.c
+ src/wrapper/jcsample-12.c
+ src/wrapper/jcsample-16.c
+ src/wrapper/jcsample-8.c
+ src/wrapper/jdapistd-12.c
+ src/wrapper/jdapistd-16.c
+ src/wrapper/jdapistd-8.c
+ src/wrapper/jdcoefct-12.c
+ src/wrapper/jdcoefct-8.c
+ src/wrapper/jdcolor-12.c
+ src/wrapper/jdcolor-16.c
+ src/wrapper/jdcolor-8.c
+ src/wrapper/jddctmgr-12.c
+ src/wrapper/jddctmgr-8.c
+ src/wrapper/jddiffct-12.c
+ src/wrapper/jddiffct-16.c
+ src/wrapper/jddiffct-8.c
+ src/wrapper/jdlossls-12.c
+ src/wrapper/jdlossls-16.c
+ src/wrapper/jdlossls-8.c
+ src/wrapper/jdmainct-12.c
+ src/wrapper/jdmainct-16.c
+ src/wrapper/jdmainct-8.c
+ src/wrapper/jdmerge-12.c
+ src/wrapper/jdmerge-8.c
+ src/wrapper/jdpostct-12.c
+ src/wrapper/jdpostct-16.c
+ src/wrapper/jdpostct-8.c
+ src/wrapper/jdsample-12.c
+ src/wrapper/jdsample-16.c
+ src/wrapper/jdsample-8.c
+ src/wrapper/jfdctfst-12.c
+ src/wrapper/jfdctfst-8.c
+ src/wrapper/jfdctint-12.c
+ src/wrapper/jfdctint-8.c
+ src/wrapper/jidctflt-12.c
+ src/wrapper/jidctflt-8.c
+ src/wrapper/jidctfst-12.c
+ src/wrapper/jidctfst-8.c
+ src/wrapper/jidctint-12.c
+ src/wrapper/jidctint-8.c
+ src/wrapper/jidctred-12.c
+ src/wrapper/jidctred-8.c
+ src/wrapper/jquant1-12.c
+ src/wrapper/jquant1-8.c
+ src/wrapper/jquant2-12.c
+ src/wrapper/jquant2-8.c
+ src/wrapper/jutils-12.c
+ src/wrapper/jutils-16.c
+ src/wrapper/jutils-8.c
+ src/wrapper/rdppm-12.c
+ src/wrapper/rdppm-16.c
+ src/wrapper/rdppm-8.c
+ src/wrapper/wrppm-12.c
+ src/wrapper/wrppm-16.c
+ src/wrapper/wrppm-8.c
+ src/wrbmp.c
)
END()