Skip to content

Commit

Permalink
Merge pull request #3 from HolyWu/patch
Browse files Browse the repository at this point in the history
Fix error and add JPEG XL support to CI-built DLL
  • Loading branch information
myrsloik authored Oct 24, 2021
2 parents d1c65bd + abf961c commit 3042a32
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
git
mingw-w64-${{matrix.env}}-aom
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-highway
mingw-w64-${{matrix.env}}-lcms2
mingw-w64-${{matrix.env}}-libde265
mingw-w64-${{matrix.env}}-meson
Expand All @@ -50,8 +51,8 @@ jobs:
run: |
git clone https://github.com/AcademySoftwareFoundation/Imath.git --depth 1
pushd Imath
cmake -S . -B building -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/${{matrix.sys}} -DIMATH_INSTALL_PKG_CONFIG=ON -G Ninja
ninja -C building install
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/${{matrix.sys}} -DIMATH_INSTALL_PKG_CONFIG=ON -G Ninja
ninja -C build install
popd
rm -rf Imath
Expand All @@ -66,29 +67,41 @@ jobs:
rm -rf libheif
cp /${{matrix.sys}}/include/libheif/heif.h /${{matrix.sys}}/include/heif.h
- name: Install libjxl
run: |
git clone https://github.com/libjxl/libjxl.git --depth 1
pushd libjxl
git submodule update --init --remote --depth 1 --recursive
cmake -S . -B build -DINSTALL_GTEST=OFF -DBUILD_GMOCK=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-DHWY_DISABLED_TARGETS=\"HWY_AVX2|HWY_AVX3\"" -DCMAKE_INSTALL_PREFIX=/${{matrix.sys}} -DJPEGXL_ENABLE_BENCHMARK=OFF -DJPEGXL_ENABLE_EXAMPLES=OFF -DJPEGXL_ENABLE_MANPAGES=OFF -DJPEGXL_ENABLE_SJPEG=OFF -DJPEGXL_ENABLE_TOOLS=OFF -DJPEGXL_FORCE_SYSTEM_BROTLI=ON -DJPEGXL_FORCE_SYSTEM_HWY=ON -G Ninja
ninja -C build install
popd
rm -rf libjxl
mv /${{matrix.sys}}/lib/libjxl-static.a /${{matrix.sys}}/lib/libjxl.a
mv /${{matrix.sys}}/lib/libjxl_threads-static.a /${{matrix.sys}}/lib/libjxl_threads.a
- name: Install libtiff
run: |
git clone https://gitlab.com/libtiff/libtiff.git --depth 1
pushd libtiff
cmake -S . -B building -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/${{matrix.sys}} -Dlerc=OFF -G Ninja
ninja -C building install
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/${{matrix.sys}} -Dlerc=OFF -G Ninja
ninja -C build install
popd
rm -rf libtiff
- name: Install OpenEXR
run: |
git clone https://github.com/AcademySoftwareFoundation/openexr.git --depth 1
pushd openexr
cmake -S . -B building -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/${{matrix.sys}} -DOPENEXR_BUILD_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -DOPENEXR_INSTALL_PKG_CONFIG=ON -DOPENEXR_INSTALL_TOOLS=OFF -G Ninja
ninja -C building install
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/${{matrix.sys}} -DOPENEXR_BUILD_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF -DOPENEXR_INSTALL_PKG_CONFIG=ON -DOPENEXR_INSTALL_TOOLS=OFF -G Ninja
ninja -C build install
popd
rm -rf openexr
- name: Install ImageMagick
run: |
git clone https://github.com/ImageMagick/ImageMagick.git --depth 1
pushd ImageMagick
./configure --prefix=/${{matrix.sys}} --disable-shared --enable-hdri --disable-docs --without-utilities --without-xml
./configure --prefix=/${{matrix.sys}} --disable-shared --enable-hdri --disable-docs --without-utilities --with-jxl --without-xml CPPFLAGS="-DJXL_STATIC_DEFINE -DJXL_THREADS_STATIC_DEFINE"
make install -j2
popd
rm -rf ImageMagick
Expand All @@ -97,6 +110,7 @@ jobs:
run: |
meson build -Dstatic=true
ninja -C build
strip build/libimwri.dll
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
Expand Down
17 changes: 11 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ project('IMWRI', 'cpp',
default_options: ['buildtype=release', 'warning_level=2', 'b_lto=true', 'b_ndebug=if-release', 'cpp_std=c++14'],
license: 'LGPL-2.1-or-later',
meson_version: '>=0.51.0',
version: '1'
version: '2'
)

