Skip to content

Commit 97c3aca

Browse files
committed
Updated OPUS to 1.6
1 parent e800f9e commit 97c3aca

File tree

345 files changed

+843729
-12556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+843729
-12556
lines changed

libopus-android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ tasks.register('compileOpus') {
8181
"-DOPUS_BUILD_SHARED_LIBRARY=true",
8282
"-DCMAKE_TOOLCHAIN_FILE=" + android.ndkDirectory + "/build/cmake/android.toolchain.cmake",
8383
"-DANDROID_NATIVE_API_LEVEL=23", "-DANDROID_ABI=" + abi,
84-
"-DANDROID_STL=c++_shared"
84+
"-DANDROID_STL=c++_shared", "-DOPUS_DISABLE_INTRINSICS=true"
8585
}
8686

8787
exec {

libopus-android/src/main/cpp/opus/opus.h

Lines changed: 199 additions & 5 deletions
Large diffs are not rendered by default.

libopus-android/src/main/cpp/opus/opus_custom.h

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
extern "C" {
4242
#endif
4343

44-
#ifdef CUSTOM_MODES
44+
#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API)
4545
# define OPUS_CUSTOM_EXPORT OPUS_EXPORT
4646
# define OPUS_CUSTOM_EXPORT_STATIC OPUS_EXPORT
4747
#else
@@ -141,7 +141,7 @@ OPUS_CUSTOM_EXPORT_STATIC OPUS_WARN_UNUSED_RESULT int opus_custom_encoder_get_si
141141
int channels
142142
) OPUS_ARG_NONNULL(1);
143143

144-
# ifdef CUSTOM_MODES
144+
#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API)
145145
/** Initializes a previously allocated encoder state
146146
* The memory pointed to by st must be the size returned by opus_custom_encoder_get_size.
147147
* This is intended for applications which use their own allocator instead of malloc.
@@ -230,6 +230,27 @@ OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_encode(
230230
int maxCompressedBytes
231231
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
232232

233+
/** Encodes a frame of audio.
234+
* @param [in] st <tt>OpusCustomEncoder*</tt>: Encoder state
235+
* @param [in] pcm <tt>opus_int32*</tt>: PCM audio in signed 32-bit format (native endian) representing (or slightly exceeding) 24-bit values.
236+
* There must be exactly frame_size samples per channel.
237+
* @param [in] frame_size <tt>int</tt>: Number of samples per frame of input signal
238+
* @param [out] compressed <tt>char *</tt>: The compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.
239+
* @param [in] maxCompressedBytes <tt>int</tt>: Maximum number of bytes to use for compressing the frame
240+
* (can change from one frame to another)
241+
* @return Number of bytes written to "compressed".
242+
* If negative, an error has occurred (see error codes). It is IMPORTANT that
243+
* the length returned be somehow transmitted to the decoder. Otherwise, no
244+
* decoding is possible.
245+
*/
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+
233254
/** Perform a CTL function on an Opus custom encoder.
234255
*
235256
* Generally the request and subsequent arguments are generated
@@ -326,6 +347,23 @@ OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT int opus_custom_decode(
326347
int frame_size
327348
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
328349

350+
/** Decode an opus custom frame
351+
* @param [in] st <tt>OpusCustomDecoder*</tt>: Decoder state
352+
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss
353+
* @param [in] len <tt>int</tt>: Number of bytes in payload
354+
* @param [out] pcm <tt>opus_int32*</tt>: Output signal (interleaved if 2 channels) representing (or slightly exceeding) 24-bit values. length
355+
* is frame_size*channels*sizeof(opus_int32)
356+
* @param [in] frame_size Number of samples per channel of available space in *pcm.
357+
* @returns Number of decoded samples or @ref opus_errorcodes
358+
*/
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+
329367
/** Perform a CTL function on an Opus custom decoder.
330368
*
331369
* Generally the request and subsequent arguments are generated

libopus-android/src/main/cpp/opus/opus_defines.h

Lines changed: 110 additions & 44 deletions
Large diffs are not rendered by default.

libopus-android/src/main/cpp/opus/opus_multistream.h

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ extern "C" {
4444
/** Macros to trigger compilation errors when the wrong types are provided to a
4545
* CTL. */
4646
/**@{*/
47-
#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
48-
#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
47+
#define opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
48+
#define opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
4949
/**@}*/
5050

5151
/** These are the actual encoder and decoder CTL ID numbers.
@@ -83,7 +83,7 @@ extern "C" {
8383
* @retval OPUS_BAD_ARG The index of the requested stream was out of range.
8484
* @hideinitializer
8585
*/
86-
#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
86+
#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, opus_check_int(x), opus_check_encstate_ptr(y)
8787

8888
/** Gets the decoder state for an individual stream of a multistream decoder.
8989
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you
@@ -96,7 +96,7 @@ extern "C" {
9696
* @retval OPUS_BAD_ARG The index of the requested stream was out of range.
9797
* @hideinitializer
9898
*/
99-
#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
99+
#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, opus_check_int(x), opus_check_decstate_ptr(y)
100100

101101
/**@}*/
102102

@@ -143,7 +143,7 @@ extern "C" {
143143
* <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis
144144
* channel ordering</a>. A decoder may wish to apply an additional permutation
145145
* to the mapping the encoder used to achieve a different output channel
146-
* order (e.g. for outputing in WAV order).
146+
* order (e.g. for outputting in WAV order).
147147
*
148148
* Each multistream packet contains an Opus packet for each stream, and all of
149149
* the Opus packets in a single multistream packet must have the same
@@ -382,6 +382,44 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode(
382382
opus_int32 max_data_bytes
383383
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
384384

385+
/** Encodes a multistream Opus frame.
386+
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
387+
* @param[in] pcm <tt>const opus_int32*</tt>: The input signal as interleaved
388+
* samples representing (or slightly exceeding) 24-bit values.
389+
* This must contain
390+
* <code>frame_size*channels</code>
391+
* samples.
392+
* @param frame_size <tt>int</tt>: Number of samples per channel in the input
393+
* signal.
394+
* This must be an Opus frame size for the
395+
* encoder's sampling rate.
396+
* For example, at 48 kHz the permitted values
397+
* are 120, 240, 480, 960, 1920, and 2880.
398+
* Passing in a duration of less than 10 ms
399+
* (480 samples at 48 kHz) will prevent the
400+
* encoder from using the LPC or hybrid modes.
401+
* @param[out] data <tt>unsigned char*</tt>: Output payload.
402+
* This must contain storage for at
403+
* least \a max_data_bytes.
404+
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
405+
* memory for the output
406+
* payload. This may be
407+
* used to impose an upper limit on
408+
* the instant bitrate, but should
409+
* not be used as the only bitrate
410+
* control. Use #OPUS_SET_BITRATE to
411+
* control the bitrate.
412+
* @returns The length of the encoded packet (in bytes) on success or a
413+
* negative error code (see @ref opus_errorcodes) on failure.
414+
*/
415+
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode24(
416+
OpusMSEncoder *st,
417+
const opus_int32 *pcm,
418+
int frame_size,
419+
unsigned char *data,
420+
opus_int32 max_data_bytes
421+
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
422+
385423
/** Encodes a multistream Opus frame from floating point input.
386424
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state.
387425
* @param[in] pcm <tt>const float*</tt>: The input signal as interleaved
@@ -510,7 +548,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_crea
510548
int *error
511549
) OPUS_ARG_NONNULL(5);
512550

513-
/** Intialize a previously allocated decoder state object.
551+
/** Initialize a previously allocated decoder state object.
514552
* The memory pointed to by \a st must be at least the size returned by
515553
* opus_multistream_encoder_get_size().
516554
* This is intended for applications which use their own allocator instead of
@@ -591,6 +629,44 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode(
591629
int decode_fec
592630
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
593631

632+
/** Decode a multistream Opus packet.
633+
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
634+
* @param[in] data <tt>const unsigned char*</tt>: Input payload.
635+
* Use a <code>NULL</code>
636+
* pointer to indicate packet
637+
* loss.
638+
* @param len <tt>opus_int32</tt>: Number of bytes in payload.
639+
* @param[out] pcm <tt>opus_int32*</tt>: Output signal, with interleaved
640+
* samples representing (or slightly exceeding) 24-bit values.
641+
* This must contain room for
642+
* <code>frame_size*channels</code>
643+
* samples.
644+
* @param frame_size <tt>int</tt>: The number of samples per channel of
645+
* available space in \a pcm.
646+
* If this is less than the maximum packet duration
647+
* (120 ms; 5760 for 48kHz), this function will not be capable
648+
* of decoding some packets. In the case of PLC (data==NULL)
649+
* or FEC (decode_fec=1), then frame_size needs to be exactly
650+
* the duration of audio that is missing, otherwise the
651+
* decoder will not be in the optimal state to decode the
652+
* next incoming packet. For the PLC and FEC cases, frame_size
653+
* <b>must</b> be a multiple of 2.5 ms.
654+
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
655+
* forward error correction data be decoded.
656+
* If no such data is available, the frame is
657+
* decoded as if it were lost.
658+
* @returns Number of samples decoded on success or a negative error code
659+
* (see @ref opus_errorcodes) on failure.
660+
*/
661+
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode24(
662+
OpusMSDecoder *st,
663+
const unsigned char *data,
664+
opus_int32 len,
665+
opus_int32 *pcm,
666+
int frame_size,
667+
int decode_fec
668+
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
669+
594670
/** Decode a multistream Opus packet with floating point output.
595671
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state.
596672
* @param[in] data <tt>const unsigned char*</tt>: Input payload.

libopus-android/src/main/cpp/opus/opus_projection.h

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ extern "C" {
6969
* of the demixing matrix.
7070
* @hideinitializer
7171
*/
72-
#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST, __opus_check_int_ptr(x)
72+
#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST, opus_check_int_ptr(x)
7373

7474

7575
/** Gets the size in bytes of the demixing matrix from the encoder.
7676
* @param[out] x <tt>opus_int32 *</tt>: Returns the size in bytes of the
7777
* demixing matrix.
7878
* @hideinitializer
7979
*/
80-
#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, __opus_check_int_ptr(x)
80+
#define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, opus_check_int_ptr(x)
8181

8282

8383
/** Copies the demixing matrix to the supplied pointer location.
@@ -87,7 +87,7 @@ extern "C" {
8787
* pointer location.
8888
* @hideinitializer
8989
*/
90-
#define OPUS_PROJECTION_GET_DEMIXING_MATRIX(x,y) OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, x, __opus_check_int(y)
90+
#define OPUS_PROJECTION_GET_DEMIXING_MATRIX(x,y) OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, x, opus_check_int(y)
9191

9292

9393
/**@}*/
@@ -260,6 +260,44 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode(
260260
opus_int32 max_data_bytes
261261
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
262262

263+
/** Encodes a projection Opus frame.
264+
* @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
265+
* @param[in] pcm <tt>const opus_int32*</tt>: The input signal as interleaved
266+
* samples representing (or slightly exceeding) 24-bit values.
267+
* This must contain
268+
* <code>frame_size*channels</code>
269+
* samples.
270+
* @param frame_size <tt>int</tt>: Number of samples per channel in the input
271+
* signal.
272+
* This must be an Opus frame size for the
273+
* encoder's sampling rate.
274+
* For example, at 48 kHz the permitted values
275+
* are 120, 240, 480, 960, 1920, and 2880.
276+
* Passing in a duration of less than 10 ms
277+
* (480 samples at 48 kHz) will prevent the
278+
* encoder from using the LPC or hybrid modes.
279+
* @param[out] data <tt>unsigned char*</tt>: Output payload.
280+
* This must contain storage for at
281+
* least \a max_data_bytes.
282+
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
283+
* memory for the output
284+
* payload. This may be
285+
* used to impose an upper limit on
286+
* the instant bitrate, but should
287+
* not be used as the only bitrate
288+
* control. Use #OPUS_SET_BITRATE to
289+
* control the bitrate.
290+
* @returns The length of the encoded packet (in bytes) on success or a
291+
* negative error code (see @ref opus_errorcodes) on failure.
292+
*/
293+
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode24(
294+
OpusProjectionEncoder *st,
295+
const opus_int32 *pcm,
296+
int frame_size,
297+
unsigned char *data,
298+
opus_int32 max_data_bytes
299+
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
300+
263301

264302
/** Encodes a projection Opus frame from floating point input.
265303
* @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
@@ -405,7 +443,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionDecoder *opus_projection_decod
405443
) OPUS_ARG_NONNULL(5);
406444

407445

408-
/** Intialize a previously allocated projection decoder state object.
446+
/** Initialize a previously allocated projection decoder state object.
409447
* The memory pointed to by \a st must be at least the size returned by
410448
* opus_projection_decoder_get_size().
411449
* This is intended for applications which use their own allocator instead of
@@ -493,6 +531,43 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode(
493531
int decode_fec
494532
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
495533

534+
/** Decode a projection Opus packet.
535+
* @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
536+
* @param[in] data <tt>const unsigned char*</tt>: Input payload.
537+
* Use a <code>NULL</code>
538+
* pointer to indicate packet
539+
* loss.
540+
* @param len <tt>opus_int32</tt>: Number of bytes in payload.
541+
* @param[out] pcm <tt>opus_int32*</tt>: Output signal, with interleaved
542+
* samples representing (or slightly exceeding) 24-bit values.
543+
* This must contain room for
544+
* <code>frame_size*channels</code>
545+
* samples.
546+
* @param frame_size <tt>int</tt>: The number of samples per channel of
547+
* available space in \a pcm.
548+
* If this is less than the maximum packet duration
549+
* (120 ms; 5760 for 48kHz), this function will not be capable
550+
* of decoding some packets. In the case of PLC (data==NULL)
551+
* or FEC (decode_fec=1), then frame_size needs to be exactly
552+
* the duration of audio that is missing, otherwise the
553+
* decoder will not be in the optimal state to decode the
554+
* next incoming packet. For the PLC and FEC cases, frame_size
555+
* <b>must</b> be a multiple of 2.5 ms.
556+
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
557+
* forward error correction data be decoded.
558+
* If no such data is available, the frame is
559+
* decoded as if it were lost.
560+
* @returns Number of samples decoded on success or a negative error code
561+
* (see @ref opus_errorcodes) on failure.
562+
*/
563+
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode24(
564+
OpusProjectionDecoder *st,
565+
const unsigned char *data,
566+
opus_int32 len,
567+
opus_int32 *pcm,
568+
int frame_size,
569+
int decode_fec
570+
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
496571

497572
/** Decode a projection Opus packet with floating point output.
498573
* @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.

0 commit comments

Comments
 (0)