return 0;
}
-static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samples)
+static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *samples)
{
AVFilterContext *ctx = inlink->dst;
VolDetectContext *vd = ctx->priv;
vd->histogram[pcm[i] + 0x8000]++;
}
- return ff_filter_samples(inlink->dst->outputs[0], samples);
+ return ff_filter_frame(inlink->dst->outputs[0], samples);
}
#define MAX_DB 91
print_stats(ctx);
}
+static const AVFilterPad volumedetect_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .get_audio_buffer = ff_null_get_audio_buffer,
+ .filter_frame = filter_frame,
+ .min_perms = AV_PERM_READ,
+ },
+ { NULL }
+};
+
+static const AVFilterPad volumedetect_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ },
+ { NULL }
+};
+
AVFilter avfilter_af_volumedetect = {
.name = "volumedetect",
.description = NULL_IF_CONFIG_SMALL("Detect audio volume."),
.priv_size = sizeof(VolDetectContext),
.query_formats = query_formats,
.uninit = uninit,
-
- .inputs = (const AVFilterPad[]) {
- { .name = "default",
- .type = AVMEDIA_TYPE_AUDIO,
- .get_audio_buffer = ff_null_get_audio_buffer,
- .filter_samples = filter_samples,
- .min_perms = AV_PERM_READ, },
- { .name = NULL }
- },
- .outputs = (const AVFilterPad[]) {
- { .name = "default",
- .type = AVMEDIA_TYPE_AUDIO, },
- { .name = NULL }
- },
+ .inputs = volumedetect_inputs,
+ .outputs = volumedetect_outputs,
};