From patchwork Tue Oct 3 15:35:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 44120 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1204:b0:15d:8365:d4b8 with SMTP id v4csp2140619pzf; Tue, 3 Oct 2023 08:36:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfHpmwtbQh8aMJRv70BsPLeuJH7CmywUchAJWVPwikk/mAl5YRxLb7ysHXJU7ZLUHjE3Ky X-Received: by 2002:a17:906:1d:b0:9b2:9a0e:9972 with SMTP id 29-20020a170906001d00b009b29a0e9972mr13489591eja.13.1696347395834; Tue, 03 Oct 2023 08:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696347395; cv=none; d=google.com; s=arc-20160816; b=gg1amXWqV0ME+rPmIPe8uv3gbEDe+WwtdVyvdyr3uXK4xXQnGUlszHBaAEZQoMqOyq 7Y0fD/FTw0fUQojCpe8eSd/MT+q7ddYZAgLf10Ap+/laW2ORlfwdUiBwftuipHNXdcwg N7Qb8yVXa1V6jBD44h9DjcHlmBFVtGv94lbJfLRpCjWXxQpTX6Vkt/V1JvQ+I16Z6sYn r4Qf3ifFndDzBOQFMCdRkQy7t/0fkU04KsTa+SmExtU37wLIgVJc5akcVouO/ROzOrpx jI49NKyb1ijHSgyBwlquHOyi7I6zl+RQlglukb2SrgI4KkArSuKNEpMomU+UMX+yL6mI 4Osw== 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=HQT6yrAuYQ92vY/BXtY+qkwE+ra+mmGEzIPwTFLZxKc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Dfq/n9yKISCQ00YJSReiRaJMJkCzZRR5rcyFSYY0JzN4S8lJplLfQcixz8wxoj5Es5 kTBt88wymByJ3vo9rEhh1Pgi21PY8wrHwTWX2VT1VnR4kcXr7Aha3evkarGX17xCZrdi Bt41OOiM48JO3ueftxQGZcy+oJZZuvqomvyNVe+PRCjqw3SQffRCMvKIH0IsVCSt1OaA Rq2HVDoPVoT/sIsvfGKZM3FVKgQ4gtx8HtlZHb3YX9iqohjm2+g1oRn/ocMsQAdXBlMk Ou461XEDPavvaJJ+sPRkjZT410pB70NRs3Po5c1DxShorRX9sIqDlyyNPOtSvUyYNCRU bJgQ== 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 kf1-20020a17090776c100b009a1694c93adsi698490ejc.249.2023.10.03.08.36.35; Tue, 03 Oct 2023 08:36:35 -0700 (PDT) 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 2CB1E68CCFB; Tue, 3 Oct 2023 18:35:53 +0300 (EEST) 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 DC2B268CA68 for ; Tue, 3 Oct 2023 18:35:41 +0300 (EEST) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 97AB0525A for ; Tue, 3 Oct 2023 17:35:41 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id SygVZmZCnUPO for ; Tue, 3 Oct 2023 17:35:41 +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 mail1.khirnov.net (Postfix) with ESMTPS id 32CDB526E for ; Tue, 3 Oct 2023 17:35:40 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3179D3A076E for ; Tue, 3 Oct 2023 17:35:33 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Oct 2023 17:35:20 +0200 Message-Id: <20231003153526.19228-6-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231003153526.19228-1-anton@khirnov.net> References: <20231003153526.19228-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/12] fftools/ffmpeg_enc: unbreak -force_key_frames source_no_drop 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: +BaD78cV2Gmj Unlike the 'source' mode, which preserves source keyframe-marking as-is, the 'source_no_drop' mode attempts to keep track of keyframes dropped by framerate conversion and mark the next output frame as key in such cases. However, * c75be061487 broke this functionality entirely, and made it equivalent to 'source' * even before it would only work when the frame immediately following the dropped keyframe is preserved and not dropped as well Also, drop a redundant check for 'frame' in setting dropped_keyframe, as it is redundant with the check on the above line. --- fftools/ffmpeg_enc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index b928bf208c..42f64a4a49 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -1066,7 +1066,7 @@ finish: } ost->last_dropped = *nb_frames == *nb_frames_prev && frame; - ost->kf.dropped_keyframe = ost->last_dropped && frame && (frame->flags & AV_FRAME_FLAG_KEY); + ost->kf.dropped_keyframe |= ost->last_dropped && (frame->flags & AV_FRAME_FLAG_KEY); } static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, @@ -1109,8 +1109,9 @@ static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf, (in_picture->flags & AV_FRAME_FLAG_KEY) && !dup_idx) { goto force_keyframe; } else if (kf->type == KF_FORCE_SOURCE_NO_DROP && !dup_idx) { + int dropped_keyframe = kf->dropped_keyframe; kf->dropped_keyframe = 0; - if ((in_picture->flags & AV_FRAME_FLAG_KEY) || kf->dropped_keyframe) + if ((in_picture->flags & AV_FRAME_FLAG_KEY) || dropped_keyframe) goto force_keyframe; }