Skip to content
Snippets Groups Projects
Commit 1d13ff6a authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Fixes multistream doc

parent 77ebbdf9
No related branches found
No related tags found
No related merge requests found
...@@ -200,7 +200,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels); ...@@ -200,7 +200,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels);
* @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 opus_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 bandwidth or number of channels if the bitrate
* selected is too low. This also means that it is safe to always use 48 kHz stereo input * selected is too low. This also means that it is safe to always use 48 kHz stereo input
* and let the encoder optimize the encoding. * and let the encoder optimize the encoding.
*/ */
...@@ -212,7 +212,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( ...@@ -212,7 +212,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create(
); );
/** 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_get_size(). * The memory pointed to by st must be at least the size returned by opus_encoder_get_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.
...@@ -250,10 +250,11 @@ OPUS_EXPORT int opus_encoder_init( ...@@ -250,10 +250,11 @@ OPUS_EXPORT int opus_encoder_init(
* least \a max_data_bytes. * least \a max_data_bytes.
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
* memory for the output * memory for the output
* payload. * payload. This may be
* This should not be used by * used to impose an upper limit on
* itself to control the * the variable bitrate, but should
* bitrate. * not be used as the only bitrate
* control.
* @returns The length of the encoded packet (in bytes) on success or a * @returns The length of the encoded packet (in bytes) on success or a
* negative error code (see @ref opus_errorcodes) on failure. * negative error code (see @ref opus_errorcodes) on failure.
*/ */
...@@ -289,10 +290,11 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( ...@@ -289,10 +290,11 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode(
* least \a max_data_bytes. * least \a max_data_bytes.
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
* memory for the output * memory for the output
* payload. * payload. This may be
* This should not be used by * used to impose an upper limit on
* itself to control the * the variable bitrate, but should
* bitrate. * not be used as the only bitrate
* control.
* @returns The length of the encoded packet (in bytes) on success or a * @returns The length of the encoded packet (in bytes) on success or a
* negative error code (see @ref opus_errorcodes) on failure. * negative error code (see @ref opus_errorcodes) on failure.
*/ */
...@@ -422,7 +424,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( ...@@ -422,7 +424,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create(
); );
/** 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 at least 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.
......
...@@ -68,7 +68,7 @@ extern "C" { ...@@ -68,7 +68,7 @@ extern "C" {
* well. * well.
* In addition, you may retrieve the encoder or decoder state for an specific * In addition, you may retrieve the encoder or decoder state for an specific
* stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or * stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or
* #OPUS_MULTISTREAM_GET_DECODER and apply CTLs to it individually. * #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually.
*/ */
/**@{*/ /**@{*/
...@@ -111,8 +111,9 @@ extern "C" { ...@@ -111,8 +111,9 @@ extern "C" {
* duration, can be computed without any special negotation. * duration, can be computed without any special negotation.
* *
* The format for multistream Opus packets is defined in the * The format for multistream Opus packets is defined in the
* <a href="http://tools.ietf.org/html/draft-terriberry-oggopus-01">Ogg * <a href="http://tools.ietf.org/html/draft-terriberry-oggopus">Ogg
* encapsulation specification</a>. * encapsulation specification</a> and is based on the self-delimited Opus
* framing described in Appendix B of <a href="http://tools.ietf.org/html/rfc6716">RFC 6716</a>.
* Normal Opus packets are just a degenerate case of multistream Opus packets, * Normal Opus packets are just a degenerate case of multistream Opus packets,
* and can be encoded or decoded with the multistream API by setting * and can be encoded or decoded with the multistream API by setting
* <code>streams</code> to <code>1</code> when initializing the encoder or * <code>streams</code> to <code>1</code> when initializing the encoder or
...@@ -124,13 +125,25 @@ extern "C" { ...@@ -124,13 +125,25 @@ extern "C" {
* The streams are ordered so that all coupled streams appear at the * The streams are ordered so that all coupled streams appear at the
* beginning. * beginning.
* *
* A <code>mapping</code> table defines which decoded channel should be used * A <code>mapping</code> table defines which decoded channel <code>i</code>
* for each output channel. The output channels specified by the encoder * should be used for each input/output (I/O) channel <code>j</code>. This table is
* typically provided as an unsigned char array.
* Let <code>i = mapping[j]</code> be the index for I/O channel <code>j</code>.
* If <code>i < 2*coupled_streams</code>, then I/O channel <code>j</code> is
* encoded as the left channel of stream <code>(i/2)</code> if <code>i</code>
* is even, or as the right channel of stream <code>(i/2)</code> if
* <code>i</code> is odd. Otherwise, I/O channel <code>j</code> is encoded as
* mono in stream <code>(i - coupled_streams)</code>, unless it has the special
* value 255, in which case it is omitted from the encoding entirely (the
* decoder will reproduce it as silence). Each value <code>i</code> must either
* be the special value 255 or be less than <code>streams + coupled_streams</code>.
*
* The output channels specified by the encoder
* should use the * should use the
* <a href="http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9">Vorbis * <a href="http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9">Vorbis
* channel ordering</a>. A decoder may wish to apply an additional permutation * channel ordering</a>. A decoder may wish to apply an additional permutation
* to the mapping the encoder used to achieve a different output channel * to the mapping the encoder used to achieve a different output channel
* order. * order (e.g. for outputing in WAV order).
* *
* Each multistream packet contains an Opus packet for each stream, and all of * Each multistream packet contains an Opus packet for each stream, and all of
* the Opus packets in a single multistream packet must have the same * the Opus packets in a single multistream packet must have the same
...@@ -200,12 +213,12 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size ...@@ -200,12 +213,12 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size
* 24000, or 48000. * 24000, or 48000.
* @param channels <tt>int</tt>: Number of channels in the input signal. * @param channels <tt>int</tt>: Number of channels in the input signal.
* This must be at most 255. * This must be at most 255.
* It may be different from the number of * It may be greater than the number of
* channels (<code>streams + * coded channels (<code>streams +
* coupled_streams</code>). * coupled_streams</code>).
* @param streams <tt>int</tt>: The total number of streams to encode from the * @param streams <tt>int</tt>: The total number of streams to encode from the
* input. * input.
* This must be no more than 255. * This must be no more than the number of channels.
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
* to encode. * to encode.
* This must be no larger than the total * This must be no larger than the total
...@@ -213,24 +226,13 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size ...@@ -213,24 +226,13 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size
* Additionally, The total number of * Additionally, The total number of
* encoded channels (<code>streams + * encoded channels (<code>streams +
* coupled_streams</code>) must be no * coupled_streams</code>) must be no
* more than 255. * more than the number of input channels.
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
* encoded channels to input channels. * encoded channels to input channels, as described in
* Let <code>i = mapping[j]</code> be the index for input * @ref opus_multistream. As an extra constraint, the
* channel <code>j</code>. * multistream encoder does not allow encoding coupled
* If <code>i < 2*coupled_streams</code>, then input * streams for which one channel is unused since this
* channel <code>j</code> is encoded as the left channel of * is never a good idea.
* stream <code>(i/2)</code> if <code>i</code> is even, and
* as the right channel of stream <code>(i/2)</code> if
* <code>i</code> is odd.
* Otherwise, input channel <code>j</code> is encoded as
* mono in stream <code>(i - coupled_streams)</code>,
* unless it has the special value 255, in which case it is
* omitted from the encoding entirely (the decoder will
* reproduce it as silence).
* Each value <code>i</code> must either be the special
* value 255 or be less than
* <code>streams + coupled_streams</code>.
* @param application <tt>int</tt>: The target encoder application. * @param application <tt>int</tt>: The target encoder application.
* This must be one of the following: * This must be one of the following:
* <dl> * <dl>
...@@ -257,7 +259,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_crea ...@@ -257,7 +259,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_crea
) OPUS_ARG_NONNULL(5); ) OPUS_ARG_NONNULL(5);
/** Initialize a previously allocated multistream encoder state. /** Initialize a previously allocated multistream encoder state.
* The memory pointed to by \a st must be the size returned by * The memory pointed to by \a st must be at least the size returned by
* opus_multistream_encoder_get_size(). * opus_multistream_encoder_get_size().
* This is intended for applications which use their own allocator instead of * This is intended for applications which use their own allocator instead of
* malloc. * malloc.
...@@ -270,12 +272,12 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_crea ...@@ -270,12 +272,12 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_crea
* 24000, or 48000. * 24000, or 48000.
* @param channels <tt>int</tt>: Number of channels in the input signal. * @param channels <tt>int</tt>: Number of channels in the input signal.
* This must be at most 255. * This must be at most 255.
* It may be different from the number of * It may be greater than the number of
* coded channels (<code>streams + * coded channels (<code>streams +
* coupled_streams</code>). * coupled_streams</code>).
* @param streams <tt>int</tt>: The total number of streams to encode from the * @param streams <tt>int</tt>: The total number of streams to encode from the
* input. * input.
* This must be no more than 255. * This must be no more than the number of channels.
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
* to encode. * to encode.
* This must be no larger than the total * This must be no larger than the total
...@@ -283,10 +285,13 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_crea ...@@ -283,10 +285,13 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_crea
* Additionally, The total number of * Additionally, The total number of
* encoded channels (<code>streams + * encoded channels (<code>streams +
* coupled_streams</code>) must be no * coupled_streams</code>) must be no
* more than 255. * more than the number of input channels.
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
* encoded channels to input channels. * encoded channels to input channels, as described in
* See opus_multistream_encoder_create() for details. * @ref opus_multistream. As an extra constraint, the
* multistream encoder does not allow encoding coupled
* streams for which one channel is unused since this
* is never a good idea.
* @param application <tt>int</tt>: The target encoder application. * @param application <tt>int</tt>: The target encoder application.
* This must be one of the following: * This must be one of the following:
* <dl> * <dl>
...@@ -314,7 +319,7 @@ OPUS_EXPORT int opus_multistream_encoder_init( ...@@ -314,7 +319,7 @@ OPUS_EXPORT int opus_multistream_encoder_init(
/** Encodes a multistream Opus frame. /** Encodes a multistream Opus frame.
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. * @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
* @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved * @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved
* samples. * samples.
* This must contain * This must contain
* <code>frame_size*channels</code> * <code>frame_size*channels</code>
* samples. * samples.
...@@ -331,9 +336,11 @@ OPUS_EXPORT int opus_multistream_encoder_init( ...@@ -331,9 +336,11 @@ OPUS_EXPORT int opus_multistream_encoder_init(
* This must contain storage for at * This must contain storage for at
* least \a max_data_bytes. * least \a max_data_bytes.
* @param max_data_bytes <tt>opus_int32</tt>: Size of the allocated memory for * @param max_data_bytes <tt>opus_int32</tt>: Size of the allocated memory for
* the output payload. * the output payload. This may be
* This should not be used by * used to impose an upper limit on
* itself to control the bitrate. * the variable bitrate, but should
* not be used as the only bitrate
* control.
* @returns The length of the encoded packet (in bytes) on success or a * @returns The length of the encoded packet (in bytes) on success or a
* negative error code (see @ref opus_errorcodes) on failure. * negative error code (see @ref opus_errorcodes) on failure.
*/ */
...@@ -372,9 +379,11 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( ...@@ -372,9 +379,11 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode(
* This must contain storage for at * This must contain storage for at
* least \a max_data_bytes. * least \a max_data_bytes.
* @param max_data_bytes <tt>opus_int32</tt>: Size of the allocated memory for * @param max_data_bytes <tt>opus_int32</tt>: Size of the allocated memory for
* the output payload. * the output payload. This may be
* This should not be used by * used to impose an upper limit on
* itself to control the bitrate. * the variable bitrate, but should
* not be used as the only bitrate
* control.
* @returns The length of the encoded packet (in bytes) on success or a * @returns The length of the encoded packet (in bytes) on success or a
* negative error code (see @ref opus_errorcodes) on failure. * negative error code (see @ref opus_errorcodes) on failure.
*/ */
...@@ -437,7 +446,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size ...@@ -437,7 +446,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
* This must be one of 8000, 12000, 16000, * This must be one of 8000, 12000, 16000,
* 24000, or 48000. * 24000, or 48000.
* @param channels <tt>int</tt>: Number of channels to decode. * @param channels <tt>int</tt>: Number of channels to output.
* This must be at most 255. * This must be at most 255.
* It may be different from the number of coded * It may be different from the number of coded
* channels (<code>streams + * channels (<code>streams +
...@@ -454,21 +463,8 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size ...@@ -454,21 +463,8 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size
* coupled_streams</code>) must be no * coupled_streams</code>) must be no
* more than 255. * more than 255.
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
* coded channels to output channels. * coded channels to output channels, as described in
* Let <code>i = mapping[j]</code> be the index for output * @ref opus_multistream.
* channel <code>j</code>.
* If <code>i < 2*coupled_streams</code>, then the output
* for channel <code>j</code> is taken from the left
* channel of stream <code>(i/2)</code> if <code>i</code>
* <code>i</code> is even, and from the right channel of
* stream <code>(i/2)</code> if <code>i</code> is odd.
* Otherwise, the output for channel <code>j</code> is
* taken from stream <code>(i - coupled_streams)</code>
* decoded as mono, unless it has the special value 255, in
* which case silence is used instead.
* Each value <code>i</code> must either be the special
* value 255 or be less than
* <code>streams + coupled_streams</code>.
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
* code (see @ref opus_errorcodes) on * code (see @ref opus_errorcodes) on
* failure. * failure.
...@@ -483,7 +479,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_crea ...@@ -483,7 +479,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_crea
) OPUS_ARG_NONNULL(5); ) OPUS_ARG_NONNULL(5);
/** Intialize a previously allocated decoder state object. /** Intialize a previously allocated decoder state object.
* The memory pointed to by \a st must be the size returned by * The memory pointed to by \a st must be at least the size returned by
* opus_multistream_encoder_get_size(). * opus_multistream_encoder_get_size().
* This is intended for applications which use their own allocator instead of * This is intended for applications which use their own allocator instead of
* malloc. * malloc.
...@@ -494,7 +490,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_crea ...@@ -494,7 +490,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_crea
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
* This must be one of 8000, 12000, 16000, * This must be one of 8000, 12000, 16000,
* 24000, or 48000. * 24000, or 48000.
* @param channels <tt>int</tt>: Number of channels to decode. * @param channels <tt>int</tt>: Number of channels to output.
* This must be at most 255. * This must be at most 255.
* It may be different from the number of coded * It may be different from the number of coded
* channels (<code>streams + * channels (<code>streams +
...@@ -511,8 +507,8 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_crea ...@@ -511,8 +507,8 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_crea
* coupled_streams</code>) must be no * coupled_streams</code>) must be no
* more than 255. * more than 255.
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from * @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from
* coded channels to output channels. * coded channels to output channels, as described in
* See opus_multistream_decoder_create() for details. * @ref opus_multistream.
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
* on failure. * on failure.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment