diff --git a/default.nix b/default.nix index da92337..db7fdf0 100644 --- a/default.nix +++ b/default.nix @@ -8,6 +8,7 @@ in addgrain = prev.callPackage ./plugins/addgrain { }; autocrop = prev.callPackage ./plugins/autocrop { }; awarpsharp2 = prev.callPackage ./plugins/awarpsharp2 { }; + bestaudiosource = prev.callPackage ./plugins/bestaudiosource { }; beziercurve = prev.callPackage ./plugins/beziercurve { }; bifrost = prev.callPackage ./plugins/bifrost { }; bilateral = prev.callPackage ./plugins/bilateral { }; diff --git a/plugins/bestaudiosource/0001-Fix-audio-source-iteration-with-Wsign-compare.patch b/plugins/bestaudiosource/0001-Fix-audio-source-iteration-with-Wsign-compare.patch new file mode 100644 index 0000000..f393135 --- /dev/null +++ b/plugins/bestaudiosource/0001-Fix-audio-source-iteration-with-Wsign-compare.patch @@ -0,0 +1,58 @@ +From 060ebbed04ba4ce351c4f9f641308e1b84ee30f5 Mon Sep 17 00:00:00 2001 +From: Simon Bruder +Date: Mon, 25 Apr 2022 11:33:22 +0200 +Subject: [PATCH] Fix audio source iteration with -Wsign-compare + +--- + src/audiosource.cpp | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/audiosource.cpp b/src/audiosource.cpp +index 9d34f47..88d9820 100644 +--- a/src/audiosource.cpp ++++ b/src/audiosource.cpp +@@ -292,7 +292,7 @@ bool BestAudioSource::GetExactDuration() { + if (HasExactNumAudioSamples) + return true; + int Index = -1; +- for (int i = 0; i < MaxAudioSources; i++) { ++ for (size_t i = 0; i < MaxAudioSources; i++) { + if (Decoders[i] && (Index < 0 || Decoders[Index]->GetFrameNumber() < Decoders[i]->GetFrameNumber())) + Index = i; + } +@@ -386,14 +386,14 @@ void BestAudioSource::GetAudio(uint8_t * const * const Data, int64_t Start, int6 + return; + + int Index = -1; +- for (int i = 0; i < MaxAudioSources; i++) { ++ for (size_t i = 0; i < MaxAudioSources; i++) { + if (Decoders[i] && Decoders[i]->GetSamplePosition() <= Start && (Index < 0 || Decoders[Index]->GetSamplePosition() < Decoders[i]->GetSamplePosition())) + Index = i; + } + + // If an empty slot exists simply spawn a new decoder there + if (Index < 0) { +- for (int i = 0; i < MaxAudioSources; i++) { ++ for (size_t i = 0; i < MaxAudioSources; i++) { + if (!Decoders[i]) { + Index = i; + Decoders[i] = new LWAudioDecoder(Source.c_str(), Track, FFOptions); +@@ -405,7 +405,7 @@ void BestAudioSource::GetAudio(uint8_t * const * const Data, int64_t Start, int6 + // No far enough back decoder exists and all slots are occupied so evict a random one + if (Index < 0) { + Index = 0; +- for (int i = 0; i < MaxAudioSources; i++) { ++ for (size_t i = 0; i < MaxAudioSources; i++) { + if (Decoders[i] && DecoderLastUse[i] < DecoderLastUse[Index]) + Index = i; + } +@@ -458,4 +458,4 @@ void BestAudioSource::GetAudio(uint8_t * const * const Data, int64_t Start, int6 + + if (Count != 0) + throw AudioException("Code error, failed to provide all samples"); +-} +\ No newline at end of file ++} +-- +2.33.1 + diff --git a/plugins/bestaudiosource/default.nix b/plugins/bestaudiosource/default.nix new file mode 100644 index 0000000..4d5d265 --- /dev/null +++ b/plugins/bestaudiosource/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, ffmpeg, vapoursynth }: + +stdenv.mkDerivation rec { + pname = "bestaudiosource"; + version = "unstable-2021-09-28"; + + src = fetchFromGitHub { + owner = "vapoursynth"; + repo = pname; + rev = "87d6cba4a119f347e146de8f9751646b6f21284c"; + sha256 = "sha256-ylNPv/QOBcJk6QTuXL/W6kJGJ+7Yg7WEFS5HEp7AIYY="; + }; + + patches = [ + ./0001-Fix-audio-source-iteration-with-Wsign-compare.patch + ]; + + nativeBuildInputs = [ meson ninja pkg-config ]; + buildInputs = [ ffmpeg vapoursynth ]; + + postPatch = '' + substituteInPlace meson.build \ + --replace "vapoursynth_dep.get_pkgconfig_variable('libdir')" "get_option('libdir')" + ''; + + meta = with lib; { + description = "Audio source and FFmpeg wrapper plugin for VapourSynth"; + homepage = "https://github.com/vapoursynth/bestaudiosource"; + license = licenses.mit; + maintainers = with maintainers; [ sbruder ]; + platforms = platforms.all; + }; +}