From be68a9ae94a1f50c8c7a22f2bdd76ab12fd71a1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jes=C3=BAs=20de=20Vicente=20Pe=C3=B1a?=
 <devicentepena@webrtc.org>
Date: Tue, 11 Feb 2020 09:27:10 +0100
Subject: [PATCH] Fix for an assertion when running the fixed point tests

Signed-off-by: Felicia Lim <flim@google.com>
---
 src/opus_encoder.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index e339d3329..4a10098e8 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1152,16 +1152,18 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
     if (!is_silence)
       st->voice_ratio = -1;
 
-    if (analysis_info.valid) {
-       activity = !is_silence &&
-              analysis_info.activity_probability >= DTX_ACTIVITY_THRESHOLD;
-       if (!activity) {
-          opus_val32 noise_energy = compute_frame_energy(pcm, frame_size, st->channels, st->arch);
-          /* do not mark as active unless is sufficiently quiet */
-          activity = st->peak_signal_energy < (PSEUDO_SNR_THRESHOLD * noise_energy);
-       }
-    } else {
+    if (is_silence)
+    {
        activity = !is_silence;
+    } else if (analysis_info.valid)
+    {
+       activity = analysis_info.activity_probability >= DTX_ACTIVITY_THRESHOLD;
+       if (!activity)
+       {
+           /* Mark as active if this noise frame is sufficiently loud */
+           opus_val32 noise_energy = compute_frame_energy(pcm, frame_size, st->channels, st->arch);
+           activity = st->peak_signal_energy < (PSEUDO_SNR_THRESHOLD * noise_energy);
+       }
     }
 
     st->detected_bandwidth = 0;
-- 
GitLab