• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include <stdlib.h>
12 #include <string.h>
13 
14 #include "noise_suppression_x.h"
15 #include "nsx_core.h"
16 #include "nsx_defines.h"
17 
WebRtcNsx_get_version(char * versionStr,short length)18 int WebRtcNsx_get_version(char *versionStr, short length)
19 {
20     const char version[] = "NS\t3.1.0";
21     const short versionLen = (short)strlen(version) + 1; // +1 for null-termination
22 
23     if (versionStr == NULL)
24     {
25         return -1;
26     }
27 
28     if (versionLen > length)
29     {
30         return -1;
31     }
32 
33     strncpy(versionStr, version, versionLen);
34 
35     return 0;
36 }
37 
WebRtcNsx_Create(NsxHandle ** nsxInst)38 int WebRtcNsx_Create(NsxHandle **nsxInst)
39 {
40     *nsxInst = (NsxHandle*)malloc(sizeof(NsxInst_t));
41     if (*nsxInst != NULL)
42     {
43         (*(NsxInst_t**)nsxInst)->initFlag = 0;
44         return 0;
45     } else
46     {
47         return -1;
48     }
49 
50 }
51 
WebRtcNsx_Free(NsxHandle * nsxInst)52 int WebRtcNsx_Free(NsxHandle *nsxInst)
53 {
54     free(nsxInst);
55     return 0;
56 }
57 
WebRtcNsx_Init(NsxHandle * nsxInst,WebRtc_UWord32 fs)58 int WebRtcNsx_Init(NsxHandle *nsxInst, WebRtc_UWord32 fs)
59 {
60     return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs);
61 }
62 
WebRtcNsx_set_policy(NsxHandle * nsxInst,int mode)63 int WebRtcNsx_set_policy(NsxHandle *nsxInst, int mode)
64 {
65     return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode);
66 }
67 
WebRtcNsx_Process(NsxHandle * nsxInst,short * speechFrame,short * speechFrameHB,short * outFrame,short * outFrameHB)68 int WebRtcNsx_Process(NsxHandle *nsxInst, short *speechFrame, short *speechFrameHB,
69                       short *outFrame, short *outFrameHB)
70 {
71     return WebRtcNsx_ProcessCore((NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame,
72                               outFrameHB);
73 }
74 
75