diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libopus')
3 files changed, 102 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libopus/default.nix b/nixpkgs/pkgs/development/libraries/libopus/default.nix new file mode 100644 index 000000000000..b2b095f5607e --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libopus/default.nix @@ -0,0 +1,73 @@ +{ lib +, stdenv +, fetchpatch +, fetchurl +, meson +, python3 +, ninja +, fixedPoint ? false +, withCustomModes ? true +, withIntrinsics ? stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isx86 +, withAsm ? false + +# tests +, ffmpeg-headless +}: + +stdenv.mkDerivation rec { + pname = "libopus"; + version = "1.4"; + + src = fetchurl { + url = "https://downloads.xiph.org/releases/opus/opus-${version}.tar.gz"; + sha256 = "sha256-ybMrQlO+WuY9H/Fu6ga5S18PKVG3oCrO71jjo85JxR8="; + }; + + patches = [ + ./fix-pkg-config-paths.patch + # Some tests time out easily on slower machines + ./test-timeout.patch + # Fix meson build for arm64. Remove with next release + # https://gitlab.xiph.org/xiph/opus/-/merge_requests/59 + (fetchpatch { + url = "https://gitlab.xiph.org/xiph/opus/-/commit/20c032d27c59d65b19b8ffbb2608e5282fe817eb.patch"; + hash = "sha256-2pX+0ay5PTyHL2plameBX2L1Q4aTx7V7RGiTdhNIuE4="; + }) + ]; + + postPatch = '' + patchShebangs meson/ + ''; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ + meson + python3 + ninja + ]; + + mesonFlags = [ + (lib.mesonBool "fixed-point" fixedPoint) + (lib.mesonBool "custom-modes" withCustomModes) + (lib.mesonEnable "intrinsics" withIntrinsics) + (lib.mesonEnable "rtcd" (withIntrinsics || withAsm)) + (lib.mesonEnable "asm" withAsm) + (lib.mesonEnable "docs" false) + ]; + + doCheck = !stdenv.isi686 && !stdenv.isAarch32; # test_unit_LPC_inv_pred_gain fails + + passthru.tests = { + inherit ffmpeg-headless; + }; + + meta = with lib; { + description = "Open, royalty-free, highly versatile audio codec"; + homepage = "https://opus-codec.org/"; + changelog = "https://gitlab.xiph.org/xiph/opus/-/releases/v${version}"; + license = licenses.bsd3; + platforms = platforms.all; + maintainers = [ ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/libopus/fix-pkg-config-paths.patch b/nixpkgs/pkgs/development/libraries/libopus/fix-pkg-config-paths.patch new file mode 100644 index 000000000000..d54b7f5558c9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libopus/fix-pkg-config-paths.patch @@ -0,0 +1,13 @@ +--- i/meson.build ++++ w/meson.build +@@ -591,8 +591,8 @@ pkgconf = configuration_data() + + pkgconf.set('prefix', join_paths(get_option('prefix'))) + pkgconf.set('exec_prefix', '${prefix}') +-pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir'))) +-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir'))) ++pkgconf.set('libdir', '${prefix}' / get_option('libdir')) ++pkgconf.set('includedir', '${prefix}' / get_option('includedir')) + pkgconf.set('VERSION', opus_version) + pkgconf.set('PC_BUILD', pc_build) + pkgconf.set('LIBM', libm.found() ? '-lm' : '') diff --git a/nixpkgs/pkgs/development/libraries/libopus/test-timeout.patch b/nixpkgs/pkgs/development/libraries/libopus/test-timeout.patch new file mode 100644 index 000000000000..e20f12cc1d54 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/libopus/test-timeout.patch @@ -0,0 +1,16 @@ +diff --git a/tests/meson.build b/tests/meson.build +index 5f3ac9d..74b2de7 100644 +--- a/tests/meson.build ++++ b/tests/meson.build +@@ -1,8 +1,8 @@ + # Tests that link to libopus + opus_tests = [ +- ['test_opus_api'], +- ['test_opus_decode', [], 60], +- ['test_opus_encode', 'opus_encode_regressions.c', 120], ++ ['test_opus_api', [], 60], ++ ['test_opus_decode', [], 120], ++ ['test_opus_encode', 'opus_encode_regressions.c', 240], + ['test_opus_padding'], + ['test_opus_projection'], + ] |