mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 23:58:17 +00:00
codec-utils: add a gst_codec_utils_aac_get_index_from_sample_rate
It maps a sample rate to a well known AAC sample rate index.
This commit is contained in:
parent
047abdc944
commit
ee088c6b3f
4 changed files with 29 additions and 4 deletions
|
@ -1994,6 +1994,7 @@ gst_pb_utils_get_codec_description
|
|||
<INCLUDE>gst/pbutils/codec-utils.h</INCLUDE>
|
||||
<SUBSECTION>
|
||||
gst_codec_utils_aac_get_sample_rate_from_index
|
||||
gst_codec_utils_aac_get_index_from_sample_rate
|
||||
gst_codec_utils_aac_get_profile
|
||||
gst_codec_utils_aac_get_level
|
||||
gst_codec_utils_aac_caps_set_level_and_profile
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
#define GST_SIMPLE_CAPS_HAS_FIELD(caps,field) \
|
||||
gst_structure_has_field(gst_caps_get_structure((caps),0),(field))
|
||||
|
||||
static const guint aac_sample_rates[] = { 96000, 88200, 64000, 48000, 44100,
|
||||
32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350
|
||||
};
|
||||
|
||||
static const gchar *
|
||||
digit_to_string (guint digit)
|
||||
{
|
||||
|
@ -71,10 +75,6 @@ digit_to_string (guint digit)
|
|||
guint
|
||||
gst_codec_utils_aac_get_sample_rate_from_index (guint sr_idx)
|
||||
{
|
||||
static const guint aac_sample_rates[] = { 96000, 88200, 64000, 48000, 44100,
|
||||
32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350
|
||||
};
|
||||
|
||||
if (G_LIKELY (sr_idx < G_N_ELEMENTS (aac_sample_rates)))
|
||||
return aac_sample_rates[sr_idx];
|
||||
|
||||
|
@ -82,6 +82,28 @@ gst_codec_utils_aac_get_sample_rate_from_index (guint sr_idx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_codec_utils_aac_get_index_from_sample_rate:
|
||||
* @rate: Sample rate
|
||||
*
|
||||
* Translates the sample rate to the index corresponding to it in AAC spec.
|
||||
*
|
||||
* Returns: The AAC index for this sample rate, -1 if the rate is not a
|
||||
* valid AAC sample rate.
|
||||
*/
|
||||
gint
|
||||
gst_codec_utils_aac_get_index_from_sample_rate (guint rate)
|
||||
{
|
||||
guint n;
|
||||
|
||||
for (n = 0; n < G_N_ELEMENTS (aac_sample_rates); n++)
|
||||
if (aac_sample_rates[n] == rate)
|
||||
return n;
|
||||
|
||||
GST_WARNING ("Invalid sample rate %u", rate);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_codec_utils_aac_get_profile:
|
||||
* @audio_config: a pointer to the AudioSpecificConfig as specified in the
|
||||
|
|
|
@ -29,6 +29,7 @@ G_BEGIN_DECLS
|
|||
/* AAC */
|
||||
|
||||
guint gst_codec_utils_aac_get_sample_rate_from_index (guint sr_idx);
|
||||
gint gst_codec_utils_aac_get_index_from_sample_rate (guint rate);
|
||||
|
||||
const gchar * gst_codec_utils_aac_get_profile (const guint8 * audio_config, guint len);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ EXPORTS
|
|||
gst_codec_utils_aac_get_level
|
||||
gst_codec_utils_aac_get_profile
|
||||
gst_codec_utils_aac_get_sample_rate_from_index
|
||||
gst_codec_utils_aac_get_index_from_sample_rate
|
||||
gst_codec_utils_h264_caps_set_level_and_profile
|
||||
gst_codec_utils_h264_get_level
|
||||
gst_codec_utils_h264_get_level_idc
|
||||
|
|
Loading…
Reference in a new issue