[pulseaudio-discuss] [PATCH] When Speex is compiled with FIXED_POINT defined, it scales float input to +/-32768 instead of +/-1. But Pulseaudio invokes speex float method with input in range of +/-1. So in order to make floating point resamplers work with Speex compiled with FIXED_POINT, we need to rescale the input to Speex.

Damir Jelić poljarinho at gmail.com
Wed Dec 25 05:09:48 PST 2013


Hi Fahad.

Please don't put the whole commit message into the subject of the
commit, here are some useful commit message guidelines:
    https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines

On Mon, Dec 23, 2013 at 11:09:17PM +0500, Fahad Arslan wrote:
> From: Fahad Arslan <Fahad_Arslan at mentor.com>
> 
> Signed-off-by: Fahad Arslan <Fahad_Arslan at mentor.com>
> ---
>  src/pulsecore/resampler.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
> index f0c663f..34bdfc3 100644
> --- a/src/pulsecore/resampler.c
> +++ b/src/pulsecore/resampler.c
> @@ -1435,7 +1435,7 @@ static int libsamplerate_init(pa_resampler *r) {
>  
>  static unsigned speex_resample_float(pa_resampler *r, const pa_memchunk *input, unsigned in_n_frames, pa_memchunk *output, unsigned *out_n_frames) {
>      float *in, *out;
> -    uint32_t inf = in_n_frames, outf = *out_n_frames;
> +    uint32_t inf = in_n_frames, outf = *out_n_frames, i;
>      SpeexResamplerState *state;
>  
>      pa_assert(r);
> @@ -1448,6 +1448,11 @@ static unsigned speex_resample_float(pa_resampler *r, const pa_memchunk *input,
>      in = pa_memblock_acquire_chunk(input);
>      out = pa_memblock_acquire_chunk(output);
>  
> +    /* Speex float API scale range is +/-32768 instead of +/-1.
> +       So rescale input before passing it to Speex. */
> +    for (i = 0; i < inf; i++)
> +        in[i] = 32768.*in[i];

This breaks speex-float if it isn't compiled with FIXED_POINT defined
(most desktop machines don't use FIXED_POINT), also I think that this
kind of logic should go into the choose_work_format() function inside of
resampler.c, no?

> +    

Trailing whitespace.

>      pa_assert_se(speex_resampler_process_interleaved_float(state, in, &inf, out, &outf) == 0);
>  
>      pa_memblock_release(input->memblock);
> -- 
> 1.7.9.5
> 


More information about the pulseaudio-discuss mailing list