2 * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * audioconvert.h: audio format conversion library
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifndef __AUDIO_CONVERT_H__
23 #define __AUDIO_CONVERT_H__
26 #include <gst/audio/multichannel.h>
38 NOISE_SHAPING_NONE = 0,
39 NOISE_SHAPING_ERROR_FEEDBACK,
45 typedef struct _AudioConvertCtx AudioConvertCtx;
46 typedef struct _AudioConvertFmt AudioConvertFmt;
48 struct _AudioConvertFmt
56 GstAudioChannelPosition *pos;
65 typedef void (*AudioConvertUnpack) (gpointer src, gpointer dst, gint scale,
67 typedef void (*AudioConvertPack) (gpointer src, gpointer dst, gint scale,
70 typedef void (*AudioConvertMix) (AudioConvertCtx *, gpointer, gpointer, gint);
71 typedef void (*AudioConvertQuantize) (AudioConvertCtx * ctx, gpointer src,
72 gpointer dst, gint count);
74 struct _AudioConvertCtx
79 AudioConvertUnpack unpack;
80 AudioConvertPack pack;
82 /* channel conversion matrix, m[in_channels][out_channels].
83 * If identity matrix, passthrough applies. */
85 /* temp storage for channelmix */
89 gboolean mix_passthrough;
98 AudioConvertMix channel_mix;
100 AudioConvertQuantize quantize;
103 /* random number generate for dither noise */
104 GRand *dither_random;
105 /* last random number generated per channel for hifreq TPDF dither */
106 gpointer last_random;
107 /* contains the past quantization errors, error[out_channels][count] */
111 gboolean audio_convert_clean_fmt (AudioConvertFmt * fmt);
113 gboolean audio_convert_prepare_context (AudioConvertCtx * ctx,
114 AudioConvertFmt * in, AudioConvertFmt * out, DitherType dither,
115 NoiseShapingType ns);
116 gboolean audio_convert_get_sizes (AudioConvertCtx * ctx, gint samples,
117 gint * srcsize, gint * dstsize);
119 gboolean audio_convert_clean_context (AudioConvertCtx * ctx);
121 gboolean audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
122 gpointer dst, gint samples, gboolean src_writable);
124 #endif /* __AUDIO_CONVERT_H__ */