* [FFmpeg-devel] [PATCH v2 1/7] libavcodec: Preserve AFD side data when going from AVPacket to AVFrame
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 ` Devin Heitmueller
2023-07-02 17:38 ` Marton Balint
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 2/7] vf_drawtext: Add ability to show AFD value Devin Heitmueller
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Devin Heitmueller @ 2023-06-30 21:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Devin Heitmueller
This is needed to ensure that AFD data continues to work when
capturing V210 video with the Decklink libavdevice input.
Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
libavcodec/decode.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a7c1302..6ee2c85 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1331,6 +1331,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx,
{ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
{ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
{ AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC },
+ { AV_PKT_DATA_AFD, AV_FRAME_DATA_AFD },
{ AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE },
{ AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE },
{ AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
--
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/7] libavcodec: Preserve AFD side data when going from AVPacket to AVFrame
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
0 siblings, 0 replies; 15+ messages in thread
From: Marton Balint @ 2023-07-02 17:38 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, 30 Jun 2023, Devin Heitmueller wrote:
> This is needed to ensure that AFD data continues to work when
> capturing V210 video with the Decklink libavdevice input.
>
Will apply.
Thanks,
Marton
> Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
> ---
> libavcodec/decode.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index a7c1302..6ee2c85 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1331,6 +1331,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx,
> { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
> { AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
> { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC },
> + { AV_PKT_DATA_AFD, AV_FRAME_DATA_AFD },
> { AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE },
> { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE },
> { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
> --
> 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".
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* [FFmpeg-devel] [PATCH v2 2/7] vf_drawtext: Add ability to show AFD value
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-06-30 21:38 ` Devin Heitmueller
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 3/7] avcodec/avframe: add new side data types for Bar Data Devin Heitmueller
` (5 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Devin Heitmueller @ 2023-06-30 21:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Devin Heitmueller
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/7] avcodec/avframe: add new side data types for Bar Data
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-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 2/7] vf_drawtext: Add ability to show AFD value Devin Heitmueller
@ 2023-06-30 21:38 ` Devin Heitmueller
2023-07-01 8:11 ` Anton Khirnov
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 4/7] libavfilter: Add filter to insert AFD/bar data Devin Heitmueller
` (4 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Devin Heitmueller @ 2023-06-30 21:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Devin Heitmueller
Add new side data types for both AVPacket and AVFrame to support
"bar data" as defined in SMPTE 2016-1, ATSC A/53, and SCTE 128-1.
Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
libavcodec/decode.c | 1 +
libavcodec/defs.h | 12 ++++++++++++
libavcodec/packet.h | 6 ++++++
libavutil/frame.h | 6 ++++++
4 files changed, 25 insertions(+)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6ee2c85..5aafce7 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1332,6 +1332,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx,
{ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
{ AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC },
{ AV_PKT_DATA_AFD, AV_FRAME_DATA_AFD },
+ { AV_PKT_DATA_BARDATA, AV_FRAME_DATA_BARDATA },
{ AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE },
{ AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE },
{ AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
diff --git a/libavcodec/defs.h b/libavcodec/defs.h
index fbe3254..deadfe7 100644
--- a/libavcodec/defs.h
+++ b/libavcodec/defs.h
@@ -119,6 +119,18 @@ typedef struct AVPanScan {
} AVPanScan;
/**
+ * Bar data - used by side data for avcodec and avframe. Defines the location
+ * of horizontal or vertical black bars (i.e. letterbox/pillar bars)
+ */
+typedef struct AVBarData {
+ int top_bottom; /* 0=top/bottom 1=left/right */
+ int top;
+ int left;
+ int bottom;
+ int right;
+} AVBarData;
+
+/**
* This structure describes the bitrate properties of an encoded bitstream. It
* roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
* parameters for H.264/HEVC.
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index f28e7e7..bdad21e 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -300,6 +300,12 @@ enum AVPacketSideDataType {
AV_PKT_DATA_DYNAMIC_HDR10_PLUS,
/**
+ * Bar data. See SMPTE ST2016-1, ATSC A/53, SCTE 128-1
+ * Format for this data can be found in the AVBarData struct
+ */
+ AV_PKT_DATA_BARDATA,
+
+ /**
* The number of side data types.
* This is not part of the public API/ABI in the sense that it may
* change when new side data types are added.
diff --git a/libavutil/frame.h b/libavutil/frame.h
index a491315..317b663 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -214,6 +214,12 @@ enum AVFrameSideDataType {
* Ambient viewing environment metadata, as defined by H.274.
*/
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
+ /**
+ * SMPTE ST 2016-1 Bar data
+ * The data is the AVBarData struct defined in libavcodec.
+ * Note: See SMPTE ST 2016-1:2009 Section 8 for the interaction between AFD and Bar Data
+ */
+ AV_FRAME_DATA_BARDATA,
};
enum AVActiveFormatDescription {
--
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 3/7] avcodec/avframe: add new side data types for Bar Data
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
0 siblings, 1 reply; 15+ messages in thread
From: Anton Khirnov @ 2023-07-01 8:11 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Devin Heitmueller
Quoting Devin Heitmueller (2023-06-30 23:38:51)
> Add new side data types for both AVPacket and AVFrame to support
> "bar data" as defined in SMPTE 2016-1, ATSC A/53, and SCTE 128-1.
>
> Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
> ---
> libavcodec/decode.c | 1 +
> libavcodec/defs.h | 12 ++++++++++++
> libavcodec/packet.h | 6 ++++++
> libavutil/frame.h | 6 ++++++
> 4 files changed, 25 insertions(+)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 6ee2c85..5aafce7 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1332,6 +1332,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx,
> { AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
> { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC },
> { AV_PKT_DATA_AFD, AV_FRAME_DATA_AFD },
> + { AV_PKT_DATA_BARDATA, AV_FRAME_DATA_BARDATA },
> { AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE },
> { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE },
> { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
> diff --git a/libavcodec/defs.h b/libavcodec/defs.h
> index fbe3254..deadfe7 100644
> --- a/libavcodec/defs.h
> +++ b/libavcodec/defs.h
> @@ -119,6 +119,18 @@ typedef struct AVPanScan {
> } AVPanScan;
>
> /**
> + * Bar data - used by side data for avcodec and avframe. Defines the location
> + * of horizontal or vertical black bars (i.e. letterbox/pillar bars)
> + */
> +typedef struct AVBarData {
> + int top_bottom; /* 0=top/bottom 1=left/right */
> + int top;
> + int left;
> + int bottom;
> + int right;
Am I understanding correctly that half of these are never used for a
given AVBarData instance? Seems wasteful. Could make it a generic
bound0, bound1 or a union instead.
--
Anton Khirnov
_______________________________________________
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 3/7] avcodec/avframe: add new side data types for Bar Data
2023-07-01 8:11 ` Anton Khirnov
@ 2023-07-03 12:51 ` Devin Heitmueller
0 siblings, 0 replies; 15+ messages in thread
From: Devin Heitmueller @ 2023-07-03 12:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches, Devin Heitmueller
On Sat, Jul 1, 2023 at 4:11 AM Anton Khirnov <anton@khirnov.net> wrote:
> > /**
> > + * Bar data - used by side data for avcodec and avframe. Defines the location
> > + * of horizontal or vertical black bars (i.e. letterbox/pillar bars)
> > + */
> > +typedef struct AVBarData {
> > + int top_bottom; /* 0=top/bottom 1=left/right */
> > + int top;
> > + int left;
> > + int bottom;
> > + int right;
>
> Am I understanding correctly that half of these are never used for a
> given AVBarData instance? Seems wasteful. Could make it a generic
> bound0, bound1 or a union instead.
It was only an extra eight bytes per video frame, so I wasn't
particularly worried about the size. That said, perhaps a union would
make it more clear that you can't set both simultaneously.
Devin
--
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com e: devin.heitmueller@ltnglobal.com
_______________________________________________
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* [FFmpeg-devel] [PATCH v2 4/7] libavfilter: Add filter to insert AFD/bar data
2023-06-30 21:38 [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
` (2 preceding siblings ...)
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 3/7] avcodec/avframe: add new side data types for Bar Data Devin Heitmueller
@ 2023-06-30 21:38 ` 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
` (3 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Devin Heitmueller @ 2023-06-30 21:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Devin Heitmueller
Introduce a new filter which allows the user to manually set the
AFD or bar data side data on AVFrames.
Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
doc/filters.texi | 52 ++++++++++++++++++
libavfilter/Makefile | 1 +
libavfilter/allfilters.c | 1 +
libavfilter/vf_afd.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 187 insertions(+)
create mode 100644 libavfilter/vf_afd.c
diff --git a/doc/filters.texi b/doc/filters.texi
index 793868b..ae74b4c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21338,6 +21338,58 @@ This filter use field-dominance information in frame to decide which
of each pair of fields to place first in the output.
If it gets it wrong use @ref{setfield} filter before @code{separatefields} filter.
+@section setafd
+
+The @code{setafd} filter sets the Aspect Ratio Description side data for the
+output video.
+
+This filter allows configuration of AFD metadata (conforming to
+ETSI TS 101 154 or SMPTE ST2016-1), as well as Bar Data (conforming to
+SMPTE 2016-1, ATSC A/53, and SCTE 128-1)
+
+It accepts the following parameters:
+
+@table @option
+
+@item afd
+This parameters dictates whether AFD side data will be injected. It is
+enabled by default.
+
+@item code
+If AFD output is enabled, this parameter will specify the AFD code to
+insert into the video stream. Valid values are from 0x00 to 0x0f.
+
+@item bardata
+This parameter dictates whether bar data will be injected. It is
+disabled by default.
+
+@item top
+@item bottom
+@item left
+@item right
+If bardata output is enabled, These parameters specify the dimensions
+of the bar data. Typically only top/bottom or left/right would be specified.
+If either top or bottom are specified, the bar data inserted will be for those
+parameters (even if left/right are also specified).
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Set the AFD value to 0x08
+@example
+ffmpeg -i INPUT -vf setafd=code=0x08 OUTPUT
+@end example
+@item
+Set the Bar data to a top width of 100 and a bottom width of 120
+@example
+ffmpeg -i INPUT -vf setafd=afd=0:bardata=1:top=100:bottom=120 OUTPUT
+@end example
+
+@end itemize
+
@section setdar, setsar
The @code{setdar} filter sets the Display Aspect Ratio for the filter
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9b78135..6153fac 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -469,6 +469,7 @@ OBJS-$(CONFIG_SELECTIVECOLOR_FILTER) += vf_selectivecolor.o
OBJS-$(CONFIG_SENDCMD_FILTER) += f_sendcmd.o
OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += vf_separatefields.o
OBJS-$(CONFIG_SETDAR_FILTER) += vf_aspect.o
+OBJS-$(CONFIG_SETAFD_FILTER) += vf_afd.o
OBJS-$(CONFIG_SETFIELD_FILTER) += vf_setparams.o
OBJS-$(CONFIG_SETPARAMS_FILTER) += vf_setparams.o
OBJS-$(CONFIG_SETPTS_FILTER) += setpts.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9a7fadc..7d2114c 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -438,6 +438,7 @@ extern const AVFilter ff_vf_select;
extern const AVFilter ff_vf_selectivecolor;
extern const AVFilter ff_vf_sendcmd;
extern const AVFilter ff_vf_separatefields;
+extern const AVFilter ff_vf_setafd;
extern const AVFilter ff_vf_setdar;
extern const AVFilter ff_vf_setfield;
extern const AVFilter ff_vf_setparams;
diff --git a/libavfilter/vf_afd.c b/libavfilter/vf_afd.c
new file mode 100644
index 0000000..a6120c8
--- /dev/null
+++ b/libavfilter/vf_afd.c
@@ -0,0 +1,133 @@
+/*
+ * AFD and Bardata Insertion Filter
+ * Copyright (c) 2023 LTN Global Communications
+ *
+ * Author: Devin Heitmueller <dheitmueller@ltnglobal.com>
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * Active Format Description and Bar Data Insertion Filter
+ */
+
+#include "libavcodec/defs.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "internal.h"
+
+typedef struct AFDContext {
+ const AVClass *class;
+ int enable_afd;
+ int afd_code;
+ int enable_bardata;
+ int top;
+ int bottom;
+ int left;
+ int right;
+} AFDContext;
+
+static int filter_frame(AVFilterLink *link, AVFrame *frame)
+{
+ AFDContext *s = link->dst->priv;
+ AVFrameSideData *side_data;
+ AVBarData *bar_data;
+
+ /* Insert/tweak the side-data for AFD */
+ if (s->enable_afd) {
+ /* Insert/tweak the side-data for Bar Data */
+ side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_AFD);
+ if (!side_data) {
+ side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_AFD, sizeof(unsigned char));
+ if (side_data == NULL)
+ return -ENOMEM;
+ }
+ side_data->data[0] = s->afd_code;
+ }
+
+ if (s->enable_bardata) {
+ /* Insert/tweak the side-data for Bar Data */
+ side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_BARDATA);
+ if (!side_data) {
+ side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_BARDATA, sizeof(AVBarData));
+ if (side_data == NULL)
+ return -ENOMEM;
+ }
+ bar_data = (AVBarData *) side_data->data;
+ if (s->top || s->bottom) {
+ bar_data->top_bottom = 1;
+ bar_data->top = s->top;
+ bar_data->bottom = s->bottom;
+ bar_data->left = 0;
+ bar_data->right = 0;
+ } else {
+ bar_data->top_bottom = 0;
+ bar_data->top = 0;
+ bar_data->bottom = 0;
+ bar_data->left = s->left;
+ bar_data->right = s->right;
+ }
+ }
+
+ return ff_filter_frame(link->dst->outputs[0], frame);
+}
+
+#define OFFSET(x) offsetof(AFDContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+
+static const AVOption setafd_options[] = {
+ /* AFD Options */
+ { "afd", "Enable AFD insertion", OFFSET(enable_afd), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, .flags = FLAGS },
+ { "code", "AFD code to insert", OFFSET(afd_code), AV_OPT_TYPE_INT, {.i64=0}, 0, 0x0F, FLAGS },
+
+ /* Bar data Options */
+ { "bardata","Enable Bar Data insertion", OFFSET(enable_bardata), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, .flags = FLAGS },
+ { "top", "top bar position", OFFSET(top), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+ { "bottom","bottom bar position", OFFSET(bottom), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+ { "left", "left bar position", OFFSET(left), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+ { "right", "right bar position", OFFSET(right), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
+ { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(setafd);
+
+static const AVFilterPad avfilter_vf_setafd_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .filter_frame = filter_frame,
+ },
+};
+
+static const AVFilterPad avfilter_vf_setafd_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ },
+};
+
+const AVFilter ff_vf_setafd = {
+ .name = "setafd",
+ .description = NULL_IF_CONFIG_SMALL("Set AFD and/or Bar Data for video frames"),
+ .priv_size = sizeof(AFDContext),
+ .priv_class = &setafd_class,
+ .flags = AVFILTER_FLAG_METADATA_ONLY,
+ FILTER_INPUTS(avfilter_vf_setafd_inputs),
+ FILTER_OUTPUTS(avfilter_vf_setafd_outputs),
+};
--
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* [FFmpeg-devel] [PATCH v2 5/7] libavutil: Provide a side data description for newly introduced bar data
2023-06-30 21:38 [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
` (3 preceding siblings ...)
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 ` Devin Heitmueller
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 6/7] v210enc: Pass through " Devin Heitmueller
` (2 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Devin Heitmueller @ 2023-06-30 21:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Devin Heitmueller
Add a new description for bar data, so that the presence of bar
data can be seen through ffprobe.
Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
libavutil/frame.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavutil/frame.c b/libavutil/frame.c
index b6cee2d..03d1b31 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -941,6 +941,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type)
case AV_FRAME_DATA_REPLAYGAIN: return "AVReplayGain";
case AV_FRAME_DATA_DISPLAYMATRIX: return "3x3 displaymatrix";
case AV_FRAME_DATA_AFD: return "Active format description";
+ case AV_FRAME_DATA_BARDATA: return "SMPTE 2016-1 bar data";
case AV_FRAME_DATA_MOTION_VECTORS: return "Motion vectors";
case AV_FRAME_DATA_SKIP_SAMPLES: return "Skip samples";
case AV_FRAME_DATA_AUDIO_SERVICE_TYPE: return "Audio service type";
--
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* [FFmpeg-devel] [PATCH v2 6/7] v210enc: Pass through bar data
2023-06-30 21:38 [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
` (4 preceding siblings ...)
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 ` Devin Heitmueller
2023-06-30 22:41 ` Kieran Kunhya
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
7 siblings, 1 reply; 15+ messages in thread
From: Devin Heitmueller @ 2023-06-30 21:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Devin Heitmueller
When encoding to V210, make sure the bar side data makes it through
in the resulting AVPacket. This is needed so the decklink output
module can put out bar data as VANC when in 10-bit mode.
Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
libavcodec/v210enc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 2a30ed7..69a2d72 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -103,6 +103,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
memcpy(buf, side_data->data, side_data->size);
}
+ side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_BARDATA);
+ if (side_data && side_data->size) {
+ uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_BARDATA, side_data->size);
+ if (!buf)
+ return AVERROR(ENOMEM);
+ memcpy(buf, side_data->data, side_data->size);
+ }
+
*got_packet = 1;
return 0;
}
--
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/7] v210enc: Pass through bar data
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
0 siblings, 1 reply; 15+ messages in thread
From: Kieran Kunhya @ 2023-06-30 22:41 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Devin Heitmueller
On Fri, 30 Jun 2023 at 21:42, Devin Heitmueller <
devin.heitmueller@ltnglobal.com> wrote:
> When encoding to V210, make sure the bar side data makes it through
> in the resulting AVPacket. This is needed so the decklink output
> module can put out bar data as VANC when in 10-bit mode.
>
ff_decode_frame_props_from_pkt surely does this better than the mess of ifs
in v210enc?
Kieran
_______________________________________________
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 6/7] v210enc: Pass through bar data
2023-06-30 22:41 ` Kieran Kunhya
@ 2023-07-01 0:44 ` Devin Heitmueller
0 siblings, 0 replies; 15+ messages in thread
From: Devin Heitmueller @ 2023-07-01 0:44 UTC (permalink / raw)
To: Kieran Kunhya
Cc: Devin Heitmueller, FFmpeg development discussions and patches
Hi Kieran,
On Fri, Jun 30, 2023 at 6:41 PM Kieran Kunhya <kierank@obe.tv> wrote:
>
> On Fri, 30 Jun 2023 at 21:42, Devin Heitmueller <devin.heitmueller@ltnglobal.com> wrote:
>>
>> When encoding to V210, make sure the bar side data makes it through
>> in the resulting AVPacket. This is needed so the decklink output
>> module can put out bar data as VANC when in 10-bit mode.
>
>
> ff_decode_frame_props_from_pkt surely does this better than the mess of ifs in v210enc?
The ff_decode_frame_props_from_pkt() function is used when going from
AVPackets to AVFrames. The v210enc codec goes in the other direction
- from AVFrames to AVPackets. In fact
ff_decode_frame_props_from_pkt() does get used by v210dec.
Now I wouldn't necessarily be against somebody introducing a new
function which goes in the opposite direction and could potentially be
shared by other encoders. But my intent was just to implement it the
same way as the other conversions were done, not to refactor the code
and design some new approach.
Devin
--
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com e: devin.heitmueller@ltnglobal.com
_______________________________________________
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* [FFmpeg-devel] [PATCH v2 7/7] avdevice/decklink_enc: Add support for output of bar data as VANC
2023-06-30 21:38 [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
` (5 preceding siblings ...)
2023-06-30 21:38 ` [FFmpeg-devel] [PATCH v2 6/7] v210enc: Pass through " Devin Heitmueller
@ 2023-06-30 21:38 ` Devin Heitmueller
2023-07-01 8:14 ` [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Anton Khirnov
7 siblings, 0 replies; 15+ messages in thread
From: Devin Heitmueller @ 2023-06-30 21:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Devin Heitmueller
SMPTE ST2016-3 supports both AFD and bar data within the VANC message.
Extend the existing support to pass through both.
Example usage:
ffmpeg -i input.ts -vf setafd=afd=1:code=0x00:bardata=1:top=100:bottom=120 -f decklink -vcodec v210 'DeckLink Duo (4)'
Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
---
libavdevice/decklink_enc.cpp | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 11e67c4..9ad902f 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -467,23 +467,39 @@ static void construct_afd(AVFormatContext *avctx, struct decklink_ctx *ctx,
struct klvanc_packet_afd_s *afd = NULL;
uint16_t *afd_words = NULL;
uint16_t len;
- size_t size;
+ size_t size, bardata_size;
int f1_line = 12, f2_line = 0, ret;
const uint8_t *data = av_packet_get_side_data(pkt, AV_PKT_DATA_AFD, &size);
- if (!data || size == 0)
+ const AVBarData *bardata = (AVBarData *) av_packet_get_side_data(pkt, AV_PKT_DATA_BARDATA, &bardata_size);
+
+ if ((!data || size == 0) && (!bardata || bardata_size != sizeof(AVBarData)))
return;
ret = klvanc_create_AFD(&afd);
if (ret)
return;
- ret = klvanc_set_AFD_val(afd, data[0]);
- if (ret) {
- av_log(avctx, AV_LOG_ERROR, "Invalid AFD value specified: %d\n",
- data[0]);
- klvanc_destroy_AFD(afd);
- return;
+ if (data) {
+ ret = klvanc_set_AFD_val(afd, data[0]);
+ if (ret) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid AFD value specified: %d\n",
+ data[0]);
+ klvanc_destroy_AFD(afd);
+ return;
+ }
+ }
+
+ if (bardata) {
+ if (bardata->top_bottom) {
+ afd->barDataFlags = BARS_TOPBOTTOM;
+ afd->top = bardata->top;
+ afd->bottom = bardata->bottom;
+ } else {
+ afd->barDataFlags = BARS_LEFTRIGHT;
+ afd->left = bardata->left;
+ afd->right = bardata->right;
+ }
}
/* Compute the AR flag based on the DAR (see ST 2016-1:2009 Sec 9.1). Note, we treat
--
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data
2023-06-30 21:38 [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data Devin Heitmueller
` (6 preceding siblings ...)
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 ` Anton Khirnov
2023-07-03 13:44 ` Devin Heitmueller
7 siblings, 1 reply; 15+ messages in thread
From: Anton Khirnov @ 2023-07-01 8:14 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Devin Heitmueller
IIUC the only source of bar data after this set is the new filter you're
adding. Is there supposed to be some other demuxer or decoder that
produces it?
Also, FATE tests would be much appreciated.
--
Anton Khirnov
_______________________________________________
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".
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 0/7] Misc AFD improvements and support for Bar Data
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
0 siblings, 0 replies; 15+ messages in thread
From: Devin Heitmueller @ 2023-07-03 13:44 UTC (permalink / raw)
To: FFmpeg development discussions and patches, Devin Heitmueller
Hi Anton,
On Sat, Jul 1, 2023 at 4:14 AM Anton Khirnov <anton@khirnov.net> wrote:
>
> IIUC the only source of bar data after this set is the new filter you're
> adding. Is there supposed to be some other demuxer or decoder that
> produces it?
I have support in my tree for the H.264 and HEVC decoders, but I still
need to rebase it against master.
> Also, FATE tests would be much appreciated.
Sure. At this point it wasn't clear I could do FATE tests since the
patch series today only includes support for filtering and the
decklink output. I agree though that once the H.264 and/or HEVC stuff
is submitted it makes sense to generate a short sample for FATE usage.
Devin
--
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com e: devin.heitmueller@ltnglobal.com
_______________________________________________
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".
^ permalink raw reply [flat|nested] 15+ messages in thread