blob: 0ebf3de8dc3e0dde72b873a87bde93b63ad1fdb0 [file] [log] [blame]
Jean-Marc Valin8b2ff0d2009-10-17 21:40:10 -04001/* Copyright (c) 2007-2008 CSIRO
2 Copyright (c) 2007-2009 Xiph.Org Foundation
3 Copyright (c) 2008 Gregory Maxwell
4 Written by Jean-Marc Valin and Gregory Maxwell */
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +11005/**
6 @file celt.h
Jean-Marc Valin56522ad2009-06-05 17:17:25 -04007 @brief Contains all the functions for encoding and decoding audio
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +11008 */
9
Jean-Marc Valin013c31d2007-11-30 11:36:46 +110010/*
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
13 are met:
14
15 - Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17
18 - Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21
Jean-Marc Valin013c31d2007-11-30 11:36:46 +110022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*/
34
35#ifndef CELT_H
36#define CELT_H
37
Jean-Marc Valind77d6a52011-07-29 17:33:06 -040038#include "opus_types.h"
Jean-Marc Valin3d3bb682008-01-31 10:05:39 +110039
Jean-Marc Valin77ff83a2008-01-22 13:16:36 +110040#ifdef __cplusplus
41extern "C" {
42#endif
43
Peter Kirk19f9dc92008-06-06 14:38:38 +020044#if defined(__GNUC__) && defined(CELT_BUILD)
Jean-Marc Valin9edde422011-05-05 15:30:44 -040045#define CELT_EXPORT __attribute__ ((visibility ("default")))
Peter Kirk19f9dc92008-06-06 14:38:38 +020046#elif defined(WIN32)
Jean-Marc Valin9edde422011-05-05 15:30:44 -040047#define CELT_EXPORT __declspec(dllexport)
Peter Kirk19f9dc92008-06-06 14:38:38 +020048#else
Jean-Marc Valin9edde422011-05-05 15:30:44 -040049#define CELT_EXPORT
Peter Kirk19f9dc92008-06-06 14:38:38 +020050#endif
51
Jean-Marc Valind77d6a52011-07-29 17:33:06 -040052#define _celt_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
Jean-Marc Valinc3086a92011-03-21 13:26:03 -040053#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)))
Jean-Marc Valinef20e392011-03-18 15:34:11 -040054#define _celt_check_int_ptr(ptr) ((ptr) + ((ptr) - (int*)(ptr)))
Jean-Marc Valinb6f90612008-10-05 22:39:13 -040055
Jean-Marc Valin8c19b032008-02-20 15:53:15 +110056/* Error codes */
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +110057/** No error */
Jean-Marc Valin94d4ea92008-01-27 17:34:35 +110058#define CELT_OK 0
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +110059/** An (or more) invalid argument (e.g. out of range) */
Jean-Marc Valin94d4ea92008-01-27 17:34:35 +110060#define CELT_BAD_ARG -1
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +110061/** The mode struct passed is invalid */
Jean-Marc Valinef20e392011-03-18 15:34:11 -040062#define CELT_BUFFER_TOO_SMALL -2
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +110063/** An internal error was detected */
Jean-Marc Valin94d4ea92008-01-27 17:34:35 +110064#define CELT_INTERNAL_ERROR -3
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +110065/** The data passed (e.g. compressed data to decoder) is corrupted */
Jean-Marc Valin94d4ea92008-01-27 17:34:35 +110066#define CELT_CORRUPTED_DATA -4
Jean-Marc Valinc18fb1d2008-09-30 07:36:54 -040067/** Invalid/unsupported request number */
Jean-Marc Valinb6f90612008-10-05 22:39:13 -040068#define CELT_UNIMPLEMENTED -5
Jean-Marc Valin56522ad2009-06-05 17:17:25 -040069/** An encoder or decoder structure is invalid or already freed */
Gregory Maxwell17169992009-06-04 15:15:34 -040070#define CELT_INVALID_STATE -6
Jean-Marc Valinece94a02009-10-16 07:30:14 -040071/** Memory allocation has failed */
Jean-Marc Valin163b02e2009-10-16 21:32:52 -040072#define CELT_ALLOC_FAIL -7
Jean-Marc Valina76a0b22008-01-17 22:43:05 +110073
Jean-Marc Valinc3086a92011-03-21 13:26:03 -040074
75/* Encoder/decoder Requests */
Jean-Marc Valin7bb26e12011-02-01 17:04:27 -050076
Jean-Marc Valinb6f90612008-10-05 22:39:13 -040077#define CELT_SET_COMPLEXITY_REQUEST 2
Jean-Marc Valin5ac6d422008-10-09 07:27:10 -040078/** Controls the complexity from 0-10 (int) */
Jean-Marc Valinb6f90612008-10-05 22:39:13 -040079#define CELT_SET_COMPLEXITY(x) CELT_SET_COMPLEXITY_REQUEST, _celt_check_int(x)
Jean-Marc Valin7bb26e12011-02-01 17:04:27 -050080
Gregory Maxwell2dd3d322009-06-05 14:05:51 -040081#define CELT_SET_PREDICTION_REQUEST 4
82/** Controls the use of interframe prediction.
83 0=Independent frames
84 1=Short term interframe prediction allowed
85 2=Long term prediction allowed
86 */
87#define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, _celt_check_int(x)
Jean-Marc Valin7bb26e12011-02-01 17:04:27 -050088
89#define CELT_SET_BITRATE_REQUEST 6
Jean-Marc Valin56522ad2009-06-05 17:17:25 -040090/** Set the target VBR rate in bits per second(int); 0=CBR (default) */
Jean-Marc Valin7bb26e12011-02-01 17:04:27 -050091#define CELT_SET_BITRATE(x) CELT_SET_BITRATE_REQUEST, _celt_check_int(x)
92
John Ridges454d1d02009-05-21 22:38:39 -040093#define CELT_RESET_STATE_REQUEST 8
Jean-Marc Valinc3086a92011-03-21 13:26:03 -040094/** Reset the encoder/decoder memories to zero*/
John Ridges454d1d02009-05-21 22:38:39 -040095#define CELT_RESET_STATE CELT_RESET_STATE_REQUEST
Jean-Marc Valinc18fb1d2008-09-30 07:36:54 -040096
Jean-Marc Valin79b34eb2010-12-05 17:22:06 -050097#define CELT_SET_VBR_CONSTRAINT_REQUEST 10
98#define CELT_SET_VBR_CONSTRAINT(x) CELT_SET_VBR_CONSTRAINT_REQUEST, _celt_check_int(x)
99
Jean-Marc Valin7bb26e12011-02-01 17:04:27 -0500100#define CELT_SET_VBR_REQUEST 12
101#define CELT_SET_VBR(x) CELT_SET_VBR_REQUEST, _celt_check_int(x)
102
Jean-Marc Valin0b405d12011-02-04 01:03:42 -0500103#define CELT_SET_INPUT_CLIPPING_REQUEST 14
104#define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, _celt_check_int(x)
105
Jean-Marc Valinef20e392011-03-18 15:34:11 -0400106#define CELT_GET_AND_CLEAR_ERROR_REQUEST 15
107#define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, _celt_check_int_ptr(x)
108
Jean-Marc Valinff96b162011-03-21 11:32:50 -0400109#define CELT_GET_LOOKAHEAD_REQUEST 17
110#define CELT_GET_LOOKAHEAD(x) CELT_GET_LOOKAHEAD_REQUEST, _celt_check_int_ptr(x)
111
Jean-Marc Valinc3086a92011-03-21 13:26:03 -0400112#define CELT_SET_CHANNELS_REQUEST 18
113#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, _celt_check_int(x)
114
Jean-Marc Valin69653882011-04-21 10:41:13 -0400115#define CELT_SET_LOSS_PERC_REQUEST 20
116#define CELT_SET_LOSS_PERC(x) CELT_SET_LOSS_PERC_REQUEST, _celt_check_int(x)
117
Jean-Marc Valinef20e392011-03-18 15:34:11 -0400118/* Internal */
Jean-Marc Valin5f961462010-05-19 13:38:10 -0400119#define CELT_SET_START_BAND_REQUEST 10000
Jean-Marc Valin5f961462010-05-19 13:38:10 -0400120#define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x)
121
Jean-Marc Valin525d7cf2010-07-13 14:14:16 -0400122#define CELT_SET_END_BAND_REQUEST 10001
123#define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, _celt_check_int(x)
124
Jean-Marc Valinf1916a12011-01-31 10:51:30 -0500125
Jean-Marc Valine6acfe02011-03-11 16:31:24 -0500126
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400127/** Contains the state of an encoder. One encoder state is needed
128 for each stream. It is initialised once at the beginning of the
129 stream. Do *not* re-initialise the state for every frame.
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +1100130 @brief Encoder state
131 */
Jean-Marc Valin269d40a2007-12-07 11:29:45 +1100132typedef struct CELTEncoder CELTEncoder;
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100133
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400134/** State of the decoder. One decoder state is needed for each stream.
135 It is initialised once at the beginning of the stream. Do *not*
136 re-initialise the state for every frame */
Jean-Marc Valin269d40a2007-12-07 11:29:45 +1100137typedef struct CELTDecoder CELTDecoder;
Jean-Marc Valin013c31d2007-11-30 11:36:46 +1100138
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400139/** The mode contains all the information necessary to create an
140 encoder. Both the encoder and decoder need to be initialised
141 with exactly the same mode, otherwise the quality will be very
142 bad */
Jean-Marc Valinc245a222007-12-06 19:14:20 +1100143typedef struct CELTMode CELTMode;
Jean-Marc Valin013c31d2007-11-30 11:36:46 +1100144
Jean-Marc Valinf997ad52008-01-31 16:47:16 +1100145
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +1100146/** \defgroup codec Encoding and decoding */
147/* @{ */
148
149/* Mode calls */
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100150
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400151/** Creates a new mode struct. This will be passed to an encoder or
152 decoder. The mode MUST NOT BE DESTROYED until the encoders and
153 decoders that use it are destroyed as well.
Gregory Maxwell8ed86582008-12-02 12:06:14 -0500154 @param Fs Sampling rate (32000 to 96000 Hz)
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400155 @param frame_size Number of samples (per channel) to encode in each
156 packet (even values; 64 - 512)
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100157 @param error Returned error code (if NULL, no error will be returned)
158 @return A newly created mode
159*/
Jean-Marc Valind77d6a52011-07-29 17:33:06 -0400160CELT_EXPORT CELTMode *celt_mode_create(opus_int32 Fs, int frame_size, int *error);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100161
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400162/** Destroys a mode struct. Only call this after all encoders and
163 decoders using this mode are destroyed as well.
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100164 @param mode Mode to be destroyed
165*/
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400166CELT_EXPORT void celt_mode_destroy(CELTMode *mode);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100167
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100168/* Encoder stuff */
169
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400170CELT_EXPORT int celt_encoder_get_size(int channels);
Jean-Marc Valin8cf29f02011-01-30 23:38:28 -0500171
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400172CELT_EXPORT int celt_encoder_get_size_custom(const CELTMode *mode, int channels);
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +1100173
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400174/** Creates a new encoder state. Each stream needs its own encoder
175 state (can't be shared across simultaneous streams).
Jean-Marc Valinc97b2582011-01-28 23:07:32 -0500176 @param channels Number of channels
177 @param error Returns an error code
178 @return Newly created encoder state.
179*/
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400180CELT_EXPORT CELTEncoder *celt_encoder_create(int sampling_rate, int channels, int *error);
Jean-Marc Valinc97b2582011-01-28 23:07:32 -0500181
182/** Creates a new encoder state. Each stream needs its own encoder
183 state (can't be shared across simultaneous streams).
Jean-Marc Valin56522ad2009-06-05 17:17:25 -0400184 @param mode Contains all the information about the characteristics of
185 * the stream (must be the same characteristics as used for the
186 * decoder)
Jean-Marc Valin954fb112009-10-22 21:14:22 -0400187 @param channels Number of channels
188 @param error Returns an error code
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100189 @return Newly created encoder state.
190*/
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400191CELT_EXPORT CELTEncoder *celt_encoder_create_custom(const CELTMode *mode, int channels, int *error);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100192
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400193CELT_EXPORT CELTEncoder *celt_encoder_init(CELTEncoder *st, int sampling_rate, int channels, int *error);
Jean-Marc Valinc97b2582011-01-28 23:07:32 -0500194
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400195CELT_EXPORT CELTEncoder *celt_encoder_init_custom(CELTEncoder *st, const CELTMode *mode, int channels, int *error);
Jean-Marc Valin7cfb7302010-08-27 16:54:33 -0400196
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100197/** Destroys a an encoder state.
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +1100198 @param st Encoder state to be destroyed
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100199 */
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400200CELT_EXPORT void celt_encoder_destroy(CELTEncoder *st);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100201
202/** Encodes a frame of audio.
203 @param st Encoder state
Jean-Marc Valind56c6102010-05-07 20:30:22 -0400204 @param pcm PCM audio in float format, with a normal range of ±1.0.
205 * Samples with a range beyond ±1.0 are supported but will
206 * be clipped by decoders using the integer API and should
207 * only be used if it is known that the far end supports
208 * extended dynmaic range. There must be exactly
209 * frame_size samples per channel.
210 @param compressed The compressed data is written here. This may not alias pcm or
211 * optional_synthesis.
212 @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
213 * (can change from one frame to another)
214 @return Number of bytes written to "compressed". Will be the same as
215 * "nbCompressedBytes" unless the stream is VBR and will never be larger.
216 * If negative, an error has occurred (see error codes). It is IMPORTANT that
217 * the length returned be somehow transmitted to the decoder. Otherwise, no
218 * decoding is possible.
219*/
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400220CELT_EXPORT int celt_encode_float(CELTEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
Gregory Maxwellf0d6e312009-02-16 21:29:15 -0500221
Jean-Marc Valin5ac6d422008-10-09 07:27:10 -0400222/** Encodes a frame of audio.
223 @param st Encoder state
Jean-Marc Valind56c6102010-05-07 20:30:22 -0400224 @param pcm PCM audio in signed 16-bit format (native endian). There must be
225 * exactly frame_size samples per channel.
226 @param compressed The compressed data is written here. This may not alias pcm or
227 * optional_synthesis.
228 @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
229 * (can change from one frame to another)
230 @return Number of bytes written to "compressed". Will be the same as
231 * "nbCompressedBytes" unless the stream is VBR and will never be larger.
232 * If negative, an error has occurred (see error codes). It is IMPORTANT that
233 * the length returned be somehow transmitted to the decoder. Otherwise, no
234 * decoding is possible.
235 */
Jean-Marc Valind77d6a52011-07-29 17:33:06 -0400236CELT_EXPORT int celt_encode(CELTEncoder *st, const opus_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100237
Jean-Marc Valinc18fb1d2008-09-30 07:36:54 -0400238/** Query and set encoder parameters
239 @param st Encoder state
240 @param request Parameter to change or query
241 @param value Pointer to a 32-bit int value
242 @return Error code
243*/
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400244CELT_EXPORT int celt_encoder_ctl(CELTEncoder * st, int request, ...);
Jean-Marc Valinc18fb1d2008-09-30 07:36:54 -0400245
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100246/* Decoder stuff */
247
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400248CELT_EXPORT int celt_decoder_get_size(int channels);
Jean-Marc Valin8cf29f02011-01-30 23:38:28 -0500249
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400250CELT_EXPORT int celt_decoder_get_size_custom(const CELTMode *mode, int channels);
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +1100251
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100252/** Creates a new decoder state. Each stream needs its own decoder state (can't
253 be shared across simultaneous streams).
254 @param mode Contains all the information about the characteristics of the
255 stream (must be the same characteristics as used for the encoder)
Jean-Marc Valin954fb112009-10-22 21:14:22 -0400256 @param channels Number of channels
257 @param error Returns an error code
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100258 @return Newly created decoder state.
259 */
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400260CELT_EXPORT CELTDecoder *celt_decoder_create(int sampling_rate, int channels, int *error);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100261
Jean-Marc Valinc97b2582011-01-28 23:07:32 -0500262/** Creates a new decoder state. Each stream needs its own decoder state (can't
263 be shared across simultaneous streams).
264 @param mode Contains all the information about the characteristics of the
265 stream (must be the same characteristics as used for the encoder)
266 @param channels Number of channels
267 @param error Returns an error code
268 @return Newly created decoder state.
269 */
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400270CELT_EXPORT CELTDecoder *celt_decoder_create_custom(const CELTMode *mode, int channels, int *error);
Jean-Marc Valinc97b2582011-01-28 23:07:32 -0500271
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400272CELT_EXPORT CELTDecoder *celt_decoder_init(CELTDecoder *st, int sampling_rate, int channels, int *error);
Jean-Marc Valinc97b2582011-01-28 23:07:32 -0500273
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400274CELT_EXPORT CELTDecoder *celt_decoder_init_custom(CELTDecoder *st, const CELTMode *mode, int channels, int *error);
Jean-Marc Valin7cfb7302010-08-27 16:54:33 -0400275
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100276/** Destroys a a decoder state.
Jean-Marc Valin879fbfd2008-02-20 17:17:13 +1100277 @param st Decoder state to be destroyed
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100278 */
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400279CELT_EXPORT void celt_decoder_destroy(CELTDecoder *st);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100280
281/** Decodes a frame of audio.
282 @param st Decoder state
283 @param data Compressed data produced by an encoder
284 @param len Number of bytes to read from "data". This MUST be exactly the number
285 of bytes returned by the encoder. Using a larger value WILL NOT WORK.
286 @param pcm One frame (frame_size samples per channel) of decoded PCM will be
Jean-Marc Valin5ac6d422008-10-09 07:27:10 -0400287 returned here in float format.
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100288 @return Error code.
289 */
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400290CELT_EXPORT int celt_decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm, int frame_size);
Gregory Maxwellf0d6e312009-02-16 21:29:15 -0500291
Jean-Marc Valin5ac6d422008-10-09 07:27:10 -0400292/** Decodes a frame of audio.
293 @param st Decoder state
294 @param data Compressed data produced by an encoder
295 @param len Number of bytes to read from "data". This MUST be exactly the number
296 of bytes returned by the encoder. Using a larger value WILL NOT WORK.
297 @param pcm One frame (frame_size samples per channel) of decoded PCM will be
298 returned here in 16-bit PCM format (native endian).
299 @return Error code.
300 */
Jean-Marc Valind77d6a52011-07-29 17:33:06 -0400301CELT_EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, opus_int16 *pcm, int frame_size);
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100302
John Ridges454d1d02009-05-21 22:38:39 -0400303/** Query and set decoder parameters
304 @param st Decoder state
305 @param request Parameter to change or query
306 @param value Pointer to a 32-bit int value
307 @return Error code
308 */
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400309CELT_EXPORT int celt_decoder_ctl(CELTDecoder * st, int request, ...);
John Ridges454d1d02009-05-21 22:38:39 -0400310
311
Jean-Marc Valina3803a92009-10-24 11:24:34 -0400312/** Returns the English string that corresponds to an error code
313 * @param error Error code (negative for an error, 0 for success
314 * @return Constant string (must NOT be freed)
315 */
Jean-Marc Valin9edde422011-05-05 15:30:44 -0400316CELT_EXPORT const char *celt_strerror(int error);
Jean-Marc Valinece94a02009-10-16 07:30:14 -0400317
Jean-Marc Valina3803a92009-10-24 11:24:34 -0400318/* @} */
319
Jean-Marc Valin8c19b032008-02-20 15:53:15 +1100320
Jean-Marc Valin77ff83a2008-01-22 13:16:36 +1100321#ifdef __cplusplus
322}
323#endif
324
Jean-Marc Valin013c31d2007-11-30 11:36:46 +1100325#endif /*CELT_H */