diff mbox

[i-g-t,2/6] lib/audio: Replace sqrt(a*a + b*b) with hypot(a, b)

Message ID 20180514080251.11224-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson May 14, 2018, 8:02 a.m. UTC
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_audio.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Tvrtko Ursulin May 14, 2018, 10:20 a.m. UTC | #1
On 14/05/2018 09:02, Chris Wilson wrote:
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   lib/igt_audio.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/lib/igt_audio.c b/lib/igt_audio.c
> index 2321d1c6e..229ce6c69 100644
> --- a/lib/igt_audio.c
> +++ b/lib/igt_audio.c
> @@ -266,9 +266,7 @@ bool audio_signal_detect(struct audio_signal *signal, int channels,
>   		max = 0;
>   
>   		for (i = 0; i < frames / 2; i++) {
> -			amplitude[i] = sqrt(data[i] * data[i] +
> -					    data[frames - i] *
> -					    data[frames - i]);
> +			amplitude[i] = hypot(data[i], data[frames - i]);
>   			if (amplitude[i] > max)
>   				max = amplitude[i];
>   		}
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox

Patch

diff --git a/lib/igt_audio.c b/lib/igt_audio.c
index 2321d1c6e..229ce6c69 100644
--- a/lib/igt_audio.c
+++ b/lib/igt_audio.c
@@ -266,9 +266,7 @@  bool audio_signal_detect(struct audio_signal *signal, int channels,
 		max = 0;
 
 		for (i = 0; i < frames / 2; i++) {
-			amplitude[i] = sqrt(data[i] * data[i] +
-					    data[frames - i] *
-					    data[frames - i]);
+			amplitude[i] = hypot(data[i], data[frames - i]);
 			if (amplitude[i] > max)
 				max = amplitude[i];
 		}