From patchwork Fri Jun 30 21:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 42351 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1e:b0:12b:9ae3:586d with SMTP id c30csp2791310pzh; Fri, 30 Jun 2023 13:41:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlG6BzXyY0AiFxCmjlS4YsohwWmiqXZ3ahzVbpG7YnAu+xYyoGSJMhgpwlvmfbtejVSyFyP3 X-Received: by 2002:a2e:80d9:0:b0:2b6:a3a0:5f7 with SMTP id r25-20020a2e80d9000000b002b6a3a005f7mr2707506ljg.9.1688157693788; Fri, 30 Jun 2023 13:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688157693; cv=none; d=google.com; s=arc-20160816; b=ZCT1wIkLf3z5iopyAWltWhU2K6IL5tEZ/wCEl6FPimjoHXtucJYBjISM3sXUAHmTgL ygAWAo0+3JBZIuRbMLW1RA2FnpBZ+5IXWDWw/dqlcIYlyLJ4b8GDRq76GzLb7i/Mrrg+ mbqM0I78P6zZw/IYU4BnwFRWRoXoxxqR1XrmI1A/XSGgStx1Lro405cUPKgEwytQsWna lCWBZY7ppu7rQdz8P+Ws6iYTg5CqNmp+I4ViFxSf2pKy2m8MbkJHgTlcjtWOsskDYNHz YYEUq7WhpcoGh6HA1/VsmZ6kAo/jQvrMT4jTyC0I9pMD+wgmHCDJzBt2pahN69DxQFlw AA4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=XxEz3SDifz+Bcjnh+zRO4WprN4P50MgqfMtARui9QyU=; fh=pXLAZvRiz3/uELcsWNfKAkJPgyV9/rr3Mrznj9KeXEo=; b=uoLMXh6+BA+ZMVi5dHmpJjsB3PU8BMkx+AfTzoJlyneiSvzu68JvxI/BVYlaIONJZm kCFSF6Vk7W0Kgb971RsT75wr/QtF7FvIekhFH6LEd4mJhNbI0ZLVi77vCecW26WUrWm3 DywBWBO/WcNhm7zt0u/2+BVvhNe4EN7ofg23kl2U40+KtY05ta8iIuYuws4uSFzb3qt0 6CCDM5eM/THBL+0VU38z6vZQ4keV4Ic+aEA0y4QKAOUGM1PW7OYM5SVpsYALvbbwZU03 Lb9C64aZfmca/TZQ4upcQcrt4GTXj3L7dndosiWasiVBEgUDMKWBFp9IcOGQfQQhYeqV B+LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ltnglobal-com.20221208.gappssmtp.com header.s=20221208 header.b=J1reMB+7; 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 a20-20020a17090682d400b00986432cf57csi8450876ejy.942.2023.06.30.13.41.33; Fri, 30 Jun 2023 13:41:33 -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=@ltnglobal-com.20221208.gappssmtp.com header.s=20221208 header.b=J1reMB+7; 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 3DDAE68C43E; Fri, 30 Jun 2023 23:41:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 993A468C33C for ; Fri, 30 Jun 2023 23:41:05 +0300 (EEST) Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-3fde8e4d321so15909881cf.2 for ; Fri, 30 Jun 2023 13:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ltnglobal-com.20221208.gappssmtp.com; s=20221208; t=1688157664; x=1690749664; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=jirLEB5kKeMEu5/vNh7En4EpyEEaU3GXRFo4P0Nc6Ys=; b=J1reMB+78OCXaRIUEIuPnNr8fOjy9nXiouApf/ZqOqxd8lmc8/NiWte3PLNiwFCEiY hkTC6vl17Ter6yDo5Ef1O7ZRN/pCYcpf73WDXgHYBbOFa7gKHgiXlbXe5BC9OEdrFF+9 7Pr80nq2DHp+QHfZyINpouVcGMchwvw37FDcSjvlul4VDUnv27rTf/5NobBl5lm7n0q6 1aJyID6wgqsZBwR3CktA7tYrSVzGvgLLShUJKZTsyJArK5tuBCGWh85tiISGCAKJKzpV /GUSizg8ljM6u1R4HpN+U3hXk1nVui0ZeTorVJFso+aFdOGFwrZvzsOAfh/BKSC3poha C0Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688157664; x=1690749664; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jirLEB5kKeMEu5/vNh7En4EpyEEaU3GXRFo4P0Nc6Ys=; b=b4L6gMBMHch6QeUIyHvgTbSn0DRyuzn+U1nypweO/8YuquMyPOPTPpcA6zl8owJqah x6WUf60pawIjg9rzSoQ2WGkRgJAc+kNPvV1bn1eDCj8ec3z89Dwl0B6yB6T4K4exlEDj zfxHx7azRco3z9XoTDZRZSitNqB72AgJEffkPErc5PUUB4R9sVZ3n/EQ7GbVIIEV/9ny MoFSAUWF/vvzI4pBAuDop9PPp4T+zQdAS+EY2nPIUzWLYFxBY2UezcCVC9w+4bz+jTcK 3Qzz+n8KUGFTp+9OP8tk1LprecomHalVtMuCcY96juSkij/3BVsSs65yr8Im/IBkRxzx Bv+Q== X-Gm-Message-State: AC+VfDz1jvrGYDWfYhbe1eTBkDmZXW5y/HtwCFOBBDZbxUDnS7odI/s7 qTalSXCIkEGAn9Mz4XqFRk/KxkJHU7ytrYT7aW8= X-Received: by 2002:a05:622a:1744:b0:3f7:b95:f088 with SMTP id l4-20020a05622a174400b003f70b95f088mr4721975qtk.20.1688157664089; Fri, 30 Jun 2023 13:41:04 -0700 (PDT) Received: from ltnt-nyc-580testdevin.livetimenet.com (pool-71-105-132-214.nycmny.fios.verizon.net. [71.105.132.214]) by smtp.gmail.com with ESMTPSA id bq8-20020a05622a1c0800b003e0945575dasm4409885qtb.1.2023.06.30.13.41.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2023 13:41:03 -0700 (PDT) From: Devin Heitmueller X-Google-Original-From: Devin Heitmueller To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Jun 2023 17:38:50 -0400 Message-Id: <1688161135-11774-3-git-send-email-dheitmueller@ltnglobal.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1688161135-11774-1-git-send-email-dheitmueller@ltnglobal.com> References: <1688161135-11774-1-git-send-email-dheitmueller@ltnglobal.com> Subject: [FFmpeg-devel] [PATCH v2 2/7] vf_drawtext: Add ability to show AFD value 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 Cc: Devin Heitmueller MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: SATkj+qP8Vn2 Add an "afd" variable which shows the current AFD side data for the given frame. This is to assist in debugging as it allows us to burn the current AFD right into the video. Example usage: ./ffmpeg -y -i afd.ts -vf drawtext=fontfile=/Library/Fonts/Verdana.ttf:text="AFD=%{afd}":fontsize=32:x=10:y=50:fontcolor=blue burnin.ts Signed-off-by: Devin Heitmueller Conflicts: libavfilter/vf_drawtext.c --- doc/filters.texi | 5 +++++ libavfilter/vf_drawtext.c | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index f17488c..793868b 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -12698,6 +12698,11 @@ The following functions are available: @table @command +@item afd +The Active Format Descriptor value of the current frame (as specified in the +frame's side data). This can be useful for debugging aspect ratio issues. +See standards ETSI TS 101 154 or SMPTE ST2016-1 for more details on its meaning. + @item expr, e The expression evaluation result. diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 7854362..76ab016 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -319,7 +319,6 @@ typedef struct DrawTextContext { int text_shaping; ///< 1 to shape the text before drawing it #endif AVDictionary *metadata; - int boxw; ///< the value of the boxw parameter int boxh; ///< the value of the boxh parameter int text_align; ///< the horizontal and vertical text alignment @@ -331,6 +330,7 @@ typedef struct DrawTextContext { int tab_count; ///< the number of tab characters int blank_advance64; ///< the size of the space character int tab_warning_printed; ///< ensure the tab warning to be printed only once + AVFrame *frame; } DrawTextContext; #define OFFSET(x) offsetof(DrawTextContext, x) @@ -1251,6 +1251,22 @@ static int func_metadata(AVFilterContext *ctx, AVBPrint *bp, return 0; } +static int func_afd(AVFilterContext *ctx, AVBPrint *bp, + char *fct, unsigned argc, char **argv, int tag) +{ + DrawTextContext *s = ctx->priv; + AVFrameSideData *side_data; + + side_data = av_frame_get_side_data(s->frame, AV_FRAME_DATA_AFD); + if (side_data) { + av_bprintf(bp, "0x%02x", side_data->data[0]); + } else { + av_bprintf(bp, "none"); + } + + return 0; +} + static int func_strftime(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag) { @@ -1429,6 +1445,7 @@ static const struct drawtext_function { { "frame_num", 0, 0, 0, func_frame_num }, { "n", 0, 0, 0, func_frame_num }, { "metadata", 1, 2, 0, func_metadata }, + { "afd", 0, 0, 0, func_afd }, }; static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct, @@ -2153,6 +2170,7 @@ FF_ENABLE_DEPRECATION_WARNINGS s->var_values[VAR_DURATION] = frame->duration * av_q2d(inlink->time_base); s->metadata = frame->metadata; + s->frame = frame; for (int i = 0; i < loop; i++) { if (header) {