blob: 6eb973a07ad8f46e88e271a936fe37a497d205b3 [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
Ralph Giles1b951962011-09-07 10:40:25 -070028/**
29 * @file opus_multistream.h
30 * @brief Opus reference implementation multistream API
31 */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040032
33#ifndef OPUS_MULTISTREAM_H
34#define OPUS_MULTISTREAM_H
35
36#include "opus.h"
37
38typedef struct OpusMSEncoder OpusMSEncoder;
39typedef struct OpusMSDecoder OpusMSDecoder;
40
41OPUS_EXPORT OpusMSEncoder *opus_multistream_encoder_create(
Ralph Giles1b951962011-09-07 10:40:25 -070042 int Fs, /**< Sampling rate of input signal (Hz) */
43 int channels, /**< Number of channels (1/2) in input signal */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040044 int streams,
45 int coupled_streams,
46 unsigned char *mapping,
Ralph Giles1b951962011-09-07 10:40:25 -070047 int application, /**< Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
48 int *error /**< Error code */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040049);
50
51OPUS_EXPORT int opus_multistream_encoder_init(
Ralph Giles1b951962011-09-07 10:40:25 -070052 OpusMSEncoder *st, /**< Encoder state */
53 int Fs, /**< Sampling rate of input signal (Hz) */
54 int channels, /**< Number of channels (1/2) in input signal */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040055 int streams,
56 int coupled_streams,
57 unsigned char *mapping,
Ralph Giles1b951962011-09-07 10:40:25 -070058 int application /**< Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040059);
60
Ralph Giles1b951962011-09-07 10:40:25 -070061/** Returns length of the data payload (in bytes) */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040062OPUS_EXPORT int opus_multistream_encode(
Ralph Giles1b951962011-09-07 10:40:25 -070063 OpusMSEncoder *st, /**< Encoder state */
64 const opus_int16 *pcm, /**< Input signal (interleaved if 2 channels). length is frame_size*channels */
65 int frame_size, /**< Number of samples per frame of input signal */
66 unsigned char *data, /**< Output payload (no more than max_data_bytes long) */
67 int max_data_bytes /**< Allocated memory for payload; don't use for controlling bitrate */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040068);
69
Ralph Giles1b951962011-09-07 10:40:25 -070070/** Returns length of the data payload (in bytes) */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040071OPUS_EXPORT int opus_multistream_encode_float(
Ralph Giles1b951962011-09-07 10:40:25 -070072 OpusMSEncoder *st, /**< Encoder state */
73 const float *pcm, /**< Input signal (interleaved if 2 channels). length is frame_size*channels */
74 int frame_size, /**< Number of samples per frame of input signal */
75 unsigned char *data, /**< Output payload (no more than max_data_bytes long) */
76 int max_data_bytes /**< Allocated memory for payload; don't use for controlling bitrate */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040077 );
78
79OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st);
80
81OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...);
82
83OPUS_EXPORT OpusMSDecoder *opus_multistream_decoder_create(
Ralph Giles1b951962011-09-07 10:40:25 -070084 int Fs, /**< Sampling rate of input signal (Hz) */
85 int channels, /**< Number of channels (1/2) in input signal */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040086 int streams,
87 int coupled_streams,
Jean-Marc Valin9d48deb2011-08-29 09:56:14 -040088 unsigned char *mapping,
Ralph Giles1b951962011-09-07 10:40:25 -070089 int *error /**< Error code */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040090);
91
92OPUS_EXPORT int opus_multistream_decoder_init(
Ralph Giles1b951962011-09-07 10:40:25 -070093 OpusMSDecoder *st, /**< Encoder state */
94 int Fs, /**< Sampling rate of input signal (Hz) */
95 int channels, /**< Number of channels (1/2) in input signal */
Jean-Marc Valind4e93402011-08-27 00:52:26 -040096 int streams,
97 int coupled_streams,
98 unsigned char *mapping
99);
100
Ralph Giles1b951962011-09-07 10:40:25 -0700101/** Returns the number of samples decoded or a negative error code */
Jean-Marc Valind4e93402011-08-27 00:52:26 -0400102OPUS_EXPORT int opus_multistream_decode(
Ralph Giles1b951962011-09-07 10:40:25 -0700103 OpusMSDecoder *st, /**< Decoder state */
104 const unsigned char *data, /**< Input payload. Use a NULL pointer to indicate packet loss */
105 int len, /**< Number of bytes in payload */
106 opus_int16 *pcm, /**< Output signal (interleaved if 2 channels). length is frame_size*channels */
107 int frame_size, /**< Number of samples per frame of input signal */
108 int decode_fec /**< Flag (0/1) to request that any in-band forward error correction data be */
109 /**< decoded. If no such data is available the frame is decoded as if it were lost. */
Jean-Marc Valind4e93402011-08-27 00:52:26 -0400110);
111
Ralph Giles1b951962011-09-07 10:40:25 -0700112/** Returns the number of samples decoded or a negative error code */
Jean-Marc Valind4e93402011-08-27 00:52:26 -0400113OPUS_EXPORT int opus_multistream_decode_float(
Ralph Giles1b951962011-09-07 10:40:25 -0700114 OpusMSDecoder *st, /**< Decoder state */
115 const unsigned char *data, /**< Input payload. Use a NULL pointer to indicate packet loss */
116 int len, /**< Number of bytes in payload */
117 float *pcm, /**< Output signal (interleaved if 2 channels). length is frame_size*channels */
118 int frame_size, /**< Number of samples per frame of input signal */
119 int decode_fec /**< Flag (0/1) to request that any in-band forward error correction data be */
120 /**< decoded. If no such data is available the frame is decoded as if it were lost. */
Jean-Marc Valind4e93402011-08-27 00:52:26 -0400121);
122
123OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...);
124
125OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st);
126
127#endif /* OPUS_MULTISTREAM_H */