Add float as an intermediate format, as well as float mixing. Enable test that was...
[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 typedef struct _AudioConvertCtx AudioConvertCtx;
29 typedef struct _AudioConvertFmt AudioConvertFmt;
30
31 struct _AudioConvertFmt
32 {
33   /* general caps */
34   gboolean is_int;
35   gint endianness;
36   gint width;
37   gint rate;
38   gint channels;
39   GstAudioChannelPosition *pos;
40
41   /* int audio caps */
42   gboolean sign;
43   gint depth;
44
45   gint unit_size;
46 };
47
48 typedef void (*AudioConvertUnpack) (gpointer src, gpointer dst, gint scale, gint count);
49 typedef void (*AudioConvertPack) (gpointer src, gpointer dst, gint scale, gint count);
50
51 typedef void (*AudioConvertMix) (AudioConvertCtx *, gpointer, gpointer, gint);
52
53 struct _AudioConvertCtx
54 {
55   AudioConvertFmt in;
56   AudioConvertFmt out;
57
58   AudioConvertUnpack unpack;
59   AudioConvertPack pack;
60
61   /* channel conversion matrix, m[in_channels][out_channels].
62    * If identity matrix, passthrough applies. */
63   gfloat **matrix;
64   /* temp storage for channelmix */
65   gpointer tmp;
66
67   gboolean in_default;
68   gboolean mix_passthrough;
69   gboolean out_default;
70
71   gpointer tmpbuf;
72   gint tmpbufsize;
73
74   gint in_scale;
75   gint out_scale;
76   
77   AudioConvertMix channel_mix;
78 };
79
80 gboolean        audio_convert_clean_fmt         (AudioConvertFmt *fmt); 
81
82 gboolean        audio_convert_prepare_context   (AudioConvertCtx *ctx, AudioConvertFmt *in, 
83                                                  AudioConvertFmt *out);
84 gboolean        audio_convert_get_sizes         (AudioConvertCtx *ctx, gint samples, gint *srcsize,
85                                                  gint *dstsize);
86
87 gboolean        audio_convert_clean_context     (AudioConvertCtx *ctx);
88
89 gboolean        audio_convert_convert           (AudioConvertCtx *ctx, gpointer src, 
90                                                  gpointer dst, gint samples, gboolean src_writable);
91
92 #endif /* __AUDIO_CONVERT_H__ */