Index: gst/audioconvert/audioconvert.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst/audioconvert/audioconvert.h,v
retrieving revision 1.5
diff -u -p -r1.5 audioconvert.h
--- gst/audioconvert/audioconvert.h	6 Dec 2005 19:41:56 -0000	1.5
+++ gst/audioconvert/audioconvert.h	23 Jan 2007 12:54:42 -0000
@@ -37,6 +37,7 @@ struct _AudioConvertFmt
   gint rate;
   gint channels;
   GstAudioChannelPosition *pos;
+  gboolean unpositioned_layout;
 
   /* int audio caps */
   gboolean sign;
Index: gst/audioconvert/audioconvert.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst/audioconvert/audioconvert.c,v
retrieving revision 1.12
diff -u -p -r1.12 audioconvert.c
--- gst/audioconvert/audioconvert.c	10 Oct 2006 12:49:01 -0000	1.12
+++ gst/audioconvert/audioconvert.c	23 Jan 2007 12:54:42 -0000
@@ -233,6 +233,8 @@ audio_convert_prepare_context (AudioConv
   ctx->in = *in;
   ctx->out = *out;
 
+  g_assert (in->unpositioned_layout == out->unpositioned_layout);
+
   gst_channel_mix_setup_matrix (ctx);
 
   idx = audio_convert_get_func_index (in);
Index: gst/audioconvert/gstaudioconvert.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst/audioconvert/gstaudioconvert.c,v
retrieving revision 1.106
diff -u -p -r1.106 gstaudioconvert.c
--- gst/audioconvert/gstaudioconvert.c	23 Sep 2006 15:24:54 -0000	1.106
+++ gst/audioconvert/gstaudioconvert.c	23 Jan 2007 12:54:44 -0000
@@ -96,6 +96,8 @@ static GstFlowReturn gst_audio_convert_t
     GstBuffer * inbuf, GstBuffer * outbuf);
 static GstFlowReturn gst_audio_convert_transform_ip (GstBaseTransform * base,
     GstBuffer * buf);
+static gboolean structure_has_fixed_channel_positions (GstStructure * s,
+    gboolean * unpositioned_layout);
 
 /* AudioConvert signals and args */
 enum
@@ -122,32 +124,32 @@ GST_BOILERPLATE_FULL (GstAudioConvert, g
 GST_STATIC_CAPS ( \
   "audio/x-raw-float, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) BYTE_ORDER, " \
     "width = (int) 32;" \
   "audio/x-raw-int, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
     "width = (int) 32, " \
     "depth = (int) [ 1, 32 ], " \
     "signed = (boolean) { true, false }; " \
   "audio/x-raw-int, "   \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], "       \
+    "channels = (int) [ 1, MAX ], "       \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, "        \
     "width = (int) 24, "        \
     "depth = (int) [ 1, 24 ], " "signed = (boolean) { true, false }; "  \
   "audio/x-raw-int, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
     "width = (int) 16, " \
     "depth = (int) [ 1, 16 ], " \
     "signed = (boolean) { true, false }; " \
   "audio/x-raw-int, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
     "width = (int) 8, " \
     "depth = (int) [ 1, 8 ], " \
@@ -251,6 +253,10 @@ gst_audio_convert_parse_caps (const GstC
     goto no_values;
   if (!(fmt->pos = gst_audio_get_channel_positions (structure)))
     goto no_values;
+
+  fmt->unpositioned_layout = FALSE;
+  structure_has_fixed_channel_positions (structure, &fmt->unpositioned_layout);
+
   if (!gst_structure_get_int (structure, "width", &fmt->width))
     goto no_values;
   if (!gst_structure_get_int (structure, "rate", &fmt->rate))
@@ -405,6 +411,42 @@ set_structure_widths (GstStructure * s, 
   g_value_unset (&list);
 }
 
+static gboolean
+structure_has_fixed_channel_positions (GstStructure * s,
+    gboolean * unpositioned_layout)
+{
+  GstAudioChannelPosition *pos;
+  const GValue *val;
+  gint channels = 0;
+
+  if (!gst_structure_get_int (s, "channels", &channels))
+    return FALSE; /* probably a range */
+
+  if (channels > 8) {
+    GST_LOG ("%d channels, undefined channel positions are implicit", channels);
+    *unpositioned_layout = TRUE;
+    return TRUE;
+  }
+
+  val = gst_structure_get_value (s, "channel-positions");
+  if (val == NULL || !gst_value_is_fixed (val)) {
+    GST_LOG ("no or unfixed channel-positions in %" GST_PTR_FORMAT, s);
+    return FALSE;
+  }
+
+  pos = gst_audio_get_channel_positions (s);
+  if ((pos && pos[0] == GST_AUDIO_CHANNEL_POSITION_NONE) || channels > 8) {
+    GST_LOG ("fixed undefined channel-positions in %" GST_PTR_FORMAT, s);
+    *unpositioned_layout = TRUE;
+  } else {
+    GST_LOG ("fixed defined channel-positions in %" GST_PTR_FORMAT, s);
+    *unpositioned_layout = FALSE;
+  }
+  g_free (pos);
+
+  return TRUE;
+}
+
 /* Audioconvert can perform all conversions on audio except for resampling. 
  * However, there are some conversions we _prefer_ not to do. For example, it's
  * better to convert format (float<->int, endianness, etc) than the number of
@@ -422,8 +464,8 @@ gst_audio_convert_transform_caps (GstBas
 {
   GstCaps *ret;
   GstStructure *s, *structure;
-  gboolean isfloat;
-  gint width, depth, channels;
+  gboolean isfloat, allow_mixing;
+  gint width, depth, channels = 0;
   const gchar *fields_used[] = {
     "width", "depth", "rate", "channels", "endianness", "signed"
   };
@@ -479,11 +521,18 @@ gst_audio_convert_transform_caps (GstBas
     }
   }
 
+  allow_mixing = TRUE;
   if (gst_structure_get_int (structure, "channels", &channels)) {
-    if (channels == 8)
-      gst_structure_set (s, "channels", G_TYPE_INT, 8, NULL);
-    else
-      gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, channels, 8, NULL);
+    gboolean unpositioned;
+
+    /* we don't support mixing for channels without channel positions */
+    if (structure_has_fixed_channel_positions (s, &unpositioned))
+      allow_mixing = (unpositioned == FALSE);
+  }
+  if (!allow_mixing || channels == 8) {
+    gst_structure_set (s, "channels", G_TYPE_INT, channels, NULL);
+  } else {
+    gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, channels, 8, NULL);
   }
   gst_caps_append_structure (ret, s);
 
@@ -518,7 +567,12 @@ gst_audio_convert_transform_caps (GstBas
    * it's very bad to drop channels entirely.
    */
   s = gst_structure_copy (s);
-  gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, 1, 8, NULL);
+  if (allow_mixing) {
+    gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, 1, 8, NULL);
+  } else {
+    /* allow_mixing can only be FALSE if we got a fixed number of channels */
+    gst_structure_set (s, "channels", G_TYPE_INT, channels, NULL);
+  }
   gst_caps_append_structure (ret, s);
 
   /* Same, plus a float<->int conversion */
Index: gst/audioconvert/gstchannelmix.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst/audioconvert/gstchannelmix.c,v
retrieving revision 1.14
diff -u -p -r1.14 gstchannelmix.c
--- gst/audioconvert/gstchannelmix.c	18 Jan 2007 16:23:35 -0000	1.14
+++ gst/audioconvert/gstchannelmix.c	23 Jan 2007 12:54:44 -0000
@@ -464,9 +464,12 @@ static void
 gst_channel_mix_fill_matrix (AudioConvertCtx * this)
 {
   gst_channel_mix_fill_identical (this);
-  gst_channel_mix_fill_compatible (this);
-  gst_channel_mix_fill_others (this);
-  gst_channel_mix_fill_normalize (this);
+
+  if (!this->in.unpositioned_layout) {
+    gst_channel_mix_fill_compatible (this);
+    gst_channel_mix_fill_others (this);
+    gst_channel_mix_fill_normalize (this);
+  }
 }
 
 /* only call after this->out and this->in are filled in */
Index: tests/check/elements/audioconvert.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/tests/check/elements/audioconvert.c,v
retrieving revision 1.20
diff -u -p -r1.20 audioconvert.c
--- tests/check/elements/audioconvert.c	21 Aug 2006 11:42:12 -0000	1.20
+++ tests/check/elements/audioconvert.c	23 Jan 2007 12:54:44 -0000
@@ -3,6 +3,7 @@
  * unit test for audioconvert
  *
  * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
