image_pack 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +18 -0
- data/LICENSE.txt +21 -0
- data/README.md +140 -0
- data/THIRD_PARTY_NOTICES.md +8 -0
- data/ext/image_pack/extconf.rb +515 -0
- data/ext/image_pack/image_pack.c +1618 -0
- data/ext/image_pack/vendor/.vendored +1 -0
- data/ext/image_pack/vendor/mozjpeg/BUILDING.txt +902 -0
- data/ext/image_pack/vendor/mozjpeg/CMakeLists.txt +1593 -0
- data/ext/image_pack/vendor/mozjpeg/LICENSE.md +132 -0
- data/ext/image_pack/vendor/mozjpeg/README-mozilla.txt +194 -0
- data/ext/image_pack/vendor/mozjpeg/README-turbo.txt +346 -0
- data/ext/image_pack/vendor/mozjpeg/README.ijg +258 -0
- data/ext/image_pack/vendor/mozjpeg/README.md +29 -0
- data/ext/image_pack/vendor/mozjpeg/cderror.h +128 -0
- data/ext/image_pack/vendor/mozjpeg/cdjpeg.c +156 -0
- data/ext/image_pack/vendor/mozjpeg/cdjpeg.h +171 -0
- data/ext/image_pack/vendor/mozjpeg/cjpeg.c +961 -0
- data/ext/image_pack/vendor/mozjpeg/cmyk.h +60 -0
- data/ext/image_pack/vendor/mozjpeg/coderules.txt +78 -0
- data/ext/image_pack/vendor/mozjpeg/croptest.in +95 -0
- data/ext/image_pack/vendor/mozjpeg/djpeg.c +855 -0
- data/ext/image_pack/vendor/mozjpeg/example.txt +464 -0
- data/ext/image_pack/vendor/mozjpeg/jaricom.c +157 -0
- data/ext/image_pack/vendor/mozjpeg/jcapimin.c +307 -0
- data/ext/image_pack/vendor/mozjpeg/jcapistd.c +168 -0
- data/ext/image_pack/vendor/mozjpeg/jcarith.c +972 -0
- data/ext/image_pack/vendor/mozjpeg/jccoefct.c +609 -0
- data/ext/image_pack/vendor/mozjpeg/jccolext.c +144 -0
- data/ext/image_pack/vendor/mozjpeg/jccolor.c +721 -0
- data/ext/image_pack/vendor/mozjpeg/jcdctmgr.c +1776 -0
- data/ext/image_pack/vendor/mozjpeg/jcext.c +219 -0
- data/ext/image_pack/vendor/mozjpeg/jchuff.c +1146 -0
- data/ext/image_pack/vendor/mozjpeg/jchuff.h +57 -0
- data/ext/image_pack/vendor/mozjpeg/jcicc.c +105 -0
- data/ext/image_pack/vendor/mozjpeg/jcinit.c +82 -0
- data/ext/image_pack/vendor/mozjpeg/jcmainct.c +162 -0
- data/ext/image_pack/vendor/mozjpeg/jcmarker.c +844 -0
- data/ext/image_pack/vendor/mozjpeg/jcmaster.c +958 -0
- data/ext/image_pack/vendor/mozjpeg/jcmaster.h +56 -0
- data/ext/image_pack/vendor/mozjpeg/jcomapi.c +109 -0
- data/ext/image_pack/vendor/mozjpeg/jconfig.h.in +37 -0
- data/ext/image_pack/vendor/mozjpeg/jconfig.txt +93 -0
- data/ext/image_pack/vendor/mozjpeg/jconfigint.h.in +44 -0
- data/ext/image_pack/vendor/mozjpeg/jcparam.c +991 -0
- data/ext/image_pack/vendor/mozjpeg/jcphuff.c +1123 -0
- data/ext/image_pack/vendor/mozjpeg/jcprepct.c +351 -0
- data/ext/image_pack/vendor/mozjpeg/jcsample.c +522 -0
- data/ext/image_pack/vendor/mozjpeg/jcstest.c +126 -0
- data/ext/image_pack/vendor/mozjpeg/jctrans.c +408 -0
- data/ext/image_pack/vendor/mozjpeg/jdapimin.c +407 -0
- data/ext/image_pack/vendor/mozjpeg/jdapistd.c +691 -0
- data/ext/image_pack/vendor/mozjpeg/jdarith.c +782 -0
- data/ext/image_pack/vendor/mozjpeg/jdatadst-tj.c +198 -0
- data/ext/image_pack/vendor/mozjpeg/jdatadst.c +299 -0
- data/ext/image_pack/vendor/mozjpeg/jdatasrc-tj.c +194 -0
- data/ext/image_pack/vendor/mozjpeg/jdatasrc.c +295 -0
- data/ext/image_pack/vendor/mozjpeg/jdcoefct.c +881 -0
- data/ext/image_pack/vendor/mozjpeg/jdcoefct.h +83 -0
- data/ext/image_pack/vendor/mozjpeg/jdcol565.c +384 -0
- data/ext/image_pack/vendor/mozjpeg/jdcolext.c +141 -0
- data/ext/image_pack/vendor/mozjpeg/jdcolor.c +881 -0
- data/ext/image_pack/vendor/mozjpeg/jdct.h +208 -0
- data/ext/image_pack/vendor/mozjpeg/jddctmgr.c +367 -0
- data/ext/image_pack/vendor/mozjpeg/jdhuff.c +834 -0
- data/ext/image_pack/vendor/mozjpeg/jdhuff.h +247 -0
- data/ext/image_pack/vendor/mozjpeg/jdicc.c +167 -0
- data/ext/image_pack/vendor/mozjpeg/jdinput.c +408 -0
- data/ext/image_pack/vendor/mozjpeg/jdmainct.c +460 -0
- data/ext/image_pack/vendor/mozjpeg/jdmainct.h +71 -0
- data/ext/image_pack/vendor/mozjpeg/jdmarker.c +1374 -0
- data/ext/image_pack/vendor/mozjpeg/jdmaster.c +727 -0
- data/ext/image_pack/vendor/mozjpeg/jdmaster.h +33 -0
- data/ext/image_pack/vendor/mozjpeg/jdmerge.c +587 -0
- data/ext/image_pack/vendor/mozjpeg/jdmerge.h +47 -0
- data/ext/image_pack/vendor/mozjpeg/jdmrg565.c +354 -0
- data/ext/image_pack/vendor/mozjpeg/jdmrgext.c +184 -0
- data/ext/image_pack/vendor/mozjpeg/jdphuff.c +679 -0
- data/ext/image_pack/vendor/mozjpeg/jdpostct.c +294 -0
- data/ext/image_pack/vendor/mozjpeg/jdsample.c +524 -0
- data/ext/image_pack/vendor/mozjpeg/jdsample.h +50 -0
- data/ext/image_pack/vendor/mozjpeg/jdtrans.c +156 -0
- data/ext/image_pack/vendor/mozjpeg/jerror.c +251 -0
- data/ext/image_pack/vendor/mozjpeg/jerror.h +335 -0
- data/ext/image_pack/vendor/mozjpeg/jfdctflt.c +169 -0
- data/ext/image_pack/vendor/mozjpeg/jfdctfst.c +227 -0
- data/ext/image_pack/vendor/mozjpeg/jfdctint.c +288 -0
- data/ext/image_pack/vendor/mozjpeg/jidctflt.c +240 -0
- data/ext/image_pack/vendor/mozjpeg/jidctfst.c +371 -0
- data/ext/image_pack/vendor/mozjpeg/jidctint.c +2627 -0
- data/ext/image_pack/vendor/mozjpeg/jidctred.c +409 -0
- data/ext/image_pack/vendor/mozjpeg/jinclude.h +147 -0
- data/ext/image_pack/vendor/mozjpeg/jmemmgr.c +1180 -0
- data/ext/image_pack/vendor/mozjpeg/jmemnobs.c +110 -0
- data/ext/image_pack/vendor/mozjpeg/jmemsys.h +178 -0
- data/ext/image_pack/vendor/mozjpeg/jmorecfg.h +382 -0
- data/ext/image_pack/vendor/mozjpeg/jpeg_nbits_table.h +4098 -0
- data/ext/image_pack/vendor/mozjpeg/jpegcomp.h +32 -0
- data/ext/image_pack/vendor/mozjpeg/jpegint.h +453 -0
- data/ext/image_pack/vendor/mozjpeg/jpeglib.h +1211 -0
- data/ext/image_pack/vendor/mozjpeg/jpegtran.c +827 -0
- data/ext/image_pack/vendor/mozjpeg/jpegyuv.c +172 -0
- data/ext/image_pack/vendor/mozjpeg/jquant1.c +856 -0
- data/ext/image_pack/vendor/mozjpeg/jquant2.c +1286 -0
- data/ext/image_pack/vendor/mozjpeg/jsimd.h +123 -0
- data/ext/image_pack/vendor/mozjpeg/jsimd_none.c +431 -0
- data/ext/image_pack/vendor/mozjpeg/jsimddct.h +70 -0
- data/ext/image_pack/vendor/mozjpeg/jstdhuff.c +144 -0
- data/ext/image_pack/vendor/mozjpeg/jutils.c +133 -0
- data/ext/image_pack/vendor/mozjpeg/jversion.h.in +56 -0
- data/ext/image_pack/vendor/mozjpeg/libjpeg.map.in +11 -0
- data/ext/image_pack/vendor/mozjpeg/libjpeg.txt +3150 -0
- data/ext/image_pack/vendor/mozjpeg/rdbmp.c +690 -0
- data/ext/image_pack/vendor/mozjpeg/rdcolmap.c +253 -0
- data/ext/image_pack/vendor/mozjpeg/rdgif.c +720 -0
- data/ext/image_pack/vendor/mozjpeg/rdjpeg.c +160 -0
- data/ext/image_pack/vendor/mozjpeg/rdjpgcom.c +494 -0
- data/ext/image_pack/vendor/mozjpeg/rdpng.c +194 -0
- data/ext/image_pack/vendor/mozjpeg/rdppm.c +781 -0
- data/ext/image_pack/vendor/mozjpeg/rdswitch.c +642 -0
- data/ext/image_pack/vendor/mozjpeg/rdtarga.c +508 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jccolext-neon.c +148 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jchuff-neon.c +334 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jsimd.c +976 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jsimd_neon.S +1200 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jccolext-neon.c +316 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jchuff-neon.c +411 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jsimd.c +1053 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jsimd_neon.S +2254 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/align.h +28 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jccolor-neon.c +160 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jcgray-neon.c +120 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jcgryext-neon.c +106 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jchuff.h +131 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jcphuff-neon.c +623 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jcsample-neon.c +192 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jdcolext-neon.c +374 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jdcolor-neon.c +141 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jdmerge-neon.c +144 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jdmrgext-neon.c +723 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jdsample-neon.c +569 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jfdctfst-neon.c +214 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jfdctint-neon.c +376 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jidctfst-neon.c +472 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jidctint-neon.c +801 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jidctred-neon.c +486 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/jquanti-neon.c +193 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/neon-compat.h +26 -0
- data/ext/image_pack/vendor/mozjpeg/simd/arm/neon-compat.h.in +37 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-avx2.asm +578 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-mmx.asm +476 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-sse2.asm +503 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-avx2.asm +121 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-mmx.asm +121 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-sse2.asm +120 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-avx2.asm +113 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-mmx.asm +113 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-sse2.asm +112 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-avx2.asm +457 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-mmx.asm +355 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-sse2.asm +382 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jchuff-sse2.asm +761 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcphuff-sse2.asm +662 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-avx2.asm +388 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-mmx.asm +324 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-sse2.asm +351 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-avx2.asm +515 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-mmx.asm +404 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-sse2.asm +458 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-avx2.asm +118 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-mmx.asm +117 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-sse2.asm +117 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-avx2.asm +136 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-mmx.asm +123 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-sse2.asm +135 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-avx2.asm +575 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-mmx.asm +460 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-sse2.asm +517 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-avx2.asm +760 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-mmx.asm +731 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-sse2.asm +724 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctflt-3dn.asm +318 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctflt-sse.asm +369 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctfst-mmx.asm +395 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctfst-sse2.asm +403 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-avx2.asm +331 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-mmx.asm +620 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-sse2.asm +633 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-3dn.asm +451 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-sse.asm +571 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-sse2.asm +497 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctfst-mmx.asm +499 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctfst-sse2.asm +501 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-avx2.asm +453 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-mmx.asm +851 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-sse2.asm +858 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctred-mmx.asm +704 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctred-sse2.asm +592 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-3dn.asm +230 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-mmx.asm +276 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-sse.asm +208 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquantf-sse2.asm +168 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquanti-avx2.asm +188 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jquanti-sse2.asm +201 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jsimd.c +1312 -0
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jsimdcpu.asm +135 -0
- data/ext/image_pack/vendor/mozjpeg/simd/jsimd.h +1258 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd.c +1143 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd_dspr2.S +4543 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd_dspr2_asm.h +292 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolext-mmi.c +455 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolor-mmi.c +148 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgray-mmi.c +132 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgryext-mmi.c +374 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcsample-mmi.c +98 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcsample.h +28 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolext-mmi.c +415 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolor-mmi.c +139 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmerge-mmi.c +149 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmrgext-mmi.c +615 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdsample-mmi.c +304 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctfst-mmi.c +255 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctint-mmi.c +398 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctfst-mmi.c +395 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctint-mmi.c +571 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jquanti-mmi.c +124 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jsimd.c +866 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jsimd_mmi.h +69 -0
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/loongson-mmintrin.h +1334 -0
- data/ext/image_pack/vendor/mozjpeg/simd/nasm/jcolsamp.inc +135 -0
- data/ext/image_pack/vendor/mozjpeg/simd/nasm/jdct.inc +31 -0
- data/ext/image_pack/vendor/mozjpeg/simd/nasm/jsimdcfg.inc +93 -0
- data/ext/image_pack/vendor/mozjpeg/simd/nasm/jsimdcfg.inc.h +133 -0
- data/ext/image_pack/vendor/mozjpeg/simd/nasm/jsimdext.inc +520 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolext-altivec.c +269 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolor-altivec.c +116 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgray-altivec.c +111 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgryext-altivec.c +228 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcsample-altivec.c +159 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcsample.h +28 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolext-altivec.c +276 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolor-altivec.c +106 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmerge-altivec.c +130 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmrgext-altivec.c +329 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdsample-altivec.c +400 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctfst-altivec.c +154 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctint-altivec.c +258 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctfst-altivec.c +255 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctint-altivec.c +357 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jquanti-altivec.c +250 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jsimd.c +884 -0
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jsimd_altivec.h +98 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolext-avx2.asm +559 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolext-sse2.asm +484 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolor-avx2.asm +121 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolor-sse2.asm +120 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgray-avx2.asm +113 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgray-sse2.asm +112 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgryext-avx2.asm +438 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgryext-sse2.asm +363 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jchuff-sse2.asm +583 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcphuff-sse2.asm +639 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcsample-avx2.asm +367 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcsample-sse2.asm +330 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolext-avx2.asm +496 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolext-sse2.asm +439 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolor-avx2.asm +118 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolor-sse2.asm +117 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmerge-avx2.asm +136 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmerge-sse2.asm +135 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmrgext-avx2.asm +596 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmrgext-sse2.asm +538 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdsample-avx2.asm +696 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdsample-sse2.asm +665 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctflt-sse.asm +355 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctfst-sse2.asm +389 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctint-avx2.asm +320 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctint-sse2.asm +619 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctflt-sse2.asm +482 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctfst-sse2.asm +491 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctint-avx2.asm +418 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctint-sse2.asm +847 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctred-sse2.asm +574 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jquantf-sse2.asm +155 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jquanti-avx2.asm +163 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jquanti-sse2.asm +188 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jsimd.c +1110 -0
- data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jsimdcpu.asm +86 -0
- data/ext/image_pack/vendor/mozjpeg/strtest.c +170 -0
- data/ext/image_pack/vendor/mozjpeg/structure.txt +900 -0
- data/ext/image_pack/vendor/mozjpeg/tjbench.c +1044 -0
- data/ext/image_pack/vendor/mozjpeg/tjbenchtest.in +256 -0
- data/ext/image_pack/vendor/mozjpeg/tjbenchtest.java.in +215 -0
- data/ext/image_pack/vendor/mozjpeg/tjexample.c +406 -0
- data/ext/image_pack/vendor/mozjpeg/tjexampletest.in +149 -0
- data/ext/image_pack/vendor/mozjpeg/tjexampletest.java.in +151 -0
- data/ext/image_pack/vendor/mozjpeg/tjunittest.c +961 -0
- data/ext/image_pack/vendor/mozjpeg/tjutil.c +70 -0
- data/ext/image_pack/vendor/mozjpeg/tjutil.h +53 -0
- data/ext/image_pack/vendor/mozjpeg/transupp.c +2373 -0
- data/ext/image_pack/vendor/mozjpeg/transupp.h +243 -0
- data/ext/image_pack/vendor/mozjpeg/turbojpeg-jni.c +1259 -0
- data/ext/image_pack/vendor/mozjpeg/turbojpeg.c +2320 -0
- data/ext/image_pack/vendor/mozjpeg/turbojpeg.h +1784 -0
- data/ext/image_pack/vendor/mozjpeg/usage.txt +679 -0
- data/ext/image_pack/vendor/mozjpeg/wizard.txt +220 -0
- data/ext/image_pack/vendor/mozjpeg/wrbmp.c +552 -0
- data/ext/image_pack/vendor/mozjpeg/wrgif.c +580 -0
- data/ext/image_pack/vendor/mozjpeg/wrjpgcom.c +577 -0
- data/ext/image_pack/vendor/mozjpeg/wrppm.c +366 -0
- data/ext/image_pack/vendor/mozjpeg/wrtarga.c +258 -0
- data/ext/image_pack/vendor/mozjpeg/yuvjpeg.c +268 -0
- data/lib/image_pack/backend.rb +8 -0
- data/lib/image_pack/configuration.rb +23 -0
- data/lib/image_pack/errors.rb +13 -0
- data/lib/image_pack/version.rb +5 -0
- data/lib/image_pack.rb +208 -0
- metadata +433 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "mkmf"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require "rbconfig"
|
|
6
|
+
|
|
7
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.4.0")
|
|
8
|
+
abort "image_pack requires Ruby >= 3.4.0; got #{RUBY_VERSION}"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
MOZJPEG_CORE_SOURCES = %w[
|
|
12
|
+
jcapimin.c
|
|
13
|
+
jcapistd.c
|
|
14
|
+
jccoefct.c
|
|
15
|
+
jccolor.c
|
|
16
|
+
jcdctmgr.c
|
|
17
|
+
jchuff.c
|
|
18
|
+
jcext.c
|
|
19
|
+
jcicc.c
|
|
20
|
+
jcinit.c
|
|
21
|
+
jcmainct.c
|
|
22
|
+
jcmarker.c
|
|
23
|
+
jcmaster.c
|
|
24
|
+
jcomapi.c
|
|
25
|
+
jcparam.c
|
|
26
|
+
jcphuff.c
|
|
27
|
+
jcprepct.c
|
|
28
|
+
jcsample.c
|
|
29
|
+
jctrans.c
|
|
30
|
+
jdapimin.c
|
|
31
|
+
jdapistd.c
|
|
32
|
+
jdatadst.c
|
|
33
|
+
jdatasrc.c
|
|
34
|
+
jdcoefct.c
|
|
35
|
+
jdcolor.c
|
|
36
|
+
jddctmgr.c
|
|
37
|
+
jdhuff.c
|
|
38
|
+
jdicc.c
|
|
39
|
+
jdinput.c
|
|
40
|
+
jdmainct.c
|
|
41
|
+
jdmarker.c
|
|
42
|
+
jdmaster.c
|
|
43
|
+
jdmerge.c
|
|
44
|
+
jdphuff.c
|
|
45
|
+
jdpostct.c
|
|
46
|
+
jdsample.c
|
|
47
|
+
jdtrans.c
|
|
48
|
+
jerror.c
|
|
49
|
+
jfdctflt.c
|
|
50
|
+
jfdctfst.c
|
|
51
|
+
jfdctint.c
|
|
52
|
+
jidctflt.c
|
|
53
|
+
jidctfst.c
|
|
54
|
+
jidctint.c
|
|
55
|
+
jidctred.c
|
|
56
|
+
jquant1.c
|
|
57
|
+
jquant2.c
|
|
58
|
+
jutils.c
|
|
59
|
+
jmemmgr.c
|
|
60
|
+
jmemnobs.c
|
|
61
|
+
].freeze
|
|
62
|
+
|
|
63
|
+
NEON_AARCH64_SOURCES = [
|
|
64
|
+
"simd/arm/aarch64/jsimd.c",
|
|
65
|
+
"simd/arm/aarch64/jchuff-neon.c",
|
|
66
|
+
"simd/arm/jccolor-neon.c",
|
|
67
|
+
"simd/arm/jcgray-neon.c",
|
|
68
|
+
"simd/arm/jcphuff-neon.c",
|
|
69
|
+
"simd/arm/jcsample-neon.c",
|
|
70
|
+
"simd/arm/jdcolor-neon.c",
|
|
71
|
+
"simd/arm/jdmerge-neon.c",
|
|
72
|
+
"simd/arm/jdsample-neon.c",
|
|
73
|
+
"simd/arm/jfdctfst-neon.c",
|
|
74
|
+
"simd/arm/jfdctint-neon.c",
|
|
75
|
+
"simd/arm/jidctfst-neon.c",
|
|
76
|
+
"simd/arm/jidctint-neon.c",
|
|
77
|
+
"simd/arm/jidctred-neon.c",
|
|
78
|
+
"simd/arm/jquanti-neon.c",
|
|
79
|
+
].freeze
|
|
80
|
+
|
|
81
|
+
X86_64_C_SOURCES = [
|
|
82
|
+
"simd/x86_64/jsimd.c",
|
|
83
|
+
].freeze
|
|
84
|
+
|
|
85
|
+
X86_64_ASM_SOURCES = %w[
|
|
86
|
+
simd/x86_64/jsimdcpu.asm
|
|
87
|
+
simd/x86_64/jfdctflt-sse.asm
|
|
88
|
+
simd/x86_64/jccolor-sse2.asm
|
|
89
|
+
simd/x86_64/jcgray-sse2.asm
|
|
90
|
+
simd/x86_64/jchuff-sse2.asm
|
|
91
|
+
simd/x86_64/jcphuff-sse2.asm
|
|
92
|
+
simd/x86_64/jcsample-sse2.asm
|
|
93
|
+
simd/x86_64/jdcolor-sse2.asm
|
|
94
|
+
simd/x86_64/jdmerge-sse2.asm
|
|
95
|
+
simd/x86_64/jdsample-sse2.asm
|
|
96
|
+
simd/x86_64/jfdctfst-sse2.asm
|
|
97
|
+
simd/x86_64/jfdctint-sse2.asm
|
|
98
|
+
simd/x86_64/jidctflt-sse2.asm
|
|
99
|
+
simd/x86_64/jidctfst-sse2.asm
|
|
100
|
+
simd/x86_64/jidctint-sse2.asm
|
|
101
|
+
simd/x86_64/jidctred-sse2.asm
|
|
102
|
+
simd/x86_64/jquantf-sse2.asm
|
|
103
|
+
simd/x86_64/jquanti-sse2.asm
|
|
104
|
+
simd/x86_64/jccolor-avx2.asm
|
|
105
|
+
simd/x86_64/jcgray-avx2.asm
|
|
106
|
+
simd/x86_64/jcsample-avx2.asm
|
|
107
|
+
simd/x86_64/jdcolor-avx2.asm
|
|
108
|
+
simd/x86_64/jdmerge-avx2.asm
|
|
109
|
+
simd/x86_64/jdsample-avx2.asm
|
|
110
|
+
simd/x86_64/jfdctint-avx2.asm
|
|
111
|
+
simd/x86_64/jidctint-avx2.asm
|
|
112
|
+
simd/x86_64/jquanti-avx2.asm
|
|
113
|
+
].freeze
|
|
114
|
+
|
|
115
|
+
X86_64_ASM_TEMPLATE_SOURCES = %w[
|
|
116
|
+
simd/x86_64/jccolext-sse2.asm
|
|
117
|
+
simd/x86_64/jcgryext-sse2.asm
|
|
118
|
+
simd/x86_64/jdcolext-sse2.asm
|
|
119
|
+
simd/x86_64/jdmrgext-sse2.asm
|
|
120
|
+
simd/x86_64/jccolext-avx2.asm
|
|
121
|
+
simd/x86_64/jcgryext-avx2.asm
|
|
122
|
+
simd/x86_64/jdcolext-avx2.asm
|
|
123
|
+
simd/x86_64/jdmrgext-avx2.asm
|
|
124
|
+
].freeze
|
|
125
|
+
|
|
126
|
+
MOZJPEG_VERSION = "4.1.5"
|
|
127
|
+
MOZJPEG_VERSION_NUMBER = "4001005"
|
|
128
|
+
|
|
129
|
+
def find_vendor_dir
|
|
130
|
+
candidates = [
|
|
131
|
+
File.join(__dir__, "vendor"),
|
|
132
|
+
File.join(__dir__, "..", "..", "..", "..", "ext", "image_pack", "vendor"),
|
|
133
|
+
File.expand_path("../../ext/image_pack/vendor", __dir__),
|
|
134
|
+
File.join(Dir.pwd, "ext", "image_pack", "vendor"),
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
dir = __dir__
|
|
138
|
+
6.times do
|
|
139
|
+
candidates << File.join(dir, "ext", "image_pack", "vendor")
|
|
140
|
+
dir = File.dirname(dir)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
candidates.find { |path| File.exist?(File.join(path, ".vendored")) }
|
|
144
|
+
&.then { |path| File.expand_path(path) }
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def find_image_pack_c_dir
|
|
148
|
+
candidates = [
|
|
149
|
+
__dir__,
|
|
150
|
+
File.join(__dir__, "..", "..", "..", "..", "ext", "image_pack"),
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
dir = __dir__
|
|
154
|
+
6.times do
|
|
155
|
+
candidates << File.join(dir, "ext", "image_pack")
|
|
156
|
+
dir = File.dirname(dir)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
candidates.find { |path| File.exist?(File.join(path, "image_pack.c")) }
|
|
160
|
+
&.then { |path| File.expand_path(path) } || __dir__
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def msvc?
|
|
164
|
+
/mswin|mingw|cygwin/i.match?(RUBY_PLATFORM)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def sizeof_size_t
|
|
168
|
+
value = RbConfig::CONFIG["SIZEOF_SIZE_T"] || RbConfig::CONFIG["SIZEOF_VOIDP"] || RbConfig::CONFIG["SIZEOF_LONG"]
|
|
169
|
+
value.to_i.positive? ? value.to_i : 8
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def inline_keyword
|
|
173
|
+
msvc? ? "__inline" : "inline __attribute__((always_inline))"
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def thread_local_keyword
|
|
177
|
+
msvc? ? "__declspec(thread)" : "__thread"
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def detect_simd_arch
|
|
181
|
+
case RUBY_PLATFORM
|
|
182
|
+
when /\A(?:arm64|aarch64)/ then :neon_aarch64
|
|
183
|
+
when /\A(?:x86_64|x64)/ then :x86_64
|
|
184
|
+
else :none
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def find_nasm
|
|
189
|
+
ENV["AS_NASM"].presence_or_nil ||
|
|
190
|
+
%w[nasm yasm].find { |bin| system("which #{bin} >/dev/null 2>&1") }
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def write_mozjpeg_config_headers!(build_dir, with_simd:)
|
|
194
|
+
with_simd_flag = with_simd ? "#define WITH_SIMD 1" : "#undef WITH_SIMD"
|
|
195
|
+
|
|
196
|
+
File.write(File.join(build_dir, "jconfig.h"), <<~HEADER)
|
|
197
|
+
/* Generated by image_pack extconf.rb. */
|
|
198
|
+
#define JPEG_LIB_VERSION 62
|
|
199
|
+
#define LIBJPEG_TURBO_VERSION #{MOZJPEG_VERSION}
|
|
200
|
+
#define LIBJPEG_TURBO_VERSION_NUMBER #{MOZJPEG_VERSION_NUMBER}
|
|
201
|
+
#undef C_ARITH_CODING_SUPPORTED
|
|
202
|
+
#undef D_ARITH_CODING_SUPPORTED
|
|
203
|
+
#define MEM_SRCDST_SUPPORTED 1
|
|
204
|
+
#{with_simd_flag}
|
|
205
|
+
#define BITS_IN_JSAMPLE 8
|
|
206
|
+
#undef RIGHT_SHIFT_IS_UNSIGNED
|
|
207
|
+
HEADER
|
|
208
|
+
|
|
209
|
+
File.write(File.join(build_dir, "jconfigint.h"), <<~HEADER)
|
|
210
|
+
/* Generated by image_pack extconf.rb. */
|
|
211
|
+
#define BUILD "image_pack"
|
|
212
|
+
#undef inline
|
|
213
|
+
#define INLINE #{inline_keyword}
|
|
214
|
+
#define THREAD_LOCAL #{thread_local_keyword}
|
|
215
|
+
#define PACKAGE_NAME "mozjpeg"
|
|
216
|
+
#define VERSION "#{MOZJPEG_VERSION}"
|
|
217
|
+
#define SIZEOF_SIZE_T #{sizeof_size_t}
|
|
218
|
+
#if defined(__has_attribute)
|
|
219
|
+
#if __has_attribute(fallthrough)
|
|
220
|
+
#define FALLTHROUGH __attribute__((fallthrough));
|
|
221
|
+
#else
|
|
222
|
+
#define FALLTHROUGH
|
|
223
|
+
#endif
|
|
224
|
+
#else
|
|
225
|
+
#define FALLTHROUGH
|
|
226
|
+
#endif
|
|
227
|
+
HEADER
|
|
228
|
+
|
|
229
|
+
File.write(File.join(build_dir, "jversion.h"), <<~HEADER)
|
|
230
|
+
/* Generated by image_pack extconf.rb. */
|
|
231
|
+
#if JPEG_LIB_VERSION >= 80
|
|
232
|
+
#define JVERSION "8d 15-Jan-2012"
|
|
233
|
+
#elif JPEG_LIB_VERSION >= 70
|
|
234
|
+
#define JVERSION "7 27-Jun-2009"
|
|
235
|
+
#else
|
|
236
|
+
#define JVERSION "6b 27-Mar-1998"
|
|
237
|
+
#endif
|
|
238
|
+
|
|
239
|
+
#define JCOPYRIGHT \
|
|
240
|
+
"Copyright (C) 2009-2023 D. R. Commander\\n" \
|
|
241
|
+
"Copyright (C) 2015, 2020 Google, Inc.\\n" \
|
|
242
|
+
"Copyright (C) 2019-2020 Arm Limited\\n" \
|
|
243
|
+
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\\n" \
|
|
244
|
+
"Copyright (C) 2011-2016 Siarhei Siamashka\\n" \
|
|
245
|
+
"Copyright (C) 2015 Intel Corporation\\n" \
|
|
246
|
+
"Copyright (C) 2013-2014 Linaro Limited\\n" \
|
|
247
|
+
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\\n" \
|
|
248
|
+
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\\n" \
|
|
249
|
+
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\\n" \
|
|
250
|
+
"Copyright (C) 1999-2006 MIYASAKA Masaru\\n" \
|
|
251
|
+
"Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
|
|
252
|
+
|
|
253
|
+
#define JCOPYRIGHT_SHORT \
|
|
254
|
+
"Copyright (C) 1991-2023 The libjpeg-turbo Project and many others"
|
|
255
|
+
HEADER
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def select_simd_backend(mozjpeg_dir, arch)
|
|
259
|
+
case arch
|
|
260
|
+
when :neon_aarch64
|
|
261
|
+
template_in = File.join(mozjpeg_dir, "simd", "arm", "neon-compat.h.in")
|
|
262
|
+
sources_present = NEON_AARCH64_SOURCES.all? { |rel| File.exist?(File.join(mozjpeg_dir, rel)) }
|
|
263
|
+
template_present = File.exist?(template_in)
|
|
264
|
+
|
|
265
|
+
if sources_present && template_present
|
|
266
|
+
write_neon_compat_header!(mozjpeg_dir)
|
|
267
|
+
|
|
268
|
+
{
|
|
269
|
+
kind: :neon_aarch64,
|
|
270
|
+
c_sources: NEON_AARCH64_SOURCES,
|
|
271
|
+
asm_sources: [],
|
|
272
|
+
extra_includes: [
|
|
273
|
+
File.join(mozjpeg_dir, "simd", "arm"),
|
|
274
|
+
File.join(mozjpeg_dir, "simd", "arm", "aarch64"),
|
|
275
|
+
],
|
|
276
|
+
extra_cflags: "-DNEON_INTRINSICS=1"
|
|
277
|
+
}
|
|
278
|
+
else
|
|
279
|
+
missing = NEON_AARCH64_SOURCES.reject { |rel| File.exist?(File.join(mozjpeg_dir, rel)) }
|
|
280
|
+
missing << "simd/arm/neon-compat.h.in" unless template_present
|
|
281
|
+
warn "image_pack: ARM64 detected but NEON sources missing under #{mozjpeg_dir}:"
|
|
282
|
+
missing.each { |m| warn " - #{m}" }
|
|
283
|
+
warn "image_pack: re-run `bundle exec rake vendor` after updating script/vendor_libs.rb."
|
|
284
|
+
warn "image_pack: falling back to scalar."
|
|
285
|
+
{ kind: :none }
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
when :x86_64
|
|
289
|
+
if find_nasm.nil?
|
|
290
|
+
warn "image_pack: x86_64 detected but NASM/YASM not found on PATH. Falling back to scalar; install nasm for ~3-4x speedup."
|
|
291
|
+
{ kind: :none }
|
|
292
|
+
elsif !X86_64_C_SOURCES.all? { |rel| File.exist?(File.join(mozjpeg_dir, rel)) }
|
|
293
|
+
warn "image_pack: x86_64 SIMD sources missing under #{mozjpeg_dir}/simd/x86_64/. Falling back to scalar."
|
|
294
|
+
{ kind: :none }
|
|
295
|
+
else
|
|
296
|
+
{
|
|
297
|
+
kind: :x86_64_simd,
|
|
298
|
+
c_sources: X86_64_C_SOURCES,
|
|
299
|
+
asm_sources: X86_64_ASM_SOURCES.select { |rel| File.exist?(File.join(mozjpeg_dir, rel)) },
|
|
300
|
+
extra_includes: [
|
|
301
|
+
File.join(mozjpeg_dir, "simd"),
|
|
302
|
+
File.join(mozjpeg_dir, "simd", "nasm"),
|
|
303
|
+
File.join(mozjpeg_dir, "simd", "x86_64"),
|
|
304
|
+
],
|
|
305
|
+
extra_cflags: "",
|
|
306
|
+
}
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
else
|
|
310
|
+
{ kind: :none }
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
NEON_COMPAT_HEADER = <<~HEADER
|
|
315
|
+
/*
|
|
316
|
+
* Generated by image_pack extconf.rb (replaces simd/arm/neon-compat.h.in
|
|
317
|
+
* which CMake would otherwise process). All three intrinsic feature flags
|
|
318
|
+
* are unconditionally enabled — every AArch64 toolchain image_pack supports
|
|
319
|
+
* provides them.
|
|
320
|
+
*/
|
|
321
|
+
#ifndef IMAGE_PACK_NEON_COMPAT_H
|
|
322
|
+
#define IMAGE_PACK_NEON_COMPAT_H
|
|
323
|
+
|
|
324
|
+
#define HAVE_VLD1_S16_X3
|
|
325
|
+
#define HAVE_VLD1_U16_X2
|
|
326
|
+
#define HAVE_VLD1Q_U8_X4
|
|
327
|
+
|
|
328
|
+
#if defined(_MSC_VER) && !defined(__clang__)
|
|
329
|
+
#define BUILTIN_CLZ(x) _CountLeadingZeros(x)
|
|
330
|
+
#define BUILTIN_CLZLL(x) _CountLeadingZeros64(x)
|
|
331
|
+
#define BUILTIN_BSWAP64(x) _byteswap_uint64(x)
|
|
332
|
+
#elif defined(__clang__) || defined(__GNUC__)
|
|
333
|
+
#define BUILTIN_CLZ(x) __builtin_clz(x)
|
|
334
|
+
#define BUILTIN_CLZLL(x) __builtin_clzll(x)
|
|
335
|
+
#define BUILTIN_BSWAP64(x) __builtin_bswap64(x)
|
|
336
|
+
#else
|
|
337
|
+
#error "Unknown compiler"
|
|
338
|
+
#endif
|
|
339
|
+
|
|
340
|
+
#endif /* IMAGE_PACK_NEON_COMPAT_H */
|
|
341
|
+
HEADER
|
|
342
|
+
|
|
343
|
+
def write_neon_compat_header!(mozjpeg_dir)
|
|
344
|
+
target = File.join(mozjpeg_dir, "simd", "arm", "neon-compat.h")
|
|
345
|
+
return target if File.exist?(target) &&
|
|
346
|
+
File.read(target) == NEON_COMPAT_HEADER
|
|
347
|
+
FileUtils.mkdir_p(File.dirname(target))
|
|
348
|
+
File.write(target, NEON_COMPAT_HEADER)
|
|
349
|
+
puts " Generated #{target}"
|
|
350
|
+
target
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
class String
|
|
354
|
+
unless instance_methods.include?(:presence_or_nil)
|
|
355
|
+
def presence_or_nil
|
|
356
|
+
empty? ? nil : self
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
class NilClass
|
|
361
|
+
unless instance_methods.include?(:presence_or_nil)
|
|
362
|
+
def presence_or_nil
|
|
363
|
+
nil
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
def configure_vendored_mozjpeg(vendor_dir)
|
|
369
|
+
versions = File.read(File.join(vendor_dir, ".vendored"))
|
|
370
|
+
mozjpeg_dir = File.join(vendor_dir, "mozjpeg")
|
|
371
|
+
|
|
372
|
+
abort "vendored MozJPEG sources not found in #{mozjpeg_dir}" unless Dir.exist?(mozjpeg_dir)
|
|
373
|
+
|
|
374
|
+
missing_sources = MOZJPEG_CORE_SOURCES.reject { |source| File.exist?(File.join(mozjpeg_dir, source)) }
|
|
375
|
+
abort "vendored MozJPEG sources are incomplete: #{missing_sources.join(', ')}" unless missing_sources.empty?
|
|
376
|
+
|
|
377
|
+
arch = detect_simd_arch
|
|
378
|
+
backend = select_simd_backend(mozjpeg_dir, arch)
|
|
379
|
+
with_simd = backend[:kind] != :none
|
|
380
|
+
simd_c_sources = backend.fetch(:c_sources, [])
|
|
381
|
+
simd_asm_sources = backend.fetch(:asm_sources, [])
|
|
382
|
+
scalar_fallback = with_simd ? [] : ["jsimd_none.c"]
|
|
383
|
+
|
|
384
|
+
all_c_sources = MOZJPEG_CORE_SOURCES + scalar_fallback + simd_c_sources
|
|
385
|
+
|
|
386
|
+
puts "Building with VENDORED MozJPEG from #{mozjpeg_dir}"
|
|
387
|
+
puts " #{versions.tr("\n", ", ")}"
|
|
388
|
+
puts " arch=#{arch} backend=#{backend[:kind]}"
|
|
389
|
+
puts " #{MOZJPEG_CORE_SOURCES.length} core C files + " \
|
|
390
|
+
"#{simd_c_sources.length} SIMD C files + " \
|
|
391
|
+
"#{simd_asm_sources.length} ASM files" \
|
|
392
|
+
"#{with_simd ? '' : ' + jsimd_none.c stub'}"
|
|
393
|
+
|
|
394
|
+
build_dir = Dir.pwd
|
|
395
|
+
write_mozjpeg_config_headers!(build_dir, with_simd: with_simd)
|
|
396
|
+
|
|
397
|
+
$CPPFLAGS += " -I#{build_dir}"
|
|
398
|
+
$CPPFLAGS += " -I#{mozjpeg_dir}"
|
|
399
|
+
|
|
400
|
+
vpath_dirs = [find_image_pack_c_dir, mozjpeg_dir]
|
|
401
|
+
|
|
402
|
+
if with_simd
|
|
403
|
+
backend[:extra_includes].each { |inc| $CPPFLAGS += " -I#{inc}" }
|
|
404
|
+
extra_cflags = backend[:extra_cflags].to_s
|
|
405
|
+
$CFLAGS += " #{extra_cflags}" unless extra_cflags.empty?
|
|
406
|
+
simd_c_dirs = simd_c_sources.map { |rel| File.dirname(File.join(mozjpeg_dir, rel)) }.uniq
|
|
407
|
+
vpath_dirs += simd_c_dirs
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
$srcs = ["image_pack.c"] + all_c_sources
|
|
411
|
+
$VPATH = vpath_dirs.uniq
|
|
412
|
+
|
|
413
|
+
{
|
|
414
|
+
backend: backend,
|
|
415
|
+
with_simd: with_simd,
|
|
416
|
+
vpath_dirs: vpath_dirs.uniq,
|
|
417
|
+
asm_sources: simd_asm_sources,
|
|
418
|
+
mozjpeg_dir: mozjpeg_dir,
|
|
419
|
+
}
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
def patch_makefile_vpath!(vpath_dirs)
|
|
423
|
+
makefile = File.read("Makefile")
|
|
424
|
+
return if makefile.include?("# vendored mozjpeg vpath")
|
|
425
|
+
|
|
426
|
+
vpath_lines = vpath_dirs.map { |dir| "vpath %.c #{dir}" }.join("\n")
|
|
427
|
+
|
|
428
|
+
makefile.sub!(/^(VPATH\s*=[^\n]*)$/) { "#{Regexp.last_match(1)}\n# vendored mozjpeg vpath\n#{vpath_lines}" }
|
|
429
|
+
File.write("Makefile", makefile)
|
|
430
|
+
puts " Patched Makefile with #{vpath_dirs.length} VPATH entries"
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def patch_makefile_nasm!(asm_sources, mozjpeg_dir)
|
|
434
|
+
return if asm_sources.empty?
|
|
435
|
+
|
|
436
|
+
nasm = find_nasm
|
|
437
|
+
abort "NASM/YASM disappeared between probe and Makefile patch?" unless nasm
|
|
438
|
+
|
|
439
|
+
fmt, platform_define, pic_define =
|
|
440
|
+
case RUBY_PLATFORM
|
|
441
|
+
when /darwin/
|
|
442
|
+
["macho64", "MACHO", nil]
|
|
443
|
+
when /linux/
|
|
444
|
+
["elf64", "ELF", "PIC"]
|
|
445
|
+
when /mswin|mingw|cygwin/
|
|
446
|
+
["win64", "WIN64", nil]
|
|
447
|
+
else
|
|
448
|
+
["elf64", "ELF", "PIC"]
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
obj_ext = RbConfig::CONFIG["OBJEXT"] || "o"
|
|
452
|
+
|
|
453
|
+
asm_objs = asm_sources.map { |rel| File.basename(rel, ".asm") + ".#{obj_ext}" }
|
|
454
|
+
inc_dirs = [
|
|
455
|
+
File.join(mozjpeg_dir, "simd"),
|
|
456
|
+
File.join(mozjpeg_dir, "simd", "nasm"),
|
|
457
|
+
File.join(mozjpeg_dir, "simd", "x86_64"),
|
|
458
|
+
File.join(mozjpeg_dir, "win"),
|
|
459
|
+
].select { |d| Dir.exist?(d) }
|
|
460
|
+
|
|
461
|
+
nasm_includes = inc_dirs.map { |d| "-I#{d}/" }.join(" ")
|
|
462
|
+
arch_defines = %w[elf64 macho64 win64].include?(fmt) ? ["__x86_64__"] : []
|
|
463
|
+
nasm_defines = ([platform_define, pic_define] + arch_defines).compact.map { |name| "-D#{name}" }.join(" ")
|
|
464
|
+
|
|
465
|
+
rules = +""
|
|
466
|
+
asm_sources.each do |rel|
|
|
467
|
+
src = File.join(mozjpeg_dir, rel)
|
|
468
|
+
obj = File.basename(rel, ".asm") + ".#{obj_ext}"
|
|
469
|
+
rules << "#{obj}: #{src}\n"
|
|
470
|
+
rules << "\t#{nasm} -f#{fmt} #{nasm_defines} #{nasm_includes} -o $@ $<\n"
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
makefile = File.read("Makefile")
|
|
474
|
+
return if makefile.include?("# vendored mozjpeg nasm")
|
|
475
|
+
|
|
476
|
+
asm_obj_line = asm_objs.join(" ")
|
|
477
|
+
makefile.sub!(/^(OBJS\s*=[^\n]*)$/) { "#{Regexp.last_match(1)} #{asm_obj_line}\n# vendored mozjpeg nasm" }
|
|
478
|
+
makefile << "\n# vendored mozjpeg nasm rules\n"
|
|
479
|
+
makefile << rules
|
|
480
|
+
File.write("Makefile", makefile)
|
|
481
|
+
puts " Patched Makefile with #{asm_sources.length} NASM rules (#{nasm}, -f#{fmt})"
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
vendor_dir = find_vendor_dir
|
|
485
|
+
|
|
486
|
+
unless vendor_dir
|
|
487
|
+
abort <<~MSG
|
|
488
|
+
vendored native library is missing.
|
|
489
|
+
Run `bundle exec rake vendor` before building the gem package.
|
|
490
|
+
Published gems must include ext/image_pack/vendor/.vendored and ext/image_pack/vendor/mozjpeg/*.
|
|
491
|
+
MSG
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
build_info = configure_vendored_mozjpeg(vendor_dir)
|
|
495
|
+
|
|
496
|
+
$warnflags = ""
|
|
497
|
+
|
|
498
|
+
unless msvc?
|
|
499
|
+
$CFLAGS += " -O3 -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -std=gnu11"
|
|
500
|
+
else
|
|
501
|
+
$CFLAGS += " -O2"
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
$CFLAGS += " -DIMAGE_PACK_RUBY34_ONLY=1"
|
|
505
|
+
$CFLAGS += build_info[:with_simd] ? " -DIMAGE_PACK_HAS_SIMD=1" : " -DIMAGE_PACK_PURE_C=1"
|
|
506
|
+
$LIBS += " -lm" unless msvc?
|
|
507
|
+
|
|
508
|
+
have_header("ruby/thread.h") or abort "ruby/thread.h not found"
|
|
509
|
+
have_header("ruby/version.h") or abort "ruby/version.h not found"
|
|
510
|
+
have_header("jpeglib.h") or abort "jpeglib.h not found in vendored MozJPEG include paths"
|
|
511
|
+
|
|
512
|
+
create_makefile("image_pack/image_pack")
|
|
513
|
+
|
|
514
|
+
patch_makefile_vpath!(build_info[:vpath_dirs])
|
|
515
|
+
patch_makefile_nasm!(build_info[:asm_sources], build_info[:mozjpeg_dir])
|