* commit '1ba95a9cca57b023b9b9de071a5671fc05b05e58': lavfi: add avfilter_init_dict() for initializing a filter with a dict. Conflicts: libavfilter/avfilter.c
Unified · Split
| @@ -168,6 +168,7 @@ API changes, most recent first: · 167 unmodified lines | |||
| 168 | Add AVFilterContext.graph pointing to the AVFilterGraph that contains the | 168 | Add AVFilterContext.graph pointing to the AVFilterGraph that contains the |
| 169 | filter. | 169 | filter. |
| 170 | Add avfilter_init_str(), deprecate avfilter_init_filter(). | 170 | Add avfilter_init_str(), deprecate avfilter_init_filter(). |
| 171 | Add avfilter_init_dict(). | ||
| 171 | 172 | ||
| 172 | 2013-xx-xx - lavfi 3.7.0 - avfilter.h | 173 | 2013-xx-xx - lavfi 3.7.0 - avfilter.h |
| 173 | Add AVFilter.priv_class for exporting filter options through the AVOptions API | 174 | Add AVFilter.priv_class for exporting filter options through the AVOptions API |
| @@ -688,6 +688,28 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 687 unmodified lines | |||
| 688 | } | 688 | } |
| 689 | #endif | 689 | #endif |
| 690 | 690 | ||
| 691 | int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) | ||
| 692 | { | ||
| 693 | int ret = 0; | ||
| 694 | |||
| 695 | if (ctx->filter->priv_class) { | ||
| 696 | ret = av_opt_set_dict(ctx->priv, options); | ||
| 697 | if (ret < 0) { | ||
| 698 | av_log(ctx, AV_LOG_ERROR, "Error applying options to the filter.\n"); | ||
| 699 | return ret; | ||
| 700 | } | ||
| 701 | } | ||
| 702 | |||
| 703 | if (ctx->filter->init_opaque) | ||
| 704 | ret = ctx->filter->init_opaque(ctx, NULL); | ||
| 705 | else if (ctx->filter->init) | ||
| 706 | ret = ctx->filter->init(ctx); | ||
| 707 | else if (ctx->filter->init_dict) | ||
| 708 | ret = ctx->filter->init_dict(ctx, options); | ||
| 709 | |||
| 710 | return ret; | ||
| 711 | } | ||
| 712 | |||
| 691 | int avfilter_init_str(AVFilterContext *filter, const char *args) | 713 | int avfilter_init_str(AVFilterContext *filter, const char *args) |
| 692 | { | 714 | { |
| 693 | AVDictionary *options = NULL; | 715 | AVDictionary *options = NULL; |
| @@ -794,20 +816,7 @@ int avfilter_init_str(AVFilterContext *filter, const char *args) · 100 unmodified lines | |||
| 794 | } | 816 | } |
| 795 | } | 817 | } |
| 796 | 818 | ||
| 797 | if (filter->filter->priv_class) { | 819 | ret = avfilter_init_dict(filter, &options); |
| 798 | ret = av_opt_set_dict(filter->priv, &options); | ||
| 799 | if (ret < 0) { | ||
| 800 | av_log(filter, AV_LOG_ERROR, "Error applying options to the filter.\n"); | ||
| 801 | goto fail; | ||
| 802 | } | ||
| 803 | } | ||
| 804 | |||
| 805 | if (filter->filter->init_opaque) | ||
| 806 | ret = filter->filter->init_opaque(filter, NULL); | ||
| 807 | else if (filter->filter->init) | ||
| 808 | ret = filter->filter->init(filter); | ||
| 809 | else if (filter->filter->init_dict) | ||
| 810 | ret = filter->filter->init_dict(filter, &options); | ||
| 811 | if (ret < 0) | 820 | if (ret < 0) |
| 812 | goto fail; | 821 | goto fail; |
| 813 | 822 | ||
| @@ -888,6 +888,28 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 887 unmodified lines | |||
| 888 | */ | 888 | */ |
| 889 | int avfilter_init_str(AVFilterContext *ctx, const char *args); | 889 | int avfilter_init_str(AVFilterContext *ctx, const char *args); |
| 890 | 890 | ||
| 891 | /** | ||
| 892 | * Initialize a filter with the supplied dictionary of options. | ||
| 893 | * | ||
| 894 | * @param ctx uninitialized filter context to initialize | ||
| 895 | * @param options An AVDictionary filled with options for this filter. On | ||
| 896 | * return this parameter will be destroyed and replaced with | ||
| 897 | * a dict containing options that were not found. This dictionary | ||
| 898 | * must be freed by the caller. | ||
| 899 | * May be NULL, then this function is equivalent to | ||
| 900 | * avfilter_init_str() with the second parameter set to NULL. | ||
| 901 | * @return 0 on success, a negative AVERROR on failure | ||
| 902 | * | ||
| 903 | * @note This function and avfilter_init_str() do essentially the same thing, | ||
| 904 | * the difference is in manner in which the options are passed. It is up to the | ||
| 905 | * calling code to choose whichever is more preferable. The two functions also | ||
| 906 | * behave differently when some of the provided options are not declared as | ||
| 907 | * supported by the filter. In such a case, avfilter_init_str() will fail, but | ||
| 908 | * this function will leave those extra options in the options AVDictionary and | ||
| 909 | * continue as usual. | ||
| 910 | */ | ||
| 911 | int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options); | ||
| 912 | |||
| 891 | /** | 913 | /** |
| 892 | * Free a filter context. This will also remove the filter from its | 914 | * Free a filter context. This will also remove the filter from its |
| 893 | * filtergraph's list of filters. | 915 | * filtergraph's list of filters. |