zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

compress_params.h (16460B) - Raw


      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 
     21 #include <linux/types.h>
     22 
     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
     28 
     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
     47 
     48 /*
     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)
     52  */
     53 
     54 #define SND_AUDIOPROFILE_PCM                 ((__u32) 0x00000001)
     55 
     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)
     61 
     62 #define SND_AUDIOPROFILE_AMR                 ((__u32) 0x00000001)
     63 
     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)
     68 
     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)
     76 
     77 #define SND_AUDIOPROFILE_AMRWB               ((__u32) 0x00000001)
     78 
     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)
     83 
     84 #define SND_AUDIOPROFILE_AMRWBPLUS           ((__u32) 0x00000001)
     85 
     86 #define SND_AUDIOPROFILE_AAC                 ((__u32) 0x00000001)
     87 
     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)
     99 
    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)
    108 
    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)
    116 
    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)
    125 
    126 #define SND_AUDIOSTREAMFORMAT_WMA_ASF        ((__u32) 0x00000001)
    127 /*
    128  * Some implementations strip the ASF header and only send ASF packets
    129  * to the DSP
    130  */
    131 #define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR  ((__u32) 0x00000002)
    132 
    133 #define SND_AUDIOPROFILE_REALAUDIO           ((__u32) 0x00000001)
    134 
    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)
    139 
    140 #define SND_AUDIOPROFILE_VORBIS              ((__u32) 0x00000001)
    141 
    142 #define SND_AUDIOMODE_VORBIS                 ((__u32) 0x00000001)
    143 
    144 #define SND_AUDIOPROFILE_FLAC                ((__u32) 0x00000001)
    145 
    146 /*
    147  * Define quality levels for FLAC encoders, from LEVEL0 (fast)
    148  * to LEVEL8 (best)
    149  */
    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)
    159 
    160 #define SND_AUDIOSTREAMFORMAT_FLAC           ((__u32) 0x00000001)
    161 #define SND_AUDIOSTREAMFORMAT_FLAC_OGG       ((__u32) 0x00000002)
    162 
    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)
    167 
    168 /*
    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.
    172  */
    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)
    192 
    193 #define SND_AUDIOPROFILE_G723_1              ((__u32) 0x00000001)
    194 
    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 
    199 #define SND_AUDIOPROFILE_G729                ((__u32) 0x00000001)
    200 
    201 #define SND_AUDIOMODE_G729_ANNEX_A           ((__u32) 0x00000001)
    202 #define SND_AUDIOMODE_G729_ANNEX_B           ((__u32) 0x00000002)
    203 
    204 /* <FIXME: multichannel encoders aren't supported for now. Would need
    205    an additional definition of channel arrangement> */
    206 
    207 /* VBR/CBR definitions */
    208 #define SND_RATECONTROLMODE_CONSTANTBITRATE  ((__u32) 0x00000001)
    209 #define SND_RATECONTROLMODE_VARIABLEBITRATE  ((__u32) 0x00000002)
    210 
    211 /* Encoder options */
    212 
    213 struct snd_enc_wma {
    214 	__u32 super_block_align; /* WMA Type-specific data */
    215 };
    216 
    217 
    218 /**
    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.
    231  *
    232  * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
    233  * properties
    234  *
    235  * For best quality users should specify VBR mode and set quality levels.
    236  */
    237 
    238 struct snd_enc_vorbis {
    239 	__s32 quality;
    240 	__u32 managed;
    241 	__u32 max_bit_rate;
    242 	__u32 min_bit_rate;
    243 	__u32 downmix;
    244 } __attribute__((packed, aligned(4)));
    245 
    246 
    247 /**
    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
    252  *
    253  * These options were extracted from the OpenMAX IL spec
    254  */
    255 
    256 struct snd_enc_real {
    257 	__u32 quant_bits;
    258 	__u32 start_region;
    259 	__u32 num_regions;
    260 } __attribute__((packed, aligned(4)));
    261 
    262 /**
    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
    267  *
    268  * These options were extracted from the FLAC online documentation
    269  * at http://flac.sourceforge.net/documentation_tools_flac.html
    270  *
    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.
    274  *
    275  * By default the Subset format is used by encoders.
    276  *
    277  * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
    278  * not supported in this API.
    279  */
    280 
    281 struct snd_enc_flac {
    282 	__u32 num;
    283 	__u32 gain;
    284 } __attribute__((packed, aligned(4)));
    285 
    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)));
    290 
    291 struct snd_dec_flac {
    292 	__u16 sample_size;
    293 	__u16 min_blk_size;
    294 	__u16 max_blk_size;
    295 	__u16 min_frame_size;
    296 	__u16 max_frame_size;
    297 	__u16 reserved;
    298 } __attribute__((packed, aligned(4)));
    299 
    300 struct snd_dec_wma {
    301 	__u32 encoder_option;
    302 	__u32 adv_encoder_option;
    303 	__u32 adv_encoder_option2;
    304 	__u32 reserved;
    305 } __attribute__((packed, aligned(4)));
    306 
    307 struct snd_dec_alac {
    308 	__u32 frame_length;
    309 	__u8 compatible_version;
    310 	__u8 pb;
    311 	__u8 mb;
    312 	__u8 kb;
    313 	__u32 max_run;
    314 	__u32 max_frame_bytes;
    315 } __attribute__((packed, aligned(4)));
    316 
    317 struct snd_dec_ape {
    318 	__u16 compatible_version;
    319 	__u16 compression_level;
    320 	__u32 format_flags;
    321 	__u32 blocks_per_frame;
    322 	__u32 final_frame_blocks;
    323 	__u32 total_frames;
    324 	__u32 seek_table_present;
    325 } __attribute__((packed, aligned(4)));
    326 
    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)));
    338 
    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
    351  *
    352  * This structure provides a scalar value for profiles, modes and stream
    353  * format fields.
    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
    358  * configurations.
    359  *
    360  */
    361 
    362 struct snd_codec_desc {
    363 	__u32 max_ch;
    364 	__u32 sample_rates[MAX_NUM_SAMPLE_RATES];
    365 	__u32 num_sample_rates;
    366 	__u32 bit_rate[MAX_NUM_BITRATES];
    367 	__u32 num_bitrates;
    368 	__u32 rate_control;
    369 	__u32 profiles;
    370 	__u32 modes;
    371 	__u32 formats;
    372 	__u32 min_buffer;
    373 	__u32 reserved[15];
    374 } __attribute__((packed, aligned(4)));
    375 
    376 /** struct snd_codec
    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
    382  *		overrides.
    383  * @sample_rate: Audio sample rate of input data in Hz, use values like 48000
    384  *		for this.
    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
    399  */
    400 
    401 struct snd_codec {
    402 	__u32 id;
    403 	__u32 ch_in;
    404 	__u32 ch_out;
    405 	__u32 sample_rate;
    406 	__u32 bit_rate;
    407 	__u32 rate_control;
    408 	__u32 profile;
    409 	__u32 level;
    410 	__u32 ch_mode;
    411 	__u32 format;
    412 	__u32 align;
    413 	union snd_codec_options options;
    414 	__u32 reserved[3];
    415 } __attribute__((packed, aligned(4)));
    416 
    417 #endif