xref: /aosp_15_r20/external/libopus/include/opus_custom.h (revision a58d3d2adb790c104798cd88c8a3aff4fa8b82cc)
1*a58d3d2aSXin Li /* Copyright (c) 2007-2008 CSIRO
2*a58d3d2aSXin Li    Copyright (c) 2007-2009 Xiph.Org Foundation
3*a58d3d2aSXin Li    Copyright (c) 2008-2012 Gregory Maxwell
4*a58d3d2aSXin Li    Written by Jean-Marc Valin and Gregory Maxwell */
5*a58d3d2aSXin Li /*
6*a58d3d2aSXin Li    Redistribution and use in source and binary forms, with or without
7*a58d3d2aSXin Li    modification, are permitted provided that the following conditions
8*a58d3d2aSXin Li    are met:
9*a58d3d2aSXin Li 
10*a58d3d2aSXin Li    - Redistributions of source code must retain the above copyright
11*a58d3d2aSXin Li    notice, this list of conditions and the following disclaimer.
12*a58d3d2aSXin Li 
13*a58d3d2aSXin Li    - Redistributions in binary form must reproduce the above copyright
14*a58d3d2aSXin Li    notice, this list of conditions and the following disclaimer in the
15*a58d3d2aSXin Li    documentation and/or other materials provided with the distribution.
16*a58d3d2aSXin Li 
17*a58d3d2aSXin Li    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18*a58d3d2aSXin Li    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*a58d3d2aSXin Li    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20*a58d3d2aSXin Li    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21*a58d3d2aSXin Li    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22*a58d3d2aSXin Li    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23*a58d3d2aSXin Li    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24*a58d3d2aSXin Li    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25*a58d3d2aSXin Li    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26*a58d3d2aSXin Li    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27*a58d3d2aSXin Li    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*a58d3d2aSXin Li */
29*a58d3d2aSXin Li 
30*a58d3d2aSXin Li /**
31*a58d3d2aSXin Li   @file opus_custom.h
32*a58d3d2aSXin Li   @brief Opus-Custom reference implementation API
33*a58d3d2aSXin Li  */
34*a58d3d2aSXin Li 
35*a58d3d2aSXin Li #ifndef OPUS_CUSTOM_H
36*a58d3d2aSXin Li #define OPUS_CUSTOM_H
37*a58d3d2aSXin Li 
38*a58d3d2aSXin Li #include "opus_defines.h"
39*a58d3d2aSXin Li 
40*a58d3d2aSXin Li #ifdef __cplusplus
41*a58d3d2aSXin Li extern "C" {
42*a58d3d2aSXin Li #endif
43*a58d3d2aSXin Li 
44*a58d3d2aSXin Li #ifdef CUSTOM_MODES
45*a58d3d2aSXin Li # define OPUS_CUSTOM_EXPORT OPUS_EXPORT
46*a58d3d2aSXin Li # define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT
47*a58d3d2aSXin Li #else
48*a58d3d2aSXin Li # define OPUS_CUSTOM_EXPORT
49*a58d3d2aSXin Li # ifdef OPUS_BUILD
50*a58d3d2aSXin Li #  define OPUS_CUSTOM_EXPORT_STATIC static OPUS_INLINE
51*a58d3d2aSXin Li # else
52*a58d3d2aSXin Li #  define OPUS_CUSTOM_EXPORT_STATIC
53*a58d3d2aSXin Li # endif
54*a58d3d2aSXin Li #endif
55*a58d3d2aSXin Li 
56*a58d3d2aSXin Li /** @defgroup opus_custom Opus Custom
57*a58d3d2aSXin Li   * @{
58*a58d3d2aSXin Li   *  Opus Custom is an optional part of the Opus specification and
59*a58d3d2aSXin Li   * reference implementation which uses a distinct API from the regular
60*a58d3d2aSXin Li   * API and supports frame sizes that are not normally supported.\ Use
61*a58d3d2aSXin Li   * of Opus Custom is discouraged for all but very special applications
62*a58d3d2aSXin Li   * for which a frame size different from 2.5, 5, 10, or 20 ms is needed
63*a58d3d2aSXin Li   * (for either complexity or latency reasons) and where interoperability
64*a58d3d2aSXin Li   * is less important.
65*a58d3d2aSXin Li   *
66*a58d3d2aSXin Li   * In addition to the interoperability limitations the use of Opus custom
67*a58d3d2aSXin Li   * disables a substantial chunk of the codec and generally lowers the
68*a58d3d2aSXin Li   * quality available at a given bitrate. Normally when an application needs
69*a58d3d2aSXin Li   * a different frame size from the codec it should buffer to match the
70*a58d3d2aSXin Li   * sizes but this adds a small amount of delay which may be important
71*a58d3d2aSXin Li   * in some very low latency applications. Some transports (especially
72*a58d3d2aSXin Li   * constant rate RF transports) may also work best with frames of
73*a58d3d2aSXin Li   * particular durations.
74*a58d3d2aSXin Li   *
75*a58d3d2aSXin Li   * Libopus only supports custom modes if they are enabled at compile time.
76*a58d3d2aSXin Li   *
77*a58d3d2aSXin Li   * The Opus Custom API is similar to the regular API but the
78*a58d3d2aSXin Li   * @ref opus_encoder_create and @ref opus_decoder_create calls take
79*a58d3d2aSXin Li   * an additional mode parameter which is a structure produced by
80*a58d3d2aSXin Li   * a call to @ref opus_custom_mode_create. Both the encoder and decoder
81*a58d3d2aSXin Li   * must create a mode using the same sample rate (fs) and frame size
82*a58d3d2aSXin Li   * (frame size) so these parameters must either be signaled out of band
83*a58d3d2aSXin Li   * or fixed in a particular implementation.
84*a58d3d2aSXin Li   *
85*a58d3d2aSXin Li   * Similar to regular Opus the custom modes support on the fly frame size
86*a58d3d2aSXin Li   * switching, but the sizes available depend on the particular frame size in
87*a58d3d2aSXin Li   * use. For some initial frame sizes on a single on the fly size is available.
88*a58d3d2aSXin Li   */
89*a58d3d2aSXin Li 
90*a58d3d2aSXin Li /** Contains the state of an encoder. One encoder state is needed
91*a58d3d2aSXin Li     for each stream. It is initialized once at the beginning of the
92*a58d3d2aSXin Li     stream. Do *not* re-initialize the state for every frame.
93*a58d3d2aSXin Li    @brief Encoder state
94*a58d3d2aSXin Li  */
95*a58d3d2aSXin Li typedef struct OpusCustomEncoder OpusCustomEncoder;
96*a58d3d2aSXin Li 
97*a58d3d2aSXin Li /** State of the decoder. One decoder state is needed for each stream.
98*a58d3d2aSXin Li     It is initialized once at the beginning of the stream. Do *not*
99*a58d3d2aSXin Li     re-initialize the state for every frame.
100*a58d3d2aSXin Li    @brief Decoder state
101*a58d3d2aSXin Li  */
102*a58d3d2aSXin Li typedef struct OpusCustomDecoder OpusCustomDecoder;
103*a58d3d2aSXin Li 
104*a58d3d2aSXin Li /** The mode contains all the information necessary to create an
105*a58d3d2aSXin Li     encoder. Both the encoder and decoder need to be initialized
106*a58d3d2aSXin Li     with exactly the same mode, otherwise the output will be
107*a58d3d2aSXin Li     corrupted. The mode MUST NOT BE DESTROYED until the encoders and
108*a58d3d2aSXin Li     decoders that use it are destroyed as well.
109*a58d3d2aSXin Li    @brief Mode configuration
110*a58d3d2aSXin Li  */
111*a58d3d2aSXin Li typedef struct OpusCustomMode OpusCustomMode;
112*a58d3d2aSXin Li 
113*a58d3d2aSXin Li /** Creates a new mode struct. This will be passed to an encoder or
114*a58d3d2aSXin Li   * decoder. The mode MUST NOT BE DESTROYED until the encoders and
115*a58d3d2aSXin Li   * decoders that use it are destroyed as well.
116*a58d3d2aSXin Li   * @param [in] Fs <tt>int</tt>: Sampling rate (8000 to 96000 Hz)
117*a58d3d2aSXin Li   * @param [in] frame_size <tt>int</tt>: Number of samples (per channel) to encode in each
118*a58d3d2aSXin Li   *        packet (64 - 1024, prime factorization must contain zero or more 2s, 3s, or 5s and no other primes)
119*a58d3d2aSXin Li   * @param [out] error <tt>int*</tt>: Returned error code (if NULL, no error will be returned)
120*a58d3d2aSXin Li   * @return A newly created mode
121*a58d3d2aSXin Li   */
122*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error);
123*a58d3d2aSXin Li 
124*a58d3d2aSXin Li /** Destroys a mode struct. Only call this after all encoders and
125*a58d3d2aSXin Li   * decoders using this mode are destroyed as well.
126*a58d3d2aSXin Li   * @param [in] mode <tt>OpusCustomMode*</tt>: Mode to be freed.
127*a58d3d2aSXin Li   */
128*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT void opus_custom_mode_destroy(OpusCustomMode *mode);
129*a58d3d2aSXin Li 
130*a58d3d2aSXin Li 
131*a58d3d2aSXin Li #if !defined(OPUS_BUILD) || defined(CELT_ENCODER_C)
132*a58d3d2aSXin Li 
133*a58d3d2aSXin Li /* Encoder */
134*a58d3d2aSXin Li /** Gets the size of an OpusCustomEncoder structure.
135*a58d3d2aSXin Li   * @param [in] mode <tt>OpusCustomMode *</tt>: Mode configuration
136*a58d3d2aSXin Li   * @param [in] channels <tt>int</tt>: Number of channels
137*a58d3d2aSXin Li   * @returns size
138*a58d3d2aSXin Li   */
139*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_encoder_get_size(
140*a58d3d2aSXin Li     const OpusCustomMode *mode,
141*a58d3d2aSXin Li     int channels
142*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1);
143*a58d3d2aSXin Li 
144*a58d3d2aSXin Li # ifdef CUSTOM_MODES
145*a58d3d2aSXin Li /** Initializes a previously allocated encoder state
146*a58d3d2aSXin Li   * The memory pointed to by st must be the size returned by opus_custom_encoder_get_size.
147*a58d3d2aSXin Li   * This is intended for applications which use their own allocator instead of malloc.
148*a58d3d2aSXin Li   * @see opus_custom_encoder_create(),opus_custom_encoder_get_size()
149*a58d3d2aSXin Li   * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
150*a58d3d2aSXin Li   * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
151*a58d3d2aSXin Li   * @param [in] mode <tt>OpusCustomMode *</tt>: Contains all the information about the characteristics of
152*a58d3d2aSXin Li   *  the stream (must be the same characteristics as used for the
153*a58d3d2aSXin Li   *  decoder)
154*a58d3d2aSXin Li   * @param [in] channels <tt>int</tt>: Number of channels
155*a58d3d2aSXin Li   * @return OPUS_OK Success or @ref opus_errorcodes
156*a58d3d2aSXin Li   */
157*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT int opus_custom_encoder_init(
158*a58d3d2aSXin Li     OpusCustomEncoder *st,
159*a58d3d2aSXin Li     const OpusCustomMode *mode,
160*a58d3d2aSXin Li     int channels
161*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
162*a58d3d2aSXin Li # endif
163*a58d3d2aSXin Li #endif
164*a58d3d2aSXin Li 
165*a58d3d2aSXin Li 
166*a58d3d2aSXin Li /** Creates a new encoder state. Each stream needs its own encoder
167*a58d3d2aSXin Li   * state (can't be shared across simultaneous streams).
168*a58d3d2aSXin Li   * @param [in] mode <tt>OpusCustomMode*</tt>: Contains all the information about the characteristics of
169*a58d3d2aSXin Li   *  the stream (must be the same characteristics as used for the
170*a58d3d2aSXin Li   *  decoder)
171*a58d3d2aSXin Li   * @param [in] channels <tt>int</tt>: Number of channels
172*a58d3d2aSXin Li   * @param [out] error <tt>int*</tt>: Returns an error code
173*a58d3d2aSXin Li   * @return Newly created encoder state.
174*a58d3d2aSXin Li */
175*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomEncoder *opus_custom_encoder_create(
176*a58d3d2aSXin Li     const OpusCustomMode *mode,
177*a58d3d2aSXin Li     int channels,
178*a58d3d2aSXin Li     int *error
179*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1);
180*a58d3d2aSXin Li 
181*a58d3d2aSXin Li 
182*a58d3d2aSXin Li /** Destroys an encoder state.
183*a58d3d2aSXin Li   * @param[in] st <tt>OpusCustomEncoder*</tt>: State to be freed.
184*a58d3d2aSXin Li   */
185*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT void opus_custom_encoder_destroy(OpusCustomEncoder *st);
186*a58d3d2aSXin Li 
187*a58d3d2aSXin Li /** Encodes a frame of audio.
188*a58d3d2aSXin Li   * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
189*a58d3d2aSXin Li   * @param [in] pcm <tt>float*</tt>: PCM audio in float format, with a normal range of +/-1.0.
190*a58d3d2aSXin Li   *          Samples with a range beyond +/-1.0 are supported but will
191*a58d3d2aSXin Li   *          be clipped by decoders using the integer API and should
192*a58d3d2aSXin Li   *          only be used if it is known that the far end supports
193*a58d3d2aSXin Li   *          extended dynamic range. There must be exactly
194*a58d3d2aSXin Li   *          frame_size samples per channel.
195*a58d3d2aSXin Li   * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
196*a58d3d2aSXin Li   * @param [out] compressed <tt>char *</tt>: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.
197*a58d3d2aSXin Li   * @param [in] maxCompressedBytes <tt>int</tt>: Maximum number of bytes to use for compressing the frame
198*a58d3d2aSXin Li   *          (can change from one frame to another)
199*a58d3d2aSXin Li   * @return Number of bytes written to "compressed".
200*a58d3d2aSXin Li   *       If negative, an error has occurred (see error codes). It is IMPORTANT that
201*a58d3d2aSXin Li   *       the length returned be somehow transmitted to the decoder. Otherwise, no
202*a58d3d2aSXin Li   *       decoding is possible.
203*a58d3d2aSXin Li   */
204*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode_float(
205*a58d3d2aSXin Li     OpusCustomEncoder *st,
206*a58d3d2aSXin Li     const float *pcm,
207*a58d3d2aSXin Li     int frame_size,
208*a58d3d2aSXin Li     unsigned char *compressed,
209*a58d3d2aSXin Li     int maxCompressedBytes
210*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
211*a58d3d2aSXin Li 
212*a58d3d2aSXin Li /** Encodes a frame of audio.
213*a58d3d2aSXin Li   * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
214*a58d3d2aSXin Li   * @param [in] pcm <tt>opus_int16*</tt>: PCM audio in signed 16-bit format (native endian).
215*a58d3d2aSXin Li   *          There must be exactly frame_size samples per channel.
216*a58d3d2aSXin Li   * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
217*a58d3d2aSXin Li   * @param [out] compressed <tt>char *</tt>: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.
218*a58d3d2aSXin Li   * @param [in] maxCompressedBytes <tt>int</tt>: Maximum number of bytes to use for compressing the frame
219*a58d3d2aSXin Li   *          (can change from one frame to another)
220*a58d3d2aSXin Li   * @return Number of bytes written to "compressed".
221*a58d3d2aSXin Li   *       If negative, an error has occurred (see error codes). It is IMPORTANT that
222*a58d3d2aSXin Li   *       the length returned be somehow transmitted to the decoder. Otherwise, no
223*a58d3d2aSXin Li   *       decoding is possible.
224*a58d3d2aSXin Li  */
225*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode(
226*a58d3d2aSXin Li     OpusCustomEncoder *st,
227*a58d3d2aSXin Li     const opus_int16 *pcm,
228*a58d3d2aSXin Li     int frame_size,
229*a58d3d2aSXin Li     unsigned char *compressed,
230*a58d3d2aSXin Li     int maxCompressedBytes
231*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
232*a58d3d2aSXin Li 
233*a58d3d2aSXin Li /** Perform a CTL function on an Opus custom encoder.
234*a58d3d2aSXin Li   *
235*a58d3d2aSXin Li   * Generally the request and subsequent arguments are generated
236*a58d3d2aSXin Li   * by a convenience macro.
237*a58d3d2aSXin Li   * @see opus_encoderctls
238*a58d3d2aSXin Li   */
239*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT int opus_custom_encoder_ctl(OpusCustomEncoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
240*a58d3d2aSXin Li 
241*a58d3d2aSXin Li 
242*a58d3d2aSXin Li #if !defined(OPUS_BUILD) || defined(CELT_DECODER_C)
243*a58d3d2aSXin Li /* Decoder */
244*a58d3d2aSXin Li 
245*a58d3d2aSXin Li /** Gets the size of an OpusCustomDecoder structure.
246*a58d3d2aSXin Li   * @param [in] mode <tt>OpusCustomMode *</tt>: Mode configuration
247*a58d3d2aSXin Li   * @param [in] channels <tt>int</tt>: Number of channels
248*a58d3d2aSXin Li   * @returns size
249*a58d3d2aSXin Li   */
250*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_decoder_get_size(
251*a58d3d2aSXin Li     const OpusCustomMode *mode,
252*a58d3d2aSXin Li     int channels
253*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1);
254*a58d3d2aSXin Li 
255*a58d3d2aSXin Li /** Initializes a previously allocated decoder state
256*a58d3d2aSXin Li   * The memory pointed to by st must be the size returned by opus_custom_decoder_get_size.
257*a58d3d2aSXin Li   * This is intended for applications which use their own allocator instead of malloc.
258*a58d3d2aSXin Li   * @see opus_custom_decoder_create(),opus_custom_decoder_get_size()
259*a58d3d2aSXin Li   * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
260*a58d3d2aSXin Li   * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
261*a58d3d2aSXin Li   * @param [in] mode <tt>OpusCustomMode *</tt>: Contains all the information about the characteristics of
262*a58d3d2aSXin Li   *  the stream (must be the same characteristics as used for the
263*a58d3d2aSXin Li   *  encoder)
264*a58d3d2aSXin Li   * @param [in] channels <tt>int</tt>: Number of channels
265*a58d3d2aSXin Li   * @return OPUS_OK Success or @ref opus_errorcodes
266*a58d3d2aSXin Li   */
267*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT_STATIC int opus_custom_decoder_init(
268*a58d3d2aSXin Li     OpusCustomDecoder *st,
269*a58d3d2aSXin Li     const OpusCustomMode *mode,
270*a58d3d2aSXin Li     int channels
271*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2);
272*a58d3d2aSXin Li 
273*a58d3d2aSXin Li #endif
274*a58d3d2aSXin Li 
275*a58d3d2aSXin Li 
276*a58d3d2aSXin Li /** Creates a new decoder state. Each stream needs its own decoder state (can't
277*a58d3d2aSXin Li   * be shared across simultaneous streams).
278*a58d3d2aSXin Li   * @param [in] mode <tt>OpusCustomMode</tt>: Contains all the information about the characteristics of the
279*a58d3d2aSXin Li   *          stream (must be the same characteristics as used for the encoder)
280*a58d3d2aSXin Li   * @param [in] channels <tt>int</tt>: Number of channels
281*a58d3d2aSXin Li   * @param [out] error <tt>int*</tt>: Returns an error code
282*a58d3d2aSXin Li   * @return Newly created decoder state.
283*a58d3d2aSXin Li   */
284*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomDecoder *opus_custom_decoder_create(
285*a58d3d2aSXin Li     const OpusCustomMode *mode,
286*a58d3d2aSXin Li     int channels,
287*a58d3d2aSXin Li     int *error
288*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1);
289*a58d3d2aSXin Li 
290*a58d3d2aSXin Li /** Destroys a decoder state.
291*a58d3d2aSXin Li   * @param[in] st <tt>OpusCustomDecoder*</tt>: State to be freed.
292*a58d3d2aSXin Li   */
293*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT void opus_custom_decoder_destroy(OpusCustomDecoder *st);
294*a58d3d2aSXin Li 
295*a58d3d2aSXin Li /** Decode an opus custom frame with floating point output
296*a58d3d2aSXin Li   * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
297*a58d3d2aSXin Li   * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
298*a58d3d2aSXin Li   * @param [in] len <tt>int</tt>: Number of bytes in payload
299*a58d3d2aSXin Li   * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length
300*a58d3d2aSXin Li   *  is frame_size*channels*sizeof(float)
301*a58d3d2aSXin Li   * @param [in] frame_size Number of samples per channel of available space in *pcm.
302*a58d3d2aSXin Li   * @returns Number of decoded samples or @ref opus_errorcodes
303*a58d3d2aSXin Li   */
304*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode_float(
305*a58d3d2aSXin Li     OpusCustomDecoder *st,
306*a58d3d2aSXin Li     const unsigned char *data,
307*a58d3d2aSXin Li     int len,
308*a58d3d2aSXin Li     float *pcm,
309*a58d3d2aSXin Li     int frame_size
310*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
311*a58d3d2aSXin Li 
312*a58d3d2aSXin Li /** Decode an opus custom frame
313*a58d3d2aSXin Li   * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
314*a58d3d2aSXin Li   * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
315*a58d3d2aSXin Li   * @param [in] len <tt>int</tt>: Number of bytes in payload
316*a58d3d2aSXin Li   * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length
317*a58d3d2aSXin Li   *  is frame_size*channels*sizeof(opus_int16)
318*a58d3d2aSXin Li   * @param [in] frame_size Number of samples per channel of available space in *pcm.
319*a58d3d2aSXin Li   * @returns Number of decoded samples or @ref opus_errorcodes
320*a58d3d2aSXin Li   */
321*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode(
322*a58d3d2aSXin Li     OpusCustomDecoder *st,
323*a58d3d2aSXin Li     const unsigned char *data,
324*a58d3d2aSXin Li     int len,
325*a58d3d2aSXin Li     opus_int16 *pcm,
326*a58d3d2aSXin Li     int frame_size
327*a58d3d2aSXin Li ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
328*a58d3d2aSXin Li 
329*a58d3d2aSXin Li /** Perform a CTL function on an Opus custom decoder.
330*a58d3d2aSXin Li   *
331*a58d3d2aSXin Li   * Generally the request and subsequent arguments are generated
332*a58d3d2aSXin Li   * by a convenience macro.
333*a58d3d2aSXin Li   * @see opus_genericctls
334*a58d3d2aSXin Li   */
335*a58d3d2aSXin Li OPUS_CUSTOM_EXPORT int opus_custom_decoder_ctl(OpusCustomDecoder * OPUS_RESTRICT st, int request, ...) OPUS_ARG_NONNULL(1);
336*a58d3d2aSXin Li 
337*a58d3d2aSXin Li /**@}*/
338*a58d3d2aSXin Li 
339*a58d3d2aSXin Li #ifdef __cplusplus
340*a58d3d2aSXin Li }
341*a58d3d2aSXin Li #endif
342*a58d3d2aSXin Li 
343*a58d3d2aSXin Li #endif /* OPUS_CUSTOM_H */
344