From patchwork Tue Mar 15 09:05:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34743 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837023nkb; Tue, 15 Mar 2022 02:06:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpK7PeGaxAEBifvqwzLvF+SOl0S4ovgUKs+dUMKA2LM8ijKPO2lyZl8vxrbbawpSdAWYZ2 X-Received: by 2002:a05:6402:4312:b0:418:8a5a:14b9 with SMTP id m18-20020a056402431200b004188a5a14b9mr7228542edc.294.1647335167904; Tue, 15 Mar 2022 02:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335167; cv=none; d=google.com; s=arc-20160816; b=YjM+cIC1y6/gOKyXl4vyPmc2jlPA3v6LImbFmNhJvAPg+gAkJxoqMbV2UIDqJWYGK+ g/G1WROp7DD0iNTAiGCc9u3gHLJ4JQd3IslRM6goYAgsEmocKW9l2Dm9Dwh/LcZ7C/xp VjxxhsiyDPDm8+Caiul+u0c6WIkcqPa3vTQsgYQyuSvyx4VQv6Nq1OLFUeB6y8D+xwjY V3sHF3891FJv1Whhlf5+o28X26/RVTwdJhFXdfpZYk/gfhBMmfhI8h4Yq5dGDMDlP6RH c0qs+bgFa/+8HsEJE+Wl6Kssrr5E4mWFEz4yevQ+sJMf4+uPYt1aENypd48j0cb5XxMU 6v6Q== 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=0kfDbaeDzURUg2F6UeyzWWDoVm5qJFleTN+fCUxNuqU=; b=aW7uHbJmIkdszjiYCiIZvn3XZnEHa6D5pO7HTTte2p73+hZF2hQAUZN/nopTGwL4ya BoxvEZT4FbWLcCUQgUHVsKa6mWvFSo2++RIWvKoRyxOG6zw3QcsZ/AokWdWttp5sfHz1 /Qa2jhul21nlhtXPRUOvNJiu9NXa/gGwEZAZZo52Rmkx/KohM0M3SChHIS04ta2xx8k5 hnCVBS77vIcE6vqZbCRxlDGoHbS0SiZdmgQUh85JqsZ0GPZZGBeTeKaB/1scGgJGxXYu 3Ua8rV/4Twg+ovhoKe7dAjEXcvuH+66/Xq0irHqEQbqvzJFaFytFJmBYhocFfqSEOSQO 9CrA== 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 j40-20020a05640223a800b00418cc738a03si421140eda.152.2022.03.15.02.06.07; Tue, 15 Mar 2022 02:06:07 -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 7B8DB68B1AD; Tue, 15 Mar 2022 11:05:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AC55A68A948 for ; Tue, 15 Mar 2022 11:05:48 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 55AB6240179 for ; Tue, 15 Mar 2022 10:05:48 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id drJBJsxzw6Pj for ; Tue, 15 Mar 2022 10:05:47 +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 mail0.khirnov.net (Postfix) with ESMTPS id 6886924017E for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 198BB3A06EC; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:27 +0100 Message-Id: <20220315090532.27295-5-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220315090532.27295-1-anton@khirnov.net> References: <20220315090532.27295-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/10] fftools: move opt_timelimit from cmdutils to ffmpeg 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: 9697RJgtummd This option is only supported by ffmpeg. --- fftools/cmdutils.c | 17 ----------------- fftools/ffmpeg_opt.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 12ef07b62f..e5684fa840 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -47,10 +47,6 @@ #include "libavutil/opt.h" #include "cmdutils.h" #include "opt_common.h" -#if HAVE_SYS_RESOURCE_H -#include -#include -#endif #ifdef _WIN32 #include #endif @@ -797,19 +793,6 @@ do { \ return 0; } -int opt_timelimit(void *optctx, const char *opt, const char *arg) -{ -#if HAVE_SETRLIMIT - int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); - struct rlimit rl = { lim, lim + 1 }; - if (setrlimit(RLIMIT_CPU, &rl)) - perror("setrlimit"); -#else - av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt); -#endif - return 0; -} - void print_error(const char *filename, int err) { char errbuf[128]; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index b2746259d7..778e02c39e 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -19,8 +19,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include +#if HAVE_SYS_RESOURCE_H +#include +#include +#endif + #include "ffmpeg.h" #include "cmdutils.h" #include "opt_common.h" @@ -3501,6 +3508,19 @@ static int opt_progress(void *optctx, const char *opt, const char *arg) return 0; } +int opt_timelimit(void *optctx, const char *opt, const char *arg) +{ +#if HAVE_SETRLIMIT + int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); + struct rlimit rl = { lim, lim + 1 }; + if (setrlimit(RLIMIT_CPU, &rl)) + perror("setrlimit"); +#else + av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt); +#endif + return 0; +} + #define OFFSET(x) offsetof(OptionsContext, x) const OptionDef options[] = { /* main options */