Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 66 additions & 4 deletions .github/workflows/ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- os: macos-latest
CC: clang
CXX: clang++
- os: windows-latest
CC: cl
CXX: cl
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.CC }}
Expand All @@ -29,6 +32,7 @@ jobs:
with:
python-version: 3.11
- name: Install meson and ninja
if: matrix.os != 'windows-latest'
run: |
python -m pip install --upgrade pip
pip install meson
Expand All @@ -41,20 +45,60 @@ jobs:
if: matrix.os == 'macos-latest'
run: |
brew install -q ninja nasm
- name: Install dependencies (windows)
if: matrix.os == 'windows-latest'
run: |
choco install -y nasm pkgconfiglite
pip install meson ninja
- name: Setup MSVC
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
- uses: actions/checkout@v6
- name: Build vmaf
- name: Build vmaf (unix)
if: matrix.os != 'windows-latest'
run: |
meson setup libvmaf libvmaf/build --buildtype release
sudo ninja -vC libvmaf/build install
- name: Prepare FFmpeg
- name: Build vmaf (windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
meson setup libvmaf libvmaf/build --buildtype release --default-library static --prefix "C:/vmaf"
meson install -C libvmaf/build
- name: Prepare static libs for MSVC
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Rename-Item -Path C:\vmaf\lib\libpthreadVC3.a -NewName C:\vmaf\lib\pthreadVC3.lib
Rename-Item -Path C:\vmaf\lib\libpthreadVCE3.a -NewName C:\vmaf\lib\pthreadVCE3.lib
Rename-Item -Path C:\vmaf\lib\libpthreadVSE3.a -NewName C:\vmaf\lib\pthreadVSE3.lib
Rename-Item -Path C:\vmaf\lib\libvmaf.a -NewName C:\vmaf\lib\vmaf.lib
echo "INCLUDE=C:/vmaf/include;$env:INCLUDE" >> $env:GITHUB_ENV
echo "LIB=C:/vmaf/lib;$env:LIB" >> $env:GITHUB_ENV
echo "PATH=C:/vmaf/bin;$env:PATH" >> $env:GITHUB_ENV
echo "PKG_CONFIG_PATH=C:/vmaf/lib/pkgconfig;$env:PKG_CONFIG_PATH" >> $env:GITHUB_ENV
- name: Prepare FFmpeg (unix)
if: matrix.os != 'windows-latest'
run: |
git clone -q --branch master --depth=1 "https://github.com/FFmpeg/FFmpeg" ffmpeg
cd ffmpeg
./configure --enable-version3 --enable-libvmaf --disable-indevs --cc="$CC" --cxx="$CXX" || { less ffbuild/config.log; exit 1; }
- name: Make FFmpeg
- name: Prepare FFmpeg (windows)
if: matrix.os == 'windows-latest'
run: |
git clone --depth=1 https://gitlab.freedesktop.org/gstreamer/meson-ports/ffmpeg.git ffmpeg
cd ffmpeg
meson setup build --buildtype release -Dversion3=enabled -Dindevs=disabled -Dlibvmaf=enabled -Dprograms=enabled --prefix "C:/ffmpeg"
- name: Make FFmpeg (unix)
if: matrix.os != 'windows-latest'
run: |
sudo make -C ffmpeg --quiet -j $(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu) install
- name: Test ffmpeg
- name: Make FFmpeg (windows)
if: matrix.os == 'windows-latest'
run: |
meson install -C ffmpeg/build
- name: Test ffmpeg (unix)
if: matrix.os != 'windows-latest'
run: |
curl "https://gist.githubusercontent.com/1480c1/0c4575da638ef6e8203feffd0597de16/raw/akiyo_cif.tar.xz.base64" | base64 -d | tar xJ
vmaf_score=$(ffmpeg -hide_banner -nostats -i encoded.mkv -i orig.mkv -filter_complex libvmaf -f null - 2>&1 | grep 'VMAF score' | tr ' ' '\n' | tail -n1)
Expand All @@ -67,3 +111,21 @@ jobs:
exit 0
fi
continue-on-error: true
- name: Test ffmpeg (MSVC)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
curl "https://gist.githubusercontent.com/1480c1/0c4575da638ef6e8203feffd0597de16/raw/akiyo_cif.tar.xz.base64" | base64 -d | tar xJ
$ffmpeg = "C:/ffmpeg/bin/ffmpeg.exe"
$vmaf_score = (& $ffmpeg -hide_banner -nostats -i encoded.mkv -i orig.mkv -filter_complex libvmaf -f null - 2>&1 |
Select-String "VMAF score" |
ForEach-Object { $_.ToString().Split()[-1] }).Trim()
echo "VMAF score: $vmaf_score"
if ($vmaf_score -ne "93.663925") {
echo "vmaf score doesn't match 93.663925"
exit 1
} else {
echo "vmaf score matches"
exit 0
}
continue-on-error: true
109 changes: 54 additions & 55 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,77 @@ on:
pull_request:

jobs:
build:
build-windows:
runs-on: windows-latest

strategy:
fail-fast: false
matrix:
include:
# Disabled 32-bit job due to vmaf score mismatch
#- msystem: MINGW32
# MINGW_PACKAGE_PREFIX: mingw-w64-i686
# CFLAGS: -msse2 -mfpmath=sse -mstackrealign
- msystem: MINGW64
MINGW_PACKAGE_PREFIX: mingw-w64-x86_64
env:
CC: ccache gcc
CXX: ccache g++
CFLAGS: -pipe -static -O3 -mtune=generic -D_FILE_OFFSET_BITS=64 -mthreads ${{ matrix.CFLAGS }}
CXXFLAGS: -pipe -static -O3 -mtune=generic -D_FILE_OFFSET_BITS=64 -mthreads ${{ matrix.CXXFLAGS }}
LDFLAGS: -pipe -static -static-libgcc -static-libstdc++ ${{ matrix.LDFLAGS }}
defaults:
run:
shell: msys2 {0}
build:
- type: mingw
msystem: MINGW64
prefix: mingw-w64-x86_64
- type: msvc

steps:
- uses: actions/checkout@v6
with:
submodules: true
fetch-depth: 0
- name: Cache ccache files
uses: actions/cache@v4
with:
path: |
.ccache
key: ${{ runner.os }}-${{ matrix.msystem }}-0-${{ hashFiles('**/*.c') }}
restore-keys: |
${{ runner.os }}-${{ matrix.msystem }}-0-
${{ runner.os }}-${{ matrix.msystem }}-

- uses: msys2/setup-msys2@v2
- name: Setup MSYS2
if: matrix.build.type == 'mingw'
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
install: ${{ matrix.MINGW_PACKAGE_PREFIX }}-ccache ${{ matrix.MINGW_PACKAGE_PREFIX }}-nasm ${{ matrix.MINGW_PACKAGE_PREFIX }}-pkg-config ${{ matrix.MINGW_PACKAGE_PREFIX }}-gcc ${{ matrix.MINGW_PACKAGE_PREFIX }}-meson ${{ matrix.MINGW_PACKAGE_PREFIX }}-ninja vim make diffutils
msystem: ${{ matrix.build.msystem }}
install: ${{ matrix.build.prefix }}-ccache ${{ matrix.build.prefix }}-nasm ${{ matrix.build.prefix }}-pkg-config ${{ matrix.build.prefix }}-gcc ${{ matrix.build.prefix }}-meson ${{ matrix.build.prefix }}-ninja vim make diffutils
update: true
path-type: inherit

- name: Set ccache dir
run: echo "name=CCACHE_DIR::$PWD/.ccache" >> $GITHUB_ENV
- name: Build (MINGW)
if: matrix.build.type == 'mingw'
shell: msys2 {0}
run: |
echo "name=CCACHE_DIR::$PWD/.ccache" >> $GITHUB_ENV
meson setup libvmaf libvmaf/build --buildtype release --default-library static --prefix "$MINGW_PREFIX"
meson install -C libvmaf/build
meson test -C libvmaf/build --num-processes $(nproc)

# Export MINGW_PREFIX to the global environment
echo "MINGW_PREFIX=$(cygpath -m "$MINGW_PREFIX")" >> $GITHUB_ENV

- name: Configure vmaf
run: meson setup libvmaf libvmaf/build --buildtype release --default-library static --prefix "$MINGW_PREFIX"
- name: Build vmaf
run: meson install -C libvmaf/build
- name: Upload MINGW build
if: matrix.build.type == 'mingw'
uses: actions/upload-artifact@v5
with:
name: mingw-vmaf
path: ${{ env.MINGW_PREFIX }}/bin/vmaf.exe

- name: Test vmaf
run: meson test -C libvmaf/build --num-processes $(nproc)
- name: Setup MSVC environment
if: matrix.build.type == 'msvc'
uses: ilammy/msvc-dev-cmd@v1

- name: Install Meson and Ninja
if: matrix.build.type == 'msvc'
run: |
pip install meson ninja

- name: Get binary path & Current Release
id: get_info
- name: Install build tools
if: matrix.build.type == 'msvc'
run: |
ldd "$MINGW_PREFIX/bin/vmaf.exe" || true
echo "path=$(cygpath -m "$(command -v vmaf)")" >> $GITHUB_OUTPUT
echo "upload_url=$(curl -L https://api.github.com/repos/${{ github.repository }}/releases/tags/$(cut -d/ -f3 <<< ${{ github.ref }}) | jq -r ."upload_url")" >> $GITHUB_OUTPUT
choco install xxd -y

- name: Upload vmaf
- name: Build (MSVC)
if: matrix.build.type == 'msvc'
shell: cmd
run: |
meson setup libvmaf libvmaf/build-msvc --buildtype release --default-library static --prefix C:/vmaf-install-msvc
meson install -C libvmaf/build-msvc
meson test -C libvmaf/build-msvc

- name: Upload MSVC build
if: matrix.build.type == 'msvc'
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.msystem }}-vmaf
path: ${{ steps.get_info.outputs.path }}
- name: Upload vmaf
if: steps.get_info.outputs.upload_url != 'null' && matrix.msystem == 'MINGW64'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_info.outputs.upload_url }}
asset_path: ${{ steps.get_info.outputs.path }}
asset_name: vmaf.exe
asset_content_type: application/vnd.microsoft.portable-executable
name: msvc-vmaf
path: C:/vmaf-install-msvc/bin/vmaf.exe
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "GerHobbelt-pthread-win32"]
path = libvmaf/subprojects/pthread-win32
url = https://github.com/GerHobbelt/pthread-win32
38 changes: 38 additions & 0 deletions libvmaf/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ elif host_machine.system() == 'darwin'
endif

