---
name: "opus_encoderctls"
section: "3"
platform: "linux"
package: "libopus-doc"
version: "1.5.2-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/opus_encoderctls"
---

# opus\_encoderctls(3)

Encoder related CTLs - These are convenience macros for use with the opus\_encode\_ctl interface.

## NAME

opus\_encoderctls - Encoder related CTLs

 \- These are convenience macros for use with the `opus_encode_ctl` interface.

## SYNOPSIS

### Macros

\#define **OPUS\_SET\_COMPLEXITY**(x)\
 Configures the encoder's computational complexity.  #define **OPUS\_GET\_COMPLEXITY**(x)\
 Gets the encoder's complexity configuration.  #define **OPUS\_SET\_BITRATE**(x)\
 Configures the bitrate in the encoder.  #define **OPUS\_GET\_BITRATE**(x)\
 Gets the encoder's bitrate configuration.  #define **OPUS\_SET\_VBR**(x)\
 Enables or disables variable bitrate (VBR) in the encoder.  #define **OPUS\_GET\_VBR**(x)\
 Determine if variable bitrate (VBR) is enabled in the encoder.  #define **OPUS\_SET\_VBR\_CONSTRAINT**(x)\
 Enables or disables constrained VBR in the encoder.  #define **OPUS\_GET\_VBR\_CONSTRAINT**(x)\
 Determine if constrained VBR is enabled in the encoder.  #define **OPUS\_SET\_FORCE\_CHANNELS**(x)\
 Configures mono/stereo forcing in the encoder.  #define **OPUS\_GET\_FORCE\_CHANNELS**(x)\
 Gets the encoder's forced channel configuration.  #define **OPUS\_SET\_MAX\_BANDWIDTH**(x)\
 Configures the maximum bandpass that the encoder will select automatically.  #define **OPUS\_GET\_MAX\_BANDWIDTH**(x)\
 Gets the encoder's configured maximum allowed bandpass.  #define **OPUS\_SET\_BANDWIDTH**(x)\
 Sets the encoder's bandpass to a specific value.  #define **OPUS\_SET\_SIGNAL**(x)\
 Configures the type of signal being encoded.  #define **OPUS\_GET\_SIGNAL**(x)\
 Gets the encoder's configured signal type.  #define **OPUS\_SET\_APPLICATION**(x)\
 Configures the encoder's intended application.  #define **OPUS\_GET\_APPLICATION**(x)\
 Gets the encoder's configured application.  #define **OPUS\_GET\_LOOKAHEAD**(x)\
 Gets the total samples of delay added by the entire codec.  #define **OPUS\_SET\_INBAND\_FEC**(x)\
 Configures the encoder's use of inband forward error correction (FEC).  #define **OPUS\_GET\_INBAND\_FEC**(x)\
 Gets encoder's configured use of inband forward error correction.  #define **OPUS\_SET\_PACKET\_LOSS\_PERC**(x)\
 Configures the encoder's expected packet loss percentage.  #define **OPUS\_GET\_PACKET\_LOSS\_PERC**(x)\
 Gets the encoder's configured packet loss percentage.  #define **OPUS\_SET\_DTX**(x)\
 Configures the encoder's use of discontinuous transmission (DTX).  #define **OPUS\_GET\_DTX**(x)\
 Gets encoder's configured use of discontinuous transmission.  #define **OPUS\_SET\_LSB\_DEPTH**(x)\
 Configures the depth of signal being encoded.  #define **OPUS\_GET\_LSB\_DEPTH**(x)\
 Gets the encoder's configured signal depth.  #define **OPUS\_SET\_EXPERT\_FRAME\_DURATION**(x)\
 Configures the encoder's use of variable duration frames.  #define **OPUS\_GET\_EXPERT\_FRAME\_DURATION**(x)\
 Gets the encoder's configured use of variable duration frames.  #define **OPUS\_SET\_PREDICTION\_DISABLED**(x)\
 If set to 1, disables almost all use of prediction, making frames almost completely independent.  #define **OPUS\_GET\_PREDICTION\_DISABLED**(x)\
 Gets the encoder's configured prediction status.  #define **OPUS\_SET\_DRED\_DURATION**(x)\
 If non-zero, enables Deep Redundancy (DRED) and use the specified maximum number of 10-ms redundant frames.  #define **OPUS\_GET\_DRED\_DURATION**(x)\
 Gets the encoder's configured Deep Redundancy (DRED) maximum number of frames.  #define **OPUS\_SET\_DNN\_BLOB**(data,  len)\
 Provide external DNN weights from binary object (only when explicitly built without the weights)

