MLECO-3164: Additional refactoring of KWS API

Part 1
* Add KwsClassifier
* KwsPostProcess can now be told to average results
* Averaging is handlded by KwsClassifier
* Current sliding window index is now an argument of DoPreProcess

Change-Id: I07626da595ad1cbd982e8366f0d1bb56d1040459
diff --git a/source/application/api/use_case/kws/src/KwsProcessing.cc b/source/application/api/use_case/kws/src/KwsProcessing.cc
index 2d5c085..843ac58 100644
--- a/source/application/api/use_case/kws/src/KwsProcessing.cc
+++ b/source/application/api/use_case/kws/src/KwsProcessing.cc
@@ -66,9 +66,8 @@
         }
     }
 
-    bool KwsPreProcess::DoPreProcess(const void* data, size_t inputSize)
+    bool KwsPreProcess::DoPreProcess(const void* data, size_t inferenceIndex)
     {
-        UNUSED(inputSize);
         if (data == nullptr) {
             printf_err("Data pointer is null");
         }
@@ -77,8 +76,8 @@
         auto input = static_cast<const int16_t*>(data);
         this->m_mfccSlidingWindow.Reset(input);
 
-        /* Cache is only usable if we have more than 1 inference in an audio clip. */
-        bool useCache = this->m_audioWindowIndex > 0 && this->m_numReusedMfccVectors > 0;
+        /* Cache is only usable if we have more than 1 inference to do and it's not the first inference. */
+        bool useCache = inferenceIndex > 0 && this->m_numReusedMfccVectors > 0;
 
         /* Use a sliding window to calculate MFCC features frame by frame. */
         while (this->m_mfccSlidingWindow.HasNext()) {
@@ -163,7 +162,7 @@
         TfLiteQuantization quant = inputTensor->quantization;
 
         if (kTfLiteAffineQuantization == quant.type) {
-            auto *quantParams = (TfLiteAffineQuantization *) quant.params;
+            auto* quantParams = (TfLiteAffineQuantization*) quant.params;
             const float quantScale = quantParams->scale->data[0];
             const int quantOffset = quantParams->zero_point->data[0];
 
@@ -191,20 +190,22 @@
         return mfccFeatureCalc;
     }
 
-    KwsPostProcess::KwsPostProcess(TfLiteTensor* outputTensor, Classifier& classifier,
+    KwsPostProcess::KwsPostProcess(TfLiteTensor* outputTensor, KwsClassifier& classifier,
                                    const std::vector<std::string>& labels,
-                                   std::vector<ClassificationResult>& results)
+                                   std::vector<ClassificationResult>& results, size_t averagingWindowLen)
             :m_outputTensor{outputTensor},
              m_kwsClassifier{classifier},
              m_labels{labels},
              m_results{results}
-    {}
+    {
+        this->m_resultHistory = {averagingWindowLen, std::vector<float>(labels.size())};
+    }
 
     bool KwsPostProcess::DoPostProcess()
     {
         return this->m_kwsClassifier.GetClassificationResults(
                 this->m_outputTensor, this->m_results,
-                this->m_labels, 1, true);
+                this->m_labels, 1, true, this->m_resultHistory);
     }
 
 } /* namespace app */