From 4a5a212f35cc0a38c129c67b2507f857ca6e7054 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Mon, 15 Aug 2022 03:04:07 +0200 Subject: [PATCH] bestsource: Switch to GetPackedAudio() After vapoursynth/bestsource#7 , BestSource now has a function to get the packed audio instead, so we just use that directly. --- src/audio_provider_bestsource.cpp | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/audio_provider_bestsource.cpp b/src/audio_provider_bestsource.cpp index 7229df827..5390788dc 100644 --- a/src/audio_provider_bestsource.cpp +++ b/src/audio_provider_bestsource.cpp @@ -75,37 +75,8 @@ catch (AudioException const& err) { throw agi::AudioProviderError("Failed to create BestAudioSource"); } -// Taken from BestSource code and reversed -template -static void PackChannels(const uint8_t *Src, void *Dst, size_t Length, size_t Channels) { - const T *S = reinterpret_cast(Src); - T *D = reinterpret_cast(Dst); - for (size_t i = 0; i < Length; i++) { - for (size_t c = 0; c < Channels; c++) - D[c] = S[Length * c]; - S += 1; - D += Channels; - } -} - void BSAudioProvider::FillBuffer(void *Buf, int64_t Start, int64_t Count) const { - // BS unpacked the channels, so until it gets a feature to disable that, let's just - // pack them in the same way they were unpacked - std::vector unpacked_buf(channels * bytes_per_sample * Count); - std::vector bufs(channels); - for (int i = 0; i < channels; i++) { - bufs[i] = unpacked_buf.data() + i * bytes_per_sample * Count; - } - const_cast(bs).GetAudio(bufs.data(), Start, Count); - - if (bytes_per_sample == 1) - PackChannels(unpacked_buf.data(), Buf, Count, channels); - else if (bytes_per_sample == 2) - PackChannels(unpacked_buf.data(), Buf, Count, channels); - else if (bytes_per_sample == 4) - PackChannels(unpacked_buf.data(), Buf, Count, channels); - else if (bytes_per_sample == 8) - PackChannels(unpacked_buf.data(), Buf, Count, channels); + const_cast(bs).GetPackedAudio(reinterpret_cast(Buf), Start, Count); } }