Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio: Volume: Add IPC4 native Q1.31 mode and optimize #9900

Merged
merged 3 commits into from
Mar 21, 2025

Conversation

singalsu
Copy link
Collaborator

No description provided.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@singalsu whats the overall MCPS delta for this PR ?

@singalsu
Copy link
Collaborator Author

singalsu commented Mar 14, 2025

@singalsu whats the overall MCPS delta for this PR ?

Here's savings for peakvolume and gain component builds. I did this while checking spectrograms with process_test('gain', <16/24/32>, <16/24/32> , 48000, 0, 1, 'xt-run'); for the testbench xt builds. All conversions produced clean audio.

Screenshot from 2025-03-14 20-04-44

#define VOL_MAX INT32_MAX

/** \brief Volume 0dB value. */
#define VOL_ZERO_DB INT32_MAX
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it's correct and maybe it's just me, but it does look a bit confusing, or at least unclear. Maybe at least a bit larger comment could help. Is this the same value because by convention volume doesn't get positive or do these two macros have different usage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In IPC4 due to Q1.31 format the max volume and (near) 0 dB gain value are the same since the max linear gain is 0.9999... In IPC3 we used Q-formats those allowed amplification in volume component. I don't want to yet remove the IPC3 gain range since we still have IPC3 in the code. But we can do it later if we remove IPC3 from git main. But I don't think the Q1.31 is a good choice since it can't represent exactly gain 1 and it can't amplify. But that's what we have now.

ae_int64 mult0;
ae_int64 mult1;
//ae_int64 mult0;
//ae_int64 mult1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

left-over?

@singalsu singalsu marked this pull request as ready for review March 17, 2025 15:55
@singalsu
Copy link
Collaborator Author

Failed one quickbuild test due to Python timeout. Retrying.

Only the output align register needs to be cleared. The priming
of input stream with e.g. AE_ZALIGN128() fully initializes it.

Signed-off-by: Seppo Ingalsuo <[email protected]>
These registers are set later in the code in the load
instructions. This change saves a bit of code size and
a tiny amount of processor cycles.

Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch adds Q1.31 gain to existing options Q8.16, Q8.23.
The Q1.31 x Q1.31 or Q1.31 x Q1.15 to multiplications are
directly supported by HiFi instructions without need for
additional shifts. Also for HiFi5 the most parallel
multiplications are available for suitable Q1.31 product.

In HiFi5 version s24 and s32 peakvolume and gain the single
multiply instruction AE_MULF32S_HH() or AE_MULF32S_LL() is
changed to quad multiply AE_MULF2P32X4RS().

In HiFi4 and HiFi3 version s24 and s32 the single multiply is
changed to dual multiply AE_MULFP32X2RS().

The MCPS saving in HiFi3/4/5 builds for gain and peakvolume
with 16/24/32 bits stereo 48 kHz formats varies between 0.5%
and 6.1%. At smallest the saving is 0.02 MCPS and at largest
0.2 MCPS.

The savings are quite small because the volume gain computation
has been already optimized and most of the load has happens in
SOF modules framework instead of gain multiplications.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@kv2019i kv2019i merged commit f3e3403 into thesofproject:main Mar 21, 2025
45 of 49 checks passed
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.

4 participants