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
432 return ctx->name ? ctx->name : ctx->filter->name;432 return ctx->name ? ctx->name : ctx->filter->name;
433}433}
434 434
435static 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
443static 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
435static const AVClass avfilter_class = {463static const AVClass avfilter_class = {
436 .class_name = "AVFilter",464 .class_name = "AVFilter",
437 .item_name = default_filter_name,465 .item_name = default_filter_name,
438 .version = LIBAVUTIL_VERSION_INT,466 .version = LIBAVUTIL_VERSION_INT,
439 .category = AV_CLASS_CATEGORY_FILTER,467 .category = AV_CLASS_CATEGORY_FILTER,
468 .child_next = filter_child_next,
469 .child_class_next = filter_child_class_next,
440};470};
441 471
472const AVClass *avfilter_get_class(void)
473{
474 return &avfilter_class;
475}
476
442int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)477int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
443{478{
444 AVFilterContext *ret;479 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