Skip to content

Audio: Volume: Optimize read frag usage from zero crossing search - #5328

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
singalsu:volume_zc_read_frag_optimize
Feb 23, 2022
Merged

Audio: Volume: Optimize read frag usage from zero crossing search#5328
lgirdwood merged 1 commit into
thesofproject:mainfrom
singalsu:volume_zc_read_frag_optimize

Conversation

@singalsu

@singalsu singalsu commented Feb 8, 2022

Copy link
Copy Markdown
Collaborator

This patch optimizes the buffer seek for zero crossing. The
audio_stream_read_frag_s16/24/32() is replaced with block
based search. The search block is defined by new stream function
audio_stream_rewind_bytes_without_wrap(). The other added stream
function audio_stream_rewind_wrap() handles the pointer wrap
when reading backwards.

The saving during volume ramping is from 12.4 MCPS to 10.8 MCPS
(1.6 MCPS) for 16 bit play, and 16.4 MCPS to 14.4 MCPS (2 MCPS)
for 24 bit and 32 bit playback.

Signed-off-by: Seppo Ingalsuo seppo.ingalsuo@linux.intel.com

@singalsu

singalsu commented Feb 8, 2022

Copy link
Copy Markdown
Collaborator Author

Here's a plot of execution times while ramping volume. To see better the impact this topology was changed to use 800 ms long ramp with zero-crossings detect. The last 200 ms in 1000 ms long capture is lower load due to completed ramp. Upper row is original and lower row is optimized.

Screenshot from 2022-02-08 16-36-00

@singalsu

singalsu commented Feb 8, 2022

Copy link
Copy Markdown
Collaborator Author

Something wrong -- I'm getting different zero crossings locations (debugged with testbench printtf()) with optimized 32 bit, finding out why ...

Comment thread src/audio/volume/volume.c Outdated
This patch optimizes the buffer seek for zero crossing. The
audio_stream_read_frag_s16/24/32() is replaced with block
based search. The search block is defined by new stream function
audio_stream_rewind_bytes_without_wrap(). The other added stream
function audio_stream_rewind_wrap() handles the pointer wrap
when reading backwards.

The saving during volume ramping is from 12.4 MCPS to 10.8 MCPS
(1.6 MCPS) for 16 bit play, and 16.4 MCPS to 14.4 MCPS (2 MCPS)
for 24 bit and 32 bit playback.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
singalsu force-pushed the volume_zc_read_frag_optimize branch from 9a35400 to 4ea90b7 Compare February 8, 2022 17:07
@singalsu
singalsu marked this pull request as ready for review February 8, 2022 17:08
@singalsu

singalsu commented Feb 8, 2022

Copy link
Copy Markdown
Collaborator Author

I think there's a mistake in zero-crossing search in the original code. This patch is not changing the functionality, just speeds it. The prev_sum is not updated when crossing is found so I think it misses every other. Also I think in start the prev_sum should be set to sum of last frame, then seek backwards and update sum and compare. If issue is confirmed I would do other PR.

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu any update - ready to merge now ?

@singalsu

Copy link
Copy Markdown
Collaborator Author

@singalsu any update - ready to merge now ?

This is OK for me. I didn't change zero crossing search algorithm, this performs identically to current version but is faster.

@lgirdwood
lgirdwood merged commit be752fd into thesofproject:main Feb 23, 2022
@singalsu
singalsu deleted the volume_zc_read_frag_optimize branch September 15, 2022 13:16
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