LS:MP FFmpeg 8.1 - how these DLLs were compiled
==============================================

FFmpeg configure line (as recorded by FFmpeg itself, FFMPEG_CONFIGURATION / avcodec_configuration()):

  configure --prefix='H:/LosSantosMultiplayer/vendor/ffmpeg/_build/packages/ffmpeg_x64-windows-release-dyn' --toolchain=msvc --enable-pic --disable-doc --enable-runtime-cpudetect --disable-autodetect --disable-everything --build-suffix=_lsmp --disable-network --target-os=win32 --enable-w32threads --enable-d3d11va --enable-d3d12va --enable-dxva2 --enable-mediafoundation --cc=clang-cl.exe --cxx=clang-cl.exe --windres=llvm-rc.exe --ld=lld-link.exe --nm=llvm-nm.exe --ar='ar-lib llvm-lib.exe' --ranlib=':' --disable-ffmpeg --disable-ffplay --disable-ffprobe --enable-avcodec --disable-avdevice --enable-avformat --disable-avfilter --enable-swresample --enable-swscale --disable-alsa --enable-amf --enable-libaom --enable-libsvtav1 --disable-libass --disable-avisynth --disable-bzlib --disable-libdav1d --disable-libfdk-aac --disable-libfontconfig --disable-libharfbuzz --disable-libfreetype --disable-libfribidi --disable-iconv --disable-libilbc --disable-lzma --disable-libmp3lame --disable-libmodplug --enable-cuda --enable-nvenc --disable-nvdec --disable-cuvid --enable-ffnvcodec --disable-opencl --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --disable-openssl --disable-schannel --enable-libopus --disable-sdl2 --disable-libsnappy --disable-libsoxr --disable-libspeex --disable-libssh --disable-libtensorflow --disable-libtesseract --disable-libtheora --disable-libvorbis --enable-libvpx --disable-vulkan --disable-libwebp --disable-libx264 --disable-libx265 --disable-libxml2 --enable-zlib --disable-libsrt --disable-libmfx --enable-libvpl --disable-vaapi --disable-libzmq --disable-librubberband --enable-cross-compile --disable-static --enable-shared --extra-cflags='-DHAVE_UNISTD_H=0' --pkg-config='H:/LosSantosMultiplayer/vendor/ffmpeg/_build/downloads/tools/msys2/3e71d1f8e22ab23f/mingw64/bin/pkg-config.exe' --pkg-config-flags=--static --enable-encoder='h264_nvenc,hevc_nvenc,av1_nvenc,h264_amf,hevc_amf,av1_amf,h264_qsv,hevc_qsv,av1_qsv,h264_d3d12va,hevc_d3d12va,av1_d3d12va,h264_mf,hevc_mf,av1_mf,aac_mf,libvpx_vp9,libaom_av1,ffv1,png,exr,flac,prores_ks,pcm_s16le,pcm_s24le,pcm_f32le,libopus,libsvtav1' --enable-muxer='mp4,mov,matroska,webm,avi,image2,wav,ogg' --enable-protocol=file --enable-parser='h264,hevc,av1,vp9,opus,flac,png,aac' --enable-bsfs --enable-optimizations --extra-cflags=-MD --extra-cxxflags=-MD --extra-ldflags='-libpath:H:/LosSantosMultiplayer/vendor/ffmpeg/_build/installed/x64-windows-release-dyn/lib' --arch=x86_64 --enable-asm --enable-x86asm

Compiler: clang version 22.1.8 (clang-cl, bundled with Visual Studio 18 Community: VC\Tools\Llvm\x64\bin)
Linker: lld-link (same LLVM), archiver llvm-lib, resource compiler llvm-rc, NASM from vcpkg, msys2 bash/make from vcpkg.
Compiler flags (cflags.rsp): -nologo -DWIN32 -D_WINDOWS -utf-8 -clang:-march=x86-64-v2 -clang:-mtune=generic -Gw -flto=thin -MD -O2 -Oi -Gy -DNDEBUG -Z7    -I "H:/LosSantosMultiplayer/vendor/ffmpeg/_build/installed/x64-windows-release-dyn/include"
Linker flags (ldflags.rsp):  -machine:x64 -nologo -DEBUG -INCREMENTAL:NO -OPT:REF -OPT:ICF -OPT:REF -OPT:ICF -PDBALTPATH:%_PDB% -Brepro

To rebuild: see SOURCE.md (below) and run build.ps1 (included in this archive, together with the vcpkg
overlay ports in port\, the triplet/toolchain in triplets\ and tools\).

