Skip to content
Merged
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
20 changes: 18 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
id: native-prefix-cache
uses: actions/cache/restore@v4
with:
path: gh-cache/
path: buildscripts/prefix/
key: native-prefix-${{ runner.os }}-${{ env.CACHE_IDENTIFIER }}
restore-keys: |
native-prefix-${{ runner.os }}-
Expand All @@ -95,16 +95,19 @@ jobs:
automake \
build-essential \
ccache \
dos2unix \
gcc g++ \
cmake \
gettext \
glslang-tools \
gperf \
libtool \
nasm \
ninja-build \
pkg-config \
python3 \
python3-pip \
spirv-tools \
unzip \
wget

Expand All @@ -118,6 +121,15 @@ jobs:
set -euxo pipefail
cd buildscripts
./download.sh

echo "Downloading latest Vulkan-Headers..."
if [ ! -d "deps/Vulkan-Headers" ]; then
git clone https://github.com/KhronosGroup/Vulkan-Headers.git deps/Vulkan-Headers
fi

echo "Normalizing line endings for all scripts..."
cd ..
find . -type f \( -name '*.sh' -o -name 'gradlew' \) -exec dos2unix {} +

- name: Save Android SDK cache
if: steps.android-sdk-cache.outputs.cache-hit != 'true'
Expand All @@ -130,7 +142,7 @@ jobs:
if: steps.native-prefix-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: gh-cache/
path: buildscripts/prefix/
key: native-prefix-${{ runner.os }}-${{ env.CACHE_IDENTIFIER }}

- name: Show ccache stats before build
Expand All @@ -151,6 +163,10 @@ jobs:
[ "$ENABLE_ARM_V9A" = "true" ] && arches+=(arm64-v9a)
[ "$ENABLE_X86_ARCH" = "true" ] && arches+=(x86 x86_64)
for arch in "${arches[@]}"; do
echo "Injecting Vulkan headers into prefix/$arch/include..."
mkdir -p "prefix/$arch/include"
cp -r deps/Vulkan-Headers/include/vulkan "prefix/$arch/include/"
cp -r deps/Vulkan-Headers/include/vk_video "prefix/$arch/include/"
./buildall.sh --arch "$arch" mpv
done

Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
id: native-prefix-cache
uses: actions/cache/restore@v4
with:
path: gh-cache/
path: buildscripts/prefix/
key: native-prefix-${{ runner.os }}-${{ env.CACHE_IDENTIFIER }}
restore-keys: |
native-prefix-${{ runner.os }}-
Expand All @@ -147,15 +147,18 @@ jobs:
build-essential \
ccache \
cmake \
dos2unix \
gcc g++ \
gettext \
glslang-tools \
gperf \
libtool \
nasm \
ninja-build \
pkg-config \
python3 \
python3-pip \
spirv-tools \
unzip \
wget

Expand All @@ -169,6 +172,15 @@ jobs:
set -euxo pipefail
cd buildscripts
./download.sh

echo "Downloading latest Vulkan-Headers..."
if [ ! -d "deps/Vulkan-Headers" ]; then
git clone https://github.com/KhronosGroup/Vulkan-Headers.git deps/Vulkan-Headers
fi

echo "Normalizing line endings for all scripts..."
cd ..
find . -type f \( -name '*.sh' -o -name 'gradlew' \) -exec dos2unix {} +

- name: Save Android SDK cache
if: steps.android-sdk-cache.outputs.cache-hit != 'true'
Expand All @@ -181,7 +193,7 @@ jobs:
if: steps.native-prefix-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: gh-cache/
path: buildscripts/prefix/
key: native-prefix-${{ runner.os }}-${{ env.CACHE_IDENTIFIER }}

