diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-06-06 01:05:33 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2023-06-06 01:05:33 +0300 |
commit | b767c4c4429a1b51071cc4bc02f0ee4a36404699 (patch) | |
tree | 941d4e917a9ed298d46162a5643a65bce3934f21 | |
parent | 285f1c12f45bab66890773017096a2da6dc1bfdb (diff) |
Fix units for dred_offset in API
-rw-r--r-- | src/opus_decoder.c | 2 | ||||
-rw-r--r-- | src/opus_demo.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 9091fbb0..8f5e9682 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -669,7 +669,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, /* if blend==0, the last PLC call was "update" and we need to feed two extra 10-ms frames. */ if (st->lpcnet.blend == 0) needed_feature_frames+=2; for (i=0;i<needed_feature_frames;i++) { - int feature_offset = (needed_feature_frames-i-1 + (dred_offset/(st->Fs/100)-1)*features_per_frame); + int feature_offset = (needed_feature_frames-i-1 + (dred_offset/(st->Fs/100)-2)); if (feature_offset <= 4*dred->nb_latents-1) { lpcnet_plc_fec_add(&st->lpcnet, dred->fec_features+feature_offset*DRED_NUM_FEATURES); } else { diff --git a/src/opus_demo.c b/src/opus_demo.c index 7594c5cc..563d3c5b 100644 --- a/src/opus_demo.c +++ b/src/opus_demo.c @@ -854,9 +854,9 @@ int main(int argc, char *argv[]) opus_int32 output_samples=0; int dred_input; opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples)); - dred_input = lost_count*output_samples*100/sampling_rate; + dred_input = lost_count*output_samples; /* Only decode the amount we need to fill in the gap. */ - opus_dred_parse(dred_dec, dred, data, len, IMIN(100, IMAX(0, dred_input))*480, 48000, 0); + opus_dred_parse(dred_dec, dred, data, len, IMIN(48000, IMAX(0, dred_input)), sampling_rate, 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++) { @@ -866,7 +866,7 @@ int main(int argc, char *argv[]) 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)); - output_samples = opus_decoder_dred_decode(dec, dred, (lost_count-fr)*sampling_rate/100, out, output_samples); + output_samples = opus_decoder_dred_decode(dec, dred, (lost_count-fr)*output_samples, out, output_samples); } else { output_samples = max_frame_size; output_samples = opus_decode(dec, data, len, out, output_samples, 0); |