History

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

Paul B Mahol committed 5 years ago

Commit ccd95cb1 parent 2d36d2f1 file · +15 −10Browse files

Unified · Split

libavfilter/af_speechnorm.c+15−10
@@ -236,7 +236,7 @@ static double min_gain(AVFilterContext *ctx, ChannelContext *cc, int max_size) · 235 unmodified lines
236 return min_gain;236 return min_gain;
237}237}
238 238
239#define ANALYZE_CHANNEL(name, ptype, zero) \239#define ANALYZE_CHANNEL(name, ptype, zero, min_peak) \
240static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, \240static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, \
241 const uint8_t *srcp, int nb_samples) \241 const uint8_t *srcp, int nb_samples) \
242{ \242{ \
@@ -250,11 +250,11 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, · 7 unmodified lines
250 while (n < nb_samples) { \250 while (n < nb_samples) { \
251 if ((cc->state != (src[n] >= zero)) || \251 if ((cc->state != (src[n] >= zero)) || \
252 (cc->pi[cc->pi_end].size > s->max_period)) { \252 (cc->pi[cc->pi_end].size > s->max_period)) { \
253 double max_peak = cc->pi[cc->pi_end].max_peak; \253 ptype max_peak = cc->pi[cc->pi_end].max_peak; \
254 int state = cc->state; \254 int state = cc->state; \
255 cc->state = src[n] >= zero; \255 cc->state = src[n] >= zero; \
256 av_assert0(cc->pi[cc->pi_end].size > 0); \256 av_assert0(cc->pi[cc->pi_end].size > 0); \
257 if (cc->pi[cc->pi_end].max_peak >= MIN_PEAK || \257 if (max_peak >= min_peak || \
258 cc->pi[cc->pi_end].size > s->max_period) { \258 cc->pi[cc->pi_end].size > s->max_period) { \
259 cc->pi[cc->pi_end].type = 1; \259 cc->pi[cc->pi_end].type = 1; \
260 cc->pi_end++; \260 cc->pi_end++; \
@@ -290,8 +290,8 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, · 29 unmodified lines
290 } \290 } \
291}291}
292 292
293ANALYZE_CHANNEL(dbl, double, 0.0)293ANALYZE_CHANNEL(dbl, double, 0.0, MIN_PEAK)
294ANALYZE_CHANNEL(flt, float, 0.f)294ANALYZE_CHANNEL(flt, float, 0.f, (float)MIN_PEAK)
295 295
296#define FILTER_CHANNELS(name, ptype) \296#define FILTER_CHANNELS(name, ptype) \
297static void filter_channels_## name (AVFilterContext *ctx, \297static void filter_channels_## name (AVFilterContext *ctx, \
@@ -325,12 +325,17 @@ static void filter_channels_## name (AVFilterContext *ctx, · 27 unmodified lines
325FILTER_CHANNELS(dbl, double)325FILTER_CHANNELS(dbl, double)
326FILTER_CHANNELS(flt, float)326FILTER_CHANNELS(flt, float)
327 327
328static double lerp(double min, double max, double mix)328static double dlerp(double min, double max, double mix)
329{329{
330 return min + (max - min) * mix;330 return min + (max - min) * mix;
331}331}
332 332
333#define FILTER_LINK_CHANNELS(name, ptype) \333static float flerp(float min, float max, float mix)
334{
335 return min + (max - min) * mix;
336}
337
338#define FILTER_LINK_CHANNELS(name, ptype, tlerp) \
334static void filter_link_channels_## name (AVFilterContext *ctx, \339static void filter_link_channels_## name (AVFilterContext *ctx, \
335 AVFrame *in, int nb_samples) \340 AVFrame *in, int nb_samples) \
336{ \341{ \
@@ -371,7 +376,7 @@ static void filter_link_channels_## name (AVFilterContext *ctx, · 34 unmodified lines
371 continue; \376 continue; \
372 \377 \
373 for (int i = n; i < n + min_size; i++) { \378 for (int i = n; i < n + min_size; i++) { \
374 ptype g = lerp(s->prev_gain, gain, (i - n) / (double)min_size); \379 ptype g = tlerp(s->prev_gain, gain, (i - n) / (ptype)min_size); \
375 dst[i] *= g; \380 dst[i] *= g; \
376 } \381 } \
377 } \382 } \
@@ -381,8 +386,8 @@ static void filter_link_channels_## name (AVFilterContext *ctx, · 3 unmodified lines
381 } \386 } \
382}387}
383 388
384FILTER_LINK_CHANNELS(dbl, double)389FILTER_LINK_CHANNELS(dbl, double, dlerp)
385FILTER_LINK_CHANNELS(flt, float)390FILTER_LINK_CHANNELS(flt, float, flerp)
386 391
387static int filter_frame(AVFilterContext *ctx)392static int filter_frame(AVFilterContext *ctx)
388{393{

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t