# Header checks
if cc.has_header('malloc.h', args: test_args)
add_project_arguments('-DHAVE_MALLOC_H', language: ['c', 'cpp'])
endif
if cc.has_header('alloca.h', args: test_args)
add_project_arguments('-DHAVE_ALLOCA_H', language: ['c', 'cpp'])
endif

stdatomic_dependency = []
if not cc.check_header('stdatomic.h')
if cc.get_id() == 'msvc'
Expand All @@ -46,6 +53,37 @@ if not cc.check_header('stdatomic.h')
endif
endif

builtin_clz_dependency = []
if cc.get_id() == 'msvc'
builtin_clz_dependency = declare_dependency(
include_directories : include_directories('src/compat/msvc'),
compile_args : ['-DHAVE_BUILTIN_CLZ_COMPAT'],
)
endif

if cc.check_header('getopt.h', args: test_args)
getopt_dependency = declare_dependency(compile_args : '-DHAVE_GETOPT_H')
else
getopt_dependency = declare_dependency(
compile_args : '-DHAVE_GETOPT_H',
sources: ['src/compat/getopt/getopt.c'],
include_directories : include_directories('src/compat/getopt'),
)
endif

pthreadwin32_inc = []
if cc.get_id() == 'msvc'
cmake = import('cmake')

