History

lavfi: add avfilter_get_class() and iteration callbacks

Allow iteration over filter options.

Stefano Sabatini committed 14 years ago

Commit 5c0d8bc1 parent a25346e4 files · +46 −1Browse files

Showing the changes to libavfilter/avfilter.c (1 of 4 files). Show all

Unified · Split

libavfilter/avfilter.c+35−0
@@ -432,13 +432,48 @@ static const char *default_filter_name(void *filter_ctx) · 431 unmodified lines
432432 return ctx->name ? ctx->name : ctx->filter->name;
433433 }
434434
435+static void *filter_child_next(void *obj, void *prev)
436+{
437+ AVFilterContext *ctx = obj;
438+ if (!prev && ctx->filter && ctx->filter->priv_class)
439+ return ctx->priv;
440+ return NULL;
441+}
442+
443+static const AVClass *filter_child_class_next(const AVClass *prev)
444+{
445+ AVFilter **filter_ptr = NULL;
446+
447+ /* find the filter that corresponds to prev */
448+ while (prev && *(filter_ptr = av_filter_next(filter_ptr)))
449+ if ((*filter_ptr)->priv_class == prev)
450+ break;
451+
452+ /* could not find filter corresponding to prev */
453+ if (prev && !(*filter_ptr))
454+ return NULL;
455+
456+ /* find next filter with specific options */
457+ while (*(filter_ptr = av_filter_next(filter_ptr)))
458+ if ((*filter_ptr)->priv_class)
459+ return (*filter_ptr)->priv_class;
460+ return NULL;
461+}
462+
435463 static const AVClass avfilter_class = {
436464 .class_name = "AVFilter",
437465 .item_name = default_filter_name,
438466 .version = LIBAVUTIL_VERSION_INT,
439467 .category = AV_CLASS_CATEGORY_FILTER,
468+ .child_next = filter_child_next,
469+ .child_class_next = filter_child_class_next,
440470 };
441471
472+const AVClass *avfilter_get_class(void)
473+{
474+ return &avfilter_class;
475+}
476+
442477 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
443478 {
444479 AVFilterContext *ret;

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