mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +00:00
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
This commit is contained in:
parent
d3b914ad91
commit
f9023ba24e
2 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue