From patchwork Sun Nov 19 11:49:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 44718 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6a89:b0:181:818d:5e7f with SMTP id bi9csp993362pzb; Sun, 19 Nov 2023 03:49:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBUgU0K9OEh/4uDswTCQ6Q/CWlS45VJrX4h4V3acybVwsLtykTxta2RgeSHlHUQCBS0A1V X-Received: by 2002:a17:907:c004:b0:9dd:bd42:4ec7 with SMTP id ss4-20020a170907c00400b009ddbd424ec7mr3541506ejc.38.1700394591998; Sun, 19 Nov 2023 03:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700394591; cv=none; d=google.com; s=arc-20160816; b=huQC4cn84US7nt5J8n1MjPMnSwhonkjp8tB6gbrFVYKLnEk0viCj93f+lf64b9VDpU REDMzhLsuO9LyoX+BnPBV8+MmgGUF2jX/ZMPdX6NqJscGpFj5GYH+9/AXxYeOPyu/+J+ nXUYJYJu1M0LusmVmJA/sydfrGRdoVwGWicR7eSBoQ0p34oBvAnEV63gX4TNO6umWk62 sUaXCdMGD+R5sHMSKWgNAh9J+lTkpO+k7tXKRVL2+9wsy5mEGoGOHXeHiYhxxEr3o5Dy mXVNIe7MIjIUU8eVT5RtDq8ouiu104sGTSDpyQ4WhoMCZOfSGpRNcG+0Creb2xkipDne a4lA== 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=6zLQBdUNSBIOaatO0SJjNU8BDpuqbpK4DLlrLAERjQQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=W3ZUyYbvQZYvkPWR89S0EK8B1kjPaPj4WFQRXrrChL4vdAZwwOkrHZDxdmcbLk7VjN k/DCHq7sa3kYrhEJuW3KOAvTbXAjhcrul93ac6buSwoZ3o5mHmF2X/NZ8jhxTsBaGFZS Gmywe4Geu9NTgssLzHKAcm85txaieqAvOvha71Qw3tud6YtTPjE7wqMUsSSFq846W8dH VWv1kAw4tgO9tZJYCmLyr/yn0fepmVlGyF0Sm+zZ/HVinQacxlOZiSVwbHbV4I/MOQrv TW84jMI69WQSLwYQtOn/2hTxIj27FmQcrXzCHJwWZORJzcnRrTHW6edPsFyCKQxdixg3 Z5EA== 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 gx24-20020a170906f1d800b009b2d4dd4a10si3524226ejb.892.2023.11.19.03.49.51; Sun, 19 Nov 2023 03:49:51 -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 DB77468CD69; Sun, 19 Nov 2023 13:49:42 +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 ED17068CC0B for ; Sun, 19 Nov 2023 13:49:34 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 17C5514E4 for ; Sun, 19 Nov 2023 12:49:34 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id BTKL5-3F5Xjp for ; Sun, 19 Nov 2023 12:49:33 +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 612C110B9 for ; Sun, 19 Nov 2023 12:49:33 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2D0863A054A for ; Sun, 19 Nov 2023 12:49:27 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Nov 2023 12:49:17 +0100 Message-ID: <20231119114917.1277-2-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119114917.1277-1-anton@khirnov.net> References: <20231119114917.1277-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/vsrc_ddagrab: add an option to avoid duplicating frames 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: WbUDmd+aOS25 --- doc/filters.texi | 15 +++++++++++---- libavfilter/vsrc_ddagrab.c | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index bd4e4ca8f7..30b7c73826 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -28165,10 +28165,10 @@ it'll always be captured. @item framerate Maximum framerate at which the desktop will be captured - the interval between successive frames will not be smaller than the inverse of the framerate. When -the desktop is not being updated often enough, the filter will duplicate -a previous frame. Note that there is no background buffering going on, so when -the filter is not polled often enough then the actual inter-frame interval may -be significantly larger. +@var{dup_frames} is true (the default) and the desktop is not being updated +often enough, the filter will duplicate a previous frame. Note that there is no +background buffering going on, so when the filter is not polled often enough +then the actual inter-frame interval may be significantly larger. Defaults to 30 FPS. @@ -28201,6 +28201,13 @@ Passes all supported output formats to DDA and returns what DDA decides to use. Filter initialization will fail if 10 bit format is requested but unavailable. @end table +@item dup_frames +When this option is set to true (the default), the filter will duplicate frames +when the desktop has not been updated in order to maintain approximately +constant target framerate. When this option is set to false, the filter will +wait for the desktop to be updated (inter-frame intervals may vary significantly +in this case). + @end table @subsection Examples diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c index 9c59faf53e..76dd11af51 100644 --- a/libavfilter/vsrc_ddagrab.c +++ b/libavfilter/vsrc_ddagrab.c @@ -101,6 +101,7 @@ typedef struct DdagrabContext { int out_fmt; int allow_fallback; int force_fmt; + int dup_frames; } DdagrabContext; #define OFFSET(x) offsetof(DdagrabContext, x) @@ -124,6 +125,8 @@ static const AVOption ddagrab_options[] = { OFFSET(allow_fallback), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "force_fmt", "exclude BGRA from format list (experimental, discouraged by Microsoft)", OFFSET(force_fmt), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, + { "dup_frames", "duplicate frames to maintain framerate", + OFFSET(dup_frames), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, { NULL } }; @@ -1067,7 +1070,9 @@ static int ddagrab_request_frame(AVFilterLink *outlink) now -= dda->first_pts; if (!dda->probed_texture) { - ret = next_frame_internal(avctx, &cur_texture, 0); + do { + ret = next_frame_internal(avctx, &cur_texture, 0); + } while (ret == AVERROR(EAGAIN) && !dda->dup_frames); } else { cur_texture = dda->probed_texture; dda->probed_texture = NULL;