History

avfilter/af_silencedetect: add planar sample formats support

Paul B Mahol committed 5 years ago

Commit a4101dc1 parent ba3c09b1 file · +40 −4Browse files

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

Unified · Split

libavfilter/af_silencedetect.c+40−4
@@ -131,11 +131,35 @@ static void silencedetect_##name(SilenceDetectContext *s, AVFrame *insamples, · 130 unmodified lines
131131 nb_samples_notify, time_base); \
132132 }
133133
134+#define SILENCE_DETECT_PLANAR(name, type) \
135+static void silencedetect_##name(SilenceDetectContext *s, AVFrame *insamples, \
136+ int nb_samples, int64_t nb_samples_notify, \
137+ AVRational time_base) \
138+{ \
139+ const int channels = insamples->channels; \
140+ const type noise = s->noise; \
141+ \
142+ nb_samples /= channels; \
143+ for (int i = 0; i < nb_samples; i++) { \
144+ for (int ch = 0; ch < insamples->channels; ch++) { \
145+ const type *p = (const type *)insamples->extended_data[ch]; \
146+ update(s, insamples, p[i] < noise && p[i] > -noise, \
147+ channels * i + ch, \
148+ nb_samples_notify, time_base); \
149+ } \
150+ } \
151+}
152+
134153 SILENCE_DETECT(dbl, double)
135154 SILENCE_DETECT(flt, float)
136155 SILENCE_DETECT(s32, int32_t)
137156 SILENCE_DETECT(s16, int16_t)
138157
158+SILENCE_DETECT_PLANAR(dblp, double)
159+SILENCE_DETECT_PLANAR(fltp, float)
160+SILENCE_DETECT_PLANAR(s32p, int32_t)
161+SILENCE_DETECT_PLANAR(s16p, int16_t)
162+
139163 static int config_input(AVFilterLink *inlink)
140164 {
141165 AVFilterContext *ctx = inlink->dst;
@@ -165,6 +189,18 @@ static int config_input(AVFilterLink *inlink) · 23 unmodified lines
165189 s->noise *= INT16_MAX;
166190 s->silencedetect = silencedetect_s16;
167191 break;
192+ case AV_SAMPLE_FMT_DBLP: s->silencedetect = silencedetect_dblp; break;
193+ case AV_SAMPLE_FMT_FLTP: s->silencedetect = silencedetect_fltp; break;
194+ case AV_SAMPLE_FMT_S32P:
195+ s->noise *= INT32_MAX;
196+ s->silencedetect = silencedetect_s32p;
197+ break;
198+ case AV_SAMPLE_FMT_S16P:
199+ s->noise *= INT16_MAX;
200+ s->silencedetect = silencedetect_s16p;
201+ break;
202+ default:
203+ return AVERROR_BUG;
168204 }
169205
170206 return 0;
@@ -198,10 +234,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) · 27 unmodified lines
198234 static int query_formats(AVFilterContext *ctx)
199235 {
200236 static const enum AVSampleFormat sample_fmts[] = {
201− AV_SAMPLE_FMT_DBL,
202− AV_SAMPLE_FMT_FLT,
203− AV_SAMPLE_FMT_S32,
204− AV_SAMPLE_FMT_S16,
237+ AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
238+ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
239+ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32P,
240+ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
205241 AV_SAMPLE_FMT_NONE
206242 };
207243 int ret = ff_set_common_all_channel_counts(ctx);

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