public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] lib/igt_audio: normalize samples when extracting channel
Date: Mon, 13 May 2019 17:11:25 +0300	[thread overview]
Message-ID: <20190513141125.7902-1-simon.ser@intel.com> (raw)

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@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;

 	return dst_len;
 }
--
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-05-13 14:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13 14:11 Simon Ser [this message]
2019-05-13 15:38 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_audio: normalize samples when extracting channel Patchwork
2019-05-13 16:25 ` [igt-dev] [PATCH i-g-t] " Ville Syrjälä
2019-05-14  6:32   ` Ser, Simon
2019-05-14 12:29     ` Ville Syrjälä
2019-05-13 18:36 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190513141125.7902-1-simon.ser@intel.com \
    --to=simon.ser@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox