xiph / xiph/opus

how to use Opus 1.5 DRED?

Open
#376 3 comments 2 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

I tried to use the DRED of opus 1.5 in my real-time intercom software, and used the way in the demo to simulate the packet loss.
I observed the log and found that when I started to speak, and there was packet loss, the normal call [opus_dred_parse], its return value has always been 0, so the decoder will only call [opus_decode].
However when I stop talking, the [opus_dred_parse] will return a positive number, and then use [opus_ decoder_dred_decode] to decode the packet, I don't understand why, is this the right situation? thanks!

 lost = (packet_loss_perc>0) && (rand()%100 < packet_loss_perc);
        }
        if (len == 0) lost = 1;
        if (lost)
        {
           lost_count++;
           run_decoder = 0;
        } else {
           run_decoder= 1;
        }
        if (run_decoder)
            run_decoder += lost_count;
        if (!lost && lost_count > 0) {
            opus_int32 output_samples=0;
            opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples));
            dred_input = lost_count*output_samples;
            /* Only decode the amount we need to fill in the gap. */
            ret = opus_dred_parse(dred_dec, dred, data, len, IMIN(48000, IMAX(0, dred_input)), sampling_rate, &dred_end, 0);
            dred_input = ret > 0 ? ret : 0;
        }
        /* FIXME: Figure out how to trigger the decoder when the last packet of the file is lost. */
        for (fr=0;fr<run_decoder;fr++) {
            opus_int32 output_samples=0;
            if (fr == lost_count-1 && opus_packet_has_lbrr(data, len)) {
               opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples));
               output_samples = opus_decode(dec, data, len, out, output_samples, 1);
            } else if (fr < lost_count) {
               opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples));
               if (dred_input > 0)
                  output_samples = opus_decoder_dred_decode(dec, dred, (lost_count-fr)*output_samples, out, output_samples);
               else
                  output_samples = opus_decode(dec, NULL, 0, out, output_samples, 0);
            } else {
               output_samples = max_frame_size;
               output_samples = opus_decode(dec, data, len, out, output_samples, 0);
            }

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 with the DRED demo flow and the shown calls to opus_dred_parse, opus_decoder_dred_decode, and opus_decode. Trace the packet-loss and speech-start/stop paths, then compare the observed return values with the decoder's expected behavior. Done means documenting whether this sequence is correct or identifying a reproducible defect and its relevant test coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.