From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C124146737 for ; Fri, 16 Jun 2023 09:33:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7FF1568C622; Fri, 16 Jun 2023 12:30:45 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3396768C5D6 for ; Fri, 16 Jun 2023 12:30:27 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id C0E1F41BA3; Fri, 16 Jun 2023 11:30:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907826; bh=HKWjlu8KKEg6OlLK2OancmXPiWY/FBr2CWdzCUWqUn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WZuqMKKhVV5eDAz/5o3GEzMFPsj5jB8I2xYbb0T1cXqIEpyL9rfrdppotUHqUtH03 thXnP7EqcLPKNptFr5Ij4QvamwKDRH87JgUEsfkbtGNzVlJsCSWhmDiWn2AxLOynpK J8a3WJhM28stnJLaSGXLYlvuxoKrQ/StHZKdWKjo= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:50 +0200 Message-ID: <20230616092959.5247-13-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/22] lavfi/vf_libplacebo: determine PTS of next frame from any input X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Niklas Haas 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 08bb468c6b..5903bd5a01 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -971,11 +971,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()); @@ -987,24 +987,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)), )); @@ -1016,7 +1023,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".