From 5cac0656a3cb8d04fc8d43b729c493f3e0e98d54 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 30 Oct 2012 18:59:19 +0100 Subject: af_ashowinfo: integrate config_input() in filter_samples. This is simpler and also should allow the code to function when the channel number changes. Signed-off-by: Michael Niedermayer --- libavfilter/af_ashowinfo.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'libavfilter/af_ashowinfo.c') diff --git a/libavfilter/af_ashowinfo.c b/libavfilter/af_ashowinfo.c index 1a70deee28..82ce261064 100644 --- a/libavfilter/af_ashowinfo.c +++ b/libavfilter/af_ashowinfo.c @@ -48,17 +48,6 @@ typedef struct AShowInfoContext { uint64_t frame; } AShowInfoContext; -static int config_input(AVFilterLink *inlink) -{ - AShowInfoContext *s = inlink->dst->priv; - int channels = av_get_channel_layout_nb_channels(inlink->channel_layout); - s->plane_checksums = av_malloc(channels * sizeof(*s->plane_checksums)); - if (!s->plane_checksums) - return AVERROR(ENOMEM); - - return 0; -} - static void uninit(AVFilterContext *ctx) { AShowInfoContext *s = ctx->priv; @@ -77,6 +66,11 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) int data_size = buf->audio->nb_samples * block_align; int planes = planar ? channels : 1; int i; + void *tmp_ptr = av_realloc(s->plane_checksums, channels * sizeof(*s->plane_checksums)); + + if (!tmp_ptr) + return AVERROR(ENOMEM); + s->plane_checksums = tmp_ptr; for (i = 0; i < planes; i++) { uint8_t *data = buf->extended_data[i]; @@ -114,7 +108,6 @@ static const AVFilterPad inputs[] = { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .get_audio_buffer = ff_null_get_audio_buffer, - .config_props = config_input, .filter_samples = filter_samples, .min_perms = AV_PERM_READ, }, -- cgit v1.2.3