mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
SPDX tags make the licensing information easy to understand and clear, and they are machine parseable. See https://spdx.dev for more information.
30 lines
643 B
C
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;
|
|
}
|