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,20 +321,16 @@ 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 */
|
||||||
{
|
|
||||||
gint biggest = 0;
|
|
||||||
|
|
||||||
if (!ctx->in_default)
|
if (!ctx->in_default)
|
||||||
biggest = insize * 32 / ctx->in.width;
|
biggest = insize * 32 / ctx->in.width;
|
||||||
|
|
||||||
if (!ctx->mix_passthrough)
|
if (!ctx->mix_passthrough)
|
||||||
biggest = MAX (biggest, outsize * 32 / ctx->out.width);
|
biggest = MAX (biggest, outsize * 32 / ctx->out.width);
|
||||||
|
|
||||||
/* see if one of the buffers can be used as temp */
|
/* see if one of the buffers can be used as temp */
|
||||||
if (insize >= biggest && src_writable)
|
if (outsize >= biggest)
|
||||||
tmpbuf = src;
|
|
||||||
else if (outsize >= biggest)
|
|
||||||
tmpbuf = dst;
|
tmpbuf = dst;
|
||||||
|
else if (insize >= biggest && src_writable)
|
||||||
|
tmpbuf = src;
|
||||||
else {
|
else {
|
||||||
if (biggest > ctx->tmpbufsize) {
|
if (biggest > ctx->tmpbufsize) {
|
||||||
ctx->tmpbuf = g_realloc (ctx->tmpbuf, biggest);
|
ctx->tmpbuf = g_realloc (ctx->tmpbuf, biggest);
|
||||||
|
@ -343,41 +338,37 @@ audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
||||||
}
|
}
|
||||||
tmpbuf = ctx->tmpbuf;
|
tmpbuf = ctx->tmpbuf;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* this is our source data, we start with the input src data. */
|
|
||||||
inbuf = src;
|
|
||||||
outbuf = dst;
|
|
||||||
|
|
||||||
|
/* start conversion */
|
||||||
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