blob: 1fc764dceaa3378c5772c608828c4f201864a288 [file] [log] [blame] [view]
Tom Finegan9e57db22017-06-07 07:22:37 -07001# AV1 Codec Library
2
3## Building the library and applications
4
5### Prerequisites
6
7 1. [CMake](https://cmake.org) version 3.5 or higher.
8 2. [Git](https://git-scm.com/).
9 3. [Perl](https://www.perl.org/).
10 4. For x86 targets, [yasm](http://yasm.tortall.net/), which is preferred, or a
11 recent version of [nasm](http://www.nasm.us/).
12 5. Building the documentation requires [doxygen](http://doxygen.org).
13
14### Basic build
15
16CMake replaces the configure step typical of many projects. Running CMake will
17produce configuration and build files for the currently selected CMake
18generator. For most systems the default generator is Unix Makefiles. The basic
19form of a makefile build is the following:
20
21 $ cmake path/to/aom
22 $ make
23
24The above will generate a makefile build that produces the AV1 library and
25applications for the current host system after the make step completes
26successfully. The compiler chosen varies by host platform, but a general rule
27applies: On systems where cc and c++ are present in $PATH at the time CMake is
28run the generated build will use cc and c++ by default.
29
30### Configuration options
31
32The AV1 codec library has a great many configuration options. These come in two
33varieties:
34
35 1. Build system configuration options. These have the form `ENABLE_FEATURE`.
36 2. AV1 codec configuration options. These have the form `CONFIG_FEATURE`.
37
38Both types of options are set at the time CMake is run. The following example
39enables ccache and disables high bit depth:
40
41 $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_HIGHBITDEPTH=0
42 $ make
43
44The available configuration options are too numerous to list here. Build system
45configuration options can be found at the top of the CMakeLists.txt file found
46in the root of the AV1 repository, and AV1 codec configuration options can
47currently be found in the file `build/cmake/aom_config_defaults.cmake`.
48
49### Cross compiling
50
51For the purposes of building the AV1 codec and applications and relative to the
52scope of this guide, all builds for architectures differing from the native host
53architecture will be considered cross compiles. The AV1 CMake build handles
54cross compiling via the use of toolchain files included in the AV1 repository.
55The toolchain files available at the time of this writing are:
56
57 - arm64-ios.cmake
58 - arm64-linux-gcc.cmake
59 - armv7-ios.cmake
60 - armv7-linux-gcc.cmake
61 - armv7s-ios.cmake
62 - mips32-linux-gcc.cmake
63 - mips64-linux-gcc.cmake
64 - x86-ios-simulator.cmake
65 - x86-linux.cmake
66 - x86-macos.cmake
67 - x86\_64-ios-simulator.cmake
68
69The following example demonstrates use of the x86-macos.cmake toolchain file on
70a x86\_64 MacOS host:
71
72 $ cmake path/to/aom \
73 -DCMAKE_TOOLCHAIN_FILE=path/to/aom/build/cmake/toolchains/x86-macos.cmake
74 $ make
75
76To build for an unlisted target creation of a new toolchain file is the best
77solution. The existing toolchain files can be used a starting point for a new
78toolchain file since each one exposes the basic requirements for toolchain files
79as used in the AV1 codec build.
80
81As a temporary work around an unoptimized AV1 configuration that builds only C
82and C++ sources can be produced using the following commands:
83
84 $ cmake path/to/aom -DAOM_TARGET_CPU=generic
85 $ make
86
87In addition to the above it's important to note that the toolchain files
88suffixed with gcc behave differently than the others. These toolchain files
89attempt to obey the $CROSS environment variable.
90
91### Microsoft Visual Studio builds
92
93Building the AV1 codec library in Microsoft Visual Studio is supported. The
94following example demonstrates generating projects and a solution for the
95Microsoft IDE:
96
97 # This does not require a bash shell; command.exe is fine.
98 $ cmake path/to/aom -G "Visual Studio 15 2017"
99
100### Xcode builds
101
102Building the AV1 codec library in Xcode is supported. The following example
103demonstrates generating an Xcode project:
104
105 $ cmake path/to/aom -G Xcode
106
107
108## Testing the AV1 codec
109
110### Testing basics
111
112Currently there are two types of tests in the AV1 codec repository:
113
114 1. Unit tests.
115 2. Example tests.
116
117The unit tests can be run at build time:
118
119 # Before running the make command the LIBAOM_TEST_DATA_PATH environment
120 # variable should be set to avoid downloading the test files to the
121 # cmake build configuration directory.
122 $ cmake path/to/aom
123 # Note: The AV1 CMake build creates many test targets. Running make
124 # with multiple jobs will speed up the test run significantly.
125 $ make runtests
126
127The example tests require a bash shell and can be run in the following manner:
128
129 # See the note above about LIBAOM_TEST_DATA_PATH above.
130 $ cmake path/to/aom
131 $ make
132 # It's best to build the testdata target using many make jobs.
133 # Running it like this will verify and download (if necessary)
134 # one at a time, which takes a while.
135 $ make testdata
136 $ path/to/aom/test/examples.sh --bin-path examples
137
138### IDE hosted tests
139
140By default the generated projects files created by CMake will not include the
141runtests and testdata rules when generating for IDEs like Microsoft Visual
142Studio and Xcode. This is done to avoid intolerably long build cycles in the
143IDEs-- IDE behavior is to build all targets when selecting the build project
144options in MSVS and Xcode. To enable the test rules in IDEs the
145`ENABLE_IDE_TEST_HOSTING` variable must be enabled at CMake generation time:
146
147 # This example uses Xcode. To get a list of the generators
148 # available, run cmake with the -G argument missing its
149 # value.
150 $ cmake path/to/aom -DENABLE_IDE_TEST_HOSTING=1 -G Xcode
151
152### Downloading the test data
153
154The fastest and easiest way to obtain the test data is to use CMake to generate
155a build using the Unix Makefiles generator, and then to build only the testdata
156rule:
157
158 $ cmake path/to/aom -G "Unix Makefiles"
159 # 28 is used because there are 28 test files as of this writing.
160 $ make -j28 testdata
161
162The above make command will only download and verify the test data.
163
164
165## Coding style
166
167The coding style used by this project is enforced with clang-format using the
168configuration contained in the .clang-format file in the root of the repository.
169
170Before pushing changes for review you can format your code with:
171
172 # Apply clang-format to modified .c, .h and .cc files
173 $ clang-format -i --style=file \
174 $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc')
175
176Check the .clang-format file for the version used to generate it if there is any
177difference between your local formatting and the review system.
178
179See also: http://clang.llvm.org/docs/ClangFormat.html
180
181## Support
182
183This library is an open source project supported by its community. Please
184please email aomediacodec@jointdevelopment.kavi.com for help.
185
186## Bug reports
187
188Bug reports can be filed in the Alliance for Open Media
189[issue tracker](https://bugs.chromium.org/p/aomedia/issues/list).