1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_WINDOW_H_
16 #define TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_WINDOW_H_
17 
18 #include <stdint.h>
19 #include <stdlib.h>
20 
21 #define kFrontendWindowBits 12
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 struct WindowState {
28   size_t size;
29   int16_t* coefficients;
30   size_t step;
31 
32   int16_t* input;
33   size_t input_used;
34   int16_t* output;
35   int16_t max_abs_output_value;
36 };
37 
38 // Applies a window to the samples coming in, stepping forward at the given
39 // rate.
40 int WindowProcessSamples(struct WindowState* state, const int16_t* samples,
41                          size_t num_samples, size_t* num_samples_read);
42 
43 void WindowReset(struct WindowState* state);
44 
45 #ifdef __cplusplus
46 }  // extern "C"
47 #endif
48 
49 #endif  // TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_WINDOW_H_
50