This directory contains files used in gecko builds from FFmpeg
(http://ffmpeg.org). The current files are from FFmpeg as of
revision n4.2.2-1-g19bfd72126
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
git checkout n4.2.2-1-g19bfd72126

This copy has a single patch backported from a later revision to fix the build with recent binutils:

http://git.videolan.org/?p=ffmpeg.git;a=patch;h=effadce6c756247ea8bae32dc13bb3e6f464f0eb
that is available as `1846703.patch` in this directory. As usual this has other
changes that don't come from upstream, in `changes.patch`

All source files match their path from the library's source archive.

Currently, we only use the vp8, vp9, mp3, and flac portion of the library. If
this changes, configuration files will most likely need to be updated.

AVX2 must be disabled on Linux 32 bits due to the use of yasm 1.1 on the build bots.
Once yasm is upgraded to 1.2 or later, AVX2 code could be re-enabled.
Add --disable-avx2 to configure on those platforms.

configuration files were generated as follow using the configure script:
 ./configure --disable-all --enable-avcodec --enable-decoder=vp8,vp9,mp3,flac \
             --enable-parser=vp8,vp9 --disable-static --enable-shared \
             --disable-autodetect
config*:
replace: /HAVE_(MALLOC_H|ARC4RANDOM|LOCALTIME_R|MEMALIGN|POSIX_MEMALIGN)/d
# sed -i bak -E '/HAVE_(MALLOC_H|ARC4RANDOM|LOCALTIME_R|MEMALIGN|POSIX_MEMALIGN)/d' config.h

config_unix32.h:
add to configure command: --disable-asm --disable-x86asm --cc='clang -m32'

config_android32.h: Only mp3 and flac are enabled on this platform.
./configure --disable-all --enable-avcodec --enable-decoder=mp3,flac \
            --disable-static --enable-shared --disable-autodetect \
            --enable-small --target-os=linux --arch=arm --enable-cross-compile \
            --cc=$HOME/.mozbuild/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang

config_unix32.h/config_unix64.h/config_unix64.asm:
replace: s/HAVE_SYSCTL 1/HAVE_SYSCTL 0

config_win{32|64}.{h|asm}:
add to configure command: --toolchain=msvc

config_aarch64_win64.h: You will need to install cpp (either using msys or wsl)
./configure --disable-all --enable-avcodec --enable-decoder=vp8,vp9,mp3,flac \
            --enable-parser=vp8,vp9 --disable-static --enable-shared \
            --disable-autodetect  --toolchain=msvc --enable-cross-compile \
            --target-os=win32 --arch=arm64

Regenerate defaults_disabled.{h,asm} with:
$ grep -E ".*_(INDEV|OUTDEV|DECODER|ENCODER|DEMUXER|MUXER|PARSER|FILTER|HWACCEL|PROTOCOL|ENCODERS|DECODERS|HWACCELS|INDEVS|OUTDEVS|FILTERS|DEMUXERS|MUXERS|PROTOCOLS|BSF) 0" config.h | sort -d -u > ~/Work/Mozilla/mozilla-central/media/ffvpx/defaults_disabled.h
$ grep -E ".*_(INDEV|OUTDEV|DECODER|ENCODER|DEMUXER|MUXER|PARSER|FILTER|HWACCEL|PROTOCOL|ENCODERS|DECODERS|HWACCELS|INDEVS|OUTDEVS|FILTERS|DEMUXERS|MUXERS|PROTOCOLS|BSF) 0" config.asm | sort -d -u > ~/Work/Mozilla/mozilla-central/media/ffvpx/defaults_disabled.asm

The GNU comm utility is a useful tool to compare and extract only the changes.

To update the source tree, perform a diff on the files listed in FILES.
The diffs should typically apply to the ffvpx tree.
e.g. something like this would do:
Run in the ffmpeg original tree:
$ for i in `cat $PATH_CENTRAL/media/ffvpx/FILES`; do git diff $REV_LASTSYNC HEAD >> patch.diff; done
Then apply patch.diff on the ffvpx tree.

Compilation will reveal if any files are missing.

- bug1603271-videodsp-pointer-overflow.patch to avoid a UBSan pointer-overflow
  by combining a two-step pointer adjustment into a single positive-offset step.

Additionally, `jni.h` and `jni.c` in ffmpeg sources need to be renamed to
`fffjni.h` and `fffjni.c`, and `#include` to those files need to be updated.
This is because there are header collisions with the JDK.
 
`moz.build` files might need to be modified as well, in light of compilation
and link errors.

There are going to be a lot of changes in terms of symbols exported. Adjust
`libavutil/avutil.symbols` and `libavcodec/avcodec.symbols` by removing and

Finally, apply the patches:
- vp9-get-format-rollback.patch to fix a VP9 decoder error handling issue.