pthreadwin32_opts = cmake.subproject_options()
pthreadwin32_opts.add_cmake_defines({
'BUILD_SHARED_LIBS': false,
})
pthreadwin32_proj = cmake.subproject('pthread-win32', options: pthreadwin32_opts)
pthreadwin32_lib = pthreadwin32_proj.dependency('pthreadVC3')
pthreadwin32_inc = include_directories('./subprojects/pthread-win32')
endif

subdir('include')
subdir('src')
subdir('tools')
Expand Down
38 changes: 38 additions & 0 deletions libvmaf/src/compat/getopt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ya_getopt - Yet another getopt
==============================

What is ya_getopt.
------------------

Ya_getopt is a drop-in replacement of [GNU C library getopt](http://man7.org/linux/man-pages/man3/getopt.3.html).
`getopt()`, `getopt_long()` and `getopt_long_only()` are implemented excluding the following GNU extension features.

1. If *optstring* contains **W** followed by a semicolon, then **-W** **foo** is
treated as the long option **--foo**.

2. \_\<PID>\_GNU\_nonoption\_argv\_flags\_

The license is 2-clause BSD-style license. You can use the Linux getopt compatible function
under Windows, Solaris and so on without having to worry about license issue.

Note for contributors
---------------------

Don't send me a patch if you have looked at GNU C library getopt source code.
That's because I made this with clean room design to avoid the influence of the GNU LGPL.

Please make a test script passed by the GNU C library getopt but not by ya_getopt instead.

License
-------

2-clause BSD-style license

Other getopt functions
----------------------

* [public domain AT&T getopt](https://www.google.co.jp/search?q=public+domain+at%26t+getopt) public domain, no getopt_long, no getopt_long_only, no argv permutation
* [Free Getopt](http://freegetopt.sourceforge.net/) 3-clause BSD-style licence, no getopt_long, no getopt_long_only
* [getopt_port](https://github.com/kimgr/getopt_port/) 3-clause BSD-style licence, no getopt_long_only, no argv permutation
* [XGetopt - A Unix-compatible getopt() for MFC and Win32](http://www.codeproject.com/Articles/1940/XGetopt-A-Unix-compatible-getopt-for-MFC-and-Win32)
* [Full getopt Port for Unicode and Multibyte Microsoft Visual C, C++, or MFC Projects](http://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso) LGPL
Loading
Loading