[FFmpeg-devel] [PATCH 2/2] avfilter: Dont partially merge lists

Michael Niedermayer michaelni at gmx.at
Mon Jul 22 02:56:16 CEST 2013


This prevents the unneeded insertion of multiple aresample filters in some cases

The format merging is moved to avoid having to call the channel layout
merge twice (which currently does not work as dry run mode with ff_merge_channel_layouts()
does not work

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavfilter/avfiltergraph.c |   31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 3c1b7c3..641bc11 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -404,20 +404,34 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
             if (!link)
                 continue;
 
+            if (link->in_formats != link->out_formats
+                && link->in_formats && link->out_formats)
+                if (!ff_merge_formats(link->in_formats, link->out_formats,
+                                      link->type, 1))
+                    convert_needed = 1;
+            if (link->type == AVMEDIA_TYPE_AUDIO) {
+//                 if (link->in_channel_layouts != link->out_channel_layouts
+//                     && link->in_channel_layouts && link->out_channel_layouts)
+//                     if (!ff_merge_channel_layouts(link->in_channel_layouts, link->out_channel_layouts,
+//                                         1))
+//                         convert_needed = 1;
+
+                if (link->in_samplerates != link->out_samplerates
+                    && link->in_samplerates && link->out_samplerates)
+                    if (!ff_merge_samplerates(link->in_samplerates, link->out_samplerates,
+                                        1))
+                        convert_needed = 1;
+            }
+
 #define MERGE_DISPATCH(field, statement)                                     \
             if (!(link->in_ ## field && link->out_ ## field)) {              \
                 count_delayed++;                                             \
             } else if (link->in_ ## field == link->out_ ## field) {          \
                 count_already_merged++;                                      \
-            } else {                                                         \
+            } else if (!convert_needed) {                                                         \
                 count_merged++;                                              \
                 statement                                                    \
             }
-            MERGE_DISPATCH(formats,
-                if (!ff_merge_formats(link->in_formats, link->out_formats,
-                                      link->type, 0))
-                    convert_needed = 1;
-            )
             if (link->type == AVMEDIA_TYPE_AUDIO) {
                 MERGE_DISPATCH(channel_layouts,
                     if (!ff_merge_channel_layouts(link->in_channel_layouts,
@@ -430,6 +444,11 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
                         convert_needed = 1;
                 )
             }
+            MERGE_DISPATCH(formats,
+                if (!ff_merge_formats(link->in_formats, link->out_formats,
+                                      link->type, 0))
+                    convert_needed = 1;
+            )
 #undef MERGE_DISPATCH
 
             if (convert_needed) {
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list