mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
audio: add function to build audio format
This commit is contained in:
parent
b657f5bce7
commit
7db6fa37b4
2 changed files with 52 additions and 6 deletions
|
@ -101,6 +101,48 @@ static GstAudioFormatInfo formats[] = {
|
|||
SILENT_0)
|
||||
};
|
||||
|
||||
/**
|
||||
* gst_audio_format_build_int:
|
||||
* @sign: signed or unsigned format
|
||||
* @endianness: G_LITTLE_ENDIAN or G_BIG_ENDIAN
|
||||
* @width: amount of bits used per sample
|
||||
* @depth: amount of used bits in @width
|
||||
*
|
||||
* Construct a #GstAudioFormat with given parameters.
|
||||
*
|
||||
* Returns: a #GstAudioFormat or GST_AUDIO_FORMAT_UNKNOWN when no audio format
|
||||
* exists with the given parameters.
|
||||
*/
|
||||
GstAudioFormat
|
||||
gst_audio_format_build_int (gboolean sign, gint endianness,
|
||||
gint width, gint depth)
|
||||
{
|
||||
gint i, e;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
|
||||
GstAudioFormatInfo *finfo = &formats[i];
|
||||
|
||||
/* must be int */
|
||||
if (!GST_AUDIO_FORMAT_INFO_IS_INT (finfo))
|
||||
continue;
|
||||
/* width and depth must match */
|
||||
if (width != GST_AUDIO_FORMAT_INFO_WIDTH (finfo))
|
||||
continue;
|
||||
if (depth != GST_AUDIO_FORMAT_INFO_DEPTH (finfo))
|
||||
continue;
|
||||
/* if there is endianness, it must match */
|
||||
e = GST_AUDIO_FORMAT_INFO_ENDIANNESS (finfo);
|
||||
if (e && e != endianness)
|
||||
continue;
|
||||
/* check sign */
|
||||
if (sign && !GST_AUDIO_FORMAT_INFO_IS_SIGNED (finfo))
|
||||
continue;
|
||||
|
||||
return GST_AUDIO_FORMAT_INFO_FORMAT (finfo);
|
||||
}
|
||||
return GST_AUDIO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_audio_format_from_string:
|
||||
* @format: a format string
|
||||
|
|
|
@ -227,6 +227,10 @@ struct _GstAudioFormatInfo {
|
|||
#define GST_AUDIO_FORMAT_INFO_WIDTH(info) ((info)->width)
|
||||
#define GST_AUDIO_FORMAT_INFO_DEPTH(info) ((info)->depth)
|
||||
|
||||
|
||||
GstAudioFormat gst_audio_format_build_int (gboolean sign, gint endianness,
|
||||
gint width, gint depth) G_GNUC_CONST;
|
||||
|
||||
GstAudioFormat gst_audio_format_from_string (const gchar *format) G_GNUC_CONST;
|
||||
const gchar * gst_audio_format_to_string (GstAudioFormat format) G_GNUC_CONST;
|
||||
const GstAudioFormatInfo *
|
||||
|
|
Loading…
Reference in a new issue