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 CE9D7409CE for ; Mon, 4 Apr 2022 11:33:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4EEEA68B254; Mon, 4 Apr 2022 14:32:27 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1DBA568B109 for ; Mon, 4 Apr 2022 14:32:18 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A58762404FE for ; Mon, 4 Apr 2022 13:32:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id KJvFrmNnTElR for ; Mon, 4 Apr 2022 13:32:14 +0200 (CEST) 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 mail0.khirnov.net (Postfix) with ESMTPS id 9109E2400F5 for ; Mon, 4 Apr 2022 13:32:14 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id A37D83A06CD; Mon, 4 Apr 2022 13:32:11 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Apr 2022 13:29:51 +0200 Message-Id: <20220404113037.13070-4-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220404113037.13070-1-anton@khirnov.net> References: <20220404113037.13070-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/49] fftools/ffmpeg: stop using OutputStream.frame_number for streamcopy 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 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: This field is currently used by checks - skipping packets before the first keyframe - skipping packets before start time to test whether any packets have been output already. But since frame_number is incremented after the bitstream filters are applied (which may involve delay), this use is incorrect. The keyframe check works around this by adding an extra flag, the start-time check does not. Simplify both checks by replacing the seen_kf flag with a flag tracking whether any packets have been output by do_streamcopy(). --- fftools/ffmpeg.c | 10 +++++----- fftools/ffmpeg.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 13be32f0cf..29b01f9d93 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -894,8 +894,6 @@ static void output_packet(OutputFile *of, AVPacket *pkt, /* apply the output bitstream filters */ if (ost->bsf_ctx) { - if (pkt->flags & AV_PKT_FLAG_KEY) - ost->seen_kf = 1; ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt); if (ret < 0) goto finish; @@ -2043,11 +2041,11 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p return; } - if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && - !ost->copy_initial_nonkeyframes && !ost->seen_kf) + if (!ost->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) && + !ost->copy_initial_nonkeyframes) return; - if (!ost->frame_number && !ost->copy_prior_start) { + if (!ost->streamcopy_started && !ost->copy_prior_start) { int64_t comp_start = start_time; if (copy_ts && f->start_time != AV_NOPTS_VALUE) comp_start = FFMAX(start_time, f->start_time + f->ts_offset); @@ -2101,6 +2099,8 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p ost->sync_opts += opkt->duration; output_packet(of, opkt, ost, 0); + + ost->streamcopy_started = 1; } int guess_input_channel_layout(InputStream *ist) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1e14bf9fa9..04369df139 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -536,7 +536,7 @@ typedef struct OutputStream { int inputs_done; const char *attachment_filename; - int seen_kf; + int streamcopy_started; int copy_initial_nonkeyframes; int copy_prior_start; char *disposition; -- 2.34.1 _______________________________________________ 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".