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>
29 * GstAudioConvertDithering:
30 * @DITHER_NONE: No dithering
31 * @DITHER_RPDF: Rectangular dithering
32 * @DITHER_TPDF: Triangular dithering (default)
33 * @DITHER_TPDF_HF: High frequency triangular dithering
35 * Set of available dithering methods when converting audio.
43 } GstAudioConvertDithering;
46 * GstAudioConvertNoiseShaping:
47 * @NOISE_SHAPING_NONE: No noise shaping (default)
48 * @NOISE_SHAPING_ERROR_FEEDBACK: Error feedback
49 * @NOISE_SHAPING_SIMPLE: Simple 2-pole noise shaping
50 * @NOISE_SHAPING_MEDIUM: Medium 5-pole noise shaping
51 * @NOISE_SHAPING_HIGH: High 8-pole noise shaping
53 * Set of available noise shaping methods
57 NOISE_SHAPING_NONE = 0,
58 NOISE_SHAPING_ERROR_FEEDBACK,
62 } GstAudioConvertNoiseShaping;
64 typedef struct _AudioConvertCtx AudioConvertCtx;
65 typedef struct _AudioConvertFmt AudioConvertFmt;
67 struct _AudioConvertFmt
75 GstAudioChannelPosition *pos;
76 gboolean unpositioned_layout;
85 typedef void (*AudioConvertUnpack) (gpointer src, gpointer dst, gint scale,
87 typedef void (*AudioConvertPack) (gpointer src, gpointer dst, gint scale,
90 typedef void (*AudioConvertMix) (AudioConvertCtx *, gpointer, gpointer, gint);
91 typedef void (*AudioConvertQuantize) (AudioConvertCtx * ctx, gpointer src,
92 gpointer dst, gint count);
94 struct _AudioConvertCtx
99 AudioConvertUnpack unpack;
100 AudioConvertPack pack;
102 /* channel conversion matrix, m[in_channels][out_channels].
103 * If identity matrix, passthrough applies. */
105 /* temp storage for channelmix */
109 gboolean mix_passthrough;
110 gboolean out_default;
118 AudioConvertMix channel_mix;
120 AudioConvertQuantize quantize;
122 GstAudioConvertDithering dither;
123 GstAudioConvertNoiseShaping ns;
124 /* random number generate for dither noise */
125 GRand *dither_random;
126 /* last random number generated per channel for hifreq TPDF dither */
127 gpointer last_random;
128 /* contains the past quantization errors, error[out_channels][count] */
132 gboolean audio_convert_clean_fmt (AudioConvertFmt * fmt);
134 gboolean audio_convert_prepare_context (AudioConvertCtx * ctx,
135 AudioConvertFmt * in, AudioConvertFmt * out,
136 GstAudioConvertDithering dither, GstAudioConvertNoiseShaping ns);
137 gboolean audio_convert_get_sizes (AudioConvertCtx * ctx, gint samples,
138 gint * srcsize, gint * dstsize);
140 gboolean audio_convert_clean_context (AudioConvertCtx * ctx);
142 gboolean audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
143 gpointer dst, gint samples, gboolean src_writable);
145 #endif /* __AUDIO_CONVERT_H__ */