Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 1 | # AV1 Codec Library |
| 2 | |
Tom Finegan | bca03fc | 2017-12-08 07:47:06 -0800 | [diff] [blame] | 3 | ## Contents |
| 4 | 1. [Building the lib and applications](#building-the-library-and-applications) |
| 5 | - [Prerequisites](#prerequisites) |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 6 | - [Get the code](#get-the-code) |
Tom Finegan | bca03fc | 2017-12-08 07:47:06 -0800 | [diff] [blame] | 7 | - [Basics](#basic-build) |
| 8 | - [Configuration options](#configuration-options) |
| 9 | - [Dylib builds](#dylib-builds) |
| 10 | - [Debugging](#debugging) |
| 11 | - [Cross compiling](#cross-compiling) |
| 12 | - [Sanitizer support](#sanitizers) |
| 13 | - [MSVC builds](#microsoft-visual-studio-builds) |
| 14 | - [Xcode builds](#xcode-builds) |
| 15 | - [Emscripten builds](#emscripten-builds) |
Tom Finegan | aa71f07 | 2018-01-31 06:54:01 -0800 | [diff] [blame] | 16 | - [Extra Build Flags](#extra-build-flags) |
Tom Finegan | bca03fc | 2017-12-08 07:47:06 -0800 | [diff] [blame] | 17 | 2. [Testing the library](#testing-the-av1-codec) |
| 18 | - [Basics](#testing-basics) |
| 19 | - [Unit tests](#1_unit-tests) |
| 20 | - [Example tests](#2_example-tests) |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 21 | - [Encoder tests](#3_encoder-tests) |
Tom Finegan | bca03fc | 2017-12-08 07:47:06 -0800 | [diff] [blame] | 22 | - [IDE hosted tests](#ide-hosted-tests) |
| 23 | - [Downloading test data](#downloading-the-test-data) |
Wan-Teh Chang | cbf8a79 | 2018-05-11 11:22:06 -0700 | [diff] [blame] | 24 | - [Adding a new test data file](#adding-a-new-test-data-file) |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 25 | - [Additional test data](#additional-test-data) |
Tom Finegan | bca03fc | 2017-12-08 07:47:06 -0800 | [diff] [blame] | 26 | - [Sharded testing](#sharded-testing) |
| 27 | - [Running tests directly](#1_running-test_libaom-directly) |
| 28 | - [Running tests via CMake](#2_running-the-tests-via-the-cmake-build) |
| 29 | 3. [Coding style](#coding-style) |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 30 | 4. [Submitting patches](#submitting-patches) |
| 31 | - [Login cookie](#login-cookie) |
| 32 | - [Contributor agreement](#contributor-agreement) |
| 33 | - [Testing your code](#testing-your-code) |
| 34 | - [Commit message hook](#commit-message-hook) |
| 35 | - [Upload your change](#upload-your-change) |
| 36 | - [Incorporating Reviewer Comments](#incorporating-reviewer-comments) |
| 37 | - [Submitting your change](#submitting-your-change) |
| 38 | - [Viewing change status](#viewing-the-status-of-uploaded-changes) |
| 39 | 5. [Support](#support) |
| 40 | 6. [Bug reports](#bug-reports) |
Tom Finegan | bca03fc | 2017-12-08 07:47:06 -0800 | [diff] [blame] | 41 | |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 42 | ## Building the library and applications |
| 43 | |
| 44 | ### Prerequisites |
| 45 | |
| 46 | 1. [CMake](https://cmake.org) version 3.5 or higher. |
| 47 | 2. [Git](https://git-scm.com/). |
| 48 | 3. [Perl](https://www.perl.org/). |
| 49 | 4. For x86 targets, [yasm](http://yasm.tortall.net/), which is preferred, or a |
| 50 | recent version of [nasm](http://www.nasm.us/). |
| 51 | 5. Building the documentation requires [doxygen](http://doxygen.org). |
Tom Finegan | ff766cd | 2017-06-20 14:18:03 -0700 | [diff] [blame] | 52 | 6. Building the unit tests requires [Python](https://www.python.org/). |
Tom Finegan | 84d3599 | 2017-07-07 10:38:01 -0700 | [diff] [blame] | 53 | 7. Emscripten builds require the portable |
| 54 | [EMSDK](https://kripken.github.io/emscripten-site/index.html). |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 55 | |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 56 | ### Get the code |
| 57 | |
| 58 | The AV1 library source code is stored in the Alliance for Open Media Git |
| 59 | repository: |
| 60 | |
| 61 | ~~~ |
| 62 | $ git clone https://aomedia.googlesource.com/aom |
| 63 | # By default, the above command stores the source in the aom directory: |
| 64 | $ cd aom |
| 65 | ~~~ |
| 66 | |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 67 | ### Basic build |
| 68 | |
| 69 | CMake replaces the configure step typical of many projects. Running CMake will |
| 70 | produce configuration and build files for the currently selected CMake |
| 71 | generator. For most systems the default generator is Unix Makefiles. The basic |
| 72 | form of a makefile build is the following: |
| 73 | |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 74 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 75 | $ cmake path/to/aom |
| 76 | $ make |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 77 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 78 | |
| 79 | The above will generate a makefile build that produces the AV1 library and |
| 80 | applications for the current host system after the make step completes |
| 81 | successfully. The compiler chosen varies by host platform, but a general rule |
| 82 | applies: On systems where cc and c++ are present in $PATH at the time CMake is |
| 83 | run the generated build will use cc and c++ by default. |
| 84 | |
| 85 | ### Configuration options |
| 86 | |
| 87 | The AV1 codec library has a great many configuration options. These come in two |
| 88 | varieties: |
| 89 | |
| 90 | 1. Build system configuration options. These have the form `ENABLE_FEATURE`. |
| 91 | 2. AV1 codec configuration options. These have the form `CONFIG_FEATURE`. |
| 92 | |
| 93 | Both types of options are set at the time CMake is run. The following example |
Sebastien Alaiwan | 7c524d4 | 2018-01-02 10:10:55 +0100 | [diff] [blame] | 94 | enables ccache and disables the AV1 encoder: |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 95 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 96 | ~~~ |
Sebastien Alaiwan | 7c524d4 | 2018-01-02 10:10:55 +0100 | [diff] [blame] | 97 | $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_AV1_ENCODER=0 |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 98 | $ make |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 99 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 100 | |
| 101 | The available configuration options are too numerous to list here. Build system |
| 102 | configuration options can be found at the top of the CMakeLists.txt file found |
| 103 | in the root of the AV1 repository, and AV1 codec configuration options can |
| 104 | currently be found in the file `build/cmake/aom_config_defaults.cmake`. |
| 105 | |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 106 | ### Dylib builds |
| 107 | |
| 108 | A dylib (shared object) build of the AV1 codec library can be enabled via the |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 109 | CMake built in variable `BUILD_SHARED_LIBS`: |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 110 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 111 | ~~~ |
| 112 | $ cmake path/to/aom -DBUILD_SHARED_LIBS=1 |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 113 | $ make |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 114 | ~~~ |
Tom Finegan | 84f2d79 | 2017-06-15 23:06:44 -0700 | [diff] [blame] | 115 | |
| 116 | This is currently only supported on non-Windows targets. |
| 117 | |
Tom Finegan | fe809bd | 2017-09-27 11:54:24 -0700 | [diff] [blame] | 118 | ### Debugging |
| 119 | |
| 120 | Depending on the generator used there are multiple ways of going about |
| 121 | debugging AV1 components. For single configuration generators like the Unix |
| 122 | Makefiles generator, setting `CMAKE_BUILD_TYPE` to Debug is sufficient: |
| 123 | |
| 124 | ~~~ |
| 125 | $ cmake path/to/aom -DCMAKE_BUILD_TYPE=Debug |
| 126 | ~~~ |
| 127 | |
| 128 | For Xcode, mainly because configuration controls for Xcode builds are buried two |
Tom Finegan | d77323d | 2017-09-29 09:41:43 -0700 | [diff] [blame] | 129 | configuration windows deep and must be set for each subproject within the Xcode |
| 130 | IDE individually, `CMAKE_CONFIGURATION_TYPES` should be set to Debug: |
Tom Finegan | fe809bd | 2017-09-27 11:54:24 -0700 | [diff] [blame] | 131 | |
| 132 | ~~~ |
| 133 | $ cmake path/to/aom -G Xcode -DCMAKE_CONFIGURATION_TYPES=Debug |
| 134 | ~~~ |
| 135 | |
| 136 | For Visual Studio the in-IDE configuration controls should be used. Simply set |
| 137 | the IDE project configuration to Debug to allow for stepping through the code. |
| 138 | |
| 139 | In addition to the above it can sometimes be useful to debug only C and C++ |
Tom Finegan | d77323d | 2017-09-29 09:41:43 -0700 | [diff] [blame] | 140 | code. To disable all assembly code and intrinsics set `AOM_TARGET_CPU` to |
Tom Finegan | fe809bd | 2017-09-27 11:54:24 -0700 | [diff] [blame] | 141 | generic at generation time: |
| 142 | |
| 143 | ~~~ |
| 144 | $ cmake path/to/aom -DAOM_TARGET_CPU=generic |
| 145 | ~~~ |
| 146 | |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 147 | ### Cross compiling |
| 148 | |
| 149 | For the purposes of building the AV1 codec and applications and relative to the |
| 150 | scope of this guide, all builds for architectures differing from the native host |
| 151 | architecture will be considered cross compiles. The AV1 CMake build handles |
| 152 | cross compiling via the use of toolchain files included in the AV1 repository. |
| 153 | The toolchain files available at the time of this writing are: |
| 154 | |
| 155 | - arm64-ios.cmake |
| 156 | - arm64-linux-gcc.cmake |
Martin Storsjo | 6a124ba | 2018-04-13 00:23:38 +0300 | [diff] [blame] | 157 | - arm64-mingw-gcc.cmake |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 158 | - armv7-ios.cmake |
| 159 | - armv7-linux-gcc.cmake |
Martin Storsjo | 6a124ba | 2018-04-13 00:23:38 +0300 | [diff] [blame] | 160 | - armv7-mingw-gcc.cmake |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 161 | - armv7s-ios.cmake |
| 162 | - mips32-linux-gcc.cmake |
| 163 | - mips64-linux-gcc.cmake |
| 164 | - x86-ios-simulator.cmake |
| 165 | - x86-linux.cmake |
| 166 | - x86-macos.cmake |
Tom Finegan | d77323d | 2017-09-29 09:41:43 -0700 | [diff] [blame] | 167 | - x86-mingw-gcc.cmake |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 168 | - x86\_64-ios-simulator.cmake |
Tom Finegan | d77323d | 2017-09-29 09:41:43 -0700 | [diff] [blame] | 169 | - x86\_64-mingw-gcc.cmake |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 170 | |
| 171 | The following example demonstrates use of the x86-macos.cmake toolchain file on |
| 172 | a x86\_64 MacOS host: |
| 173 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 174 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 175 | $ cmake path/to/aom \ |
| 176 | -DCMAKE_TOOLCHAIN_FILE=path/to/aom/build/cmake/toolchains/x86-macos.cmake |
| 177 | $ make |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 178 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 179 | |
| 180 | To build for an unlisted target creation of a new toolchain file is the best |
| 181 | solution. The existing toolchain files can be used a starting point for a new |
| 182 | toolchain file since each one exposes the basic requirements for toolchain files |
| 183 | as used in the AV1 codec build. |
| 184 | |
| 185 | As a temporary work around an unoptimized AV1 configuration that builds only C |
| 186 | and C++ sources can be produced using the following commands: |
| 187 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 188 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 189 | $ cmake path/to/aom -DAOM_TARGET_CPU=generic |
| 190 | $ make |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 191 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 192 | |
| 193 | In addition to the above it's important to note that the toolchain files |
| 194 | suffixed with gcc behave differently than the others. These toolchain files |
| 195 | attempt to obey the $CROSS environment variable. |
| 196 | |
Tom Finegan | 8a30baf | 2017-09-13 11:35:34 -0700 | [diff] [blame] | 197 | ### Sanitizers |
| 198 | |
| 199 | Sanitizer integration is built-in to the CMake build system. To enable a |
| 200 | sanitizer, add `-DSANITIZE=<type>` to the CMake command line. For example, to |
| 201 | enable address sanitizer: |
| 202 | |
| 203 | ~~~ |
| 204 | $ cmake path/to/aom -DSANITIZE=address |
| 205 | $ make |
| 206 | ~~~ |
| 207 | |
| 208 | Sanitizers available vary by platform, target, and compiler. Consult your |
| 209 | compiler documentation to determine which, if any, are available. |
| 210 | |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 211 | ### Microsoft Visual Studio builds |
| 212 | |
| 213 | Building the AV1 codec library in Microsoft Visual Studio is supported. The |
| 214 | following example demonstrates generating projects and a solution for the |
| 215 | Microsoft IDE: |
| 216 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 217 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 218 | # This does not require a bash shell; command.exe is fine. |
| 219 | $ cmake path/to/aom -G "Visual Studio 15 2017" |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 220 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 221 | |
| 222 | ### Xcode builds |
| 223 | |
| 224 | Building the AV1 codec library in Xcode is supported. The following example |
| 225 | demonstrates generating an Xcode project: |
| 226 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 227 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 228 | $ cmake path/to/aom -G Xcode |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 229 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 230 | |
Tom Finegan | 84d3599 | 2017-07-07 10:38:01 -0700 | [diff] [blame] | 231 | ### Emscripten builds |
| 232 | |
| 233 | Building the AV1 codec library with Emscripten is supported. Typically this is |
| 234 | used to hook into the AOMAnalyzer GUI application. These instructions focus on |
| 235 | using the inspector with AOMAnalyzer, but all tools can be built with |
| 236 | Emscripten. |
| 237 | |
| 238 | It is assumed here that you have already downloaded and installed the EMSDK, |
| 239 | installed and activated at least one toolchain, and setup your environment |
| 240 | appropriately using the emsdk\_env script. |
| 241 | |
| 242 | 1. Download [AOMAnalyzer](https://people.xiph.org/~mbebenita/analyzer/). |
| 243 | |
| 244 | 2. Configure the build: |
| 245 | |
| 246 | ~~~ |
| 247 | $ cmake path/to/aom \ |
| 248 | -DENABLE_CCACHE=1 \ |
| 249 | -DAOM_TARGET_CPU=generic \ |
| 250 | -DENABLE_DOCS=0 \ |
Tom Finegan | d9647f2 | 2018-06-19 13:27:57 -0700 | [diff] [blame^] | 251 | -DENABLE_TESTS=0 \ |
Tom Finegan | 84d3599 | 2017-07-07 10:38:01 -0700 | [diff] [blame] | 252 | -DCONFIG_ACCOUNTING=1 \ |
| 253 | -DCONFIG_INSPECTION=1 \ |
| 254 | -DCONFIG_MULTITHREAD=0 \ |
| 255 | -DCONFIG_RUNTIME_CPU_DETECT=0 \ |
Tom Finegan | 84d3599 | 2017-07-07 10:38:01 -0700 | [diff] [blame] | 256 | -DCONFIG_WEBM_IO=0 \ |
| 257 | -DCMAKE_TOOLCHAIN_FILE=path/to/emsdk-portable/.../Emscripten.cmake |
| 258 | ~~~ |
| 259 | |
| 260 | 3. Build it: run make if that's your generator of choice: |
| 261 | |
| 262 | ~~~ |
| 263 | $ make inspect |
| 264 | ~~~ |
| 265 | |
| 266 | 4. Run the analyzer: |
| 267 | |
| 268 | ~~~ |
| 269 | # inspect.js is in the examples sub directory of the directory in which you |
| 270 | # executed cmake. |
| 271 | $ path/to/AOMAnalyzer path/to/examples/inspect.js path/to/av1/input/file |
| 272 | ~~~ |
| 273 | |
Tom Finegan | aa71f07 | 2018-01-31 06:54:01 -0800 | [diff] [blame] | 274 | ### Extra build flags |
| 275 | |
| 276 | Three variables allow for passing of additional flags to the build system. |
| 277 | |
| 278 | - AOM\_EXTRA\_C\_FLAGS |
| 279 | - AOM\_EXTRA\_CXX\_FLAGS |
| 280 | - AOM\_EXTRA\_EXE\_LINKER\_FLAGS |
| 281 | |
| 282 | The build system attempts to ensure the flags passed through the above variables |
| 283 | are passed to tools last in order to allow for override of default behavior. |
| 284 | These flags can be used, for example, to enable asserts in a release build: |
| 285 | |
| 286 | ~~~ |
| 287 | $ cmake path/to/aom \ |
| 288 | -DCMAKE_BUILD_TYPE=Release \ |
| 289 | -DAOM_EXTRA_C_FLAGS=-UNDEBUG \ |
| 290 | -DAOM_EXTRA_CXX_FLAGS=-UNDEBUG |
| 291 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 292 | |
| 293 | ## Testing the AV1 codec |
| 294 | |
| 295 | ### Testing basics |
| 296 | |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 297 | There are several methods of testing the AV1 codec. All of these methods require |
| 298 | the presence of the AV1 source code and a working build of the AV1 library and |
| 299 | applications. |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 300 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 301 | #### 1. Unit tests: |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 302 | |
| 303 | The unit tests can be run at build time: |
| 304 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 305 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 306 | # Before running the make command the LIBAOM_TEST_DATA_PATH environment |
| 307 | # variable should be set to avoid downloading the test files to the |
| 308 | # cmake build configuration directory. |
| 309 | $ cmake path/to/aom |
| 310 | # Note: The AV1 CMake build creates many test targets. Running make |
| 311 | # with multiple jobs will speed up the test run significantly. |
| 312 | $ make runtests |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 313 | ~~~ |
| 314 | |
| 315 | #### 2. Example tests: |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 316 | |
| 317 | The example tests require a bash shell and can be run in the following manner: |
| 318 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 319 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 320 | # See the note above about LIBAOM_TEST_DATA_PATH above. |
| 321 | $ cmake path/to/aom |
| 322 | $ make |
| 323 | # It's best to build the testdata target using many make jobs. |
| 324 | # Running it like this will verify and download (if necessary) |
| 325 | # one at a time, which takes a while. |
| 326 | $ make testdata |
| 327 | $ path/to/aom/test/examples.sh --bin-path examples |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 328 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 329 | |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 330 | #### 3. Encoder tests: |
| 331 | |
| 332 | When making a change to the encoder run encoder tests to confirm that your |
| 333 | change has a positive or negligible impact on encode quality. When running these |
| 334 | tests the build configuration should be changed to enable internal encoder |
| 335 | statistics: |
| 336 | |
| 337 | ~~~ |
| 338 | $ cmake path/to/aom -DCONFIG_INTERNAL_STATS=1 |
| 339 | $ make |
| 340 | ~~~ |
| 341 | |
| 342 | The repository contains scripts intended to make running these tests as simple |
| 343 | as possible. The following example demonstrates creating a set of baseline clips |
| 344 | for comparison to results produced after making your change to libaom: |
| 345 | |
| 346 | ~~~ |
| 347 | # This will encode all Y4M files in the current directory using the |
| 348 | # settings specified to create the encoder baseline statistical data: |
| 349 | $ cd path/to/test/inputs |
| 350 | # This command line assumes that run_encodes.sh, its helper script |
| 351 | # best_encode.sh, and the aomenc you intend to test are all within a |
| 352 | # directory in your PATH. |
| 353 | $ run_encodes.sh 200 500 50 baseline |
| 354 | ~~~ |
| 355 | |
| 356 | After making your change and creating the baseline clips, you'll need to run |
| 357 | encodes that include your change(s) to confirm that things are working as |
| 358 | intended: |
| 359 | |
| 360 | ~~~ |
| 361 | # This will encode all Y4M files in the current directory using the |
| 362 | # settings specified to create the statistical data for your change: |
| 363 | $ cd path/to/test/inputs |
| 364 | # This command line assumes that run_encodes.sh, its helper script |
| 365 | # best_encode.sh, and the aomenc you intend to test are all within a |
| 366 | # directory in your PATH. |
| 367 | $ run_encodes.sh 200 500 50 mytweak |
| 368 | ~~~ |
| 369 | |
| 370 | After creating both data sets you can use `test/visual_metrics.py` to generate a |
| 371 | report that can be viewed in a web browser: |
| 372 | |
| 373 | ~~~ |
| 374 | $ visual_metrics.py metrics_template.html "*stt" baseline mytweak \ |
| 375 | > mytweak.html |
| 376 | ~~~ |
| 377 | |
| 378 | You can view the report by opening mytweak.html in a web browser. |
| 379 | |
| 380 | |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 381 | ### IDE hosted tests |
| 382 | |
| 383 | By default the generated projects files created by CMake will not include the |
| 384 | runtests and testdata rules when generating for IDEs like Microsoft Visual |
| 385 | Studio and Xcode. This is done to avoid intolerably long build cycles in the |
| 386 | IDEs-- IDE behavior is to build all targets when selecting the build project |
| 387 | options in MSVS and Xcode. To enable the test rules in IDEs the |
| 388 | `ENABLE_IDE_TEST_HOSTING` variable must be enabled at CMake generation time: |
| 389 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 390 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 391 | # This example uses Xcode. To get a list of the generators |
| 392 | # available, run cmake with the -G argument missing its |
| 393 | # value. |
| 394 | $ cmake path/to/aom -DENABLE_IDE_TEST_HOSTING=1 -G Xcode |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 395 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 396 | |
| 397 | ### Downloading the test data |
| 398 | |
| 399 | The fastest and easiest way to obtain the test data is to use CMake to generate |
| 400 | a build using the Unix Makefiles generator, and then to build only the testdata |
| 401 | rule: |
| 402 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 403 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 404 | $ cmake path/to/aom -G "Unix Makefiles" |
| 405 | # 28 is used because there are 28 test files as of this writing. |
| 406 | $ make -j28 testdata |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 407 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 408 | |
| 409 | The above make command will only download and verify the test data. |
| 410 | |
Wan-Teh Chang | cbf8a79 | 2018-05-11 11:22:06 -0700 | [diff] [blame] | 411 | ### Adding a new test data file |
| 412 | |
| 413 | First, add the new test data file to the `aom-test-data` bucket of the |
| 414 | `aomedia-testing` project on Google Cloud Platform. You may need to ask someone |
| 415 | with the necessary access permissions to do this for you. |
| 416 | |
| 417 | Once the new test data file has been added to `aom-test-data`, create a CL to |
| 418 | add the name of the new test data file to `test/test_data_util.cmake` and add |
| 419 | the SHA1 checksum of the new test data file to `test/test-data.sha1`. (The SHA1 |
| 420 | checksum of a file can be calculated by running the `sha1sum` command on the |
| 421 | file.) |
| 422 | |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 423 | ### Additional test data |
| 424 | |
| 425 | The test data mentioned above is strictly intended for unit testing. |
| 426 | |
| 427 | Additional input data for testing the encoder can be obtained from: |
| 428 | https://media.xiph.org/video/derf/ |
| 429 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 430 | ### Sharded testing |
| 431 | |
| 432 | The AV1 codec library unit tests are built upon gtest which supports sharding of |
| 433 | test jobs. Sharded test runs can be achieved in a couple of ways. |
| 434 | |
| 435 | #### 1. Running test\_libaom directly: |
| 436 | |
| 437 | ~~~ |
James Zern | 47cd7be | 2018-03-16 18:12:10 -0700 | [diff] [blame] | 438 | # Set the environment variable GTEST_TOTAL_SHARDS to control the number of |
| 439 | # shards. |
| 440 | $ export GTEST_TOTAL_SHARDS=10 |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 441 | # (GTEST shard indexing is 0 based). |
James Zern | 515c869 | 2017-08-30 16:32:28 -0700 | [diff] [blame] | 442 | $ seq 0 $(( $GTEST_TOTAL_SHARDS - 1 )) \ |
| 443 | | xargs -n 1 -P 0 -I{} env GTEST_SHARD_INDEX={} ./test_libaom |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 444 | ~~~ |
| 445 | |
| 446 | To create a test shard for each CPU core available on the current system set |
| 447 | `GTEST_TOTAL_SHARDS` to the number of CPU cores on your system minus one. |
| 448 | |
| 449 | #### 2. Running the tests via the CMake build: |
| 450 | |
| 451 | ~~~ |
| 452 | # For IDE based builds, ENABLE_IDE_TEST_HOSTING must be enabled. See |
| 453 | # the IDE hosted tests section above for more information. If the IDE |
| 454 | # supports building targets concurrently tests will be sharded by default. |
| 455 | |
| 456 | # For make and ninja builds the -j parameter controls the number of shards |
| 457 | # at test run time. This example will run the tests using 10 shards via |
| 458 | # make. |
| 459 | $ make -j10 runtests |
| 460 | ~~~ |
| 461 | |
| 462 | The maximum number of test targets that can run concurrently is determined by |
| 463 | the number of CPUs on the system where the build is configured as detected by |
| 464 | CMake. A system with 24 cores can run 24 test shards using a value of 24 with |
| 465 | the `-j` parameter. When CMake is unable to detect the number of cores 10 shards |
| 466 | is the default maximum value. |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 467 | |
| 468 | ## Coding style |
| 469 | |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 470 | We are using the Google C Coding Style defined by the |
| 471 | [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). |
| 472 | |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 473 | The coding style used by this project is enforced with clang-format using the |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 474 | configuration contained in the |
| 475 | [.clang-format](https://chromium.googlesource.com/webm/aom/+/master/.clang-format) |
| 476 | file in the root of the repository. |
| 477 | |
| 478 | You can download clang-format using your system's package manager, or directly |
| 479 | from [llvm.org](http://llvm.org/releases/download.html). You can also view the |
| 480 | [documentation](https://clang.llvm.org/docs/ClangFormat.html) on llvm.org. |
| 481 | Output from clang-format varies by clang-format version, for best results your |
| 482 | version should match the one used on Jenkins. You can find the clang-format |
| 483 | version by reading the comment in the `.clang-format` file linked above. |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 484 | |
| 485 | Before pushing changes for review you can format your code with: |
| 486 | |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 487 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 488 | # Apply clang-format to modified .c, .h and .cc files |
| 489 | $ clang-format -i --style=file \ |
| 490 | $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc') |
Tom Finegan | 007b2ee | 2017-07-11 14:47:06 -0700 | [diff] [blame] | 491 | ~~~ |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 492 | |
| 493 | Check the .clang-format file for the version used to generate it if there is any |
| 494 | difference between your local formatting and the review system. |
| 495 | |
Tom Finegan | 9007d34 | 2017-12-14 07:47:13 -0800 | [diff] [blame] | 496 | Some Git installations have clang-format integration. Here are some examples: |
| 497 | |
| 498 | ~~~ |
| 499 | # Apply clang-format to all staged changes: |
| 500 | $ git clang-format |
| 501 | |
| 502 | # Clang format all staged and unstaged changes: |
| 503 | $ git clang-format -f |
| 504 | |
| 505 | # Clang format all staged and unstaged changes interactively: |
| 506 | $ git clang-format -f -p |
| 507 | ~~~ |
| 508 | |
| 509 | ## Submitting patches |
| 510 | |
| 511 | We manage the submission of patches using the |
| 512 | [Gerrit](https://www.gerritcodereview.com/) code review tool. This tool |
| 513 | implements a workflow on top of the Git version control system to ensure that |
| 514 | all changes get peer reviewed and tested prior to their distribution. |
| 515 | |
| 516 | ### Login cookie |
| 517 | |
| 518 | Browse to [AOMedia Git index](https://aomedia.googlesource.com/) and login with |
| 519 | your account (Gmail credentials, for example). Next, follow the |
| 520 | `Generate Password` Password link at the top of the page. You’ll be given |
| 521 | instructions for creating a cookie to use with our Git repos. |
| 522 | |
| 523 | ### Contributor agreement |
| 524 | |
| 525 | You will be required to execute a |
| 526 | [contributor agreement](http://aomedia.org/license) to ensure that the AOMedia |
| 527 | Project has the right to distribute your changes. |
| 528 | |
| 529 | ### Testing your code |
| 530 | |
| 531 | The testing basics are covered in the [testing section](#testing-the-av1-codec) |
| 532 | above. |
| 533 | |
| 534 | In addition to the local tests, many more (e.g. asan, tsan, valgrind) will run |
| 535 | through Jenkins instances upon upload to gerrit. |
| 536 | |
| 537 | ### Commit message hook |
| 538 | |
| 539 | Gerrit requires that each submission include a unique Change-Id. You can assign |
| 540 | one manually using git commit --amend, but it’s easier to automate it with the |
| 541 | commit-msg hook provided by Gerrit. |
| 542 | |
| 543 | Copy commit-msg to the `.git/hooks` directory of your local repo. Here's an |
| 544 | example: |
| 545 | |
| 546 | ~~~ |
| 547 | $ curl -Lo aom/.git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg |
| 548 | |
| 549 | # Next, ensure that the downloaded commit-msg script is executable: |
| 550 | $ chmod u+x aom/.git/hooks/commit-msg |
| 551 | ~~~ |
| 552 | |
| 553 | See the Gerrit |
| 554 | [documentation](https://gerrit-review.googlesource.com/Documentation/user-changeid.html) |
| 555 | for more information. |
| 556 | |
| 557 | ### Upload your change |
| 558 | |
| 559 | The command line to upload your patch looks like this: |
| 560 | |
| 561 | ~~~ |
| 562 | $ git push https://aomedia-review.googlesource.com/aom HEAD:refs/for/master |
| 563 | ~~~ |
| 564 | |
| 565 | ### Incorporating reviewer comments |
| 566 | |
| 567 | If you previously uploaded a change to Gerrit and the Approver has asked for |
| 568 | changes, follow these steps: |
| 569 | |
| 570 | 1. Edit the files to make the changes the reviewer has requested. |
| 571 | 2. Recommit your edits using the --amend flag, for example: |
| 572 | |
| 573 | ~~~ |
| 574 | $ git commit -a --amend |
| 575 | ~~~ |
| 576 | |
| 577 | 3. Use the same git push command as above to upload to Gerrit again for another |
| 578 | review cycle. |
| 579 | |
| 580 | In general, you should not rebase your changes when doing updates in response to |
| 581 | review. Doing so can make it harder to follow the evolution of your change in |
| 582 | the diff view. |
| 583 | |
| 584 | ### Submitting your change |
| 585 | |
| 586 | Once your change has been Approved and Verified, you can “submit” it through the |
| 587 | Gerrit UI. This will usually automatically rebase your change onto the branch |
| 588 | specified. |
| 589 | |
| 590 | Sometimes this can’t be done automatically. If you run into this problem, you |
| 591 | must rebase your changes manually: |
| 592 | |
| 593 | ~~~ |
| 594 | $ git fetch |
| 595 | $ git rebase origin/branchname |
| 596 | ~~~ |
| 597 | |
| 598 | If there are any conflicts, resolve them as you normally would with Git. When |
| 599 | you’re done, reupload your change. |
| 600 | |
| 601 | ### Viewing the status of uploaded changes |
| 602 | |
| 603 | To check the status of a change that you uploaded, open |
| 604 | [Gerrit](https://aomedia-review.googlesource.com/), sign in, and click My > |
| 605 | Changes. |
Tom Finegan | 9e57db2 | 2017-06-07 07:22:37 -0700 | [diff] [blame] | 606 | |
| 607 | ## Support |
| 608 | |
| 609 | This library is an open source project supported by its community. Please |
| 610 | please email aomediacodec@jointdevelopment.kavi.com for help. |
| 611 | |
| 612 | ## Bug reports |
| 613 | |
| 614 | Bug reports can be filed in the Alliance for Open Media |
| 615 | [issue tracker](https://bugs.chromium.org/p/aomedia/issues/list). |