Skip to content

Commit

Permalink
libvmaf: build with meson
Browse files Browse the repository at this point in the history
  • Loading branch information
kylophone committed Nov 6, 2019
1 parent d4d48dd commit 82a86e0
Show file tree
Hide file tree
Showing 990 changed files with 1,838 additions and 70,789 deletions.
19 changes: 14 additions & 5 deletions .travis.yml
Expand Up @@ -10,13 +10,22 @@ before_install:
- sudo apt-get install -qq g++-9
- export CXX="g++-9" CC="gcc-9"
- sudo apt-get install git
- sudo apt-get install ninja-build python3-pip python3-setuptools

install:
- pip install tox-travis
- pip3 install meson

script:
- make
- sudo make install
- make testlib
- make testlibdyn
- export LD_LIBRARY_PATH=$(pwd)/src/libvmaf:$LD_LIBRARY_PATH && tox -c python/ -- -v -p no:warnings -m 'main or lib' --doctest-modules
- >
cd third_party/libsvm &&
make lib &&
cd -
- >
cd libvmaf &&
mkdir build && cd build &&
meson .. --buildtype release &&
ninja -vC . test &&
DESTDIR=$(pwd)/install ninja -vC . install &&
cd ../..
- tox -c python/ -- -v -p no:warnings -m 'main or lib' --doctest-modules
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Change Log

## [Upcoming]

**New features:**
- libvmaf has been relocated, and now has its own self-enclosed source tree (`./libvmaf/`) and build system (`meson`).

## (9/8/2019) [1.3.15]

**Fixed bugs:**
Expand Down
34 changes: 10 additions & 24 deletions Makefile
@@ -1,29 +1,15 @@
all:
cd src/ptools; $(MAKE); cd ../..;
cd src/libsvm; $(MAKE); cd ../..;
cd src/libsvm; $(MAKE) lib; cd ../..;
cd src/libvmaf; $(MAKE); cd ../..;
cd third_party/libsvm && make lib

clean:
cd src/ptools; $(MAKE) clean; cd ../..;
cd src/libsvm; $(MAKE) clean; cd ../..;
cd src/libvmaf; $(MAKE) clean; cd ../..;
mkdir -p libvmaf/build && cd libvmaf/build && \
meson .. --buildtype release && \
ninja -vC .

test:
@echo hello;
clean:
cd third_party/libsvm && make clean && cd -
rm -rf libvmaf/build

install:
cd src/libvmaf; $(MAKE) install; cd ../..;

uninstall:
cd src/libvmaf; $(MAKE) uninstall; cd ../..;

testlib:
cd src/libvmaf; $(MAKE) testlib; cd ../..;

testlibdyn:
cd src/libvmaf; $(MAKE) testlibdyn; cd ../..;

.PHONY: all clean $(TARGETS)


mkdir -p libvmaf/build && cd libvmaf/build && \
meson .. --buildtype release && \
ninja -vC . install
53 changes: 37 additions & 16 deletions appveyor.yml
@@ -1,20 +1,41 @@
image: Visual Studio 2017
configuration: Release
os: Visual Studio 2017

build:
project: vmaf.sln
environment:
matrix:
- arch: x86
compiler: msvc2015
- arch: x64
compiler: msvc2015
- arch: x86
compiler: msvc2017
- arch: x64
compiler: msvc2017

after_build: 7z a vmaf-win-x64.zip x64\Release\*.*
platform:
- x64

artifacts:
- path: vmaf-win-x64.zip
- path: x64\Release\*.*
install:
# Download ninja
- cmd: mkdir C:\ninja-build
- ps: (new-object net.webclient).DownloadFile('https://github.com/mesonbuild/cidata/raw/master/ninja.exe', 'C:\ninja-build\ninja.exe')
# Set paths to dependencies (based on architecture)
- cmd: if %arch%==x86 (set PYTHON_ROOT=C:\python37) else (set PYTHON_ROOT=C:\python37-x64)
# Print out dependency paths
- cmd: echo Using Python at %PYTHON_ROOT%
# Add neccessary paths to PATH variable
- cmd: set PATH=%cd%;C:\ninja-build;%PYTHON_ROOT%;%PYTHON_ROOT%\Scripts;%PATH%
# Install meson
- cmd: pip install meson
# Set up the build environment
- cmd: if %compiler%==msvc2015 ( call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %arch% )
- cmd: if %compiler%==msvc2017 ( call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %arch% )