## Detailed Description

These are convenience macros for use with the `opus_encode_ctl` interface.

They are used to generate the appropriate series of arguments for that call, passing the correct type, size and so on as expected for each particular request.

Some usage examples:

```
int ret;
ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO));
if (ret != OPUS_OK) return ret;
opus_int32 rate;
opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate));
opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
```

**See also**

**Generic CTLs**, **Opus Encoder**

## Macro Definition Documentation

### #define OPUS\_GET\_APPLICATION(x)

Gets the encoder's configured application.

**See also**

**OPUS\_SET\_APPLICATION**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **OPUS\_APPLICATION\_VOIP**

  Process signal for improved speech intelligibility.

- **OPUS\_APPLICATION\_AUDIO**

  Favor faithfulness to the original input.

- **OPUS\_APPLICATION\_RESTRICTED\_LOWDELAY**

  Configure the minimum possible coding delay by disabling certain modes of operation.

### #define OPUS\_GET\_BITRATE(x)

Gets the encoder's bitrate configuration.

**See also**

**OPUS\_SET\_BITRATE**

**Parameters**

*x* `opus_int32 *`: Returns the bitrate in bits per second. The default is determined based on the number of channels and the input sampling rate.

### #define OPUS\_GET\_COMPLEXITY(x)

Gets the encoder's complexity configuration.

**See also**

**OPUS\_SET\_COMPLEXITY**

**Parameters**

*x* `opus_int32 *`: Returns a value in the range 0-10, inclusive.

### #define OPUS\_GET\_DRED\_DURATION(x)

Gets the encoder's configured Deep Redundancy (DRED) maximum number of frames.

### #define OPUS\_GET\_DTX(x)

Gets encoder's configured use of discontinuous transmission.

**See also**

**OPUS\_SET\_DTX**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **0**

  DTX disabled (default).

- **1**

  DTX enabled.

### #define OPUS\_GET\_EXPERT\_FRAME\_DURATION(x)

Gets the encoder's configured use of variable duration frames.

**See also**

**OPUS\_SET\_EXPERT\_FRAME\_DURATION**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **OPUS\_FRAMESIZE\_ARG**

  Select frame size from the argument (default).

- **OPUS\_FRAMESIZE\_2\_5\_MS**

  Use 2.5 ms frames.

- **OPUS\_FRAMESIZE\_5\_MS**

  Use 5 ms frames.

- **OPUS\_FRAMESIZE\_10\_MS**

  Use 10 ms frames.

- **OPUS\_FRAMESIZE\_20\_MS**

  Use 20 ms frames.

- **OPUS\_FRAMESIZE\_40\_MS**

  Use 40 ms frames.

- **OPUS\_FRAMESIZE\_60\_MS**

  Use 60 ms frames.

- **OPUS\_FRAMESIZE\_80\_MS**

  Use 80 ms frames.

- **OPUS\_FRAMESIZE\_100\_MS**

  Use 100 ms frames.

- **OPUS\_FRAMESIZE\_120\_MS**

  Use 120 ms frames.

### #define OPUS\_GET\_FORCE\_CHANNELS(x)

Gets the encoder's forced channel configuration.

**See also**

**OPUS\_SET\_FORCE\_CHANNELS**

**Parameters**

*x* `opus_int32 *`:

- **OPUS\_AUTO**

  Not forced (default)

- **1**

  Forced mono

- **2**

  Forced stereo

### #define OPUS\_GET\_INBAND\_FEC(x)

Gets encoder's configured use of inband forward error correction.

**See also**

**OPUS\_SET\_INBAND\_FEC**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **0**

  Inband FEC disabled (default).

- **1**

  Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.

- **2**

  Inband FEC enabled, but does not necessarily switch to SILK if we have music.

### #define OPUS\_GET\_LOOKAHEAD(x)

Gets the total samples of delay added by the entire codec. This can be queried by the encoder and then the provided number of samples can be skipped on from the start of the decoder's output to provide time aligned input and output. From the perspective of a decoding application the real data begins this many samples late.

The decoder contribution to this delay is identical for all decoders, but the encoder portion of the delay may vary from implementation to implementation, version to version, or even depend on the encoder's initial configuration. Applications needing delay compensation should call this CTL rather than hard-coding a value.

**Parameters**

*x* `opus_int32 *`: Number of lookahead samples

