Opus audio codec (RFC 6716): API and operations manual
| 1.6

Loading...
Searching...
No Matches
opus_custom.h
Go to the documentation of this file.
1/* Copyright (c) 2007-2008 CSIRO
2 Copyright (c) 2007-2009 Xiph.Org Foundation
3 Copyright (c) 2008-2012 Gregory Maxwell
4 Written by Jean-Marc Valin and Gregory Maxwell */
5/*
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 - Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 - Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
34
35#ifndef OPUS_CUSTOM_H
36#define OPUS_CUSTOM_H
37
38#include "opus_defines.h"
39
40#ifdef __cplusplus
41 extern "C" {
42#endif
43
44#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API)
45# define OPUS_CUSTOM_EXPORT OPUS_EXPORT
46# define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT
47#else
48# define OPUS_CUSTOM_EXPORT
49# ifdef OPUS_BUILD
50# define OPUS_CUSTOM_EXPORT_STATIC static OPUS_INLINE
51# else
52# define OPUS_CUSTOM_EXPORT_STATIC
53# endif
54#endif
55
89
95 typedef struct OpusCustomEncoder OpusCustomEncoder;
96
102 typedef struct OpusCustomDecoder OpusCustomDecoder;
103
111 typedef struct OpusCustomMode OpusCustomMode;
112
122 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error);
123
128 OPUS_CUSTOM_EXPORT void opus_custom_mode_destroy(OpusCustomMode *mode);
129
130
131#if !defined(OPUS_BUILD) || defined(CELT_ENCODER_C)
132
133/* Encoder */
139 OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_encoder_get_size(
140 const OpusCustomMode *mode,
141 int channels
142) OPUS_ARG_NONNULL(1);
143
144#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API)
157 OPUS_CUSTOM_EXPORT int opus_custom_encoder_init(
158 OpusCustomEncoder *st,
159 const OpusCustomMode *mode,
160 int channels
161) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
162# endif
163#endif
164
165
175 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomEncoder *opus_custom_encoder_create(
176 const OpusCustomMode *mode,
177 int channels,
178 int *error
179) OPUS_ARG_NONNULL(1);
180
181
185 OPUS_CUSTOM_EXPORT void opus_custom_encoder_destroy(OpusCustomEncoder *st);
186
204 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode_float(
205 OpusCustomEncoder *st,
206 const float *pcm,
207 int frame_size,
208 unsigned char *compressed,
209 int maxCompressedBytes
210) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
211
225 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode(
226 OpusCustomEncoder *st,
227 const opus_int16 *pcm,
228 int frame_size,
229 unsigned char *compressed,
230 int maxCompressedBytes
231) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
232
246 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode24(
247 OpusCustomEncoder *st,
248 const opus_int32 *pcm,
249 int frame_size,
250 unsigned char *compressed,
251 int maxCompressedBytes
252) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
253
260 OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
261
262
263#if !defined(OPUS_BUILD) || defined(CELT_DECODER_C)
264/* Decoder */
265
271 OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_decoder_get_size(
272 const OpusCustomMode *mode,
273 int channels
274) OPUS_ARG_NONNULL(1);
275
288 OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_init(
289 OpusCustomDecoder *st,
290 const OpusCustomMode *mode,
291 int channels
292) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
293
294#endif
295
296
305 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomDecoder *opus_custom_decoder_create(
306 const OpusCustomMode *mode,
307 int channels,
308 int *error
309) OPUS_ARG_NONNULL(1);
310
314 OPUS_CUSTOM_EXPORT void opus_custom_decoder_destroy(OpusCustomDecoder *st);
315
325 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode_float(
326 OpusCustomDecoder *st,
327 const unsigned char *data,
328 int len,
329 float *pcm,
330 int frame_size
331) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
332
342 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode(
343 OpusCustomDecoder *st,
344 const unsigned char *data,
345 int len,
346 opus_int16 *pcm,
347 int frame_size
348) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
349
359 OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode24(
360 OpusCustomDecoder *st,
361 const unsigned char *data,
362 int len,
363 opus_int32 *pcm,
364 int frame_size
365) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
366
373 OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
374
376
377#ifdef __cplusplus
378}
379#endif
380
381#endif /* OPUS_CUSTOM_H */
opus_custom_decoder_destroy
void opus_custom_decoder_destroy(OpusCustomDecoder *st)
Destroys a decoder state.
opus_custom_mode_destroy
void opus_custom_mode_destroy(OpusCustomMode *mode)
Destroys a mode struct.
opus_custom_encode
int opus_custom_encode(OpusCustomEncoder *st, const opus_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes)
Encodes a frame of audio.
opus_custom_encoder_get_size
int opus_custom_encoder_get_size(const OpusCustomMode *mode, int channels)
Gets the size of an OpusCustomEncoder structure.
opus_custom_encode24
int opus_custom_encode24(OpusCustomEncoder *st, const opus_int32 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes)
Encodes a frame of audio.
opus_custom_encoder_destroy
void opus_custom_encoder_destroy(OpusCustomEncoder *st)
Destroys an encoder state.
opus_custom_decoder_create
OpusCustomDecoder * opus_custom_decoder_create(const OpusCustomMode *mode, int channels, int *error)
Creates a new decoder state.
opus_custom_encoder_create
OpusCustomEncoder * opus_custom_encoder_create(const OpusCustomMode *mode, int channels, int *error)
Creates a new encoder state.
OpusCustomEncoder
struct OpusCustomEncoder OpusCustomEncoder
Contains the state of an encoder.
Definition opus_custom.h:95
opus_custom_decoder_ctl
int opus_custom_decoder_ctl(OpusCustomDecoder *OPUS_RESTRICT st, int request,...)
Perform a CTL function on an Opus custom decoder.
opus_custom_encode_float
int opus_custom_encode_float(OpusCustomEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes)
Encodes a frame of audio.
opus_custom_decoder_get_size
int opus_custom_decoder_get_size(const OpusCustomMode *mode, int channels)
Gets the size of an OpusCustomDecoder structure.
opus_custom_mode_create
OpusCustomMode * opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error)
Creates a new mode struct.
opus_custom_decode_float
int opus_custom_decode_float(OpusCustomDecoder *st, const unsigned char *data, int len, float *pcm, int frame_size)
Decode an opus custom frame with floating point output.
OpusCustomDecoder
struct OpusCustomDecoder OpusCustomDecoder
State of the decoder.
Definition opus_custom.h:102
opus_custom_encoder_ctl
int opus_custom_encoder_ctl(OpusCustomEncoder *OPUS_RESTRICT st, int request,...)
Perform a CTL function on an Opus custom encoder.
opus_custom_decoder_init
int opus_custom_decoder_init(OpusCustomDecoder *st, const OpusCustomMode *mode, int channels)
Initializes a previously allocated decoder state The memory pointed to by st must be the size returne...
OpusCustomMode
struct OpusCustomMode OpusCustomMode
The mode contains all the information necessary to create an encoder.
Definition opus_custom.h:111
opus_custom_decode24
int opus_custom_decode24(OpusCustomDecoder *st, const unsigned char *data, int len, opus_int32 *pcm, int frame_size)
Decode an opus custom frame.
opus_custom_decode
int opus_custom_decode(OpusCustomDecoder *st, const unsigned char *data, int len, opus_int16 *pcm, int frame_size)
Decode an opus custom frame.
OPUS_CUSTOM_EXPORT_STATIC
#define OPUS_CUSTOM_EXPORT_STATIC
Definition opus_custom.h:52
OPUS_CUSTOM_EXPORT
#define OPUS_CUSTOM_EXPORT
Definition opus_custom.h:48
opus_defines.h
Opus reference implementation constants.
opus_int32
int opus_int32
Definition opus_types.h:161
opus_int16
short opus_int16
Definition opus_types.h:159