Removes an arbitrary hardcoded limit on the number of filters.
Unified · Split
| @@ -211,7 +211,6 @@ static void exit_program(void) · 210 unmodified lines | |||
| 211 | 211 | ||
| 212 | uninit_opts(); | 212 | uninit_opts(); |
| 213 | 213 | ||
| 214 | avfilter_uninit(); | ||
| 215 | avformat_network_deinit(); | 214 | avformat_network_deinit(); |
| 216 | 215 | ||
| 217 | if (received_sigterm) { | 216 | if (received_sigterm) { |
| @@ -1246,9 +1246,6 @@ static void do_exit(void) · 1245 unmodified lines | |||
| 1246 | cur_stream = NULL; | 1246 | cur_stream = NULL; |
| 1247 | } | 1247 | } |
| 1248 | uninit_opts(); | 1248 | uninit_opts(); |
| 1249 | #if CONFIG_AVFILTER | ||
| 1250 | avfilter_uninit(); | ||
| 1251 | #endif | ||
| 1252 | avformat_network_deinit(); | 1249 | avformat_network_deinit(); |
| 1253 | if (show_status) | 1250 | if (show_status) |
| 1254 | printf("\n"); | 1251 | printf("\n"); |
| @@ -1130,12 +1130,12 @@ int show_protocols(void *optctx, const char *opt, const char *arg) · 1129 unmodified lines | |||
| 1130 | 1130 | ||
| 1131 | int show_filters(void *optctx, const char *opt, const char *arg) | 1131 | int show_filters(void *optctx, const char *opt, const char *arg) |
| 1132 | { | 1132 | { |
| 1133 | AVFilter av_unused(**filter) = NULL; | 1133 | const AVFilter av_unused(*filter) = NULL; |
| 1134 | 1134 | ||
| 1135 | printf("Filters:\n"); | 1135 | printf("Filters:\n"); |
| 1136 | #if CONFIG_AVFILTER | 1136 | #if CONFIG_AVFILTER |
| 1137 | while ((filter = av_filter_next(filter)) && *filter) | 1137 | while ((filter = avfilter_next(filter))) |
| 1138 | printf("%-16s %s\n", (*filter)->name, (*filter)->description); | 1138 | printf("%-16s %s\n", filter->name, filter->description); |
| 1139 | #endif | 1139 | #endif |
| 1140 | return 0; | 1140 | return 0; |
| 1141 | } | 1141 | } |
| @@ -24,6 +24,8 @@ API changes, most recent first: · 23 unmodified lines | |||
| 24 | Add avfilter_init_dict(). | 24 | Add avfilter_init_dict(). |
| 25 | Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags. | 25 | Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags. |
| 26 | Add avfilter_pad_count() for counting filter inputs/outputs. | 26 | Add avfilter_pad_count() for counting filter inputs/outputs. |
| 27 | Add avfilter_next(), deprecate av_filter_next(). | ||
| 28 | Deprecate avfilter_uninit(). | ||
| 27 | 29 | ||
| 28 | 2013-xx-xx - lavfi 3.7.0 - avfilter.h | 30 | 2013-xx-xx - lavfi 3.7.0 - avfilter.h |
| 29 | Add AVFilter.priv_class for exporting filter options through the AVOptions API | 31 | Add AVFilter.priv_class for exporting filter options through the AVOptions API |
| @@ -267,42 +267,44 @@ int ff_poll_frame(AVFilterLink *link) · 266 unmodified lines | |||
| 267 | return min; | 267 | return min; |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | #define MAX_REGISTERED_AVFILTERS_NB 64 | 270 | static AVFilter *first_filter; |
| 271 | |||
| 272 | static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; | ||
| 273 | |||
| 274 | static int next_registered_avfilter_idx = 0; | ||
| 275 | 271 | ||
| 276 | AVFilter *avfilter_get_by_name(const char *name) | 272 | AVFilter *avfilter_get_by_name(const char *name) |
| 277 | { | 273 | { |
| 278 | int i; | 274 | AVFilter *f = NULL; |
| 279 | 275 | ||
| 280 | for (i = 0; registered_avfilters[i]; i++) | 276 | while ((f = avfilter_next(f))) |
| 281 | if (!strcmp(registered_avfilters[i]->name, name)) | 277 | if (!strcmp(f->name, name)) |
| 282 | return registered_avfilters[i]; | 278 | return f; |
| 283 | 279 | ||
| 284 | return NULL; | 280 | return NULL; |
| 285 | } | 281 | } |
| 286 | 282 | ||
| 287 | int avfilter_register(AVFilter *filter) | 283 | int avfilter_register(AVFilter *filter) |
| 288 | { | 284 | { |
| 289 | if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB) | 285 | AVFilter **f = &first_filter; |
| 290 | return -1; | 286 | while (*f) |
| 291 | 287 | f = &(*f)->next; | |
| 292 | registered_avfilters[next_registered_avfilter_idx++] = filter; | 288 | *f = filter; |
| 289 | filter->next = NULL; | ||
| 293 | return 0; | 290 | return 0; |
| 294 | } | 291 | } |
| 295 | 292 | ||
| 293 | const AVFilter *avfilter_next(const AVFilter *prev) | ||
| 294 | { | ||
| 295 | return prev ? prev->next : first_filter; | ||
| 296 | } | ||
| 297 | |||
| 298 | #if FF_API_OLD_FILTER_REGISTER | ||
| 296 | AVFilter **av_filter_next(AVFilter **filter) | 299 | AVFilter **av_filter_next(AVFilter **filter) |
| 297 | { | 300 | { |
| 298 | return filter ? ++filter : ®istered_avfilters[0]; | 301 | return filter ? &(*filter)->next : &first_filter; |
| 299 | } | 302 | } |
| 300 | 303 | ||
| 301 | void avfilter_uninit(void) | 304 | void avfilter_uninit(void) |
| 302 | { | 305 | { |
| 303 | memset(registered_avfilters, 0, sizeof(registered_avfilters)); | ||
| 304 | next_registered_avfilter_idx = 0; | ||
| 305 | } | 306 | } |
| 307 | #endif | ||
| 306 | 308 | ||
| 307 | int avfilter_pad_count(const AVFilterPad *pads) | 309 | int avfilter_pad_count(const AVFilterPad *pads) |
| 308 | { | 310 | { |
| @@ -331,15 +333,15 @@ static void *filter_child_next(void *obj, void *prev) · 22 unmodified lines | |||
| 331 | 333 | ||
| 332 | static const AVClass *filter_child_class_next(const AVClass *prev) | 334 | static const AVClass *filter_child_class_next(const AVClass *prev) |
| 333 | { | 335 | { |
| 334 | AVFilter **f = NULL; | 336 | AVFilter *f = NULL; |
| 335 | 337 | ||
| 336 | while (prev && *(f = av_filter_next(f))) | 338 | while (prev && (f = avfilter_next(f))) |
| 337 | if ((*f)->priv_class == prev) | 339 | if (f->priv_class == prev) |
| 338 | break; | 340 | break; |
| 339 | 341 | ||
| 340 | while (*(f = av_filter_next(f))) | 342 | while ((f = avfilter_next(f))) |
| 341 | if ((*f)->priv_class) | 343 | if (f->priv_class) |
| 342 | return (*f)->priv_class; | 344 | return f->priv_class; |
| 343 | 345 | ||
| 344 | return NULL; | 346 | return NULL; |
| 345 | } | 347 | } |
| @@ -457,6 +457,8 @@ typedef struct AVFilter { · 456 unmodified lines | |||
| 457 | int (*query_formats)(AVFilterContext *); | 457 | int (*query_formats)(AVFilterContext *); |
| 458 | 458 | ||
| 459 | int priv_size; ///< size of private data to allocate for the filter | 459 | int priv_size; ///< size of private data to allocate for the filter |
| 460 | |||
| 461 | struct AVFilter *next; | ||
| 460 | } AVFilter; | 462 | } AVFilter; |
| 461 | 463 | ||
| 462 | /** An instance of a filter */ | 464 | /** An instance of a filter */ |
| @@ -622,8 +624,11 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, · 159 unmodified lines | |||
| 622 | /** Initialize the filter system. Register all builtin filters. */ | 624 | /** Initialize the filter system. Register all builtin filters. */ |
| 623 | void avfilter_register_all(void); | 625 | void avfilter_register_all(void); |
| 624 | 626 | ||
| 627 | #if FF_API_OLD_FILTER_REGISTER | ||
| 625 | /** Uninitialize the filter system. Unregister all filters. */ | 628 | /** Uninitialize the filter system. Unregister all filters. */ |
| 629 | attribute_deprecated | ||
| 626 | void avfilter_uninit(void); | 630 | void avfilter_uninit(void); |
| 631 | #endif | ||
| 627 | 632 | ||
| 628 | /** | 633 | /** |
| 629 | * Register a filter. This is only needed if you plan to use | 634 | * Register a filter. This is only needed if you plan to use |
| @@ -646,13 +651,24 @@ int avfilter_register(AVFilter *filter); · 16 unmodified lines | |||
| 646 | */ | 651 | */ |
| 647 | AVFilter *avfilter_get_by_name(const char *name); | 652 | AVFilter *avfilter_get_by_name(const char *name); |
| 648 | 653 | ||
| 654 | /** | ||
| 655 | * Iterate over all registered filters. | ||
| 656 | * @return If prev is non-NULL, next registered filter after prev or NULL if | ||
| 657 | * prev is the last filter. If prev is NULL, return the first registered filter. | ||
| 658 | */ | ||
| 659 | const AVFilter *avfilter_next(const AVFilter *prev); | ||
| 660 | |||
| 661 | #if FF_API_OLD_FILTER_REGISTER | ||
| 649 | /** | 662 | /** |
| 650 | * If filter is NULL, returns a pointer to the first registered filter pointer, | 663 | * If filter is NULL, returns a pointer to the first registered filter pointer, |
| 651 | * if filter is non-NULL, returns the next pointer after filter. | 664 | * if filter is non-NULL, returns the next pointer after filter. |
| 652 | * If the returned pointer points to NULL, the last registered filter | 665 | * If the returned pointer points to NULL, the last registered filter |
| 653 | * was already reached. | 666 | * was already reached. |
| 667 | * @deprecated use avfilter_next() | ||
| 654 | */ | 668 | */ |
| 669 | attribute_deprecated | ||
| 655 | AVFilter **av_filter_next(AVFilter **filter); | 670 | AVFilter **av_filter_next(AVFilter **filter); |
| 671 | #endif | ||
| 656 | 672 | ||
| 657 | #if FF_API_AVFILTER_OPEN | 673 | #if FF_API_AVFILTER_OPEN |
| 658 | /** | 674 | /** |
| @@ -64,5 +64,8 @@ · 63 unmodified lines | |||
| 64 | #ifndef FF_API_AVFILTER_INIT_FILTER | 64 | #ifndef FF_API_AVFILTER_INIT_FILTER |
| 65 | #define FF_API_AVFILTER_INIT_FILTER (LIBAVFILTER_VERSION_MAJOR < 4) | 65 | #define FF_API_AVFILTER_INIT_FILTER (LIBAVFILTER_VERSION_MAJOR < 4) |
| 66 | #endif | 66 | #endif |
| 67 | #ifndef FF_API_OLD_FILTER_REGISTER | ||
| 68 | #define FF_API_OLD_FILTER_REGISTER (LIBAVFILTER_VERSION_MAJOR < 4) | ||
| 69 | #endif | ||
| 67 | 70 | ||
| 68 | #endif /* AVFILTER_VERSION_H */ | 71 | #endif /* AVFILTER_VERSION_H */ |