diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-01-18 23:35:14 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-01-19 01:11:47 +0100 |
commit | 45238d78cd9535b33bfbeeaaac4645af1bd93834 (patch) | |
tree | 13f9e3d1d69dbc563e9c77dd44f22d117a5614d7 | |
parent | 8a656121a392c16428a05e27d6a33a7923e1b0b2 (diff) | |
download | fiv-45238d78cd9535b33bfbeeaaac4645af1bd93834.tar.gz fiv-45238d78cd9535b33bfbeeaaac4645af1bd93834.tar.xz fiv-45238d78cd9535b33bfbeeaaac4645af1bd93834.zip |
Mesonize JPEG Quant Smooth
Now SIMD works on amd64, although the build remains questionable,
because it assumes that all of its compiler flags will work.
This way we lose an uncomfortable git submodule.
Also, add Meson subprojects to .gitignore.
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | fiv-io.c | 5 | ||||
m--------- | jpeg-quantsmooth | 0 | ||||
-rw-r--r-- | meson.build | 11 | ||||
-rw-r--r-- | meson_options.txt | 2 | ||||
-rw-r--r-- | subprojects/libjpegqs.wrap | 9 | ||||
-rw-r--r-- | subprojects/packagefiles/libjpegqs/meson.build | 41 |
8 files changed, 63 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e22552 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/subprojects/* +!/subprojects/*.wrap +!/subprojects/packagefiles diff --git a/.gitmodules b/.gitmodules index e8c4d71..c6b083b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "wuffs-mirror-release-c"] path = wuffs-mirror-release-c url = https://github.com/google/wuffs-mirror-release-c -[submodule "jpeg-quantsmooth"] - path = jpeg-quantsmooth - url = https://github.com/ilyakurdyukov/jpeg-quantsmooth.git @@ -32,10 +32,7 @@ #include <stdio.h> #include <jpeglib.h> -// This library is tricky to build, simply make it work at all. -#define NO_SIMD -#include <jpeg-quantsmooth/quantsmooth.h> -#undef NO_SIMD +#include <libjpegqs.h> #endif // HAVE_JPEG_QS // Colour management must be handled before RGB conversions. diff --git a/jpeg-quantsmooth b/jpeg-quantsmooth deleted file mode 160000 -Subproject c86c6418ea6c827513d206694847033f9ca5015 diff --git a/meson.build b/meson.build index cab46ad..0ccc8cd 100644 --- a/meson.build +++ b/meson.build @@ -17,6 +17,12 @@ add_project_arguments( # add_project_link_arguments(flags, language : ['c']) #endif +# The likelihood of this being installed is nearly zero. Enable the wrap. +libjpegqs = dependency('libjpegqs', + required : get_option('libjpegqs'), + allow_fallback : true, +) + lcms2 = dependency('lcms2', required : get_option('lcms2')) # Note that only libraw_r is thread-safe, but we'll just run it out-of process. libraw = dependency('libraw', required : get_option('libraw')) @@ -30,7 +36,6 @@ dependencies = [ dependency('pixman-1'), dependency('libturbojpeg'), - dependency('libjpeg', required : get_option('jpeg-qs')), dependency('libwebp'), dependency('libwebpdemux'), dependency('libwebpdecoder', required : false), @@ -42,6 +47,7 @@ dependencies = [ ), lcms2, + libjpegqs, libraw, librsvg, xcursor, @@ -54,8 +60,7 @@ dependencies = [ conf = configuration_data() conf.set_quoted('PROJECT_NAME', meson.project_name()) conf.set_quoted('PROJECT_VERSION', meson.project_version()) -# TODO(p): Wrap it in a Meson subproject, try to enable SIMD. -conf.set('HAVE_JPEG_QS', get_option('jpeg-qs').enabled()) +conf.set('HAVE_JPEG_QS', libjpegqs.found()) conf.set('HAVE_LCMS2', lcms2.found()) conf.set('HAVE_LIBRAW', libraw.found()) conf.set('HAVE_LIBRSVG', librsvg.found()) diff --git a/meson_options.txt b/meson_options.txt index 1ecc87b..d59a568 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,6 +1,6 @@ option('lcms2', type : 'feature', value : 'auto', description : 'Build with Little CMS colour management') -option('jpeg-qs', type : 'feature', value : 'enabled', +option('libjpegqs', type : 'feature', value : 'auto', description : 'Build with JPEG Quant Smooth integration') option('libraw', type : 'feature', value : 'auto', description : 'Build with raw photo support, requires LibRaw') diff --git a/subprojects/libjpegqs.wrap b/subprojects/libjpegqs.wrap new file mode 100644 index 0000000..c6a8f6f --- /dev/null +++ b/subprojects/libjpegqs.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = jpeg-quantsmooth-1.20210408 +source_url = https://github.com/ilyakurdyukov/jpeg-quantsmooth/archive/refs/tags/1.20210408.tar.gz +source_filename = jpeg-quantsmooth-1.20210408.tar.gz +source_hash = 5937ca26db33888cab8638c1a8dc7a367a953bd0857ceb1290d5abc6febf3116 +patch_directory = libjpegqs + +[provide] +libjpegqs = jpegqs_dep diff --git a/subprojects/packagefiles/libjpegqs/meson.build b/subprojects/packagefiles/libjpegqs/meson.build new file mode 100644 index 0000000..9755f59 --- /dev/null +++ b/subprojects/packagefiles/libjpegqs/meson.build @@ -0,0 +1,41 @@ +# vim: noet ts=4 sts=4 sw=4: +project('jpeg-qs', 'c') +add_project_arguments(meson.get_compiler('c') + .get_supported_arguments('-Wno-misleading-indentation'), + '-DWITH_LOG', language : 'c') + +deps = [ + dependency('libjpeg'), + meson.get_compiler('c').find_library('m', required : false), +] + +if host_machine.cpu_family() == 'x86_64' + jpegqs_avx512 = static_library('jpegqs-avx512', 'libjpegqs.c', + c_args : ['-DSIMD_SELECT', '-DSIMD_NAME=avx512', + '-mavx512f', '-mfma', '-DSIMD_AVX512'], + dependencies : deps) + jpegqs_avx2 = static_library('jpegqs-avx2', 'libjpegqs.c', + c_args : ['-DSIMD_SELECT', '-DSIMD_NAME=avx2', + '-mavx2', '-mfma', '-DSIMD_AVX2'], + dependencies : deps) + jpegqs_sse2 = static_library('jpegqs-sse2', 'libjpegqs.c', + c_args : ['-DSIMD_SELECT', '-DSIMD_NAME=sse2', '-msse2', '-DSIMD_SSE2'], + dependencies : deps) + jpegqs_base = static_library('jpegqs-base', 'libjpegqs.c', + c_args : ['-DSIMD_SELECT', '-DSIMD_NAME=base', '-DSIMD_BASE'], + dependencies : deps) + + jpegqs_lib = static_library('jpegqs', 'libjpegqs.c', + c_args : ['-DSIMD_SELECT'], + dependencies : deps, + link_with : [jpegqs_base, jpegqs_sse2, jpegqs_avx2, jpegqs_avx512]) +else + jpegqs_lib = static_library('jpegqs', 'libjpegqs.c', + c_args : ['-DNO_SIMD'], + dependencies : deps) +endif + +jpegqs_dep = declare_dependency( + link_with : jpegqs_lib, + include_directories : include_directories('.'), +) |