From patchwork Tue Mar 15 09:05:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34744 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837128nkb; Tue, 15 Mar 2022 02:06:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB6Dg/pzPYK6l3BCPcRqX/DV/mXxJOo4996UFqgXaAzKJBVYA7PPkyZfYJBS3BPggPvqNx X-Received: by 2002:a05:6402:2750:b0:416:29dd:1d17 with SMTP id z16-20020a056402275000b0041629dd1d17mr24211135edd.387.1647335176882; Tue, 15 Mar 2022 02:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335176; cv=none; d=google.com; s=arc-20160816; b=b3M+o08qW/UGsN2KH4qvyNx7Q7+KOggbe/wOh1mEwSw7707L2jxqXWYKcY8z3gyt5j 72hIbGXRKXHgd7ElIalg7+v6piylkX4nkbGMARADyA42AS1swghYThgmaVabvNF9j9W1 quLATRzZCGZqEpM6KRJ814fhssmxe4ctjoOJRve3DbPd5DBYlOYylJgKtWvoDZBwWv6h bK6RqoGbsM5sAbHMid2RSL1S/lhI6jS1cR/jtZTAjI1d/rSMbpL1cY0Ap188Zzbn+hc0 T7lASOh0FuTZbN7liP79YxDPvakr4ZbdD+r0jm7ipjktmothiUmt/UmPotLEiOgm0Y3U zC4Q== 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:message-id:date:to:from :delivered-to; bh=8tae3Vagvm58wDaJl48V4L01O8MxwknZOJLFxMmuuaE=; b=VVgyoeZefEvtExR4aWjnFQlRN/4KRNW3zxshdX5WLjyXpahzs7jr+EQkG7NRFrsnmn ayqFGmaunVADd4mQxcVbVhY8v/GenUz7ik5bRQ6d3ef2M9HBG9j455BwLPjqUiJwNsG+ Z2OrBxXKBEEiCUWx8j3zwHsPmGyjJ6AcvKDbt44AhH946wYJ+UFco3sqvQjUlqVSNUTa RZdIwVj8cLpY2HY2pdMA9pyxeuUzfUQ8yYOulxZjH7+vrtiP5EOXmj3gSLaQUZfRJ3d3 dmajDpDdz1CoLOYl84+n4P1hwegHuOZ9nrF6Uc4NWMiBolgIXI7lMge/iQzA/4bwi8de 5wZw== 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 qa13-20020a170907868d00b006db2a446a3asi12475393ejc.714.2022.03.15.02.06.16; Tue, 15 Mar 2022 02:06:16 -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 A162D68B195; Tue, 15 Mar 2022 11:05:56 +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 3939A68B195 for ; Tue, 15 Mar 2022 11:05:49 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D3AFE24017E 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 ZI3J0bSQHysH for ; Tue, 15 Mar 2022 10:05:46 +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 4EF452400F5 for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 07E913A0406; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:23 +0100 Message-Id: <20220315090532.27295-1-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/10] fftools/cmdutils: drop prototypes for nonexistent functions 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: gUj9zTsmHt2J --- fftools/cmdutils.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 50eed9b13a..d8e5aa342b 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -66,11 +66,6 @@ void exit_program(int ret) av_noreturn; */ void init_dynload(void); -/** - * Initialize the cmdutils option system, in particular - * allocate the *_opts contexts. - */ -void init_opts(void); /** * Uninitialize the cmdutils option system, in particular * free the *_opts contexts and their contents. @@ -108,8 +103,6 @@ int opt_report(void *optctx, const char *opt, const char *arg); int opt_max_alloc(void *optctx, const char *opt, const char *arg); -int opt_codec_debug(void *optctx, const char *opt, const char *arg); - /** * Limit the execution time. */ From patchwork Tue Mar 15 09:05:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34742 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2836918nkb; Tue, 15 Mar 2022 02:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6Gkz5KMqwtj1pcxOZ648Xt1kH39ooavvG2gypXe2vSjdjqr32CWFK2sIQvjMfgjw+ce9q X-Received: by 2002:a17:907:3f86:b0:6db:b745:f761 with SMTP id hr6-20020a1709073f8600b006dbb745f761mr12012993ejc.610.1647335158147; Tue, 15 Mar 2022 02:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335158; cv=none; d=google.com; s=arc-20160816; b=q4nEvO8SzmrVyuRbKDcRlMfybcmhSew1UmUQ1TnD0NJxJ+s1HRbf8yWTa8Q/MGpV3m 95Etnz5SUSibIIs3jSWIORieayMazoiQCCe5L2CkFqdDQJwFNGp+DDWJqDsT4X5mhj7O PsM6gL8bxUfB4LrHTHmJQo5iHiughnFknIYfEACkInEW1pPGdH/jdMWaz6tRrucF2Pth IdJUUFWC9hD+In277jVKg4BiF+2nvJ5Z9DrRu6lgylNIg0i371gdvZ71/fqlEM6WqZYu KcpFJmggNHluK6OBvoPOuekn3XHaGT/xGd+0bxaXElCPCVkaAaSUJ2BqmZHr0CfewZCx 8ErA== 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=q644PnGwSSJdBEQmluaVtHeHigvHrvw1V/xCPYCmXb8=; b=rMhqT5EpI9i7jDk4j5LOs4Nkd9zzKEbrQz5CmjI81LlY86AyuDYZ/xeDOV0tVDb18F U0p/qatjyuKTNXBqbRZD0UDCkbVrVVT03J5AqEqjXmDNekSjMVMQ1ZCVBfoulOe84MnY huUqcW+Lr0tU3G72wdXn0KjnX2lWFPAY5hBrlVBJgV/Q4EtyzPopkyEPahpnjnSHfNsw n/L2K3REvX/INcetqLHMO7Nnbda4FbXUE7uktVP/ekUuKCSGGZEptZiD8JYusN97m7G3 iLjyXqBfYzw1XaQAsFRBBN2Psl3cJJvgpFrWkAcnmRL0dI+INW+rd3BdWNw8tKdLtxRd 3dAA== 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 e26-20020a170906315a00b006cf60c8c029si9871721eje.340.2022.03.15.02.05.57; Tue, 15 Mar 2022 02:05: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 5B2CC68B19C; Tue, 15 Mar 2022 11:05:54 +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 DEC0968A255 for ; Tue, 15 Mar 2022 11:05:47 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 72C9824052D for ; Tue, 15 Mar 2022 10:05:47 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id m-Ov0o1rbGm0 for ; Tue, 15 Mar 2022 10:05:46 +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 5E5A2240179 for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 09D093A0189; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:24 +0100 Message-Id: <20220315090532.27295-2-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 02/10] fftools/cmdutils: drop extern declarations for nonexistent variables 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: eXWnTJKj3fyw --- fftools/cmdutils.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index d8e5aa342b..f460cb028e 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -44,8 +44,6 @@ extern const char program_name[]; */ extern const int program_birth_year; -extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; -extern AVFormatContext *avformat_opts; extern AVDictionary *sws_dict; extern AVDictionary *swr_opts; extern AVDictionary *format_opts, *codec_opts; From patchwork Tue Mar 15 09:05:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34746 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837329nkb; Tue, 15 Mar 2022 02:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLBEMcZiRZc8ltmB6BwrsXumyOfnmCvITXXA9i12ls1t5TF3AwfZu8wqCMDKQoAqpYHla0 X-Received: by 2002:a17:906:32d8:b0:6ce:d850:f79 with SMTP id k24-20020a17090632d800b006ced8500f79mr21081755ejk.414.1647335196974; Tue, 15 Mar 2022 02:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335196; cv=none; d=google.com; s=arc-20160816; b=vquoa4AgYlYuT62bOA0qzODQcTWYqE6ydDzVMJbOniqZHifhM0/PBcSK0NnhGc8Rsb eQ2LvTN1ji0TxDmOTDlqLcVfCEQck/X5VRj77HoL0yTRtMkPqSwC6ppibxCboQpo4OW4 CcCtJ2TwSHWk1lxU7kaz/8ZKRhZ480uyliCuGk+SvaAJ/OQdR8vjheOfPZUcrfP+C6Nl oW1F7gR/72Ug23BOfPgKKSFu5EePXt3rdklLai0CUDckxaDpPizs9ISy13psDQqiLzrk D8r+BXBLW9aIZsqne54yQKHoxxpNcDYdxFFyoKj7iF9wTmLVl5qRHzcVrEaDBZNdo5A4 MpLA== 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=P20HPBrZHkTF9kEIS2PI4L3s/G3c7QoSVBaJ6Ft7dUk=; b=d6CwqBKf7itgU0RdtoIRbw2Hue/QPvDRKoPsPbrFnyy14l7h1d0gdOBuMTYvzhoT2n E3CoKS1J4fKReQVcRb4cgHOk5YtIhT280fRLguxDHTiiXeHW6B/Px0b/hRyiJ71YoQpg lhj+QxpQ1dTMz0rWwdKBgZ0p5YKxSkDRUZyu2wIZ7Bg3BdBr+76d3JxocjJpZ+NX/A0W iViGL1Bm7xkXuzfSEZmr3BfBZmhcAS3wiYm8tzRudcmAjrYnsyODm4EhGcHD25TUcRWf 6Zb/0YuCucDTwXvyUlp8LU0OLPhEGKemOBGfL2GBt3vBO1lwZ8nIbKt07A1UvFQcIENA ZPWw== 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 kw7-20020a170907770700b006ccb88d08dcsi10391968ejc.441.2022.03.15.02.06.36; Tue, 15 Mar 2022 02:06:36 -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 7666168B1CA; Tue, 15 Mar 2022 11:05:58 +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 5713168B1A5 for ; Tue, 15 Mar 2022 11:05:51 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F14382404FE for ; Tue, 15 Mar 2022 10:05:50 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NsQq-FHJUypg for ; Tue, 15 Mar 2022 10:05:48 +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 94753240506 for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 0C4E03A0631; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:25 +0100 Message-Id: <20220315090532.27295-3-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 03/10] fftools: drop useless indirection 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: j0E4v/qsltFb --- fftools/cmdutils.c | 4 ++-- fftools/cmdutils.h | 2 -- fftools/ffmpeg.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 4b50e15eef..0ac98852fe 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -1961,7 +1961,7 @@ static void show_help_filter(const char *name) count = avfilter_filter_pad_count(f, 0); for (i = 0; i < count; i++) { printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), - media_type_string(avfilter_pad_get_type(f->inputs, i))); + av_get_media_type_string(avfilter_pad_get_type(f->inputs, i))); } if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS) printf(" dynamic (depending on the options)\n"); @@ -1972,7 +1972,7 @@ static void show_help_filter(const char *name) count = avfilter_filter_pad_count(f, 1); for (i = 0; i < count; i++) { printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), - media_type_string(avfilter_pad_get_type(f->outputs, i))); + av_get_media_type_string(avfilter_pad_get_type(f->outputs, i))); } if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS) printf(" dynamic (depending on the options)\n"); diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index f460cb028e..57db531f5c 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -633,8 +633,6 @@ void *grow_array(void *array, int elem_size, int *size, int new_size); */ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); -#define media_type_string av_get_media_type_string - #define GROW_ARRAY(array, nb_elems)\ array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 9a3fdc636d..eaca897aec 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1606,7 +1606,7 @@ static void print_final_stats(int64_t total_size) total_packets += ist->nb_packets; av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", - i, j, media_type_string(type)); + i, j, av_get_media_type_string(type)); av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", ist->nb_packets, ist->data_size); @@ -1640,7 +1640,7 @@ static void print_final_stats(int64_t total_size) total_packets += ost->packets_written; av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", - i, j, media_type_string(type)); + i, j, av_get_media_type_string(type)); if (ost->encoding_needed) { av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", ost->frames_encoded); From patchwork Tue Mar 15 09:05:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34748 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837526nkb; Tue, 15 Mar 2022 02:06:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxodGyVwz4sJqT0BXA7N8yoBjtcEoLa309fNtkjJkM6ssFmBIn5DF7cDDuqLyVKzLBOUrf X-Received: by 2002:a17:907:7286:b0:6db:d279:49ee with SMTP id dt6-20020a170907728600b006dbd27949eemr7589412ejc.191.1647335219175; Tue, 15 Mar 2022 02:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335219; cv=none; d=google.com; s=arc-20160816; b=VJBpnEiz2h1ZPKkBZAUpy7A/KJB6l/op3vRmoe8vKZQ5Fl4VJf9aqwz5qewnD80etb hP+kSfkQBqNqtwlmGPqvkrDrP5b0PlvQswhSPTuQvD+16+8+diOLV4QFbhdlY87Lf43h 1jrtEM/c/YO+UtMJr8YJn6JALpIoJcm2dVoExG5d8DYNlYRU9WJhvitadeGiOkfNEsqT QwqQ7OpkQZej283FwOTmlVt3flEqA0feNlAMCzY/Hnod9aV2chld+wYjP4EnoEvUCH0T u8UnukgbN+DTVwGvn/uCIIikiCcnBsjNTUFNO0kJYvOFB2BIayaly9E9qHHvExyYtaqg V4Gw== 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=D6d3eZ4SaNGZ8EqSZZS2FpywOTm+uXZ9+EJVPB6nVps=; b=u6cWpYiDZtV/vM37WgS1kRHhlH261S/Ed5WXbnp9pWs1s+GhFxJE86Jxqq5DwivI8h gBP5rBB85t2sUVsOlfvC5UfoPHKCjtHXDx0dRudewbD1d1J5UYP8Hm38JcnT0wwA0WJ+ KVZF59mBFvfVHUFKjYc85JdFfv05dn8r3/ffUukAire+VXqpO3ph7zFJG5/AOpRn5juH fETnbjZBL53C6izgi2rEkDw1dTer4/YJlpc+vVg6ZKz3Rc23pTy/a74kJzP9HhdmhjPw VO7OO3Xstz8LaygfWLHGFwrqBSN+VQMCrjGr5Dmf4us52v0ywIafuCGUg4tpLfGSjAXJ g9xw== 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 i10-20020aa7c9ca000000b00410820eff01si11289442edt.339.2022.03.15.02.06.58; Tue, 15 Mar 2022 02:06:59 -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 5578868B09B; Tue, 15 Mar 2022 11:06:01 +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 2B07A68B1CA for ; Tue, 15 Mar 2022 11:05:53 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D3A7024050B for ; Tue, 15 Mar 2022 10:05:51 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ddAfpMSMxc3I for ; Tue, 15 Mar 2022 10:05:49 +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 686C824017C for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 15E943A06CD; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:26 +0100 Message-Id: <20220315090532.27295-4-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 04/10] fftools/cmdutils: split common option handlers into their own file 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: bNrnT2C4YlCN --- fftools/Makefile | 2 +- fftools/cmdutils.c | 1399 +-------------- fftools/cmdutils.h | 202 --- fftools/ffmpeg_opt.c | 1 + fftools/ffplay.c | 1 + fftools/ffprobe.c | 1 + fftools/{cmdutils.c => opt_common.c} | 2450 ++++++++------------------ fftools/opt_common.h | 231 +++ 8 files changed, 985 insertions(+), 3302 deletions(-) copy fftools/{cmdutils.c => opt_common.c} (60%) create mode 100644 fftools/opt_common.h diff --git a/fftools/Makefile b/fftools/Makefile index da420786eb..5ebf50d42e 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -12,7 +12,7 @@ ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) OBJS-ffmpeg += fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o define DOFFTOOL -OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes) +OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes) $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1)) $$(OBJS-$(1)): | fftools $$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1)) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 0ac98852fe..12ef07b62f 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -32,30 +32,21 @@ #include "config.h" #include "compat/va_copy.h" #include "libavformat/avformat.h" -#include "libavfilter/avfilter.h" -#include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libswresample/swresample.h" -#include "libpostproc/postprocess.h" -#include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" -#include "libavutil/bprint.h" #include "libavutil/channel_layout.h" #include "libavutil/display.h" #include "libavutil/mathematics.h" #include "libavutil/imgutils.h" #include "libavutil/libm.h" #include "libavutil/parseutils.h" -#include "libavutil/pixdesc.h" #include "libavutil/eval.h" #include "libavutil/dict.h" #include "libavutil/opt.h" -#include "libavutil/cpu.h" -#include "libavutil/ffversion.h" -#include "libavutil/version.h" -#include "libavcodec/bsf.h" #include "cmdutils.h" +#include "opt_common.h" #if HAVE_SYS_RESOURCE_H #include #include @@ -64,22 +55,12 @@ #include #endif -static int init_report(const char *env); - AVDictionary *sws_dict; AVDictionary *swr_opts; AVDictionary *format_opts, *codec_opts; -static FILE *report_file; -static int report_file_level = AV_LOG_DEBUG; int hide_banner = 0; -enum show_muxdemuxers { - SHOW_DEFAULT, - SHOW_DEMUXERS, - SHOW_MUXERS, -}; - void uninit_opts(void) { av_dict_free(&swr_opts); @@ -93,22 +74,6 @@ void log_callback_help(void *ptr, int level, const char *fmt, va_list vl) vfprintf(stdout, fmt, vl); } -static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl) -{ - va_list vl2; - char line[1024]; - static int print_prefix = 1; - - va_copy(vl2, vl); - av_log_default_callback(ptr, level, fmt, vl); - av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix); - va_end(vl2); - if (report_file_level >= level) { - fputs(line, report_file); - fflush(report_file); - } -} - void init_dynload(void) { #if HAVE_SETDLLDIRECTORY && defined(_WIN32) @@ -461,7 +426,7 @@ int locate_option(int argc, char **argv, const OptionDef *options, return 0; } -static void dump_argument(const char *a) +static void dump_argument(FILE *report_file, const char *a) { const unsigned char *p; @@ -507,12 +472,13 @@ void parse_loglevel(int argc, char **argv, const OptionDef *options) opt_loglevel(NULL, "loglevel", argv[idx + 1]); idx = locate_option(argc, argv, options, "report"); if ((env = getenv("FFREPORT")) || idx) { - init_report(env); + FILE *report_file = NULL; + init_report(env, &report_file); if (report_file) { int i; fprintf(report_file, "Command line:\n"); for (i = 0; i < argc; i++) { - dump_argument(argv[i]); + dump_argument(report_file, argv[i]); fputc(i < argc - 1 ? ' ' : '\n', report_file); } fflush(report_file); @@ -831,246 +797,6 @@ do { \ return 0; } -int opt_cpuflags(void *optctx, const char *opt, const char *arg) -{ - int ret; - unsigned flags = av_get_cpu_flags(); - - if ((ret = av_parse_cpu_caps(&flags, arg)) < 0) - return ret; - - av_force_cpu_flags(flags); - return 0; -} - -int opt_cpucount(void *optctx, const char *opt, const char *arg) -{ - int ret; - int count; - - static const AVOption opts[] = { - {"count", NULL, 0, AV_OPT_TYPE_INT, { .i64 = -1}, -1, INT_MAX}, - {NULL}, - }; - static const AVClass class = { - .class_name = "cpucount", - .item_name = av_default_item_name, - .option = opts, - .version = LIBAVUTIL_VERSION_INT, - }; - const AVClass *pclass = &class; - - ret = av_opt_eval_int(&pclass, opts, arg, &count); - - if (!ret) { - av_cpu_force_count(count); - } - - return ret; -} - -int opt_loglevel(void *optctx, const char *opt, const char *arg) -{ - const struct { const char *name; int level; } log_levels[] = { - { "quiet" , AV_LOG_QUIET }, - { "panic" , AV_LOG_PANIC }, - { "fatal" , AV_LOG_FATAL }, - { "error" , AV_LOG_ERROR }, - { "warning", AV_LOG_WARNING }, - { "info" , AV_LOG_INFO }, - { "verbose", AV_LOG_VERBOSE }, - { "debug" , AV_LOG_DEBUG }, - { "trace" , AV_LOG_TRACE }, - }; - const char *token; - char *tail; - int flags = av_log_get_flags(); - int level = av_log_get_level(); - int cmd, i = 0; - - av_assert0(arg); - while (*arg) { - token = arg; - if (*token == '+' || *token == '-') { - cmd = *token++; - } else { - cmd = 0; - } - if (!i && !cmd) { - flags = 0; /* missing relative prefix, build absolute value */ - } - if (av_strstart(token, "repeat", &arg)) { - if (cmd == '-') { - flags |= AV_LOG_SKIP_REPEATED; - } else { - flags &= ~AV_LOG_SKIP_REPEATED; - } - } else if (av_strstart(token, "level", &arg)) { - if (cmd == '-') { - flags &= ~AV_LOG_PRINT_LEVEL; - } else { - flags |= AV_LOG_PRINT_LEVEL; - } - } else { - break; - } - i++; - } - if (!*arg) { - goto end; - } else if (*arg == '+') { - arg++; - } else if (!i) { - flags = av_log_get_flags(); /* level value without prefix, reset flags */ - } - - for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { - if (!strcmp(log_levels[i].name, arg)) { - level = log_levels[i].level; - goto end; - } - } - - level = strtol(arg, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". " - "Possible levels are numbers or:\n", arg); - for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) - av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name); - exit_program(1); - } - -end: - av_log_set_flags(flags); - av_log_set_level(level); - return 0; -} - -static void expand_filename_template(AVBPrint *bp, const char *template, - struct tm *tm) -{ - int c; - - while ((c = *(template++))) { - if (c == '%') { - if (!(c = *(template++))) - break; - switch (c) { - case 'p': - av_bprintf(bp, "%s", program_name); - break; - case 't': - av_bprintf(bp, "%04d%02d%02d-%02d%02d%02d", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); - break; - case '%': - av_bprint_chars(bp, c, 1); - break; - } - } else { - av_bprint_chars(bp, c, 1); - } - } -} - -static int init_report(const char *env) -{ - char *filename_template = NULL; - char *key, *val; - int ret, count = 0; - int prog_loglevel, envlevel = 0; - time_t now; - struct tm *tm; - AVBPrint filename; - - if (report_file) /* already opened */ - return 0; - time(&now); - tm = localtime(&now); - - while (env && *env) { - if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) { - if (count) - av_log(NULL, AV_LOG_ERROR, - "Failed to parse FFREPORT environment variable: %s\n", - av_err2str(ret)); - break; - } - if (*env) - env++; - count++; - if (!strcmp(key, "file")) { - av_free(filename_template); - filename_template = val; - val = NULL; - } else if (!strcmp(key, "level")) { - char *tail; - report_file_level = strtol(val, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n"); - exit_program(1); - } - envlevel = 1; - } else { - av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key); - } - av_free(val); - av_free(key); - } - - av_bprint_init(&filename, 0, AV_BPRINT_SIZE_AUTOMATIC); - expand_filename_template(&filename, - av_x_if_null(filename_template, "%p-%t.log"), tm); - av_free(filename_template); - if (!av_bprint_is_complete(&filename)) { - av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n"); - return AVERROR(ENOMEM); - } - - prog_loglevel = av_log_get_level(); - if (!envlevel) - report_file_level = FFMAX(report_file_level, prog_loglevel); - - report_file = fopen(filename.str, "w"); - if (!report_file) { - int ret = AVERROR(errno); - av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n", - filename.str, strerror(errno)); - return ret; - } - av_log_set_callback(log_callback_report); - av_log(NULL, AV_LOG_INFO, - "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n" - "Report written to \"%s\"\n" - "Log level: %d\n", - program_name, - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, - filename.str, report_file_level); - av_bprint_finalize(&filename, NULL); - return 0; -} - -int opt_report(void *optctx, const char *opt, const char *arg) -{ - return init_report(NULL); -} - -int opt_max_alloc(void *optctx, const char *opt, const char *arg) -{ - char *tail; - size_t max; - - max = strtol(arg, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg); - exit_program(1); - } - av_max_alloc(max); - return 0; -} - int opt_timelimit(void *optctx, const char *opt, const char *arg) { #if HAVE_SETRLIMIT @@ -1094,960 +820,6 @@ void print_error(const char *filename, int err) av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr); } -static int warned_cfg = 0; - -#define INDENT 1 -#define SHOW_VERSION 2 -#define SHOW_CONFIG 4 -#define SHOW_COPYRIGHT 8 - -#define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ - if (CONFIG_##LIBNAME) { \ - const char *indent = flags & INDENT? " " : ""; \ - if (flags & SHOW_VERSION) { \ - unsigned int version = libname##_version(); \ - av_log(NULL, level, \ - "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \ - indent, #libname, \ - LIB##LIBNAME##_VERSION_MAJOR, \ - LIB##LIBNAME##_VERSION_MINOR, \ - LIB##LIBNAME##_VERSION_MICRO, \ - AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\ - AV_VERSION_MICRO(version)); \ - } \ - if (flags & SHOW_CONFIG) { \ - const char *cfg = libname##_configuration(); \ - if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \ - if (!warned_cfg) { \ - av_log(NULL, level, \ - "%sWARNING: library configuration mismatch\n", \ - indent); \ - warned_cfg = 1; \ - } \ - av_log(NULL, level, "%s%-11s configuration: %s\n", \ - indent, #libname, cfg); \ - } \ - } \ - } \ - -static void print_all_libs_info(int flags, int level) -{ - PRINT_LIB_INFO(avutil, AVUTIL, flags, level); - PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); - PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); - PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); - PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); - PRINT_LIB_INFO(swscale, SWSCALE, flags, level); - PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level); - PRINT_LIB_INFO(postproc, POSTPROC, flags, level); -} - -static void print_program_info(int flags, int level) -{ - const char *indent = flags & INDENT? " " : ""; - - av_log(NULL, level, "%s version " FFMPEG_VERSION, program_name); - if (flags & SHOW_COPYRIGHT) - av_log(NULL, level, " Copyright (c) %d-%d the FFmpeg developers", - program_birth_year, CONFIG_THIS_YEAR); - av_log(NULL, level, "\n"); - av_log(NULL, level, "%sbuilt with %s\n", indent, CC_IDENT); - - av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent); -} - -static void print_buildconf(int flags, int level) -{ - const char *indent = flags & INDENT ? " " : ""; - char str[] = { FFMPEG_CONFIGURATION }; - char *conflist, *remove_tilde, *splitconf; - - // Change all the ' --' strings to '~--' so that - // they can be identified as tokens. - while ((conflist = strstr(str, " --")) != NULL) { - conflist[0] = '~'; - } - - // Compensate for the weirdness this would cause - // when passing 'pkg-config --static'. - while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) { - remove_tilde[sizeof("pkg-config~") - 2] = ' '; - } - - splitconf = strtok(str, "~"); - av_log(NULL, level, "\n%sconfiguration:\n", indent); - while (splitconf != NULL) { - av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf); - splitconf = strtok(NULL, "~"); - } -} - -void show_banner(int argc, char **argv, const OptionDef *options) -{ - int idx = locate_option(argc, argv, options, "version"); - if (hide_banner || idx) - return; - - print_program_info (INDENT|SHOW_COPYRIGHT, AV_LOG_INFO); - print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_INFO); - print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_INFO); -} - -int show_version(void *optctx, const char *opt, const char *arg) -{ - av_log_set_callback(log_callback_help); - print_program_info (SHOW_COPYRIGHT, AV_LOG_INFO); - print_all_libs_info(SHOW_VERSION, AV_LOG_INFO); - - return 0; -} - -int show_buildconf(void *optctx, const char *opt, const char *arg) -{ - av_log_set_callback(log_callback_help); - print_buildconf (INDENT|0, AV_LOG_INFO); - - return 0; -} - -int show_license(void *optctx, const char *opt, const char *arg) -{ -#if CONFIG_NONFREE - printf( - "This version of %s has nonfree parts compiled in.\n" - "Therefore it is not legally redistributable.\n", - program_name ); -#elif CONFIG_GPLV3 - printf( - "%s is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 3 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "%s is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with %s. If not, see .\n", - program_name, program_name, program_name ); -#elif CONFIG_GPL - printf( - "%s is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "%s is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with %s; if not, write to the Free Software\n" - "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n", - program_name, program_name, program_name ); -#elif CONFIG_LGPLV3 - printf( - "%s is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU Lesser General Public License as published by\n" - "the Free Software Foundation; either version 3 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "%s is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU Lesser General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU Lesser General Public License\n" - "along with %s. If not, see .\n", - program_name, program_name, program_name ); -#else - printf( - "%s is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU Lesser General Public\n" - "License as published by the Free Software Foundation; either\n" - "version 2.1 of the License, or (at your option) any later version.\n" - "\n" - "%s is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - "Lesser General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU Lesser General Public\n" - "License along with %s; if not, write to the Free Software\n" - "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n", - program_name, program_name, program_name ); -#endif - - return 0; -} - -static int is_device(const AVClass *avclass) -{ - if (!avclass) - return 0; - return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category); -} - -static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers) -{ - void *ifmt_opaque = NULL; - const AVInputFormat *ifmt = NULL; - void *ofmt_opaque = NULL; - const AVOutputFormat *ofmt = NULL; - const char *last_name; - int is_dev; - - printf("%s\n" - " D. = Demuxing supported\n" - " .E = Muxing supported\n" - " --\n", device_only ? "Devices:" : "File formats:"); - last_name = "000"; - for (;;) { - int decode = 0; - int encode = 0; - const char *name = NULL; - const char *long_name = NULL; - - if (muxdemuxers !=SHOW_DEMUXERS) { - ofmt_opaque = NULL; - while ((ofmt = av_muxer_iterate(&ofmt_opaque))) { - is_dev = is_device(ofmt->priv_class); - if (!is_dev && device_only) - continue; - if ((!name || strcmp(ofmt->name, name) < 0) && - strcmp(ofmt->name, last_name) > 0) { - name = ofmt->name; - long_name = ofmt->long_name; - encode = 1; - } - } - } - if (muxdemuxers != SHOW_MUXERS) { - ifmt_opaque = NULL; - while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) { - is_dev = is_device(ifmt->priv_class); - if (!is_dev && device_only) - continue; - if ((!name || strcmp(ifmt->name, name) < 0) && - strcmp(ifmt->name, last_name) > 0) { - name = ifmt->name; - long_name = ifmt->long_name; - encode = 0; - } - if (name && strcmp(ifmt->name, name) == 0) - decode = 1; - } - } - if (!name) - break; - last_name = name; - - printf(" %c%c %-15s %s\n", - decode ? 'D' : ' ', - encode ? 'E' : ' ', - name, - long_name ? long_name:" "); - } - return 0; -} - -int show_formats(void *optctx, const char *opt, const char *arg) -{ - return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT); -} - -int show_muxers(void *optctx, const char *opt, const char *arg) -{ - return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS); -} - -int show_demuxers(void *optctx, const char *opt, const char *arg) -{ - return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS); -} - -int show_devices(void *optctx, const char *opt, const char *arg) -{ - return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT); -} - -#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ - if (codec->field) { \ - const type *p = codec->field; \ - \ - printf(" Supported " list_name ":"); \ - while (*p != term) { \ - get_name(*p); \ - printf(" %s", name); \ - p++; \ - } \ - printf("\n"); \ - } \ - -static void print_codec(const AVCodec *c) -{ - int encoder = av_codec_is_encoder(c); - - printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name, - c->long_name ? c->long_name : ""); - - printf(" General capabilities: "); - if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND) - printf("horizband "); - if (c->capabilities & AV_CODEC_CAP_DR1) - printf("dr1 "); - if (c->capabilities & AV_CODEC_CAP_DELAY) - printf("delay "); - if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) - printf("small "); - if (c->capabilities & AV_CODEC_CAP_SUBFRAMES) - printf("subframes "); - if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL) - printf("exp "); - if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF) - printf("chconf "); - if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE) - printf("paramchange "); - if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) - printf("variable "); - if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | - AV_CODEC_CAP_SLICE_THREADS | - AV_CODEC_CAP_OTHER_THREADS)) - printf("threads "); - if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING) - printf("avoidprobe "); - if (c->capabilities & AV_CODEC_CAP_HARDWARE) - printf("hardware "); - if (c->capabilities & AV_CODEC_CAP_HYBRID) - printf("hybrid "); - if (!c->capabilities) - printf("none"); - printf("\n"); - - if (c->type == AVMEDIA_TYPE_VIDEO || - c->type == AVMEDIA_TYPE_AUDIO) { - printf(" Threading capabilities: "); - switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | - AV_CODEC_CAP_SLICE_THREADS | - AV_CODEC_CAP_OTHER_THREADS)) { - case AV_CODEC_CAP_FRAME_THREADS | - AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break; - case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break; - case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break; - case AV_CODEC_CAP_OTHER_THREADS: printf("other"); break; - default: printf("none"); break; - } - printf("\n"); - } - - if (avcodec_get_hw_config(c, 0)) { - printf(" Supported hardware devices: "); - for (int i = 0;; i++) { - const AVCodecHWConfig *config = avcodec_get_hw_config(c, i); - if (!config) - break; - printf("%s ", av_hwdevice_get_type_name(config->device_type)); - } - printf("\n"); - } - - if (c->supported_framerates) { - const AVRational *fps = c->supported_framerates; - - printf(" Supported framerates:"); - while (fps->num) { - printf(" %d/%d", fps->num, fps->den); - fps++; - } - printf("\n"); - } - PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats", - AV_PIX_FMT_NONE, GET_PIX_FMT_NAME); - PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0, - GET_SAMPLE_RATE_NAME); - PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats", - AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME); - PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts", - 0, GET_CH_LAYOUT_DESC); - - if (c->priv_class) { - show_help_children(c->priv_class, - AV_OPT_FLAG_ENCODING_PARAM | - AV_OPT_FLAG_DECODING_PARAM); - } -} - -static char get_media_type_char(enum AVMediaType type) -{ - switch (type) { - case AVMEDIA_TYPE_VIDEO: return 'V'; - case AVMEDIA_TYPE_AUDIO: return 'A'; - case AVMEDIA_TYPE_DATA: return 'D'; - case AVMEDIA_TYPE_SUBTITLE: return 'S'; - case AVMEDIA_TYPE_ATTACHMENT:return 'T'; - default: return '?'; - } -} - -static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter, - int encoder) -{ - const AVCodec *c; - while ((c = av_codec_iterate(iter))) { - if (c->id == id && - (encoder ? av_codec_is_encoder(c) : av_codec_is_decoder(c))) - return c; - } - return NULL; -} - -static int compare_codec_desc(const void *a, const void *b) -{ - const AVCodecDescriptor * const *da = a; - const AVCodecDescriptor * const *db = b; - - return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) : - strcmp((*da)->name, (*db)->name); -} - -static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) -{ - const AVCodecDescriptor *desc = NULL; - const AVCodecDescriptor **codecs; - unsigned nb_codecs = 0, i = 0; - - while ((desc = avcodec_descriptor_next(desc))) - nb_codecs++; - if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs)))) { - av_log(NULL, AV_LOG_ERROR, "Out of memory\n"); - exit_program(1); - } - desc = NULL; - while ((desc = avcodec_descriptor_next(desc))) - codecs[i++] = desc; - av_assert0(i == nb_codecs); - qsort(codecs, nb_codecs, sizeof(*codecs), compare_codec_desc); - *rcodecs = codecs; - return nb_codecs; -} - -static void print_codecs_for_id(enum AVCodecID id, int encoder) -{ - void *iter = NULL; - const AVCodec *codec; - - printf(" (%s: ", encoder ? "encoders" : "decoders"); - - while ((codec = next_codec_for_id(id, &iter, encoder))) - printf("%s ", codec->name); - - printf(")"); -} - -int show_codecs(void *optctx, const char *opt, const char *arg) -{ - const AVCodecDescriptor **codecs; - unsigned i, nb_codecs = get_codecs_sorted(&codecs); - - printf("Codecs:\n" - " D..... = Decoding supported\n" - " .E.... = Encoding supported\n" - " ..V... = Video codec\n" - " ..A... = Audio codec\n" - " ..S... = Subtitle codec\n" - " ...I.. = Intra frame-only codec\n" - " ....L. = Lossy compression\n" - " .....S = Lossless compression\n" - " -------\n"); - for (i = 0; i < nb_codecs; i++) { - const AVCodecDescriptor *desc = codecs[i]; - const AVCodec *codec; - void *iter = NULL; - - if (strstr(desc->name, "_deprecated")) - continue; - - printf(" "); - printf(avcodec_find_decoder(desc->id) ? "D" : "."); - printf(avcodec_find_encoder(desc->id) ? "E" : "."); - - printf("%c", get_media_type_char(desc->type)); - printf((desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : "."); - printf((desc->props & AV_CODEC_PROP_LOSSY) ? "L" : "."); - printf((desc->props & AV_CODEC_PROP_LOSSLESS) ? "S" : "."); - - printf(" %-20s %s", desc->name, desc->long_name ? desc->long_name : ""); - - /* print decoders/encoders when there's more than one or their - * names are different from codec name */ - while ((codec = next_codec_for_id(desc->id, &iter, 0))) { - if (strcmp(codec->name, desc->name)) { - print_codecs_for_id(desc->id, 0); - break; - } - } - iter = NULL; - while ((codec = next_codec_for_id(desc->id, &iter, 1))) { - if (strcmp(codec->name, desc->name)) { - print_codecs_for_id(desc->id, 1); - break; - } - } - - printf("\n"); - } - av_free(codecs); - return 0; -} - -static void print_codecs(int encoder) -{ - const AVCodecDescriptor **codecs; - unsigned i, nb_codecs = get_codecs_sorted(&codecs); - - printf("%s:\n" - " V..... = Video\n" - " A..... = Audio\n" - " S..... = Subtitle\n" - " .F.... = Frame-level multithreading\n" - " ..S... = Slice-level multithreading\n" - " ...X.. = Codec is experimental\n" - " ....B. = Supports draw_horiz_band\n" - " .....D = Supports direct rendering method 1\n" - " ------\n", - encoder ? "Encoders" : "Decoders"); - for (i = 0; i < nb_codecs; i++) { - const AVCodecDescriptor *desc = codecs[i]; - const AVCodec *codec; - void *iter = NULL; - - while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { - printf(" %c", get_media_type_char(desc->type)); - printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : "."); - printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : "."); - printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : "."); - printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : "."); - printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : "."); - - printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : ""); - if (strcmp(codec->name, desc->name)) - printf(" (codec %s)", desc->name); - - printf("\n"); - } - } - av_free(codecs); -} - -int show_decoders(void *optctx, const char *opt, const char *arg) -{ - print_codecs(0); - return 0; -} - -int show_encoders(void *optctx, const char *opt, const char *arg) -{ - print_codecs(1); - return 0; -} - -int show_bsfs(void *optctx, const char *opt, const char *arg) -{ - const AVBitStreamFilter *bsf = NULL; - void *opaque = NULL; - - printf("Bitstream filters:\n"); - while ((bsf = av_bsf_iterate(&opaque))) - printf("%s\n", bsf->name); - printf("\n"); - return 0; -} - -int show_protocols(void *optctx, const char *opt, const char *arg) -{ - void *opaque = NULL; - const char *name; - - printf("Supported file protocols:\n" - "Input:\n"); - while ((name = avio_enum_protocols(&opaque, 0))) - printf(" %s\n", name); - printf("Output:\n"); - while ((name = avio_enum_protocols(&opaque, 1))) - printf(" %s\n", name); - return 0; -} - -int show_filters(void *optctx, const char *opt, const char *arg) -{ -#if CONFIG_AVFILTER - const AVFilter *filter = NULL; - char descr[64], *descr_cur; - void *opaque = NULL; - int i, j; - const AVFilterPad *pad; - - printf("Filters:\n" - " T.. = Timeline support\n" - " .S. = Slice threading\n" - " ..C = Command support\n" - " A = Audio input/output\n" - " V = Video input/output\n" - " N = Dynamic number and/or type of input/output\n" - " | = Source or sink filter\n"); - while ((filter = av_filter_iterate(&opaque))) { - descr_cur = descr; - for (i = 0; i < 2; i++) { - unsigned nb_pads; - if (i) { - *(descr_cur++) = '-'; - *(descr_cur++) = '>'; - } - pad = i ? filter->outputs : filter->inputs; - nb_pads = avfilter_filter_pad_count(filter, i); - for (j = 0; j < nb_pads; j++) { - if (descr_cur >= descr + sizeof(descr) - 4) - break; - *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j)); - } - if (!j) - *(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) || - ( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|'; - } - *descr_cur = 0; - printf(" %c%c%c %-17s %-10s %s\n", - filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.', - filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.', - filter->process_command ? 'C' : '.', - filter->name, descr, filter->description); - } -#else - printf("No filters available: libavfilter disabled\n"); -#endif - return 0; -} - -int show_colors(void *optctx, const char *opt, const char *arg) -{ - const char *name; - const uint8_t *rgb; - int i; - - printf("%-32s #RRGGBB\n", "name"); - - for (i = 0; name = av_get_known_color_name(i, &rgb); i++) - printf("%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]); - - return 0; -} - -int show_pix_fmts(void *optctx, const char *opt, const char *arg) -{ - const AVPixFmtDescriptor *pix_desc = NULL; - - printf("Pixel formats:\n" - "I.... = Supported Input format for conversion\n" - ".O... = Supported Output format for conversion\n" - "..H.. = Hardware accelerated format\n" - "...P. = Paletted format\n" - "....B = Bitstream format\n" - "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL BIT_DEPTHS\n" - "-----\n"); - -#if !CONFIG_SWSCALE -# define sws_isSupportedInput(x) 0 -# define sws_isSupportedOutput(x) 0 -#endif - - while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) { - enum AVPixelFormat av_unused pix_fmt = av_pix_fmt_desc_get_id(pix_desc); - printf("%c%c%c%c%c %-16s %d %3d %d", - sws_isSupportedInput (pix_fmt) ? 'I' : '.', - sws_isSupportedOutput(pix_fmt) ? 'O' : '.', - pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL ? 'H' : '.', - pix_desc->flags & AV_PIX_FMT_FLAG_PAL ? 'P' : '.', - pix_desc->flags & AV_PIX_FMT_FLAG_BITSTREAM ? 'B' : '.', - pix_desc->name, - pix_desc->nb_components, - av_get_bits_per_pixel(pix_desc), - pix_desc->comp[0].depth); - - for (unsigned i = 1; i < pix_desc->nb_components; i++) - printf("-%d", pix_desc->comp[i].depth); - printf("\n"); - } - return 0; -} - -int show_layouts(void *optctx, const char *opt, const char *arg) -{ - int i = 0; - uint64_t layout, j; - const char *name, *descr; - - printf("Individual channels:\n" - "NAME DESCRIPTION\n"); - for (i = 0; i < 63; i++) { - name = av_get_channel_name((uint64_t)1 << i); - if (!name) - continue; - descr = av_get_channel_description((uint64_t)1 << i); - printf("%-14s %s\n", name, descr); - } - printf("\nStandard channel layouts:\n" - "NAME DECOMPOSITION\n"); - for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) { - if (name) { - printf("%-14s ", name); - for (j = 1; j; j <<= 1) - if ((layout & j)) - printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j)); - printf("\n"); - } - } - return 0; -} - -int show_sample_fmts(void *optctx, const char *opt, const char *arg) -{ - int i; - char fmt_str[128]; - for (i = -1; i < AV_SAMPLE_FMT_NB; i++) - printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i)); - return 0; -} - -int show_dispositions(void *optctx, const char *opt, const char *arg) -{ - for (int i = 0; i < 32; i++) { - const char *str = av_disposition_to_string(1U << i); - if (str) - printf("%s\n", str); - } - return 0; -} - -static void show_help_codec(const char *name, int encoder) -{ - const AVCodecDescriptor *desc; - const AVCodec *codec; - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n"); - return; - } - - codec = encoder ? avcodec_find_encoder_by_name(name) : - avcodec_find_decoder_by_name(name); - - if (codec) - print_codec(codec); - else if ((desc = avcodec_descriptor_get_by_name(name))) { - void *iter = NULL; - int printed = 0; - - while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { - printed = 1; - print_codec(codec); - } - - if (!printed) { - av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, " - "but no %s for it are available. FFmpeg might need to be " - "recompiled with additional external libraries.\n", - name, encoder ? "encoders" : "decoders"); - } - } else { - av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n", - name); - } -} - -static void show_help_demuxer(const char *name) -{ - const AVInputFormat *fmt = av_find_input_format(name); - - if (!fmt) { - av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); - return; - } - - printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name); - - if (fmt->extensions) - printf(" Common extensions: %s.\n", fmt->extensions); - - if (fmt->priv_class) - show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM); -} - -static void show_help_protocol(const char *name) -{ - const AVClass *proto_class; - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No protocol name specified.\n"); - return; - } - - proto_class = avio_protocol_get_class(name); - if (!proto_class) { - av_log(NULL, AV_LOG_ERROR, "Unknown protocol '%s'.\n", name); - return; - } - - show_help_children(proto_class, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM); -} - -static void show_help_muxer(const char *name) -{ - const AVCodecDescriptor *desc; - const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL); - - if (!fmt) { - av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); - return; - } - - printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name); - - if (fmt->extensions) - printf(" Common extensions: %s.\n", fmt->extensions); - if (fmt->mime_type) - printf(" Mime type: %s.\n", fmt->mime_type); - if (fmt->video_codec != AV_CODEC_ID_NONE && - (desc = avcodec_descriptor_get(fmt->video_codec))) { - printf(" Default video codec: %s.\n", desc->name); - } - if (fmt->audio_codec != AV_CODEC_ID_NONE && - (desc = avcodec_descriptor_get(fmt->audio_codec))) { - printf(" Default audio codec: %s.\n", desc->name); - } - if (fmt->subtitle_codec != AV_CODEC_ID_NONE && - (desc = avcodec_descriptor_get(fmt->subtitle_codec))) { - printf(" Default subtitle codec: %s.\n", desc->name); - } - - if (fmt->priv_class) - show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM); -} - -#if CONFIG_AVFILTER -static void show_help_filter(const char *name) -{ -#if CONFIG_AVFILTER - const AVFilter *f = avfilter_get_by_name(name); - int i, count; - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n"); - return; - } else if (!f) { - av_log(NULL, AV_LOG_ERROR, "Unknown filter '%s'.\n", name); - return; - } - - printf("Filter %s\n", f->name); - if (f->description) - printf(" %s\n", f->description); - - if (f->flags & AVFILTER_FLAG_SLICE_THREADS) - printf(" slice threading supported\n"); - - printf(" Inputs:\n"); - count = avfilter_filter_pad_count(f, 0); - for (i = 0; i < count; i++) { - printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), - av_get_media_type_string(avfilter_pad_get_type(f->inputs, i))); - } - if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS) - printf(" dynamic (depending on the options)\n"); - else if (!count) - printf(" none (source filter)\n"); - - printf(" Outputs:\n"); - count = avfilter_filter_pad_count(f, 1); - for (i = 0; i < count; i++) { - printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), - av_get_media_type_string(avfilter_pad_get_type(f->outputs, i))); - } - if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS) - printf(" dynamic (depending on the options)\n"); - else if (!count) - printf(" none (sink filter)\n"); - - if (f->priv_class) - show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | - AV_OPT_FLAG_AUDIO_PARAM); - if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) - printf("This filter has support for timeline through the 'enable' option.\n"); -#else - av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; " - "can not to satisfy request\n"); -#endif -} -#endif - -static void show_help_bsf(const char *name) -{ - const AVBitStreamFilter *bsf = av_bsf_get_by_name(name); - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No bitstream filter name specified.\n"); - return; - } else if (!bsf) { - av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name); - return; - } - - printf("Bit stream filter %s\n", bsf->name); - PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs", - AV_CODEC_ID_NONE, GET_CODEC_NAME); - if (bsf->priv_class) - show_help_children(bsf->priv_class, AV_OPT_FLAG_BSF_PARAM); -} - -int show_help(void *optctx, const char *opt, const char *arg) -{ - char *topic, *par; - av_log_set_callback(log_callback_help); - - topic = av_strdup(arg ? arg : ""); - if (!topic) - return AVERROR(ENOMEM); - par = strchr(topic, '='); - if (par) - *par++ = 0; - - if (!*topic) { - show_help_default(topic, par); - } else if (!strcmp(topic, "decoder")) { - show_help_codec(par, 0); - } else if (!strcmp(topic, "encoder")) { - show_help_codec(par, 1); - } else if (!strcmp(topic, "demuxer")) { - show_help_demuxer(par); - } else if (!strcmp(topic, "muxer")) { - show_help_muxer(par); - } else if (!strcmp(topic, "protocol")) { - show_help_protocol(par); -#if CONFIG_AVFILTER - } else if (!strcmp(topic, "filter")) { - show_help_filter(par); -#endif - } else if (!strcmp(topic, "bsf")) { - show_help_bsf(par); - } else { - show_help_default(topic, par); - } - - av_freep(&topic); - return 0; -} - int read_yesno(void) { int c = getchar(); @@ -2242,164 +1014,3 @@ double get_rotation(int32_t *displaymatrix) return theta; } - -#if CONFIG_AVDEVICE -static void print_device_list(const AVDeviceInfoList *device_list) -{ - // print devices - for (int i = 0; i < device_list->nb_devices; i++) { - const AVDeviceInfo *device = device_list->devices[i]; - printf("%c %s [%s] (", device_list->default_device == i ? '*' : ' ', - device->device_name, device->device_description); - if (device->nb_media_types > 0) { - for (int j = 0; j < device->nb_media_types; ++j) { - const char* media_type = av_get_media_type_string(device->media_types[j]); - if (j > 0) - printf(", "); - printf("%s", media_type ? media_type : "unknown"); - } - } else { - printf("none"); - } - printf(")\n"); - } -} -static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts) -{ - int ret; - AVDeviceInfoList *device_list = NULL; - - if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) - return AVERROR(EINVAL); - - printf("Auto-detected sources for %s:\n", fmt->name); - if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) { - printf("Cannot list sources: %s\n", av_err2str(ret)); - goto fail; - } - - print_device_list(device_list); - - fail: - avdevice_free_list_devices(&device_list); - return ret; -} - -static int print_device_sinks(const AVOutputFormat *fmt, AVDictionary *opts) -{ - int ret; - AVDeviceInfoList *device_list = NULL; - - if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) - return AVERROR(EINVAL); - - printf("Auto-detected sinks for %s:\n", fmt->name); - if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) { - printf("Cannot list sinks: %s\n", av_err2str(ret)); - goto fail; - } - - print_device_list(device_list); - - fail: - avdevice_free_list_devices(&device_list); - return ret; -} - -static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionary **opts) -{ - int ret; - if (arg) { - char *opts_str = NULL; - av_assert0(dev && opts); - *dev = av_strdup(arg); - if (!*dev) - return AVERROR(ENOMEM); - if ((opts_str = strchr(*dev, ','))) { - *(opts_str++) = '\0'; - if (opts_str[0] && ((ret = av_dict_parse_string(opts, opts_str, "=", ":", 0)) < 0)) { - av_freep(dev); - return ret; - } - } - } else - printf("\nDevice name is not provided.\n" - "You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.\n\n"); - return 0; -} - -int show_sources(void *optctx, const char *opt, const char *arg) -{ - const AVInputFormat *fmt = NULL; - char *dev = NULL; - AVDictionary *opts = NULL; - int ret = 0; - int error_level = av_log_get_level(); - - av_log_set_level(AV_LOG_WARNING); - - if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) - goto fail; - - do { - fmt = av_input_audio_device_next(fmt); - if (fmt) { - if (!strcmp(fmt->name, "lavfi")) - continue; //it's pointless to probe lavfi - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sources(fmt, opts); - } - } while (fmt); - do { - fmt = av_input_video_device_next(fmt); - if (fmt) { - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sources(fmt, opts); - } - } while (fmt); - fail: - av_dict_free(&opts); - av_free(dev); - av_log_set_level(error_level); - return ret; -} - -int show_sinks(void *optctx, const char *opt, const char *arg) -{ - const AVOutputFormat *fmt = NULL; - char *dev = NULL; - AVDictionary *opts = NULL; - int ret = 0; - int error_level = av_log_get_level(); - - av_log_set_level(AV_LOG_WARNING); - - if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) - goto fail; - - do { - fmt = av_output_audio_device_next(fmt); - if (fmt) { - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sinks(fmt, opts); - } - } while (fmt); - do { - fmt = av_output_video_device_next(fmt); - if (fmt) { - if (dev && !av_match_name(dev, fmt->name)) - continue; - print_device_sinks(fmt, opts); - } - } while (fmt); - fail: - av_dict_free(&opts); - av_free(dev); - av_log_set_level(error_level); - return ret; -} - -#endif diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 57db531f5c..5a32461f66 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -76,31 +76,12 @@ void uninit_opts(void); */ void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); -/** - * Override the cpuflags. - */ -int opt_cpuflags(void *optctx, const char *opt, const char *arg); - -/** - * Override the cpucount. - */ -int opt_cpucount(void *optctx, const char *opt, const char *arg); - /** * Fallback for options that are not explicitly handled, these will be * parsed through AVOptions. */ int opt_default(void *optctx, const char *opt, const char *arg); -/** - * Set the libav* libraries log level. - */ -int opt_loglevel(void *optctx, const char *opt, const char *arg); - -int opt_report(void *optctx, const char *opt, const char *arg); - -int opt_max_alloc(void *optctx, const char *opt, const char *arg); - /** * Limit the execution time. */ @@ -197,49 +178,6 @@ typedef struct OptionDef { void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags); -#if CONFIG_AVDEVICE -#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \ - { "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \ - "list sources of the input device", "device" }, \ - { "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \ - "list sinks of the output device", "device" }, \ - -#else -#define CMDUTILS_COMMON_OPTIONS_AVDEVICE -#endif - -#define CMDUTILS_COMMON_OPTIONS \ - { "L", OPT_EXIT, { .func_arg = show_license }, "show license" }, \ - { "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ - { "?", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ - { "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ - { "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ - { "version", OPT_EXIT, { .func_arg = show_version }, "show version" }, \ - { "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" }, \ - { "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" }, \ - { "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \ - { "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \ - { "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \ - { "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \ - { "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" }, \ - { "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" }, \ - { "bsfs", OPT_EXIT, { .func_arg = show_bsfs }, "show available bit stream filters" }, \ - { "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" }, \ - { "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" }, \ - { "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" }, \ - { "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" }, \ - { "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" }, \ - { "dispositions", OPT_EXIT, { .func_arg = show_dispositions}, "show available stream dispositions" }, \ - { "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" }, \ - { "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \ - { "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \ - { "report", 0, { .func_arg = opt_report }, "generate a report" }, \ - { "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" }, \ - { "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, \ - { "cpucount", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpucount }, "force specific cpu count", "count" }, \ - { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, \ - CMDUTILS_COMMON_OPTIONS_AVDEVICE \ - /** * Show help for all options with given flags in class and all its * children. @@ -252,11 +190,6 @@ void show_help_children(const AVClass *class, int flags); */ void show_help_default(const char *opt, const char *arg); -/** - * Generic -h handler common to all fftools. - */ -int show_help(void *optctx, const char *opt, const char *arg); - /** * Parse the command line arguments. * @@ -445,141 +378,6 @@ void print_error(const char *filename, int err); */ void show_banner(int argc, char **argv, const OptionDef *options); -/** - * Print the version of the program to stdout. The version message - * depends on the current versions of the repository and of the libav* - * libraries. - * This option processing function does not utilize the arguments. - */ -int show_version(void *optctx, const char *opt, const char *arg); - -/** - * Print the build configuration of the program to stdout. The contents - * depend on the definition of FFMPEG_CONFIGURATION. - * This option processing function does not utilize the arguments. - */ -int show_buildconf(void *optctx, const char *opt, const char *arg); - -/** - * Print the license of the program to stdout. The license depends on - * the license of the libraries compiled into the program. - * This option processing function does not utilize the arguments. - */ -int show_license(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the formats supported by the - * program (including devices). - * This option processing function does not utilize the arguments. - */ -int show_formats(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the muxers supported by the - * program (including devices). - * This option processing function does not utilize the arguments. - */ -int show_muxers(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the demuxer supported by the - * program (including devices). - * This option processing function does not utilize the arguments. - */ -int show_demuxers(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the devices supported by the - * program. - * This option processing function does not utilize the arguments. - */ -int show_devices(void *optctx, const char *opt, const char *arg); - -#if CONFIG_AVDEVICE -/** - * Print a listing containing autodetected sinks of the output device. - * Device name with options may be passed as an argument to limit results. - */ -int show_sinks(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing autodetected sources of the input device. - * Device name with options may be passed as an argument to limit results. - */ -int show_sources(void *optctx, const char *opt, const char *arg); -#endif - -/** - * Print a listing containing all the codecs supported by the - * program. - * This option processing function does not utilize the arguments. - */ -int show_codecs(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the decoders supported by the - * program. - */ -int show_decoders(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the encoders supported by the - * program. - */ -int show_encoders(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the filters supported by the - * program. - * This option processing function does not utilize the arguments. - */ -int show_filters(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the bit stream filters supported by the - * program. - * This option processing function does not utilize the arguments. - */ -int show_bsfs(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the protocols supported by the - * program. - * This option processing function does not utilize the arguments. - */ -int show_protocols(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the pixel formats supported by the - * program. - * This option processing function does not utilize the arguments. - */ -int show_pix_fmts(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the standard channel layouts supported by - * the program. - * This option processing function does not utilize the arguments. - */ -int show_layouts(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the sample formats supported by the - * program. - */ -int show_sample_fmts(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all supported stream dispositions. - */ -int show_dispositions(void *optctx, const char *opt, const char *arg); - -/** - * Print a listing containing all the color names and values recognized - * by the program. - */ -int show_colors(void *optctx, const char *opt, const char *arg); - /** * Return a positive value if a line read from standard input * starts with [yY], otherwise return 0. diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f983c74a66..b2746259d7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -23,6 +23,7 @@ #include "ffmpeg.h" #include "cmdutils.h" +#include "opt_common.h" #include "libavformat/avformat.h" diff --git a/fftools/ffplay.c b/fftools/ffplay.c index ac48d8765d..c929ce32ed 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -59,6 +59,7 @@ #include #include "cmdutils.h" +#include "opt_common.h" const char program_name[] = "ffplay"; const int program_birth_year = 2003; diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 66206b66d9..42032ee9d6 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -55,6 +55,7 @@ #include "libswresample/swresample.h" #include "libpostproc/postprocess.h" #include "cmdutils.h" +#include "opt_common.h" #include "libavutil/thread.h" diff --git a/fftools/cmdutils.c b/fftools/opt_common.c similarity index 60% copy from fftools/cmdutils.c copy to fftools/opt_common.c index 0ac98852fe..38fbee9b6c 100644 --- a/fftools/cmdutils.c +++ b/fftools/opt_common.c @@ -1,6 +1,5 @@ /* - * Various utilities for command line tools - * Copyright (c) 2000-2003 Fabrice Bellard + * Option handlers shared between the tools. * * This file is part of FFmpeg. * @@ -19,1196 +18,56 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include -#include -#include - -/* Include only the enabled headers since some compilers (namely, Sun - Studio) will not omit unused inline functions and create undefined - references to libraries that are not being built. */ - -#include "config.h" -#include "compat/va_copy.h" -#include "libavformat/avformat.h" -#include "libavfilter/avfilter.h" -#include "libavdevice/avdevice.h" -#include "libswscale/swscale.h" -#include "libswresample/swresample.h" -#include "libpostproc/postprocess.h" -#include "libavutil/attributes.h" -#include "libavutil/avassert.h" -#include "libavutil/avstring.h" -#include "libavutil/bprint.h" -#include "libavutil/channel_layout.h" -#include "libavutil/display.h" -#include "libavutil/mathematics.h" -#include "libavutil/imgutils.h" -#include "libavutil/libm.h" -#include "libavutil/parseutils.h" -#include "libavutil/pixdesc.h" -#include "libavutil/eval.h" -#include "libavutil/dict.h" -#include "libavutil/opt.h" -#include "libavutil/cpu.h" -#include "libavutil/ffversion.h" -#include "libavutil/version.h" -#include "libavcodec/bsf.h" -#include "cmdutils.h" -#if HAVE_SYS_RESOURCE_H -#include -#include -#endif -#ifdef _WIN32 -#include -#endif - -static int init_report(const char *env); - -AVDictionary *sws_dict; -AVDictionary *swr_opts; -AVDictionary *format_opts, *codec_opts; - -static FILE *report_file; -static int report_file_level = AV_LOG_DEBUG; -int hide_banner = 0; - -enum show_muxdemuxers { - SHOW_DEFAULT, - SHOW_DEMUXERS, - SHOW_MUXERS, -}; - -void uninit_opts(void) -{ - av_dict_free(&swr_opts); - av_dict_free(&sws_dict); - av_dict_free(&format_opts); - av_dict_free(&codec_opts); -} - -void log_callback_help(void *ptr, int level, const char *fmt, va_list vl) -{ - vfprintf(stdout, fmt, vl); -} - -static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl) -{ - va_list vl2; - char line[1024]; - static int print_prefix = 1; - - va_copy(vl2, vl); - av_log_default_callback(ptr, level, fmt, vl); - av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix); - va_end(vl2); - if (report_file_level >= level) { - fputs(line, report_file); - fflush(report_file); - } -} - -void init_dynload(void) -{ -#if HAVE_SETDLLDIRECTORY && defined(_WIN32) - /* Calling SetDllDirectory with the empty string (but not NULL) removes the - * current working directory from the DLL search path as a security pre-caution. */ - SetDllDirectory(""); -#endif -} - -static void (*program_exit)(int ret); - -void register_exit(void (*cb)(int ret)) -{ - program_exit = cb; -} - -void exit_program(int ret) -{ - if (program_exit) - program_exit(ret); - - exit(ret); -} - -double parse_number_or_die(const char *context, const char *numstr, int type, - double min, double max) -{ - char *tail; - const char *error; - double d = av_strtod(numstr, &tail); - if (*tail) - error = "Expected number for %s but found: %s\n"; - else if (d < min || d > max) - error = "The value for %s was %s which is not within %f - %f\n"; - else if (type == OPT_INT64 && (int64_t)d != d) - error = "Expected int64 for %s but found %s\n"; - else if (type == OPT_INT && (int)d != d) - error = "Expected int for %s but found %s\n"; - else - return d; - av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max); - exit_program(1); - return 0; -} - -int64_t parse_time_or_die(const char *context, const char *timestr, - int is_duration) -{ - int64_t us; - if (av_parse_time(&us, timestr, is_duration) < 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n", - is_duration ? "duration" : "date", context, timestr); - exit_program(1); - } - return us; -} - -void show_help_options(const OptionDef *options, const char *msg, int req_flags, - int rej_flags, int alt_flags) -{ - const OptionDef *po; - int first; - - first = 1; - for (po = options; po->name; po++) { - char buf[128]; - - if (((po->flags & req_flags) != req_flags) || - (alt_flags && !(po->flags & alt_flags)) || - (po->flags & rej_flags)) - continue; - - if (first) { - printf("%s\n", msg); - first = 0; - } - av_strlcpy(buf, po->name, sizeof(buf)); - if (po->argname) { - av_strlcat(buf, " ", sizeof(buf)); - av_strlcat(buf, po->argname, sizeof(buf)); - } - printf("-%-17s %s\n", buf, po->help); - } - printf("\n"); -} - -void show_help_children(const AVClass *class, int flags) -{ - void *iter = NULL; - const AVClass *child; - if (class->option) { - av_opt_show2(&class, NULL, flags, 0); - printf("\n"); - } - - while (child = av_opt_child_class_iterate(class, &iter)) - show_help_children(child, flags); -} - -static const OptionDef *find_option(const OptionDef *po, const char *name) -{ - while (po->name) { - const char *end; - if (av_strstart(name, po->name, &end) && (!*end || *end == ':')) - break; - po++; - } - return po; -} - -/* _WIN32 means using the windows libc - cygwin doesn't define that - * by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while - * it doesn't provide the actual command line via GetCommandLineW(). */ -#if HAVE_COMMANDLINETOARGVW && defined(_WIN32) -#include -/* Will be leaked on exit */ -static char** win32_argv_utf8 = NULL; -static int win32_argc = 0; - -/** - * Prepare command line arguments for executable. - * For Windows - perform wide-char to UTF-8 conversion. - * Input arguments should be main() function arguments. - * @param argc_ptr Arguments number (including executable) - * @param argv_ptr Arguments list. - */ -static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) -{ - char *argstr_flat; - wchar_t **argv_w; - int i, buffsize = 0, offset = 0; - - if (win32_argv_utf8) { - *argc_ptr = win32_argc; - *argv_ptr = win32_argv_utf8; - return; - } - - win32_argc = 0; - argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc); - if (win32_argc <= 0 || !argv_w) - return; - - /* determine the UTF-8 buffer size (including NULL-termination symbols) */ - for (i = 0; i < win32_argc; i++) - buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, - NULL, 0, NULL, NULL); - - win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize); - argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1); - if (!win32_argv_utf8) { - LocalFree(argv_w); - return; - } - - for (i = 0; i < win32_argc; i++) { - win32_argv_utf8[i] = &argstr_flat[offset]; - offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, - &argstr_flat[offset], - buffsize - offset, NULL, NULL); - } - win32_argv_utf8[i] = NULL; - LocalFree(argv_w); - - *argc_ptr = win32_argc; - *argv_ptr = win32_argv_utf8; -} -#else -static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) -{ - /* nothing to do */ -} -#endif /* HAVE_COMMANDLINETOARGVW */ - -static int write_option(void *optctx, const OptionDef *po, const char *opt, - const char *arg) -{ - /* new-style options contain an offset into optctx, old-style address of - * a global var*/ - void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? - (uint8_t *)optctx + po->u.off : po->u.dst_ptr; - int *dstcount; - - if (po->flags & OPT_SPEC) { - SpecifierOpt **so = dst; - char *p = strchr(opt, ':'); - char *str; - - dstcount = (int *)(so + 1); - *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1); - str = av_strdup(p ? p + 1 : ""); - if (!str) - return AVERROR(ENOMEM); - (*so)[*dstcount - 1].specifier = str; - dst = &(*so)[*dstcount - 1].u; - } - - if (po->flags & OPT_STRING) { - char *str; - str = av_strdup(arg); - av_freep(dst); - if (!str) - return AVERROR(ENOMEM); - *(char **)dst = str; - } else if (po->flags & OPT_BOOL || po->flags & OPT_INT) { - *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); - } else if (po->flags & OPT_INT64) { - *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); - } else if (po->flags & OPT_TIME) { - *(int64_t *)dst = parse_time_or_die(opt, arg, 1); - } else if (po->flags & OPT_FLOAT) { - *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); - } else if (po->flags & OPT_DOUBLE) { - *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); - } else if (po->u.func_arg) { - int ret = po->u.func_arg(optctx, opt, arg); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, - "Failed to set value '%s' for option '%s': %s\n", - arg, opt, av_err2str(ret)); - return ret; - } - } - if (po->flags & OPT_EXIT) - exit_program(0); - - return 0; -} - -int parse_option(void *optctx, const char *opt, const char *arg, - const OptionDef *options) -{ - const OptionDef *po; - int ret; - - po = find_option(options, opt); - if (!po->name && opt[0] == 'n' && opt[1] == 'o') { - /* handle 'no' bool option */ - po = find_option(options, opt + 2); - if ((po->name && (po->flags & OPT_BOOL))) - arg = "0"; - } else if (po->flags & OPT_BOOL) - arg = "1"; - - if (!po->name) - po = find_option(options, "default"); - if (!po->name) { - av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt); - return AVERROR(EINVAL); - } - if (po->flags & HAS_ARG && !arg) { - av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt); - return AVERROR(EINVAL); - } - - ret = write_option(optctx, po, opt, arg); - if (ret < 0) - return ret; - - return !!(po->flags & HAS_ARG); -} - -void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, - void (*parse_arg_function)(void *, const char*)) -{ - const char *opt; - int optindex, handleoptions = 1, ret; - - /* perform system-dependent conversions for arguments list */ - prepare_app_arguments(&argc, &argv); - - /* parse options */ - optindex = 1; - while (optindex < argc) { - opt = argv[optindex++]; - - if (handleoptions && opt[0] == '-' && opt[1] != '\0') { - if (opt[1] == '-' && opt[2] == '\0') { - handleoptions = 0; - continue; - } - opt++; - - if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0) - exit_program(1); - optindex += ret; - } else { - if (parse_arg_function) - parse_arg_function(optctx, opt); - } - } -} - -int parse_optgroup(void *optctx, OptionGroup *g) -{ - int i, ret; - - av_log(NULL, AV_LOG_DEBUG, "Parsing a group of options: %s %s.\n", - g->group_def->name, g->arg); - - for (i = 0; i < g->nb_opts; i++) { - Option *o = &g->opts[i]; - - if (g->group_def->flags && - !(g->group_def->flags & o->opt->flags)) { - av_log(NULL, AV_LOG_ERROR, "Option %s (%s) cannot be applied to " - "%s %s -- you are trying to apply an input option to an " - "output file or vice versa. Move this option before the " - "file it belongs to.\n", o->key, o->opt->help, - g->group_def->name, g->arg); - return AVERROR(EINVAL); - } - - av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument %s.\n", - o->key, o->opt->help, o->val); - - ret = write_option(optctx, o->opt, o->key, o->val); - if (ret < 0) - return ret; - } - - av_log(NULL, AV_LOG_DEBUG, "Successfully parsed a group of options.\n"); - - return 0; -} - -int locate_option(int argc, char **argv, const OptionDef *options, - const char *optname) -{ - const OptionDef *po; - int i; - - for (i = 1; i < argc; i++) { - const char *cur_opt = argv[i]; - - if (*cur_opt++ != '-') - continue; - - po = find_option(options, cur_opt); - if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o') - po = find_option(options, cur_opt + 2); - - if ((!po->name && !strcmp(cur_opt, optname)) || - (po->name && !strcmp(optname, po->name))) - return i; - - if (!po->name || po->flags & HAS_ARG) - i++; - } - return 0; -} - -static void dump_argument(const char *a) -{ - const unsigned char *p; - - for (p = a; *p; p++) - if (!((*p >= '+' && *p <= ':') || (*p >= '@' && *p <= 'Z') || - *p == '_' || (*p >= 'a' && *p <= 'z'))) - break; - if (!*p) { - fputs(a, report_file); - return; - } - fputc('"', report_file); - for (p = a; *p; p++) { - if (*p == '\\' || *p == '"' || *p == '$' || *p == '`') - fprintf(report_file, "\\%c", *p); - else if (*p < ' ' || *p > '~') - fprintf(report_file, "\\x%02x", *p); - else - fputc(*p, report_file); - } - fputc('"', report_file); -} - -static void check_options(const OptionDef *po) -{ - while (po->name) { - if (po->flags & OPT_PERFILE) - av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT)); - po++; - } -} - -void parse_loglevel(int argc, char **argv, const OptionDef *options) -{ - int idx = locate_option(argc, argv, options, "loglevel"); - const char *env; - - check_options(options); - - if (!idx) - idx = locate_option(argc, argv, options, "v"); - if (idx && argv[idx + 1]) - opt_loglevel(NULL, "loglevel", argv[idx + 1]); - idx = locate_option(argc, argv, options, "report"); - if ((env = getenv("FFREPORT")) || idx) { - init_report(env); - if (report_file) { - int i; - fprintf(report_file, "Command line:\n"); - for (i = 0; i < argc; i++) { - dump_argument(argv[i]); - fputc(i < argc - 1 ? ' ' : '\n', report_file); - } - fflush(report_file); - } - } - idx = locate_option(argc, argv, options, "hide_banner"); - if (idx) - hide_banner = 1; -} - -static const AVOption *opt_find(void *obj, const char *name, const char *unit, - int opt_flags, int search_flags) -{ - const AVOption *o = av_opt_find(obj, name, unit, opt_flags, search_flags); - if(o && !o->flags) - return NULL; - return o; -} - -#define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 -int opt_default(void *optctx, const char *opt, const char *arg) -{ - const AVOption *o; - int consumed = 0; - char opt_stripped[128]; - const char *p; - const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); -#if CONFIG_SWSCALE - const AVClass *sc = sws_get_class(); -#endif -#if CONFIG_SWRESAMPLE - const AVClass *swr_class = swr_get_class(); -#endif - - if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) - av_log_set_level(AV_LOG_DEBUG); - - if (!(p = strchr(opt, ':'))) - p = opt + strlen(opt); - av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); - - if ((o = opt_find(&cc, opt_stripped, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || - ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && - (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) { - av_dict_set(&codec_opts, opt, arg, FLAGS); - consumed = 1; - } - if ((o = opt_find(&fc, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { - av_dict_set(&format_opts, opt, arg, FLAGS); - if (consumed) - av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt); - consumed = 1; - } -#if CONFIG_SWSCALE - if (!consumed && (o = opt_find(&sc, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { - struct SwsContext *sws = sws_alloc_context(); - int ret = av_opt_set(sws, opt, arg, 0); - sws_freeContext(sws); - if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") || - !strcmp(opt, "dstw") || !strcmp(opt, "dsth") || - !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) { - av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n"); - return AVERROR(EINVAL); - } - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); - return ret; - } - - av_dict_set(&sws_dict, opt, arg, FLAGS); - - consumed = 1; - } -#else - if (!consumed && !strcmp(opt, "sws_flags")) { - av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg); - consumed = 1; - } -#endif -#if CONFIG_SWRESAMPLE - if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0, - AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { - struct SwrContext *swr = swr_alloc(); - int ret = av_opt_set(swr, opt, arg, 0); - swr_free(&swr); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); - return ret; - } - av_dict_set(&swr_opts, opt, arg, FLAGS); - consumed = 1; - } -#endif - - if (consumed) - return 0; - return AVERROR_OPTION_NOT_FOUND; -} - -/* - * Check whether given option is a group separator. - * - * @return index of the group definition that matched or -1 if none - */ -static int match_group_separator(const OptionGroupDef *groups, int nb_groups, - const char *opt) -{ - int i; - - for (i = 0; i < nb_groups; i++) { - const OptionGroupDef *p = &groups[i]; - if (p->sep && !strcmp(p->sep, opt)) - return i; - } - - return -1; -} - -/* - * Finish parsing an option group. - * - * @param group_idx which group definition should this group belong to - * @param arg argument of the group delimiting option - */ -static void finish_group(OptionParseContext *octx, int group_idx, - const char *arg) -{ - OptionGroupList *l = &octx->groups[group_idx]; - OptionGroup *g; - - GROW_ARRAY(l->groups, l->nb_groups); - g = &l->groups[l->nb_groups - 1]; - - *g = octx->cur_group; - g->arg = arg; - g->group_def = l->group_def; - g->sws_dict = sws_dict; - g->swr_opts = swr_opts; - g->codec_opts = codec_opts; - g->format_opts = format_opts; - - codec_opts = NULL; - format_opts = NULL; - sws_dict = NULL; - swr_opts = NULL; - - memset(&octx->cur_group, 0, sizeof(octx->cur_group)); -} - -/* - * Add an option instance to currently parsed group. - */ -static void add_opt(OptionParseContext *octx, const OptionDef *opt, - const char *key, const char *val) -{ - int global = !(opt->flags & (OPT_PERFILE | OPT_SPEC | OPT_OFFSET)); - OptionGroup *g = global ? &octx->global_opts : &octx->cur_group; - - GROW_ARRAY(g->opts, g->nb_opts); - g->opts[g->nb_opts - 1].opt = opt; - g->opts[g->nb_opts - 1].key = key; - g->opts[g->nb_opts - 1].val = val; -} - -static void init_parse_context(OptionParseContext *octx, - const OptionGroupDef *groups, int nb_groups) -{ - static const OptionGroupDef global_group = { "global" }; - int i; - - memset(octx, 0, sizeof(*octx)); - - octx->nb_groups = nb_groups; - octx->groups = av_calloc(octx->nb_groups, sizeof(*octx->groups)); - if (!octx->groups) - exit_program(1); - - for (i = 0; i < octx->nb_groups; i++) - octx->groups[i].group_def = &groups[i]; - - octx->global_opts.group_def = &global_group; - octx->global_opts.arg = ""; -} - -void uninit_parse_context(OptionParseContext *octx) -{ - int i, j; - - for (i = 0; i < octx->nb_groups; i++) { - OptionGroupList *l = &octx->groups[i]; - - for (j = 0; j < l->nb_groups; j++) { - av_freep(&l->groups[j].opts); - av_dict_free(&l->groups[j].codec_opts); - av_dict_free(&l->groups[j].format_opts); - - av_dict_free(&l->groups[j].sws_dict); - av_dict_free(&l->groups[j].swr_opts); - } - av_freep(&l->groups); - } - av_freep(&octx->groups); - - av_freep(&octx->cur_group.opts); - av_freep(&octx->global_opts.opts); - - uninit_opts(); -} - -int split_commandline(OptionParseContext *octx, int argc, char *argv[], - const OptionDef *options, - const OptionGroupDef *groups, int nb_groups) -{ - int optindex = 1; - int dashdash = -2; - - /* perform system-dependent conversions for arguments list */ - prepare_app_arguments(&argc, &argv); - - init_parse_context(octx, groups, nb_groups); - av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n"); - - while (optindex < argc) { - const char *opt = argv[optindex++], *arg; - const OptionDef *po; - int ret; - - av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt); - - if (opt[0] == '-' && opt[1] == '-' && !opt[2]) { - dashdash = optindex; - continue; - } - /* unnamed group separators, e.g. output filename */ - if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) { - finish_group(octx, 0, opt); - av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name); - continue; - } - opt++; - -#define GET_ARG(arg) \ -do { \ - arg = argv[optindex++]; \ - if (!arg) { \ - av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\ - return AVERROR(EINVAL); \ - } \ -} while (0) - - /* named group separators, e.g. -i */ - if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) { - GET_ARG(arg); - finish_group(octx, ret, arg); - av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n", - groups[ret].name, arg); - continue; - } - - /* normal options */ - po = find_option(options, opt); - if (po->name) { - if (po->flags & OPT_EXIT) { - /* optional argument, e.g. -h */ - arg = argv[optindex++]; - } else if (po->flags & HAS_ARG) { - GET_ARG(arg); - } else { - arg = "1"; - } - - add_opt(octx, po, opt, arg); - av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with " - "argument '%s'.\n", po->name, po->help, arg); - continue; - } - - /* AVOptions */ - if (argv[optindex]) { - ret = opt_default(NULL, opt, argv[optindex]); - if (ret >= 0) { - av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with " - "argument '%s'.\n", opt, argv[optindex]); - optindex++; - continue; - } else if (ret != AVERROR_OPTION_NOT_FOUND) { - av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' " - "with argument '%s'.\n", opt, argv[optindex]); - return ret; - } - } - - /* boolean -nofoo options */ - if (opt[0] == 'n' && opt[1] == 'o' && - (po = find_option(options, opt + 2)) && - po->name && po->flags & OPT_BOOL) { - add_opt(octx, po, opt, "0"); - av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with " - "argument 0.\n", po->name, po->help); - continue; - } - - av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", opt); - return AVERROR_OPTION_NOT_FOUND; - } - - if (octx->cur_group.nb_opts || codec_opts || format_opts) - av_log(NULL, AV_LOG_WARNING, "Trailing option(s) found in the " - "command: may be ignored.\n"); - - av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n"); - - return 0; -} - -int opt_cpuflags(void *optctx, const char *opt, const char *arg) -{ - int ret; - unsigned flags = av_get_cpu_flags(); - - if ((ret = av_parse_cpu_caps(&flags, arg)) < 0) - return ret; - - av_force_cpu_flags(flags); - return 0; -} - -int opt_cpucount(void *optctx, const char *opt, const char *arg) -{ - int ret; - int count; - - static const AVOption opts[] = { - {"count", NULL, 0, AV_OPT_TYPE_INT, { .i64 = -1}, -1, INT_MAX}, - {NULL}, - }; - static const AVClass class = { - .class_name = "cpucount", - .item_name = av_default_item_name, - .option = opts, - .version = LIBAVUTIL_VERSION_INT, - }; - const AVClass *pclass = &class; - - ret = av_opt_eval_int(&pclass, opts, arg, &count); - - if (!ret) { - av_cpu_force_count(count); - } - - return ret; -} - -int opt_loglevel(void *optctx, const char *opt, const char *arg) -{ - const struct { const char *name; int level; } log_levels[] = { - { "quiet" , AV_LOG_QUIET }, - { "panic" , AV_LOG_PANIC }, - { "fatal" , AV_LOG_FATAL }, - { "error" , AV_LOG_ERROR }, - { "warning", AV_LOG_WARNING }, - { "info" , AV_LOG_INFO }, - { "verbose", AV_LOG_VERBOSE }, - { "debug" , AV_LOG_DEBUG }, - { "trace" , AV_LOG_TRACE }, - }; - const char *token; - char *tail; - int flags = av_log_get_flags(); - int level = av_log_get_level(); - int cmd, i = 0; - - av_assert0(arg); - while (*arg) { - token = arg; - if (*token == '+' || *token == '-') { - cmd = *token++; - } else { - cmd = 0; - } - if (!i && !cmd) { - flags = 0; /* missing relative prefix, build absolute value */ - } - if (av_strstart(token, "repeat", &arg)) { - if (cmd == '-') { - flags |= AV_LOG_SKIP_REPEATED; - } else { - flags &= ~AV_LOG_SKIP_REPEATED; - } - } else if (av_strstart(token, "level", &arg)) { - if (cmd == '-') { - flags &= ~AV_LOG_PRINT_LEVEL; - } else { - flags |= AV_LOG_PRINT_LEVEL; - } - } else { - break; - } - i++; - } - if (!*arg) { - goto end; - } else if (*arg == '+') { - arg++; - } else if (!i) { - flags = av_log_get_flags(); /* level value without prefix, reset flags */ - } - - for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { - if (!strcmp(log_levels[i].name, arg)) { - level = log_levels[i].level; - goto end; - } - } - - level = strtol(arg, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". " - "Possible levels are numbers or:\n", arg); - for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) - av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name); - exit_program(1); - } - -end: - av_log_set_flags(flags); - av_log_set_level(level); - return 0; -} - -static void expand_filename_template(AVBPrint *bp, const char *template, - struct tm *tm) -{ - int c; - - while ((c = *(template++))) { - if (c == '%') { - if (!(c = *(template++))) - break; - switch (c) { - case 'p': - av_bprintf(bp, "%s", program_name); - break; - case 't': - av_bprintf(bp, "%04d%02d%02d-%02d%02d%02d", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); - break; - case '%': - av_bprint_chars(bp, c, 1); - break; - } - } else { - av_bprint_chars(bp, c, 1); - } - } -} - -static int init_report(const char *env) -{ - char *filename_template = NULL; - char *key, *val; - int ret, count = 0; - int prog_loglevel, envlevel = 0; - time_t now; - struct tm *tm; - AVBPrint filename; - - if (report_file) /* already opened */ - return 0; - time(&now); - tm = localtime(&now); - - while (env && *env) { - if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) { - if (count) - av_log(NULL, AV_LOG_ERROR, - "Failed to parse FFREPORT environment variable: %s\n", - av_err2str(ret)); - break; - } - if (*env) - env++; - count++; - if (!strcmp(key, "file")) { - av_free(filename_template); - filename_template = val; - val = NULL; - } else if (!strcmp(key, "level")) { - char *tail; - report_file_level = strtol(val, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n"); - exit_program(1); - } - envlevel = 1; - } else { - av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key); - } - av_free(val); - av_free(key); - } - - av_bprint_init(&filename, 0, AV_BPRINT_SIZE_AUTOMATIC); - expand_filename_template(&filename, - av_x_if_null(filename_template, "%p-%t.log"), tm); - av_free(filename_template); - if (!av_bprint_is_complete(&filename)) { - av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n"); - return AVERROR(ENOMEM); - } - - prog_loglevel = av_log_get_level(); - if (!envlevel) - report_file_level = FFMAX(report_file_level, prog_loglevel); - - report_file = fopen(filename.str, "w"); - if (!report_file) { - int ret = AVERROR(errno); - av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n", - filename.str, strerror(errno)); - return ret; - } - av_log_set_callback(log_callback_report); - av_log(NULL, AV_LOG_INFO, - "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n" - "Report written to \"%s\"\n" - "Log level: %d\n", - program_name, - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, - filename.str, report_file_level); - av_bprint_finalize(&filename, NULL); - return 0; -} - -int opt_report(void *optctx, const char *opt, const char *arg) -{ - return init_report(NULL); -} - -int opt_max_alloc(void *optctx, const char *opt, const char *arg) -{ - char *tail; - size_t max; - - max = strtol(arg, &tail, 10); - if (*tail) { - av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg); - exit_program(1); - } - av_max_alloc(max); - 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]; - const char *errbuf_ptr = errbuf; - - if (av_strerror(err, errbuf, sizeof(errbuf)) < 0) - errbuf_ptr = strerror(AVUNERROR(err)); - av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr); -} - -static int warned_cfg = 0; - -#define INDENT 1 -#define SHOW_VERSION 2 -#define SHOW_CONFIG 4 -#define SHOW_COPYRIGHT 8 - -#define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ - if (CONFIG_##LIBNAME) { \ - const char *indent = flags & INDENT? " " : ""; \ - if (flags & SHOW_VERSION) { \ - unsigned int version = libname##_version(); \ - av_log(NULL, level, \ - "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \ - indent, #libname, \ - LIB##LIBNAME##_VERSION_MAJOR, \ - LIB##LIBNAME##_VERSION_MINOR, \ - LIB##LIBNAME##_VERSION_MICRO, \ - AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\ - AV_VERSION_MICRO(version)); \ - } \ - if (flags & SHOW_CONFIG) { \ - const char *cfg = libname##_configuration(); \ - if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \ - if (!warned_cfg) { \ - av_log(NULL, level, \ - "%sWARNING: library configuration mismatch\n", \ - indent); \ - warned_cfg = 1; \ - } \ - av_log(NULL, level, "%s%-11s configuration: %s\n", \ - indent, #libname, cfg); \ - } \ - } \ - } \ - -static void print_all_libs_info(int flags, int level) -{ - PRINT_LIB_INFO(avutil, AVUTIL, flags, level); - PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); - PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); - PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); - PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); - PRINT_LIB_INFO(swscale, SWSCALE, flags, level); - PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level); - PRINT_LIB_INFO(postproc, POSTPROC, flags, level); -} - -static void print_program_info(int flags, int level) -{ - const char *indent = flags & INDENT? " " : ""; - - av_log(NULL, level, "%s version " FFMPEG_VERSION, program_name); - if (flags & SHOW_COPYRIGHT) - av_log(NULL, level, " Copyright (c) %d-%d the FFmpeg developers", - program_birth_year, CONFIG_THIS_YEAR); - av_log(NULL, level, "\n"); - av_log(NULL, level, "%sbuilt with %s\n", indent, CC_IDENT); +#include "config.h" - av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent); -} +#include -static void print_buildconf(int flags, int level) -{ - const char *indent = flags & INDENT ? " " : ""; - char str[] = { FFMPEG_CONFIGURATION }; - char *conflist, *remove_tilde, *splitconf; +#include "cmdutils.h" +#include "opt_common.h" - // Change all the ' --' strings to '~--' so that - // they can be identified as tokens. - while ((conflist = strstr(str, " --")) != NULL) { - conflist[0] = '~'; - } +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/bprint.h" +#include "libavutil/channel_layout.h" +#include "libavutil/cpu.h" +#include "libavutil/dict.h" +#include "libavutil/error.h" +#include "libavutil/ffversion.h" +#include "libavutil/log.h" +#include "libavutil/mem.h" +#include "libavutil/parseutils.h" +#include "libavutil/pixdesc.h" +#include "libavutil/version.h" - // Compensate for the weirdness this would cause - // when passing 'pkg-config --static'. - while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) { - remove_tilde[sizeof("pkg-config~") - 2] = ' '; - } +#include "libavcodec/avcodec.h" +#include "libavcodec/bsf.h" +#include "libavcodec/codec.h" +#include "libavcodec/codec_desc.h" +#include "libavcodec/version.h" - splitconf = strtok(str, "~"); - av_log(NULL, level, "\n%sconfiguration:\n", indent); - while (splitconf != NULL) { - av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf); - splitconf = strtok(NULL, "~"); - } -} +#include "libavformat/avformat.h" +#include "libavformat/version.h" -void show_banner(int argc, char **argv, const OptionDef *options) -{ - int idx = locate_option(argc, argv, options, "version"); - if (hide_banner || idx) - return; +#include "libavdevice/avdevice.h" +#include "libavdevice/version.h" - print_program_info (INDENT|SHOW_COPYRIGHT, AV_LOG_INFO); - print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_INFO); - print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_INFO); -} +#include "libswscale/swscale.h" +#include "libswscale/version.h" -int show_version(void *optctx, const char *opt, const char *arg) -{ - av_log_set_callback(log_callback_help); - print_program_info (SHOW_COPYRIGHT, AV_LOG_INFO); - print_all_libs_info(SHOW_VERSION, AV_LOG_INFO); +#include "libswresample/swresample.h" +#include "libswresample/version.h" - return 0; -} +#include "libpostproc/postprocess.h" +#include "libpostproc/version.h" -int show_buildconf(void *optctx, const char *opt, const char *arg) -{ - av_log_set_callback(log_callback_help); - print_buildconf (INDENT|0, AV_LOG_INFO); +enum show_muxdemuxers { + SHOW_DEFAULT, + SHOW_DEMUXERS, + SHOW_MUXERS, +}; - return 0; -} +static FILE *report_file; +static int report_file_level = AV_LOG_DEBUG; int show_license(void *optctx, const char *opt, const char *arg) { @@ -1284,94 +143,120 @@ int show_license(void *optctx, const char *opt, const char *arg) return 0; } -static int is_device(const AVClass *avclass) +static int warned_cfg = 0; + +#define INDENT 1 +#define SHOW_VERSION 2 +#define SHOW_CONFIG 4 +#define SHOW_COPYRIGHT 8 + +#define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ + if (CONFIG_##LIBNAME) { \ + const char *indent = flags & INDENT? " " : ""; \ + if (flags & SHOW_VERSION) { \ + unsigned int version = libname##_version(); \ + av_log(NULL, level, \ + "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \ + indent, #libname, \ + LIB##LIBNAME##_VERSION_MAJOR, \ + LIB##LIBNAME##_VERSION_MINOR, \ + LIB##LIBNAME##_VERSION_MICRO, \ + AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\ + AV_VERSION_MICRO(version)); \ + } \ + if (flags & SHOW_CONFIG) { \ + const char *cfg = libname##_configuration(); \ + if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \ + if (!warned_cfg) { \ + av_log(NULL, level, \ + "%sWARNING: library configuration mismatch\n", \ + indent); \ + warned_cfg = 1; \ + } \ + av_log(NULL, level, "%s%-11s configuration: %s\n", \ + indent, #libname, cfg); \ + } \ + } \ + } \ + +static void print_all_libs_info(int flags, int level) { - if (!avclass) - return 0; - return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category); + PRINT_LIB_INFO(avutil, AVUTIL, flags, level); + PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); + PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); + PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); + PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); + PRINT_LIB_INFO(swscale, SWSCALE, flags, level); + PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level); + PRINT_LIB_INFO(postproc, POSTPROC, flags, level); +} + +static void print_program_info(int flags, int level) +{ + const char *indent = flags & INDENT? " " : ""; + + av_log(NULL, level, "%s version " FFMPEG_VERSION, program_name); + if (flags & SHOW_COPYRIGHT) + av_log(NULL, level, " Copyright (c) %d-%d the FFmpeg developers", + program_birth_year, CONFIG_THIS_YEAR); + av_log(NULL, level, "\n"); + av_log(NULL, level, "%sbuilt with %s\n", indent, CC_IDENT); + + av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent); } -static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers) +static void print_buildconf(int flags, int level) { - void *ifmt_opaque = NULL; - const AVInputFormat *ifmt = NULL; - void *ofmt_opaque = NULL; - const AVOutputFormat *ofmt = NULL; - const char *last_name; - int is_dev; + const char *indent = flags & INDENT ? " " : ""; + char str[] = { FFMPEG_CONFIGURATION }; + char *conflist, *remove_tilde, *splitconf; - printf("%s\n" - " D. = Demuxing supported\n" - " .E = Muxing supported\n" - " --\n", device_only ? "Devices:" : "File formats:"); - last_name = "000"; - for (;;) { - int decode = 0; - int encode = 0; - const char *name = NULL; - const char *long_name = NULL; + // Change all the ' --' strings to '~--' so that + // they can be identified as tokens. + while ((conflist = strstr(str, " --")) != NULL) { + conflist[0] = '~'; + } - if (muxdemuxers !=SHOW_DEMUXERS) { - ofmt_opaque = NULL; - while ((ofmt = av_muxer_iterate(&ofmt_opaque))) { - is_dev = is_device(ofmt->priv_class); - if (!is_dev && device_only) - continue; - if ((!name || strcmp(ofmt->name, name) < 0) && - strcmp(ofmt->name, last_name) > 0) { - name = ofmt->name; - long_name = ofmt->long_name; - encode = 1; - } - } - } - if (muxdemuxers != SHOW_MUXERS) { - ifmt_opaque = NULL; - while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) { - is_dev = is_device(ifmt->priv_class); - if (!is_dev && device_only) - continue; - if ((!name || strcmp(ifmt->name, name) < 0) && - strcmp(ifmt->name, last_name) > 0) { - name = ifmt->name; - long_name = ifmt->long_name; - encode = 0; - } - if (name && strcmp(ifmt->name, name) == 0) - decode = 1; - } - } - if (!name) - break; - last_name = name; + // Compensate for the weirdness this would cause + // when passing 'pkg-config --static'. + while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) { + remove_tilde[sizeof("pkg-config~") - 2] = ' '; + } - printf(" %c%c %-15s %s\n", - decode ? 'D' : ' ', - encode ? 'E' : ' ', - name, - long_name ? long_name:" "); + splitconf = strtok(str, "~"); + av_log(NULL, level, "\n%sconfiguration:\n", indent); + while (splitconf != NULL) { + av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf); + splitconf = strtok(NULL, "~"); } - return 0; } -int show_formats(void *optctx, const char *opt, const char *arg) +void show_banner(int argc, char **argv, const OptionDef *options) { - return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT); -} + int idx = locate_option(argc, argv, options, "version"); + if (hide_banner || idx) + return; -int show_muxers(void *optctx, const char *opt, const char *arg) -{ - return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS); + print_program_info (INDENT|SHOW_COPYRIGHT, AV_LOG_INFO); + print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_INFO); + print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_INFO); } -int show_demuxers(void *optctx, const char *opt, const char *arg) +int show_version(void *optctx, const char *opt, const char *arg) { - return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS); + av_log_set_callback(log_callback_help); + print_program_info (SHOW_COPYRIGHT, AV_LOG_INFO); + print_all_libs_info(SHOW_VERSION, AV_LOG_INFO); + + return 0; } -int show_devices(void *optctx, const char *opt, const char *arg) +int show_buildconf(void *optctx, const char *opt, const char *arg) { - return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT); + av_log_set_callback(log_callback_help); + print_buildconf (INDENT|0, AV_LOG_INFO); + + return 0; } #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ @@ -1454,54 +339,273 @@ static void print_codec(const AVCodec *c) printf("\n"); } - if (c->supported_framerates) { - const AVRational *fps = c->supported_framerates; + if (c->supported_framerates) { + const AVRational *fps = c->supported_framerates; + + printf(" Supported framerates:"); + while (fps->num) { + printf(" %d/%d", fps->num, fps->den); + fps++; + } + printf("\n"); + } + PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats", + AV_PIX_FMT_NONE, GET_PIX_FMT_NAME); + PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0, + GET_SAMPLE_RATE_NAME); + PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats", + AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME); + PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts", + 0, GET_CH_LAYOUT_DESC); + + if (c->priv_class) { + show_help_children(c->priv_class, + AV_OPT_FLAG_ENCODING_PARAM | + AV_OPT_FLAG_DECODING_PARAM); + } +} + +static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter, + int encoder) +{ + const AVCodec *c; + while ((c = av_codec_iterate(iter))) { + if (c->id == id && + (encoder ? av_codec_is_encoder(c) : av_codec_is_decoder(c))) + return c; + } + return NULL; +} + +static void show_help_codec(const char *name, int encoder) +{ + const AVCodecDescriptor *desc; + const AVCodec *codec; + + if (!name) { + av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n"); + return; + } + + codec = encoder ? avcodec_find_encoder_by_name(name) : + avcodec_find_decoder_by_name(name); + + if (codec) + print_codec(codec); + else if ((desc = avcodec_descriptor_get_by_name(name))) { + void *iter = NULL; + int printed = 0; + + while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { + printed = 1; + print_codec(codec); + } + + if (!printed) { + av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, " + "but no %s for it are available. FFmpeg might need to be " + "recompiled with additional external libraries.\n", + name, encoder ? "encoders" : "decoders"); + } + } else { + av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n", + name); + } +} + +static void show_help_demuxer(const char *name) +{ + const AVInputFormat *fmt = av_find_input_format(name); + + if (!fmt) { + av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); + return; + } + + printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name); + + if (fmt->extensions) + printf(" Common extensions: %s.\n", fmt->extensions); + + if (fmt->priv_class) + show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM); +} + +static void show_help_protocol(const char *name) +{ + const AVClass *proto_class; + + if (!name) { + av_log(NULL, AV_LOG_ERROR, "No protocol name specified.\n"); + return; + } + + proto_class = avio_protocol_get_class(name); + if (!proto_class) { + av_log(NULL, AV_LOG_ERROR, "Unknown protocol '%s'.\n", name); + return; + } + + show_help_children(proto_class, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM); +} + +static void show_help_muxer(const char *name) +{ + const AVCodecDescriptor *desc; + const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL); + + if (!fmt) { + av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); + return; + } + + printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name); + + if (fmt->extensions) + printf(" Common extensions: %s.\n", fmt->extensions); + if (fmt->mime_type) + printf(" Mime type: %s.\n", fmt->mime_type); + if (fmt->video_codec != AV_CODEC_ID_NONE && + (desc = avcodec_descriptor_get(fmt->video_codec))) { + printf(" Default video codec: %s.\n", desc->name); + } + if (fmt->audio_codec != AV_CODEC_ID_NONE && + (desc = avcodec_descriptor_get(fmt->audio_codec))) { + printf(" Default audio codec: %s.\n", desc->name); + } + if (fmt->subtitle_codec != AV_CODEC_ID_NONE && + (desc = avcodec_descriptor_get(fmt->subtitle_codec))) { + printf(" Default subtitle codec: %s.\n", desc->name); + } + + if (fmt->priv_class) + show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM); +} + +#if CONFIG_AVFILTER +static void show_help_filter(const char *name) +{ +#if CONFIG_AVFILTER + const AVFilter *f = avfilter_get_by_name(name); + int i, count; + + if (!name) { + av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n"); + return; + } else if (!f) { + av_log(NULL, AV_LOG_ERROR, "Unknown filter '%s'.\n", name); + return; + } + + printf("Filter %s\n", f->name); + if (f->description) + printf(" %s\n", f->description); - printf(" Supported framerates:"); - while (fps->num) { - printf(" %d/%d", fps->num, fps->den); - fps++; - } - printf("\n"); + if (f->flags & AVFILTER_FLAG_SLICE_THREADS) + printf(" slice threading supported\n"); + + printf(" Inputs:\n"); + count = avfilter_filter_pad_count(f, 0); + for (i = 0; i < count; i++) { + printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), + av_get_media_type_string(avfilter_pad_get_type(f->inputs, i))); } - PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats", - AV_PIX_FMT_NONE, GET_PIX_FMT_NAME); - PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0, - GET_SAMPLE_RATE_NAME); - PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats", - AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME); - PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts", - 0, GET_CH_LAYOUT_DESC); + if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS) + printf(" dynamic (depending on the options)\n"); + else if (!count) + printf(" none (source filter)\n"); - if (c->priv_class) { - show_help_children(c->priv_class, - AV_OPT_FLAG_ENCODING_PARAM | - AV_OPT_FLAG_DECODING_PARAM); + printf(" Outputs:\n"); + count = avfilter_filter_pad_count(f, 1); + for (i = 0; i < count; i++) { + printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), + av_get_media_type_string(avfilter_pad_get_type(f->outputs, i))); } + if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS) + printf(" dynamic (depending on the options)\n"); + else if (!count) + printf(" none (sink filter)\n"); + + if (f->priv_class) + show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | + AV_OPT_FLAG_AUDIO_PARAM); + if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) + printf("This filter has support for timeline through the 'enable' option.\n"); +#else + av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; " + "can not to satisfy request\n"); +#endif } +#endif -static char get_media_type_char(enum AVMediaType type) +static void show_help_bsf(const char *name) { - switch (type) { - case AVMEDIA_TYPE_VIDEO: return 'V'; - case AVMEDIA_TYPE_AUDIO: return 'A'; - case AVMEDIA_TYPE_DATA: return 'D'; - case AVMEDIA_TYPE_SUBTITLE: return 'S'; - case AVMEDIA_TYPE_ATTACHMENT:return 'T'; - default: return '?'; + const AVBitStreamFilter *bsf = av_bsf_get_by_name(name); + + if (!name) { + av_log(NULL, AV_LOG_ERROR, "No bitstream filter name specified.\n"); + return; + } else if (!bsf) { + av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name); + return; } + + printf("Bit stream filter %s\n", bsf->name); + PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs", + AV_CODEC_ID_NONE, GET_CODEC_NAME); + if (bsf->priv_class) + show_help_children(bsf->priv_class, AV_OPT_FLAG_BSF_PARAM); } -static const AVCodec *next_codec_for_id(enum AVCodecID id, void **iter, - int encoder) +int show_help(void *optctx, const char *opt, const char *arg) { - const AVCodec *c; - while ((c = av_codec_iterate(iter))) { - if (c->id == id && - (encoder ? av_codec_is_encoder(c) : av_codec_is_decoder(c))) - return c; + char *topic, *par; + av_log_set_callback(log_callback_help); + + topic = av_strdup(arg ? arg : ""); + if (!topic) + return AVERROR(ENOMEM); + par = strchr(topic, '='); + if (par) + *par++ = 0; + + if (!*topic) { + show_help_default(topic, par); + } else if (!strcmp(topic, "decoder")) { + show_help_codec(par, 0); + } else if (!strcmp(topic, "encoder")) { + show_help_codec(par, 1); + } else if (!strcmp(topic, "demuxer")) { + show_help_demuxer(par); + } else if (!strcmp(topic, "muxer")) { + show_help_muxer(par); + } else if (!strcmp(topic, "protocol")) { + show_help_protocol(par); +#if CONFIG_AVFILTER + } else if (!strcmp(topic, "filter")) { + show_help_filter(par); +#endif + } else if (!strcmp(topic, "bsf")) { + show_help_bsf(par); + } else { + show_help_default(topic, par); } - return NULL; + + av_freep(&topic); + return 0; +} + +static void print_codecs_for_id(enum AVCodecID id, int encoder) +{ + void *iter = NULL; + const AVCodec *codec; + + printf(" (%s: ", encoder ? "encoders" : "decoders"); + + while ((codec = next_codec_for_id(id, &iter, encoder))) + printf("%s ", codec->name); + + printf(")"); } static int compare_codec_desc(const void *a, const void *b) @@ -1534,17 +638,16 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) return nb_codecs; } -static void print_codecs_for_id(enum AVCodecID id, int encoder) +static char get_media_type_char(enum AVMediaType type) { - void *iter = NULL; - const AVCodec *codec; - - printf(" (%s: ", encoder ? "encoders" : "decoders"); - - while ((codec = next_codec_for_id(id, &iter, encoder))) - printf("%s ", codec->name); - - printf(")"); + switch (type) { + case AVMEDIA_TYPE_VIDEO: return 'V'; + case AVMEDIA_TYPE_AUDIO: return 'A'; + case AVMEDIA_TYPE_DATA: return 'D'; + case AVMEDIA_TYPE_SUBTITLE: return 'S'; + case AVMEDIA_TYPE_ATTACHMENT:return 'T'; + default: return '?'; + } } int show_codecs(void *optctx, const char *opt, const char *arg) @@ -1666,21 +769,6 @@ int show_bsfs(void *optctx, const char *opt, const char *arg) return 0; } -int show_protocols(void *optctx, const char *opt, const char *arg) -{ - void *opaque = NULL; - const char *name; - - printf("Supported file protocols:\n" - "Input:\n"); - while ((name = avio_enum_protocols(&opaque, 0))) - printf(" %s\n", name); - printf("Output:\n"); - while ((name = avio_enum_protocols(&opaque, 1))) - printf(" %s\n", name); - return 0; -} - int show_filters(void *optctx, const char *opt, const char *arg) { #if CONFIG_AVFILTER @@ -1730,6 +818,111 @@ int show_filters(void *optctx, const char *opt, const char *arg) return 0; } +static int is_device(const AVClass *avclass) +{ + if (!avclass) + return 0; + return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category); +} + +static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers) +{ + void *ifmt_opaque = NULL; + const AVInputFormat *ifmt = NULL; + void *ofmt_opaque = NULL; + const AVOutputFormat *ofmt = NULL; + const char *last_name; + int is_dev; + + printf("%s\n" + " D. = Demuxing supported\n" + " .E = Muxing supported\n" + " --\n", device_only ? "Devices:" : "File formats:"); + last_name = "000"; + for (;;) { + int decode = 0; + int encode = 0; + const char *name = NULL; + const char *long_name = NULL; + + if (muxdemuxers !=SHOW_DEMUXERS) { + ofmt_opaque = NULL; + while ((ofmt = av_muxer_iterate(&ofmt_opaque))) { + is_dev = is_device(ofmt->priv_class); + if (!is_dev && device_only) + continue; + if ((!name || strcmp(ofmt->name, name) < 0) && + strcmp(ofmt->name, last_name) > 0) { + name = ofmt->name; + long_name = ofmt->long_name; + encode = 1; + } + } + } + if (muxdemuxers != SHOW_MUXERS) { + ifmt_opaque = NULL; + while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) { + is_dev = is_device(ifmt->priv_class); + if (!is_dev && device_only) + continue; + if ((!name || strcmp(ifmt->name, name) < 0) && + strcmp(ifmt->name, last_name) > 0) { + name = ifmt->name; + long_name = ifmt->long_name; + encode = 0; + } + if (name && strcmp(ifmt->name, name) == 0) + decode = 1; + } + } + if (!name) + break; + last_name = name; + + printf(" %c%c %-15s %s\n", + decode ? 'D' : ' ', + encode ? 'E' : ' ', + name, + long_name ? long_name:" "); + } + return 0; +} + +int show_formats(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT); +} + +int show_muxers(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS); +} + +int show_demuxers(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS); +} + +int show_devices(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT); +} + +int show_protocols(void *optctx, const char *opt, const char *arg) +{ + void *opaque = NULL; + const char *name; + + printf("Supported file protocols:\n" + "Input:\n"); + while ((name = avio_enum_protocols(&opaque, 0))) + printf(" %s\n", name); + printf("Output:\n"); + while ((name = avio_enum_protocols(&opaque, 1))) + printf(" %s\n", name); + return 0; +} + int show_colors(void *optctx, const char *opt, const char *arg) { const char *name; @@ -1808,439 +1001,286 @@ int show_layouts(void *optctx, const char *opt, const char *arg) printf("\n"); } } - return 0; -} - -int show_sample_fmts(void *optctx, const char *opt, const char *arg) -{ - int i; - char fmt_str[128]; - for (i = -1; i < AV_SAMPLE_FMT_NB; i++) - printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i)); - return 0; -} - -int show_dispositions(void *optctx, const char *opt, const char *arg) -{ - for (int i = 0; i < 32; i++) { - const char *str = av_disposition_to_string(1U << i); - if (str) - printf("%s\n", str); - } - return 0; -} - -static void show_help_codec(const char *name, int encoder) -{ - const AVCodecDescriptor *desc; - const AVCodec *codec; - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n"); - return; - } - - codec = encoder ? avcodec_find_encoder_by_name(name) : - avcodec_find_decoder_by_name(name); - - if (codec) - print_codec(codec); - else if ((desc = avcodec_descriptor_get_by_name(name))) { - void *iter = NULL; - int printed = 0; - - while ((codec = next_codec_for_id(desc->id, &iter, encoder))) { - printed = 1; - print_codec(codec); - } - - if (!printed) { - av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, " - "but no %s for it are available. FFmpeg might need to be " - "recompiled with additional external libraries.\n", - name, encoder ? "encoders" : "decoders"); - } - } else { - av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n", - name); - } -} - -static void show_help_demuxer(const char *name) -{ - const AVInputFormat *fmt = av_find_input_format(name); - - if (!fmt) { - av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); - return; - } - - printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name); - - if (fmt->extensions) - printf(" Common extensions: %s.\n", fmt->extensions); - - if (fmt->priv_class) - show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM); -} - -static void show_help_protocol(const char *name) -{ - const AVClass *proto_class; - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No protocol name specified.\n"); - return; - } - - proto_class = avio_protocol_get_class(name); - if (!proto_class) { - av_log(NULL, AV_LOG_ERROR, "Unknown protocol '%s'.\n", name); - return; - } - - show_help_children(proto_class, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM); -} - -static void show_help_muxer(const char *name) -{ - const AVCodecDescriptor *desc; - const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL); - - if (!fmt) { - av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); - return; - } - - printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name); - - if (fmt->extensions) - printf(" Common extensions: %s.\n", fmt->extensions); - if (fmt->mime_type) - printf(" Mime type: %s.\n", fmt->mime_type); - if (fmt->video_codec != AV_CODEC_ID_NONE && - (desc = avcodec_descriptor_get(fmt->video_codec))) { - printf(" Default video codec: %s.\n", desc->name); - } - if (fmt->audio_codec != AV_CODEC_ID_NONE && - (desc = avcodec_descriptor_get(fmt->audio_codec))) { - printf(" Default audio codec: %s.\n", desc->name); - } - if (fmt->subtitle_codec != AV_CODEC_ID_NONE && - (desc = avcodec_descriptor_get(fmt->subtitle_codec))) { - printf(" Default subtitle codec: %s.\n", desc->name); - } - - if (fmt->priv_class) - show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM); -} - -#if CONFIG_AVFILTER -static void show_help_filter(const char *name) -{ -#if CONFIG_AVFILTER - const AVFilter *f = avfilter_get_by_name(name); - int i, count; - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n"); - return; - } else if (!f) { - av_log(NULL, AV_LOG_ERROR, "Unknown filter '%s'.\n", name); - return; - } - - printf("Filter %s\n", f->name); - if (f->description) - printf(" %s\n", f->description); - - if (f->flags & AVFILTER_FLAG_SLICE_THREADS) - printf(" slice threading supported\n"); - - printf(" Inputs:\n"); - count = avfilter_filter_pad_count(f, 0); - for (i = 0; i < count; i++) { - printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), - av_get_media_type_string(avfilter_pad_get_type(f->inputs, i))); - } - if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS) - printf(" dynamic (depending on the options)\n"); - else if (!count) - printf(" none (source filter)\n"); - - printf(" Outputs:\n"); - count = avfilter_filter_pad_count(f, 1); - for (i = 0; i < count; i++) { - printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), - av_get_media_type_string(avfilter_pad_get_type(f->outputs, i))); - } - if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS) - printf(" dynamic (depending on the options)\n"); - else if (!count) - printf(" none (sink filter)\n"); - - if (f->priv_class) - show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | - AV_OPT_FLAG_AUDIO_PARAM); - if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) - printf("This filter has support for timeline through the 'enable' option.\n"); -#else - av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; " - "can not to satisfy request\n"); -#endif -} -#endif - -static void show_help_bsf(const char *name) -{ - const AVBitStreamFilter *bsf = av_bsf_get_by_name(name); - - if (!name) { - av_log(NULL, AV_LOG_ERROR, "No bitstream filter name specified.\n"); - return; - } else if (!bsf) { - av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name); - return; - } - - printf("Bit stream filter %s\n", bsf->name); - PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs", - AV_CODEC_ID_NONE, GET_CODEC_NAME); - if (bsf->priv_class) - show_help_children(bsf->priv_class, AV_OPT_FLAG_BSF_PARAM); -} - -int show_help(void *optctx, const char *opt, const char *arg) -{ - char *topic, *par; - av_log_set_callback(log_callback_help); - - topic = av_strdup(arg ? arg : ""); - if (!topic) - return AVERROR(ENOMEM); - par = strchr(topic, '='); - if (par) - *par++ = 0; - - if (!*topic) { - show_help_default(topic, par); - } else if (!strcmp(topic, "decoder")) { - show_help_codec(par, 0); - } else if (!strcmp(topic, "encoder")) { - show_help_codec(par, 1); - } else if (!strcmp(topic, "demuxer")) { - show_help_demuxer(par); - } else if (!strcmp(topic, "muxer")) { - show_help_muxer(par); - } else if (!strcmp(topic, "protocol")) { - show_help_protocol(par); -#if CONFIG_AVFILTER - } else if (!strcmp(topic, "filter")) { - show_help_filter(par); -#endif - } else if (!strcmp(topic, "bsf")) { - show_help_bsf(par); - } else { - show_help_default(topic, par); - } + return 0; +} - av_freep(&topic); +int show_sample_fmts(void *optctx, const char *opt, const char *arg) +{ + int i; + char fmt_str[128]; + for (i = -1; i < AV_SAMPLE_FMT_NB; i++) + printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i)); + return 0; +} + +int show_dispositions(void *optctx, const char *opt, const char *arg) +{ + for (int i = 0; i < 32; i++) { + const char *str = av_disposition_to_string(1U << i); + if (str) + printf("%s\n", str); + } return 0; } -int read_yesno(void) +int opt_cpuflags(void *optctx, const char *opt, const char *arg) { - int c = getchar(); - int yesno = (av_toupper(c) == 'Y'); + int ret; + unsigned flags = av_get_cpu_flags(); - while (c != '\n' && c != EOF) - c = getchar(); + if ((ret = av_parse_cpu_caps(&flags, arg)) < 0) + return ret; - return yesno; + av_force_cpu_flags(flags); + return 0; } -FILE *get_preset_file(char *filename, size_t filename_size, - const char *preset_name, int is_path, - const char *codec_name) +int opt_cpucount(void *optctx, const char *opt, const char *arg) { - FILE *f = NULL; - int i; - const char *base[3] = { getenv("FFMPEG_DATADIR"), - getenv("HOME"), - FFMPEG_DATADIR, }; + int ret; + int count; - if (is_path) { - av_strlcpy(filename, preset_name, filename_size); - f = fopen(filename, "r"); - } else { -#if HAVE_GETMODULEHANDLE && defined(_WIN32) - char datadir[MAX_PATH], *ls; - base[2] = NULL; - - if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1)) - { - for (ls = datadir; ls < datadir + strlen(datadir); ls++) - if (*ls == '\\') *ls = '/'; - - if (ls = strrchr(datadir, '/')) - { - *ls = 0; - strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir)); - base[2] = datadir; - } - } -#endif - for (i = 0; i < 3 && !f; i++) { - if (!base[i]) - continue; - snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], - i != 1 ? "" : "/.ffmpeg", preset_name); - f = fopen(filename, "r"); - if (!f && codec_name) { - snprintf(filename, filename_size, - "%s%s/%s-%s.ffpreset", - base[i], i != 1 ? "" : "/.ffmpeg", codec_name, - preset_name); - f = fopen(filename, "r"); - } - } + static const AVOption opts[] = { + {"count", NULL, 0, AV_OPT_TYPE_INT, { .i64 = -1}, -1, INT_MAX}, + {NULL}, + }; + static const AVClass class = { + .class_name = "cpucount", + .item_name = av_default_item_name, + .option = opts, + .version = LIBAVUTIL_VERSION_INT, + }; + const AVClass *pclass = &class; + + ret = av_opt_eval_int(&pclass, opts, arg, &count); + + if (!ret) { + av_cpu_force_count(count); } - return f; + return ret; } -int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) +static void expand_filename_template(AVBPrint *bp, const char *template, + struct tm *tm) { - int ret = avformat_match_stream_specifier(s, st, spec); - if (ret < 0) - av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec); - return ret; + int c; + + while ((c = *(template++))) { + if (c == '%') { + if (!(c = *(template++))) + break; + switch (c) { + case 'p': + av_bprintf(bp, "%s", program_name); + break; + case 't': + av_bprintf(bp, "%04d%02d%02d-%02d%02d%02d", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + break; + case '%': + av_bprint_chars(bp, c, 1); + break; + } + } else { + av_bprint_chars(bp, c, 1); + } + } } -AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, - AVFormatContext *s, AVStream *st, const AVCodec *codec) +static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl) { - AVDictionary *ret = NULL; - const AVDictionaryEntry *t = NULL; - int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM - : AV_OPT_FLAG_DECODING_PARAM; - char prefix = 0; - const AVClass *cc = avcodec_get_class(); - - if (!codec) - codec = s->oformat ? avcodec_find_encoder(codec_id) - : avcodec_find_decoder(codec_id); - - switch (st->codecpar->codec_type) { - case AVMEDIA_TYPE_VIDEO: - prefix = 'v'; - flags |= AV_OPT_FLAG_VIDEO_PARAM; - break; - case AVMEDIA_TYPE_AUDIO: - prefix = 'a'; - flags |= AV_OPT_FLAG_AUDIO_PARAM; - break; - case AVMEDIA_TYPE_SUBTITLE: - prefix = 's'; - flags |= AV_OPT_FLAG_SUBTITLE_PARAM; - break; + va_list vl2; + char line[1024]; + static int print_prefix = 1; + + va_copy(vl2, vl); + av_log_default_callback(ptr, level, fmt, vl); + av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix); + va_end(vl2); + if (report_file_level >= level) { + fputs(line, report_file); + fflush(report_file); } +} + +int init_report(const char *env, FILE **file) +{ + char *filename_template = NULL; + char *key, *val; + int ret, count = 0; + int prog_loglevel, envlevel = 0; + time_t now; + struct tm *tm; + AVBPrint filename; - while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) { - const AVClass *priv_class; - char *p = strchr(t->key, ':'); + if (report_file) /* already opened */ + return 0; + time(&now); + tm = localtime(&now); - /* check stream specification in opt name */ - if (p) - switch (check_stream_specifier(s, st, p + 1)) { - case 1: *p = 0; break; - case 0: continue; - default: exit_program(1); + while (env && *env) { + if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) { + if (count) + av_log(NULL, AV_LOG_ERROR, + "Failed to parse FFREPORT environment variable: %s\n", + av_err2str(ret)); + break; + } + if (*env) + env++; + count++; + if (!strcmp(key, "file")) { + av_free(filename_template); + filename_template = val; + val = NULL; + } else if (!strcmp(key, "level")) { + char *tail; + report_file_level = strtol(val, &tail, 10); + if (*tail) { + av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n"); + exit_program(1); } + envlevel = 1; + } else { + av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key); + } + av_free(val); + av_free(key); + } - if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) || - !codec || - ((priv_class = codec->priv_class) && - av_opt_find(&priv_class, t->key, NULL, flags, - AV_OPT_SEARCH_FAKE_OBJ))) - av_dict_set(&ret, t->key, t->value, 0); - else if (t->key[0] == prefix && - av_opt_find(&cc, t->key + 1, NULL, flags, - AV_OPT_SEARCH_FAKE_OBJ)) - av_dict_set(&ret, t->key + 1, t->value, 0); - - if (p) - *p = ':'; + av_bprint_init(&filename, 0, AV_BPRINT_SIZE_AUTOMATIC); + expand_filename_template(&filename, + av_x_if_null(filename_template, "%p-%t.log"), tm); + av_free(filename_template); + if (!av_bprint_is_complete(&filename)) { + av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n"); + return AVERROR(ENOMEM); } - return ret; -} -AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, - AVDictionary *codec_opts) -{ - int i; - AVDictionary **opts; - - if (!s->nb_streams) - return NULL; - opts = av_calloc(s->nb_streams, sizeof(*opts)); - if (!opts) { - av_log(NULL, AV_LOG_ERROR, - "Could not alloc memory for stream options.\n"); - exit_program(1); + prog_loglevel = av_log_get_level(); + if (!envlevel) + report_file_level = FFMAX(report_file_level, prog_loglevel); + + report_file = fopen(filename.str, "w"); + if (!report_file) { + int ret = AVERROR(errno); + av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n", + filename.str, strerror(errno)); + return ret; } - for (i = 0; i < s->nb_streams; i++) - opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, - s, s->streams[i], NULL); - return opts; + av_log_set_callback(log_callback_report); + av_log(NULL, AV_LOG_INFO, + "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n" + "Report written to \"%s\"\n" + "Log level: %d\n", + program_name, + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, + filename.str, report_file_level); + av_bprint_finalize(&filename, NULL); + + if (file) + *file = report_file; + + return 0; } -void *grow_array(void *array, int elem_size, int *size, int new_size) +int opt_report(void *optctx, const char *opt, const char *arg) { - if (new_size >= INT_MAX / elem_size) { - av_log(NULL, AV_LOG_ERROR, "Array too big.\n"); - exit_program(1); - } - if (*size < new_size) { - uint8_t *tmp = av_realloc_array(array, new_size, elem_size); - if (!tmp) { - av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n"); - exit_program(1); - } - memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size); - *size = new_size; - return tmp; - } - return array; + return init_report(NULL, NULL); } -void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems) +int opt_max_alloc(void *optctx, const char *opt, const char *arg) { - void *new_elem; + char *tail; + size_t max; - if (!(new_elem = av_mallocz(elem_size)) || - av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0) { - av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n"); + max = strtol(arg, &tail, 10); + if (*tail) { + av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg); exit_program(1); } - return new_elem; + av_max_alloc(max); + return 0; } -double get_rotation(int32_t *displaymatrix) +int opt_loglevel(void *optctx, const char *opt, const char *arg) { - double theta = 0; - if (displaymatrix) - theta = -round(av_display_rotation_get((int32_t*) displaymatrix)); + const struct { const char *name; int level; } log_levels[] = { + { "quiet" , AV_LOG_QUIET }, + { "panic" , AV_LOG_PANIC }, + { "fatal" , AV_LOG_FATAL }, + { "error" , AV_LOG_ERROR }, + { "warning", AV_LOG_WARNING }, + { "info" , AV_LOG_INFO }, + { "verbose", AV_LOG_VERBOSE }, + { "debug" , AV_LOG_DEBUG }, + { "trace" , AV_LOG_TRACE }, + }; + const char *token; + char *tail; + int flags = av_log_get_flags(); + int level = av_log_get_level(); + int cmd, i = 0; + + av_assert0(arg); + while (*arg) { + token = arg; + if (*token == '+' || *token == '-') { + cmd = *token++; + } else { + cmd = 0; + } + if (!i && !cmd) { + flags = 0; /* missing relative prefix, build absolute value */ + } + if (av_strstart(token, "repeat", &arg)) { + if (cmd == '-') { + flags |= AV_LOG_SKIP_REPEATED; + } else { + flags &= ~AV_LOG_SKIP_REPEATED; + } + } else if (av_strstart(token, "level", &arg)) { + if (cmd == '-') { + flags &= ~AV_LOG_PRINT_LEVEL; + } else { + flags |= AV_LOG_PRINT_LEVEL; + } + } else { + break; + } + i++; + } + if (!*arg) { + goto end; + } else if (*arg == '+') { + arg++; + } else if (!i) { + flags = av_log_get_flags(); /* level value without prefix, reset flags */ + } - theta -= 360*floor(theta/360 + 0.9/360); + for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { + if (!strcmp(log_levels[i].name, arg)) { + level = log_levels[i].level; + goto end; + } + } - if (fabs(theta - 90*round(theta/90)) > 2) - av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n" - "If you want to help, upload a sample " - "of this file to https://streams.videolan.org/upload/ " - "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)"); + level = strtol(arg, &tail, 10); + if (*tail) { + av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". " + "Possible levels are numbers or:\n", arg); + for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) + av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name); + exit_program(1); + } - return theta; +end: + av_log_set_flags(flags); + av_log_set_level(level); + return 0; } #if CONFIG_AVDEVICE @@ -2264,6 +1304,7 @@ static void print_device_list(const AVDeviceInfoList *device_list) printf(")\n"); } } + static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts) { int ret; @@ -2401,5 +1442,4 @@ int show_sinks(void *optctx, const char *opt, const char *arg) av_log_set_level(error_level); return ret; } - -#endif +#endif /* CONFIG_AVDEVICE */ diff --git a/fftools/opt_common.h b/fftools/opt_common.h new file mode 100644 index 0000000000..ea1d16e769 --- /dev/null +++ b/fftools/opt_common.h @@ -0,0 +1,231 @@ +/* + * Option handlers shared between the tools. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef FFTOOLS_OPT_COMMON_H +#define FFTOOLS_OPT_COMMON_H + +#include "config.h" + +#include "cmdutils.h" + +#if CONFIG_AVDEVICE +/** + * Print a listing containing autodetected sinks of the output device. + * Device name with options may be passed as an argument to limit results. + */ +int show_sinks(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing autodetected sources of the input device. + * Device name with options may be passed as an argument to limit results. + */ +int show_sources(void *optctx, const char *opt, const char *arg); +#endif + +#if CONFIG_AVDEVICE +#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \ + { "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \ + "list sources of the input device", "device" }, \ + { "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \ + "list sinks of the output device", "device" }, \ + +#else +#define CMDUTILS_COMMON_OPTIONS_AVDEVICE +#endif + +/** + * Print the license of the program to stdout. The license depends on + * the license of the libraries compiled into the program. + * This option processing function does not utilize the arguments. + */ +int show_license(void *optctx, const char *opt, const char *arg); + +/** + * Generic -h handler common to all fftools. + */ +int show_help(void *optctx, const char *opt, const char *arg); + +/** + * Print the version of the program to stdout. The version message + * depends on the current versions of the repository and of the libav* + * libraries. + * This option processing function does not utilize the arguments. + */ +int show_version(void *optctx, const char *opt, const char *arg); + +/** + * Print the build configuration of the program to stdout. The contents + * depend on the definition of FFMPEG_CONFIGURATION. + * This option processing function does not utilize the arguments. + */ +int show_buildconf(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the formats supported by the + * program (including devices). + * This option processing function does not utilize the arguments. + */ +int show_formats(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the muxers supported by the + * program (including devices). + * This option processing function does not utilize the arguments. + */ +int show_muxers(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the demuxer supported by the + * program (including devices). + * This option processing function does not utilize the arguments. + */ +int show_demuxers(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the devices supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_devices(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the codecs supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_codecs(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the decoders supported by the + * program. + */ +int show_decoders(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the encoders supported by the + * program. + */ +int show_encoders(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the bit stream filters supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_bsfs(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the protocols supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_protocols(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the filters supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_filters(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the pixel formats supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_pix_fmts(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the standard channel layouts supported by + * the program. + * This option processing function does not utilize the arguments. + */ +int show_layouts(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the sample formats supported by the + * program. + */ +int show_sample_fmts(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all supported stream dispositions. + */ +int show_dispositions(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the color names and values recognized + * by the program. + */ +int show_colors(void *optctx, const char *opt, const char *arg); + +/** + * Set the libav* libraries log level. + */ +int opt_loglevel(void *optctx, const char *opt, const char *arg); + +int opt_report(void *optctx, const char *opt, const char *arg); +int init_report(const char *env, FILE **file); + +int opt_max_alloc(void *optctx, const char *opt, const char *arg); + +/** + * Override the cpuflags. + */ +int opt_cpuflags(void *optctx, const char *opt, const char *arg); + +/** + * Override the cpucount. + */ +int opt_cpucount(void *optctx, const char *opt, const char *arg); + +#define CMDUTILS_COMMON_OPTIONS \ + { "L", OPT_EXIT, { .func_arg = show_license }, "show license" }, \ + { "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ + { "?", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ + { "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ + { "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \ + { "version", OPT_EXIT, { .func_arg = show_version }, "show version" }, \ + { "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" }, \ + { "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" }, \ + { "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \ + { "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \ + { "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \ + { "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \ + { "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" }, \ + { "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" }, \ + { "bsfs", OPT_EXIT, { .func_arg = show_bsfs }, "show available bit stream filters" }, \ + { "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" }, \ + { "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" }, \ + { "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" }, \ + { "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" }, \ + { "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" }, \ + { "dispositions", OPT_EXIT, { .func_arg = show_dispositions}, "show available stream dispositions" }, \ + { "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" }, \ + { "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \ + { "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \ + { "report", 0, { .func_arg = opt_report }, "generate a report" }, \ + { "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" }, \ + { "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, \ + { "cpucount", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpucount }, "force specific cpu count", "count" }, \ + { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, \ + CMDUTILS_COMMON_OPTIONS_AVDEVICE \ + +#endif /* FFTOOLS_OPT_COMMON_H */ 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 */ From patchwork Tue Mar 15 09:05:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34745 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837212nkb; Tue, 15 Mar 2022 02:06:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0eH/9aWnlIqJQ3iSMF2hFXHxxs/NhPNmF+FCuW4PTI9UyIgLa/xIRChTXLV8icCXgX8Oc X-Received: by 2002:a05:6402:4249:b0:418:cda3:f57c with SMTP id g9-20020a056402424900b00418cda3f57cmr810182edb.193.1647335186376; Tue, 15 Mar 2022 02:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335186; cv=none; d=google.com; s=arc-20160816; b=vz7oz6uRpTTyzBBNc5CH++FlqVgTmd0Okao6wUKebaVtV6EguxxUSp8ci7Mu21C1Xm MMXqKyvjpEb+zR9+ukue8FXw05BP0M/FDzG4LnZ7YnUXokAu/2AykzivHPkidUQ45sne /d7Y+P+vr+kAaMfLnVi7dzaACCHQ6oVPx68Xtp8/P7+Vj79NPrAFaWQoBtufKtVpY6DW WO8xL//k9Fkc+QDJQ1KMGRJAmMQqVu3KljZxNytwFsN7Gku5AonIfQzZ0r1ZeqQapWVi jvScbYFP+HSOCAs4IXUi7DePxzDLEwQvIQw7xb1BBcg9NHmvlH12xjN0a+LManF+Sf15 H7kw== 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=A1VjKENWHjW0OqQXnt2B8c//qqhYdsIKUA/OSzgN+po=; b=vopXnqhoVahzT+3ui9NdWPWGpdkcPJ/MdURnKxFTf+ALgij7EQR+E/xgJbsHSJqUxZ E3Fe/vNUCLmxpz2Fbdl2RXzRt8TJP4kWErcSkHRL4YskXA2N2bQAi3ja+XHHDDv6Ra9+ GocWVAYJsW3cW2J8wbwDtQvZnx31arxrKMdO1DQMeJUrnyq2Wzy3VRQpfxKcLq70eQf8 3rdtiXro5LilIM4kd+TPlZh12f6begMvW9RujBIMxM7Id9RyirGlcWEPYf5dflJ7KWOT Q3hePcYCYpMx8cpvTXPJNuAbBwL3ttRxEjC5CU9EwuZNAitLWn6J72SBr59whvAxOfq7 Vs/A== 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 z18-20020a05640235d200b00418763cdf2asi4890983edc.4.2022.03.15.02.06.26; Tue, 15 Mar 2022 02:06:26 -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 8BF5D68B0B9; Tue, 15 Mar 2022 11:05:57 +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 B534C68B148 for ; Tue, 15 Mar 2022 11:05:49 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5EE452400F5 for ; Tue, 15 Mar 2022 10:05:49 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id rapb51M8Lffv for ; Tue, 15 Mar 2022 10:05:48 +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 92ABE2404FE for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 1D1963A0763; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:28 +0100 Message-Id: <20220315090532.27295-6-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 06/10] fftools/ffmpeg: drop mistakenly added empty line 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: ivGZYcCqd8Kk --- fftools/ffmpeg_opt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 778e02c39e..5f08cab908 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1,4 +1,3 @@ - /* * ffmpeg option parsing * From patchwork Tue Mar 15 09:05:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34749 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837643nkb; Tue, 15 Mar 2022 02:07:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo9aUUgf8yW6F6PZ1/Ow5Lw0BMxYZy1ljYKViBqJlVh6by3fCi28XXnXLm/iSJGsK84tOd X-Received: by 2002:a17:906:1ece:b0:6ce:e14:6d92 with SMTP id m14-20020a1709061ece00b006ce0e146d92mr22076773ejj.408.1647335231051; Tue, 15 Mar 2022 02:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335231; cv=none; d=google.com; s=arc-20160816; b=UCCEohFkLqpSRbKBESNxamj/RRpa2vH5+dqYujqrltdG6zBKmJa3n0mfUbpA2b6LTV xvK/FCvZM0U7s1o4jy0+G7kRScASVS/oLXBVvkPpkBd74lSElPFDPtqcVGKoMt872DA/ NolKIFIlmV/USKdS0THP+GQe6eBzpPNnSfjoCJGG1R5zJFwAGXSsin5lKRBKMqt3UcBv r+jY1/Kcfz0oO8WyygMxFob4ot5yckgF3/Udd9Yx9OPHHunU9rkrd6TikvZBKD4KSKI+ G93T1BXxsj8rHsEaIQMMCqxZdv4tM4LD7orjxjIh+WYOPqDKjM+gpqkKii4twoPZEne6 Urjg== 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=0lFnP7trUhFpxaheBrHioZhToig0DEVnFGEPI9bCT0c=; b=G8JkxCPSvlEbTWiTN7YG+LLsqONhefFljbnCrexEegwmZdasI4aByRHpfQox/Mr0ea Vyp7MQwXUyvEb6XEp2Kx4NJDGLnYa1/SwepPS1lP9gT0gIY3LasAJHDpaJwwstEYOsc+ 3QBXD3/2wxVKwZrV1QL8OUELbgPuiw04+Su/LVsPqBE008fAGdpbTMqvjIaSnOKAQ7CI iByFLRbDXSIiLFcEznuLzgq3M3DAbqtU7W/RLZwxqKSPwmh4mXeQqwDLA0yocv3Qly7B 9VOTwxO0W84AiQdMAj4rTdsi6R1YIjfzs5psgyWajIScHre+UfeVjbZ1Pp9lXjrJlBvw SBuw== 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 h22-20020a056402281600b0041865d2c996si5792109ede.212.2022.03.15.02.07.10; Tue, 15 Mar 2022 02:07:11 -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 4A90C68B212; Tue, 15 Mar 2022 11:06:02 +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 F3AA368B1E6 for ; Tue, 15 Mar 2022 11:05:53 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 50B2924017C for ; Tue, 15 Mar 2022 10:05:52 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id QEwZL053NIbD for ; Tue, 15 Mar 2022 10:05:51 +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 A7F16240507 for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 20BB73A07AE; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:29 +0100 Message-Id: <20220315090532.27295-7-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 07/10] fftools/ffplay: drop options deprecated since 2011 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: PYF6G8RAwMAB --- doc/ffplay.texi | 8 -------- fftools/ffplay.c | 14 -------------- 2 files changed, 22 deletions(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index e187b5852e..0f090128f2 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -34,10 +34,6 @@ various FFmpeg APIs. Force displayed width. @item -y @var{height} Force displayed height. -@item -s @var{size} -Set frame size (WxH or abbreviation), needed for videos which do -not contain a header with the frame size like raw YUV. This option -has been deprecated in favor of private options, try -video_size. @item -fs Start in fullscreen mode. @item -an @@ -126,10 +122,6 @@ Read @var{input_url}. @section Advanced options @table @option -@item -pix_fmt @var{format} -Set pixel format. -This option has been deprecated in favor of private options, try -pixel_format. - @item -stats Print several playback statistics, in particular show the stream duration, the codec parameters, the current position in the stream and diff --git a/fftools/ffplay.c b/fftools/ffplay.c index c929ce32ed..38df91f72e 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -3471,12 +3471,6 @@ static void event_loop(VideoState *cur_stream) } } -static int opt_frame_size(void *optctx, const char *opt, const char *arg) -{ - av_log(NULL, AV_LOG_WARNING, "Option -s is deprecated, use -video_size.\n"); - return opt_default(NULL, "video_size", arg); -} - static int opt_width(void *optctx, const char *opt, const char *arg) { screen_width = parse_number_or_die(opt, arg, OPT_INT64, 1, INT_MAX); @@ -3499,12 +3493,6 @@ static int opt_format(void *optctx, const char *opt, const char *arg) return 0; } -static int opt_frame_pix_fmt(void *optctx, const char *opt, const char *arg) -{ - av_log(NULL, AV_LOG_WARNING, "Option -pix_fmt is deprecated, use -pixel_format.\n"); - return opt_default(NULL, "pixel_format", arg); -} - static int opt_sync(void *optctx, const char *opt, const char *arg) { if (!strcmp(arg, "audio")) @@ -3582,7 +3570,6 @@ static const OptionDef options[] = { CMDUTILS_COMMON_OPTIONS { "x", HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" }, { "y", HAS_ARG, { .func_arg = opt_height }, "force displayed height", "height" }, - { "s", HAS_ARG | OPT_VIDEO, { .func_arg = opt_frame_size }, "set frame size (WxH or abbreviation)", "size" }, { "fs", OPT_BOOL, { &is_full_screen }, "force full screen" }, { "an", OPT_BOOL, { &audio_disable }, "disable audio" }, { "vn", OPT_BOOL, { &video_disable }, "disable video" }, @@ -3599,7 +3586,6 @@ static const OptionDef options[] = { { "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" }, { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" }, { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" }, - { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, { "stats", OPT_BOOL | OPT_EXPERT, { &show_status }, "show status", "" }, { "fast", OPT_BOOL | OPT_EXPERT, { &fast }, "non spec compliant optimizations", "" }, { "genpts", OPT_BOOL | OPT_EXPERT, { &genpts }, "generate pts", "" }, From patchwork Tue Mar 15 09:05:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34747 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837411nkb; Tue, 15 Mar 2022 02:06:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlXgjS1rsBP8LQvQOrvfG0nGTR5VU8ZQEFvly5Tpl5qGMyQF4/9v9LBMsikw41KYp0fbx2 X-Received: by 2002:a17:906:a148:b0:6cd:50c7:8d4d with SMTP id bu8-20020a170906a14800b006cd50c78d4dmr21524139ejb.641.1647335207669; Tue, 15 Mar 2022 02:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335207; cv=none; d=google.com; s=arc-20160816; b=Iok7qe1+/eg+bfKJPVU5UG/lvlDJe5Nsz5NGrKBWDM9nP4KBwE7QkszaY1OjWNAqOr fMR+lVIBi0afGmb06wREbw91WAVheKQzEmO32yyxz3P+xKGO4W8sghSyTm7ug2wn01dz XpqOAk7BRnxn/jchF9wA1iOB9Vpe28BWeiWJ+mgw5btFJT7p+M/n4IcjusuxH10YiQ0m dYMpe3brRdneiOhDVJ6BiqapmS77keSMr5Piu6ZFPpZSPZjipBPOFn58Q8OX2JfcWpiV AcPVHYaGFq9DV1bP8eFpCV4acFnwMr8PXi3Vmj7lYPgfWtRWS6Yo3ZS/lw6xgTiZfPe8 KfBg== 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=tMOz3v7jeXcJ+IckN2f3fet2ptOdYrQdIHCz+btzmjs=; b=VCmgzOuG+vioWpnuzGxFsp4qDrkloKFQ9hxAqPwCxJGhFbBVSo+GvDfzCfoVZJNEQo 6P/piLLqk/NvLAe9JhL/kZ3B7cnvL/chCmPqK9mrInvocceTzWwqiC6XTnGdsRItN0X1 kDE5VR//t/8qToUVShJRw9xKqz3+IAJOrRNqasa3ahypd4UZzjTIKEu7UoiWfcgV5TDM AAk2vJutHfVAEpNuvv+BDxgzA/p820xL5ryjNaGpNa7ixEI2YY3ne5alGxDeR/fsXObg IeSWmQvqQMEB0rtj6rxNOpTRrSPqO4F86O3h9lmf5MOfBdNmgUerqYSmkaqWG5Mzek19 UapA== 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 s1-20020aa7d781000000b0041610f7b1d3si10388518edq.593.2022.03.15.02.06.47; Tue, 15 Mar 2022 02:06:47 -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 5D19868B1E6; Tue, 15 Mar 2022 11:06:00 +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 2458A68B1BA for ; Tue, 15 Mar 2022 11:05:53 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 885B3240506 for ; Tue, 15 Mar 2022 10:05:51 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id GM4q-7wcREhM for ; Tue, 15 Mar 2022 10:05:51 +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 A995924050B for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 24A3C3A0836; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:30 +0100 Message-Id: <20220315090532.27295-8-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 08/10] fftools/ffprobe; drop -show_format_entry 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: XNQSzUw/iTpL Deprecated since 2012. --- fftools/ffprobe.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 42032ee9d6..c4e962389f 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3618,22 +3618,6 @@ static int opt_show_entries(void *optctx, const char *opt, const char *arg) return ret; } -static int opt_show_format_entry(void *optctx, const char *opt, const char *arg) -{ - char *buf = av_asprintf("format=%s", arg); - int ret; - - if (!buf) - return AVERROR(ENOMEM); - - av_log(NULL, AV_LOG_WARNING, - "Option '%s' is deprecated, use '-show_entries format=%s' instead\n", - opt, arg); - ret = opt_show_entries(optctx, opt, buf); - av_free(buf); - return ret; -} - static void opt_input_file(void *optctx, const char *arg) { if (input_filename) { @@ -3894,8 +3878,6 @@ static const OptionDef real_options[] = { { "show_error", 0, { .func_arg = &opt_show_error }, "show probing error" }, { "show_format", 0, { .func_arg = &opt_show_format }, "show format/container info" }, { "show_frames", 0, { .func_arg = &opt_show_frames }, "show frames info" }, - { "show_format_entry", HAS_ARG, {.func_arg = opt_show_format_entry}, - "show a particular entry from the format/container info", "entry" }, { "show_entries", HAS_ARG, {.func_arg = opt_show_entries}, "show a set of specified entries", "entry_list" }, #if HAVE_THREADS From patchwork Tue Mar 15 09:05:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34750 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837738nkb; Tue, 15 Mar 2022 02:07:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4o5MmEk6liYQeOABmctNdheaTaqBpJbAOGCZWG0ju+yY0i2T1eIIJmOoobVqFFkbbA6Nb X-Received: by 2002:a17:906:b1d0:b0:6cf:7f39:50e0 with SMTP id bv16-20020a170906b1d000b006cf7f3950e0mr22573500ejb.760.1647335240958; Tue, 15 Mar 2022 02:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335240; cv=none; d=google.com; s=arc-20160816; b=VWdhtjPrySmvaN+9TfT8ZcPYo5W+QwmRJ8EtFMJPV1EQ9rxwKV6UvWiNBZAXA5ke/g 4n3cQtpk4zNedb/Sro6G+DBPVBtrQbBNR3b6WsOfu9+EwBfdVqPpSm7S2ABXl2r//EsQ IU/9/hS/3eublt+gGv89aPBjMGNLpxcdOgIY69ymZRPfqOVdySFl9Nq38ydAmNcsoO1g x9d94XrB2yvJLXudSJNtcua/U9XYIixSqqjAAsqWVq+XDBuBSdmeO+R7XEXog9h/T0k2 vEQKuQjKTB2E691lZ4fEkAuR/kwNNm9U/JNpqSyv62VzgUwjYj/4u6gmAK0jPLJTpONE 6B0Q== 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=jG7L8FFdTrh+Ohcb8wBCA/tU5l4t49su7864OC4NV8k=; b=JU47NfGBFs3IPw1fiSYt2018MsNi01GJLme0wIAMejrgnm3RCSHGaARMWboU9NMz1u +8OoZFNZErFO/ohLzWhOVVA5JEdcDa9fGbUkGc2avQPKhlYVAr5yG+C85sX7EY8nAOz1 9kNu6ZrdTUq/lO4z3wXnAW52TdgHsE3x5bwrwM82YH8Epeg7nUB2DummWfHNi9bdRpqz XqVwESe4bV8tAVhgcgZdLPZH7WG6n37Yz/MW+OcsYfIBEPpmXi3BEGDmARYkOKBHGze8 j0MZaylJ2l2BM/U2+4ecrqTMX2r83plAraRmZYqmmCckgW0QouO8AYQFXKPsGL8rXTd8 6fJQ== 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 lm23-20020a170906981700b006df5ed0578dsi202499ejb.36.2022.03.15.02.07.20; Tue, 15 Mar 2022 02:07:20 -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 50F7C68B17E; Tue, 15 Mar 2022 11:06:03 +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 0CF2268B1E7 for ; Tue, 15 Mar 2022 11:05:54 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 98BE6240507 for ; Tue, 15 Mar 2022 10:05:52 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id dbf-96ALZMor for ; Tue, 15 Mar 2022 10:05:51 +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 B5C78240511 for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 284B73A0837; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:31 +0100 Message-Id: <20220315090532.27295-9-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 09/10] fftools: drop the fake "default" option from ffplay/ffprobe 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: KhLIqZ/F45+G It tries to process any unhandled options as AVOptions. Handle this directly in cmdutils.c, without resorting to a confusing fake option definition (which is currently visible to the users in -help output). --- fftools/cmdutils.c | 8 +++++++- fftools/ffplay.c | 1 - fftools/ffprobe.c | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index e5684fa840..a52c87dfaf 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -302,6 +302,12 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options) { + static const OptionDef opt_avoptions = { + .name = "AVOption passthrough", + .flags = HAS_ARG, + .u.func_arg = opt_default, + }; + const OptionDef *po; int ret; @@ -315,7 +321,7 @@ int parse_option(void *optctx, const char *opt, const char *arg, arg = "1"; if (!po->name) - po = find_option(options, "default"); + po = &opt_avoptions; if (!po->name) { av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt); return AVERROR(EINVAL); diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 38df91f72e..59fba0e169 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -3607,7 +3607,6 @@ static const OptionDef options[] = { #endif { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" }, { "showmode", HAS_ARG, { .func_arg = opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" }, - { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { .func_arg = opt_default }, "generic catch all option", "" }, { "i", OPT_BOOL, { &dummy}, "read specified file", "input_file"}, { "codec", HAS_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" }, { "acodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &audio_codec_name }, "force audio decoder", "decoder_name" }, diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index c4e962389f..db8930f226 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3898,7 +3898,6 @@ static const OptionDef real_options[] = { { "private", OPT_BOOL, { &show_private_data }, "same as show_private_data" }, { "bitexact", OPT_BOOL, {&do_bitexact}, "force bitexact output" }, { "read_intervals", HAS_ARG, {.func_arg = opt_read_intervals}, "set read intervals", "read_intervals" }, - { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default}, "generic catch all option", "" }, { "i", HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", "input_file"}, { "print_filename", HAS_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"}, { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info }, From patchwork Tue Mar 15 09:05:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34751 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp2837812nkb; Tue, 15 Mar 2022 02:07:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ9nOATDu9qsq1et0V+P8l3Ryskv3FDmwoTjQZoo9fKG9Ik+x3jv0j+CyqQ5riDFnMRmza X-Received: by 2002:a17:907:7254:b0:6db:ad8f:27b4 with SMTP id ds20-20020a170907725400b006dbad8f27b4mr15362741ejc.599.1647335250383; Tue, 15 Mar 2022 02:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647335250; cv=none; d=google.com; s=arc-20160816; b=so2Ic2zBK8d30aC3Tu7yATLx13s2+GUk1TMUkZ8UmTb2+aC+HqkC9SDzJiuFoOSPMH XwWAMxIJQr+RWTP+CPxKoLYQpO3IZHgpkUrXiqpyO/GMTuyabf2nE43dlaIO6Bjkb/Kh EJQEqUQWxCPXJNoboWaOVu2QUK9iuIv1Ml3DO8BKQIw4RgX0fwfqdwxTUna9JfmIYg/o 9COsqcs3fMQDwGoeZbJpk99kOi2xeu/CrqmD+vUJ0Bxzuv1/HnZKwffH053LGB3JyrsQ CqW+AzSxq4c/thOeqXgHZGBESmLqqdb4K+PMCGFGfcdCO9gZH0NAQLZ0QlfWTQwjBdB3 2taA== 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=khNJGLDLQcaHj+DUzoShnuFlyS0js8EjuUWuwYCd0Ko=; b=NgfKr7QCHQAbp+vG0z+kNRnehz2S+bBd/aSFRi3Ptk5xQaSDqEHzXsezqn+RE1xkiL 5MA9g2Gef2nuCAvTRKXbPA9OQZa83PKz0ixroqMGet++vTDb0trIeJHwCzweNndECMQX Uune2DeKWrjzNdjLnFU7rI9lRlABzaslj8FnUd/kS6NUtr5+JuKTodd1G7monDzrzmHq UqWK3d03h8pbw5iEnYUAbI5YrqigA3YUaGqf6+uedGjrELe0ODxRQNkcqkFcyerzfPow 7dFlKvFvB/d01z5sYUUTCIM0Jd5Z1ZRAvN+ZvA1zCRD94CLb8Itjz6rqoS/o5rAn7o5L erng== 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 ka16-20020a170907991000b006a7091b99b3si9844291ejc.794.2022.03.15.02.07.30; Tue, 15 Mar 2022 02:07:30 -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 2DA8768B229; Tue, 15 Mar 2022 11:06:04 +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 8936E68B1C1 for ; Tue, 15 Mar 2022 11:05:54 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2A0CD240511 for ; Tue, 15 Mar 2022 10:05:53 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id fRZWQb2Q46jt for ; Tue, 15 Mar 2022 10:05:52 +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 B6C2B240512 for ; Tue, 15 Mar 2022 10:05:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2BEA23A0984; Tue, 15 Mar 2022 10:05:46 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Mar 2022 10:05:32 +0100 Message-Id: <20220315090532.27295-10-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 10/10] fftools/cmdutils: drop redundant code 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: rCkW+J/8zKWM It allocates a dummy sws/swr context and tries setting options on it, apparently to check if they are valid. This is redundant, since the options will be checked if/when they are later applied on a context that is actually used for conversion. --- fftools/cmdutils.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index a52c87dfaf..6e5ef1beb4 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -539,20 +539,12 @@ int opt_default(void *optctx, const char *opt, const char *arg) #if CONFIG_SWSCALE if (!consumed && (o = opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { - struct SwsContext *sws = sws_alloc_context(); - int ret = av_opt_set(sws, opt, arg, 0); - sws_freeContext(sws); if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") || !strcmp(opt, "dstw") || !strcmp(opt, "dsth") || !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) { av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n"); return AVERROR(EINVAL); } - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); - return ret; - } - av_dict_set(&sws_dict, opt, arg, FLAGS); consumed = 1; @@ -566,13 +558,6 @@ int opt_default(void *optctx, const char *opt, const char *arg) #if CONFIG_SWRESAMPLE if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { - struct SwrContext *swr = swr_alloc(); - int ret = av_opt_set(swr, opt, arg, 0); - swr_free(&swr); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); - return ret; - } av_dict_set(&swr_opts, opt, arg, FLAGS); consumed = 1; }