1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-02-04 06:08:26 +02:00

avfilter/af_speechnorm: use floats in place of doubles where it is already float used

This commit is contained in:
Paul B Mahol 2021-09-08 20:52:38 +02:00
parent 2d36d2fbd7
commit ccd95cb248

View File

@ -236,7 +236,7 @@ static double min_gain(AVFilterContext *ctx, ChannelContext *cc, int max_size)
return min_gain;
}
#define ANALYZE_CHANNEL(name, ptype, zero) \
#define ANALYZE_CHANNEL(name, ptype, zero, min_peak) \
static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, \
const uint8_t *srcp, int nb_samples) \
{ \
@ -250,11 +250,11 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc,
while (n < nb_samples) { \
if ((cc->state != (src[n] >= zero)) || \
(cc->pi[cc->pi_end].size > s->max_period)) { \
double max_peak = cc->pi[cc->pi_end].max_peak; \
ptype max_peak = cc->pi[cc->pi_end].max_peak; \
int state = cc->state; \
cc->state = src[n] >= zero; \
av_assert0(cc->pi[cc->pi_end].size > 0); \
if (cc->pi[cc->pi_end].max_peak >= MIN_PEAK || \
if (max_peak >= min_peak || \
cc->pi[cc->pi_end].size > s->max_period) { \
cc->pi[cc->pi_end].type = 1; \
cc->pi_end++; \
@ -290,8 +290,8 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc,
} \
}
ANALYZE_CHANNEL(dbl, double, 0.0)
ANALYZE_CHANNEL(flt, float, 0.f)
ANALYZE_CHANNEL(dbl, double, 0.0, MIN_PEAK)
ANALYZE_CHANNEL(flt, float, 0.f, (float)MIN_PEAK)
#define FILTER_CHANNELS(name, ptype) \
static void filter_channels_## name (AVFilterContext *ctx, \
@ -325,12 +325,17 @@ static void filter_channels_## name (AVFilterContext *ctx,
FILTER_CHANNELS(dbl, double)
FILTER_CHANNELS(flt, float)
static double lerp(double min, double max, double mix)
static double dlerp(double min, double max, double mix)
{
return min + (max - min) * mix;
}
#define FILTER_LINK_CHANNELS(name, ptype) \
static float flerp(float min, float max, float mix)
{
return min + (max - min) * mix;
}
#define FILTER_LINK_CHANNELS(name, ptype, tlerp) \
static void filter_link_channels_## name (AVFilterContext *ctx, \
AVFrame *in, int nb_samples) \
{ \
@ -371,7 +376,7 @@ static void filter_link_channels_## name (AVFilterContext *ctx,
continue; \
\
for (int i = n; i < n + min_size; i++) { \
ptype g = lerp(s->prev_gain, gain, (i - n) / (double)min_size); \
ptype g = tlerp(s->prev_gain, gain, (i - n) / (ptype)min_size); \
dst[i] *= g; \
} \
} \
@ -381,8 +386,8 @@ static void filter_link_channels_## name (AVFilterContext *ctx,
} \
}
FILTER_LINK_CHANNELS(dbl, double)
FILTER_LINK_CHANNELS(flt, float)
FILTER_LINK_CHANNELS(dbl, double, dlerp)
FILTER_LINK_CHANNELS(flt, float, flerp)
static int filter_frame(AVFilterContext *ctx)
{