Skip to content

Improve WavPack decoder performance#914

Merged
sbooth merged 4 commits into
mainfrom
wavpack-optimization
May 24, 2026
Merged

Improve WavPack decoder performance#914
sbooth merged 4 commits into
mainfrom
wavpack-optimization

Conversation

@sbooth
Copy link
Copy Markdown
Owner

@sbooth sbooth commented May 24, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 24, 2026 15:19
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-linter Review

Used clang-format v22.1.6

Click here for the full clang-format patch
diff --git a/Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m b/Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m
index b6c0217..74a5d9a 100644
--- a/Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m
+++ b/Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m
@@ -331 +331 @@ static int can_seek_callback(void *id) {
-    //int qmode = WavpackGetQualifyMode(_wpc);
+    // int qmode = WavpackGetQualifyMode(_wpc);
@@ -337 +337 @@ static int can_seek_callback(void *id) {
-    //} else if(qmode & QMODE_DSD_AUDIO) {
+        //} else if(qmode & QMODE_DSD_AUDIO) {
@@ -467 +467 @@ static int can_seek_callback(void *id) {
-        //int qmode = WavpackGetQualifyMode(_wpc);
+        // int qmode = WavpackGetQualifyMode(_wpc);
@@ -470 +470,2 @@ static int can_seek_callback(void *id) {
-            memcpy((unsigned char *)buffer.audioBufferList->mBuffers[0].mData + buffer.audioBufferList->mBuffers[0].mDataByteSize,
+            memcpy((unsigned char *)buffer.audioBufferList->mBuffers[0].mData +
+                           buffer.audioBufferList->mBuffers[0].mDataByteSize,
@@ -480 +481,2 @@ static int can_seek_callback(void *id) {
-                uint32_t *dst = (uint32_t *)((unsigned char *)buffer.audioBufferList->mBuffers[0].mData + buffer.audioBufferList->mBuffers[0].mDataByteSize);
+                uint32_t *dst = (uint32_t *)((unsigned char *)buffer.audioBufferList->mBuffers[0].mData +
+                                             buffer.audioBufferList->mBuffers[0].mDataByteSize);
@@ -496 +498,2 @@ static int can_seek_callback(void *id) {
-                memcpy((unsigned char *)buffer.audioBufferList->mBuffers[0].mData + buffer.audioBufferList->mBuffers[0].mDataByteSize,
+                memcpy((unsigned char *)buffer.audioBufferList->mBuffers[0].mData +
+                               buffer.audioBufferList->mBuffers[0].mDataByteSize,
@@ -501 +504,2 @@ static int can_seek_callback(void *id) {
-            float *dst = (float *)((unsigned char *)buffer.audioBufferList->mBuffers[0].mData + buffer.audioBufferList->mBuffers[0].mDataByteSize);
+            float *dst = (float *)((unsigned char *)buffer.audioBufferList->mBuffers[0].mData +
+                                   buffer.audioBufferList->mBuffers[0].mDataByteSize);
@@ -507 +511 @@ static int can_seek_callback(void *id) {
-            //float scaleFactor = ldexpf(1.0f, -(WavpackGetBitsPerSample(_wpc) - 1));
+            // float scaleFactor = ldexpf(1.0f, -(WavpackGetBitsPerSample(_wpc) - 1));

Have any feedback or feature suggestions? Share it here.

Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
@github-actions github-actions Bot dismissed their stale review May 24, 2026 15:22

outdated suggestion

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve WavPack decoding throughput by switching the decoder’s PCM output to interleaved buffers and using bulk/vectorized operations (memcpy, SIMD, vDSP) instead of per-channel deinterleaving loops.

Changes:

  • Switch WavPack decoder output formats from non-interleaved to interleaved for float and integer PCM.
  • Replace manual deinterleaving/loops with bulk memcpy, SIMD shifting for lossless integer alignment, and Accelerate/vDSP for lossy int→float conversion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m
Comment thread Sources/CSFBAudioEngine/Decoders/SFBWavPackDecoder.m Outdated
@sbooth sbooth merged commit 484f54e into main May 24, 2026
2 of 3 checks passed
@sbooth sbooth deleted the wavpack-optimization branch May 24, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants