Merge branch 'autotools'

This commit is contained in:
Arttu Ylä-Outinen 2015-12-21 15:54:30 +02:00
commit 9abdee7cc3
12 changed files with 394 additions and 40 deletions

22
.gitignore vendored
View file

@ -11,6 +11,24 @@
/doxygen_html /doxygen_html
/doxygen /doxygen
# Autotools generated
.deps
.dirstamp
.libs
Makefile
Makefile.in
/aclocal.m4
/autom4te.cache
/build-aux
/config.h
/config.h.in*
/config.status
/configure
/kvazaar
/libtool
/m4
/stamp-h1
# Other files # Other files
*.exe *.exe
*.o *.o
@ -19,10 +37,14 @@
*.log *.log
.kdev4 .kdev4
configure.scan
src/kvazaar src/kvazaar
src/libkvazaar.a src/libkvazaar.a
src/libkvazaar.la
src/libkvazaar.so.* src/libkvazaar.so.*
src/kvazaar.dll src/kvazaar.dll
src/libkvazaar.dll.a src/libkvazaar.dll.a
src/libkvazaar.*.dylib src/libkvazaar.*.dylib
src/kvazaar.pc src/kvazaar.pc
tests/kvazaar_tests
tests/kvazaar_tests.trs

View file

@ -1,20 +1,20 @@
#!/bin/sh #!/bin/sh
set -ev set -ev
./autogen.sh
./configure
make
if [ -n "$VALGRIND_TEST" ]; then if [ -n "$VALGRIND_TEST" ]; then
cd src libtool execute valgrind --leak-check=full --error-exitcode=1 -- \
make debug src/kvazaar -i mandelbrot_${TEST_DIM}.yuv --input-res=${TEST_DIM} -o /dev/null \
valgrind --leak-check=full --error-exitcode=1 ./kvazaar_debug -i ../mandelbrot_${TEST_DIM}.yuv --input-res=${TEST_DIM} -o /dev/null $VALGRIND_TEST $VALGRIND_TEST
elif [ -n "$EXPECTED_STATUS" ]; then elif [ -n "$EXPECTED_STATUS" ]; then
cd src
make cli
set +e set +e
./kvazaar $PARAMS libtool execute src/kvazaar $PARAMS
EXIT_STATUS=$? EXIT_STATUS=$?
set -e set -e
[ "$EXIT_STATUS" = "$EXPECTED_STATUS" ] [ "$EXIT_STATUS" = "$EXPECTED_STATUS" ]
else else
cd src make check
make
make tests
fi fi

View file

@ -2,7 +2,6 @@ language: c
env: env:
global: global:
- AS=nasm
- KVZ_DISABLE_AVX2=1 - KVZ_DISABLE_AVX2=1
- TEST_DIM=264x130 - TEST_DIM=264x130
- TEST_FRAMES=10 - TEST_FRAMES=10
@ -15,17 +14,14 @@ matrix:
include: include:
- compiler: clang - compiler: clang
env: KVZ_DISABLE_AVX2=""
- compiler: gcc-4.8 - compiler: gcc-4.8
env: KVZ_DISABLE_AVX2=""
# Check for external symbols without kvz_ prefix. # Check for external symbols without kvz_ prefix.
- compiler: gcc-4.8 - compiler: gcc-4.8
env: KVZ_DISABLE_AVX2=""
script: script:
- cd src - ./autogen.sh
- make libkvazaar.a - ./configure && make
- (! nm -go --defined-only libkvazaar.a | grep -v ' kvz_') - (! nm -go --defined-only src/.libs/libkvazaar.a | grep -v ' kvz_')
# These valgrind tests are slow, so they are performed with the minimum # These valgrind tests are slow, so they are performed with the minimum
# number of small frames and fast settings. # number of small frames and fast settings.
@ -63,7 +59,7 @@ matrix:
- env: TEST_FRAMES=20 VALGRIND_TEST="--gop=8 -p0 --threads=2 --wpp --owf=0 --rd=0 --no-rdoq --no-deblock --no-sao --no-signhide --subme=0 --pu-depth-inter=1-3 --pu-depth-intra=2-3" - env: TEST_FRAMES=20 VALGRIND_TEST="--gop=8 -p0 --threads=2 --wpp --owf=0 --rd=0 --no-rdoq --no-deblock --no-sao --no-signhide --subme=0 --pu-depth-inter=1-3 --pu-depth-intra=2-3"
# Tests trying to use invalid input dimensions # Tests trying to use invalid input dimensions
- env: EXPECTED_STATUS=1 PARAMS="-i kvazaar --input-res=1x65 -o /dev/null" - env: EXPECTED_STATUS=1 PARAMS="-i src/kvazaar --input-res=1x65 -o /dev/null"
addons: addons:
apt: apt:
@ -71,11 +67,14 @@ addons:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
packages: packages:
- autoconf
- gcc - gcc
- gcc-4.8 - gcc-4.8
- libtool
- nasm - nasm
- p7zip-full - p7zip-full
- valgrind - valgrind
- yasm
install: install:
- source .travis-install.sh - source .travis-install.sh

13
Makefile.am Normal file
View file

@ -0,0 +1,13 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src tests
dist_doc_DATA = COPYING CREDITS README.md
EXTRA_DIST = \
build \
doc \
docs.doxy \
greatest \
SConstruct \
tools

View file

@ -199,17 +199,15 @@ possible.
- The executable needs pthreadVC2.dll to be present. Either install it - The executable needs pthreadVC2.dll to be present. Either install it
somewhere or ship it with the executable. somewhere or ship it with the executable.
###GCC ###Autotools
- Makefile can be found in the src directory. Run the following commands to compile and install Kvazaar.
- Yasm is expected to be in PATH.
- Alternatively, NASM can be used by passing `AS=nasm` to make.
On Linux, both the shared and the static library are built and installed ./autogen.sh
by default. On Windows and OS X, the default is to only build the ./configure
DLL/dylib. The static command line program is built by default on all make
platforms. sudo make install
The default targets can be installed by running `make install`. See `./configure --help` for more options.
###OS X ###OS X
- The program should compile and work on OS X but you might need a newer - The program should compile and work on OS X but you might need a newer

6
autogen.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
git submodule init
git submodule update
mkdir -p m4
autoreconf -if

104
configure.ac Normal file
View file

@ -0,0 +1,104 @@
AC_INIT([kvazaar], m4_esyscmd([printf $(awk '/#define KVZ_VERSION/ { print $3 }' src/global.h)]))
AC_CONFIG_SRCDIR([src/encmain.c])
# Library version number
ver_major=2
ver_minor=2
ver_release=0
# not used, but it prevents configure from adding a lot of defines to the CFLAGS
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 dist-xz foreign subdir-objects])
AM_SILENT_RULES([yes])
AC_PROG_CC
AM_PROG_AR
LT_INIT([win32-dll])
CFLAGS="-Wall -Wtype-limits -Wvla -I$srcdir/src -ftree-vectorize -fvisibility=hidden -std=gnu99 -DKVZ_DLL_EXPORTS $CFLAGS"
LIBS="-lm $LIBS"
# --disable-werror
AC_ARG_ENABLE([werror], [AS_HELP_STRING([--disable-werror], [don't treat warnings as errors [no]])],
[], [CFLAGS="-Werror $CFLAGS"]
)
# check for getopt
AC_CHECK_HEADER([getopt.h], [], [CFLAGS="$CFLAGS -I$srcdir/src/extras"])
# host and cpu specific settings
AS_CASE([$host_cpu],
[i?86], [BITS="32" ASFLAGS="$ASFLAGS -DARCH_X86_64=0" X86="true"],
[x86_64], [BITS="64" ASFLAGS="$ASFLAGS -DARCH_X86_64=1 -m amd64" X86="true"],
[powerpc*], [PPC="true"],
[arm*], [ARM="true"]
)
AS_CASE([$host_os],
[darwin*], [
ASFLAGS="$ASFLAGS -f macho$BITS -DPREFIX"
],
[cygwin*|msys*|mingw*], [
CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
AS_IF(
[test "x$BITS" = "x32"], [
ASFLAGS="$ASFLAGS -fwin32 -DPREFIX -DHAVE_ALIGNED_STACK=0"
], [
ASFLAGS="$ASFLAGS -fwin64 -DHAVE_ALIGNED_STACK=1"
]
)
], [
ASFLAGS="$ASFLAGS -f elf$BITS"
CFLAGS="$CFLAGS -pthread"
LDFLAGS="$LDFLAGS -pthread -Wl,-z,noexecstack"
LIBS="$LIBS -lrt -lpthread"
]
)
# YASM checks
AS_IF([test "x$X86" = "xtrue"], [
AC_CHECK_TOOL([YASM], [yasm], [no])
])
AS_IF([test "x$YASM" != "xno"], [have_yasm="yes"])
AC_ARG_ENABLE([asm], [AS_HELP_STRING([--disable-asm], [disable assembly [no]])],
[], [enable_asm="yes"]
)
AS_IF([test "x$enable_asm" != "xno" -a $have_yasm != "yes"],
[enable_asm="no"]
)
AM_CONDITIONAL([HAVE_X86], [test "x$X86" = "xtrue"])
AM_CONDITIONAL([HAVE_PPC], [test "x$PPC" = "xtrue"])
AM_CONDITIONAL([HAVE_ARM], [test "x$ARM" = "xtrue"])
AM_CONDITIONAL([ENABLE_ASM], [test "x$enable_asm" = "xyes" -a "x$have_yasm" = "xyes" ])
AC_ARG_VAR([ASFLAGS], [ASFLAGS to use for assembler])
AC_SUBST([ASFLAGS])
# use KVZ_API_VERSION for sonames
#KVZ_API_VERSION="$($AWK '/#define KVZ_API_VERSION/ { print $3 }' $srcdir/src/kvazaar_version.h)"
# use library version for sonames (specified in src/Makefile)
KVZ_API_VERSION="$ver_major:$ver_minor:$ver_release"
AC_SUBST([KVZ_API_VERSION])
AC_CONFIG_FILES([Makefile
src/Makefile
src/kvazaar.pc
tests/Makefile])
AC_OUTPUT

View file

@ -53,7 +53,8 @@ CFLAGS += -O2 -g -ftree-vectorize
CFLAGS += -fvisibility=hidden -std=gnu99 CFLAGS += -fvisibility=hidden -std=gnu99
CFLAGS += -DKVZ_DLL_EXPORTS CFLAGS += -DKVZ_DLL_EXPORTS
CFLAGS += $(INCLUDEDIRS) $(WARNINGS) CFLAGS += $(INCLUDEDIRS) $(WARNINGS)
LDFLAGS += -O2 -fvisibility=hidden -lm -pthread LDFLAGS += -O2 -fvisibility=hidden -pthread
LIBS += -lm
ARCH ?= $(shell uname -m) ARCH ?= $(shell uname -m)

183
src/Makefile.am Normal file
View file

@ -0,0 +1,183 @@
bin_PROGRAMS = kvazaar
lib_LTLIBRARIES = libkvazaar.la
EXTRA_DIST = \
Makefile-old \
SConscript \
extras/getopt.c \
extras/getopt.h
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA = kvazaar.pc
include_HEADERS = \
kvazaar.h \
kvazaar_version.h
noinst_HEADERS = \
extras/x86inc.asm
kvazaar_SOURCES = \
encmain.c \
cli.h \
cli.c \
yuv_io.c \
yuv_io.h
kvazaar_LDADD = libkvazaar.la $(LIBS)
libkvazaar_la_SOURCES = \
bitstream.c \
bitstream.h \
cabac.c \
cabac.h \
checkpoint.c \
checkpoint.h \
config.c \
config.h \
context.c \
context.h \
cu.c \
cu.h \
encoder.c \
encoder.h \
encoderstate.c \
encoderstate.h \
encoder_state-bitstream.c \
encoder_state-bitstream.h \
encoder_state-ctors_dtors.c \
encoder_state-ctors_dtors.h \
encoder_state-geometry.c \
encoder_state-geometry.h \
filter.c \
filter.h \
global.h \
image.c \
image.h \
imagelist.c \
imagelist.h \
input_frame_buffer.c \
input_frame_buffer.h \
inter.c \
interface_main.c \
inter.h \
intra.c \
intra.h \
kvazaar.c \
kvazaar_internal.h \
nal.c \
nal.h \
rate_control.c \
rate_control.h \
rdo.c \
rdo.h \
sao.c \
sao.h \
scalinglist.c \
scalinglist.h \
search.c \
search.h \
search_inter.c \
search_inter.h \
search_intra.c \
search_intra.h \
tables.c \
tables.h \
threadqueue.c \
threadqueue.h \
threads.h \
transform.c \
transform.h \
videoframe.c \
videoframe.h \
strategies/altivec/picture-altivec.c \
strategies/altivec/picture-altivec.h \
strategies/generic/dct-generic.c \
strategies/generic/dct-generic.h \
strategies/generic/intra-generic.c \
strategies/generic/intra-generic.h \
strategies/generic/ipol-generic.c \
strategies/generic/ipol-generic.h \
strategies/generic/nal-generic.c \
strategies/generic/nal-generic.h \
strategies/generic/picture-generic.c \
strategies/generic/picture-generic.h \
strategies/generic/quant-generic.c \
strategies/generic/quant-generic.h \
strategies/sse2/picture-sse2.c \
strategies/sse2/picture-sse2.h \
strategies/sse41/picture-sse41.c \
strategies/sse41/picture-sse41.h \
strategies/strategies-common.h \
strategies/strategies-dct.c \
strategies/strategies-dct.h \
strategies/strategies-intra.c \
strategies/strategies-intra.h \
strategies/strategies-ipol.c \
strategies/strategies-ipol.h \
strategies/strategies-nal.c \
strategies/strategies-nal.h \
strategies/strategies-picture.c \
strategies/strategies-picture.h \
strategies/strategies-quant.c \
strategies/strategies-quant.h \
strategies/x86_asm/picture-x86-asm.c \
strategies/x86_asm/picture-x86-asm.h \
strategyselector.c \
strategyselector.h
avx2_sources = \
strategies/avx2/dct-avx2.c \
strategies/avx2/dct-avx2.h \
strategies/avx2/intra-avx2.c \
strategies/avx2/intra-avx2.h \
strategies/avx2/ipol-avx2.c \
strategies/avx2/ipol-avx2.h \
strategies/avx2/picture-avx2.c \
strategies/avx2/picture-avx2.h \
strategies/avx2/quant-avx2.c \
strategies/avx2/quant-avx2.h
libkvazaar_la_SOURCES += $(avx2_sources)
libkvazaar_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-number $(KVZ_API_VERSION)
if HAVE_PPC
strategies/altivec/picture-altivec.lo: CFLAGS += -maltivec
else #HAVE_PPC
if HAVE_X86
strategies/sse2/picture-sse2.lo: CFLAGS += -msse2
strategies/sse41/picture-sse41.lo: CFLAGS += -msse4.1
$(avx2_sources): CFLAGS += -mavx2
if ENABLE_ASM
libkvazaar_la_SOURCES += \
strategies/x86_asm/picture-x86-asm-sad.asm \
strategies/x86_asm/picture-x86-asm-sad.h \
strategies/x86_asm/picture-x86-asm-satd.asm \
strategies/x86_asm/picture-x86-asm-satd.h
strategies/x86_asm/picture-x86-asm.lo: CFLAGS += -DKVZ_COMPILE_ASM
strategies/x86_asm/picture-x86-asm-sad.lo: strategies/x86_asm/picture-x86-asm-sad.asm
strategies/x86_asm/picture-x86-asm-satd.lo: strategies/x86_asm/picture-x86-asm-satd.asm
endif #ENABLE_ASM
endif #HAVE_X86
endif #HAVE_PPC
yasm_verbose = $(yasm_verbose_@AM_V@)
yasm_verbose_ = $(yasm_verbose_@AM_DEFAULT_V@)
yasm_verbose_0 = @echo " YASM " $@;
.asm.lo:
$(yasm_verbose)$(LIBTOOL) --mode=compile $(YASM) -I$(srcdir)/extras $(ASFLAGS) $< -o $@ -prefer-non-pic 1>/dev/null

View file

@ -35,23 +35,31 @@
extern "C" { extern "C" {
#endif #endif
#if defined(KVZ_STATIC_LIB) #if defined(KVZ_DLL_EXPORTS)
// Using or building kvazaar as a static library. #if !defined(PIC)
// Building static kvazaar library.
#define KVZ_PUBLIC #define KVZ_PUBLIC
#elif defined(_WIN32) || defined(__CYGWIN__) #elif defined(_WIN32) || defined(__CYGWIN__)
#ifdef KVZ_DLL_EXPORTS // Building kvazaar DLL on Windows.
// Building kvazaar on windows.
#define KVZ_PUBLIC __declspec(dllexport) #define KVZ_PUBLIC __declspec(dllexport)
#else
// Using kvazaar as a DLL on windows.
#define KVZ_PUBLIC __declspec(dllimport)
#endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
// Using GCC and not on windows. // Building kvazaar shared library with GCC.
#define KVZ_PUBLIC __attribute__ ((visibility ("default"))) #define KVZ_PUBLIC __attribute__ ((visibility ("default")))
#else #else
#define KVZ_PUBLIC #define KVZ_PUBLIC
#endif #endif
#else
#if defined(KVZ_STATIC_LIB)
// Using static kvazaar library.
#define KVZ_PUBLIC
#elif defined(_WIN32) || defined(__CYGWIN__)
// Using kvazaar DLL on Windows.
#define KVZ_PUBLIC __declspec(dllimport)
#else
// Using kvazaar shared library and not on Windows.
#define KVZ_PUBLIC
#endif
#endif
/** /**
* Maximum length of a GoP structure. * Maximum length of a GoP structure.

View file

@ -6,5 +6,6 @@ incdir=${prefix}/include
Name: libkvazaar Name: libkvazaar
Description: Open-source HEVC encoder Description: Open-source HEVC encoder
Version: @VERSION@ Version: @VERSION@
Libs: -L${libdir} -lkvazaar -lm @LIBS@ Libs: -L${libdir} -lkvazaar
Libs.private: @LIBS@
Cflags: -I${incdir} Cflags: -I${incdir}

19
tests/Makefile.am Normal file
View file

@ -0,0 +1,19 @@
TESTS = $(check_PROGRAMS)
check_PROGRAMS = kvazaar_tests
kvazaar_tests_SOURCES = \
dct_tests.c \
intra_sad_tests.c \
sad_tests.c \
sad_tests.h \
satd_tests.c \
satd_tests.h \
speed_tests.c \
tests_main.c \
test_strategies.c \
test_strategies.h
kvazaar_tests_CFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src
kvazaar_tests_LDFLAGS = -static $(top_builddir)/src/libkvazaar.la $(LIBS)