aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_rubberband.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2015-09-30 13:02:03 +0200
committerPaul B Mahol <onemda@gmail.com>2015-09-30 13:02:03 +0200
commit6ce02126cec5ceb4c0f0be8099aba89d61345c09 (patch)
tree8c1f909f6d1ec2f4d70cf7352b01aa2d5cc8e6cf /libavfilter/af_rubberband.c
parent3178931a14f5accf028495943f5bc3391f5043c8 (diff)
downloadffmpeg-6ce02126cec5ceb4c0f0be8099aba89d61345c09.tar.gz
avfilter/af_rubberband: flush only if there is something available
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/af_rubberband.c')
-rw-r--r--libavfilter/af_rubberband.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/libavfilter/af_rubberband.c b/libavfilter/af_rubberband.c
index abd6483a75..0a15fdc51a 100644
--- a/libavfilter/af_rubberband.c
+++ b/libavfilter/af_rubberband.c
@@ -175,29 +175,31 @@ static int request_frame(AVFilterLink *outlink)
ret = ff_request_frame(ctx->inputs[0]);
if (ret == AVERROR_EOF && !s->flushed) {
- AVFrame *out = ff_get_audio_buffer(inlink, 1);
- int nb_samples;
+ if (rubberband_available(s->rbs) > 0) {
+ AVFrame *out = ff_get_audio_buffer(inlink, 1);
+ int nb_samples;
- if (!out)
- return AVERROR(ENOMEM);
-
- rubberband_process(s->rbs, (const float *const *)out->data, 1, 1);
- av_frame_free(&out);
- s->flushed = 1;
- nb_samples = rubberband_available(s->rbs);
-
- if (nb_samples > 0) {
- out = ff_get_audio_buffer(inlink, nb_samples);
if (!out)
return AVERROR(ENOMEM);
- out->pts = av_rescale_q(s->nb_samples_out,
- (AVRational){ 1, outlink->sample_rate },
- outlink->time_base);
- nb_samples = rubberband_retrieve(s->rbs, (float *const *)out->data, nb_samples);
- out->nb_samples = nb_samples;
- ret = ff_filter_frame(outlink, out);
- s->nb_samples_out += nb_samples;
+
+ rubberband_process(s->rbs, (const float *const *)out->data, 1, 1);
+ av_frame_free(&out);
+ nb_samples = rubberband_available(s->rbs);
+
+ if (nb_samples > 0) {
+ out = ff_get_audio_buffer(inlink, nb_samples);
+ if (!out)
+ return AVERROR(ENOMEM);
+ out->pts = av_rescale_q(s->nb_samples_out,
+ (AVRational){ 1, outlink->sample_rate },
+ outlink->time_base);
+ nb_samples = rubberband_retrieve(s->rbs, (float *const *)out->data, nb_samples);
+ out->nb_samples = nb_samples;
+ ret = ff_filter_frame(outlink, out);
+ s->nb_samples_out += nb_samples;
+ }
}
+ s->flushed = 1;
av_log(ctx, AV_LOG_DEBUG, "nb_samples_in %"PRId64" nb_samples_out %"PRId64"\n",
s->nb_samples_in, s->nb_samples_out);
}