Skip to content

Commit

Permalink
CI: added libva to release
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSte committed Jan 26, 2024
1 parent 672f428 commit 0624f02
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ more information.
- [ ] Cross compile for raspberry pi
- [ ] Segmentation fault when running --record without a camera being
available.
- [ ] Fix release workflow such that it links libva correctly to static ffmpeg.
- [ ] Fix issue with ffmpeg + hw acceleration on my arch machine:

```
Expand Down
15 changes: 13 additions & 2 deletions cmake/Find.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,25 @@ function(find_libva)
set(libva_shorts va va-drm va-wayland va-x11)
set(libva_longs LIBVA_LIBRARY LIBVA_DRM_LIBRARY LIBVA_WAYLAND_LIBRARY
LIBVA_X11_LIBRARY)
if(LIBVA_DIR)
message(STATUS "LIBVA_DIR: ${LIBVA_DIR}")
set(find_args PATHS ${LIBVA_DIR} NO_DEFAULT_PATH)
endif()

find_libdrm()
find_path(LIBVA_INCLUDE_DIR NAMES va/va.h)
find_path(
LIBVA_INCLUDE_DIR
NAMES va/va.h
PATH_SUFFIXES include ${find_args})
message(STATUS "LIBVA_INCLUDE_DIR: ${LIBVA_INCLUDE_DIR}")

foreach(libva_short ${libva_shorts})
_short2long(${libva_short}) # creates libva_long

find_library(${libva_long} NAMES ${libva_short})
find_library(
${libva_long}
NAMES ${libva_short}
PATH_SUFFIXES lib ${find_args})
add_library(Libva::${libva_short} UNKNOWN IMPORTED)
set_target_properties(
Libva::${libva_short}
Expand Down
14 changes: 11 additions & 3 deletions scripts/build-ffmpeg
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,25 @@ install_dependencies_apt() {
echo "Updating apt-get"
sudo apt-get update -qq
echo "Installing build tools and dependencies"
sudo apt-get -y install autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev gnutls-bin libunistring-dev libaom-dev libdav1d-dev tar
sudo apt-get -y install autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev gnutls-bin libunistring-dev libaom-dev libdav1d-dev tar

echo "Installing ffmpeg dependencies"
sudo apt-get -y install nasm libx264-dev libx265-dev libvpx-dev libfdk-aac-dev libopus-dev libdav1d-dev libnuma-dev
}

install_dependencies_pacman() {
echo "Installing build tools and dependencies"
sudo pacman -S --noconfirm --needed autoconf automake cmake git libass freetype2 sdl2 libtool libva libvdpau libvorbis libxcb meson ninja pkgconf texinfo wget yasm zlib gnutls libunistring aom dav1d tar
sudo pacman -S --noconfirm autoconf automake cmake git libass freetype2 sdl2 libtool libvdpau libvorbis libxcb meson ninja pkgconf texinfo wget yasm gnutls libunistring aom dav1d tar
sudo pacman -S --noconfirm zlib || true

echo "Installing ffmpeg dependencies"
sudo pacman -S --noconfirm --needed nasm x264 x265 libvpx fdkaac opus numactl
sudo pacman -S --noconfirm nasm x264 x265 fdkaac opus numactl
sudo pacman -S --noconfirm libvpx || true
}

build_libva() {
echo "Building libva"
"$this_dir/build-libva"
}

compile_libaom() {
Expand Down Expand Up @@ -141,6 +148,7 @@ dir=$(pwd)

mkdir -p "$source_dir" "$bin_dir"
install_dependencies
build_libva -s "$source_dir/libva"
compile_libaom
compile_libsvtav1
compile_libvmaf
Expand Down
28 changes: 23 additions & 5 deletions scripts/build-libva
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env bash
set -euo pipefail

usage="$(basename "$0") [-h] <prefix> -- Compiles libva from source and
usage="$(basename "$0") [-h] -- Compiles libva from source and
installs it to <prefix>. The libraries will be installed to <prefix>/lib. If
the prefix is not provided, the script will exit.
Expand All @@ -10,10 +10,10 @@ The packages managers \`apt\` and \`pacman\` are supported.
where:
-h, --help show this help text
-s, --source-dir source directory (default: ./libva)
<prefix> the prefix to install libva to"
-p, --prefix the prefix to install libva to (default: /usr)"

src="./libva"
prefix=""
prefix="/usr"
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
Expand Down Expand Up @@ -43,29 +43,47 @@ src=$(realpath "$src")
prefix=$(realpath "$prefix")

install_deps() {
echo "Installing dependencies"
if command -v apt-get &>/dev/null; then
echo "apt-get found"
remove_libva_apt
install_deps_apt
elif command -v pacman &>/dev/null; then
echo "pacman found"
remove_libva_pacman
install_deps_pacman
else
echo "No supported package manager found"
exit 1
fi
}

remove_libva_apt() {
echo "Removing libva"
sudo apt-get -y remove libva-dev || true
sudo apt-get -y remove libva2 || true
}

remove_libva_pacman() {
echo "Removing libva"
sudo pacman -R --noconfirm -dd libva || true
}

install_deps_apt() {
sudo apt-get -y install git cmake pkg-config meson libdrm-dev automake libtool autogen
echo "Installing apt dependencies"
sudo apt-get -y install autogen automake cmake git libdrm-dev libtool libwayland-dev libx11-dev libx11-dev libx11-xcb-perl libx11-xcb1 libxcb-dri3-dev libxcb1-dev libxext-dev libxfixes-dev meson pkg-config xorg-dev
}

install_deps_pacman() {
sudo pacman -S --noconfirm git cmake pkg-config meson libdrm automake libtool autogen
echo "Installing pacman dependencies"
sudo pacman -S --noconfirm git cmake pkg-config meson libdrm automake libtool autogen xorg wayland libxext libxfixes
}

build_libva() {
dir=$(pwd)
rm -rf "$src"
cd "$(dirname "$src")"
echo "Cloning libva"
git clone https://github.com/intel/libva.git -o "$(basename "$src")"
cd "$(basename "$src")"
./autogen.sh --prefix="$prefix" --libdir="$prefix/lib"
Expand Down
21 changes: 13 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ set(LINK_LIBS spdlog::spdlog_header_only Boost::boost Boost::filesystem
Qt6::Widgets Qt6::Multimedia Qt6::MultimediaWidgets)

# When building the project with a static Qt6 library, we need to link the
# following components statically as well:
# - Platform plugins
# - Multimedia plugins
# - FFmpeg
# - Libva
# Furthermore, the Qt plugins need to be imported manually using the
# qt_import_plugins() function.
# following components statically as well: - Platform plugins - Multimedia
# plugins - FFmpeg - Libva Furthermore, the Qt plugins need to be imported
# manually using the qt_import_plugins() function.
if(QT6_LIB_TYPE STREQUAL "STATIC_LIBRARY")
set(PLATFORM_PLUGINS
Qt6::QEglFSIntegrationPlugin
Expand All @@ -52,10 +48,19 @@ if(QT6_LIB_TYPE STREQUAL "STATIC_LIBRARY")
find_libva() # creates Libva::va/va-drm/va-x11/va-wayland
message(STATUS "FFmpeg libraries are: ${FFMPEG_LIBRARIES}")

get_target_property(VA_LIBRARY Libva::va LOCATION)
get_target_property(VA_DRM_LIBRARY Libva::va-drm LOCATION)
get_target_property(VA_X11_LIBRARY Libva::va-x11 LOCATION)
get_target_property(VA_WAYLAND_LIBRARY Libva::va-wayland LOCATION)

message(STATUS "Libva::va library is: ${VA_LIBRARY}")
message(STATUS "Libva::va-drm library is: ${VA_DRM_LIBRARY}")
message(STATUS "Libva::va-x11 library is: ${VA_X11_LIBRARY}")
message(STATUS "Libva::va-wayland library is: ${VA_WAYLAND_LIBRARY}")

list(
APPEND
LINK_LIBS
FFmpeg::FFmpeg
Libva::va
Libva::va-drm
Libva::va-x11
Expand Down

0 comments on commit 0624f02

Please sign in to comment.