mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
Fix compilation with -Werror=float-conversion
Better make the conversions explicit so that we don't get any surprises. Fixes #4065
This commit is contained in:
parent
50870aac57
commit
1ae4374ccf
71 changed files with 286 additions and 284 deletions
|
|
@ -26,11 +26,11 @@ static void set_coefficient(struct biquad *bq, double b0, double b1, double b2,
|
|||
double a0, double a1, double a2)
|
||||
{
|
||||
double a0_inv = 1 / a0;
|
||||
bq->b0 = b0 * a0_inv;
|
||||
bq->b1 = b1 * a0_inv;
|
||||
bq->b2 = b2 * a0_inv;
|
||||
bq->a1 = a1 * a0_inv;
|
||||
bq->a2 = a2 * a0_inv;
|
||||
bq->b0 = (float)(b0 * a0_inv);
|
||||
bq->b1 = (float)(b1 * a0_inv);
|
||||
bq->b2 = (float)(b2 * a0_inv);
|
||||
bq->a1 = (float)(a1 * a0_inv);
|
||||
bq->a2 = (float)(a2 * a0_inv);
|
||||
}
|
||||
|
||||
static void biquad_lowpass(struct biquad *bq, double cutoff)
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ done:
|
|||
spa_debug_type_find_short_name(spa_type_audio_channel, j + _SH));
|
||||
|
||||
mix->matrix_orig[ic][jc++] = matrix[i][j];
|
||||
sum += fabs(matrix[i][j]);
|
||||
sum += fabsf(matrix[i][j]);
|
||||
|
||||
if (matrix[i][j] == 0.0f)
|
||||
spa_strbuf_append(&sb1, " ");
|
||||
|
|
@ -772,7 +772,7 @@ int channelmix_init(struct channelmix *mix)
|
|||
mix->process = info->process;
|
||||
mix->set_volume = impl_channelmix_set_volume;
|
||||
mix->cpu_flags = info->cpu_flags;
|
||||
mix->delay = mix->rear_delay * mix->freq / 1000.0f;
|
||||
mix->delay = (uint32_t)(mix->rear_delay * mix->freq / 1000.0f);
|
||||
mix->func_name = info->name;
|
||||
|
||||
spa_log_debug(mix->log, "selected %s delay:%d options:%08x", info->name, mix->delay,
|
||||
|
|
|
|||
|
|
@ -969,7 +969,8 @@ conv_deinterleave_32s_1s_sse2(void *data, void * SPA_RESTRICT dst[], const void
|
|||
s += 4*n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
d0[n] = bswap_32(*s);
|
||||
uint32_t *di = (uint32_t*)&d0[n], *si = (uint32_t*)s;
|
||||
*di = bswap_32(*si);
|
||||
s += n_channels;
|
||||
}
|
||||
}
|
||||
|
|
@ -1011,10 +1012,10 @@ conv_deinterleave_32s_4s_sse2(void *data, void * SPA_RESTRICT dst[], const void
|
|||
s += 4 * n_channels;
|
||||
}
|
||||
for(; n < n_samples; n++) {
|
||||
d0[n] = bswap_32(s[0]);
|
||||
d1[n] = bswap_32(s[1]);
|
||||
d2[n] = bswap_32(s[2]);
|
||||
d3[n] = bswap_32(s[3]);
|
||||
*((uint32_t*)&d0[n]) = bswap_32(*((uint32_t*)&s[0]));
|
||||
*((uint32_t*)&d1[n]) = bswap_32(*((uint32_t*)&s[1]));
|
||||
*((uint32_t*)&d2[n]) = bswap_32(*((uint32_t*)&s[2]));
|
||||
*((uint32_t*)&d3[n]) = bswap_32(*((uint32_t*)&s[3]));
|
||||
s += n_channels;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ static inline void blackman_window(float *taps, int n_taps)
|
|||
{
|
||||
int n;
|
||||
for (n = 0; n < n_taps; n++) {
|
||||
float w = 2 * M_PI * n / (n_taps-1);
|
||||
taps[n] = 0.3635819 - 0.4891775 * cos(w)
|
||||
+ 0.1365995 * cos(2 * w) - 0.0106411 * cos(3 * w);
|
||||
float w = 2.0f * M_PIf * n / (n_taps-1);
|
||||
taps[n] = 0.3635819f - 0.4891775f * cosf(w)
|
||||
+ 0.1365995f * cosf(2 * w) - 0.0106411f * cosf(3 * w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ static inline int hilbert_generate(float *taps, int n_taps)
|
|||
for (i = 0; i < n_taps; i++) {
|
||||
int k = -(n_taps / 2) + i;
|
||||
if (k & 1) {
|
||||
float pk = M_PI * k;
|
||||
float pk = M_PIf * k;
|
||||
taps[i] *= (1.0f - cosf(pk)) / pk;
|
||||
} else {
|
||||
taps[i] = 0.0f;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ DEFINE_RESAMPLER(full,arch) \
|
|||
float *d = dst[c]; \
|
||||
\
|
||||
index = ioffs; \
|
||||
phase = data->phase; \
|
||||
phase = (uint32_t)data->phase; \
|
||||
\
|
||||
for (o = ooffs; o < olen && index + n_taps <= ilen; o++) { \
|
||||
inner_product_##arch(&d[o], &s[index], \
|
||||
|
|
@ -117,12 +117,12 @@ DEFINE_RESAMPLER(full,arch) \
|
|||
DEFINE_RESAMPLER(inter,arch) \
|
||||
{ \
|
||||
struct native_data *data = r->data; \
|
||||
uint32_t index, stride = data->filter_stride; \
|
||||
uint32_t index, stride = data->filter_stride; \
|
||||
uint32_t n_phases = data->n_phases, out_rate = data->out_rate; \
|
||||
uint32_t n_taps = data->n_taps; \
|
||||
uint32_t c, o, olen = *out_len, ilen = *in_len; \
|
||||
uint32_t inc = data->inc, frac = data->frac; \
|
||||
float phase; \
|
||||
float phase; \
|
||||
\
|
||||
if (r->channels == 0) \
|
||||
return; \
|
||||
|
|
@ -135,8 +135,8 @@ DEFINE_RESAMPLER(inter,arch) \
|
|||
phase = data->phase; \
|
||||
\
|
||||
for (o = ooffs; o < olen && index + n_taps <= ilen; o++) { \
|
||||
float ph = phase * n_phases / out_rate; \
|
||||
uint32_t offset = floorf(ph); \
|
||||
float ph = phase * n_phases / out_rate; \
|
||||
uint32_t offset = (uint32_t)floorf(ph); \
|
||||
inner_product_ip_##arch(&d[o], &s[index], \
|
||||
&data->filter[(offset + 0) * stride], \
|
||||
&data->filter[(offset + 1) * stride], \
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ static int build_filter(float *taps, uint32_t stride, uint32_t n_taps, uint32_t
|
|||
for (j = 0; j < n_taps12; j++, t += 1.0) {
|
||||
/* exploit symmetry in filter taps */
|
||||
taps[(n_phases - i) * stride + n_taps12 + j] =
|
||||
taps[i * stride + (n_taps12 - j - 1)] =
|
||||
cutoff * sinc(t * cutoff) * window(t, n_taps);
|
||||
taps[i * stride + (n_taps12 - j - 1)] = (float)
|
||||
(cutoff * sinc(t * cutoff) * window(t, n_taps));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -141,7 +141,7 @@ static void impl_native_update_rate(struct resample *r, double rate)
|
|||
return;
|
||||
|
||||
old_out_rate = data->out_rate;
|
||||
in_rate = r->i_rate / rate;
|
||||
in_rate = (uint32_t)(r->i_rate / rate);
|
||||
out_rate = r->o_rate;
|
||||
phase = data->phase;
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ static uint32_t impl_native_in_len(struct resample *r, uint32_t out_len)
|
|||
struct native_data *data = r->data;
|
||||
uint32_t in_len;
|
||||
|
||||
in_len = (data->phase + out_len * data->frac) / data->out_rate;
|
||||
in_len = (uint32_t)((data->phase + out_len * data->frac) / data->out_rate);
|
||||
in_len += out_len * data->inc + (data->n_taps - data->hist);
|
||||
|
||||
spa_log_trace_fp(r->log, "native %p: hist:%d %d->%d", r, data->hist, out_len, in_len);
|
||||
|
|
@ -194,7 +194,7 @@ static uint32_t impl_native_out_len(struct resample *r, uint32_t in_len)
|
|||
uint32_t out_len;
|
||||
|
||||
in_len = in_len - SPA_MIN(in_len, (data->n_taps - data->hist) + 1);
|
||||
out_len = in_len * data->out_rate - data->phase;
|
||||
out_len = (uint32_t)(in_len * data->out_rate - data->phase);
|
||||
out_len = (out_len + data->in_rate - 1) / data->in_rate;
|
||||
|
||||
spa_log_trace_fp(r->log, "native %p: hist:%d %d->%d", r, data->hist, in_len, out_len);
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ static uint32_t cpu_flags;
|
|||
|
||||
SPA_LOG_IMPL(logger);
|
||||
|
||||
#define MATRIX(...) (float[]) { __VA_ARGS__ }
|
||||
#define MATRIX(...) (double[]) { __VA_ARGS__ }
|
||||
|
||||
#include "test-helper.h"
|
||||
#include "channelmix-ops.c"
|
||||
|
||||
#define CLOSE_ENOUGH(a,b) (fabs((a)-(b)) < 0.000001f)
|
||||
|
||||
static void dump_matrix(struct channelmix *mix, float *coeff)
|
||||
static void dump_matrix(struct channelmix *mix, double *coeff)
|
||||
{
|
||||
uint32_t i, j;
|
||||
|
||||
|
|
@ -33,13 +33,13 @@ static void dump_matrix(struct channelmix *mix, float *coeff)
|
|||
for (j = 0; j < mix->src_chan; j++) {
|
||||
float v = mix->matrix[i][j];
|
||||
spa_log_debug(mix->log, "%d %d: %f <-> %f", i, j, v, *coeff);
|
||||
spa_assert_se(CLOSE_ENOUGH(v, *coeff));
|
||||
spa_assert_se(CLOSE_ENOUGH(v, (float)*coeff));
|
||||
coeff++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_mix(uint32_t src_chan, uint32_t src_mask, uint32_t dst_chan, uint32_t dst_mask, uint32_t options, float *coeff)
|
||||
static void test_mix(uint32_t src_chan, uint32_t src_mask, uint32_t dst_chan, uint32_t dst_mask, uint32_t options, double *coeff)
|
||||
{
|
||||
struct channelmix mix;
|
||||
|
||||
|
|
@ -336,7 +336,7 @@ static void test_n_m_impl(void)
|
|||
|
||||
for (i = 0; i < 16; i++) {
|
||||
for (j = 0; j < N_SAMPLES; j++)
|
||||
src_data[i][j] = (drand48() - 0.5f) * 2.5f;
|
||||
src_data[i][j] = (float)((drand48() - 0.5f) * 2.5f);
|
||||
src[i] = src_data[i];
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +360,7 @@ static void test_n_m_impl(void)
|
|||
/* random matrix */
|
||||
for (i = 0; i < mix.dst_chan; i++) {
|
||||
for (j = 0; j < mix.src_chan; j++) {
|
||||
mix.matrix_orig[i][j] = drand48() - 0.5f;
|
||||
mix.matrix_orig[i][j] = (float)(drand48() - 0.5f);
|
||||
}
|
||||
}
|
||||
channelmix_set_volume(&mix, 1.0f, false, 0, NULL);
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ static void test_f32_s32(void)
|
|||
static void test_s32_f32(void)
|
||||
{
|
||||
static const int32_t in[] = { 0, 0x7fffff00, 0x80000000, 0x40000000, 0xc0000000 };
|
||||
static const float out[] = { 0.0f, 0.999999880791, -1.0f, 0.5, -0.5, };
|
||||
static const float out[] = { 0.0f, 0.999999880791f, -1.0f, 0.5, -0.5, };
|
||||
|
||||
run_test("test_s32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
|
||||
true, false, conv_s32_to_f32d_c);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static void test_impl(void)
|
|||
float min[2] = { 0.0f, 0.0f }, max[2] = { 0.0f, 0.0f }, absmax[2] = { 0.0f, 0.0f };
|
||||
|
||||
for (i = 0; i < SPA_N_ELEMENTS(vals); i++)
|
||||
vals[i] = (drand48() - 0.5f) * 2.5f;
|
||||
vals[i] = (float)((drand48() - 0.5f) * 2.5f);
|
||||
|
||||
peaks_min_max_c(&peaks, &vals[1], SPA_N_ELEMENTS(vals) - 1, &min[0], &max[0]);
|
||||
printf("c peaks min:%f max:%f\n", min[0], max[0]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue