blob: 75558bf608bb9dabbe31e1e576f772a293e66732 [file] [log] [blame]
Vinod Koul50c34cf2011-12-23 10:36:37 +05301/*
2 * 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#ifndef __SND_COMPRESS_PARAMS_H
52#define __SND_COMPRESS_PARAMS_H
53
Vinod Koul50c34cf2011-12-23 10:36:37 +053054/* AUDIO CODECS SUPPORTED */
55#define MAX_NUM_CODECS 32
56#define MAX_NUM_CODEC_DESCRIPTORS 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#define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
72#define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
Srikanth Uyyala66f781a2012-06-13 23:23:25 +053073#define SND_AUDIOCODEC_AC3 ((__u32) 0x0000000E)
74#define SND_AUDIOCODEC_DTS ((__u32) 0x0000000F)
75#define SND_AUDIOCODEC_AC3_PASS_THROUGH ((__u32) 0x00000010)
76#define SND_AUDIOCODEC_WMA_PRO ((__u32) 0x00000011)
77#define SND_AUDIOCODEC_DTS_PASS_THROUGH ((__u32) 0x00000012)
78#define SND_AUDIOCODEC_DTS_LBR ((__u32) 0x00000013)
79#define SND_AUDIOCODEC_DTS_TRANSCODE_LOOPBACK ((__u32) 0x00000014)
80
Vinod Koul50c34cf2011-12-23 10:36:37 +053081/*
82 * Profile and modes are listed with bit masks. This allows for a
83 * more compact representation of fields that will not evolve
84 * (in contrast to the list of codecs)
85 */
86
87#define SND_AUDIOPROFILE_PCM ((__u32) 0x00000001)
88
89/* MP3 modes are only useful for encoders */
90#define SND_AUDIOCHANMODE_MP3_MONO ((__u32) 0x00000001)
91#define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
92#define SND_AUDIOCHANMODE_MP3_JOINTSTEREO ((__u32) 0x00000004)
93#define SND_AUDIOCHANMODE_MP3_DUAL ((__u32) 0x00000008)
94
95#define SND_AUDIOPROFILE_AMR ((__u32) 0x00000001)
96
97/* AMR modes are only useful for encoders */
98#define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
99#define SND_AUDIOMODE_AMR_VAD1 ((__u32) 0x00000002)
100#define SND_AUDIOMODE_AMR_VAD2 ((__u32) 0x00000004)
101
102#define SND_AUDIOSTREAMFORMAT_UNDEFINED ((__u32) 0x00000000)
103#define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
104#define SND_AUDIOSTREAMFORMAT_IF1 ((__u32) 0x00000002)
105#define SND_AUDIOSTREAMFORMAT_IF2 ((__u32) 0x00000004)
106#define SND_AUDIOSTREAMFORMAT_FSF ((__u32) 0x00000008)
107#define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
108#define SND_AUDIOSTREAMFORMAT_ITU ((__u32) 0x00000020)
109
110#define SND_AUDIOPROFILE_AMRWB ((__u32) 0x00000001)
111
112/* AMRWB modes are only useful for encoders */
113#define SND_AUDIOMODE_AMRWB_DTX_OFF ((__u32) 0x00000001)
114#define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
115#define SND_AUDIOMODE_AMRWB_VAD2 ((__u32) 0x00000004)
116
117#define SND_AUDIOPROFILE_AMRWBPLUS ((__u32) 0x00000001)
118
119#define SND_AUDIOPROFILE_AAC ((__u32) 0x00000001)
120
121/* AAC modes are required for encoders and decoders */
122#define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
123#define SND_AUDIOMODE_AAC_LC ((__u32) 0x00000002)
124#define SND_AUDIOMODE_AAC_SSR ((__u32) 0x00000004)
125#define SND_AUDIOMODE_AAC_LTP ((__u32) 0x00000008)
126#define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
127#define SND_AUDIOMODE_AAC_SCALABLE ((__u32) 0x00000020)
128#define SND_AUDIOMODE_AAC_ERLC ((__u32) 0x00000040)
129#define SND_AUDIOMODE_AAC_LD ((__u32) 0x00000080)
130#define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
131#define SND_AUDIOMODE_AAC_HE_MPS ((__u32) 0x00000200)
132
133/* AAC formats are required for encoders and decoders */
134#define SND_AUDIOSTREAMFORMAT_MP2ADTS ((__u32) 0x00000001)
135#define SND_AUDIOSTREAMFORMAT_MP4ADTS ((__u32) 0x00000002)
136#define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
137#define SND_AUDIOSTREAMFORMAT_MP4LATM ((__u32) 0x00000008)
138#define SND_AUDIOSTREAMFORMAT_ADIF ((__u32) 0x00000010)
139#define SND_AUDIOSTREAMFORMAT_MP4FF ((__u32) 0x00000020)
140#define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
141
142#define SND_AUDIOPROFILE_WMA7 ((__u32) 0x00000001)
143#define SND_AUDIOPROFILE_WMA8 ((__u32) 0x00000002)
144#define SND_AUDIOPROFILE_WMA9 ((__u32) 0x00000004)
145#define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
146
147#define SND_AUDIOMODE_WMA_LEVEL1 ((__u32) 0x00000001)
148#define SND_AUDIOMODE_WMA_LEVEL2 ((__u32) 0x00000002)
149#define SND_AUDIOMODE_WMA_LEVEL3 ((__u32) 0x00000004)
150#define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
151#define SND_AUDIOMODE_WMAPRO_LEVELM0 ((__u32) 0x00000010)
152#define SND_AUDIOMODE_WMAPRO_LEVELM1 ((__u32) 0x00000020)
153#define SND_AUDIOMODE_WMAPRO_LEVELM2 ((__u32) 0x00000040)
154#define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
155
156#define SND_AUDIOSTREAMFORMAT_WMA_ASF ((__u32) 0x00000001)
157/*
158 * Some implementations strip the ASF header and only send ASF packets
159 * to the DSP
160 */
161#define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR ((__u32) 0x00000002)
162
163#define SND_AUDIOPROFILE_REALAUDIO ((__u32) 0x00000001)
164
165#define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
166#define SND_AUDIOMODE_REALAUDIO_8 ((__u32) 0x00000002)
167#define SND_AUDIOMODE_REALAUDIO_10 ((__u32) 0x00000004)
168#define SND_AUDIOMODE_REALAUDIO_SURROUND ((__u32) 0x00000008)
169
170#define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
171
172#define SND_AUDIOMODE_VORBIS ((__u32) 0x00000001)
173
174#define SND_AUDIOPROFILE_FLAC ((__u32) 0x00000001)
175
176/*
177 * Define quality levels for FLAC encoders, from LEVEL0 (fast)
178 * to LEVEL8 (best)
179 */
180#define SND_AUDIOMODE_FLAC_LEVEL0 ((__u32) 0x00000001)
181#define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
182#define SND_AUDIOMODE_FLAC_LEVEL2 ((__u32) 0x00000004)
183#define SND_AUDIOMODE_FLAC_LEVEL3 ((__u32) 0x00000008)
184#define SND_AUDIOMODE_FLAC_LEVEL4 ((__u32) 0x00000010)
185#define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
186#define SND_AUDIOMODE_FLAC_LEVEL6 ((__u32) 0x00000040)
187#define SND_AUDIOMODE_FLAC_LEVEL7 ((__u32) 0x00000080)
188#define SND_AUDIOMODE_FLAC_LEVEL8 ((__u32) 0x00000100)
189
190#define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
191#define SND_AUDIOSTREAMFORMAT_FLAC_OGG ((__u32) 0x00000002)
192
193/* IEC61937 payloads without CUVP and preambles */
194#define SND_AUDIOPROFILE_IEC61937 ((__u32) 0x00000001)
195/* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
196#define SND_AUDIOPROFILE_IEC61937_SPDIF ((__u32) 0x00000002)
197
198/*
199 * IEC modes are mandatory for decoders. Format autodetection
200 * will only happen on the DSP side with mode 0. The PCM mode should
201 * not be used, the PCM codec should be used instead.
202 */
203#define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
204#define SND_AUDIOMODE_IEC_LPCM ((__u32) 0x00000001)
205#define SND_AUDIOMODE_IEC_AC3 ((__u32) 0x00000002)
206#define SND_AUDIOMODE_IEC_MPEG1 ((__u32) 0x00000004)
207#define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
208#define SND_AUDIOMODE_IEC_MPEG2 ((__u32) 0x00000010)
209#define SND_AUDIOMODE_IEC_AACLC ((__u32) 0x00000020)
210#define SND_AUDIOMODE_IEC_DTS ((__u32) 0x00000040)
211#define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
212#define SND_AUDIOMODE_IEC_SACD ((__u32) 0x00000100)
213#define SND_AUDIOMODE_IEC_EAC3 ((__u32) 0x00000200)
214#define SND_AUDIOMODE_IEC_DTS_HD ((__u32) 0x00000400)
215#define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
216#define SND_AUDIOMODE_IEC_DST ((__u32) 0x00001000)
217#define SND_AUDIOMODE_IEC_WMAPRO ((__u32) 0x00002000)
218#define SND_AUDIOMODE_IEC_REF_CXT ((__u32) 0x00004000)
219#define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
220#define SND_AUDIOMODE_IEC_HE_AAC2 ((__u32) 0x00010000)
221#define SND_AUDIOMODE_IEC_MPEG_SURROUND ((__u32) 0x00020000)
222
223#define SND_AUDIOPROFILE_G723_1 ((__u32) 0x00000001)
224
225#define SND_AUDIOMODE_G723_1_ANNEX_A ((__u32) 0x00000001)
226#define SND_AUDIOMODE_G723_1_ANNEX_B ((__u32) 0x00000002)
227#define SND_AUDIOMODE_G723_1_ANNEX_C ((__u32) 0x00000004)
228
229#define SND_AUDIOPROFILE_G729 ((__u32) 0x00000001)
230
231#define SND_AUDIOMODE_G729_ANNEX_A ((__u32) 0x00000001)
232#define SND_AUDIOMODE_G729_ANNEX_B ((__u32) 0x00000002)
233
234/* <FIXME: multichannel encoders aren't supported for now. Would need
235 an additional definition of channel arrangement> */
236
237/* VBR/CBR definitions */
238#define SND_RATECONTROLMODE_CONSTANTBITRATE ((__u32) 0x00000001)
239#define SND_RATECONTROLMODE_VARIABLEBITRATE ((__u32) 0x00000002)
240
241/* Encoder options */
242
243struct snd_enc_wma {
244 __u32 super_block_align; /* WMA Type-specific data */
Steve Mucklef132c6c2012-06-06 18:30:57 -0700245 __u32 bits_per_sample;
246 __u32 channelmask;
247 __u32 encodeopt;
Aviral Guptaf9925652012-06-14 00:51:19 +0530248 __u32 encodeopt1;
249 __u32 encodeopt2;
Vinod Koul50c34cf2011-12-23 10:36:37 +0530250};
251
252
253/**
254 * struct snd_enc_vorbis
255 * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
256 * In the default mode of operation, the quality level is 3.
257 * Normal quality range is 0 - 10.
258 * @managed: Boolean. Set bitrate management mode. This turns off the
259 * normal VBR encoding, but allows hard or soft bitrate constraints to be
260 * enforced by the encoder. This mode can be slower, and may also be
261 * lower quality. It is primarily useful for streaming.
262 * @max_bit_rate: Enabled only if managed is TRUE
263 * @min_bit_rate: Enabled only if managed is TRUE
264 * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
265 * non-stereo streams). Useful for lower-bitrate encoding.
266 *
267 * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
268 * properties
269 *
270 * For best quality users should specify VBR mode and set quality levels.
271 */
272
273struct snd_enc_vorbis {
274 __s32 quality;
275 __u32 managed;
276 __u32 max_bit_rate;
277 __u32 min_bit_rate;
278 __u32 downmix;
279};
280
281
282/**
283 * struct snd_enc_real
284 * @quant_bits: number of coupling quantization bits in the stream
285 * @start_region: coupling start region in the stream
286 * @num_regions: number of regions value
287 *
288 * These options were extracted from the OpenMAX IL spec
289 */
290
291struct snd_enc_real {
292 __u32 quant_bits;
293 __u32 start_region;
294 __u32 num_regions;
295};
296
297/**
298 * struct snd_enc_flac
299 * @num: serial number, valid only for OGG formats
300 * needs to be set by application
301 * @gain: Add replay gain tags
302 *
303 * These options were extracted from the FLAC online documentation
304 * at http://flac.sourceforge.net/documentation_tools_flac.html
305 *
306 * To make the API simpler, it is assumed that the user will select quality
307 * profiles. Additional options that affect encoding quality and speed can
308 * be added at a later stage if needed.
309 *
310 * By default the Subset format is used by encoders.
311 *
312 * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
313 * not supported in this API.
314 */
315
316struct snd_enc_flac {
317 __u32 num;
318 __u32 gain;
319};
320
321struct snd_enc_generic {
322 __u32 bw; /* encoder bandwidth */
323 __s32 reserved[15];
324};
325
326union snd_codec_options {
327 struct snd_enc_wma wma;
328 struct snd_enc_vorbis vorbis;
329 struct snd_enc_real real;
330 struct snd_enc_flac flac;
331 struct snd_enc_generic generic;
332};
333
334/** struct snd_codec_desc - description of codec capabilities
335 * @max_ch: Maximum number of audio channels
336 * @sample_rates: Sampling rates in Hz, use SNDRV_PCM_RATE_xxx for this
337 * @bit_rate: Indexed array containing supported bit rates
338 * @num_bitrates: Number of valid values in bit_rate array
339 * @rate_control: value is specified by SND_RATECONTROLMODE defines.
340 * @profiles: Supported profiles. See SND_AUDIOPROFILE defines.
341 * @modes: Supported modes. See SND_AUDIOMODE defines
342 * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines
343 * @min_buffer: Minimum buffer size handled by codec implementation
344 * @reserved: reserved for future use
345 *
346 * This structure provides a scalar value for profiles, modes and stream
347 * format fields.
348 * If an implementation supports multiple combinations, they will be listed as
349 * codecs with different descriptors, for example there would be 2 descriptors
350 * for AAC-RAW and AAC-ADTS.
351 * This entails some redundancy but makes it easier to avoid invalid
352 * configurations.
353 *
354 */
355
356struct snd_codec_desc {
357 __u32 max_ch;
358 __u32 sample_rates;
359 __u32 bit_rate[MAX_NUM_BITRATES];
360 __u32 num_bitrates;
361 __u32 rate_control;
362 __u32 profiles;
363 __u32 modes;
364 __u32 formats;
365 __u32 min_buffer;
366 __u32 reserved[15];
367};
368
369/** struct snd_codec
370 * @id: Identifies the supported audio encoder/decoder.
371 * See SND_AUDIOCODEC macros.
372 * @ch_in: Number of input audio channels
373 * @ch_out: Number of output channels. In case of contradiction between
374 * this field and the channelMode field, the channelMode field
375 * overrides.
376 * @sample_rate: Audio sample rate of input data
377 * @bit_rate: Bitrate of encoded data. May be ignored by decoders
378 * @rate_control: Encoding rate control. See SND_RATECONTROLMODE defines.
379 * Encoders may rely on profiles for quality levels.
380 * May be ignored by decoders.
381 * @profile: Mandatory for encoders, can be mandatory for specific
382 * decoders as well. See SND_AUDIOPROFILE defines.
383 * @level: Supported level (Only used by WMA at the moment)
384 * @ch_mode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
385 * @format: Format of encoded bistream. Mandatory when defined.
386 * See SND_AUDIOSTREAMFORMAT defines.
387 * @align: Block alignment in bytes of an audio sample.
388 * Only required for PCM or IEC formats.
389 * @options: encoder-specific settings
390 * @reserved: reserved for future use
391 */
392
393struct snd_codec {
394 __u32 id;
395 __u32 ch_in;
396 __u32 ch_out;
397 __u32 sample_rate;
398 __u32 bit_rate;
399 __u32 rate_control;
400 __u32 profile;
401 __u32 level;
402 __u32 ch_mode;
403 __u32 format;
404 __u32 align;
405 union snd_codec_options options;
406 __u32 reserved[3];
407};
408
409#endif