aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2024-11-03 22:32:51 +0100
committerMarton Balint <cus@passwd.hu>2024-11-11 21:56:34 +0100
commitb33a59416072ad31a5840f33f9975d88acf45add (patch)
tree91e02c19c6cabbe13a12eadc3a31772b76135d70 /libavfilter
parent97c5cc3a5c7c69ed3289c54ef020bca28d82c39d (diff)
downloadffmpeg-b33a59416072ad31a5840f33f9975d88acf45add.tar.gz
avfilter/f_loop: fix length of aloop leftover buffer
If the audio loop stops inside an audio frame, the leftover buffer contains the end of the frame, which is not looped. The length supposed to be the part which was not written to the loop buffer, so we need to drain exactly that number of bytes from the leftover buffer. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/f_loop.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index 9b01a85405..3372c77fee 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -170,14 +170,13 @@ static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
s->pts += av_rescale_q(s->start - s->ignored_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
}
s->nb_samples += ret - drain;
- drain = frame->nb_samples - written;
- if (s->nb_samples == s->size && drain > 0) {
+ if (s->nb_samples == s->size && frame->nb_samples > written) {
int ret2;
ret2 = av_audio_fifo_write(s->left, (void **)frame->extended_data, frame->nb_samples);
if (ret2 < 0)
return ret2;
- av_audio_fifo_drain(s->left, drain);
+ av_audio_fifo_drain(s->left, written);
}
frame->nb_samples = ret;
s->pts += av_rescale_q(ret, (AVRational){1, outlink->sample_rate}, outlink->time_base);