----------------------------------------------------------------------------------------------------
# LS:MP FFmpeg build: corresponding source and build recipe

This file lets anyone rebuild, bit for bit where the toolchain allows, the FFmpeg DLLs that
LS:MP ships in `bin\ffmpeg\` (LGPL-2.1-or-later "corresponding source"). One script does the
whole thing: `vendor\ffmpeg\build.ps1`.

The ready-made source archive shipped with the binaries is **`bin\ffmpeg\source\lsmp-ffmpeg-source.zip`**
(repo: `vendor\ffmpeg\source\lsmp-ffmpeg-source.zip`). It contains:

* `ffmpeg-8.1\` - the exact FFmpeg source tree that was compiled (upstream n8.1 tarball + the port patches);
* `CHANGES.diff` - every change against the upstream n8.1 tarball (`git apply -p1`);
* `BUILD.txt` - the exact configure line, compiler, flags, dependency versions and URLs (+ this file);
* `port\`, `triplets\`, `tools\`, `build.ps1`, `SOURCE.md`, `NOTICE.txt` - the build recipe.

The same archive is published at <https://dl.lsmp.gg/clients/open-source/lsmp-ffmpeg-source.zip>
(LGPL 2.1 section 6(a): the complete corresponding source accompanies the binaries).

LS:MP Encoder (`lsmp-encoder.exe`, MIT) is the only program that loads these DLLs.

## Result

| DLL | FFmpeg library |
|---|---|
| `avcodec_lsmp-62.dll` | libavcodec 62 |
| `avformat_lsmp-62.dll` | libavformat 62 |
| `avutil_lsmp-60.dll` | libavutil 60 |
| `swresample_lsmp-6.dll` | libswresample 6 |
| `swscale_lsmp-9.dll` | libswscale 9 |

FFmpeg reports `License: LGPL version 2.1 or later`. libvpx, libaom, SVT-AV1 (+fastfeat), libopus,
zlib and libvpl are linked statically into these DLLs (all permissive licences); no other DLL is needed besides the
Microsoft VC++ 2015-2026 runtime (vcruntime140.dll / vcruntime140_1.dll, UCRT) and Windows system DLLs.

## FFmpeg source

* Version: **FFmpeg 8.1** (git tag `n8.1`)
* Tarball: <https://github.com/ffmpeg/ffmpeg/archive/n8.1.tar.gz>
* SHA-512: `1dee3967057619dd7f2f78c63de85bb97af16c974bd9225c2336d42c7c8765c04f77490aac36af2daf953bc52c7faa37750a09265e133708f6a1709028573834`
* Patches applied (all in `port\ffmpeg\`, from vcpkg's ffmpeg port 8.1, port-version 2):
  `0002-fix-msvc-link.patch`, `0003-fix-windowsinclude.patch`, `0004-dependencies.patch`,
  `0005-fix-nasm.patch`, `0007-fix-lib-naming.patch`, `0013-define-WINVER.patch`,
  `0024-fix-osx-host-c11.patch`, `0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch`,
  `0045-use-prebuilt-bin2c.patch`, `0046-fix-msvc-detection.patch`, `0047-fix-msvc-utf8.patch`
  (`0042-fix-arm64-linux.patch` is present in the port but not applied by its portfile).
  LS:MP does not patch FFmpeg's source code; LS:MP's changes are build options only.

## Build system

* vcpkg tool `2026-03-04-4b3e4c276b5b87a649e66341e11553e8c577459c`, vcpkg ports tree at commit
  `baababd134e882ca22d7432a915fc6feae882ce0` (<https://github.com/microsoft/vcpkg>), classic mode.
* Overlay ports (in this folder):
  * `port\ffmpeg` = vcpkg's `ports/ffmpeg` (8.1#2) with LS:MP changes marked `[LSMP]` in
    `portfile.cmake`/`vcpkg.json`: `--disable-everything` + explicit component whitelist,
    `--build-suffix=_lsmp`, `--disable-network`, no schannel, libvpl instead of libmfx,
    no nvdec/cuvid, `pkg-config --static` (static deps in a DLL build), hard failure if the
    licence is not LGPL 2.1+ or if a forbidden encoder (native aac, openh264, kvazaar, x264,
    x265, dnxhd, fdk-aac) is compiled in.
  * `port\libvpl` = new port for Intel libvpl 2.16.0 (vcpkg has none).
  * `port\libvpx` = vcpkg's `ports/libvpx` (1.16.0), unchanged except the msys2 fix below.
    **libvpx is the only component compiled with MSVC `cl.exe`** (VS 18 default toolset, `/O2 /Gw`,
    no LTO): vcpkg builds it through libvpx's generated MSBuild projects, which compile the
    `*_avx2.c` intrinsics files without per-file target flags; cl.exe accepts that, clang-cl
    rejects it ("always_inline function '_mm256_...' requires target feature 'avx2'").
  * `port\ffnvcodec` = vcpkg's `ports/ffnvcodec` (13.0.19.0), unchanged except the msys2 fix below.
  * `tools\msys-mandatory-aslr-fix.ps1` (called by the ffmpeg, libvpx and ffnvcodec overlays right
    after `vcpkg_acquire_msys`): on a machine with system-wide Mandatory ASLR
    (Exploit protection "Force randomization for images"), msys2's non-DYNAMICBASE binaries are
    relocated per process and Cygwin `fork()` fails (0xC0000142). The script sets
    `IMAGE_FILE_RELOCS_STRIPPED` on those msys2 images so they keep their preferred base. It only
    touches the build tools (in the build's own downloads root), never the produced binaries, and
    has no effect on machines without Mandatory ASLR.
* Overlay triplet `triplets\x64-windows-release-dyn.cmake` (x64, release only, dynamic CRT `/MD`,
  FFmpeg as DLLs, all other ports static) chainloading `triplets\x64-windows-clang-cl.toolchain.cmake`.
* vcpkg features: `ffmpeg[core,avcodec,avformat,swresample,swscale,nvcodec,amf,qsv,vpx,opus,aom,svt-av1,zlib]`
  (`svt-av1` is a feature added by the LS:MP overlay: `--enable-libsvtav1`).

### Toolchain

* Visual Studio 18 Community, Windows SDK 10.0.26100.0.
* Compiler/linker: the **public LLVM 22.1.8 bundled with Visual Studio**
  (`VC\Tools\Llvm\x64\bin`: `clang-cl.exe`, `lld-link.exe`, `llvm-lib.exe`, `llvm-rc.exe`, `llvm-nm.exe`;
  "C++ Clang tools for Windows" component). FFmpeg is configured with `--toolchain=msvc
  --cc=clang-cl.exe --cxx=clang-cl.exe --ld=lld-link.exe` (its msvc toolchain mode accepts
  clang-cl as compiler and lld-link as linker). FFmpeg's own `--enable-lto` cannot be used in this
  mode (configure requires cc and ld of the same type), so ThinLTO is passed through CFLAGS and
  lld-link performs the LTO step.
* Assembler: NASM fetched by vcpkg (x86 SIMD enabled: `--enable-asm --enable-x86asm`,
  `--enable-runtime-cpudetect`).
* msys2 (bash, make, pkgconf) fetched by vcpkg to run configure/make.
* Flags (from the triplet, added to vcpkg's release flags `/nologo /DWIN32 /D_WINDOWS /utf-8 /MD /O2 /Oi /Gy /DNDEBUG /Z7`):
  * C/C++: `/clang:-march=x86-64-v2 /clang:-mtune=generic /Gw -flto=thin`
    (libvpx, built with cl.exe: `/Gw` only). FFmpeg configure adds `-O2` and its own warnings/defines.
  * Link: `/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF /PDBALTPATH:%_PDB% /Brepro`
    (PDBs are produced but not shipped).

## Exact configure line

As recorded by FFmpeg (`FFMPEG_CONFIGURATION`, returned by `avcodec_configuration()`); the paths are those of
build.ps1's default build root `vendor\ffmpeg\_build`:

```text
configure --prefix='H:/LosSantosMultiplayer/vendor/ffmpeg/_build/packages/ffmpeg_x64-windows-release-dyn' --toolchain=msvc --enable-pic --disable-doc --enable-runtime-cpudetect --disable-autodetect --disable-everything --build-suffix=_lsmp --disable-network --target-os=win32 --enable-w32threads --enable-d3d11va --enable-d3d12va --enable-dxva2 --enable-mediafoundation --cc=clang-cl.exe --cxx=clang-cl.exe --windres=llvm-rc.exe --ld=lld-link.exe --nm=llvm-nm.exe --ar='ar-lib llvm-lib.exe' --ranlib=':' --disable-ffmpeg --disable-ffplay --disable-ffprobe --enable-avcodec --disable-avdevice --enable-avformat --disable-avfilter --enable-swresample --enable-swscale --disable-alsa --enable-amf --enable-libaom --enable-libsvtav1 --disable-libass --disable-avisynth --disable-bzlib --disable-libdav1d --disable-libfdk-aac --disable-libfontconfig --disable-libharfbuzz --disable-libfreetype --disable-libfribidi --disable-iconv --disable-libilbc --disable-lzma --disable-libmp3lame --disable-libmodplug --enable-cuda --enable-nvenc --disable-nvdec --disable-cuvid --enable-ffnvcodec --disable-opencl --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --disable-openssl --disable-schannel --enable-libopus --disable-sdl2 --disable-libsnappy --disable-libsoxr --disable-libspeex --disable-libssh --disable-libtensorflow --disable-libtesseract --disable-libtheora --disable-libvorbis --enable-libvpx --disable-vulkan --disable-libwebp --disable-libx264 --disable-libx265 --disable-libxml2 --enable-zlib --disable-libsrt --disable-libmfx --enable-libvpl --disable-vaapi --disable-libzmq --disable-librubberband --enable-cross-compile --disable-static --enable-shared --extra-cflags='-DHAVE_UNISTD_H=0' --pkg-config='H:/LosSantosMultiplayer/vendor/ffmpeg/_build/downloads/tools/msys2/3e71d1f8e22ab23f/mingw64/bin/pkg-config.exe' --pkg-config-flags=--static --enable-encoder='h264_nvenc,hevc_nvenc,av1_nvenc,h264_amf,hevc_amf,av1_amf,h264_qsv,hevc_qsv,av1_qsv,h264_d3d12va,hevc_d3d12va,av1_d3d12va,h264_mf,hevc_mf,av1_mf,aac_mf,libvpx_vp9,libaom_av1,ffv1,png,exr,flac,pcm_s16le,pcm_s24le,pcm_f32le,libopus,libsvtav1' --enable-muxer='mp4,mov,matroska,webm,avi,image2,wav,ogg' --enable-protocol=file --enable-parser='h264,hevc,av1,vp9,opus,flac,png,aac' --enable-bsfs --enable-optimizations --extra-cflags=-MD --extra-cxxflags=-MD --extra-ldflags='-libpath:H:/LosSantosMultiplayer/vendor/ffmpeg/_build/installed/x64-windows-release-dyn/lib' --arch=x86_64 --enable-asm --enable-x86asm
```

Result: `License: LGPL version 2.1 or later`; 27 encoders (aac_mf, av1_amf, av1_d3d12va, av1_mf, av1_nvenc,
av1_qsv, exr, ffv1, flac, h264_amf, h264_d3d12va, h264_mf, h264_nvenc, h264_qsv, hevc_amf, hevc_d3d12va,
hevc_mf, hevc_nvenc, hevc_qsv, libaom-av1, libopus, libsvtav1, libvpx-vp9, pcm_f32le, pcm_s16le, pcm_s24le, png),
0 decoders, 8 muxers (avi, image2, matroska, mov, mp4, ogg, wav, webm), 0 demuxers, protocol `file`,
parsers aac/ac3/av1/flac/h264/hevc/opus/png/vp9, all 49 bitstream filters, no filters/devices/hwaccels.

## Dependencies (statically linked into the FFmpeg DLLs, or headers only)

| Component | Version | Licence | Source (SHA-512) | vcpkg port patches |
|---|---|---|---|---|
| libvpx | 1.16.0 | BSD-3-Clause | <https://github.com/webmproject/libvpx/archive/v1.16.0.tar.gz> (`07f5e352411d6c0be331706d1835ac89bafbeddcbbac5542b473323766e9e974f4f68b33590f2aa50a7d8d69468a642b508cbb0a7c49a82c9933b07820f9c9d9`) | 0003-add-uwp-v142-and-v143-support, 0004-remove-library-suffixes, 0005-dont-expect-gnu-diff (overlay `port\libvpx`) |
| libaom | 3.13.1 (git `d772e334cc724105040382a977ebb10dfd393293`) | BSD-2-Clause + AOM patent licence | <https://aomedia.googlesource.com/aom> at that commit | aom-rename-static, aom-uninitialized-pointer, aom-fix-nasm (vcpkg `ports/aom` 3.13.1#2) |
| SVT-AV1 | 3.1.2 | BSD-3-Clause-Clear + AOM patent licence (PATENTS.md) | <https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v3.1.2/SVT-AV1-v3.1.2.tar.gz> (`4301e923965e3bff30a0fd2f74ae023d19260f91c2361d48ea7bc1718f501dcca73fa17cb8795b23392ca1bfbe1f4d55edcbb5ce06a2fa9e41da36c5166f527d`) | no-force-llvm, no-safestringlib, unvendor-fastfeat (vcpkg `ports/svt-av1` 3.1.2) |
| fast-C-src (fastfeat) | git `391d5e939eb1545d24c10533d7de424db8d9c191` | BSD-3-Clause | <https://github.com/edrosten/fast-C-src/archive/391d5e939eb1545d24c10533d7de424db8d9c191.tar.gz> (`d6f401e2f80193c4f1f99e1ef59af7107d674c515574cf513c5977c4c95c49c0520d2a6e6787f617b42d9e3bd93c78b8fa7f1d8dc8901351820590078e62130e`) | vcpkg `ports/fastfeat` 391d5e9#4 (adds CMakeLists.txt) |
| libopus | 1.5.2 | BSD-3-Clause | <https://github.com/xiph/opus/archive/v1.5.2.tar.gz> (`4ffefd9c035671024f9720c5129bfe395dea04f0d6b730041c2804e89b1db6e4d19633ad1ae58855afc355034233537361e707f26dc53adac916554830038fab`) | fix-pkgconfig-version (vcpkg `ports/opus` 1.5.2#1) |
| zlib | 1.3.1 | Zlib | <https://github.com/madler/zlib/archive/v1.3.1.tar.gz> (`8c9642495bafd6fad4ab9fb67f09b268c69ff9af0f4f20cf15dfc18852ff1f312bd8ca41de761b3f8d8e90e77d79f2ccacd3d4c5b19e475ecf09d021fdfe9088`) | 0001..0003 (vcpkg `ports/zlib` 1.3.1) |
| Intel libvpl | 2.16.0 | MIT | <https://github.com/intel/libvpl/archive/v2.16.0.tar.gz> (`bda6e8387f1e86eee86357a967ae58d9e87e2cada50317913ee8452e116220c5837643ea62c0b04baf9783daeca76d12ca63a34ce6acd6fb3ea2511bb47696bc`) | none (overlay `port\libvpl`) |
| nv-codec-headers | 13.0.19.0 | MIT | <https://github.com/FFmpeg/nv-codec-headers/archive/n13.0.19.0.tar.gz> (`103381914daf92ae11a409b2c9d0a9036bd40e3f7f244fa05202ed19c863f0630818c72e09e829b336754d727672b75d2789978a5875b355c3bc107fa9ca3ec6`) | none (headers only) |
| AMD AMF headers | 1.5.0 | MIT | <https://github.com/GPUOpen-LibrariesAndSDKs/AMF/releases/download/v1.5.0/AMF-headers-v1.5.0.tar.gz> (`37d618c846bd2ba77ee282ac152fc5f807631007fca8156fca7e541ad1d1cb23786794aaad1ee3d3eb30b2011c4336bec9011031202c3238d91fe48d1e92f97b`) | none (headers only) |

## Rebuild

```powershell
# prerequisites: VS 18 with "Desktop development with C++" + "C++ Clang tools for Windows",
# vcpkg cloned to C:\vcpkg and checked out at baababd134e882ca22d7432a915fc6feae882ce0
powershell -ExecutionPolicy Bypass -File vendor\ffmpeg\build.ps1
```

`build.ps1` runs `vcpkg install` with the overlay ports/triplets into `vendor\ffmpeg\_build\`
(never into `C:\vcpkg\installed`), then stages `bin\` (DLLs), `include\` (headers), `licenses\`
and copies DLLs + licences + NOTICE.txt + SOURCE.md to the dev install `H:\LSMP\bin\ffmpeg\`.

## Shipping notes

* The LS:MP publisher silently drops any path containing `.lib`, `.exp` or `.pdb`: no loose shipped file
  (DLLs, licences, NOTICE/SOURCE, the zip itself) may have such a name. Import libraries and PDBs stay in
  `vendor\ffmpeg\_build`. Entries inside the source zip are not affected.
* **When the FFmpeg major versions change** (new `*_lsmp-NN.dll` names), add the previous file names
  (e.g. `bin\ffmpeg\avcodec_lsmp-62.dll`, `avformat_lsmp-62.dll`, `avutil_lsmp-60.dll`, `swresample_lsmp-6.dll`,
  `swscale_lsmp-9.dll`) to `UpdateBuilder2\delete-list.txt` so updates remove them from player installs, and
  update the ABI majors expected by `Tools\lsmp-encoder`.
* After a rebuild, upload `source\lsmp-ffmpeg-source.zip` to `https://dl.lsmp.gg/clients/open-source/` so the
  published copy keeps matching the shipped binaries.
