Skip to content
Snippets Groups Projects
Commit f9023ba2 authored by Thomas Vander Stichele's avatar Thomas Vander Stichele
Browse files

added helper function to calculate maximum possible sample value based on caps

Original commit message from CVS:
added helper function to calculate maximum possible sample value based
on caps
parent d3b914ad
No related branches found
No related tags found
No related merge requests found
......@@ -119,3 +119,24 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
}
return length;
}
long
gst_audio_highest_sample_value (GstPad* pad)
/* calculate highest possible sample value
* based on capabilities of pad
*/
{
gboolean is_signed = FALSE;
gint width = 0;
GstCaps *caps = NULL;
caps = GST_PAD_CAPS (pad);
// FIXME : Please change this to a better warning method !
if (caps == NULL)
printf ("WARNING: gstaudio: could not get caps of pad !\n");
width = gst_caps_get_int (caps, "width");
is_signed = gst_caps_get_boolean (caps, "signed");
if (is_signed) --width;
/* example : 16 bit, signed : samples between -32768 and 32767 */
return ((long) (1 << width));
}
......@@ -37,3 +37,6 @@ long gst_audio_frame_rate (GstPad *pad);
/* calculate length in seconds of audio buffer buf based on caps of pad */
double gst_audio_length (GstPad* pad, GstBuffer* buf);
/* calculate highest possible sample value based on capabilities of pad */
long gst_audio_highest_sample_value (GstPad* pad);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment