From 617fcd2cf0352574cace66392001228bb96769a2 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> Date: Wed, 16 Mar 2011 22:11:53 -0400 Subject: [PATCH] Fixes a few PLC/DTX bugs due to the recent decode API change --- celt | 2 +- src/opus_decoder.c | 7 +++++-- src/opus_encoder.c | 3 +++ src/test_opus.c | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/celt b/celt index 6f6e8b398..1a8bf37db 160000 --- a/celt +++ b/celt @@ -1 +1 @@ -Subproject commit 6f6e8b39842a7d175e89f47e4d37ad5de8143ad2 +Subproject commit 1a8bf37dbaa461d410c101d1be302a67b4927035 diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 92a728770..63c2bacbc 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -216,8 +216,9 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, /* Shrink decoder because of raw bits */ dec.storage -= redundancy_bytes; } - start_band = 17; } + if (mode != MODE_CELT_ONLY) + start_band = 17; if (mode != MODE_SILK_ONLY) { @@ -343,7 +344,9 @@ int opus_decode(OpusDecoder *st, const unsigned char *data, unsigned char ch, toc; /* 48 x 2.5 ms = 120 ms */ short size[48]; - if (len<1) + if (len==0 || data==NULL) + return opus_decode_frame(st, NULL, 0, pcm, frame_size, 0); + else if (len<0) return CELT_BAD_ARG; st->mode = opus_packet_get_mode(data); st->bandwidth = opus_packet_get_bandwidth(data); diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 89b39eb7c..b0a22f9f8 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -293,6 +293,9 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, fprintf (stderr, "SILK encode error: %d\n", ret); /* Handle error */ } + if (nBytes==0) + return 0; + /* Extract SILK internal bandwidth for signaling in first byte */ if( st->mode == MODE_SILK_ONLY ) { if( st->silk_mode.internalSampleRate == 8000 ) { diff --git a/src/test_opus.c b/src/test_opus.c index dceed530a..f164780d7 100644 --- a/src/test_opus.c +++ b/src/test_opus.c @@ -285,13 +285,13 @@ int main(int argc, char *argv[]) #if OPUS_TEST_RANGE_CODER_STATE enc_final_range[toggle] = opus_encoder_get_final_range( enc ); #endif - if (len[toggle] <= 0) + if (len[toggle] < 0) { fprintf (stderr, "opus_encode() returned %d\n", len[toggle]); return 1; } - lost = rand()%100<packet_loss_perc; + lost = rand()%100<packet_loss_perc || len[toggle]==0; if( count >= use_inbandfec ) { /* delay by one packet when using in-band FEC */ if( use_inbandfec ) { -- GitLab