Chris@69: /* Copyright (c) 2017 Google Inc. Chris@69: Written by Andrew Allen */ Chris@69: /* Chris@69: Redistribution and use in source and binary forms, with or without Chris@69: modification, are permitted provided that the following conditions Chris@69: are met: Chris@69: Chris@69: - Redistributions of source code must retain the above copyright Chris@69: notice, this list of conditions and the following disclaimer. Chris@69: Chris@69: - Redistributions in binary form must reproduce the above copyright Chris@69: notice, this list of conditions and the following disclaimer in the Chris@69: documentation and/or other materials provided with the distribution. Chris@69: Chris@69: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@69: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@69: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@69: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER Chris@69: OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@69: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@69: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@69: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@69: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@69: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@69: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@69: */ Chris@69: Chris@69: /** Chris@69: * @file opus_projection.h Chris@69: * @brief Opus projection reference API Chris@69: */ Chris@69: Chris@69: #ifndef OPUS_PROJECTION_H Chris@69: #define OPUS_PROJECTION_H Chris@69: Chris@69: #include "opus_multistream.h" Chris@69: Chris@69: #ifdef __cplusplus Chris@69: extern "C" { Chris@69: #endif Chris@69: Chris@69: /** @cond OPUS_INTERNAL_DOC */ Chris@69: Chris@69: /** These are the actual encoder and decoder CTL ID numbers. Chris@69: * They should not be used directly by applications.c Chris@69: * In general, SETs should be even and GETs should be odd.*/ Chris@69: /**@{*/ Chris@69: #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST 6001 Chris@69: #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST 6003 Chris@69: #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST 6005 Chris@69: /**@}*/ Chris@69: Chris@69: Chris@69: /** @endcond */ Chris@69: Chris@69: /** @defgroup opus_projection_ctls Projection specific encoder and decoder CTLs Chris@69: * Chris@69: * These are convenience macros that are specific to the Chris@69: * opus_projection_encoder_ctl() and opus_projection_decoder_ctl() Chris@69: * interface. Chris@69: * The CTLs from @ref opus_genericctls, @ref opus_encoderctls, Chris@69: * @ref opus_decoderctls, and @ref opus_multistream_ctls may be applied to a Chris@69: * projection encoder or decoder as well. Chris@69: */ Chris@69: /**@{*/ Chris@69: Chris@69: /** Gets the gain (in dB. S7.8-format) of the demixing matrix from the encoder. Chris@69: * @param[out] x opus_int32 *: Returns the gain (in dB. S7.8-format) Chris@69: * of the demixing matrix. Chris@69: * @hideinitializer Chris@69: */ Chris@69: #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: Chris@69: /** Gets the size in bytes of the demixing matrix from the encoder. Chris@69: * @param[out] x opus_int32 *: Returns the size in bytes of the Chris@69: * demixing matrix. Chris@69: * @hideinitializer Chris@69: */ Chris@69: #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, __opus_check_int_ptr(x) Chris@69: Chris@69: Chris@69: /** Copies the demixing matrix to the supplied pointer location. Chris@69: * @param[out] x unsigned char *: Returns the demixing matrix to the Chris@69: * supplied pointer location. Chris@69: * @param y opus_int32: The size in bytes of the reserved memory at the Chris@69: * pointer location. Chris@69: * @hideinitializer Chris@69: */ Chris@69: #define OPUS_PROJECTION_GET_DEMIXING_MATRIX(x,y) OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, x, __opus_check_int(y) Chris@69: Chris@69: Chris@69: /**@}*/ Chris@69: Chris@69: /** Opus projection encoder state. Chris@69: * This contains the complete state of a projection Opus encoder. Chris@69: * It is position independent and can be freely copied. Chris@69: * @see opus_projection_ambisonics_encoder_create Chris@69: */ Chris@69: typedef struct OpusProjectionEncoder OpusProjectionEncoder; Chris@69: Chris@69: Chris@69: /** Opus projection decoder state. Chris@69: * This contains the complete state of a projection Opus decoder. Chris@69: * It is position independent and can be freely copied. Chris@69: * @see opus_projection_decoder_create Chris@69: * @see opus_projection_decoder_init Chris@69: */ Chris@69: typedef struct OpusProjectionDecoder OpusProjectionDecoder; Chris@69: Chris@69: Chris@69: /**\name Projection encoder functions */ Chris@69: /**@{*/ Chris@69: Chris@69: /** Gets the size of an OpusProjectionEncoder structure. Chris@69: * @param channels int: The total number of input channels to encode. Chris@69: * This must be no more than 255. Chris@69: * @param mapping_family int: The mapping family to use for selecting Chris@69: * the appropriate projection. Chris@69: * @returns The size in bytes on success, or a negative error code Chris@69: * (see @ref opus_errorcodes) on error. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_ambisonics_encoder_get_size( Chris@69: int channels, Chris@69: int mapping_family Chris@69: ); Chris@69: Chris@69: Chris@69: /** Allocates and initializes a projection encoder state. Chris@69: * Call opus_projection_encoder_destroy() to release Chris@69: * this object when finished. Chris@69: * @param Fs opus_int32: Sampling rate of the input signal (in Hz). Chris@69: * This must be one of 8000, 12000, 16000, Chris@69: * 24000, or 48000. Chris@69: * @param channels int: Number of channels in the input signal. Chris@69: * This must be at most 255. Chris@69: * It may be greater than the number of Chris@69: * coded channels (streams + Chris@69: * coupled_streams). Chris@69: * @param mapping_family int: The mapping family to use for selecting Chris@69: * the appropriate projection. Chris@69: * @param[out] streams int *: The total number of streams that will Chris@69: * be encoded from the input. Chris@69: * @param[out] coupled_streams int *: Number of coupled (2 channel) Chris@69: * streams that will be encoded from the input. Chris@69: * @param application int: The target encoder application. Chris@69: * This must be one of the following: Chris@69: *
Chris@69: *
#OPUS_APPLICATION_VOIP
Chris@69: *
Process signal for improved speech intelligibility.
Chris@69: *
#OPUS_APPLICATION_AUDIO
Chris@69: *
Favor faithfulness to the original input.
Chris@69: *
#OPUS_APPLICATION_RESTRICTED_LOWDELAY
Chris@69: *
Configure the minimum possible coding delay by disabling certain modes Chris@69: * of operation.
Chris@69: *
Chris@69: * @param[out] error int *: Returns #OPUS_OK on success, or an error Chris@69: * code (see @ref opus_errorcodes) on Chris@69: * failure. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionEncoder *opus_projection_ambisonics_encoder_create( Chris@69: opus_int32 Fs, Chris@69: int channels, Chris@69: int mapping_family, Chris@69: int *streams, Chris@69: int *coupled_streams, Chris@69: int application, Chris@69: int *error Chris@69: ) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5); Chris@69: Chris@69: Chris@69: /** Initialize a previously allocated projection encoder state. Chris@69: * The memory pointed to by \a st must be at least the size returned by Chris@69: * opus_projection_ambisonics_encoder_get_size(). Chris@69: * This is intended for applications which use their own allocator instead of Chris@69: * malloc. Chris@69: * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. Chris@69: * @see opus_projection_ambisonics_encoder_create Chris@69: * @see opus_projection_ambisonics_encoder_get_size Chris@69: * @param st OpusProjectionEncoder*: Projection encoder state to initialize. Chris@69: * @param Fs opus_int32: Sampling rate of the input signal (in Hz). Chris@69: * This must be one of 8000, 12000, 16000, Chris@69: * 24000, or 48000. Chris@69: * @param channels int: Number of channels in the input signal. Chris@69: * This must be at most 255. Chris@69: * It may be greater than the number of Chris@69: * coded channels (streams + Chris@69: * coupled_streams). Chris@69: * @param streams int: The total number of streams to encode from the Chris@69: * input. Chris@69: * This must be no more than the number of channels. Chris@69: * @param coupled_streams int: Number of coupled (2 channel) streams Chris@69: * to encode. Chris@69: * This must be no larger than the total Chris@69: * number of streams. Chris@69: * Additionally, The total number of Chris@69: * encoded channels (streams + Chris@69: * coupled_streams) must be no Chris@69: * more than the number of input channels. Chris@69: * @param application int: The target encoder application. Chris@69: * This must be one of the following: Chris@69: *
Chris@69: *
#OPUS_APPLICATION_VOIP
Chris@69: *
Process signal for improved speech intelligibility.
Chris@69: *
#OPUS_APPLICATION_AUDIO
Chris@69: *
Favor faithfulness to the original input.
Chris@69: *
#OPUS_APPLICATION_RESTRICTED_LOWDELAY
Chris@69: *
Configure the minimum possible coding delay by disabling certain modes Chris@69: * of operation.
Chris@69: *
Chris@69: * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) Chris@69: * on failure. Chris@69: */ Chris@69: OPUS_EXPORT int opus_projection_ambisonics_encoder_init( Chris@69: OpusProjectionEncoder *st, Chris@69: opus_int32 Fs, Chris@69: int channels, Chris@69: int mapping_family, Chris@69: int *streams, Chris@69: int *coupled_streams, Chris@69: int application Chris@69: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6); Chris@69: Chris@69: Chris@69: /** Encodes a projection Opus frame. Chris@69: * @param st OpusProjectionEncoder*: Projection encoder state. Chris@69: * @param[in] pcm const opus_int16*: The input signal as interleaved Chris@69: * samples. Chris@69: * This must contain Chris@69: * frame_size*channels Chris@69: * samples. Chris@69: * @param frame_size int: Number of samples per channel in the input Chris@69: * signal. Chris@69: * This must be an Opus frame size for the Chris@69: * encoder's sampling rate. Chris@69: * For example, at 48 kHz the permitted values Chris@69: * are 120, 240, 480, 960, 1920, and 2880. Chris@69: * Passing in a duration of less than 10 ms Chris@69: * (480 samples at 48 kHz) will prevent the Chris@69: * encoder from using the LPC or hybrid modes. Chris@69: * @param[out] data unsigned char*: Output payload. Chris@69: * This must contain storage for at Chris@69: * least \a max_data_bytes. Chris@69: * @param [in] max_data_bytes opus_int32: Size of the allocated Chris@69: * memory for the output Chris@69: * payload. This may be Chris@69: * used to impose an upper limit on Chris@69: * the instant bitrate, but should Chris@69: * not be used as the only bitrate Chris@69: * control. Use #OPUS_SET_BITRATE to Chris@69: * control the bitrate. Chris@69: * @returns The length of the encoded packet (in bytes) on success or a Chris@69: * negative error code (see @ref opus_errorcodes) on failure. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode( Chris@69: OpusProjectionEncoder *st, Chris@69: const opus_int16 *pcm, Chris@69: int frame_size, Chris@69: unsigned char *data, Chris@69: opus_int32 max_data_bytes Chris@69: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); Chris@69: Chris@69: Chris@69: /** Encodes a projection Opus frame from floating point input. Chris@69: * @param st OpusProjectionEncoder*: Projection encoder state. Chris@69: * @param[in] pcm const float*: The input signal as interleaved Chris@69: * samples with a normal range of Chris@69: * +/-1.0. Chris@69: * Samples with a range beyond +/-1.0 Chris@69: * are supported but will be clipped by Chris@69: * decoders using the integer API and Chris@69: * should only be used if it is known Chris@69: * that the far end supports extended Chris@69: * dynamic range. Chris@69: * This must contain Chris@69: * frame_size*channels Chris@69: * samples. Chris@69: * @param frame_size int: Number of samples per channel in the input Chris@69: * signal. Chris@69: * This must be an Opus frame size for the Chris@69: * encoder's sampling rate. Chris@69: * For example, at 48 kHz the permitted values Chris@69: * are 120, 240, 480, 960, 1920, and 2880. Chris@69: * Passing in a duration of less than 10 ms Chris@69: * (480 samples at 48 kHz) will prevent the Chris@69: * encoder from using the LPC or hybrid modes. Chris@69: * @param[out] data unsigned char*: Output payload. Chris@69: * This must contain storage for at Chris@69: * least \a max_data_bytes. Chris@69: * @param [in] max_data_bytes opus_int32: Size of the allocated Chris@69: * memory for the output Chris@69: * payload. This may be Chris@69: * used to impose an upper limit on Chris@69: * the instant bitrate, but should Chris@69: * not be used as the only bitrate Chris@69: * control. Use #OPUS_SET_BITRATE to Chris@69: * control the bitrate. Chris@69: * @returns The length of the encoded packet (in bytes) on success or a Chris@69: * negative error code (see @ref opus_errorcodes) on failure. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode_float( Chris@69: OpusProjectionEncoder *st, Chris@69: const float *pcm, Chris@69: int frame_size, Chris@69: unsigned char *data, Chris@69: opus_int32 max_data_bytes Chris@69: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); Chris@69: Chris@69: Chris@69: /** Frees an OpusProjectionEncoder allocated by Chris@69: * opus_projection_ambisonics_encoder_create(). Chris@69: * @param st OpusProjectionEncoder*: Projection encoder state to be freed. Chris@69: */ Chris@69: OPUS_EXPORT void opus_projection_encoder_destroy(OpusProjectionEncoder *st); Chris@69: Chris@69: Chris@69: /** Perform a CTL function on a projection Opus encoder. Chris@69: * Chris@69: * Generally the request and subsequent arguments are generated by a Chris@69: * convenience macro. Chris@69: * @param st OpusProjectionEncoder*: Projection encoder state. Chris@69: * @param request This and all remaining parameters should be replaced by one Chris@69: * of the convenience macros in @ref opus_genericctls, Chris@69: * @ref opus_encoderctls, @ref opus_multistream_ctls, or Chris@69: * @ref opus_projection_ctls Chris@69: * @see opus_genericctls Chris@69: * @see opus_encoderctls Chris@69: * @see opus_multistream_ctls Chris@69: * @see opus_projection_ctls Chris@69: */ Chris@69: OPUS_EXPORT int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); Chris@69: Chris@69: Chris@69: /**@}*/ Chris@69: Chris@69: /**\name Projection decoder functions */ Chris@69: /**@{*/ Chris@69: Chris@69: /** Gets the size of an OpusProjectionDecoder structure. Chris@69: * @param channels int: The total number of output channels. Chris@69: * This must be no more than 255. Chris@69: * @param streams int: The total number of streams coded in the Chris@69: * input. Chris@69: * This must be no more than 255. Chris@69: * @param coupled_streams int: Number streams to decode as coupled Chris@69: * (2 channel) streams. Chris@69: * This must be no larger than the total Chris@69: * number of streams. Chris@69: * Additionally, The total number of Chris@69: * coded channels (streams + Chris@69: * coupled_streams) must be no Chris@69: * more than 255. Chris@69: * @returns The size in bytes on success, or a negative error code Chris@69: * (see @ref opus_errorcodes) on error. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_decoder_get_size( Chris@69: int channels, Chris@69: int streams, Chris@69: int coupled_streams Chris@69: ); Chris@69: Chris@69: Chris@69: /** Allocates and initializes a projection decoder state. Chris@69: * Call opus_projection_decoder_destroy() to release Chris@69: * this object when finished. Chris@69: * @param Fs opus_int32: Sampling rate to decode at (in Hz). Chris@69: * This must be one of 8000, 12000, 16000, Chris@69: * 24000, or 48000. Chris@69: * @param channels int: Number of channels to output. Chris@69: * This must be at most 255. Chris@69: * It may be different from the number of coded Chris@69: * channels (streams + Chris@69: * coupled_streams). Chris@69: * @param streams int: The total number of streams coded in the Chris@69: * input. Chris@69: * This must be no more than 255. Chris@69: * @param coupled_streams int: Number of streams to decode as coupled Chris@69: * (2 channel) streams. Chris@69: * This must be no larger than the total Chris@69: * number of streams. Chris@69: * Additionally, The total number of Chris@69: * coded channels (streams + Chris@69: * coupled_streams) must be no Chris@69: * more than 255. Chris@69: * @param[in] demixing_matrix const unsigned char[demixing_matrix_size]: Demixing matrix Chris@69: * that mapping from coded channels to output channels, Chris@69: * as described in @ref opus_projection and Chris@69: * @ref opus_projection_ctls. Chris@69: * @param demixing_matrix_size opus_int32: The size in bytes of the Chris@69: * demixing matrix, as Chris@69: * described in @ref Chris@69: * opus_projection_ctls. Chris@69: * @param[out] error int *: Returns #OPUS_OK on success, or an error Chris@69: * code (see @ref opus_errorcodes) on Chris@69: * failure. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionDecoder *opus_projection_decoder_create( Chris@69: opus_int32 Fs, Chris@69: int channels, Chris@69: int streams, Chris@69: int coupled_streams, Chris@69: unsigned char *demixing_matrix, Chris@69: opus_int32 demixing_matrix_size, Chris@69: int *error Chris@69: ) OPUS_ARG_NONNULL(5); Chris@69: Chris@69: Chris@69: /** Intialize a previously allocated projection decoder state object. Chris@69: * The memory pointed to by \a st must be at least the size returned by Chris@69: * opus_projection_decoder_get_size(). Chris@69: * This is intended for applications which use their own allocator instead of Chris@69: * malloc. Chris@69: * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. Chris@69: * @see opus_projection_decoder_create Chris@69: * @see opus_projection_deocder_get_size Chris@69: * @param st OpusProjectionDecoder*: Projection encoder state to initialize. Chris@69: * @param Fs opus_int32: Sampling rate to decode at (in Hz). Chris@69: * This must be one of 8000, 12000, 16000, Chris@69: * 24000, or 48000. Chris@69: * @param channels int: Number of channels to output. Chris@69: * This must be at most 255. Chris@69: * It may be different from the number of coded Chris@69: * channels (streams + Chris@69: * coupled_streams). Chris@69: * @param streams int: The total number of streams coded in the Chris@69: * input. Chris@69: * This must be no more than 255. Chris@69: * @param coupled_streams int: Number of streams to decode as coupled Chris@69: * (2 channel) streams. Chris@69: * This must be no larger than the total Chris@69: * number of streams. Chris@69: * Additionally, The total number of Chris@69: * coded channels (streams + Chris@69: * coupled_streams) must be no Chris@69: * more than 255. Chris@69: * @param[in] demixing_matrix const unsigned char[demixing_matrix_size]: Demixing matrix Chris@69: * that mapping from coded channels to output channels, Chris@69: * as described in @ref opus_projection and Chris@69: * @ref opus_projection_ctls. Chris@69: * @param demixing_matrix_size opus_int32: The size in bytes of the Chris@69: * demixing matrix, as Chris@69: * described in @ref Chris@69: * opus_projection_ctls. Chris@69: * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) Chris@69: * on failure. Chris@69: */ Chris@69: OPUS_EXPORT int opus_projection_decoder_init( Chris@69: OpusProjectionDecoder *st, Chris@69: opus_int32 Fs, Chris@69: int channels, Chris@69: int streams, Chris@69: int coupled_streams, Chris@69: unsigned char *demixing_matrix, Chris@69: opus_int32 demixing_matrix_size Chris@69: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); Chris@69: Chris@69: Chris@69: /** Decode a projection Opus packet. Chris@69: * @param st OpusProjectionDecoder*: Projection decoder state. Chris@69: * @param[in] data const unsigned char*: Input payload. Chris@69: * Use a NULL Chris@69: * pointer to indicate packet Chris@69: * loss. Chris@69: * @param len opus_int32: Number of bytes in payload. Chris@69: * @param[out] pcm opus_int16*: Output signal, with interleaved Chris@69: * samples. Chris@69: * This must contain room for Chris@69: * frame_size*channels Chris@69: * samples. Chris@69: * @param frame_size int: The number of samples per channel of Chris@69: * available space in \a pcm. Chris@69: * If this is less than the maximum packet duration Chris@69: * (120 ms; 5760 for 48kHz), this function will not be capable Chris@69: * of decoding some packets. In the case of PLC (data==NULL) Chris@69: * or FEC (decode_fec=1), then frame_size needs to be exactly Chris@69: * the duration of audio that is missing, otherwise the Chris@69: * decoder will not be in the optimal state to decode the Chris@69: * next incoming packet. For the PLC and FEC cases, frame_size Chris@69: * must be a multiple of 2.5 ms. Chris@69: * @param decode_fec int: Flag (0 or 1) to request that any in-band Chris@69: * forward error correction data be decoded. Chris@69: * If no such data is available, the frame is Chris@69: * decoded as if it were lost. Chris@69: * @returns Number of samples decoded on success or a negative error code Chris@69: * (see @ref opus_errorcodes) on failure. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode( Chris@69: OpusProjectionDecoder *st, Chris@69: const unsigned char *data, Chris@69: opus_int32 len, Chris@69: opus_int16 *pcm, Chris@69: int frame_size, Chris@69: int decode_fec Chris@69: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); Chris@69: Chris@69: Chris@69: /** Decode a projection Opus packet with floating point output. Chris@69: * @param st OpusProjectionDecoder*: Projection decoder state. Chris@69: * @param[in] data const unsigned char*: Input payload. Chris@69: * Use a NULL Chris@69: * pointer to indicate packet Chris@69: * loss. Chris@69: * @param len opus_int32: Number of bytes in payload. Chris@69: * @param[out] pcm opus_int16*: Output signal, with interleaved Chris@69: * samples. Chris@69: * This must contain room for Chris@69: * frame_size*channels Chris@69: * samples. Chris@69: * @param frame_size int: The number of samples per channel of Chris@69: * available space in \a pcm. Chris@69: * If this is less than the maximum packet duration Chris@69: * (120 ms; 5760 for 48kHz), this function will not be capable Chris@69: * of decoding some packets. In the case of PLC (data==NULL) Chris@69: * or FEC (decode_fec=1), then frame_size needs to be exactly Chris@69: * the duration of audio that is missing, otherwise the Chris@69: * decoder will not be in the optimal state to decode the Chris@69: * next incoming packet. For the PLC and FEC cases, frame_size Chris@69: * must be a multiple of 2.5 ms. Chris@69: * @param decode_fec int: Flag (0 or 1) to request that any in-band Chris@69: * forward error correction data be decoded. Chris@69: * If no such data is available, the frame is Chris@69: * decoded as if it were lost. Chris@69: * @returns Number of samples decoded on success or a negative error code Chris@69: * (see @ref opus_errorcodes) on failure. Chris@69: */ Chris@69: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode_float( Chris@69: OpusProjectionDecoder *st, Chris@69: const unsigned char *data, Chris@69: opus_int32 len, Chris@69: float *pcm, Chris@69: int frame_size, Chris@69: int decode_fec Chris@69: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); Chris@69: Chris@69: Chris@69: /** Perform a CTL function on a projection Opus decoder. Chris@69: * Chris@69: * Generally the request and subsequent arguments are generated by a Chris@69: * convenience macro. Chris@69: * @param st OpusProjectionDecoder*: Projection decoder state. Chris@69: * @param request This and all remaining parameters should be replaced by one Chris@69: * of the convenience macros in @ref opus_genericctls, Chris@69: * @ref opus_decoderctls, @ref opus_multistream_ctls, or Chris@69: * @ref opus_projection_ctls. Chris@69: * @see opus_genericctls Chris@69: * @see opus_decoderctls Chris@69: * @see opus_multistream_ctls Chris@69: * @see opus_projection_ctls Chris@69: */ Chris@69: OPUS_EXPORT int opus_projection_decoder_ctl(OpusProjectionDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); Chris@69: Chris@69: Chris@69: /** Frees an OpusProjectionDecoder allocated by Chris@69: * opus_projection_decoder_create(). Chris@69: * @param st OpusProjectionDecoder: Projection decoder state to be freed. Chris@69: */ Chris@69: OPUS_EXPORT void opus_projection_decoder_destroy(OpusProjectionDecoder *st); Chris@69: Chris@69: Chris@69: /**@}*/ Chris@69: Chris@69: /**@}*/ Chris@69: Chris@69: #ifdef __cplusplus Chris@69: } Chris@69: #endif Chris@69: Chris@69: #endif /* OPUS_PROJECTION_H */