2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-30 09:39:08 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-11-11 20:16:11 +01:00
|
|
|
#include "webrtc/modules/audio_processing/ns/noise_suppression.h"
|
2012-09-08 00:09:26 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2013-05-28 08:11:59 +00:00
|
|
|
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
|
|
|
|
#include "webrtc/modules/audio_processing/ns/defines.h"
|
|
|
|
|
#include "webrtc/modules/audio_processing/ns/ns_core.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-06-10 21:43:36 +02:00
|
|
|
NsHandle* WebRtcNs_Create() {
|
|
|
|
|
NoiseSuppressionC* self = malloc(sizeof(NoiseSuppressionC));
|
|
|
|
|
self->initFlag = 0;
|
|
|
|
|
return (NsHandle*)self;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-10 07:56:57 +02:00
|
|
|
void WebRtcNs_Free(NsHandle* NS_inst) {
|
2011-10-05 23:36:01 +00:00
|
|
|
free(NS_inst);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
Revert 7297 "Remove the different block lengths in ns_core"
> Remove the different block lengths in ns_core
>
> This CL has bit-exact output.
>
> What it does:
> * Remove the blockLen10Ms, as it is hardcoded to be equal to blockLen.
> * This makes outLen to be always zero, so it can be removed too.
> * It also avoids the need to have an outBuf, because it is not used, so it is also removed
> * Replaced blockLen10Ms by blockLen everywhere, since they were hardcoded to be equal.
> * We don't need to check if outLen is zero, because it always is, so it was removed.
> * Of course, the outBuf needs no initial set or copying around, because it is not used.
>
> BUG=webrtc:3811
> R=bjornv@webrtc.org, kwiberg@webrtc.org
>
> Review URL: https://webrtc-codereview.appspot.com/30539004
TBR=aluebs@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/26629004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7306 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-09-26 14:33:08 +00:00
|
|
|
int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) {
|
2014-12-18 09:11:33 +00:00
|
|
|
return WebRtcNs_InitCore((NoiseSuppressionC*)NS_inst, fs);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-05 23:36:01 +00:00
|
|
|
int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) {
|
2014-12-18 09:11:33 +00:00
|
|
|
return WebRtcNs_set_policy_core((NoiseSuppressionC*)NS_inst, mode);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-10 19:30:57 +00:00
|
|
|
void WebRtcNs_Analyze(NsHandle* NS_inst, const float* spframe) {
|
2014-12-18 09:11:33 +00:00
|
|
|
WebRtcNs_AnalyzeCore((NoiseSuppressionC*)NS_inst, spframe);
|
2014-09-18 09:54:06 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2014-12-10 19:30:57 +00:00
|
|
|
void WebRtcNs_Process(NsHandle* NS_inst,
|
|
|
|
|
const float* const* spframe,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t num_bands,
|
2014-12-10 19:30:57 +00:00
|
|
|
float* const* outframe) {
|
2014-12-18 09:11:33 +00:00
|
|
|
WebRtcNs_ProcessCore((NoiseSuppressionC*)NS_inst, spframe, num_bands,
|
|
|
|
|
outframe);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2012-07-12 21:00:43 +00:00
|
|
|
|
|
|
|
|
float WebRtcNs_prior_speech_probability(NsHandle* handle) {
|
2014-12-18 09:11:33 +00:00
|
|
|
NoiseSuppressionC* self = (NoiseSuppressionC*)handle;
|
2012-07-12 21:00:43 +00:00
|
|
|
if (handle == NULL) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (self->initFlag == 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return self->priorSpeechProb;
|
|
|
|
|
}
|
2016-02-09 11:24:32 -08:00
|
|
|
|
|
|
|
|
const float* WebRtcNs_noise_estimate(const NsHandle* handle) {
|
|
|
|
|
const NoiseSuppressionC* self = (const NoiseSuppressionC*)handle;
|
|
|
|
|
if (handle == NULL || self->initFlag == 0) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
return self->noise;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t WebRtcNs_num_freq() {
|
|
|
|
|
return HALF_ANAL_BLOCKL;
|
|
|
|
|
}
|