gst-libs/gst/audio/multichannel.c: Allow non-standard 2 channel layouts.

Original commit message from CVS:
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions):
Allow non-standard 2 channel layouts.
* tests/check/elements/audioconvert.c: (GST_START_TEST):
Add some tests for converting and remapping non-standard 1 and 2
channel layouts.
This commit is contained in:
Sebastian Dröge 2008-05-21 07:39:56 +00:00
parent d47bd6d7bc
commit d03bbd1e3e
3 changed files with 245 additions and 0 deletions

View file

@ -1,3 +1,13 @@
2008-05-21 Sebastian Dröge <slomo@circular-chaos.org>
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions):
Allow non-standard 2 channel layouts.
* tests/check/elements/audioconvert.c: (GST_START_TEST):
Add some tests for converting and remapping non-standard 1 and 2
channel layouts.
2008-05-21 Sebastian Dröge <slomo@circular-chaos.org>
* gst/audioconvert/gstchannelmix.c:

View file

@ -135,12 +135,14 @@ gst_audio_check_channel_positions (const GstAudioChannelPosition * pos,
/* Throw warning if we encounter an unusual 2-channel configuration,
* at least until someone finds a reason why we should not */
#if 0
if (channels == 2 && (pos[0] != GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT ||
pos[1] != GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT)) {
g_warning ("channels=2 implies stereo, but channel positions are "
"< %d, %d>", pos[0], pos[1]);
return FALSE;
}
#endif
return TRUE;
}

View file

@ -827,6 +827,119 @@ GST_START_TEST (test_multichannel_conversion)
TRUE));
}
{
gint16 in[] = { 1, 2 };
gint16 out[] = { 1, 1, 2, 2 };
GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_MONO };
GstAudioChannelPosition out_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
};
set_channel_positions (in_caps, 1, in_layout);
set_channel_positions (out_caps, 2, out_layout);
RUN_CONVERSION ("1 channels to 2 with standard layout", in,
in_caps, out, out_caps);
}
{
gint16 in[] = { 1, 2 };
gint16 out[] = { 1, 0, 2, 0 };
GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT };
GstAudioChannelPosition out_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
};
set_channel_positions (in_caps, 1, in_layout);
set_channel_positions (out_caps, 2, out_layout);
RUN_CONVERSION ("1 channels to 2 with non-standard layout", in,
in_caps, out, out_caps);
}
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { 2, 4 };
GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
};
GstAudioChannelPosition out_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER };
set_channel_positions (in_caps, 2, in_layout);
set_channel_positions (out_caps, 1, out_layout);
RUN_CONVERSION ("2 channels to 1 with non-standard layout", in,
in_caps, out, out_caps);
}
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { 2, 4 };
GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
};
GstAudioChannelPosition out_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_MONO };
set_channel_positions (in_caps, 2, in_layout);
set_channel_positions (out_caps, 1, out_layout);
RUN_CONVERSION ("2 channels to 1 with standard layout", in,
in_caps, out, out_caps);
}
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { 2, 4 };
GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER
};
GstAudioChannelPosition out_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_MONO };
set_channel_positions (in_caps, 2, in_layout);
set_channel_positions (out_caps, 1, out_layout);
RUN_CONVERSION ("2 channels to 1 with non-standard layout", in,
in_caps, out, out_caps);
}
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { 1, 3 };
GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT
};
GstAudioChannelPosition out_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_MONO };
set_channel_positions (in_caps, 2, in_layout);
set_channel_positions (out_caps, 1, out_layout);
RUN_CONVERSION ("2 channels to 1 with non-standard layout", in,
in_caps, out, out_caps);
}
}
GST_END_TEST;
@ -923,6 +1036,126 @@ GST_START_TEST (test_channel_remapping)
RUN_CONVERSION ("3 channels layout remapping float32 --> int16", in,
in_caps, out, out_caps);
}
/* gint16 to gint16 with 2 channels and non-standard layout */
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { -1, 2, -2, 4 };
GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
GST_AUDIO_CHANNEL_POSITION_LFE
};
GstAudioChannelPosition out_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
};
set_channel_positions (in_caps, 2, in_layout);
set_channel_positions (out_caps, 2, out_layout);
RUN_CONVERSION ("2 channels layout remapping int16 --> int16", in,
in_caps, out, out_caps);
}
/* gint16 to gint16 with 2 channels and non-standard layout */
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { 2, 1, 4, 3 };
GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT
};
GstAudioChannelPosition out_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
};
set_channel_positions (in_caps, 2, in_layout);
set_channel_positions (out_caps, 2, out_layout);
RUN_CONVERSION ("2 channels layout remapping int16 --> int16", in,
in_caps, out, out_caps);
}
/* gint16 to gint16 with 2 channels and non-standard layout */
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { -1, 2, -3, 4 };
GstCaps *in_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (2, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER
};
GstAudioChannelPosition out_layout[2] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
};
set_channel_positions (in_caps, 2, in_layout);
set_channel_positions (out_caps, 2, out_layout);
RUN_CONVERSION ("2 channels layout remapping int16 --> int16", in,
in_caps, out, out_caps);
}
/* gint16 to gint16 with 1 channel and non-standard layout */
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { 0, 0, 0, 0 };
GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT };
GstAudioChannelPosition out_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT };
set_channel_positions (in_caps, 1, in_layout);
set_channel_positions (out_caps, 1, out_layout);
RUN_CONVERSION ("1 channels layout remapping int16 --> int16", in,
in_caps, out, out_caps);
}
/* gint16 to gint16 with 1 channel and non-standard layout */
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { 1, 2, 3, 4 };
GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_MONO };
GstAudioChannelPosition out_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER };
set_channel_positions (in_caps, 1, in_layout);
set_channel_positions (out_caps, 1, out_layout);
RUN_CONVERSION ("1 channels layout remapping int16 --> int16", in,
in_caps, out, out_caps);
}
/* gint16 to gint16 with 1 channel and non-standard layout */
{
gint16 in[] = { 1, 2, 3, 4 };
gint16 out[] = { -1, -2, -3, -4 };
GstCaps *in_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstCaps *out_caps = get_int_mc_caps (1, "BYTE_ORDER", 16, 16, TRUE, FALSE);
GstAudioChannelPosition in_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_FRONT_MONO };
GstAudioChannelPosition out_layout[1] =
{ GST_AUDIO_CHANNEL_POSITION_REAR_LEFT };
set_channel_positions (in_caps, 1, in_layout);
set_channel_positions (out_caps, 1, out_layout);
RUN_CONVERSION ("1 channels layout remapping int16 --> int16", in,
in_caps, out, out_caps);
}
}
GST_END_TEST;