History

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.

Michael Niedermayer committed 13 years ago

Commit 835cc0f2 parents f4db6bf fa2a34c7 files · +52 −34Browse files

Unified · Split

7 files
  1. cmdutils.c +4 −4
  2. doc/APIchanges +2 −0
  3. ffmpeg.c +0 −1
  4. ffplay.c +0 −1
  5. libavfilter/avfilter.c +27 −28
  6. libavfilter/avfilter.h +16 −0
  7. libavfilter/version.h +3 −0
cmdutils.c+4−4
@@ -1448,21 +1448,21 @@ int show_protocols(void *optctx, const char *opt, const char *arg) · 1447 unmodified lines
14481448
14491449 int show_filters(void *optctx, const char *opt, const char *arg)
14501450 {
1451− AVFilter av_unused(**filter) = NULL;
1451+ const AVFilter av_unused(*filter) = NULL;
14521452 char descr[64], *descr_cur;
14531453 int i, j;
14541454 const AVFilterPad *pad;
14551455
14561456 printf("Filters:\n");
14571457 #if CONFIG_AVFILTER
1458− while ((filter = av_filter_next(filter)) && *filter) {
1458+ while ((filter = avfilter_next(filter))) {
14591459 descr_cur = descr;
14601460 for (i = 0; i < 2; i++) {
14611461 if (i) {
14621462 *(descr_cur++) = '-';
14631463 *(descr_cur++) = '>';
14641464 }
1465− pad = i ? (*filter)->outputs : (*filter)->inputs;
1465+ pad = i ? filter->outputs : filter->inputs;
14661466 for (j = 0; pad && pad[j].name; j++) {
14671467 if (descr_cur >= descr + sizeof(descr) - 4)
14681468 break;
@@ -1472,7 +1472,7 @@ int show_filters(void *optctx, const char *opt, const char *arg) · 3 unmodified lines
14721472 *(descr_cur++) = '|';
14731473 }
14741474 *descr_cur = 0;
1475− printf("%-16s %-10s %s\n", (*filter)->name, descr, (*filter)->description);
1475+ printf("%-16s %-10s %s\n", filter->name, descr, filter->description);
14761476 }
14771477 #endif
14781478 return 0;
doc/APIchanges+2−0
@@ -171,6 +171,8 @@ API changes, most recent first: · 170 unmodified lines
171171 Add avfilter_init_dict().
172172 Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags.
173173 Add avfilter_pad_count() for counting filter inputs/outputs.
174+ Add avfilter_next(), deprecate av_filter_next().
175+ Deprecate avfilter_uninit().
174176
175177 2013-xx-xx - lavfi 3.7.0 - avfilter.h
176178 Add AVFilter.priv_class for exporting filter options through the AVOptions API
ffmpeg.c+0−1
@@ -499,7 +499,6 @@ static void exit_program(void) · 498 unmodified lines
499499
500500 uninit_opts();
501501
502− avfilter_uninit();
503502 avformat_network_deinit();
504503
505504 if (received_sigterm) {
ffplay.c+0−1
@@ -1027,7 +1027,6 @@ static void do_exit(VideoState *is) · 1026 unmodified lines
10271027 av_lockmgr_register(NULL);
10281028 uninit_opts();
10291029 #if CONFIG_AVFILTER
1030− avfilter_uninit();
10311030 av_freep(&vfilters);
10321031 #endif
10331032 avformat_network_deinit();
libavfilter/avfilter.c+27−28
@@ -386,55 +386,53 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha · 385 unmodified lines
386386 return AVERROR(ENOSYS);
387387 }
388388
389−#define MAX_REGISTERED_AVFILTERS_NB 256
390−
391−static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1];
392−
393−static int next_registered_avfilter_idx = 0;
389+static AVFilter *first_filter;
394390
395391 AVFilter *avfilter_get_by_name(const char *name)
396392 {
397− int i;
393+ AVFilter *f = NULL;
398394
399− for (i = 0; registered_avfilters[i]; i++)
400− if (!strcmp(registered_avfilters[i]->name, name))
401− return registered_avfilters[i];
395+ while ((f = avfilter_next(f)))
396+ if (!strcmp(f->name, name))
397+ return f;
402398
403399 return NULL;
404400 }
405401
406402 int avfilter_register(AVFilter *filter)
407403 {
404+ AVFilter **f = &first_filter;
408405 int i;
409406
410− if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB) {
411− av_log(NULL, AV_LOG_ERROR,
412− "Maximum number of registered filters %d reached, "
413− "impossible to register filter with name '%s'\n",
414− MAX_REGISTERED_AVFILTERS_NB, filter->name);
415− return AVERROR(ENOMEM);
416− }
417−
418407 for(i=0; filter->inputs && filter->inputs[i].name; i++) {
419408 const AVFilterPad *input = &filter->inputs[i];
420409 av_assert0( !input->filter_frame
421410 || (!input->start_frame && !input->end_frame));
422411 }
423412
424− registered_avfilters[next_registered_avfilter_idx++] = filter;
413+ while (*f)
414+ f = &(*f)->next;
415+ *f = filter;
416+ filter->next = NULL;
417+
425418 return 0;
426419 }
427420
421+const AVFilter *avfilter_next(const AVFilter *prev)
422+{
423+ return prev ? prev->next : first_filter;
424+}
425+
426+#if FF_API_OLD_FILTER_REGISTER
428427 AVFilter **av_filter_next(AVFilter **filter)
429428 {
430− return filter ? ++filter : &registered_avfilters[0];
429+ return filter ? &(*filter)->next : &first_filter;
431430 }
432431
433432 void avfilter_uninit(void)
434433 {
435− memset(registered_avfilters, 0, sizeof(registered_avfilters));
436− next_registered_avfilter_idx = 0;
437434 }
435+#endif
438436
439437 int avfilter_pad_count(const AVFilterPad *pads)
440438 {
@@ -463,21 +461,22 @@ static void *filter_child_next(void *obj, void *prev) · 22 unmodified lines
463461
464462 static const AVClass *filter_child_class_next(const AVClass *prev)
465463 {
466− AVFilter **f = NULL;
464+ AVFilter *f = NULL;
467465
468466 /* find the filter that corresponds to prev */
469− while (prev && *(f = av_filter_next(f)))
470− if ((*f)->priv_class == prev)
467+ while (prev && (f = avfilter_next(f)))
468+ if (f->priv_class == prev)
471469 break;
472470
473471 /* could not find filter corresponding to prev */
474− if (prev && !(*f))
472+ if (prev && !f)
475473 return NULL;
476474
477475 /* find next filter with specific options */
478− while (*(f = av_filter_next(f)))
479− if ((*f)->priv_class)
480− return (*f)->priv_class;
476+ while ((f = avfilter_next(f)))
477+ if (f->priv_class)
478+ return f->priv_class;
479+
481480 return NULL;
482481 }
483482
libavfilter/avfilter.h+16−0
@@ -496,6 +496,8 @@ typedef struct AVFilter { · 495 unmodified lines
496496
497497 int priv_size; ///< size of private data to allocate for the filter
498498
499+ struct AVFilter *next;
500+
499501 /**
500502 * Make the filter instance process a command.
501503 *
@@ -837,8 +839,11 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha · 335 unmodified lines
837839 /** Initialize the filter system. Register all builtin filters. */
838840 void avfilter_register_all(void);
839841
842+#if FF_API_OLD_FILTER_REGISTER
840843 /** Uninitialize the filter system. Unregister all filters. */
844+attribute_deprecated
841845 void avfilter_uninit(void);
846+#endif
842847
843848 /**
844849 * Register a filter. This is only needed if you plan to use
@@ -861,13 +866,24 @@ int avfilter_register(AVFilter *filter); · 16 unmodified lines
861866 */
862867 AVFilter *avfilter_get_by_name(const char *name);
863868
869+/**
870+ * Iterate over all registered filters.
871+ * @return If prev is non-NULL, next registered filter after prev or NULL if
872+ * prev is the last filter. If prev is NULL, return the first registered filter.
873+ */
874+const AVFilter *avfilter_next(const AVFilter *prev);
875+
876+#if FF_API_OLD_FILTER_REGISTER
864877 /**
865878 * If filter is NULL, returns a pointer to the first registered filter pointer,
866879 * if filter is non-NULL, returns the next pointer after filter.
867880 * If the returned pointer points to NULL, the last registered filter
868881 * was already reached.
882+ * @deprecated use avfilter_next()
869883 */
884+attribute_deprecated
870885 AVFilter **av_filter_next(AVFilter **filter);
886+#endif
871887
872888 #if FF_API_AVFILTER_OPEN
873889 /**
libavfilter/version.h+3−0
@@ -75,5 +75,8 @@ · 74 unmodified lines
7575 #ifndef FF_API_AVFILTER_INIT_FILTER
7676 #define FF_API_AVFILTER_INIT_FILTER (LIBAVFILTER_VERSION_MAJOR < 4)
7777 #endif
78+#ifndef FF_API_OLD_FILTER_REGISTER
79+#define FF_API_OLD_FILTER_REGISTER (LIBAVFILTER_VERSION_MAJOR < 4)
80+#endif
7881
7982 #endif /* AVFILTER_VERSION_H */

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