Improve silence handling
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 13 Feb 2019 18:33:42 +0000 (13:33 -0500)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 13 Feb 2019 21:52:52 +0000 (16:52 -0500)
Copy the previous analysis data instead of flagging as invalid

src/analysis.c

index 23bae42..cb46dec 100644 (file)
@@ -547,7 +547,11 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
     tonal->mem_fill = 240 + remaining;
     if (is_silence)
     {
-       info->valid = 0;
+       /* On silence, copy the previous analysis. */
+       int prev_pos = tonal->write_pos-2;
+       if (prev_pos < 0)
+          prev_pos += DETECT_SIZE;
+       OPUS_COPY(info, &tonal->info[prev_pos], 1);
        RESTORE_STACK;
        return;
     }