From patchwork Mon Sep 19 09:45:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38041 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1112737pzh; Mon, 19 Sep 2022 02:46:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70feBy4lrAnZ/DudCn1cN/HqVfgPIxIOFRKEmaAgqJkqUwKHn9+DRAm3vESaKdf7sJADE9 X-Received: by 2002:aa7:c585:0:b0:453:e1c6:7dc6 with SMTP id g5-20020aa7c585000000b00453e1c67dc6mr5272247edq.245.1663580788593; Mon, 19 Sep 2022 02:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663580788; cv=none; d=google.com; s=arc-20160816; b=Xc3qlyJR8H6O7ZCJ3Rf3UjUY+Yrdg4WPmmMmY4UfkoIgYNIwDTM7lvpj76qd+XQhqm /plehbKgpkprl7nTFaxdMsNKo6qwiniBRcseQVUJwwJ2rN2Xj+sBXwX+E/6G0vAALio+ pprtEzqEKAhHTkwOvTZX7Zm6X81/Ua2jLSNepwjN086vgtSOsAbRl9plYJzY9+HIFqAJ AndOenK8NSBMRS2wBLKI9VUrQwOPaQk4xgE/brMVphRMxnpqjaFYS/5Ri2W/FioDkomA CkZ3M/krPH+KmBV597MRx3Ur7QgamG4z1HjIu4Q3b0eK7lfvL2t1HpC36T6hIBKjaVIJ B4Ow== 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:dkim-signature:delivered-to; bh=SBL0OKas5mbVFLM0ObqvpNifBpz1Jsj+tFsV0sCh8zA=; b=KOR903y9u0V8U3YTo7iY3aa3IQn6JtsjV0FFPx/54icFvEpVr+N8IVJxiu5o2GP7nO VWd+oKBoF0VfvCzizz434tQ3nuW5X2EFGWeBlBKX4NfTL1/37oxQWDuy/AbzZcWe5BqH j+sKDZ4WjuCYE/7crEItTpPmfCt69kAML0ycCzNfBD2ksteEfbnduvnWjz4EltUKu/3d LAnsPabZQE5OUukZUB/uoguq1dlxuTrZFghsw+i7f1JjxiQi1guvKE0M9SMIAFpDddBN oc2qfRlZfIgsHk84vqcokE7vkIerZQad2OUZJq5jgY7Ex6k8USpk0mUPV5WmuFlPic3D VahA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=TiGa1qvI; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fj4-20020a1709069c8400b007799e328e10si25684636ejc.999.2022.09.19.02.46.28; Mon, 19 Sep 2022 02:46:28 -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; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=TiGa1qvI; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 49AFE68BC5D; Mon, 19 Sep 2022 12:46:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout02.mail.de (shout02.mail.de [62.201.172.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 59BBE68BB99 for ; Mon, 19 Sep 2022 12:46:06 +0300 (EEST) Received: from postfix03.mail.de (postfix03.bt.mail.de [10.0.121.127]) by shout02.mail.de (Postfix) with ESMTP id B969FA0C1B for ; Mon, 19 Sep 2022 11:46:05 +0200 (CEST) Received: from smtp01.mail.de (smtp01.bt.mail.de [10.0.121.211]) by postfix03.mail.de (Postfix) with ESMTP id 9981580101 for ; Mon, 19 Sep 2022 11:46:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1663580765; bh=h3SrmAVpYz8HuJhSx5RTyKIMBb7s3/JSTLlKRHB62dw=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=TiGa1qvIKLynLbVgwUEzs6SsPqh/oceOfLTHYMy1BIwp/hvoTOdRxQBzOeoqvLic+ GmROdvUV5bn27euJBf4aSAvGQ2lhpf7OifutqqjQENcVdOWa3zQ0I4NohdGUlLTwwA lKuJRFB0Ap0Era8M6xP2XF7+gtUSvunrnYFb0nFyCspteXYpyhwdwJbH/If1whtH13 NyRHS4C0BxNiZg6+IinEsm4RI3iEqJxYOkIeyoatvAoQPNtg+vEDdfW8ilQ6MJSiX/ dx9ft65d0Yn283c+MPWxXOSAGXOGgVF1rNs1/3U/+dQTvXs1yZYVBEqHJaV1UImWco dZXei9Lf9BnCw== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id 5A09210015D for ; Mon, 19 Sep 2022 11:46:05 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 11:45:59 +0200 Message-Id: <20220919094604.4645-2-thilo.borgmann@mail.de> In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de> References: <20220919094604.4645-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 4278 X-purgate-ID: 154282::1663580765-CD7F95FC-A2617EAD/0/0 Subject: [FFmpeg-devel] [PATCH v4 1/6] lavu/opt: Allow options to be arguments of other options 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: wV+GTReXbW6w Adds AV_OPT_FLAG_ARGUMENT for options being used as arguments for other options. Adds av_arg_show() to allow printing of such arguments in help output. --- doc/APIchanges | 4 ++++ libavutil/opt.c | 14 +++++++++++++- libavutil/opt.h | 8 ++++++++ libavutil/version.h | 4 ++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 729f56be7b..e4b2fc8799 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,10 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-19 - xxxxxxxxxx - lavu 57.37.100 - opt.h + Add AV_OPT_FLAG_ARGUMENT. + Add av_arg_show() to print arguments to options. + 2022-09-03 - xxxxxxxxxx - lavu 57.36.100 - pixfmt.h Add AV_PIX_FMT_P012, AV_PIX_FMT_Y212, AV_PIX_FMT_XV30, AV_PIX_FMT_XV36 diff --git a/libavutil/opt.c b/libavutil/opt.c index a3940f47fb..89ef111690 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1256,7 +1256,7 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); else av_log(av_log_obj, AV_LOG_INFO, " %s%-17s ", - (opt->flags & AV_OPT_FLAG_FILTERING_PARAM) ? " " : "-", + (opt->flags & (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_ARGUMENT)) ? " " : "-", opt->name); switch (opt->type) { @@ -1329,6 +1329,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); break; } + if (!(opt->flags & AV_OPT_FLAG_ARGUMENT)) { av_log(av_log_obj, AV_LOG_INFO, "%c%c%c%c%c%c%c%c%c%c%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.', (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.', @@ -1341,6 +1342,7 @@ FF_ENABLE_DEPRECATION_WARNINGS (opt->flags & AV_OPT_FLAG_BSF_PARAM) ? 'B' : '.', (opt->flags & AV_OPT_FLAG_RUNTIME_PARAM) ? 'T' : '.', (opt->flags & AV_OPT_FLAG_DEPRECATED) ? 'P' : '.'); + } if (opt->help) av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); @@ -1456,6 +1458,16 @@ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags) return 0; } +int av_arg_show(void *obj, void *av_log_obj) +{ + if (!obj) + return -1; + + opt_list(obj, av_log_obj, NULL, AV_OPT_FLAG_ARGUMENT, 0, -1); + + return 0; +} + void av_opt_set_defaults(void *s) { av_opt_set_defaults2(s, 0, 0); diff --git a/libavutil/opt.h b/libavutil/opt.h index 461b5d3b6b..dce3483237 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -297,6 +297,7 @@ typedef struct AVOption { #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering #define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is deprecated, users should refer to AVOption.help text for more information #define AV_OPT_FLAG_CHILD_CONSTS (1<<18) ///< set if option constants can also reside in child objects +#define AV_OPT_FLAG_ARGUMENT (1<<19) ///< set if option is an argument to another option //FIXME think about enc-audio, ... style flags /** @@ -386,6 +387,13 @@ typedef struct AVOptionRanges { */ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags); +/** + * Show the obj arguments. + * + * @param av_log_obj log context to use for showing the options + */ +int av_arg_show(void *obj, void *av_log_obj); + /** * Set the values of all AVOption fields to their default values. * diff --git a/libavutil/version.h b/libavutil/version.h index 0585fa7b80..9c44cef6aa 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 36 -#define LIBAVUTIL_VERSION_MICRO 102 +#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ From patchwork Mon Sep 19 09:46:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38042 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1112802pzh; Mon, 19 Sep 2022 02:46:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4s94cAhOa4vXtmvxAGygVXtZZNk50vyGOAVewQS1bYpAtEnukh41wJAbgYkeJCM8xFIffY X-Received: by 2002:a05:6402:791:b0:454:40f7:63e5 with SMTP id d17-20020a056402079100b0045440f763e5mr1081578edy.293.1663580797140; Mon, 19 Sep 2022 02:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663580797; cv=none; d=google.com; s=arc-20160816; b=q9t9KQUvcJKQi/xKVdpLgs0ubC1fM+T89mMAoiX8v8q7tzCKJ10VEX2rS6vVHr1bnY qTLx1zW0BOK+TyxbG1rXq+HG8BBHa2SGFgP20UvqhC/Rb+rNSFSBKMQ24xoDoM6V9h3A okdIzkfSsvXYmEMNnQl7T7QzYkX6kxTRFUBAXyzkeEw2r8wjigjozi18rFVYJNK0akhl edFFUCCDp3PkUk8VoDIa55XS/+ExtOImL/fsR0nPLYFcDDwqPkqR3qqTjSr6lE7uYPcL qT0McnRmtDl7qPDI8Tdy4s3C3MHsxrOg7BuFwEMwR38Ab49/tZeFYaL+teDxq/Nj/YJO md1Q== 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:dkim-signature:delivered-to; bh=XtY4hV5mM9Lq815ljonMI6+xlv4wR5C+brCUTpKQUCM=; b=v9TwJNHW0Viy1DiLk5/mFYlaOnCmf5CUGZbad9xNH58toT023T2qFB8zHEIluylOOE KiR+DTMrpoOO3z+vyKZWGX3nKagSoaU9v3k9OGBQqud1+uSVF60kZl66cAM7d4awCPH9 trMnJZsWUByUYYPONDhIxN7VRxRqeZq6ffaJgdcmBFg3X37jkqLpeJBNIciOrmhJDGqK m82q4AN4VWWwNMLfyb2LyUvOI7gA681P3ixCa4Z+DkUBJLp/yxXDMq3CFr/BXerlPO88 xdZHuLSIOOTGXmXnJcr602tfuKP2gO0f/WVez3Bn7AzgxjiTQQSJOmx3SgItcYbo7mWu SiDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=3QvTvW6Q; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u15-20020aa7d88f000000b0044de650cc36si7819690edq.147.2022.09.19.02.46.36; Mon, 19 Sep 2022 02:46:37 -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; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=3QvTvW6Q; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 698B268BB99; Mon, 19 Sep 2022 12:46:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout01.mail.de (shout01.mail.de [62.201.172.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C8B868BBA7 for ; Mon, 19 Sep 2022 12:46:06 +0300 (EEST) Received: from postfix03.mail.de (postfix03.bt.mail.de [10.0.121.127]) by shout01.mail.de (Postfix) with ESMTP id 129E3A051D for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) Received: from smtp01.mail.de (smtp01.bt.mail.de [10.0.121.211]) by postfix03.mail.de (Postfix) with ESMTP id EB96180101 for ; Mon, 19 Sep 2022 11:46:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1663580766; bh=G/dQsMdVX8AWUCQKIN8ZSO78OZECAwJxAf/tYB2rZJQ=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=3QvTvW6QnEeI+LUIylysoy7j5Asjtui8XRio27uMw1XA3/julZW1ESqcfqFzlbb2d 7S3gvJb6JWqbLxQxBnXcXbtAkw8luprnSDlnA5XAUUk3AZfaLQdFGT+GBfdqMo3Z3B Y1WAuzYL08BxJQpVxkoPoV6TWxtdCJVXXx+mJ5LicjfAPVzG2rnpCfk28sJ3zrCn0p w1aVpOgLprH+sbOY5pTqbGGBxTQK3O5S0qaiech4MlnJSfORi0jKr6huFdEI2Rlenj xmxrq17sW+kEFdIaar/trI+syWpMcQSof0+IddCHX7S/CMZFph3VB/sA9LkQj9CrJ1 47hWMCkyMyAMQ== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id A626C100416 for ; Mon, 19 Sep 2022 11:46:05 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 11:46:00 +0200 Message-Id: <20220919094604.4645-3-thilo.borgmann@mail.de> In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de> References: <20220919094604.4645-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 952 X-purgate-ID: 154282::1663580765-CD7F95FC-7716B026/0/0 Subject: [FFmpeg-devel] [PATCH v4 2/6] fftools/cmdutils: Print arguments of options 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: norfgTu0JfIV --- fftools/cmdutils.c | 5 +++++ fftools/cmdutils.h | 1 + 2 files changed, 6 insertions(+) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index f911c52be2..b6dd73902b 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -162,6 +162,11 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, av_strlcat(buf, po->argname, sizeof(buf)); } printf("-%-17s %s\n", buf, po->help); + + if (po->args) { + const AVClass *p = po->args; + av_arg_show(&p, NULL); + } } printf("\n"); } diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 4496221983..2f469f8c25 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -175,6 +175,7 @@ typedef struct OptionDef { } u; const char *help; const char *argname; + const AVClass *args; } OptionDef; /** From patchwork Mon Sep 19 09:46:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38043 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1112859pzh; Mon, 19 Sep 2022 02:46:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4umbk4BdhYKvW/IbR9BQaY53Kdfl/DutMVT/7y3geKmtsAMnZ0numFztvezOswjNEwbtw0 X-Received: by 2002:a17:906:8463:b0:771:a3d2:7c3 with SMTP id hx3-20020a170906846300b00771a3d207c3mr11642226ejc.592.1663580806247; Mon, 19 Sep 2022 02:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663580806; cv=none; d=google.com; s=arc-20160816; b=wdLo+sFuqXtA4zqt9d1QprYPG17zv0d6NjWzTzrI6w/YBroeHNWCVDi0gS5g7AY4me V67BLHRYusdXRj+l5YPhp3NYHmnVm6jrmscT9J8KoDBz2OIQOU+S9kEuiA0oEhIqCaHU O3jHlTfpWzqIyvqtVJpk8QVijMJHPAoUbtVlrubyOGkJVgQRfF3jdW//KeQbHDC8Pq+7 S6CTXp9/wpRdFbitJ9jdKxt5MeP2Qjq/6LMG0rkaa6JquidQk/pvnW4tOK20NpDZ0eGl 9VYr5CQIqTBRxD98YLTrNRPDm9I4FsFOKaWmLSr5OkEbKjzuYtwZUhdLocXRPo8v46CH H6jg== 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:dkim-signature:delivered-to; bh=IgYR2fnVnQ19x5vle1CU2Ll2jv2XtMhXW2mx0r/E+3I=; b=Dae4GGYTmPK9wVvY5FutN/6dNJIuGyx5PGa0yFvT7v3aPQx5pDSiZFCFMTXdXWBhZx IlQ6xhvsYb0s8iV7REKyC5ftjG9wB8vpseG2bZEHCvMb4lZaKL9gwkoXUe9fv/PW3X9a f4Ft3FxAQfC+k4hl+nY1LEjp9MhbADqli9BC1bi1ygj+QHjPVg5esX2S+3Log3B+at86 N8Iek7N3onF/G+426aJpQRcTXBSoqoVBt63IQldhdxxBj2WhDkS/JdKrZwglp5mhXxva jinXly/gCiZUO5P3brbbrYWB4JMEI239KSwbR3/zw6IECkLkeWvHD+A2GNBqykCX3d9f lDhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=ivAVMgA0; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e2-20020a50d4c2000000b00450fda68304si8588032edj.349.2022.09.19.02.46.45; Mon, 19 Sep 2022 02:46:46 -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; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=ivAVMgA0; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 848D068BC58; Mon, 19 Sep 2022 12:46:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout02.mail.de (shout02.mail.de [62.201.172.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B273868BB03 for ; Mon, 19 Sep 2022 12:46:06 +0300 (EEST) Received: from postfix01.mail.de (postfix01.bt.mail.de [10.0.121.125]) by shout02.mail.de (Postfix) with ESMTP id 58636A0C35 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) Received: from smtp01.mail.de (smtp01.bt.mail.de [10.0.121.211]) by postfix01.mail.de (Postfix) with ESMTP id 412998014F for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1663580766; bh=ZTDAmqLc/pEcnWwsulzSAVDNiBLnxOJjf26zaht+63E=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=ivAVMgA0uQClgnb0cD7UQpnAGnfJHlNhvs2fSUe3i0HM21zFVkBKc8OomeK+aypfG If0KFVbGY5FrWSXJtVa/8TrPDMPhS7vEY8fb7fA1AL3oSAn2Cqe1lgqYaEW4no7V+R 2Z9piIeTZjf/RYvu1LMKrPcC7zsHfYvL06Pz2kgaile4M0JrzS0WTLSQyJ4t/xAmyk 9NAdtPv9NyymDlJm9+ISCAQnhLLxcSII1ZysmpKM5SewdTyHk5YgdSWacjQyvjJJHV 7bPAZKZuTaKaaDHrsjhJ+jjZD8nX1McNKAuhiDZmx8K5ylrIB7ShWmOYFKcsRThITh zpSRkvg5DxoJQ== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id 0528A10015D for ; Mon, 19 Sep 2022 11:46:05 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 11:46:01 +0200 Message-Id: <20220919094604.4645-4-thilo.borgmann@mail.de> In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de> References: <20220919094604.4645-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 5044 X-purgate-ID: 154282::1663580766-CD7F95FC-F4435AE4/0/0 Subject: [FFmpeg-devel] [PATCH v4 3/6] fftools: Add support for dictionary options 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: nncZ0YvBgLAl From: Jan Ekström --- fftools/cmdutils.c | 17 +++++++++++++++++ fftools/cmdutils.h | 2 ++ fftools/ffmpeg_opt.c | 29 ++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index b6dd73902b..f918d83854 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -137,6 +137,21 @@ int64_t parse_time_or_die(const char *context, const char *timestr, return us; } +static AVDictionary *parse_dict_or_die(const char *context, + const char *dict_str) +{ + AVDictionary *dict = NULL; + int ret = av_dict_parse_string(&dict, dict_str, "=", ":", 0); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Failed to create a dictionary from '%s': %s!\n", + dict_str, av_err2str(ret)); + exit_program(1); + } + + return dict; +} + void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags) { @@ -299,6 +314,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, *(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->flags & OPT_DICT) { + *(AVDictionary **)dst = parse_dict_or_die(opt, arg); } else if (po->u.func_arg) { int ret = po->u.func_arg(optctx, opt, arg); if (ret < 0) { diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 2f469f8c25..c7a4628191 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -140,6 +140,7 @@ typedef struct SpecifierOpt { uint64_t ui64; float f; double dbl; + AVDictionary *dict; } u; } SpecifierOpt; @@ -168,6 +169,7 @@ typedef struct OptionDef { #define OPT_DOUBLE 0x20000 #define OPT_INPUT 0x40000 #define OPT_OUTPUT 0x80000 +#define OPT_DICT 0x100000 union { void *dst_ptr; int (*func_arg)(void *, const char *, const char *); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 5febe319e4..be1cd673f6 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -62,6 +62,21 @@ #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64 #define SPECIFIER_OPT_FMT_f "%f" #define SPECIFIER_OPT_FMT_dbl "%lf" +#define SPECIFIER_OPT_FMT_dict "%s" + +static char* specifier_opt_func_dict(char **valstr, AVDictionary *val) { + int ret; + ret = av_dict_get_string(val, valstr, '=', ':'); + return (ret < 0) ? NULL : *valstr; +} + +#define SPECIFIER_OPT_FUNC_str(val) val +#define SPECIFIER_OPT_FUNC_i(val) val +#define SPECIFIER_OPT_FUNC_i64(val) val +#define SPECIFIER_OPT_FUNC_ui64(val) val +#define SPECIFIER_OPT_FUNC_f(val) val +#define SPECIFIER_OPT_FUNC_dbl(val) val +#define SPECIFIER_OPT_FUNC_dict(val) specifier_opt_func_dict(&valstr, val) static const char *const opt_name_codec_names[] = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL}; static const char *const opt_name_audio_channels[] = {"ac", NULL}; @@ -114,11 +129,13 @@ static const char *const opt_name_bits_per_raw_sample[] = {"bits_per_raw_s #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\ {\ char namestr[128] = "";\ + char *valstr = NULL;\ const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\ for (i = 0; opt_name_##name[i]; i++)\ av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? (opt_name_##name[i+2] ? ", " : " or ") : "");\ av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\ - namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\ + namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, SPECIFIER_OPT_FUNC_##type(so->u.type));\ + av_freep(&valstr);\ } #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ @@ -208,11 +225,17 @@ static void uninit_options(OptionsContext *o) av_freep(&(*so)[i].specifier); if (po->flags & OPT_STRING) av_freep(&(*so)[i].u.str); + else if (po->flags & OPT_DICT) + av_dict_free(&(*so)[i].u.dict); } av_freep(so); *count = 0; - } else if (po->flags & OPT_OFFSET && po->flags & OPT_STRING) - av_freep(dst); + } else if (po->flags & OPT_OFFSET) { + if (po->flags & OPT_STRING) + av_freep(dst); + else if (po->flags & OPT_DICT) + av_dict_free((AVDictionary **)dst); + } po++; } From patchwork Mon Sep 19 09:46:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38045 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1112968pzh; Mon, 19 Sep 2022 02:47:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SF0J/i/VRwEh4WcDHPRkx4CQP1DJ3piDRrzSZvHcf4cx8kvSPK+mlpRTiW0fP9V955Wme X-Received: by 2002:a17:906:794f:b0:781:7231:d72f with SMTP id l15-20020a170906794f00b007817231d72fmr1237277ejo.63.1663580825610; Mon, 19 Sep 2022 02:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663580825; cv=none; d=google.com; s=arc-20160816; b=JIgYEKzd8A2u+PIY6Q69nCU9n4BYRuiwEFTUA7szJJBsVRRPNDFHColnvgAnWHjNEo xunm1alVfp/0TyLS3nYnFDHrzYr2zb8RWOeu65Q90W/k7zYSDrpAZpAi71DN5AdotwbZ WPLfycfXYzAdrJLqyrUVO8iTm/oa6eobTUyiBJJnA4zwuDDBgnHJB939M/krGW/Q4yGi K+GngvbxjXQRT7upVnId/9WTPJkRibo2WElzpkZVBcdZzNtyKrVfNQucVqiNPeLC0avj nN4XJQepO8NAgv4p3lv3umnjB3V/e1A5o0TIMj99oKDQgMfky5QRQK6gaBwomQ6tB3QW N0dQ== 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:dkim-signature:delivered-to; bh=9NCwarZz5FRGJDqZryrZMF+CHsV/JQZfSN/EOQMLOZg=; b=oU03fN5LYdzQjAbYhp/JE8rrLvLsvyj+UqBxT8dvGIqLsGpyBUfGnzVRHrU93jboTj mfrCnXxfIljhmNtW+ZWyJEOs18KAXaTJ8bLQK42SbldH+iCO+sGNyPrkKjqt6+MD+rB5 sNfT0HmusOqMXlYv2PxbolsBgP/a1QeZyyqY37EhIEfzXuWE2J33OBETdFhDxNS2hy6V Ngn6FKxGU3/vb3cbT7WPZYYqpmklUknJe7XMSVTPntbiBx2pYT4xSvTOtRK4msDocgpk UXcNz8b9z7ac27CS8rNyNmGghWTF0/lkkIa1SSGBR1wi4tkQ783aKAiZv6iCw2+l8Flg kJGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=tSleYTev; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e10-20020a056402190a00b0044874cf4c88si11815969edz.430.2022.09.19.02.47.05; Mon, 19 Sep 2022 02:47:05 -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; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=tSleYTev; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7985068BC7D; Mon, 19 Sep 2022 12:46:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout02.mail.de (shout02.mail.de [62.201.172.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C7CCE68BC64 for ; Mon, 19 Sep 2022 12:46:11 +0300 (EEST) Received: from postfix02.mail.de (postfix02.bt.mail.de [10.0.121.126]) by shout02.mail.de (Postfix) with ESMTP id 9BFCCA0C61 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) Received: from smtp01.mail.de (smtp01.bt.mail.de [10.0.121.211]) by postfix02.mail.de (Postfix) with ESMTP id 840BEA03C6 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1663580766; bh=iGapqFXDk05upwAd8qt3jJxhijaD24qI1Ynll2vBFvQ=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=tSleYTevuqogsJml6fFa3FJaKTvPVAnZP7wPpNYnuLhNpRguNW1A6zr8LLZHlWCgu Iob1oiAO9KRVkgS1+bMHb/237LKDg27pGInGF1XEacndUFLzqNqe5WRomyAMFWGTCg k7IVkzyA3F/g9nACwBn7+bDnJBqM2bECbwwqWzTY+WNDujiybvYwa5JLRPP3hs17aK Wy1yjYQcJque/TT5IpmGuPsh9XMYAEc+gQP8gbLA+O9EsPiYQMg3YXroY1KeUFottF uwR96ZquFw592/H6On9RcwGuWaeD37lt2BwLtRZoLS8yV5xzEWOQLdmKCfaVl5EBUE FqzcsPMjy4tKQ== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id 4EF88100170 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 11:46:02 +0200 Message-Id: <20220919094604.4645-5-thilo.borgmann@mail.de> In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de> References: <20220919094604.4645-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 4044 X-purgate-ID: 154282::1663580766-CD7F95FC-DE6621B5/0/0 Subject: [FFmpeg-devel] [PATCH v4 4/6] lavu/display: Add horizontal and vertical scaling to the display matrix 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: +khK/JKgpitd --- doc/APIchanges | 3 +++ libavutil/display.c | 35 +++++++++++++++++++++++++++++++++++ libavutil/display.h | 26 ++++++++++++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index e4b2fc8799..9dc393d999 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-19 - xxxxxxxxxx - lavu 57.38.100 - display.h + Add av_display_matrix_scale(), av_display_{h,v}scale_get() + 2022-09-19 - xxxxxxxxxx - lavu 57.37.100 - opt.h Add AV_OPT_FLAG_ARGUMENT. Add av_arg_show() to print arguments to options. diff --git a/libavutil/display.c b/libavutil/display.c index d31061283c..434ed50104 100644 --- a/libavutil/display.c +++ b/libavutil/display.c @@ -48,6 +48,30 @@ double av_display_rotation_get(const int32_t matrix[9]) return -rotation; } +double av_display_hscale_get(const int32_t matrix[9]) +{ + double scale; + + scale = hypot(CONV_FP(matrix[0]), CONV_FP(matrix[1])); + + if (scale == 0.0) + return NAN; + + return scale; +} + +double av_display_vscale_get(const int32_t matrix[9]) +{ + double scale; + + scale = hypot(CONV_FP(matrix[3]), CONV_FP(matrix[4])); + + if (scale == 0.0) + return NAN; + + return scale; +} + void av_display_rotation_set(int32_t matrix[9], double angle) { double radians = -angle * M_PI / 180.0f; @@ -72,3 +96,14 @@ void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip) for (i = 0; i < 9; i++) matrix[i] *= flip[i % 3]; } + +void av_display_matrix_scale(int32_t matrix[9], double hscale, double vscale) +{ + // hscale + matrix[0] = CONV_DB(CONV_FP(matrix[0]) * hscale); + matrix[1] = CONV_DB(CONV_FP(matrix[1]) * hscale); + + // vscale + matrix[3] = CONV_DB(CONV_FP(matrix[3]) * vscale); + matrix[4] = CONV_DB(CONV_FP(matrix[4]) * vscale); +} diff --git a/libavutil/display.h b/libavutil/display.h index 31d8bef361..ef507eb521 100644 --- a/libavutil/display.h +++ b/libavutil/display.h @@ -86,6 +86,24 @@ */ double av_display_rotation_get(const int32_t matrix[9]); +/** + * Extract the horizontal scaling component of the transformation matrix. + * + * @param matrix the transformation matrix + * @return the horizontal scaling by which the transformation matrix scales the frame + * in the horizontal direction. + */ +double av_display_hscale_get(const int32_t matrix[9]); + +/** + * Extract the vertical scaling component of the transformation matrix. + * + * @param matrix the transformation matrix + * @return the vertical scaling by which the transformation matrix scales the frame + * in the vertical direction. + */ +double av_display_vscale_get(const int32_t matrix[9]); + /** * Initialize a transformation matrix describing a pure clockwise * rotation by the specified angle (in degrees). @@ -105,6 +123,14 @@ void av_display_rotation_set(int32_t matrix[9], double angle); */ void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip); +/** + * Scale the input matrix horizontally and/or vertically. + * + * @param matrix an allocated transformation matrix + * @param hscale scale factor by which the matrix should be scaled horizontally + * @param vscale scale factor by which the matrix should be scaled vertically + */ +void av_display_matrix_scale(int32_t matrix[9], double hscale, double vscale); /** * @} * @} diff --git a/libavutil/version.h b/libavutil/version.h index 9c44cef6aa..5aca550f45 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MINOR 38 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From patchwork Mon Sep 19 09:46:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38046 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1113037pzh; Mon, 19 Sep 2022 02:47:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7J92/6Xmv9/4tq6R22RBnaVHJiIgG3GjIU6V/4Tx1YW4oTn3mXICZ25T/d1x4eP+8rP13w X-Received: by 2002:a05:6402:3549:b0:454:414e:a7fd with SMTP id f9-20020a056402354900b00454414ea7fdmr1100199edd.69.1663580836197; Mon, 19 Sep 2022 02:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663580836; cv=none; d=google.com; s=arc-20160816; b=gZAVN30JsuTgVR2z+TNYrReSKph3fmq/Bo+1hklUC7g0KsNCPcubQ2E7VqcJ+mAZce VvUm3xm5yBNcm52NI+nlshBhC08NaXIBpR3G+28+nE3K8QQ97koDbOICAa0yIzhxa+82 nv1iu3Hs2CyEn4I/MJZ3uct2LNaFXE/CokIW1vkWf/kgO1OnrfmC89trACWqBZ0B38fm ljOTIt4v+mezF4Sdq+A62iv7rP1huaCCtUOGNuQL74gw71K5LW0IGvvmzIJascyUm0MK umhr+0sHakqZcOU2PfoKGbLSLyQTBQug7NYzytvjYA1+UEldXqgonqanc6UOpFdv65Ik fVdg== 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:dkim-signature:delivered-to; bh=QZRtGWU52msurbaXDJy8srJUbgxRRcyUib1F8Hb8H18=; b=zuIvT5bwH4e5eelPgfqtzH3msEbKI824N5qdQ8+J9yBatfVlXID6ZfO7DZ3APGPr/A pTJ35PCdn/IoST7s+vntTf8P309cRQgKJcGyffEnfhm5bmCjHd4kmwQSyXQ3Hfw8+MqU qZ8vf3R8v4bdpYKAC2+Iat0l6WTQVHAV0IU9GKTZvg9AP08TP6SNA6EQxqOR25B7vS+b AZ9XJH1liGAFe9ndTTcDARgBQYiJ90Eq1j4gcFTFdGtaXxXDBVCSvPC8PiYs/vCypcZD ubAGzglcLQwUeE5+BjkZOGjxNiKvyEH107z5wzlsdL2kHWXwAz+9rhNZq0Mr1WeEAV10 ZRVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=5dkZo6w4; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dn8-20020a17090794c800b0077b45792af2si3995934ejc.464.2022.09.19.02.47.15; Mon, 19 Sep 2022 02:47: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; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=5dkZo6w4; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 795D568BC84; Mon, 19 Sep 2022 12:46:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout02.mail.de (shout02.mail.de [62.201.172.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 64DF268BC13 for ; Mon, 19 Sep 2022 12:46:12 +0300 (EEST) Received: from postfix01.mail.de (postfix01.bt.mail.de [10.0.121.125]) by shout02.mail.de (Postfix) with ESMTP id F2FA9A0C0F for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) Received: from smtp01.mail.de (smtp01.bt.mail.de [10.0.121.211]) by postfix01.mail.de (Postfix) with ESMTP id DA04B802BB for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1663580766; bh=bI0c07TkkuYO4msVJI/6v+38eNAjrmjY4Vobj79oIhU=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=5dkZo6w45vjLzTdTUcpSrGdCxv6IyS2BuRhVzs1gYO9YCOUQi/iVloU6uI5z4z8rF bJE2O1VLs6w94Usca4fmxfoCxRO04eSo7st8tJvWV7r4mxCZshtxNazw7qYBKYtEGe w1wD7QpyCUT0VM318Zu7yH9XicAaQfZsqyoxz4h3b8Cn3F9zbsqkStCok10XCSepg/ Ppa+ZDsMO/QauoAEt/0n4fpkkGPtHQV4lI2BfSIRTTP3XtpOoqeEjv5iacNTPmKwN0 cFAhfCSn0QqcuGGXrwUPCbEZvVR5o3mReTZcak5oFD4qJFyxh1N8ul8dFAdnWdlyMa tnPrES99OiNCQ== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id 91ADA100107 for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 11:46:03 +0200 Message-Id: <20220919094604.4645-6-thilo.borgmann@mail.de> In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de> References: <20220919094604.4645-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 12663 X-purgate-ID: 154282::1663580766-CD7F95FC-9ED4071B/0/0 Subject: [FFmpeg-devel] [PATCH v4 5/6] ffmpeg: Add display_matrix option 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: bo79zX4PHKuz From: Jan Ekström This enables overriding the rotation as well as horizontal/vertical flip state of a specific video stream on the input side. Additionally, switch the singular test that was utilizing the rotation metadata to instead override the input display rotation, thus leading to the same result. --- doc/ffmpeg.texi | 18 ++++++ fftools/ffmpeg.h | 2 + fftools/ffmpeg_filter.c | 13 ++++ fftools/ffmpeg_opt.c | 123 ++++++++++++++++++++++++++++++++++++ tests/fate/filter-video.mak | 2 +- 5 files changed, 157 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 42440d93b4..ee86faedc8 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -912,6 +912,24 @@ If used together with @option{-vcodec copy}, it will affect the aspect ratio stored at container level, but not the aspect ratio stored in encoded frames, if it exists. +@item -display_matrix[:@var{stream_specifier}] @var{opt1=val1[,opt2=val2]...} (@emph{input,per-stream}) +Set the video display matrix according to given options. +We support scaling, flipping and rotation. The order of application to an Image is scale, flip, rotate. + +@table @option +@item rotation=@var{number} +Set the rotation using a floating point number that describes a pure +counter-clockwise rotation in degrees. +The @code{-autorotate} logic will be affected. +@item hflip=@var{[0,1]} +@item vflip=@var{[0,1]} +Set a horizontal or vertical flip. +@item hscale=@var{number} +Set a horizontal scaling by factor of the given floating-point value. +@item vscale=@var{number} +Set a vertical scaling by factor of the given floating-point value. +@end table + @item -vn (@emph{input/output}) As an input option, blocks all video streams of a file from being filtered or being automatically selected or mapped for any output. See @code{-discard} diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ede0b2bd96..524a1d415a 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -193,6 +193,8 @@ typedef struct OptionsContext { int nb_force_fps; SpecifierOpt *frame_aspect_ratios; int nb_frame_aspect_ratios; + SpecifierOpt *display_matrixes; + int nb_display_matrixes; SpecifierOpt *rc_overrides; int nb_rc_overrides; SpecifierOpt *intra_matrices; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 7a5308425d..8bcba0d3a2 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -779,9 +779,22 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { int32_t *displaymatrix = ifilter->displaymatrix; double theta; + double hscale = 1.0f; + double vscale = 1.0f; if (!displaymatrix) displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + + if (displaymatrix) { + hscale = av_display_hscale_get(displaymatrix); + vscale = av_display_vscale_get(displaymatrix); + if (hscale != 1.0f || vscale != 1.0f) { + char scale_buf[128]; + snprintf(scale_buf, sizeof(scale_buf), "%f*iw:%f*ih", hscale, vscale); + ret = insert_filter(&last_filter, &pad_idx, "scale", scale_buf); + } + } + theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index be1cd673f6..ba56267460 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -20,6 +20,7 @@ #include "config.h" +#include #include #if HAVE_SYS_RESOURCE_H @@ -45,6 +46,7 @@ #include "libavutil/avutil.h" #include "libavutil/bprint.h" #include "libavutil/channel_layout.h" +#include "libavutil/display.h" #include "libavutil/getenv_utf8.h" #include "libavutil/intreadwrite.h" #include "libavutil/fifo.h" @@ -101,6 +103,7 @@ static const char *const opt_name_forced_key_frames[] = {"forced_key_fra static const char *const opt_name_fps_mode[] = {"fps_mode", NULL}; static const char *const opt_name_force_fps[] = {"force_fps", NULL}; static const char *const opt_name_frame_aspect_ratios[] = {"aspect", NULL}; +static const char *const opt_name_display_matrixes[] = {"display_matrix", NULL}; static const char *const opt_name_rc_overrides[] = {"rc_override", NULL}; static const char *const opt_name_intra_matrices[] = {"intra_matrix", NULL}; static const char *const opt_name_inter_matrices[] = {"inter_matrix", NULL}; @@ -126,6 +129,38 @@ static const char *const opt_name_time_bases[] = {"time_base", NU static const char *const opt_name_enc_time_bases[] = {"enc_time_base", NULL}; static const char *const opt_name_bits_per_raw_sample[] = {"bits_per_raw_sample", NULL}; +// XXX this should probably go into a seperate file _args.c and #included here + struct DisplayMatrix { + const AVClass *class; + double rotation; + int hflip; + int vflip; + double hscale; + double vscale; + }; +#define OFFSET(x) offsetof(struct DisplayMatrix, x) + static const AVOption display_matrix_args[] = { + { "rotation", "set rotation", OFFSET(rotation), AV_OPT_TYPE_DOUBLE, + { .dbl = DBL_MAX }, -(DBL_MAX), DBL_MAX - 1.0f, AV_OPT_FLAG_ARGUMENT}, + { "hflip", "set hflip", OFFSET(hflip), AV_OPT_TYPE_BOOL, + { .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, + { "vflip", "set vflip", OFFSET(vflip), AV_OPT_TYPE_BOOL, + { .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, + { "hscale", "set horizontal scale factor", OFFSET(hscale), AV_OPT_TYPE_DOUBLE, + { .dbl = DBL_MAX }, 0.0f, DBL_MAX - 1.0f, AV_OPT_FLAG_ARGUMENT}, + { "vscale", "set vertical scale factor", OFFSET(vscale), AV_OPT_TYPE_DOUBLE, + { .dbl = DBL_MAX }, 0.0f, DBL_MAX - 1.0f, AV_OPT_FLAG_ARGUMENT}, + { NULL }, + }; + static const AVClass class_display_matrix_args = { + .class_name = "display_matrix_args", + .item_name = av_default_item_name, + .option = display_matrix_args, + .version = LIBAVUTIL_VERSION_INT, + }; +#undef OFFSET +// XXX + #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\ {\ char namestr[128] = "";\ @@ -824,6 +859,85 @@ static int opt_recording_timestamp(void *optctx, const char *opt, const char *ar return 0; } +static void add_display_matrix_to_stream(OptionsContext *o, + AVFormatContext *ctx, AVStream *st) +{ + int hflip_set = 0, vflip_set = 0, display_rotation_set = 0, hscale_set = 0, vscale_set = 0; + uint8_t *buf = NULL; + + struct DisplayMatrix test_args = { + .class = &class_display_matrix_args, + .rotation = DBL_MAX, + .hflip = -1, + .vflip = -1, + .hscale = DBL_MAX, + .vscale = DBL_MAX, + }; + + AVDictionary *global_args = NULL; + AVDictionary *local_args = NULL; + AVDictionaryEntry *en = NULL; + + MATCH_PER_STREAM_OPT(display_matrixes, dict, global_args, ctx, st); + + if (!global_args) + return; + + // make a copy of the dict so it doesn't get freed from underneath us + if (av_dict_copy(&local_args, global_args, 0) < 0) { + av_log(NULL, AV_LOG_FATAL, + "Failed to copy argument dict for display matrix!\n"); + exit_program(1); + } + + if (av_opt_set_dict2(&test_args, &local_args, 0) < 0) { + av_log(NULL, AV_LOG_FATAL, + "Failed to set options for a display matrix!\n"); + exit_program(1); + } + + while ((en = av_dict_get(local_args, "", en, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_FATAL, + "Unknown option=value pair for display matrix: " + "key: '%s', value: '%s'!\n", + en->key, en->value); + } + + if (av_dict_count(local_args)) { + exit_program(1); + } + + av_dict_free(&local_args); + + display_rotation_set = test_args.rotation != DBL_MAX; + hflip_set = test_args.hflip != -1; + vflip_set = test_args.vflip != -1; + hscale_set = test_args.hscale != DBL_MAX; + vscale_set = test_args.vscale != DBL_MAX; + + if (!display_rotation_set && !hflip_set && !vflip_set && + !hscale_set && !vscale_set) + return; + + if (!(buf = av_stream_new_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, + sizeof(int32_t) * 9))) { + av_log(NULL, AV_LOG_FATAL, "Failed to generate a display matrix!\n"); + exit_program(1); + } + + av_display_rotation_set((int32_t *)buf, + display_rotation_set ? -(test_args.rotation) : + -0.0f); + av_display_matrix_flip((int32_t *)buf, + hflip_set ? test_args.hflip : 0, + vflip_set ? test_args.vflip : 0); + + av_display_matrix_scale((int32_t *)buf, + hscale_set ? test_args.hscale : 1.0f, + vscale_set ? test_args.vscale : 1.0f); +} + + static const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder) { const AVCodecDescriptor *desc; @@ -958,6 +1072,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + add_display_matrix_to_stream(o, ic, st); + MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st); MATCH_PER_STREAM_OPT(hwaccel_output_formats, str, hwaccel_output_format, ic, st); @@ -1883,6 +1999,8 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in ost->frame_aspect_ratio = q; } + add_display_matrix_to_stream(o, oc, st); + MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st); @@ -4044,6 +4162,11 @@ const OptionDef options[] = { { "aspect", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(frame_aspect_ratios) }, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" }, + { "display_matrix", OPT_VIDEO | HAS_ARG | OPT_DICT | OPT_SPEC | + OPT_INPUT, { .off = OFFSET(display_matrixes) }, + "define a display matrix with rotation, and/or horizontal/vertical " + "flip/scale for stream(s)", + "arguments", &class_display_matrix_args }, { "pix_fmt", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_pix_fmts) }, "set pixel format", "format" }, diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index 372c70bba7..763390ea51 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -691,7 +691,7 @@ fate-filter-metadata-avf-aphase-meter-out-of-phase: SRC = $(TARGET_SAMPLES)/filt fate-filter-metadata-avf-aphase-meter-out-of-phase: CMD = run $(FILTER_METADATA_COMMAND) "amovie='$(SRC)',aphasemeter=video=0" FATE_FILTER_SAMPLES-$(call TRANSCODE, RAWVIDEO H264, MOV, ARESAMPLE_FILTER AAC_FIXED_DECODER) += fate-filter-meta-4560-rotate0 -fate-filter-meta-4560-rotate0: CMD = transcode mov $(TARGET_SAMPLES)/filter/sample-in-issue-505.mov mov "-c copy -metadata:s:v:0 rotate=0" "-af aresample" "" "" "-flags +bitexact -c:a aac_fixed" +fate-filter-meta-4560-rotate0: CMD = transcode "mov -display_matrix:v:0 rotation=0" $(TARGET_SAMPLES)/filter/sample-in-issue-505.mov mov "-c copy" "-af aresample" "" "" "-flags +bitexact -c:a aac_fixed" FATE_FILTER_CMP_METADATA-$(CONFIG_BLOCKDETECT_FILTER) += fate-filter-refcmp-blockdetect-yuv fate-filter-refcmp-blockdetect-yuv: CMD = cmp_metadata blockdetect yuv420p 0.015 From patchwork Mon Sep 19 09:46:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thilo Borgmann X-Patchwork-Id: 38044 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1112910pzh; Mon, 19 Sep 2022 02:46:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GIo3bQGZakKOGuSvfFRAzSkfjZnU2+dAHPckLFvOtaQZzOTQ0NPn/bcOE7Fzt2iYFPDOy X-Received: by 2002:aa7:d6d9:0:b0:44d:e1b7:d905 with SMTP id x25-20020aa7d6d9000000b0044de1b7d905mr14866978edr.32.1663580815732; Mon, 19 Sep 2022 02:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663580815; cv=none; d=google.com; s=arc-20160816; b=Q+N5wIpsMJ3/XktAC0j8pf2zqD2C6LzSKm5QwZE0jjcvXP7o//Tp0kMp/sY+uVpXZj Bi1/mt/ubzOoSKX3KpWqsCes+XYWyu18LCXzWjE0Ia0JeNgLNUIiNeK3npuj7ea3oK5Y 5RBehO0+8NcOGlyBNK1U8SrbH1W81YFdEwsovpv5UoW5azZABP1HuoE/i5F5mtyIZ47d Cjm2q+8Se11EQw5SdteKwag36hJvXvZy02gi7YJPOx/18+TbuzOpO6jyQJuHkitBrsgD g6lrOkGnUaep8dgGXnKfal7q+4+9hrUi/mRwewJIsL4bFbL0iN35xigCLvXQ482kOgKo NT6g== 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:dkim-signature:delivered-to; bh=2/wD969omf/yNRBDBw8DhAto81zGucjst01l483mQ60=; b=loGndAWJcf1AyZlNz9Qt2yY2e6W98uMDDFL2GtJn3GCpKcxqsMClvPsOlLWwAl6axb dxKInsKjKRAG6svg+9dk8MAfkR31at182US4rWlF8izjize0L1LC3ghtd34TCM6ciPL6 jsUBYKSOcE3jWxItF8yrNP85stnAG5IZlObwKTEXas6i6S1yiAgb+HTijkfaSKidH4hy AziITt1qt/iLmwhu5hLCrRN3tkVTXs0SVCdEstZJRqzQr+kgyyVXZknz2j4dFA7Ymd0c kUMdJ5zkGw2i8Nic7+hHyIDoPLubkUn021OHgz9KjlUZ+MP/jH9KJGeAxsp2Sx5U7FPN izxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=0dRtNrBQ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bf26-20020a0564021a5a00b0044ea569baa2si8171208edb.557.2022.09.19.02.46.55; Mon, 19 Sep 2022 02:46:55 -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; dkim=neutral (body hash did not verify) header.i=@mail.de header.s=mailde202009 header.b=0dRtNrBQ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mail.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64A4E68BC73; Mon, 19 Sep 2022 12:46:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shout01.mail.de (shout01.mail.de [62.201.172.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B995D68BC13 for ; Mon, 19 Sep 2022 12:46:11 +0300 (EEST) Received: from postfix01.mail.de (postfix01.bt.mail.de [10.0.121.125]) by shout01.mail.de (Postfix) with ESMTP id 4F9E7A060D for ; Mon, 19 Sep 2022 11:46:07 +0200 (CEST) Received: from smtp01.mail.de (smtp01.bt.mail.de [10.0.121.211]) by postfix01.mail.de (Postfix) with ESMTP id 36907802BB for ; Mon, 19 Sep 2022 11:46:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde202009; t=1663580767; bh=5OnZzPO2Ai5D9vjuBDp/Y4pMweq4FJg0VpKhbkEGy5E=; h=From:To:Subject:Date:Message-Id:From:To:CC:Subject:Reply-To; b=0dRtNrBQmN/UMcUgSdzcwVU4WTzc3n3Ix3U/rdnU9zBOxaTjDk9e7PG5Gm83drZ8d 9cTU5YhuHI9Gg0rwr6rv6uK192rJvhSlwoj56n5TIqo+sylg3dk8Ji40dBSDzNh003 +HzJqiv9OoClP1FNgaCXwpnE4IppjsXMameb9UzC8PSsFtCm1oum1WcWQPoYn0K4wF 8BBS8xr8fhz5UARS2kHsmMnjEBIdpOozUrz42YjIt2pn+OWLBxoXJ+DbSwTCZg4fHn OWbhoLGYWQAiKi62bqVzZpu0gxo/LrXJJbpHy7My/hBT5GZdSPcf4Q/T2wXCcr4buZ 9m4Qt1CA7ygKw== Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp01.mail.de (Postfix) with ESMTPSA id E887B10015D for ; Mon, 19 Sep 2022 11:46:06 +0200 (CEST) From: Thilo Borgmann To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Sep 2022 11:46:04 +0200 Message-Id: <20220919094604.4645-7-thilo.borgmann@mail.de> In-Reply-To: <20220919094604.4645-1-thilo.borgmann@mail.de> References: <20220919094604.4645-1-thilo.borgmann@mail.de> MIME-Version: 1.0 X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 3361 X-purgate-ID: 154282::1663580767-CD7F95FC-7CDBB470/0/0 Subject: [FFmpeg-devel] [PATCH v4 6/6] ffmpeg: Deprecate display rotation override with a metadata key 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: ztE22cBbfyOR From: Jan Ekström Now that we have proper options for defining display matrix overrides, this should no longer be required. fftools does not have its own versioning, so for now the define is just set to 1 and disables the functionality if set to zero. --- fftools/ffmpeg.c | 2 ++ fftools/ffmpeg.h | 5 +++++ fftools/ffmpeg_opt.c | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0e1477299d..65b0b83a18 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2831,12 +2831,14 @@ static int init_output_stream_streamcopy(OutputStream *ost) } } +#if FFMPEG_ROTATION_METADATA if (ost->rotate_overridden) { uint8_t *sd = av_stream_new_side_data(ost->st, AV_PKT_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (sd) av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value); } +#endif switch (par->codec_type) { case AVMEDIA_TYPE_AUDIO: diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 524a1d415a..c134b15726 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -53,6 +53,7 @@ #define FFMPEG_OPT_PSNR 1 #define FFMPEG_OPT_MAP_CHANNEL 1 #define FFMPEG_OPT_MAP_SYNC 1 +#define FFMPEG_ROTATION_METADATA 1 enum VideoSyncMethod { VSYNC_AUTO = -1, @@ -532,11 +533,15 @@ typedef struct OutputStream { int is_cfr; int force_fps; int top_field_first; +#if FFMPEG_ROTATION_METADATA int rotate_overridden; +#endif int autoscale; int bitexact; int bits_per_raw_sample; +#if FFMPEG_ROTATION_METADATA double rotate_override_value; +#endif AVRational frame_aspect_ratio; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index ba56267460..71e62d0aa7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2960,16 +2960,26 @@ static void of_add_metadata(AVFormatContext *oc, const OptionsContext *o) for (int j = 0; j < oc->nb_streams; j++) { OutputStream *ost = output_streams[nb_output_streams - oc->nb_streams + j]; if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) { +#if FFMPEG_ROTATION_METADATA if (!strcmp(o->metadata[i].u.str, "rotate")) { char *tail; double theta = av_strtod(val, &tail); if (!*tail) { ost->rotate_overridden = 1; ost->rotate_override_value = theta; + + av_log(NULL, AV_LOG_WARNING, + "Conversion of a 'rotate' metadata key to a " + "proper display matrix rotation is deprecated. " + "See -display_matrix for setting rotation " + "instead."); } } else { +#endif av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0); +#if FFMPEG_ROTATION_METADATA } +#endif } else if (ret < 0) exit_program(1); }