mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-23 17:14:23 +00:00
audio-converter: add a convenience conversion method
This is useful from python bindings https://bugzilla.gnome.org/show_bug.cgi?id=793492
This commit is contained in:
parent
6a4a82f355
commit
9cf4293bde
3 changed files with 42 additions and 0 deletions
|
@ -658,6 +658,7 @@ GstAudioConverterFlags
|
||||||
gst_audio_converter_new
|
gst_audio_converter_new
|
||||||
gst_audio_converter_free
|
gst_audio_converter_free
|
||||||
gst_audio_converter_samples
|
gst_audio_converter_samples
|
||||||
|
gst_audio_converter_convert
|
||||||
gst_audio_converter_get_in_frames
|
gst_audio_converter_get_in_frames
|
||||||
gst_audio_converter_get_max_latency
|
gst_audio_converter_get_max_latency
|
||||||
gst_audio_converter_get_out_frames
|
gst_audio_converter_get_out_frames
|
||||||
|
|
|
@ -1447,6 +1447,41 @@ gst_audio_converter_samples (GstAudioConverter * convert,
|
||||||
return convert->convert (convert, flags, in, in_frames, out, out_frames);
|
return convert->convert (convert, flags, in, in_frames, out, out_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_audio_converter_convert:
|
||||||
|
* @flags: extra #GstAudioConverterFlags
|
||||||
|
* @in: (array length=in_size) (element-type guint8): input data
|
||||||
|
* @in_size: size of @in
|
||||||
|
* @out: (out) (array length=out_size) (element-type guint8): a pointer where
|
||||||
|
* the output data will be written
|
||||||
|
* @out_size: (out): a pointer where the size of @out will be written
|
||||||
|
*
|
||||||
|
* Convenience wrapper around gst_audio_converter_samples(), which will
|
||||||
|
* perform allocation of the output buffer based on the result from
|
||||||
|
* gst_audio_converter_get_out_frames().
|
||||||
|
*
|
||||||
|
* Returns: %TRUE is the conversion could be performed.
|
||||||
|
*
|
||||||
|
* Since: 1.14
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_audio_converter_convert (GstAudioConverter * convert,
|
||||||
|
GstAudioConverterFlags flags, gpointer in, gsize in_size,
|
||||||
|
gpointer * out, gsize * out_size)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (convert != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (flags ^ GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE, FALSE);
|
||||||
|
|
||||||
|
gsize in_frames = in_size / convert->in.bpf;
|
||||||
|
gsize out_frames = gst_audio_converter_get_out_frames (convert, in_frames);
|
||||||
|
|
||||||
|
*out_size = out_frames * convert->out.bpf;
|
||||||
|
*out = g_malloc0 (*out_size);
|
||||||
|
|
||||||
|
return gst_audio_converter_samples (convert, flags, &in, in_frames, out,
|
||||||
|
out_frames);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_audio_converter_supports_inplace:
|
* gst_audio_converter_supports_inplace:
|
||||||
* @convert: a #GstAudioConverter
|
* @convert: a #GstAudioConverter
|
||||||
|
|
|
@ -159,6 +159,12 @@ gboolean gst_audio_converter_samples (GstAudioConverter * co
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
gboolean gst_audio_converter_supports_inplace (GstAudioConverter *convert);
|
gboolean gst_audio_converter_supports_inplace (GstAudioConverter *convert);
|
||||||
|
|
||||||
|
GST_EXPORT
|
||||||
|
gboolean gst_audio_converter_convert (GstAudioConverter * convert,
|
||||||
|
GstAudioConverterFlags flags,
|
||||||
|
gpointer in, gsize in_size,
|
||||||
|
gpointer *out, gsize *out_size);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_AUDIO_CONVERTER_H__ */
|
#endif /* __GST_AUDIO_CONVERTER_H__ */
|
||||||
|
|
Loading…
Reference in a new issue