### #define OPUS\_GET\_LSB\_DEPTH(x)

Gets the encoder's configured signal depth.

**See also**

**OPUS\_SET\_LSB\_DEPTH**

**Parameters**

*x* `opus_int32 *`: Input precision in bits, between 8 and 24 (default: 24).

### #define OPUS\_GET\_MAX\_BANDWIDTH(x)

Gets the encoder's configured maximum allowed bandpass.

**See also**

**OPUS\_SET\_MAX\_BANDWIDTH**

**Parameters**

*x* `opus_int32 *`: Allowed values:

- **OPUS\_BANDWIDTH\_NARROWBAND**

  4 kHz passband

- **OPUS\_BANDWIDTH\_MEDIUMBAND**

  6 kHz passband

- **OPUS\_BANDWIDTH\_WIDEBAND**

  8 kHz passband

- **OPUS\_BANDWIDTH\_SUPERWIDEBAND**

  12 kHz passband

- **OPUS\_BANDWIDTH\_FULLBAND**

  20 kHz passband (default)

### #define OPUS\_GET\_PACKET\_LOSS\_PERC(x)

Gets the encoder's configured packet loss percentage.

**See also**

**OPUS\_SET\_PACKET\_LOSS\_PERC**

**Parameters**

*x* `opus_int32 *`: Returns the configured loss percentage in the range 0-100, inclusive (default: 0).

### #define OPUS\_GET\_PREDICTION\_DISABLED(x)

Gets the encoder's configured prediction status.

**See also**

**OPUS\_SET\_PREDICTION\_DISABLED**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **0**

  Prediction enabled (default).

- **1**

  Prediction disabled.

### #define OPUS\_GET\_SIGNAL(x)

Gets the encoder's configured signal type.

**See also**

**OPUS\_SET\_SIGNAL**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **OPUS\_AUTO**

  (default)

- **OPUS\_SIGNAL\_VOICE**

  Bias thresholds towards choosing LPC or Hybrid modes.

- **OPUS\_SIGNAL\_MUSIC**

  Bias thresholds towards choosing MDCT modes.

### #define OPUS\_GET\_VBR(x)

Determine if variable bitrate (VBR) is enabled in the encoder.

**See also**

**OPUS\_SET\_VBR**

**OPUS\_GET\_VBR\_CONSTRAINT**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **0**

  Hard CBR.

- **1**

  VBR (default). The exact type of VBR may be retrieved via **OPUS\_GET\_VBR\_CONSTRAINT**.

### #define OPUS\_GET\_VBR\_CONSTRAINT(x)

Determine if constrained VBR is enabled in the encoder.

**See also**

**OPUS\_SET\_VBR\_CONSTRAINT**

**OPUS\_GET\_VBR**

**Parameters**

*x* `opus_int32 *`: Returns one of the following values:

- **0**

  Unconstrained VBR.

- **1**

  Constrained VBR (default).

### #define OPUS\_SET\_APPLICATION(x)

Configures the encoder's intended application. The initial value is a mandatory argument to the encoder\_create function.

**See also**

**OPUS\_GET\_APPLICATION**

**Parameters**

*x* `opus_int32`: Returns one of the following values:

- **OPUS\_APPLICATION\_VOIP**

  Process signal for improved speech intelligibility.

- **OPUS\_APPLICATION\_AUDIO**

  Favor faithfulness to the original input.

- **OPUS\_APPLICATION\_RESTRICTED\_LOWDELAY**

  Configure the minimum possible coding delay by disabling certain modes of operation.

### #define OPUS\_SET\_BANDWIDTH(x)

Sets the encoder's bandpass to a specific value. This prevents the encoder from automatically selecting the bandpass based on the available bitrate. If an application knows the bandpass of the input audio it is providing, it should normally use **OPUS\_SET\_MAX\_BANDWIDTH** instead, which still gives the encoder the freedom to reduce the bandpass when the bitrate becomes too low, for better overall quality.

**See also**

**OPUS\_GET\_BANDWIDTH**

**Parameters**

*x* `opus_int32`: Allowed values:

- **OPUS\_AUTO**

  (default)

- **OPUS\_BANDWIDTH\_NARROWBAND**

  4 kHz passband

- **OPUS\_BANDWIDTH\_MEDIUMBAND**

  6 kHz passband

- **OPUS\_BANDWIDTH\_WIDEBAND**

  8 kHz passband

- **OPUS\_BANDWIDTH\_SUPERWIDEBAND**

  12 kHz passband

