diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-12 15:01:41 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-12 15:08:40 +0200 |
commit | 835cc0f2e7098fbb548d7622110c4fdc0831809d (patch) | |
tree | 22408566623b068dd3eb0ab2a49751fb1ecde67d /libavfilter/avfilter.c | |
parent | f4db6bfeb86feda2aeb98072e55b55de85ba0962 (diff) | |
parent | fa2a34cd40d124161c748bb0f430dc63c94dd0da (diff) | |
download | ffmpeg-835cc0f2e7098fbb548d7622110c4fdc0831809d.tar.gz |
Merge commit 'fa2a34cd40d124161c748bb0f430dc63c94dd0da'
* commit 'fa2a34cd40d124161c748bb0f430dc63c94dd0da':
lavfi: change the filter registering system to match the other libraries
Conflicts:
cmdutils.c
ffplay.c
libavfilter/avfilter.c
libavfilter/avfilter.h
This removes the ability to put AVFilters in read only memory and having
them shareable.
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r-- | libavfilter/avfilter.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index e03b6f2f61..484eda1c7f 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -386,55 +386,53 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha return AVERROR(ENOSYS); } -#define MAX_REGISTERED_AVFILTERS_NB 256 - -static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; - -static int next_registered_avfilter_idx = 0; +static AVFilter *first_filter; AVFilter *avfilter_get_by_name(const char *name) { - int i; + AVFilter *f = NULL; - for (i = 0; registered_avfilters[i]; i++) - if (!strcmp(registered_avfilters[i]->name, name)) - return registered_avfilters[i]; + while ((f = avfilter_next(f))) + if (!strcmp(f->name, name)) + return f; return NULL; } int avfilter_register(AVFilter *filter) { + AVFilter **f = &first_filter; int i; - if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB) { - av_log(NULL, AV_LOG_ERROR, - "Maximum number of registered filters %d reached, " - "impossible to register filter with name '%s'\n", - MAX_REGISTERED_AVFILTERS_NB, filter->name); - return AVERROR(ENOMEM); - } - for(i=0; filter->inputs && filter->inputs[i].name; i++) { const AVFilterPad *input = &filter->inputs[i]; av_assert0( !input->filter_frame || (!input->start_frame && !input->end_frame)); } - registered_avfilters[next_registered_avfilter_idx++] = filter; + while (*f) + f = &(*f)->next; + *f = filter; + filter->next = NULL; + return 0; } +const AVFilter *avfilter_next(const AVFilter *prev) +{ + return prev ? prev->next : first_filter; +} + +#if FF_API_OLD_FILTER_REGISTER AVFilter **av_filter_next(AVFilter **filter) { - return filter ? ++filter : ®istered_avfilters[0]; + return filter ? &(*filter)->next : &first_filter; } void avfilter_uninit(void) { - memset(registered_avfilters, 0, sizeof(registered_avfilters)); - next_registered_avfilter_idx = 0; } +#endif int avfilter_pad_count(const AVFilterPad *pads) { @@ -463,21 +461,22 @@ static void *filter_child_next(void *obj, void *prev) static const AVClass *filter_child_class_next(const AVClass *prev) { - AVFilter **f = NULL; + AVFilter *f = NULL; /* find the filter that corresponds to prev */ - while (prev && *(f = av_filter_next(f))) - if ((*f)->priv_class == prev) + while (prev && (f = avfilter_next(f))) + if (f->priv_class == prev) break; /* could not find filter corresponding to prev */ - if (prev && !(*f)) + if (prev && !f) return NULL; /* find next filter with specific options */ - while (*(f = av_filter_next(f))) - if ((*f)->priv_class) - return (*f)->priv_class; + while ((f = avfilter_next(f))) + if (f->priv_class) + return f->priv_class; + return NULL; } |