* 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.
Showing the changes to libavfilter/avfilter.c (1 of 7 files). Show all
Unified · Split
| @@ -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 | |