public class OpusCustom
extends java.lang.Object
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 |
|---|---|
static class |
OpusCustom.Functions
Contains the function pointers loaded from
Opus.getLibrary(). |
| Modifier and Type | Method and Description |
|---|---|
static int |
nopus_custom_decode_float(long st,
long data,
int len,
long pcm,
int frame_size)
Unsafe version of:
custom_decode_float |
static int |
nopus_custom_decode(long st,
long data,
int len,
long pcm,
int frame_size)
Unsafe version of:
custom_decode |
static long |
nopus_custom_decoder_create(long mode,
int channels,
long error)
Unsafe version of:
custom_decoder_create |
static int |
nopus_custom_encode_float(long st,
long pcm,
int frame_size,
long compressed,
int maxCompressedBytes)
Unsafe version of:
custom_encode_float |
static int |
nopus_custom_encode(long st,
long pcm,
int frame_size,
long compressed,
int maxCompressedBytes)
Unsafe version of:
custom_encode |
static long |
nopus_custom_encoder_create(long mode,
int channels,
long error)
Unsafe version of:
custom_encoder_create |
static long |
nopus_custom_mode_create(int Fs,
int frame_size,
long error)
Unsafe version of:
custom_mode_create |
static int |
opus_custom_decode_float(long st,
java.nio.ByteBuffer data,
java.nio.FloatBuffer pcm,
int frame_size)
Decode an opus custom frame with floating point output.
|
static int |
opus_custom_decode(long st,
java.nio.ByteBuffer data,
java.nio.ShortBuffer pcm,
int frame_size)
Decode an opus custom frame.
|
static long |
opus_custom_decoder_create(long mode,
int channels,
java.nio.IntBuffer error)
Creates a new decoder state.
|
static int |
opus_custom_decoder_ctl(long st,
int request)
Performs a CTL function on an Opus custom decoder.
|
static int |
opus_custom_decoder_ctl(long st,
Opus.CTLRequest request)
Performs a CTL function on an Opus custom decoder.
|
static void |
opus_custom_decoder_destroy(long st)
Destroys a an decoder state.
|
static int |
opus_custom_decoder_get_size(long mode,
int channels)
Gets the size of an
OpusCustomDecoder structure. |
static int |
opus_custom_decoder_init(long st,
long mode,
int channels)
Initializes a previously allocated decoder state.
|
static int |
opus_custom_encode_float(long st,
java.nio.FloatBuffer pcm,
int frame_size,
java.nio.ByteBuffer compressed)
Encodes a frame of audio.
|
static int |
opus_custom_encode(long st,
java.nio.ShortBuffer pcm,
int frame_size,
java.nio.ByteBuffer compressed)
Encodes a frame of audio.
|
static long |
opus_custom_encoder_create(long mode,
int channels,
java.nio.IntBuffer error)
Creates a new encoder state.
|
static int |
opus_custom_encoder_ctl(long st,
int request)
Performs a CTL function on an Opus custom encoder.
|
static int |
opus_custom_encoder_ctl(long st,
Opus.CTLRequest request)
Performs a CTL function on an Opus custom encoder.
|
static void |
opus_custom_encoder_destroy(long st)
Destroys a an encoder state.
|
static int |
opus_custom_encoder_get_size(long mode,
int channels)
Gets the size of an
OpusCustomEncoder structure. |
static int |
opus_custom_encoder_init(long st,
long mode,
int channels)
Initializes a previously allocated encoder state.
|
static long |
opus_custom_mode_create(int Fs,
int frame_size,
java.nio.IntBuffer error)
Creates a new mode struct.
|
static void |
opus_custom_mode_destroy(long mode)
Destroys a mode struct.
|
public static long nopus_custom_mode_create(int Fs,
int frame_size,
long error)
custom_mode_createpublic static long opus_custom_mode_create(int Fs,
int frame_size,
@Nullable
java.nio.IntBuffer error)
Fs - sampling rate (8000 to 96000 Hz)frame_size - 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 primeserror - returned error code (if NULL, no error will be returned)public static void opus_custom_mode_destroy(long mode)
mode - mode to be freedpublic static int opus_custom_encoder_get_size(long mode,
int channels)
OpusCustomEncoder structure.mode - mode configurationchannels - number of channelspublic static int opus_custom_encoder_init(long st,
long mode,
int channels)
The memory pointed to by st must be the size returned by custom_encoder_get_size. This is intended for applications which use their own
allocator instead of malloc.
To reset a previously initialized state use the RESET_STATE CTL.
st - encoder statemode - contains all the information about the characteristics of the stream (must be the same characteristics as used for the decoder)channels - number of channelsOK Success or a negative error codepublic static long nopus_custom_encoder_create(long mode,
int channels,
long error)
custom_encoder_createpublic static long opus_custom_encoder_create(long mode,
int channels,
@Nullable
java.nio.IntBuffer error)
Each stream needs its own encoder state (can't be shared across simultaneous streams).
mode - contains all the information about the characteristics of the stream (must be the same characteristics as used for the decoder)channels - number of channelserror - returns an error codepublic static void opus_custom_encoder_destroy(long st)
st - state to be freedpublic static int nopus_custom_encode_float(long st,
long pcm,
int frame_size,
long compressed,
int maxCompressedBytes)
custom_encode_floatmaxCompressedBytes - maximum number of bytes to use for compressing the frame (can change from one frame to another)public static int opus_custom_encode_float(long st,
java.nio.FloatBuffer pcm,
int frame_size,
java.nio.ByteBuffer compressed)
st - encoder statepcm - PCM audio in float format, with a normal range of +/-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.frame_size - number of samples per frame of input signalcompressed - the compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.compress on success, or a negative error codepublic static int nopus_custom_encode(long st,
long pcm,
int frame_size,
long compressed,
int maxCompressedBytes)
custom_encodemaxCompressedBytes - maximum number of bytes to use for compressing the frame (can change from one frame to another)public static int opus_custom_encode(long st,
java.nio.ShortBuffer pcm,
int frame_size,
java.nio.ByteBuffer compressed)
st - encoder statepcm - PCM audio in signed 16-bit format (native endian). (There must be exactly frame_size samples per channel.)frame_size - number of samples per frame of input signalcompressed - the compressed data is written here. This may not alias pcm and must be at least maxCompressedBytes long.compress on success, or a negative error codepublic static int opus_custom_decoder_get_size(long mode,
int channels)
OpusCustomDecoder structure.mode - mode configurationchannels - number of channelspublic static int opus_custom_decoder_init(long st,
long mode,
int channels)
The memory pointed to by st must be the size returned by custom_decoder_get_size. This is intended for applications which use their own
allocator instead of malloc.
To reset a previously initialized state use the RESET_STATE CTL.
st - decoder statemode - contains all the information about the characteristics of the stream (must be the same characteristics as used for the encoder)channels - number of channelsOK Success or a negative error codepublic static long nopus_custom_decoder_create(long mode,
int channels,
long error)
custom_decoder_createpublic static long opus_custom_decoder_create(long mode,
int channels,
@Nullable
java.nio.IntBuffer error)
Each stream needs its own decoder state (can't be shared across simultaneous streams).
mode - contains all the information about the characteristics of the stream (must be the same characteristics as used for the encoder)channels - number of channelserror - returns an error codepublic static void opus_custom_decoder_destroy(long st)
st - state to be freedpublic static int nopus_custom_decode_float(long st,
long data,
int len,
long pcm,
int frame_size)
custom_decode_floatlen - number of bytes in payloadpublic static int opus_custom_decode_float(long st,
@Nullable
java.nio.ByteBuffer data,
java.nio.FloatBuffer pcm,
int frame_size)
st - decoder statedata - input payload. Use a NULL pointer to indicate packet loss.pcm - output signal (interleaved if 2 channels) (length is frame_size*channels*sizeof(float)frame_size - number of samples per channel of available space in pcmpublic static int nopus_custom_decode(long st,
long data,
int len,
long pcm,
int frame_size)
custom_decodelen - number of bytes in payloadpublic static int opus_custom_decode(long st,
@Nullable
java.nio.ByteBuffer data,
java.nio.ShortBuffer pcm,
int frame_size)
st - decoder statedata - input payload. Use a NULL pointer to indicate packet loss.pcm - output signal (interleaved if 2 channels) (length is frame_size*channels*sizeof(opus_int16)frame_size - number of samples per channel of available space in pcmpublic static int opus_custom_encoder_ctl(long st,
int request)
st - encoder staterequest - CTL requestpublic static int opus_custom_encoder_ctl(long st,
Opus.CTLRequest request)
st - encoder staterequest - CTL requestpublic static int opus_custom_decoder_ctl(long st,
int request)
st - decoder staterequest - CTL requestpublic static int opus_custom_decoder_ctl(long st,
Opus.CTLRequest request)
st - decoder staterequest - CTL requestCopyright LWJGL. All Rights Reserved. License terms.