Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2023-10-15 06:19:28 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-10-15 06:19:28 +0300
commit98726c4ca61ddfb691e7fc2dff26d9e51e7fffaa (patch)
tree7aa7af2dc78fb15739307e107d47478d322464f5
parentcbd3a80552a918e71ced43e7e2af35092a170629 (diff)
Fix PLC in opus_demo when DRED is not present
-rw-r--r--src/opus_demo.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/opus_demo.c b/src/opus_demo.c
index b48845c9..66c7492a 100644
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -835,6 +835,7 @@ int main(int argc, char *argv[])
} else {
int fr;
int run_decoder;
+ int dred_input=0;
if (packet_loss_file != NULL) {
if ( fscanf(packet_loss_file, "%d", &lost) != 1) {
lost = 0;
@@ -854,11 +855,11 @@ int main(int argc, char *argv[])
run_decoder += lost_count;
if (!lost && lost_count > 0) {
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;
/* Only decode the amount we need to fill in the gap. */
- opus_dred_parse(dred_dec, dred, data, len, IMIN(48000, IMAX(0, dred_input)), sampling_rate, 0);
+ ret = opus_dred_parse(dred_dec, dred, data, len, IMIN(48000, IMAX(0, dred_input)), sampling_rate, 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++) {
@@ -868,7 +869,10 @@ 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)*output_samples, out, 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);