Opus
Opus audio codec (RFC 6716): API and operations manual
1.6.1
opus_multistream.h
Go to the documentation of this file.
1 /* Copyright (c) 2011 Xiph.Org Foundation
2  Written by Jean-Marc Valin */
3 /*
4  Redistribution and use in source and binary forms, with or without
5  modification, are permitted provided that the following conditions
6  are met:
7 
8  - Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10 
11  - Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in the
13  documentation and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
33 #ifndef OPUS_MULTISTREAM_H
34 #define OPUS_MULTISTREAM_H
35 
36 #include "opus.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
47 #define opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
48 #define opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
49 
55 #define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
56 #define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
57 
86 #define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, opus_check_int(x), opus_check_encstate_ptr(y)
87 
99 #define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, opus_check_int(x), opus_check_decstate_ptr(y)
100 
176 
184 
203 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size(
204  int streams,
205  int coupled_streams
206 );
207 
208 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size(
209  int channels,
210  int mapping_family
211 );
212 
213 
257 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create(
258  opus_int32 Fs,
259  int channels,
260  int streams,
261  int coupled_streams,
262  const unsigned char *mapping,
263  int application,
264  int *error
265 ) OPUS_ARG_NONNULL(5);
266 
267 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create(
268  opus_int32 Fs,
269  int channels,
270  int mapping_family,
271  int *streams,
272  int *coupled_streams,
273  unsigned char *mapping,
274  int application,
275  int *error
276 ) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6);
277 
326 OPUS_EXPORT int opus_multistream_encoder_init(
327  OpusMSEncoder *st,
328  opus_int32 Fs,
329  int channels,
330  int streams,
331  int coupled_streams,
332  const unsigned char *mapping,
333  int application
334 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
335 
337  OpusMSEncoder *st,
338  opus_int32 Fs,
339  int channels,
340  int mapping_family,
341  int *streams,
342  int *coupled_streams,
343  unsigned char *mapping,
344  int application
345 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6) OPUS_ARG_NONNULL(7);
346 
377 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode(
378  OpusMSEncoder *st,
379  const opus_int16 *pcm,
380  int frame_size,
381  unsigned char *data,
382  opus_int32 max_data_bytes
383 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
384 
415 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode24(
416  OpusMSEncoder *st,
417  const opus_int32 *pcm,
418  int frame_size,
419  unsigned char *data,
420  opus_int32 max_data_bytes
421 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
422 
460 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float(
461  OpusMSEncoder *st,
462  const float *pcm,
463  int frame_size,
464  unsigned char *data,
465  opus_int32 max_data_bytes
466 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
467 
472 OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
473 
486 OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
487 
508 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size(
509  int streams,
510  int coupled_streams
511 );
512 
542 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create(
543  opus_int32 Fs,
544  int channels,
545  int streams,
546  int coupled_streams,
547  const unsigned char *mapping,
548  int *error
549 ) OPUS_ARG_NONNULL(5);
550 
585 OPUS_EXPORT int opus_multistream_decoder_init(
586  OpusMSDecoder *st,
587  opus_int32 Fs,
588  int channels,
589  int streams,
590  int coupled_streams,
591  const unsigned char *mapping
592 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
593 
623 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode(
624  OpusMSDecoder *st,
625  const unsigned char *data,
626  opus_int32 len,
627  opus_int16 *pcm,
628  int frame_size,
629  int decode_fec
630 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
631 
661 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode24(
662  OpusMSDecoder *st,
663  const unsigned char *data,
664  opus_int32 len,
665  opus_int32 *pcm,
666  int frame_size,
667  int decode_fec
668 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
669 
699 OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float(
700  OpusMSDecoder *st,
701  const unsigned char *data,
702  opus_int32 len,
703  float *pcm,
704  int frame_size,
705  int decode_fec
706 ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
707 
720 OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
721 
726 OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
727 
732 #ifdef __cplusplus
733 }
734 #endif
735 
736 #endif /* OPUS_MULTISTREAM_H */
opus_int32 opus_multistream_surround_encoder_get_size(int channels, int mapping_family)
void opus_multistream_decoder_destroy(OpusMSDecoder *st)
Frees an OpusMSDecoder allocated by opus_multistream_decoder_create().
int opus_multistream_decode(OpusMSDecoder *st, const unsigned char *data, opus_int32 len, opus_int16 *pcm, int frame_size, int decode_fec)
Decode a multistream Opus packet.
opus_int32 opus_multistream_decoder_get_size(int streams, int coupled_streams)
Gets the size of an OpusMSDecoder structure.
short opus_int16
Definition: opus_types.h:159
int opus_multistream_surround_encoder_init(OpusMSEncoder *st, opus_int32 Fs, int channels, int mapping_family, int *streams, int *coupled_streams, unsigned char *mapping, int application)
int opus_multistream_encode(OpusMSEncoder *st, const opus_int16 *pcm, int frame_size, unsigned char *data, opus_int32 max_data_bytes)
Encodes a multistream Opus frame.
int opus_multistream_encoder_init(OpusMSEncoder *st, opus_int32 Fs, int channels, int streams, int coupled_streams, const unsigned char *mapping, int application)
Initialize a previously allocated multistream encoder state.
int opus_multistream_encode_float(OpusMSEncoder *st, const float *pcm, int frame_size, unsigned char *data, opus_int32 max_data_bytes)
Encodes a multistream Opus frame from floating point input.
OpusMSEncoder * opus_multistream_surround_encoder_create(opus_int32 Fs, int channels, int mapping_family, int *streams, int *coupled_streams, unsigned char *mapping, int application, int *error)
int opus_int32
Definition: opus_types.h:161
int opus_multistream_decoder_init(OpusMSDecoder *st, opus_int32 Fs, int channels, int streams, int coupled_streams, const unsigned char *mapping)
Initialize a previously allocated decoder state object.
int opus_multistream_encode24(OpusMSEncoder *st, const opus_int32 *pcm, int frame_size, unsigned char *data, opus_int32 max_data_bytes)
Encodes a multistream Opus frame.
int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request,...)
Perform a CTL function on a multistream Opus decoder.
int opus_multistream_decode_float(OpusMSDecoder *st, const unsigned char *data, opus_int32 len, float *pcm, int frame_size, int decode_fec)
Decode a multistream Opus packet with floating point output.
struct OpusMSDecoder OpusMSDecoder
Opus multistream decoder state.
Definition: opus_multistream.h:183
struct OpusMSEncoder OpusMSEncoder
Opus multistream encoder state.
Definition: opus_multistream.h:175
Opus reference implementation API.
opus_int32 opus_multistream_encoder_get_size(int streams, int coupled_streams)
Gets the size of an OpusMSEncoder structure.
OpusMSEncoder * opus_multistream_encoder_create(opus_int32 Fs, int channels, int streams, int coupled_streams, const unsigned char *mapping, int application, int *error)
Allocates and initializes a multistream encoder state.
void opus_multistream_encoder_destroy(OpusMSEncoder *st)
Frees an OpusMSEncoder allocated by opus_multistream_encoder_create().
OpusMSDecoder * opus_multistream_decoder_create(opus_int32 Fs, int channels, int streams, int coupled_streams, const unsigned char *mapping, int *error)
Allocates and initializes a multistream decoder state.
int opus_multistream_decode24(OpusMSDecoder *st, const unsigned char *data, opus_int32 len, opus_int32 *pcm, int frame_size, int decode_fec)
Decode a multistream Opus packet.
int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request,...)
Perform a CTL function on a multistream Opus encoder.
For more information visit the Opus Website.