pipewire/spa/plugins/audioconvert/peaks-ops-c.c
Barnabás Pőcze 934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00

30 lines
643 B
C

/* Spa */
/* SPDX-FileCopyrightText: Copyright © 2022 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#include <math.h>
#include "peaks-ops.h"
void peaks_min_max_c(struct peaks *peaks, const float * SPA_RESTRICT src,
uint32_t n_samples, float *min, float *max)
{
uint32_t n;
float t, mi = *min, ma = *max;
for (n = 0; n < n_samples; n++) {
t = src[n];
mi = fminf(mi, t);
ma = fmaxf(ma, t);
}
*min = mi;
*max = ma;
}
float peaks_abs_max_c(struct peaks *peaks, const float * SPA_RESTRICT src,
uint32_t n_samples, float max)
{
uint32_t n;
for (n = 0; n < n_samples; n++)
max = fmaxf(fabsf(src[n]), max);
return max;
}