summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-12 15:01:41 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-04-12 15:08:40 +0200
commit835cc0f2e7098fbb548d7622110c4fdc0831809d (patch)
tree22408566623b068dd3eb0ab2a49751fb1ecde67d
parentf4db6bfeb86feda2aeb98072e55b55de85ba0962 (diff)
parentfa2a34cd40d124161c748bb0f430dc63c94dd0da (diff)
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>
-rw-r--r--cmdutils.c8
-rw-r--r--doc/APIchanges2
-rw-r--r--ffmpeg.c1
-rw-r--r--ffplay.c1
-rw-r--r--libavfilter/avfilter.c55
-rw-r--r--libavfilter/avfilter.h16
-rw-r--r--libavfilter/version.h3
7 files changed, 52 insertions, 34 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 4634ae20ff..bdcbebd4c2 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -1448,21 +1448,21 @@ int show_protocols(void *optctx, const char *opt, const char *arg)
int show_filters(void *optctx, const char *opt, const char *arg)
{
- AVFilter av_unused(**filter) = NULL;
+ const AVFilter av_unused(*filter) = NULL;
char descr[64], *descr_cur;
int i, j;
const AVFilterPad *pad;
printf("Filters:\n");
#if CONFIG_AVFILTER
- while ((filter = av_filter_next(filter)) && *filter) {
+ while ((filter = avfilter_next(filter))) {
descr_cur = descr;
for (i = 0; i < 2; i++) {
if (i) {
*(descr_cur++) = '-';
*(descr_cur++) = '>';
}
- pad = i ? (*filter)->outputs : (*filter)->inputs;
+ pad = i ? filter->outputs : filter->inputs;
for (j = 0; pad && pad[j].name; j++) {
if (descr_cur >= descr + sizeof(descr) - 4)
break;
@@ -1472,7 +1472,7 @@ int show_filters(void *optctx, const char *opt, const char *arg)
*(descr_cur++) = '|';
}
*descr_cur = 0;
- printf("%-16s %-10s %s\n", (*filter)->name, descr, (*filter)->description);
+ printf("%-16s %-10s %s\n", filter->name, descr, filter->description);
}
#endif
return 0;
diff --git a/doc/APIchanges b/doc/APIchanges
index 3a435afe71..6d0beb316c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -171,6 +171,8 @@ API changes, most recent first:
Add avfilter_init_dict().
Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags.
Add avfilter_pad_count() for counting filter inputs/outputs.
+ Add avfilter_next(), deprecate av_filter_next().
+ Deprecate avfilter_uninit().
2013-xx-xx - lavfi 3.7.0 - avfilter.h
Add AVFilter.priv_class for exporting filter options through the AVOptions API
diff --git a/ffmpeg.c b/ffmpeg.c
index b6e03345a2..3f26249d42 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -499,7 +499,6 @@ static void exit_program(void)
uninit_opts();
- avfilter_uninit();
avformat_network_deinit();
if (received_sigterm) {
diff --git a/ffplay.c b/ffplay.c
index 759f46f3b5..a9fef72622 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1027,7 +1027,6 @@ static void do_exit(VideoState *is)
av_lockmgr_register(NULL);
uninit_opts();
#if CONFIG_AVFILTER
- avfilter_uninit();
av_freep(&vfilters);
#endif
avformat_network_deinit();
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 : &registered_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;
}
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 4bc97554fe..44143b010a 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -496,6 +496,8 @@ typedef struct AVFilter {
int priv_size; ///< size of private data to allocate for the filter
+ struct AVFilter *next;
+
/**
* Make the filter instance process a command.
*
@@ -837,8 +839,11 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha
/** Initialize the filter system. Register all builtin filters. */
void avfilter_register_all(void);
+#if FF_API_OLD_FILTER_REGISTER
/** Uninitialize the filter system. Unregister all filters. */
+attribute_deprecated
void avfilter_uninit(void);
+#endif
/**
* Register a filter. This is only needed if you plan to use
@@ -862,12 +867,23 @@ int avfilter_register(AVFilter *filter);
AVFilter *avfilter_get_by_name(const char *name);
/**
+ * Iterate over all registered filters.
+ * @return If prev is non-NULL, next registered filter after prev or NULL if
+ * prev is the last filter. If prev is NULL, return the first registered filter.
+ */
+const AVFilter *avfilter_next(const AVFilter *prev);
+
+#if FF_API_OLD_FILTER_REGISTER
+/**
* If filter is NULL, returns a pointer to the first registered filter pointer,
* if filter is non-NULL, returns the next pointer after filter.
* If the returned pointer points to NULL, the last registered filter
* was already reached.
+ * @deprecated use avfilter_next()
*/
+attribute_deprecated
AVFilter **av_filter_next(AVFilter **filter);
+#endif
#if FF_API_AVFILTER_OPEN
/**
diff --git a/libavfilter/version.h b/libavfilter/version.h
index ef14ae9bfc..3112dd5cd0 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -75,5 +75,8 @@
#ifndef FF_API_AVFILTER_INIT_FILTER
#define FF_API_AVFILTER_INIT_FILTER (LIBAVFILTER_VERSION_MAJOR < 4)
#endif
+#ifndef FF_API_OLD_FILTER_REGISTER
+#define FF_API_OLD_FILTER_REGISTER (LIBAVFILTER_VERSION_MAJOR < 4)
+#endif
#endif /* AVFILTER_VERSION_H */