annotate osx/include/opus/opus_projection.h @ 69:7aeed7906520

Add Opus sources and macOS builds
author Chris Cannam
date Wed, 23 Jan 2019 13:48:08 +0000
parents
children
rev   line source
Chris@69 1 /* Copyright (c) 2017 Google Inc.
Chris@69 2 Written by Andrew Allen */
Chris@69 3 /*
Chris@69 4 Redistribution and use in source and binary forms, with or without
Chris@69 5 modification, are permitted provided that the following conditions
Chris@69 6 are met:
Chris@69 7
Chris@69 8 - Redistributions of source code must retain the above copyright
Chris@69 9 notice, this list of conditions and the following disclaimer.
Chris@69 10
Chris@69 11 - Redistributions in binary form must reproduce the above copyright
Chris@69 12 notice, this list of conditions and the following disclaimer in the
Chris@69 13 documentation and/or other materials provided with the distribution.
Chris@69 14
Chris@69 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@69 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@69 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@69 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
Chris@69 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@69 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@69 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@69 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@69 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@69 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@69 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@69 26 */
Chris@69 27
Chris@69 28 /**
Chris@69 29 * @file opus_projection.h
Chris@69 30 * @brief Opus projection reference API
Chris@69 31 */
Chris@69 32
Chris@69 33 #ifndef OPUS_PROJECTION_H
Chris@69 34 #define OPUS_PROJECTION_H
Chris@69 35
Chris@69 36 #include "opus_multistream.h"
Chris@69 37
Chris@69 38 #ifdef __cplusplus
Chris@69 39 extern "C" {
Chris@69 40 #endif
Chris@69 41
Chris@69 42 /** @cond OPUS_INTERNAL_DOC */
Chris@69 43
Chris@69 44 /** These are the actual encoder and decoder CTL ID numbers.
Chris@69 45 * They should not be used directly by applications.c
Chris@69 46 * In general, SETs should be even and GETs should be odd.*/
Chris@69 47 /**@{*/
Chris@69 48 #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST 6001
Chris@69 49 #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST 6003
Chris@69 50 #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST 6005
Chris@69 51 /**@}*/
Chris@69 52
Chris@69 53
Chris@69 54 /** @endcond */
Chris@69 55
Chris@69 56 /** @defgroup opus_projection_ctls Projection specific encoder and decoder CTLs
Chris@69 57 *
Chris@69 58 * These are convenience macros that are specific to the
Chris@69 59 * opus_projection_encoder_ctl() and opus_projection_decoder_ctl()
Chris@69 60 * interface.
Chris@69 61 * The CTLs from @ref opus_genericctls, @ref opus_encoderctls,
Chris@69 62 * @ref opus_decoderctls, and @ref opus_multistream_ctls may be applied to a
Chris@69 63 * projection encoder or decoder as well.
Chris@69 64 */
Chris@69 65 /**@{*/
Chris@69 66
Chris@69 67 /** Gets the gain (in dB. S7.8-format) of the demixing matrix from the encoder.
Chris@69 68 * @param[out] x <tt>opus_int32 *</tt>: Returns the gain (in dB. S7.8-format)
Chris@69 69 * of the demixing matrix.
Chris@69 70 * @hideinitializer
Chris@69 71 */
Chris@69 72 #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST, __opus_check_int_ptr(x)
Chris@69 73
Chris@69 74
Chris@69 75 /** Gets the size in bytes of the demixing matrix from the encoder.
Chris@69 76 * @param[out] x <tt>opus_int32 *</tt>: Returns the size in bytes of the
Chris@69 77 * demixing matrix.
Chris@69 78 * @hideinitializer
Chris@69 79 */
Chris@69 80 #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, __opus_check_int_ptr(x)
Chris@69 81
Chris@69 82
Chris@69 83 /** Copies the demixing matrix to the supplied pointer location.
Chris@69 84 * @param[out] x <tt>unsigned char *</tt>: Returns the demixing matrix to the
Chris@69 85 * supplied pointer location.
Chris@69 86 * @param y <tt>opus_int32</tt>: The size in bytes of the reserved memory at the
Chris@69 87 * pointer location.
Chris@69 88 * @hideinitializer
Chris@69 89 */
Chris@69 90 #define OPUS_PROJECTION_GET_DEMIXING_MATRIX(x,y) OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, x, __opus_check_int(y)
Chris@69 91
Chris@69 92
Chris@69 93 /**@}*/
Chris@69 94
Chris@69 95 /** Opus projection encoder state.
Chris@69 96 * This contains the complete state of a projection Opus encoder.
Chris@69 97 * It is position independent and can be freely copied.
Chris@69 98 * @see opus_projection_ambisonics_encoder_create
Chris@69 99 */
Chris@69 100 typedef struct OpusProjectionEncoder OpusProjectionEncoder;
Chris@69 101
Chris@69 102
Chris@69 103 /** Opus projection decoder state.
Chris@69 104 * This contains the complete state of a projection Opus decoder.
Chris@69 105 * It is position independent and can be freely copied.
Chris@69 106 * @see opus_projection_decoder_create
Chris@69 107 * @see opus_projection_decoder_init
Chris@69 108 */
Chris@69 109 typedef struct OpusProjectionDecoder OpusProjectionDecoder;
Chris@69 110
Chris@69 111
Chris@69 112 /**\name Projection encoder functions */
Chris@69 113 /**@{*/
Chris@69 114
Chris@69 115 /** Gets the size of an OpusProjectionEncoder structure.
Chris@69 116 * @param channels <tt>int</tt>: The total number of input channels to encode.
Chris@69 117 * This must be no more than 255.
Chris@69 118 * @param mapping_family <tt>int</tt>: The mapping family to use for selecting
Chris@69 119 * the appropriate projection.
Chris@69 120 * @returns The size in bytes on success, or a negative error code
Chris@69 121 * (see @ref opus_errorcodes) on error.
Chris@69 122 */
Chris@69 123 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_ambisonics_encoder_get_size(
Chris@69 124 int channels,
Chris@69 125 int mapping_family
Chris@69 126 );
Chris@69 127
Chris@69 128
Chris@69 129 /** Allocates and initializes a projection encoder state.
Chris@69 130 * Call opus_projection_encoder_destroy() to release
Chris@69 131 * this object when finished.
Chris@69 132 * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
Chris@69 133 * This must be one of 8000, 12000, 16000,
Chris@69 134 * 24000, or 48000.
Chris@69 135 * @param channels <tt>int</tt>: Number of channels in the input signal.
Chris@69 136 * This must be at most 255.
Chris@69 137 * It may be greater than the number of
Chris@69 138 * coded channels (<code>streams +
Chris@69 139 * coupled_streams</code>).
Chris@69 140 * @param mapping_family <tt>int</tt>: The mapping family to use for selecting
Chris@69 141 * the appropriate projection.
Chris@69 142 * @param[out] streams <tt>int *</tt>: The total number of streams that will
Chris@69 143 * be encoded from the input.
Chris@69 144 * @param[out] coupled_streams <tt>int *</tt>: Number of coupled (2 channel)
Chris@69 145 * streams that will be encoded from the input.
Chris@69 146 * @param application <tt>int</tt>: The target encoder application.
Chris@69 147 * This must be one of the following:
Chris@69 148 * <dl>
Chris@69 149 * <dt>#OPUS_APPLICATION_VOIP</dt>
Chris@69 150 * <dd>Process signal for improved speech intelligibility.</dd>
Chris@69 151 * <dt>#OPUS_APPLICATION_AUDIO</dt>
Chris@69 152 * <dd>Favor faithfulness to the original input.</dd>
Chris@69 153 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
Chris@69 154 * <dd>Configure the minimum possible coding delay by disabling certain modes
Chris@69 155 * of operation.</dd>
Chris@69 156 * </dl>
Chris@69 157 * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
Chris@69 158 * code (see @ref opus_errorcodes) on
Chris@69 159 * failure.
Chris@69 160 */
Chris@69 161 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionEncoder *opus_projection_ambisonics_encoder_create(
Chris@69 162 opus_int32 Fs,
Chris@69 163 int channels,
Chris@69 164 int mapping_family,
Chris@69 165 int *streams,
Chris@69 166 int *coupled_streams,
Chris@69 167 int application,
Chris@69 168 int *error
Chris@69 169 ) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5);
Chris@69 170
Chris@69 171
Chris@69 172 /** Initialize a previously allocated projection encoder state.
Chris@69 173 * The memory pointed to by \a st must be at least the size returned by
Chris@69 174 * opus_projection_ambisonics_encoder_get_size().
Chris@69 175 * This is intended for applications which use their own allocator instead of
Chris@69 176 * malloc.
Chris@69 177 * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
Chris@69 178 * @see opus_projection_ambisonics_encoder_create
Chris@69 179 * @see opus_projection_ambisonics_encoder_get_size
Chris@69 180 * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state to initialize.
Chris@69 181 * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
Chris@69 182 * This must be one of 8000, 12000, 16000,
Chris@69 183 * 24000, or 48000.
Chris@69 184 * @param channels <tt>int</tt>: Number of channels in the input signal.
Chris@69 185 * This must be at most 255.
Chris@69 186 * It may be greater than the number of
Chris@69 187 * coded channels (<code>streams +
Chris@69 188 * coupled_streams</code>).
Chris@69 189 * @param streams <tt>int</tt>: The total number of streams to encode from the
Chris@69 190 * input.
Chris@69 191 * This must be no more than the number of channels.
Chris@69 192 * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
Chris@69 193 * to encode.
Chris@69 194 * This must be no larger than the total
Chris@69 195 * number of streams.
Chris@69 196 * Additionally, The total number of
Chris@69 197 * encoded channels (<code>streams +
Chris@69 198 * coupled_streams</code>) must be no
Chris@69 199 * more than the number of input channels.
Chris@69 200 * @param application <tt>int</tt>: The target encoder application.
Chris@69 201 * This must be one of the following:
Chris@69 202 * <dl>
Chris@69 203 * <dt>#OPUS_APPLICATION_VOIP</dt>
Chris@69 204 * <dd>Process signal for improved speech intelligibility.</dd>
Chris@69 205 * <dt>#OPUS_APPLICATION_AUDIO</dt>
Chris@69 206 * <dd>Favor faithfulness to the original input.</dd>
Chris@69 207 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
Chris@69 208 * <dd>Configure the minimum possible coding delay by disabling certain modes
Chris@69 209 * of operation.</dd>
Chris@69 210 * </dl>
Chris@69 211 * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
Chris@69 212 * on failure.
Chris@69 213 */
Chris@69 214 OPUS_EXPORT int opus_projection_ambisonics_encoder_init(
Chris@69 215 OpusProjectionEncoder *st,
Chris@69 216 opus_int32 Fs,
Chris@69 217 int channels,
Chris@69 218 int mapping_family,
Chris@69 219 int *streams,
Chris@69 220 int *coupled_streams,
Chris@69 221 int application
Chris@69 222 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6);
Chris@69 223
Chris@69 224
Chris@69 225 /** Encodes a projection Opus frame.
Chris@69 226 * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
Chris@69 227 * @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved
Chris@69 228 * samples.
Chris@69 229 * This must contain
Chris@69 230 * <code>frame_size*channels</code>
Chris@69 231 * samples.
Chris@69 232 * @param frame_size <tt>int</tt>: Number of samples per channel in the input
Chris@69 233 * signal.
Chris@69 234 * This must be an Opus frame size for the
Chris@69 235 * encoder's sampling rate.
Chris@69 236 * For example, at 48 kHz the permitted values
Chris@69 237 * are 120, 240, 480, 960, 1920, and 2880.
Chris@69 238 * Passing in a duration of less than 10 ms
Chris@69 239 * (480 samples at 48 kHz) will prevent the
Chris@69 240 * encoder from using the LPC or hybrid modes.
Chris@69 241 * @param[out] data <tt>unsigned char*</tt>: Output payload.
Chris@69 242 * This must contain storage for at
Chris@69 243 * least \a max_data_bytes.
Chris@69 244 * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
Chris@69 245 * memory for the output
Chris@69 246 * payload. This may be
Chris@69 247 * used to impose an upper limit on
Chris@69 248 * the instant bitrate, but should
Chris@69 249 * not be used as the only bitrate
Chris@69 250 * control. Use #OPUS_SET_BITRATE to
Chris@69 251 * control the bitrate.
Chris@69 252 * @returns The length of the encoded packet (in bytes) on success or a
Chris@69 253 * negative error code (see @ref opus_errorcodes) on failure.
Chris@69 254 */
Chris@69 255 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode(
Chris@69 256 OpusProjectionEncoder *st,
Chris@69 257 const opus_int16 *pcm,
Chris@69 258 int frame_size,
Chris@69 259 unsigned char *data,
Chris@69 260 opus_int32 max_data_bytes
Chris@69 261 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
Chris@69 262
Chris@69 263
Chris@69 264 /** Encodes a projection Opus frame from floating point input.
Chris@69 265 * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
Chris@69 266 * @param[in] pcm <tt>const float*</tt>: The input signal as interleaved
Chris@69 267 * samples with a normal range of
Chris@69 268 * +/-1.0.
Chris@69 269 * Samples with a range beyond +/-1.0
Chris@69 270 * are supported but will be clipped by
Chris@69 271 * decoders using the integer API and
Chris@69 272 * should only be used if it is known
Chris@69 273 * that the far end supports extended
Chris@69 274 * dynamic range.
Chris@69 275 * This must contain
Chris@69 276 * <code>frame_size*channels</code>
Chris@69 277 * samples.
Chris@69 278 * @param frame_size <tt>int</tt>: Number of samples per channel in the input
Chris@69 279 * signal.
Chris@69 280 * This must be an Opus frame size for the
Chris@69 281 * encoder's sampling rate.
Chris@69 282 * For example, at 48 kHz the permitted values
Chris@69 283 * are 120, 240, 480, 960, 1920, and 2880.
Chris@69 284 * Passing in a duration of less than 10 ms
Chris@69 285 * (480 samples at 48 kHz) will prevent the
Chris@69 286 * encoder from using the LPC or hybrid modes.
Chris@69 287 * @param[out] data <tt>unsigned char*</tt>: Output payload.
Chris@69 288 * This must contain storage for at
Chris@69 289 * least \a max_data_bytes.
Chris@69 290 * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
Chris@69 291 * memory for the output
Chris@69 292 * payload. This may be
Chris@69 293 * used to impose an upper limit on
Chris@69 294 * the instant bitrate, but should
Chris@69 295 * not be used as the only bitrate
Chris@69 296 * control. Use #OPUS_SET_BITRATE to
Chris@69 297 * control the bitrate.
Chris@69 298 * @returns The length of the encoded packet (in bytes) on success or a
Chris@69 299 * negative error code (see @ref opus_errorcodes) on failure.
Chris@69 300 */
Chris@69 301 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode_float(
Chris@69 302 OpusProjectionEncoder *st,
Chris@69 303 const float *pcm,
Chris@69 304 int frame_size,
Chris@69 305 unsigned char *data,
Chris@69 306 opus_int32 max_data_bytes
Chris@69 307 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
Chris@69 308
Chris@69 309
Chris@69 310 /** Frees an <code>OpusProjectionEncoder</code> allocated by
Chris@69 311 * opus_projection_ambisonics_encoder_create().
Chris@69 312 * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state to be freed.
Chris@69 313 */
Chris@69 314 OPUS_EXPORT void opus_projection_encoder_destroy(OpusProjectionEncoder *st);
Chris@69 315
Chris@69 316
Chris@69 317 /** Perform a CTL function on a projection Opus encoder.
Chris@69 318 *
Chris@69 319 * Generally the request and subsequent arguments are generated by a
Chris@69 320 * convenience macro.
Chris@69 321 * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
Chris@69 322 * @param request This and all remaining parameters should be replaced by one
Chris@69 323 * of the convenience macros in @ref opus_genericctls,
Chris@69 324 * @ref opus_encoderctls, @ref opus_multistream_ctls, or
Chris@69 325 * @ref opus_projection_ctls
Chris@69 326 * @see opus_genericctls
Chris@69 327 * @see opus_encoderctls
Chris@69 328 * @see opus_multistream_ctls
Chris@69 329 * @see opus_projection_ctls
Chris@69 330 */
Chris@69 331 OPUS_EXPORT int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
Chris@69 332
Chris@69 333
Chris@69 334 /**@}*/
Chris@69 335
Chris@69 336 /**\name Projection decoder functions */
Chris@69 337 /**@{*/
Chris@69 338
Chris@69 339 /** Gets the size of an <code>OpusProjectionDecoder</code> structure.
Chris@69 340 * @param channels <tt>int</tt>: The total number of output channels.
Chris@69 341 * This must be no more than 255.
Chris@69 342 * @param streams <tt>int</tt>: The total number of streams coded in the
Chris@69 343 * input.
Chris@69 344 * This must be no more than 255.
Chris@69 345 * @param coupled_streams <tt>int</tt>: Number streams to decode as coupled
Chris@69 346 * (2 channel) streams.
Chris@69 347 * This must be no larger than the total
Chris@69 348 * number of streams.
Chris@69 349 * Additionally, The total number of
Chris@69 350 * coded channels (<code>streams +
Chris@69 351 * coupled_streams</code>) must be no
Chris@69 352 * more than 255.
Chris@69 353 * @returns The size in bytes on success, or a negative error code
Chris@69 354 * (see @ref opus_errorcodes) on error.
Chris@69 355 */
Chris@69 356 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_decoder_get_size(
Chris@69 357 int channels,
Chris@69 358 int streams,
Chris@69 359 int coupled_streams
Chris@69 360 );
Chris@69 361
Chris@69 362
Chris@69 363 /** Allocates and initializes a projection decoder state.
Chris@69 364 * Call opus_projection_decoder_destroy() to release
Chris@69 365 * this object when finished.
Chris@69 366 * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
Chris@69 367 * This must be one of 8000, 12000, 16000,
Chris@69 368 * 24000, or 48000.
Chris@69 369 * @param channels <tt>int</tt>: Number of channels to output.
Chris@69 370 * This must be at most 255.
Chris@69 371 * It may be different from the number of coded
Chris@69 372 * channels (<code>streams +
Chris@69 373 * coupled_streams</code>).
Chris@69 374 * @param streams <tt>int</tt>: The total number of streams coded in the
Chris@69 375 * input.
Chris@69 376 * This must be no more than 255.
Chris@69 377 * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
Chris@69 378 * (2 channel) streams.
Chris@69 379 * This must be no larger than the total
Chris@69 380 * number of streams.
Chris@69 381 * Additionally, The total number of
Chris@69 382 * coded channels (<code>streams +
Chris@69 383 * coupled_streams</code>) must be no
Chris@69 384 * more than 255.
Chris@69 385 * @param[in] demixing_matrix <tt>const unsigned char[demixing_matrix_size]</tt>: Demixing matrix
Chris@69 386 * that mapping from coded channels to output channels,
Chris@69 387 * as described in @ref opus_projection and
Chris@69 388 * @ref opus_projection_ctls.
Chris@69 389 * @param demixing_matrix_size <tt>opus_int32</tt>: The size in bytes of the
Chris@69 390 * demixing matrix, as
Chris@69 391 * described in @ref
Chris@69 392 * opus_projection_ctls.
Chris@69 393 * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
Chris@69 394 * code (see @ref opus_errorcodes) on
Chris@69 395 * failure.
Chris@69 396 */
Chris@69 397 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionDecoder *opus_projection_decoder_create(
Chris@69 398 opus_int32 Fs,
Chris@69 399 int channels,
Chris@69 400 int streams,
Chris@69 401 int coupled_streams,
Chris@69 402 unsigned char *demixing_matrix,
Chris@69 403 opus_int32 demixing_matrix_size,
Chris@69 404 int *error
Chris@69 405 ) OPUS_ARG_NONNULL(5);
Chris@69 406
Chris@69 407
Chris@69 408 /** Intialize a previously allocated projection decoder state object.
Chris@69 409 * The memory pointed to by \a st must be at least the size returned by
Chris@69 410 * opus_projection_decoder_get_size().
Chris@69 411 * This is intended for applications which use their own allocator instead of
Chris@69 412 * malloc.
Chris@69 413 * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
Chris@69 414 * @see opus_projection_decoder_create
Chris@69 415 * @see opus_projection_deocder_get_size
Chris@69 416 * @param st <tt>OpusProjectionDecoder*</tt>: Projection encoder state to initialize.
Chris@69 417 * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
Chris@69 418 * This must be one of 8000, 12000, 16000,
Chris@69 419 * 24000, or 48000.
Chris@69 420 * @param channels <tt>int</tt>: Number of channels to output.
Chris@69 421 * This must be at most 255.
Chris@69 422 * It may be different from the number of coded
Chris@69 423 * channels (<code>streams +
Chris@69 424 * coupled_streams</code>).
Chris@69 425 * @param streams <tt>int</tt>: The total number of streams coded in the
Chris@69 426 * input.
Chris@69 427 * This must be no more than 255.
Chris@69 428 * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
Chris@69 429 * (2 channel) streams.
Chris@69 430 * This must be no larger than the total
Chris@69 431 * number of streams.
Chris@69 432 * Additionally, The total number of
Chris@69 433 * coded channels (<code>streams +
Chris@69 434 * coupled_streams</code>) must be no
Chris@69 435 * more than 255.
Chris@69 436 * @param[in] demixing_matrix <tt>const unsigned char[demixing_matrix_size]</tt>: Demixing matrix
Chris@69 437 * that mapping from coded channels to output channels,
Chris@69 438 * as described in @ref opus_projection and
Chris@69 439 * @ref opus_projection_ctls.
Chris@69 440 * @param demixing_matrix_size <tt>opus_int32</tt>: The size in bytes of the
Chris@69 441 * demixing matrix, as
Chris@69 442 * described in @ref
Chris@69 443 * opus_projection_ctls.
Chris@69 444 * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
Chris@69 445 * on failure.
Chris@69 446 */
Chris@69 447 OPUS_EXPORT int opus_projection_decoder_init(
Chris@69 448 OpusProjectionDecoder *st,
Chris@69 449 opus_int32 Fs,
Chris@69 450 int channels,
Chris@69 451 int streams,
Chris@69 452 int coupled_streams,
Chris@69 453 unsigned char *demixing_matrix,
Chris@69 454 opus_int32 demixing_matrix_size
Chris@69 455 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
Chris@69 456
Chris@69 457
Chris@69 458 /** Decode a projection Opus packet.
Chris@69 459 * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
Chris@69 460 * @param[in] data <tt>const unsigned char*</tt>: Input payload.
Chris@69 461 * Use a <code>NULL</code>
Chris@69 462 * pointer to indicate packet
Chris@69 463 * loss.
Chris@69 464 * @param len <tt>opus_int32</tt>: Number of bytes in payload.
Chris@69 465 * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
Chris@69 466 * samples.
Chris@69 467 * This must contain room for
Chris@69 468 * <code>frame_size*channels</code>
Chris@69 469 * samples.
Chris@69 470 * @param frame_size <tt>int</tt>: The number of samples per channel of
Chris@69 471 * available space in \a pcm.
Chris@69 472 * If this is less than the maximum packet duration
Chris@69 473 * (120 ms; 5760 for 48kHz), this function will not be capable
Chris@69 474 * of decoding some packets. In the case of PLC (data==NULL)
Chris@69 475 * or FEC (decode_fec=1), then frame_size needs to be exactly
Chris@69 476 * the duration of audio that is missing, otherwise the
Chris@69 477 * decoder will not be in the optimal state to decode the
Chris@69 478 * next incoming packet. For the PLC and FEC cases, frame_size
Chris@69 479 * <b>must</b> be a multiple of 2.5 ms.
Chris@69 480 * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
Chris@69 481 * forward error correction data be decoded.
Chris@69 482 * If no such data is available, the frame is
Chris@69 483 * decoded as if it were lost.
Chris@69 484 * @returns Number of samples decoded on success or a negative error code
Chris@69 485 * (see @ref opus_errorcodes) on failure.
Chris@69 486 */
Chris@69 487 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode(
Chris@69 488 OpusProjectionDecoder *st,
Chris@69 489 const unsigned char *data,
Chris@69 490 opus_int32 len,
Chris@69 491 opus_int16 *pcm,
Chris@69 492 int frame_size,
Chris@69 493 int decode_fec
Chris@69 494 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
Chris@69 495
Chris@69 496
Chris@69 497 /** Decode a projection Opus packet with floating point output.
Chris@69 498 * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
Chris@69 499 * @param[in] data <tt>const unsigned char*</tt>: Input payload.
Chris@69 500 * Use a <code>NULL</code>
Chris@69 501 * pointer to indicate packet
Chris@69 502 * loss.
Chris@69 503 * @param len <tt>opus_int32</tt>: Number of bytes in payload.
Chris@69 504 * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
Chris@69 505 * samples.
Chris@69 506 * This must contain room for
Chris@69 507 * <code>frame_size*channels</code>
Chris@69 508 * samples.
Chris@69 509 * @param frame_size <tt>int</tt>: The number of samples per channel of
Chris@69 510 * available space in \a pcm.
Chris@69 511 * If this is less than the maximum packet duration
Chris@69 512 * (120 ms; 5760 for 48kHz), this function will not be capable
Chris@69 513 * of decoding some packets. In the case of PLC (data==NULL)
Chris@69 514 * or FEC (decode_fec=1), then frame_size needs to be exactly
Chris@69 515 * the duration of audio that is missing, otherwise the
Chris@69 516 * decoder will not be in the optimal state to decode the
Chris@69 517 * next incoming packet. For the PLC and FEC cases, frame_size
Chris@69 518 * <b>must</b> be a multiple of 2.5 ms.
Chris@69 519 * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
Chris@69 520 * forward error correction data be decoded.
Chris@69 521 * If no such data is available, the frame is
Chris@69 522 * decoded as if it were lost.
Chris@69 523 * @returns Number of samples decoded on success or a negative error code
Chris@69 524 * (see @ref opus_errorcodes) on failure.
Chris@69 525 */
Chris@69 526 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode_float(
Chris@69 527 OpusProjectionDecoder *st,
Chris@69 528 const unsigned char *data,
Chris@69 529 opus_int32 len,
Chris@69 530 float *pcm,
Chris@69 531 int frame_size,
Chris@69 532 int decode_fec
Chris@69 533 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
Chris@69 534
Chris@69 535
Chris@69 536 /** Perform a CTL function on a projection Opus decoder.
Chris@69 537 *
Chris@69 538 * Generally the request and subsequent arguments are generated by a
Chris@69 539 * convenience macro.
Chris@69 540 * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
Chris@69 541 * @param request This and all remaining parameters should be replaced by one
Chris@69 542 * of the convenience macros in @ref opus_genericctls,
Chris@69 543 * @ref opus_decoderctls, @ref opus_multistream_ctls, or
Chris@69 544 * @ref opus_projection_ctls.
Chris@69 545 * @see opus_genericctls
Chris@69 546 * @see opus_decoderctls
Chris@69 547 * @see opus_multistream_ctls
Chris@69 548 * @see opus_projection_ctls
Chris@69 549 */
Chris@69 550 OPUS_EXPORT int opus_projection_decoder_ctl(OpusProjectionDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
Chris@69 551
Chris@69 552
Chris@69 553 /** Frees an <code>OpusProjectionDecoder</code> allocated by
Chris@69 554 * opus_projection_decoder_create().
Chris@69 555 * @param st <tt>OpusProjectionDecoder</tt>: Projection decoder state to be freed.
Chris@69 556 */
Chris@69 557 OPUS_EXPORT void opus_projection_decoder_destroy(OpusProjectionDecoder *st);
Chris@69 558
Chris@69 559
Chris@69 560 /**@}*/
Chris@69 561
Chris@69 562 /**@}*/
Chris@69 563
Chris@69 564 #ifdef __cplusplus
Chris@69 565 }
Chris@69 566 #endif
Chris@69 567
Chris@69 568 #endif /* OPUS_PROJECTION_H */