Opus: Generic CTLs

Opus audio codec (RFC 6716): API and operations manual
| 1.2

Loading...
Searching...
No Matches
Generic CTLs

These macros are used with the `opus_decoder_ctl` and `opus_encoder_ctl` calls to generate a particular request. More...

## Macros
#define | OPUS_RESET_STATE
| Resets the codec state to be equivalent to a freshly initialized state.
#define | OPUS_GET_FINAL_RANGE(x)
| Gets the final state of the codec's entropy coder.
#define | OPUS_GET_BANDWIDTH(x)
| Gets the encoder's configured bandpass or the decoder's last bandpass.
#define | OPUS_GET_SAMPLE_RATE(x)
| Gets the sampling rate the encoder or decoder was initialized with.
#define | OPUS_SET_PHASE_INVERSION_DISABLED(x)
| 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.
#define | OPUS_GET_PHASE_INVERSION_DISABLED(x)
| Gets the encoder's configured phase inversion status.

## Detailed Description

These macros are used with the `opus_decoder_ctl` and `opus_encoder_ctl` calls to generate a particular request.

When called on an `OpusDecoder` they apply to that particular decoder instance. When called on an `OpusEncoder` they apply to the corresponding setting on that encoder instance, if present.

Some usage examples:

int ret;
opus_int32 pitch;
ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch));
if (ret == OPUS_OK) return ret;
opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE);
opus_int32 enc_bw, dec_bw;
opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw));
opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw));
if (enc_bw != dec_bw) {
printf("packet bandwidth mismatch!\n");
}
opus_decoder_ctl
int opus_decoder_ctl(OpusDecoder *st, int request,...)
Perform a CTL function on an Opus decoder.
OPUS_GET_PITCH
#define OPUS_GET_PITCH(x)
Gets the pitch of the last decoded frame, if available.
Definition opus_defines.h:755
opus_encoder_ctl
int opus_encoder_ctl(OpusEncoder *st, int request,...)
Perform a CTL function on an Opus encoder.
OPUS_OK
#define OPUS_OK
No error.
Definition opus_defines.h:46
OPUS_GET_BANDWIDTH
#define OPUS_GET_BANDWIDTH(x)
Gets the encoder's configured bandpass or the decoder's last bandpass.
Definition opus_defines.h:682
OPUS_RESET_STATE
#define OPUS_RESET_STATE
Resets the codec state to be equivalent to a freshly initialized state.
Definition opus_defines.h:658
opus_int32
int opus_int32
Definition opus_types.h:146

See also
  Opus Encoder, opus_decoder_ctl, opus_encoder_ctl, Decoder related CTLs, Encoder related CTLs

## Macro Definition Documentation

## ◆ OPUS_GET_BANDWIDTH

#define OPUS_GET_BANDWIDTH | ( |  | x | ) |

Gets the encoder's configured bandpass or the decoder's last bandpass.

See also
  OPUS_SET_BANDWIDTH

Parameters

  [out] | x | opus_int32 *: Returns one of the following 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

## ◆ OPUS_GET_FINAL_RANGE

#define OPUS_GET_FINAL_RANGE | ( |  | x | ) |

Gets the final state of the codec's entropy coder.

This is used for testing purposes, The encoder and decoder state should be identical after coding a payload (assuming no data corruption or software bugs)

Parameters

  [out] | x | opus_uint32 *: Entropy coder state

## ◆ OPUS_GET_PHASE_INVERSION_DISABLED

#define OPUS_GET_PHASE_INVERSION_DISABLED | ( |  | x | ) |

Gets the encoder's configured phase inversion status.

See also
  OPUS_SET_PHASE_INVERSION_DISABLED

Parameters

  [out] | x | opus_int32 *: Returns one of the following values: 0 Stereo phase inversion enabled (default). 1 Stereo phase inversion disabled.

## ◆ OPUS_GET_SAMPLE_RATE

#define OPUS_GET_SAMPLE_RATE | ( |  | x | ) |

Gets the sampling rate the encoder or decoder was initialized with.

This simply returns the `Fs` value passed to opus_encoder_init() or opus_decoder_init().

Parameters

  [out] | x | opus_int32 *: Sampling rate of encoder or decoder.

## ◆ OPUS_RESET_STATE

#define OPUS_RESET_STATE

Resets the codec state to be equivalent to a freshly initialized state.

This should be called when switching streams in order to prevent the back to back decoding from giving different results from one at a time decoding.

## ◆ OPUS_SET_PHASE_INVERSION_DISABLED

#define OPUS_SET_PHASE_INVERSION_DISABLED | ( |  | x | ) |

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.

Disabling phase inversion in the decoder does not comply with RFC 6716, although it does not cause any interoperability issue and is expected to become part of the Opus standard once RFC 6716 is updated by draft-ietf-codec-opus-update.

See also
  OPUS_GET_PHASE_INVERSION_DISABLED

Parameters

  [in] | x | opus_int32: Allowed values: 0 Enable phase inversion (default). 1 Disable phase inversion.

- Generated by 1.17.0