1*77c1e3ccSAndroid Build Coastguard WorkerREADME.md {#LREADME} 2*77c1e3ccSAndroid Build Coastguard Worker========= 3*77c1e3ccSAndroid Build Coastguard Worker# AV1 Codec Library 4*77c1e3ccSAndroid Build Coastguard Worker 5*77c1e3ccSAndroid Build Coastguard Worker## Contents 6*77c1e3ccSAndroid Build Coastguard Worker1. [Building the lib and applications](#building-the-library-and-applications) 7*77c1e3ccSAndroid Build Coastguard Worker - [Prerequisites](#prerequisites) 8*77c1e3ccSAndroid Build Coastguard Worker - [Get the code](#get-the-code) 9*77c1e3ccSAndroid Build Coastguard Worker - [Basics](#basic-build) 10*77c1e3ccSAndroid Build Coastguard Worker - [Configuration options](#configuration-options) 11*77c1e3ccSAndroid Build Coastguard Worker - [Dylib builds](#dylib-builds) 12*77c1e3ccSAndroid Build Coastguard Worker - [Debugging](#debugging) 13*77c1e3ccSAndroid Build Coastguard Worker - [Cross compiling](#cross-compiling) 14*77c1e3ccSAndroid Build Coastguard Worker - [Sanitizer support](#sanitizers) 15*77c1e3ccSAndroid Build Coastguard Worker - [MSVC builds](#microsoft-visual-studio-builds) 16*77c1e3ccSAndroid Build Coastguard Worker - [Xcode builds](#xcode-builds) 17*77c1e3ccSAndroid Build Coastguard Worker - [Emscripten builds](#emscripten-builds) 18*77c1e3ccSAndroid Build Coastguard Worker - [Extra Build Flags](#extra-build-flags) 19*77c1e3ccSAndroid Build Coastguard Worker - [Build with VMAF support](#build-with-vmaf) 20*77c1e3ccSAndroid Build Coastguard Worker2. [Testing the library](#testing-the-av1-codec) 21*77c1e3ccSAndroid Build Coastguard Worker - [Basics](#testing-basics) 22*77c1e3ccSAndroid Build Coastguard Worker - [Unit tests](#unit-tests) 23*77c1e3ccSAndroid Build Coastguard Worker - [Example tests](#example-tests) 24*77c1e3ccSAndroid Build Coastguard Worker - [Encoder tests](#encoder-tests) 25*77c1e3ccSAndroid Build Coastguard Worker - [IDE hosted tests](#ide-hosted-tests) 26*77c1e3ccSAndroid Build Coastguard Worker - [Downloading test data](#downloading-the-test-data) 27*77c1e3ccSAndroid Build Coastguard Worker - [Adding a new test data file](#adding-a-new-test-data-file) 28*77c1e3ccSAndroid Build Coastguard Worker - [Additional test data](#additional-test-data) 29*77c1e3ccSAndroid Build Coastguard Worker - [Sharded testing](#sharded-testing) 30*77c1e3ccSAndroid Build Coastguard Worker - [Running tests directly](#running-test_libaom-directly) 31*77c1e3ccSAndroid Build Coastguard Worker - [Running tests via CMake](#running-the-tests-via-the-cmake-build) 32*77c1e3ccSAndroid Build Coastguard Worker3. [Coding style](#coding-style) 33*77c1e3ccSAndroid Build Coastguard Worker4. [License header](#license-header) 34*77c1e3ccSAndroid Build Coastguard Worker5. [Submitting patches](#submitting-patches) 35*77c1e3ccSAndroid Build Coastguard Worker - [Login cookie](#login-cookie) 36*77c1e3ccSAndroid Build Coastguard Worker - [Contributor agreement](#contributor-agreement) 37*77c1e3ccSAndroid Build Coastguard Worker - [Testing your code](#testing-your-code) 38*77c1e3ccSAndroid Build Coastguard Worker - [Commit message hook](#commit-message-hook) 39*77c1e3ccSAndroid Build Coastguard Worker - [Upload your change](#upload-your-change) 40*77c1e3ccSAndroid Build Coastguard Worker - [Incorporating Reviewer Comments](#incorporating-reviewer-comments) 41*77c1e3ccSAndroid Build Coastguard Worker - [Submitting your change](#submitting-your-change) 42*77c1e3ccSAndroid Build Coastguard Worker - [Viewing change status](#viewing-the-status-of-uploaded-changes) 43*77c1e3ccSAndroid Build Coastguard Worker6. [Support](#support) 44*77c1e3ccSAndroid Build Coastguard Worker7. [Bug reports](#bug-reports) 45*77c1e3ccSAndroid Build Coastguard Worker 46*77c1e3ccSAndroid Build Coastguard Worker## Building the library and applications {#building-the-library-and-applications} 47*77c1e3ccSAndroid Build Coastguard Worker 48*77c1e3ccSAndroid Build Coastguard Worker### Prerequisites {#prerequisites} 49*77c1e3ccSAndroid Build Coastguard Worker 50*77c1e3ccSAndroid Build Coastguard Worker1. [CMake](https://cmake.org). See CMakeLists.txt for the minimum version 51*77c1e3ccSAndroid Build Coastguard Worker required. 52*77c1e3ccSAndroid Build Coastguard Worker2. [Git](https://git-scm.com/). 53*77c1e3ccSAndroid Build Coastguard Worker3. A modern C compiler. gcc 6+, clang 7+, Microsoft Visual Studio 2019+ or 54*77c1e3ccSAndroid Build Coastguard Worker the latest version of MinGW-w64 (clang64 or ucrt toolchains) are 55*77c1e3ccSAndroid Build Coastguard Worker recommended. A C++ compiler is necessary to build the unit tests and some 56*77c1e3ccSAndroid Build Coastguard Worker features contained in the examples. 57*77c1e3ccSAndroid Build Coastguard Worker4. [Perl](https://www.perl.org/). 58*77c1e3ccSAndroid Build Coastguard Worker5. For x86 targets, [yasm](http://yasm.tortall.net/) or a recent version (2.14 59*77c1e3ccSAndroid Build Coastguard Worker or later) of [nasm](http://www.nasm.us/). (If both yasm and nasm are 60*77c1e3ccSAndroid Build Coastguard Worker present, yasm will be used by default. Pass -DENABLE_NASM=ON to cmake to 61*77c1e3ccSAndroid Build Coastguard Worker select nasm.) If you download yasm with the intention to work with Visual 62*77c1e3ccSAndroid Build Coastguard Worker Studio, please download win32.exe or win64.exe and rename it into yasm.exe. 63*77c1e3ccSAndroid Build Coastguard Worker DO NOT download or use vsyasm.exe. 64*77c1e3ccSAndroid Build Coastguard Worker6. Building the documentation requires 65*77c1e3ccSAndroid Build Coastguard Worker [doxygen version 1.8.10 or newer](http://doxygen.org). 66*77c1e3ccSAndroid Build Coastguard Worker7. Emscripten builds require the portable 67*77c1e3ccSAndroid Build Coastguard Worker [EMSDK](https://kripken.github.io/emscripten-site/index.html). 68*77c1e3ccSAndroid Build Coastguard Worker 69*77c1e3ccSAndroid Build Coastguard Worker### Get the code {#get-the-code} 70*77c1e3ccSAndroid Build Coastguard Worker 71*77c1e3ccSAndroid Build Coastguard WorkerThe AV1 library source code is stored in the Alliance for Open Media Git 72*77c1e3ccSAndroid Build Coastguard Workerrepository: 73*77c1e3ccSAndroid Build Coastguard Worker 74*77c1e3ccSAndroid Build Coastguard Worker~~~ 75*77c1e3ccSAndroid Build Coastguard Worker $ git clone https://aomedia.googlesource.com/aom 76*77c1e3ccSAndroid Build Coastguard Worker # By default, the above command stores the source in the aom directory: 77*77c1e3ccSAndroid Build Coastguard Worker $ cd aom 78*77c1e3ccSAndroid Build Coastguard Worker~~~ 79*77c1e3ccSAndroid Build Coastguard Worker 80*77c1e3ccSAndroid Build Coastguard Worker### Basic build {#basic-build} 81*77c1e3ccSAndroid Build Coastguard Worker 82*77c1e3ccSAndroid Build Coastguard WorkerCMake replaces the configure step typical of many projects. Running CMake will 83*77c1e3ccSAndroid Build Coastguard Workerproduce configuration and build files for the currently selected CMake 84*77c1e3ccSAndroid Build Coastguard Workergenerator. For most systems the default generator is Unix Makefiles. The basic 85*77c1e3ccSAndroid Build Coastguard Workerform of a makefile build is the following: 86*77c1e3ccSAndroid Build Coastguard Worker 87*77c1e3ccSAndroid Build Coastguard Worker~~~ 88*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom 89*77c1e3ccSAndroid Build Coastguard Worker $ make 90*77c1e3ccSAndroid Build Coastguard Worker~~~ 91*77c1e3ccSAndroid Build Coastguard Worker 92*77c1e3ccSAndroid Build Coastguard WorkerThe above will generate a makefile build that produces the AV1 library and 93*77c1e3ccSAndroid Build Coastguard Workerapplications for the current host system after the make step completes 94*77c1e3ccSAndroid Build Coastguard Workersuccessfully. The compiler chosen varies by host platform, but a general rule 95*77c1e3ccSAndroid Build Coastguard Workerapplies: On systems where cc and c++ are present in $PATH at the time CMake is 96*77c1e3ccSAndroid Build Coastguard Workerrun the generated build will use cc and c++ by default. 97*77c1e3ccSAndroid Build Coastguard Worker 98*77c1e3ccSAndroid Build Coastguard Worker### Configuration options {#configuration-options} 99*77c1e3ccSAndroid Build Coastguard Worker 100*77c1e3ccSAndroid Build Coastguard WorkerThe AV1 codec library has a great many configuration options. These come in two 101*77c1e3ccSAndroid Build Coastguard Workervarieties: 102*77c1e3ccSAndroid Build Coastguard Worker 103*77c1e3ccSAndroid Build Coastguard Worker 1. Build system configuration options. These have the form `ENABLE_FEATURE`. 104*77c1e3ccSAndroid Build Coastguard Worker 2. AV1 codec configuration options. These have the form `CONFIG_FEATURE`. 105*77c1e3ccSAndroid Build Coastguard Worker 106*77c1e3ccSAndroid Build Coastguard WorkerBoth types of options are set at the time CMake is run. The following example 107*77c1e3ccSAndroid Build Coastguard Workerenables ccache and disables the AV1 encoder: 108*77c1e3ccSAndroid Build Coastguard Worker 109*77c1e3ccSAndroid Build Coastguard Worker~~~ 110*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_AV1_ENCODER=0 111*77c1e3ccSAndroid Build Coastguard Worker $ make 112*77c1e3ccSAndroid Build Coastguard Worker~~~ 113*77c1e3ccSAndroid Build Coastguard Worker 114*77c1e3ccSAndroid Build Coastguard WorkerThe available configuration options are too numerous to list here. Build system 115*77c1e3ccSAndroid Build Coastguard Workerconfiguration options can be found at the top of the CMakeLists.txt file found 116*77c1e3ccSAndroid Build Coastguard Workerin the root of the AV1 repository, and AV1 codec configuration options can 117*77c1e3ccSAndroid Build Coastguard Workercurrently be found in the file `build/cmake/aom_config_defaults.cmake`. 118*77c1e3ccSAndroid Build Coastguard Worker 119*77c1e3ccSAndroid Build Coastguard Worker### Dylib builds {#dylib-builds} 120*77c1e3ccSAndroid Build Coastguard Worker 121*77c1e3ccSAndroid Build Coastguard WorkerA dylib (shared object) build of the AV1 codec library can be enabled via the 122*77c1e3ccSAndroid Build Coastguard WorkerCMake built in variable `BUILD_SHARED_LIBS`: 123*77c1e3ccSAndroid Build Coastguard Worker 124*77c1e3ccSAndroid Build Coastguard Worker~~~ 125*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DBUILD_SHARED_LIBS=1 126*77c1e3ccSAndroid Build Coastguard Worker $ make 127*77c1e3ccSAndroid Build Coastguard Worker~~~ 128*77c1e3ccSAndroid Build Coastguard Worker 129*77c1e3ccSAndroid Build Coastguard WorkerThis is currently only supported on non-Windows targets. 130*77c1e3ccSAndroid Build Coastguard Worker 131*77c1e3ccSAndroid Build Coastguard Worker### Debugging {#debugging} 132*77c1e3ccSAndroid Build Coastguard Worker 133*77c1e3ccSAndroid Build Coastguard WorkerDepending on the generator used there are multiple ways of going about 134*77c1e3ccSAndroid Build Coastguard Workerdebugging AV1 components. For single configuration generators like the Unix 135*77c1e3ccSAndroid Build Coastguard WorkerMakefiles generator, setting `CMAKE_BUILD_TYPE` to Debug is sufficient: 136*77c1e3ccSAndroid Build Coastguard Worker 137*77c1e3ccSAndroid Build Coastguard Worker~~~ 138*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DCMAKE_BUILD_TYPE=Debug 139*77c1e3ccSAndroid Build Coastguard Worker~~~ 140*77c1e3ccSAndroid Build Coastguard Worker 141*77c1e3ccSAndroid Build Coastguard WorkerFor Xcode, mainly because configuration controls for Xcode builds are buried two 142*77c1e3ccSAndroid Build Coastguard Workerconfiguration windows deep and must be set for each subproject within the Xcode 143*77c1e3ccSAndroid Build Coastguard WorkerIDE individually, `CMAKE_CONFIGURATION_TYPES` should be set to Debug: 144*77c1e3ccSAndroid Build Coastguard Worker 145*77c1e3ccSAndroid Build Coastguard Worker~~~ 146*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -G Xcode -DCMAKE_CONFIGURATION_TYPES=Debug 147*77c1e3ccSAndroid Build Coastguard Worker~~~ 148*77c1e3ccSAndroid Build Coastguard Worker 149*77c1e3ccSAndroid Build Coastguard WorkerFor Visual Studio the in-IDE configuration controls should be used. Simply set 150*77c1e3ccSAndroid Build Coastguard Workerthe IDE project configuration to Debug to allow for stepping through the code. 151*77c1e3ccSAndroid Build Coastguard Worker 152*77c1e3ccSAndroid Build Coastguard WorkerIn addition to the above it can sometimes be useful to debug only C and C++ 153*77c1e3ccSAndroid Build Coastguard Workercode. To disable all assembly code and intrinsics set `AOM_TARGET_CPU` to 154*77c1e3ccSAndroid Build Coastguard Workergeneric at generation time: 155*77c1e3ccSAndroid Build Coastguard Worker 156*77c1e3ccSAndroid Build Coastguard Worker~~~ 157*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DAOM_TARGET_CPU=generic 158*77c1e3ccSAndroid Build Coastguard Worker~~~ 159*77c1e3ccSAndroid Build Coastguard Worker 160*77c1e3ccSAndroid Build Coastguard Worker### Cross compiling {#cross-compiling} 161*77c1e3ccSAndroid Build Coastguard Worker 162*77c1e3ccSAndroid Build Coastguard WorkerFor the purposes of building the AV1 codec and applications and relative to the 163*77c1e3ccSAndroid Build Coastguard Workerscope of this guide, all builds for architectures differing from the native host 164*77c1e3ccSAndroid Build Coastguard Workerarchitecture will be considered cross compiles. The AV1 CMake build handles 165*77c1e3ccSAndroid Build Coastguard Workercross compiling via the use of toolchain files included in the AV1 repository. 166*77c1e3ccSAndroid Build Coastguard WorkerThe toolchain files available at the time of this writing are: 167*77c1e3ccSAndroid Build Coastguard Worker 168*77c1e3ccSAndroid Build Coastguard Worker - arm64-ios.cmake 169*77c1e3ccSAndroid Build Coastguard Worker - arm64-linux-clang.cmake 170*77c1e3ccSAndroid Build Coastguard Worker - arm64-linux-gcc.cmake 171*77c1e3ccSAndroid Build Coastguard Worker - arm64-mingw-gcc.cmake 172*77c1e3ccSAndroid Build Coastguard Worker - armv7-ios.cmake 173*77c1e3ccSAndroid Build Coastguard Worker - armv7-linux-gcc.cmake 174*77c1e3ccSAndroid Build Coastguard Worker - armv7-mingw-gcc.cmake 175*77c1e3ccSAndroid Build Coastguard Worker - armv7s-ios.cmake 176*77c1e3ccSAndroid Build Coastguard Worker - ppc-linux-gcc.cmake 177*77c1e3ccSAndroid Build Coastguard Worker - riscv-linux-gcc.cmake 178*77c1e3ccSAndroid Build Coastguard Worker - x86-ios-simulator.cmake 179*77c1e3ccSAndroid Build Coastguard Worker - x86-linux.cmake 180*77c1e3ccSAndroid Build Coastguard Worker - x86-macos.cmake 181*77c1e3ccSAndroid Build Coastguard Worker - x86-mingw-gcc.cmake 182*77c1e3ccSAndroid Build Coastguard Worker - x86\_64-ios-simulator.cmake 183*77c1e3ccSAndroid Build Coastguard Worker - x86\_64-mingw-gcc.cmake 184*77c1e3ccSAndroid Build Coastguard Worker 185*77c1e3ccSAndroid Build Coastguard WorkerThe following example demonstrates use of the x86-macos.cmake toolchain file on 186*77c1e3ccSAndroid Build Coastguard Workera x86\_64 MacOS host: 187*77c1e3ccSAndroid Build Coastguard Worker 188*77c1e3ccSAndroid Build Coastguard Worker~~~ 189*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom \ 190*77c1e3ccSAndroid Build Coastguard Worker -DCMAKE_TOOLCHAIN_FILE=path/to/aom/build/cmake/toolchains/x86-macos.cmake 191*77c1e3ccSAndroid Build Coastguard Worker $ make 192*77c1e3ccSAndroid Build Coastguard Worker~~~ 193*77c1e3ccSAndroid Build Coastguard Worker 194*77c1e3ccSAndroid Build Coastguard WorkerTo build for an unlisted target creation of a new toolchain file is the best 195*77c1e3ccSAndroid Build Coastguard Workersolution. The existing toolchain files can be used a starting point for a new 196*77c1e3ccSAndroid Build Coastguard Workertoolchain file since each one exposes the basic requirements for toolchain files 197*77c1e3ccSAndroid Build Coastguard Workeras used in the AV1 codec build. 198*77c1e3ccSAndroid Build Coastguard Worker 199*77c1e3ccSAndroid Build Coastguard WorkerAs a temporary work around an unoptimized AV1 configuration that builds only C 200*77c1e3ccSAndroid Build Coastguard Workerand C++ sources can be produced using the following commands: 201*77c1e3ccSAndroid Build Coastguard Worker 202*77c1e3ccSAndroid Build Coastguard Worker~~~ 203*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DAOM_TARGET_CPU=generic 204*77c1e3ccSAndroid Build Coastguard Worker $ make 205*77c1e3ccSAndroid Build Coastguard Worker~~~ 206*77c1e3ccSAndroid Build Coastguard Worker 207*77c1e3ccSAndroid Build Coastguard WorkerIn addition to the above it's important to note that the toolchain files 208*77c1e3ccSAndroid Build Coastguard Workersuffixed with gcc behave differently than the others. These toolchain files 209*77c1e3ccSAndroid Build Coastguard Workerattempt to obey the $CROSS environment variable. 210*77c1e3ccSAndroid Build Coastguard Worker 211*77c1e3ccSAndroid Build Coastguard Worker### Sanitizers {#sanitizers} 212*77c1e3ccSAndroid Build Coastguard Worker 213*77c1e3ccSAndroid Build Coastguard WorkerSanitizer integration is built-in to the CMake build system. To enable a 214*77c1e3ccSAndroid Build Coastguard Workersanitizer, add `-DSANITIZE=<type>` to the CMake command line. For example, to 215*77c1e3ccSAndroid Build Coastguard Workerenable address sanitizer: 216*77c1e3ccSAndroid Build Coastguard Worker 217*77c1e3ccSAndroid Build Coastguard Worker~~~ 218*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DSANITIZE=address 219*77c1e3ccSAndroid Build Coastguard Worker $ make 220*77c1e3ccSAndroid Build Coastguard Worker~~~ 221*77c1e3ccSAndroid Build Coastguard Worker 222*77c1e3ccSAndroid Build Coastguard WorkerSanitizers available vary by platform, target, and compiler. Consult your 223*77c1e3ccSAndroid Build Coastguard Workercompiler documentation to determine which, if any, are available. 224*77c1e3ccSAndroid Build Coastguard Worker 225*77c1e3ccSAndroid Build Coastguard Worker### Microsoft Visual Studio builds {#microsoft-visual-studio-builds} 226*77c1e3ccSAndroid Build Coastguard Worker 227*77c1e3ccSAndroid Build Coastguard WorkerBuilding the AV1 codec library in Microsoft Visual Studio is supported. Visual 228*77c1e3ccSAndroid Build Coastguard WorkerStudio 2019 (16.0) or later is required. The following example demonstrates 229*77c1e3ccSAndroid Build Coastguard Workergenerating projects and a solution for the Microsoft IDE: 230*77c1e3ccSAndroid Build Coastguard Worker 231*77c1e3ccSAndroid Build Coastguard Worker~~~ 232*77c1e3ccSAndroid Build Coastguard Worker # This does not require a bash shell; Command Prompt (cmd.exe) is fine. 233*77c1e3ccSAndroid Build Coastguard Worker # This assumes the build host is a Windows x64 computer. 234*77c1e3ccSAndroid Build Coastguard Worker 235*77c1e3ccSAndroid Build Coastguard Worker # To create a Visual Studio 2022 solution for the x64 target: 236*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -G "Visual Studio 17 2022" 237*77c1e3ccSAndroid Build Coastguard Worker 238*77c1e3ccSAndroid Build Coastguard Worker # To create a Visual Studio 2022 solution for the 32-bit x86 target: 239*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -G "Visual Studio 17 2022" -A Win32 240*77c1e3ccSAndroid Build Coastguard Worker 241*77c1e3ccSAndroid Build Coastguard Worker # To create a Visual Studio 2019 solution for the x64 target: 242*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -G "Visual Studio 16 2019" 243*77c1e3ccSAndroid Build Coastguard Worker 244*77c1e3ccSAndroid Build Coastguard Worker # To create a Visual Studio 2019 solution for the 32-bit x86 target: 245*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -G "Visual Studio 16 2019" -A Win32 246*77c1e3ccSAndroid Build Coastguard Worker 247*77c1e3ccSAndroid Build Coastguard Worker # To build the solution: 248*77c1e3ccSAndroid Build Coastguard Worker $ cmake --build . 249*77c1e3ccSAndroid Build Coastguard Worker~~~ 250*77c1e3ccSAndroid Build Coastguard Worker 251*77c1e3ccSAndroid Build Coastguard WorkerNOTE: The build system targets Windows 7 or later by compiling files with 252*77c1e3ccSAndroid Build Coastguard Worker`-D_WIN32_WINNT=0x0601`. 253*77c1e3ccSAndroid Build Coastguard Worker 254*77c1e3ccSAndroid Build Coastguard Worker### Xcode builds {#xcode-builds} 255*77c1e3ccSAndroid Build Coastguard Worker 256*77c1e3ccSAndroid Build Coastguard WorkerBuilding the AV1 codec library in Xcode is supported. The following example 257*77c1e3ccSAndroid Build Coastguard Workerdemonstrates generating an Xcode project: 258*77c1e3ccSAndroid Build Coastguard Worker 259*77c1e3ccSAndroid Build Coastguard Worker~~~ 260*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -G Xcode 261*77c1e3ccSAndroid Build Coastguard Worker~~~ 262*77c1e3ccSAndroid Build Coastguard Worker 263*77c1e3ccSAndroid Build Coastguard Worker### Emscripten builds {#emscripten-builds} 264*77c1e3ccSAndroid Build Coastguard Worker 265*77c1e3ccSAndroid Build Coastguard WorkerBuilding the AV1 codec library with Emscripten is supported. Typically this is 266*77c1e3ccSAndroid Build Coastguard Workerused to hook into the AOMAnalyzer GUI application. These instructions focus on 267*77c1e3ccSAndroid Build Coastguard Workerusing the inspector with AOMAnalyzer, but all tools can be built with 268*77c1e3ccSAndroid Build Coastguard WorkerEmscripten. 269*77c1e3ccSAndroid Build Coastguard Worker 270*77c1e3ccSAndroid Build Coastguard WorkerIt is assumed here that you have already downloaded and installed the EMSDK, 271*77c1e3ccSAndroid Build Coastguard Workerinstalled and activated at least one toolchain, and setup your environment 272*77c1e3ccSAndroid Build Coastguard Workerappropriately using the emsdk\_env script. 273*77c1e3ccSAndroid Build Coastguard Worker 274*77c1e3ccSAndroid Build Coastguard Worker1. Build [AOM Analyzer](https://github.com/xiph/aomanalyzer). 275*77c1e3ccSAndroid Build Coastguard Worker 276*77c1e3ccSAndroid Build Coastguard Worker2. Configure the build: 277*77c1e3ccSAndroid Build Coastguard Worker 278*77c1e3ccSAndroid Build Coastguard Worker~~~ 279*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom \ 280*77c1e3ccSAndroid Build Coastguard Worker -DENABLE_CCACHE=1 \ 281*77c1e3ccSAndroid Build Coastguard Worker -DAOM_TARGET_CPU=generic \ 282*77c1e3ccSAndroid Build Coastguard Worker -DENABLE_DOCS=0 \ 283*77c1e3ccSAndroid Build Coastguard Worker -DENABLE_TESTS=0 \ 284*77c1e3ccSAndroid Build Coastguard Worker -DCONFIG_ACCOUNTING=1 \ 285*77c1e3ccSAndroid Build Coastguard Worker -DCONFIG_INSPECTION=1 \ 286*77c1e3ccSAndroid Build Coastguard Worker -DCONFIG_MULTITHREAD=0 \ 287*77c1e3ccSAndroid Build Coastguard Worker -DCONFIG_RUNTIME_CPU_DETECT=0 \ 288*77c1e3ccSAndroid Build Coastguard Worker -DCONFIG_WEBM_IO=0 \ 289*77c1e3ccSAndroid Build Coastguard Worker -DCMAKE_TOOLCHAIN_FILE=path/to/emsdk-portable/.../Emscripten.cmake 290*77c1e3ccSAndroid Build Coastguard Worker~~~ 291*77c1e3ccSAndroid Build Coastguard Worker 292*77c1e3ccSAndroid Build Coastguard Worker3. Build it: run make if that's your generator of choice: 293*77c1e3ccSAndroid Build Coastguard Worker 294*77c1e3ccSAndroid Build Coastguard Worker~~~ 295*77c1e3ccSAndroid Build Coastguard Worker $ make inspect 296*77c1e3ccSAndroid Build Coastguard Worker~~~ 297*77c1e3ccSAndroid Build Coastguard Worker 298*77c1e3ccSAndroid Build Coastguard Worker4. Run the analyzer: 299*77c1e3ccSAndroid Build Coastguard Worker 300*77c1e3ccSAndroid Build Coastguard Worker~~~ 301*77c1e3ccSAndroid Build Coastguard Worker # inspect.js is in the examples sub directory of the directory in which you 302*77c1e3ccSAndroid Build Coastguard Worker # executed cmake. 303*77c1e3ccSAndroid Build Coastguard Worker $ path/to/AOMAnalyzer path/to/examples/inspect.js path/to/av1/input/file 304*77c1e3ccSAndroid Build Coastguard Worker~~~ 305*77c1e3ccSAndroid Build Coastguard Worker 306*77c1e3ccSAndroid Build Coastguard Worker### Extra build flags {#extra-build-flags} 307*77c1e3ccSAndroid Build Coastguard Worker 308*77c1e3ccSAndroid Build Coastguard WorkerThree variables allow for passing of additional flags to the build system. 309*77c1e3ccSAndroid Build Coastguard Worker 310*77c1e3ccSAndroid Build Coastguard Worker- AOM\_EXTRA\_C\_FLAGS 311*77c1e3ccSAndroid Build Coastguard Worker- AOM\_EXTRA\_CXX\_FLAGS 312*77c1e3ccSAndroid Build Coastguard Worker- AOM\_EXTRA\_EXE\_LINKER\_FLAGS 313*77c1e3ccSAndroid Build Coastguard Worker 314*77c1e3ccSAndroid Build Coastguard WorkerThe build system attempts to ensure the flags passed through the above variables 315*77c1e3ccSAndroid Build Coastguard Workerare passed to tools last in order to allow for override of default behavior. 316*77c1e3ccSAndroid Build Coastguard WorkerThese flags can be used, for example, to enable asserts in a release build: 317*77c1e3ccSAndroid Build Coastguard Worker 318*77c1e3ccSAndroid Build Coastguard Worker~~~ 319*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom \ 320*77c1e3ccSAndroid Build Coastguard Worker -DCMAKE_BUILD_TYPE=Release \ 321*77c1e3ccSAndroid Build Coastguard Worker -DAOM_EXTRA_C_FLAGS=-UNDEBUG \ 322*77c1e3ccSAndroid Build Coastguard Worker -DAOM_EXTRA_CXX_FLAGS=-UNDEBUG 323*77c1e3ccSAndroid Build Coastguard Worker~~~ 324*77c1e3ccSAndroid Build Coastguard Worker 325*77c1e3ccSAndroid Build Coastguard Worker### Build with VMAF support {#build-with-vmaf} 326*77c1e3ccSAndroid Build Coastguard Worker 327*77c1e3ccSAndroid Build Coastguard WorkerAfter installing 328*77c1e3ccSAndroid Build Coastguard Worker[libvmaf.a](https://github.com/Netflix/vmaf/tree/master/libvmaf), 329*77c1e3ccSAndroid Build Coastguard Workeryou can use it with the encoder: 330*77c1e3ccSAndroid Build Coastguard Worker 331*77c1e3ccSAndroid Build Coastguard Worker~~~ 332*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DCONFIG_TUNE_VMAF=1 333*77c1e3ccSAndroid Build Coastguard Worker~~~ 334*77c1e3ccSAndroid Build Coastguard Worker 335*77c1e3ccSAndroid Build Coastguard WorkerPlease note that the default VMAF model 336*77c1e3ccSAndroid Build Coastguard Worker("/usr/local/share/model/vmaf_v0.6.1.json") 337*77c1e3ccSAndroid Build Coastguard Workerwill be used unless you set the following flag when running the encoder: 338*77c1e3ccSAndroid Build Coastguard Worker 339*77c1e3ccSAndroid Build Coastguard Worker~~~ 340*77c1e3ccSAndroid Build Coastguard Worker # --vmaf-model-path=path/to/model 341*77c1e3ccSAndroid Build Coastguard Worker~~~ 342*77c1e3ccSAndroid Build Coastguard Worker 343*77c1e3ccSAndroid Build Coastguard Worker## Testing the AV1 codec {#testing-the-av1-codec} 344*77c1e3ccSAndroid Build Coastguard Worker 345*77c1e3ccSAndroid Build Coastguard Worker### Testing basics {#testing-basics} 346*77c1e3ccSAndroid Build Coastguard Worker 347*77c1e3ccSAndroid Build Coastguard WorkerThere are several methods of testing the AV1 codec. All of these methods require 348*77c1e3ccSAndroid Build Coastguard Workerthe presence of the AV1 source code and a working build of the AV1 library and 349*77c1e3ccSAndroid Build Coastguard Workerapplications. 350*77c1e3ccSAndroid Build Coastguard Worker 351*77c1e3ccSAndroid Build Coastguard Worker#### 1. Unit tests: {#unit-tests} 352*77c1e3ccSAndroid Build Coastguard Worker 353*77c1e3ccSAndroid Build Coastguard WorkerThe unit tests can be run at build time: 354*77c1e3ccSAndroid Build Coastguard Worker 355*77c1e3ccSAndroid Build Coastguard Worker~~~ 356*77c1e3ccSAndroid Build Coastguard Worker # Before running the make command the LIBAOM_TEST_DATA_PATH environment 357*77c1e3ccSAndroid Build Coastguard Worker # variable should be set to avoid downloading the test files to the 358*77c1e3ccSAndroid Build Coastguard Worker # cmake build configuration directory. 359*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom 360*77c1e3ccSAndroid Build Coastguard Worker # Note: The AV1 CMake build creates many test targets. Running make 361*77c1e3ccSAndroid Build Coastguard Worker # with multiple jobs will speed up the test run significantly. 362*77c1e3ccSAndroid Build Coastguard Worker $ make runtests 363*77c1e3ccSAndroid Build Coastguard Worker~~~ 364*77c1e3ccSAndroid Build Coastguard Worker 365*77c1e3ccSAndroid Build Coastguard Worker#### 2. Example tests: {#example-tests} 366*77c1e3ccSAndroid Build Coastguard Worker 367*77c1e3ccSAndroid Build Coastguard WorkerThe example tests require a bash shell and can be run in the following manner: 368*77c1e3ccSAndroid Build Coastguard Worker 369*77c1e3ccSAndroid Build Coastguard Worker~~~ 370*77c1e3ccSAndroid Build Coastguard Worker # See the note above about LIBAOM_TEST_DATA_PATH above. 371*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom 372*77c1e3ccSAndroid Build Coastguard Worker $ make 373*77c1e3ccSAndroid Build Coastguard Worker # It's best to build the testdata target using many make jobs. 374*77c1e3ccSAndroid Build Coastguard Worker # Running it like this will verify and download (if necessary) 375*77c1e3ccSAndroid Build Coastguard Worker # one at a time, which takes a while. 376*77c1e3ccSAndroid Build Coastguard Worker $ make testdata 377*77c1e3ccSAndroid Build Coastguard Worker $ path/to/aom/test/examples.sh --bin-path examples 378*77c1e3ccSAndroid Build Coastguard Worker~~~ 379*77c1e3ccSAndroid Build Coastguard Worker 380*77c1e3ccSAndroid Build Coastguard Worker#### 3. Encoder tests: {#encoder-tests} 381*77c1e3ccSAndroid Build Coastguard Worker 382*77c1e3ccSAndroid Build Coastguard WorkerWhen making a change to the encoder run encoder tests to confirm that your 383*77c1e3ccSAndroid Build Coastguard Workerchange has a positive or negligible impact on encode quality. When running these 384*77c1e3ccSAndroid Build Coastguard Workertests the build configuration should be changed to enable internal encoder 385*77c1e3ccSAndroid Build Coastguard Workerstatistics: 386*77c1e3ccSAndroid Build Coastguard Worker 387*77c1e3ccSAndroid Build Coastguard Worker~~~ 388*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DCONFIG_INTERNAL_STATS=1 389*77c1e3ccSAndroid Build Coastguard Worker $ make 390*77c1e3ccSAndroid Build Coastguard Worker~~~ 391*77c1e3ccSAndroid Build Coastguard Worker 392*77c1e3ccSAndroid Build Coastguard WorkerThe repository contains scripts intended to make running these tests as simple 393*77c1e3ccSAndroid Build Coastguard Workeras possible. The following example demonstrates creating a set of baseline clips 394*77c1e3ccSAndroid Build Coastguard Workerfor comparison to results produced after making your change to libaom: 395*77c1e3ccSAndroid Build Coastguard Worker 396*77c1e3ccSAndroid Build Coastguard Worker~~~ 397*77c1e3ccSAndroid Build Coastguard Worker # This will encode all Y4M files in the current directory using the 398*77c1e3ccSAndroid Build Coastguard Worker # settings specified to create the encoder baseline statistical data: 399*77c1e3ccSAndroid Build Coastguard Worker $ cd path/to/test/inputs 400*77c1e3ccSAndroid Build Coastguard Worker # This command line assumes that run_encodes.sh, its helper script 401*77c1e3ccSAndroid Build Coastguard Worker # best_encode.sh, and the aomenc you intend to test are all within a 402*77c1e3ccSAndroid Build Coastguard Worker # directory in your PATH. 403*77c1e3ccSAndroid Build Coastguard Worker $ run_encodes.sh 200 500 50 baseline 404*77c1e3ccSAndroid Build Coastguard Worker~~~ 405*77c1e3ccSAndroid Build Coastguard Worker 406*77c1e3ccSAndroid Build Coastguard WorkerAfter making your change and creating the baseline clips, you'll need to run 407*77c1e3ccSAndroid Build Coastguard Workerencodes that include your change(s) to confirm that things are working as 408*77c1e3ccSAndroid Build Coastguard Workerintended: 409*77c1e3ccSAndroid Build Coastguard Worker 410*77c1e3ccSAndroid Build Coastguard Worker~~~ 411*77c1e3ccSAndroid Build Coastguard Worker # This will encode all Y4M files in the current directory using the 412*77c1e3ccSAndroid Build Coastguard Worker # settings specified to create the statistical data for your change: 413*77c1e3ccSAndroid Build Coastguard Worker $ cd path/to/test/inputs 414*77c1e3ccSAndroid Build Coastguard Worker # This command line assumes that run_encodes.sh, its helper script 415*77c1e3ccSAndroid Build Coastguard Worker # best_encode.sh, and the aomenc you intend to test are all within a 416*77c1e3ccSAndroid Build Coastguard Worker # directory in your PATH. 417*77c1e3ccSAndroid Build Coastguard Worker $ run_encodes.sh 200 500 50 mytweak 418*77c1e3ccSAndroid Build Coastguard Worker~~~ 419*77c1e3ccSAndroid Build Coastguard Worker 420*77c1e3ccSAndroid Build Coastguard WorkerAfter creating both data sets you can use `test/visual_metrics.py` to generate a 421*77c1e3ccSAndroid Build Coastguard Workerreport that can be viewed in a web browser: 422*77c1e3ccSAndroid Build Coastguard Worker 423*77c1e3ccSAndroid Build Coastguard Worker~~~ 424*77c1e3ccSAndroid Build Coastguard Worker $ visual_metrics.py metrics_template.html "*stt" baseline mytweak \ 425*77c1e3ccSAndroid Build Coastguard Worker > mytweak.html 426*77c1e3ccSAndroid Build Coastguard Worker~~~ 427*77c1e3ccSAndroid Build Coastguard Worker 428*77c1e3ccSAndroid Build Coastguard WorkerYou can view the report by opening mytweak.html in a web browser. 429*77c1e3ccSAndroid Build Coastguard Worker 430*77c1e3ccSAndroid Build Coastguard Worker 431*77c1e3ccSAndroid Build Coastguard Worker### IDE hosted tests {#ide-hosted-tests} 432*77c1e3ccSAndroid Build Coastguard Worker 433*77c1e3ccSAndroid Build Coastguard WorkerBy default the generated projects files created by CMake will not include the 434*77c1e3ccSAndroid Build Coastguard Workerruntests and testdata rules when generating for IDEs like Microsoft Visual 435*77c1e3ccSAndroid Build Coastguard WorkerStudio and Xcode. This is done to avoid intolerably long build cycles in the 436*77c1e3ccSAndroid Build Coastguard WorkerIDEs-- IDE behavior is to build all targets when selecting the build project 437*77c1e3ccSAndroid Build Coastguard Workeroptions in MSVS and Xcode. To enable the test rules in IDEs the 438*77c1e3ccSAndroid Build Coastguard Worker`ENABLE_IDE_TEST_HOSTING` variable must be enabled at CMake generation time: 439*77c1e3ccSAndroid Build Coastguard Worker 440*77c1e3ccSAndroid Build Coastguard Worker~~~ 441*77c1e3ccSAndroid Build Coastguard Worker # This example uses Xcode. To get a list of the generators 442*77c1e3ccSAndroid Build Coastguard Worker # available, run cmake with the -G argument missing its 443*77c1e3ccSAndroid Build Coastguard Worker # value. 444*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -DENABLE_IDE_TEST_HOSTING=1 -G Xcode 445*77c1e3ccSAndroid Build Coastguard Worker~~~ 446*77c1e3ccSAndroid Build Coastguard Worker 447*77c1e3ccSAndroid Build Coastguard Worker### Downloading the test data {#downloading-the-test-data} 448*77c1e3ccSAndroid Build Coastguard Worker 449*77c1e3ccSAndroid Build Coastguard WorkerThe fastest and easiest way to obtain the test data is to use CMake to generate 450*77c1e3ccSAndroid Build Coastguard Workera build using the Unix Makefiles generator, and then to build only the testdata 451*77c1e3ccSAndroid Build Coastguard Workerrule. By default the test files will be downloaded to the current directory. The 452*77c1e3ccSAndroid Build Coastguard Worker`LIBAOM_TEST_DATA_PATH` environment variable can be used to set a 453*77c1e3ccSAndroid Build Coastguard Workercustom one. 454*77c1e3ccSAndroid Build Coastguard Worker 455*77c1e3ccSAndroid Build Coastguard Worker~~~ 456*77c1e3ccSAndroid Build Coastguard Worker $ cmake path/to/aom -G "Unix Makefiles" 457*77c1e3ccSAndroid Build Coastguard Worker # 28 is used because there are 28 test files as of this writing. 458*77c1e3ccSAndroid Build Coastguard Worker $ make -j28 testdata 459*77c1e3ccSAndroid Build Coastguard Worker~~~ 460*77c1e3ccSAndroid Build Coastguard Worker 461*77c1e3ccSAndroid Build Coastguard WorkerThe above make command will only download and verify the test data. 462*77c1e3ccSAndroid Build Coastguard Worker 463*77c1e3ccSAndroid Build Coastguard Worker### Adding a new test data file {#adding-a-new-test-data-file} 464*77c1e3ccSAndroid Build Coastguard Worker 465*77c1e3ccSAndroid Build Coastguard WorkerFirst, add the new test data file to the `aom-test-data` bucket of the 466*77c1e3ccSAndroid Build Coastguard Worker`aomedia-testing` project on Google Cloud Platform. You may need to ask someone 467*77c1e3ccSAndroid Build Coastguard Workerwith the necessary access permissions to do this for you. 468*77c1e3ccSAndroid Build Coastguard Worker 469*77c1e3ccSAndroid Build Coastguard WorkerNOTE: When a new test data file is added to the `aom-test-data` bucket, its 470*77c1e3ccSAndroid Build Coastguard Worker"Public access" is initially "Not public". We need to change its 471*77c1e3ccSAndroid Build Coastguard Worker"Public access" to "Public" by using the following 472*77c1e3ccSAndroid Build Coastguard Worker[`gsutil`](https://cloud.google.com/storage/docs/gsutil_install) command: 473*77c1e3ccSAndroid Build Coastguard Worker~~~ 474*77c1e3ccSAndroid Build Coastguard Worker $ gsutil acl ch -g all:R gs://aom-test-data/test-data-file-name 475*77c1e3ccSAndroid Build Coastguard Worker~~~ 476*77c1e3ccSAndroid Build Coastguard WorkerThis command grants the `AllUsers` group READ access to the file named 477*77c1e3ccSAndroid Build Coastguard Worker"test-data-file-name" in the `aom-test-data` bucket. 478*77c1e3ccSAndroid Build Coastguard Worker 479*77c1e3ccSAndroid Build Coastguard WorkerOnce the new test data file has been added to `aom-test-data`, create a CL to 480*77c1e3ccSAndroid Build Coastguard Workeradd the name of the new test data file to `test/test_data_util.cmake` and add 481*77c1e3ccSAndroid Build Coastguard Workerthe SHA1 checksum of the new test data file to `test/test-data.sha1`. (The SHA1 482*77c1e3ccSAndroid Build Coastguard Workerchecksum of a file can be calculated by running the `sha1sum` command on the 483*77c1e3ccSAndroid Build Coastguard Workerfile.) 484*77c1e3ccSAndroid Build Coastguard Worker 485*77c1e3ccSAndroid Build Coastguard Worker### Additional test data {#additional-test-data} 486*77c1e3ccSAndroid Build Coastguard Worker 487*77c1e3ccSAndroid Build Coastguard WorkerThe test data mentioned above is strictly intended for unit testing. 488*77c1e3ccSAndroid Build Coastguard Worker 489*77c1e3ccSAndroid Build Coastguard WorkerAdditional input data for testing the encoder can be obtained from: 490*77c1e3ccSAndroid Build Coastguard Workerhttps://media.xiph.org/video/derf/ 491*77c1e3ccSAndroid Build Coastguard Worker 492*77c1e3ccSAndroid Build Coastguard Worker### Sharded testing {#sharded-testing} 493*77c1e3ccSAndroid Build Coastguard Worker 494*77c1e3ccSAndroid Build Coastguard WorkerThe AV1 codec library unit tests are built upon gtest which supports sharding of 495*77c1e3ccSAndroid Build Coastguard Workertest jobs. Sharded test runs can be achieved in a couple of ways. 496*77c1e3ccSAndroid Build Coastguard Worker 497*77c1e3ccSAndroid Build Coastguard Worker#### 1. Running test\_libaom directly: {#running-test_libaom-directly} 498*77c1e3ccSAndroid Build Coastguard Worker 499*77c1e3ccSAndroid Build Coastguard Worker~~~ 500*77c1e3ccSAndroid Build Coastguard Worker # Set the environment variable GTEST_TOTAL_SHARDS to control the number of 501*77c1e3ccSAndroid Build Coastguard Worker # shards. 502*77c1e3ccSAndroid Build Coastguard Worker $ export GTEST_TOTAL_SHARDS=10 503*77c1e3ccSAndroid Build Coastguard Worker # (GTEST shard indexing is 0 based). 504*77c1e3ccSAndroid Build Coastguard Worker $ seq 0 $(( $GTEST_TOTAL_SHARDS - 1 )) \ 505*77c1e3ccSAndroid Build Coastguard Worker | xargs -n 1 -P 0 -I{} env GTEST_SHARD_INDEX={} ./test_libaom 506*77c1e3ccSAndroid Build Coastguard Worker~~~ 507*77c1e3ccSAndroid Build Coastguard Worker 508*77c1e3ccSAndroid Build Coastguard WorkerTo create a test shard for each CPU core available on the current system set 509*77c1e3ccSAndroid Build Coastguard Worker`GTEST_TOTAL_SHARDS` to the number of CPU cores on your system minus one. 510*77c1e3ccSAndroid Build Coastguard Worker 511*77c1e3ccSAndroid Build Coastguard Worker#### 2. Running the tests via the CMake build: {#running-the-tests-via-the-cmake-build} 512*77c1e3ccSAndroid Build Coastguard Worker 513*77c1e3ccSAndroid Build Coastguard Worker~~~ 514*77c1e3ccSAndroid Build Coastguard Worker # For IDE based builds, ENABLE_IDE_TEST_HOSTING must be enabled. See 515*77c1e3ccSAndroid Build Coastguard Worker # the IDE hosted tests section above for more information. If the IDE 516*77c1e3ccSAndroid Build Coastguard Worker # supports building targets concurrently tests will be sharded by default. 517*77c1e3ccSAndroid Build Coastguard Worker 518*77c1e3ccSAndroid Build Coastguard Worker # For make and ninja builds the -j parameter controls the number of shards 519*77c1e3ccSAndroid Build Coastguard Worker # at test run time. This example will run the tests using 10 shards via 520*77c1e3ccSAndroid Build Coastguard Worker # make. 521*77c1e3ccSAndroid Build Coastguard Worker $ make -j10 runtests 522*77c1e3ccSAndroid Build Coastguard Worker~~~ 523*77c1e3ccSAndroid Build Coastguard Worker 524*77c1e3ccSAndroid Build Coastguard WorkerThe maximum number of test targets that can run concurrently is determined by 525*77c1e3ccSAndroid Build Coastguard Workerthe number of CPUs on the system where the build is configured as detected by 526*77c1e3ccSAndroid Build Coastguard WorkerCMake. A system with 24 cores can run 24 test shards using a value of 24 with 527*77c1e3ccSAndroid Build Coastguard Workerthe `-j` parameter. When CMake is unable to detect the number of cores 10 shards 528*77c1e3ccSAndroid Build Coastguard Workeris the default maximum value. 529*77c1e3ccSAndroid Build Coastguard Worker 530*77c1e3ccSAndroid Build Coastguard Worker## Coding style {#coding-style} 531*77c1e3ccSAndroid Build Coastguard Worker 532*77c1e3ccSAndroid Build Coastguard WorkerWe are using the Google C Coding Style defined by the 533*77c1e3ccSAndroid Build Coastguard Worker[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). 534*77c1e3ccSAndroid Build Coastguard Worker 535*77c1e3ccSAndroid Build Coastguard WorkerThe coding style used by this project is enforced with clang-format using the 536*77c1e3ccSAndroid Build Coastguard Workerconfiguration contained in the 537*77c1e3ccSAndroid Build Coastguard Worker[.clang-format](https://chromium.googlesource.com/webm/aom/+/main/.clang-format) 538*77c1e3ccSAndroid Build Coastguard Workerfile in the root of the repository. 539*77c1e3ccSAndroid Build Coastguard Worker 540*77c1e3ccSAndroid Build Coastguard WorkerYou can download clang-format using your system's package manager, or directly 541*77c1e3ccSAndroid Build Coastguard Workerfrom [llvm.org](http://llvm.org/releases/download.html). You can also view the 542*77c1e3ccSAndroid Build Coastguard Worker[documentation](https://clang.llvm.org/docs/ClangFormat.html) on llvm.org. 543*77c1e3ccSAndroid Build Coastguard WorkerOutput from clang-format varies by clang-format version, for best results your 544*77c1e3ccSAndroid Build Coastguard Workerversion should match the one used on Jenkins. You can find the clang-format 545*77c1e3ccSAndroid Build Coastguard Workerversion by reading the comment in the `.clang-format` file linked above. 546*77c1e3ccSAndroid Build Coastguard Worker 547*77c1e3ccSAndroid Build Coastguard WorkerBefore pushing changes for review you can format your code with: 548*77c1e3ccSAndroid Build Coastguard Worker 549*77c1e3ccSAndroid Build Coastguard Worker~~~ 550*77c1e3ccSAndroid Build Coastguard Worker # Apply clang-format to modified .c, .h and .cc files 551*77c1e3ccSAndroid Build Coastguard Worker $ clang-format -i --style=file \ 552*77c1e3ccSAndroid Build Coastguard Worker $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc') 553*77c1e3ccSAndroid Build Coastguard Worker~~~ 554*77c1e3ccSAndroid Build Coastguard Worker 555*77c1e3ccSAndroid Build Coastguard WorkerCheck the .clang-format file for the version used to generate it if there is any 556*77c1e3ccSAndroid Build Coastguard Workerdifference between your local formatting and the review system. 557*77c1e3ccSAndroid Build Coastguard Worker 558*77c1e3ccSAndroid Build Coastguard WorkerSome Git installations have clang-format integration. Here are some examples: 559*77c1e3ccSAndroid Build Coastguard Worker 560*77c1e3ccSAndroid Build Coastguard Worker~~~ 561*77c1e3ccSAndroid Build Coastguard Worker # Apply clang-format to all staged changes: 562*77c1e3ccSAndroid Build Coastguard Worker $ git clang-format 563*77c1e3ccSAndroid Build Coastguard Worker 564*77c1e3ccSAndroid Build Coastguard Worker # Clang format all staged and unstaged changes: 565*77c1e3ccSAndroid Build Coastguard Worker $ git clang-format -f 566*77c1e3ccSAndroid Build Coastguard Worker 567*77c1e3ccSAndroid Build Coastguard Worker # Clang format all staged and unstaged changes interactively: 568*77c1e3ccSAndroid Build Coastguard Worker $ git clang-format -f -p 569*77c1e3ccSAndroid Build Coastguard Worker~~~ 570*77c1e3ccSAndroid Build Coastguard Worker 571*77c1e3ccSAndroid Build Coastguard Worker## License header {#license-header} 572*77c1e3ccSAndroid Build Coastguard Worker 573*77c1e3ccSAndroid Build Coastguard WorkerUse the following comment block in new C/C++ source files, replacing "${year}" 574*77c1e3ccSAndroid Build Coastguard Workerwith the current year. The same comment should be added to other file types, 575*77c1e3ccSAndroid Build Coastguard Workeradjusting the comment syntax as necessary. 576*77c1e3ccSAndroid Build Coastguard Worker 577*77c1e3ccSAndroid Build Coastguard Worker``` 578*77c1e3ccSAndroid Build Coastguard Worker/* 579*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) ${year}, Alliance for Open Media. All rights reserved. 580*77c1e3ccSAndroid Build Coastguard Worker * 581*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and 582*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 583*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can 584*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open 585*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the 586*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 587*77c1e3ccSAndroid Build Coastguard Worker */ 588*77c1e3ccSAndroid Build Coastguard Worker``` 589*77c1e3ccSAndroid Build Coastguard Worker 590*77c1e3ccSAndroid Build Coastguard Worker## Submitting patches {#submitting-patches} 591*77c1e3ccSAndroid Build Coastguard Worker 592*77c1e3ccSAndroid Build Coastguard WorkerWe manage the submission of patches using the 593*77c1e3ccSAndroid Build Coastguard Worker[Gerrit](https://www.gerritcodereview.com/) code review tool. This tool 594*77c1e3ccSAndroid Build Coastguard Workerimplements a workflow on top of the Git version control system to ensure that 595*77c1e3ccSAndroid Build Coastguard Workerall changes get peer reviewed and tested prior to their distribution. 596*77c1e3ccSAndroid Build Coastguard Worker 597*77c1e3ccSAndroid Build Coastguard Worker### Login cookie {#login-cookie} 598*77c1e3ccSAndroid Build Coastguard Worker 599*77c1e3ccSAndroid Build Coastguard WorkerBrowse to [AOMedia Git index](https://aomedia.googlesource.com/) and login with 600*77c1e3ccSAndroid Build Coastguard Workeryour account (Gmail credentials, for example). Next, follow the 601*77c1e3ccSAndroid Build Coastguard Worker`Generate Password` Password link at the top of the page. You’ll be given 602*77c1e3ccSAndroid Build Coastguard Workerinstructions for creating a cookie to use with our Git repos. 603*77c1e3ccSAndroid Build Coastguard Worker 604*77c1e3ccSAndroid Build Coastguard WorkerYou must also have a Gerrit account associated with your Google account. To do 605*77c1e3ccSAndroid Build Coastguard Workerthis visit the [Gerrit review server](https://aomedia-review.googlesource.com) 606*77c1e3ccSAndroid Build Coastguard Workerand click "Sign in" (top right). 607*77c1e3ccSAndroid Build Coastguard Worker 608*77c1e3ccSAndroid Build Coastguard Worker### Contributor agreement {#contributor-agreement} 609*77c1e3ccSAndroid Build Coastguard Worker 610*77c1e3ccSAndroid Build Coastguard WorkerYou will be required to execute a 611*77c1e3ccSAndroid Build Coastguard Worker[contributor agreement](http://aomedia.org/license) to ensure that the AOMedia 612*77c1e3ccSAndroid Build Coastguard WorkerProject has the right to distribute your changes. 613*77c1e3ccSAndroid Build Coastguard Worker 614*77c1e3ccSAndroid Build Coastguard WorkerNote: If you are pushing changes on behalf of an Alliance for Open Media member 615*77c1e3ccSAndroid Build Coastguard Workerorganization this step is not necessary. 616*77c1e3ccSAndroid Build Coastguard Worker 617*77c1e3ccSAndroid Build Coastguard Worker### Testing your code {#testing-your-code} 618*77c1e3ccSAndroid Build Coastguard Worker 619*77c1e3ccSAndroid Build Coastguard WorkerThe testing basics are covered in the [testing section](#testing-the-av1-codec) 620*77c1e3ccSAndroid Build Coastguard Workerabove. 621*77c1e3ccSAndroid Build Coastguard Worker 622*77c1e3ccSAndroid Build Coastguard WorkerIn addition to the local tests, many more (e.g. asan, tsan, valgrind) will run 623*77c1e3ccSAndroid Build Coastguard Workerthrough Jenkins instances upon upload to gerrit. 624*77c1e3ccSAndroid Build Coastguard Worker 625*77c1e3ccSAndroid Build Coastguard Worker### Commit message hook {#commit-message-hook} 626*77c1e3ccSAndroid Build Coastguard Worker 627*77c1e3ccSAndroid Build Coastguard WorkerGerrit requires that each submission include a unique Change-Id. You can assign 628*77c1e3ccSAndroid Build Coastguard Workerone manually using git commit --amend, but it’s easier to automate it with the 629*77c1e3ccSAndroid Build Coastguard Workercommit-msg hook provided by Gerrit. 630*77c1e3ccSAndroid Build Coastguard Worker 631*77c1e3ccSAndroid Build Coastguard WorkerCopy commit-msg to the `.git/hooks` directory of your local repo. Here's an 632*77c1e3ccSAndroid Build Coastguard Workerexample: 633*77c1e3ccSAndroid Build Coastguard Worker 634*77c1e3ccSAndroid Build Coastguard Worker~~~ 635*77c1e3ccSAndroid Build Coastguard Worker $ curl -Lo aom/.git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg 636*77c1e3ccSAndroid Build Coastguard Worker 637*77c1e3ccSAndroid Build Coastguard Worker # Next, ensure that the downloaded commit-msg script is executable: 638*77c1e3ccSAndroid Build Coastguard Worker $ chmod u+x aom/.git/hooks/commit-msg 639*77c1e3ccSAndroid Build Coastguard Worker~~~ 640*77c1e3ccSAndroid Build Coastguard Worker 641*77c1e3ccSAndroid Build Coastguard WorkerSee the Gerrit 642*77c1e3ccSAndroid Build Coastguard Worker[documentation](https://gerrit-review.googlesource.com/Documentation/user-changeid.html) 643*77c1e3ccSAndroid Build Coastguard Workerfor more information. 644*77c1e3ccSAndroid Build Coastguard Worker 645*77c1e3ccSAndroid Build Coastguard Worker### Upload your change {#upload-your-change} 646*77c1e3ccSAndroid Build Coastguard Worker 647*77c1e3ccSAndroid Build Coastguard WorkerThe command line to upload your patch looks like this: 648*77c1e3ccSAndroid Build Coastguard Worker 649*77c1e3ccSAndroid Build Coastguard Worker~~~ 650*77c1e3ccSAndroid Build Coastguard Worker $ git push https://aomedia-review.googlesource.com/aom HEAD:refs/for/main 651*77c1e3ccSAndroid Build Coastguard Worker~~~ 652*77c1e3ccSAndroid Build Coastguard Worker 653*77c1e3ccSAndroid Build Coastguard Worker### Incorporating reviewer comments {#incorporating-reviewer-comments} 654*77c1e3ccSAndroid Build Coastguard Worker 655*77c1e3ccSAndroid Build Coastguard WorkerIf you previously uploaded a change to Gerrit and the Approver has asked for 656*77c1e3ccSAndroid Build Coastguard Workerchanges, follow these steps: 657*77c1e3ccSAndroid Build Coastguard Worker 658*77c1e3ccSAndroid Build Coastguard Worker1. Edit the files to make the changes the reviewer has requested. 659*77c1e3ccSAndroid Build Coastguard Worker2. Recommit your edits using the --amend flag, for example: 660*77c1e3ccSAndroid Build Coastguard Worker 661*77c1e3ccSAndroid Build Coastguard Worker~~~ 662*77c1e3ccSAndroid Build Coastguard Worker $ git commit -a --amend 663*77c1e3ccSAndroid Build Coastguard Worker~~~ 664*77c1e3ccSAndroid Build Coastguard Worker 665*77c1e3ccSAndroid Build Coastguard Worker3. Use the same git push command as above to upload to Gerrit again for another 666*77c1e3ccSAndroid Build Coastguard Worker review cycle. 667*77c1e3ccSAndroid Build Coastguard Worker 668*77c1e3ccSAndroid Build Coastguard WorkerIn general, you should not rebase your changes when doing updates in response to 669*77c1e3ccSAndroid Build Coastguard Workerreview. Doing so can make it harder to follow the evolution of your change in 670*77c1e3ccSAndroid Build Coastguard Workerthe diff view. 671*77c1e3ccSAndroid Build Coastguard Worker 672*77c1e3ccSAndroid Build Coastguard Worker### Submitting your change {#submitting-your-change} 673*77c1e3ccSAndroid Build Coastguard Worker 674*77c1e3ccSAndroid Build Coastguard WorkerOnce your change has been Approved and Verified, you can “submit” it through the 675*77c1e3ccSAndroid Build Coastguard WorkerGerrit UI. This will usually automatically rebase your change onto the branch 676*77c1e3ccSAndroid Build Coastguard Workerspecified. 677*77c1e3ccSAndroid Build Coastguard Worker 678*77c1e3ccSAndroid Build Coastguard WorkerSometimes this can’t be done automatically. If you run into this problem, you 679*77c1e3ccSAndroid Build Coastguard Workermust rebase your changes manually: 680*77c1e3ccSAndroid Build Coastguard Worker 681*77c1e3ccSAndroid Build Coastguard Worker~~~ 682*77c1e3ccSAndroid Build Coastguard Worker $ git fetch 683*77c1e3ccSAndroid Build Coastguard Worker $ git rebase origin/branchname 684*77c1e3ccSAndroid Build Coastguard Worker~~~ 685*77c1e3ccSAndroid Build Coastguard Worker 686*77c1e3ccSAndroid Build Coastguard WorkerIf there are any conflicts, resolve them as you normally would with Git. When 687*77c1e3ccSAndroid Build Coastguard Workeryou’re done, reupload your change. 688*77c1e3ccSAndroid Build Coastguard Worker 689*77c1e3ccSAndroid Build Coastguard Worker### Viewing the status of uploaded changes {#viewing-the-status-of-uploaded-changes} 690*77c1e3ccSAndroid Build Coastguard Worker 691*77c1e3ccSAndroid Build Coastguard WorkerTo check the status of a change that you uploaded, open 692*77c1e3ccSAndroid Build Coastguard Worker[Gerrit](https://aomedia-review.googlesource.com/), sign in, and click My > 693*77c1e3ccSAndroid Build Coastguard WorkerChanges. 694*77c1e3ccSAndroid Build Coastguard Worker 695*77c1e3ccSAndroid Build Coastguard Worker## Support {#support} 696*77c1e3ccSAndroid Build Coastguard Worker 697*77c1e3ccSAndroid Build Coastguard WorkerThis library is an open source project supported by its community. Please 698*77c1e3ccSAndroid Build Coastguard Workerplease email [email protected] for help. 699*77c1e3ccSAndroid Build Coastguard Worker 700*77c1e3ccSAndroid Build Coastguard Worker## Bug reports {#bug-reports} 701*77c1e3ccSAndroid Build Coastguard Worker 702*77c1e3ccSAndroid Build Coastguard WorkerBug reports can be filed in the Alliance for Open Media 703*77c1e3ccSAndroid Build Coastguard Worker[issue tracker](https://aomedia.issues.chromium.org/). For security reports, 704*77c1e3ccSAndroid Build Coastguard Workerselect 'Security report' from the Template dropdown. 705