1{ lib
2, stdenv
3, fetchpatch
4, fetchurl
5, meson
6, python3
7, ninja
8, fixedPoint ? false
9, withCustomModes ? true
10, withIntrinsics ? stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isx86
11, withAsm ? false
12
13# tests
14, ffmpeg-headless
15}:
16
17stdenv.mkDerivation rec {
18 pname = "libopus";
19 version = "1.4";
20
21 src = fetchurl {
22 url = "https://downloads.xiph.org/releases/opus/opus-${version}.tar.gz";
23 sha256 = "sha256-ybMrQlO+WuY9H/Fu6ga5S18PKVG3oCrO71jjo85JxR8=";
24 };
25
26 patches = [
27 ./fix-pkg-config-paths.patch
28 # Some tests time out easily on slower machines
29 ./test-timeout.patch
30 # Fix meson build for arm64. Remove with next release
31 # https://gitlab.xiph.org/xiph/opus/-/merge_requests/59
32 (fetchpatch {
33 url = "https://gitlab.xiph.org/xiph/opus/-/commit/20c032d27c59d65b19b8ffbb2608e5282fe817eb.patch";
34 hash = "sha256-2pX+0ay5PTyHL2plameBX2L1Q4aTx7V7RGiTdhNIuE4=";
35 })
36 ];
37
38 postPatch = ''
39 patchShebangs meson/
40 '';
41
42 outputs = [ "out" "dev" ];
43
44 nativeBuildInputs = [
45 meson
46 python3
47 ninja
48 ];
49
50 mesonFlags = [
51 (lib.mesonBool "fixed-point" fixedPoint)
52 (lib.mesonBool "custom-modes" withCustomModes)
53 (lib.mesonEnable "intrinsics" withIntrinsics)
54 (lib.mesonEnable "rtcd" (withIntrinsics || withAsm))
55 (lib.mesonEnable "asm" withAsm)
56 (lib.mesonEnable "docs" false)
57 ];
58
59 doCheck = !stdenv.isi686 && !stdenv.isAarch32; # test_unit_LPC_inv_pred_gain fails
60
61 passthru.tests = {
62 inherit ffmpeg-headless;
63 };
64
65 meta = with lib; {
66 description = "Open, royalty-free, highly versatile audio codec";
67 homepage = "https://opus-codec.org/";
68 changelog = "https://gitlab.xiph.org/xiph/opus/-/releases/v${version}";
69 license = licenses.bsd3;
70 platforms = platforms.all;
71 maintainers = [ ];
72 };
73}