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