[FFmpeg-devel] [PATCH] avfilter/setpts: add command support

2023-05-01 Thread Oleg Afanasyev
I'm using setpts to generate timelapses with slowdowns in the middle.
Using setpts filter requires complicated expr to handle intervals. This
patch allows commands to change expr and also adds a constant that
provides time of last command applications to allow specifying gradual
changes using difference between time and cmd time.

--
with best regards
Oleg Afanasyev
From a714a0957a57c1d392feca0ba675ba5ac7c875ee Mon Sep 17 00:00:00 2001
From: Oleg 
Date: Sat, 29 Apr 2023 19:56:46 +0100
Subject: [PATCH] avfilter/setpts: add command support

Add support for changing expr on the fly.

Signed-off-by: Oleg 
---
 doc/filters.texi |  7 +
 libavfilter/setpts.c | 68 +---
 2 files changed, 58 insertions(+), 17 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 50e1682144..fbdb1f8ecf 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -29384,6 +29384,9 @@ The wallclock (RTC) time at the start of the movie in microseconds.
 @item TB
 The timebase of the input timestamps.
 
+@item T_CHANGE
+Time of the first frame after command was applied or time of the first frame if no commands.
+
 @end table
 
 @subsection Examples
@@ -29439,6 +29442,10 @@ asetpts=N/SR/TB
 
 @end itemize
 
+@subsection Commands
+
+Both filters support all above options as @ref{commands}.
+
 @section setrange
 
 Force color range for the output video frame.
diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c
index 5bcc0c2dcf..7b09ce7707 100644
--- a/libavfilter/setpts.c
+++ b/libavfilter/setpts.c
@@ -63,6 +63,7 @@ static const char *const var_names[] = {
 "S",   //   Number of samples in the current frame
 "SR",  //   Audio sample rate
 "FR",  ///< defined only for constant frame-rate video
+"T_CHANGE",///< time of first frame after latest command was applied
 NULL
 };
 
@@ -90,7 +91,8 @@ enum var_name {
 VAR_S,
 VAR_SR,
 VAR_FR,
-VAR_VARS_NB
+VAR_T_CHANGE,
+VAR_VARS_NB,
 };
 
 typedef struct SetPTSContext {
@@ -120,6 +122,7 @@ static av_cold int init(AVFilterContext *ctx)
 setpts->var_values[VAR_PREV_OUTT]   = NAN;
 setpts->var_values[VAR_STARTPTS]= NAN;
 setpts->var_values[VAR_STARTT]  = NAN;
+setpts->var_values[VAR_T_CHANGE]= NAN;
 return 0;
 }
 
@@ -163,6 +166,9 @@ static double eval_pts(SetPTSContext *setpts, AVFilterLink *inlink, AVFrame *fra
 setpts->var_values[VAR_STARTPTS] = TS2D(pts);
 setpts->var_values[VAR_STARTT  ] = TS2T(pts, inlink->time_base);
 }
+if (isnan(setpts->var_values[VAR_T_CHANGE])) {
+setpts->var_values[VAR_T_CHANGE] = TS2T(pts, inlink->time_base);
+}
 setpts->var_values[VAR_PTS   ] = TS2D(pts);
 setpts->var_values[VAR_T ] = TS2T(pts, inlink->time_base);
 #if FF_API_FRAME_PKT
@@ -269,14 +275,40 @@ static av_cold void uninit(AVFilterContext *ctx)
 setpts->expr = NULL;
 }
 
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *arg,
+   char *res, int res_len, int flags)
+{
+SetPTSContext *setpts = ctx->priv;
+int ret;
+
+ret = ff_filter_process_command(ctx, cmd, arg, res, res_len, flags);
+
+if (ret < 0)
+return ret;
+
+if (!strcmp(cmd, "expr")) {
+av_expr_free(setpts->expr);
+ret = av_expr_parse(>expr, arg, var_names, NULL, NULL, NULL, NULL, 0, ctx);
+if (ret < 0) {
+av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", arg);
+}
+setpts->var_values[VAR_T_CHANGE] = NAN;
+} else {
+ret = AVERROR(EINVAL);
+}
+
+return ret;
+}
+
 #define OFFSET(x) offsetof(SetPTSContext, x)
 #define V AV_OPT_FLAG_VIDEO_PARAM
 #define A AV_OPT_FLAG_AUDIO_PARAM
+#define R AV_OPT_FLAG_RUNTIME_PARAM
 #define F AV_OPT_FLAG_FILTERING_PARAM
 
 #if CONFIG_SETPTS_FILTER
 static const AVOption setpts_options[] = {
-{ "expr", "Expression determining the frame timestamp", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "PTS" }, .flags = V|F },
+{ "expr", "Expression determining the frame timestamp", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "PTS" }, .flags = V|F|R },
 { NULL }
 };
 AVFILTER_DEFINE_CLASS(setpts);
@@ -297,12 +329,13 @@ static const AVFilterPad avfilter_vf_setpts_outputs[] = {
 };
 
 const AVFilter ff_vf_setpts = {
-.name  = "setpts",
-.description = NULL_IF_CONFIG_SMALL("Set PTS for the output video frame."),
-.init  = init,
-.activate  = activate,
-.uninit= uninit,
-.flags = AVFILTER_FLAG_METADATA_ONLY,
+.name= "setpts",
+.description = NULL_IF_CONFIG_SMALL("Set PTS for the output video frame."),
+.init= init,
+.activate= activate,
+.uninit  = uninit,
+.process_command = process_command,
+.flags   = AVFILTER_FLAG_METADATA_ONLY,
 
 .priv_size = sizeof(SetPTSContext),
 .priv_class = 

[FFmpeg-devel] [PATCH 2/3] avfilter/vf_libplacebo: add flexible crop exprs

2023-05-01 Thread Niklas Haas
From: Niklas Haas 

Motivated by a desire to use vf_libplacebo as a GPU-accelerated
cropping/padding/zooming filter. This commit adds support for setting
the `input/target.crop` fields as dynamic expressions.

Re-use the same generic variables available to other scale and crop type
filters, and also add some more that we can afford as a result of being
able to set these properties dynamically.

It's worth pointing out that `out_t/ot` is currently redundant with
`in_t/t` since it will always contain the same PTS values, but I plan on
changing this in the near future.

I decided to also expose `crop_w/crop_h` and `pos_w/pos_h` as variables
in the expression parser itself, since this enables the fairly common
use case of determining dimensions first and then placing the image
appropriately, such as is done in the default behavior (which centers
the cropped/placed region by default).
---
 doc/filters.texi|  55 --
 libavfilter/vf_libplacebo.c | 145 +++-
 2 files changed, 192 insertions(+), 8 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 35df5c339a7..2d49f93b9e2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15991,10 +15991,31 @@ in source frames.
 @table @option
 @item w
 @item h
-Set the output video dimension expression. Default value is the input 
dimension.
+Set the output video dimension expression. Default values are @code{iw} and
+@code{ih}.
 
 Allows for the same expressions as the @ref{scale} filter.
 
+@item crop_x
+@item crop_y
+Set the input crop x/y expressions, default values are @code{(iw-cw)/2} and
+@code{(ih-ch)/2}.
+
+@item crop_w
+@item crop_h
+Set the input crop width/height expressions, default values are @code{iw} and
+@code{ih}.
+
+@item pos_x
+@item pos_y
+Set the output placement x/y expressions, default values are @code{(ow-pw)/2}
+and @code{(oh-ph)/2}.
+
+@item pos_w
+@item pos_h
+Set the output placement width/height expressions, default values are @code{ow}
+and @code{oh}.
+
 @item format
 Set the output format override. If unset (the default), frames will be output
 in the same format as the respective input frames. Otherwise, format conversion
@@ -16006,9 +16027,9 @@ Work the same as the identical @ref{scale} filter 
options.
 
 @item normalize_sar
 If enabled, output frames will always have a pixel aspect ratio of 1:1. This
-will introduce padding/cropping as necessary. If disabled (the default), any
-aspect ratio mismatches, including those from e.g. anamorphic video sources,
-are forwarded to the output pixel aspect ratio.
+will introduce additional padding/cropping as necessary. If disabled (the
+default), any aspect ratio mismatches, including those from e.g. anamorphic
+video sources, are forwarded to the output pixel aspect ratio.
 
 @item pad_crop_ratio
 Specifies a ratio (between @code{0.0} and @code{1.0}) between padding and
@@ -16020,7 +16041,7 @@ approaches.
 
 @item fillcolor
 Set the color used to fill the output area not covered by the output image, for
-example as a result of @ref{normalize_sar}. For the general syntax of this
+example as a result of @option{normalize_sar}. For the general syntax of this
 option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils
 manual,ffmpeg-utils}. Defaults to @code{black}.
 
@@ -16045,6 +16066,30 @@ BT.2020+PQ, overriding the usual input frame metadata. 
These will also be
 picked as the values of @code{auto} for the respective frame output options.
 @end table
 
+In addition to the expression constants documented for the @ref{scale} filter,
+the @option{crop_w}, @option{crop_h}, @option{crop_x}, @option{crop_y},
+@option{pos_w}, @option{pos_h}, @option{pos_x} and @option{pos_y} options can
+also contain the following constants:
+
+@table @option
+@item crop_w, cw
+@item crop_h, ch
+The computed values of @option{crop_w} and @option{crop_h}.
+
+@item pos_w, pw
+@item pos_h, ph
+The computed values of @option{pos_w} and @option{pos_h}.
+
+@item in_t, t
+The input frame timestamp, in seconds. NAN if input timestamp is unknown.
+
+@item out_t, ot
+The input frame timestamp, in seconds. NAN if input timestamp is unknown.
+
+@item n
+The input frame number, starting with 0.
+@end table
+
 @subsubsection Scaling
 The options in this section control how libplacebo performs upscaling and (if
 necessary) downscaling. Note that libplacebo will always internally operate on
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index fcdc97e48e2..6fe3e0ea882 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -16,6 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/eval.h"
 #include "libavutil/file.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
@@ -60,6 +61,50 @@ static const struct pl_tone_map_function * const 
tonemapping_funcs[TONE_MAP_COUN
 [TONE_MAP_LINEAR]= _tone_map_linear,
 };
 
+static const 

[FFmpeg-devel] [PATCH 3/3] doc/filters/libplacebo: fix outdated/wrong note

2023-05-01 Thread Niklas Haas
From: Niklas Haas 

This has not been the case since c0b93c4f8+48c385fb4c.
---
 doc/filters.texi | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 2d49f93b9e2..9ffa9dfe22f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15976,8 +15976,7 @@ ffmpeg -i input.mov -vf lensfun=make=Canon:model="Canon 
EOS 100D":lens_model="Ca
 @section libplacebo
 
 Flexible GPU-accelerated processing filter based on libplacebo
