[FFmpeg-cvslog] avfiltergraph: avoid harmful auto audio conversions.

Nicolas George git at videolan.org
Thu Feb 23 10:00:11 CET 2012


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Thu Feb 16 16:49:43 2012 +0100| [42655b24c2eab7e06fc56c59c21a50abe2aaf019] | committer: Nicolas George

avfiltergraph: avoid harmful auto audio conversions.

With the current code, an automatically inserted aconvert necessary
for format change would usually convert to mono for no good reason.

The new code will not avoid all conversions, but at least will keep
them among the layouts common to both filters.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42655b24c2eab7e06fc56c59c21a50abe2aaf019
---

 libavfilter/avfiltergraph.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index c97e495..50ba8fb 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -187,6 +187,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
 {
     int i, j, ret;
     char filt_args[128];
+    AVFilterFormats *formats, *chlayouts, *packing;
 
     /* ask all the sub-filters for their supported media formats */
     for (i = 0; i < graph->filter_count; i++) {
@@ -221,9 +222,13 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
                     !link->in_packing   || !link->out_packing)
                     return AVERROR(EINVAL);
 
-                if (!avfilter_merge_formats(link->in_formats,   link->out_formats)   ||
-                    !avfilter_merge_formats(link->in_chlayouts, link->out_chlayouts) ||
-                    !avfilter_merge_formats(link->in_packing,   link->out_packing))
+                /* Merge all three list before checking: that way, in all
+                 * three categories, aconvert will use a common format
+                 * whenever possible. */
+                formats   = avfilter_merge_formats(link->in_formats,   link->out_formats);
+                chlayouts = avfilter_merge_formats(link->in_chlayouts, link->out_chlayouts);
+                packing   = avfilter_merge_formats(link->in_packing,   link->out_packing);
+                if (!formats || !chlayouts || !packing)
                     if (ret = insert_conv_filter(graph, link, "aconvert", NULL))
                        return ret;
             }



More information about the ffmpeg-cvslog mailing list