meson.build 6.54 KB
Newer Older
1
# Copyright © 2018-2019, VideoLAN and dav1d authors
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
# 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.

#
# Build definition for the dav1d library
#

# libdav1d source files
libdav1d_sources = files(
    'picture.c',
32
    'cpu.c',
33 34
    'data.c',
    'ref.c',
35
    'log.c',
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    'getbits.c',
    'obu.c',
    'decode.c',
    'cdf.c',
    'msac.c',
    'tables.c',
    'scan.c',
    'dequant_tables.c',
    'intra_edge.c',
    'lf_mask.c',
    'ref_mvs.c',
    'warpmv.c',
    'wedge.c',
    'qm.c',
)

# libdav1d bitdepth source files
# These files are compiled for each bitdepth with
# `BITDEPTH` defined to the currently built bitdepth.
libdav1d_tmpl_sources = files(
56
    'ipred_prepare_tmpl.c',
57 58 59 60 61 62 63 64 65
    'ipred_tmpl.c',
    'itx_tmpl.c',
    'lf_apply_tmpl.c',
    'loopfilter_tmpl.c',
    'mc_tmpl.c',
    'cdef_apply_tmpl.c',
    'cdef_tmpl.c',
    'lr_apply_tmpl.c',
    'looprestoration_tmpl.c',
66 67
    'recon_tmpl.c',
    'film_grain_tmpl.c',
68 69 70 71 72 73 74 75 76 77 78
)

# libdav1d entrypoint source files
# These source files contain library entry points and are
# built with the stack-realign flag set, where necessary.
libdav1d_entrypoints_sources = files(
    'lib.c',
    'thread_task.c'
)

# ASM specific sources
79
libdav1d_nasm_objs = []
80
if is_asm_enabled
81 82
    if (host_machine.cpu_family() == 'aarch64' or
        host_machine.cpu_family().startswith('arm'))
83

84 85 86 87
        libdav1d_sources += files(
            'arm/cpu.c',
        )
        libdav1d_tmpl_sources += files(
88
            'arm/cdef_init_tmpl.c',
89
            'arm/looprestoration_init_tmpl.c',
90
            'arm/mc_init_tmpl.c',
91 92
        )
        if host_machine.cpu_family() == 'aarch64'
93
            libdav1d_sources += files(
94
                'arm/64/cdef.S',
95
                'arm/64/looprestoration.S',
96
                'arm/64/mc.S',
97 98
            )
        elif host_machine.cpu_family().startswith('arm')
99
            libdav1d_sources += files(
100
                'arm/32/looprestoration.S',
101
                'arm/32/mc.S',
102 103 104
            )
        endif
    elif host_machine.cpu_family().startswith('x86')
105

106 107 108
        libdav1d_sources += files(
            'x86/cpu.c',
        )
109

110
        libdav1d_tmpl_sources += files(
111
            'x86/cdef_init_tmpl.c',
112 113 114 115 116
            'x86/ipred_init_tmpl.c',
            'x86/itx_init_tmpl.c',
            'x86/loopfilter_init_tmpl.c',
            'x86/looprestoration_init_tmpl.c',
            'x86/mc_init_tmpl.c',
117
        )
118

119 120
        # NASM source files
        libdav1d_sources_asm = files(
121
            'x86/cdef.asm',
122
            'x86/cdef_ssse3.asm',
123
            'x86/cpuid.asm',
124
            'x86/ipred.asm',
125
            'x86/itx.asm',
126
            'x86/loopfilter.asm',
127
            'x86/looprestoration.asm',
128
            'x86/looprestoration_ssse3.asm',
129
            'x86/mc.asm',
130
            'x86/mc_ssse3.asm',
131
            'x86/itx_ssse3.asm',
132
            'x86/ipred_ssse3.asm',
133 134 135 136 137
        )

        # Compile the ASM sources with NASM
        libdav1d_nasm_objs = nasm_gen.process(libdav1d_sources_asm)
    endif
138 139 140 141 142 143 144 145
endif



#
# Windows .rc file
#

146
if host_machine.system() == 'windows' and get_option('default_library') != 'static'
147
    rc_version_array = meson.project_version().split('.')
148 149
    winmod = import('windows')
    rc_data = configuration_data()
150 151 152
    rc_data.set('VERSION_MAJOR', rc_version_array[0])
    rc_data.set('VERSION_MINOR', rc_version_array[1])
    rc_data.set('VERSION_REVISION', rc_version_array[2])
153
    rc_data.set('VERSION_EXTRA', '0')
154
    rc_data.set('COPYRIGHT_YEARS', '2019')
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176

    rc_file = configure_file(
        input : 'dav1d.rc.in',
        output : 'dav1d.rc',
        configuration : rc_data
    )

    libdav1d_rc_obj = winmod.compile_resources(rc_file)
else
    libdav1d_rc_obj = []
endif




#
# Library definitions
#

# Helper library for dav1d entrypoints
libdav1d_entrypoints_objs = static_library('dav1d_entrypoint',
    libdav1d_entrypoints_sources,
177
    rev_target, config_h_target,
178 179

    include_directories : dav1d_inc_dirs,
180
    dependencies: [stdatomic_dependency],
181
    c_args : [stackalign_flag, stackrealign_flag],
182 183 184 185 186 187 188 189 190 191 192
    install : false,
    build_by_default : false,
).extract_all_objects()

# Helper library for each bitdepth
libdav1d_bitdepth_objs = []
foreach bitdepth : dav1d_bitdepths
    libdav1d_bitdepth_objs += static_library(
        'dav1d_bitdepth_@0@'.format(bitdepth),
        libdav1d_tmpl_sources, config_h_target,
        include_directories: dav1d_inc_dirs,
193
        dependencies : [stdatomic_dependency],
194 195 196 197 198 199
        c_args : ['-DBITDEPTH=@0@'.format(bitdepth)] + stackalign_flag,
        install : false,
        build_by_default : false,
    ).extract_all_objects()
endforeach

200 201 202 203 204 205 206 207
# The final dav1d library
if host_machine.system() == 'windows'
    dav1d_soversion = ''
else
    dav1d_soversion = dav1d_version_major
endif

libdav1d = library('dav1d',
208 209 210 211 212 213 214 215 216 217
    libdav1d_sources,
    libdav1d_nasm_objs,
    libdav1d_rc_obj,

    objects : [
        libdav1d_bitdepth_objs,
        libdav1d_entrypoints_objs
        ],

    include_directories : dav1d_inc_dirs,
218 219 220 221 222
    dependencies : [
        stdatomic_dependency,
        thread_dependency,
        thread_compat_dep,
        ],
223
    c_args : [stackalign_flag],
Janne Grunau's avatar
Janne Grunau committed
224
    version : dav1d_soname_version,
225
    soversion : dav1d_soversion,
226 227
    install : true,
)
228 229 230 231 232 233 234 235 236 237 238

#
# Generate pkg-config .pc file
#
pkg_mod = import('pkgconfig')
pkg_mod.generate(libraries: libdav1d,
    version: meson.project_version(),
    name: 'libdav1d',
    filebase: 'dav1d',
    description: 'AV1 decoding library'
)