Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Devin Heitmueller <devin.heitmueller@ltnglobal.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Devin Heitmueller <dheitmueller@ltnglobal.com>
Subject: [FFmpeg-devel] [PATCH v2 2/7] vf_drawtext: Add ability to show AFD value
Date: Fri, 30 Jun 2023 17:38:50 -0400
Message-ID: <1688161135-11774-3-git-send-email-dheitmueller@ltnglobal.com> (raw)
In-Reply-To: <1688161135-11774-1-git-send-email-dheitmueller@ltnglobal.com>

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 <dheitmueller@ltnglobal.com>

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) {
-- 
1.8.3.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2023-06-30 20:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30 21:38 [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 1/7] libavcodec: Preserve AFD side data when going from AVPacket to AVFrame Devin Heitmueller
2023-07-02 17:38   ` Marton Balint
2023-06-30 21:38 ` Devin Heitmueller [this message]
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 3/7] avcodec/avframe: add new side data types for Bar Data Devin Heitmueller
2023-07-01  8:11   ` Anton Khirnov
2023-07-03 12:51     ` Devin Heitmueller
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 4/7] libavfilter: Add filter to insert AFD/bar data Devin Heitmueller
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 5/7] libavutil: Provide a side data description for newly introduced bar data Devin Heitmueller
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 6/7] v210enc: Pass through " Devin Heitmueller
2023-06-30 22:41   ` Kieran Kunhya
2023-07-01  0:44     ` Devin Heitmueller
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 7/7] avdevice/decklink_enc: Add support for output of bar data as VANC Devin Heitmueller
2023-07-01  8:14 ` [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Anton Khirnov
2023-07-03 13:44   ` Devin Heitmueller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1688161135-11774-3-git-send-email-dheitmueller@ltnglobal.com \
    --to=devin.heitmueller@ltnglobal.com \
    --cc=dheitmueller@ltnglobal.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git