xiph / xiph/opus

OPUS_GET_BITRATE always returns default value for opus_multistream_encoder

Open
#175 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
3.3k
Forks
808
PR merge metrics
No merged PRs in 30d

Description

When I call the OPUS_GET_BITRATE control on a multistream encoder, it always returns the default value, e.g. 144000 for 2 channels at 48 kHz

int32_t bitrate = 64000; // could also be OPUS_BITRATE_MAX

opus_multistream_encoder_ctl(state, OPUS_SET_BITRATE(bitrate));

 // always returns the default...
opus_multistream_encoder_ctl(state, OPUS_GET_BITRATE(&bitrate));

other controls like OPUS_GET_COMPLEXITY or OPUS_GET_SIGNAL work as expected.

Here's the reason:

opus_multistream_encoder has a dedicated field bitrate_bps and OPUS_SET_BITRATE sets it as expected. OPUS_GET_BITRATE, however, internally calls opus_encoder_ctl on the sub-states, which gets the value of user_bitrate_bps. Since the latter is initialized to OPUS_AUTO and never overriden, it would always return the value of the default bitrate.

Not sure what's the best approach to fix this...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at opus_multistream_encoder_ctl and trace the OPUS_SET_BITRATE and OPUS_GET_BITRATE paths into opus_encoder_ctl. Compare the multistream encoder's bitrate_bps with the sub-state user_bitrate_bps behavior. Done means the getter reports the bitrate previously set on a multistream encoder, including OPUS_BITRATE_MAX, rather than the default value.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.