From cdddec07209243c8398717ba3e701ac79ad6d6f4 Mon Sep 17 00:00:00 2001 From: Vignesh Venkat Date: Mon, 1 Apr 2024 09:50:30 -0700 Subject: [PATCH] android_jni: Allow loading dav1d as a separate shared object Try loading libdav1d.so as a separate shared object. This allows apps to share dav1d between video and AVIF decoding without having to bundle it within libavif_android.so to reduce the APK size. --- .../src/main/java/org/aomedia/avif/android/AvifDecoder.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android_jni/avifandroidjni/src/main/java/org/aomedia/avif/android/AvifDecoder.java b/android_jni/avifandroidjni/src/main/java/org/aomedia/avif/android/AvifDecoder.java index 5e9fc86409..674c6e5600 100644 --- a/android_jni/avifandroidjni/src/main/java/org/aomedia/avif/android/AvifDecoder.java +++ b/android_jni/avifandroidjni/src/main/java/org/aomedia/avif/android/AvifDecoder.java @@ -37,6 +37,12 @@ @SuppressWarnings("CatchAndPrintStackTrace") public class AvifDecoder { static { + // If dav1d is built as a separate shared object, try loading that first. + try { + System.loadLibrary("dav1d"); + } catch (UnsatisfiedLinkError exception) { + // This is not an error. Do nothing. + } try { System.loadLibrary("avif_android"); } catch (UnsatisfiedLinkError exception) {