summarylogtreecommitdiffstats
path: root/7002_system_av1_support.patch
blob: 2812a003e81521f0894603d2331b067c9de0f224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# HG changeset patch
# User Thomas Deutschmann <whissi@gentoo.org>
# Parent  a58801e9e29b0db9da0b5d90b96f2e05ff062de1

# Parent  66f9c84511dda432587261f6b9ebf07c4771aad8
Add ability to use system-av1 (media-libs/libaom and media-libs/dav1d) instead of bundled.

diff --git a/config/external/moz.build b/config/external/moz.build
--- a/config/external/moz.build
+++ b/config/external/moz.build
@@ -39,9 +39,10 @@
 if not CONFIG["MOZ_SYSTEM_LIBVPX"]:
     external_dirs += ["media/libvpx"]
 
-if CONFIG["MOZ_AV1"]:
-    external_dirs += ["media/libaom"]
-    external_dirs += ["media/libdav1d"]
+if CONFIG['MOZ_AV1']:
+    if not CONFIG['MOZ_SYSTEM_AV1']:
+        external_dirs += ['media/libaom']
+        external_dirs += ['media/libdav1d']
 
 if not CONFIG["MOZ_SYSTEM_PNG"]:
     external_dirs += ["media/libpng"]
diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
--- a/config/system-headers.mozbuild
+++ b/config/system-headers.mozbuild
@@ -1301,6 +1301,14 @@
         'proxy.h',
     ]
 
+if CONFIG['MOZ_SYSTEM_AV1']:
+    system_headers += [
+        'aom/aom_decoder.h',
+        'aom/aomdx.h',
+        'aom/aom_image.h',
+        'dav1d/dav1d.h',
+    ]
+
 if CONFIG['MOZ_SYSTEM_LIBVPX']:
     system_headers += [
         'vpx_mem/vpx_mem.h',
diff --git a/dom/media/platforms/moz.build b/dom/media/platforms/moz.build
--- a/dom/media/platforms/moz.build
+++ b/dom/media/platforms/moz.build
@@ -78,6 +78,12 @@
         "agnostic/AOMDecoder.cpp",
         "agnostic/DAV1DDecoder.cpp",
     ]
+    if CONFIG['MOZ_SYSTEM_AV1']:
+        CXXFLAGS += CONFIG['MOZ_SYSTEM_LIBAOM_CFLAGS']
+        OS_LIBS  += CONFIG['MOZ_SYSTEM_LIBAOM_LIBS']
+        CXXFLAGS += CONFIG['MOZ_SYSTEM_LIBDAV1D_CFLAGS']
+        OS_LIBS  += CONFIG['MOZ_SYSTEM_LIBDAV1D_LIBS']
+
 
 if CONFIG["MOZ_OMX"]:
     EXPORTS += [
diff --git a/toolkit/moz.configure b/toolkit/moz.configure
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -563,7 +563,24 @@
         return True
 
 
-@depends(target, nasm_version, when=av1 & compile_environment)
+option('--with-system-av1',
+       help="Use system av1 (located with pkgconfig)")
+
+system_libaom_info = pkg_check_modules('MOZ_SYSTEM_LIBAOM', 'aom >= 1.0.0',
+                                       when='--with-system-av1')
+
+system_libdav1d_info = pkg_check_modules('MOZ_SYSTEM_LIBDAV1D', 'dav1d >= 0.1.1',
+                                         when='--with-system-av1')
+
+@depends(system_libaom_info, system_libdav1d_info)
+def system_av1(system_libaom_info, system_libdav1d_info):
+    has_av1_libs = False
+    if system_libaom_info and system_libdav1d_info:
+        has_av1_libs = True
+    return has_av1_libs
+
+
+@depends(target, nasm_version, when=av1 & depends(system_av1)(lambda v: not v) & compile_environment)
 def dav1d_asm(target, nasm_version):
     if target.cpu == "aarch64":
         return True