Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-04-02 01:48:36 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-04-02 02:17:02 +0400
commit49891784ce70456305f19847d4188f07bbc1b6e1 (patch)
treeea5bd40d34743197c8cd4329ba223a8ba49118b3 /libavfilter/avfiltergraph.c
parent178f75a5aeb3606bb7947e08f0b89826f5e31f85 (diff)
parent95587d29d73c5cdf39062fde3f21436f8abf3e79 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: vsrc_buffer: allow buffering arbitrary number of frames. vf_scale: avoid a pointless memcpy in no-op conversion. avfiltergraph: try to reduce format conversions in filters. avfiltergraph: add an AVClass to AVFilterGraph on next major bump. id3v2: fix skipping extended header in id3v2.4 Conflicts: libavfilter/vf_scale.c libavfilter/vsrc_buffer.c libavformat/id3v2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r--libavfilter/avfiltergraph.c64
1 files changed, 62 insertions, 2 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 50ba8fbcf8..af06a9172f 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -28,9 +28,23 @@
#include "avfiltergraph.h"
#include "internal.h"
+#include "libavutil/log.h"
+
+static const AVClass filtergraph_class = {
+ .class_name = "AVFilterGraph",
+ .item_name = av_default_item_name,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVFilterGraph *avfilter_graph_alloc(void)
{
- return av_mallocz(sizeof(AVFilterGraph));
+ AVFilterGraph *ret = av_mallocz(sizeof(AVFilterGraph));
+ if (!ret)
+ return NULL;
+#if FF_API_GRAPH_AVCLASS
+ ret->av_class = &filtergraph_class;
+#endif
+ return ret;
}
void avfilter_graph_free(AVFilterGraph **graph)
@@ -261,6 +275,49 @@ static void pick_format(AVFilterLink *link)
}
}
+static int reduce_formats_on_filter(AVFilterContext *filter)
+{
+ int i, j, k, ret = 0;
+
+ for (i = 0; i < filter->input_count; i++) {
+ AVFilterLink *link = filter->inputs[i];
+ int format = link->out_formats->formats[0];
+
+ if (link->out_formats->format_count != 1)
+ continue;
+
+ for (j = 0; j < filter->output_count; j++) {
+ AVFilterLink *out_link = filter->outputs[j];
+ AVFilterFormats *fmts = out_link->in_formats;
+
+ if (link->type != out_link->type ||
+ out_link->in_formats->format_count == 1)
+ continue;
+
+ for (k = 0; k < out_link->in_formats->format_count; k++)
+ if (fmts->formats[k] == format) {
+ fmts->formats[0] = format;
+ fmts->format_count = 1;
+ ret = 1;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+static void reduce_formats(AVFilterGraph *graph)
+{
+ int i, reduced;
+
+ do {
+ reduced = 0;
+
+ for (i = 0; i < graph->filter_count; i++)
+ reduced |= reduce_formats_on_filter(graph->filters[i]);
+ } while (reduced);
+}
+
static void pick_formats(AVFilterGraph *graph)
{
int i, j;
@@ -284,7 +341,10 @@ int ff_avfilter_graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx)
return ret;
/* Once everything is merged, it's possible that we'll still have
- * multiple valid media format choices. We pick the first one. */
+ * multiple valid media format choices. We try to minimize the amount
+ * of format conversion inside filters */
+ reduce_formats(graph);
+
pick_formats(graph);
return 0;