History

avfilter/vf_lut2: add support for commands

Paul B Mahol committed 5 years ago

Commit 5f592131 parent 629dd8e2 files · +28 −9Browse files

Unified · Split

2 files
  1. doc/filters.texi +4 −0
  2. libavfilter/vf_lut2.c +24 −9
doc/filters.texi+4−0
@@ -14221,6 +14221,10 @@ The second input video bit depth. · 14220 unmodified lines
1422114221
1422214222 All expressions default to "x".
1422314223
14224+@subsection Commands
14225+
14226+This filter supports the all above options as @ref{commands} except option @code{d}.
14227+
1422414228 @subsection Examples
1422514229
1422614230 @itemize
libavfilter/vf_lut2.c+24−9
@@ -79,12 +79,13 @@ typedef struct ThreadData { · 78 unmodified lines
7979
8080 #define OFFSET(x) offsetof(LUT2Context, x)
8181 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
82+#define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
8283
8384 static const AVOption options[] = {
84− { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
85− { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
86− { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
87− { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
85+ { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
86+ { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
87+ { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
88+ { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
8889 { "d", "set output depth", OFFSET(odepth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 16, .flags = FLAGS },
8990 { NULL }
9091 };
@@ -353,7 +354,8 @@ static int config_output(AVFilterLink *outlink) · 262 unmodified lines
353354 }
354355
355356 for (p = 0; p < s->nb_planes; p++) {
356− s->lut[p] = av_malloc_array(1 << s->depth, sizeof(uint16_t));
357+ if (!s->lut[p])
358+ s->lut[p] = av_malloc_array(1 << s->depth, sizeof(uint16_t));
357359 if (!s->lut[p])
358360 return AVERROR(ENOMEM);
359361 }
@@ -543,6 +545,17 @@ static const AVFilterPad outputs[] = { · 183 unmodified lines
543545 { NULL }
544546 };
545547
548+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
549+ char *res, int res_len, int flags)
550+{
551+ int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
552+
553+ if (ret < 0)
554+ return ret;
555+
556+ return config_output(ctx->outputs[0]);
557+}
558+
546559 #define lut2_options options
547560
548561 FRAMESYNC_DEFINE_CLASS(lut2, LUT2Context, fs);
@@ -560,6 +573,7 @@ AVFilter ff_vf_lut2 = { · 11 unmodified lines
560573 .outputs = outputs,
561574 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
562575 AVFILTER_FLAG_SLICE_THREADS,
576+ .process_command = process_command,
563577 };
564578
565579 #if CONFIG_TLUT2_FILTER
@@ -610,10 +624,10 @@ static int tlut2_filter_frame(AVFilterLink *inlink, AVFrame *frame) · 44 unmodified lines
610624 }
611625
612626 static const AVOption tlut2_options[] = {
613− { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
614− { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
615− { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
616− { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = FLAGS },
627+ { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
628+ { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
629+ { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
630+ { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, { .str = "x" }, .flags = TFLAGS },
617631 { NULL }
618632 };
619633
@@ -650,6 +664,7 @@ AVFilter ff_vf_tlut2 = { · 30 unmodified lines
650664 .outputs = tlut2_outputs,
651665 .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
652666 AVFILTER_FLAG_SLICE_THREADS,
667+ .process_command = process_command,
653668 };
654669
655670 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t