aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/avf_showvolume.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-05-27 18:44:19 +0200
committerPaul B Mahol <onemda@gmail.com>2019-05-27 18:44:19 +0200
commit5ddaedcaec39162972b26487e68b75cd37804075 (patch)
tree181a5f1ad471b7cab47f5983014ab8f74130e1a3 /libavfilter/avf_showvolume.c
parentf78172b29ae7422237a4843da119f099a03cd55a (diff)
downloadffmpeg-5ddaedcaec39162972b26487e68b75cd37804075.tar.gz
avfilter/avf_showvolume: switch to activate
Diffstat (limited to 'libavfilter/avf_showvolume.c')
-rw-r--r--libavfilter/avf_showvolume.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
index 6b553c4eba..7a8e583556 100644
--- a/libavfilter/avf_showvolume.c
+++ b/libavfilter/avf_showvolume.c
@@ -26,6 +26,7 @@
#include "libavutil/parseutils.h"
#include "libavutil/xga_font_data.h"
#include "avfilter.h"
+#include "filters.h"
#include "formats.h"
#include "audio.h"
#include "video.h"
@@ -47,6 +48,7 @@ typedef struct ShowVolumeContext {
float bgopacity;
int mode;
+ int nb_samples;
AVFrame *out;
AVExpr *c_expr;
int draw_text;
@@ -162,12 +164,8 @@ static int config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
ShowVolumeContext *s = ctx->priv;
- int nb_samples;
- nb_samples = FFMAX(1024, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5);
- inlink->partial_buf_size =
- inlink->min_samples =
- inlink->max_samples = nb_samples;
+ s->nb_samples = FFMAX(1024, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5);
s->values = av_calloc(inlink->channels * VAR_VARS_NB, sizeof(double));
if (!s->values)
return AVERROR(ENOMEM);
@@ -449,6 +447,28 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
return ff_filter_frame(outlink, out);
}
+static int activate(AVFilterContext *ctx)
+{
+ AVFilterLink *inlink = ctx->inputs[0];
+ AVFilterLink *outlink = ctx->outputs[0];
+ ShowVolumeContext *s = ctx->priv;
+ AVFrame *in = NULL;
+ int ret;
+
+ FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
+
+ ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in);
+ if (ret < 0)
+ return ret;
+ if (ret > 0)
+ return filter_frame(inlink, in);
+
+ FF_FILTER_FORWARD_STATUS(inlink, outlink);
+ FF_FILTER_FORWARD_WANTED(outlink, inlink);
+
+ return FFERROR_NOT_READY;
+}
+
static av_cold void uninit(AVFilterContext *ctx)
{
ShowVolumeContext *s = ctx->priv;
@@ -465,7 +485,6 @@ static const AVFilterPad showvolume_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.config_props = config_input,
- .filter_frame = filter_frame,
},
{ NULL }
};
@@ -483,6 +502,7 @@ AVFilter ff_avf_showvolume = {
.name = "showvolume",
.description = NULL_IF_CONFIG_SMALL("Convert input audio volume to video output."),
.init = init,
+ .activate = activate,
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(ShowVolumeContext),