- **OPUS\_BANDWIDTH\_FULLBAND**

  20 kHz passband

### #define OPUS\_SET\_BITRATE(x)

Configures the bitrate in the encoder. Rates from 500 to 512000 bits per second are meaningful, as well as the special values **OPUS\_AUTO** and **OPUS\_BITRATE\_MAX**. The value **OPUS\_BITRATE\_MAX** can be used to cause the codec to use as much rate as it can, which is useful for controlling the rate by adjusting the output buffer size.

**See also**

**OPUS\_GET\_BITRATE**

**Parameters**

*x* `opus_int32`: Bitrate in bits per second. The default is determined based on the number of channels and the input sampling rate.

### #define OPUS\_SET\_COMPLEXITY(x)

Configures the encoder's computational complexity. The supported range is 0-10 inclusive with 10 representing the highest complexity.

**See also**

**OPUS\_GET\_COMPLEXITY**

**Parameters**

*x* `opus_int32`: Allowed values: 0-10, inclusive.

### #define OPUS\_SET\_DNN\_BLOB(data, len)

Provide external DNN weights from binary object (only when explicitly built without the weights)

### #define OPUS\_SET\_DRED\_DURATION(x)

If non-zero, enables Deep Redundancy (DRED) and use the specified maximum number of 10-ms redundant frames.

### #define OPUS\_SET\_DTX(x)

Configures the encoder's use of discontinuous transmission (DTX).

**Note**

This is only applicable to the LPC layer

**See also**

**OPUS\_GET\_DTX**

**Parameters**

*x* `opus_int32`: Allowed values:

- **0**

  Disable DTX (default).

- **1**

  Enabled DTX.

### #define OPUS\_SET\_EXPERT\_FRAME\_DURATION(x)

Configures the encoder's use of variable duration frames. When variable duration is enabled, the encoder is free to use a shorter frame size than the one requested in the opus\_encode\*() call. It is then the user's responsibility to verify how much audio was encoded by checking the ToC byte of the encoded packet. The part of the audio that was not encoded needs to be resent to the encoder for the next call. Do not use this option unless you **really** know what you are doing.

**See also**

**OPUS\_GET\_EXPERT\_FRAME\_DURATION**

**Parameters**

*x* `opus_int32`: Allowed values:

- **OPUS\_FRAMESIZE\_ARG**

  Select frame size from the argument (default).

- **OPUS\_FRAMESIZE\_2\_5\_MS**

  Use 2.5 ms frames.

- **OPUS\_FRAMESIZE\_5\_MS**

  Use 5 ms frames.

- **OPUS\_FRAMESIZE\_10\_MS**

  Use 10 ms frames.

- **OPUS\_FRAMESIZE\_20\_MS**

  Use 20 ms frames.

- **OPUS\_FRAMESIZE\_40\_MS**

  Use 40 ms frames.

- **OPUS\_FRAMESIZE\_60\_MS**

  Use 60 ms frames.

- **OPUS\_FRAMESIZE\_80\_MS**

  Use 80 ms frames.

- **OPUS\_FRAMESIZE\_100\_MS**

  Use 100 ms frames.

- **OPUS\_FRAMESIZE\_120\_MS**

  Use 120 ms frames.

### #define OPUS\_SET\_FORCE\_CHANNELS(x)

Configures mono/stereo forcing in the encoder. This can force the encoder to produce packets encoded as either mono or stereo, regardless of the format of the input audio. This is useful when the caller knows that the input signal is currently a mono source embedded in a stereo stream.

**See also**

**OPUS\_GET\_FORCE\_CHANNELS**

**Parameters**

*x* `opus_int32`: Allowed values:

- **OPUS\_AUTO**

  Not forced (default)

- **1**

  Forced mono

- **2**

  Forced stereo

### #define OPUS\_SET\_INBAND\_FEC(x)

Configures the encoder's use of inband forward error correction (FEC).

**Note**

This is only applicable to the LPC layer

**See also**

**OPUS\_GET\_INBAND\_FEC**

**Parameters**

*x* `opus_int32`: Allowed values:

- **0**

  Disable inband FEC (default).

- **1**

  Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.

- **2**

  Inband FEC enabled, but does not necessarily switch to SILK if we have music.

### #define OPUS\_SET\_LSB\_DEPTH(x)

Configures the depth of signal being encoded. This is a hint which helps the encoder identify silence and near-silence. It represents the number of significant bits of linear intensity below which the signal contains ignorable quantization or other noise.

