* 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.
Unified · Split
| @@ -1448,21 +1448,21 @@ int show_protocols(void *optctx, const char *opt, const char *arg) · 1447 unmodified lines | ||
| 1448 | 1448 | |
| 1449 | 1449 | int show_filters(void *optctx, const char *opt, const char *arg) |
| 1450 | 1450 | { |
| 1451 | − AVFilter av_unused(**filter) = NULL; | |
| 1451 | + const AVFilter av_unused(*filter) = NULL; | |
| 1452 | 1452 | char descr[64], *descr_cur; |
| 1453 | 1453 | int i, j; |
| 1454 | 1454 | const AVFilterPad *pad; |
| 1455 | 1455 | |
| 1456 | 1456 | printf("Filters:\n"); |
| 1457 | 1457 | #if CONFIG_AVFILTER |
| 1458 | − while ((filter = av_filter_next(filter)) && *filter) { | |
| 1458 | + while ((filter = avfilter_next(filter))) { | |
| 1459 | 1459 | descr_cur = descr; |
| 1460 | 1460 | for (i = 0; i < 2; i++) { |
| 1461 | 1461 | if (i) { |
| 1462 | 1462 | *(descr_cur++) = '-'; |
| 1463 | 1463 | *(descr_cur++) = '>'; |
| 1464 | 1464 | } |
| 1465 | − pad = i ? (*filter)->outputs : (*filter)->inputs; | |
| 1465 | + pad = i ? filter->outputs : filter->inputs; | |
| 1466 | 1466 | for (j = 0; pad && pad[j].name; j++) { |
| 1467 | 1467 | if (descr_cur >= descr + sizeof(descr) - 4) |
| 1468 | 1468 | break; |
| @@ -1472,7 +1472,7 @@ int show_filters(void *optctx, const char *opt, const char *arg) · 3 unmodified lines | ||
| 1472 | 1472 | *(descr_cur++) = '|'; |
| 1473 | 1473 | } |
| 1474 | 1474 | *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); | |
| 1476 | 1476 | } |
| 1477 | 1477 | #endif |
| 1478 | 1478 | return 0; |
| @@ -171,6 +171,8 @@ API changes, most recent first: · 170 unmodified lines | ||
| 171 | 171 | Add avfilter_init_dict(). |
| 172 | 172 | Add AVFilter.flags field and AVFILTER_FLAG_DYNAMIC_{INPUTS,OUTPUTS} flags. |
| 173 | 173 | Add avfilter_pad_count() for counting filter inputs/outputs. |
| 174 | + Add avfilter_next(), deprecate av_filter_next(). | |
| 175 | + Deprecate avfilter_uninit(). | |
| 174 | 176 | |
| 175 | 177 | 2013-xx-xx - lavfi 3.7.0 - avfilter.h |
| 176 | 178 | Add AVFilter.priv_class for exporting filter options through the AVOptions API |
| @@ -499,7 +499,6 @@ static void exit_program(void) · 498 unmodified lines | ||
| 499 | 499 | |
| 500 | 500 | uninit_opts(); |
| 501 | 501 | |
| 502 | − avfilter_uninit(); | |
| 503 | 502 | avformat_network_deinit(); |
| 504 | 503 | |
| 505 | 504 | if (received_sigterm) { |
| @@ -1027,7 +1027,6 @@ static void do_exit(VideoState *is) · 1026 unmodified lines | ||
| 1027 | 1027 | av_lockmgr_register(NULL); |
| 1028 | 1028 | uninit_opts(); |
| 1029 | 1029 | #if CONFIG_AVFILTER |
| 1030 | − avfilter_uninit(); | |
| 1031 | 1030 | av_freep(&vfilters); |
| 1032 | 1031 | #endif |
| 1033 | 1032 | avformat_network_deinit(); |
| @@ -386,55 +386,53 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha · 385 unmodified lines | ||
| 386 | 386 | return AVERROR(ENOSYS); |
| 387 | 387 | } |
| 388 | 388 | |
| 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; | |
| 394 | 390 | |
| 395 | 391 | AVFilter *avfilter_get_by_name(const char *name) |
| 396 | 392 | { |
| 397 | − int i; | |
| 393 | + AVFilter *f = NULL; | |
| 398 | 394 | |
| 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; | |
| 402 | 398 | |
| 403 | 399 | return NULL; |
| 404 | 400 | } |
| 405 | 401 | |
| 406 | 402 | int avfilter_register(AVFilter *filter) |
| 407 | 403 | { |
| 404 | + AVFilter **f = &first_filter; | |
| 408 | 405 | int i; |
| 409 | 406 | |
| 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 | − | |
| 418 | 407 | for(i=0; filter->inputs && filter->inputs[i].name; i++) { |
| 419 | 408 | const AVFilterPad *input = &filter->inputs[i]; |
| 420 | 409 | av_assert0( !input->filter_frame |
| 421 | 410 | || (!input->start_frame && !input->end_frame)); |
| 422 | 411 | } |
| 423 | 412 | |
| 424 | − registered_avfilters[next_registered_avfilter_idx++] = filter; | |
| 413 | + while (*f) | |
| 414 | + f = &(*f)->next; | |
| 415 | + *f = filter; | |
| 416 | + filter->next = NULL; | |
| 417 | + | |
| 425 | 418 | return 0; |
| 426 | 419 | } |
| 427 | 420 | |
| 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 | |
| 428 | 427 | AVFilter **av_filter_next(AVFilter **filter) |
| 429 | 428 | { |
| 430 | − return filter ? ++filter : ®istered_avfilters[0]; | |
| 429 | + return filter ? &(*filter)->next : &first_filter; | |
| 431 | 430 | } |
| 432 | 431 | |
| 433 | 432 | void avfilter_uninit(void) |
| 434 | 433 | { |
| 435 | − memset(registered_avfilters, 0, sizeof(registered_avfilters)); | |
| 436 | − next_registered_avfilter_idx = 0; | |
| 437 | 434 | } |
| 435 | +#endif | |
| 438 | 436 | |
| 439 | 437 | int avfilter_pad_count(const AVFilterPad *pads) |
| 440 | 438 | { |
| @@ -463,21 +461,22 @@ static void *filter_child_next(void *obj, void *prev) · 22 unmodified lines | ||
| 463 | 461 | |
| 464 | 462 | static const AVClass *filter_child_class_next(const AVClass *prev) |
| 465 | 463 | { |
| 466 | − AVFilter **f = NULL; | |
| 464 | + AVFilter *f = NULL; | |
| 467 | 465 | |
| 468 | 466 | /* 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) | |
| 471 | 469 | break; |
| 472 | 470 | |
| 473 | 471 | /* could not find filter corresponding to prev */ |
| 474 | − if (prev && !(*f)) | |
| 472 | + if (prev && !f) | |
| 475 | 473 | return NULL; |
| 476 | 474 | |
| 477 | 475 | /* 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 | + | |
| 481 | 480 | return NULL; |
| 482 | 481 | } |
| 483 | 482 | |
| @@ -496,6 +496,8 @@ typedef struct AVFilter { · 495 unmodified lines | ||
| 496 | 496 | |
| 497 | 497 | int priv_size; ///< size of private data to allocate for the filter |
| 498 | 498 | |
| 499 | + struct AVFilter *next; | |
| 500 | + | |
| 499 | 501 | /** |
| 500 | 502 | * Make the filter instance process a command. |
| 501 | 503 | * |
| @@ -837,8 +839,11 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha · 335 unmodified lines | ||
| 837 | 839 | /** Initialize the filter system. Register all builtin filters. */ |
| 838 | 840 | void avfilter_register_all(void); |
| 839 | 841 | |
| 842 | +#if FF_API_OLD_FILTER_REGISTER | |
| 840 | 843 | /** Uninitialize the filter system. Unregister all filters. */ |
| 844 | +attribute_deprecated | |
| 841 | 845 | void avfilter_uninit(void); |
| 846 | +#endif | |
| 842 | 847 | |
| 843 | 848 | /** |
| 844 | 849 | * Register a filter. This is only needed if you plan to use |
| @@ -861,13 +866,24 @@ int avfilter_register(AVFilter *filter); · 16 unmodified lines | ||
| 861 | 866 | */ |
| 862 | 867 | AVFilter *avfilter_get_by_name(const char *name); |
| 863 | 868 | |
| 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 | |
| 864 | 877 | /** |
| 865 | 878 | * If filter is NULL, returns a pointer to the first registered filter pointer, |
| 866 | 879 | * if filter is non-NULL, returns the next pointer after filter. |
| 867 | 880 | * If the returned pointer points to NULL, the last registered filter |
| 868 | 881 | * was already reached. |
| 882 | + * @deprecated use avfilter_next() | |
| 869 | 883 | */ |
| 884 | +attribute_deprecated | |
| 870 | 885 | AVFilter **av_filter_next(AVFilter **filter); |
| 886 | +#endif | |
| 871 | 887 | |
| 872 | 888 | #if FF_API_AVFILTER_OPEN |
| 873 | 889 | /** |
| @@ -75,5 +75,8 @@ · 74 unmodified lines | ||
| 75 | 75 | #ifndef FF_API_AVFILTER_INIT_FILTER |
| 76 | 76 | #define FF_API_AVFILTER_INIT_FILTER (LIBAVFILTER_VERSION_MAJOR < 4) |
| 77 | 77 | #endif |
| 78 | +#ifndef FF_API_OLD_FILTER_REGISTER | |
| 79 | +#define FF_API_OLD_FILTER_REGISTER (LIBAVFILTER_VERSION_MAJOR < 4) | |
| 80 | +#endif | |
| 78 | 81 | |
| 79 | 82 | #endif /* AVFILTER_VERSION_H */ |