annotate win32-msvc/include/opus/opus_projection.h @ 70:9e21af8f0420

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