Replace scoped_ptr with unique_ptr in webrtc/modules/audio_processing/vad/

BUG=webrtc:5520

Review URL: https://codereview.webrtc.org/1699003002

Cr-Commit-Position: refs/heads/master@{#11657}
This commit is contained in:
kwiberg
2016-02-17 07:59:48 -08:00
committed by Commit bot
parent a293ef0618
commit dabf07f477
9 changed files with 26 additions and 20 deletions

View File

@ -11,6 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_COMMON_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_COMMON_H_
#include <stddef.h>
static const int kSampleRateHz = 16000;
static const size_t kLength10Ms = kSampleRateHz / 100;
static const size_t kMaxNumFrames = 4;

View File

@ -11,7 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_
#include "webrtc/base/scoped_ptr.h"
#include <memory>
#include "webrtc/modules/audio_processing/vad/common.h"
#include "webrtc/modules/audio_processing/vad/gmm.h"
#include "webrtc/typedefs.h"
@ -50,7 +51,7 @@ class PitchBasedVad {
double p_prior_;
rtc::scoped_ptr<VadCircularBuffer> circular_buffer_;
std::unique_ptr<VadCircularBuffer> circular_buffer_;
};
} // namespace webrtc

View File

@ -13,8 +13,9 @@
#include <math.h>
#include <stdio.h>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/audio_processing/vad/vad_audio_proc_internal.h"
#include "webrtc/test/testsupport/fileutils.h"
@ -58,7 +59,7 @@ class PoleZeroFilterTest : public ::testing::Test {
private:
void TestClean();
rtc::scoped_ptr<PoleZeroFilter> my_filter_;
std::unique_ptr<PoleZeroFilter> my_filter_;
};
void PoleZeroFilterTest::FilterSubframes(int num_subframes) {

View File

@ -11,7 +11,6 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/audio_processing/vad/common.h"
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
#include "webrtc/typedefs.h"

View File

@ -12,15 +12,16 @@
#include <string.h>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/test/testsupport/fileutils.h"
namespace webrtc {
TEST(StandaloneVadTest, Api) {
rtc::scoped_ptr<StandaloneVad> vad(StandaloneVad::Create());
std::unique_ptr<StandaloneVad> vad(StandaloneVad::Create());
int16_t data[kLength10Ms] = {0};
// Valid frame length (for 32 kHz rate), but not what the VAD is expecting.
@ -59,7 +60,7 @@ TEST(StandaloneVadTest, DISABLED_ActivityDetection) {
#else
TEST(StandaloneVadTest, ActivityDetection) {
#endif
rtc::scoped_ptr<StandaloneVad> vad(StandaloneVad::Create());
std::unique_ptr<StandaloneVad> vad(StandaloneVad::Create());
const size_t kDataLength = kLength10Ms;
int16_t data[kDataLength] = {0};

View File

@ -11,7 +11,8 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_AUDIO_PROC_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_AUDIO_PROC_H_
#include "webrtc/base/scoped_ptr.h"
#include <memory>
#include "webrtc/modules/audio_processing/vad/common.h"
#include "webrtc/typedefs.h"
@ -79,9 +80,9 @@ class VadAudioProc {
double log_old_gain_;
double old_lag_;
rtc::scoped_ptr<PitchAnalysisStruct> pitch_analysis_handle_;
rtc::scoped_ptr<PreFiltBankstr> pre_filter_handle_;
rtc::scoped_ptr<PoleZeroFilter> high_pass_filter_;
std::unique_ptr<PitchAnalysisStruct> pitch_analysis_handle_;
std::unique_ptr<PreFiltBankstr> pre_filter_handle_;
std::unique_ptr<PoleZeroFilter> high_pass_filter_;
};
} // namespace webrtc

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_CIRCULAR_BUFFER_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_CIRCULAR_BUFFER_H_
#include "webrtc/base/scoped_ptr.h"
#include <memory>
namespace webrtc {
@ -58,7 +58,7 @@ class VadCircularBuffer {
// corresponding linear index.
int ConvertToLinearIndex(int* index) const;
rtc::scoped_ptr<double[]> buffer_;
std::unique_ptr<double[]> buffer_;
bool is_full_;
int index_;
int buffer_size_;

View File

@ -12,8 +12,9 @@
#include <stdio.h>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
namespace webrtc {
@ -44,7 +45,7 @@ static void InsertZeros(int num_zeros, VadCircularBuffer* circular_buffer) {
}
TEST(VadCircularBufferTest, GeneralTest) {
rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
std::unique_ptr<VadCircularBuffer> circular_buffer(
VadCircularBuffer::Create(kShortBuffSize));
double mean_val;
@ -72,7 +73,7 @@ TEST(VadCircularBufferTest, GeneralTest) {
}
TEST(VadCircularBufferTest, TransientsRemoval) {
rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
std::unique_ptr<VadCircularBuffer> circular_buffer(
VadCircularBuffer::Create(kLongBuffSize));
// Let the first transient be in wrap-around.
InsertZeros(kLongBuffSize - kWidthThreshold / 2, circular_buffer.get());
@ -91,7 +92,7 @@ TEST(VadCircularBufferTest, TransientsRemoval) {
}
TEST(VadCircularBufferTest, TransientDetection) {
rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
std::unique_ptr<VadCircularBuffer> circular_buffer(
VadCircularBuffer::Create(kLongBuffSize));
// Let the first transient be in wrap-around.
int num_insertion = kLongBuffSize - kWidthThreshold / 2;

View File

@ -11,9 +11,9 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
#include <memory>
#include <vector>
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/resampler/include/resampler.h"
#include "webrtc/modules/audio_processing/vad/vad_audio_proc.h"
#include "webrtc/modules/audio_processing/vad/common.h"
@ -58,7 +58,7 @@ class VoiceActivityDetector {
Resampler resampler_;
VadAudioProc audio_processing_;
rtc::scoped_ptr<StandaloneVad> standalone_vad_;
std::unique_ptr<StandaloneVad> standalone_vad_;
PitchBasedVad pitch_based_vad_;
int16_t resampled_[kLength10Ms];