aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2023-06-15 16:03:32 +0200
committerNiklas Haas <git@haasn.dev>2023-06-20 17:09:58 +0200
commit6c41c3f92815b9b62d19f871cbb261afbd58d5a0 (patch)
tree074bddfed86d35c146e142ac7e747621b91c2da6
parent502b699a506b7854d382a58e4910f5f13f4846e4 (diff)
downloadffmpeg-6c41c3f92815b9b62d19f871cbb261afbd58d5a0.tar.gz
lavfi/vf_libplacebo: only drain actually used PTS
When combining multiple inputs, the output PTS may be less than the PTS of the input. In this case, the current's code assumption of always draining one value from the FIFO is incorrect. Replace by a smarter function which drains only those PTS values that were actually consumed.
-rw-r--r--libavfilter/vf_libplacebo.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 47f019fa19..753d6f3cc7 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -971,6 +971,13 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input)
return 0;
}
+static void drain_input_pts(LibplaceboInput *in, int64_t until)
+{
+ int64_t pts;
+ while (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0 && pts <= until)
+ av_fifo_drain2(in->out_pts, 1);
+}
+
static int libplacebo_activate(AVFilterContext *ctx)
{
int ret, retry = 0;
@@ -1023,8 +1030,7 @@ static int libplacebo_activate(AVFilterContext *ctx)
ff_inlink_request_frame(in->link);
return 0;
case PL_QUEUE_OK:
- if (!s->fps.num)
- av_fifo_drain2(in->out_pts, 1);
+ drain_input_pts(in, out_pts);
return output_frame(ctx, out_pts);
case PL_QUEUE_ERR:
return AVERROR_EXTERNAL;