mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
audioconvert: cleanups and add some docs
Add docs for the internal audioconvert object before moving it to the audio library. Remove get_sizes and implement the trivial logic in the element. Remove some unused orc functions
This commit is contained in:
parent
4ae24dcb25
commit
1635bc0a45
5 changed files with 65 additions and 58 deletions
|
@ -1,7 +1,8 @@
|
||||||
/* GStreamer
|
/* GStreamer
|
||||||
* Copyright (C) 2005 Wim Taymans <wim at fluendo dot com>
|
* Copyright (C) 2005 Wim Taymans <wim at fluendo dot com>
|
||||||
|
* (C) 2015 Wim Taymans <wim.taymans@gmail.com>
|
||||||
*
|
*
|
||||||
* audioconvert.c: Convert audio to different audio formats automatically
|
* audioconverter.c: Convert audio to different audio formats automatically
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -30,6 +31,28 @@
|
||||||
#include "audioconvert.h"
|
#include "audioconvert.h"
|
||||||
#include "gstaudioconvertorc.h"
|
#include "gstaudioconvertorc.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:audioconverter
|
||||||
|
* @short_description: Generic audio conversion
|
||||||
|
*
|
||||||
|
* <refsect2>
|
||||||
|
* <para>
|
||||||
|
* This object is used to convert audio samples from one format to another.
|
||||||
|
* The object can perform conversion of:
|
||||||
|
* <itemizedlist>
|
||||||
|
* <listitem><para>
|
||||||
|
* audio format with optional dithering and noise shaping
|
||||||
|
* </para></listitem>
|
||||||
|
* <listitem><para>
|
||||||
|
* audio samplerate
|
||||||
|
* </para></listitem>
|
||||||
|
* <listitem><para>
|
||||||
|
* audio channels and channel layout
|
||||||
|
* </para></listitem>
|
||||||
|
* </para>
|
||||||
|
* </refsect2>
|
||||||
|
*/
|
||||||
|
|
||||||
typedef void (*AudioConvertFunc) (gpointer dst, const gpointer src, gint count);
|
typedef void (*AudioConvertFunc) (gpointer dst, const gpointer src, gint count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,9 +183,19 @@ gst_audio_converter_get_config (GstAudioConverter * convert)
|
||||||
return convert->config;
|
return convert->config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* gst_audio_converter_new: (skip)
|
||||||
|
* @in: a source #GstAudioInfo
|
||||||
|
* @out: a destination #GstAudioInfo
|
||||||
|
* @config: (transfer full): a #GstStructure with configuration options
|
||||||
*
|
*
|
||||||
|
* Create a new #GstAudioConverter that is able to convert between @in and @out
|
||||||
|
* audio formats.
|
||||||
|
*
|
||||||
|
* @config contains extra configuration options, see #GST_VIDEO_CONVERTER_OPT_*
|
||||||
|
* parameters for details about the options and values.
|
||||||
|
*
|
||||||
|
* Returns: a #GstAudioConverter or %NULL if conversion is not possible.
|
||||||
*/
|
*/
|
||||||
GstAudioConverter *
|
GstAudioConverter *
|
||||||
gst_audio_converter_new (GstAudioInfo * in, GstAudioInfo * out,
|
gst_audio_converter_new (GstAudioInfo * in, GstAudioInfo * out,
|
||||||
|
@ -289,6 +322,12 @@ unpositioned:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_audio_converter_free:
|
||||||
|
* @convert: a #GstAudioConverter
|
||||||
|
*
|
||||||
|
* Free a previously allocated @convert instance.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
gst_audio_converter_free (GstAudioConverter * convert)
|
gst_audio_converter_free (GstAudioConverter * convert)
|
||||||
{
|
{
|
||||||
|
@ -308,20 +347,18 @@ gst_audio_converter_free (GstAudioConverter * convert)
|
||||||
g_slice_free (GstAudioConverter, convert);
|
g_slice_free (GstAudioConverter, convert);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
/**
|
||||||
gst_audio_converter_get_sizes (GstAudioConverter * convert, gint samples,
|
* gst_audio_converter_samples:
|
||||||
gint * srcsize, gint * dstsize)
|
* @convert: a #GstAudioConverter
|
||||||
{
|
* @flags: extra #GstAudioConverterFlags
|
||||||
g_return_val_if_fail (convert != NULL, FALSE);
|
* @src: source samples
|
||||||
|
* @dst: output samples
|
||||||
if (srcsize)
|
* @samples: number of samples
|
||||||
*srcsize = samples * convert->in.bpf;
|
*
|
||||||
if (dstsize)
|
* Perform the conversion @src to @dst using @convert.
|
||||||
*dstsize = samples * convert->out.bpf;
|
*
|
||||||
|
* Returns: %TRUE is the conversion could be performed.
|
||||||
return TRUE;
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_audio_converter_samples (GstAudioConverter * convert,
|
gst_audio_converter_samples (GstAudioConverter * convert,
|
||||||
GstAudioConverterFlags flags, gpointer src, gpointer dst, gint samples)
|
GstAudioConverterFlags flags, gpointer src, gpointer dst, gint samples)
|
||||||
|
|
|
@ -80,10 +80,6 @@ gboolean gst_audio_converter_set_config (GstAudioConverter * con
|
||||||
const GstStructure * gst_audio_converter_get_config (GstAudioConverter * convert);
|
const GstStructure * gst_audio_converter_get_config (GstAudioConverter * convert);
|
||||||
|
|
||||||
|
|
||||||
gboolean gst_audio_converter_get_sizes (GstAudioConverter * convert,
|
|
||||||
gint samples,
|
|
||||||
gint * srcsize, gint * dstsize);
|
|
||||||
|
|
||||||
gboolean gst_audio_converter_samples (GstAudioConverter * convert,
|
gboolean gst_audio_converter_samples (GstAudioConverter * convert,
|
||||||
GstAudioConverterFlags flags,
|
GstAudioConverterFlags flags,
|
||||||
gpointer src, gpointer dst,
|
gpointer src, gpointer dst,
|
||||||
|
|
|
@ -198,6 +198,7 @@ gst_audio_convert_dispose (GObject * obj)
|
||||||
{
|
{
|
||||||
GstAudioConvert *this = GST_AUDIO_CONVERT (obj);
|
GstAudioConvert *this = GST_AUDIO_CONVERT (obj);
|
||||||
|
|
||||||
|
if (this->convert)
|
||||||
gst_audio_converter_free (this->convert);
|
gst_audio_converter_free (this->convert);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
||||||
|
@ -708,9 +709,8 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
|
|
||||||
/* get in/output sizes, to see if the buffers we got are of correct
|
/* get in/output sizes, to see if the buffers we got are of correct
|
||||||
* sizes */
|
* sizes */
|
||||||
if (!gst_audio_converter_get_sizes (this->convert, samples, &insize,
|
insize = samples * this->in_info.bpf;
|
||||||
&outsize))
|
outsize = samples * this->out_info.bpf;
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (insize == 0 || outsize == 0)
|
if (insize == 0 || outsize == 0)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
@ -752,12 +752,6 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
error:
|
|
||||||
{
|
|
||||||
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
|
|
||||||
(NULL), ("cannot get input/output sizes for %d samples", samples));
|
|
||||||
return GST_FLOW_ERROR;
|
|
||||||
}
|
|
||||||
wrong_size:
|
wrong_size:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
|
||||||
|
|
|
@ -13,24 +13,3 @@ divd d1, t1, 2147483648.0L
|
||||||
|
|
||||||
muld t1, s1, 2147483648.0L
|
muld t1, s1, 2147483648.0L
|
||||||
convdl d1, t1
|
convdl d1, t1
|
||||||
|
|
||||||
.function audio_convert_orc_int_bias
|
|
||||||
.dest 4 d1 gint32
|
|
||||||
.source 4 s1 gint32
|
|
||||||
.param 4 bias gint32
|
|
||||||
.param 4 mask gint32
|
|
||||||
.temp 4 t1
|
|
||||||
|
|
||||||
addssl t1, s1, bias
|
|
||||||
andl d1, t1, mask
|
|
||||||
|
|
||||||
.function audio_convert_orc_int_dither
|
|
||||||
.dest 4 d1 gint32
|
|
||||||
.source 4 s1 gint32
|
|
||||||
.source 4 dither gint32
|
|
||||||
.param 4 mask gint32
|
|
||||||
.temp 4 t1
|
|
||||||
|
|
||||||
addssl t1, s1, dither
|
|
||||||
andl d1, t1, mask
|
|
||||||
|
|
||||||
|
|
|
@ -818,14 +818,15 @@ gst_channel_mix_mix_double (GstChannelMix * mix,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_channel_mix_mix:
|
* gst_channel_mix_mix:
|
||||||
* @mix:
|
* @mix: a #GstChannelMix
|
||||||
* @format:
|
* @format: a #GstAudioFormat
|
||||||
* @layout:
|
* @layout: a #GstAudioLayout
|
||||||
* @in_data:
|
* @in_data: input samples
|
||||||
* @out_data:
|
* @out_data: output samples
|
||||||
* @samples:
|
* @samples: number of samples
|
||||||
*
|
*
|
||||||
* Perform channel mixing
|
* Perform channel mixing on @in_data and write the result to @out_data.
|
||||||
|
* @in_data and @out_data need to be in @format and @layout.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_channel_mix_mix (GstChannelMix * mix, GstAudioFormat format,
|
gst_channel_mix_mix (GstChannelMix * mix, GstAudioFormat format,
|
||||||
|
|
Loading…
Reference in a new issue