avfilter/af_afir: kill useless code which increases latency for no reason

This commit is contained in:
Paul B Mahol 2018-11-09 10:40:16 +01:00
parent 07bc603757
commit 16d91b7e99
2 changed files with 9 additions and 34 deletions

View File

@ -120,16 +120,13 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
AVFrame *out = NULL;
int ret;
s->nb_samples = in->nb_samples;
if (!s->want_skip) {
out = ff_get_audio_buffer(outlink, s->nb_samples);
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
}
out = ff_get_audio_buffer(outlink, s->nb_samples);
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
}
if (s->pts == AV_NOPTS_VALUE)
@ -139,11 +136,9 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
s->part_index = (s->part_index + 1) % s->nb_partitions;
if (!s->want_skip) {
out->pts = s->pts;
if (s->pts != AV_NOPTS_VALUE)
s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
}
out->pts = s->pts;
if (s->pts != AV_NOPTS_VALUE)
s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
s->index++;
if (s->index == 3)
@ -152,14 +147,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
av_frame_free(&in);
s->in[0] = NULL;
if (s->want_skip == 1) {
s->want_skip = 0;
ret = 0;
} else {
ret = ff_filter_frame(outlink, out);
}
return ret;
return ff_filter_frame(outlink, out);
}
static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint32_t color)
@ -496,16 +484,7 @@ static int activate(AVFilterContext *ctx)
return ret;
}
if (s->need_padding) {
in = ff_get_audio_buffer(outlink, s->part_size);
if (!in)
return AVERROR(ENOMEM);
s->need_padding = 0;
ret = 1;
} else {
ret = ff_inlink_consume_samples(ctx->inputs[0], s->part_size, s->part_size, &in);
}
ret = ff_inlink_consume_samples(ctx->inputs[0], s->part_size, s->part_size, &in);
if (ret > 0)
ret = fir_frame(s, in, outlink);
@ -626,8 +605,6 @@ static int config_output(AVFilterLink *outlink)
s->nb_channels = outlink->channels;
s->nb_coef_channels = ctx->inputs[1]->channels;
s->want_skip = 1;
s->need_padding = 1;
s->pts = AV_NOPTS_VALUE;
return 0;

View File

@ -66,8 +66,6 @@ typedef struct AudioFIRContext {
int nb_coef_channels;
int one2many;
int nb_samples;
int want_skip;
int need_padding;
RDFTContext **rdft, **irdft;
float **sum;