From patchwork Tue Sep 19 19:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 43791 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a886:b0:149:dfde:5c0a with SMTP id ca6csp168956pzb; Tue, 19 Sep 2023 12:21:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcu3CenC0/JtJKsyCR1jOhv1lRzfop0ckzXoGY4xkZgEj7qUFWn7DBG/cnu+TRsRsu+NR+ X-Received: by 2002:a17:906:209a:b0:9a5:da6c:6539 with SMTP id 26-20020a170906209a00b009a5da6c6539mr249023ejq.75.1695151318321; Tue, 19 Sep 2023 12:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695151318; cv=none; d=google.com; s=arc-20160816; b=bjh/sTxkUjYTJ+LgqFogmbX2t3a85Euxg26spMdLx/RVJk19JLhKWU9yc6iIqK4rhO OB8ZeuLGYh64IfFIVa91DuXwi15r01H5tFUbHA/kxLyHZA+BSdAg66L79AA7NVAOTPvD +R+ikXkmPRYTiHvqMVRhUdZyr2OHxEwJi8CH6DH0WhSwcGFHpafy9wtO98QbMmBjHeT2 VVb66AYzjC0pYNcy3o2q9TR338Pscf0YIWy63IU1hJxDDwKDGUTyvsgYuC94oepeLEG2 2Q89nTXmylQYGvYmiYUJW9BJtRkFyw37FjNf3veW+aT6fmuk9VbRof9i8U4sq95nuvJ8 sLgQ== 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=0Js8lwCrO3X1q8Of3nq8B/r5us4ecLytb+fuYnm5qXA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=VR0TVkNgsd/dboymYWRmYqAP+Xreiteeq4uGB7dmUiRNO/nQj5DLCZ0Xt14lHMB0BC yz7/gAlgo/FLE/JneYc8kf9ExaQNXdrZ+hfP7qJrBxnctHUSjX9geVD+nhZRbo/xHOa7 O/sc5aRifVjOzLgg1MBa5TnDMPckR7walDhoSg5uc1YD2WTRhqt9R71M9rm0aSXGQfcR z0TSVOjO4RrseDONCoFrmEGHI/V1A045awnxnz0LiRFt2D30Z7gKwZW3yeF89gwCzkBE UxsQkWQa7VHvA0g+ELpru4QzZculRisNHlZVRX7Li8UKCwE19807vTUR5o10eKR8qhL+ eMhg== 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 rp9-20020a170906d96900b0098d861f6513si9868207ejb.68.2023.09.19.12.21.57; Tue, 19 Sep 2023 12:21:58 -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 473FC68C941; Tue, 19 Sep 2023 22:21:07 +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 9319E68C911 for ; Tue, 19 Sep 2023 22:21:03 +0300 (EEST) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 406BD10 for ; Tue, 19 Sep 2023 21:21:03 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id qgFWwWEVMIG1 for ; Tue, 19 Sep 2023 21:20:58 +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 5F1425138 for ; Tue, 19 Sep 2023 21:20:42 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 528D93A0212 for ; Tue, 19 Sep 2023 21:20:42 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 19 Sep 2023 21:10:34 +0200 Message-Id: <20230919191044.18873-8-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230919191044.18873-1-anton@khirnov.net> References: <20230919191044.18873-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/27] 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: nim2By+aBtw5 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 df79eaff59..1db67d1497 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; }