Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-09-08 21:52:38 +0300
committerPaul B Mahol <onemda@gmail.com>2021-09-08 22:44:54 +0300
commitccd95cb248562a4ad7eeba0aa8aff992a1daa625 (patch)
tree70acde05692bc21799ba03f5e0914bb772bbe6cb /libavfilter/af_speechnorm.c
parent2d36d2fbd775fa9e2a92b1225b1964c5a8499df3 (diff)
avfilter/af_speechnorm: use floats in place of doubles where it is already float used
Diffstat (limited to 'libavfilter/af_speechnorm.c')
-rw-r--r--libavfilter/af_speechnorm.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/libavfilter/af_speechnorm.c b/libavfilter/af_speechnorm.c
index e94608fb41..0d1c6bd25d 100644
--- a/libavfilter/af_speechnorm.c
+++ b/libavfilter/af_speechnorm.c
@@ -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)
{