diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-12-02 20:12:27 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-12-02 20:12:27 +0000 |
commit | 037be76e1588fc8135dd307ba0be4c792b3e93e6 (patch) | |
tree | 80f3a139615d0c530fd2399ce8daf437271ab58c /libavfilter | |
parent | 9398024c048092786f1dcf0809fb55bdbf96a70f (diff) | |
download | ffmpeg-037be76e1588fc8135dd307ba0be4c792b3e93e6.tar.gz |
Add avfilter_graph_create_filter().
Originally committed as revision 25862 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/avfilter.h | 2 | ||||
-rw-r--r-- | libavfilter/avfiltergraph.c | 38 | ||||
-rw-r--r-- | libavfilter/avfiltergraph.h | 17 |
3 files changed, 45 insertions, 12 deletions
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index f7aaf7fb6d..4dea65310c 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -25,7 +25,7 @@ #include "libavutil/avutil.h" #define LIBAVFILTER_VERSION_MAJOR 1 -#define LIBAVFILTER_VERSION_MINOR 66 +#define LIBAVFILTER_VERSION_MINOR 67 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 97dd120d89..8a258912df 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -53,6 +53,27 @@ int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) return 0; } +int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, + const char *name, const char *args, void *opaque, + AVFilterGraph *graph_ctx) +{ + int ret; + + if ((ret = avfilter_open(filt_ctx, filt, name)) < 0) + goto fail; + if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0) + goto fail; + if ((ret = avfilter_graph_add_filter(graph_ctx, *filt_ctx)) < 0) + goto fail; + return 0; + +fail: + if (*filt_ctx) + avfilter_free(*filt_ctx); + *filt_ctx = NULL; + return ret; +} + int ff_avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx) { AVFilterContext *filt; @@ -113,7 +134,7 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name) static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) { - int i, j; + int i, j, ret; int scaler_count = 0; char inst_name[30]; @@ -139,17 +160,12 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) /* couldn't merge format lists. auto-insert scale filter */ snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d", scaler_count++); - avfilter_open(&scale, avfilter_get_by_name("scale"), inst_name); - snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts); - if(!scale || scale->filter->init(scale, scale_args, NULL) || - avfilter_insert_filter(link, scale, 0, 0)) { - avfilter_free(scale); - return -1; - } - - if (avfilter_graph_add_filter(graph, scale) < 0) - return -1; + if ((ret = avfilter_graph_create_filter(&scale, avfilter_get_by_name("scale"), + inst_name, scale_args, NULL, graph)) < 0) + return ret; + if ((ret = avfilter_insert_filter(link, scale, 0, 0)) < 0) + return ret; scale->filter->query_formats(scale); if (((link = scale-> inputs[0]) && diff --git a/libavfilter/avfiltergraph.h b/libavfilter/avfiltergraph.h index ca369aa589..74d7a12812 100644 --- a/libavfilter/avfiltergraph.h +++ b/libavfilter/avfiltergraph.h @@ -53,6 +53,23 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name); int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter); /** + * Create and add a filter instance into an existing graph. + * The filter instance is created from the filter filt and inited + * with the parameters args and opaque. + * + * In case of success put in *filt_ctx the pointer to the created + * filter instance, otherwise set *filt_ctx to NULL. + * + * @param name the instance name to give to the created filter instance + * @param graph_ctx the filter graph + * @return a negative AVERROR error code in case of failure, a non + * negative value otherwise + */ +int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, + const char *name, const char *args, void *opaque, + AVFilterGraph *graph_ctx); + +/** * Check validity and configure all the links and formats in the graph. * * @param graphctx the filter graph |