[igt-dev] [PATCH i-g-t] lib/igt_audio: normalize samples when extracting channel
Ville Syrjälä
ville.syrjala at linux.intel.com
Mon May 13 16:25:47 UTC 2019
On Mon, May 13, 2019 at 05:11:25PM +0300, Simon Ser wrote:
> audio_extract_channel_s32_le converts S32 samples to double. Prior to this
> patch, the output samples weren't normalized, resulting in values up to
> INT32_MAX.
>
> Future amplitude tests need to be format-agnostic (ie. shouldn't care whether
> the format used is S16 or S32). Thus, it is preferable to always use normalized
> double values.
>
> The current tests don't check the amplitude (or check it relative to the max.
> on the whole buffer), so they still pass without any modification.
>
> Signed-off-by: Simon Ser <simon.ser at intel.com>
> ---
> lib/igt_audio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/igt_audio.c b/lib/igt_audio.c
> index fd8cf07c0de3..f4b169595f6c 100644
> --- a/lib/igt_audio.c
> +++ b/lib/igt_audio.c
> @@ -389,7 +389,7 @@ size_t audio_extract_channel_s32_le(double *dst, size_t dst_cap,
> dst_len = src_len / n_channels;
> igt_assert(dst_len <= dst_cap);
> for (i = 0; i < dst_len; i++)
> - dst[i] = (double) src[i * n_channels + channel];
> + dst[i] = (double) src[i * n_channels + channel] / INT32_MAX;
Do we care that the most negative value could result
in a normalized value < -1.0?
>
> return dst_len;
> }
> --
> 2.21.0
>
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Ville Syrjälä
Intel
More information about the igt-dev
mailing list