FFmpeg development notes

Websites

Documentation

Building

List all compile options:

$ ./configure --help | vim -

Quick development build; takes about 90 seconds on an M1 MacBook Air:

$ ./configure --disable-optimizations --disable-asm
$ make -j $(nproc)
$ make -j $(sysctl -n hw.logicalcpu)

Troubleshooting build:

$ ./configure --disable-optimizations --assert-level=2 --toolchain=clang-asan
$ ./configure --disable-optimizations --assert-level=2 --toolchain=clang-asan-ubsan

--enable-memory-poisoning makes av_malloc and friends basically just do memset(ptr, 0x2a, size). Does not add any asan-style bounds checking.

Regression testing

FATE documentation: https://ffmpeg.org/fate.html, TLDR:

$ ./configure --disable-optimizations --assert-level=2 --toolchain=clang-asan --samples=$HOME/Proj/FFmpeg-FATE
$ make
$ make fate-rsync
$ make fate

Benchmarking

checkasm docs: https://checkasm.videolan.me/

Build within FFmpeg:

$ make checkasm

List tests:

$ ./tests/checkasm/checkasm --list-tests | sort | vim -

The easiest way to see what test calls what functions is to check the source code:
-> tests/checkasm/checkasm.c.

Example:

$ ./tests/checkasm/checkasm --bench --test=vf_bwdif
Output
checkasm:
 - CPU: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (000906E9)
 - Timing source: x86 (rdtsc)
 - Bench duration: 1000 µs per function (4003730 cycles)
 - Random seed: 2684063072
C:
 - vf_bwdif.bwdif8 [OK]
 - vf_bwdif.bwdif10 [OK]
 - vf_bwdif.bwdif8.line3 [OK]
 - vf_bwdif.bwdif8.edge  [OK]
 - vf_bwdif.bwdif8.intra [OK]
SSE2:
 - vf_bwdif.bwdif8       [OK]
 - vf_bwdif.bwdif10      [OK]
SSSE3:
 - vf_bwdif.bwdif8       [OK]
 - vf_bwdif.bwdif10      [OK]
AVX2:
 - vf_bwdif.bwdif8       [OK]
 - vf_bwdif.bwdif10      [OK]
checkasm: all 6 tests passed
Benchmark results:
  name                       cycles (vs ref)
  bwdif8_c:                 28876.2
  bwdif8_sse2:               1056.1 (25.12x)
  bwdif8_ssse3:               870.5 (22.92x)
  bwdif8_avx2:                550.6 (40.40x)
  bwdif8.edge.s0.p0_c:       1373.2
  bwdif8.edge.s0.p1_c:       1310.2
  bwdif8.edge.s1.p0_c:       5368.5
  bwdif8.edge.s1.p1_c:       5824.8
  bwdif8.intra_c:             584.1
  bwdif8.line3.rnd.p0_c:    40020.9
  bwdif8.line3.rnd.p1_c:    30286.6
  bwdif10_c:                27988.9
  bwdif10_sse2:               935.6 (27.51x)
  bwdif10_ssse3:              864.2 (27.04x)
  bwdif10_avx2:               594.3 (36.53x)