[FFmpeg-cvslog] avfilter/af_speechnorm: use floats in place of doubles where it is already float used
Paul B Mahol
git at videolan.org
Wed Sep 8 22:45:18 EEST 2021
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed Sep 8 20:52:38 2021 +0200| [ccd95cb248562a4ad7eeba0aa8aff992a1daa625] | committer: Paul B Mahol
avfilter/af_speechnorm: use floats in place of doubles where it is already float used
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ccd95cb248562a4ad7eeba0aa8aff992a1daa625
---
libavfilter/af_speechnorm.c | 25 +++++++++++++++----------
1 file 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)
{
More information about the ffmpeg-cvslog
mailing list