diff --git a/GNUmakefile b/GNUmakefile deleted file mode 100644 index 00d795d..0000000 --- a/GNUmakefile +++ /dev/null @@ -1,54 +0,0 @@ -#---------------------------------------------------------------------------- -# Makefile for VapourSynth-BM3D -#---------------------------------------------------------------------------- - -include config.mak - -vpath %.cpp $(SRCDIR) -vpath %.h $(SRCDIR) - -SRCS = source/BM3D_Base.cpp \ - source/BM3D_Basic.cpp \ - source/BM3D.cpp \ - source/BM3D_Final.cpp \ - source/VAggregate.cpp \ - source/VBM3D_Base.cpp \ - source/VBM3D_Basic.cpp \ - source/VBM3D_Final.cpp \ - source/VSPlugin.cpp - -OBJS = $(SRCS:%.cpp=%.o) - -.PHONY: all install clean distclean dep - -all: $(LIBNAME) - -$(LIBNAME): $(OBJS) - $(LD) -o $@ $(LDFLAGS) $^ $(LIBS) - -@ $(if $(STRIP), $(STRIP) -x $@) - -%.o: %.cpp .depend - $(CXX) $(CXXFLAGS) -c $< -o $@ - -install: all - install -d $(libdir) - install -m 755 $(LIBNAME) $(libdir) - -clean: - $(RM) *.dll *.so *.dylib $(OBJS) .depend - -distclean: clean - $(RM) config.* - -dep: .depend - -ifneq ($(wildcard .depend),) -include .depend -endif - -.depend: config.mak - @$(RM) .depend - @$(foreach SRC, $(SRCS:%=$(SRCDIR)/%), $(CXX) $(SRC) $(CXXFLAGS) -MT $(SRC:$(SRCDIR)/%.cpp=%.o) -MM >> .depend;) - -config.mak: - ./configure diff --git a/README.md b/README.md index bfa9993..2cef750 100644 --- a/README.md +++ b/README.md @@ -434,3 +434,10 @@ ref = haf.SMDegrain(src) flt = core.bm3d.VFinal(src, ref, radius=1, matrix=100).bm3d.VAggregate(radius=1) flt = core.bm3d.OPP2RGB(flt) ``` + +## Compilation + +``` +meson build +ninja -C build +``` diff --git a/configure b/configure deleted file mode 100755 index 7cbd5b7..0000000 --- a/configure +++ /dev/null @@ -1,263 +0,0 @@ -#!/bin/sh - -#---------------------------------------------------------------------------- -# configure script for VapourSynth-BM3D -#---------------------------------------------------------------------------- - -## This script was modified based on d2vsource/configure. - -# -- help ------------------------------------------------------------------- -if test x"$1" = x"-h" -o x"$1" = x"--help" ; then -cat << EOF -Usage: [PKG_CONFIG_PATH=/foo/bar/lib/pkgconfig] ./configure [options] -options: - -h, --help print help (this) - - --install=PATH set dir for install library - [/usr/local/lib/vapoursynth] - - --cxx=CXX use a defined compiler for compilation and linking - [g++] - --target-os=OS build programs to run on OS [auto] - --cross-prefix=PREFIX use PREFIX for compilation tools - --sysroot=SYSROOT root of cross-build tree - --enable-debug compile with debug symbols and never strip - - --extra-cxxflags=XCXXFLAGS add XCXXFLAGS to CXXFLAGS - --extra-ldflags=XLDFLAGS add XLDFLAGS to LDFLAGS - --extra-libs=XLIBS add XLIBS to LIBS - - --target=TARGET set target instruction set - - sse2 - [sse2] - -EOF -exit 1 -fi - -#-- func -------------------------------------------------------------------- -error_exit() -{ - echo error: $1 - exit 1 -} - -log_echo() -{ - echo $1 - echo >> config.log - echo --------------------------------- >> config.log - echo $1 >> config.log -} - -cc_check() -{ - rm -f conftest.c - if [ -n "$3" ]; then - echo "#include <$3>" >> config.log - echo 'extern "C" {' > conftest.cpp - echo "#include <$3>" >> conftest.cpp - echo } >> conftest.cpp - fi - echo "int main(void){$4 return 0;}" >> config.log - echo "int main(void){$4 return 0;}" >> conftest.cpp - echo $CXX conftest.cpp -o conftest $1 $2 >> config.log - $CXX conftest.cpp -o conftest $1 $2 2>> config.log - ret=$? - echo $ret >> config.log - rm -f conftest* - return $ret -} -#---------------------------------------------------------------------------- -rm -f config.* .depend - -SRCDIR="$(cd $(dirname $0); pwd)" -test "$SRCDIR" = "$(pwd)" && SRCDIR=. -test -n "$(echo $SRCDIR | grep ' ')" && \ - error_exit "out-of-tree builds are impossible with whitespace in source path" - -# -- init ------------------------------------------------------------------- -libdir="/usr/local/lib/vapoursynth" - -TARGET_OS="" -CROSS="" - -SYSROOT="" -CXX="g++" -LD="g++" -STRIP="strip" - -DEBUG="" - -LIBNAME="" - -CXXFLAGS="-std=c++11 -Wall -Wno-unused-local-typedefs -I. -I$SRCDIR/include -DNDEBUG" -LDFLAGS="" -SOFLAGS="-shared" -DEPLIBS="fftw3f" -TARGET="-msse2" - -# -- options ---------------------------------------------------------------- -echo all command lines: > config.log -echo "$*" >> config.log - -for opt; do - optarg="${opt#*=}" - case "$opt" in - --install=*) - libdir="$optarg" - ;; - --enable-debug) - DEBUG="enabled" - CXXFLAGS="$CXXFLAGS -g -UNDEBUG" - ;; - --cxx=*) - CXX="$optarg" - LD="$optarg" - ;; - --extra-cxxflags=*) - XCXXFLAGS="$optarg" - ;; - --extra-ldflags=*) - XLDFLAGS="$optarg" - ;; - --extra-libs=*) - XLIBS="$optarg" - ;; - --target-os=*) - TARGET_OS="$optarg" - ;; - --cross-prefix=*) - CROSS="$optarg" - ;; - --sysroot=*) - CXXFLAGS="$CXXFLAGS --sysroot=$optarg" - LDFLAGS="$LDFLAGS --sysroot=$optarg" - ;; - --target=*) - TARGET="-m$optarg" - ;; - *) - error_exit "unknown option $opt" - ;; - esac -done - -CXXFLAGS="$CXXFLAGS $XCXXFLAGS $TARGET" -LDFLAGS="$LDFLAGS $XLDFLAGS" - -CXX="${CROSS}${CXX}" -LD="${CROSS}${LD}" -STRIP="${CROSS}${STRIP}" -for f in "$CXX" "$LD" "$STRIP"; do - test -n "$(which $f 2> /dev/null)" || error_exit "$f is not executable" -done - -if test -n "$TARGET_OS"; then - TARGET_OS=$(echo $TARGET_OS | tr '[A-Z]' '[a-z]') -else - TARGET_OS=$($CXX -dumpmachine | tr '[A-Z]' '[a-z]') -fi -case "$TARGET_OS" in - *mingw*) - LIBNAME="BM3D.dll" - SOFLAGS="$SOFLAGS -Wl,--dll,--add-stdcall-alias" - ;; - *darwin*) - LIBNAME="libbm3d.dylib" - SOFLAGS="$SOFLAGS -dynamiclib -Wl,-undefined,suppress -Wl,-read_only_relocs,suppress -Wl,-flat_namespace" - ;; - *linux*|*bsd*) - LIBNAME="libbm3d.so" - CXXFLAGS="$CXXFLAGS -fPIC" - SOFLAGS="$SOFLAGS -Wl,-soname,$LIBNAME -fPIC" - ;; - *) - error_exit "target is unsupported system" -esac - - -log_echo "CXXFLAGS/LDFLAGS checking..." -if ! cc_check "$CXXFLAGS" "$LDFLAGS"; then - error_exit "invalid CXXFLAGS/LDFLAGS" -fi -if cc_check "-O2 -ffast-math $CXXFLAGS" "$LDFLAGS"; then - CXXFLAGS="-O2 -ffast-math $CXXFLAGS" -fi -if cc_check "$CXXFLAGS" "$LDFLAGS"; then - CXXFLAGS="$CXXFLAGS" -fi - -PKGCONFIGBIN="pkg-config" -test -n "$(which ${CROSS}${PKGCONFIGBIN} 2> /dev/null)" && \ - PKGCONFIGBIN=${CROSS}${PKGCONFIGBIN} - -if $PKGCONFIGBIN --exists $DEPLIBS 2> /dev/null; then - LIBS="$($PKGCONFIGBIN --libs $DEPLIBS)" - CXXFLAGS="$CXXFLAGS $($PKGCONFIGBIN --cflags $DEPLIBS)" -else - for lib in $DEPLIBS; do - LIBS="$LIBS -l${lib#lib}" - done - log_echo "warning: pkg-config or pc files not found, lib detection may be inaccurate." -fi - -log_echo "checking for vapoursynth headers..." -if $PKGCONFIGBIN --exists vapoursynth 2> /dev/null; then - VSCFLAGS="$($PKGCONFIGBIN --cflags vapoursynth)" -else - log_echo "warning: pkg-config or pc files not found, header detection may be inaccurate." -fi -if ! cc_check "$CXXFLAGS $VSCFLAGS" "$LDFLAGS $LIBS $XLIBS" "VapourSynth.h" "getVapourSynthAPI;" ; then - log_echo "error: vapoursynth checking failed." - error_exit "VapourSynth.h might not be installed." -fi - -log_echo "checking for fftw3f..." -if ! cc_check "$CXXFLAGS" "$LDFLAGS $LIBS $XLIBS" "fftw3.h" "fftwf_free(nullptr);" ; then - log_echo "error: fftw3f checking failed." - error_exit "fftw3.h might not be installed or some libs missing." -fi - -LDFLAGS="$SOFLAGS $LDFLAGS" -LIBS="$LIBS $XLIBS" -CXXFLAGS="$CXXFLAGS $VSCFLAGS" - - -cat >> config.mak << EOF -CXX = $CXX -LD = $LD -STRIP = $STRIP -CXXFLAGS = $CXXFLAGS -LDFLAGS = $LDFLAGS -LIBS = $LIBS -SRCDIR = $SRCDIR -LIBNAME = $LIBNAME -libdir = $libdir -EOF - -cat >> config.log << EOF ---------------------------------- - setting ---------------------------------- -EOF -cat config.mak >> config.log - -cat << EOF - -settings... -CXX = $CXX -LD = $LD -STRIP = $STRIP -CXXFLAGS = $CXXFLAGS -LDFLAGS = $LDFLAGS -LIBS = $LIBS -LIBNAME = $LIBNAME -install path = $libdir -EOF - -test "$SRCDIR" = "." || ln -sf $SRCDIR/GNUmakefile . - -echo configure finished. - -exit 0 diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..66f9131 --- /dev/null +++ b/meson.build @@ -0,0 +1,51 @@ +project('BM3D', 'cpp', + default_options : ['buildtype=release', 'b_ndebug=if-release', 'cpp_std=c++14'], + meson_version : '>=0.48.0', + version : '8' +) + +add_project_arguments('-Wno-unused-local-typedefs', language : 'cpp') + +sources = [ + 'include/Block.h', + 'include/BM3D.h', + 'include/BM3D_Base.h', + 'include/BM3D_Basic.h', + 'include/BM3D_Final.h', + 'include/Conversion.hpp', + 'include/fftw3_helper.hpp', + 'include/Helper.h', + 'include/OPP2RGB.h', + 'include/RGB2OPP.h', + 'include/Specification.h', + 'include/Type.h', + 'include/VAggregate.h', + 'include/VBM3D_Base.h', + 'include/VBM3D_Basic.h', + 'include/VBM3D_Final.h', + 'source/BM3D.cpp', + 'source/BM3D_Base.cpp', + 'source/BM3D_Basic.cpp', + 'source/BM3D_Final.cpp', + 'source/VAggregate.cpp', + 'source/VBM3D_Base.cpp', + 'source/VBM3D_Basic.cpp', + 'source/VBM3D_Final.cpp', + 'source/VSPlugin.cpp' +] + +vapoursynth_dep = dependency('vapoursynth').partial_dependency(compile_args : true, includes : true) + +fftw3f_dep = dependency('fftw3f') + +if host_machine.cpu_family().startswith('x86') + add_project_arguments('-mfpmath=sse', '-msse2', language : 'cpp') +endif + +shared_module('bm3d', sources, + dependencies : [vapoursynth_dep, fftw3f_dep], + include_directories : include_directories('include'), + install : true, + install_dir : join_paths(vapoursynth_dep.get_pkgconfig_variable('libdir'), 'vapoursynth'), + gnu_symbol_visibility : 'hidden' +)