blob: c4e7e6c27c431fcb4dac2edb31073251767181a3 [file] [log] [blame] [view]
Yunqing Wang8d139f12020-05-13 17:00:36 -07001README.md {#LREADME}
2=========
Tom Finegan9e57db22017-06-07 07:22:37 -07003# AV1 Codec Library
4
Tom Fineganbca03fc2017-12-08 07:47:06 -08005## Contents
61. [Building the lib and applications](#building-the-library-and-applications)
7 - [Prerequisites](#prerequisites)
Tom Finegan9007d342017-12-14 07:47:13 -08008 - [Get the code](#get-the-code)
Tom Fineganbca03fc2017-12-08 07:47:06 -08009 - [Basics](#basic-build)
10 - [Configuration options](#configuration-options)
11 - [Dylib builds](#dylib-builds)
12 - [Debugging](#debugging)
13 - [Cross compiling](#cross-compiling)
14 - [Sanitizer support](#sanitizers)
15 - [MSVC builds](#microsoft-visual-studio-builds)
16 - [Xcode builds](#xcode-builds)
17 - [Emscripten builds](#emscripten-builds)
Tom Fineganaa71f072018-01-31 06:54:01 -080018 - [Extra Build Flags](#extra-build-flags)
sdeng29c62152019-12-09 12:44:18 -080019 - [Build with VMAF support](#build-with-vmaf)
Tom Fineganbca03fc2017-12-08 07:47:06 -0800202. [Testing the library](#testing-the-av1-codec)
21 - [Basics](#testing-basics)
22 - [Unit tests](#1_unit-tests)
23 - [Example tests](#2_example-tests)
Tom Finegan9007d342017-12-14 07:47:13 -080024 - [Encoder tests](#3_encoder-tests)
Tom Fineganbca03fc2017-12-08 07:47:06 -080025 - [IDE hosted tests](#ide-hosted-tests)
26 - [Downloading test data](#downloading-the-test-data)
Wan-Teh Changcbf8a792018-05-11 11:22:06 -070027 - [Adding a new test data file](#adding-a-new-test-data-file)
Tom Finegan9007d342017-12-14 07:47:13 -080028 - [Additional test data](#additional-test-data)
Tom Fineganbca03fc2017-12-08 07:47:06 -080029 - [Sharded testing](#sharded-testing)
30 - [Running tests directly](#1_running-test_libaom-directly)
31 - [Running tests via CMake](#2_running-the-tests-via-the-cmake-build)
323. [Coding style](#coding-style)
Tom Finegan9007d342017-12-14 07:47:13 -0800334. [Submitting patches](#submitting-patches)
34 - [Login cookie](#login-cookie)
35 - [Contributor agreement](#contributor-agreement)
36 - [Testing your code](#testing-your-code)
37 - [Commit message hook](#commit-message-hook)
38 - [Upload your change](#upload-your-change)
39 - [Incorporating Reviewer Comments](#incorporating-reviewer-comments)
40 - [Submitting your change](#submitting-your-change)
41 - [Viewing change status](#viewing-the-status-of-uploaded-changes)
425. [Support](#support)
436. [Bug reports](#bug-reports)
Tom Fineganbca03fc2017-12-08 07:47:06 -080044
Yunqing Wang04caf8b2020-05-11 20:52:17 -070045## Building the library and applications {#building-the-library-and-applications}
Tom Finegan9e57db22017-06-07 07:22:37 -070046
Yunqing Wang04caf8b2020-05-11 20:52:17 -070047### Prerequisites {#prerequisites}
Tom Finegan9e57db22017-06-07 07:22:37 -070048
49 1. [CMake](https://cmake.org) version 3.5 or higher.
50 2. [Git](https://git-scm.com/).
51 3. [Perl](https://www.perl.org/).
52 4. For x86 targets, [yasm](http://yasm.tortall.net/), which is preferred, or a
Yaowu Xu5fc83f32019-11-05 15:41:05 -080053 recent version of [nasm](http://www.nasm.us/). If you download yasm with
54 the intention to work with Visual Studio, please download win32.exe or
55 win64.exe and rename it into yasm.exe. DO NOT download or use vsyasm.exe.
Yunqing Wangc7c0f272020-05-08 14:15:09 -070056 5. Building the documentation requires
57 [doxygen version 1.8.10 or newer](http://doxygen.org).
Tom Fineganff766cd2017-06-20 14:18:03 -070058 6. Building the unit tests requires [Python](https://www.python.org/).
Tom Finegan84d35992017-07-07 10:38:01 -070059 7. Emscripten builds require the portable
60 [EMSDK](https://kripken.github.io/emscripten-site/index.html).
Tom Finegan9e57db22017-06-07 07:22:37 -070061
Yunqing Wang04caf8b2020-05-11 20:52:17 -070062### Get the code {#get-the-code}
Tom Finegan9007d342017-12-14 07:47:13 -080063
64The AV1 library source code is stored in the Alliance for Open Media Git
65repository:
66
67~~~
68 $ git clone https://aomedia.googlesource.com/aom
69 # By default, the above command stores the source in the aom directory:
70 $ cd aom
71~~~
72
Yunqing Wang04caf8b2020-05-11 20:52:17 -070073### Basic build {#basic-build}
Tom Finegan9e57db22017-06-07 07:22:37 -070074
75CMake replaces the configure step typical of many projects. Running CMake will
76produce configuration and build files for the currently selected CMake
77generator. For most systems the default generator is Unix Makefiles. The basic
78form of a makefile build is the following:
79
Tom Finegan9007d342017-12-14 07:47:13 -080080~~~
Tom Finegan9e57db22017-06-07 07:22:37 -070081 $ cmake path/to/aom
82 $ make
Tom Finegan9007d342017-12-14 07:47:13 -080083~~~
Tom Finegan9e57db22017-06-07 07:22:37 -070084
85The above will generate a makefile build that produces the AV1 library and
86applications for the current host system after the make step completes
87successfully. The compiler chosen varies by host platform, but a general rule
88applies: On systems where cc and c++ are present in $PATH at the time CMake is
89run the generated build will use cc and c++ by default.
90
Yunqing Wang04caf8b2020-05-11 20:52:17 -070091### Configuration options {#configuration-options}
Tom Finegan9e57db22017-06-07 07:22:37 -070092
93The AV1 codec library has a great many configuration options. These come in two
94varieties:
95
96 1. Build system configuration options. These have the form `ENABLE_FEATURE`.
97 2. AV1 codec configuration options. These have the form `CONFIG_FEATURE`.
98
99Both types of options are set at the time CMake is run. The following example
Sebastien Alaiwan7c524d42018-01-02 10:10:55 +0100100enables ccache and disables the AV1 encoder:
Tom Finegan9e57db22017-06-07 07:22:37 -0700101
Tom Finegan007b2ee2017-07-11 14:47:06 -0700102~~~
Sebastien Alaiwan7c524d42018-01-02 10:10:55 +0100103 $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_AV1_ENCODER=0
Tom Finegan9e57db22017-06-07 07:22:37 -0700104 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700105~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700106
107The available configuration options are too numerous to list here. Build system
108configuration options can be found at the top of the CMakeLists.txt file found
109in the root of the AV1 repository, and AV1 codec configuration options can
110currently be found in the file `build/cmake/aom_config_defaults.cmake`.
111
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700112### Dylib builds {#dylib-builds}
Tom Finegan84f2d792017-06-15 23:06:44 -0700113
114A dylib (shared object) build of the AV1 codec library can be enabled via the
Tom Finegan007b2ee2017-07-11 14:47:06 -0700115CMake built in variable `BUILD_SHARED_LIBS`:
Tom Finegan84f2d792017-06-15 23:06:44 -0700116
Tom Finegan007b2ee2017-07-11 14:47:06 -0700117~~~
118 $ cmake path/to/aom -DBUILD_SHARED_LIBS=1
Tom Finegan84f2d792017-06-15 23:06:44 -0700119 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700120~~~
Tom Finegan84f2d792017-06-15 23:06:44 -0700121
122This is currently only supported on non-Windows targets.
123
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700124### Debugging {#debugging}
Tom Fineganfe809bd2017-09-27 11:54:24 -0700125
126Depending on the generator used there are multiple ways of going about
127debugging AV1 components. For single configuration generators like the Unix
128Makefiles generator, setting `CMAKE_BUILD_TYPE` to Debug is sufficient:
129
130~~~
131 $ cmake path/to/aom -DCMAKE_BUILD_TYPE=Debug
132~~~
133
134For Xcode, mainly because configuration controls for Xcode builds are buried two
Tom Finegand77323d2017-09-29 09:41:43 -0700135configuration windows deep and must be set for each subproject within the Xcode
136IDE individually, `CMAKE_CONFIGURATION_TYPES` should be set to Debug:
Tom Fineganfe809bd2017-09-27 11:54:24 -0700137
138~~~
139 $ cmake path/to/aom -G Xcode -DCMAKE_CONFIGURATION_TYPES=Debug
140~~~
141
142For Visual Studio the in-IDE configuration controls should be used. Simply set
143the IDE project configuration to Debug to allow for stepping through the code.
144
145In addition to the above it can sometimes be useful to debug only C and C++
Tom Finegand77323d2017-09-29 09:41:43 -0700146code. To disable all assembly code and intrinsics set `AOM_TARGET_CPU` to
Tom Fineganfe809bd2017-09-27 11:54:24 -0700147generic at generation time:
148
149~~~
150 $ cmake path/to/aom -DAOM_TARGET_CPU=generic
151~~~
152
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700153### Cross compiling {#cross-compiling}
Tom Finegan9e57db22017-06-07 07:22:37 -0700154
155For the purposes of building the AV1 codec and applications and relative to the
156scope of this guide, all builds for architectures differing from the native host
157architecture will be considered cross compiles. The AV1 CMake build handles
158cross compiling via the use of toolchain files included in the AV1 repository.
159The toolchain files available at the time of this writing are:
160
161 - arm64-ios.cmake
162 - arm64-linux-gcc.cmake
Martin Storsjo6a124ba2018-04-13 00:23:38 +0300163 - arm64-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700164 - armv7-ios.cmake
165 - armv7-linux-gcc.cmake
Martin Storsjo6a124ba2018-04-13 00:23:38 +0300166 - armv7-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700167 - armv7s-ios.cmake
168 - mips32-linux-gcc.cmake
169 - mips64-linux-gcc.cmake
170 - x86-ios-simulator.cmake
171 - x86-linux.cmake
172 - x86-macos.cmake
Tom Finegand77323d2017-09-29 09:41:43 -0700173 - x86-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700174 - x86\_64-ios-simulator.cmake
Tom Finegand77323d2017-09-29 09:41:43 -0700175 - x86\_64-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700176
177The following example demonstrates use of the x86-macos.cmake toolchain file on
178a x86\_64 MacOS host:
179
Tom Finegan007b2ee2017-07-11 14:47:06 -0700180~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700181 $ cmake path/to/aom \
182 -DCMAKE_TOOLCHAIN_FILE=path/to/aom/build/cmake/toolchains/x86-macos.cmake
183 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700184~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700185
186To build for an unlisted target creation of a new toolchain file is the best
187solution. The existing toolchain files can be used a starting point for a new
188toolchain file since each one exposes the basic requirements for toolchain files
189as used in the AV1 codec build.
190
191As a temporary work around an unoptimized AV1 configuration that builds only C
192and C++ sources can be produced using the following commands:
193
Tom Finegan007b2ee2017-07-11 14:47:06 -0700194~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700195 $ cmake path/to/aom -DAOM_TARGET_CPU=generic
196 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700197~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700198
199In addition to the above it's important to note that the toolchain files
200suffixed with gcc behave differently than the others. These toolchain files
201attempt to obey the $CROSS environment variable.
202
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700203### Sanitizers {#sanitizers}
Tom Finegan8a30baf2017-09-13 11:35:34 -0700204
205Sanitizer integration is built-in to the CMake build system. To enable a
206sanitizer, add `-DSANITIZE=<type>` to the CMake command line. For example, to
207enable address sanitizer:
208
209~~~
210 $ cmake path/to/aom -DSANITIZE=address
211 $ make
212~~~
213
214Sanitizers available vary by platform, target, and compiler. Consult your
215compiler documentation to determine which, if any, are available.
216
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700217### Microsoft Visual Studio builds {#microsoft-visual-studio-builds}
Tom Finegan9e57db22017-06-07 07:22:37 -0700218
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800219Building the AV1 codec library in Microsoft Visual Studio is supported. Visual
Wan-Teh Chang758ac372020-01-31 15:43:51 -0800220Studio 2017 (15.0) or later is required. The following example demonstrates
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800221generating projects and a solution for the Microsoft IDE:
Tom Finegan9e57db22017-06-07 07:22:37 -0700222
Tom Finegan007b2ee2017-07-11 14:47:06 -0700223~~~
Wan-Teh Chang758ac372020-01-31 15:43:51 -0800224 # This does not require a bash shell; Command Prompt (cmd.exe) is fine.
Wan-Teh Changd3527152020-03-31 15:48:31 -0700225 # This assumes the build host is a Windows x64 computer.
226
227 # To build with Visual Studio 2019 for the x64 target:
Wan-Teh Chang758ac372020-01-31 15:43:51 -0800228 $ cmake path/to/aom -G "Visual Studio 16 2019"
229 $ cmake --build .
Wan-Teh Changd3527152020-03-31 15:48:31 -0700230
231 # To build with Visual Studio 2019 for the 32-bit x86 target:
232 $ cmake path/to/aom -G "Visual Studio 16 2019" -A Win32
233 $ cmake --build .
234
235 # To build with Visual Studio 2017 for the x64 target:
236 $ cmake path/to/aom -G "Visual Studio 15 2017" -T host=x64 -A x64
237 $ cmake --build .
238
239 # To build with Visual Studio 2017 for the 32-bit x86 target:
240 $ cmake path/to/aom -G "Visual Studio 15 2017" -T host=x64
241 $ cmake --build .
Tom Finegan007b2ee2017-07-11 14:47:06 -0700242~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700243
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800244NOTE: The build system targets Windows 7 or later by compiling files with
245`-D_WIN32_WINNT=0x0601`.
246
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700247### Xcode builds {#xcode-builds}
Tom Finegan9e57db22017-06-07 07:22:37 -0700248
249Building the AV1 codec library in Xcode is supported. The following example
250demonstrates generating an Xcode project:
251
Tom Finegan007b2ee2017-07-11 14:47:06 -0700252~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700253 $ cmake path/to/aom -G Xcode
Tom Finegan007b2ee2017-07-11 14:47:06 -0700254~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700255
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700256### Emscripten builds {#emscripten-builds}
Tom Finegan84d35992017-07-07 10:38:01 -0700257
258Building the AV1 codec library with Emscripten is supported. Typically this is
259used to hook into the AOMAnalyzer GUI application. These instructions focus on
260using the inspector with AOMAnalyzer, but all tools can be built with
261Emscripten.
262
263It is assumed here that you have already downloaded and installed the EMSDK,
264installed and activated at least one toolchain, and setup your environment
265appropriately using the emsdk\_env script.
266
2671. Download [AOMAnalyzer](https://people.xiph.org/~mbebenita/analyzer/).
268
2692. Configure the build:
270
271~~~
272 $ cmake path/to/aom \
273 -DENABLE_CCACHE=1 \
274 -DAOM_TARGET_CPU=generic \
275 -DENABLE_DOCS=0 \
Tom Finegand9647f22018-06-19 13:27:57 -0700276 -DENABLE_TESTS=0 \
Tom Finegan84d35992017-07-07 10:38:01 -0700277 -DCONFIG_ACCOUNTING=1 \
278 -DCONFIG_INSPECTION=1 \
279 -DCONFIG_MULTITHREAD=0 \
280 -DCONFIG_RUNTIME_CPU_DETECT=0 \
Tom Finegan84d35992017-07-07 10:38:01 -0700281 -DCONFIG_WEBM_IO=0 \
282 -DCMAKE_TOOLCHAIN_FILE=path/to/emsdk-portable/.../Emscripten.cmake
283~~~
284
2853. Build it: run make if that's your generator of choice:
286
287~~~
288 $ make inspect
289~~~
290
2914. Run the analyzer:
292
293~~~
294 # inspect.js is in the examples sub directory of the directory in which you
295 # executed cmake.
296 $ path/to/AOMAnalyzer path/to/examples/inspect.js path/to/av1/input/file
297~~~
298
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700299### Extra build flags {#extra-build-flags}
Tom Fineganaa71f072018-01-31 06:54:01 -0800300
301Three variables allow for passing of additional flags to the build system.
302
303- AOM\_EXTRA\_C\_FLAGS
304- AOM\_EXTRA\_CXX\_FLAGS
305- AOM\_EXTRA\_EXE\_LINKER\_FLAGS
306
307The build system attempts to ensure the flags passed through the above variables
308are passed to tools last in order to allow for override of default behavior.
309These flags can be used, for example, to enable asserts in a release build:
310
311~~~
312 $ cmake path/to/aom \
313 -DCMAKE_BUILD_TYPE=Release \
314 -DAOM_EXTRA_C_FLAGS=-UNDEBUG \
315 -DAOM_EXTRA_CXX_FLAGS=-UNDEBUG
316~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700317
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700318### Build with VMAF support {#build-with-vmaf}
sdeng29c62152019-12-09 12:44:18 -0800319
320After installing
sdeng@google.comf13555b2020-11-30 15:15:54 -0800321[libvmaf.a](https://github.com/Netflix/vmaf/tree/master/libvmaf),
sdeng29c62152019-12-09 12:44:18 -0800322you can use it with the encoder:
323
324~~~
325 $ cmake path/to/aom -DCONFIG_TUNE_VMAF=1
326~~~
327
328Please note that the default VMAF model
Sai Dengb53a4d72021-03-17 15:15:10 -0700329("/usr/local/share/model/vmaf_v0.6.1.json")
sdeng29c62152019-12-09 12:44:18 -0800330will be used unless you set the following flag when running the encoder:
331
332~~~
333 # --vmaf-model-path=path/to/model
334~~~
335
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700336## Testing the AV1 codec {#testing-the-av1-codec}
Tom Finegan9e57db22017-06-07 07:22:37 -0700337
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700338### Testing basics {#testing-basics}
Tom Finegan9e57db22017-06-07 07:22:37 -0700339
Tom Finegan9007d342017-12-14 07:47:13 -0800340There are several methods of testing the AV1 codec. All of these methods require
341the presence of the AV1 source code and a working build of the AV1 library and
342applications.
Tom Finegan9e57db22017-06-07 07:22:37 -0700343
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700344#### 1. Unit tests: {#1_unit-tests}
Tom Finegan9e57db22017-06-07 07:22:37 -0700345
346The unit tests can be run at build time:
347
Tom Finegan007b2ee2017-07-11 14:47:06 -0700348~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700349 # Before running the make command the LIBAOM_TEST_DATA_PATH environment
350 # variable should be set to avoid downloading the test files to the
351 # cmake build configuration directory.
352 $ cmake path/to/aom
353 # Note: The AV1 CMake build creates many test targets. Running make
354 # with multiple jobs will speed up the test run significantly.
355 $ make runtests
Tom Finegan007b2ee2017-07-11 14:47:06 -0700356~~~
357
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700358#### 2. Example tests: {#2_example-tests}
Tom Finegan9e57db22017-06-07 07:22:37 -0700359
360The example tests require a bash shell and can be run in the following manner:
361
Tom Finegan007b2ee2017-07-11 14:47:06 -0700362~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700363 # See the note above about LIBAOM_TEST_DATA_PATH above.
364 $ cmake path/to/aom
365 $ make
366 # It's best to build the testdata target using many make jobs.
367 # Running it like this will verify and download (if necessary)
368 # one at a time, which takes a while.
369 $ make testdata
370 $ path/to/aom/test/examples.sh --bin-path examples
Tom Finegan007b2ee2017-07-11 14:47:06 -0700371~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700372
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700373#### 3. Encoder tests: {#3_encoder-tests}
Tom Finegan9007d342017-12-14 07:47:13 -0800374
375When making a change to the encoder run encoder tests to confirm that your
376change has a positive or negligible impact on encode quality. When running these
377tests the build configuration should be changed to enable internal encoder
378statistics:
379
380~~~
381 $ cmake path/to/aom -DCONFIG_INTERNAL_STATS=1
382 $ make
383~~~
384
385The repository contains scripts intended to make running these tests as simple
386as possible. The following example demonstrates creating a set of baseline clips
387for comparison to results produced after making your change to libaom:
388
389~~~
390 # This will encode all Y4M files in the current directory using the
391 # settings specified to create the encoder baseline statistical data:
392 $ cd path/to/test/inputs
393 # This command line assumes that run_encodes.sh, its helper script
394 # best_encode.sh, and the aomenc you intend to test are all within a
395 # directory in your PATH.
396 $ run_encodes.sh 200 500 50 baseline
397~~~
398
399After making your change and creating the baseline clips, you'll need to run
400encodes that include your change(s) to confirm that things are working as
401intended:
402
403~~~
404 # This will encode all Y4M files in the current directory using the
405 # settings specified to create the statistical data for your change:
406 $ cd path/to/test/inputs
407 # This command line assumes that run_encodes.sh, its helper script
408 # best_encode.sh, and the aomenc you intend to test are all within a
409 # directory in your PATH.
410 $ run_encodes.sh 200 500 50 mytweak
411~~~
412
413After creating both data sets you can use `test/visual_metrics.py` to generate a
414report that can be viewed in a web browser:
415
416~~~
417 $ visual_metrics.py metrics_template.html "*stt" baseline mytweak \
418 > mytweak.html
419~~~
420
421You can view the report by opening mytweak.html in a web browser.
422
423
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700424### IDE hosted tests {#ide-hosted-tests}
Tom Finegan9e57db22017-06-07 07:22:37 -0700425
426By default the generated projects files created by CMake will not include the
427runtests and testdata rules when generating for IDEs like Microsoft Visual
428Studio and Xcode. This is done to avoid intolerably long build cycles in the
429IDEs-- IDE behavior is to build all targets when selecting the build project
430options in MSVS and Xcode. To enable the test rules in IDEs the
431`ENABLE_IDE_TEST_HOSTING` variable must be enabled at CMake generation time:
432
Tom Finegan007b2ee2017-07-11 14:47:06 -0700433~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700434 # This example uses Xcode. To get a list of the generators
435 # available, run cmake with the -G argument missing its
436 # value.
437 $ cmake path/to/aom -DENABLE_IDE_TEST_HOSTING=1 -G Xcode
Tom Finegan007b2ee2017-07-11 14:47:06 -0700438~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700439
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700440### Downloading the test data {#downloading-the-test-data}
Tom Finegan9e57db22017-06-07 07:22:37 -0700441
442The fastest and easiest way to obtain the test data is to use CMake to generate
443a build using the Unix Makefiles generator, and then to build only the testdata
444rule:
445
Tom Finegan007b2ee2017-07-11 14:47:06 -0700446~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700447 $ cmake path/to/aom -G "Unix Makefiles"
448 # 28 is used because there are 28 test files as of this writing.
449 $ make -j28 testdata
Tom Finegan007b2ee2017-07-11 14:47:06 -0700450~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700451
452The above make command will only download and verify the test data.
453
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700454### Adding a new test data file {#adding-a-new-test-data-file}
Wan-Teh Changcbf8a792018-05-11 11:22:06 -0700455
456First, add the new test data file to the `aom-test-data` bucket of the
457`aomedia-testing` project on Google Cloud Platform. You may need to ask someone
458with the necessary access permissions to do this for you.
459
Wan-Teh Changec81dee2018-07-24 16:05:39 -0700460NOTE: When a new test data file is added to the `aom-test-data` bucket, its
461"Public access" is initially "Not public". We need to change its
Wan-Teh Chang4f21f692018-08-06 14:08:19 -0700462"Public access" to "Public" by using the following
463[`gsutil`](https://cloud.google.com/storage/docs/gsutil_install) command:
464~~~
465 $ gsutil acl ch -g all:R gs://aom-test-data/test-data-file-name
466~~~
467This command grants the `AllUsers` group READ access to the file named
468"test-data-file-name" in the `aom-test-data` bucket.
Wan-Teh Changec81dee2018-07-24 16:05:39 -0700469
Wan-Teh Changcbf8a792018-05-11 11:22:06 -0700470Once the new test data file has been added to `aom-test-data`, create a CL to
471add the name of the new test data file to `test/test_data_util.cmake` and add
472the SHA1 checksum of the new test data file to `test/test-data.sha1`. (The SHA1
473checksum of a file can be calculated by running the `sha1sum` command on the
474file.)
475
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700476### Additional test data {#additional-test-data}
Tom Finegan9007d342017-12-14 07:47:13 -0800477
478The test data mentioned above is strictly intended for unit testing.
479
480Additional input data for testing the encoder can be obtained from:
481https://media.xiph.org/video/derf/
482
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700483### Sharded testing {#sharded-testing}
Tom Finegan007b2ee2017-07-11 14:47:06 -0700484
485The AV1 codec library unit tests are built upon gtest which supports sharding of
486test jobs. Sharded test runs can be achieved in a couple of ways.
487
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700488#### 1. Running test\_libaom directly: {#1_running-test_libaom-directly}
Tom Finegan007b2ee2017-07-11 14:47:06 -0700489
490~~~
James Zern47cd7be2018-03-16 18:12:10 -0700491 # Set the environment variable GTEST_TOTAL_SHARDS to control the number of
492 # shards.
493 $ export GTEST_TOTAL_SHARDS=10
Tom Finegan007b2ee2017-07-11 14:47:06 -0700494 # (GTEST shard indexing is 0 based).
James Zern515c8692017-08-30 16:32:28 -0700495 $ seq 0 $(( $GTEST_TOTAL_SHARDS - 1 )) \
496 | xargs -n 1 -P 0 -I{} env GTEST_SHARD_INDEX={} ./test_libaom
Tom Finegan007b2ee2017-07-11 14:47:06 -0700497~~~
498
499To create a test shard for each CPU core available on the current system set
500`GTEST_TOTAL_SHARDS` to the number of CPU cores on your system minus one.
501
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700502#### 2. Running the tests via the CMake build: {#2_running-the-tests-via-the-cmake-build}
Tom Finegan007b2ee2017-07-11 14:47:06 -0700503
504~~~
505 # For IDE based builds, ENABLE_IDE_TEST_HOSTING must be enabled. See
506 # the IDE hosted tests section above for more information. If the IDE
507 # supports building targets concurrently tests will be sharded by default.
508
509 # For make and ninja builds the -j parameter controls the number of shards
510 # at test run time. This example will run the tests using 10 shards via
511 # make.
512 $ make -j10 runtests
513~~~
514
515The maximum number of test targets that can run concurrently is determined by
516the number of CPUs on the system where the build is configured as detected by
517CMake. A system with 24 cores can run 24 test shards using a value of 24 with
518the `-j` parameter. When CMake is unable to detect the number of cores 10 shards
519is the default maximum value.
Tom Finegan9e57db22017-06-07 07:22:37 -0700520
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700521## Coding style {#coding-style}
Tom Finegan9e57db22017-06-07 07:22:37 -0700522
Tom Finegan9007d342017-12-14 07:47:13 -0800523We are using the Google C Coding Style defined by the
524[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
525
Tom Finegan9e57db22017-06-07 07:22:37 -0700526The coding style used by this project is enforced with clang-format using the
Tom Finegan9007d342017-12-14 07:47:13 -0800527configuration contained in the
528[.clang-format](https://chromium.googlesource.com/webm/aom/+/master/.clang-format)
529file in the root of the repository.
530
531You can download clang-format using your system's package manager, or directly
532from [llvm.org](http://llvm.org/releases/download.html). You can also view the
533[documentation](https://clang.llvm.org/docs/ClangFormat.html) on llvm.org.
534Output from clang-format varies by clang-format version, for best results your
535version should match the one used on Jenkins. You can find the clang-format
536version by reading the comment in the `.clang-format` file linked above.
Tom Finegan9e57db22017-06-07 07:22:37 -0700537
538Before pushing changes for review you can format your code with:
539
Tom Finegan007b2ee2017-07-11 14:47:06 -0700540~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700541 # Apply clang-format to modified .c, .h and .cc files
542 $ clang-format -i --style=file \
543 $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc')
Tom Finegan007b2ee2017-07-11 14:47:06 -0700544~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700545
546Check the .clang-format file for the version used to generate it if there is any
547difference between your local formatting and the review system.
548
Tom Finegan9007d342017-12-14 07:47:13 -0800549Some Git installations have clang-format integration. Here are some examples:
550
551~~~
552 # Apply clang-format to all staged changes:
553 $ git clang-format
554
555 # Clang format all staged and unstaged changes:
556 $ git clang-format -f
557
558 # Clang format all staged and unstaged changes interactively:
559 $ git clang-format -f -p
560~~~
561
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700562## Submitting patches {#submitting-patches}
Tom Finegan9007d342017-12-14 07:47:13 -0800563
564We manage the submission of patches using the
565[Gerrit](https://www.gerritcodereview.com/) code review tool. This tool
566implements a workflow on top of the Git version control system to ensure that
567all changes get peer reviewed and tested prior to their distribution.
568
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700569### Login cookie {#login-cookie}
Tom Finegan9007d342017-12-14 07:47:13 -0800570
571Browse to [AOMedia Git index](https://aomedia.googlesource.com/) and login with
572your account (Gmail credentials, for example). Next, follow the
573`Generate Password` Password link at the top of the page. You’ll be given
574instructions for creating a cookie to use with our Git repos.
575
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700576### Contributor agreement {#contributor-agreement}
Tom Finegan9007d342017-12-14 07:47:13 -0800577
578You will be required to execute a
579[contributor agreement](http://aomedia.org/license) to ensure that the AOMedia
580Project has the right to distribute your changes.
581
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700582### Testing your code {#testing-your-code}
Tom Finegan9007d342017-12-14 07:47:13 -0800583
584The testing basics are covered in the [testing section](#testing-the-av1-codec)
585above.
586
587In addition to the local tests, many more (e.g. asan, tsan, valgrind) will run
588through Jenkins instances upon upload to gerrit.
589
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700590### Commit message hook {#commit-message-hook}
Tom Finegan9007d342017-12-14 07:47:13 -0800591
592Gerrit requires that each submission include a unique Change-Id. You can assign
593one manually using git commit --amend, but it’s easier to automate it with the
594commit-msg hook provided by Gerrit.
595
596Copy commit-msg to the `.git/hooks` directory of your local repo. Here's an
597example:
598
599~~~
600 $ curl -Lo aom/.git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg
601
602 # Next, ensure that the downloaded commit-msg script is executable:
603 $ chmod u+x aom/.git/hooks/commit-msg
604~~~
605
606See the Gerrit
607[documentation](https://gerrit-review.googlesource.com/Documentation/user-changeid.html)
608for more information.
609
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700610### Upload your change {#upload-your-change}
Tom Finegan9007d342017-12-14 07:47:13 -0800611
612The command line to upload your patch looks like this:
613
614~~~
615 $ git push https://aomedia-review.googlesource.com/aom HEAD:refs/for/master
616~~~
617
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700618### Incorporating reviewer comments {#incorporating-reviewer-comments}
Tom Finegan9007d342017-12-14 07:47:13 -0800619
620If you previously uploaded a change to Gerrit and the Approver has asked for
621changes, follow these steps:
622
6231. Edit the files to make the changes the reviewer has requested.
6242. Recommit your edits using the --amend flag, for example:
625
626~~~
627 $ git commit -a --amend
628~~~
629
6303. Use the same git push command as above to upload to Gerrit again for another
631 review cycle.
632
633In general, you should not rebase your changes when doing updates in response to
634review. Doing so can make it harder to follow the evolution of your change in
635the diff view.
636
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700637### Submitting your change {#submitting-your-change}
Tom Finegan9007d342017-12-14 07:47:13 -0800638
639Once your change has been Approved and Verified, you can “submit” it through the
640Gerrit UI. This will usually automatically rebase your change onto the branch
641specified.
642
643Sometimes this can’t be done automatically. If you run into this problem, you
644must rebase your changes manually:
645
646~~~
647 $ git fetch
648 $ git rebase origin/branchname
649~~~
650
651If there are any conflicts, resolve them as you normally would with Git. When
652you’re done, reupload your change.
653
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700654### Viewing the status of uploaded changes {#viewing-the-status-of-uploaded-changes}
Tom Finegan9007d342017-12-14 07:47:13 -0800655
656To check the status of a change that you uploaded, open
657[Gerrit](https://aomedia-review.googlesource.com/), sign in, and click My >
658Changes.
Tom Finegan9e57db22017-06-07 07:22:37 -0700659
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700660## Support {#support}
Tom Finegan9e57db22017-06-07 07:22:37 -0700661
662This library is an open source project supported by its community. Please
663please email aomediacodec@jointdevelopment.kavi.com for help.
664
Yunqing Wang04caf8b2020-05-11 20:52:17 -0700665## Bug reports {#bug-reports}
Tom Finegan9e57db22017-06-07 07:22:37 -0700666
667Bug reports can be filed in the Alliance for Open Media
668[issue tracker](https://bugs.chromium.org/p/aomedia/issues/list).