The Opus codec is designed for interactive speech and audio transmission over the Internet. It is designed by the IETF Codec Working Group and incorporates technology from Skype's SILK codec and Xiph.Org's CELT codec.
The Opus codec is designed to handle a wide range of interactive audio applications, including Voice over IP, videoconferencing, in-game chat, and even remote live music performances. It can scale from low bit-rate narrowband speech to very high quality stereo music. Its main features are:
This section describes the process and functions used to encode Opus.
Since Opus is a stateful codec, the encoding process starts with creating an encoder state. This can be done with:
int error;
OpusEncoder *enc;
enc = opus_encoder_create(Fs, channels, application, &error);
From this point, enc can be used for encoding an audio stream. An encoder state must not be used for more than one stream at the
same time. Similarly, the encoder state must not be re-initialized for each frame.
While encoder_create allocates memory for the state, it's also possible to initialize pre-allocated memory:
int size;
int error;
OpusEncoder *enc;
size = opus_encoder_get_size(channels);
enc = malloc(size);
error = opus_encoder_init(enc, Fs, channels, application);
where encoder_get_size returns the required size for the encoder state. Note that future versions of this code may change the size, so no assuptions
should be made about it.
The encoder state is always continuous in memory and only a shallow copy is sufficient to copy it (e.g. memcpy()).
It is possible to change some of the encoder's settings using the encoder_ctl interface. All these settings already default to the recommended
value, so they should only be changed when necessary. The most common settings one may want to change are:
opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate));
opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity));
opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type));
where
bitrate is in bits per second (b/s),complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest, andsignal_type is either AUTO (default), SIGNAL_VOICE, or SIGNAL_MUSIC.See Encoder related CTLs and Generic CTLs for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream.
To encode a frame, encode or encode_float must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data:
len = opus_encode(enc, audio_frame, frame_size, packet, max_packet);
where
audio_frame is the audio data in short (or float for encode_float),frame_size is the duration of the frame in samples (per channel),packet is the byte array to which the compressed data is written, andmax_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended). Do not use max_packet to
control VBR target bitrate, instead use the SET_BITRATE_REQUEST CTL.encode and encode_float return the number of bytes actually written to the packet. The return value can be negative, which indicates that
an error has occurred. If the return value is 2 bytes or less, then the packet does not need to be transmitted (DTX).
Once the encoder state if no longer needed, it can be destroyed with
opus_encoder_destroy(enc);
If the encoder was created with encoder_init rather than encoder_create, then no action is required aside from potentially freeing the memory
that was manually allocated for it (calling free(enc) for the example above).
This page describes the process and functions used to decode Opus.
The decoding process also starts with creating a decoder state. This can be done with:
int error;
OpusDecoder *dec;
dec = opus_decoder_create(Fs, channels, &error);
where
OK on success), andWhile decoder_create allocates memory for the state, it's also possible to initialize pre-allocated memory:
int size;
int error;
OpusDecoder *dec;
size = opus_decoder_get_size(channels);
dec = malloc(size);
error = opus_decoder_init(dec, Fs, channels);
where decoder_get_size returns the required size for the decoder state. Note that future versions of this code may change the size, so no assuptions
should be made about it.
The decoder state is always continuous in memory and only a shallow copy is sufficient to copy it (e.g. memcpy()).
To decode a frame, decode or decode_float must be called with a packet of compressed audio data:
frame_size = opus_decode(dec, packet, len, decoded, max_size, 0);
where
packet is the byte array containing the compressed datalen is the exact number of bytes contained in the packetdecoded is the decoded audio data in opus_int16 (or float for decode_float), andmax_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array.decode and decode_float return the number of samples (per channel) decoded from the packet. If that value is negative, then an error has
occurred. This can occur if the packet is corrupted or if the audio buffer is too small to hold the decoded audio.
Opus is a stateful codec with overlapping blocks and as a result Opus packets are not coded independently of each other. Packets must be passed into the decoder serially and in the correct order for a correct decode. Lost packets can be replaced with loss concealment by calling the decoder with a null pointer and zero length for the missing packet.
A single codec state may only be accessed from a single thread at a time and any required locking must be performed by the caller. Separate streams
must be decoded with separate decoder states and can be decoded in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK
defined.
The repacketizer can be used to merge multiple Opus packets into a single packet or alternatively to split Opus packets that have previously been merged. Splitting valid Opus packets is always guaranteed to succeed, whereas merging valid packets only succeeds if all frames have the same mode, bandwidth, and frame size, and when the total duration of the merged packet is no more than 120 ms. The 120 ms limit comes from the specification and limits decoder memory requirements at a point where framing overhead becomes negligible.
The repacketizer currently only operates on elementary Opus streams. It will not manipualte multistream packets successfully, except in the degenerate case where they consist of data from a single stream.
The repacketizing process starts with creating a repacketizer state, either by calling repacketizer_create or by allocating the memory yourself,
e.g.,
OpusRepacketizer *rp;
rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size());
if (rp != NULL)
opus_repacketizer_init(rp);
Then the application should submit packets with repacketizer_cat, extract new packets with repacketizer_out or repacketizer_out_range, and
then reset the state for the next set of input packets via repacketizer_init.
For example, to split a sequence of packets into individual frames:
unsigned char *data;
int len;
while (get_next_packet(&data, &len))
{
unsigned char out[1276];
opus_int32 out_len;
int nb_frames;
int err;
int i;
err = opus_repacketizer_cat(rp, data, len);
if (err != OPUS_OK)
{
release_packet(data);
return err;
}
nb_frames = opus_repacketizer_get_nb_frames(rp);
for (i = 0; i < nb_frames; i++)
{
out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out));
if (out_len < 0)
{
release_packet(data);
return (int)out_len;
}
output_next_packet(out, out_len);
}
opus_repacketizer_init(rp);
release_packet(data);
}
Alternatively, to combine a sequence of frames into packets that each contain up to TARGET_DURATION_MS milliseconds of data:
// The maximum number of packets with duration TARGET_DURATION_MS occurs
// when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
// packets.
unsigned char *data[(TARGET_DURATION_MS*2/5)+1];
opus_int32 len[(TARGET_DURATION_MS*2/5)+1];
int nb_packets;
unsigned char out[1277*(TARGET_DURATION_MS*2/2)];
opus_int32 out_len;
int prev_toc;
nb_packets = 0;
while (get_next_packet(data+nb_packets, len+nb_packets))
{
int nb_frames;
int err;
nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]);
if (nb_frames < 1)
{
release_packets(data, nb_packets+1);
return nb_frames;
}
nb_frames += opus_repacketizer_get_nb_frames(rp);
// If adding the next packet would exceed our target, or it has an
// incompatible TOC sequence, output the packets we already have before
// submitting it.
// N.B., The nb_packets > 0 check ensures we've submitted at least one
// packet since the last call to opus_repacketizer_init(). Otherwise a
// single packet longer than TARGET_DURATION_MS would cause us to try to
// output an (invalid) empty packet. It also ensures that prev_toc has
// been set to a valid value. Additionally, len[nb_packets] > 0 is
// guaranteed by the call to opus_packet_get_nb_frames() above, so the
// reference to data[nb_packets][0] should be valid.
if (nb_packets > 0 && (
((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) ||
opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames >
TARGET_DURATION_MS*48))
{
out_len = opus_repacketizer_out(rp, out, sizeof(out));
if (out_len < 0)
{
release_packets(data, nb_packets+1);
return (int)out_len;
}
output_next_packet(out, out_len);
opus_repacketizer_init(rp);
release_packets(data, nb_packets);
data[0] = data[nb_packets];
len[0] = len[nb_packets];
nb_packets = 0;
}
err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]);
if (err != OPUS_OK)
{
release_packets(data, nb_packets+1);
return err;
}
prev_toc = data[nb_packets][0];
nb_packets++;
}
// Output the final, partial packet.
if (nb_packets > 0)
{
out_len = opus_repacketizer_out(rp, out, sizeof(out));
release_packets(data, nb_packets);
if (out_len < 0)
return (int)out_len;
output_next_packet(out, out_len);
}
An alternate way of merging packets is to simply call repacketizer_cat unconditionally until it fails. At that point, the merged packet can be
obtained with opus_repacketizer_out() and the input packet for which opus_repacketizer_cat() needs to be re-added to a newly
reinitialized repacketizer state.
| Modifier and Type | Class and Description |
|---|---|
| public abstract static class | |
| public static class | |
| public static class | |
| public static class | |
| public static class | |
| public static class | Opus.
Contains the function pointers loaded from the opus |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| public static SharedLibrary | |||||||||||
| public static int | nopus_decode(long st, long data, int
number of bytes in payload len, long pcm, int frame_size, int decode_fec)Unsafe version of: | ||||||||||
| public static int | nopus_decode_float(long st, long data, int
number of bytes in payload len, long pcm, int frame_size, int decode_fec)Unsafe version of: | ||||||||||
| public static long | |||||||||||
| public static int | nopus_decoder_get_nb_samples(long dec, long packet, int
length of packet len)Unsafe version of: | ||||||||||
| public static int | nopus_encode(long st, long pcm, int frame_size, long data, int
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. Use max_data_bytes)SET_BITRATE_REQUEST to control the bitrate.Unsafe version of: | ||||||||||
| public static int | nopus_encode_float(long st, long pcm, int frame_size, long data, int
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. Use max_data_bytes)SET_BITRATE_REQUEST to control the bitrate.Unsafe version of: | ||||||||||
| public static long | nopus_encoder_create(int Fs, int channels, int application, long error)
Unsafe version of: | ||||||||||
| public static long | |||||||||||
| public static int | nopus_multistream_packet_pad(long data, int len, int new_len, int nb_streams)
Unsafe version of: | ||||||||||
| public static int | nopus_multistream_packet_unpad(long data, int len, int nb_streams)
Unsafe version of: | ||||||||||
| public static int | |||||||||||
| public static int | |||||||||||
| public static int | nopus_packet_get_nb_frames(long packet, int
length of packet len)Unsafe version of: | ||||||||||
| public static int | nopus_packet_get_nb_samples(long packet, int
length of packet len, int Fs)Unsafe version of: | ||||||||||
| public static int | nopus_packet_get_samples_per_frame(long data, int Fs)
Unsafe version of: | ||||||||||
| public static int | |||||||||||
| public static int | nopus_packet_parse(long data, int
size of data len, long out_toc, long frames, long size, long payload_offset)Unsafe version of: | ||||||||||
| public static int | |||||||||||
| public static void | nopus_pcm_soft_clip(long pcm, int frame_size, int
number of channels channels, long softclip_mem)Unsafe version of: | ||||||||||
| public static int | nopus_repacketizer_cat(long rp, long data, int
the number of bytes in the packet data len)Unsafe version of: | ||||||||||
| public static int | nopus_repacketizer_out(long rp, long data, int
the maximum number of bytes to store in the output buffer. In order to guarantee success, this should be at least
maxlen)1277*opus_repacketizer_get_nb_frames(rp). However, 1*opus_repacketizer_get_nb_frames(rp) plus the size of all packet data submitted
to the repacketizer since the last call to repacketizer_init or repacketizer_create is also sufficient, and possibly much smaller.Unsafe version of: | ||||||||||
| public static int | nopus_repacketizer_out_range(long rp, int begin, int end, long data, int
the maximum number of bytes to store in the output buffer. In order to guarantee success, this should be at least maxlen)1276 for a single frame,
or for multiple frames, 1277*(end-begin). However, 1*(end-begin) plus the size of all packet data submitted to the repacketizer
since the last call to repacketizer_init or repacketizer_create is also sufficient, and possibly much smaller.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 pcm.
frame_size, int 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 ( 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. decode_fec)Decodes an Opus packet. | ||||||||||
| 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 pcm.
frame_size, int 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 ( 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. decode_fec)Decodes an Opus packet with floating point output. | ||||||||||
| public static long | opus_decoder_create(int
sampling rate of input signal (Hz). One of: Fs, int
number of channels to decode. One of: channels, IntBuffer error)
Allocates and initializes a decoder state. | ||||||||||
| private static int | |||||||||||
| public static int | opus_decoder_ctl(long
decoder state st, int CTL request request)Performs a CTL function on an Opus decoder. | ||||||||||
| public static int | opus_decoder_ctl(long
decoder state st, Opus.CTL request requestPerforms a CTL function on an Opus decoder. | ||||||||||
| public static void | |||||||||||
| public static int | Returns: number of samples,BAD_ARG if insufficient data was passed to the function, or INVALID_PACKET if the compressed data passed is corrupted or of an
unsupported typedecoder state dec, ByteBuffer Opus packet packet)Gets the number of samples of an Opus packet. | ||||||||||
| public static int | Returns: the size in bytesnumber of channels. One of: channels)
Gets the size of an | ||||||||||
| public static int | Returns: OK on success or a negative error code on errordecoder state st, int sampling rate of input signal (Hz). One of: Fs, int
number of channels to decode. One of: channels)
Initializes a previously allocated decoder state. | ||||||||||
| public static int | Returns: the length of the encoded packet (in bytes) on success or a negative error code on errorencoder state st, ShortBuffer input signal (interleaved if 2 channels) (length is pcm, int frame_size*channels*sizeof(opus_int16))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. frame_size, ByteBuffer output payload data)Encodes an Opus frame. | ||||||||||
| public static int | Returns: the length of the encoded packet (in bytes) on success or a negative error code on errorencoder state st, FloatBuffer input signal (interleaved if 2 channels) 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. (length is
frame_size*channels*sizeof(float))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. frame_size, ByteBuffer output payload data)Encodes an Opus frame from floating point input. | ||||||||||
| public static long | opus_encoder_create(int
sampling rate of input signal (Hz). One of: Fs, int
number of channels in input signal. One of: channels, int
coding mode. One of: application, IntBuffer error)
Allocates and initializes an encoder state. | ||||||||||
| private static int | |||||||||||
| public static int | opus_encoder_ctl(long
encoder state st, int CTL request request)Performs a CTL function on an Opus encoder. | ||||||||||
| public static int | opus_encoder_ctl(long
encoder state st, Opus.CTL request requestPerforms a CTL function on an Opus encoder. | ||||||||||
| public static void | |||||||||||
| public static int | Returns: the size in bytesnumber of channels. One of: channels)
Gets the size of an | ||||||||||
| public static int | Returns: OK on success or a negative error code on errorencoder state st, int sampling rate of input signal (Hz). One of: Fs, int
number of channels in input signal. One of: channels, int
coding mode. One of: application)
Initializes a previously allocated encoder state. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's configured application. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's configured bandpass or the decoder's last bandpass. | ||||||||||
| public static Opus. | Returns: the bitrate in bits per second. The default is determined based on the number of channels and the input sampling rate.Gets the encoder's bitrate configuration. | ||||||||||
| public static Opus. | Returns: a value in the range 0-10, inclusiveGets the encoder's complexity configuration. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets encoder's configured use of discontinuous transmission. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's configured use of variable duration frames. | ||||||||||
| public static Opus. | Returns: entropy coder stateGets the final state of the codec's entropy coder. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's forced channel configuration. | ||||||||||
| public static Opus. | Returns: amount to scale PCM signal by in Q8 dB units.Gets the decoder's configured gain adjustment. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the DTX state of the encoder. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets encoder's configured use of inband forward error correction. | ||||||||||
| public static Opus. | Returns: number of samples (at current sampling rate).Gets the duration (in samples) of the last packet successfully decoded or concealed. | ||||||||||
| public static Opus. | Returns: number of lookahead samplesGets the total samples of delay added by the entire codec. | ||||||||||
| public static Opus. | Returns: input precision in bits, between 8 and 24 (default: 24).Gets the encoder's configured signal depth. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's configured maximum allowed bandpass. | ||||||||||
| public static Opus. | Returns: the configured loss percentage in the range 0-100, inclusive (default: 0)Gets the encoder's configured packet loss percentage. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's configured phase inversion status. | ||||||||||
| public static Opus. | Returns: pitch period at 48 kHz (or 0 if not available)Gets the pitch of the last decoded frame, if available. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's configured prediction status. | ||||||||||
| public static Opus. | Returns: sampling rate of encoder or decoder.Gets the sampling rate the encoder or decoder was initialized with. | ||||||||||
| public static Opus. | Returns: one of the following values:
Gets the encoder's configured signal type. | ||||||||||
| public static Opus. | Returns: one of the following values:
Determines if variable bitrate (VBR) is enabled in the encoder. | ||||||||||
| public static Opus. | Returns: one of the following values:
Determines if constrained VBR is enabled in the encoder. | ||||||||||
| public static String | |||||||||||
| public static int | Returns: the new size of the output packet on success,BAD_ARG if len was less than 1 or new_len was less than len, or INVALID_PACKET
if data did not contain a valid Opus packetthe buffer containing the packet to pad data, int the size of the packet. This must be at least 1. len, int the desired size of the packet after padding. This must be at least 1. new_len, int the number of streams (not channels) in the packet. This must be at least as large as nb_streams)len.Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence). | ||||||||||
| public static int | Returns: the new size of the output packet on success,BAD_ARG if len was less than 1, or INVALID_PACKET if data did not contain a valid Opus
packetthe buffer containing the packet to strip data, int the size of the packet. This must be at least 1. len, int the number of streams (not channels) in the packet. This must be at least 1. nb_streams)Removes all padding from a given Opus multi-stream packet and rewrite the TOC sequence to minimize space usage. | ||||||||||
| public static int | Returns: the bandwidth of the packer on success, orINVALID_PACKET if the compressed data passed is corrupted or of an unsupported typeOpus packet data)Gets the bandwidth of an Opus packet. | ||||||||||
| public static int | Returns: number of channels, orINVALID_PACKET if the compressed data passed is corrupted or of an unsupported typeOpus packet data)Gets the number of channels from an Opus packet. | ||||||||||
| public static int | Returns: number of frames,BAD_ARG if insufficient data was passed to the function, or INVALID_PACKET if the compressed data passed is corrupted or of an
unsupported typeOpus packet packet)Gets the number of frames in an Opus packet. | ||||||||||
| public static int | Returns: number of samples,BAD_ARG if insufficient data was passed to the function, or INVALID_PACKET if the compressed data passed is corrupted or of an
unsupported typeOpus packet packet, int sampling rate in Hz. This must be a multiple of 400, or inaccurate results will be returned. Fs)Gets the number of samples of an Opus packet. | ||||||||||
| public static int | Returns: number of samples per frameOpus packet. This must contain at least one byte of data. data, int sampling rate in Hz. This must be a multiple of 400, or inaccurate results will be returned. Fs)Gets the number of samples per frame from an Opus packet. | ||||||||||
| public static int | Returns: the new size of the output packet on success,BAD_ARG if len was less than 1 or new_len was less than len, or INVALID_PACKET
if data did not contain a valid Opus packetthe buffer containing the packet to pad data, int the size of the packet. This must be at least 1. len, int the desired size of the packet after padding. This must be at least as large as new_len)len.Pads a given Opus packet to a larger size (possibly changing the TOC sequence). | ||||||||||
| public static int | opus_packet_parse(ByteBuffer
Opus packet to be parsed data, ByteBuffer TOC pointer out_toc, PointerBuffer encapsulated frames frames, ShortBuffer sizes of the encapsulated frames size, IntBuffer returns the position of the payload within the packet (in bytes) payload_offset)Parses an opus packet into one or more frames. | ||||||||||
| public static int | Returns: the new size of the output packet on success,BAD_ARG if len was less than 1, or INVALID_PACKET if data did not contain a valid Opus
packetthe buffer containing the packet to strip data, int the size of the packet. This must be at least 1. len)Removes all padding from a given Opus packet and rewrite the TOC sequence to minimize space usage. | ||||||||||
| public static void | opus_pcm_soft_clip(FloatBuffer
input PCM and modified PCM pcm, int number of samples per channel to process frame_size, FloatBuffer state memory for the soft clipping process (one float per channel, initialized to zero) softclip_mem)Applies soft-clipping to bring a float signal within the | ||||||||||
| public static int | Returns: OK on success, or INVALID_PACKET if the packet did not have a valid TOC sequence, the packet's TOC sequence was not compatible with previously
submitted packets (because the coding mode, audio bandwidth, frame size, or channel count did not match), or adding this packet would increase the
total amount of audio stored in the repacketizer state to more than 120 ms.the repacketizer state to which to add the packet rp, ByteBuffer data)Adds a packet to the current repacketizer state. | ||||||||||
| public static long | opus_repacketizer_create()
Allocates memory and initializes the new repacketizer with | ||||||||||
| public static void | opus_repacketizer_destroy(long
state to be freed rp)Frees an | ||||||||||
| public static int | Returns: the total number of frames contained in the packet data submitted to the repacketizer statethe repacketizer state containing the frames rp)Returns the total number of frames contained in packet data submitted to the repacketizer state so far via | ||||||||||
| public static int | Returns: the size in bytesGets the size of an | ||||||||||
| public static long | opus_repacketizer_init(long
the repacketizer state to (re)initialize rp)(Re)initializes a previously allocated repacketizer state. | ||||||||||
| public static int | Returns: the total size of the output packet on success, orBUFFER_TOO_SMALL if maxlen was insufficient to contain the complete output packetthe repacketizer state from which to construct the new packet rp, ByteBuffer the buffer in which to store the output packet data)Constructs a new packet from data previously submitted to the repacketizer state via | ||||||||||
| public static int | Returns: the total size of the output packet on success,BAD_ARG if [begin,end) was an invalid range of frames (begin < 0,
begin >= end, or end > opus_repacketizer_get_nb_frames()), or BUFFER_TOO_SMALL if maxlen was insufficient to contain the
complete output packet.the repacketizer state from which to construct the new packet rp, int the index of the first frame in the current repacketizer state to include in the output begin, int one past the index of the last frame in the current repacketizer state to include in the output end, ByteBuffer the buffer in which to store the output packet data)Constructs a new packet from data previously submitted to the repacketizer state via | ||||||||||
| public static Opus. | OPUS_SET_APPLICATION(int
allowed values:
value)
Configures the encoder's intended application. | ||||||||||
| public static Opus. | OPUS_SET_BANDWIDTH(int
allowed values:
value)
Sets the encoder's bandpass to a specific value. | ||||||||||
| public static Opus. | OPUS_SET_BITRATE(int
bitrate in bits per second. The default is determined based on the number of channels and the input sampling rate. value)Configures the bitrate in the encoder. | ||||||||||
| public static Opus. | |||||||||||
| public static Opus. | OPUS_SET_DTX(int
allowed valued:
value)
Configures the encoder's use of discontinuous transmission (DTX). | ||||||||||
| public static Opus. | OPUS_SET_EXPERT_FRAME_DURATION(int
allowed valued:
value)
Configures the encoder's use of variable duration frames. | ||||||||||
| public static Opus. | OPUS_SET_FORCE_CHANNELS(int
allowed values:
value)
Configures mono/stereo forcing in the encoder. | ||||||||||
| public static Opus. | OPUS_SET_GAIN(int
amount to scale PCM signal by in Q8 dB units. value)Configures decoder gain adjustment. | ||||||||||
| public static Opus. | OPUS_SET_INBAND_FEC(int
allowed values:
value)
Configures the encoder's use of inband forward error correction (FEC). | ||||||||||
| public static Opus. | OPUS_SET_LSB_DEPTH(int
input precision in bits, between 8 and 24 (default: 24). value)Configures the depth of signal being encoded. | ||||||||||
| public static Opus. | OPUS_SET_MAX_BANDWIDTH(int
allowed values:
value)
Configures the maximum bandpass that the encoder will select automatically. | ||||||||||
| public static Opus. | OPUS_SET_PACKET_LOSS_PERC(int
loss percentage in the range 0-100, inclusive (default: 0) value)Configures the encoder's expected packet loss percentage. | ||||||||||
| public static Opus. | OPUS_SET_PHASE_INVERSION_DISABLED(int
allowed valued:
value)
If set to 1, disables the use of phase inversion for intensity stereo, improving the quality of mono downmixes, but slightly reducing normal stereo quality. | ||||||||||
| public static Opus. | OPUS_SET_PREDICTION_DISABLED(int
allowed valued:
value)
If set to 1, disables almost all use of prediction, making frames almost completely independent. | ||||||||||
| public static Opus. | OPUS_SET_SIGNAL(int
allowed values:
value)
Configures the type of signal being encoded. | ||||||||||
| public static Opus. | OPUS_SET_VBR(int
allowed values:
value)
Enables or disables variable bitrate (VBR) in the encoder. | ||||||||||
| public static Opus. | OPUS_SET_VBR_CONSTRAINT(int
allowed values:
value)
Enables or disables constrained VBR in the encoder. | ||||||||||
| public static String | Returns: error stringerror number error)Converts an opus error code into a human readable string. |