Commit d217d811 authored by George Kiagiadakis's avatar George Kiagiadakis

tests: audio: test gst_audio_buffer_reorder_channels() also with non-interleaved buffers

parent 34efe479
......@@ -847,6 +847,7 @@ typedef struct
gint channels;
GstAudioChannelPosition from[32], to[32];
gint32 in[32], out[32];
gint32 plane_offsets[32];
gboolean fail;
} MultichannelReorderData;
......@@ -858,12 +859,14 @@ GST_START_TEST (test_multichannel_reorder)
{GST_AUDIO_CHANNEL_POSITION_MONO},
{0, 1, 2, 3},
{0, 1, 2, 3},
{0},
FALSE},
{1,
{GST_AUDIO_CHANNEL_POSITION_MONO},
{GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER},
{0, 1, 2, 3},
{0, 1, 2, 3},
{0},
TRUE},
{2,
{GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
......@@ -872,6 +875,7 @@ GST_START_TEST (test_multichannel_reorder)
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT},
{0, 1, 2, 3},
{0, 1, 2, 3},
{0, 1},
FALSE},
{2,
{GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
......@@ -880,6 +884,7 @@ GST_START_TEST (test_multichannel_reorder)
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT},
{0, 1, 2, 3},
{1, 0, 3, 2},
{1, 0},
FALSE},
{4,
{GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
......@@ -892,6 +897,7 @@ GST_START_TEST (test_multichannel_reorder)
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER},
{0, 1, 2, 3},
{1, 2, 0, 3},
{1, 2, 0, 3},
FALSE},
{4,
{GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
......@@ -904,6 +910,7 @@ GST_START_TEST (test_multichannel_reorder)
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER},
{0, 1, 2, 3},
{3, 0, 1, 2},
{3, 0, 1, 2},
FALSE},
{4,
{GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
......@@ -916,11 +923,13 @@ GST_START_TEST (test_multichannel_reorder)
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT},
{0, 1, 2, 3},
{3, 2, 1, 0},
{3, 2, 1, 0},
FALSE},
};
gint i;
gint i, j;
GstBuffer *buf;
GstMapInfo map;
GstAudioMapInfo amap;
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
buf =
......@@ -931,6 +940,8 @@ GST_START_TEST (test_multichannel_reorder)
fail_if (gst_audio_buffer_reorder_channels (buf, GST_AUDIO_FORMAT_S32,
tests[i].channels, tests[i].from, tests[i].to));
} else {
/* first interpret as interleaved */
fail_unless (gst_audio_buffer_reorder_channels (buf, GST_AUDIO_FORMAT_S32,
tests[i].channels, tests[i].from, tests[i].to));
......@@ -938,6 +949,24 @@ GST_START_TEST (test_multichannel_reorder)
fail_unless_equals_int (map.size, sizeof (tests[i].in));
fail_unless (memcmp (tests[i].out, map.data, map.size) == 0);
gst_buffer_unmap (buf, &map);
/* now interpret as planar */
gst_buffer_add_audio_meta (buf, GST_AUDIO_FORMAT_S32,
GST_AUDIO_LAYOUT_NON_INTERLEAVED, tests[i].channels,
sizeof (tests[i].in) / (tests[i].channels * sizeof (gint32)), NULL);
fail_unless (gst_audio_buffer_reorder_channels (buf, GST_AUDIO_FORMAT_S32,
tests[i].channels, tests[i].from, tests[i].to));
fail_unless (gst_audio_buffer_map (buf, &amap, GST_MAP_READ));
fail_unless_equals_int (amap.n_planes, tests[i].channels);
fail_unless_equals_int (amap.plane_size,
sizeof (tests[i].in) / tests[i].channels);
for (j = 0; j < amap.n_planes; j++) {
fail_unless_equals_pointer (amap.planes[j],
amap.map_info.data + tests[i].plane_offsets[j] * amap.plane_size);
}
}
gst_buffer_unref (buf);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment