af_resample: avoid conversion of identical sample formats for 1 channel
authorJustin Ruggles <justin.ruggles@gmail.com>
Thu, 20 Sep 2012 17:28:34 +0000 (13:28 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Sun, 7 Oct 2012 20:45:50 +0000 (16:45 -0400)
When there is only 1 channel, the planar and interleaved formats of the same
data type should be treated as identical.

libavfilter/af_resample.c

index c51f9d2..58a9b2a 100644 (file)
@@ -93,7 +93,11 @@ static int config_output(AVFilterLink *outlink)
 
     if (inlink->channel_layout == outlink->channel_layout &&
         inlink->sample_rate    == outlink->sample_rate    &&
 
     if (inlink->channel_layout == outlink->channel_layout &&
         inlink->sample_rate    == outlink->sample_rate    &&
-        inlink->format         == outlink->format)
+        (inlink->format        == outlink->format ||
+        (av_get_channel_layout_nb_channels(inlink->channel_layout)  == 1 &&
+         av_get_channel_layout_nb_channels(outlink->channel_layout) == 1 &&
+         av_get_planar_sample_fmt(inlink->format) ==
+         av_get_planar_sample_fmt(outlink->format))))
         return 0;
 
     if (!(s->avr = avresample_alloc_context()))
         return 0;
 
     if (!(s->avr = avresample_alloc_context()))
@@ -226,6 +230,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
 fail:
         avfilter_unref_buffer(buf);
     } else {
 fail:
         avfilter_unref_buffer(buf);
     } else {
+        buf->format = outlink->format;
         ret = ff_filter_samples(outlink, buf);
         s->got_output = 1;
     }
         ret = ff_filter_samples(outlink, buf);
         s->got_output = 1;
     }