From patchwork Wed Dec 13 19:30:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: FFmpeg Technical Committee X-Patchwork-Id: 45119 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp4501419pzf; Wed, 13 Dec 2023 11:31:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAkTTy7DV6nmmCW1vaPBTYVep3tDJPUumjOK1H8GzWxhjJhDUkw6o1ZNunlXuorqhjzC7v X-Received: by 2002:a19:675e:0:b0:50b:ed57:758c with SMTP id e30-20020a19675e000000b0050bed57758cmr7082240lfj.1.1702495874131; Wed, 13 Dec 2023 11:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702495874; cv=none; d=google.com; s=arc-20160816; b=SK3uKrMZaWlNNSGlbok+rQMw4f6Hu5PrEKvqrpy6tejDnFKUD8nsxpiHVbcE+/qF85 A7A7VHP2vUZAGP3IJzB8fCrUzRxbcyRQf12Pc71OrpaX1snRCWi7wz41lqkaB4WLJx0K okA+Yj0gHX8vQkrz6ryJKLIDEsmm2s9LDhKY6gzefyJJ32KLCCsqGxjD2QPOHFBmhQ+W Dj6KpjnZCTxtuymqnJnwjIzHjpSrfRrToM/f3beysjH1ORB/rhY/i8wnYXAPa/Y4AlN/ ioicP22rUC/M/puT+UCO1evi8KM74o/zYHK9rngB7m2ddqMNVzEXOwgYFW5kVSypD4Uf kttw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=PjMVf4YeMbmQuFkq4EpHIbNttpK76+bAcGq/WEp1hMc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=K27+3WkU7ikVrY5Rbz0x1QzzMrgcqQI6tC/rEjRiVnlFxCM47Ombv1D5f/unWNZsuK 0DR+D68DpFy/6OWCqsoPUf4g3Ezhznms1C3kaQnTvVLEzRn5AaNGb5KlXddKvH9oud5j A1+MrYeawV8LO8kf2IOErFUh4BZEwP67HAx5qZdbV0QUdpZbba70IJXNqn3ZDGcSMrPE zJH+tyDqPmJaQIica2cQ4kr3FEpPaObvRruGH+m4/Ycf1oW0VwS4ladljEQbC5Swphuf jTTtG6niJcwW+UFOTTGhn2+YaCkhQnQrzBpeEVRMMRZZFmyrkS9tq39vPqngLH+wzBMl l0Nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s26-20020a1709066c9a00b00a1d06bdb79bsi5868416ejr.190.2023.12.13.11.31.13; Wed, 13 Dec 2023 11:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 37CD968CDD1; Wed, 13 Dec 2023 21:30:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 910B468D07D for ; Wed, 13 Dec 2023 21:30:28 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 068071BA4 for ; Wed, 13 Dec 2023 20:30:24 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id X6otFlTXAtu8 for ; Wed, 13 Dec 2023 20:30:23 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 71B8E1CAE for ; Wed, 13 Dec 2023 20:30:21 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 864053A07CC for ; Wed, 13 Dec 2023 20:30:14 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Dec 2023 20:30:06 +0100 Message-ID: <20231213193007.17471-11-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231213193007.17471-1-anton@khirnov.net> References: <20231213193007.17471-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/12] fftools/ffmpeg: update the reported timestamp at the end 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2Q2doXU0C4dD Reported-by: microchip --- fftools/ffmpeg.c | 2 +- fftools/ffmpeg_sched.c | 13 ++++++++----- fftools/ffmpeg_sched.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8077248254..4c706eb46a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -926,7 +926,7 @@ static int transcode(Scheduler *sch) print_report(0, timer_start, cur_time, transcode_ts); } - ret = sch_stop(sch); + ret = sch_stop(sch, &transcode_ts); /* write the trailer if needed */ for (i = 0; i < nb_output_files; i++) { diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index ab14d6233e..b1c7db776e 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -423,7 +423,7 @@ static void task_init(Scheduler *sch, SchTask *task, enum SchedulerNodeType type task->func_arg = func_arg; } -static int64_t trailing_dts(const Scheduler *sch) +static int64_t trailing_dts(const Scheduler *sch, int count_finished) { int64_t min_dts = INT64_MAX; @@ -433,7 +433,7 @@ static int64_t trailing_dts(const Scheduler *sch) for (unsigned j = 0; j < mux->nb_streams; j++) { const SchMuxStream *ms = &mux->streams[j]; - if (ms->source_finished) + if (ms->source_finished && !count_finished) continue; if (ms->last_dts == AV_NOPTS_VALUE) return AV_NOPTS_VALUE; @@ -445,7 +445,7 @@ static int64_t trailing_dts(const Scheduler *sch) return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts; } -int sch_stop(Scheduler *sch) +int sch_stop(Scheduler *sch, int64_t *finish_ts) { int ret = 0, err; @@ -492,6 +492,9 @@ int sch_stop(Scheduler *sch) ret = err_merge(ret, err); } + if (finish_ts) + *finish_ts = trailing_dts(sch, 1); + return ret; } @@ -502,7 +505,7 @@ void sch_free(Scheduler **psch) if (!sch) return; - sch_stop(sch); + sch_stop(sch, NULL); for (unsigned i = 0; i < sch->nb_demux; i++) { SchDemux *d = &sch->demux[i]; @@ -1194,7 +1197,7 @@ static void schedule_update_locked(Scheduler *sch) if (atomic_load(&sch->terminate)) return; - dts = trailing_dts(sch); + dts = trailing_dts(sch, 0); atomic_store(&sch->last_dts, dts); diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h index 94bbd30e98..b167d8d158 100644 --- a/fftools/ffmpeg_sched.h +++ b/fftools/ffmpeg_sched.h @@ -127,7 +127,7 @@ Scheduler *sch_alloc(void); void sch_free(Scheduler **sch); int sch_start(Scheduler *sch); -int sch_stop(Scheduler *sch); +int sch_stop(Scheduler *sch, int64_t *finish_ts); /** * Wait until transcoding terminates or the specified timeout elapses.