Skip to content

how to use Opus 1.5 DRED? #376

Description

@sayakasama

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);
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions