[FFmpeg-cvslog] avfilter/vf_lut3d: lut1d: add support for commands
Paul B Mahol
git at videolan.org
Sat Feb 6 13:47:41 EET 2021
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Feb 6 12:45:39 2021 +0100| [d8181cbbc48d262ed820ff2c4265f846be7fe6d1] | committer: Paul B Mahol
avfilter/vf_lut3d: lut1d: add support for commands
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d8181cbbc48d262ed820ff2c4265f846be7fe6d1
---
doc/filters.texi | 4 ++++
libavfilter/vf_lut3d.c | 34 +++++++++++++++++++++++++++-------
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index c91db8c346..c150c29114 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -13914,6 +13914,10 @@ Interpolate values using the spline interpolation.
@end table
@end table
+ at subsection Commands
+
+This filter supports the all above options as @ref{commands}.
+
@anchor{lut3d}
@section lut3d
diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
index fb33c93c34..ad559dbf10 100644
--- a/libavfilter/vf_lut3d.c
+++ b/libavfilter/vf_lut3d.c
@@ -100,6 +100,7 @@ typedef struct ThreadData {
#define OFFSET(x) offsetof(LUT3DContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
#define COMMON_OPTIONS \
{ "interp", "select interpolation mode", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERPOLATE_TETRAHEDRAL}, 0, NB_INTERP_MODE-1, FLAGS, "interp_mode" }, \
{ "nearest", "use values from the nearest defined points", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_NEAREST}, INT_MIN, INT_MAX, FLAGS, "interp_mode" }, \
@@ -1798,13 +1799,13 @@ try_again:
}
static const AVOption lut1d_options[] = {
- { "file", "set 1D LUT file name", OFFSET(file), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
- { "interp", "select interpolation mode", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERPOLATE_1D_LINEAR}, 0, NB_INTERP_1D_MODE-1, FLAGS, "interp_mode" },
- { "nearest", "use values from the nearest defined points", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_NEAREST}, INT_MIN, INT_MAX, FLAGS, "interp_mode" },
- { "linear", "use values from the linear interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_LINEAR}, INT_MIN, INT_MAX, FLAGS, "interp_mode" },
- { "cosine", "use values from the cosine interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_COSINE}, INT_MIN, INT_MAX, FLAGS, "interp_mode" },
- { "cubic", "use values from the cubic interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_CUBIC}, INT_MIN, INT_MAX, FLAGS, "interp_mode" },
- { "spline", "use values from the spline interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_SPLINE}, INT_MIN, INT_MAX, FLAGS, "interp_mode" },
+ { "file", "set 1D LUT file name", OFFSET(file), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = TFLAGS },
+ { "interp", "select interpolation mode", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=INTERPOLATE_1D_LINEAR}, 0, NB_INTERP_1D_MODE-1, TFLAGS, "interp_mode" },
+ { "nearest", "use values from the nearest defined points", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_NEAREST}, 0, 0, TFLAGS, "interp_mode" },
+ { "linear", "use values from the linear interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_LINEAR}, 0, 0, TFLAGS, "interp_mode" },
+ { "cosine", "use values from the cosine interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_COSINE}, 0, 0, TFLAGS, "interp_mode" },
+ { "cubic", "use values from the cubic interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_CUBIC}, 0, 0, TFLAGS, "interp_mode" },
+ { "spline", "use values from the spline interpolation", 0, AV_OPT_TYPE_CONST, {.i64=INTERPOLATE_1D_SPLINE}, 0, 0, TFLAGS, "interp_mode" },
{ NULL }
};
@@ -2234,6 +2235,24 @@ static int filter_frame_1d(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(outlink, out);
}
+static int lut1d_process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+ char *res, int res_len, int flags)
+{
+ LUT1DContext *lut1d = ctx->priv;
+ int ret;
+
+ ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
+ if (ret < 0)
+ return ret;
+
+ ret = lut1d_init(ctx);
+ if (ret < 0) {
+ set_identity_matrix_1d(lut1d, 32);
+ return ret;
+ }
+ return config_input_1d(ctx->inputs[0]);
+}
+
static const AVFilterPad lut1d_inputs[] = {
{
.name = "default",
@@ -2262,5 +2281,6 @@ AVFilter ff_vf_lut1d = {
.outputs = lut1d_outputs,
.priv_class = &lut1d_class,
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
+ .process_command = lut1d_process_command,
};
#endif
More information about the ffmpeg-cvslog
mailing list