[FFmpeg-cvslog] avfilter/avf_ahistogram: switch to activate
Paul B Mahol
git at videolan.org
Mon Apr 29 16:22:03 EEST 2019
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Apr 29 12:43:18 2019 +0200| [77aacdb03683a9fc7e9f4255b92421e62a0866fc] | committer: Paul B Mahol
avfilter/avf_ahistogram: switch to activate
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77aacdb03683a9fc7e9f4255b92421e62a0866fc
---
libavfilter/avf_ahistogram.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/libavfilter/avf_ahistogram.c b/libavfilter/avf_ahistogram.c
index 6daafb0746..7795f3913c 100644
--- a/libavfilter/avf_ahistogram.c
+++ b/libavfilter/avf_ahistogram.c
@@ -22,6 +22,7 @@
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "avfilter.h"
+#include "filters.h"
#include "formats.h"
#include "audio.h"
#include "video.h"
@@ -54,6 +55,7 @@ typedef struct AudioHistogramContext {
float *combine_buffer;
AVFrame *in[101];
int first;
+ int nb_samples;
} AudioHistogramContext;
#define OFFSET(x) offsetof(AudioHistogramContext, x)
@@ -117,13 +119,8 @@ static int config_input(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
AudioHistogramContext *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(1, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5);
s->dchannels = s->dmode == SINGLE ? 1 : inlink->channels;
s->shistogram = av_calloc(s->w, s->dchannels * sizeof(*s->shistogram));
if (!s->shistogram)
@@ -369,6 +366,28 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(outlink, av_frame_clone(s->out));
}
+static int activate(AVFilterContext *ctx)
+{
+ AVFilterLink *inlink = ctx->inputs[0];
+ AVFilterLink *outlink = ctx->outputs[0];
+ AudioHistogramContext *s = ctx->priv;
+ AVFrame *in;
+ 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)
{
AudioHistogramContext *s = ctx->priv;
@@ -387,7 +406,6 @@ static const AVFilterPad ahistogram_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.config_props = config_input,
- .filter_frame = filter_frame,
},
{ NULL }
};
@@ -407,6 +425,7 @@ AVFilter ff_avf_ahistogram = {
.uninit = uninit,
.query_formats = query_formats,
.priv_size = sizeof(AudioHistogramContext),
+ .activate = activate,
.inputs = ahistogram_inputs,
.outputs = ahistogram_outputs,
.priv_class = &ahistogram_class,
More information about the ffmpeg-cvslog
mailing list