Add some documentation comments, and some new headers to be scanned.
[platform/upstream/gstreamer.git] / gst / audioconvert / audioconvert.h
1 /* GStreamer
2  * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  *
4  * audioconvert.h: audio format conversion library
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #ifndef __AUDIO_CONVERT_H__
23 #define __AUDIO_CONVERT_H__
24
25 #include <gst/gst.h>
26 #include <gst/audio/multichannel.h>
27
28 /**
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
34  *
35  * Set of available dithering methods when converting audio.
36  */
37 typedef enum
38 {
39   DITHER_NONE = 0,
40   DITHER_RPDF,
41   DITHER_TPDF,
42   DITHER_TPDF_HF
43 } GstAudioConvertDithering;
44
45 /**
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
52  *
53  * Set of available noise shaping methods
54  */
55 typedef enum
56 {
57   NOISE_SHAPING_NONE = 0,
58   NOISE_SHAPING_ERROR_FEEDBACK,
59   NOISE_SHAPING_SIMPLE,
60   NOISE_SHAPING_MEDIUM,
61   NOISE_SHAPING_HIGH
62 } GstAudioConvertNoiseShaping;
63
64 typedef struct _AudioConvertCtx AudioConvertCtx;
65 typedef struct _AudioConvertFmt AudioConvertFmt;
66
67 struct _AudioConvertFmt
68 {
69   /* general caps */
70   gboolean is_int;
71   gint endianness;
72   gint width;
73   gint rate;
74   gint channels;
75   GstAudioChannelPosition *pos;
76   gboolean unpositioned_layout;
77
78   /* int audio caps */
79   gboolean sign;
80   gint depth;
81
82   gint unit_size;
83 };
84
85 typedef void (*AudioConvertUnpack) (gpointer src, gpointer dst, gint scale,
86     gint count);
87 typedef void (*AudioConvertPack) (gpointer src, gpointer dst, gint scale,
88     gint count);
89
90 typedef void (*AudioConvertMix) (AudioConvertCtx *, gpointer, gpointer, gint);
91 typedef void (*AudioConvertQuantize) (AudioConvertCtx * ctx, gpointer src,
92     gpointer dst, gint count);
93
94 struct _AudioConvertCtx
95 {
96   AudioConvertFmt in;
97   AudioConvertFmt out;
98
99   AudioConvertUnpack unpack;
100   AudioConvertPack pack;
101
102   /* channel conversion matrix, m[in_channels][out_channels].
103    * If identity matrix, passthrough applies. */
104   gfloat **matrix;
105   /* temp storage for channelmix */
106   gpointer tmp;
107
108   gboolean in_default;
109   gboolean mix_passthrough;
110   gboolean out_default;
111
112   gpointer tmpbuf;
113   gint tmpbufsize;
114
115   gint in_scale;
116   gint out_scale;
117
118   AudioConvertMix channel_mix;
119
120   AudioConvertQuantize quantize;
121
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] */
129   gdouble *error_buf;
130 };
131
132 gboolean audio_convert_clean_fmt (AudioConvertFmt * fmt);
133
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);
139
140 gboolean audio_convert_clean_context (AudioConvertCtx * ctx);
141
142 gboolean audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
143     gpointer dst, gint samples, gboolean src_writable);
144
145 #endif /* __AUDIO_CONVERT_H__ */