michael@0: /* Copyright (c) 2011 Xiph.Org Foundation
michael@0: Written by Jean-Marc Valin */
michael@0: /*
michael@0: Redistribution and use in source and binary forms, with or without
michael@0: modification, are permitted provided that the following conditions
michael@0: are met:
michael@0:
michael@0: - Redistributions of source code must retain the above copyright
michael@0: notice, this list of conditions and the following disclaimer.
michael@0:
michael@0: - Redistributions in binary form must reproduce the above copyright
michael@0: notice, this list of conditions and the following disclaimer in the
michael@0: documentation and/or other materials provided with the distribution.
michael@0:
michael@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
michael@0: OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
michael@0: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
michael@0: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
michael@0: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
michael@0: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
michael@0: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
michael@0: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0: */
michael@0:
michael@0: /**
michael@0: * @file opus_multistream.h
michael@0: * @brief Opus reference implementation multistream API
michael@0: */
michael@0:
michael@0: #ifndef OPUS_MULTISTREAM_H
michael@0: #define OPUS_MULTISTREAM_H
michael@0:
michael@0: #include "opus.h"
michael@0:
michael@0: #ifdef __cplusplus
michael@0: extern "C" {
michael@0: #endif
michael@0:
michael@0: /** @cond OPUS_INTERNAL_DOC */
michael@0:
michael@0: /** Macros to trigger compilation errors when the wrong types are provided to a
michael@0: * CTL. */
michael@0: /**@{*/
michael@0: #define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
michael@0: #define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
michael@0: /**@}*/
michael@0:
michael@0: /** These are the actual encoder and decoder CTL ID numbers.
michael@0: * They should not be used directly by applications.
michael@0: * In general, SETs should be even and GETs should be odd.*/
michael@0: /**@{*/
michael@0: #define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
michael@0: #define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
michael@0: /**@}*/
michael@0:
michael@0: /** @endcond */
michael@0:
michael@0: /** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs
michael@0: *
michael@0: * These are convenience macros that are specific to the
michael@0: * opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl()
michael@0: * interface.
michael@0: * The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and
michael@0: * @ref opus_decoderctls may be applied to a multistream encoder or decoder as
michael@0: * well.
michael@0: * In addition, you may retrieve the encoder or decoder state for an specific
michael@0: * stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or
michael@0: * #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually.
michael@0: */
michael@0: /**@{*/
michael@0:
michael@0: /** Gets the encoder state for an individual stream of a multistream encoder.
michael@0: * @param[in] x opus_int32: The index of the stream whose encoder you
michael@0: * wish to retrieve.
michael@0: * This must be non-negative and less than
michael@0: * the streams
parameter used
michael@0: * to initialize the encoder.
michael@0: * @param[out] y OpusEncoder**: Returns a pointer to the given
michael@0: * encoder state.
michael@0: * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
michael@0: * @hideinitializer
michael@0: */
michael@0: #define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
michael@0:
michael@0: /** Gets the decoder state for an individual stream of a multistream decoder.
michael@0: * @param[in] x opus_int32: The index of the stream whose decoder you
michael@0: * wish to retrieve.
michael@0: * This must be non-negative and less than
michael@0: * the streams
parameter used
michael@0: * to initialize the decoder.
michael@0: * @param[out] y OpusDecoder**: Returns a pointer to the given
michael@0: * decoder state.
michael@0: * @retval OPUS_BAD_ARG The index of the requested stream was out of range.
michael@0: * @hideinitializer
michael@0: */
michael@0: #define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
michael@0:
michael@0: /**@}*/
michael@0:
michael@0: /** @defgroup opus_multistream Opus Multistream API
michael@0: * @{
michael@0: *
michael@0: * The multistream API allows individual Opus streams to be combined into a
michael@0: * single packet, enabling support for up to 255 channels. Unlike an
michael@0: * elementary Opus stream, the encoder and decoder must negotiate the channel
michael@0: * configuration before the decoder can successfully interpret the data in the
michael@0: * packets produced by the encoder. Some basic information, such as packet
michael@0: * duration, can be computed without any special negotiation.
michael@0: *
michael@0: * The format for multistream Opus packets is defined in the
michael@0: * Ogg
michael@0: * encapsulation specification and is based on the self-delimited Opus
michael@0: * framing described in Appendix B of RFC 6716.
michael@0: * Normal Opus packets are just a degenerate case of multistream Opus packets,
michael@0: * and can be encoded or decoded with the multistream API by setting
michael@0: * streams
to 1
when initializing the encoder or
michael@0: * decoder.
michael@0: *
michael@0: * Multistream Opus streams can contain up to 255 elementary Opus streams.
michael@0: * These may be either "uncoupled" or "coupled", indicating that the decoder
michael@0: * is configured to decode them to either 1 or 2 channels, respectively.
michael@0: * The streams are ordered so that all coupled streams appear at the
michael@0: * beginning.
michael@0: *
michael@0: * A mapping
table defines which decoded channel i
michael@0: * should be used for each input/output (I/O) channel j
. This table is
michael@0: * typically provided as an unsigned char array.
michael@0: * Let i = mapping[j]
be the index for I/O channel j
.
michael@0: * If i < 2*coupled_streams
, then I/O channel j
is
michael@0: * encoded as the left channel of stream (i/2)
if i
michael@0: * is even, or as the right channel of stream (i/2)
if
michael@0: * i
is odd. Otherwise, I/O channel j
is encoded as
michael@0: * mono in stream (i - coupled_streams)
, unless it has the special
michael@0: * value 255, in which case it is omitted from the encoding entirely (the
michael@0: * decoder will reproduce it as silence). Each value i
must either
michael@0: * be the special value 255 or be less than streams + coupled_streams
.
michael@0: *
michael@0: * The output channels specified by the encoder
michael@0: * should use the
michael@0: * Vorbis
michael@0: * channel ordering. A decoder may wish to apply an additional permutation
michael@0: * to the mapping the encoder used to achieve a different output channel
michael@0: * order (e.g. for outputing in WAV order).
michael@0: *
michael@0: * Each multistream packet contains an Opus packet for each stream, and all of
michael@0: * the Opus packets in a single multistream packet must have the same
michael@0: * duration. Therefore the duration of a multistream packet can be extracted
michael@0: * from the TOC sequence of the first stream, which is located at the
michael@0: * beginning of the packet, just like an elementary Opus stream:
michael@0: *
michael@0: * @code
michael@0: * int nb_samples;
michael@0: * int nb_frames;
michael@0: * nb_frames = opus_packet_get_nb_frames(data, len);
michael@0: * if (nb_frames < 1)
michael@0: * return nb_frames;
michael@0: * nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames;
michael@0: * @endcode
michael@0: *
michael@0: * The general encoding and decoding process proceeds exactly the same as in
michael@0: * the normal @ref opus_encoder and @ref opus_decoder APIs.
michael@0: * See their documentation for an overview of how to use the corresponding
michael@0: * multistream functions.
michael@0: */
michael@0:
michael@0: /** Opus multistream encoder state.
michael@0: * This contains the complete state of a multistream Opus encoder.
michael@0: * It is position independent and can be freely copied.
michael@0: * @see opus_multistream_encoder_create
michael@0: * @see opus_multistream_encoder_init
michael@0: */
michael@0: typedef struct OpusMSEncoder OpusMSEncoder;
michael@0:
michael@0: /** Opus multistream decoder state.
michael@0: * This contains the complete state of a multistream Opus decoder.
michael@0: * It is position independent and can be freely copied.
michael@0: * @see opus_multistream_decoder_create
michael@0: * @see opus_multistream_decoder_init
michael@0: */
michael@0: typedef struct OpusMSDecoder OpusMSDecoder;
michael@0:
michael@0: /**\name Multistream encoder functions */
michael@0: /**@{*/
michael@0:
michael@0: /** Gets the size of an OpusMSEncoder structure.
michael@0: * @param streams int: The total number of streams to encode from the
michael@0: * input.
michael@0: * This must be no more than 255.
michael@0: * @param coupled_streams int: Number of coupled (2 channel) streams
michael@0: * to encode.
michael@0: * This must be no larger than the total
michael@0: * number of streams.
michael@0: * Additionally, The total number of
michael@0: * encoded channels (streams +
michael@0: * coupled_streams
) must be no
michael@0: * more than 255.
michael@0: * @returns The size in bytes on success, or a negative error code
michael@0: * (see @ref opus_errorcodes) on error.
michael@0: */
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size(
michael@0: int streams,
michael@0: int coupled_streams
michael@0: );
michael@0:
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size(
michael@0: int channels,
michael@0: int mapping_family
michael@0: );
michael@0:
michael@0:
michael@0: /** Allocates and initializes a multistream encoder state.
michael@0: * Call opus_multistream_encoder_destroy() to release
michael@0: * this object when finished.
michael@0: * @param Fs opus_int32: Sampling rate of the input signal (in Hz).
michael@0: * This must be one of 8000, 12000, 16000,
michael@0: * 24000, or 48000.
michael@0: * @param channels int: Number of channels in the input signal.
michael@0: * This must be at most 255.
michael@0: * It may be greater than the number of
michael@0: * coded channels (streams +
michael@0: * coupled_streams
).
michael@0: * @param streams int: The total number of streams to encode from the
michael@0: * input.
michael@0: * This must be no more than the number of channels.
michael@0: * @param coupled_streams int: Number of coupled (2 channel) streams
michael@0: * to encode.
michael@0: * This must be no larger than the total
michael@0: * number of streams.
michael@0: * Additionally, The total number of
michael@0: * encoded channels (streams +
michael@0: * coupled_streams
) must be no
michael@0: * more than the number of input channels.
michael@0: * @param[in] mapping const unsigned char[channels]
: Mapping from
michael@0: * encoded channels to input channels, as described in
michael@0: * @ref opus_multistream. As an extra constraint, the
michael@0: * multistream encoder does not allow encoding coupled
michael@0: * streams for which one channel is unused since this
michael@0: * is never a good idea.
michael@0: * @param application int: The target encoder application.
michael@0: * This must be one of the following:
michael@0: *
streams +
michael@0: * coupled_streams
).
michael@0: * @param streams int: The total number of streams to encode from the
michael@0: * input.
michael@0: * This must be no more than the number of channels.
michael@0: * @param coupled_streams int: Number of coupled (2 channel) streams
michael@0: * to encode.
michael@0: * This must be no larger than the total
michael@0: * number of streams.
michael@0: * Additionally, The total number of
michael@0: * encoded channels (streams +
michael@0: * coupled_streams
) must be no
michael@0: * more than the number of input channels.
michael@0: * @param[in] mapping const unsigned char[channels]
: Mapping from
michael@0: * encoded channels to input channels, as described in
michael@0: * @ref opus_multistream. As an extra constraint, the
michael@0: * multistream encoder does not allow encoding coupled
michael@0: * streams for which one channel is unused since this
michael@0: * is never a good idea.
michael@0: * @param application int: The target encoder application.
michael@0: * This must be one of the following:
michael@0: * frame_size*channels
michael@0: * samples.
michael@0: * @param frame_size int: Number of samples per channel in the input
michael@0: * signal.
michael@0: * This must be an Opus frame size for the
michael@0: * encoder's sampling rate.
michael@0: * For example, at 48 kHz the permitted values
michael@0: * are 120, 240, 480, 960, 1920, and 2880.
michael@0: * Passing in a duration of less than 10 ms
michael@0: * (480 samples at 48 kHz) will prevent the
michael@0: * encoder from using the LPC or hybrid modes.
michael@0: * @param[out] data unsigned char*: Output payload.
michael@0: * This must contain storage for at
michael@0: * least \a max_data_bytes.
michael@0: * @param [in] max_data_bytes opus_int32: Size of the allocated
michael@0: * memory for the output
michael@0: * payload. This may be
michael@0: * used to impose an upper limit on
michael@0: * the instant bitrate, but should
michael@0: * not be used as the only bitrate
michael@0: * control. Use #OPUS_SET_BITRATE to
michael@0: * control the bitrate.
michael@0: * @returns The length of the encoded packet (in bytes) on success or a
michael@0: * negative error code (see @ref opus_errorcodes) on failure.
michael@0: */
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode(
michael@0: OpusMSEncoder *st,
michael@0: const opus_int16 *pcm,
michael@0: int frame_size,
michael@0: unsigned char *data,
michael@0: opus_int32 max_data_bytes
michael@0: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
michael@0:
michael@0: /** Encodes a multistream Opus frame from floating point input.
michael@0: * @param st OpusMSEncoder*: Multistream encoder state.
michael@0: * @param[in] pcm const float*: The input signal as interleaved
michael@0: * samples with a normal range of
michael@0: * +/-1.0.
michael@0: * Samples with a range beyond +/-1.0
michael@0: * are supported but will be clipped by
michael@0: * decoders using the integer API and
michael@0: * should only be used if it is known
michael@0: * that the far end supports extended
michael@0: * dynamic range.
michael@0: * This must contain
michael@0: * frame_size*channels
michael@0: * samples.
michael@0: * @param frame_size int: Number of samples per channel in the input
michael@0: * signal.
michael@0: * This must be an Opus frame size for the
michael@0: * encoder's sampling rate.
michael@0: * For example, at 48 kHz the permitted values
michael@0: * are 120, 240, 480, 960, 1920, and 2880.
michael@0: * Passing in a duration of less than 10 ms
michael@0: * (480 samples at 48 kHz) will prevent the
michael@0: * encoder from using the LPC or hybrid modes.
michael@0: * @param[out] data unsigned char*: Output payload.
michael@0: * This must contain storage for at
michael@0: * least \a max_data_bytes.
michael@0: * @param [in] max_data_bytes opus_int32: Size of the allocated
michael@0: * memory for the output
michael@0: * payload. This may be
michael@0: * used to impose an upper limit on
michael@0: * the instant bitrate, but should
michael@0: * not be used as the only bitrate
michael@0: * control. Use #OPUS_SET_BITRATE to
michael@0: * control the bitrate.
michael@0: * @returns The length of the encoded packet (in bytes) on success or a
michael@0: * negative error code (see @ref opus_errorcodes) on failure.
michael@0: */
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float(
michael@0: OpusMSEncoder *st,
michael@0: const float *pcm,
michael@0: int frame_size,
michael@0: unsigned char *data,
michael@0: opus_int32 max_data_bytes
michael@0: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
michael@0:
michael@0: /** Frees an OpusMSEncoder
allocated by
michael@0: * opus_multistream_encoder_create().
michael@0: * @param st OpusMSEncoder*: Multistream encoder state to be freed.
michael@0: */
michael@0: OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
michael@0:
michael@0: /** Perform a CTL function on a multistream Opus encoder.
michael@0: *
michael@0: * Generally the request and subsequent arguments are generated by a
michael@0: * convenience macro.
michael@0: * @param st OpusMSEncoder*: Multistream encoder state.
michael@0: * @param request This and all remaining parameters should be replaced by one
michael@0: * of the convenience macros in @ref opus_genericctls,
michael@0: * @ref opus_encoderctls, or @ref opus_multistream_ctls.
michael@0: * @see opus_genericctls
michael@0: * @see opus_encoderctls
michael@0: * @see opus_multistream_ctls
michael@0: */
michael@0: OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
michael@0:
michael@0: /**@}*/
michael@0:
michael@0: /**\name Multistream decoder functions */
michael@0: /**@{*/
michael@0:
michael@0: /** Gets the size of an OpusMSDecoder
structure.
michael@0: * @param streams int: The total number of streams coded in the
michael@0: * input.
michael@0: * This must be no more than 255.
michael@0: * @param coupled_streams int: Number streams to decode as coupled
michael@0: * (2 channel) streams.
michael@0: * This must be no larger than the total
michael@0: * number of streams.
michael@0: * Additionally, The total number of
michael@0: * coded channels (streams +
michael@0: * coupled_streams
) must be no
michael@0: * more than 255.
michael@0: * @returns The size in bytes on success, or a negative error code
michael@0: * (see @ref opus_errorcodes) on error.
michael@0: */
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size(
michael@0: int streams,
michael@0: int coupled_streams
michael@0: );
michael@0:
michael@0: /** Allocates and initializes a multistream decoder state.
michael@0: * Call opus_multistream_decoder_destroy() to release
michael@0: * this object when finished.
michael@0: * @param Fs opus_int32: Sampling rate to decode at (in Hz).
michael@0: * This must be one of 8000, 12000, 16000,
michael@0: * 24000, or 48000.
michael@0: * @param channels int: Number of channels to output.
michael@0: * This must be at most 255.
michael@0: * It may be different from the number of coded
michael@0: * channels (streams +
michael@0: * coupled_streams
).
michael@0: * @param streams int: The total number of streams coded in the
michael@0: * input.
michael@0: * This must be no more than 255.
michael@0: * @param coupled_streams int: Number of streams to decode as coupled
michael@0: * (2 channel) streams.
michael@0: * This must be no larger than the total
michael@0: * number of streams.
michael@0: * Additionally, The total number of
michael@0: * coded channels (streams +
michael@0: * coupled_streams
) must be no
michael@0: * more than 255.
michael@0: * @param[in] mapping const unsigned char[channels]
: Mapping from
michael@0: * coded channels to output channels, as described in
michael@0: * @ref opus_multistream.
michael@0: * @param[out] error int *: Returns #OPUS_OK on success, or an error
michael@0: * code (see @ref opus_errorcodes) on
michael@0: * failure.
michael@0: */
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create(
michael@0: opus_int32 Fs,
michael@0: int channels,
michael@0: int streams,
michael@0: int coupled_streams,
michael@0: const unsigned char *mapping,
michael@0: int *error
michael@0: ) OPUS_ARG_NONNULL(5);
michael@0:
michael@0: /** Intialize a previously allocated decoder state object.
michael@0: * The memory pointed to by \a st must be at least the size returned by
michael@0: * opus_multistream_encoder_get_size().
michael@0: * This is intended for applications which use their own allocator instead of
michael@0: * malloc.
michael@0: * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
michael@0: * @see opus_multistream_decoder_create
michael@0: * @see opus_multistream_deocder_get_size
michael@0: * @param st OpusMSEncoder*: Multistream encoder state to initialize.
michael@0: * @param Fs opus_int32: Sampling rate to decode at (in Hz).
michael@0: * This must be one of 8000, 12000, 16000,
michael@0: * 24000, or 48000.
michael@0: * @param channels int: Number of channels to output.
michael@0: * This must be at most 255.
michael@0: * It may be different from the number of coded
michael@0: * channels (streams +
michael@0: * coupled_streams
).
michael@0: * @param streams int: The total number of streams coded in the
michael@0: * input.
michael@0: * This must be no more than 255.
michael@0: * @param coupled_streams int: Number of streams to decode as coupled
michael@0: * (2 channel) streams.
michael@0: * This must be no larger than the total
michael@0: * number of streams.
michael@0: * Additionally, The total number of
michael@0: * coded channels (streams +
michael@0: * coupled_streams
) must be no
michael@0: * more than 255.
michael@0: * @param[in] mapping const unsigned char[channels]
: Mapping from
michael@0: * coded channels to output channels, as described in
michael@0: * @ref opus_multistream.
michael@0: * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
michael@0: * on failure.
michael@0: */
michael@0: OPUS_EXPORT int opus_multistream_decoder_init(
michael@0: OpusMSDecoder *st,
michael@0: opus_int32 Fs,
michael@0: int channels,
michael@0: int streams,
michael@0: int coupled_streams,
michael@0: const unsigned char *mapping
michael@0: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
michael@0:
michael@0: /** Decode a multistream Opus packet.
michael@0: * @param st OpusMSDecoder*: Multistream decoder state.
michael@0: * @param[in] data const unsigned char*: Input payload.
michael@0: * Use a NULL
michael@0: * pointer to indicate packet
michael@0: * loss.
michael@0: * @param len opus_int32: Number of bytes in payload.
michael@0: * @param[out] pcm opus_int16*: Output signal, with interleaved
michael@0: * samples.
michael@0: * This must contain room for
michael@0: * frame_size*channels
michael@0: * samples.
michael@0: * @param frame_size int: The number of samples per channel of
michael@0: * available space in \a pcm.
michael@0: * If this is less than the maximum packet duration
michael@0: * (120 ms; 5760 for 48kHz), this function will not be capable
michael@0: * of decoding some packets. In the case of PLC (data==NULL)
michael@0: * or FEC (decode_fec=1), then frame_size needs to be exactly
michael@0: * the duration of audio that is missing, otherwise the
michael@0: * decoder will not be in the optimal state to decode the
michael@0: * next incoming packet. For the PLC and FEC cases, frame_size
michael@0: * must be a multiple of 2.5 ms.
michael@0: * @param decode_fec int: Flag (0 or 1) to request that any in-band
michael@0: * forward error correction data be decoded.
michael@0: * If no such data is available, the frame is
michael@0: * decoded as if it were lost.
michael@0: * @returns Number of samples decoded on success or a negative error code
michael@0: * (see @ref opus_errorcodes) on failure.
michael@0: */
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode(
michael@0: OpusMSDecoder *st,
michael@0: const unsigned char *data,
michael@0: opus_int32 len,
michael@0: opus_int16 *pcm,
michael@0: int frame_size,
michael@0: int decode_fec
michael@0: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
michael@0:
michael@0: /** Decode a multistream Opus packet with floating point output.
michael@0: * @param st OpusMSDecoder*: Multistream decoder state.
michael@0: * @param[in] data const unsigned char*: Input payload.
michael@0: * Use a NULL
michael@0: * pointer to indicate packet
michael@0: * loss.
michael@0: * @param len opus_int32: Number of bytes in payload.
michael@0: * @param[out] pcm opus_int16*: Output signal, with interleaved
michael@0: * samples.
michael@0: * This must contain room for
michael@0: * frame_size*channels
michael@0: * samples.
michael@0: * @param frame_size int: The number of samples per channel of
michael@0: * available space in \a pcm.
michael@0: * If this is less than the maximum packet duration
michael@0: * (120 ms; 5760 for 48kHz), this function will not be capable
michael@0: * of decoding some packets. In the case of PLC (data==NULL)
michael@0: * or FEC (decode_fec=1), then frame_size needs to be exactly
michael@0: * the duration of audio that is missing, otherwise the
michael@0: * decoder will not be in the optimal state to decode the
michael@0: * next incoming packet. For the PLC and FEC cases, frame_size
michael@0: * must be a multiple of 2.5 ms.
michael@0: * @param decode_fec int: Flag (0 or 1) to request that any in-band
michael@0: * forward error correction data be decoded.
michael@0: * If no such data is available, the frame is
michael@0: * decoded as if it were lost.
michael@0: * @returns Number of samples decoded on success or a negative error code
michael@0: * (see @ref opus_errorcodes) on failure.
michael@0: */
michael@0: OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float(
michael@0: OpusMSDecoder *st,
michael@0: const unsigned char *data,
michael@0: opus_int32 len,
michael@0: float *pcm,
michael@0: int frame_size,
michael@0: int decode_fec
michael@0: ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
michael@0:
michael@0: /** Perform a CTL function on a multistream Opus decoder.
michael@0: *
michael@0: * Generally the request and subsequent arguments are generated by a
michael@0: * convenience macro.
michael@0: * @param st OpusMSDecoder*: Multistream decoder state.
michael@0: * @param request This and all remaining parameters should be replaced by one
michael@0: * of the convenience macros in @ref opus_genericctls,
michael@0: * @ref opus_decoderctls, or @ref opus_multistream_ctls.
michael@0: * @see opus_genericctls
michael@0: * @see opus_decoderctls
michael@0: * @see opus_multistream_ctls
michael@0: */
michael@0: OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
michael@0:
michael@0: /** Frees an OpusMSDecoder
allocated by
michael@0: * opus_multistream_decoder_create().
michael@0: * @param st OpusMSDecoder: Multistream decoder state to be freed.
michael@0: */
michael@0: OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
michael@0:
michael@0: /**@}*/
michael@0:
michael@0: /**@}*/
michael@0:
michael@0: #ifdef __cplusplus
michael@0: }
michael@0: #endif
michael@0:
michael@0: #endif /* OPUS_MULTISTREAM_H */