1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) AND MIT) */
3 * compress_params.h - codec types and parameters for compressed data
6 * Copyright (C) 2011 Intel Corporation
7 * Authors: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
8 * Vinod Koul <vinod.koul@linux.intel.com>
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 * The definitions in this file are derived from the OpenMAX AL version 1.1
13 * and OpenMAX IL v 1.1.2 header files which contain the copyright notice below
14 * and are licensed under the MIT license.
16 * Copyright (c) 2007-2010 The Khronos Group Inc.
18 #ifndef __SND_COMPRESS_PARAMS_H
19 #define __SND_COMPRESS_PARAMS_H
21 #include <linux/types.h>
23 /* AUDIO CODECS SUPPORTED */
24 #define MAX_NUM_CODECS 32
25 #define MAX_NUM_CODEC_DESCRIPTORS 32
26 #define MAX_NUM_BITRATES 32
27 #define MAX_NUM_SAMPLE_RATES 32
29 /* Codecs are listed linearly to allow for extensibility */
30 #define SND_AUDIOCODEC_PCM ((__u32) 0x00000001)
31 #define SND_AUDIOCODEC_MP3 ((__u32) 0x00000002)
32 #define SND_AUDIOCODEC_AMR ((__u32) 0x00000003)
33 #define SND_AUDIOCODEC_AMRWB ((__u32) 0x00000004)
34 #define SND_AUDIOCODEC_AMRWBPLUS ((__u32) 0x00000005)
35 #define SND_AUDIOCODEC_AAC ((__u32) 0x00000006)
36 #define SND_AUDIOCODEC_WMA ((__u32) 0x00000007)
37 #define SND_AUDIOCODEC_REAL ((__u32) 0x00000008)
38 #define SND_AUDIOCODEC_VORBIS ((__u32) 0x00000009)
39 #define SND_AUDIOCODEC_FLAC ((__u32) 0x0000000A)
40 #define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B)
41 #define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
42 #define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
43 #define SND_AUDIOCODEC_BESPOKE ((__u32) 0x0000000E)
44 #define SND_AUDIOCODEC_ALAC ((__u32) 0x0000000F)
45 #define SND_AUDIOCODEC_APE ((__u32) 0x00000010)
46 #define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_APE
49 * Profile and modes are listed with bit masks. This allows for a
50 * more compact representation of fields that will not evolve
51 * (in contrast to the list of codecs)
54 #define SND_AUDIOPROFILE_PCM ((__u32) 0x00000001)
56 /* MP3 modes are only useful for encoders */
57 #define SND_AUDIOCHANMODE_MP3_MONO ((__u32) 0x00000001)
58 #define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
59 #define SND_AUDIOCHANMODE_MP3_JOINTSTEREO ((__u32) 0x00000004)
60 #define SND_AUDIOCHANMODE_MP3_DUAL ((__u32) 0x00000008)
62 #define SND_AUDIOPROFILE_AMR ((__u32) 0x00000001)
64 /* AMR modes are only useful for encoders */
65 #define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
66 #define SND_AUDIOMODE_AMR_VAD1 ((__u32) 0x00000002)
67 #define SND_AUDIOMODE_AMR_VAD2 ((__u32) 0x00000004)
69 #define SND_AUDIOSTREAMFORMAT_UNDEFINED ((__u32) 0x00000000)
70 #define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
71 #define SND_AUDIOSTREAMFORMAT_IF1 ((__u32) 0x00000002)
72 #define SND_AUDIOSTREAMFORMAT_IF2 ((__u32) 0x00000004)
73 #define SND_AUDIOSTREAMFORMAT_FSF ((__u32) 0x00000008)
74 #define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
75 #define SND_AUDIOSTREAMFORMAT_ITU ((__u32) 0x00000020)
77 #define SND_AUDIOPROFILE_AMRWB ((__u32) 0x00000001)
79 /* AMRWB modes are only useful for encoders */
80 #define SND_AUDIOMODE_AMRWB_DTX_OFF ((__u32) 0x00000001)
81 #define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
82 #define SND_AUDIOMODE_AMRWB_VAD2 ((__u32) 0x00000004)
84 #define SND_AUDIOPROFILE_AMRWBPLUS ((__u32) 0x00000001)
86 #define SND_AUDIOPROFILE_AAC ((__u32) 0x00000001)
88 /* AAC modes are required for encoders and decoders */
89 #define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
90 #define SND_AUDIOMODE_AAC_LC ((__u32) 0x00000002)
91 #define SND_AUDIOMODE_AAC_SSR ((__u32) 0x00000004)
92 #define SND_AUDIOMODE_AAC_LTP ((__u32) 0x00000008)
93 #define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
94 #define SND_AUDIOMODE_AAC_SCALABLE ((__u32) 0x00000020)
95 #define SND_AUDIOMODE_AAC_ERLC ((__u32) 0x00000040)
96 #define SND_AUDIOMODE_AAC_LD ((__u32) 0x00000080)
97 #define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
98 #define SND_AUDIOMODE_AAC_HE_MPS ((__u32) 0x00000200)
100 /* AAC formats are required for encoders and decoders */
101 #define SND_AUDIOSTREAMFORMAT_MP2ADTS ((__u32) 0x00000001)
102 #define SND_AUDIOSTREAMFORMAT_MP4ADTS ((__u32) 0x00000002)
103 #define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
104 #define SND_AUDIOSTREAMFORMAT_MP4LATM ((__u32) 0x00000008)
105 #define SND_AUDIOSTREAMFORMAT_ADIF ((__u32) 0x00000010)
106 #define SND_AUDIOSTREAMFORMAT_MP4FF ((__u32) 0x00000020)
107 #define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
109 #define SND_AUDIOPROFILE_WMA7 ((__u32) 0x00000001)
110 #define SND_AUDIOPROFILE_WMA8 ((__u32) 0x00000002)
111 #define SND_AUDIOPROFILE_WMA9 ((__u32) 0x00000004)
112 #define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
113 #define SND_AUDIOPROFILE_WMA9_PRO ((__u32) 0x00000010)
114 #define SND_AUDIOPROFILE_WMA9_LOSSLESS ((__u32) 0x00000020)
115 #define SND_AUDIOPROFILE_WMA10_LOSSLESS ((__u32) 0x00000040)
117 #define SND_AUDIOMODE_WMA_LEVEL1 ((__u32) 0x00000001)
118 #define SND_AUDIOMODE_WMA_LEVEL2 ((__u32) 0x00000002)
119 #define SND_AUDIOMODE_WMA_LEVEL3 ((__u32) 0x00000004)
120 #define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
121 #define SND_AUDIOMODE_WMAPRO_LEVELM0 ((__u32) 0x00000010)
122 #define SND_AUDIOMODE_WMAPRO_LEVELM1 ((__u32) 0x00000020)
123 #define SND_AUDIOMODE_WMAPRO_LEVELM2 ((__u32) 0x00000040)
124 #define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
126 #define SND_AUDIOSTREAMFORMAT_WMA_ASF ((__u32) 0x00000001)
128 * Some implementations strip the ASF header and only send ASF packets
131 #define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR ((__u32) 0x00000002)
133 #define SND_AUDIOPROFILE_REALAUDIO ((__u32) 0x00000001)
135 #define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
136 #define SND_AUDIOMODE_REALAUDIO_8 ((__u32) 0x00000002)
137 #define SND_AUDIOMODE_REALAUDIO_10 ((__u32) 0x00000004)
138 #define SND_AUDIOMODE_REALAUDIO_SURROUND ((__u32) 0x00000008)
140 #define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
142 #define SND_AUDIOMODE_VORBIS ((__u32) 0x00000001)
144 #define SND_AUDIOPROFILE_FLAC ((__u32) 0x00000001)
147 * Define quality levels for FLAC encoders, from LEVEL0 (fast)
150 #define SND_AUDIOMODE_FLAC_LEVEL0 ((__u32) 0x00000001)
151 #define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
152 #define SND_AUDIOMODE_FLAC_LEVEL2 ((__u32) 0x00000004)
153 #define SND_AUDIOMODE_FLAC_LEVEL3 ((__u32) 0x00000008)
154 #define SND_AUDIOMODE_FLAC_LEVEL4 ((__u32) 0x00000010)
155 #define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
156 #define SND_AUDIOMODE_FLAC_LEVEL6 ((__u32) 0x00000040)
157 #define SND_AUDIOMODE_FLAC_LEVEL7 ((__u32) 0x00000080)
158 #define SND_AUDIOMODE_FLAC_LEVEL8 ((__u32) 0x00000100)
160 #define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
161 #define SND_AUDIOSTREAMFORMAT_FLAC_OGG ((__u32) 0x00000002)
163 /* IEC61937 payloads without CUVP and preambles */
164 #define SND_AUDIOPROFILE_IEC61937 ((__u32) 0x00000001)
165 /* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
166 #define SND_AUDIOPROFILE_IEC61937_SPDIF ((__u32) 0x00000002)
169 * IEC modes are mandatory for decoders. Format autodetection
170 * will only happen on the DSP side with mode 0. The PCM mode should
171 * not be used, the PCM codec should be used instead.
173 #define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
174 #define SND_AUDIOMODE_IEC_LPCM ((__u32) 0x00000001)
175 #define SND_AUDIOMODE_IEC_AC3 ((__u32) 0x00000002)
176 #define SND_AUDIOMODE_IEC_MPEG1 ((__u32) 0x00000004)
177 #define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
178 #define SND_AUDIOMODE_IEC_MPEG2 ((__u32) 0x00000010)
179 #define SND_AUDIOMODE_IEC_AACLC ((__u32) 0x00000020)
180 #define SND_AUDIOMODE_IEC_DTS ((__u32) 0x00000040)
181 #define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
182 #define SND_AUDIOMODE_IEC_SACD ((__u32) 0x00000100)
183 #define SND_AUDIOMODE_IEC_EAC3 ((__u32) 0x00000200)
184 #define SND_AUDIOMODE_IEC_DTS_HD ((__u32) 0x00000400)
185 #define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
186 #define SND_AUDIOMODE_IEC_DST ((__u32) 0x00001000)
187 #define SND_AUDIOMODE_IEC_WMAPRO ((__u32) 0x00002000)
188 #define SND_AUDIOMODE_IEC_REF_CXT ((__u32) 0x00004000)
189 #define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
190 #define SND_AUDIOMODE_IEC_HE_AAC2 ((__u32) 0x00010000)
191 #define SND_AUDIOMODE_IEC_MPEG_SURROUND ((__u32) 0x00020000)
193 #define SND_AUDIOPROFILE_G723_1 ((__u32) 0x00000001)
195 #define SND_AUDIOMODE_G723_1_ANNEX_A ((__u32) 0x00000001)
196 #define SND_AUDIOMODE_G723_1_ANNEX_B ((__u32) 0x00000002)
197 #define SND_AUDIOMODE_G723_1_ANNEX_C ((__u32) 0x00000004)
199 #define SND_AUDIOPROFILE_G729 ((__u32) 0x00000001)
201 #define SND_AUDIOMODE_G729_ANNEX_A ((__u32) 0x00000001)
202 #define SND_AUDIOMODE_G729_ANNEX_B ((__u32) 0x00000002)
204 /* <FIXME: multichannel encoders aren't supported for now. Would need
205 an additional definition of channel arrangement> */
207 /* VBR/CBR definitions */
208 #define SND_RATECONTROLMODE_CONSTANTBITRATE ((__u32) 0x00000001)
209 #define SND_RATECONTROLMODE_VARIABLEBITRATE ((__u32) 0x00000002)
211 /* Encoder options */
214 __u32 super_block_align; /* WMA Type-specific data */
219 * struct snd_enc_vorbis - Vorbis encoder parameters
220 * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
221 * In the default mode of operation, the quality level is 3.
222 * Normal quality range is 0 - 10.
223 * @managed: Boolean. Set bitrate management mode. This turns off the
224 * normal VBR encoding, but allows hard or soft bitrate constraints to be
225 * enforced by the encoder. This mode can be slower, and may also be
226 * lower quality. It is primarily useful for streaming.
227 * @max_bit_rate: Enabled only if managed is TRUE
228 * @min_bit_rate: Enabled only if managed is TRUE
229 * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
230 * non-stereo streams). Useful for lower-bitrate encoding.
232 * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
235 * For best quality users should specify VBR mode and set quality levels.
238 struct snd_enc_vorbis {
244 } __attribute__((packed, aligned(4)));
248 * struct snd_enc_real - RealAudio encoder parameters
249 * @quant_bits: number of coupling quantization bits in the stream
250 * @start_region: coupling start region in the stream
251 * @num_regions: number of regions value
253 * These options were extracted from the OpenMAX IL spec
256 struct snd_enc_real {
260 } __attribute__((packed, aligned(4)));
263 * struct snd_enc_flac - FLAC encoder parameters
264 * @num: serial number, valid only for OGG formats
265 * needs to be set by application
266 * @gain: Add replay gain tags
268 * These options were extracted from the FLAC online documentation
269 * at http://flac.sourceforge.net/documentation_tools_flac.html
271 * To make the API simpler, it is assumed that the user will select quality
272 * profiles. Additional options that affect encoding quality and speed can
273 * be added at a later stage if needed.
275 * By default the Subset format is used by encoders.
277 * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
278 * not supported in this API.
281 struct snd_enc_flac {
284 } __attribute__((packed, aligned(4)));
286 struct snd_enc_generic {
287 __u32 bw; /* encoder bandwidth */
288 __s32 reserved[15]; /* Can be used for SND_AUDIOCODEC_BESPOKE */
289 } __attribute__((packed, aligned(4)));
291 struct snd_dec_flac {
295 __u16 min_frame_size;
296 __u16 max_frame_size;
298 } __attribute__((packed, aligned(4)));
301 __u32 encoder_option;
302 __u32 adv_encoder_option;
303 __u32 adv_encoder_option2;
305 } __attribute__((packed, aligned(4)));
307 struct snd_dec_alac {
309 __u8 compatible_version;
314 __u32 max_frame_bytes;
315 } __attribute__((packed, aligned(4)));
318 __u16 compatible_version;
319 __u16 compression_level;
321 __u32 blocks_per_frame;
322 __u32 final_frame_blocks;
324 __u32 seek_table_present;
325 } __attribute__((packed, aligned(4)));
327 union snd_codec_options {
328 struct snd_enc_wma wma;
329 struct snd_enc_vorbis vorbis;
330 struct snd_enc_real real;
331 struct snd_enc_flac flac;
332 struct snd_enc_generic generic;
333 struct snd_dec_flac flac_d;
334 struct snd_dec_wma wma_d;
335 struct snd_dec_alac alac_d;
336 struct snd_dec_ape ape_d;
337 } __attribute__((packed, aligned(4)));
339 /** struct snd_codec_desc - description of codec capabilities
340 * @max_ch: Maximum number of audio channels
341 * @sample_rates: Sampling rates in Hz, use values like 48000 for this
342 * @num_sample_rates: Number of valid values in sample_rates array
343 * @bit_rate: Indexed array containing supported bit rates
344 * @num_bitrates: Number of valid values in bit_rate array
345 * @rate_control: value is specified by SND_RATECONTROLMODE defines.
346 * @profiles: Supported profiles. See SND_AUDIOPROFILE defines.
347 * @modes: Supported modes. See SND_AUDIOMODE defines
348 * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines
349 * @min_buffer: Minimum buffer size handled by codec implementation
350 * @reserved: reserved for future use
352 * This structure provides a scalar value for profiles, modes and stream
354 * If an implementation supports multiple combinations, they will be listed as
355 * codecs with different descriptors, for example there would be 2 descriptors
356 * for AAC-RAW and AAC-ADTS.
357 * This entails some redundancy but makes it easier to avoid invalid
362 struct snd_codec_desc {
364 __u32 sample_rates[MAX_NUM_SAMPLE_RATES];
365 __u32 num_sample_rates;
366 __u32 bit_rate[MAX_NUM_BITRATES];
374 } __attribute__((packed, aligned(4)));
377 * @id: Identifies the supported audio encoder/decoder.
378 * See SND_AUDIOCODEC macros.
379 * @ch_in: Number of input audio channels
380 * @ch_out: Number of output channels. In case of contradiction between
381 * this field and the channelMode field, the channelMode field
383 * @sample_rate: Audio sample rate of input data in Hz, use values like 48000
385 * @bit_rate: Bitrate of encoded data. May be ignored by decoders
386 * @rate_control: Encoding rate control. See SND_RATECONTROLMODE defines.
387 * Encoders may rely on profiles for quality levels.
388 * May be ignored by decoders.
389 * @profile: Mandatory for encoders, can be mandatory for specific
390 * decoders as well. See SND_AUDIOPROFILE defines.
391 * @level: Supported level (Only used by WMA at the moment)
392 * @ch_mode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
393 * @format: Format of encoded bistream. Mandatory when defined.
394 * See SND_AUDIOSTREAMFORMAT defines.
395 * @align: Block alignment in bytes of an audio sample.
396 * Only required for PCM or IEC formats.
397 * @options: encoder-specific settings
398 * @reserved: reserved for future use
413 union snd_codec_options options;
415 } __attribute__((packed, aligned(4)));