egra: and even more faster text rendering
[iv.d.git] / clibcelt / d / libcelt.d
blobb8f9139c470c067b7c5d2dea09f45682886d1591
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:
10 - Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
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.
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.
29 module iv.libcelt /*is aliced*/;
30 pragma(lib, "celt");
31 import iv.alice;
32 extern(C) nothrow @nogc:
34 /**
35 @file opus_types.h
36 @brief Opus reference implementation types
39 alias opus_int16 = short;
40 alias opus_uint16 = ushort;
41 alias opus_int32 = int;
42 alias opus_uint32 = uint;
45 /**
46 * @file opus_defines.h
47 * @brief Opus reference implementation constants
50 /** @defgroup opus_errorcodes Error codes
51 * @{
53 /** No error @hideinitializer*/
54 enum OPUS_OK = 0;
55 /** One or more invalid/out of range arguments @hideinitializer*/
56 enum OPUS_BAD_ARG = -1;
57 /** Not enough bytes allocated in the buffer @hideinitializer*/
58 enum OPUS_BUFFER_TOO_SMALL = -2;
59 /** An internal error was detected @hideinitializer*/
60 enum OPUS_INTERNAL_ERROR = -3;
61 /** The compressed data passed is corrupted @hideinitializer*/
62 enum OPUS_INVALID_PACKET = -4;
63 /** Invalid/unsupported request number @hideinitializer*/
64 enum OPUS_UNIMPLEMENTED = -5;
65 /** An encoder or decoder structure is invalid or already freed @hideinitializer*/
66 enum OPUS_INVALID_STATE = -6;
67 /** Memory allocation has failed @hideinitializer*/
68 enum OPUS_ALLOC_FAIL = -7;
69 /**@}*/
71 /** These are the actual Encoder CTL ID numbers.
72 * They should not be used directly by applications.
73 * In general, SETs should be even and GETs should be odd.*/
74 enum OPUS_SET_APPLICATION_REQUEST = 4000;
75 enum OPUS_GET_APPLICATION_REQUEST = 4001;
76 enum OPUS_SET_BITRATE_REQUEST = 4002;
77 enum OPUS_GET_BITRATE_REQUEST = 4003;
78 enum OPUS_SET_MAX_BANDWIDTH_REQUEST = 4004;
79 enum OPUS_GET_MAX_BANDWIDTH_REQUEST = 4005;
80 enum OPUS_SET_VBR_REQUEST = 4006;
81 enum OPUS_GET_VBR_REQUEST = 4007;
82 enum OPUS_SET_BANDWIDTH_REQUEST = 4008;
83 enum OPUS_GET_BANDWIDTH_REQUEST = 4009;
84 enum OPUS_SET_COMPLEXITY_REQUEST = 4010;
85 enum OPUS_GET_COMPLEXITY_REQUEST = 4011;
86 enum OPUS_SET_INBAND_FEC_REQUEST = 4012;
87 enum OPUS_GET_INBAND_FEC_REQUEST = 4013;
88 enum OPUS_SET_PACKET_LOSS_PERC_REQUEST = 4014;
89 enum OPUS_GET_PACKET_LOSS_PERC_REQUEST = 4015;
90 enum OPUS_SET_DTX_REQUEST = 4016;
91 enum OPUS_GET_DTX_REQUEST = 4017;
92 enum OPUS_SET_VBR_CONSTRAINT_REQUEST = 4020;
93 enum OPUS_GET_VBR_CONSTRAINT_REQUEST = 4021;
94 enum OPUS_SET_FORCE_CHANNELS_REQUEST = 4022;
95 enum OPUS_GET_FORCE_CHANNELS_REQUEST = 4023;
96 enum OPUS_SET_SIGNAL_REQUEST = 4024;
97 enum OPUS_GET_SIGNAL_REQUEST = 4025;
98 enum OPUS_GET_LOOKAHEAD_REQUEST = 4027;
99 /* enum OPUS_RESET_STATE = 4028; */
100 enum OPUS_GET_SAMPLE_RATE_REQUEST = 4029;
101 enum OPUS_GET_FINAL_RANGE_REQUEST = 4031;
102 enum OPUS_GET_PITCH_REQUEST = 4033;
103 enum OPUS_SET_GAIN_REQUEST = 4034;
104 enum OPUS_GET_GAIN_REQUEST = 4045; /* Should have been 4035 */
105 enum OPUS_SET_LSB_DEPTH_REQUEST = 4036;
106 enum OPUS_GET_LSB_DEPTH_REQUEST = 4037;
107 enum OPUS_GET_LAST_PACKET_DURATION_REQUEST = 4039;
108 enum OPUS_SET_EXPERT_FRAME_DURATION_REQUEST = 4040;
109 enum OPUS_GET_EXPERT_FRAME_DURATION_REQUEST = 4041;
110 enum OPUS_SET_PREDICTION_DISABLED_REQUEST = 4042;
111 enum OPUS_GET_PREDICTION_DISABLED_REQUEST = 4043;
112 /* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */
113 enum OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST = 4046;
114 enum OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST = 4047;
116 /** @defgroup opus_ctlvalues Pre-defined values for CTL interface
117 * @see opus_genericctls, opus_encoderctls
118 * @{
120 /* Values for the various encoder CTLs */
121 enum OPUS_AUTO = -1000; /**<Auto/default setting @hideinitializer*/
122 enum OPUS_BITRATE_MAX = -1; /**<Maximum bitrate @hideinitializer*/
124 /** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
125 * @hideinitializer */
126 enum OPUS_APPLICATION_VOIP = 2048;
127 /** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
128 * @hideinitializer */
129 enum OPUS_APPLICATION_AUDIO = 2049;
130 /** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
131 * @hideinitializer */
132 enum OPUS_APPLICATION_RESTRICTED_LOWDELAY = 2051;
134 enum OPUS_SIGNAL_VOICE = 3001; /**< Signal being encoded is voice */
135 enum OPUS_SIGNAL_MUSIC = 3002; /**< Signal being encoded is music */
136 enum OPUS_BANDWIDTH_NARROWBAND = 1101; /**< 4 kHz bandpass @hideinitializer*/
137 enum OPUS_BANDWIDTH_MEDIUMBAND = 1102; /**< 6 kHz bandpass @hideinitializer*/
138 enum OPUS_BANDWIDTH_WIDEBAND = 1103; /**< 8 kHz bandpass @hideinitializer*/
139 enum OPUS_BANDWIDTH_SUPERWIDEBAND = 1104; /**<12 kHz bandpass @hideinitializer*/
140 enum OPUS_BANDWIDTH_FULLBAND = 1105; /**<20 kHz bandpass @hideinitializer*/
142 enum OPUS_FRAMESIZE_ARG = 5000; /**< Select frame size from the argument (default) */
143 enum OPUS_FRAMESIZE_2_5_MS = 5001; /**< Use 2.5 ms frames */
144 enum OPUS_FRAMESIZE_5_MS = 5002; /**< Use 5 ms frames */
145 enum OPUS_FRAMESIZE_10_MS = 5003; /**< Use 10 ms frames */
146 enum OPUS_FRAMESIZE_20_MS = 5004; /**< Use 20 ms frames */
147 enum OPUS_FRAMESIZE_40_MS = 5005; /**< Use 40 ms frames */
148 enum OPUS_FRAMESIZE_60_MS = 5006; /**< Use 60 ms frames */
149 enum OPUS_FRAMESIZE_80_MS = 5007; /**< Use 80 ms frames */
150 enum OPUS_FRAMESIZE_100_MS = 5008; /**< Use 100 ms frames */
151 enum OPUS_FRAMESIZE_120_MS = 5009; /**< Use 120 ms frames */
153 /**@}*/
156 /** @defgroup opus_encoderctls Encoder related CTLs
158 * These are convenience macros for use with the \c opus_encode_ctl
159 * interface. They are used to generate the appropriate series of
160 * arguments for that call, passing the correct type, size and so
161 * on as expected for each particular request.
163 * Some usage examples:
165 * @code
166 * int ret;
167 * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO));
168 * if (ret != OPUS_OK) return ret;
170 * opus_int32 rate;
171 * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate));
173 * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
174 * @endcode
176 * @see opus_genericctls, opus_encoder
177 * @{
180 /+TODO
181 /** Configures the encoder's computational complexity.
182 * The supported range is 0-10 inclusive with 10 representing the highest complexity.
183 * @see OPUS_GET_COMPLEXITY
184 * @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive.
186 * @hideinitializer */
187 #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
188 /** Gets the encoder's complexity configuration.
189 * @see OPUS_SET_COMPLEXITY
190 * @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10,
191 * inclusive.
192 * @hideinitializer */
193 #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
195 /** Configures the bitrate in the encoder.
196 * Rates from 500 to 512000 bits per second are meaningful, as well as the
197 * special values #OPUS_AUTO and #OPUS_BITRATE_MAX.
198 * The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much
199 * rate as it can, which is useful for controlling the rate by adjusting the
200 * output buffer size.
201 * @see OPUS_GET_BITRATE
202 * @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default
203 * is determined based on the number of
204 * channels and the input sampling rate.
205 * @hideinitializer */
206 #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
207 /** Gets the encoder's bitrate configuration.
208 * @see OPUS_SET_BITRATE
209 * @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second.
210 * The default is determined based on the
211 * number of channels and the input
212 * sampling rate.
213 * @hideinitializer */
214 #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
216 /** Enables or disables variable bitrate (VBR) in the encoder.
217 * The configured bitrate may not be met exactly because frames must
218 * be an integer number of bytes in length.
219 * @see OPUS_GET_VBR
220 * @see OPUS_SET_VBR_CONSTRAINT
221 * @param[in] x <tt>opus_int32</tt>: Allowed values:
222 * <dl>
223 * <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can
224 * cause noticeable quality degradation.</dd>
225 * <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by
226 * #OPUS_SET_VBR_CONSTRAINT.</dd>
227 * </dl>
228 * @hideinitializer */
229 #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
230 /** Determine if variable bitrate (VBR) is enabled in the encoder.
231 * @see OPUS_SET_VBR
232 * @see OPUS_GET_VBR_CONSTRAINT
233 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
234 * <dl>
235 * <dt>0</dt><dd>Hard CBR.</dd>
236 * <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via
237 * #OPUS_GET_VBR_CONSTRAINT.</dd>
238 * </dl>
239 * @hideinitializer */
240 #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
242 /** Enables or disables constrained VBR in the encoder.
243 * This setting is ignored when the encoder is in CBR mode.
244 * @warning Only the MDCT mode of Opus currently heeds the constraint.
245 * Speech mode ignores it completely, hybrid mode may fail to obey it
246 * if the LPC layer uses more bitrate than the constraint would have
247 * permitted.
248 * @see OPUS_GET_VBR_CONSTRAINT
249 * @see OPUS_SET_VBR
250 * @param[in] x <tt>opus_int32</tt>: Allowed values:
251 * <dl>
252 * <dt>0</dt><dd>Unconstrained VBR.</dd>
253 * <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one
254 * frame of buffering delay assuming a transport with a
255 * serialization speed of the nominal bitrate.</dd>
256 * </dl>
257 * @hideinitializer */
258 #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
259 /** Determine if constrained VBR is enabled in the encoder.
260 * @see OPUS_SET_VBR_CONSTRAINT
261 * @see OPUS_GET_VBR
262 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
263 * <dl>
264 * <dt>0</dt><dd>Unconstrained VBR.</dd>
265 * <dt>1</dt><dd>Constrained VBR (default).</dd>
266 * </dl>
267 * @hideinitializer */
268 #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
270 /** Configures mono/stereo forcing in the encoder.
271 * This can force the encoder to produce packets encoded as either mono or
272 * stereo, regardless of the format of the input audio. This is useful when
273 * the caller knows that the input signal is currently a mono source embedded
274 * in a stereo stream.
275 * @see OPUS_GET_FORCE_CHANNELS
276 * @param[in] x <tt>opus_int32</tt>: Allowed values:
277 * <dl>
278 * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd>
279 * <dt>1</dt> <dd>Forced mono</dd>
280 * <dt>2</dt> <dd>Forced stereo</dd>
281 * </dl>
282 * @hideinitializer */
283 #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
284 /** Gets the encoder's forced channel configuration.
285 * @see OPUS_SET_FORCE_CHANNELS
286 * @param[out] x <tt>opus_int32 *</tt>:
287 * <dl>
288 * <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd>
289 * <dt>1</dt> <dd>Forced mono</dd>
290 * <dt>2</dt> <dd>Forced stereo</dd>
291 * </dl>
292 * @hideinitializer */
293 #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
295 /** Configures the maximum bandpass that the encoder will select automatically.
296 * Applications should normally use this instead of #OPUS_SET_BANDWIDTH
297 * (leaving that set to the default, #OPUS_AUTO). This allows the
298 * application to set an upper bound based on the type of input it is
299 * providing, but still gives the encoder the freedom to reduce the bandpass
300 * when the bitrate becomes too low, for better overall quality.
301 * @see OPUS_GET_MAX_BANDWIDTH
302 * @param[in] x <tt>opus_int32</tt>: Allowed values:
303 * <dl>
304 * <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
305 * <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
306 * <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
307 * <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
308 * <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd>
309 * </dl>
310 * @hideinitializer */
311 #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
313 /** Gets the encoder's configured maximum allowed bandpass.
314 * @see OPUS_SET_MAX_BANDWIDTH
315 * @param[out] x <tt>opus_int32 *</tt>: Allowed values:
316 * <dl>
317 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
318 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
319 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
320 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
321 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd>
322 * </dl>
323 * @hideinitializer */
324 #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
326 /** Sets the encoder's bandpass to a specific value.
327 * This prevents the encoder from automatically selecting the bandpass based
328 * on the available bitrate. If an application knows the bandpass of the input
329 * audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH
330 * instead, which still gives the encoder the freedom to reduce the bandpass
331 * when the bitrate becomes too low, for better overall quality.
332 * @see OPUS_GET_BANDWIDTH
333 * @param[in] x <tt>opus_int32</tt>: Allowed values:
334 * <dl>
335 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
336 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
337 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
338 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
339 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
340 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd>
341 * </dl>
342 * @hideinitializer */
343 #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
345 /** Configures the type of signal being encoded.
346 * This is a hint which helps the encoder's mode selection.
347 * @see OPUS_GET_SIGNAL
348 * @param[in] x <tt>opus_int32</tt>: Allowed values:
349 * <dl>
350 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
351 * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd>
352 * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd>
353 * </dl>
354 * @hideinitializer */
355 #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
356 /** Gets the encoder's configured signal type.
357 * @see OPUS_SET_SIGNAL
358 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
359 * <dl>
360 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
361 * <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd>
362 * <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd>
363 * </dl>
364 * @hideinitializer */
365 #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
368 /** Configures the encoder's intended application.
369 * The initial value is a mandatory argument to the encoder_create function.
370 * @see OPUS_GET_APPLICATION
371 * @param[in] x <tt>opus_int32</tt>: Returns one of the following values:
372 * <dl>
373 * <dt>#OPUS_APPLICATION_VOIP</dt>
374 * <dd>Process signal for improved speech intelligibility.</dd>
375 * <dt>#OPUS_APPLICATION_AUDIO</dt>
376 * <dd>Favor faithfulness to the original input.</dd>
377 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
378 * <dd>Configure the minimum possible coding delay by disabling certain modes
379 * of operation.</dd>
380 * </dl>
381 * @hideinitializer */
382 #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
383 /** Gets the encoder's configured application.
384 * @see OPUS_SET_APPLICATION
385 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
386 * <dl>
387 * <dt>#OPUS_APPLICATION_VOIP</dt>
388 * <dd>Process signal for improved speech intelligibility.</dd>
389 * <dt>#OPUS_APPLICATION_AUDIO</dt>
390 * <dd>Favor faithfulness to the original input.</dd>
391 * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
392 * <dd>Configure the minimum possible coding delay by disabling certain modes
393 * of operation.</dd>
394 * </dl>
395 * @hideinitializer */
396 #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
398 /** Gets the total samples of delay added by the entire codec.
399 * This can be queried by the encoder and then the provided number of samples can be
400 * skipped on from the start of the decoder's output to provide time aligned input
401 * and output. From the perspective of a decoding application the real data begins this many
402 * samples late.
404 * The decoder contribution to this delay is identical for all decoders, but the
405 * encoder portion of the delay may vary from implementation to implementation,
406 * version to version, or even depend on the encoder's initial configuration.
407 * Applications needing delay compensation should call this CTL rather than
408 * hard-coding a value.
409 * @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples
410 * @hideinitializer */
411 #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
413 /** Configures the encoder's use of inband forward error correction (FEC).
414 * @note This is only applicable to the LPC layer
415 * @see OPUS_GET_INBAND_FEC
416 * @param[in] x <tt>opus_int32</tt>: Allowed values:
417 * <dl>
418 * <dt>0</dt><dd>Disable inband FEC (default).</dd>
419 * <dt>1</dt><dd>Enable inband FEC.</dd>
420 * </dl>
421 * @hideinitializer */
422 #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
423 /** Gets encoder's configured use of inband forward error correction.
424 * @see OPUS_SET_INBAND_FEC
425 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
426 * <dl>
427 * <dt>0</dt><dd>Inband FEC disabled (default).</dd>
428 * <dt>1</dt><dd>Inband FEC enabled.</dd>
429 * </dl>
430 * @hideinitializer */
431 #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
433 /** Configures the encoder's expected packet loss percentage.
434 * Higher values trigger progressively more loss resistant behavior in the encoder
435 * at the expense of quality at a given bitrate in the absence of packet loss, but
436 * greater quality under loss.
437 * @see OPUS_GET_PACKET_LOSS_PERC
438 * @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0).
439 * @hideinitializer */
440 #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
441 /** Gets the encoder's configured packet loss percentage.
442 * @see OPUS_SET_PACKET_LOSS_PERC
443 * @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage
444 * in the range 0-100, inclusive (default: 0).
445 * @hideinitializer */
446 #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
448 /** Configures the encoder's use of discontinuous transmission (DTX).
449 * @note This is only applicable to the LPC layer
450 * @see OPUS_GET_DTX
451 * @param[in] x <tt>opus_int32</tt>: Allowed values:
452 * <dl>
453 * <dt>0</dt><dd>Disable DTX (default).</dd>
454 * <dt>1</dt><dd>Enabled DTX.</dd>
455 * </dl>
456 * @hideinitializer */
457 #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
458 /** Gets encoder's configured use of discontinuous transmission.
459 * @see OPUS_SET_DTX
460 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
461 * <dl>
462 * <dt>0</dt><dd>DTX disabled (default).</dd>
463 * <dt>1</dt><dd>DTX enabled.</dd>
464 * </dl>
465 * @hideinitializer */
466 #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
467 /** Configures the depth of signal being encoded.
469 * This is a hint which helps the encoder identify silence and near-silence.
470 * It represents the number of significant bits of linear intensity below
471 * which the signal contains ignorable quantization or other noise.
473 * For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting
474 * for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate
475 * for 16-bit linear pcm input with opus_encode_float().
477 * When using opus_encode() instead of opus_encode_float(), or when libopus
478 * is compiled for fixed-point, the encoder uses the minimum of the value
479 * set here and the value 16.
481 * @see OPUS_GET_LSB_DEPTH
482 * @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24
483 * (default: 24).
484 * @hideinitializer */
485 #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x)
486 /** Gets the encoder's configured signal depth.
487 * @see OPUS_SET_LSB_DEPTH
488 * @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and
489 * 24 (default: 24).
490 * @hideinitializer */
491 #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x)
493 /** Configures the encoder's use of variable duration frames.
494 * When variable duration is enabled, the encoder is free to use a shorter frame
495 * size than the one requested in the opus_encode*() call.
496 * It is then the user's responsibility
497 * to verify how much audio was encoded by checking the ToC byte of the encoded
498 * packet. The part of the audio that was not encoded needs to be resent to the
499 * encoder for the next call. Do not use this option unless you <b>really</b>
500 * know what you are doing.
501 * @see OPUS_GET_EXPERT_FRAME_DURATION
502 * @param[in] x <tt>opus_int32</tt>: Allowed values:
503 * <dl>
504 * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
505 * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
506 * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd>
507 * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
508 * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
509 * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
510 * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
511 * <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd>
512 * <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd>
513 * <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd>
514 * </dl>
515 * @hideinitializer */
516 #define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x)
517 /** Gets the encoder's configured use of variable duration frames.
518 * @see OPUS_SET_EXPERT_FRAME_DURATION
519 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
520 * <dl>
521 * <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd>
522 * <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd>
523 * <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd>
524 * <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd>
525 * <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd>
526 * <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd>
527 * <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd>
528 * <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd>
529 * <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd>
530 * <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd>
531 * </dl>
532 * @hideinitializer */
533 #define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x)
535 /** If set to 1, disables almost all use of prediction, making frames almost
536 * completely independent. This reduces quality.
537 * @see OPUS_GET_PREDICTION_DISABLED
538 * @param[in] x <tt>opus_int32</tt>: Allowed values:
539 * <dl>
540 * <dt>0</dt><dd>Enable prediction (default).</dd>
541 * <dt>1</dt><dd>Disable prediction.</dd>
542 * </dl>
543 * @hideinitializer */
544 #define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x)
545 /** Gets the encoder's configured prediction status.
546 * @see OPUS_SET_PREDICTION_DISABLED
547 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
548 * <dl>
549 * <dt>0</dt><dd>Prediction enabled (default).</dd>
550 * <dt>1</dt><dd>Prediction disabled.</dd>
551 * </dl>
552 * @hideinitializer */
553 #define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x)
555 /**@}*/
557 /** @defgroup opus_genericctls Generic CTLs
559 * These macros are used with the \c opus_decoder_ctl and
560 * \c opus_encoder_ctl calls to generate a particular
561 * request.
563 * When called on an \c OpusDecoder they apply to that
564 * particular decoder instance. When called on an
565 * \c OpusEncoder they apply to the corresponding setting
566 * on that encoder instance, if present.
568 * Some usage examples:
570 * @code
571 * int ret;
572 * opus_int32 pitch;
573 * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch));
574 * if (ret == OPUS_OK) return ret;
576 * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
577 * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE);
579 * opus_int32 enc_bw, dec_bw;
580 * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw));
581 * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw));
582 * if (enc_bw != dec_bw) {
583 * printf("packet bandwidth mismatch!\n");
585 * @endcode
587 * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls
588 * @{
591 /** Resets the codec state to be equivalent to a freshly initialized state.
592 * This should be called when switching streams in order to prevent
593 * the back to back decoding from giving different results from
594 * one at a time decoding.
595 * @hideinitializer */
596 enum OPUS_RESET_STATE = 4028;
598 /+TODO
599 /** Gets the final state of the codec's entropy coder.
600 * This is used for testing purposes,
601 * The encoder and decoder state should be identical after coding a payload
602 * (assuming no data corruption or software bugs)
604 * @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state
606 * @hideinitializer */
607 #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
609 /** Gets the encoder's configured bandpass or the decoder's last bandpass.
610 * @see OPUS_SET_BANDWIDTH
611 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
612 * <dl>
613 * <dt>#OPUS_AUTO</dt> <dd>(default)</dd>
614 * <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd>
615 * <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd>
616 * <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd>
617 * <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd>
618 * <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd>
619 * </dl>
620 * @hideinitializer */
621 #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
623 /** Gets the sampling rate the encoder or decoder was initialized with.
624 * This simply returns the <code>Fs</code> value passed to opus_encoder_init()
625 * or opus_decoder_init().
626 * @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder.
627 * @hideinitializer
629 #define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x)
631 /** If set to 1, disables the use of phase inversion for intensity stereo,
632 * improving the quality of mono downmixes, but slightly reducing normal
633 * stereo quality. Disabling phase inversion in the decoder does not comply
634 * with RFC 6716, although it does not cause any interoperability issue and
635 * is expected to become part of the Opus standard once RFC 6716 is updated
636 * by draft-ietf-codec-opus-update.
637 * @see OPUS_GET_PHASE_INVERSION_DISABLED
638 * @param[in] x <tt>opus_int32</tt>: Allowed values:
639 * <dl>
640 * <dt>0</dt><dd>Enable phase inversion (default).</dd>
641 * <dt>1</dt><dd>Disable phase inversion.</dd>
642 * </dl>
643 * @hideinitializer */
644 #define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x)
645 /** Gets the encoder's configured phase inversion status.
646 * @see OPUS_SET_PHASE_INVERSION_DISABLED
647 * @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
648 * <dl>
649 * <dt>0</dt><dd>Stereo phase inversion enabled (default).</dd>
650 * <dt>1</dt><dd>Stereo phase inversion disabled.</dd>
651 * </dl>
652 * @hideinitializer */
653 #define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x)
655 /**@}*/
657 /** @defgroup opus_decoderctls Decoder related CTLs
658 * @see opus_genericctls, opus_encoderctls, opus_decoder
659 * @{
662 /+TODO
663 /** Configures decoder gain adjustment.
664 * Scales the decoded output by a factor specified in Q8 dB units.
665 * This has a maximum range of -32768 to 32767 inclusive, and returns
666 * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment.
667 * This setting survives decoder reset.
669 * gain = pow(10, x/(20.0*256))
671 * @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units.
672 * @hideinitializer */
673 #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x)
674 /** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
676 * @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units.
677 * @hideinitializer */
678 #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x)
680 /** Gets the duration (in samples) of the last packet successfully decoded or concealed.
681 * @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate).
682 * @hideinitializer */
683 #define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x)
685 /** Gets the pitch of the last decoded frame, if available.
686 * This can be used for any post-processing algorithm requiring the use of pitch,
687 * e.g. time stretching/shortening. If the last frame was not voiced, or if the
688 * pitch was not coded in the frame, then zero is returned.
690 * This CTL is only implemented for decoder instances.
692 * @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available)
694 * @hideinitializer */
695 #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
697 /**@}*/
699 /** @defgroup opus_libinfo Opus library information functions
700 * @{
703 /** Converts an opus error code into a human readable string.
705 * @param[in] error <tt>int</tt>: Error number
706 * @returns Error string
708 const(char)* opus_strerror (int error);
709 const(char)[] opus_strerr (int error) {
710 auto s = opus_strerror(error);
711 if (s !is null) {
712 uint len = 0;
713 while (s[len]) ++len;
714 return s[0..len];
716 return null;
719 /** Gets the libopus version string.
721 * Applications may look for the substring "-fixed" in the version string to
722 * determine whether they have a fixed-point or floating-point build at
723 * runtime.
725 * @returns Version string
727 /**@}*/
728 const(char)* opus_get_version_string ();
729 const(char)[] opus_get_version_str () {
730 auto s = opus_get_version_string();
731 if (s !is null) {
732 uint len = 0;
733 while (s[len]) ++len;
734 return s[0..len];
736 return null;
741 @file opus_custom.h
742 @brief Opus-Custom reference implementation API
745 enum OPUS_CUSTOM_MAX_PACKET = 1275;
748 /** @defgroup opus_custom Opus Custom
749 * @{
750 * Opus Custom is an optional part of the Opus specification and
751 * reference implementation which uses a distinct API from the regular
752 * API and supports frame sizes that are not normally supported.\ Use
753 * of Opus Custom is discouraged for all but very special applications
754 * for which a frame size different from 2.5, 5, 10, or 20 ms is needed
755 * (for either complexity or latency reasons) and where interoperability
756 * is less important.
758 * In addition to the interoperability limitations the use of Opus custom
759 * disables a substantial chunk of the codec and generally lowers the
760 * quality available at a given bitrate. Normally when an application needs
761 * a different frame size from the codec it should buffer to match the
762 * sizes but this adds a small amount of delay which may be important
763 * in some very low latency applications. Some transports (especially
764 * constant rate RF transports) may also work best with frames of
765 * particular durations.
767 * Libopus only supports custom modes if they are enabled at compile time.
769 * The Opus Custom API is similar to the regular API but the
770 * @ref opus_encoder_create and @ref opus_decoder_create calls take
771 * an additional mode parameter which is a structure produced by
772 * a call to @ref opus_custom_mode_create. Both the encoder and decoder
773 * must create a mode using the same sample rate (fs) and frame size
774 * (frame size) so these parameters must either be signaled out of band
775 * or fixed in a particular implementation.
777 * Similar to regular Opus the custom modes support on the fly frame size
778 * switching, but the sizes available depend on the particular frame size in
779 * use. For some initial frame sizes on a single on the fly size is available.
782 /** Contains the state of an encoder. One encoder state is needed
783 for each stream. It is initialized once at the beginning of the
784 stream. Do *not* re-initialize the state for every frame.
785 @brief Encoder state
787 struct OpusCustomEncoder;
789 /** State of the decoder. One decoder state is needed for each stream.
790 It is initialized once at the beginning of the stream. Do *not*
791 re-initialize the state for every frame.
792 @brief Decoder state
794 struct OpusCustomDecoder;
796 /** The mode contains all the information necessary to create an
797 encoder. Both the encoder and decoder need to be initialized
798 with exactly the same mode, otherwise the output will be
799 corrupted.
800 @brief Mode configuration
802 struct OpusCustomMode;
804 /** Creates a new mode struct. This will be passed to an encoder or
805 * decoder. The mode MUST NOT BE DESTROYED until the encoders and
806 * decoders that use it are destroyed as well.
807 * @param [in] Fs <tt>int</tt>: Sampling rate (8000 to 96000 Hz)
808 * @param [in] frame_size <tt>int</tt>: Number of samples (per channel) to encode in each
809 * packet (64 - 1024, prime factorization must contain zero or more 2s, 3s, or 5s and no other primes)
810 * @param [out] error <tt>int*</tt>: Returned error code (if NULL, no error will be returned)
811 * @return A newly created mode
813 OpusCustomMode* opus_custom_mode_create(opus_int32 Fs, int frame_size, int* error);
815 /** Destroys a mode struct. Only call this after all encoders and
816 * decoders using this mode are destroyed as well.
817 * @param [in] mode <tt>OpusCustomMode*</tt>: Mode to be freed.
819 void opus_custom_mode_destroy (OpusCustomMode* mode);
822 /** Gets the size of an OpusCustomEncoder structure.
823 * @param [in] mode <tt>OpusCustomMode *</tt>: Mode configuration
824 * @param [in] channels <tt>int</tt>: Number of channels
825 * @returns size
827 int opus_custom_encoder_get_size (const(OpusCustomMode)* mode, int channels) /*OPUS_ARG_NONNULL(1)*/;
829 /** Initializes a previously allocated encoder state
830 * The memory pointed to by st must be the size returned by opus_custom_encoder_get_size.
831 * This is intended for applications which use their own allocator instead of malloc.
832 * @see opus_custom_encoder_create(),opus_custom_encoder_get_size()
833 * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
834 * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
835 * @param [in] mode <tt>OpusCustomMode *</tt>: Contains all the information about the characteristics of
836 * the stream (must be the same characteristics as used for the
837 * decoder)
838 * @param [in] channels <tt>int</tt>: Number of channels
839 * @return OPUS_OK Success or @ref opus_errorcodes
841 int opus_custom_encoder_init (OpusCustomEncoder* st, const(OpusCustomMode)* mode, int channels) /*OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2)*/;
844 /** Creates a new encoder state. Each stream needs its own encoder
845 * state (can't be shared across simultaneous streams).
846 * @param [in] mode <tt>OpusCustomMode*</tt>: Contains all the information about the characteristics of
847 * the stream (must be the same characteristics as used for the
848 * decoder)
849 * @param [in] channels <tt>int</tt>: Number of channels
850 * @param [out] error <tt>int*</tt>: Returns an error code
851 * @return Newly created encoder state.
853 OpusCustomEncoder* opus_custom_encoder_create (const(OpusCustomMode)* mode, int channels, int* error) /*OPUS_ARG_NONNULL(1)*/;
856 /** Destroys a an encoder state.
857 * @param[in] st <tt>OpusCustomEncoder*</tt>: State to be freed.
859 void opus_custom_encoder_destroy (OpusCustomEncoder* st);
861 /** Encodes a frame of audio.
862 * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
863 * @param [in] pcm <tt>float*</tt>: PCM audio in float format, with a normal range of +/-1.0.
864 * Samples with a range beyond +/-1.0 are supported but will
865 * be clipped by decoders using the integer API and should
866 * only be used if it is known that the far end supports
867 * extended dynamic range. There must be exactly
868 * frame_size samples per channel.
869 * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
870 * @param [out] compressed <tt>char *</tt>: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.
871 * @param [in] maxCompressedBytes <tt>int</tt>: Maximum number of bytes to use for compressing the frame
872 * (can change from one frame to another)
873 * @return Number of bytes written to "compressed".
874 * If negative, an error has occurred (see error codes). It is IMPORTANT that
875 * the length returned be somehow transmitted to the decoder. Otherwise, no
876 * decoding is possible.
878 int opus_custom_encode_float (OpusCustomEncoder* st, const(float)* pcm, int frame_size, void* compressed, int maxCompressedBytes) /*OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4)*/;
880 /** Encodes a frame of audio.
881 * @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
882 * @param [in] pcm <tt>opus_int16*</tt>: PCM audio in signed 16-bit format (native endian).
883 * There must be exactly frame_size samples per channel.
884 * @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
885 * @param [out] compressed <tt>char *</tt>: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.
886 * @param [in] maxCompressedBytes <tt>int</tt>: Maximum number of bytes to use for compressing the frame
887 * (can change from one frame to another)
888 * @return Number of bytes written to "compressed".
889 * If negative, an error has occurred (see error codes). It is IMPORTANT that
890 * the length returned be somehow transmitted to the decoder. Otherwise, no
891 * decoding is possible.
893 int opus_custom_encode (OpusCustomEncoder* st, const(opus_int16)* pcm, int frame_size, void* compressed, int maxCompressedBytes) /*OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4)*/;
895 /** Perform a CTL function on an Opus custom encoder.
897 * Generally the request and subsequent arguments are generated
898 * by a convenience macro.
899 * @see opus_encoderctls
901 int opus_custom_encoder_ctl (OpusCustomEncoder* /*OPUS_RESTRICT*/st, int request, ...) /*OPUS_ARG_NONNULL(1)*/;
904 /** Gets the size of an OpusCustomDecoder structure.
905 * @param [in] mode <tt>OpusCustomMode *</tt>: Mode configuration
906 * @param [in] channels <tt>int</tt>: Number of channels
907 * @returns size
909 int opus_custom_decoder_get_size (const(OpusCustomMode)* mode, int channels) /*OPUS_ARG_NONNULL(1)*/;
911 /** Initializes a previously allocated decoder state
912 * The memory pointed to by st must be the size returned by opus_custom_decoder_get_size.
913 * This is intended for applications which use their own allocator instead of malloc.
914 * @see opus_custom_decoder_create(),opus_custom_decoder_get_size()
915 * To reset a previously initialized state use the OPUS_RESET_STATE CTL.
916 * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
917 * @param [in] mode <tt>OpusCustomMode *</tt>: Contains all the information about the characteristics of
918 * the stream (must be the same characteristics as used for the
919 * encoder)
920 * @param [in] channels <tt>int</tt>: Number of channels
921 * @return OPUS_OK Success or @ref opus_errorcodes
923 int opus_custom_decoder_init (OpusCustomDecoder* st, const(OpusCustomMode)* mode, int channels) /*OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2)*/;
926 /** Creates a new decoder state. Each stream needs its own decoder state (can't
927 * be shared across simultaneous streams).
928 * @param [in] mode <tt>OpusCustomMode</tt>: Contains all the information about the characteristics of the
929 * stream (must be the same characteristics as used for the encoder)
930 * @param [in] channels <tt>int</tt>: Number of channels
931 * @param [out] error <tt>int*</tt>: Returns an error code
932 * @return Newly created decoder state.
934 OpusCustomDecoder* opus_custom_decoder_create (const(OpusCustomMode)* mode, int channels, int* error) /*OPUS_ARG_NONNULL(1)*/;
936 /** Destroys a an decoder state.
937 * @param[in] st <tt>OpusCustomDecoder*</tt>: State to be freed.
939 void opus_custom_decoder_destroy (OpusCustomDecoder* st);
941 /** Decode an opus custom frame with floating point output
942 * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
943 * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
944 * @param [in] len <tt>int</tt>: Number of bytes in payload
945 * @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length
946 * is frame_size*channels*sizeof(float)
947 * @param [in] frame_size Number of samples per channel of available space in *pcm.
948 * @returns Number of decoded samples or @ref opus_errorcodes
950 int opus_custom_decode_float (OpusCustomDecoder* st, const(void)* data, int len, float* pcm, int frame_size) /*OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4)*/;
952 /** Decode an opus custom frame
953 * @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
954 * @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
955 * @param [in] len <tt>int</tt>: Number of bytes in payload
956 * @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length
957 * is frame_size*channels*sizeof(opus_int16)
958 * @param [in] frame_size Number of samples per channel of available space in *pcm.
959 * @returns Number of decoded samples or @ref opus_errorcodes
961 int opus_custom_decode (OpusCustomDecoder* st, const(void)* data, int len, opus_int16* pcm, int frame_size) /*OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4)*/;
963 /** Perform a CTL function on an Opus custom decoder.
965 * Generally the request and subsequent arguments are generated
966 * by a convenience macro.
967 * @see opus_genericctls
969 int opus_custom_decoder_ctl (OpusCustomDecoder* /*OPUS_RESTRICT*/st, int request, ...) /*OPUS_ARG_NONNULL(1)*/;
971 /**@}*/