[pulseaudio-discuss] [PATCH 1/4] resampler-test: Add zero padding.

Alexander E. Patrakov patrakov at gmail.com
Fri Jan 10 04:54:27 PST 2014

poljar wrote:
> For the resampler test we create 10 samples and run them through a
> resampler and then we try to run run the resampler backwards. This
> crashes if our original 10 samples are not enough to produce any output
> on the original run.

> This patch adds additional zero padding to our original 10 samples. This
> way all resample methods produce enough output to run the resampler
> backwards.
> ---
>  src/tests/resampler-test.c | 40 ++++++++++++++++++++++++++++++++--------
>  1 file changed, 32 insertions(+), 8 deletions(-)
> diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c
> index 566b69f..84c21ad 100644
> --- a/src/tests/resampler-test.c
> +++ b/src/tests/resampler-test.c
> @@ -40,6 +40,12 @@
>  #include <pulsecore/sample-util.h>
>  #include <pulsecore/core-util.h>
> +/* The size of the padding is determined by running the resampler
> + * test with different padding values and watching if it crashes.
> + * As it turns out src-sinc-best-quality needs a huge amount of
> + * samples. At least 278 samples are needed so round it up to 280 */
> +#define PADDING 280

I have two contradicting opinions about this, but they are just that - my 
opinions. Pick one of them.

1. It would be nice to put a link to http://www.mega-nerd.com/SRC/faq.html#Q006 here. It explains why this is needed with some 

2. Resamplers that insist on the equivalent of speex's 
speex_resampler_skip_zeros() (and that's what happens here) are IMHO somewhat 
broken for streaming conversions. Instead of buffering the initial samples, a 
good resampler should have pretended that there are enough zeros before them, 
and should have indicated the latency introduced by this. The test caught what 
could be classified as a real bug (chopping off the initial output samples, 
produced by combining the implied silence before the input, the initial input 
samples, and the resampler's window over that), and you are changing it as if 
this caught a false positive. OTOH if it cannot be fixed or worked around 
inside pulseaudio, all that remains is to put a link to http://www.mega-nerd.com/SRC/faq.html#Q006 here.

Alexander E. Patrakov

More information about the pulseaudio-discuss mailing list