audioconvert: simplify fixate_format function some more
authorTim-Philipp Müller <tim@centricular.net>
Fri, 23 Aug 2013 18:41:32 +0000 (19:41 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Fri, 23 Aug 2013 18:43:14 +0000 (19:43 +0100)
If we have no output format yet, any format will do. The
!out_info condition existed in every path, so just split
it our for clarity. KISS.

gst/audioconvert/gstaudioconvert.c

index 4f5f406..06b6566 100644 (file)
@@ -499,15 +499,23 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins,
 
     t_depth = GST_AUDIO_FORMAT_INFO_DEPTH (t_info);
 
-    if (t_depth == in_depth && (!out_info || out_depth != in_depth
-            || (t_flags == in_flags && out_flags != in_flags))) {
+    /* Any output format is better than no output format at all */
+    if (!out_info) {
+      out_info = t_info;
+      out_depth = t_depth;
+      out_flags = t_flags;
+      continue;
+    }
+
+    if (t_depth == in_depth && (out_depth != in_depth || (t_flags == in_flags
+                && out_flags != in_flags))) {
       /* Prefer to use the first format that has the same depth with the same
        * flags, and if none with the same flags exist use the first other one
        * that has the same depth */
       out_info = t_info;
       out_depth = t_depth;
       out_flags = t_flags;
-    } else if (t_depth >= in_depth && (!out_info || in_depth > out_depth
+    } else if (t_depth >= in_depth && (in_depth > out_depth
             || (out_depth >= in_depth && t_flags == in_flags
                 && out_flags != in_flags))) {
       /* Otherwise use the first format that has a higher depth with the same flags,
@@ -516,7 +524,7 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins,
       out_info = t_info;
       out_depth = t_depth;
       out_flags = t_flags;
-    } else if (!out_info || (t_depth > out_depth && out_depth < in_depth)
+    } else if ((t_depth > out_depth && out_depth < in_depth)
         || (t_flags == in_flags && out_flags != in_flags
             && out_depth == t_depth)) {
       /* Else get at least the one with the highest depth, ideally with the same flags */