From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH v2 13/22] lavfi/vf_libplacebo: determine PTS of next frame from any input
Date: Sun, 18 Jun 2023 13:17:05 +0200
Message-ID: <20230618111955.40994-15-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20230618111955.40994-2-ffmpeg@haasn.xyz>
From: Niklas Haas <git@haasn.dev>
When combining multiple inputs with different PTS and durations, in
input-timed mode, we emit one output frame for every input frame PTS,
from *any* input. So when combining a low FPS stream with a high FPS
stream, the output framerate would match the higher FPS, independent of
which order they are specified in.
---
libavfilter/vf_libplacebo.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index a56ebbf54e7..47f019fa192 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -973,11 +973,11 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input)
static int libplacebo_activate(AVFilterContext *ctx)
{
- int ret;
+ int ret, retry = 0;
LibplaceboContext *s = ctx->priv;
LibplaceboInput *in = &s->inputs[0];
AVFilterLink *outlink = ctx->outputs[0];
- int64_t pts;
+ int64_t pts, out_pts;
FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
pl_log_level_update(s->log, get_log_level());
@@ -989,24 +989,31 @@ static int libplacebo_activate(AVFilterContext *ctx)
if (ff_outlink_frame_wanted(outlink)) {
if (s->fps.num) {
- pts = outlink->frame_count_out;
- } else if (av_fifo_peek(in->out_pts, &pts, 1, 0) < 0) {
- /* No frames queued */
- if (in->status) {
- pts = in->status_pts;
- } else {
- ff_inlink_request_frame(in->link);
- return 0;
+ out_pts = outlink->frame_count_out;
+ } else {
+ /* Determine the PTS of the next frame from any active input */
+ out_pts = INT64_MAX;
+ for (int i = 0; i < s->nb_inputs; i++) {
+ LibplaceboInput *in = &s->inputs[i];
+ if (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0) {
+ out_pts = FFMIN(out_pts, pts);
+ } else if (!in->status) {
+ ff_inlink_request_frame(in->link);
+ retry = true;
+ }
}
+
+ if (retry) /* some inputs are incomplete */
+ return 0;
}
- if (s->status && pts >= s->status_pts) {
+ if (s->status && out_pts >= s->status_pts) {
ff_outlink_set_status(outlink, s->status, s->status_pts);
return 0;
}
in->qstatus = pl_queue_update(in->queue, &in->mix, pl_queue_params(
- .pts = pts * av_q2d(outlink->time_base),
+ .pts = out_pts * av_q2d(outlink->time_base),
.radius = pl_frame_mix_radius(&s->params),
.vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)),
));
@@ -1018,7 +1025,7 @@ static int libplacebo_activate(AVFilterContext *ctx)
case PL_QUEUE_OK:
if (!s->fps.num)
av_fifo_drain2(in->out_pts, 1);
- return output_frame(ctx, pts);
+ return output_frame(ctx, out_pts);
case PL_QUEUE_ERR:
return AVERROR_EXTERNAL;
}
--
2.41.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-06-18 11:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-18 11:16 [FFmpeg-devel] lavfi/vf_libplacebo: generalize to multiple inputs Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 01/22] lavfi/vf_libplacebo: drop redundant case Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 02/22] lavfi/vf_libplacebo: move input-specific state to struct Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 03/22] lavfi/vf_libplacebo: move input handling to separate function Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 04/22] lavfi/vf_libplacebo: cosmetic Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 05/22] lavfi/vf_libplacebo: move temporary vars into per-input struct Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 06/22] lavif/vf_libplacebo: remove pl_frame_mix from output_frame_mix Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 07/22] lavfi/vf_libplacebo: factor out ref frame logic Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 08/22] lavfi/vf_libplacebo: use correct link in update_crops() Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 09/22] lavfi/vf_libplacebo: replace s->input by dynamic array Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 10/22] lavfi/vf_libplacebo: keep track of latest status globally Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 11/22] lavfi/vf_libplacebo: support blending multiple inputs Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 12/22] lavfi/vf_libplacebo: handle " Niklas Haas
2023-06-18 11:17 ` Niklas Haas [this message]
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 14/22] lavfi/vf_libplacebo: only drain actually used PTS Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 15/22] lavfi/vf_libplacebo: generalize frame update to multiple inputs Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 16/22] lavfi/vf_libplacebo: make input-dependent vars dynamic Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 17/22] lavfi/vf_libplacebo: add in_idx variable Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 18/22] lavfi/vf_libplacebo: set format list for all inputs Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 19/22] lavfi/vf_libplacebo: skip cache selectively per-input Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 20/22] lavfi/vf_libplacebo: also skip cache if in FPS == out FPS Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 21/22] lavfi/vf_libplacebo: set time_base/frame_rate dynamically Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 22/22] lavfi/vf_libplacebo: add nb_inputs option Niklas Haas
2023-06-20 14:50 ` [FFmpeg-devel] lavfi/vf_libplacebo: generalize to multiple inputs Marvin Scholz
2023-06-20 15:12 ` Niklas Haas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230618111955.40994-15-ffmpeg@haasn.xyz \
--to=ffmpeg@haasn.xyz \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=git@haasn.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git