blob: 7203e5fdaa458727e741f9b25b6b80b76559c3fb [file] [log] [blame]
Vinod Koul12ac0b562011-09-02 11:36:22 +05301/*
2 * snd_compress_params.h - codec types and parameters for compressed data
3 * streaming interface
4 *
5 * Copyright (C) 2011 Intel Corporation
6 * Authors: Pierre-Louis.Bossart <pierre-louis.bossart@linux.intel.com>
7 * Vinod Koul <vinod.koul@linux.intel.com>
8 *
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 *
26 * The definitions in this file are derived from the OpenMAX AL version 1.1
27 * and OpenMAX IL v 1.1.2 header files which contain the copyright notice below.
28 *
29 * Copyright (c) 2007-2010 The Khronos Group Inc.
30 *
31 * Permission is hereby granted, free of charge, to any person obtaining
32 * a copy of this software and/or associated documentation files (the
33 * "Materials "), to deal in the Materials without restriction, including
34 * without limitation the rights to use, copy, modify, merge, publish,
35 * distribute, sublicense, and/or sell copies of the Materials, and to
36 * permit persons to whom the Materials are furnished to do so, subject to
37 * the following conditions:
38 *
39 * The above copyright notice and this permission notice shall be included
40 * in all copies or substantial portions of the Materials.
41 *
42 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
43 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
49 *
50 */
51
52
53/* AUDIO CODECS SUPPORTED */
54#define MAX_NUM_CODECS 32
55#define MAX_NUM_CODEC_DESCRIPTORS 32
56#define MAX_NUM_RATES 32
57#define MAX_NUM_BITRATES 32
58
59/* Codecs are listed linearly to allow for extensibility */
60#define SND_AUDIOCODEC_PCM ((__u32) 0x00000001)
61#define SND_AUDIOCODEC_MP3 ((__u32) 0x00000002)
62#define SND_AUDIOCODEC_AMR ((__u32) 0x00000003)
63#define SND_AUDIOCODEC_AMRWB ((__u32) 0x00000004)
64#define SND_AUDIOCODEC_AMRWBPLUS ((__u32) 0x00000005)
65#define SND_AUDIOCODEC_AAC ((__u32) 0x00000006)
66#define SND_AUDIOCODEC_WMA ((__u32) 0x00000007)
67#define SND_AUDIOCODEC_REAL ((__u32) 0x00000008)
68#define SND_AUDIOCODEC_VORBIS ((__u32) 0x00000009)
69#define SND_AUDIOCODEC_FLAC ((__u32) 0x0000000A)
70#define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B)
71
72/*
73 * Profile and modes are listed with bit masks. This allows for a
74 * more compact representation of fields that will not evolve
75 * (in contrast to the list of codecs)
76 */
77
78#define SND_AUDIOPROFILE_PCM ((__u32) 0x00000001)
79
80/* MP3 modes are only useful for encoders */
81#define SND_AUDIOCHANMODE_MP3_MONO ((__u32) 0x00000001)
82#define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
83#define SND_AUDIOCHANMODE_MP3_JOINTSTEREO ((__u32) 0x00000004)
84#define SND_AUDIOCHANMODE_MP3_DUAL ((__u32) 0x00000008)
85
86#define SND_AUDIOPROFILE_AMR ((__u32) 0x00000001)
87
88/* AMR modes are only useful for encoders */
89#define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
90#define SND_AUDIOMODE_AMR_VAD1 ((__u32) 0x00000002)
91#define SND_AUDIOMODE_AMR_VAD2 ((__u32) 0x00000004)
92
93#define SND_AUDIOSTREAMFORMAT_UNDEFINED ((__u32) 0x00000000)
94#define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
95#define SND_AUDIOSTREAMFORMAT_IF1 ((__u32) 0x00000002)
96#define SND_AUDIOSTREAMFORMAT_IF2 ((__u32) 0x00000004)
97#define SND_AUDIOSTREAMFORMAT_FSF ((__u32) 0x00000008)
98#define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
99#define SND_AUDIOSTREAMFORMAT_ITU ((__u32) 0x00000020)
100
101#define SND_AUDIOPROFILE_AMRWB ((__u32) 0x00000001)
102
103/* AMRWB modes are only useful for encoders */
104#define SND_AUDIOMODE_AMRWB_DTX_OFF ((__u32) 0x00000001)
105#define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
106#define SND_AUDIOMODE_AMRWB_VAD2 ((__u32) 0x00000004)
107
108#define SND_AUDIOPROFILE_AMRWBPLUS ((__u32) 0x00000001)
109
110#define SND_AUDIOPROFILE_AAC ((__u32) 0x00000001)
111
112/* AAC modes are required for encoders and decoders */
113#define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
114#define SND_AUDIOMODE_AAC_LC ((__u32) 0x00000002)
115#define SND_AUDIOMODE_AAC_SSR ((__u32) 0x00000004)
116#define SND_AUDIOMODE_AAC_LTP ((__u32) 0x00000008)
117#define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
118#define SND_AUDIOMODE_AAC_SCALABLE ((__u32) 0x00000020)
119#define SND_AUDIOMODE_AAC_ERLC ((__u32) 0x00000040)
120#define SND_AUDIOMODE_AAC_LD ((__u32) 0x00000080)
121#define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
122#define SND_AUDIOMODE_AAC_HE_MPS ((__u32) 0x00000200)
123
124/* AAC formats are required for encoders and decoders */
125#define SND_AUDIOSTREAMFORMAT_MP2ADTS ((__u32) 0x00000001)
126#define SND_AUDIOSTREAMFORMAT_MP4ADTS ((__u32) 0x00000002)
127#define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
128#define SND_AUDIOSTREAMFORMAT_MP4LATM ((__u32) 0x00000008)
129#define SND_AUDIOSTREAMFORMAT_ADIF ((__u32) 0x00000010)
130#define SND_AUDIOSTREAMFORMAT_MP4FF ((__u32) 0x00000020)
131#define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
132
133#define SND_AUDIOPROFILE_WMA7 ((__u32) 0x00000001)
134#define SND_AUDIOPROFILE_WMA8 ((__u32) 0x00000002)
135#define SND_AUDIOPROFILE_WMA9 ((__u32) 0x00000004)
136#define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
137
138#define SND_AUDIOMODE_WMA_LEVEL1 ((__u32) 0x00000001)
139#define SND_AUDIOMODE_WMA_LEVEL2 ((__u32) 0x00000002)
140#define SND_AUDIOMODE_WMA_LEVEL3 ((__u32) 0x00000004)
141#define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
142#define SND_AUDIOMODE_WMAPRO_LEVELM0 ((__u32) 0x00000010)
143#define SND_AUDIOMODE_WMAPRO_LEVELM1 ((__u32) 0x00000020)
144#define SND_AUDIOMODE_WMAPRO_LEVELM2 ((__u32) 0x00000040)
145#define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
146
147#define SND_AUDIOSTREAMFORMAT_WMA_ASF ((__u32) 0x00000001)
148/*
149 * Some implementations strip the ASF header and only send ASF packets
150 * to the DSP
151 */
152#define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR ((__u32) 0x00000002)
153
154#define SND_AUDIOPROFILE_REALAUDIO ((__u32) 0x00000001)
155
156#define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
157#define SND_AUDIOMODE_REALAUDIO_8 ((__u32) 0x00000002)
158#define SND_AUDIOMODE_REALAUDIO_10 ((__u32) 0x00000004)
159#define SND_AUDIOMODE_REALAUDIO_SURROUND ((__u32) 0x00000008)
160
161#define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
162
163#define SND_AUDIOMODE_VORBIS ((__u32) 0x00000001)
164
165#define SND_AUDIOPROFILE_FLAC ((__u32) 0x00000001)
166
167/*
168 * Define quality levels for FLAC encoders, from LEVEL0 (fast)
169 * to LEVEL8 (best)
170 */
171#define SND_AUDIOMODE_FLAC_LEVEL0 ((__u32) 0x00000001)
172#define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
173#define SND_AUDIOMODE_FLAC_LEVEL2 ((__u32) 0x00000004)
174#define SND_AUDIOMODE_FLAC_LEVEL3 ((__u32) 0x00000008)
175#define SND_AUDIOMODE_FLAC_LEVEL4 ((__u32) 0x00000010)
176#define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
177#define SND_AUDIOMODE_FLAC_LEVEL6 ((__u32) 0x00000040)
178#define SND_AUDIOMODE_FLAC_LEVEL7 ((__u32) 0x00000080)
179#define SND_AUDIOMODE_FLAC_LEVEL8 ((__u32) 0x00000100)
180
181#define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
182#define SND_AUDIOSTREAMFORMAT_FLAC_OGG ((__u32) 0x00000002)
183
184/* IEC61937 payloads without CUVP and preambles */
185#define SND_AUDIOPROFILE_IEC61937 ((__u32) 0x00000001)
186/* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
187#define SND_AUDIOPROFILE_IEC61937_SPDIF ((__u32) 0x00000002)
188
189/*
190 * IEC modes are mandatory for decoders. Format autodetection
191 * will only happen on the DSP side with mode 0. The PCM mode should
192 * not be used, the PCM codec should be used instead
193 */
194#define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
195#define SND_AUDIOMODE_IEC_LPCM ((__u32) 0x00000001)
196#define SND_AUDIOMODE_IEC_AC3 ((__u32) 0x00000002)
197#define SND_AUDIOMODE_IEC_MPEG1 ((__u32) 0x00000004)
198#define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
199#define SND_AUDIOMODE_IEC_MPEG2 ((__u32) 0x00000010)
200#define SND_AUDIOMODE_IEC_AACLC ((__u32) 0x00000020)
201#define SND_AUDIOMODE_IEC_DTS ((__u32) 0x00000040)
202#define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
203#define SND_AUDIOMODE_IEC_SACD ((__u32) 0x00000100)
204#define SND_AUDIOMODE_IEC_EAC3 ((__u32) 0x00000200)
205#define SND_AUDIOMODE_IEC_DTS_HD ((__u32) 0x00000400)
206#define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
207#define SND_AUDIOMODE_IEC_DST ((__u32) 0x00001000)
208#define SND_AUDIOMODE_IEC_WMAPRO ((__u32) 0x00002000)
209#define SND_AUDIOMODE_IEC_REF_CXT ((__u32) 0x00004000)
210#define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
211#define SND_AUDIOMODE_IEC_HE_AAC2 ((__u32) 0x00010000)
212#define SND_AUDIOMODE_IEC_MPEG_SURROUND ((__u32) 0x00020000)
213
214/* <FIXME: multichannel encoders aren't supported for now. Would need
215 an additional definition of channel arrangement> */
216
217/* VBR/CBR definitions */
218#define SND_RATECONTROLMODE_CONSTANTBITRATE ((__u32) 0x00000001)
219#define SND_RATECONTROLMODE_VARIABLEBITRATE ((__u32) 0x00000002)
220
221/* Encoder options */
222
223struct wmaEncoderOptions {
224 __u32 super_block_align; /* WMA Type-specific data */
225};
226
227
228/**
229 * struct vorbisEncoderOptions
230 * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
231 * In the default mode of operation, the quality level is 3.
232 * Normal quality range is 0 - 10.
233 * @managed: Boolean. Set bitrate management mode. This turns off the
234 * normal VBR encoding, but allows hard or soft bitrate constraints to be
235 * enforced by the encoder. This mode can be slower, and may also be
236 * lower quality. It is primarily useful for streaming.
237 * @maxBitrate: enabled only is managed is TRUE
238 * @minBitrate: enabled only is managed is TRUE
239 * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
240 * non-stereo streams). Useful for lower-bitrate encoding.
241 *
242 * These options were extracted from the OpenMAX IL spec and gstreamer vorbisenc
243 * properties
244 *
245 * For best quality users should specify VBR mode and set quality levels.
246 */
247
248struct vorbisEncoderOptions {
249 int quality;
250 __u32 managed;
251 __u32 maxBitrate;
252 __u32 minBirate;
253 __u32 downmix;
254};
255
256
257/**
258 * struct realEncoderOptions
259 * @coupling_quant_bits: is the number of coupling quantization bits in the stream
260 * @coupling_start_region: is the coupling start region in the stream
261 * @num_regions: is the number of regions value
262 *
263 * These options were extracted from the OpenMAX IL spec
264 */
265
266struct realEncoderOptions {
267 __u32 coupling_quant_bits;
268 __u32 coupling_start_region;
269 __u32 num_regions;
270};
271
272/**
273 * struct flacEncoderOptions
274 * @serialNumber: valid only for OGG formats, needs to be set by application
275 * @replayGain: Add ReplayGain tags
276 *
277 * These options were extracted from the FLAC online documentation
278 * at http://flac.sourceforge.net/documentation_tools_flac.html
279 *
280 * To make the API simpler, it is assumed that the user will select quality
281 * profiles. Additional options that affect encoding quality and speed can
282 * be added at a later stage if need be.
283 *
284 * By default the Subset format is used by encoders.
285 *
286 * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
287 * not supported in this API.
288 */
289
290struct flacEncoderOptions {
291 __u32 serialNumber;
292 __u32 replayGain;
293};
294
295struct genericEncoderOptions {
296 __u32 encoderBandwidth;
297 int reserved[15];
298};
299
300union AudioCodecOptions {
301 struct wmaEncoderOptions wmaSpecificOptions;
302 struct vorbisEncoderOptions vorbisSpecificOptions;
303 struct realEncoderOptions realSpecificOptions;
304 struct flacEncoderOptions flacEncoderOptions;
305 struct genericEncoderOptions genericOptions;
306};
307
308/** struct SndAudioCodecDescriptor - description of codec capabilities
309 * @maxChannels: maximum number of audio channels
310 * @minBitsPerSample: Minimum bits per sample of PCM data <FIXME: needed?>
311 * @maxBitsPerSample: Maximum bits per sample of PCM data <FIXME: needed?>
312 * @minSampleRate: Minimum sampling rate supported, unit is Hz
313 * @maxSampleRate: Minimum sampling rate supported, unit is Hz
314 * @isFreqRangeContinuous: TRUE if the device supports a continuous range of
315 * sampling rates between minSampleRate and maxSampleRate;
316 * otherwise FALSE <FIXME: needed?>
317 * @SampleRatesSupported: Indexed array containing supported sampling rates in Hz
318 * @numSampleRatesSupported: Size of the pSamplesRatesSupported array
319 * @minBitRate: Minimum bitrate in bits per second
320 * @maxBitRate: Max bitrate in bits per second
321 * @isBitrateRangeContinuous: TRUE if the device supports a continuous range of
322 * bitrates between minBitRate and maxBitRate; otherwise FALSE
323 * @BitratesSupported: Indexed array containing supported bit rates
324 * @numBitratesSupported: Size of the pBiratesSupported array
325 * @rateControlSupported: value is specified by SND_RATECONTROLMODE defines.
326 * @profileSetting: Profile supported. See SND_AUDIOPROFILE defines.
327 * @modeSetting: Mode supported. See SND_AUDIOMODE defines
328 * @streamFormat: Format supported. See SND_AUDIOSTREAMFORMAT defines
329 * @reserved: reserved for future use
330 *
331 * This structure provides a scalar value for profile, mode and stream format fields.
332 * If an implementation supports multiple combinations, they will be listed as codecs
333 * with different IDs, for example there would be 2 decoders for AAC-RAW and AAC-ADTS.
334 * This entails some redundancy but makes it easier to avoid invalid configurations.
335 *
336 */
337
338struct SndAudioCodecDescriptor {
339 __u32 maxChannels;
340 __u32 minBitsPerSample;
341 __u32 maxBitsPerSample;
342 __u32 minSampleRate;
343 __u32 maxSampleRate;
344 __u32 isFreqRangeContinuous;
345 __u32 sampleRatesSupported[MAX_NUM_RATES];
346 __u32 numSampleRatesSupported;
347 __u32 minBitRate;
348 __u32 maxBitRate;
349 __u32 isBitrateRangeContinuous;
350 __u32 bitratesSupported[MAX_NUM_BITRATES];
351 __u32 numBitratesSupported;
352 __u32 rateControlSupported;
353 __u32 profileSetting;
354 __u32 modeSetting;
355 __u32 streamFormat;
356 __u32 reserved[16];
357};
358
359/** struct SndAudioCodecSettings -
360 * @codecId: Identifies the supported audio encoder/decoder. See SND_AUDIOCODEC macros.
361 * @channelsIn: Number of input audio channels
362 * @channelsOut: Number of output channels. In case of contradiction between this field and the
363 * channelMode field, the channelMode field overrides
364 * @sampleRate: Audio sample rate of input data
365 * @bitRate: Bitrate of encoded data. May be ignored by decoders
366 * @bitsPerSample: <FIXME: Needed? DSP implementations can handle their own format>
367 * @rateControl: Encoding rate control. See SND_RATECONTROLMODE defines.
368 * Encoders may rely on profiles for quality levels.
369 * May be ignored by decoders.
370 * @profileSetting: Mandatory for encoders, can be mandatory for specific decoders as well.
371 * See SND_AUDIOPROFILE defines
372 * @levelSetting: Supported level (Only used by WMA at the moment)
373 * @channelMode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
374 * @streamFormat: Format of encoded bistream. Mandatory when defined. See SND_AUDIOSTREAMFORMAT
375 * defines
376 * @blockAlignment: Block alignment in bytes of an audio sample. Only required for PCM or IEC formats
377 * @options: encoder-specific settings
378 * @reserved: reserved for future use
379 */
380
381struct SndAudioCodecSettings {
382 __u32 codecId;
383 __u32 channelsIn;
384 __u32 channelsOut;
385 __u32 sampleRate;
386 __u32 bitRate;
387 __u32 bitsPerSample;
388 __u32 rateControl;
389 __u32 profileSetting;
390 __u32 levelSetting;
391 __u32 channelMode;
392 __u32 streamFormat;
393 __u32 blockAlignment;
394 union AudioCodecOptions options;
395 __u32 reserved[3];
396};