Fix opus - #23
Open
anzz1 wants to merge 2 commits into
Open
Conversation
anzz1
force-pushed
the
patch-1
branch
2 times, most recently
from
February 9, 2025 19:40
276d483 to
0360f9f
Compare
Author
|
I realize now that the wrong implementation of DTX is reverse-engineered from steam's, so it's their wrong implementation. The decoder does implement PLC correctly though, so when the DTX is corrected on the sender's side, even though it doesn't match steam's, it does work correctly. |
belomaxorka
added a commit
to belomaxorka/ReVoice
that referenced
this pull request
Jul 4, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sending 0 sized payload is not how DTX is implemented in Opus
Instead
opus_encodecan return 1 for maximum of MAX_CONSECUTIVE_DTX frames and it means to transmit nothingAfter 10 frames not sent, the 11th frame is not empty but encoded silence frame. Then 10 frames not sent again.
ref: https://www.opus-codec.org/docs/html_api/group__opusencoder.html
If the return value is 1 byte, then the packet does not need to be transmitted (DTX).Receiving end use
opus_decodewith packet loss concealment generating silence with (0, 0) parameters like already implemented, as the DTX packets are "lost".So
MAX_PACKET_LOSSmust align withMAX_CONSECUTIVE_DTXAlso Opus Compress function was non-functioning,
psReadneeds to be advanced forFRAME_SIZE*2when you readFRAME_SIZE*2, notMAX_FRAME_SIZE. But it currently isn't used.Open Questions
There is currently a strange situation with codecs which doesn't really make sense
Currently only two types of client are detected, "speex" and "opus". Not silk, but its still used for compression but not decompression, for which opus is used.
"opus" clients are determined by sv_version cvar engine build >4554 (which also could be silk clients?).
Check the following chart
sender: "vct_speex"
-> for "vct_opus" clients transcoded to Silk -> can be heard by as long as support Silk
->passed as-is to "vct_speex" clients.
sender: "vct_silk"
-> for "opus" gets passed as-is -> can be heard by "vct_opus" client as long as support Silk
-> not transcoded, can't be heard by "vct_speex" clients.
sender: "vct_opus"
-> for "vct_opus" gets passed as-is -> can be heard by "vct_opus" client as long as support Opus_PLC
-> transcoded to Speex for "speex" clients.
So if aim was to use Silk for compatibility purposes, it doesn't quite hit the mark right now.
Because Silk clients are not detected (or detected as "opus"), nor are their packets transcoded to Speex.
Also I don't know if such client version exist with only Opus_PLC support, but those would only be able to speak to Speex/Opus, but only hear other Opus due to their packets received properly as Opus_PLC but when packets are sent to them, Silk is used.
receiver ↓
Again at least up-to-date Steam clients support both silk and opus_plc so it's not a problem for those clients, but it still doesn't make sense.
I think for maximum compatibility you should either always compress to Silk, which can be heard by all clients supporting Silk.
But if Silk is not to be used, like currently their speech is skipped for Speex clients, shouldn't the compression use opus_PLC like the decompression does?