- name: Show ccache stats before build
Expand All @@ -202,6 +214,10 @@ jobs:
[ "$ENABLE_ARM_V9A" = "true" ] && arches+=(arm64-v9a)
[ "$ENABLE_X86_ARCH" = "true" ] && arches+=(x86 x86_64)
for arch in "${arches[@]}"; do
echo "Injecting Vulkan headers into prefix/$arch/include..."
mkdir -p "prefix/$arch/include"
cp -r deps/Vulkan-Headers/include/vulkan "prefix/$arch/include/"
cp -r deps/Vulkan-Headers/include/vk_video "prefix/$arch/include/"
./buildall.sh --arch "$arch" mpv
done

Expand Down
8 changes: 7 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
compileSdk 36

defaultConfig {
minSdkVersion 24
minSdkVersion 33
targetSdkVersion 36

versionCode 38
Expand All @@ -22,6 +22,12 @@ android {
buildConfig = true
}

sourceSets {
main {
jniLibs.srcDirs = ['src/main/libs']
}
}

// https://youtrack.jetbrains.com/issue/KT-55947
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/is/xyz/mpv/BaseMPVView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ abstract class BaseMPVView(context: Context, attrs: AttributeSet) : SurfaceView(
} catch (e: Exception) {
Log.e(TAG, "Failed to set SSL_CERT_FILE", e)
}

// Adreno-optimized Vulkan defaults for vo=gpu-next
MPVLib.setOptionString("gpu-api", "vulkan")
MPVLib.setOptionString("vulkan-async-compute", "no")
MPVLib.setOptionString("vulkan-async-transfer", "no")
MPVLib.setOptionString("vulkan-queue-count", "1")
MPVLib.setOptionString("vd-lavc-film-grain", "gpu")

initOptions()

MPVLib.init()
Expand Down Expand Up @@ -74,7 +82,7 @@ abstract class BaseMPVView(context: Context, attrs: AttributeSet) : SurfaceView(
this.filePath = filePath
}

private var voInUse: String = "gpu"
private var voInUse: String = "gpu-next"

/**
* Sets the VO to use.
Expand Down
11 changes: 8 additions & 3 deletions buildscripts/buildall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ loadarch () {
}

setup_prefix () {
if [ ! -d "$prefix_dir" ]; then
mkdir -p "$prefix_dir"
# enforce flat structure (/usr/local -> /)
mkdir -p "$prefix_dir"
# enforce flat structure (/usr/local -> /)
# Always re-create: cache restore may replace symlinks with real directories
if [ ! -L "$prefix_dir/usr" ]; then
rm -rf "$prefix_dir/usr"
ln -s . "$prefix_dir/usr"
fi
if [ ! -L "$prefix_dir/local" ]; then
rm -rf "$prefix_dir/local"
ln -s . "$prefix_dir/local"
fi

Expand Down
5 changes: 3 additions & 2 deletions buildscripts/include/depinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ v_vvdec=2.3.0
v_mpeghdec=1.0.2
v_libiamf=1.0.0
v_liblcevc=0.4.1
v_dav1d=1.5.3


## Dependency tree
Expand All @@ -37,7 +38,7 @@ dep_vvdec=()
dep_mpeghdec=()
dep_libiamf=()
dep_liblcevc=()
dep_ffmpeg=(mbedtls dav1d vvdec mpeghdec libiamf liblcevc)
dep_ffmpeg=(mbedtls dav1d vvdec mpeghdec libiamf liblcevc shaderc)
dep_freetype2=()
dep_fribidi=()
dep_harfbuzz=()
Expand All @@ -60,4 +61,4 @@ dep_mpv_android=(mpv python)
v_ci_ffmpeg=n8.1.1

# filename used to uniquely identify a build prefix
ci_tarball="prefix-all-ndk-${v_ndk}-lua-${v_lua}-mujs-${v_mujs}-unibreak-${v_unibreak}-harfbuzz-${v_harfbuzz}-fribidi-${v_fribidi}-freetype-${v_freetype}-mbedtls-${v_mbedtls}-openssl-${v_openssl}-python-${v_python}-curl-${v_curl}-vvdec-${v_vvdec}-mpeghdec-${v_mpeghdec}-libiamf-${v_libiamf}-liblcevc-${v_liblcevc}-ffmpeg-${v_ci_ffmpeg}.tgz"
ci_tarball="prefix-all-ndk-${v_ndk}-lua-${v_lua}-mujs-${v_mujs}-unibreak-${v_unibreak}-harfbuzz-${v_harfbuzz}-fribidi-${v_fribidi}-freetype-${v_freetype}-mbedtls-${v_mbedtls}-openssl-${v_openssl}-python-${v_python}-curl-${v_curl}-vvdec-${v_vvdec}-mpeghdec-${v_mpeghdec}-libiamf-${v_libiamf}-liblcevc-${v_liblcevc}-dav1d-${v_dav1d}-ffmpeg-${v_ci_ffmpeg}.tgz"
2 changes: 1 addition & 1 deletion buildscripts/include/download-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ ! -d mbedtls ]; then
fi

# dav1d (canonical repo, GitHub is read-only mirror)
[ ! -d dav1d ] && git clone https://github.com/videolan/dav1d
[ ! -d dav1d ] && git clone --depth 1 --branch $v_dav1d https://github.com/videolan/dav1d

# vvdec — Fraunhofer VVC (H.266) decoder
if [ ! -d vvdec ]; then
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/scripts/dav1d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi
unset CC CXX # meson wants these unset

meson setup $build --cross-file "$prefix_dir"/crossfile.txt \
-Denable_tests=false -Db_lto=true -Dstack_alignment=16 \
-Denable_tests=false -Dstack_alignment=16 \
-Denable_asm=true

ninja -C $build -j$cores
Expand Down
9 changes: 8 additions & 1 deletion buildscripts/scripts/ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ args=(
--target-os=android --enable-cross-compile
--cross-prefix=$ndk_triple- --cc=$CC --pkg-config=pkg-config --nm=llvm-nm
--arch=${ndk_triple%%-*} --cpu=$cpu
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib"
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib -lvulkan"

--enable-{jni,mediacodec,mbedtls,libdav1d}

# === VULKAN SUPPORT & OPTIMIZATIONS ===
--enable-vulkan
--enable-libshaderc
--enable-decoder=prores_vulkan,ffv1_vulkan,dpx_vulkan
--enable-encoder=ffv1_vulkan,prores_vulkan
--enable-filter=bwdif_vulkan,xfade_vulkan,hflip_vulkan,vflip_vulkan,scale_vulkan,overlay_vulkan,avgblur_vulkan,blend_vulkan,flip_vulkan,transpose_vulkan

# === NEW CODECS (FFmpeg n8.1.1) ===

# VVC (H.266) — Versatile Video Coding
Expand Down
12 changes: 10 additions & 2 deletions buildscripts/scripts/shaderc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ cat >"$prefix_dir"/lib/pkgconfig/shaderc_combined.pc <<"END"
Name: shaderc_combined
Description:
Version: 2022.3-unknown
Libs: -L/usr/local/lib -lshaderc_combined
Libs: -L/usr/local/lib -lshaderc_combined -lc++ -lm
Cflags: -I/usr/local/include
END

if [ -z "$(pkg-config --cflags shaderc_combined)" ]; then
cat >"$prefix_dir"/lib/pkgconfig/shaderc.pc <<"END"
Name: shaderc
Description:
Version: 2022.3-unknown
Libs: -L/usr/local/lib -lshaderc_combined -lc++ -lm
Cflags: -I/usr/local/include
END

if [ -z "$(pkg-config --cflags shaderc_combined)" ] || [ -z "$(pkg-config --cflags shaderc)" ]; then
echo >&2 "shaderc pkg-config sanity check failed"
exit 1
fi
59 changes: 59 additions & 0 deletions wsl-compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
set -e

# WSL Compilation Script for MPV Android AAR
# This script compiles the optimized Vulkan/Adreno AAR library from WSL Ubuntu.

echo "=========================================================="
echo " Vulkan-Optimized MPV Android AAR Compiler for WSL"
echo "=========================================================="

# 1. Sanity Checks
if ! grep -qis "microsoft" /proc/version && ! grep -qis "wsl" /proc/version; then
echo "Warning: This script is designed to run inside WSL (Windows Subsystem for Linux)."
echo "It seems you are running this elsewhere. Let's proceed, but make sure you are on Ubuntu/Debian."
read -p "Press Enter to continue..."
fi

echo "Step 1: Installing Ubuntu dependencies (requires sudo)..."
sudo apt-get update
sudo apt-get install -y \
autoconf \
pkg-config \
libtool \
ninja-build \
unzip \
wget \
meson \
python3 \
nasm \
git \
openjdk-17-jdk \
clang \
build-essential

# 2. Check Java Version
if ! javac -version &>/dev/null; then
echo "Error: JDK 17 is required but could not be found. Please ensure openjdk-17-jdk is installed and configured."
exit 1
fi

echo "Step 2: Checking out/downloading Android SDK and NDK dependencies..."
cd buildscripts
./download.sh

echo "Step 3: Compiling dependencies for standard arm64-v8a..."
./buildall.sh --arch arm64

echo "Step 4: Compiling dependencies for optimized arm64-v9a (Snapdragon 8s Gen 3 / Adreno 735)..."
./buildall.sh --arch arm64-v9a

echo "Step 5: Building final JNI wrappers and packaging AAR..."
./buildall.sh mpv-android

echo "=========================================================="
echo " Build Completed Successfully!"
echo "=========================================================="
echo "Your optimized AAR file is located at:"
ls -lh ../app/build/outputs/aar/*.aar
echo "=========================================================="
Binary file added wsl-source.tar
Binary file not shown.
43 changes: 43 additions & 0 deletions wsl_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

# Fast rsync to avoid 9p filesystem overhead for excluded heavy folders
echo "Step 1: Synchronizing source code to WSL home directory..."
mkdir -p /home/sagnik/mpvlibAndroid
rsync -a --delete \
--exclude='.git' \
--exclude='build' \
--exclude='.gradle' \
--exclude='app/build' \
--exclude='buildscripts/prefix' \
--exclude='buildscripts/deps' \
--exclude='buildscripts/sdk' \
--exclude='buildscripts/_build*' \
--exclude='wsl-source.tar' \
/mnt/c/Users/sagni/StudioProjects/mpvlibAndroid/ /home/sagnik/mpvlibAndroid/

cd /home/sagnik/mpvlibAndroid

echo "Step 2: Cleaning any leftover build files just in case..."
rm -rf buildscripts/prefix buildscripts/deps buildscripts/sdk buildscripts/_build* app/build

echo "Step 3: Downloading SDK, NDK, and dependencies..."
cd buildscripts
echo 2007 | sudo -S ./download.sh
echo 2007 | sudo -S chown -R $USER:$USER /home/sagnik/mpvlibAndroid

echo "Step 4: Building arm64-v8a (base) - CLEAN BUILD..."
./buildall.sh --clean --arch arm64

echo "Step 5: Building arm64-v9a (SVE2 optimized) - CLEAN BUILD..."
./buildall.sh --clean --arch arm64-v9a

echo "Step 6: Packaging final mpv-android AAR..."
./buildall.sh mpv-android
cd ..

echo "Step 7: Copying generated AARs back to Windows host..."
mkdir -p /mnt/c/Users/sagni/StudioProjects/mpvlibAndroid/app/build/outputs/aar/
cp -r app/build/outputs/aar/* /mnt/c/Users/sagni/StudioProjects/mpvlibAndroid/app/build/outputs/aar/

echo "ALL DONE!"
Loading
Loading