Since we do not support "standalone" filters not attached to an AVFilterGraph, we should not have a public function to create such filters. In addition that function is horribly named, the action it does cannot be possibly described as "opening" a filter.
Showing the changes to libavfilter/avfilter.c (1 of 7 files). Show all
Unified · Split
| @@ -352,17 +352,16 @@ static const AVClass avfilter_class = { · 351 unmodified lines | ||
| 352 | 352 | .child_class_next = filter_child_class_next, |
| 353 | 353 | }; |
| 354 | 354 | |
| 355 | −int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name) | |
| 355 | +AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) | |
| 356 | 356 | { |
| 357 | 357 | AVFilterContext *ret; |
| 358 | − *filter_ctx = NULL; | |
| 359 | 358 | |
| 360 | 359 | if (!filter) |
| 361 | − return AVERROR(EINVAL); | |
| 360 | + return NULL; | |
| 362 | 361 | |
| 363 | 362 | ret = av_mallocz(sizeof(AVFilterContext)); |
| 364 | 363 | if (!ret) |
| 365 | − return AVERROR(ENOMEM); | |
| 364 | + return NULL; | |
| 366 | 365 | |
| 367 | 366 | ret->av_class = &avfilter_class; |
| 368 | 367 | ret->filter = filter; |
| @@ -404,8 +403,7 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in · 35 unmodified lines | ||
| 404 | 403 | ret->input_count = ret->nb_inputs; |
| 405 | 404 | #endif |
| 406 | 405 | |
| 407 | − *filter_ctx = ret; | |
| 408 | − return 0; | |
| 406 | + return ret; | |
| 409 | 407 | |
| 410 | 408 | err: |
| 411 | 409 | av_freep(&ret->inputs); |
| @@ -416,9 +414,17 @@ err: · 4 unmodified lines | ||
| 416 | 414 | ret->nb_outputs = 0; |
| 417 | 415 | av_freep(&ret->priv); |
| 418 | 416 | av_free(ret); |
| 419 | − return AVERROR(ENOMEM); | |
| 417 | + return NULL; | |
| 420 | 418 | } |
| 421 | 419 | |
| 420 | +#if FF_API_AVFILTER_OPEN | |
| 421 | +int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name) | |
| 422 | +{ | |
| 423 | + *filter_ctx = ff_filter_alloc(filter, inst_name); | |
| 424 | + return *filter_ctx ? 0 : AVERROR(ENOMEM); | |
| 425 | +} | |
| 426 | +#endif | |
| 427 | + | |
| 422 | 428 | void avfilter_free(AVFilterContext *filter) |
| 423 | 429 | { |
| 424 | 430 | int i; |