blob: c93a17be11635f5e6b93aa37b95d8256087287f7 [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)
sdeng29c62152019-12-09 12:44:18 -080017 - [Build with VMAF support](#build-with-vmaf)
Tom Fineganbca03fc2017-12-08 07:47:06 -0800182. [Testing the library](#testing-the-av1-codec)
19 - [Basics](#testing-basics)
20 - [Unit tests](#1_unit-tests)
21 - [Example tests](#2_example-tests)
Tom Finegan9007d342017-12-14 07:47:13 -080022 - [Encoder tests](#3_encoder-tests)
Tom Fineganbca03fc2017-12-08 07:47:06 -080023 - [IDE hosted tests](#ide-hosted-tests)
24 - [Downloading test data](#downloading-the-test-data)
Wan-Teh Changcbf8a792018-05-11 11:22:06 -070025 - [Adding a new test data file](#adding-a-new-test-data-file)
Tom Finegan9007d342017-12-14 07:47:13 -080026 - [Additional test data](#additional-test-data)
Tom Fineganbca03fc2017-12-08 07:47:06 -080027 - [Sharded testing](#sharded-testing)
28 - [Running tests directly](#1_running-test_libaom-directly)
29 - [Running tests via CMake](#2_running-the-tests-via-the-cmake-build)
303. [Coding style](#coding-style)
Tom Finegan9007d342017-12-14 07:47:13 -0800314. [Submitting patches](#submitting-patches)
32 - [Login cookie](#login-cookie)
33 - [Contributor agreement](#contributor-agreement)
34 - [Testing your code](#testing-your-code)
35 - [Commit message hook](#commit-message-hook)
36 - [Upload your change](#upload-your-change)
37 - [Incorporating Reviewer Comments](#incorporating-reviewer-comments)
38 - [Submitting your change](#submitting-your-change)
39 - [Viewing change status](#viewing-the-status-of-uploaded-changes)
405. [Support](#support)
416. [Bug reports](#bug-reports)
Tom Fineganbca03fc2017-12-08 07:47:06 -080042
Tom Finegan9e57db22017-06-07 07:22:37 -070043## Building the library and applications
44
45### Prerequisites
46
47 1. [CMake](https://cmake.org) version 3.5 or higher.
48 2. [Git](https://git-scm.com/).
49 3. [Perl](https://www.perl.org/).
50 4. For x86 targets, [yasm](http://yasm.tortall.net/), which is preferred, or a
Yaowu Xu5fc83f32019-11-05 15:41:05 -080051 recent version of [nasm](http://www.nasm.us/). If you download yasm with
52 the intention to work with Visual Studio, please download win32.exe or
53 win64.exe and rename it into yasm.exe. DO NOT download or use vsyasm.exe.
Tom Finegan9e57db22017-06-07 07:22:37 -070054 5. Building the documentation requires [doxygen](http://doxygen.org).
Tom Fineganff766cd2017-06-20 14:18:03 -070055 6. Building the unit tests requires [Python](https://www.python.org/).
Tom Finegan84d35992017-07-07 10:38:01 -070056 7. Emscripten builds require the portable
57 [EMSDK](https://kripken.github.io/emscripten-site/index.html).
Tom Finegan9e57db22017-06-07 07:22:37 -070058
Tom Finegan9007d342017-12-14 07:47:13 -080059### Get the code
60
61The AV1 library source code is stored in the Alliance for Open Media Git
62repository:
63
64~~~
65 $ git clone https://aomedia.googlesource.com/aom
66 # By default, the above command stores the source in the aom directory:
67 $ cd aom
68~~~
69
Tom Finegan9e57db22017-06-07 07:22:37 -070070### Basic build
71
72CMake replaces the configure step typical of many projects. Running CMake will
73produce configuration and build files for the currently selected CMake
74generator. For most systems the default generator is Unix Makefiles. The basic
75form of a makefile build is the following:
76
Tom Finegan9007d342017-12-14 07:47:13 -080077~~~
Tom Finegan9e57db22017-06-07 07:22:37 -070078 $ cmake path/to/aom
79 $ make
Tom Finegan9007d342017-12-14 07:47:13 -080080~~~
Tom Finegan9e57db22017-06-07 07:22:37 -070081
82The above will generate a makefile build that produces the AV1 library and
83applications for the current host system after the make step completes
84successfully. The compiler chosen varies by host platform, but a general rule
85applies: On systems where cc and c++ are present in $PATH at the time CMake is
86run the generated build will use cc and c++ by default.
87
88### Configuration options
89
90The AV1 codec library has a great many configuration options. These come in two
91varieties:
92
93 1. Build system configuration options. These have the form `ENABLE_FEATURE`.
94 2. AV1 codec configuration options. These have the form `CONFIG_FEATURE`.
95
96Both types of options are set at the time CMake is run. The following example
Sebastien Alaiwan7c524d42018-01-02 10:10:55 +010097enables ccache and disables the AV1 encoder:
Tom Finegan9e57db22017-06-07 07:22:37 -070098
Tom Finegan007b2ee2017-07-11 14:47:06 -070099~~~
Sebastien Alaiwan7c524d42018-01-02 10:10:55 +0100100 $ cmake path/to/aom -DENABLE_CCACHE=1 -DCONFIG_AV1_ENCODER=0
Tom Finegan9e57db22017-06-07 07:22:37 -0700101 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700102~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700103
104The available configuration options are too numerous to list here. Build system
105configuration options can be found at the top of the CMakeLists.txt file found
106in the root of the AV1 repository, and AV1 codec configuration options can
107currently be found in the file `build/cmake/aom_config_defaults.cmake`.
108
Tom Finegan84f2d792017-06-15 23:06:44 -0700109### Dylib builds
110
111A dylib (shared object) build of the AV1 codec library can be enabled via the
Tom Finegan007b2ee2017-07-11 14:47:06 -0700112CMake built in variable `BUILD_SHARED_LIBS`:
Tom Finegan84f2d792017-06-15 23:06:44 -0700113
Tom Finegan007b2ee2017-07-11 14:47:06 -0700114~~~
115 $ cmake path/to/aom -DBUILD_SHARED_LIBS=1
Tom Finegan84f2d792017-06-15 23:06:44 -0700116 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700117~~~
Tom Finegan84f2d792017-06-15 23:06:44 -0700118
119This is currently only supported on non-Windows targets.
120
Tom Fineganfe809bd2017-09-27 11:54:24 -0700121### Debugging
122
123Depending on the generator used there are multiple ways of going about
124debugging AV1 components. For single configuration generators like the Unix
125Makefiles generator, setting `CMAKE_BUILD_TYPE` to Debug is sufficient:
126
127~~~
128 $ cmake path/to/aom -DCMAKE_BUILD_TYPE=Debug
129~~~
130
131For Xcode, mainly because configuration controls for Xcode builds are buried two
Tom Finegand77323d2017-09-29 09:41:43 -0700132configuration windows deep and must be set for each subproject within the Xcode
133IDE individually, `CMAKE_CONFIGURATION_TYPES` should be set to Debug:
Tom Fineganfe809bd2017-09-27 11:54:24 -0700134
135~~~
136 $ cmake path/to/aom -G Xcode -DCMAKE_CONFIGURATION_TYPES=Debug
137~~~
138
139For Visual Studio the in-IDE configuration controls should be used. Simply set
140the IDE project configuration to Debug to allow for stepping through the code.
141
142In addition to the above it can sometimes be useful to debug only C and C++
Tom Finegand77323d2017-09-29 09:41:43 -0700143code. To disable all assembly code and intrinsics set `AOM_TARGET_CPU` to
Tom Fineganfe809bd2017-09-27 11:54:24 -0700144generic at generation time:
145
146~~~
147 $ cmake path/to/aom -DAOM_TARGET_CPU=generic
148~~~
149
Tom Finegan9e57db22017-06-07 07:22:37 -0700150### Cross compiling
151
152For the purposes of building the AV1 codec and applications and relative to the
153scope of this guide, all builds for architectures differing from the native host
154architecture will be considered cross compiles. The AV1 CMake build handles
155cross compiling via the use of toolchain files included in the AV1 repository.
156The toolchain files available at the time of this writing are:
157
158 - arm64-ios.cmake
159 - arm64-linux-gcc.cmake
Martin Storsjo6a124ba2018-04-13 00:23:38 +0300160 - arm64-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700161 - armv7-ios.cmake
162 - armv7-linux-gcc.cmake
Martin Storsjo6a124ba2018-04-13 00:23:38 +0300163 - armv7-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700164 - armv7s-ios.cmake
165 - mips32-linux-gcc.cmake
166 - mips64-linux-gcc.cmake
167 - x86-ios-simulator.cmake
168 - x86-linux.cmake
169 - x86-macos.cmake
Tom Finegand77323d2017-09-29 09:41:43 -0700170 - x86-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700171 - x86\_64-ios-simulator.cmake
Tom Finegand77323d2017-09-29 09:41:43 -0700172 - x86\_64-mingw-gcc.cmake
Tom Finegan9e57db22017-06-07 07:22:37 -0700173
174The following example demonstrates use of the x86-macos.cmake toolchain file on
175a x86\_64 MacOS host:
176
Tom Finegan007b2ee2017-07-11 14:47:06 -0700177~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700178 $ cmake path/to/aom \
179 -DCMAKE_TOOLCHAIN_FILE=path/to/aom/build/cmake/toolchains/x86-macos.cmake
180 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700181~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700182
183To build for an unlisted target creation of a new toolchain file is the best
184solution. The existing toolchain files can be used a starting point for a new
185toolchain file since each one exposes the basic requirements for toolchain files
186as used in the AV1 codec build.
187
188As a temporary work around an unoptimized AV1 configuration that builds only C
189and C++ sources can be produced using the following commands:
190
Tom Finegan007b2ee2017-07-11 14:47:06 -0700191~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700192 $ cmake path/to/aom -DAOM_TARGET_CPU=generic
193 $ make
Tom Finegan007b2ee2017-07-11 14:47:06 -0700194~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700195
196In addition to the above it's important to note that the toolchain files
197suffixed with gcc behave differently than the others. These toolchain files
198attempt to obey the $CROSS environment variable.
199
Tom Finegan8a30baf2017-09-13 11:35:34 -0700200### Sanitizers
201
202Sanitizer integration is built-in to the CMake build system. To enable a
203sanitizer, add `-DSANITIZE=<type>` to the CMake command line. For example, to
204enable address sanitizer:
205
206~~~
207 $ cmake path/to/aom -DSANITIZE=address
208 $ make
209~~~
210
211Sanitizers available vary by platform, target, and compiler. Consult your
212compiler documentation to determine which, if any, are available.
213
Tom Finegan9e57db22017-06-07 07:22:37 -0700214### Microsoft Visual Studio builds
215
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800216Building the AV1 codec library in Microsoft Visual Studio is supported. Visual
Wan-Teh Chang758ac372020-01-31 15:43:51 -0800217Studio 2017 (15.0) or later is required. The following example demonstrates
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800218generating projects and a solution for the Microsoft IDE:
Tom Finegan9e57db22017-06-07 07:22:37 -0700219
Tom Finegan007b2ee2017-07-11 14:47:06 -0700220~~~
Wan-Teh Chang758ac372020-01-31 15:43:51 -0800221 # This does not require a bash shell; Command Prompt (cmd.exe) is fine.
222 $ cmake path/to/aom -G "Visual Studio 16 2019"
223 $ cmake --build .
Tom Finegan007b2ee2017-07-11 14:47:06 -0700224~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700225
Wan-Teh Chang64545cb2018-11-14 08:47:44 -0800226NOTE: The build system targets Windows 7 or later by compiling files with
227`-D_WIN32_WINNT=0x0601`.
228
Tom Finegan9e57db22017-06-07 07:22:37 -0700229### Xcode builds
230
231Building the AV1 codec library in Xcode is supported. The following example
232demonstrates generating an Xcode project:
233
Tom Finegan007b2ee2017-07-11 14:47:06 -0700234~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700235 $ cmake path/to/aom -G Xcode
Tom Finegan007b2ee2017-07-11 14:47:06 -0700236~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700237
Tom Finegan84d35992017-07-07 10:38:01 -0700238### Emscripten builds
239
240Building the AV1 codec library with Emscripten is supported. Typically this is
241used to hook into the AOMAnalyzer GUI application. These instructions focus on
242using the inspector with AOMAnalyzer, but all tools can be built with
243Emscripten.
244
245It is assumed here that you have already downloaded and installed the EMSDK,
246installed and activated at least one toolchain, and setup your environment
247appropriately using the emsdk\_env script.
248
2491. Download [AOMAnalyzer](https://people.xiph.org/~mbebenita/analyzer/).
250
2512. Configure the build:
252
253~~~
254 $ cmake path/to/aom \
255 -DENABLE_CCACHE=1 \
256 -DAOM_TARGET_CPU=generic \
257 -DENABLE_DOCS=0 \
Tom Finegand9647f22018-06-19 13:27:57 -0700258 -DENABLE_TESTS=0 \
Tom Finegan84d35992017-07-07 10:38:01 -0700259 -DCONFIG_ACCOUNTING=1 \
260 -DCONFIG_INSPECTION=1 \
261 -DCONFIG_MULTITHREAD=0 \
262 -DCONFIG_RUNTIME_CPU_DETECT=0 \
Tom Finegan84d35992017-07-07 10:38:01 -0700263 -DCONFIG_WEBM_IO=0 \
264 -DCMAKE_TOOLCHAIN_FILE=path/to/emsdk-portable/.../Emscripten.cmake
265~~~
266
2673. Build it: run make if that's your generator of choice:
268
269~~~
270 $ make inspect
271~~~
272
2734. Run the analyzer:
274
275~~~
276 # inspect.js is in the examples sub directory of the directory in which you
277 # executed cmake.
278 $ path/to/AOMAnalyzer path/to/examples/inspect.js path/to/av1/input/file
279~~~
280
Tom Fineganaa71f072018-01-31 06:54:01 -0800281### Extra build flags
282
283Three variables allow for passing of additional flags to the build system.
284
285- AOM\_EXTRA\_C\_FLAGS
286- AOM\_EXTRA\_CXX\_FLAGS
287- AOM\_EXTRA\_EXE\_LINKER\_FLAGS
288
289The build system attempts to ensure the flags passed through the above variables
290are passed to tools last in order to allow for override of default behavior.
291These flags can be used, for example, to enable asserts in a release build:
292
293~~~
294 $ cmake path/to/aom \
295 -DCMAKE_BUILD_TYPE=Release \
296 -DAOM_EXTRA_C_FLAGS=-UNDEBUG \
297 -DAOM_EXTRA_CXX_FLAGS=-UNDEBUG
298~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700299
sdeng29c62152019-12-09 12:44:18 -0800300### Build with VMAF support
301
302After installing
303[libvmaf.a](https://github.com/Netflix/vmaf/blob/master/resource/doc/libvmaf.md),
304you can use it with the encoder:
305
306~~~
307 $ cmake path/to/aom -DCONFIG_TUNE_VMAF=1
308~~~
309
310Please note that the default VMAF model
311("/usr/local/share/model/vmaf_v0.6.1.pkl")
312will be used unless you set the following flag when running the encoder:
313
314~~~
315 # --vmaf-model-path=path/to/model
316~~~
317
Tom Finegan9e57db22017-06-07 07:22:37 -0700318## Testing the AV1 codec
319
320### Testing basics
321
Tom Finegan9007d342017-12-14 07:47:13 -0800322There are several methods of testing the AV1 codec. All of these methods require
323the presence of the AV1 source code and a working build of the AV1 library and
324applications.
Tom Finegan9e57db22017-06-07 07:22:37 -0700325
Tom Finegan007b2ee2017-07-11 14:47:06 -0700326#### 1. Unit tests:
Tom Finegan9e57db22017-06-07 07:22:37 -0700327
328The unit tests can be run at build time:
329
Tom Finegan007b2ee2017-07-11 14:47:06 -0700330~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700331 # Before running the make command the LIBAOM_TEST_DATA_PATH environment
332 # variable should be set to avoid downloading the test files to the
333 # cmake build configuration directory.
334 $ cmake path/to/aom
335 # Note: The AV1 CMake build creates many test targets. Running make
336 # with multiple jobs will speed up the test run significantly.
337 $ make runtests
Tom Finegan007b2ee2017-07-11 14:47:06 -0700338~~~
339
340#### 2. Example tests:
Tom Finegan9e57db22017-06-07 07:22:37 -0700341
342The example tests require a bash shell and can be run in the following manner:
343
Tom Finegan007b2ee2017-07-11 14:47:06 -0700344~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700345 # See the note above about LIBAOM_TEST_DATA_PATH above.
346 $ cmake path/to/aom
347 $ make
348 # It's best to build the testdata target using many make jobs.
349 # Running it like this will verify and download (if necessary)
350 # one at a time, which takes a while.
351 $ make testdata
352 $ path/to/aom/test/examples.sh --bin-path examples
Tom Finegan007b2ee2017-07-11 14:47:06 -0700353~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700354
Tom Finegan9007d342017-12-14 07:47:13 -0800355#### 3. Encoder tests:
356
357When making a change to the encoder run encoder tests to confirm that your
358change has a positive or negligible impact on encode quality. When running these
359tests the build configuration should be changed to enable internal encoder
360statistics:
361
362~~~
363 $ cmake path/to/aom -DCONFIG_INTERNAL_STATS=1
364 $ make
365~~~
366
367The repository contains scripts intended to make running these tests as simple
368as possible. The following example demonstrates creating a set of baseline clips
369for comparison to results produced after making your change to libaom:
370
371~~~
372 # This will encode all Y4M files in the current directory using the
373 # settings specified to create the encoder baseline statistical data:
374 $ cd path/to/test/inputs
375 # This command line assumes that run_encodes.sh, its helper script
376 # best_encode.sh, and the aomenc you intend to test are all within a
377 # directory in your PATH.
378 $ run_encodes.sh 200 500 50 baseline
379~~~
380
381After making your change and creating the baseline clips, you'll need to run
382encodes that include your change(s) to confirm that things are working as
383intended:
384
385~~~
386 # This will encode all Y4M files in the current directory using the
387 # settings specified to create the statistical data for your change:
388 $ cd path/to/test/inputs
389 # This command line assumes that run_encodes.sh, its helper script
390 # best_encode.sh, and the aomenc you intend to test are all within a
391 # directory in your PATH.
392 $ run_encodes.sh 200 500 50 mytweak
393~~~
394
395After creating both data sets you can use `test/visual_metrics.py` to generate a
396report that can be viewed in a web browser:
397
398~~~
399 $ visual_metrics.py metrics_template.html "*stt" baseline mytweak \
400 > mytweak.html
401~~~
402
403You can view the report by opening mytweak.html in a web browser.
404
405
Tom Finegan9e57db22017-06-07 07:22:37 -0700406### IDE hosted tests
407
408By default the generated projects files created by CMake will not include the
409runtests and testdata rules when generating for IDEs like Microsoft Visual
410Studio and Xcode. This is done to avoid intolerably long build cycles in the
411IDEs-- IDE behavior is to build all targets when selecting the build project
412options in MSVS and Xcode. To enable the test rules in IDEs the
413`ENABLE_IDE_TEST_HOSTING` variable must be enabled at CMake generation time:
414
Tom Finegan007b2ee2017-07-11 14:47:06 -0700415~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700416 # This example uses Xcode. To get a list of the generators
417 # available, run cmake with the -G argument missing its
418 # value.
419 $ cmake path/to/aom -DENABLE_IDE_TEST_HOSTING=1 -G Xcode
Tom Finegan007b2ee2017-07-11 14:47:06 -0700420~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700421
422### Downloading the test data
423
424The fastest and easiest way to obtain the test data is to use CMake to generate
425a build using the Unix Makefiles generator, and then to build only the testdata
426rule:
427
Tom Finegan007b2ee2017-07-11 14:47:06 -0700428~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700429 $ cmake path/to/aom -G "Unix Makefiles"
430 # 28 is used because there are 28 test files as of this writing.
431 $ make -j28 testdata
Tom Finegan007b2ee2017-07-11 14:47:06 -0700432~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700433
434The above make command will only download and verify the test data.
435
Wan-Teh Changcbf8a792018-05-11 11:22:06 -0700436### Adding a new test data file
437
438First, add the new test data file to the `aom-test-data` bucket of the
439`aomedia-testing` project on Google Cloud Platform. You may need to ask someone
440with the necessary access permissions to do this for you.
441
Wan-Teh Changec81dee2018-07-24 16:05:39 -0700442NOTE: When a new test data file is added to the `aom-test-data` bucket, its
443"Public access" is initially "Not public". We need to change its
Wan-Teh Chang4f21f692018-08-06 14:08:19 -0700444"Public access" to "Public" by using the following
445[`gsutil`](https://cloud.google.com/storage/docs/gsutil_install) command:
446~~~
447 $ gsutil acl ch -g all:R gs://aom-test-data/test-data-file-name
448~~~
449This command grants the `AllUsers` group READ access to the file named
450"test-data-file-name" in the `aom-test-data` bucket.
Wan-Teh Changec81dee2018-07-24 16:05:39 -0700451
Wan-Teh Changcbf8a792018-05-11 11:22:06 -0700452Once the new test data file has been added to `aom-test-data`, create a CL to
453add the name of the new test data file to `test/test_data_util.cmake` and add
454the SHA1 checksum of the new test data file to `test/test-data.sha1`. (The SHA1
455checksum of a file can be calculated by running the `sha1sum` command on the
456file.)
457
Tom Finegan9007d342017-12-14 07:47:13 -0800458### Additional test data
459
460The test data mentioned above is strictly intended for unit testing.
461
462Additional input data for testing the encoder can be obtained from:
463https://media.xiph.org/video/derf/
464
Tom Finegan007b2ee2017-07-11 14:47:06 -0700465### Sharded testing
466
467The AV1 codec library unit tests are built upon gtest which supports sharding of
468test jobs. Sharded test runs can be achieved in a couple of ways.
469
470#### 1. Running test\_libaom directly:
471
472~~~
James Zern47cd7be2018-03-16 18:12:10 -0700473 # Set the environment variable GTEST_TOTAL_SHARDS to control the number of
474 # shards.
475 $ export GTEST_TOTAL_SHARDS=10
Tom Finegan007b2ee2017-07-11 14:47:06 -0700476 # (GTEST shard indexing is 0 based).
James Zern515c8692017-08-30 16:32:28 -0700477 $ seq 0 $(( $GTEST_TOTAL_SHARDS - 1 )) \
478 | xargs -n 1 -P 0 -I{} env GTEST_SHARD_INDEX={} ./test_libaom
Tom Finegan007b2ee2017-07-11 14:47:06 -0700479~~~
480
481To create a test shard for each CPU core available on the current system set
482`GTEST_TOTAL_SHARDS` to the number of CPU cores on your system minus one.
483
484#### 2. Running the tests via the CMake build:
485
486~~~
487 # For IDE based builds, ENABLE_IDE_TEST_HOSTING must be enabled. See
488 # the IDE hosted tests section above for more information. If the IDE
489 # supports building targets concurrently tests will be sharded by default.
490
491 # For make and ninja builds the -j parameter controls the number of shards
492 # at test run time. This example will run the tests using 10 shards via
493 # make.
494 $ make -j10 runtests
495~~~
496
497The maximum number of test targets that can run concurrently is determined by
498the number of CPUs on the system where the build is configured as detected by
499CMake. A system with 24 cores can run 24 test shards using a value of 24 with
500the `-j` parameter. When CMake is unable to detect the number of cores 10 shards
501is the default maximum value.
Tom Finegan9e57db22017-06-07 07:22:37 -0700502
503## Coding style
504
Tom Finegan9007d342017-12-14 07:47:13 -0800505We are using the Google C Coding Style defined by the
506[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
507
Tom Finegan9e57db22017-06-07 07:22:37 -0700508The coding style used by this project is enforced with clang-format using the
Tom Finegan9007d342017-12-14 07:47:13 -0800509configuration contained in the
510[.clang-format](https://chromium.googlesource.com/webm/aom/+/master/.clang-format)
511file in the root of the repository.
512
513You can download clang-format using your system's package manager, or directly
514from [llvm.org](http://llvm.org/releases/download.html). You can also view the
515[documentation](https://clang.llvm.org/docs/ClangFormat.html) on llvm.org.
516Output from clang-format varies by clang-format version, for best results your
517version should match the one used on Jenkins. You can find the clang-format
518version by reading the comment in the `.clang-format` file linked above.
Tom Finegan9e57db22017-06-07 07:22:37 -0700519
520Before pushing changes for review you can format your code with:
521
Tom Finegan007b2ee2017-07-11 14:47:06 -0700522~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700523 # Apply clang-format to modified .c, .h and .cc files
524 $ clang-format -i --style=file \
525 $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc')
Tom Finegan007b2ee2017-07-11 14:47:06 -0700526~~~
Tom Finegan9e57db22017-06-07 07:22:37 -0700527
528Check the .clang-format file for the version used to generate it if there is any
529difference between your local formatting and the review system.
530
Tom Finegan9007d342017-12-14 07:47:13 -0800531Some Git installations have clang-format integration. Here are some examples:
532
533~~~
534 # Apply clang-format to all staged changes:
535 $ git clang-format
536
537 # Clang format all staged and unstaged changes:
538 $ git clang-format -f
539
540 # Clang format all staged and unstaged changes interactively:
541 $ git clang-format -f -p
542~~~
543
544## Submitting patches
545
546We manage the submission of patches using the
547[Gerrit](https://www.gerritcodereview.com/) code review tool. This tool
548implements a workflow on top of the Git version control system to ensure that
549all changes get peer reviewed and tested prior to their distribution.
550
551### Login cookie
552
553Browse to [AOMedia Git index](https://aomedia.googlesource.com/) and login with
554your account (Gmail credentials, for example). Next, follow the
555`Generate Password` Password link at the top of the page. You’ll be given
556instructions for creating a cookie to use with our Git repos.
557
558### Contributor agreement
559
560You will be required to execute a
561[contributor agreement](http://aomedia.org/license) to ensure that the AOMedia
562Project has the right to distribute your changes.
563
564### Testing your code
565
566The testing basics are covered in the [testing section](#testing-the-av1-codec)
567above.
568
569In addition to the local tests, many more (e.g. asan, tsan, valgrind) will run
570through Jenkins instances upon upload to gerrit.
571
572### Commit message hook
573
574Gerrit requires that each submission include a unique Change-Id. You can assign
575one manually using git commit --amend, but it’s easier to automate it with the
576commit-msg hook provided by Gerrit.
577
578Copy commit-msg to the `.git/hooks` directory of your local repo. Here's an
579example:
580
581~~~
582 $ curl -Lo aom/.git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg
583
584 # Next, ensure that the downloaded commit-msg script is executable:
585 $ chmod u+x aom/.git/hooks/commit-msg
586~~~
587
588See the Gerrit
589[documentation](https://gerrit-review.googlesource.com/Documentation/user-changeid.html)
590for more information.
591
592### Upload your change
593
594The command line to upload your patch looks like this:
595
596~~~
597 $ git push https://aomedia-review.googlesource.com/aom HEAD:refs/for/master
598~~~
599
600### Incorporating reviewer comments
601
602If you previously uploaded a change to Gerrit and the Approver has asked for
603changes, follow these steps:
604
6051. Edit the files to make the changes the reviewer has requested.
6062. Recommit your edits using the --amend flag, for example:
607
608~~~
609 $ git commit -a --amend
610~~~
611
6123. Use the same git push command as above to upload to Gerrit again for another
613 review cycle.
614
615In general, you should not rebase your changes when doing updates in response to
616review. Doing so can make it harder to follow the evolution of your change in
617the diff view.
618
619### Submitting your change
620
621Once your change has been Approved and Verified, you can “submit” it through the
622Gerrit UI. This will usually automatically rebase your change onto the branch
623specified.
624
625Sometimes this can’t be done automatically. If you run into this problem, you
626must rebase your changes manually:
627
628~~~
629 $ git fetch
630 $ git rebase origin/branchname
631~~~
632
633If there are any conflicts, resolve them as you normally would with Git. When
634you’re done, reupload your change.
635
636### Viewing the status of uploaded changes
637
638To check the status of a change that you uploaded, open
639[Gerrit](https://aomedia-review.googlesource.com/), sign in, and click My >
640Changes.
Tom Finegan9e57db22017-06-07 07:22:37 -0700641
642## Support
643
644This library is an open source project supported by its community. Please
645please email aomediacodec@jointdevelopment.kavi.com for help.
646
647## Bug reports
648
649Bug reports can be filed in the Alliance for Open Media
650[issue tracker](https://bugs.chromium.org/p/aomedia/issues/list).