compress_params.h 17 KB

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