commit 25a5572d5cd137aa6d893e09a00bd39908a59a18 Author: Christoph Moench-Tegeder Date: Tue Sep 10 22:23:32 2024 +0200 based on: commit 717bba28411c Author: Jory A. Pratt Date: Thu Jun 13 11:53:00 2019 -0700 Bug 1559213 - Allow to use system av1 libs instead of bundled. diff --git config/external/moz.build config/external/moz.build index a24b470396cf..547f5f5c9e04 100644 --- config/external/moz.build +++ config/external/moz.build @@ -40,8 +40,9 @@ if not CONFIG["MOZ_SYSTEM_LIBVPX"]: external_dirs += ["media/libvpx"] if CONFIG["MOZ_AV1"]: - external_dirs += ["media/libaom"] - external_dirs += ["media/libdav1d"] + 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 dom/media/platforms/moz.build dom/media/platforms/moz.build index 61536cc6e225..29cf635bbb44 100644 --- dom/media/platforms/moz.build +++ dom/media/platforms/moz.build @@ -71,6 +71,11 @@ if CONFIG["MOZ_AV1"]: "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 media/ffvpx/libavcodec/moz.build media/ffvpx/libavcodec/moz.build index 6f09049a6068..90a82a19a9d1 100644 --- media/ffvpx/libavcodec/moz.build +++ media/ffvpx/libavcodec/moz.build @@ -119,10 +119,16 @@ if not CONFIG['MOZ_FFVPX_AUDIOONLY']: 'vp9recon.c', 'vpx_rac.c', ] - USE_LIBS += [ - 'dav1d', - 'media_libdav1d_asm', - ] + if CONFIG["MOZ_SYSTEM_AV1"]: + CFLAGS += CONFIG['MOZ_SYSTEM_LIBDAV1D_CFLAGS'] + OS_LIBS += CONFIG['MOZ_SYSTEM_LIBDAV1D_LIBS'] + CFLAGS += CONFIG['MOZ_SYSTEM_LIBAOM_CFLAGS'] + OS_LIBS += CONFIG['MOZ_SYSTEM_LIBAOM_LIBS'] + else: + USE_LIBS += [ + 'dav1d', + 'media_libdav1d_asm', + ] if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": LOCAL_INCLUDES += ['/media/mozva'] SOURCES += [ diff --git media/libopus/moz.build media/libopus/moz.build index 943aee79ee99..4ad07e3e98af 100644 --- media/libopus/moz.build +++ media/libopus/moz.build @@ -58,7 +58,7 @@ if not CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]: DEFINES["FIXED_POINT"] = 1 DEFINES["DISABLE_FLOAT_API"] = True -if CONFIG["OS_ARCH"] == "Linux": +if CONFIG["OS_ARCH"] in ("FreeBSD", "Linux"): OS_LIBS += [ "m", ] diff --git media/libvorbis/moz.build media/libvorbis/moz.build index cd17d4f89759..816edd72a000 100644 --- media/libvorbis/moz.build +++ media/libvorbis/moz.build @@ -45,7 +45,7 @@ LOCAL_INCLUDES += ['lib'] if CONFIG['OS_ARCH'] == 'SunOS': DEFINES['HAVE_ALLOCA_H'] = True -if CONFIG["OS_ARCH"] == "Linux": +if CONFIG["OS_ARCH"] in ("FreeBSD", "Linux"): OS_LIBS += [ "m", ] diff --git toolkit/moz.configure toolkit/moz.configure index 1f85d2831f2f..07294b93f850 100644 --- toolkit/moz.configure +++ toolkit/moz.configure @@ -883,7 +883,23 @@ def av1(value): return True -@depends(target, 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, when=av1 & depends(system_av1)(lambda v: not v) & compile_environment) def dav1d_asm(target): if target.cpu in ("aarch64", "x86", "x86_64"): return True @@ -899,6 +915,7 @@ set_config("MOZ_DAV1D_ASM", dav1d_asm) set_define("MOZ_DAV1D_ASM", dav1d_asm) set_config("MOZ_AV1", av1) set_define("MOZ_AV1", av1) +set_config("MOZ_SYSTEM_AV1", depends_if(system_av1)(lambda _: True)) # JXL Image Codec Support # ==============================================================