diff options
Diffstat (limited to '')
-rw-r--r-- | media/libdav1d/moz.build | 215 |
1 files changed, 215 insertions, 0 deletions
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() |