resampler: Precompute some common filter coefficients

While this is quite fast on x86 (order of a few microseconds), the
computation can take a few milliseconds on ARM (measured at 1.9ms (32000
-> 48000) and 3.3ms (32000 -> 44100) on a Cortex A53).

Let's precompute some common rates so that we can avoid this overhead on
each stream (or any other audioconvert) instantiation. The approach
taken here is to write a little program to create the resampler
instance, and run that on the host at compile-time to generate some
common rate conversions.
This commit is contained in:
Arun Raghavan 2024-08-07 12:30:10 -04:00
parent 46f89d8009
commit 70a7bae5d7
5 changed files with 260 additions and 1 deletions

View file

@ -105,10 +105,40 @@ if have_neon
simd_dependencies += audioconvert_neon
endif
sparesampledumpcoeffs_sources = [
'resample-native.c',
'resample-native-c.c',
'spa-resample-dump-coeffs.c',
]
sparesampledumpcoeffs = executable(
'spa-resample-dump-coeffs',
sparesampledumpcoeffs_sources,
c_args : [ cc_flags_native, '-DRESAMPLE_DISABLE_PRECOMP' ],
dependencies : [ spa_dep, mathlib_native ],
install : false,
native : true,
)
precomptuples = []
foreach tuple : get_option('resampler-precomp-tuples')
precomptuples += '-t ' + tuple
endforeach
resample_native_precomp_h = custom_target(
'resample-native-precomp.h',
output : 'resample-native-precomp.h',
capture : true,
command : [
sparesampledumpcoeffs,
] + precomptuples
)
audioconvert_lib = static_library('audioconvert',
['fmt-ops.c',
'channelmix-ops.c',
'peaks-ops.c',
resample_native_precomp_h,
'resample-native.c',
'resample-peaks.c',
'wavfile.c',