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: Multiband DRC: Optimize source and sink buffers access #5511

Merged
merged 4 commits into from
Mar 14, 2022

Conversation

singalsu
Copy link
Collaborator

No description provided.

…ions

This patch adds functions to retrieve number of PCM samples until
source or sink buffer circular wrap need.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch replaces the audio stream read/write frag functions
based source read and sink write operations. The processing is
performed in blocks those are based on number of samples from
audio_stream_samples_without_wrap_s16/s24/32() function.

On TGL-H and stereo 48 kHz playback stream the MCPS is decreased
from 216.8/216.8/216.0 to 201.6/200.4/200.8 for s16/s24/s32
formats. The saving is in average 15.6 MCPS.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds build of topologies sof-hda-generic-multiband-drc.tplg
and sof-hda-generic-2ch-multiband-drc.tplg. The processing happens in
pipeline part after mixer. Volume is controlled in PGA before mixer.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch fixes issue in testbench when multiband-drc is executed.
Since the library libsof_multiband_drc.so includes also crossover
and drc component sources the topology component register is done
for drc instead of multiband-drc. Therefore testench executes drc
when multiband-drc run is attempted.

Placement of multiband-drc as last in sources list is a workaround
to fix but recommended now since this impacts only testbench. The
proper fix of moving DRC and Crossover parts to library would be
a much larger change.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
Copy link
Collaborator Author

singalsu commented Mar 10, 2022

The audio processing times for a 20s long stereo 48 kHz clip are shown in next plot. The saving is in average 40 us or 15.6 MCPS. Upper row is before optimization, lower row is after optimization.

Screenshot from 2022-03-10 17-22-00

@singalsu
Copy link
Collaborator Author

singalsu commented Mar 10, 2022

The component passed this testbench samples comparison test. In addition to changes in patch for testbench run line cd->process_enabled = 1; was added to multiband_drc_prepare() to switch the processing on.

$ cat tb_compare_step1.sh
#!/bin/sh

set -e

COMP=multiband-drc
CLIP=~/Music/misc/vanhalen.wav

cd $SOF_WORKSPACE/sof
#git checkout main

scripts/build-tools.sh 
scripts/build-tools.sh -t
scripts/rebuild-testbench.sh 
cd tools/test/audio

convert_raw_s24.sh "$CLIP" in_s24.raw
convert_raw_s16.sh "$CLIP" in_s16.raw
convert_raw_s32.sh "$CLIP" in_s32.raw

./comp_run.sh $COMP playback 16 16 48000 48000 in_s16.raw ref_s16.raw 2> /dev/null
./comp_run.sh $COMP playback 24 24 48000 48000 in_s24.raw ref_s24.raw 2> /dev/null
./comp_run.sh $COMP playback 32 32 48000 48000 in_s32.raw ref_s32.raw 2> /dev/null

echo Next git checkout the branch to test


$ cat tb_compare_step2.sh
#!/bin/sh

set -e

COMP=multiband-drc

cd $SOF_WORKSPACE/sof
scripts/build-tools.sh 
scripts/build-tools.sh -t
scripts/rebuild-testbench.sh 
cd tools/test/audio

./comp_run.sh $COMP playback 16 16 48000 48000 in_s16.raw pr_s16.raw 2> /dev/null
./comp_run.sh $COMP playback 24 24 48000 48000 in_s24.raw pr_s24.raw 2> /dev/null
./comp_run.sh $COMP playback 32 32 48000 48000 in_s32.raw pr_s32.raw 2> /dev/null

echo Compare s16 ...
cmp -l pr_s16.raw ref_s16.raw

echo Compare s24 ...
cmp -l pr_s24.raw ref_s24.raw

echo Compare s32 ...
cmp -l pr_s32.raw ref_s32.raw

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.

@cujomalainey @johnylin76 fyi any comments ?

@johnylin76
Copy link
Contributor

Looks good to me. Thanks a lot, Seppo.

@lgirdwood lgirdwood merged commit 4013215 into thesofproject:main Mar 14, 2022
@singalsu singalsu deleted the mbdrc_read_write_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.

3 participants