blob: e8b06e12e4690868aaff153e64adf3deb7a4f557 [file] [log] [blame] [view]
Tom Finegan9e57db22017-06-07 07:22:37 -07001# AV1 Codec Library
2
Tom Fineganbca03fc2017-12-08 07:47:06 -08003## Contents
41. [Building the lib and applications](#building-the-library-and-applications)
5 - [Prerequisites](#prerequisites)
Tom Finegan9007d342017-12-14 07:47:13 -08006 - [Get the code](#get-the-code)
Tom Fineganbca03fc2017-12-08 07:47:06 -08007 - [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 Fineganaa71f072018-01-31 06:54:01 -080016 - [Extra Build Flags](#extra-build-flags)
Tom Fineganbca03fc2017-12-08 07:47:06 -0800172. [Testing the library](#testing-the-av1-codec)
18 - [Basics](#testing-basics)
19 - [Unit tests](#1_unit-tests)
20 - [Example tests](#2_example-tests)
Tom Finegan9007d342017-12-14 07:47:13 -080021 - [Encoder tests](#3_encoder-tests)
Tom Fineganbca03fc2017-12-08 07:47:06 -080022 - [IDE hosted tests](#ide-hosted-tests)
23 - [Downloading test data](#downloading-the-test-data)
Wan-Teh Changcbf8a792018-05-11 11:22:06 -070024 - [Adding a new test data file](#adding-a-new-test-data-file)
Tom Finegan9007d342017-12-14 07:47:13 -080025 - [Additional test data](#additional-test-data)
Tom Fineganbca03fc2017-12-08 07:47:06 -080026 - [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)
293. [Coding style](#coding-style)
Tom Finegan9007d342017-12-14 07:47:13 -0800304. [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)
395. [Support](#support)
406. [Bug reports](#bug-reports)
Tom Fineganbca03fc2017-12-08 07:47:06 -080041
Tom Finegan9e57db22017-06-07 07:22:37 -070042## 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
Yaowu Xu5fc83f32019-11-05 15:41:05 -080050 recent version of [nasm](http://www.nasm.us/). If you download yasm with
51 the intention to work with Visual Studio, please download win32.exe or
52 win64.exe and rename it into yasm.exe. DO NOT download or use vsyasm.exe.
Tom Finegan9e57db22017-06-07 07:22:37 -070053 5. Building the documentation requires [doxygen](http://doxygen.org).
Tom Fineganff766cd2017-06-20 14:18:03 -070054 6. Building the unit tests requires [Python](https://www.python.org/).
Tom Finegan84d35992017-07-07 10:38:01 -070055 7. Emscripten builds require the portable
56 [EMSDK](https://kripken.github.io/emscripten-site/index.html).
Tom Finegan9e57db22017-06-07 07:22:37 -070057
Tom Finegan9007d342017-12-14 07:47:13 -080058### Get the code
59
60The AV1 library source code is stored in the Alliance for Open Media Git
61repository:
62
63~~~
64 $ git clone https://aomedia.googlesource.com/aom
65 # By default, the above command stores the source in the aom directory:
66 $ cd aom
67~~~
68
Tom Finegan9e57db22017-06-07 07:22:37 -070069### Basic build
70
71CMake replaces the configure step typical of many projects. Running CMake will
72produce configuration and build files for the currently selected CMake
73generator. For most systems the default generator is Unix Makefiles. The basic
74form of a makefile build is the following:
75
Tom Finegan9007d342017-12-14 07:47:13 -080076~~~
Tom Finegan9e57db22017-06-07 07:22:37 -070077 $ cmake path/to/aom
78 $ make
Tom Finegan9007d342017-12-14 07:47:13 -080079~~~
Tom Finegan9e57db22017-06-07 07:22:37 -070080
81The above will generate a makefile build that produces the AV1 library and
82applications for the current host system after the make step completes
83successfully. The compiler chosen varies by host platform, but a general rule
84applies: On systems where cc and c++ are present in $PATH at the time CMake is
85run the generated build will use cc and c++ by default.
86
87### Configuration options
88
89The AV1 codec library has a great many configuration options. These come in two
90varieties:
91
92 1. Build system configuration options. These have the form `ENABLE_FEATURE`.
93 2. AV1 codec configuration options. These have the form `CONFIG_FEATURE`.
94
95Both types of options are set at the time CMake is run. The following example
Sebastien Alaiwan7c524d42018-01-02 10:10:55 +010096enables ccache and disables the AV1 encoder:
Tom Finegan9e57db22017-06-07 07:22:37 -070097
Tom Finegan007b2ee2017-07-11 14:47:06 -070098~~~
Sebastien Alaiwan7c524d42018-01-02 10:10:55 +010099 $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_AV1_ENCODER=0
Tom Finegan9e57db22017-06-07 07:22:37 -0700100 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700101~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700102
103The available configuration options are too numerous to list here. Build system
104configuration options can be found at the top of the CMakeLists.txt file found
105in the root of the AV1 repository, and AV1 codec configuration options can
106currently be found in the file `build/cmake/aom_config_defaults.cmake`.
107
Tom Finegan84f2d792017-06-15 23:06:44 -0700108### Dylib builds
109
110A dylib (shared object) build of the AV1 codec library can be enabled via the
Tom Finegan007b2ee2017-07-11 14:47:06 -0700111CMake built in variable `BUILD_SHARED_LIBS`:
Tom Finegan84f2d792017-06-15 23:06:44 -0700112
Tom Finegan007b2ee2017-07-11 14:47:06 -0700113~~~
114 $ cmake path/to/aom -DBUILD_SHARED_LIBS=1
Tom Finegan84f2d792017-06-15 23:06:44 -0700115 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700116~~~
Tom Finegan84f2d792017-06-15 23:06:44 -0700117
118This is currently only supported on non-Windows targets.
119
Tom Fineganfe809bd2017-09-27 11:54:24 -0700120### Debugging
121
122Depending on the generator used there are multiple ways of going about
123debugging AV1 components. For single configuration generators like the Unix
124Makefiles generator, setting `CMAKE_BUILD_TYPE` to Debug is sufficient:
125
126~~~
127 $ cmake path/to/aom -DCMAKE_BUILD_TYPE=Debug
128~~~
129
130For Xcode, mainly because configuration controls for Xcode builds are buried two
Tom Finegand77323d2017-09-29 09:41:43 -0700131configuration windows deep and must be set for each subproject within the Xcode
132IDE individually, `CMAKE_CONFIGURATION_TYPES` should be set to Debug:
Tom Fineganfe809bd2017-09-27 11:54:24 -0700133
134~~~
135 $ cmake path/to/aom -G Xcode -DCMAKE_CONFIGURATION_TYPES=Debug
136~~~
137
138For Visual Studio the in-IDE configuration controls should be used. Simply set
139the IDE project configuration to Debug to allow for stepping through the code.
140
141In addition to the above it can sometimes be useful to debug only C and C++
Tom Finegand77323d2017-09-29 09:41:43 -0700142code. To disable all assembly code and intrinsics set `AOM_TARGET_CPU` to
Tom Fineganfe809bd2017-09-27 11:54:24 -0700143generic at generation time:
144
145~~~
146 $ cmake path/to/aom -DAOM_TARGET_CPU=generic
147~~~
148
Tom Finegan9e57db22017-06-07 07:22:37 -0700149### Cross compiling
150
151For the purposes of building the AV1 codec and applications and relative to the
152scope of this guide, all builds for architectures differing from the native host
153architecture will be considered cross compiles. The AV1 CMake build handles
154cross compiling via the use of toolchain files included in the AV1 repository.
155The toolchain files available at the time of this writing are:
156
157 - arm64-ios.cmake
158 - arm64-linux-gcc.cmake
Martin Storsjo6a124ba2018-04-13 00:23:38 +0300159 - arm64-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700160 - armv7-ios.cmake
161 - armv7-linux-gcc.cmake
Martin Storsjo6a124ba2018-04-13 00:23:38 +0300162 - armv7-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700163 - armv7s-ios.cmake
164 - mips32-linux-gcc.cmake
165 - mips64-linux-gcc.cmake
166 - x86-ios-simulator.cmake
167 - x86-linux.cmake
168 - x86-macos.cmake
Tom Finegand77323d2017-09-29 09:41:43 -0700169 - x86-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700170 - x86\_64-ios-simulator.cmake
Tom Finegand77323d2017-09-29 09:41:43 -0700171 - x86\_64-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700172
173The following example demonstrates use of the x86-macos.cmake toolchain file on
174a x86\_64 MacOS host:
175
Tom Finegan007b2ee2017-07-11 14:47:06 -0700176~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700177 $ cmake path/to/aom \
178 -DCMAKE_TOOLCHAIN_FILE=path/to/aom/build/cmake/toolchains/x86-macos.cmake
179 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700180~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700181
182To build for an unlisted target creation of a new toolchain file is the best
183solution. The existing toolchain files can be used a starting point for a new
184toolchain file since each one exposes the basic requirements for toolchain files
185as used in the AV1 codec build.
186
187As a temporary work around an unoptimized AV1 configuration that builds only C
188and C++ sources can be produced using the following commands:
189
Tom Finegan007b2ee2017-07-11 14:47:06 -0700190~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700191 $ cmake path/to/aom -DAOM_TARGET_CPU=generic
192 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700193~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700194
195In addition to the above it's important to note that the toolchain files
196suffixed with gcc behave differently than the others. These toolchain files
197attempt to obey the $CROSS environment variable.
198
Tom Finegan8a30baf2017-09-13 11:35:34 -0700199### Sanitizers
200
201Sanitizer integration is built-in to the CMake build system. To enable a
202sanitizer, add `-DSANITIZE=<type>` to the CMake command line. For example, to
203enable address sanitizer:
204
205~~~
206 $ cmake path/to/aom -DSANITIZE=address
207 $ make
208~~~
209
210Sanitizers available vary by platform, target, and compiler. Consult your
211compiler documentation to determine which, if any, are available.
212
Tom Finegan9e57db22017-06-07 07:22:37 -0700213### Microsoft Visual Studio builds
214
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800215Building the AV1 codec library in Microsoft Visual Studio is supported. Visual
216Studio 2015 (14.0) or later is required. The following example demonstrates
217generating projects and a solution for the Microsoft IDE:
Tom Finegan9e57db22017-06-07 07:22:37 -0700218
Tom Finegan007b2ee2017-07-11 14:47:06 -0700219~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700220 # This does not require a bash shell; command.exe is fine.
221 $ cmake path/to/aom -G "Visual Studio 15 2017"
Tom Finegan007b2ee2017-07-11 14:47:06 -0700222~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700223
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800224NOTE: The build system targets Windows 7 or later by compiling files with
225`-D_WIN32_WINNT=0x0601`.
226
Tom Finegan9e57db22017-06-07 07:22:37 -0700227### Xcode builds
228
229Building the AV1 codec library in Xcode is supported. The following example
230demonstrates generating an Xcode project:
231
Tom Finegan007b2ee2017-07-11 14:47:06 -0700232~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700233 $ cmake path/to/aom -G Xcode
Tom Finegan007b2ee2017-07-11 14:47:06 -0700234~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700235
Tom Finegan84d35992017-07-07 10:38:01 -0700236### Emscripten builds
237
238Building the AV1 codec library with Emscripten is supported. Typically this is
239used to hook into the AOMAnalyzer GUI application. These instructions focus on
240using the inspector with AOMAnalyzer, but all tools can be built with
241Emscripten.
242
243It is assumed here that you have already downloaded and installed the EMSDK,
244installed and activated at least one toolchain, and setup your environment
245appropriately using the emsdk\_env script.
246
2471. Download [AOMAnalyzer](https://people.xiph.org/~mbebenita/analyzer/).
248
2492. Configure the build:
250
251~~~
252 $ cmake path/to/aom \
253 -DENABLE_CCACHE=1 \
254 -DAOM_TARGET_CPU=generic \
255 -DENABLE_DOCS=0 \
Tom Finegand9647f22018-06-19 13:27:57 -0700256 -DENABLE_TESTS=0 \
Tom Finegan84d35992017-07-07 10:38:01 -0700257 -DCONFIG_ACCOUNTING=1 \
258 -DCONFIG_INSPECTION=1 \
259 -DCONFIG_MULTITHREAD=0 \
260 -DCONFIG_RUNTIME_CPU_DETECT=0 \
Tom Finegan84d35992017-07-07 10:38:01 -0700261 -DCONFIG_WEBM_IO=0 \
262 -DCMAKE_TOOLCHAIN_FILE=path/to/emsdk-portable/.../Emscripten.cmake
263~~~
264
2653. Build it: run make if that's your generator of choice:
266
267~~~
268 $ make inspect
269~~~
270
2714. Run the analyzer:
272
273~~~
274 # inspect.js is in the examples sub directory of the directory in which you
275 # executed cmake.
276 $ path/to/AOMAnalyzer path/to/examples/inspect.js path/to/av1/input/file
277~~~
278
Tom Fineganaa71f072018-01-31 06:54:01 -0800279### Extra build flags
280
281Three variables allow for passing of additional flags to the build system.
282
283- AOM\_EXTRA\_C\_FLAGS
284- AOM\_EXTRA\_CXX\_FLAGS
285- AOM\_EXTRA\_EXE\_LINKER\_FLAGS
286
287The build system attempts to ensure the flags passed through the above variables
288are passed to tools last in order to allow for override of default behavior.
289These flags can be used, for example, to enable asserts in a release build:
290
291~~~
292 $ cmake path/to/aom \
293 -DCMAKE_BUILD_TYPE=Release \
294 -DAOM_EXTRA_C_FLAGS=-UNDEBUG \
295 -DAOM_EXTRA_CXX_FLAGS=-UNDEBUG
296~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700297
298## Testing the AV1 codec
299
300### Testing basics
301
Tom Finegan9007d342017-12-14 07:47:13 -0800302There are several methods of testing the AV1 codec. All of these methods require
303the presence of the AV1 source code and a working build of the AV1 library and
304applications.
Tom Finegan9e57db22017-06-07 07:22:37 -0700305
Tom Finegan007b2ee2017-07-11 14:47:06 -0700306#### 1. Unit tests:
Tom Finegan9e57db22017-06-07 07:22:37 -0700307
308The unit tests can be run at build time:
309
Tom Finegan007b2ee2017-07-11 14:47:06 -0700310~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700311 # Before running the make command the LIBAOM_TEST_DATA_PATH environment
312 # variable should be set to avoid downloading the test files to the
313 # cmake build configuration directory.
314 $ cmake path/to/aom
315 # Note: The AV1 CMake build creates many test targets. Running make
316 # with multiple jobs will speed up the test run significantly.
317 $ make runtests
Tom Finegan007b2ee2017-07-11 14:47:06 -0700318~~~
319
320#### 2. Example tests:
Tom Finegan9e57db22017-06-07 07:22:37 -0700321
322The example tests require a bash shell and can be run in the following manner:
323
Tom Finegan007b2ee2017-07-11 14:47:06 -0700324~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700325 # See the note above about LIBAOM_TEST_DATA_PATH above.
326 $ cmake path/to/aom
327 $ make
328 # It's best to build the testdata target using many make jobs.
329 # Running it like this will verify and download (if necessary)
330 # one at a time, which takes a while.
331 $ make testdata
332 $ path/to/aom/test/examples.sh --bin-path examples
Tom Finegan007b2ee2017-07-11 14:47:06 -0700333~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700334
Tom Finegan9007d342017-12-14 07:47:13 -0800335#### 3. Encoder tests:
336
337When making a change to the encoder run encoder tests to confirm that your
338change has a positive or negligible impact on encode quality. When running these
339tests the build configuration should be changed to enable internal encoder
340statistics:
341
342~~~
343 $ cmake path/to/aom -DCONFIG_INTERNAL_STATS=1
344 $ make
345~~~
346
347The repository contains scripts intended to make running these tests as simple
348as possible. The following example demonstrates creating a set of baseline clips
349for comparison to results produced after making your change to libaom:
350
351~~~
352 # This will encode all Y4M files in the current directory using the
353 # settings specified to create the encoder baseline statistical data:
354 $ cd path/to/test/inputs
355 # This command line assumes that run_encodes.sh, its helper script
356 # best_encode.sh, and the aomenc you intend to test are all within a
357 # directory in your PATH.
358 $ run_encodes.sh 200 500 50 baseline
359~~~
360
361After making your change and creating the baseline clips, you'll need to run
362encodes that include your change(s) to confirm that things are working as
363intended:
364
365~~~
366 # This will encode all Y4M files in the current directory using the
367 # settings specified to create the statistical data for your change:
368 $ cd path/to/test/inputs
369 # This command line assumes that run_encodes.sh, its helper script
370 # best_encode.sh, and the aomenc you intend to test are all within a
371 # directory in your PATH.
372 $ run_encodes.sh 200 500 50 mytweak
373~~~
374
375After creating both data sets you can use `test/visual_metrics.py` to generate a
376report that can be viewed in a web browser:
377
378~~~
379 $ visual_metrics.py metrics_template.html "*stt" baseline mytweak \
380 > mytweak.html
381~~~
382
383You can view the report by opening mytweak.html in a web browser.
384
385
Tom Finegan9e57db22017-06-07 07:22:37 -0700386### IDE hosted tests
387
388By default the generated projects files created by CMake will not include the
389runtests and testdata rules when generating for IDEs like Microsoft Visual
390Studio and Xcode. This is done to avoid intolerably long build cycles in the
391IDEs-- IDE behavior is to build all targets when selecting the build project
392options in MSVS and Xcode. To enable the test rules in IDEs the
393`ENABLE_IDE_TEST_HOSTING` variable must be enabled at CMake generation time:
394
Tom Finegan007b2ee2017-07-11 14:47:06 -0700395~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700396 # This example uses Xcode. To get a list of the generators
397 # available, run cmake with the -G argument missing its
398 # value.
399 $ cmake path/to/aom -DENABLE_IDE_TEST_HOSTING=1 -G Xcode
Tom Finegan007b2ee2017-07-11 14:47:06 -0700400~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700401
402### Downloading the test data
403
404The fastest and easiest way to obtain the test data is to use CMake to generate
405a build using the Unix Makefiles generator, and then to build only the testdata
406rule:
407
Tom Finegan007b2ee2017-07-11 14:47:06 -0700408~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700409 $ cmake path/to/aom -G "Unix Makefiles"
410 # 28 is used because there are 28 test files as of this writing.
411 $ make -j28 testdata
Tom Finegan007b2ee2017-07-11 14:47:06 -0700412~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700413
414The above make command will only download and verify the test data.
415
Wan-Teh Changcbf8a792018-05-11 11:22:06 -0700416### Adding a new test data file
417
418First, add the new test data file to the `aom-test-data` bucket of the
419`aomedia-testing` project on Google Cloud Platform. You may need to ask someone
420with the necessary access permissions to do this for you.
421
Wan-Teh Changec81dee2018-07-24 16:05:39 -0700422NOTE: When a new test data file is added to the `aom-test-data` bucket, its
423"Public access" is initially "Not public". We need to change its
Wan-Teh Chang4f21f692018-08-06 14:08:19 -0700424"Public access" to "Public" by using the following
425[`gsutil`](https://cloud.google.com/storage/docs/gsutil_install) command:
426~~~
427 $ gsutil acl ch -g all:R gs://aom-test-data/test-data-file-name
428~~~
429This command grants the `AllUsers` group READ access to the file named
430"test-data-file-name" in the `aom-test-data` bucket.
Wan-Teh Changec81dee2018-07-24 16:05:39 -0700431
Wan-Teh Changcbf8a792018-05-11 11:22:06 -0700432Once the new test data file has been added to `aom-test-data`, create a CL to
433add the name of the new test data file to `test/test_data_util.cmake` and add
434the SHA1 checksum of the new test data file to `test/test-data.sha1`. (The SHA1
435checksum of a file can be calculated by running the `sha1sum` command on the
436file.)
437
Tom Finegan9007d342017-12-14 07:47:13 -0800438### Additional test data
439
440The test data mentioned above is strictly intended for unit testing.
441
442Additional input data for testing the encoder can be obtained from:
443https://media.xiph.org/video/derf/
444
Tom Finegan007b2ee2017-07-11 14:47:06 -0700445### Sharded testing
446
447The AV1 codec library unit tests are built upon gtest which supports sharding of
448test jobs. Sharded test runs can be achieved in a couple of ways.
449
450#### 1. Running test\_libaom directly:
451
452~~~
James Zern47cd7be2018-03-16 18:12:10 -0700453 # Set the environment variable GTEST_TOTAL_SHARDS to control the number of
454 # shards.
455 $ export GTEST_TOTAL_SHARDS=10
Tom Finegan007b2ee2017-07-11 14:47:06 -0700456 # (GTEST shard indexing is 0 based).
James Zern515c8692017-08-30 16:32:28 -0700457 $ seq 0 $(( $GTEST_TOTAL_SHARDS - 1 )) \
458 | xargs -n 1 -P 0 -I{} env GTEST_SHARD_INDEX={} ./test_libaom
Tom Finegan007b2ee2017-07-11 14:47:06 -0700459~~~
460
461To create a test shard for each CPU core available on the current system set
462`GTEST_TOTAL_SHARDS` to the number of CPU cores on your system minus one.
463
464#### 2. Running the tests via the CMake build:
465
466~~~
467 # For IDE based builds, ENABLE_IDE_TEST_HOSTING must be enabled. See
468 # the IDE hosted tests section above for more information. If the IDE
469 # supports building targets concurrently tests will be sharded by default.
470
471 # For make and ninja builds the -j parameter controls the number of shards
472 # at test run time. This example will run the tests using 10 shards via
473 # make.
474 $ make -j10 runtests
475~~~
476
477The maximum number of test targets that can run concurrently is determined by
478the number of CPUs on the system where the build is configured as detected by
479CMake. A system with 24 cores can run 24 test shards using a value of 24 with
480the `-j` parameter. When CMake is unable to detect the number of cores 10 shards
481is the default maximum value.
Tom Finegan9e57db22017-06-07 07:22:37 -0700482
483## Coding style
484
Tom Finegan9007d342017-12-14 07:47:13 -0800485We are using the Google C Coding Style defined by the
486[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
487
Tom Finegan9e57db22017-06-07 07:22:37 -0700488The coding style used by this project is enforced with clang-format using the
Tom Finegan9007d342017-12-14 07:47:13 -0800489configuration contained in the
490[.clang-format](https://chromium.googlesource.com/webm/aom/+/master/.clang-format)
491file in the root of the repository.
492
493You can download clang-format using your system's package manager, or directly
494from [llvm.org](http://llvm.org/releases/download.html). You can also view the
495[documentation](https://clang.llvm.org/docs/ClangFormat.html) on llvm.org.
496Output from clang-format varies by clang-format version, for best results your
497version should match the one used on Jenkins. You can find the clang-format
498version by reading the comment in the `.clang-format` file linked above.
Tom Finegan9e57db22017-06-07 07:22:37 -0700499
500Before pushing changes for review you can format your code with:
501
Tom Finegan007b2ee2017-07-11 14:47:06 -0700502~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700503 # Apply clang-format to modified .c, .h and .cc files
504 $ clang-format -i --style=file \
505 $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc')
Tom Finegan007b2ee2017-07-11 14:47:06 -0700506~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700507
508Check the .clang-format file for the version used to generate it if there is any
509difference between your local formatting and the review system.
510
Tom Finegan9007d342017-12-14 07:47:13 -0800511Some Git installations have clang-format integration. Here are some examples:
512
513~~~
514 # Apply clang-format to all staged changes:
515 $ git clang-format
516
517 # Clang format all staged and unstaged changes:
518 $ git clang-format -f
519
520 # Clang format all staged and unstaged changes interactively:
521 $ git clang-format -f -p
522~~~
523
524## Submitting patches
525
526We manage the submission of patches using the
527[Gerrit](https://www.gerritcodereview.com/) code review tool. This tool
528implements a workflow on top of the Git version control system to ensure that
529all changes get peer reviewed and tested prior to their distribution.
530
531### Login cookie
532
533Browse to [AOMedia Git index](https://aomedia.googlesource.com/) and login with
534your account (Gmail credentials, for example). Next, follow the
535`Generate Password` Password link at the top of the page. You’ll be given
536instructions for creating a cookie to use with our Git repos.
537
538### Contributor agreement
539
540You will be required to execute a
541[contributor agreement](http://aomedia.org/license) to ensure that the AOMedia
542Project has the right to distribute your changes.
543
544### Testing your code
545
546The testing basics are covered in the [testing section](#testing-the-av1-codec)
547above.
548
549In addition to the local tests, many more (e.g. asan, tsan, valgrind) will run
550through Jenkins instances upon upload to gerrit.
551
552### Commit message hook
553
554Gerrit requires that each submission include a unique Change-Id. You can assign
555one manually using git commit --amend, but it’s easier to automate it with the
556commit-msg hook provided by Gerrit.
557
558Copy commit-msg to the `.git/hooks` directory of your local repo. Here's an
559example:
560
561~~~
562 $ curl -Lo aom/.git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg
563
564 # Next, ensure that the downloaded commit-msg script is executable:
565 $ chmod u+x aom/.git/hooks/commit-msg
566~~~
567
568See the Gerrit
569[documentation](https://gerrit-review.googlesource.com/Documentation/user-changeid.html)
570for more information.
571
572### Upload your change
573
574The command line to upload your patch looks like this:
575
576~~~
577 $ git push https://aomedia-review.googlesource.com/aom HEAD:refs/for/master
578~~~
579
580### Incorporating reviewer comments
581
582If you previously uploaded a change to Gerrit and the Approver has asked for
583changes, follow these steps:
584
5851. Edit the files to make the changes the reviewer has requested.
5862. Recommit your edits using the --amend flag, for example:
587
588~~~
589 $ git commit -a --amend
590~~~
591
5923. Use the same git push command as above to upload to Gerrit again for another
593 review cycle.
594
595In general, you should not rebase your changes when doing updates in response to
596review. Doing so can make it harder to follow the evolution of your change in
597the diff view.
598
599### Submitting your change
600
601Once your change has been Approved and Verified, you can “submit” it through the
602Gerrit UI. This will usually automatically rebase your change onto the branch
603specified.
604
605Sometimes this can’t be done automatically. If you run into this problem, you
606must rebase your changes manually:
607
608~~~
609 $ git fetch
610 $ git rebase origin/branchname
611~~~
612
613If there are any conflicts, resolve them as you normally would with Git. When
614you’re done, reupload your change.
615
616### Viewing the status of uploaded changes
617
618To check the status of a change that you uploaded, open
619[Gerrit](https://aomedia-review.googlesource.com/), sign in, and click My >
620Changes.
Tom Finegan9e57db22017-06-07 07:22:37 -0700621
622## Support
623
624This library is an open source project supported by its community. Please
625please email aomediacodec@jointdevelopment.kavi.com for help.
626
627## Bug reports
628
629Bug reports can be filed in the Alliance for Open Media
630[issue tracker](https://bugs.chromium.org/p/aomedia/issues/list).