| opus.h | | opus.h | |
|
| /* Copyright (c) 2010-2012 IETF Trust, Xiph.Org Foundation, Skype Limited.
All rights reserved. | | /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited | |
| Written by Jean-Marc Valin and Koen Vos */ | | Written by Jean-Marc Valin and Koen Vos */ | |
| /* | | /* | |
|
| | | | |
| This file is extracted from RFC6716. Please see that RFC for additional | | | |
| information. | | | |
| | | | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions | | modification, are permitted provided that the following conditions | |
| are met: | | are met: | |
| | | | |
| - Redistributions of source code must retain the above copyright | | - Redistributions of source code must retain the above copyright | |
| notice, this list of conditions and the following disclaimer. | | notice, this list of conditions and the following disclaimer. | |
| | | | |
| - Redistributions in binary form must reproduce the above copyright | | - Redistributions in binary form must reproduce the above copyright | |
| notice, this list of conditions and the following disclaimer in the | | notice, this list of conditions and the following disclaimer in the | |
| documentation and/or other materials provided with the distribution. | | documentation and/or other materials provided with the distribution. | |
| | | | |
|
| - Neither the name of Internet Society, IETF or IETF Trust, nor the | | | |
| names of specific contributors, may be used to endorse or promote | | | |
| products derived from this software without specific prior written | | | |
| permission. | | | |
| | | | |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWN
ER | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWN
ER | |
| OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| | | | |
| skipping to change at line 65 | | skipping to change at line 56 | |
| * The Opus codec is designed for interactive speech and audio transmission
over the Internet. | | * The Opus codec is designed for interactive speech and audio transmission
over the Internet. | |
| * It is designed by the IETF Codec Working Group and incorporates technolo
gy from | | * It is designed by the IETF Codec Working Group and incorporates technolo
gy from | |
| * Skype's SILK codec and Xiph.Org's CELT codec. | | * Skype's SILK codec and Xiph.Org's CELT codec. | |
| * | | * | |
| * The Opus codec is designed to handle a wide range of interactive audio a
pplications, | | * The Opus codec is designed to handle a wide range of interactive audio a
pplications, | |
| * including Voice over IP, videoconferencing, in-game chat, and even remot
e live music | | * including Voice over IP, videoconferencing, in-game chat, and even remot
e live music | |
| * performances. It can scale from low bit-rate narrowband speech to very h
igh quality | | * performances. It can scale from low bit-rate narrowband speech to very h
igh quality | |
| * stereo music. Its main features are: | | * stereo music. Its main features are: | |
| | | | |
| * @li Sampling rates from 8 to 48 kHz | | * @li Sampling rates from 8 to 48 kHz | |
|
| * @li Bit-rates from 6 kb/s 510 kb/s | | * @li Bit-rates from 6 kb/s to 510 kb/s | |
| * @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) | | * @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) | |
| * @li Audio bandwidth from narrowband to full-band | | * @li Audio bandwidth from narrowband to full-band | |
| * @li Support for speech and music | | * @li Support for speech and music | |
| * @li Support for mono and stereo | | * @li Support for mono and stereo | |
|
| | | * @li Support for multichannel (up to 255 channels) | |
| * @li Frame sizes from 2.5 ms to 60 ms | | * @li Frame sizes from 2.5 ms to 60 ms | |
| * @li Good loss robustness and packet loss concealment (PLC) | | * @li Good loss robustness and packet loss concealment (PLC) | |
| * @li Floating point and fixed-point implementation | | * @li Floating point and fixed-point implementation | |
| * | | * | |
| * Documentation sections: | | * Documentation sections: | |
|
| * @li @ref opusencoder | | * @li @ref opus_encoder | |
| * @li @ref opusdecoder | | * @li @ref opus_decoder | |
| * @li @ref repacketizer | | * @li @ref opus_repacketizer | |
| * @li @ref libinfo | | * @li @ref opus_libinfo | |
| | | * @li @ref opus_custom | |
| */ | | */ | |
| | | | |
|
| /** @defgroup opusencoder Opus Encoder | | /** @defgroup opus_encoder Opus Encoder | |
| * @{ | | * @{ | |
| * | | * | |
|
| | | * @brief This page describes the process and functions used to encode Opu | |
| | | s. | |
| | | * | |
| * Since Opus is a stateful codec, the encoding process starts with creati
ng an encoder | | * Since Opus is a stateful codec, the encoding process starts with creati
ng an encoder | |
| * state. This can be done with: | | * state. This can be done with: | |
| * | | * | |
| * @code | | * @code | |
| * int error; | | * int error; | |
| * OpusEncoder *enc; | | * OpusEncoder *enc; | |
| * enc = opus_encoder_create(Fs, channels, application, &error); | | * enc = opus_encoder_create(Fs, channels, application, &error); | |
| * @endcode | | * @endcode | |
| * | | * | |
| * From this point, @c enc can be used for encoding an audio stream. An en
coder state | | * From this point, @c enc can be used for encoding an audio stream. An en
coder state | |
| | | | |
| skipping to change at line 131 | | skipping to change at line 126 | |
| * opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); | | * opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); | |
| * opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); | | * opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); | |
| * @endcode | | * @endcode | |
| * | | * | |
| * where | | * where | |
| * | | * | |
| * @arg bitrate is in bits per second (b/s) | | * @arg bitrate is in bits per second (b/s) | |
| * @arg complexity is a value from 1 to 10, where 1 is the lowest complexi
ty and 10 is the highest | | * @arg complexity is a value from 1 to 10, where 1 is the lowest complexi
ty and 10 is the highest | |
| * @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or O
PUS_SIGNAL_MUSIC | | * @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or O
PUS_SIGNAL_MUSIC | |
| * | | * | |
|
| * See @ref encoderctls and @ref genericctls for a complete list of parame
ters that can be set or queried. Most parameters can be set or changed at a
ny time during a stream. | | * See @ref opus_encoderctls and @ref opus_genericctls for a complete list
of parameters that can be set or queried. Most parameters can be set or ch
anged at any time during a stream. | |
| * | | * | |
| * To encode a frame, opus_encode() or opus_encode_float() must be called
with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: | | * To encode a frame, opus_encode() or opus_encode_float() must be called
with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: | |
| * @code | | * @code | |
| * len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); | | * len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); | |
| * @endcode | | * @endcode | |
| * | | * | |
| * where | | * where | |
| * <ul> | | * <ul> | |
| * <li>audio_frame is the audio data in opus_int16 (or float for opus_enco
de_float())</li> | | * <li>audio_frame is the audio data in opus_int16 (or float for opus_enco
de_float())</li> | |
| * <li>frame_size is the duration of the frame in samples (per channel)</l
i> | | * <li>frame_size is the duration of the frame in samples (per channel)</l
i> | |
| * <li>packet is the byte array to which the compressed data is written</l
i> | | * <li>packet is the byte array to which the compressed data is written</l
i> | |
|
| * <li>max_packet is the maximum number of bytes that can be written in th
e packet (1276 bytes is recommended)</li> | | * <li>max_packet is the maximum number of bytes that can be written in th
e packet (4000 bytes is recommended)</li> | |
| * </ul> | | * </ul> | |
| * | | * | |
| * opus_encode() and opus_encode_frame() return the number of bytes actual
ly written to the packet. | | * opus_encode() and opus_encode_frame() return the number of bytes actual
ly written to the packet. | |
| * The return value <b>can be negative</b>, which indicates that an error
has occurred. If the return value | | * The return value <b>can be negative</b>, which indicates that an error
has occurred. If the return value | |
| * is 1 byte, then the packet does not need to be transmitted (DTX). | | * is 1 byte, then the packet does not need to be transmitted (DTX). | |
| * | | * | |
| * Once the encoder state if no longer needed, it can be destroyed with | | * Once the encoder state if no longer needed, it can be destroyed with | |
| * | | * | |
| * @code | | * @code | |
| * opus_encoder_destroy(enc); | | * opus_encoder_destroy(enc); | |
| | | | |
| skipping to change at line 169 | | skipping to change at line 164 | |
| * | | * | |
| */ | | */ | |
| | | | |
| /** Opus encoder state. | | /** Opus encoder state. | |
| * This contains the complete state of an Opus encoder. | | * This contains the complete state of an Opus encoder. | |
| * It is position independent and can be freely copied. | | * It is position independent and can be freely copied. | |
| * @see opus_encoder_create,opus_encoder_init | | * @see opus_encoder_create,opus_encoder_init | |
| */ | | */ | |
| typedef struct OpusEncoder OpusEncoder; | | typedef struct OpusEncoder OpusEncoder; | |
| | | | |
|
| OPUS_EXPORT int opus_encoder_get_size(int channels); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels)
; | |
| | | | |
| /** | | /** | |
| */ | | */ | |
| | | | |
| /** Allocates and initializes an encoder state. | | /** Allocates and initializes an encoder state. | |
| * There are three coding modes: | | * There are three coding modes: | |
| * | | * | |
| * @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voi
ce | | * @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voi
ce | |
| * signals. It enhances the input signal by high-pass filtering and | | * signals. It enhances the input signal by high-pass filtering and | |
| * emphasizing formants and harmonics. Optionally it includes in-band | | * emphasizing formants and harmonics. Optionally it includes in-band | |
| | | | |
| skipping to change at line 191 | | skipping to change at line 186 | |
| * mode for typical VoIP applications. Because of the enhancement, | | * mode for typical VoIP applications. Because of the enhancement, | |
| * even at high bitrates the output may sound different from the input. | | * even at high bitrates the output may sound different from the input. | |
| * | | * | |
| * @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for mo
st | | * @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for mo
st | |
| * non-voice signals like music. Use this mode for music and mixed | | * non-voice signals like music. Use this mode for music and mixed | |
| * (music/voice) content, broadcast, and applications requiring less | | * (music/voice) content, broadcast, and applications requiring less | |
| * than 15 ms of coding delay. | | * than 15 ms of coding delay. | |
| * | | * | |
| * @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that | | * @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that | |
| * disables the speech-optimized mode in exchange for slightly reduced d
elay. | | * disables the speech-optimized mode in exchange for slightly reduced d
elay. | |
|
| | | * This mode can only be set on an newly initialized or freshly reset en | |
| | | coder | |
| | | * because it changes the codec delay. | |
| * | | * | |
| * This is useful when the caller knows that the speech-optimized modes wil
l not be needed (use with caution). | | * This is useful when the caller knows that the speech-optimized modes wil
l not be needed (use with caution). | |
| * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) | |
| * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input sig
nal | | * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input sig
nal | |
| * @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION
_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY
) | | * @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION
_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY
) | |
|
| * @param [out] error <tt>int*</tt>: @ref errorcodes | | * @param [out] error <tt>int*</tt>: @ref opus_errorcodes | |
| * @note Regardless of the sampling rate and number channels selected, the
Opus encoder | | * @note Regardless of the sampling rate and number channels selected, the
Opus encoder | |
| * can switch to a lower audio audio bandwidth or number of channels if the
bitrate | | * can switch to a lower audio audio bandwidth or number of channels if the
bitrate | |
| * selected is too low. This also means that it is safe to always use 48 kH
z stereo input | | * selected is too low. This also means that it is safe to always use 48 kH
z stereo input | |
| * and let the encoder optimize the encoding. | | * and let the encoder optimize the encoding. | |
| */ | | */ | |
|
| OPUS_EXPORT OpusEncoder *opus_encoder_create( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( | |
| opus_int32 Fs, | | opus_int32 Fs, | |
| int channels, | | int channels, | |
| int application, | | int application, | |
| int *error | | int *error | |
| ); | | ); | |
| | | | |
| /** Initializes a previously allocated encoder state | | /** Initializes a previously allocated encoder state | |
| * The memory pointed to by st must be the size returned by opus_encoder_g
et_size. | | * The memory pointed to by st must be the size returned by opus_encoder_g
et_size. | |
| * This is intended for applications which use their own allocator instead
of malloc. | | * This is intended for applications which use their own allocator instead
of malloc. | |
| * @see opus_encoder_create(),opus_encoder_get_size() | | * @see opus_encoder_create(),opus_encoder_get_size() | |
| * To reset a previously initialized state use the OPUS_RESET_STATE CTL. | | * To reset a previously initialized state use the OPUS_RESET_STATE CTL. | |
| * @param [in] st <tt>OpusEncoder*</tt>: Encoder state | | * @param [in] st <tt>OpusEncoder*</tt>: Encoder state | |
| * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) | |
| * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input si
gnal | | * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input si
gnal | |
| * @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOI
P/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY) | | * @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOI
P/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY) | |
|
| * @retval OPUS_OK Success or @ref errorcodes | | * @retval OPUS_OK Success or @ref opus_errorcodes | |
| */ | | */ | |
| OPUS_EXPORT int opus_encoder_init( | | OPUS_EXPORT int opus_encoder_init( | |
| OpusEncoder *st, | | OpusEncoder *st, | |
| opus_int32 Fs, | | opus_int32 Fs, | |
| int channels, | | int channels, | |
| int application | | int application | |
|
| ); | | ) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Encodes an Opus frame. | | /** Encodes an Opus frame. | |
| * The passed frame_size must an opus frame size for the encoder's samplin
g rate. | | * The passed frame_size must an opus frame size for the encoder's samplin
g rate. | |
|
| * For example, at 48kHz the permitted values are 120, 240, 480, or 960. | | * For example, at 48kHz the permitted values are 120, 240, 480, 960, 1920
, and 2880. | |
| * Passing in a duration of less than 10ms (480 samples at 48kHz) will | | * Passing in a duration of less than 10ms (480 samples at 48kHz) will | |
| * prevent the encoder from using the LPC or hybrid modes. | | * prevent the encoder from using the LPC or hybrid modes. | |
| * @param [in] st <tt>OpusEncoder*</tt>: Encoder state | | * @param [in] st <tt>OpusEncoder*</tt>: Encoder state | |
| * @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 ch
annels). length is frame_size*channels*sizeof(opus_int16) | | * @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 ch
annels). length is frame_size*channels*sizeof(opus_int16) | |
| * @param [in] frame_size <tt>int</tt>: Number of samples per frame of inp
ut signal | | * @param [in] frame_size <tt>int</tt>: Number of samples per frame of inp
ut signal | |
| * @param [out] data <tt>char*</tt>: Output payload (at least max_data_byt
es long) | | * @param [out] data <tt>char*</tt>: Output payload (at least max_data_byt
es long) | |
|
| * @param [in] max_data_bytes <tt>int</tt>: Allocated memory for payload; | | * @param [in] max_data_bytes <tt>opus_int32</tt>: Allocated memory for pa | |
| don't use for controlling bitrate | | yload; don't use for controlling bitrate | |
| * @returns length of the data payload (in bytes) or @ref errorcodes | | * @returns length of the data payload (in bytes) or @ref opus_errorcodes | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_encode( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( | |
| OpusEncoder *st, | | OpusEncoder *st, | |
| const opus_int16 *pcm, | | const opus_int16 *pcm, | |
| int frame_size, | | int frame_size, | |
| unsigned char *data, | | unsigned char *data, | |
|
| int max_data_bytes | | opus_int32 max_data_bytes | |
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Encodes an Opus frame from floating point input. | | /** Encodes an Opus frame from floating point input. | |
| * The passed frame_size must an opus frame size for the encoder's samplin
g rate. | | * The passed frame_size must an opus frame size for the encoder's samplin
g rate. | |
|
| * For example, at 48kHz the permitted values are 120, 240, 480, or 960. | | * For example, at 48kHz the permitted values are 120, 240, 480, 960, 1920
, and 2880. | |
| * Passing in a duration of less than 10ms (480 samples at 48kHz) will | | * Passing in a duration of less than 10ms (480 samples at 48kHz) will | |
| * prevent the encoder from using the LPC or hybrid modes. | | * prevent the encoder from using the LPC or hybrid modes. | |
| * @param [in] st <tt>OpusEncoder*</tt>: Encoder state | | * @param [in] st <tt>OpusEncoder*</tt>: Encoder state | |
|
| * @param [in] pcm <tt>float*</tt>: Input signal (interleaved if 2 channel | | * @param [in] pcm <tt>float*</tt>: Input in float format (interleaved if | |
| s). length is frame_size*channels*sizeof(float) | | 2 channels), with a normal range of +/-1.0. | |
| | | * Samples with a range beyond +/-1.0 are supported but will | |
| | | * be clipped by decoders using the integer API and should | |
| | | * only be used if it is known that the far end supports | |
| | | * extended dynamic range. | |
| | | * length is frame_size*channels*sizeof(float) | |
| * @param [in] frame_size <tt>int</tt>: Number of samples per frame of inp
ut signal | | * @param [in] frame_size <tt>int</tt>: Number of samples per frame of inp
ut signal | |
| * @param [out] data <tt>char*</tt>: Output payload (at least max_data_byt
es long) | | * @param [out] data <tt>char*</tt>: Output payload (at least max_data_byt
es long) | |
|
| * @param [in] max_data_bytes <tt>int</tt>: Allocated memory for payload; | | * @param [in] max_data_bytes <tt>opus_int32</tt>: Allocated memory for pa | |
| don't use for controlling bitrate | | yload; don't use for controlling bitrate | |
| * @returns length of the data payload (in bytes) or @ref errorcodes | | * @returns length of the data payload (in bytes) or @ref opus_errorcodes | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_encode_float( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float( | |
| OpusEncoder *st, | | OpusEncoder *st, | |
| const float *pcm, | | const float *pcm, | |
| int frame_size, | | int frame_size, | |
| unsigned char *data, | | unsigned char *data, | |
|
| int max_data_bytes | | opus_int32 max_data_bytes | |
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Frees an OpusEncoder allocated by opus_encoder_create. | | /** Frees an OpusEncoder allocated by opus_encoder_create. | |
| * @param[in] st <tt>OpusEncoder*</tt>: State to be freed. | | * @param[in] st <tt>OpusEncoder*</tt>: State to be freed. | |
| */ | | */ | |
| OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); | | OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); | |
| | | | |
| /** Perform a CTL function on an Opus encoder. | | /** Perform a CTL function on an Opus encoder. | |
| * | | * | |
| * Generally the request and subsequent arguments are generated | | * Generally the request and subsequent arguments are generated | |
| * by a convenience macro. | | * by a convenience macro. | |
|
| * @see encoderctls | | * @see opus_encoderctls | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...); | | OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_AR
G_NONNULL(1); | |
| /**@}*/ | | /**@}*/ | |
| | | | |
|
| /** @defgroup opusdecoder Opus Decoder | | /** @defgroup opus_decoder Opus Decoder | |
| * @{ | | * @{ | |
| * | | * | |
|
| | | * @brief This page describes the process and functions used to decode Opu
s. | |
| * | | * | |
| * The decoding process also starts with creating a decoder | | * The decoding process also starts with creating a decoder | |
| * state. This can be done with: | | * state. This can be done with: | |
| * @code | | * @code | |
| * int error; | | * int error; | |
| * OpusDecoder *dec; | | * OpusDecoder *dec; | |
| * dec = opus_decoder_create(Fs, channels, &error); | | * dec = opus_decoder_create(Fs, channels, &error); | |
| * @endcode | | * @endcode | |
| * where | | * where | |
| * @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 4
8000 | | * @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 4
8000 | |
| | | | |
| skipping to change at line 316 | | skipping to change at line 319 | |
| * error = opus_decoder_init(dec, Fs, channels); | | * error = opus_decoder_init(dec, Fs, channels); | |
| * @endcode | | * @endcode | |
| * where opus_decoder_get_size() returns the required size for the decoder
state. Note that | | * where opus_decoder_get_size() returns the required size for the decoder
state. Note that | |
| * future versions of this code may change the size, so no assuptions shou
ld be made about it. | | * future versions of this code may change the size, so no assuptions shou
ld be made about it. | |
| * | | * | |
| * The decoder state is always continuous in memory and only a shallow cop
y is sufficient | | * The decoder state is always continuous in memory and only a shallow cop
y is sufficient | |
| * to copy it (e.g. memcpy()) | | * to copy it (e.g. memcpy()) | |
| * | | * | |
| * To decode a frame, opus_decode() or opus_decode_float() must be called
with a packet of compressed audio data: | | * To decode a frame, opus_decode() or opus_decode_float() must be called
with a packet of compressed audio data: | |
| * @code | | * @code | |
|
| * frame_size = opus_decode(enc, packet, len, decoded, max_size); | | * frame_size = opus_decode(dec, packet, len, decoded, max_size, 0); | |
| * @endcode | | * @endcode | |
| * where | | * where | |
| * | | * | |
| * @li packet is the byte array containing the compressed data | | * @li packet is the byte array containing the compressed data | |
| * @li len is the exact number of bytes contained in the packet | | * @li len is the exact number of bytes contained in the packet | |
| * @li decoded is the decoded audio data in opus_int16 (or float for opus_
decode_float()) | | * @li decoded is the decoded audio data in opus_int16 (or float for opus_
decode_float()) | |
| * @li max_size is the max duration of the frame in samples (per channel)
that can fit into the decoded_frame array | | * @li max_size is the max duration of the frame in samples (per channel)
that can fit into the decoded_frame array | |
| * | | * | |
|
| * opus_decode() and opus_decode_frame() return the number of samples ()pe
r channel) decoded from the packet. | | * opus_decode() and opus_decode_float() return the number of samples (per
channel) decoded from the packet. | |
| * If that value is negative, then an error has occured. This can occur if
the packet is corrupted or if the audio | | * If that value is negative, then an error has occured. This can occur if
the packet is corrupted or if the audio | |
| * buffer is too small to hold the decoded audio. | | * buffer is too small to hold the decoded audio. | |
|
| | | * | |
| */ | | * Opus is a stateful codec with overlapping blocks and as a result Opus | |
| | | * packets are not coded independently of each other. Packets must be | |
| | | * passed into the decoder serially and in the correct order for a correct | |
| | | * decode. Lost packets can be replaced with loss concealment by calling | |
| | | * the decoder with a null pointer and zero length for the missing packet. | |
| | | * | |
| | | * A single codec state may only be accessed from a single thread at | |
| | | * a time and any required locking must be performed by the caller. Separa | |
| | | te | |
| | | * streams must be decoded with separate decoder states and can be decoded | |
| | | * in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOST | |
| | | ACK | |
| | | * defined. | |
| | | * | |
| | | */ | |
| | | | |
| /** Opus decoder state. | | /** Opus decoder state. | |
| * This contains the complete state of an Opus decoder. | | * This contains the complete state of an Opus decoder. | |
| * It is position independent and can be freely copied. | | * It is position independent and can be freely copied. | |
| * @see opus_decoder_create,opus_decoder_init | | * @see opus_decoder_create,opus_decoder_init | |
| */ | | */ | |
| typedef struct OpusDecoder OpusDecoder; | | typedef struct OpusDecoder OpusDecoder; | |
| | | | |
| /** Gets the size of an OpusDecoder structure. | | /** Gets the size of an OpusDecoder structure. | |
| * @param [in] channels <tt>int</tt>: Number of channels | | * @param [in] channels <tt>int</tt>: Number of channels | |
| * @returns size | | * @returns size | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_decoder_get_size(int channels); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels)
; | |
| | | | |
| /** Allocates and initializes a decoder state. | | /** Allocates and initializes a decoder state. | |
|
| * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) | | * @param [in] Fs <tt>opus_int32</tt>: Sample rate to decode at (Hz) | |
| * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input si | | * @param [in] channels <tt>int</tt>: Number of channels (1/2) to decode | |
| gnal | | * @param [out] error <tt>int*</tt>: OPUS_OK Success or @ref opus_errorcod | |
| * @param [out] error <tt>int*</tt>: OPUS_OK Success or @ref errorcodes | | es | |
| | | * | |
| | | * Internally Opus stores data at 48000 Hz, so that should be the default | |
| | | * value for Fs. However, the decoder can efficiently decode to buffers | |
| | | * at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use | |
| | | * data at the full sample rate, or knows the compressed data doesn't | |
| | | * use the full frequency range, it can request decoding at a reduced | |
| | | * rate. Likewise, the decoder is capable of filling in either mono or | |
| | | * interleaved stereo pcm buffers, at the caller's request. | |
| */ | | */ | |
|
| OPUS_EXPORT OpusDecoder *opus_decoder_create( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( | |
| opus_int32 Fs, | | opus_int32 Fs, | |
| int channels, | | int channels, | |
| int *error | | int *error | |
| ); | | ); | |
| | | | |
| /** Initializes a previously allocated decoder state. | | /** Initializes a previously allocated decoder state. | |
| * The state must be the size returned by opus_decoder_get_size. | | * The state must be the size returned by opus_decoder_get_size. | |
| * This is intended for applications which use their own allocator instead
of malloc. @see opus_decoder_create,opus_decoder_get_size | | * This is intended for applications which use their own allocator instead
of malloc. @see opus_decoder_create,opus_decoder_get_size | |
| * To reset a previously initialized state use the OPUS_RESET_STATE CTL. | | * To reset a previously initialized state use the OPUS_RESET_STATE CTL. | |
| * @param [in] st <tt>OpusDecoder*</tt>: Decoder state. | | * @param [in] st <tt>OpusDecoder*</tt>: Decoder state. | |
|
| * @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate to decode to (Hz) | |
| * @param [in] channels <tt>int</tt>: Number of channels (1/2) in input si | | * @param [in] channels <tt>int</tt>: Number of channels (1/2) to decode | |
| gnal | | * @retval OPUS_OK Success or @ref opus_errorcodes | |
| * @retval OPUS_OK Success or @ref errorcodes | | | |
| */ | | */ | |
| OPUS_EXPORT int opus_decoder_init( | | OPUS_EXPORT int opus_decoder_init( | |
| OpusDecoder *st, | | OpusDecoder *st, | |
| opus_int32 Fs, | | opus_int32 Fs, | |
| int channels | | int channels | |
|
| ); | | ) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Decode an Opus frame | | /** Decode an Opus frame | |
| * @param [in] st <tt>OpusDecoder*</tt>: Decoder state | | * @param [in] st <tt>OpusDecoder*</tt>: Decoder state | |
| * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to i
ndicate packet loss | | * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to i
ndicate packet loss | |
|
| * @param [in] len <tt>int</tt>: Number of bytes in payload* | | * @param [in] len <tt>opus_int32</tt>: Number of bytes in payload* | |
| * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2
channels). length | | * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2
channels). length | |
| * is frame_size*channels*sizeof(opus_int16) | | * is frame_size*channels*sizeof(opus_int16) | |
| * @param [in] frame_size Number of samples per channel of available space
in *pcm, | | * @param [in] frame_size Number of samples per channel of available space
in *pcm, | |
| * if less than the maximum frame size (120ms) some frames can not be dec
oded | | * if less than the maximum frame size (120ms) some frames can not be dec
oded | |
| * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-
band forward error correction data be | | * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-
band forward error correction data be | |
| * decoded. If no such data is available the frame is decoded as if it we
re lost. | | * decoded. If no such data is available the frame is decoded as if it we
re lost. | |
|
| * @returns Number of decoded samples or @ref errorcodes | | * @returns Number of decoded samples or @ref opus_errorcodes | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_decode( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode( | |
| OpusDecoder *st, | | OpusDecoder *st, | |
| const unsigned char *data, | | const unsigned char *data, | |
|
| int len, | | opus_int32 len, | |
| opus_int16 *pcm, | | opus_int16 *pcm, | |
| int frame_size, | | int frame_size, | |
| int decode_fec | | int decode_fec | |
|
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Decode an opus frame with floating point output | | /** Decode an opus frame with floating point output | |
| * @param [in] st <tt>OpusDecoder*</tt>: Decoder state | | * @param [in] st <tt>OpusDecoder*</tt>: Decoder state | |
| * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to i
ndicate packet loss | | * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to i
ndicate packet loss | |
|
| * @param [in] len <tt>int</tt>: Number of bytes in payload | | * @param [in] len <tt>opus_int32</tt>: Number of bytes in payload | |
| * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 chann
els). length | | * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 chann
els). length | |
| * is frame_size*channels*sizeof(float) | | * is frame_size*channels*sizeof(float) | |
| * @param [in] frame_size Number of samples per channel of available space
in *pcm, | | * @param [in] frame_size Number of samples per channel of available space
in *pcm, | |
| * if less than the maximum frame size (120ms) some frames can not be dec
oded | | * if less than the maximum frame size (120ms) some frames can not be dec
oded | |
| * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-
band forward error correction data be | | * @param [in] decode_fec <tt>int</tt>: Flag (0/1) to request that any in-
band forward error correction data be | |
| * decoded. If no such data is available the frame is decoded as if it we
re lost. | | * decoded. If no such data is available the frame is decoded as if it we
re lost. | |
|
| * @returns Number of decoded samples or @ref errorcodes | | * @returns Number of decoded samples or @ref opus_errorcodes | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_decode_float( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float( | |
| OpusDecoder *st, | | OpusDecoder *st, | |
| const unsigned char *data, | | const unsigned char *data, | |
|
| int len, | | opus_int32 len, | |
| float *pcm, | | float *pcm, | |
| int frame_size, | | int frame_size, | |
| int decode_fec | | int decode_fec | |
|
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Perform a CTL function on an Opus decoder. | | /** Perform a CTL function on an Opus decoder. | |
| * | | * | |
| * Generally the request and subsequent arguments are generated | | * Generally the request and subsequent arguments are generated | |
| * by a convenience macro. | | * by a convenience macro. | |
|
| * @see genericctls | | * @see opus_genericctls | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...); | | OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_AR
G_NONNULL(1); | |
| | | | |
| /** Frees an OpusDecoder allocated by opus_decoder_create. | | /** Frees an OpusDecoder allocated by opus_decoder_create. | |
| * @param[in] st <tt>OpusDecoder*</tt>: State to be freed. | | * @param[in] st <tt>OpusDecoder*</tt>: State to be freed. | |
| */ | | */ | |
| OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); | | OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); | |
| | | | |
| /** Parse an opus packet into one or more frames. | | /** Parse an opus packet into one or more frames. | |
| * Opus_decode will perform this operation internally so most applications
do | | * Opus_decode will perform this operation internally so most applications
do | |
| * not need to use this function. | | * not need to use this function. | |
| * This function does not copy the frames, the returned pointers are point
ers into | | * This function does not copy the frames, the returned pointers are point
ers into | |
| * the input packet. | | * the input packet. | |
| * @param [in] data <tt>char*</tt>: Opus packet to be parsed | | * @param [in] data <tt>char*</tt>: Opus packet to be parsed | |
|
| * @param [in] len <tt>int</tt>: size of data | | * @param [in] len <tt>opus_int32</tt>: size of data | |
| * @param [out] out_toc <tt>char*</tt>: TOC pointer | | * @param [out] out_toc <tt>char*</tt>: TOC pointer | |
| * @param [out] frames <tt>char*[48]</tt> encapsulated frames | | * @param [out] frames <tt>char*[48]</tt> encapsulated frames | |
| * @param [out] size <tt>short[48]</tt> sizes of the encapsulated frames | | * @param [out] size <tt>short[48]</tt> sizes of the encapsulated frames | |
| * @param [out] payload_offset <tt>int*</tt>: returns the position of the
payload within the packet (in bytes) | | * @param [out] payload_offset <tt>int*</tt>: returns the position of the
payload within the packet (in bytes) | |
| * @returns number of frames | | * @returns number of frames | |
| */ | | */ | |
| OPUS_EXPORT int opus_packet_parse( | | OPUS_EXPORT int opus_packet_parse( | |
| const unsigned char *data, | | const unsigned char *data, | |
|
| int len, | | opus_int32 len, | |
| unsigned char *out_toc, | | unsigned char *out_toc, | |
| const unsigned char *frames[48], | | const unsigned char *frames[48], | |
| short size[48], | | short size[48], | |
| int *payload_offset | | int *payload_offset | |
|
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Gets the bandwidth of an Opus packet. | | /** Gets the bandwidth of an Opus packet. | |
| * @param [in] data <tt>char*</tt>: Opus packet | | * @param [in] data <tt>char*</tt>: Opus packet | |
| * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) | | * @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) | |
| * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) | | * @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) | |
| * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) | | * @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) | |
| * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) | | * @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) | |
| * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) | | * @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) | |
| * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const uns
igned char *data) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Gets the number of samples per frame from an Opus packet. | | /** Gets the number of samples per frame from an Opus packet. | |
| * @param [in] data <tt>char*</tt>: Opus packet | | * @param [in] data <tt>char*</tt>: Opus packet | |
| * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz | | * @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz | |
| * @returns Number of samples per frame | | * @returns Number of samples per frame | |
| * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data
, opus_int32 Fs); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(c
onst unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Gets the number of channels from an Opus packet. | | /** Gets the number of channels from an Opus packet. | |
| * @param [in] data <tt>char*</tt>: Opus packet | | * @param [in] data <tt>char*</tt>: Opus packet | |
| * @returns Number of channels | | * @returns Number of channels | |
| * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_packet_get_nb_channels(const unsigned char *data); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const u
nsigned char *data) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Gets the number of frames in an Opus packet. | | /** Gets the number of frames in an Opus packet. | |
| * @param [in] packet <tt>char*</tt>: Opus packet | | * @param [in] packet <tt>char*</tt>: Opus packet | |
|
| * @param [in] len <tt>int</tt>: Length of packet | | * @param [in] len <tt>opus_int32</tt>: Length of packet | |
| * @returns Number of frames | | * @returns Number of frames | |
| * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_packet_get_nb_frames(const unsigned char packet[], int
len); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const uns
igned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Gets the number of samples of an Opus packet. | | /** Gets the number of samples of an Opus packet. | |
| * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state | | * @param [in] dec <tt>OpusDecoder*</tt>: Decoder state | |
| * @param [in] packet <tt>char*</tt>: Opus packet | | * @param [in] packet <tt>char*</tt>: Opus packet | |
|
| * @param [in] len <tt>int</tt>: Length of packet | | * @param [in] len <tt>opus_int32</tt>: Length of packet | |
| * @returns Number of samples | | * @returns Number of samples | |
| * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | | * @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or
of an unsupported type | |
| */ | | */ | |
|
| OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const u
nsigned char packet[], int len); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const O
pusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NON
NULL(1) OPUS_ARG_NONNULL(2); | |
| /**@}*/ | | /**@}*/ | |
| | | | |
|
| /** @defgroup repacketizer Repacketizer | | /** @defgroup opus_repacketizer Repacketizer | |
| * @{ | | * @{ | |
| * | | * | |
| * The repacketizer can be used to merge multiple Opus packets into a sing
le packet | | * The repacketizer can be used to merge multiple Opus packets into a sing
le packet | |
| * or alternatively to split Opus packets that have previously been merged
. | | * or alternatively to split Opus packets that have previously been merged
. | |
| * | | * | |
| */ | | */ | |
| | | | |
| typedef struct OpusRepacketizer OpusRepacketizer; | | typedef struct OpusRepacketizer OpusRepacketizer; | |
| | | | |
|
| OPUS_EXPORT int opus_repacketizer_get_size(void); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void); | |
| | | | |
|
| OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp); | | OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp)
OPUS_ARG_NONNULL(1); | |
| | | | |
|
| OPUS_EXPORT OpusRepacketizer *opus_repacketizer_create(void); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_cre
ate(void); | |
| | | | |
| OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); | | OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); | |
| | | | |
|
| OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned
char *data, int len); | | OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned
char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); | |
| | | | |
|
| OPUS_EXPORT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, in
t begin, int end, unsigned char *data, int maxlen); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(
OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 m
axlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); | |
| | | | |
|
| OPUS_EXPORT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(Opu
sRepacketizer *rp) OPUS_ARG_NONNULL(1); | |
| | | | |
|
| OPUS_EXPORT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned
char *data, int maxlen); | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRe
packetizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1)
; | |
| | | | |
| /**@}*/ | | /**@}*/ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* OPUS_H */ | | #endif /* OPUS_H */ | |
| | | | |
End of changes. 67 change blocks. |
| 87 lines changed or deleted | | 113 lines changed or added | |
|
| opus_defines.h | | opus_defines.h | |
|
| /* Copyright (c) 2010-2012 IETF Trust, Xiph.Org Foundation, Skype Limited.
All rights reserved. | | /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited | |
| Written by Jean-Marc Valin and Koen Vos */ | | Written by Jean-Marc Valin and Koen Vos */ | |
| /* | | /* | |
|
| | | | |
| This file is extracted from RFC6716. Please see that RFC for additional | | | |
| information. | | | |
| | | | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions | | modification, are permitted provided that the following conditions | |
| are met: | | are met: | |
| | | | |
| - Redistributions of source code must retain the above copyright | | - Redistributions of source code must retain the above copyright | |
| notice, this list of conditions and the following disclaimer. | | notice, this list of conditions and the following disclaimer. | |
| | | | |
| - Redistributions in binary form must reproduce the above copyright | | - Redistributions in binary form must reproduce the above copyright | |
| notice, this list of conditions and the following disclaimer in the | | notice, this list of conditions and the following disclaimer in the | |
| documentation and/or other materials provided with the distribution. | | documentation and/or other materials provided with the distribution. | |
| | | | |
|
| - Neither the name of Internet Society, IETF or IETF Trust, nor the | | | |
| names of specific contributors, may be used to endorse or promote | | | |
| products derived from this software without specific prior written | | | |
| permission. | | | |
| | | | |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWN
ER | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWN
ER | |
| OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 42 | |
| | | | |
| #ifndef OPUS_DEFINES_H | | #ifndef OPUS_DEFINES_H | |
| #define OPUS_DEFINES_H | | #define OPUS_DEFINES_H | |
| | | | |
| #include "opus_types.h" | | #include "opus_types.h" | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| /** @defgroup errorcodes Error codes | | /** @defgroup opus_errorcodes Error codes | |
| * @{ | | * @{ | |
| */ | | */ | |
| /** No error @hideinitializer*/ | | /** No error @hideinitializer*/ | |
| #define OPUS_OK 0 | | #define OPUS_OK 0 | |
| /** One or more invalid/out of range arguments @hideinitializer*/ | | /** One or more invalid/out of range arguments @hideinitializer*/ | |
| #define OPUS_BAD_ARG -1 | | #define OPUS_BAD_ARG -1 | |
| /** The mode struct passed is invalid @hideinitializer*/ | | /** The mode struct passed is invalid @hideinitializer*/ | |
| #define OPUS_BUFFER_TOO_SMALL -2 | | #define OPUS_BUFFER_TOO_SMALL -2 | |
| /** An internal error was detected @hideinitializer*/ | | /** An internal error was detected @hideinitializer*/ | |
| #define OPUS_INTERNAL_ERROR -3 | | #define OPUS_INTERNAL_ERROR -3 | |
| | | | |
| skipping to change at line 77 | | skipping to change at line 68 | |
| #define OPUS_INVALID_STATE -6 | | #define OPUS_INVALID_STATE -6 | |
| /** Memory allocation has failed @hideinitializer*/ | | /** Memory allocation has failed @hideinitializer*/ | |
| #define OPUS_ALLOC_FAIL -7 | | #define OPUS_ALLOC_FAIL -7 | |
| /**@}*/ | | /**@}*/ | |
| | | | |
| /** @cond OPUS_INTERNAL_DOC */ | | /** @cond OPUS_INTERNAL_DOC */ | |
| /**Export control for opus functions */ | | /**Export control for opus functions */ | |
| | | | |
| #if defined(__GNUC__) && defined(OPUS_BUILD) | | #if defined(__GNUC__) && defined(OPUS_BUILD) | |
| # define OPUS_EXPORT __attribute__ ((visibility ("default"))) | | # define OPUS_EXPORT __attribute__ ((visibility ("default"))) | |
|
| #elif defined(WIN32) | | #elif defined(WIN32) && !defined(__MINGW32__) | |
| # ifdef OPUS_BUILD | | # ifdef OPUS_BUILD | |
| # define OPUS_EXPORT __declspec(dllexport) | | # define OPUS_EXPORT __declspec(dllexport) | |
| # else | | # else | |
|
| # define OPUS_EXPORT __declspec(dllimport) | | # define OPUS_EXPORT | |
| # endif | | # endif | |
| #else | | #else | |
| # define OPUS_EXPORT | | # define OPUS_EXPORT | |
| #endif | | #endif | |
| | | | |
|
| | | # if !defined(OPUS_GNUC_PREREQ) | |
| | | # if defined(__GNUC__)&&defined(__GNUC_MINOR__) | |
| | | # define OPUS_GNUC_PREREQ(_maj,_min) \ | |
| | | ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) | |
| | | # else | |
| | | # define OPUS_GNUC_PREREQ(_maj,_min) 0 | |
| | | # endif | |
| | | # endif | |
| | | | |
| | | #if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) | |
| | | # if OPUS_GNUC_PREREQ(3,0) | |
| | | # define OPUS_RESTRICT __restrict__ | |
| | | # elif (defined(_MSC_VER) && _MSC_VER >= 1400) | |
| | | # define OPUS_RESTRICT __restrict | |
| | | # else | |
| | | # define OPUS_RESTRICT | |
| | | # endif | |
| | | #else | |
| | | # define OPUS_RESTRICT restrict | |
| | | #endif | |
| | | | |
| | | /**Warning attributes for opus functions | |
| | | * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out | |
| | | * some paranoid null checks. */ | |
| | | #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) | |
| | | # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) | |
| | | #else | |
| | | # define OPUS_WARN_UNUSED_RESULT | |
| | | #endif | |
| | | #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) | |
| | | # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) | |
| | | #else | |
| | | # define OPUS_ARG_NONNULL(_x) | |
| | | #endif | |
| | | | |
| /** These are the actual Encoder CTL ID numbers. | | /** These are the actual Encoder CTL ID numbers. | |
|
| * They should not be used directly by applications. */ | | * They should not be used directly by applications. | |
| | | * In general, SETs should be even and GETs should be odd.*/ | |
| #define OPUS_SET_APPLICATION_REQUEST 4000 | | #define OPUS_SET_APPLICATION_REQUEST 4000 | |
| #define OPUS_GET_APPLICATION_REQUEST 4001 | | #define OPUS_GET_APPLICATION_REQUEST 4001 | |
| #define OPUS_SET_BITRATE_REQUEST 4002 | | #define OPUS_SET_BITRATE_REQUEST 4002 | |
| #define OPUS_GET_BITRATE_REQUEST 4003 | | #define OPUS_GET_BITRATE_REQUEST 4003 | |
| #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 | | #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 | |
| #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 | | #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 | |
| #define OPUS_SET_VBR_REQUEST 4006 | | #define OPUS_SET_VBR_REQUEST 4006 | |
| #define OPUS_GET_VBR_REQUEST 4007 | | #define OPUS_GET_VBR_REQUEST 4007 | |
| #define OPUS_SET_BANDWIDTH_REQUEST 4008 | | #define OPUS_SET_BANDWIDTH_REQUEST 4008 | |
| #define OPUS_GET_BANDWIDTH_REQUEST 4009 | | #define OPUS_GET_BANDWIDTH_REQUEST 4009 | |
| | | | |
| skipping to change at line 115 | | skipping to change at line 142 | |
| #define OPUS_SET_DTX_REQUEST 4016 | | #define OPUS_SET_DTX_REQUEST 4016 | |
| #define OPUS_GET_DTX_REQUEST 4017 | | #define OPUS_GET_DTX_REQUEST 4017 | |
| #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 | | #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 | |
| #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 | | #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 | |
| #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 | | #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 | |
| #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 | | #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 | |
| #define OPUS_SET_SIGNAL_REQUEST 4024 | | #define OPUS_SET_SIGNAL_REQUEST 4024 | |
| #define OPUS_GET_SIGNAL_REQUEST 4025 | | #define OPUS_GET_SIGNAL_REQUEST 4025 | |
| #define OPUS_GET_LOOKAHEAD_REQUEST 4027 | | #define OPUS_GET_LOOKAHEAD_REQUEST 4027 | |
| /* #define OPUS_RESET_STATE 4028 */ | | /* #define OPUS_RESET_STATE 4028 */ | |
|
| | | #define OPUS_GET_SAMPLE_RATE_REQUEST 4029 | |
| #define OPUS_GET_FINAL_RANGE_REQUEST 4031 | | #define OPUS_GET_FINAL_RANGE_REQUEST 4031 | |
| #define OPUS_GET_PITCH_REQUEST 4033 | | #define OPUS_GET_PITCH_REQUEST 4033 | |
|
| | | #define OPUS_SET_GAIN_REQUEST 4034 | |
| | | #define OPUS_GET_GAIN_REQUEST 4045 | |
| | | #define OPUS_SET_LSB_DEPTH_REQUEST 4036 | |
| | | #define OPUS_GET_LSB_DEPTH_REQUEST 4037 | |
| | | | |
| /* Macros to trigger compilation errors when the wrong types are provided t
o a CTL */ | | /* Macros to trigger compilation errors when the wrong types are provided t
o a CTL */ | |
| #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x
)) | | #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x
)) | |
| #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) | | #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) | |
| #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) | | #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) | |
| /** @endcond */ | | /** @endcond */ | |
| | | | |
|
| /** @defgroup ctlvalues Pre-defined values for CTL interface | | /** @defgroup opus_ctlvalues Pre-defined values for CTL interface | |
| * @see genericctls, encoderctls | | * @see opus_genericctls, opus_encoderctls | |
| * @{ | | * @{ | |
| */ | | */ | |
| /* Values for the various encoder CTLs */ | | /* Values for the various encoder CTLs */ | |
| #define OPUS_AUTO -1000 /**<Auto/default setting
@hideinitializer*/ | | #define OPUS_AUTO -1000 /**<Auto/default setting
@hideinitializer*/ | |
| #define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hide
initializer*/ | | #define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hide
initializer*/ | |
| | | | |
| /** Best for most VoIP/videoconference applications where listening quality
and intelligibility matter most | | /** Best for most VoIP/videoconference applications where listening quality
and intelligibility matter most | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_APPLICATION_VOIP 2048 | | #define OPUS_APPLICATION_VOIP 2048 | |
| /** Best for broadcast/high-fidelity application where the decoded audio sh
ould be as close as possible to the input | | /** Best for broadcast/high-fidelity application where the decoded audio sh
ould be as close as possible to the input | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_APPLICATION_AUDIO 2049 | | #define OPUS_APPLICATION_AUDIO 2049 | |
| /** Only use when lowest-achievable latency is what matters most. Voice-opt
imized modes cannot be used. | | /** Only use when lowest-achievable latency is what matters most. Voice-opt
imized modes cannot be used. | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 | | #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 | |
| | | | |
| #define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded
is voice */ | | #define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded
is voice */ | |
| #define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded
is music */ | | #define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded
is music */ | |
|
| #define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4kHz bandpass @hidei | | #define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hide | |
| nitializer*/ | | initializer*/ | |
| #define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6kHz bandpass @hidei | | #define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hide | |
| nitializer*/ | | initializer*/ | |
| #define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8kHz bandpass @hidei | | #define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hide | |
| nitializer*/ | | initializer*/ | |
| #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12kHz bandpass @hidei | | #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hide | |
| nitializer*/ | | initializer*/ | |
| #define OPUS_BANDWIDTH_FULLBAND 1105 /**<20kHz bandpass @hidei | | #define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hide | |
| nitializer*/ | | initializer*/ | |
| | | | |
| /**@}*/ | | /**@}*/ | |
| | | | |
|
| /** @defgroup encoderctls Encoder related CTLs | | /** @defgroup opus_encoderctls Encoder related CTLs | |
| * | | * | |
| * These are convenience macros for use with the \c opus_encode_ctl | | * These are convenience macros for use with the \c opus_encode_ctl | |
| * interface. They are used to generate the appropriate series of | | * interface. They are used to generate the appropriate series of | |
| * arguments for that call, passing the correct type, size and so | | * arguments for that call, passing the correct type, size and so | |
| * on as expected for each particular request. | | * on as expected for each particular request. | |
| * | | * | |
| * Some usage examples: | | * Some usage examples: | |
| * | | * | |
| * @code | | * @code | |
| * int ret; | | * int ret; | |
| * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); | | * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); | |
| * if (ret != OPUS_OK) return ret; | | * if (ret != OPUS_OK) return ret; | |
| * | | * | |
|
| * int rate; | | * opus_int32 rate; | |
| * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); | | * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); | |
| * | | * | |
| * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); | | * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); | |
| * @endcode | | * @endcode | |
| * | | * | |
|
| * @see genericctls, opusencoder | | * @see opus_genericctls, opus_encoder | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** Configures the encoder's computational complexity. | | /** Configures the encoder's computational complexity. | |
| * The supported range is 0-10 inclusive with 10 representing the highest
complexity. | | * The supported range is 0-10 inclusive with 10 representing the highest
complexity. | |
|
| * The default value is 10. | | * @see OPUS_GET_COMPLEXITY | |
| * @param[in] x <tt>int</tt>: 0-10, inclusive | | * @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. | |
| | | * | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_in
t(x) | | #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_in
t(x) | |
|
| /** Gets the encoder's complexity configuration, @see OPUS_SET_COMPLEXITY | | /** Gets the encoder's complexity configuration. | |
| * @param[out] x <tt>int*</tt>: 0-10, inclusive | | * @see OPUS_SET_COMPLEXITY | |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, | |
| | | * inclusive. | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_in
t_ptr(x) | | #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_in
t_ptr(x) | |
| | | | |
| /** Configures the bitrate in the encoder. | | /** Configures the bitrate in the encoder. | |
|
| * Rates from 500 to 512000 bits per second are meaningful as well as the | | * Rates from 500 to 512000 bits per second are meaningful, as well as the | |
| * special values OPUS_BITRATE_AUTO and OPUS_BITRATE_MAX. | | * special values #OPUS_AUTO and #OPUS_BITRATE_MAX. | |
| * The value OPUS_BITRATE_MAX can be used to cause the codec to use as muc | | * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as mu | |
| h rate | | ch | |
| * as it can, which is useful for controlling the rate by adjusting the ou | | * rate as it can, which is useful for controlling the rate by adjusting t | |
| tput | | he | |
| * buffer size. | | * output buffer size. | |
| * @param[in] x <tt>opus_int32</tt>: bitrate in bits per second. | | * @see OPUS_GET_BITRATE | |
| | | * @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The defau | |
| | | lt | |
| | | * is determined based on the number of | |
| | | * channels and the input sampling rate. | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) | | #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) | |
|
| /** Gets the encoder's bitrate configuration, @see OPUS_SET_BITRATE | | /** Gets the encoder's bitrate configuration. | |
| * @param[out] x <tt>opus_int32*</tt>: bitrate in bits per second. | | * @see OPUS_SET_BITRATE | |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per se | |
| | | cond. | |
| | | * The default is determined based on | |
| | | the | |
| | | * number of channels and the input | |
| | | * sampling rate. | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(
x) | | #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(
x) | |
| | | | |
|
| /** Configures VBR in the encoder. | | /** Enables or disables variable bitrate (VBR) in the encoder. | |
| * The following values are currently supported: | | | |
| * - 0 CBR | | | |
| * - 1 VBR (default) | | | |
| * The configured bitrate may not be met exactly because frames must | | * The configured bitrate may not be met exactly because frames must | |
| * be an integer number of bytes in length. | | * be an integer number of bytes in length. | |
| * @warning Only the MDCT mode of Opus can provide hard CBR behavior. | | * @warning Only the MDCT mode of Opus can provide hard CBR behavior. | |
|
| * @param[in] x <tt>int</tt>: 0; 1 (default) | | * @see OPUS_GET_VBR | |
| | | * @see OPUS_SET_VBR_CONSTRAINT | |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this | |
| | | can | |
| | | * cause noticeable quality degradation.</dd> | |
| | | * <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by | |
| | | * #OPUS_SET_VBR_CONSTRAINT.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) | | #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) | |
|
| /** Gets the encoder's VBR configuration, @see OPUS_SET_VBR | | /** Determine if variable bitrate (VBR) is enabled in the encoder. | |
| * @param[out] x <tt>int*</tt>: 0; 1 | | * @see OPUS_SET_VBR | |
| | | * @see OPUS_GET_VBR_CONSTRAINT | |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following value | |
| | | s: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>Hard CBR.</dd> | |
| | | * <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via | |
| | | * #OPUS_GET_VBR_CONSTRAINT.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) | | #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) | |
| | | | |
|
| /** Configures constrained VBR in the encoder. | | /** Enables or disables constrained VBR in the encoder. | |
| * The following values are currently supported: | | * This setting is ignored when the encoder is in CBR mode. | |
| * - 0 Unconstrained VBR (default) | | | |
| * - 1 Maximum one frame buffering delay assuming transport with a serial | | | |
| ization speed of the nominal bitrate | | | |
| * This setting is irrelevant when the encoder is in CBR mode. | | | |
| * @warning Only the MDCT mode of Opus currently heeds the constraint. | | * @warning Only the MDCT mode of Opus currently heeds the constraint. | |
| * Speech mode ignores it completely, hybrid mode may fail to obey it | | * Speech mode ignores it completely, hybrid mode may fail to obey it | |
| * if the LPC layer uses more bitrate than the constraint would have | | * if the LPC layer uses more bitrate than the constraint would have | |
| * permitted. | | * permitted. | |
|
| * @param[in] x <tt>int</tt>: 0 (default); 1 | | * @see OPUS_GET_VBR_CONSTRAINT | |
| | | * @see OPUS_SET_VBR | |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>Unconstrained VBR.</dd> | |
| | | * <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one | |
| | | * frame of buffering delay assuming a transport with a | |
| | | * serialization speed of the nominal bitrate.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_
check_int(x) | | #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_
check_int(x) | |
|
| /** Gets the encoder's constrained VBR configuration @see OPUS_SET_VBR_CONS | | /** Determine if constrained VBR is enabled in the encoder. | |
| TRAINT | | * @see OPUS_SET_VBR_CONSTRAINT | |
| * @param[out] x <tt>int*</tt>: 0; 1 | | * @see OPUS_GET_VBR | |
| | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following value | |
| | | s: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>Unconstrained VBR.</dd> | |
| | | * <dt>1</dt><dd>Constrained VBR (default).</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_
check_int_ptr(x) | | #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_
check_int_ptr(x) | |
| | | | |
| /** Configures mono/stereo forcing in the encoder. | | /** Configures mono/stereo forcing in the encoder. | |
|
| * This is useful when the caller knows that the input signal is currently | | * This can force the encoder to produce packets encoded as either mono or | |
| a mono | | * stereo, regardless of the format of the input audio. This is useful whe | |
| * source embedded in a stereo stream. | | n | |
| * @param[in] x <tt>int</tt>: OPUS_AUTO (default); 1 (forced mono); 2 (f | | * the caller knows that the input signal is currently a mono source embed | |
| orced stereo) | | ded | |
| | | * in a stereo stream. | |
| | | * @see OPUS_GET_FORCE_CHANNELS | |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> | |
| | | * <dt>1</dt> <dd>Forced mono</dd> | |
| | | * <dt>2</dt> <dd>Forced stereo</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_
check_int(x) | | #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_
check_int(x) | |
|
| /** Gets the encoder's forced channel configuration, @see OPUS_SET_FORCE_CH | | /** Gets the encoder's forced channel configuration. | |
| ANNELS | | * @see OPUS_SET_FORCE_CHANNELS | |
| * @param[out] x <tt>int*</tt>: OPUS_AUTO; 0; 1 | | * @param[out] x <tt>opus_int32 *</tt>: | |
| | | * <dl> | |
| | | * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> | |
| | | * <dt>1</dt> <dd>Forced mono</dd> | |
| | | * <dt>2</dt> <dd>Forced stereo</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_
check_int_ptr(x) | | #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_
check_int_ptr(x) | |
| | | | |
|
| /** Configures the encoder's maximum bandpass allowed, @see OPUS_GET_MAX_BA | | /** Configures the maximum bandpass that the encoder will select automatica | |
| NDWIDTH | | lly. | |
| * The supported values are: | | * Applications should normally use this instead of #OPUS_SET_BANDWIDTH | |
| * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband | | * (leaving that set to the default, #OPUS_AUTO). This allows the | |
| * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband | | * application to set an upper bound based on the type of input it is | |
| * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband | | * providing, but still gives the encoder the freedom to reduce the bandpa | |
| * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband | | ss | |
| * - OPUS_BANDWIDTH_FULLBAND 20kHz passband (default) | | * when the bitrate becomes too low, for better overall quality. | |
| * @param[in] x <tt>int</tt>: Bandwidth value | | * @see OPUS_GET_MAX_BANDWIDTH | |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> | |
| | | * <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> | |
| | | * <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> | |
| | | * <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> | |
| | | * <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_ch
eck_int(x) | | #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_ch
eck_int(x) | |
| | | | |
|
| /** Gets the encoder's configured maximum bandpass allowed, @see OPUS_SET_M | | /** Gets the encoder's configured maximum allowed bandpass. | |
| AX_BANDWIDTH | | * @see OPUS_SET_MAX_BANDWIDTH | |
| * @param[out] x <tt>int*</tt>: Bandwidth value | | * @param[out] x <tt>opus_int32 *</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd | |
| | | > | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_ch
eck_int_ptr(x) | | #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_ch
eck_int_ptr(x) | |
| | | | |
|
| /** Configures the encoder's bandpass, @see OPUS_GET_BANDWIDTH | | /** Sets the encoder's bandpass to a specific value. | |
| * The supported values are: | | * This prevents the encoder from automatically selecting the bandpass bas | |
| * - OPUS_AUTO (default) | | ed | |
| * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband | | * on the available bitrate. If an application knows the bandpass of the i | |
| * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband | | nput | |
| * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband | | * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH | |
| * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband | | * instead, which still gives the encoder the freedom to reduce the bandpa | |
| * - OPUS_BANDWIDTH_FULLBAND 20kHz passband | | ss | |
| * @param[in] x <tt>int</tt>: Bandwidth value | | * when the bitrate becomes too low, for better overall quality. | |
| | | * @see OPUS_GET_BANDWIDTH | |
| | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(
x) | | #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(
x) | |
| | | | |
| /** Configures the type of signal being encoded. | | /** Configures the type of signal being encoded. | |
| * This is a hint which helps the encoder's mode selection. | | * This is a hint which helps the encoder's mode selection. | |
|
| * The supported values are: | | * @see OPUS_GET_SIGNAL | |
| * - OPUS_SIGNAL_AUTO (default) | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| * - OPUS_SIGNAL_VOICE | | * <dl> | |
| * - OPUS_SIGNAL_MUSIC | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> | |
| * @param[in] x <tt>int</tt>: Signal type | | * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or | |
| | | Hybrid modes.</dd> | |
| | | * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT mo | |
| | | des.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) | | #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) | |
|
| /** Gets the encoder's configured signal type, @see OPUS_SET_SIGNAL | | /** Gets the encoder's configured signal type. | |
| * | | * @see OPUS_SET_SIGNAL | |
| * @param[out] x <tt>int*</tt>: Signal type | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following value | |
| | | s: | |
| | | * <dl> | |
| | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> | |
| | | * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or | |
| | | Hybrid modes.</dd> | |
| | | * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT mo | |
| | | des.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) | | #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) | |
| | | | |
| /** Configures the encoder's intended application. | | /** Configures the encoder's intended application. | |
| * The initial value is a mandatory argument to the encoder_create functio
n. | | * The initial value is a mandatory argument to the encoder_create functio
n. | |
|
| * The supported values are: | | * @see OPUS_GET_APPLICATION | |
| * - OPUS_APPLICATION_VOIP Process signal for improved speech intelligibi | | * @param[in] x <tt>opus_int32</tt>: Returns one of the following values: | |
| lity | | * <dl> | |
| * - OPUS_APPLICATION_AUDIO Favor faithfulness to the original input | | * <dt>#OPUS_APPLICATION_VOIP</dt> | |
| * - OPUS_APPLICATION_RESTRICTED_LOWDELAY Configure the minimum possible | | * <dd>Process signal for improved speech intelligibility.</dd> | |
| coding delay | | * <dt>#OPUS_APPLICATION_AUDIO</dt> | |
| * | | * <dd>Favor faithfulness to the original input.</dd> | |
| * @param[in] x <tt>int</tt>: Application value | | * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> | |
| | | * <dd>Configure the minimum possible coding delay by disabling certain mo | |
| | | des | |
| | | * of operation.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_
int(x) | | #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_
int(x) | |
|
| /** Gets the encoder's configured application, @see OPUS_SET_APPLICATION | | /** Gets the encoder's configured application. | |
| * | | * @see OPUS_SET_APPLICATION | |
| * @param[out] x <tt>int*</tt>: Application value | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following value | |
| | | s: | |
| | | * <dl> | |
| | | * <dt>#OPUS_APPLICATION_VOIP</dt> | |
| | | * <dd>Process signal for improved speech intelligibility.</dd> | |
| | | * <dt>#OPUS_APPLICATION_AUDIO</dt> | |
| | | * <dd>Favor faithfulness to the original input.</dd> | |
| | | * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> | |
| | | * <dd>Configure the minimum possible coding delay by disabling certain mo | |
| | | des | |
| | | * of operation.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_
int_ptr(x) | | #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_
int_ptr(x) | |
| | | | |
|
| | | /** Gets the sampling rate the encoder or decoder was initialized with. | |
| | | * This simply returns the <code>Fs</code> value passed to opus_encoder_in | |
| | | it() | |
| | | * or opus_decoder_init(). | |
| | | * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decode | |
| | | r. | |
| | | * @hideinitializer | |
| | | */ | |
| | | #define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_ | |
| | | int_ptr(x) | |
| | | | |
| /** Gets the total samples of delay added by the entire codec. | | /** Gets the total samples of delay added by the entire codec. | |
| * This can be queried by the encoder and then the provided number of samp
les can be | | * This can be queried by the encoder and then the provided number of samp
les can be | |
| * skipped on from the start of the decoder's output to provide time align
ed input | | * skipped on from the start of the decoder's output to provide time align
ed input | |
| * and output. From the perspective of a decoding application the real dat
a begins this many | | * and output. From the perspective of a decoding application the real dat
a begins this many | |
| * samples late. | | * samples late. | |
| * | | * | |
| * The decoder contribution to this delay is identical for all decoders, b
ut the | | * The decoder contribution to this delay is identical for all decoders, b
ut the | |
| * encoder portion of the delay may vary from implementation to implementa
tion, | | * encoder portion of the delay may vary from implementation to implementa
tion, | |
| * version to version, or even depend on the encoder's initial configurati
on. | | * version to version, or even depend on the encoder's initial configurati
on. | |
| * Applications needing delay compensation should call this CTL rather tha
n | | * Applications needing delay compensation should call this CTL rather tha
n | |
| * hard-coding a value. | | * hard-coding a value. | |
|
| * @param[out] x <tt>int*</tt>: Number of lookahead samples | | * @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_
ptr(x) | | #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_
ptr(x) | |
| | | | |
|
| /** Configures the encoder's use of inband forward error correction. | | /** Configures the encoder's use of inband forward error correction (FEC). | |
| * @note This is only applicable to the LPC layer | | * @note This is only applicable to the LPC layer | |
|
| * | | * @see OPUS_GET_INBAND_FEC | |
| * @param[in] x <tt>int</tt>: FEC flag, 0 (disabled) is default | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>Disable inband FEC (default).</dd> | |
| | | * <dt>1</dt><dd>Enable inband FEC.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_in
t(x) | | #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_in
t(x) | |
|
| /** Gets encoder's configured use of inband forward error correction, @see | | /** Gets encoder's configured use of inband forward error correction. | |
| OPUS_SET_INBAND_FEC | | * @see OPUS_SET_INBAND_FEC | |
| * | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following value | |
| * @param[out] x <tt>int*</tt>: FEC flag | | s: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>Inband FEC disabled (default).</dd> | |
| | | * <dt>1</dt><dd>Inband FEC enabled.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_in
t_ptr(x) | | #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_in
t_ptr(x) | |
| | | | |
| /** Configures the encoder's expected packet loss percentage. | | /** Configures the encoder's expected packet loss percentage. | |
| * Higher values with trigger progressively more loss resistant behavior i
n the encoder | | * Higher values with trigger progressively more loss resistant behavior i
n the encoder | |
| * at the expense of quality at a given bitrate in the lossless case, but
greater quality | | * at the expense of quality at a given bitrate in the lossless case, but
greater quality | |
| * under loss. | | * under loss. | |
|
| * | | * @see OPUS_GET_PACKET_LOSS_PERC | |
| * @param[in] x <tt>int</tt>: Loss percentage in the range 0-100, inclus | | * @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, | |
| ive. | | inclusive (default: 0). | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __o
pus_check_int(x) | | #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __o
pus_check_int(x) | |
|
| /** Gets the encoder's configured packet loss percentage, @see OPUS_SET_PAC | | /** Gets the encoder's configured packet loss percentage. | |
| KET_LOSS_PERC | | * @see OPUS_SET_PACKET_LOSS_PERC | |
| * | | * @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percen | |
| * @param[out] x <tt>int*</tt>: Loss percentage in the range 0-100, inclus | | tage | |
| ive. | | * in the range 0-100, inclusive (def | |
| | | ault: 0). | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __o
pus_check_int_ptr(x) | | #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __o
pus_check_int_ptr(x) | |
| | | | |
|
| /** Configures the encoder's use of discontinuous transmission. | | /** Configures the encoder's use of discontinuous transmission (DTX). | |
| * @note This is only applicable to the LPC layer | | * @note This is only applicable to the LPC layer | |
|
| * | | * @see OPUS_GET_DTX | |
| * @param[in] x <tt>int</tt>: DTX flag, 0 (disabled) is default | | * @param[in] x <tt>opus_int32</tt>: Allowed values: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>Disable DTX (default).</dd> | |
| | | * <dt>1</dt><dd>Enabled DTX.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) | | #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) | |
|
| /** Gets encoder's configured use of discontinuous transmission, @see OPUS_ | | /** Gets encoder's configured use of discontinuous transmission. | |
| SET_DTX | | * @see OPUS_SET_DTX | |
| * | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following value | |
| * @param[out] x <tt>int*</tt>: DTX flag | | s: | |
| | | * <dl> | |
| | | * <dt>0</dt><dd>DTX disabled (default).</dd> | |
| | | * <dt>1</dt><dd>DTX enabled.</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) | | #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) | |
| /**@}*/ | | /**@}*/ | |
| | | | |
|
| /** @defgroup genericctls Generic CTLs | | /** @defgroup opus_genericctls Generic CTLs | |
| * | | * | |
| * These macros are used with the \c opus_decoder_ctl and | | * These macros are used with the \c opus_decoder_ctl and | |
| * \c opus_encoder_ctl calls to generate a particular | | * \c opus_encoder_ctl calls to generate a particular | |
| * request. | | * request. | |
| * | | * | |
| * When called on an \c OpusDecoder they apply to that | | * When called on an \c OpusDecoder they apply to that | |
| * particular decoder instance. When called on an | | * particular decoder instance. When called on an | |
| * \c OpusEncoder they apply to the corresponding setting | | * \c OpusEncoder they apply to the corresponding setting | |
| * on that encoder instance, if present. | | * on that encoder instance, if present. | |
| * | | * | |
| | | | |
| skipping to change at line 387 | | skipping to change at line 534 | |
| * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); | | * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); | |
| * | | * | |
| * opus_int32 enc_bw, dec_bw; | | * opus_int32 enc_bw, dec_bw; | |
| * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); | | * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); | |
| * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); | | * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); | |
| * if (enc_bw != dec_bw) { | | * if (enc_bw != dec_bw) { | |
| * printf("packet bandwidth mismatch!\n"); | | * printf("packet bandwidth mismatch!\n"); | |
| * } | | * } | |
| * @endcode | | * @endcode | |
| * | | * | |
|
| * @see opusencoder, opus_decoder_ctl, opus_encoder_ctl | | * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls
, opus_encoderctls | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** Resets the codec state to be equivalent to a freshly initialized state. | | /** Resets the codec state to be equivalent to a freshly initialized state. | |
| * This should be called when switching streams in order to prevent | | * This should be called when switching streams in order to prevent | |
| * the back to back decoding from giving different results from | | * the back to back decoding from giving different results from | |
| * one at a time decoding. | | * one at a time decoding. | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_RESET_STATE 4028 | | #define OPUS_RESET_STATE 4028 | |
| | | | |
| /** Gets the final state of the codec's entropy coder. | | /** Gets the final state of the codec's entropy coder. | |
| * This is used for testing purposes, | | * This is used for testing purposes, | |
| * The encoder and decoder state should be identical after coding a payloa
d | | * The encoder and decoder state should be identical after coding a payloa
d | |
| * (assuming no data corruption or software bugs) | | * (assuming no data corruption or software bugs) | |
| * | | * | |
|
| * @param[out] x <tt>opus_uint32*</tt>: Entropy coder state | | * @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state | |
| * | | * | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_
uint_ptr(x) | | #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_
uint_ptr(x) | |
| | | | |
| /** Gets the pitch of the last decoded frame, if available. | | /** Gets the pitch of the last decoded frame, if available. | |
| * This can be used for any post-processing algorithm requiring the use of
pitch, | | * This can be used for any post-processing algorithm requiring the use of
pitch, | |
| * e.g. time stretching/shortening. If the last frame was not voiced, or i
f the | | * e.g. time stretching/shortening. If the last frame was not voiced, or i
f the | |
| * pitch was not coded in the frame, then zero is returned. | | * pitch was not coded in the frame, then zero is returned. | |
| * | | * | |
| * This CTL is only implemented for decoder instances. | | * This CTL is only implemented for decoder instances. | |
| * | | * | |
|
| * @param[out] x <tt>opus_int32*</tt>: pitch period at 48 kHz (or 0 if not
available) | | * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if no
t available) | |
| * | | * | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) | | #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) | |
| | | | |
|
| /** Gets the encoder's configured bandpass or the decoder's last bandpass, | | /** Gets the encoder's configured bandpass or the decoder's last bandpass. | |
| @see OPUS_SET_BANDWIDTH | | * @see OPUS_SET_BANDWIDTH | |
| * @param[out] x <tt>int*</tt>: Bandwidth value | | * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following value | |
| | | s: | |
| | | * <dl> | |
| | | * <dt>#OPUS_AUTO</dt> <dd>(default)</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> | |
| | | * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> | |
| | | * </dl> | |
| * @hideinitializer */ | | * @hideinitializer */ | |
| #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_
ptr(x) | | #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_
ptr(x) | |
| | | | |
|
| | | /** Configures the depth of signal being encoded. | |
| | | * This is a hint which helps the encoder identify silence and near-silenc | |
| | | e. | |
| | | * @see OPUS_GET_LSB_DEPTH | |
| | | * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 an | |
| | | d 24 | |
| | | * (default: 24). | |
| | | * @hideinitializer */ | |
| | | #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int( | |
| | | x) | |
| | | /** Gets the encoder's configured signal depth. | |
| | | * @see OPUS_SET_LSB_DEPTH | |
| | | * @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 | |
| | | and | |
| | | * 24 (default: 24). | |
| | | * @hideinitializer */ | |
| | | #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ | |
| | | ptr(x) | |
| | | /**@}*/ | |
| | | | |
| | | /** @defgroup opus_decoderctls Decoder related CTLs | |
| | | * @see opus_genericctls, opus_encoderctls, opus_decoder | |
| | | * @{ | |
| | | */ | |
| | | | |
| | | /** Configures decoder gain adjustment. | |
| | | * Scales the decoded output by a factor specified in Q8 dB units. | |
| | | * This has a maximum range of -32768 to 32767 inclusive, and returns | |
| | | * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. | |
| | | * This setting survives decoder reset. | |
| | | * | |
| | | * gain = pow(10, x/(20.0*256)) | |
| | | * | |
| | | * @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 | |
| | | dB units. | |
| | | * @hideinitializer */ | |
| | | #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) | |
| | | /** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN | |
| | | * | |
| | | * @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q | |
| | | 8 dB units. | |
| | | * @hideinitializer */ | |
| | | #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) | |
| | | | |
| /**@}*/ | | /**@}*/ | |
| | | | |
|
| /** @defgroup libinfo Opus library information functions | | /** @defgroup opus_libinfo Opus library information functions | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| /** Converts an opus error code into a human readable string. | | /** Converts an opus error code into a human readable string. | |
| * | | * | |
| * @param[in] error <tt>int</tt>: Error number | | * @param[in] error <tt>int</tt>: Error number | |
| * @returns Error string | | * @returns Error string | |
| */ | | */ | |
| OPUS_EXPORT const char *opus_strerror(int error); | | OPUS_EXPORT const char *opus_strerror(int error); | |
| | | | |
| | | | |
End of changes. 51 change blocks. |
| 139 lines changed or deleted | | 355 lines changed or added | |
|
| opus_multistream.h | | opus_multistream.h | |
|
| /* Copyright (c) 2011-2012 IETF Trust, Xiph.Org Foundation. All rights rese
rved. | | /* Copyright (c) 2011 Xiph.Org Foundation | |
| Written by Jean-Marc Valin */ | | Written by Jean-Marc Valin */ | |
| /* | | /* | |
|
| | | | |
| This file is extracted from RFC6716. Please see that RFC for additional | | | |
| information. | | | |
| | | | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions | | modification, are permitted provided that the following conditions | |
| are met: | | are met: | |
| | | | |
| - Redistributions of source code must retain the above copyright | | - Redistributions of source code must retain the above copyright | |
| notice, this list of conditions and the following disclaimer. | | notice, this list of conditions and the following disclaimer. | |
| | | | |
| - Redistributions in binary form must reproduce the above copyright | | - Redistributions in binary form must reproduce the above copyright | |
| notice, this list of conditions and the following disclaimer in the | | notice, this list of conditions and the following disclaimer in the | |
| documentation and/or other materials provided with the distribution. | | documentation and/or other materials provided with the distribution. | |
| | | | |
|
| - Neither the name of Internet Society, IETF or IETF Trust, nor the | | | |
| names of specific contributors, may be used to endorse or promote | | | |
| products derived from this software without specific prior written | | | |
| permission. | | | |
| | | | |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWN
ER | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWN
ER | |
| OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| | | | |
| skipping to change at line 66 | | skipping to change at line 57 | |
| | | | |
| #define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 | | #define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 | |
| #define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 | | #define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 | |
| | | | |
| #define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODE
R_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) | | #define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODE
R_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) | |
| #define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODE
R_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) | | #define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODE
R_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) | |
| | | | |
| /** Allocate and initialize a multistream encoder state object. | | /** Allocate and initialize a multistream encoder state object. | |
| * Call opus_multistream_encoder_destroy() to release | | * Call opus_multistream_encoder_destroy() to release | |
| * this object when finished. */ | | * this object when finished. */ | |
|
| OPUS_EXPORT OpusMSEncoder *opus_multistream_encoder_create( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder
_create( | |
| opus_int32 Fs, /**< Sampling rate of input signal (Hz) */ | | opus_int32 Fs, /**< Sampling rate of input signal (Hz) */ | |
| int channels, /**< Number of channels in the input signal
*/ | | int channels, /**< Number of channels in the input signal
*/ | |
| int streams, /**< Total number of streams to encode from
the input */ | | int streams, /**< Total number of streams to encode from
the input */ | |
| int coupled_streams, /**< Number of coupled (stereo) streams to
encode */ | | int coupled_streams, /**< Number of coupled (stereo) streams to
encode */ | |
|
| unsigned char *mapping, /**< Encoded mapping between channels and s
treams */ | | const unsigned char *mapping, /**< Encoded mapping between channels a
nd streams */ | |
| int application, /**< Coding mode (OPUS_APPLICATION_VOIP/OPU
S_APPLICATION_AUDIO) */ | | int application, /**< Coding mode (OPUS_APPLICATION_VOIP/OPU
S_APPLICATION_AUDIO) */ | |
| int *error /**< Error code */ | | int *error /**< Error code */ | |
|
| ); | | ) OPUS_ARG_NONNULL(5); | |
| | | | |
| /** Initialize an already allocated multistream encoder state. */ | | /** Initialize an already allocated multistream encoder state. */ | |
| OPUS_EXPORT int opus_multistream_encoder_init( | | OPUS_EXPORT int opus_multistream_encoder_init( | |
| OpusMSEncoder *st, /**< Encoder state */ | | OpusMSEncoder *st, /**< Encoder state */ | |
| opus_int32 Fs, /**< Sampling rate of input signal (Hz) */ | | opus_int32 Fs, /**< Sampling rate of input signal (Hz) */ | |
| int channels, /**< Number of channels in the input signal
*/ | | int channels, /**< Number of channels in the input signal
*/ | |
| int streams, /**< Total number of streams to encode from
the input */ | | int streams, /**< Total number of streams to encode from
the input */ | |
| int coupled_streams, /**< Number of coupled (stereo) streams to
encode */ | | int coupled_streams, /**< Number of coupled (stereo) streams to
encode */ | |
|
| unsigned char *mapping, /**< Encoded mapping between channels and s
treams */ | | const unsigned char *mapping, /**< Encoded mapping between channels a
nd streams */ | |
| int application /**< Coding mode (OPUS_APPLICATION_VOIP/OPU
S_APPLICATION_AUDIO) */ | | int application /**< Coding mode (OPUS_APPLICATION_VOIP/OPU
S_APPLICATION_AUDIO) */ | |
|
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); | |
| | | | |
| /** Returns length of the data payload (in bytes) or a negative error code
*/ | | /** Returns length of the data payload (in bytes) or a negative error code
*/ | |
|
| OPUS_EXPORT int opus_multistream_encode( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( | |
| OpusMSEncoder *st, /**< Encoder state */ | | OpusMSEncoder *st, /**< Encoder state */ | |
| const opus_int16 *pcm, /**< Input signal as interleaved samples. L
ength is frame_size*channels */ | | const opus_int16 *pcm, /**< Input signal as interleaved samples. L
ength is frame_size*channels */ | |
| int frame_size, /**< Number of samples per frame of input s
ignal */ | | int frame_size, /**< Number of samples per frame of input s
ignal */ | |
| unsigned char *data, /**< Output buffer for the compressed paylo
ad (no more than max_data_bytes long) */ | | unsigned char *data, /**< Output buffer for the compressed paylo
ad (no more than max_data_bytes long) */ | |
|
| int max_data_bytes /**< Allocated memory for payload; don't us | | opus_int32 max_data_bytes /**< Allocated memory for payload; don't us | |
| e for controlling bitrate */ | | e for controlling bitrate */ | |
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Returns length of the data payload (in bytes) or a negative error code.
*/ | | /** Returns length of the data payload (in bytes) or a negative error code.
*/ | |
|
| OPUS_EXPORT int opus_multistream_encode_float( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float( | |
| OpusMSEncoder *st, /**< Encoder state */ | | OpusMSEncoder *st, /**< Encoder state */ | |
| const float *pcm, /**< Input signal interleaved in channel or
der. length is frame_size*channels */ | | const float *pcm, /**< Input signal interleaved in channel or
der. length is frame_size*channels */ | |
| int frame_size, /**< Number of samples per frame of input s
ignal */ | | int frame_size, /**< Number of samples per frame of input s
ignal */ | |
| unsigned char *data, /**< Output buffer for the compressed paylo
ad (no more than max_data_bytes long) */ | | unsigned char *data, /**< Output buffer for the compressed paylo
ad (no more than max_data_bytes long) */ | |
|
| int max_data_bytes /**< Allocated memory for payload; don't us | | opus_int32 max_data_bytes /**< Allocated memory for payload; don't us | |
| e for controlling bitrate */ | | e for controlling bitrate */ | |
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Gets the size of an OpusMSEncoder structure. | | /** Gets the size of an OpusMSEncoder structure. | |
| * @returns size | | * @returns size | |
| */ | | */ | |
|
| OPUS_EXPORT opus_int32 opus_multistream_encoder_get_size( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get
_size( | |
| int streams, /**< Total number of coded streams */ | | int streams, /**< Total number of coded streams */ | |
| int coupled_streams /**< Number of coupled (stereo) streams */ | | int coupled_streams /**< Number of coupled (stereo) streams */ | |
| ); | | ); | |
| | | | |
| /** Deallocate a multstream encoder state */ | | /** Deallocate a multstream encoder state */ | |
| OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); | | OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); | |
| | | | |
| /** Get or set options on a multistream encoder state */ | | /** Get or set options on a multistream encoder state */ | |
|
| OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request
, ...); | | OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request
, ...) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Allocate and initialize a multistream decoder state object. | | /** Allocate and initialize a multistream decoder state object. | |
| * Call opus_multistream_decoder_destroy() to release | | * Call opus_multistream_decoder_destroy() to release | |
| * this object when finished. */ | | * this object when finished. */ | |
|
| OPUS_EXPORT OpusMSDecoder *opus_multistream_decoder_create( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder
_create( | |
| opus_int32 Fs, /**< Sampling rate to decode at (Hz) */ | | opus_int32 Fs, /**< Sampling rate to decode at (Hz) */ | |
| int channels, /**< Number of channels to decode */ | | int channels, /**< Number of channels to decode */ | |
| int streams, /**< Total number of coded streams in the m
ultistream */ | | int streams, /**< Total number of coded streams in the m
ultistream */ | |
| int coupled_streams, /**< Number of coupled (stereo) streams in
the multistream */ | | int coupled_streams, /**< Number of coupled (stereo) streams in
the multistream */ | |
|
| unsigned char *mapping, /**< Stream to channel mapping table */ | | const unsigned char *mapping, /**< Stream to channel mapping table */ | |
| int *error /**< Error code */ | | int *error /**< Error code */ | |
|
| ); | | ) OPUS_ARG_NONNULL(5); | |
| | | | |
| /** Intialize a previously allocated decoder state object. */ | | /** Intialize a previously allocated decoder state object. */ | |
| OPUS_EXPORT int opus_multistream_decoder_init( | | OPUS_EXPORT int opus_multistream_decoder_init( | |
| OpusMSDecoder *st, /**< Encoder state */ | | OpusMSDecoder *st, /**< Encoder state */ | |
| opus_int32 Fs, /**< Sample rate of input signal (Hz) */ | | opus_int32 Fs, /**< Sample rate of input signal (Hz) */ | |
| int channels, /**< Number of channels in the input signal
*/ | | int channels, /**< Number of channels in the input signal
*/ | |
| int streams, /**< Total number of coded streams */ | | int streams, /**< Total number of coded streams */ | |
| int coupled_streams, /**< Number of coupled (stereo) streams */ | | int coupled_streams, /**< Number of coupled (stereo) streams */ | |
|
| unsigned char *mapping /**< Stream to channel mapping table */ | | const unsigned char *mapping /**< Stream to channel mapping table */ | |
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); | |
| | | | |
| /** Returns the number of samples decoded or a negative error code */ | | /** Returns the number of samples decoded or a negative error code */ | |
|
| OPUS_EXPORT int opus_multistream_decode( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode( | |
| OpusMSDecoder *st, /**< Decoder state */ | | OpusMSDecoder *st, /**< Decoder state */ | |
| const unsigned char *data, /**< Input payload. Use a NULL pointer to i
ndicate packet loss */ | | const unsigned char *data, /**< Input payload. Use a NULL pointer to i
ndicate packet loss */ | |
|
| int len, /**< Number of bytes in payload */ | | opus_int32 len, /**< Number of bytes in payload */ | |
| opus_int16 *pcm, /**< Output signal, samples interleaved in
channel order . length is frame_size*channels */ | | opus_int16 *pcm, /**< Output signal, samples interleaved in
channel order . length is frame_size*channels */ | |
| int frame_size, /**< Number of samples per frame of input s
ignal */ | | int frame_size, /**< Number of samples per frame of input s
ignal */ | |
| int decode_fec /**< Flag (0/1) to request that any in-band
forward error correction data be */ | | int decode_fec /**< Flag (0/1) to request that any in-band
forward error correction data be */ | |
| /**< decoded. If no such data is available
the frame is decoded as if it were lost. */ | | /**< decoded. If no such data is available
the frame is decoded as if it were lost. */ | |
|
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Returns the number of samples decoded or a negative error code */ | | /** Returns the number of samples decoded or a negative error code */ | |
|
| OPUS_EXPORT int opus_multistream_decode_float( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float( | |
| OpusMSDecoder *st, /**< Decoder state */ | | OpusMSDecoder *st, /**< Decoder state */ | |
| const unsigned char *data, /**< Input payload buffer. Use a NULL point
er to indicate packet loss */ | | const unsigned char *data, /**< Input payload buffer. Use a NULL point
er to indicate packet loss */ | |
|
| int len, /**< Number of payload bytes in data */ | | opus_int32 len, /**< Number of payload bytes in data */ | |
| float *pcm, /**< Buffer for the output signal (interlea
ved iin channel order). length is frame_size*channels */ | | float *pcm, /**< Buffer for the output signal (interlea
ved iin channel order). length is frame_size*channels */ | |
| int frame_size, /**< Number of samples per frame of input s
ignal */ | | int frame_size, /**< Number of samples per frame of input s
ignal */ | |
| int decode_fec /**< Flag (0/1) to request that any in-band
forward error correction data be */ | | int decode_fec /**< Flag (0/1) to request that any in-band
forward error correction data be */ | |
| /**< decoded. If no such data is available
the frame is decoded as if it were lost. */ | | /**< decoded. If no such data is available
the frame is decoded as if it were lost. */ | |
|
| ); | | ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); | |
| | | | |
| /** Gets the size of an OpusMSDecoder structure. | | /** Gets the size of an OpusMSDecoder structure. | |
| * @returns size | | * @returns size | |
| */ | | */ | |
|
| OPUS_EXPORT opus_int32 opus_multistream_decoder_get_size( | | OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get
_size( | |
| int streams, /**< Total number of coded streams */ | | int streams, /**< Total number of coded streams */ | |
| int coupled_streams /**< Number of coupled (stereo) streams */ | | int coupled_streams /**< Number of coupled (stereo) streams */ | |
| ); | | ); | |
| | | | |
| /** Get or set options on a multistream decoder state */ | | /** Get or set options on a multistream decoder state */ | |
|
| OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request
, ...); | | OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request
, ...) OPUS_ARG_NONNULL(1); | |
| | | | |
| /** Deallocate a multistream decoder state object */ | | /** Deallocate a multistream decoder state object */ | |
| OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); | | OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* OPUS_MULTISTREAM_H */ | | #endif /* OPUS_MULTISTREAM_H */ | |
| | | | |
End of changes. 26 change blocks. |
| 38 lines changed or deleted | | 29 lines changed or added | |
|