From: Sebastian Dröge Date: Sat, 24 Dec 2011 09:37:28 +0000 (+0100) Subject: audio: Add public functions to check channel positions validity and to get a reorder map X-Git-Tag: RELEASE-0.11.2~204 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9c12372a571439f8a86a1fd3f06fc534351a194;p=platform%2Fupstream%2Fgst-plugins-base.git audio: Add public functions to check channel positions validity and to get a reorder map --- diff --git a/gst-libs/gst/audio/audio.c b/gst-libs/gst/audio/audio.c index 90b1967..ac7c793 100644 --- a/gst-libs/gst/audio/audio.c +++ b/gst-libs/gst/audio/audio.c @@ -943,42 +943,28 @@ gst_audio_buffer_reorder_channels (GstBuffer * buffer, } gboolean -gst_audio_reorder_channels (gpointer data, gsize size, GstAudioFormat format, - gint channels, const GstAudioChannelPosition * from, - const GstAudioChannelPosition * to) +gst_audio_check_valid_channel_positions (const GstAudioChannelPosition * + position, gint channels, gboolean force_order) { - const GstAudioFormatInfo *info; - gint i, j, n; - gint reorder_map[64] = { 0, }; - guint8 *ptr; - gint bpf, bps; - guint8 tmp[64 * 8]; + return check_valid_channel_positions (position, channels, force_order, NULL); +} - info = gst_audio_format_get_info (format); +gboolean +gst_audio_get_channel_reorder_map (gint channels, + const GstAudioChannelPosition * from, const GstAudioChannelPosition * to, + gint * reorder_map) +{ + gint i, j; - g_return_val_if_fail (data != NULL, FALSE); - g_return_val_if_fail (from != NULL, FALSE); - g_return_val_if_fail (info != NULL && info->width > 0, FALSE); - g_return_val_if_fail (info->width > 0, FALSE); - g_return_val_if_fail (info->width <= 8 * 64, FALSE); - g_return_val_if_fail (size % ((info->width * channels) / 8) != 0, FALSE); + g_return_val_if_fail (reorder_map != NULL, FALSE); g_return_val_if_fail (channels > 0, FALSE); - g_return_val_if_fail (channels <= 64, FALSE); + g_return_val_if_fail (from != NULL, FALSE); g_return_val_if_fail (to != NULL, FALSE); g_return_val_if_fail (check_valid_channel_positions (from, channels, FALSE, NULL), FALSE); g_return_val_if_fail (check_valid_channel_positions (to, channels, FALSE, NULL), FALSE); - if (size == 0) - return TRUE; - - if (memcmp (from, to, channels * sizeof (from[0])) == 0) - return TRUE; - - bps = info->width / 8; - bpf = bps * channels; - /* Build reorder map and check compatibility */ for (i = 0; i < channels; i++) { if (from[i] == GST_AUDIO_CHANNEL_POSITION_NONE @@ -1003,6 +989,44 @@ gst_audio_reorder_channels (gpointer data, gsize size, GstAudioFormat format, return FALSE; } + return TRUE; +} + +gboolean +gst_audio_reorder_channels (gpointer data, gsize size, GstAudioFormat format, + gint channels, const GstAudioChannelPosition * from, + const GstAudioChannelPosition * to) +{ + const GstAudioFormatInfo *info; + gint i, j, n; + gint reorder_map[64] = { 0, }; + guint8 *ptr; + gint bpf, bps; + guint8 tmp[64 * 8]; + + info = gst_audio_format_get_info (format); + + g_return_val_if_fail (data != NULL, FALSE); + g_return_val_if_fail (from != NULL, FALSE); + g_return_val_if_fail (to != NULL, FALSE); + g_return_val_if_fail (info != NULL && info->width > 0, FALSE); + g_return_val_if_fail (info->width > 0, FALSE); + g_return_val_if_fail (info->width <= 8 * 64, FALSE); + g_return_val_if_fail (size % ((info->width * channels) / 8) != 0, FALSE); + g_return_val_if_fail (channels > 0, FALSE); + g_return_val_if_fail (channels <= 64, FALSE); + + if (size == 0) + return TRUE; + + if (memcmp (from, to, channels * sizeof (from[0])) == 0) + return TRUE; + + if (!gst_audio_get_channel_reorder_map (channels, from, to, reorder_map)) + return FALSE; + + bps = info->width / 8; + bpf = bps * channels; ptr = data; n = size / bpf; diff --git a/gst-libs/gst/audio/audio.h b/gst-libs/gst/audio/audio.h index 721e09a..c806818 100644 --- a/gst-libs/gst/audio/audio.h +++ b/gst-libs/gst/audio/audio.h @@ -532,6 +532,14 @@ gboolean gst_audio_reorder_channels (gpointer data, gsize size, const GstAudioChannelPosition * from, const GstAudioChannelPosition * to); +gboolean gst_audio_check_valid_channel_positions (const GstAudioChannelPosition *position, + gint channels, gboolean force_order); + +gboolean gst_audio_get_channel_reorder_map (gint channels, + const GstAudioChannelPosition * from, + const GstAudioChannelPosition * to, + gint *reorder_map); + G_END_DECLS #endif /* __GST_AUDIO_AUDIO_H__ */