#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)
{
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];
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
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