Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
89cc773c
Commit
89cc773c
authored
Nov 23, 2022
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experimental optimizations for channel mapping.
parent
33854acc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
11 deletions
+71
-11
miniaudio.h
miniaudio.h
+71
-11
No files found.
miniaudio.h
View file @
89cc773c
...
@@ -52138,19 +52138,82 @@ static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChann
...
@@ -52138,19 +52138,82 @@ static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChann
}
}
}
}
for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
iFrame = 0;
/* Experiment: Try an optimized unroll for some specific cases to see how it improves performance. RESULT: Good gains. */
if (channelsOut == 8) {
/* Experiment 2: Expand the inner loop to see what kind of different it makes. RESULT: Small, but worthwhile gain. */
if (channelsIn == 2) {
for (; iFrame < frameCount; iFrame += 1) {
float accumulation[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
accumulation[0] += pFramesIn[iFrame*2 + 0] * weights[0][0];
accumulation[1] += pFramesIn[iFrame*2 + 0] * weights[1][0];
accumulation[2] += pFramesIn[iFrame*2 + 0] * weights[2][0];
accumulation[3] += pFramesIn[iFrame*2 + 0] * weights[3][0];
accumulation[4] += pFramesIn[iFrame*2 + 0] * weights[4][0];
accumulation[5] += pFramesIn[iFrame*2 + 0] * weights[5][0];
accumulation[6] += pFramesIn[iFrame*2 + 0] * weights[6][0];
accumulation[7] += pFramesIn[iFrame*2 + 0] * weights[7][0];
accumulation[0] += pFramesIn[iFrame*2 + 1] * weights[0][1];
accumulation[1] += pFramesIn[iFrame*2 + 1] * weights[1][1];
accumulation[2] += pFramesIn[iFrame*2 + 1] * weights[2][1];
accumulation[3] += pFramesIn[iFrame*2 + 1] * weights[3][1];
accumulation[4] += pFramesIn[iFrame*2 + 1] * weights[4][1];
accumulation[5] += pFramesIn[iFrame*2 + 1] * weights[5][1];
accumulation[6] += pFramesIn[iFrame*2 + 1] * weights[6][1];
accumulation[7] += pFramesIn[iFrame*2 + 1] * weights[7][1];
pFramesOut[iFrame * 8 + 0] = accumulation[0];
pFramesOut[iFrame * 8 + 1] = accumulation[1];
pFramesOut[iFrame * 8 + 2] = accumulation[2];
pFramesOut[iFrame * 8 + 3] = accumulation[3];
pFramesOut[iFrame * 8 + 4] = accumulation[4];
pFramesOut[iFrame * 8 + 5] = accumulation[5];
pFramesOut[iFrame * 8 + 6] = accumulation[6];
pFramesOut[iFrame * 8 + 7] = accumulation[7];
}
} else {
/* When outputting to 8 channels, we can do everything in groups of two 4x SIMD operations. */
for (; iFrame < frameCount; iFrame += 1) {
float accumulation[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
accumulation[0] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[0][iChannelIn];
accumulation[1] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[1][iChannelIn];
accumulation[2] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[2][iChannelIn];
accumulation[3] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[3][iChannelIn];
accumulation[4] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[4][iChannelIn];
accumulation[5] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[5][iChannelIn];
accumulation[6] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[6][iChannelIn];
accumulation[7] += pFramesIn[iFrame*channelsIn + iChannelIn] * weights[7][iChannelIn];
}
pFramesOut[iFrame * 8 + 0] = accumulation[0];
pFramesOut[iFrame * 8 + 1] = accumulation[1];
pFramesOut[iFrame * 8 + 2] = accumulation[2];
pFramesOut[iFrame * 8 + 3] = accumulation[3];
pFramesOut[iFrame * 8 + 4] = accumulation[4];
pFramesOut[iFrame * 8 + 5] = accumulation[5];
pFramesOut[iFrame * 8 + 6] = accumulation[6];
pFramesOut[iFrame * 8 + 7] = accumulation[7];
}
}
}
/* Leftover frames. */
for (; iFrame < frameCount; iFrame += 1) {
for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) {
for (iChannelOut = 0; iChannelOut < channelsOut; iChannelOut += 1) {
float accumulation = 0;
float accumulation = 0;
for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
accumulation += pFramesIn[iChannelIn] * weights[iChannelOut][iChannelIn];
accumulation += pFramesIn[i
Frame*channelsIn + i
ChannelIn] * weights[iChannelOut][iChannelIn];
}
}
pFramesOut[iChannelOut] = accumulation;
pFramesOut[i
Frame*channelsOut + i
ChannelOut] = accumulation;
}
}
pFramesOut += channelsOut;
pFramesIn += channelsIn;
}
}
} else {
} else {
/* Cannot pre-compute weights because not enough room in stack-allocated buffer. */
/* Cannot pre-compute weights because not enough room in stack-allocated buffer. */
...
@@ -52161,14 +52224,11 @@ static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChann
...
@@ -52161,14 +52224,11 @@ static void ma_channel_map_apply_f32(float* pFramesOut, const ma_channel* pChann
for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
for (iChannelIn = 0; iChannelIn < channelsIn; iChannelIn += 1) {
ma_channel channelIn = ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn);
ma_channel channelIn = ma_channel_map_get_channel(pChannelMapIn, channelsIn, iChannelIn);
accumulation += pFramesIn[iChannelIn] * ma_calculate_channel_position_rectangular_weight(channelOut, channelIn);
accumulation += pFramesIn[i
Frame*channelsIn + i
ChannelIn] * ma_calculate_channel_position_rectangular_weight(channelOut, channelIn);
}
}
pFramesOut[iChannelOut] = accumulation;
pFramesOut[i
Frame*channelsOut + i
ChannelOut] = accumulation;
}
}
pFramesOut += channelsOut;
pFramesIn += channelsIn;
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment