diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-01-20 23:53:26 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2023-06-16 20:01:28 +0300 |
commit | f1db6b9d75574ba292c75fdfee3eeda19745f73e (patch) | |
tree | 9e13ac9ff7a7813c5c5715db9adf022440b9ca71 /src | |
parent | 094eaf8bf887284e1ee05617f3effc2c17918ce9 (diff) |
Only decode the DRED frames we need
Diffstat (limited to 'src')
-rw-r--r-- | src/opus_demo.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/opus_demo.c b/src/opus_demo.c index af5e30f3..54249b5f 100644 --- a/src/opus_demo.c +++ b/src/opus_demo.c @@ -796,7 +796,12 @@ int main(int argc, char *argv[]) if (run_decoder) run_decoder += lost_count; if (!lost && lost_count > 0) { - opus_decoder_dred_input(dec, data, len, 100); + 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; + /* Only decode the amount we need to fill in the gap. */ + opus_decoder_dred_input(dec, data, len, IMIN(100, IMAX(0, dred_input))); } /* FIXME: Figure out how to trigger the decoder when the last packet of the file is lost. */ for (fr=0;fr<run_decoder;fr++) { |