Class OpusProjection
- java.lang.Object
-
- org.lwjgl.util.opus.OpusProjection
-
public class OpusProjection extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OpusProjection.Functions
Contains the function pointers loaded fromOpus.getLibrary()
.
-
Field Summary
Fields Modifier and Type Field Description static int
OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST
OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST
OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUESTProjection CTLs
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
nopus_projection_ambisonics_encoder_create(int Fs, int channels, int mapping_family, long streams, long coupled_streams, int application, long error)
Unsafe version of:projection_ambisonics_encoder_create
static int
nopus_projection_ambisonics_encoder_init(long st, int Fs, int channels, int mapping_family, long streams, long coupled_streams, int application)
Unsafe version of:projection_ambisonics_encoder_init
static int
nopus_projection_decode(long st, long data, int len, long pcm, int frame_size, int decode_fec)
Unsafe version of:projection_decode
static int
nopus_projection_decode_float(long st, long data, int len, long pcm, int frame_size, int decode_fec)
Unsafe version of:projection_decode_float
static long
nopus_projection_decoder_create(int Fs, int channels, int streams, int coupled_streams, long demixing_matrix, int demixing_matrix_size, long error)
Unsafe version of:projection_decoder_create
static int
nopus_projection_decoder_init(long st, int Fs, int channels, int streams, int coupled_streams, long demixing_matrix, int demixing_matrix_size)
Unsafe version of:projection_decoder_init
static int
nopus_projection_encode(long st, long pcm, int frame_size, long data, int max_data_bytes)
Unsafe version of:projection_encode
static int
nopus_projection_encode_float(long st, long pcm, int frame_size, long data, int max_data_bytes)
Unsafe version of:projection_encode_float
static long
opus_projection_ambisonics_encoder_create(int Fs, int channels, int mapping_family, java.nio.IntBuffer streams, java.nio.IntBuffer coupled_streams, int application, java.nio.IntBuffer error)
Allocates and initializes a projection encoder state.static int
opus_projection_ambisonics_encoder_get_size(int channels, int mapping_family)
Gets the size of anOpusProjectionEncoder
structure.static int
opus_projection_ambisonics_encoder_init(long st, int Fs, int channels, int mapping_family, java.nio.IntBuffer streams, java.nio.IntBuffer coupled_streams, int application)
Initialize a previously allocated projection encoder state.static int
opus_projection_decode(long st, java.nio.ByteBuffer data, java.nio.ShortBuffer pcm, int frame_size, int decode_fec)
Decode a projection Opus packet.static int
opus_projection_decode_float(long st, java.nio.ByteBuffer data, java.nio.FloatBuffer pcm, int frame_size, int decode_fec)
Decode a projection Opus packet with floating point output.static long
opus_projection_decoder_create(int Fs, int channels, int streams, int coupled_streams, java.nio.ByteBuffer demixing_matrix, java.nio.IntBuffer error)
Allocates and initializes a projection decoder state.static int
opus_projection_decoder_ctl(long st, int request)
Performs a CTL function on a projection Opus decoder.static int
opus_projection_decoder_ctl(long st, Opus.CTLRequest request)
Performs a CTL function on a projection Opus decoder.static int
opus_projection_decoder_destroy(long st)
Frees anOpusProjectionDecoder
allocated byprojection_decoder_create
.static int
opus_projection_decoder_get_size(int channels, int streams, int coupled_streams)
Gets the size of anOpusProjectionDecoder
structure.static int
opus_projection_decoder_init(long st, int Fs, int channels, int streams, int coupled_streams, java.nio.ByteBuffer demixing_matrix)
Initialize a previously allocated projection decoder state object.static int
opus_projection_encode(long st, java.nio.ShortBuffer pcm, int frame_size, java.nio.ByteBuffer data)
Encodes a projection Opus frame.static int
opus_projection_encode_float(long st, java.nio.FloatBuffer pcm, int frame_size, java.nio.ByteBuffer data)
Encodes a projection Opus frame from floating point input.static int
opus_projection_encoder_ctl(long st, int request)
Performs a CTL function on an projection Opus encoder.static int
opus_projection_encoder_ctl(long st, Opus.CTLRequest request)
Performs a CTL function on an projection Opus encoder.static int
opus_projection_encoder_destroy(long st)
Frees anOpusProjectionEncoder
allocated byprojection_ambisonics_encoder_create
.static Opus.CTLRequest
OPUS_PROJECTION_GET_DEMIXING_MATRIX(java.nio.ByteBuffer matrix)
Copies the demixing matrix to the supplied pointer location.static Opus.CTLRequest
OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(java.nio.IntBuffer value)
Gets the gain (in dB.static Opus.CTLRequest
OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(java.nio.IntBuffer value)
Gets the size in bytes of the demixing matrix from the encoder.
-
-
-
Method Detail
-
opus_projection_ambisonics_encoder_get_size
public static int opus_projection_ambisonics_encoder_get_size(int channels, int mapping_family)
Gets the size of anOpusProjectionEncoder
structure.- Parameters:
channels
- the total number of input channels to encode. This must be no more than 255.mapping_family
- the mapping family to use for selecting the appropriate projection- Returns:
- the size in bytes on success, or a negative error code
-
nopus_projection_ambisonics_encoder_create
public static long nopus_projection_ambisonics_encoder_create(int Fs, int channels, int mapping_family, long streams, long coupled_streams, int application, long error)
Unsafe version of:projection_ambisonics_encoder_create
-
opus_projection_ambisonics_encoder_create
public static long opus_projection_ambisonics_encoder_create(int Fs, int channels, int mapping_family, java.nio.IntBuffer streams, java.nio.IntBuffer coupled_streams, int application, @Nullable java.nio.IntBuffer error)
Allocates and initializes a projection encoder state.Call
projection_encoder_destroy
to release this object when finished.- Parameters:
Fs
- sampling rate of the input signal (in Hz). One of:8000 12000 16000 24000 48000 channels
- number of channels in the input signal. This must be at most 255. It may be greater than the number of coded channels (streams + coupled_streams
).mapping_family
- the mapping family to use for selecting the appropriate projectionstreams
- the total number of streams that will be encoded from the inputcoupled_streams
- number of coupled (2 channel) streams to encode that will be encoded from the inputapplication
- the target encoder applicationerror
- returnsOK
on success, or a negative error code on failure
-
nopus_projection_ambisonics_encoder_init
public static int nopus_projection_ambisonics_encoder_init(long st, int Fs, int channels, int mapping_family, long streams, long coupled_streams, int application)
Unsafe version of:projection_ambisonics_encoder_init
-
opus_projection_ambisonics_encoder_init
public static int opus_projection_ambisonics_encoder_init(long st, int Fs, int channels, int mapping_family, java.nio.IntBuffer streams, java.nio.IntBuffer coupled_streams, int application)
Initialize a previously allocated projection encoder state.The memory pointed to by
st
must be at least the size returned byprojection_ambisonics_encoder_get_size
. This is intended for applications which use their own allocator instead ofmalloc
.To reset a previously initialized state, use the
RESET_STATE
CTL.- Parameters:
st
- projection encoder state to initializeFs
- sampling rate of the input signal (in Hz). One of:8000 12000 16000 24000 48000 channels
- number of channels in the input signal. This must be at most 255. It may be greater than the number of coded channels (streams + coupled_streams
).streams
- the total number of streams that will be encoded from the inputcoupled_streams
- number of coupled (2 channel) streams to encode that will be encoded from the input. Additionally, the total number of encoded channels (streams + coupled_streams
) must be no more than the number of input channels.application
- the target encoder application- Returns:
OK
on success, or a negative error code on failure
-
nopus_projection_encode
public static int nopus_projection_encode(long st, long pcm, int frame_size, long data, int max_data_bytes)
Unsafe version of:projection_encode
- Parameters:
max_data_bytes
- size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. UseSET_BITRATE_REQUEST
to control the bitrate.
-
opus_projection_encode
public static int opus_projection_encode(long st, java.nio.ShortBuffer pcm, int frame_size, java.nio.ByteBuffer data)
Encodes a projection Opus frame.- Parameters:
st
- projection encoder statepcm
- the input signal as interleaved samples. This must containframe_size*channels
samples.frame_size
- number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.data
- output payload. This must contain storage for atmax_data_bytes
.- Returns:
- the length of the encoded packet (in bytes) on success or a negative error code on failure
-
nopus_projection_encode_float
public static int nopus_projection_encode_float(long st, long pcm, int frame_size, long data, int max_data_bytes)
Unsafe version of:projection_encode_float
- Parameters:
max_data_bytes
- size of the allocated memory for the output payload. This may be used to impose an upper limit on the instant bitrate, but should not be used as the only bitrate control. UseSET_BITRATE_REQUEST
to control the bitrate.
-
opus_projection_encode_float
public static int opus_projection_encode_float(long st, java.nio.FloatBuffer pcm, int frame_size, java.nio.ByteBuffer data)
Encodes a projection Opus frame from floating point input.- Parameters:
st
- projection encoder statepcm
- the input signal as interleaved samples 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. This must containframe_size*channels
samples.frame_size
- number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.data
- output payload. This must contain storage for atmax_data_bytes
.- Returns:
- the length of the encoded packet (in bytes) on success or a negative error code on failure
-
opus_projection_encoder_destroy
public static int opus_projection_encoder_destroy(long st)
Frees anOpusProjectionEncoder
allocated byprojection_ambisonics_encoder_create
.- Parameters:
st
- projection encoder state to be freed
-
opus_projection_decoder_get_size
public static int opus_projection_decoder_get_size(int channels, int streams, int coupled_streams)
Gets the size of anOpusProjectionDecoder
structure.- Parameters:
channels
- the total number of output channels. This must be no more than 255.streams
- the total number of streams coded in the inputcoupled_streams
- number streams to decode as coupled (2 channel) streams. This must be no larger than the total number of streams. Additionally, The total number of coded channels (streams + coupled_streams
) must be no more than 255.- Returns:
- the size in bytes on success, or a negative error code on failure
-
nopus_projection_decoder_create
public static long nopus_projection_decoder_create(int Fs, int channels, int streams, int coupled_streams, long demixing_matrix, int demixing_matrix_size, long error)
Unsafe version of:projection_decoder_create
- Parameters:
demixing_matrix_size
- the size in bytes if the demixing matrix
-
opus_projection_decoder_create
public static long opus_projection_decoder_create(int Fs, int channels, int streams, int coupled_streams, java.nio.ByteBuffer demixing_matrix, @Nullable java.nio.IntBuffer error)
Allocates and initializes a projection decoder state.Call
projection_decoder_destroy
to release this object when finished.- Parameters:
Fs
- sampling rate of input signal (Hz). One of:8000 12000 16000 24000 48000 channels
- number of channels to outputstreams
- the total number of streams coded in the input. This must be no more than 255.coupled_streams
- number streams to decode as coupled (2 channel) streams. This must be no larger than the total number of streams. Additionally, The total number of coded channels (streams + coupled_streams
) must be no more than 255.demixing_matrix
- demixing matrix that maps from coded channels to output channelserror
- returnsOK
on success, or a negative error code on failure
-
nopus_projection_decoder_init
public static int nopus_projection_decoder_init(long st, int Fs, int channels, int streams, int coupled_streams, long demixing_matrix, int demixing_matrix_size)
Unsafe version of:projection_decoder_init
- Parameters:
demixing_matrix_size
- the size in bytes if the demixing matrix
-
opus_projection_decoder_init
public static int opus_projection_decoder_init(long st, int Fs, int channels, int streams, int coupled_streams, java.nio.ByteBuffer demixing_matrix)
Initialize a previously allocated projection decoder state object.The memory pointed to by
st
must be at least the size returned byprojection_decoder_get_size
. This is intended for applications which use their own allocator instead ofmalloc
.To reset a previously initialized state, use the
RESET_STATE
CTL.- Parameters:
st
- projection decoder state to initializeFs
- sampling rate of input signal (Hz). One of:8000 12000 16000 24000 48000 channels
- number of channels to output. This mustbe at most 255. It may be different from the number of coded channels (stream + coupled_streams
).streams
- the total number of streams coded in the input. This must be no more than 255.coupled_streams
- number streams to decode as coupled (2 channel) streams. This must be no larger than the total number of streams. Additionally, The total number of coded channels (streams + coupled_streams
) must be no more than 255.demixing_matrix
- demixing matrix that maps from coded channels to output channels- Returns:
OK
on success, or a negative error code on failure
-
nopus_projection_decode
public static int nopus_projection_decode(long st, long data, int len, long pcm, int frame_size, int decode_fec)
Unsafe version of:projection_decode
- Parameters:
len
- number of bytes in payload
-
opus_projection_decode
public static int opus_projection_decode(long st, @Nullable java.nio.ByteBuffer data, java.nio.ShortBuffer pcm, int frame_size, int decode_fec)
Decode a projection Opus packet.- Parameters:
st
- projection decoder statedata
- input payload (Use aNULL
pointer to indicate packet loss)pcm
- output signal, with interleaved samples. This must contain room forframe_size*channels
samples.frame_size
- number of samples per channel of available space inpcm
.If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (
data==NULL
) or FEC (decode_fec=1
), thenframe_size
needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases,frame_size
must be a multiple of 2.5 ms.decode_fec
- flag (0 or 1) to request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.- Returns:
- number of decoded samples on success or a negative error code on failure
-
nopus_projection_decode_float
public static int nopus_projection_decode_float(long st, long data, int len, long pcm, int frame_size, int decode_fec)
Unsafe version of:projection_decode_float
- Parameters:
len
- number of bytes in payload
-
opus_projection_decode_float
public static int opus_projection_decode_float(long st, @Nullable java.nio.ByteBuffer data, java.nio.FloatBuffer pcm, int frame_size, int decode_fec)
Decode a projection Opus packet with floating point output.- Parameters:
st
- projection decoder statedata
- input payload. Use aNULL
pointer to indicate packet losspcm
- output signal, with interleaved samples. (This must contain room forframe_size*channels
samples.)frame_size
- number of samples per channel of available space in pcm.If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (
data==NULL
) or FEC (decode_fec=1
), thenframe_size
needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases,frame_size
must be a multiple of 2.5 ms.decode_fec
- flag (0 or 1) to request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.- Returns:
- number of decoded samples on success or a negative error code on failure
-
opus_projection_decoder_destroy
public static int opus_projection_decoder_destroy(long st)
Frees anOpusProjectionDecoder
allocated byprojection_decoder_create
.- Parameters:
st
- projection decoder state to be freed
-
opus_projection_encoder_ctl
public static int opus_projection_encoder_ctl(long st, int request) public static int opus_projection_encoder_ctl(long st, Opus.CTLRequest request)
Performs a CTL function on an projection Opus encoder.- Parameters:
st
- projection encoder staterequest
- CTL request
-
opus_projection_decoder_ctl
public static int opus_projection_decoder_ctl(long st, int request) public static int opus_projection_decoder_ctl(long st, Opus.CTLRequest request)
Performs a CTL function on a projection Opus decoder.- Parameters:
st
- projection decoder staterequest
- CTL request
-
OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN
public static Opus.CTLRequest OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(java.nio.IntBuffer value)
Gets the gain (in dB. S7.8-format) of the demixing matrix from the encoder.- Returns:
- the gain (in dB. S7.8-format) of the demixing matrix.
-
OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE
public static Opus.CTLRequest OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(java.nio.IntBuffer value)
Gets the size in bytes of the demixing matrix from the encoder.- Returns:
- the size in bytes of the demixing matrix.
-
OPUS_PROJECTION_GET_DEMIXING_MATRIX
public static Opus.CTLRequest OPUS_PROJECTION_GET_DEMIXING_MATRIX(java.nio.ByteBuffer matrix)
Copies the demixing matrix to the supplied pointer location.- Parameters:
matrix
- returns the demixing matrix to the supplied pointer location.
-
-