For example, **OPUS\_SET\_LSB\_DEPTH(14)** would be an appropriate setting for G.711 u-law input. **OPUS\_SET\_LSB\_DEPTH(16)** would be appropriate for 16-bit linear pcm input with **opus\_encode\_float()**.

When using **opus\_encode()** instead of **opus\_encode\_float()**, or when libopus is compiled for fixed-point, the encoder uses the minimum of the value set here and the value 16.

**See also**

**OPUS\_GET\_LSB\_DEPTH**

**Parameters**

*x* `opus_int32`: Input precision in bits, between 8 and 24 (default: 24).

### #define OPUS\_SET\_MAX\_BANDWIDTH(x)

Configures the maximum bandpass that the encoder will select automatically. Applications should normally use this instead of **OPUS\_SET\_BANDWIDTH** (leaving that set to the default, **OPUS\_AUTO**). This allows the application to set an upper bound based on the type of input it is providing, but still gives the encoder the freedom to reduce the bandpass when the bitrate becomes too low, for better overall quality.

**See also**

**OPUS\_GET\_MAX\_BANDWIDTH**

**Parameters**

*x* `opus_int32`: Allowed values:

- **OPUS\_BANDWIDTH\_NARROWBAND**

  4 kHz passband

- **OPUS\_BANDWIDTH\_MEDIUMBAND**

  6 kHz passband

- **OPUS\_BANDWIDTH\_WIDEBAND**

  8 kHz passband

- **OPUS\_BANDWIDTH\_SUPERWIDEBAND**

  12 kHz passband

- **OPUS\_BANDWIDTH\_FULLBAND**

  20 kHz passband (default)

### #define OPUS\_SET\_PACKET\_LOSS\_PERC(x)

Configures the encoder's expected packet loss percentage. Higher values trigger progressively more loss resistant behavior in the encoder at the expense of quality at a given bitrate in the absence of packet loss, but greater quality under loss.

**See also**

**OPUS\_GET\_PACKET\_LOSS\_PERC**

**Parameters**

*x* `opus_int32`: Loss percentage in the range 0-100, inclusive (default: 0).

### #define OPUS\_SET\_PREDICTION\_DISABLED(x)

If set to 1, disables almost all use of prediction, making frames almost completely independent. This reduces quality.

**See also**

**OPUS\_GET\_PREDICTION\_DISABLED**

**Parameters**

*x* `opus_int32`: Allowed values:

- **0**

  Enable prediction (default).

- **1**

  Disable prediction.

### #define OPUS\_SET\_SIGNAL(x)

Configures the type of signal being encoded. This is a hint which helps the encoder's mode selection.

**See also**

**OPUS\_GET\_SIGNAL**

**Parameters**

*x* `opus_int32`: Allowed values:

- **OPUS\_AUTO**

  (default)

- **OPUS\_SIGNAL\_VOICE**

  Bias thresholds towards choosing LPC or Hybrid modes.

- **OPUS\_SIGNAL\_MUSIC**

  Bias thresholds towards choosing MDCT modes.

### #define OPUS\_SET\_VBR(x)

Enables or disables variable bitrate (VBR) in the encoder. The configured bitrate may not be met exactly because frames must be an integer number of bytes in length.

**See also**

**OPUS\_GET\_VBR**

**OPUS\_SET\_VBR\_CONSTRAINT**

**Parameters**

*x* `opus_int32`: Allowed values:

- **0**

  Hard CBR. For LPC/hybrid modes at very low bit-rate, this can cause noticeable quality degradation.

- **1**

  VBR (default). The exact type of VBR is controlled by **OPUS\_SET\_VBR\_CONSTRAINT**.

### #define OPUS\_SET\_VBR\_CONSTRAINT(x)

Enables or disables constrained VBR in the encoder. This setting is ignored when the encoder is in CBR mode.

**Warning**

Only the MDCT mode of Opus currently heeds the constraint. Speech mode ignores it completely, hybrid mode may fail to obey it if the LPC layer uses more bitrate than the constraint would have permitted.

**See also**

**OPUS\_GET\_VBR\_CONSTRAINT**

**OPUS\_SET\_VBR**

**Parameters**

*x* `opus_int32`: Allowed values:

- **0**

  Unconstrained VBR.

- **1**

  Constrained VBR (default). This creates a maximum of one frame of buffering delay assuming a transport with a serialization speed of the nominal bitrate.

## Author

Generated automatically by Doxygen for Opus from the source code.
