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