diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-01-20 15:53:26 -0500 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2023-01-20 15:53:26 -0500 |
commit | 1537f1567a3dc2476d2b2e3cd74a19aad8baf2cd (patch) | |
tree | 0d945e0f6139e1fbe0bc2995bec4d3d3dcab4e8c /src/opus_demo.c | |
parent | b2ef775ec6fa356027e9e8037b0bbf03ec923577 (diff) | |
download | opus-1537f1567a3dc2476d2b2e3cd74a19aad8baf2cd.tar.gz |
Only decode the DRED frames we need
Diffstat (limited to 'src/opus_demo.c')
-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++) { |