Opus
Opus audio codec (RFC 6716): API and operations manual
1.3.1
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
35#ifndef OPUS_CUSTOM_H
36#define OPUS_CUSTOM_H
37
38#include "opus_defines.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#ifdef CUSTOM_MODES
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
96
103
111
121OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error);
122
128
129
130#if !defined(OPUS_BUILD) || defined(CELT_ENCODER_C)
131
132/* Encoder */
139 const OpusCustomMode *mode,
140 int channels
141) OPUS_ARG_NONNULL(1);
142
143# ifdef CUSTOM_MODES
156OPUS_CUSTOM_EXPORT int opus_custom_encoder_init(
158 const OpusCustomMode *mode,
159 int channels
160) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
161# endif
162#endif
163
164
175 const OpusCustomMode *mode,
176 int channels,
177 int *error
178) OPUS_ARG_NONNULL(1);
179
180
185
205 const float *pcm,
206 int frame_size,
207 unsigned char *compressed,
208 int maxCompressedBytes
209) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
210
224OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode(
226 const opus_int16 *pcm,
227 int frame_size,
228 unsigned char *compressed,
229 int maxCompressedBytes
230) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
231
238OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
239
240
241#if !defined(OPUS_BUILD) || defined(CELT_DECODER_C)
242/* Decoder */
243
250 const OpusCustomMode *mode,
251 int channels
252) OPUS_ARG_NONNULL(1);
253
268 const OpusCustomMode *mode,
269 int channels
270) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
271
272#endif
273
274
284 const OpusCustomMode *mode,
285 int channels,
286 int *error
287) OPUS_ARG_NONNULL(1);
288
293
305 const unsigned char *data,
306 int len,
307 float *pcm,
308 int frame_size
309) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
310
320OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode(
322 const unsigned char *data,
323 int len,
324 opus_int16 *pcm,
325 int frame_size
326) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
327
334OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
335
338#ifdef __cplusplus
339}
340#endif
341
342#endif /* OPUS_CUSTOM_H */
void opus_custom_decoder_destroy(OpusCustomDecoder *st)
Destroys a an decoder state.
void opus_custom_mode_destroy(OpusCustomMode *mode)
Destroys a mode struct.
int opus_custom_encode(OpusCustomEncoder *st, const opus_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes)
Encodes a frame of audio.
int opus_custom_encoder_get_size(const OpusCustomMode *mode, int channels)
Gets the size of an OpusCustomEncoder structure.
void opus_custom_encoder_destroy(OpusCustomEncoder *st)
Destroys a an encoder state.
OpusCustomDecoder * opus_custom_decoder_create(const OpusCustomMode *mode, int channels, int *error)
Creates a new decoder state.
OpusCustomEncoder * opus_custom_encoder_create(const OpusCustomMode *mode, int channels, int *error)
Creates a new encoder state.
struct OpusCustomEncoder OpusCustomEncoder
Contains the state of an encoder.
Definition: opus_custom.h:95
int opus_custom_decoder_ctl(OpusCustomDecoder *OPUS_RESTRICT st, int request,...)
Perform a CTL function on an Opus custom decoder.
int opus_custom_encode_float(OpusCustomEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes)
Encodes a frame of audio.
int opus_custom_decoder_get_size(const OpusCustomMode *mode, int channels)
Gets the size of an OpusCustomDecoder structure.
OpusCustomMode * opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error)
Creates a new mode struct.
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.
struct OpusCustomDecoder OpusCustomDecoder
State of the decoder.
Definition: opus_custom.h:102
int opus_custom_encoder_ctl(OpusCustomEncoder *OPUS_RESTRICT st, int request,...)
Perform a CTL function on an Opus custom encoder.
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...
struct OpusCustomMode OpusCustomMode
The mode contains all the information necessary to create an encoder.
Definition: opus_custom.h:110
int opus_custom_decode(OpusCustomDecoder *st, const unsigned char *data, int len, opus_int16 *pcm, int frame_size)
Decode an opus custom frame.
#define OPUS_CUSTOM_EXPORT_STATIC
Definition: opus_custom.h:52
#define OPUS_CUSTOM_EXPORT
Definition: opus_custom.h:48
Opus reference implementation constants.
int opus_int32
Definition: opus_types.h:161
short opus_int16
Definition: opus_types.h:159
For more information visit the Opus Website.