-(@url{https://code.videolan.org/videolan/libplacebo}). Note that this filter
-currently only accepts Vulkan input frames.
+(@url{https://code.videolan.org/videolan/libplacebo}).
 
 @subsection Options
 
-- 
2.40.0

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

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


[FFmpeg-devel] [PATCH 1/3] avfilter/vf_libplacebo: add fillcolor option

2023-05-01 Thread Niklas Haas
From: Niklas Haas 

In some circumstances, libplacebo will clear the background as a result
of cropping/padding. Currently, this uses the hard-coded default fill
color of black. This option makes this behavior configurable.
---
 doc/filters.texi|  6 ++
 libavfilter/vf_libplacebo.c | 22 ++
 2 files changed, 28 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6d2672063c1..35df5c339a7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16018,6 +16018,12 @@ content with black borders, while a value of 
@code{1.0} always crops off parts
 of the content. Intermediate values are possible, leading to a mix of the two
 approaches.
 
+@item fillcolor
+Set the color used to fill the output area not covered by the output image, for
+example as a result of @ref{normalize_sar}. For the general syntax of this
+option, check the @ref{color syntax,,"Color" section in the ffmpeg-utils
+manual,ffmpeg-utils}. Defaults to @code{black}.
+
 @item colorspace
 @item color_primaries
 @item color_trc
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 66929223dd9..fcdc97e48e2 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -18,6 +18,7 @@
 
 #include "libavutil/file.h"
 #include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
 #include "internal.h"
 #include "vulkan_filter.h"
 #include "scale_eval.h"
@@ -73,6 +74,7 @@ typedef struct LibplaceboContext {
 /* settings */
 char *out_format_string;
 enum AVPixelFormat out_format;
+char *fillcolor;
 char *w_expr;
 char *h_expr;
 AVRational target_sar;
@@ -225,6 +227,24 @@ static int find_scaler(AVFilterContext *avctx,
 return AVERROR(EINVAL);
 }
 
+static int parse_fillcolor(AVFilterContext *avctx,
+   struct pl_render_params *params,
+   const char *color_str)
+{
+int err = 0;
+uint8_t color_rgba[4];
+
+RET(av_parse_color(color_rgba, color_str, -1, avctx));
+params->background_color[0] = (float) color_rgba[0] / UINT8_MAX;
+params->background_color[1] = (float) color_rgba[1] / UINT8_MAX;
+params->background_color[2] = (float) color_rgba[2] / UINT8_MAX;
+params->background_transparency = 1.0f - (float) color_rgba[3] / UINT8_MAX;
+return 0;
+
+fail:
+return err;
+}
+
 static void libplacebo_uninit(AVFilterContext *avctx);
 
 static int libplacebo_init(AVFilterContext *avctx)
@@ -469,6 +489,7 @@ static int process_frames(AVFilterContext *avctx, AVFrame 
*out, AVFrame *in)
 
 RET(find_scaler(avctx, , s->upscaler));
 RET(find_scaler(avctx, , s->downscaler));
+RET(parse_fillcolor(avctx, , s->fillcolor));
 
 pl_render_image(s->renderer, , , );
 pl_unmap_avframe(s->gpu, );
@@ -703,6 +724,7 @@ static const AVOption libplacebo_options[] = {
 { "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256, STATIC },
 { "normalize_sar", "force SAR normalization to 1:1", 
OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
 { "pad_crop_ratio", "ratio between padding and cropping when normalizing 
SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 
0.0, 1.0, DYNAMIC },
+{ "fillcolor", "Background fill color", OFFSET(fillcolor), 
AV_OPT_TYPE_STRING, {.str = "black"}, .flags = DYNAMIC },
 
 {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, 
{.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
 {"auto", "keep the same colorspace",  0, AV_OPT_TYPE_CONST, {.i64=-1}, 
 INT_MIN, INT_MAX, STATIC, "colorspace"},
-- 
2.40.0

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

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


Re: [FFmpeg-devel] [PATCH 01/21] fftools/ffmpeg: deprecate -adrift_threshold

2023-05-01 Thread Paul B Mahol
Approved
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 01/21] fftools/ffmpeg: deprecate -adrift_threshold

2023-05-01 Thread Anton Khirnov
If nobody has further comments, I'm planning to push the set tomorrow.

-- 
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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] Embedded documentation?

2023-05-01 Thread Timo Rothenpieler

On 01.05.2023 12:13, Nicolas George wrote:

Hi.

Three years ago, I shared some brief thoughts about embedding the
documentation in the libraries. For example, that would allow GUI
applications to open help dialogs about specific options.

To see what it would need, I wrote the following header. I did not work
any further, because groundwork need to be laid first. But now that it
was mentioned in another thread, I think it is a good idea to show it,
to see how people like it.

Please share your remarks. Even “+1” to say you like it, because people
who will not like it will not hesitate to post “-1”.

Regards,


Somewhat loosely related to this:

A frequent issue is that it's entirely non-obvious which global 
libavcodec options a codec might make use of.
Having a way to self-document that would be amazing, so those options 
show up in the --help output, ideally with their codec-specific default.


The obvious idea I had for this was to utilize the FFCodecDefault struct 
which already exists, maybe expanding it a tiny bit to allow the second 
value to be NULL, indicating "This codec uses that option, but does not 
change the default".


Main issue with this is that FFCodecDefault is a private struct.
It could just be made public and user-queryable, while making every 
current user of it aware of possible NULL-values, which they can then 
just ignore.

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

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


[FFmpeg-devel] [PATCH] avfilter: add Affine Projection adaptive audio filter

2023-05-01 Thread Paul B Mahol
Attached patch.
From 391216f55c8e226974fb2e8a0e725b254811c2b7 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Sun, 30 Apr 2023 17:06:00 +0200
Subject: [PATCH] avfilter: add Affine Projection adaptive audio filter

Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile |   1 +
 libavfilter/af_aap.c | 452 +++
 libavfilter/allfilters.c |   1 +
 3 files changed, 454 insertions(+)
 create mode 100644 libavfilter/af_aap.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 0eee5fccbe..d7c79fabd6 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -34,6 +34,7 @@ OBJS-$(CONFIG_DNN)   += dnn_filter_common.o
 include $(SRC_PATH)/libavfilter/dnn/Makefile
 
 # audio filters
+OBJS-$(CONFIG_AAP_FILTER)+= af_aap.o
 OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
 OBJS-$(CONFIG_ACOMPRESSOR_FILTER)+= af_sidechaincompress.o
 OBJS-$(CONFIG_ACONTRAST_FILTER)  += af_acontrast.o
diff --git a/libavfilter/af_aap.c b/libavfilter/af_aap.c
new file mode 100644
index 00..2ee2b61558
--- /dev/null
+++ b/libavfilter/af_aap.c
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2023 Paul B Mahol
+ *
+ * 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
+ */
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/common.h"
+#include "libavutil/float_dsp.h"
+#include "libavutil/opt.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "filters.h"
+#include "internal.h"
+
+enum OutModes {
+IN_MODE,
+DESIRED_MODE,
+OUT_MODE,
+NOISE_MODE,
+NB_OMODES
+};
+
+typedef struct AudioAPContext {
+const AVClass *class;
+
+int order;
+int projection;
+float mu;
+float delta;
+int output_mode;
+
+int kernel_size;
+AVFrame *offset;
+AVFrame *delay;
+AVFrame *coeffs;
+AVFrame *e;
+AVFrame *p;
+AVFrame *x;
+AVFrame *w;
+AVFrame *dcoeffs;
+AVFrame *tmp;
+AVFrame *tmpm;
+AVFrame *itmpm;
+
+float **tmpmp;
+float **itmpmp;
+
+AVFrame *frame[2];
+
+AVFloatDSPContext *fdsp;
+} AudioAPContext;
+
+#define OFFSET(x) offsetof(AudioAPContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define AT AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
+
+static const AVOption aap_options[] = {
+{ "order",  "set the filter order",  OFFSET(order),   AV_OPT_TYPE_INT,   {.i64=16},   1, INT16_MAX, A },
+{ "projection", "set the filter projection", OFFSET(projection),  AV_OPT_TYPE_INT,   {.i64=2},1, 256, A },
+{ "mu", "set the filter mu", OFFSET(mu),  AV_OPT_TYPE_FLOAT, {.dbl=0.0001},0,1, AT },
+{ "delta",  "set the filter delta",  OFFSET(delta),   AV_OPT_TYPE_FLOAT, {.dbl=0.001},0, 1, AT },
+{ "out_mode",   "set output mode",   OFFSET(output_mode), AV_OPT_TYPE_INT, {.i64=OUT_MODE}, 0, NB_OMODES-1, AT, "mode" },
+{  "i", "input",   0, AV_OPT_TYPE_CONST, {.i64=IN_MODE},  0, 0, AT, "mode" },
+{  "d", "desired", 0, AV_OPT_TYPE_CONST, {.i64=DESIRED_MODE}, 0, 0, AT, "mode" },
+{  "o", "output",  0, AV_OPT_TYPE_CONST, {.i64=OUT_MODE}, 0, 0, AT, "mode" },
+{  "n", "noise",   0, AV_OPT_TYPE_CONST, {.i64=NOISE_MODE},   0, 0, AT, "mode" },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(aap);
+
+static float fir_sample(AudioAPContext *s, float sample, float *delay,
+float *coeffs, float *tmp, int *offset)
+{
+const int order = s->order;
+float output;
+
+delay[*offset] = sample;
+
+memcpy(tmp, coeffs + order - *offset, order * sizeof(float));
+output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size);
+
+if (--(*offset) < 0)
+*offset = order - 1;
+
+return output;
+}
+
+static int lup_decompose(float **MA, int N, float tol, int *P)
+{
+float maxA, *ptr, absA;
+int i, j, k, imax;
+
+for (i = 0; i <= N; i++)
+P[i] = i;
+
+for (i = 0; i < N; i++) {
+maxA = 0.f;
+imax = i;
+
+for (k = i; k < N; k++)
+if ((absA = fabs(MA[k][i])) > maxA) {
+maxA = absA;
+imax = k;
+}
+
+if (maxA < tol)
+  

[FFmpeg-devel] [PATCH 1/2] avfilter/vf_tpad: use enum for start/stop_mode

2023-05-01 Thread Marvin Scholz
---
 libavfilter/vf_tpad.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index f0c065f0c3..88c3c99de4 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -27,6 +27,12 @@
 #include "formats.h"
 #include "drawutils.h"
 
+enum PadMode {
+MODE_ADD = 0,
+MODE_CLONE,
+NB_MODE
+};
+
 typedef struct TPadContext {
 const AVClass *class;
 int pad_start;
@@ -51,10 +57,10 @@ typedef struct TPadContext {
 static const AVOption tpad_options[] = {
 { "start", "set the number of frames to delay input",  
OFFSET(pad_start),  AV_OPT_TYPE_INT,   {.i64=0},0,   INT_MAX, VF },
 { "stop",  "set the number of frames to add after input finished", 
OFFSET(pad_stop),   AV_OPT_TYPE_INT,   {.i64=0},   -1,   INT_MAX, VF },
-{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
-{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=0},0, 0, VF, "mode" },
-{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=1},0, 0, VF, "mode" },
-{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=0},0, 1, VF, 
"mode" },
+{ "start_mode", "set the mode of added frames to start",   
OFFSET(start_mode), AV_OPT_TYPE_INT,   {.i64=MODE_ADD}, 0, NB_MODE-1, VF, 
"mode" },
+{ "add",   "add solid-color frames",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_ADD},   0, 0, VF, "mode" },
+{ "clone", "clone first/last frame",   0,  
AV_OPT_TYPE_CONST, {.i64=MODE_CLONE}, 0, 0, VF, "mode" },
+{ "stop_mode",  "set the mode of added frames to end", 
OFFSET(stop_mode),  AV_OPT_TYPE_INT,   {.i64=0},0, NB_MODE-1, VF, 
"mode" },
 { "start_duration", "set the duration to delay input", 
OFFSET(start_duration), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "stop_duration",  "set the duration to pad input",   
OFFSET(stop_duration),  AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT64_MAX, VF },
 { "color", "set the color of the added frames",
OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str="black"},  0, 0, VF },
@@ -91,7 +97,7 @@ static int activate(AVFilterContext *ctx)
 }
 }
 
-if (s->start_mode == 0 && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
+if (s->start_mode == MODE_ADD && s->pad_start > 0 && 
ff_outlink_frame_wanted(outlink)) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
@@ -106,7 +112,7 @@ static int activate(AVFilterContext *ctx)
 return ff_filter_frame(outlink, frame);
 }
 
-if (s->start_mode == 1 && s->pad_start > 0) {
+if (s->start_mode == MODE_CLONE && s->pad_start > 0) {
 if (s->eof) {
 ff_outlink_set_status(outlink, AVERROR_EOF, 0);
 return 0;
@@ -133,7 +139,7 @@ static int activate(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 if (ret > 0) {
-if (s->stop_mode == 1 && s->pad_stop != 0) {
+if (s->stop_mode == MODE_CLONE && s->pad_stop != 0) {
 av_frame_free(>cache_stop);
 s->cache_stop = av_frame_clone(frame);
 }
@@ -147,14 +153,14 @@ static int activate(AVFilterContext *ctx)
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
 return 0;
 }
-if (s->stop_mode == 0) {
+if (s->stop_mode == MODE_ADD) {
 frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!frame)
 return AVERROR(ENOMEM);
 ff_fill_rectangle(>draw, >color,
   frame->data, frame->linesize,
   0, 0, frame->width, frame->height);
-} else if (s->stop_mode == 1) {
+} else if (s->stop_mode == MODE_CLONE) {
 if (!s->cache_stop) {
 s->pad_stop = 0;
 ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH 2/2] avfilter/vf_tpad: accept hardware frames in clone-only mode

2023-05-01 Thread Marvin Scholz
When no drawing is to be performed, tpad can work fine with
hardware frames, so advertise this in the query_formats
callback and ensure the drawing context is never initialised
when just cloning frames.
---
 libavfilter/vf_tpad.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 88c3c99de4..cabfe33685 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -71,7 +71,12 @@ AVFILTER_DEFINE_CLASS(tpad);
 
 static int query_formats(AVFilterContext *ctx)
 {
-return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+TPadContext *s = ctx->priv;
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0))
+return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+
+return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
 }
 
 static int activate(AVFilterContext *ctx)
@@ -190,8 +195,11 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 TPadContext *s = ctx->priv;
 
-ff_draw_init(>draw, inlink->format, 0);
-ff_draw_color(>draw, >color, s->rgba_color);
+if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+(s->start_mode == MODE_ADD && s->pad_start != 0)) {
+ff_draw_init(>draw, inlink->format, 0);
+ff_draw_color(>draw, >color, s->rgba_color);
+}
 
 if (s->start_duration)
 s->pad_start = av_rescale_q(s->start_duration, inlink->frame_rate, 
av_inv_q(AV_TIME_BASE_Q));
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH 3/3] avutil/dict: constify av_dict_get return

2023-05-01 Thread Marvin Scholz
---
 doc/examples/qsv_transcode.c   |  2 +-
 libavcodec/libaomenc.c |  2 +-
 libavcodec/libkvazaar.c|  2 +-
 libavcodec/libsvtav1.c |  2 +-
 libavcodec/libvpxenc.c |  2 +-
 libavcodec/libx264.c   |  2 +-
 libavcodec/libx265.c   |  2 +-
 libavcodec/mjpegdec.c  |  2 +-
 libavcodec/qsvenc.c|  2 +-
 libavfilter/avfilter.c |  2 +-
 libavfilter/f_bench.c  |  2 +-
 libavfilter/f_drawgraph.c  |  2 +-
 libavfilter/f_select.c |  4 +--
 libavfilter/vf_cover_rect.c|  2 +-
 libavfilter/vf_drawtext.c  |  2 +-
 libavformat/aiffenc.c  |  2 +-
 libavformat/argo_asf.c |  2 +-
 libavformat/asfenc.c   |  6 ++--
 libavformat/au.c   |  2 +-
 libavformat/avformat.h |  2 +-
 libavformat/avidec.c   |  2 +-
 libavformat/avienc.c   |  2 +-
 libavformat/avio.c |  4 +--
 libavformat/dashenc.c  |  6 ++--
 libavformat/dvenc.c|  2 +-
 libavformat/flacdec.c  |  2 +-
 libavformat/flacenc.c  |  6 ++--
 libavformat/flvdec.c   |  2 +-
 libavformat/gxfenc.c   |  2 +-
 libavformat/http.c |  8 +++---
 libavformat/id3v2.c|  6 ++--
 libavformat/id3v2enc.c |  2 +-
 libavformat/imfdec.c   |  2 +-
 libavformat/matroskadec.c  |  2 +-
 libavformat/mov.c  |  6 ++--
 libavformat/movenc.c   | 46 +++---
 libavformat/mp3enc.c   |  6 ++--
 libavformat/mpegtsenc.c|  6 ++--
 libavformat/mux.c  |  2 +-
 libavformat/mux_utils.c|  2 +-
 libavformat/mxfenc.c   | 14 -
 libavformat/riffenc.c  |  2 +-
 libavformat/rmenc.c|  2 +-
 libavformat/sapenc.c   |  2 +-
 libavformat/sdp.c  |  2 +-
 libavformat/segment.c  |  4 +--
 libavformat/soxenc.c   |  2 +-
 libavformat/tee.c  |  2 +-
 libavformat/ttmlenc.c  |  4 +--
 libavformat/wavenc.c   |  4 +--
 libavformat/webmdashenc.c  | 30 +--
 libavutil/dict.c   |  9 +-
 libavutil/dict.h   |  5 
 libavutil/hwcontext_cuda.c |  2 +-
 libavutil/hwcontext_qsv.c  |  2 +-
 libavutil/hwcontext_vulkan.c   |  8 +++---
 libavutil/version.h|  1 +
 tests/api/api-threadmessage-test.c |  2 +-
 58 files changed, 136 insertions(+), 123 deletions(-)

diff --git a/doc/examples/qsv_transcode.c b/doc/examples/qsv_transcode.c
index 48128b200c..cc4c203d94 100644
--- a/doc/examples/qsv_transcode.c
+++ b/doc/examples/qsv_transcode.c
@@ -87,7 +87,7 @@ static int dynamic_set_parameter(AVCodecContext *avctx)
 frame_number++;
 if (current_setting_number < setting_number &&
 frame_number == dynamic_setting[current_setting_number].frame_number) {
-AVDictionaryEntry *e = NULL;
+const AVDictionaryEntry *e = NULL;
 ret = str_to_dict(dynamic_setting[current_setting_number++].optstr, 
);
 if (ret < 0) {
 fprintf(stderr, "The dynamic parameter is wrong\n");
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 0b88102c77..8a32f31677 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -999,7 +999,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 #if AOM_ENCODER_ABI_VERSION >= 23
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 while ((en = av_dict_get(ctx->aom_params, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
 int ret = aom_codec_set_option(>encoder, en->key, en->value);
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 168486f4ec..f9f3ce8e52 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -103,7 +103,7 @@ static av_cold int libkvazaar_init(AVCodecContext *avctx)
 if (ctx->kvz_params) {
 AVDictionary *dict = NULL;
 if (!av_dict_parse_string(, ctx->kvz_params, "=", ",", 0)) {
-AVDictionaryEntry *entry = NULL;
+const AVDictionaryEntry *entry = NULL;
 while ((entry = av_dict_get(dict, "", entry, 
AV_DICT_IGNORE_SUFFIX))) {
 if (!api->config_parse(cfg, entry->key, entry->value)) {
 av_log(avctx, AV_LOG_WARNING, "Invalid option: %s=%s.\n",
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 9174e2753c..e959c1cab0 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -151,7 +151,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 {
 SvtContext *svt_enc = avctx->priv_data;
 const AVPixFmtDescriptor *desc;
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
 // Update 

[FFmpeg-devel] [PATCH 2/3] avformat/tee: use av_dict_pop

2023-05-01 Thread Marvin Scholz
This is a well-defined way to "steal" the value of the dict entry.
---
 libavformat/tee.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index cb555f52fd..70f3f2eb29 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -157,6 +157,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 {
 int i, ret;
 AVDictionary *options = NULL, *bsf_options = NULL;
+char *entry_val = NULL;
 AVDictionaryEntry *entry;
 char *filename;
 char *format = NULL, *select = NULL, *on_fail = NULL;
@@ -171,15 +172,15 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 return ret;
 
 #define CONSUME_OPTION(option, field, action) do {  \
-if ((entry = av_dict_get(options, option, NULL, 0))) {  \
-field = entry->value;   \
+if ((!av_dict_pop(, option, NULL, _val, 0))) {\
+field = entry_val;  \
 { action }  \
-av_dict_set(, option, NULL, 0); \
+av_freep(_val);   \
 }   \
 } while (0)
 #define STEAL_OPTION(option, field) \
 CONSUME_OPTION(option, field,   \
-   entry->value = NULL; /* prevent it from being freed */)
+   entry_val = NULL; /* prevent it from being freed */)
 #define PROCESS_OPTION(option, field, function, on_error)   \
 CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } 
goto end; })
 
-- 
2.37.0 (Apple Git-136)

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

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


[FFmpeg-devel] [PATCH 1/3] avutil/dict: add av_dict_pop

2023-05-01 Thread Marvin Scholz
This new API allows to remove an entry and obtain ownership of the
key/value that was associated with the removed entry.
---
 doc/APIchanges |  4 
 libavutil/dict.c   | 27 +++
 libavutil/dict.h   | 20 
 libavutil/tests/dict.c | 34 ++
 libavutil/version.h|  2 +-
 tests/ref/fate/dict| 12 
 6 files changed, 98 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0b609e3d3b..5b807873b7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-04-29 - xx - lavu 58.7.100 - dict.c
+  Add av_dict_pop() to remove an entry from a dict
+  and get ownership of the removed key/value.
+
 2023-04-10 - xx - lavu 58.6.100 - frame.h
   av_frame_get_plane_buffer() now accepts const AVFrame*.
 
diff --git a/libavutil/dict.c b/libavutil/dict.c
index f673977a98..ac41771994 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -173,6 +173,33 @@ int av_dict_set_int(AVDictionary **pm, const char *key, 
int64_t value,
 return av_dict_set(pm, key, valuestr, flags);
 }
 
+int av_dict_pop(AVDictionary **pm, const char *key,
+char **out_key, char **out_value, int flags)
+{
+AVDictionary *m = *pm;
+AVDictionaryEntry *entry = NULL;
+entry = (AVDictionaryEntry *)av_dict_get(m, key, NULL, flags);
+if (!entry)
+return AVERROR(ENOENT);
+
+if (out_key)
+*out_key = entry->key;
+else
+av_free(entry->key);
+
+if (out_value)
+*out_value = entry->value;
+else
+av_free(entry->value);
+
+*entry = m->elems[--m->count];
+if (m && !m->count) {
+av_freep(>elems);
+av_freep(pm);
+}
+return 0;
+}
+
 static int parse_key_value_pair(AVDictionary **pm, const char **buf,
 const char *key_val_sep, const char *pairs_sep,
 int flags)
diff --git a/libavutil/dict.h b/libavutil/dict.h
index 713c9e361a..b2ab55a026 100644
--- a/libavutil/dict.h
+++ b/libavutil/dict.h
@@ -172,6 +172,26 @@ int av_dict_set(AVDictionary **pm, const char *key, const 
char *value, int flags
  */
 int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int 
flags);
 
+/**
+ * Remove the entry with the given key from the dictionary.
+ *
+ * Search for an entry matching `key` and remove it, if found. Optionally
+ * the found key and/or value can be returned using the `out_key`/`out_value`
+ * arguments.
+ *
+ * If more than one entry matches, only one entry is removed and returned
+ * on each call. Which entry is returned first in that case is undefined.
+ *
+ * @param pmPointer to a pointer to a dictionary struct.
+ * @param key   Entry key to match.
+ * @param out_key   Pointer whose pointee will be set to the matched
+ *  entry key. Must be freed by the caller. May be NULL.
+ * @param out_value Pointer whose pointee will be set to the matched
+ *  entry value. Must be freed by the caller. May be NULL.
+ */
+int av_dict_pop(AVDictionary **pm, const char *key,
+char **out_key, char **out_value, int flags);
+
 /**
  * Parse the key/value pairs list and add the parsed entries to a dictionary.
  *
diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c
index bececefb31..0652794b97 100644
--- a/libavutil/tests/dict.c
+++ b/libavutil/tests/dict.c
@@ -158,5 +158,39 @@ int main(void)
 printf("%s\n", e->value);
 av_dict_free();
 
+char *key, *val = NULL;
+int ret;
+printf("\nTesting av_dict_pop() with existing AVDictionaryEntry.key as 
key\n");
+av_dict_set(, "test-key", "test-value", 0);
+ret = av_dict_pop(, "test-key", , , 0);
+printf("%s: %s (Return code: %i)\n",
+(key) ? key : "(null)",
+(val) ? val : "(null)", ret);
+e = av_dict_get(dict, "test-key", NULL, 0);
+printf("%s\n", (e) ? e->value : "(null)");
+av_freep();
+av_freep();
+
+printf("\nTesting av_dict_pop() with nonexistent key\n");
+ret = av_dict_pop(, "test-key", , , 0);
+printf("%s: %s (Return code: %i)\n",
+(key) ? key : "(null)",
+(val) ? val : "(null)", ret);
+e = av_dict_get(dict, "test-key", NULL, 0);
+printf("%s\n", (e) ? e->value : "(null)");
+av_freep();
+av_freep();
+
+printf("\nTesting av_dict_pop() with prefix key match\n");
+av_dict_set(, "prefix-test-key", "test-value", 0);
+ret = av_dict_pop(, "prefix-test", , , AV_DICT_IGNORE_SUFFIX);
+printf("%s: %s (Return code: %i)\n",
+(key) ? key : "(null)",
+(val) ? val : "(null)", ret);
+e = av_dict_get(dict, "prefix-test", NULL, AV_DICT_IGNORE_SUFFIX);
+printf("%s\n", (e) ? e->value : "(null)");
+av_freep();
+av_freep();
+
 return 0;
 }
diff --git a/libavutil/version.h 

Re: [FFmpeg-devel] Embedded documentation?

2023-05-01 Thread Diederick C. Niehorster
On Mon, May 1, 2023 at 12:13 PM Nicolas George  wrote:

> Hi.
>
> Three years ago, I shared some brief thoughts about embedding the
> documentation in the libraries. For example, that would allow GUI
> applications to open help dialogs about specific options.
>
> To see what it would need, I wrote the following header. I did not work
> any further, because groundwork need to be laid first. But now that it
> was mentioned in another thread, I think it is a good idea to show it,
> to see how people like it.
>

+1. I assume a lot of the AVDocNode can be automatically populated from its
corresponding option? We'd not want to maintain, e.g. option names and
aliases in more than one place.

Cheers,
Dee
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v5] avformat: add MMTP parser and MMT/TLV demuxer

2023-05-01 Thread SuperFashi
v1 -> v2: Refactor using GetByteContext; Fix compile error.
v2 -> v3: Remove debug statement.
v3 -> v4: Squash commits
v4 -> v5: Improve portability; Cosmetic changes.

This patch adds an MPEG Media Transport Protocol (MMTP) parser, as defined in 
ISO/IEC 23008-1, and an MMT protocol over TLV packets (MMT/TLV) demuxer, as 
defined in ARIB STD-B32. Currently, it supports HEVC, AAC LATM, and ARIB-TTML 
demuxing.

Since MMTP is designed to transmit over IP, there is no size information within 
each MMTP packet, and there is no on-disk format defined alongside the 
protocol. One industrial solution is a simple container format using 
type–length–value packets, which is defined in ARIB STD-B32.

Another known container format for MMTP is using packet capture (pcap) files 
which records network packets. This patch does not include the demuxer for this 
container format.

Signed-off-by: SuperFashi 
---
 Changelog|1 +
 doc/demuxers.texi|4 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |1 +
 libavformat/mmtp.c   | 1528 ++
 libavformat/mmtp.h   |   64 ++
 libavformat/mmttlv.c |  334 +
 libavformat/version.h|2 +-
 8 files changed, 1934 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/mmtp.c
 create mode 100644 libavformat/mmtp.h
 create mode 100644 libavformat/mmttlv.c

diff --git a/Changelog b/Changelog
index 4901ef6ad7..594c445ea2 100644
--- a/Changelog
+++ b/Changelog
@@ -7,6 +7,7 @@ version :
 - Extend VAAPI support for libva-win32 on Windows
 - afireqsrc audio source filter
 - arls filter
+- MMTP parser and MMT/TLV demuxer
 
 version 6.0:
 - Radiance HDR image support
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 2d33b47a56..56aab251b2 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -689,6 +689,10 @@ Set the sample rate for libopenmpt to output.
 Range is from 1000 to INT_MAX. The value default is 48000.
 @end table
 
+@section mmttlv
+
+Demuxer for MMT protocol over TLV packets (MMT/TLV), as defined in ARIB 
STD-B32.
+
 @section mov/mp4/3gp
 
 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 
14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f8ad7c6a11..e32d6e71a3 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -354,6 +354,7 @@ OBJS-$(CONFIG_MLV_DEMUXER)   += mlvdec.o 
riffdec.o
 OBJS-$(CONFIG_MM_DEMUXER)+= mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)   += mmf.o
 OBJS-$(CONFIG_MMF_MUXER) += mmf.o rawenc.o
+OBJS-$(CONFIG_MMTTLV_DEMUXER)+= mmtp.o mmttlv.o
 OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index efdb34e29d..d5f4f5680e 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -270,6 +270,7 @@ extern const AVInputFormat  ff_mlv_demuxer;
 extern const AVInputFormat  ff_mm_demuxer;
 extern const AVInputFormat  ff_mmf_demuxer;
 extern const FFOutputFormat ff_mmf_muxer;
+extern const AVInputFormat  ff_mmttlv_demuxer;
 extern const AVInputFormat  ff_mods_demuxer;
 extern const AVInputFormat  ff_moflex_demuxer;
 extern const AVInputFormat  ff_mov_demuxer;
diff --git a/libavformat/mmtp.c b/libavformat/mmtp.c
new file mode 100644
index 00..c6eebbff38
--- /dev/null
+++ b/libavformat/mmtp.c
@@ -0,0 +1,1528 @@
+/*
+ * MPEG Media Transport Protocol (MMTP) parser, as defined in ISO/IEC 23008-1.
+ * Copyright (c) 2023 SuperFashi
+ *
+ * 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
+ */
+
+#include 
+
+#include "libavcodec/bytestream.h"
+#include "libavutil/avassert.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+#include "demux.h"
+#include "internal.h"
+#include "mmtp.h"
+#include "network.h"
+
+struct MMTGeneralLocationInfo {
+uint8_t location_type;
+union {
+struct {
+uint16_t packet_id;
+} type0;
+struct {
+struct in_addr ipv4_src_addr;
+struct in_addr ipv4_dst_addr;
+  

Re: [FFmpeg-devel] [PATCH 5/8] lavu: add a JSON writer API (WIP)

2023-05-01 Thread Jean-Baptiste Kempf
On Mon, 1 May 2023, at 08:57, Leo Izen wrote:
> On 4/29/23 14:33, Nicolas George wrote:
>> Anton Khirnov (12023-04-29):
>>> libavfilter is a C library with a C API. Any structured output from
>>> filters should be in the form of a C object, typically a struct. I do
>>> not see why are you so in love with strings, they make for terrible
>>> APIs.
>> 
>> Yes, strings are a terrible API, but our project is not only a set of
>> libraries, it is also a set of command-line tools, and command-line
>> tools work with strings and nothing else.
>> 
>
> This is a good argument for putting the code in fftools/ and not 
> libavutil, fwiw.

This is also my understanding.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] Embedded documentation?

2023-05-01 Thread Nicolas George
Hi.

Three years ago, I shared some brief thoughts about embedding the
documentation in the libraries. For example, that would allow GUI
applications to open help dialogs about specific options.

To see what it would need, I wrote the following header. I did not work
any further, because groundwork need to be laid first. But now that it
was mentioned in another thread, I think it is a good idea to show it,
to see how people like it.

Please share your remarks. Even “+1” to say you like it, because people
who will not like it will not hesitate to post “-1”.

Regards,

-- 
  Nicolas George
typedef struct AVDocNode AVDocNode;
typedef struct AVDocLink AVDocLink;
typedef enum AVDocNodeType AVDocNodeType;
typedef enum AVDocLinkType AVDocLinkType;

/**
 * Link to another documentation node.
 */
struct AVDocLink {
AVDocNode *target;
AVDocLinkType type;
};

/**
 * Node in the documentation system.
 *
 * A node can be the description of a codec, format, filter, option, type,
 * etc.
 */
struct AVDocNode {

/**
 * Names of the component.
 *
 * It is a concatenation of 0-terminated strings, terminated by an empty
 * string (i.e. a double 0).
 * For example "frame_rate, rate, r" would be "frame_rate\0rate\0r\0\0".
 * The first name is the main name of the component, the other are
 * aliases.
 * If this field is used as a plain C string, it contains only the main
 * name.
 */
const char *names;

/**
 * Unique identifier of the compnent.
 *
 * It is composed of alphanumeric characters plus underscore and slash
 * and written hierarchically.
 *
 * For example, the width option of the scale filter would be
 * "lavfi/vf_scale/opt_width".
 *
 * This identifier can be used for links in the text.
 *
 * It matches the symbol that makes the documentation available, in the
 * avdoc_ namespace with double underscore standing for slashes:
 * extern const AVDocNode avdoc_lavfi__vf_scale__opt_width;
 */
const char *id;

/**
 * Title / short description, possibly NULL.
 *
 * Can be used in a table of contents for example.
 */
const char *title;

/**
 * Text of the documentation in XXX Markdown / FFHTML.
 *
 * Apparently we want to write the documentation in Markdown or similar,
 * but the build system can convert when creating the data structure to
 * embed in the library.
 *
 * On one hand, Markdown can be dumped as is to the user, in a terminal
 * or a basic dialog box.
 *
 * On the other hand, strict minimalist HTML is more program-friendly,
 * which makes it more convenient for programs that want to display it
 * with actual italics 
 *
 * I think FFHTML (i.e. a small, strict and clearly documented subset of
 * HTML) would be better.
 */
const char *text;

/**
 * Object about which the documentation is.
 *
 * If not NULL, points to an object starting with an AVClass pointer.
 */
void *object;

/**
 * Links towards other nodes.
 *
 * All nodes linked in the text must have an entry here, but implicit
 * links are possible too, for example the type of an option.
 *
 * The types are ordered by type.
 */
const AVDocLink *links;

/**
 * Type of the node, and of the object documented.
 */
AVDocNodeType type;

};

/**
 * Type of a documentation node.
 */
enum AVDocNodeType {
AVDOC_TYPE_GENERIC = 0,
AVDOC_TYPE_MUXER,
AVDOC_TYPE_DEMUXER,
AVDOC_TYPE_ENCODER,
AVDOC_TYPE_DECODER,
AVDOC_TYPE_FILTER,
AVDOC_TYPE_BITSTREAM_FILTER,
AVDOC_TYPE_SWSCALER,
AVDOC_TYPE_SWRESAMPLER,
AVDOC_TYPE_DEVICE_VIDEO_OUTPUT,
AVDOC_TYPE_DEVICE_VIDEO_INPUT,
AVDOC_TYPE_DEVICE_AUDIO_OUTPUT,
AVDOC_TYPE_DEVICE_AUDIO_INPUT,
AVDOC_TYPE_DEVICE_OUTPUT,
AVDOC_TYPE_DEVICE_INPUT,
AVDOC_TYPE_OPTION,
AVDOC_TYPE_TYPE,
AVDOC_TYPE_SYNTAX,
AVDOC_TYPE_EXAMPLES,
AVDOC_TYPE_EXPLANATIONS,
};

/**
 * Type of a link, i.e. relation between the source and the target of the
 * link.
 *
 * More important links have a lower value.
 */
enum AVDocLinkType {

/**
 * The linked node is the parent.
 *
 * For example, the parent the node for a private option is the node for
 * the corresponding codec/format/filter.
 */
AVDOC_LINK_PARENT = 0x100,

/**
 * The linked node is a subpart, section, chapter, etc.
 */
AVDOC_LINK_SUBPART = 0x200,

/**
 * The linked node describes an option or an option constant.
 */
AVDOC_LINK_OPTION = 0x300,

/**
 * Threshold value for the self-contained minimal documentation of an
 * object.
 */
AVDOC_LINK_SELF_CONTAINED = 0x400,

/**
 * The linked node is the reference for a type, syntax, etc.
 */
AVDOC_LINK_REFERENCE = 0x500,

/**
 * Threshold value for the self-contained complete documentation of an
 

Re: [FFmpeg-devel] [PATCH] lavf/dv: do not set video timebase more than once

2023-05-01 Thread Anton Khirnov
Will push the set tomorrow if nobody has further objections.

-- 
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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 5/8] lavu: add a JSON writer API (WIP)

2023-05-01 Thread Nicolas George
Leo Izen (12023-05-01):
> > Yes, strings are a terrible API, but our project is not only a set of
> > libraries, it is also a set of command-line tools, and command-line
> > tools work with strings and nothing else.
> This is a good argument for putting the code in fftools/ and not libavutil,
> fwiw.

This is not wrong. But I realize now my argument was widely incomplete.
GUI applications not of our own still need text to communicate with
users about things that do not have their specific widget, for example.

The avlibraries must not only perform work for applications, they also
must help applications communicate with users about that work, and that
is done with text.

See there for a more complete wording:
http://ffmpeg.org/pipermail/ffmpeg-devel/2023-May/309077.html

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 5/8] lavu: add a JSON writer API (WIP)

2023-05-01 Thread Nicolas George
Michael Niedermayer (12023-04-30):
> There are many projects which use libavcodec, format, filter
> Human users use these projects
> 
> If the standarization is at a C struct level only then the human interface
> for each application can be different.
> Thats fine if the 2 cases use fundamentally different interfaces like a
> GUI draging, droping and connecting components vs some command line
> interface.
> But if 2 applications both use command line / string based interfaces
> it would be nice to the human user if she could use/learn the same syntax
> and transfer a working example / script from one to the other.
> 
> So i think strings do matter for C libs because of that.

Thank you for stating it that way.

I think I can make it even a little stronger:

The API of the avlibraries is so rich that applications cannot
realistically cover all of them, and this is why we have the options
system: so that applications can expose all the knobs and controls of
avlibs without having to maintain code for every one of them.

But the options system has severe limitations, including the occasional
need for half-a-dozen backslashes or more for escaping and the inability
to define AV_OPT_TYPE_SOMETHING if SOMETHING is defined in another
library than lavu or nor generic enough.

Overcoming the limitations of the options system is a project I have had
for a long time, and it connects to the project of embedding the
documentation into the libraries (which has received some support).

http://ffmpeg.org/pipermail/ffmpeg-devel/2015-December/184525.html
(the technical details in my mind have evolved a little, but not much)
http://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/268389.html

And for that, we absolutely need an efficient strings API (this is now
supported by a majority of developers, thankfully) and standardized
serialization functions. In the libraries, not the avtools.

To say it in a more concise way:

The avlibraries must not only perform work for applications, they also
must help applications communicate with users about that work, and that
is done with text.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] [RFC] web/donations: Remove ffis

2023-05-01 Thread Michael Niedermayer
On Mon, May 01, 2023 at 09:00:35AM +0200, Thilo Borgmann wrote:
> Am 01.05.23 um 02:40 schrieb Michael Niedermayer:
> > There are some problems with the ffis webpage "Unable to connect to SQL 
> > server"
> > I tried to report this but it seems my email was not achieving that.
> > It may be safer to remove the link to ffis until we understand what exactly
> > is going on on the ffis side.
> 
> Please apply.

applied

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v4] avformat: add MMTP parser and MMT/TLV demuxer

2023-05-01 Thread Anton Khirnov
Quoting SuperFashi (2023-05-01 03:10:36)
> Thanks for the feedback. I thought across libraries meant across different
> muxers/demuxers. In which case, is there any naming scheme for functions
> that are only used within lavf? Can i just remove the avpriv_ prefix?

tl;dr: use ff_ for non-static functions used within a single library

see http://ffmpeg.org/developer.html#Naming-conventions-1 for details

> For inline, my habit is to add it when there’s only one place that uses it.
> I can remove it.

I prefer to avoid it, because it's visual clutter that in most cases has
no meaningful effect.

-- 
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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] [RFC] web/donations: Remove ffis

2023-05-01 Thread Thilo Borgmann

Am 01.05.23 um 02:40 schrieb Michael Niedermayer:

There are some problems with the ffis webpage "Unable to connect to SQL server"
I tried to report this but it seems my email was not achieving that.
It may be safer to remove the link to ffis until we understand what exactly
is going on on the ffis side.


Please apply.

Thanks,
Thilo



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

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


Re: [FFmpeg-devel] [PATCH 5/8] lavu: add a JSON writer API (WIP)

2023-05-01 Thread Leo Izen



On 4/29/23 14:33, Nicolas George wrote:

Anton Khirnov (12023-04-29):

libavfilter is a C library with a C API. Any structured output from
filters should be in the form of a C object, typically a struct. I do
not see why are you so in love with strings, they make for terrible
APIs.


Yes, strings are a terrible API, but our project is not only a set of
libraries, it is also a set of command-line tools, and command-line
tools work with strings and nothing else.



This is a good argument for putting the code in fftools/ and not 
libavutil, fwiw.


- Leo Izen (Traneptora / thebombzen)

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

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


Re: [FFmpeg-devel] [PATCH 5/8] lavu: add a JSON writer API (WIP)

2023-05-01 Thread Vittorio Giovara
On Sat, Apr 29, 2023 at 8:29 PM Kieran Kunhya  wrote:

> On Sat, 29 Apr 2023 at 05:07, Derek Buitenhuis  >
> wrote:
>
> > On 4/29/2023 10:41 AM, Anton Khirnov wrote:
> > > ffprobe:
> > > * is not one of the libraries, but rather their caller
> > > * we are not in business of providing random non-multimedia-related
> > >   services to callers, unless they are useful in our libraries;
> > >   if this code is only useful in ffprobe then it should live in
> fftools/
> > > * it is not at all obvious that switching ffprobe to this code would
> > >   be an improvement; a patch actually demonstrating this would be most
> > >   useful
> >
> > +1
> >
> >
> +2
>

+3
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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