diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /media/libdav1d | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'media/libdav1d')
-rw-r--r-- | media/libdav1d/README_MOZILLA | 56 | ||||
-rw-r--r-- | media/libdav1d/asm/moz.build | 247 | ||||
-rw-r--r-- | media/libdav1d/asm/x86_32/config.asm | 11 | ||||
-rw-r--r-- | media/libdav1d/asm/x86_32/win/config.asm | 13 | ||||
-rw-r--r-- | media/libdav1d/asm/x86_64/config.asm | 9 | ||||
-rw-r--r-- | media/libdav1d/asm/x86_64/linux/config.asm | 11 | ||||
-rw-r--r-- | media/libdav1d/asm/x86_64/osx/config.asm | 13 | ||||
-rw-r--r-- | media/libdav1d/asm/x86_64/win/config.asm | 11 | ||||
-rw-r--r-- | media/libdav1d/config.h | 68 | ||||
-rw-r--r-- | media/libdav1d/generate_source.py | 11 | ||||
-rw-r--r-- | media/libdav1d/moz.build | 215 | ||||
-rw-r--r-- | media/libdav1d/moz.yaml | 73 | ||||
-rw-r--r-- | media/libdav1d/test/fuzztest/autovendored_sources.mozbuild | 0 | ||||
-rw-r--r-- | media/libdav1d/test/fuzztest/dav1d_fuzz_adapter.cpp | 9 | ||||
-rw-r--r-- | media/libdav1d/test/fuzztest/moz.build | 34 | ||||
-rwxr-xr-x | media/libdav1d/update-version.sh | 10 | ||||
-rw-r--r-- | media/libdav1d/vcs_version.h | 2 | ||||
-rw-r--r-- | media/libdav1d/version.h | 34 |
18 files changed, 827 insertions, 0 deletions
diff --git a/media/libdav1d/README_MOZILLA b/media/libdav1d/README_MOZILLA new file mode 100644 index 0000000000..bc5c270869 --- /dev/null +++ b/media/libdav1d/README_MOZILLA @@ -0,0 +1,56 @@ +This directory contains build files for dav1d. The actual library +source is in $TOPSRCDIR/third_party/dav1d/ + +Any patches or additional configuration to be applied to the +upstream source should be kept here in the media/libdav1d +directory. + +To update the library source and build config files, execute + + ./mach vendor media/libdav1d/moz.yaml + +To update to a specific upstream git tag or commit, use + + ./mach vendor media/libdav1d/moz.yaml -r <commit> + +The upstream git repository is https://code.videolan.org/videolan/dav1d + +To update to a fork, use + + ./mach vendor media/libdav1d/moz.yaml --repo <repository url> [-r <commit>] + + +The rough steps are: +- Execute ./mach vendor media/libdav1d/moz.yaml -r {tag-name} # ex: ./mach vendor media/libdav1d/moz.yaml -r 0.6.0 +- Update ./moz.build and ./asm/moz.build to add new files and remove deleted ones using + third_party/dav1d/src/meson.build as a guide (confirm with the diff) (note the + empty .asm file in x86_64) +- Some assembly files (notably avx2-specific ones) will generate no code on win32 builds, + leading to a nasm failure like: + "panic: assertion cv8_state.source_files != NULL failed at output/codeview.c:517" + These files can be identified by the `%if ARCH_X86_64` conditional around the entire contents. + To work around this error, move the sources to the moz.build block with the + `if CONFIG['CPU_ARCH'] == 'x86_64'` conditional. + See https://bugzilla.mozilla.org/show_bug.cgi?id=1712832 and + https://bugzilla.nasm.us/show_bug.cgi?id=3392658 +- Some files will be automatically added to the various autovendored_sources.mozbuild files. + In the case of the asm dir, these may cause build failures on particular platforms which + can be resolved by moving those out of autovendored_sources.mozbuild and into the regular + moz.build which has a condition on CONFIG['CPU_ARCH']. +- Files ending in _tmpl.c may be automatically added to SOURCES, resulting in build failures. + To fix this, the file must be moved to the appropriate bitdepth_basenames list where + generate_source.py will generate the templates into buildable source files. In general, + all *_tmpl.c files require BITDEPTH to be defined. +- Clone the tag from the dav1d repo and build a stand-alone libdav1d following the steps here: + https://code.videolan.org/videolan/dav1d#compile +- Copy vcs_version.h from the local build/include/vcs_version.h + to media/libdav1d/vcs_version.h +- Copy version.h from local build/include/dav1d/version.h to + media/libdav1d/version.h +- Add new options, if any, in moz.build or config.h + +Tips: +- If you see build failures in build-linux64-base-toolchains (or + similar jobs) dav1d may now require a higher minimum nasm version + than our base toolchains currently support. A bug updating the + minimum nasm version will probably be necessary. diff --git a/media/libdav1d/asm/moz.build b/media/libdav1d/asm/moz.build new file mode 100644 index 0000000000..37c26973c0 --- /dev/null +++ b/media/libdav1d/asm/moz.build @@ -0,0 +1,247 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 4 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# ASM enabled + +ASFLAGS += [ + '-I%s/third_party/dav1d/src/' % TOPSRCDIR, + '-DHAVE_AVX512ICL=1', +] + +LOCAL_INCLUDES += [ + '/third_party/dav1d/', + '/third_party/dav1d/include/', + '/third_party/dav1d/src/', +] + +# Don't export DAV1D_API symbols from libxul +# see: third_party/dav1d/include/dav1d/common.h +DEFINES['DAV1D_API'] = '' + +CFLAGS += [ + # find the config.h file. + '-I%s/dist/include/dav1d/' % TOPOBJDIR, +] + +# Store the stack alignment that will be used. +stack_alignment = 0 + +# Attaching config.asm file +if CONFIG['CPU_ARCH'] == 'x86': + # Default stack alignment can be 4 bytes. + if CONFIG['OS_TARGET'] == 'WINNT': + stack_alignment = 4 + ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/win/' % TOPSRCDIR] + else: + ASFLAGS += ['-I%s/media/libdav1d/asm/x86_32/' % TOPSRCDIR] + stack_alignment = 16 + # Change stack alignment to 16 bytes. + if CONFIG['CC_TYPE'] == 'clang': + CFLAGS += ['-mstack-alignment=16'] + elif CONFIG['CC_TYPE'] == 'gcc': + CFLAGS += ['-mpreferred-stack-boundary=4'] +elif CONFIG['CPU_ARCH'] == 'x86_64': + # Default stack aligment is 16 bytes. + stack_alignment = 16 + if CONFIG['OS_TARGET'] == 'Darwin': + ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/osx/' % TOPSRCDIR] + elif CONFIG['OS_TARGET'] == 'WINNT': + ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/win/' % TOPSRCDIR] + else: + # The rest of the platforms are all Linux-like: plain Linux + # Android, OpenBSD, NetBSD, FreeBSD, DragonFly, SunOS + ASFLAGS += ['-I%s/media/libdav1d/asm/x86_64/linux/' % TOPSRCDIR] +elif CONFIG['CPU_ARCH'] == 'aarch64': + stack_alignment = 16 + ASFLAGS += ['-I%s/dist/include/dav1d/' % TOPOBJDIR] +else: + error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH']) + +# Set the macro here instead of config.h +if stack_alignment == 0: + error('Stack alignment cannot be zero.') +DEFINES['STACK_ALIGNMENT'] = stack_alignment + +if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'): + ASFLAGS += ['-Dprivate_prefix=dav1d'] + + SOURCES += [ + '../../../third_party/dav1d/src/x86/cpu.c', + ] + + EXPORTS.dav1d += [ + '../../../third_party/dav1d/src/x86/cpu.h', + '../../../third_party/dav1d/src/x86/msac.h', + ] + + # ASM source files + if CONFIG['CPU_ARCH'] == 'x86_64': + # Empty file on all other archs. Nasm produces + # an error when it compiles empty files. + SOURCES += [ + '../../../third_party/dav1d/src/x86/cdef16_avx2.asm', # moved from autovendored + '../../../third_party/dav1d/src/x86/cdef16_avx512.asm', + '../../../third_party/dav1d/src/x86/cdef_avx2.asm', + '../../../third_party/dav1d/src/x86/cdef_avx512.asm', + '../../../third_party/dav1d/src/x86/filmgrain16_avx2.asm', + '../../../third_party/dav1d/src/x86/filmgrain16_avx512.asm', + '../../../third_party/dav1d/src/x86/filmgrain_avx2.asm', + '../../../third_party/dav1d/src/x86/filmgrain_avx512.asm', + # '../../../third_party/dav1d/src/x86/filmgrain_common.asm', + # ^ filmgrain_common.asm must *not* be in SOURCES because it's only + # used as an %include for other .asm files. Trying to assemble it + # will result in a nasm error: parser: instruction expected + '../../../third_party/dav1d/src/x86/ipred16_avx512.asm', + '../../../third_party/dav1d/src/x86/ipred_avx2.asm', + '../../../third_party/dav1d/src/x86/ipred_avx512.asm', + '../../../third_party/dav1d/src/x86/itx16_avx2.asm', + '../../../third_party/dav1d/src/x86/itx16_avx512.asm', + '../../../third_party/dav1d/src/x86/itx_avx2.asm', + '../../../third_party/dav1d/src/x86/itx_avx512.asm', + '../../../third_party/dav1d/src/x86/loopfilter16_avx2.asm', + '../../../third_party/dav1d/src/x86/loopfilter16_avx512.asm', + '../../../third_party/dav1d/src/x86/loopfilter_avx2.asm', + '../../../third_party/dav1d/src/x86/loopfilter_avx512.asm', + '../../../third_party/dav1d/src/x86/looprestoration16_avx2.asm', + '../../../third_party/dav1d/src/x86/looprestoration16_avx512.asm', + '../../../third_party/dav1d/src/x86/looprestoration_avx2.asm', + '../../../third_party/dav1d/src/x86/looprestoration_avx512.asm', + '../../../third_party/dav1d/src/x86/mc16_avx2.asm', + '../../../third_party/dav1d/src/x86/mc16_avx512.asm', + '../../../third_party/dav1d/src/x86/mc_avx2.asm', + '../../../third_party/dav1d/src/x86/mc_avx512.asm', + ] + + SOURCES += [ + '../../../third_party/dav1d/src/x86/cdef16_sse.asm', + '../../../third_party/dav1d/src/x86/cdef_sse.asm', + '../../../third_party/dav1d/src/x86/cpuid.asm', + '../../../third_party/dav1d/src/x86/filmgrain16_sse.asm', + '../../../third_party/dav1d/src/x86/filmgrain_sse.asm', + '../../../third_party/dav1d/src/x86/ipred16_avx2.asm', + '../../../third_party/dav1d/src/x86/ipred16_sse.asm', + '../../../third_party/dav1d/src/x86/ipred_sse.asm', + '../../../third_party/dav1d/src/x86/itx16_sse.asm', + '../../../third_party/dav1d/src/x86/itx_sse.asm', + '../../../third_party/dav1d/src/x86/loopfilter16_sse.asm', + '../../../third_party/dav1d/src/x86/loopfilter_sse.asm', + '../../../third_party/dav1d/src/x86/looprestoration16_sse.asm', # moved from autovendored + '../../../third_party/dav1d/src/x86/looprestoration_sse.asm', + '../../../third_party/dav1d/src/x86/mc16_sse.asm', + '../../../third_party/dav1d/src/x86/mc_sse.asm', + '../../../third_party/dav1d/src/x86/msac.asm', + '../../../third_party/dav1d/src/x86/refmvs.asm', + ] + + # BITDEPTH + # All the files here should be *_tmpl.c, and the should not appear in SOURCES, + # since they require BITDEPTH to be defined + relative_path = '../../../third_party/dav1d/src/x86/' + bitdepth_basenames = [ + ] + + + for f in bitdepth_basenames: + SOURCES += [ + '!16bd_%s' % f + ] + GeneratedFile('16bd_%s' % f, script='../generate_source.py', + entry_point='add_define', inputs=[relative_path + f], + flags=['BITDEPTH', '16']) + SOURCES += [ + '!8bd_%s' % f + ] + GeneratedFile('8bd_%s' % f, script='../generate_source.py', + entry_point='add_define', inputs=[relative_path + f], + flags=['BITDEPTH', '8']) + +elif CONFIG['CPU_ARCH'] == 'arm' or CONFIG['CPU_ARCH'] == 'aarch64': + SOURCES += [ + '../../../third_party/dav1d/src/arm/cpu.c', + ] + EXPORTS += [ + '../../../third_party/dav1d/src/arm/asm-offsets.h', + '../../../third_party/dav1d/src/arm/cpu.h', + '../../../third_party/dav1d/src/arm/msac.h', + ] + + # BITDEPTH c file + # All the files here should be *_tmpl.c, and the should not appear in SOURCES, + # since they require BITDEPTH to be defined + relative_path = '../../../third_party/dav1d/src/arm/' + bitdepth_basenames = [ + ] + + for f in bitdepth_basenames: + SOURCES += [ + '!16bd_%s' % f + ] + GeneratedFile('16bd_%s' % f, script='../generate_source.py', + entry_point='add_define', inputs=[relative_path + f], + flags=['BITDEPTH', '16']) + SOURCES += [ + '!8bd_%s' % f + ] + GeneratedFile('8bd_%s' % f, script='../generate_source.py', + entry_point='add_define', inputs=[relative_path + f], + flags=['BITDEPTH', '8']) + + # BITDEPTH .S files + if CONFIG['CPU_ARCH'] == 'aarch64': + SOURCES += [ + '../../../third_party/dav1d/src/arm/64/cdef.S', + '../../../third_party/dav1d/src/arm/64/cdef16.S', + '../../../third_party/dav1d/src/arm/64/cdef_tmpl.S', + '../../../third_party/dav1d/src/arm/64/filmgrain.S', + '../../../third_party/dav1d/src/arm/64/filmgrain16.S', + '../../../third_party/dav1d/src/arm/64/ipred.S', + '../../../third_party/dav1d/src/arm/64/ipred16.S', + # itx.S is used for both 8 and 16 bpc. + '../../../third_party/dav1d/src/arm/64/itx.S', + '../../../third_party/dav1d/src/arm/64/itx16.S', + '../../../third_party/dav1d/src/arm/64/loopfilter.S', + '../../../third_party/dav1d/src/arm/64/loopfilter16.S', + '../../../third_party/dav1d/src/arm/64/looprestoration.S', + '../../../third_party/dav1d/src/arm/64/looprestoration16.S', + '../../../third_party/dav1d/src/arm/64/looprestoration_common.S', + '../../../third_party/dav1d/src/arm/64/looprestoration_tmpl.S', + '../../../third_party/dav1d/src/arm/64/mc.S', + '../../../third_party/dav1d/src/arm/64/mc16.S', + '../../../third_party/dav1d/src/arm/64/msac.S', + '../../../third_party/dav1d/src/arm/64/refmvs.S', + ] + elif CONFIG['CPU_ARCH'] == 'arm': + SOURCES += [ + '../../../third_party/dav1d/src/arm/32/cdef.S', + '../../../third_party/dav1d/src/arm/32/cdef16.S', + '../../../third_party/dav1d/src/arm/32/cdef_tmpl.S', + '../../../third_party/dav1d/src/arm/32/filmgrain.S', + '../../../third_party/dav1d/src/arm/32/filmgrain16.S', + '../../../third_party/dav1d/src/arm/32/ipred.S', + '../../../third_party/dav1d/src/arm/32/ipred16.S', + '../../../third_party/dav1d/src/arm/32/itx.S', + '../../../third_party/dav1d/src/arm/32/itx16.S', + '../../../third_party/dav1d/src/arm/32/loopfilter.S', + '../../../third_party/dav1d/src/arm/32/loopfilter16.S', + '../../../third_party/dav1d/src/arm/32/looprestoration.S', + '../../../third_party/dav1d/src/arm/32/looprestoration16.S', + '../../../third_party/dav1d/src/arm/32/looprestoration_common.S', + '../../../third_party/dav1d/src/arm/32/looprestoration_tmpl.S', + '../../../third_party/dav1d/src/arm/32/mc.S', + '../../../third_party/dav1d/src/arm/32/mc16.S', + '../../../third_party/dav1d/src/arm/32/msac.S', + '../../../third_party/dav1d/src/arm/32/refmvs.S', + ] + +if CONFIG['CPU_ARCH'] in ('x86', 'x86_64'): + USE_NASM = True +elif CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['OS_TARGET'] == 'WINNT': + USE_INTEGRATED_CLANGCL_AS = True + +FINAL_LIBRARY = 'gkmedias' + +# We allow warnings for third-party code that can be updated from upstream. +AllowCompilerWarnings() diff --git a/media/libdav1d/asm/x86_32/config.asm b/media/libdav1d/asm/x86_32/config.asm new file mode 100644 index 0000000000..16624aa533 --- /dev/null +++ b/media/libdav1d/asm/x86_32/config.asm @@ -0,0 +1,11 @@ +; Autogenerated by the Meson build system. +; Do not edit, your changes will be lost. + +%define ARCH_X86_32 1 + +%define ARCH_X86_64 0 + +%define PIC 1 + +%define STACK_ALIGNMENT 16 + diff --git a/media/libdav1d/asm/x86_32/win/config.asm b/media/libdav1d/asm/x86_32/win/config.asm new file mode 100644 index 0000000000..f701a081aa --- /dev/null +++ b/media/libdav1d/asm/x86_32/win/config.asm @@ -0,0 +1,13 @@ +; Autogenerated by the Meson build system. +; Do not edit, your changes will be lost. + +%define ARCH_X86_32 1 + +%define ARCH_X86_64 0 + +%define PIC 1 + +%define PREFIX 1 + +%define STACK_ALIGNMENT 4 + diff --git a/media/libdav1d/asm/x86_64/config.asm b/media/libdav1d/asm/x86_64/config.asm new file mode 100644 index 0000000000..26c26f785c --- /dev/null +++ b/media/libdav1d/asm/x86_64/config.asm @@ -0,0 +1,9 @@ +; Autogenerated by the Meson build system. +; Do not edit, your changes will be lost. + +%define ARCH_X86_32 0 + +%define ARCH_X86_64 1 + +%define STACK_ALIGNMENT 32 + diff --git a/media/libdav1d/asm/x86_64/linux/config.asm b/media/libdav1d/asm/x86_64/linux/config.asm new file mode 100644 index 0000000000..8fc2739276 --- /dev/null +++ b/media/libdav1d/asm/x86_64/linux/config.asm @@ -0,0 +1,11 @@ +; Autogenerated by the Meson build system. +; Do not edit, your changes will be lost. + +%define ARCH_X86_32 0 + +%define ARCH_X86_64 1 + +%define PIC 1 + +%define STACK_ALIGNMENT 16 + diff --git a/media/libdav1d/asm/x86_64/osx/config.asm b/media/libdav1d/asm/x86_64/osx/config.asm new file mode 100644 index 0000000000..d1ad0b196e --- /dev/null +++ b/media/libdav1d/asm/x86_64/osx/config.asm @@ -0,0 +1,13 @@ +; Autogenerated by the Meson build system. +; Do not edit, your changes will be lost. + +%define ARCH_X86_32 0 + +%define ARCH_X86_64 1 + +%define PIC 1 + +%define PREFIX 1 + +%define STACK_ALIGNMENT 16 + diff --git a/media/libdav1d/asm/x86_64/win/config.asm b/media/libdav1d/asm/x86_64/win/config.asm new file mode 100644 index 0000000000..8fc2739276 --- /dev/null +++ b/media/libdav1d/asm/x86_64/win/config.asm @@ -0,0 +1,11 @@ +; Autogenerated by the Meson build system. +; Do not edit, your changes will be lost. + +%define ARCH_X86_32 0 + +%define ARCH_X86_64 1 + +%define PIC 1 + +%define STACK_ALIGNMENT 16 + diff --git a/media/libdav1d/config.h b/media/libdav1d/config.h new file mode 100644 index 0000000000..218c8ae7f4 --- /dev/null +++ b/media/libdav1d/config.h @@ -0,0 +1,68 @@ +#pragma once + +// Set platform +#if defined(__aarch64__) || defined(_M_ARM64) +# define ARCH_AARCH64 1 +#else +# define ARCH_AARCH64 0 +#endif + +#if defined(__arm__) || defined(_M_ARM) +# define ARCH_ARM 1 +#else +# define ARCH_ARM 0 +#endif + +#if defined(__i386__) || defined(_M_IX86) +# define ARCH_X86_32 1 +#else +# define ARCH_X86_32 0 +#endif + +#if defined(__x86_64__) || defined(_M_X64) +# define ARCH_X86_64 1 +#else +# define ARCH_X86_64 0 +#endif + +#if ARCH_X86_32 == 1 || ARCH_X86_64 == 1 +# define ARCH_X86 1 +#else +# define ARCH_X86 0 +#endif + +// Set both bitdepeth in every case +#define CONFIG_16BPC 1 +#define CONFIG_8BPC 1 + +// Enable asm +#if defined(MOZ_DAV1D_ASM) +# define HAVE_ASM 1 +#else +# define HAVE_ASM 0 +#endif + +#if ARCH_AARCH64 == 1 +// Those values are copied from the auto generated +// config file produced by stand alone dav1d build. +# define HAVE_AS_FUNC 0 +# define HAVE_GETAUXVAL 1 +# define PIC 3 +#endif + +// The following macros are defined from autoconf +// according to the system configuration. +// (HAVE_MEMALIGN | HAVE_ALIGNED_MALLOC | HAVE_POSIX_MEMALIGN) +// HAVE_UNISTD_H + +// Important when asm is enabled +#if defined(__APPLE__) || (ARCH_x86_32 == 1 && defined(_WIN32)) +# define PREFIX 1 +#endif + +#if defined(_WIN32) || defined(__CYGWIN__) +// _WIN32_WINNT 0x0601 is set in global macros +# define UNICODE 1 +# define _UNICODE 1 +# define __USE_MINGW_ANSI_STDIO 1 +#endif diff --git a/media/libdav1d/generate_source.py b/media/libdav1d/generate_source.py new file mode 100644 index 0000000000..4c2dad0dae --- /dev/null +++ b/media/libdav1d/generate_source.py @@ -0,0 +1,11 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + +def add_define(out_file, in_path, expr, num = ''): + out_file.write('#define %s %s\n' % (expr, num)) + with open(in_path, 'r', encoding='utf-8') as fh: + out_file.write(fh.read()) diff --git a/media/libdav1d/moz.build b/media/libdav1d/moz.build new file mode 100644 index 0000000000..923dca05eb --- /dev/null +++ b/media/libdav1d/moz.build @@ -0,0 +1,215 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Library('dav1d') + +LOCAL_INCLUDES += [ + '/third_party/dav1d', + '/third_party/dav1d/include', + '/third_party/dav1d/include/dav1d', + '/third_party/dav1d/src', +] + +EXPORTS.dav1d += [ + 'config.h', + 'version.h', +] + +# entrypoint source files +entrypoint_source_files = [ + '../../third_party/dav1d/src/lib.c', + '../../third_party/dav1d/src/thread_task.c', +] +SOURCES += [f for f in entrypoint_source_files] + +# Don't export DAV1D_API symbols from libxul +# see: third_party/dav1d/include/dav1d/common.h +DEFINES['DAV1D_API'] = '' + +if CONFIG['MOZ_DAV1D_ASM']: + DIRS += ['asm'] + + # Store the stack alignment that will be used. + stack_alignment = 0 + + # Default stack alignment can be 4 bytes on x86. + if CONFIG['CPU_ARCH'] == 'x86': + if CONFIG['OS_TARGET'] == 'WINNT': + # Allow the default to avoid crashes + stack_alignment = 4 + else: + # Update stack alignment to 16 bytes. + stack_alignment = 16 + if CONFIG['CC_TYPE'] == 'clang': + CFLAGS += ['-mstack-alignment=16'] + for ep in entrypoint_source_files: + SOURCES[ep].flags += ['-mstackrealign'] + elif CONFIG['CC_TYPE'] == 'gcc': + CFLAGS += ['-mpreferred-stack-boundary=4'] + for ep in entrypoint_source_files: + SOURCES[ep].flags += ['-mincoming-stack-boundary=2'] + elif CONFIG['CPU_ARCH'] in ('x86_64', 'aarch64'): + # The default stack alignment is 16 bytes. + stack_alignment = 16 + else: + error('Cpu arch %s is not expected' % CONFIG['CPU_ARCH']) + + # Set the macro here instead of config.h + if stack_alignment == 0: + error('Stack alignment cannot be zero.') + DEFINES['STACK_ALIGNMENT'] = stack_alignment + +if CONFIG['OS_TARGET'] == 'Linux': + # For fuzzing, We only support building on Linux currently. + include('/tools/fuzzing/libfuzzer-config.mozbuild') + if CONFIG['FUZZING_INTERFACES']: + TEST_DIRS += [ + 'test/fuzztest' + ] + +# common sources +SOURCES += [ + '../../third_party/dav1d/src/cdf.c', + '../../third_party/dav1d/src/cpu.c', + '../../third_party/dav1d/src/data.c', + '../../third_party/dav1d/src/decode.c', + '../../third_party/dav1d/src/dequant_tables.c', + '../../third_party/dav1d/src/getbits.c', + '../../third_party/dav1d/src/intra_edge.c', + '../../third_party/dav1d/src/itx_1d.c', + '../../third_party/dav1d/src/lf_mask.c', + '../../third_party/dav1d/src/log.c', + '../../third_party/dav1d/src/mem.c', + '../../third_party/dav1d/src/msac.c', + '../../third_party/dav1d/src/obu.c', + '../../third_party/dav1d/src/picture.c', + '../../third_party/dav1d/src/qm.c', + '../../third_party/dav1d/src/ref.c', + '../../third_party/dav1d/src/refmvs.c', + '../../third_party/dav1d/src/scan.c', + '../../third_party/dav1d/src/tables.c', + '../../third_party/dav1d/src/warpmv.c', + '../../third_party/dav1d/src/wedge.c', +] + +# includes src +EXPORTS.dav1d.src += [ + '../../third_party/dav1d/src/cdf.h', + '../../third_party/dav1d/src/cpu.h', + '../../third_party/dav1d/src/ctx.h', + '../../third_party/dav1d/src/data.h', + '../../third_party/dav1d/src/decode.h', + '../../third_party/dav1d/src/dequant_tables.h', + '../../third_party/dav1d/src/filmgrain.h', + '../../third_party/dav1d/src/getbits.h', + '../../third_party/dav1d/src/intra_edge.h', + '../../third_party/dav1d/src/lf_mask.h', + '../../third_party/dav1d/src/log.h', + '../../third_party/dav1d/src/mem.h', + '../../third_party/dav1d/src/msac.h', + '../../third_party/dav1d/src/obu.h', + '../../third_party/dav1d/src/picture.h', + '../../third_party/dav1d/src/qm.h', + '../../third_party/dav1d/src/ref.h', + '../../third_party/dav1d/src/refmvs.h', + '../../third_party/dav1d/src/scan.h', + '../../third_party/dav1d/src/tables.h', + '../../third_party/dav1d/src/thread.h', + '../../third_party/dav1d/src/warpmv.h', + '../../third_party/dav1d/src/wedge.h', +] + +# common BITDEPTH 8, 16 +# All the files here should be *_tmpl.c, and the should not appear in SOURCES, +# since they require BITDEPTH to be defined +relative_path = '../../third_party/dav1d/src/' +bitdepth_basenames = [ + 'cdef_apply_tmpl.c', + 'cdef_tmpl.c', + 'fg_apply_tmpl.c', + 'filmgrain_tmpl.c', + 'ipred_prepare_tmpl.c', + 'ipred_tmpl.c', + 'itx_tmpl.c', + 'lf_apply_tmpl.c', + 'loopfilter_tmpl.c', + 'looprestoration_tmpl.c', + 'lr_apply_tmpl.c', + 'mc_tmpl.c', + 'recon_tmpl.c' +] + +generated_files = [] + +for f in bitdepth_basenames: + file_bd16 = '16bd_%s' % f + file_bd8 = '8bd_%s' % f + + GeneratedFile(file_bd16, + script='generate_source.py', + entry_point='add_define', + inputs=[relative_path + f], + flags=['BITDEPTH', '16']) + GeneratedFile(file_bd8, + script='generate_source.py', + entry_point='add_define', + inputs=[relative_path + f], + flags=['BITDEPTH', '8']) + + generated_files += [file_bd16, file_bd8] + +for p in generated_files: + if p.endswith('.c'): + SOURCES += ['!%s' % p] + +EXPORTS.dav1d.src += [ + '../../third_party/dav1d/src/cdef.h', + '../../third_party/dav1d/src/cdef_apply.h', + '../../third_party/dav1d/src/fg_apply.h', + '../../third_party/dav1d/src/ipred.h', + '../../third_party/dav1d/src/ipred_prepare.h', + '../../third_party/dav1d/src/itx.h', + '../../third_party/dav1d/src/itx_1d.h', + '../../third_party/dav1d/src/lf_apply.h', + '../../third_party/dav1d/src/loopfilter.h', + '../../third_party/dav1d/src/looprestoration.h', + '../../third_party/dav1d/src/lr_apply.h', + '../../third_party/dav1d/src/mc.h', + '../../third_party/dav1d/src/recon.h', +] + +# include/common +EXPORTS.dav1d += [ + '../../third_party/dav1d/include/common/attributes.h', + '../../third_party/dav1d/include/common/bitdepth.h', + '../../third_party/dav1d/include/common/dump.h', + '../../third_party/dav1d/include/common/frame.h', + '../../third_party/dav1d/include/common/intops.h', + '../../third_party/dav1d/include/common/validate.h', +] + +# include/dav1d +EXPORTS.dav1d += [ + '../../third_party/dav1d/include/dav1d/common.h', + '../../third_party/dav1d/include/dav1d/data.h', + '../../third_party/dav1d/include/dav1d/dav1d.h', + '../../third_party/dav1d/include/dav1d/headers.h', + '../../third_party/dav1d/include/dav1d/picture.h', +] + +if CONFIG['OS_TARGET'] == 'WINNT': + SOURCES += [ + '../../third_party/dav1d/src/win32/thread.c' + ] + +if CONFIG['CC_TYPE'] == 'gcc': + LOCAL_INCLUDES += ['../../third_party/dav1d/include/compat/gcc/'] + EXPORTS.dav1d += ['../../third_party/dav1d/include/compat/gcc/stdatomic.h'] + +FINAL_LIBRARY = 'gkmedias' + +# We allow warnings for third-party code that can be updated from upstream. +AllowCompilerWarnings() diff --git a/media/libdav1d/moz.yaml b/media/libdav1d/moz.yaml new file mode 100644 index 0000000000..d97fec14d9 --- /dev/null +++ b/media/libdav1d/moz.yaml @@ -0,0 +1,73 @@ +# Version of this schema +schema: 1 + +bugzilla: + # Bugzilla product and component for this directory and subdirectories + product: Core + component: "Audio/Video: Playback" + +# Document the source of externally hosted code +origin: + + # Short name of the package/library + name: dav1d + + description: dav1d, a fast AV1 decoder + + # Full URL for the package's homepage/etc + # Usually different from repository url + url: https://code.videolan.org/videolan/dav1d + + # Human-readable identifier for this version/release + # Generally "version NNN", "tag SSS", "bookmark SSS" + release: 5aa3b38f9871859e14e55f18ab5e38318fe86305 (2023-04-08T11:47:31.000+00:00). + + # Revision to pull in + # Must be a long or short commit SHA (long preferred) + revision: 5aa3b38f9871859e14e55f18ab5e38318fe86305 + + # The package's license, where possible using the mnemonic from + # https://spdx.org/licenses/ + # Multiple licenses can be specified (as a YAML list) + # A "LICENSE" file must exist containing the full license text + license: BSD-2-Clause + + license-file: COPYING + +updatebot: + maintainer-phab: chunmin + maintainer-bz: cchang@mozilla.com + tasks: + - type: vendoring + enabled: true + frequency: release + +vendoring: + url: https://code.videolan.org/videolan/dav1d + source-hosting: gitlab + vendor-directory: third_party/dav1d + + exclude: + - build/.gitattributes + - build/.gitignore + - doc + - examples + - package + - tools + + generated: + - '{yaml_dir}/vcs_version.h' + - '{yaml_dir}/version.h' + + update-actions: + - action: copy-file + from: include/vcs_version.h.in + to: '{yaml_dir}/vcs_version.h' + - action: replace-in-file + pattern: '@VCS_TAG@' + with: '{revision}' + file: '{yaml_dir}/vcs_version.h' + - action: run-script + script: '{yaml_dir}/update-version.sh' + cwd: '{vendor_dir}' + args: ['{yaml_dir}/version.h'] diff --git a/media/libdav1d/test/fuzztest/autovendored_sources.mozbuild b/media/libdav1d/test/fuzztest/autovendored_sources.mozbuild new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/media/libdav1d/test/fuzztest/autovendored_sources.mozbuild diff --git a/media/libdav1d/test/fuzztest/dav1d_fuzz_adapter.cpp b/media/libdav1d/test/fuzztest/dav1d_fuzz_adapter.cpp new file mode 100644 index 0000000000..4a038344a8 --- /dev/null +++ b/media/libdav1d/test/fuzztest/dav1d_fuzz_adapter.cpp @@ -0,0 +1,9 @@ + +#include "FuzzingInterface.h" + +namespace dav1dfuzz { +#include "tests/libfuzzer/dav1d_fuzzer.c" +} + +MOZ_FUZZING_INTERFACE_RAW(nullptr, dav1dfuzz::LLVMFuzzerTestOneInput, + Dav1dDecode); diff --git a/media/libdav1d/test/fuzztest/moz.build b/media/libdav1d/test/fuzztest/moz.build new file mode 100644 index 0000000000..4b12fe2de6 --- /dev/null +++ b/media/libdav1d/test/fuzztest/moz.build @@ -0,0 +1,34 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Library('FuzzingDav1d') + +LOCAL_INCLUDES += [ + '/media/libdav1d', + '/third_party/dav1d', + '/third_party/dav1d/include', + '/third_party/dav1d/tests/libfuzzer/', +] + +# We currently only support building on Linux for fuzzing here, as guarded +# in media/libaom/moz.build. More support can be added later if necessary. +if CONFIG['CPU_ARCH'] == 'x86_64': + LOCAL_INCLUDES += [ + '/media/libdav1d/asm/x86_64/', + ] +elif CONFIG['CPU_ARCH'] == 'x86': + LOCAL_INCLUDES += [ + '/media/libdav1d/asm/x86_32/', + ] + +SOURCES += [ + '/third_party/dav1d/tests/libfuzzer/dav1d_fuzzer.c', + 'dav1d_fuzz_adapter.cpp', +] + +include('/tools/fuzzing/libfuzzer-config.mozbuild') + +FINAL_LIBRARY = 'xul-gtest' diff --git a/media/libdav1d/update-version.sh b/media/libdav1d/update-version.sh new file mode 100755 index 0000000000..8d51315ea7 --- /dev/null +++ b/media/libdav1d/update-version.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +MAJOR_VERSION=$(grep -E "dav1d_soname_version\s+=" meson.build | grep -o -E "'([0-9]+)" | sed "s/'//") +MINOR_VERSION=$(grep -E "dav1d_soname_version\s+=" meson.build | grep -o -E "\.([0-9]+)\." | sed "s/\.//g") +PATCH_VERSION=$(grep -E "dav1d_soname_version\s+=" meson.build | grep -o -E "([0-9]+)'" | sed "s/'//") + +sed -i.bak "s/DAV1D_API_VERSION_MAJOR \([0-9]\+\)/DAV1D_API_VERSION_MAJOR $MAJOR_VERSION/" "$1" +sed -i.bak "s/DAV1D_API_VERSION_MINOR \([0-9]\+\)/DAV1D_API_VERSION_MINOR $MINOR_VERSION/" "$1" +sed -i.bak "s/DAV1D_API_VERSION_PATCH \([0-9]\+\)/DAV1D_API_VERSION_PATCH $PATCH_VERSION/" "$1" +rm -f "$1.bak" diff --git a/media/libdav1d/vcs_version.h b/media/libdav1d/vcs_version.h new file mode 100644 index 0000000000..c74f30d0be --- /dev/null +++ b/media/libdav1d/vcs_version.h @@ -0,0 +1,2 @@ +/* auto-generated, do not edit */ +#define DAV1D_VERSION "5aa3b38f9871859e14e55f18ab5e38318fe86305" diff --git a/media/libdav1d/version.h b/media/libdav1d/version.h new file mode 100644 index 0000000000..aa4ae47874 --- /dev/null +++ b/media/libdav1d/version.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2019, VideoLAN and dav1d authors + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DAV1D_VERSION_H +#define DAV1D_VERSION_H + +#define DAV1D_API_VERSION_MAJOR 6 +#define DAV1D_API_VERSION_MINOR 8 +#define DAV1D_API_VERSION_PATCH 0 + +#endif /* DAV1D_VERSION_H */ |