compress_params.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. * 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.
  15. *
  16. * Copyright (c) 2007-2010 The Khronos Group Inc.
  17. */
  18. #ifndef __SND_COMPRESS_PARAMS_H
  19. #define __SND_COMPRESS_PARAMS_H
  20. #include <linux/types.h>
  21. /* AUDIO CODECS SUPPORTED */
  22. #define MAX_NUM_CODECS 32
  23. #define MAX_NUM_CODEC_DESCRIPTORS 32
  24. #define MAX_NUM_BITRATES 32
  25. #define MAX_NUM_SAMPLE_RATES 32
  26. /* Codecs are listed linearly to allow for extensibility */
  27. #define SND_AUDIOCODEC_PCM ((__u32) 0x00000001)
  28. #define SND_AUDIOCODEC_MP3 ((__u32) 0x00000002)
  29. #define SND_AUDIOCODEC_AMR ((__u32) 0x00000003)
  30. #define SND_AUDIOCODEC_AMRWB ((__u32) 0x00000004)
  31. #define SND_AUDIOCODEC_AMRWBPLUS ((__u32) 0x00000005)
  32. #define SND_AUDIOCODEC_AAC ((__u32) 0x00000006)
  33. #define SND_AUDIOCODEC_WMA ((__u32) 0x00000007)
  34. #define SND_AUDIOCODEC_REAL ((__u32) 0x00000008)
  35. #define SND_AUDIOCODEC_VORBIS ((__u32) 0x00000009)
  36. #define SND_AUDIOCODEC_FLAC ((__u32) 0x0000000A)
  37. #define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B)
  38. #define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
  39. #define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
  40. #define SND_AUDIOCODEC_BESPOKE ((__u32) 0x0000000E)
  41. #define SND_AUDIOCODEC_ALAC ((__u32) 0x0000000F)
  42. #define SND_AUDIOCODEC_APE ((__u32) 0x00000010)
  43. #define SND_AUDIOCODEC_MAX SND_AUDIOCODEC_APE
  44. /*
  45. * Profile and modes are listed with bit masks. This allows for a
  46. * more compact representation of fields that will not evolve
  47. * (in contrast to the list of codecs)
  48. */
  49. #define SND_AUDIOPROFILE_PCM ((__u32) 0x00000001)
  50. /* MP3 modes are only useful for encoders */
  51. #define SND_AUDIOCHANMODE_MP3_MONO ((__u32) 0x00000001)
  52. #define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
  53. #define SND_AUDIOCHANMODE_MP3_JOINTSTEREO ((__u32) 0x00000004)
  54. #define SND_AUDIOCHANMODE_MP3_DUAL ((__u32) 0x00000008)
  55. #define SND_AUDIOPROFILE_AMR ((__u32) 0x00000001)
  56. /* AMR modes are only useful for encoders */
  57. #define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
  58. #define SND_AUDIOMODE_AMR_VAD1 ((__u32) 0x00000002)
  59. #define SND_AUDIOMODE_AMR_VAD2 ((__u32) 0x00000004)
  60. #define SND_AUDIOSTREAMFORMAT_UNDEFINED ((__u32) 0x00000000)
  61. #define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
  62. #define SND_AUDIOSTREAMFORMAT_IF1 ((__u32) 0x00000002)
  63. #define SND_AUDIOSTREAMFORMAT_IF2 ((__u32) 0x00000004)
  64. #define SND_AUDIOSTREAMFORMAT_FSF ((__u32) 0x00000008)
  65. #define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
  66. #define SND_AUDIOSTREAMFORMAT_ITU ((__u32) 0x00000020)
  67. #define SND_AUDIOPROFILE_AMRWB ((__u32) 0x00000001)
  68. /* AMRWB modes are only useful for encoders */
  69. #define SND_AUDIOMODE_AMRWB_DTX_OFF ((__u32) 0x00000001)
  70. #define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
  71. #define SND_AUDIOMODE_AMRWB_VAD2 ((__u32) 0x00000004)
  72. #define SND_AUDIOPROFILE_AMRWBPLUS ((__u32) 0x00000001)
  73. #define SND_AUDIOPROFILE_AAC ((__u32) 0x00000001)
  74. /* AAC modes are required for encoders and decoders */
  75. #define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
  76. #define SND_AUDIOMODE_AAC_LC ((__u32) 0x00000002)
  77. #define SND_AUDIOMODE_AAC_SSR ((__u32) 0x00000004)
  78. #define SND_AUDIOMODE_AAC_LTP ((__u32) 0x00000008)
  79. #define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
  80. #define SND_AUDIOMODE_AAC_SCALABLE ((__u32) 0x00000020)
  81. #define SND_AUDIOMODE_AAC_ERLC ((__u32) 0x00000040)
  82. #define SND_AUDIOMODE_AAC_LD ((__u32) 0x00000080)
  83. #define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
  84. #define SND_AUDIOMODE_AAC_HE_MPS ((__u32) 0x00000200)
  85. /* AAC formats are required for encoders and decoders */
  86. #define SND_AUDIOSTREAMFORMAT_MP2ADTS ((__u32) 0x00000001)
  87. #define SND_AUDIOSTREAMFORMAT_MP4ADTS ((__u32) 0x00000002)
  88. #define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
  89. #define SND_AUDIOSTREAMFORMAT_MP4LATM ((__u32) 0x00000008)
  90. #define SND_AUDIOSTREAMFORMAT_ADIF ((__u32) 0x00000010)
  91. #define SND_AUDIOSTREAMFORMAT_MP4FF ((__u32) 0x00000020)
  92. #define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
  93. #define SND_AUDIOPROFILE_WMA7 ((__u32) 0x00000001)
  94. #define SND_AUDIOPROFILE_WMA8 ((__u32) 0x00000002)
  95. #define SND_AUDIOPROFILE_WMA9 ((__u32) 0x00000004)
  96. #define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
  97. #define SND_AUDIOPROFILE_WMA9_PRO ((__u32) 0x00000010)
  98. #define SND_AUDIOPROFILE_WMA9_LOSSLESS ((__u32) 0x00000020)
  99. #define SND_AUDIOPROFILE_WMA10_LOSSLESS ((__u32) 0x00000040)
  100. #define SND_AUDIOMODE_WMA_LEVEL1 ((__u32) 0x00000001)
  101. #define SND_AUDIOMODE_WMA_LEVEL2 ((__u32) 0x00000002)
  102. #define SND_AUDIOMODE_WMA_LEVEL3 ((__u32) 0x00000004)
  103. #define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
  104. #define SND_AUDIOMODE_WMAPRO_LEVELM0 ((__u32) 0x00000010)
  105. #define SND_AUDIOMODE_WMAPRO_LEVELM1 ((__u32) 0x00000020)
  106. #define SND_AUDIOMODE_WMAPRO_LEVELM2 ((__u32) 0x00000040)
  107. #define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
  108. #define SND_AUDIOSTREAMFORMAT_WMA_ASF ((__u32) 0x00000001)
  109. /*
  110. * Some implementations strip the ASF header and only send ASF packets
  111. * to the DSP
  112. */
  113. #define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR ((__u32) 0x00000002)
  114. #define SND_AUDIOPROFILE_REALAUDIO ((__u32) 0x00000001)
  115. #define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
  116. #define SND_AUDIOMODE_REALAUDIO_8 ((__u32) 0x00000002)
  117. #define SND_AUDIOMODE_REALAUDIO_10 ((__u32) 0x00000004)
  118. #define SND_AUDIOMODE_REALAUDIO_SURROUND ((__u32) 0x00000008)
  119. #define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
  120. #define SND_AUDIOMODE_VORBIS ((__u32) 0x00000001)
  121. #define SND_AUDIOPROFILE_FLAC ((__u32) 0x00000001)
  122. /*
  123. * Define quality levels for FLAC encoders, from LEVEL0 (fast)
  124. * to LEVEL8 (best)
  125. */
  126. #define SND_AUDIOMODE_FLAC_LEVEL0 ((__u32) 0x00000001)
  127. #define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
  128. #define SND_AUDIOMODE_FLAC_LEVEL2 ((__u32) 0x00000004)
  129. #define SND_AUDIOMODE_FLAC_LEVEL3 ((__u32) 0x00000008)
  130. #define SND_AUDIOMODE_FLAC_LEVEL4 ((__u32) 0x00000010)
  131. #define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
  132. #define SND_AUDIOMODE_FLAC_LEVEL6 ((__u32) 0x00000040)
  133. #define SND_AUDIOMODE_FLAC_LEVEL7 ((__u32) 0x00000080)
  134. #define SND_AUDIOMODE_FLAC_LEVEL8 ((__u32) 0x00000100)
  135. #define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
  136. #define SND_AUDIOSTREAMFORMAT_FLAC_OGG ((__u32) 0x00000002)
  137. /* IEC61937 payloads without CUVP and preambles */
  138. #define SND_AUDIOPROFILE_IEC61937 ((__u32) 0x00000001)
  139. /* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
  140. #define SND_AUDIOPROFILE_IEC61937_SPDIF ((__u32) 0x00000002)
  141. /*
  142. * IEC modes are mandatory for decoders. Format autodetection
  143. * will only happen on the DSP side with mode 0. The PCM mode should
  144. * not be used, the PCM codec should be used instead.
  145. */
  146. #define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
  147. #define SND_AUDIOMODE_IEC_LPCM ((__u32) 0x00000001)
  148. #define SND_AUDIOMODE_IEC_AC3 ((__u32) 0x00000002)
  149. #define SND_AUDIOMODE_IEC_MPEG1 ((__u32) 0x00000004)
  150. #define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
  151. #define SND_AUDIOMODE_IEC_MPEG2 ((__u32) 0x00000010)
  152. #define SND_AUDIOMODE_IEC_AACLC ((__u32) 0x00000020)
  153. #define SND_AUDIOMODE_IEC_DTS ((__u32) 0x00000040)
  154. #define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
  155. #define SND_AUDIOMODE_IEC_SACD ((__u32) 0x00000100)
  156. #define SND_AUDIOMODE_IEC_EAC3 ((__u32) 0x00000200)
  157. #define SND_AUDIOMODE_IEC_DTS_HD ((__u32) 0x00000400)
  158. #define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
  159. #define SND_AUDIOMODE_IEC_DST ((__u32) 0x00001000)
  160. #define SND_AUDIOMODE_IEC_WMAPRO ((__u32) 0x00002000)
  161. #define SND_AUDIOMODE_IEC_REF_CXT ((__u32) 0x00004000)
  162. #define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
  163. #define SND_AUDIOMODE_IEC_HE_AAC2 ((__u32) 0x00010000)
  164. #define SND_AUDIOMODE_IEC_MPEG_SURROUND ((__u32) 0x00020000)
  165. #define SND_AUDIOPROFILE_G723_1 ((__u32) 0x00000001)
  166. #define SND_AUDIOMODE_G723_1_ANNEX_A ((__u32) 0x00000001)
  167. #define SND_AUDIOMODE_G723_1_ANNEX_B ((__u32) 0x00000002)
  168. #define SND_AUDIOMODE_G723_1_ANNEX_C ((__u32) 0x00000004)
  169. #define SND_AUDIOPROFILE_G729 ((__u32) 0x00000001)
  170. #define SND_AUDIOMODE_G729_ANNEX_A ((__u32) 0x00000001)
  171. #define SND_AUDIOMODE_G729_ANNEX_B ((__u32) 0x00000002)
  172. /* <FIXME: multichannel encoders aren't supported for now. Would need
  173. an additional definition of channel arrangement> */
  174. /* VBR/CBR definitions */
  175. #define SND_RATECONTROLMODE_CONSTANTBITRATE ((__u32) 0x00000001)
  176. #define SND_RATECONTROLMODE_VARIABLEBITRATE ((__u32) 0x00000002)
  177. /* Encoder options */
  178. struct snd_enc_wma {
  179. __u32 super_block_align; /* WMA Type-specific data */
  180. };
  181. /**
  182. * struct snd_enc_vorbis - Vorbis encoder parameters
  183. * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
  184. * In the default mode of operation, the quality level is 3.
  185. * Normal quality range is 0 - 10.
  186. * @managed: Boolean. Set bitrate management mode. This turns off the
  187. * normal VBR encoding, but allows hard or soft bitrate constraints to be
  188. * enforced by the encoder. This mode can be slower, and may also be
  189. * lower quality. It is primarily useful for streaming.
  190. * @max_bit_rate: Enabled only if managed is TRUE
  191. * @min_bit_rate: Enabled only if managed is TRUE
  192. * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
  193. * non-stereo streams). Useful for lower-bitrate encoding.
  194. *
  195. * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
  196. * properties
  197. *
  198. * For best quality users should specify VBR mode and set quality levels.
  199. */
  200. struct snd_enc_vorbis {
  201. __s32 quality;
  202. __u32 managed;
  203. __u32 max_bit_rate;
  204. __u32 min_bit_rate;
  205. __u32 downmix;
  206. } __attribute__((packed, aligned(4)));
  207. /**
  208. * struct snd_enc_real - RealAudio encoder parameters
  209. * @quant_bits: number of coupling quantization bits in the stream
  210. * @start_region: coupling start region in the stream
  211. * @num_regions: number of regions value
  212. *
  213. * These options were extracted from the OpenMAX IL spec
  214. */
  215. struct snd_enc_real {
  216. __u32 quant_bits;
  217. __u32 start_region;
  218. __u32 num_regions;
  219. } __attribute__((packed, aligned(4)));
  220. /**
  221. * struct snd_enc_flac - FLAC encoder parameters
  222. * @num: serial number, valid only for OGG formats
  223. * needs to be set by application
  224. * @gain: Add replay gain tags
  225. *
  226. * These options were extracted from the FLAC online documentation
  227. * at http://flac.sourceforge.net/documentation_tools_flac.html
  228. *
  229. * To make the API simpler, it is assumed that the user will select quality
  230. * profiles. Additional options that affect encoding quality and speed can
  231. * be added at a later stage if needed.
  232. *
  233. * By default the Subset format is used by encoders.
  234. *
  235. * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
  236. * not supported in this API.
  237. */
  238. struct snd_enc_flac {
  239. __u32 num;
  240. __u32 gain;
  241. } __attribute__((packed, aligned(4)));
  242. struct snd_enc_generic {
  243. __u32 bw; /* encoder bandwidth */
  244. __s32 reserved[15]; /* Can be used for SND_AUDIOCODEC_BESPOKE */
  245. } __attribute__((packed, aligned(4)));
  246. struct snd_dec_flac {
  247. __u16 sample_size;
  248. __u16 min_blk_size;
  249. __u16 max_blk_size;
  250. __u16 min_frame_size;
  251. __u16 max_frame_size;
  252. __u16 reserved;
  253. } __attribute__((packed, aligned(4)));
  254. struct snd_dec_wma {
  255. __u32 encoder_option;
  256. __u32 adv_encoder_option;
  257. __u32 adv_encoder_option2;
  258. __u32 reserved;
  259. } __attribute__((packed, aligned(4)));
  260. struct snd_dec_alac {
  261. __u32 frame_length;
  262. __u8 compatible_version;
  263. __u8 pb;
  264. __u8 mb;
  265. __u8 kb;
  266. __u32 max_run;
  267. __u32 max_frame_bytes;
  268. } __attribute__((packed, aligned(4)));
  269. struct snd_dec_ape {
  270. __u16 compatible_version;
  271. __u16 compression_level;
  272. __u32 format_flags;
  273. __u32 blocks_per_frame;
  274. __u32 final_frame_blocks;
  275. __u32 total_frames;
  276. __u32 seek_table_present;
  277. } __attribute__((packed, aligned(4)));
  278. union snd_codec_options {
  279. struct snd_enc_wma wma;
  280. struct snd_enc_vorbis vorbis;
  281. struct snd_enc_real real;
  282. struct snd_enc_flac flac;
  283. struct snd_enc_generic generic;
  284. struct snd_dec_flac flac_d;
  285. struct snd_dec_wma wma_d;
  286. struct snd_dec_alac alac_d;
  287. struct snd_dec_ape ape_d;
  288. } __attribute__((packed, aligned(4)));
  289. /** struct snd_codec_desc - description of codec capabilities
  290. * @max_ch: Maximum number of audio channels
  291. * @sample_rates: Sampling rates in Hz, use values like 48000 for this
  292. * @num_sample_rates: Number of valid values in sample_rates array
  293. * @bit_rate: Indexed array containing supported bit rates
  294. * @num_bitrates: Number of valid values in bit_rate array
  295. * @rate_control: value is specified by SND_RATECONTROLMODE defines.
  296. * @profiles: Supported profiles. See SND_AUDIOPROFILE defines.
  297. * @modes: Supported modes. See SND_AUDIOMODE defines
  298. * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines
  299. * @min_buffer: Minimum buffer size handled by codec implementation
  300. * @reserved: reserved for future use
  301. *
  302. * This structure provides a scalar value for profiles, modes and stream
  303. * format fields.
  304. * If an implementation supports multiple combinations, they will be listed as
  305. * codecs with different descriptors, for example there would be 2 descriptors
  306. * for AAC-RAW and AAC-ADTS.
  307. * This entails some redundancy but makes it easier to avoid invalid
  308. * configurations.
  309. *
  310. */
  311. struct snd_codec_desc {
  312. __u32 max_ch;
  313. __u32 sample_rates[MAX_NUM_SAMPLE_RATES];
  314. __u32 num_sample_rates;
  315. __u32 bit_rate[MAX_NUM_BITRATES];
  316. __u32 num_bitrates;
  317. __u32 rate_control;
  318. __u32 profiles;
  319. __u32 modes;
  320. __u32 formats;
  321. __u32 min_buffer;
  322. __u32 reserved[15];
  323. } __attribute__((packed, aligned(4)));
  324. /** struct snd_codec
  325. * @id: Identifies the supported audio encoder/decoder.
  326. * See SND_AUDIOCODEC macros.
  327. * @ch_in: Number of input audio channels
  328. * @ch_out: Number of output channels. In case of contradiction between
  329. * this field and the channelMode field, the channelMode field
  330. * overrides.
  331. * @sample_rate: Audio sample rate of input data in Hz, use values like 48000
  332. * for this.
  333. * @bit_rate: Bitrate of encoded data. May be ignored by decoders
  334. * @rate_control: Encoding rate control. See SND_RATECONTROLMODE defines.
  335. * Encoders may rely on profiles for quality levels.
  336. * May be ignored by decoders.
  337. * @profile: Mandatory for encoders, can be mandatory for specific
  338. * decoders as well. See SND_AUDIOPROFILE defines.
  339. * @level: Supported level (Only used by WMA at the moment)
  340. * @ch_mode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
  341. * @format: Format of encoded bistream. Mandatory when defined.
  342. * See SND_AUDIOSTREAMFORMAT defines.
  343. * @align: Block alignment in bytes of an audio sample.
  344. * Only required for PCM or IEC formats.
  345. * @options: encoder-specific settings
  346. * @reserved: reserved for future use
  347. */
  348. struct snd_codec {
  349. __u32 id;
  350. __u32 ch_in;
  351. __u32 ch_out;
  352. __u32 sample_rate;
  353. __u32 bit_rate;
  354. __u32 rate_control;
  355. __u32 profile;
  356. __u32 level;
  357. __u32 ch_mode;
  358. __u32 format;
  359. __u32 align;
  360. union snd_codec_options options;
  361. __u32 reserved[3];
  362. } __attribute__((packed, aligned(4)));
  363. #endif