[igt-dev] [PATCH i-g-t 3/5] lib/igt_audio: add support for S24_LE and S32_LE signal generation
Martin Peres
martin.peres at linux.intel.com
Mon May 20 12:14:21 UTC 2019
On 17/05/2019 19:02, Simon Ser wrote:
> This adds two new helpers to generate S24_LE and S32_LE signals.
I got a little taken aback by the multiplication... until I remembered
that the doubles were between [0, 1].
I think this patch could add a small note (see below), but regardless of
what you chose to do:
Reviewed-by: Martin Peres <martin.peres at linux.intel.com>
>
> Signed-off-by: Simon Ser <simon.ser at intel.com>
> ---
> lib/igt_audio.c | 30 ++++++++++++++++++++++++++++++
> lib/igt_audio.h | 4 ++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/lib/igt_audio.c b/lib/igt_audio.c
> index 90d16fe4bd11..876084a994c3 100644
> --- a/lib/igt_audio.c
> +++ b/lib/igt_audio.c
> @@ -262,6 +262,36 @@ void audio_signal_fill_s16_le(struct audio_signal *signal, int16_t *buffer,
> free(tmp);
> }
>
> +void audio_signal_fill_s24_le(struct audio_signal *signal, int32_t *buffer,
> + size_t samples)
> +{
> + double *tmp;
> + size_t i;
> +
> + tmp = malloc(sizeof(double) * signal->channels * samples);
> + audio_signal_fill(signal, tmp, samples);
> +
/* NOTE: audio_signal_fill() returns samples between [0, 1] */
> + for (i = 0; i < signal->channels * samples; ++i)
> + buffer[i] = 0xFFFFFF * tmp[i];
> +
> + free(tmp);
> +}
> +
> +void audio_signal_fill_s32_le(struct audio_signal *signal, int32_t *buffer,
> + size_t samples)
> +{
> + double *tmp;
> + size_t i;
> +
> + tmp = malloc(sizeof(double) * signal->channels * samples);
> + audio_signal_fill(signal, tmp, samples);
> +
/* NOTE: audio_signal_fill() returns samples between [0, 1] */
> + for (i = 0; i < signal->channels * samples; ++i)
> + buffer[i] = UINT32_MAX * tmp[i];
> +
> + free(tmp);
> +}
> +
> /**
> * Checks that frequencies specified in signal, and only those, are included
> * in the input data.
> diff --git a/lib/igt_audio.h b/lib/igt_audio.h
> index f915d55d63fc..c8de70871faa 100644
> --- a/lib/igt_audio.h
> +++ b/lib/igt_audio.h
> @@ -44,6 +44,10 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
> size_t buffer_len);
> void audio_signal_fill_s16_le(struct audio_signal *signal, int16_t *buffer,
> size_t buffer_len);
> +void audio_signal_fill_s24_le(struct audio_signal *signal, int32_t *buffer,
> + size_t buffer_len);
> +void audio_signal_fill_s32_le(struct audio_signal *signal, int32_t *buffer,
> + size_t buffer_len);
> bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
> int channel, const double *samples, size_t samples_len);
> size_t audio_extract_channel_s32_le(double *dst, size_t dst_cap,
>
More information about the igt-dev
mailing list