[FFmpeg-devel] [PATCH 1/2] lavfi: add avfilter_graph_set_auto_convert().

Nicolas George nicolas.george at normalesup.org
Thu May 3 20:45:22 CEST 2012


Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavfilter/avfiltergraph.c |   13 +++++++++++++
 libavfilter/avfiltergraph.h |   17 +++++++++++++++++
 libavfilter/version.h       |    4 ++--
 3 files changed, 32 insertions(+), 2 deletions(-)


Same code as first version, function name changed according to Stefano's
suggestion.


diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 9d7b956..1a76554 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -95,6 +95,11 @@ fail:
     return ret;
 }
 
+void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
+{
+    graph->disable_auto_convert = flags;
+}
+
 int ff_avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
 {
     AVFilterContext *filt;
@@ -160,6 +165,14 @@ static int insert_conv_filter(AVFilterGraph *graph, AVFilterLink *link,
     char inst_name[32];
     AVFilterContext *filt_ctx;
 
+    if (graph->disable_auto_convert) {
+        av_log(NULL, AV_LOG_ERROR,
+               "The filters '%s' and '%s' do not have a common format "
+               "and automatic conversion is disabled.\n",
+               link->src->name, link->dst->name);
+        return AVERROR(EINVAL);
+    }
+
     snprintf(inst_name, sizeof(inst_name), "auto-inserted %s %d",
             filt_name, auto_count++);
 
diff --git a/libavfilter/avfiltergraph.h b/libavfilter/avfiltergraph.h
index b003795..d2e343d 100644
--- a/libavfilter/avfiltergraph.h
+++ b/libavfilter/avfiltergraph.h
@@ -43,6 +43,8 @@ typedef struct AVFilterGraph {
 
     AVFilterLink **sink_links;
     int sink_links_count;
+
+    unsigned disable_auto_convert;
 } AVFilterGraph;
 
 /**
@@ -84,6 +86,21 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
                                  AVFilterGraph *graph_ctx);
 
 /**
+ * Disable automatic format conversion inside the graph.
+ *
+ * Note that format conversion can still happen inside explicitly inserted
+ * scale and aconvert filters.
+ *
+ * @param flags  must be AVFILTER_DISABLE_CONVERT_ALL for now
+ */
+void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags);
+
+enum {
+    AVFILTER_AUTO_CONVERT_ALL  =  0, /**< all automatic conversions enabled */
+    AVFILTER_AUTO_CONVERT_NONE = -1, /**< all automatic conversions disabled */
+};
+
+/**
  * Check validity and configure all the links and formats in the graph.
  *
  * @param graphctx the filter graph
diff --git a/libavfilter/version.h b/libavfilter/version.h
index c9da0c5..6a9a3e9 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -29,8 +29,8 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  2
-#define LIBAVFILTER_VERSION_MINOR 72
-#define LIBAVFILTER_VERSION_MICRO 104
+#define LIBAVFILTER_VERSION_MINOR 73
+#define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
-- 
1.7.10



More information about the ffmpeg-devel mailing list