blob: 32adb2bf8ec21b2c1c20b95f6c45bf984e180ea9 [file] [log] [blame]
Jean-Marc Valind4e93402011-08-27 00:52:26 -04001/* 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 FOUNDATION OR
19 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
28
29#ifndef OPUS_MULTISTREAM_H
30#define OPUS_MULTISTREAM_H
31
32#include "opus.h"
33
34typedef struct OpusMSEncoder OpusMSEncoder;
35typedef struct OpusMSDecoder OpusMSDecoder;
36
37OPUS_EXPORT OpusMSEncoder *opus_multistream_encoder_create(
38 int Fs, /* Sampling rate of input signal (Hz) */
39 int channels, /* Number of channels (1/2) in input signal */
40 int streams,
41 int coupled_streams,
42 unsigned char *mapping,
43 int application /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
44);
45
46OPUS_EXPORT int opus_multistream_encoder_init(
47 OpusMSEncoder *st, /* Encoder state */
48 int Fs, /* Sampling rate of input signal (Hz) */
49 int channels, /* Number of channels (1/2) in input signal */
50 int streams,
51 int coupled_streams,
52 unsigned char *mapping,
53 int application /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
54);
55
56/* Returns length of the data payload (in bytes) */
57OPUS_EXPORT int opus_multistream_encode(
58 OpusMSEncoder *st, /* Encoder state */
59 const opus_int16 *pcm, /* Input signal (interleaved if 2 channels). length is frame_size*channels */
60 int frame_size, /* Number of samples per frame of input signal */
61 unsigned char *data, /* Output payload (no more than max_data_bytes long) */
62 int max_data_bytes /* Allocated memory for payload; don't use for controlling bitrate */
63);
64
65/* Returns length of the data payload (in bytes) */
66OPUS_EXPORT int opus_multistream_encode_float(
67 OpusMSEncoder *st, /* Encoder state */
68 const float *pcm, /* Input signal (interleaved if 2 channels). length is frame_size*channels */
69 int frame_size, /* Number of samples per frame of input signal */
70 unsigned char *data, /* Output payload (no more than max_data_bytes long) */
71 int max_data_bytes /* Allocated memory for payload; don't use for controlling bitrate */
72 );
73
74OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
75
76OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...);
77
78OPUS_EXPORT OpusMSDecoder *opus_multistream_decoder_create(
79 int Fs, /* Sampling rate of input signal (Hz) */
80 int channels, /* Number of channels (1/2) in input signal */
81 int streams,
82 int coupled_streams,
83 unsigned char *mapping
84);
85
86OPUS_EXPORT int opus_multistream_decoder_init(
87 OpusMSDecoder *st, /* Encoder state */
88 int Fs, /* Sampling rate of input signal (Hz) */
89 int channels, /* Number of channels (1/2) in input signal */
90 int streams,
91 int coupled_streams,
92 unsigned char *mapping
93);
94
95/* Returns the number of samples decoded or a negative error code */
96OPUS_EXPORT int opus_multistream_decode(
97 OpusMSDecoder *st, /* Decoder state */
98 const unsigned char *data, /* Input payload. Use a NULL pointer to indicate packet loss */
99 int len, /* Number of bytes in payload */
100 opus_int16 *pcm, /* Output signal (interleaved if 2 channels). length is frame_size*channels */
101 int frame_size, /* Number of samples per frame of input signal */
102 int decode_fec /* Flag (0/1) to request that any in-band forward error correction data be */
103 /* decoded. If no such data is available the frame is decoded as if it were lost. */
104);
105
106/* Returns the number of samples decoded or a negative error code */
107OPUS_EXPORT int opus_multistream_decode_float(
108 OpusMSDecoder *st, /* Decoder state */
109 const unsigned char *data, /* Input payload. Use a NULL pointer to indicate packet loss */
110 int len, /* Number of bytes in payload */
111 float *pcm, /* Output signal (interleaved if 2 channels). length is frame_size*channels */
112 int frame_size, /* Number of samples per frame of input signal */
113 int decode_fec /* Flag (0/1) to request that any in-band forward error correction data be */
114 /* decoded. If no such data is available the frame is decoded as if it were lost. */
115);
116
117OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...);
118
119OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
120
121#endif /* OPUS_MULTISTREAM_H */