#deploy:
# - provider: GitHub
# artifact: vmaf-win-x64.zip,examples.bat,libvmaf.lib,vmafossexec.exe,vmaf.exe
# auth_token:
# secure: 'hY5Mk6KOwgQ97TzEBsM7Woqr1ZIm5QTvHg8EvxMV1x8j3wk/3mNBMqWFFbEIBK0i'
# prerelease: true
# on:
# appveyor_repo_tag: true
build_script:
- cmd: cd libvmaf
- cmd: echo Building on %arch% with %compiler%
- cmd: meson --backend=ninja builddir
- cmd: ninja -vC builddir

test_script:
- cmd: cd libvmaf
- cmd: ninja -vC builddir test
15 changes: 15 additions & 0 deletions libvmaf/README.md
@@ -0,0 +1,15 @@
# libvmaf

## Compile
1. Install [Meson](https://mesonbuild.com/) (0.47 or higher) and [Ninja](https://ninja-build.org/)
2. Run `meson build --buildtype release`
3. Build with `ninja -vC build`

## Test
Build and run tests with `ninja -vC build test`

## Install
Install using `ninja -vC build install`

## Documentation
Generate HTML documentation with `ninja -vC build doc/html`
19 changes: 19 additions & 0 deletions libvmaf/doc/Doxyfile.in
@@ -0,0 +1,19 @@
PROJECT_NAME = libvmaf
OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT@
STRIP_FROM_PATH = @DOXYGEN_STRIP@
OUTPUT_LANGUAGE = English
TAB_SIZE = 4
EXTRACT_ALL = YES
OPTIMIZE_OUTPUT_FOR_C = YES
DOXYFILE_ENCODING = UTF-8
TYPEDEF_HIDES_STRUCT = YES

QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES

INPUT = @DOXYGEN_INPUT@
FILE_PATTERNS = *.h

GENERATE_HTML = YES
GENERATE_LATEX = NO
20 changes: 20 additions & 0 deletions libvmaf/doc/meson.build
@@ -0,0 +1,20 @@
doxygen = find_program('doxygen', required: false)

if doxygen.found()
conf_data = configuration_data()
doxygen_input = [join_paths(meson.source_root(), 'include/libvmaf'),
]

conf_data.set('DOXYGEN_INPUT', ' '.join(doxygen_input))
conf_data.set('DOXYGEN_STRIP', join_paths(meson.source_root(), 'include'))
conf_data.set('DOXYGEN_OUTPUT', meson.current_build_dir())
doxyfile = configure_file(input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: conf_data)

custom_target('doc',
build_by_default: false,
command: [doxygen, doxyfile],
output: ['html']
)
endif
26 changes: 26 additions & 0 deletions libvmaf/include/libvmaf/libvmaf.h
@@ -0,0 +1,26 @@
/**
*
* Copyright 2016-2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef LIBVMAF_H_
#define LIBVMAF_H_

int compute_vmaf(double* vmaf_score, char* fmt, int width, int height, int (*read_frame)(float *ref_data, float *main_data, float *temp_data, int stride_byte, void *user_data),
void *user_data, char *model_path, char *log_path, char *log_fmt, int disable_clip, int disable_avx, int enable_transform, int phone_model, int do_psnr,
int do_ssim, int do_ms_ssim, char *pool_method, int n_thread, int n_subsample, int enable_conf_interval);

#endif /* _LIBVMAF_H */
13 changes: 13 additions & 0 deletions libvmaf/include/libvmaf/meson.build
@@ -0,0 +1,13 @@
# installed version.h header generation
version_h_data = configuration_data()
version_h_data.set('VMAF_API_VERSION_MAJOR', vmaf_api_version_major)
version_h_data.set('VMAF_API_VERSION_MINOR', vmaf_api_version_minor)
version_h_data.set('VMAF_API_VERSION_PATCH', vmaf_api_version_revision)
version_h_target = configure_file(input: 'version.h.in',
output: 'version.h',
configuration: version_h_data)

# install headers
install_headers('libvmaf.h',
version_h_target,
subdir : 'libvmaf')
26 changes: 26 additions & 0 deletions libvmaf/include/libvmaf/version.h.in
@@ -0,0 +1,26 @@
/**
*
* Copyright 2016-2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef VMAF_VERSION_H
#define VMAF_VERSION_H

#define VMAF_API_VERSION_MAJOR @VMAF_API_VERSION_MAJOR@
#define VMAF_API_VERSION_MINOR @VMAF_API_VERSION_MINOR@
#define VMAF_API_VERSION_PATCH @VMAF_API_VERSION_PATCH@

#endif /* VMAF_VERSION_H */
12 changes: 12 additions & 0 deletions libvmaf/include/meson.build
@@ -0,0 +1,12 @@
# Revision file (vcs_version.h) generation
vmaf_git_dir = join_paths(libvmaf_src_root + '/../', '.git')
rev_target = vcs_tag(command: [
'git', '--git-dir', vmaf_git_dir,
'describe', '--tags', '--long',
'--match', '?.*.*', '--always'
],
input: 'vcs_version.h.in',
output: 'vcs_version.h'
)

subdir('libvmaf')
2 changes: 2 additions & 0 deletions libvmaf/include/vcs_version.h.in
@@ -0,0 +1,2 @@
/* auto-generated, do not edit */
#define VMAF_VERSION "@VCS_TAG@"
24 changes: 24 additions & 0 deletions libvmaf/meson.build
@@ -0,0 +1,24 @@
project('libvmaf', ['c', 'cpp'],
version : '1.3.16',
default_options : ['c_std=c99',
'cpp_std=c++11',
'warning_level=2',
'buildtype=release',
],
meson_version: '>= 0.47.0')

vmaf_soname_version = '0.0.0'
vmaf_api_version_array = vmaf_soname_version.split('.')
vmaf_api_version_major = vmaf_api_version_array[0]
vmaf_api_version_minor = vmaf_api_version_array[1]
vmaf_api_version_revision = vmaf_api_version_array[2]

libvmaf_src_root = meson.current_source_dir()
cc = meson.get_compiler('c')
libvmaf_inc = include_directories('include')
install_subdir('../model', install_dir: 'share')

subdir('src')
subdir('include')
subdir('tools')
subdir('doc')
4 changes: 1 addition & 3 deletions src/libvmaf/src/combo.c → libvmaf/src/combo.c
Expand Up @@ -25,7 +25,6 @@
#include <math.h>

#include "common/alloc.h"
#include "common/file_io.h"
#include "motion_tools.h"
#include "common/convolution.h"
#include "common/convolution_internal.h"
Expand All @@ -35,12 +34,11 @@
#include "combo.h"
#include "debug.h"
#include "psnr_tools.h"
#include "offset.h"

#include "common/blur_array.h"
#include "cpu_info.h"

#define read_image_b read_image_b2s
#define read_image_w read_image_w2s
#define convolution_f32_c convolution_f32_c_s
#define offset_image offset_image_s
#define FILTER_5 FILTER_5_s
Expand Down
2 changes: 1 addition & 1 deletion src/libvmaf/src/combo.h → libvmaf/src/combo.h
Expand Up @@ -28,7 +28,7 @@ extern "C" {
#include "darray.h"
#include "common/blur_array.h"

#include "pthread.h"
#include <pthread.h>

typedef struct
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/libvmaf/src/darray.h → libvmaf/src/darray.h
Expand Up @@ -25,7 +25,7 @@
extern "C" {
#endif

#include "pthread.h"
#include <pthread.h>

typedef struct
{
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions src/libvmaf/src/adm.c → libvmaf/src/feature/adm.c
Expand Up @@ -23,21 +23,19 @@
#include <string.h>

#include "common/alloc.h"
#include "common/file_io.h"
#include "adm_options.h"
#include "adm_tools.h"
#include "offset.h"

typedef adm_dwt_band_t_s adm_dwt_band_t;

#define read_image_b read_image_b2s
#define read_image_w read_image_w2s
#define adm_dwt2 adm_dwt2_s
#define adm_decouple adm_decouple_s
#define adm_csf adm_csf_s
#define adm_cm_thresh adm_cm_thresh_s
#define adm_cm adm_cm_s
#define adm_sum_cube adm_sum_cube_s
#define offset_image offset_image_s
#define offset_image offset_image_s

#define adm_csf_den_scale adm_csf_den_scale_s
#define dwt2_src_indices_filt dwt2_src_indices_filt_s
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions src/libvmaf/src/all.c → libvmaf/src/feature/all.c
Expand Up @@ -24,17 +24,14 @@
#include <string.h>

#include "common/alloc.h"
#include "common/file_io.h"
#include "common/convolution.h"
#include "common/convolution_internal.h"
#include "psnr_tools.h"
#include "motion_tools.h"
#include "all_options.h"
#include "offset.h"
#include "vif_options.h"
#include "adm_options.h"

#define read_image_b read_image_b2s
#define read_image_w read_image_w2s
#define convolution_f32_c convolution_f32_c_s
#define offset_image offset_image_s
#define FILTER_5 FILTER_5_s
Expand Down

0 comments on commit 82a86e0

Please sign in to comment.