+ * Copyright (C) <2007> Tim-Philipp Müller <tim centricular net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -35,33 +36,33 @@ GstPad *mysrcpad, *mysinkpad;
 #define CONVERT_CAPS_TEMPLATE_STRING    \
   "audio/x-raw-float, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) BYTE_ORDER, " \
     "width = (int) 32;" \
   "audio/x-raw-int, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
     "width = (int) 32, " \
     "depth = (int) [ 1, 32 ], " \
     "signed = (boolean) { true, false }; " \
   "audio/x-raw-int, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
     "width = (int) 24, " \
     "depth = (int) [ 1, 24 ], " \
     "signed = (boolean) { true, false }; " \
   "audio/x-raw-int, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
     "width = (int) 16, " \
     "depth = (int) [ 1, 16 ], " \
     "signed = (boolean) { true, false }; " \
   "audio/x-raw-int, " \
     "rate = (int) [ 1, MAX ], " \
-    "channels = (int) [ 1, 8 ], " \
+    "channels = (int) [ 1, MAX ], " \
     "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
     "width = (int) 8, " \
     "depth = (int) [ 1, 8 ], " \
@@ -228,6 +229,74 @@ static GstAudioChannelPosition mixed_up_
       }
 };
 
+/* we get this when recording from a soundcard with lots of input channels */
+static GstAudioChannelPosition undefined_positions[][9] = {
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      },
+  {
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE,
+        GST_AUDIO_CHANNEL_POSITION_NONE
+      }
+
+};
+
 static void
 set_channel_positions (GstCaps * caps, int channels,
     GstAudioChannelPosition * channelpositions)
@@ -314,7 +383,7 @@ verify_convert (const gchar * which, voi
 
   /* pushing gives away my reference ... */
   GST_DEBUG ("push it");
-  fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+  fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK);
   GST_DEBUG ("pushed it");
   /* ... and puts a new buffer on the global list */
   fail_unless (g_list_length (buffers) == 1);
@@ -487,6 +556,28 @@ GST_START_TEST (test_multichannel_conver
 
 GST_END_TEST;
 
+/* for testing channel remapping with 8 channels */
+static GstAudioChannelPosition n8chan_pos_remap_in[8] = {
+        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
+        GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
+        GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
+        GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
+        GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
+        GST_AUDIO_CHANNEL_POSITION_LFE,
+        GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
+        GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT
+   };
+static GstAudioChannelPosition n8chan_pos_remap_out[8] = {
+        GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, 
+        GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
+        GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
+        GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
+        GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
+        GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
+        GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
+        GST_AUDIO_CHANNEL_POSITION_LFE
+  };
+
 GST_START_TEST (test_channel_remapping)
 {
   /* float */
@@ -511,6 +602,20 @@ GST_START_TEST (test_channel_remapping)
         out, out_caps);
   }
 
