Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame^] | 1 | # 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 | |
| 16 | CMake replaces the configure step typical of many projects. Running CMake will |
| 17 | produce configuration and build files for the currently selected CMake |
| 18 | generator. For most systems the default generator is Unix Makefiles. The basic |
| 19 | form of a makefile build is the following: |
| 20 | |
| 21 | $ cmake path/to/aom |
| 22 | $ make |
| 23 | |
| 24 | The above will generate a makefile build that produces the AV1 library and |
| 25 | applications for the current host system after the make step completes |
| 26 | successfully. The compiler chosen varies by host platform, but a general rule |
| 27 | applies: On systems where cc and c++ are present in $PATH at the time CMake is |
| 28 | run the generated build will use cc and c++ by default. |
| 29 | |
| 30 | ### Configuration options |
| 31 | |
| 32 | The AV1 codec library has a great many configuration options. These come in two |
| 33 | varieties: |
| 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 | |
| 38 | Both types of options are set at the time CMake is run. The following example |
| 39 | enables ccache and disables high bit depth: |
| 40 | |
| 41 | $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_HIGHBITDEPTH=0 |
| 42 | $ make |
| 43 | |
| 44 | The available configuration options are too numerous to list here. Build system |
| 45 | configuration options can be found at the top of the CMakeLists.txt file found |
| 46 | in the root of the AV1 repository, and AV1 codec configuration options can |
| 47 | currently be found in the file `build/cmake/aom_config_defaults.cmake`. |
| 48 | |
| 49 | ### Cross compiling |
| 50 | |
| 51 | For the purposes of building the AV1 codec and applications and relative to the |
| 52 | scope of this guide, all builds for architectures differing from the native host |
| 53 | architecture will be considered cross compiles. The AV1 CMake build handles |
| 54 | cross compiling via the use of toolchain files included in the AV1 repository. |
| 55 | The 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 | |
| 69 | The following example demonstrates use of the x86-macos.cmake toolchain file on |
| 70 | a 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 | |
| 76 | To build for an unlisted target creation of a new toolchain file is the best |
| 77 | solution. The existing toolchain files can be used a starting point for a new |
| 78 | toolchain file since each one exposes the basic requirements for toolchain files |
| 79 | as used in the AV1 codec build. |
| 80 | |
| 81 | As a temporary work around an unoptimized AV1 configuration that builds only C |
| 82 | and C++ sources can be produced using the following commands: |
| 83 | |
| 84 | $ cmake path/to/aom -DAOM_TARGET_CPU=generic |
| 85 | $ make |
| 86 | |
| 87 | In addition to the above it's important to note that the toolchain files |
| 88 | suffixed with gcc behave differently than the others. These toolchain files |
| 89 | attempt to obey the $CROSS environment variable. |
| 90 | |
| 91 | ### Microsoft Visual Studio builds |
| 92 | |
| 93 | Building the AV1 codec library in Microsoft Visual Studio is supported. The |
| 94 | following example demonstrates generating projects and a solution for the |
| 95 | Microsoft 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 | |
| 102 | Building the AV1 codec library in Xcode is supported. The following example |
| 103 | demonstrates generating an Xcode project: |
| 104 | |
| 105 | $ cmake path/to/aom -G Xcode |
| 106 | |
| 107 | |
| 108 | ## Testing the AV1 codec |
| 109 | |
| 110 | ### Testing basics |
| 111 | |
| 112 | Currently there are two types of tests in the AV1 codec repository: |
| 113 | |
| 114 | 1. Unit tests. |
| 115 | 2. Example tests. |
| 116 | |
| 117 | The 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 | |
| 127 | The 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 | |
| 140 | By default the generated projects files created by CMake will not include the |
| 141 | runtests and testdata rules when generating for IDEs like Microsoft Visual |
| 142 | Studio and Xcode. This is done to avoid intolerably long build cycles in the |
| 143 | IDEs-- IDE behavior is to build all targets when selecting the build project |
| 144 | options 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 | |
| 154 | The fastest and easiest way to obtain the test data is to use CMake to generate |
| 155 | a build using the Unix Makefiles generator, and then to build only the testdata |
| 156 | rule: |
| 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 | |
| 162 | The above make command will only download and verify the test data. |
| 163 | |
| 164 | |
| 165 | ## Coding style |
| 166 | |
| 167 | The coding style used by this project is enforced with clang-format using the |
| 168 | configuration contained in the .clang-format file in the root of the repository. |
| 169 | |
| 170 | Before 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 | |
| 176 | Check the .clang-format file for the version used to generate it if there is any |
| 177 | difference between your local formatting and the review system. |
| 178 | |
| 179 | See also: http://clang.llvm.org/docs/ClangFormat.html |
| 180 | |
| 181 | ## Support |
| 182 | |
| 183 | This library is an open source project supported by its community. Please |
| 184 | please email aomediacodec@jointdevelopment.kavi.com for help. |
| 185 | |
| 186 | ## Bug reports |
| 187 | |
| 188 | Bug reports can be filed in the Alliance for Open Media |
| 189 | [issue tracker](https://bugs.chromium.org/p/aomedia/issues/list). |