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

Showing the changes to libavfilter (1 of 1 file). Show all

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
236236 return min_gain;
237237 }
238238
239−#define ANALYZE_CHANNEL(name, ptype, zero) \
239+#define ANALYZE_CHANNEL(name, ptype, zero, min_peak) \
240240 static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, \
241241 const uint8_t *srcp, int nb_samples) \
242242 { \
@@ -250,11 +250,11 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, · 7 unmodified lines
250250 while (n < nb_samples) { \
251251 if ((cc->state != (src[n] >= zero)) || \
252252 (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; \
254254 int state = cc->state; \
255255 cc->state = src[n] >= zero; \
256256 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 || \
258258 cc->pi[cc->pi_end].size > s->max_period) { \
259259 cc->pi[cc->pi_end].type = 1; \
260260 cc->pi_end++; \
@@ -290,8 +290,8 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, · 29 unmodified lines
290290 } \
291291 }
292292
293−ANALYZE_CHANNEL(dbl, double, 0.0)
294−ANALYZE_CHANNEL(flt, float, 0.f)
293+ANALYZE_CHANNEL(dbl, double, 0.0, MIN_PEAK)
294+ANALYZE_CHANNEL(flt, float, 0.f, (float)MIN_PEAK)
295295
296296 #define FILTER_CHANNELS(name, ptype) \
297297 static void filter_channels_## name (AVFilterContext *ctx, \
@@ -325,12 +325,17 @@ static void filter_channels_## name (AVFilterContext *ctx, · 27 unmodified lines
325325 FILTER_CHANNELS(dbl, double)
326326 FILTER_CHANNELS(flt, float)
327327
328−static double lerp(double min, double max, double mix)
328+static double dlerp(double min, double max, double mix)
329329 {
330330 return min + (max - min) * mix;
331331 }
332332
333−#define FILTER_LINK_CHANNELS(name, ptype) \
333+static 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) \
334339 static void filter_link_channels_## name (AVFilterContext *ctx, \
335340 AVFrame *in, int nb_samples) \
336341 { \
@@ -371,7 +376,7 @@ static void filter_link_channels_## name (AVFilterContext *ctx, · 34 unmodified lines
371376 continue; \
372377 \
373378 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); \
375380 dst[i] *= g; \
376381 } \
377382 } \
@@ -381,8 +386,8 @@ static void filter_link_channels_## name (AVFilterContext *ctx, · 3 unmodified lines
381386 } \
382387 }
383388
384−FILTER_LINK_CHANNELS(dbl, double)
385−FILTER_LINK_CHANNELS(flt, float)
389+FILTER_LINK_CHANNELS(dbl, double, dlerp)
390+FILTER_LINK_CHANNELS(flt, float, flerp)
386391
387392 static int filter_frame(AVFilterContext *ctx)
388393 {

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