Debian Codegraph @

gst/audioparsers/gstwavpackparse.h

raw
1 /* GStreamer Wavpack parser
2 * Copyright (C) 2012 Mark Nauwelaerts <[email protected]>
3 * Copyright (C) 2012 Nokia Corporation. All rights reserved.
4 * Contact: Stefan Kost <[email protected]>
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., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22 #ifndef __GST_WAVPACK_PARSE_H__
23 #define __GST_WAVPACK_PARSE_H__
24
25 #include <gst/gst.h>
26 #include <gst/base/gstbaseparse.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_WAVPACK_PARSE \
31 (gst_wavpack_parse_get_type())
32 #define GST_WAVPACK_PARSE(obj) \
33 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_WAVPACK_PARSE, GstWavpackParse))
34 #define GST_WAVPACK_PARSE_CLASS(klass) \
35 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_WAVPACK_PARSE, GstWavpackParseClass))
36 #define GST_IS_WAVPACK_PARSE(obj) \
37 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_WAVPACK_PARSE))
38 #define GST_IS_WAVPACK_PARSE_CLASS(klass) \
39 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_WAVPACK_PARSE))
40
41
42 #define ID_UNIQUE 0x3f
43 #define ID_OPTIONAL_DATA 0x20
44 #define ID_ODD_SIZE 0x40
45 #define ID_LARGE 0x80
46
47 #define ID_DUMMY 0x0
48 #define ID_ENCODER_INFO 0x1
49 #define ID_DECORR_TERMS 0x2
50 #define ID_DECORR_WEIGHTS 0x3
51 #define ID_DECORR_SAMPLES 0x4
52 #define ID_ENTROPY_VARS 0x5
53 #define ID_HYBRID_PROFILE 0x6
54 #define ID_SHAPING_WEIGHTS 0x7
55 #define ID_FLOAT_INFO 0x8
56 #define ID_INT32_INFO 0x9
57 #define ID_WV_BITSTREAM 0xa
58 #define ID_WVC_BITSTREAM 0xb
59 #define ID_WVX_BITSTREAM 0xc
60 #define ID_CHANNEL_INFO 0xd
61 #define ID_DSD_BLOCK 0xe
62
63 #define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1)
64 #define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2)
65 #define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3)
66 #define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4)
67 #define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5)
68 #define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6)
69 #define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7)
70 #define ID_ALT_EXTENSION (ID_OPTIONAL_DATA | 0x8)
71 #define ID_ALT_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x9)
72 #define ID_NEW_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0xa)
73 #define ID_CHANNEL_IDENTITIES (ID_OPTIONAL_DATA | 0xb)
74 #define ID_WVX_NEW_BITSTREAM (ID_OPTIONAL_DATA | ID_WVX_BITSTREAM)
75 #define ID_BLOCK_CHECKSUM (ID_OPTIONAL_DATA | 0xf)
76
77 #define FLAG_BYTES_STORED 3 // 1-4 bytes/sample
78 #define FLAG_MONO_FLAG 4 // not stereo
79 #define FLAG_HYBRID_FLAG 8 // hybrid mode
80 #define FLAG_JOINT_STEREO 0x10 // joint stereo
81 #define FLAG_CROSS_DECORR 0x20 // no-delay cross decorrelation
82 #define FLAG_HYBRID_SHAPE 0x40 // noise shape (hybrid mode only)
83 #define FLAG_FLOAT_DATA 0x80 // ieee 32-bit floating point data
84
85 #define FLAG_INT32_DATA 0x100 // special extended int handling
86 #define FLAG_HYBRID_BITRATE 0x200 // bitrate noise (hybrid mode only)
87 #define FLAG_HYBRID_BALANCE 0x400 // balance noise (hybrid stereo mode only)
88
89 #define FLAG_INITIAL_BLOCK 0x800 // initial block of multichannel segment
90 #define FLAG_FINAL_BLOCK 0x1000 // final block of multichannel segment
91
92 #define FLAG_SHIFT_LSB 13
93 #define FLAG_SHIFT_MASK (0x1fL << FLAG_SHIFT_LSB)
94
95 #define FLAG_MAG_LSB 18
96 #define FLAG_MAG_MASK (0x1fL << FLAG_MAG_LSB)
97
98 #define FLAG_SRATE_LSB 23
99 #define FLAG_SRATE_MASK (0xfL << FLAG_SRATE_LSB)
100
101 #define FLAG_FALSE_STEREO 0x40000000 // block is stereo, but data is mono
102 #define FLAG_NEW_SHAPING 0x20000000 // use IIR filter for negative shaping
103
104 #define FLAG_MONO_DATA (FLAG_MONO_FLAG | FLAG_FALSE_STEREO)
105
106 // Introduced in WavPack 5.0:
107 #define FLAG_HAS_CHECKSUM 0x10000000 // block contains a trailing checksum
108 #define FLAG_DSD_FLAG 0x80000000 // block is encoded DSD (1-bit PCM)
109
110 typedef struct {
111 char ckID [4]; /* "wvpk" */
112 guint32 ckSize; /* size of entire block (minus 8, of course) */
113 guint16 version; /* 0x402 to 0x410 are currently valid for decode */
114 guchar track_no; /* track number (0 if not used, like now) */
115 guchar index_no; /* track sub-index (0 if not used, like now) */
116 guint32 total_samples; /* total samples for entire file, but this is
117 * only valid if block_index == 0 and a value of
118 * -1 indicates unknown length */
119 guint32 block_index; /* index of first sample in block relative to
120 * beginning of file (normally this would start
121 * at 0 for the first block) */
122 guint32 block_samples; /* number of samples in this block (0 = no audio) */
123 guint32 flags; /* various flags for id and decoding */
124 guint32 crc; /* crc for actual decoded data */
125 } WavpackHeader;
126
127 typedef enum {
128 SAMPLE_TYPE_INT,
129 SAMPLE_TYPE_FLOAT,
130 SAMPLE_TYPE_DSD,
131 } WavpackSampleType;
132
133 typedef struct {
134 gboolean correction;
135 guint rate;
136 guint width;
137 guint depth;
138 guint channels;
139 guint channel_mask;
140 WavpackSampleType sample_type;
141 } WavpackInfo;
142
143 typedef struct _GstWavpackParse GstWavpackParse;
144 typedef struct _GstWavpackParseClass GstWavpackParseClass;
145
146 /**
147 * GstWavpackParse:
148 *
149 * The opaque GstWavpackParse object
150 */
151 struct _GstWavpackParse {
152 GstBaseParse baseparse;
153
154 /*< private >*/
155 gint sample_rate;
156 gint channels;
157 gint width;
158 gint depth;
159 gint channel_mask;
160 WavpackSampleType sample_type;
161
162 guint total_samples;
163
164 gboolean sent_codec_tag;
165 };
166
167 /**
168 * GstWavpackParseClass:
169 * @parent_class: Element parent class.
170 *
171 * The opaque GstWavpackParseClass data structure.
172 */
173 struct _GstWavpackParseClass {
174 GstBaseParseClass baseparse_class;
175 };
176
177 GType gst_wavpack_parse_get_type (void);
178
179 G_END_DECLS
180
181 #endif /* __GST_WAVPACK_PARSE_H__ */