+  /* int with 8 channels (= largest number allowed with channel positions) */
+  {
+    guint16 in[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+    guint16 out[] = { 4, 0, 1, 6, 7, 2, 3, 5 };
+    GstCaps *in_caps = get_int_mc_caps (8, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (8, "BYTE_ORDER", 16, 16, FALSE, TRUE);
+
+    set_channel_positions (in_caps, 8, n8chan_pos_remap_in);
+    set_channel_positions (out_caps, 8, n8chan_pos_remap_out);
+
+    RUN_CONVERSION ("8 channels layout remapping int", in, in_caps,
+        out, out_caps);
+  }
+
   /* TODO: float => int conversion with remapping and vice versa,
    *       int   => int conversion with remapping */
 }
@@ -583,8 +688,194 @@ GST_START_TEST (test_caps_negotiation)
 
 GST_END_TEST;
 
+GST_START_TEST (test_convert_undefined_multichannel)
+{
+  /* (A) CONVERSION FROM 'WORSE' TO 'BETTER' FORMAT */
+
+  /* 1 channel, NONE positions, int8 => int16 */
+  {
+    guint16 out[] = { 0x2000 };
+    guint8 in[] = { 0x20 };
+    GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 1, undefined_positions[1 - 1]);
+    set_channel_positions (in_caps, 1, undefined_positions[1 - 1]);
+
+    RUN_CONVERSION ("1 channel, undefined layout, identity conversion, "
+        "int8 => int16", in, in_caps, out, out_caps);
+  }
 
-Suite *
+  /* 2 channels, NONE positions, int8 => int16 */
+  {
+    guint16 out[] = { 0x8000, 0x2000 };
+    guint8 in[] = { 0x80, 0x20 };
+    GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 2, undefined_positions[2 - 1]);
+    set_channel_positions (in_caps, 2, undefined_positions[2 - 1]);
+
+    RUN_CONVERSION ("2 channels, undefined layout, identity conversion, "
+        "int8 => int16", in, in_caps, out, out_caps);
+  }
+
+  /* 6 channels, NONE positions, int8 => int16 */
+  {
+    guint16 out[] = { 0x0000, 0x2000, 0x8000, 0x2000, 0x0000, 0xff00 };
+    guint8 in[] = { 0x00, 0x20, 0x80, 0x20, 0x00, 0xff };
+    GstCaps *out_caps = get_int_mc_caps (6, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *in_caps = get_int_mc_caps (6, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 6, undefined_positions[6 - 1]);
+    set_channel_positions (in_caps, 6, undefined_positions[6 - 1]);
+
+    RUN_CONVERSION ("6 channels, undefined layout, identity conversion, "
+        "int8 => int16", in, in_caps, out, out_caps);
+  }
+
+  /* 9 channels, NONE positions, int8 => int16 */
+  {
+    guint16 out[] = { 0x0000, 0xff00, 0x0000, 0x2000, 0x8000, 0x2000,
+        0x0000, 0xff00, 0x0000 };
+    guint8 in[] = { 0x00, 0xff, 0x00, 0x20, 0x80, 0x20, 0x00, 0xff, 0x00 };
+    GstCaps *out_caps = get_int_mc_caps (9, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *in_caps = get_int_mc_caps (9, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 9, undefined_positions[9 - 1]);
+    set_channel_positions (in_caps, 9, undefined_positions[9 - 1]);
+
+    RUN_CONVERSION ("9 channels, undefined layout, identity conversion, "
+        "int8 => int16", in, in_caps, out, out_caps);
+  }
+
+  /* (B) CONVERSION FROM 'BETTER' TO 'WORSE' FORMAT */
+
+  /* 1 channel, NONE positions, int16 => int8 */
+  {
+    guint16 in[] = { 0x2000 };
+    guint8 out[] = { 0x20 };
+    GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 1, undefined_positions[1 - 1]);
+    set_channel_positions (in_caps, 1, undefined_positions[1 - 1]);
+
+    RUN_CONVERSION ("1 channel, undefined layout, identity conversion, "
+        "int16 => int8", in, in_caps, out, out_caps);
+  }
+
+  /* 2 channels, NONE positions, int16 => int8 */
+  {
+    guint16 in[] = { 0x8000, 0x2000 };
+    guint8 out[] = { 0x80, 0x20 };
+    GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 2, undefined_positions[2 - 1]);
+    set_channel_positions (in_caps, 2, undefined_positions[2 - 1]);
+
+    RUN_CONVERSION ("2 channels, undefined layout, identity conversion, "
+        "int16 => int8", in, in_caps, out, out_caps);
+  }
+
+  /* 6 channels, NONE positions, int16 => int8 */
+  {
+    guint16 in[] = { 0x0000, 0x2000, 0x8000, 0x2000, 0x0000, 0xff00 };
+    guint8 out[] = { 0x00, 0x20, 0x80, 0x20, 0x00, 0xff };
+    GstCaps *in_caps = get_int_mc_caps (6, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (6, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 6, undefined_positions[6 - 1]);
+    set_channel_positions (in_caps, 6, undefined_positions[6 - 1]);
+
+    RUN_CONVERSION ("6 channels, undefined layout, identity conversion, "
+        "int16 => int8", in, in_caps, out, out_caps);
+  }
+
+  /* 9 channels, NONE positions, int16 => int8 */
+  {
+    guint16 in[] = { 0x0000, 0xff00, 0x0000, 0x2000, 0x8000, 0x2000,
+        0x0000, 0xff00, 0x0000 };
+    guint8 out[] = { 0x00, 0xff, 0x00, 0x20, 0x80, 0x20, 0x00, 0xff, 0x00 };
+    GstCaps *in_caps = get_int_mc_caps (9, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (9, "BYTE_ORDER", 8, 8, FALSE, FALSE);
+    set_channel_positions (out_caps, 9, undefined_positions[9 - 1]);
+    set_channel_positions (in_caps, 9, undefined_positions[9 - 1]);
+
+    RUN_CONVERSION ("9 channels, undefined layout, identity conversion, "
+        "int16 => int8", in, in_caps, out, out_caps);
+  }
+
+  /* (C) NO CONVERSION, SAME FORMAT */
+
+  /* 1 channel, NONE positions, int16 => int16 */
+  {
+    guint16 in[] = { 0x2000 };
+    guint16 out[] = { 0x2000 };
+    GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    set_channel_positions (out_caps, 1, undefined_positions[1 - 1]);
+    set_channel_positions (in_caps, 1, undefined_positions[1 - 1]);
+
+    RUN_CONVERSION ("1 channel, undefined layout, identity conversion, "
+        "int16 => int16", in, in_caps, out, out_caps);
+  }
+
+  /* 2 channels, NONE positions, int16 => int16 */
+  {
+    guint16 in[] = { 0x8000, 0x2000 };
+    guint16 out[] = { 0x8000, 0x2000 };
+    GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    set_channel_positions (out_caps, 2, undefined_positions[2 - 1]);
+    set_channel_positions (in_caps, 2, undefined_positions[2 - 1]);
+
+    RUN_CONVERSION ("2 channels, undefined layout, identity conversion, "
+        "int16 => int16", in, in_caps, out, out_caps);
+  }
+
+  /* 6 channels, NONE positions, int16 => int16 */
+  {
+    guint16 in[] = { 0x0000, 0x2000, 0x8000, 0x2000, 0x0000, 0xff00 };
+    guint16 out[] = { 0x0000, 0x2000, 0x8000, 0x2000, 0x0000, 0xff00 };
+    GstCaps *in_caps = get_int_mc_caps (6, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (6, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    set_channel_positions (out_caps, 6, undefined_positions[6 - 1]);
+    set_channel_positions (in_caps, 6, undefined_positions[6 - 1]);
+
+    RUN_CONVERSION ("6 channels, undefined layout, identity conversion, "
+        "int16 => int16", in, in_caps, out, out_caps);
+  }
+
+  /* 9 channels, NONE positions, int16 => int16 */
+  {
+    guint16 in[] = { 0x0000, 0xff00, 0x0000, 0x2000, 0x8000, 0x2000,
+        0x0000, 0xff00, 0x0000 };
+    guint16 out[] = { 0x0000, 0xff00, 0x0000, 0x2000, 0x8000, 0x2000,
+        0x0000, 0xff00, 0x0000 };
+    GstCaps *in_caps = get_int_mc_caps (9, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_int_mc_caps (9, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    set_channel_positions (out_caps, 9, undefined_positions[9 - 1]);
+    set_channel_positions (in_caps, 9, undefined_positions[9 - 1]);
+
+    RUN_CONVERSION ("9 channels, undefined layout, identity conversion, "
+        "int16 => int16", in, in_caps, out, out_caps);
+  }
+
+  /* (C) int16 => float */
+
+  /* 9 channels, NONE positions, int16 => float */
+  {
+    guint16 in[] = { 0x0000, 0x8000, 0x0000, 0x8000, 0x8000, 0x8000,
+        0x0000, 0x8000, 0x0000 };
+    gfloat out[] = { -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, -1.0 };
+    GstCaps *in_caps = get_int_mc_caps (9, "BYTE_ORDER", 16, 16, FALSE, FALSE);
+    GstCaps *out_caps = get_float_mc_caps (9, "BYTE_ORDER", 32, FALSE);
+    set_channel_positions (out_caps, 9, undefined_positions[9 - 1]);
+    set_channel_positions (in_caps, 9, undefined_positions[9 - 1]);
+
+    RUN_CONVERSION ("9 channels, undefined layout, identity conversion, "
+        "int16 => float", in, in_caps, out, out_caps);
+  }
+}
+
+GST_END_TEST;
+
+static Suite *
 audioconvert_suite (void)
 {
   Suite *s = suite_create ("audioconvert");
@@ -597,23 +888,9 @@ audioconvert_suite (void)
   tcase_add_test (tc_chain, test_multichannel_conversion);
   tcase_add_test (tc_chain, test_channel_remapping);
   tcase_add_test (tc_chain, test_caps_negotiation);
+  tcase_add_test (tc_chain, test_convert_undefined_multichannel);
 
   return s;
 }
 
-int
-main (int argc, char **argv)
-{
-  int nf;
-
-  Suite *s = audioconvert_suite ();
-  SRunner *sr = srunner_create (s);
-
-  gst_check_init (&argc, &argv);
-
-  srunner_run_all (sr, CK_NORMAL);
-  nf = srunner_ntests_failed (sr);
-  srunner_free (sr);
-
-  return nf;
-}
+GST_CHECK_MAIN (audioconvert);
