mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
audioconvert: refactor peaks resampler
Use common code in macro and generate arch specific version. Compile with -Ofast to optimize some fmaxf calls.
This commit is contained in:
parent
a79b5c86ea
commit
6e9e02b420
9 changed files with 89 additions and 110 deletions
|
|
@ -34,11 +34,59 @@ struct peaks_data {
|
|||
float max_f[];
|
||||
};
|
||||
|
||||
void resample_peaks_process_c(struct resample *r,
|
||||
const void * SPA_RESTRICT src[], uint32_t *in_len,
|
||||
void * SPA_RESTRICT dst[], uint32_t *out_len);
|
||||
#define DEFINE_PEAKS(arch) \
|
||||
void resample_peaks_process_##arch(struct resample *r, \
|
||||
const void * SPA_RESTRICT src[], uint32_t *in_len, \
|
||||
void * SPA_RESTRICT dst[], uint32_t *out_len)
|
||||
|
||||
#define MAKE_PEAKS(arch) \
|
||||
DEFINE_PEAKS(arch) \
|
||||
{ \
|
||||
struct peaks_data *pd = r->data; \
|
||||
uint32_t c, i, o, end, chunk, i_count, o_count; \
|
||||
\
|
||||
if (SPA_UNLIKELY(r->channels == 0)) \
|
||||
return; \
|
||||
\
|
||||
for (c = 0; c < r->channels; c++) { \
|
||||
const float *s = src[c]; \
|
||||
float *d = dst[c], m = pd->max_f[c]; \
|
||||
\
|
||||
o_count = pd->o_count; \
|
||||
i_count = pd->i_count; \
|
||||
o = i = 0; \
|
||||
\
|
||||
while (i < *in_len && o < *out_len) { \
|
||||
end = ((uint64_t) (o_count + 1) \
|
||||
* r->i_rate) / r->o_rate; \
|
||||
end = end > i_count ? end - i_count : 0; \
|
||||
chunk = SPA_MIN(end, *in_len); \
|
||||
\
|
||||
m = find_abs_max_##arch(&s[i], chunk - i, m); \
|
||||
\
|
||||
i += chunk; \
|
||||
\
|
||||
if (i == end) { \
|
||||
d[o++] = m; \
|
||||
m = 0.0f; \
|
||||
o_count++; \
|
||||
} \
|
||||
} \
|
||||
pd->max_f[c] = m; \
|
||||
} \
|
||||
*out_len = o; \
|
||||
*in_len = i; \
|
||||
pd->o_count = o_count; \
|
||||
pd->i_count = i_count + i; \
|
||||
\
|
||||
while (pd->i_count >= r->i_rate) { \
|
||||
pd->i_count -= r->i_rate; \
|
||||
pd->o_count -= r->o_rate; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
DEFINE_PEAKS(c);
|
||||
#if defined (HAVE_SSE)
|
||||
void resample_peaks_process_sse(struct resample *r,
|
||||
const void * SPA_RESTRICT src[], uint32_t *in_len,
|
||||
void * SPA_RESTRICT dst[], uint32_t *out_len);
|
||||
DEFINE_PEAKS(sse);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue