summaryrefslogtreecommitdiffstats
path: root/media/libdav1d/moz.build
blob: 821845c00e38a0721bae48541064946d5a9105d6 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# -*- 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['TARGET_CPU'] == '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['TARGET_CPU'] in ('x86_64', 'aarch64'):
        # The default stack alignment is 16 bytes.
        stack_alignment = 16
    else:
        error('Cpu arch %s is not expected' % CONFIG['TARGET_CPU'])

    # 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/pal.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()