In addition to the interoperability limitations the use of Opus custom disables a substantial chunk of the codec and generally lowers the quality available at a given bitrate. Normally when an application needs a different frame size from the codec it should buffer to match the sizes but this adds a small amount of delay which may be important in some very low latency applications. Some transports (especially constant rate RF transports) may also work best with frames of particular durations.
Libopus only supports custom modes if they are enabled at compile time.
The Opus Custom API is similar to the regular API but the custom_encoder_create and custom_decoder_create calls take an additional mode parameter
which is a structure produced by a call to custom_mode_create. Both the encoder and decoder must create a mode using the same sample rate (fs) and
frame size (frame size) so these parameters must either be signaled out of band or fixed in a particular implementation.
Similar to regular Opus the custom modes support on the fly frame size switching, but the sizes available depend on the particular frame size in use. For some initial frame sizes on a single on the fly size is available.
| Modifier and Type | Class and Description |
|---|---|
| public static class | OpusCustom.
Contains the function pointers loaded from |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static int | nopus_custom_decode(long st, long data, int
number of bytes in payload len, long pcm, int frame_size)Unsafe version of: |
| public static int | nopus_custom_decode_float(long st, long data, int
number of bytes in payload len, long pcm, int frame_size)Unsafe version of: |
| public static long | nopus_custom_decoder_create(long mode, int channels, long error)
Unsafe version of: |
| public static int | nopus_custom_encode(long st, long pcm, int frame_size, long compressed, int
maximum number of bytes to use for compressing the frame (can change from one frame to another) maxCompressedBytes)Unsafe version of: |
| public static int | nopus_custom_encode_float(long st, long pcm, int frame_size, long compressed, int
maximum number of bytes to use for compressing the frame (can change from one frame to another) maxCompressedBytes)Unsafe version of: |
| public static long | nopus_custom_encoder_create(long mode, int channels, long error)
Unsafe version of: |
| public static long | |
| public static int | Returns: number of decoded samples, or a negative error codedecoder state st, ByteBuffer input payload. Use a data, ShortBuffer NULL pointer to indicate packet loss.output signal (interleaved if 2 channels) (length is pcm, int frame_size*channels*sizeof(opus_int16)number of samples per channel of available space in frame_size)pcmDecode an opus custom frame. |
| public static int | Returns: number of decoded samples, or a negative error codedecoder state st, ByteBuffer input payload. Use a data, FloatBuffer NULL pointer to indicate packet loss.output signal (interleaved if 2 channels) (length is pcm, int frame_size*channels*sizeof(float)number of samples per channel of available space in frame_size)pcmDecode an opus custom frame with floating point output. |
| public static long | Returns: newly created decoder statecontains all the information about the characteristics of the stream (must be the same characteristics as used for the encoder) mode, int number of channels channels, IntBuffer returns an error code error)Creates a new decoder state. |
| private static int | |
| public static int | opus_custom_decoder_ctl(long
decoder state st, int CTL request request)Performs a CTL function on an Opus custom decoder. |
| public static int | opus_custom_decoder_ctl(long
decoder state st, Opus.CTL request requestPerforms a CTL function on an Opus custom decoder. |
| public static void | |
| public static int | Returns: sizemode configuration mode, int number of channels channels)Gets the size of an |
| public static int | Returns: OK Success or a negative error codedecoder state st, long contains all the information about the characteristics of the stream (must be the same characteristics as used for the encoder) mode, int number of channels channels)Initializes a previously allocated decoder state. |
| public static int | Returns: the number of bytes written tocompress on success, or a negative error codeencoder state st, ShortBuffer PCM audio in signed 16-bit format (native endian). (There must be exactly pcm, int frame_size samples per channel.)number of samples per frame of input signal frame_size, ByteBuffer the compressed data is written here. This may not alias compressed)pcm and must be at least maxCompressedBytes long.Encodes a frame of audio. |
| public static int | Returns: the number of bytes written tocompress on success, or a negative error codeencoder state st, FloatBuffer PCM audio in float format, with a normal range of pcm, int +/-1.0. Samples with a range beyond +/-1.0 are supported but will be clipped by
decoders using the integer API and should only be used if it is known that the far end supports extended dynamic range. There must be exactly
frame_size samples per channel.number of samples per frame of input signal frame_size, ByteBuffer the compressed data is written here. This may not alias compressed)pcm and must be at least maxCompressedBytes long.Encodes a frame of audio. |
| public static long | Returns: newly created encoder statecontains all the information about the characteristics of the stream (must be the same characteristics as used for the decoder) mode, int number of channels channels, IntBuffer returns an error code error)Creates a new encoder state. |
| private static int | |
| public static int | opus_custom_encoder_ctl(long
encoder state st, int CTL request request)Performs a CTL function on an Opus custom encoder. |
| public static int | opus_custom_encoder_ctl(long
encoder state st, Opus.CTL request requestPerforms a CTL function on an Opus custom encoder. |
| public static void | |
| public static int | Returns: sizemode configuration mode, int number of channels channels)Gets the size of an |
| public static int | Returns: OK Success or a negative error codeencoder state st, long contains all the information about the characteristics of the stream (must be the same characteristics as used for the decoder) mode, int number of channels channels)Initializes a previously allocated encoder state. |
| public static long | opus_custom_mode_create(int
sampling rate (8000 to 96000 Hz) Fs, int number of samples (per channel) to encode in each packet (64 - 1024, prime factorization must contain zero or more 2s, 3s, or 5s and no other primes frame_size, IntBuffer returned error code (if error)NULL, no error will be returned)Creates a new mode struct. |
| public static void |
| OpusCustom | back to summary |
|---|---|
| protected OpusCustom() | |
| nopus_custom_decode | back to summary |
|---|---|
| public static int nopus_custom_decode(long st, long data, int len, long pcm, int frame_size) Unsafe version of:
| |
| nopus_custom_decode_float | back to summary |
|---|---|
| public static int nopus_custom_decode_float(long st, long data, int len, long pcm, int frame_size) Unsafe version of:
| |
| nopus_custom_decoder_create | back to summary |
|---|---|
| public static long nopus_custom_decoder_create(long mode, int channels, long error) Unsafe version of: | |
| nopus_custom_encode | back to summary |
|---|---|
| public static int nopus_custom_encode(long st, long pcm, int frame_size, long compressed, int maxCompressedBytes) Unsafe version of:
| |
| nopus_custom_encode_float | back to summary |
|---|---|
| public static int nopus_custom_encode_float(long st, long pcm, int frame_size, long compressed, int maxCompressedBytes) Unsafe version of:
| |
| nopus_custom_encoder_create | back to summary |
|---|---|
| public static long nopus_custom_encoder_create(long mode, int channels, long error) Unsafe version of: | |
| nopus_custom_mode_create | back to summary |
|---|---|
| public static long nopus_custom_mode_create(int Fs, int frame_size, long error) Unsafe version of: | |
| opus_custom_decode | back to summary |
|---|---|
| public static int opus_custom_decode(long st, ByteBuffer data, ShortBuffer pcm, int frame_size) Decode an opus custom frame.
| |
| opus_custom_decode_float | back to summary |
|---|---|
| public static int opus_custom_decode_float(long st, ByteBuffer data, FloatBuffer pcm, int frame_size) Decode an opus custom frame with floating point output.
| |
| opus_custom_decoder_create | back to summary |
|---|---|
| public static long opus_custom_decoder_create(long mode, int channels, IntBuffer error) Creates a new decoder state. Each stream needs its own decoder state (can't be shared across simultaneous streams).
| |
| opus_custom_decoder_ctl | back to summary |
|---|---|
| private static int opus_custom_decoder_ctl(long st) Performs a CTL function on an Opus custom decoder.
| |
| opus_custom_decoder_ctl | back to summary |
|---|---|
| public static int opus_custom_decoder_ctl(long st, int request) Performs a CTL function on an Opus custom decoder.
| |
| opus_custom_decoder_ctl | back to summary |
|---|---|
| public static int opus_custom_decoder_ctl(long st, Opus. Performs a CTL function on an Opus custom decoder.
| |
| opus_custom_decoder_destroy | back to summary |
|---|---|
| public static void opus_custom_decoder_destroy(long st) Destroys a decoder state.
| |
| opus_custom_decoder_get_size | back to summary |
|---|---|
| public static int opus_custom_decoder_get_size(long mode, int channels) Gets the size of an
| |
| opus_custom_decoder_init | back to summary |
|---|---|
| public static int opus_custom_decoder_init(long st, long mode, int channels) Initializes a previously allocated decoder state. The memory pointed to by To reset a previously initialized state use the
| |
| opus_custom_encode | back to summary |
|---|---|
| public static int opus_custom_encode(long st, ShortBuffer pcm, int frame_size, ByteBuffer compressed) Encodes a frame of audio.
| |
| opus_custom_encode_float | back to summary |
|---|---|
| public static int opus_custom_encode_float(long st, FloatBuffer pcm, int frame_size, ByteBuffer compressed) Encodes a frame of audio.
| |
| opus_custom_encoder_create | back to summary |
|---|---|
| public static long opus_custom_encoder_create(long mode, int channels, IntBuffer error) Creates a new encoder state. Each stream needs its own encoder state (can't be shared across simultaneous streams).
| |
| opus_custom_encoder_ctl | back to summary |
|---|---|
| private static int opus_custom_encoder_ctl(long st) Performs a CTL function on an Opus custom encoder.
| |
| opus_custom_encoder_ctl | back to summary |
|---|---|
| public static int opus_custom_encoder_ctl(long st, int request) Performs a CTL function on an Opus custom encoder.
| |
| opus_custom_encoder_ctl | back to summary |
|---|---|
| public static int opus_custom_encoder_ctl(long st, Opus. Performs a CTL function on an Opus custom encoder.
| |
| opus_custom_encoder_destroy | back to summary |
|---|---|
| public static void opus_custom_encoder_destroy(long st) Destroys an encoder state.
| |
| opus_custom_encoder_get_size | back to summary |
|---|---|
| public static int opus_custom_encoder_get_size(long mode, int channels) Gets the size of an
| |
| opus_custom_encoder_init | back to summary |
|---|---|
| public static int opus_custom_encoder_init(long st, long mode, int channels) Initializes a previously allocated encoder state. The memory pointed to by To reset a previously initialized state use the
| |
| opus_custom_mode_create | back to summary |
|---|---|
| public static long opus_custom_mode_create(int Fs, int frame_size, IntBuffer error) Creates a new mode struct. This will be passed to an encoder or decoder. The mode MUST NOT BE DESTROYED until the encoders and decoders that use it are destroyed as well.
| |
| opus_custom_mode_destroy | back to summary |
|---|---|
| public static void opus_custom_mode_destroy(long mode) Destroys a mode struct. Only call this after all encoders and decoders using this mode are destroyed as well.
| |
Opus.getLibrary().
| Modifier and Type | Field and Description |
|---|---|
| public static final long | custom_decode
Function address. |
| public static final long | custom_decode_float
Function address. |
| public static final long | custom_decoder_create
Function address. |
| public static final long | custom_decoder_ctl
Function address. |
| public static final long | custom_decoder_destroy
Function address. |
| public static final long | custom_decoder_get_size
Function address. |
| public static final long | custom_decoder_init
Function address. |
| public static final long | custom_encode
Function address. |
| public static final long | custom_encode_float
Function address. |
| public static final long | custom_encoder_create
Function address. |
| public static final long | custom_encoder_ctl
Function address. |
| public static final long | custom_encoder_destroy
Function address. |
| public static final long | custom_encoder_get_size
Function address. |
| public static final long | custom_encoder_init
Function address. |
| public static final long | custom_mode_create
Function address. |
| public static final long | custom_mode_destroy
Function address. |
| Access | Constructor and Description |
|---|---|
| private |
| custom_decode | back to summary |
|---|---|
| public static final long custom_decode Function address. | |
| custom_decode_float | back to summary |
|---|---|
| public static final long custom_decode_float Function address. | |
| custom_decoder_create | back to summary |
|---|---|
| public static final long custom_decoder_create Function address. | |
| custom_decoder_ctl | back to summary |
|---|---|
| public static final long custom_decoder_ctl Function address. | |
| custom_decoder_destroy | back to summary |
|---|---|
| public static final long custom_decoder_destroy Function address. | |
| custom_decoder_get_size | back to summary |
|---|---|
| public static final long custom_decoder_get_size Function address. | |
| custom_decoder_init | back to summary |
|---|---|
| public static final long custom_decoder_init Function address. | |
| custom_encode | back to summary |
|---|---|
| public static final long custom_encode Function address. | |
| custom_encode_float | back to summary |
|---|---|
| public static final long custom_encode_float Function address. | |
| custom_encoder_create | back to summary |
|---|---|
| public static final long custom_encoder_create Function address. | |
| custom_encoder_ctl | back to summary |
|---|---|
| public static final long custom_encoder_ctl Function address. | |
| custom_encoder_destroy | back to summary |
|---|---|
| public static final long custom_encoder_destroy Function address. | |
| custom_encoder_get_size | back to summary |
|---|---|
| public static final long custom_encoder_get_size Function address. | |
| custom_encoder_init | back to summary |
|---|---|
| public static final long custom_encoder_init Function address. | |
| custom_mode_create | back to summary |
|---|---|
| public static final long custom_mode_create Function address. | |
| custom_mode_destroy | back to summary |
|---|---|
| public static final long custom_mode_destroy Function address. | |
| Functions | back to summary |
|---|---|
| private Functions() | |