vapoursynth_dep = dependency('vapoursynth').partial_dependency(compile_args: true, includes: true)
add_project_arguments('-Wno-unused-parameter', language: 'cpp')

static = get_option('static')

vapoursynth_dep = dependency('vapoursynth', version: '>=55').partial_dependency(compile_args: true, includes: true)

deps = [
vapoursynth_dep,
dependency('libheif', static: get_option('static')),
dependency('libtiff-4', static: get_option('static')),
dependency('Magick++', static: get_option('static'))
dependency('libheif', required: false, static: static),
dependency('libjxl', required: false, static: static),
dependency('libtiff-4', required: false, static: static),
dependency('Magick++', static: static, version: '>=7.0.0')
]

install_dir = vapoursynth_dep.get_variable(pkgconfig: 'libdir') / 'vapoursynth'
Expand All @@ -29,7 +34,7 @@ if host_machine.system() == 'windows'
add_project_link_arguments('-lws2_32', language: 'cpp')
endif

if get_option('static')
if static
add_project_link_arguments('-static', language: 'cpp')
endif

Expand Down
6 changes: 3 additions & 3 deletions src/imwri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,12 @@ static const VSFrame *VS_CC readGetFrame(int n, int activationReason, void *inst
}

VSVideoFormat fformat;
vsapi->queryVideoFormat(&fformat, cf, stInteger, depth, 0, 0, core);
vsapi->queryVideoFormat(&fformat, cf, st, depth, 0, 0, core);
frame = vsapi->newVideoFrame(&fformat, width, height, nullptr, core);

if (d->alpha) {
VSVideoFormat aformat;
vsapi->queryVideoFormat(&aformat, cfGray, stInteger, depth, 0, 0, core);
vsapi->queryVideoFormat(&aformat, cfGray, st, depth, 0, 0, core);
alphaFrame = vsapi->newVideoFrame(&aformat, width, height, nullptr, core);
}

Expand Down Expand Up @@ -839,7 +839,7 @@ static void VS_CC readCreate(const VSMap *in, VSMap *out, void *userData, VSCore
// Init

VS_EXTERNAL_API(void) VapourSynthPluginInit2(VSPlugin *plugin, const VSPLUGINAPI *vspapi) {
vspapi->configPlugin(IMWRI_ID, IMWRI_NAMESPACE, IMWRI_PLUGIN_NAME, VS_MAKE_VERSION(1, 0), VAPOURSYNTH_API_VERSION, 0, plugin);
vspapi->configPlugin(IMWRI_ID, IMWRI_NAMESPACE, IMWRI_PLUGIN_NAME, VS_MAKE_VERSION(2, 0), VAPOURSYNTH_API_VERSION, 0, plugin);
vspapi->registerFunction("Write", "clip:vnode;imgformat:data;filename:data;firstnum:int:opt;quality:int:opt;dither:int:opt;compression_type:data:opt;overwrite:int:opt;alpha:vnode:opt;", "clip:vnode;", writeCreate, nullptr, plugin);
vspapi->registerFunction("Read", "filename:data[];firstnum:int:opt;mismatch:int:opt;alpha:int:opt;float_output:int:opt;embed_icc:int:opt;", "clip:vnode;", readCreate, nullptr, plugin);
}

0 comments on commit 3042a32

Please sign in to comment.