mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-16 13:26:36 +00:00
gst/audioconvert/audioconvert.c: Cleanups.
Original commit message from CVS: * gst/audioconvert/audioconvert.c: (if), (float), (audio_convert_get_func_index), (check_default), (audio_convert_clean_fmt), (audio_convert_prepare_context), (audio_convert_clean_context), (audio_convert_get_sizes), (audio_convert_convert): Cleanups.
This commit is contained in:
parent
ddec57c089
commit
b6c368ce67
2 changed files with 58 additions and 58 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2005-08-26 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/audioconvert/audioconvert.c: (if), (float),
|
||||||
|
(audio_convert_get_func_index), (check_default),
|
||||||
|
(audio_convert_clean_fmt), (audio_convert_prepare_context),
|
||||||
|
(audio_convert_clean_context), (audio_convert_get_sizes),
|
||||||
|
(audio_convert_convert):
|
||||||
|
Cleanups.
|
||||||
|
|
||||||
2005-08-26 Wim Taymans <wim@fluendo.com>
|
2005-08-26 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/audioconvert/audioconvert.c: (if), (float),
|
* gst/audioconvert/audioconvert.c: (if), (float),
|
||||||
|
|
|
@ -61,27 +61,26 @@ MAKE_UNPACK_FUNC_NAME (name) (gpointer src, gint32 *dst, \
|
||||||
UNPACK_CODE(type, 0, E_FUNC); \
|
UNPACK_CODE(type, 0, E_FUNC); \
|
||||||
}
|
}
|
||||||
|
|
||||||
MAKE_UNPACK_FUNC_U (u8, guint8, /* nothing */ )
|
MAKE_UNPACK_FUNC_U (u8, guint8, /* nothing */ );
|
||||||
MAKE_UNPACK_FUNC_S (s8, gint8, /* nothing */ )
|
MAKE_UNPACK_FUNC_S (s8, gint8, /* nothing */ );
|
||||||
MAKE_UNPACK_FUNC_U (u16_le, guint16, GUINT16_FROM_LE)
|
MAKE_UNPACK_FUNC_U (u16_le, guint16, GUINT16_FROM_LE);
|
||||||
MAKE_UNPACK_FUNC_S (s16_le, gint16, GINT16_FROM_LE)
|
MAKE_UNPACK_FUNC_S (s16_le, gint16, GINT16_FROM_LE);
|
||||||
MAKE_UNPACK_FUNC_U (u16_be, guint16, GUINT16_FROM_BE)
|
MAKE_UNPACK_FUNC_U (u16_be, guint16, GUINT16_FROM_BE);
|
||||||
MAKE_UNPACK_FUNC_S (s16_be, gint16, GINT16_FROM_BE)
|
MAKE_UNPACK_FUNC_S (s16_be, gint16, GINT16_FROM_BE);
|
||||||
MAKE_UNPACK_FUNC_U (u32_le, guint32, GUINT32_FROM_LE)
|
MAKE_UNPACK_FUNC_U (u32_le, guint32, GUINT32_FROM_LE);
|
||||||
MAKE_UNPACK_FUNC_S (s32_le, gint32, GINT32_FROM_LE)
|
MAKE_UNPACK_FUNC_S (s32_le, gint32, GINT32_FROM_LE);
|
||||||
MAKE_UNPACK_FUNC_U (u32_be, guint32, GUINT32_FROM_BE)
|
MAKE_UNPACK_FUNC_U (u32_be, guint32, GUINT32_FROM_BE);
|
||||||
MAKE_UNPACK_FUNC_S (s32_be, gint32, GINT32_FROM_BE)
|
MAKE_UNPACK_FUNC_S (s32_be, gint32, GINT32_FROM_BE);
|
||||||
|
|
||||||
/* FIXME 24 bits */
|
/* FIXME 24 bits */
|
||||||
#if 0
|
#if 0
|
||||||
gint64 cur = 0;
|
gint64 cur = 0;
|
||||||
|
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
|
|
||||||
/* Read 24-bits LE/BE into signed 64 host-endian */
|
/* Read 24-bits LE/BE into signed 64 host-endian */
|
||||||
if (this->sinkcaps.endianness == G_LITTLE_ENDIAN)
|
if (this->sinkcaps.endianness == G_LITTLE_ENDIAN) {
|
||||||
{
|
cur = src[0] | (src[1] << 8) | (src[2] << 16);
|
||||||
cur = src[0] | (src[1] << 8) | (src[2] << 16);
|
|
||||||
} else {
|
} else {
|
||||||
cur = src[2] | (src[1] << 8) | (src[0] << 16);
|
cur = src[2] | (src[1] << 8) | (src[0] << 16);
|
||||||
}
|
}
|
||||||
|
@ -307,8 +306,8 @@ audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
||||||
gpointer dst, gint samples, gboolean src_writable)
|
gpointer dst, gint samples, gboolean src_writable)
|
||||||
{
|
{
|
||||||
gint insize, outsize;
|
gint insize, outsize;
|
||||||
gboolean final;
|
gpointer outbuf, tmpbuf;
|
||||||
gpointer inbuf, outbuf, tmpbuf;
|
gint biggest = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (ctx != NULL, FALSE);
|
g_return_val_if_fail (ctx != NULL, FALSE);
|
||||||
g_return_val_if_fail (src != NULL, FALSE);
|
g_return_val_if_fail (src != NULL, FALSE);
|
||||||
|
@ -322,62 +321,54 @@ audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
||||||
outsize = ctx->out.unit_size * samples;
|
outsize = ctx->out.unit_size * samples;
|
||||||
|
|
||||||
/* find biggest temp buffer size */
|
/* find biggest temp buffer size */
|
||||||
{
|
if (!ctx->in_default)
|
||||||
gint biggest = 0;
|
biggest = insize * 32 / ctx->in.width;
|
||||||
|
if (!ctx->mix_passthrough)
|
||||||
|
biggest = MAX (biggest, outsize * 32 / ctx->out.width);
|
||||||
|
|
||||||
if (!ctx->in_default)
|
/* see if one of the buffers can be used as temp */
|
||||||
biggest = insize * 32 / ctx->in.width;
|
if (outsize >= biggest)
|
||||||
|
tmpbuf = dst;
|
||||||
if (!ctx->mix_passthrough)
|
else if (insize >= biggest && src_writable)
|
||||||
biggest = MAX (biggest, outsize * 32 / ctx->out.width);
|
tmpbuf = src;
|
||||||
|
else {
|
||||||
/* see if one of the buffers can be used as temp */
|
if (biggest > ctx->tmpbufsize) {
|
||||||
if (insize >= biggest && src_writable)
|
ctx->tmpbuf = g_realloc (ctx->tmpbuf, biggest);
|
||||||
tmpbuf = src;
|
ctx->tmpbufsize = biggest;
|
||||||
else if (outsize >= biggest)
|
|
||||||
tmpbuf = dst;
|
|
||||||
else {
|
|
||||||
if (biggest > ctx->tmpbufsize) {
|
|
||||||
ctx->tmpbuf = g_realloc (ctx->tmpbuf, biggest);
|
|
||||||
ctx->tmpbufsize = biggest;
|
|
||||||
}
|
|
||||||
tmpbuf = ctx->tmpbuf;
|
|
||||||
}
|
}
|
||||||
|
tmpbuf = ctx->tmpbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is our source data, we start with the input src data. */
|
/* start conversion */
|
||||||
inbuf = src;
|
|
||||||
outbuf = dst;
|
|
||||||
|
|
||||||
if (!ctx->in_default) {
|
if (!ctx->in_default) {
|
||||||
/* check if final conversion */
|
/* check if final conversion */
|
||||||
final = (ctx->out_default && ctx->mix_passthrough);
|
if (!(ctx->out_default && ctx->mix_passthrough))
|
||||||
|
|
||||||
if (!final)
|
|
||||||
outbuf = tmpbuf;
|
|
||||||
|
|
||||||
ctx->unpack (inbuf, outbuf, ctx->scale, samples * ctx->in.channels);
|
|
||||||
|
|
||||||
inbuf = outbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ctx->mix_passthrough) {
|
|
||||||
/* see if we need an intermediate step */
|
|
||||||
final = ctx->out_default;
|
|
||||||
|
|
||||||
if (!final)
|
|
||||||
outbuf = tmpbuf;
|
outbuf = tmpbuf;
|
||||||
else
|
else
|
||||||
outbuf = dst;
|
outbuf = dst;
|
||||||
|
|
||||||
/* convert */
|
/* unpack to default format */
|
||||||
gst_channel_mix_mix (ctx, inbuf, outbuf, samples);
|
ctx->unpack (src, outbuf, ctx->scale, samples * ctx->in.channels);
|
||||||
|
|
||||||
inbuf = outbuf;
|
src = outbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ctx->mix_passthrough) {
|
||||||
|
/* check if final conversion */
|
||||||
|
if (!ctx->out_default)
|
||||||
|
outbuf = tmpbuf;
|
||||||
|
else
|
||||||
|
outbuf = dst;
|
||||||
|
|
||||||
|
/* convert channels */
|
||||||
|
gst_channel_mix_mix (ctx, src, outbuf, samples);
|
||||||
|
|
||||||
|
src = outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->out_default) {
|
if (!ctx->out_default) {
|
||||||
ctx->pack (inbuf, dst, ctx->depth, samples * ctx->out.channels);
|
/* pack default format into dst */
|
||||||
|
ctx->pack (src, dst, ctx->depth, samples * ctx->out.channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in a new issue