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:
@ -11,6 +11,8 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_COMMON_H_
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_COMMON_H_
|
||||||
#define 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 int kSampleRateHz = 16000;
|
||||||
static const size_t kLength10Ms = kSampleRateHz / 100;
|
static const size_t kLength10Ms = kSampleRateHz / 100;
|
||||||
static const size_t kMaxNumFrames = 4;
|
static const size_t kMaxNumFrames = 4;
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_PITCH_BASED_VAD_H_
|
||||||
#define 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/common.h"
|
||||||
#include "webrtc/modules/audio_processing/vad/gmm.h"
|
#include "webrtc/modules/audio_processing/vad/gmm.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
@ -50,7 +51,7 @@ class PitchBasedVad {
|
|||||||
|
|
||||||
double p_prior_;
|
double p_prior_;
|
||||||
|
|
||||||
rtc::scoped_ptr<VadCircularBuffer> circular_buffer_;
|
std::unique_ptr<VadCircularBuffer> circular_buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -13,8 +13,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#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/modules/audio_processing/vad/vad_audio_proc_internal.h"
|
||||||
#include "webrtc/test/testsupport/fileutils.h"
|
#include "webrtc/test/testsupport/fileutils.h"
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ class PoleZeroFilterTest : public ::testing::Test {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void TestClean();
|
void TestClean();
|
||||||
rtc::scoped_ptr<PoleZeroFilter> my_filter_;
|
std::unique_ptr<PoleZeroFilter> my_filter_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PoleZeroFilterTest::FilterSubframes(int num_subframes) {
|
void PoleZeroFilterTest::FilterSubframes(int num_subframes) {
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_
|
||||||
#define 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/modules/audio_processing/vad/common.h"
|
||||||
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
|
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|||||||
@ -12,15 +12,16 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "webrtc/base/scoped_ptr.h"
|
|
||||||
#include "webrtc/modules/include/module_common_types.h"
|
#include "webrtc/modules/include/module_common_types.h"
|
||||||
#include "webrtc/test/testsupport/fileutils.h"
|
#include "webrtc/test/testsupport/fileutils.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
TEST(StandaloneVadTest, Api) {
|
TEST(StandaloneVadTest, Api) {
|
||||||
rtc::scoped_ptr<StandaloneVad> vad(StandaloneVad::Create());
|
std::unique_ptr<StandaloneVad> vad(StandaloneVad::Create());
|
||||||
int16_t data[kLength10Ms] = {0};
|
int16_t data[kLength10Ms] = {0};
|
||||||
|
|
||||||
// Valid frame length (for 32 kHz rate), but not what the VAD is expecting.
|
// Valid frame length (for 32 kHz rate), but not what the VAD is expecting.
|
||||||
@ -59,7 +60,7 @@ TEST(StandaloneVadTest, DISABLED_ActivityDetection) {
|
|||||||
#else
|
#else
|
||||||
TEST(StandaloneVadTest, ActivityDetection) {
|
TEST(StandaloneVadTest, ActivityDetection) {
|
||||||
#endif
|
#endif
|
||||||
rtc::scoped_ptr<StandaloneVad> vad(StandaloneVad::Create());
|
std::unique_ptr<StandaloneVad> vad(StandaloneVad::Create());
|
||||||
const size_t kDataLength = kLength10Ms;
|
const size_t kDataLength = kLength10Ms;
|
||||||
int16_t data[kDataLength] = {0};
|
int16_t data[kDataLength] = {0};
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,8 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_AUDIO_PROC_H_
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_AUDIO_PROC_H_
|
||||||
#define 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/modules/audio_processing/vad/common.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
@ -79,9 +80,9 @@ class VadAudioProc {
|
|||||||
double log_old_gain_;
|
double log_old_gain_;
|
||||||
double old_lag_;
|
double old_lag_;
|
||||||
|
|
||||||
rtc::scoped_ptr<PitchAnalysisStruct> pitch_analysis_handle_;
|
std::unique_ptr<PitchAnalysisStruct> pitch_analysis_handle_;
|
||||||
rtc::scoped_ptr<PreFiltBankstr> pre_filter_handle_;
|
std::unique_ptr<PreFiltBankstr> pre_filter_handle_;
|
||||||
rtc::scoped_ptr<PoleZeroFilter> high_pass_filter_;
|
std::unique_ptr<PoleZeroFilter> high_pass_filter_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_CIRCULAR_BUFFER_H_
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VAD_CIRCULAR_BUFFER_H_
|
||||||
#define 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 {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class VadCircularBuffer {
|
|||||||
// corresponding linear index.
|
// corresponding linear index.
|
||||||
int ConvertToLinearIndex(int* index) const;
|
int ConvertToLinearIndex(int* index) const;
|
||||||
|
|
||||||
rtc::scoped_ptr<double[]> buffer_;
|
std::unique_ptr<double[]> buffer_;
|
||||||
bool is_full_;
|
bool is_full_;
|
||||||
int index_;
|
int index_;
|
||||||
int buffer_size_;
|
int buffer_size_;
|
||||||
|
|||||||
@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "webrtc/base/scoped_ptr.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ static void InsertZeros(int num_zeros, VadCircularBuffer* circular_buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(VadCircularBufferTest, GeneralTest) {
|
TEST(VadCircularBufferTest, GeneralTest) {
|
||||||
rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
|
std::unique_ptr<VadCircularBuffer> circular_buffer(
|
||||||
VadCircularBuffer::Create(kShortBuffSize));
|
VadCircularBuffer::Create(kShortBuffSize));
|
||||||
double mean_val;
|
double mean_val;
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ TEST(VadCircularBufferTest, GeneralTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(VadCircularBufferTest, TransientsRemoval) {
|
TEST(VadCircularBufferTest, TransientsRemoval) {
|
||||||
rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
|
std::unique_ptr<VadCircularBuffer> circular_buffer(
|
||||||
VadCircularBuffer::Create(kLongBuffSize));
|
VadCircularBuffer::Create(kLongBuffSize));
|
||||||
// Let the first transient be in wrap-around.
|
// Let the first transient be in wrap-around.
|
||||||
InsertZeros(kLongBuffSize - kWidthThreshold / 2, circular_buffer.get());
|
InsertZeros(kLongBuffSize - kWidthThreshold / 2, circular_buffer.get());
|
||||||
@ -91,7 +92,7 @@ TEST(VadCircularBufferTest, TransientsRemoval) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(VadCircularBufferTest, TransientDetection) {
|
TEST(VadCircularBufferTest, TransientDetection) {
|
||||||
rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
|
std::unique_ptr<VadCircularBuffer> circular_buffer(
|
||||||
VadCircularBuffer::Create(kLongBuffSize));
|
VadCircularBuffer::Create(kLongBuffSize));
|
||||||
// Let the first transient be in wrap-around.
|
// Let the first transient be in wrap-around.
|
||||||
int num_insertion = kLongBuffSize - kWidthThreshold / 2;
|
int num_insertion = kLongBuffSize - kWidthThreshold / 2;
|
||||||
|
|||||||
@ -11,9 +11,9 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
|
||||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
|
#define WEBRTC_MODULES_AUDIO_PROCESSING_VAD_VOICE_ACTIVITY_DETECTOR_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "webrtc/base/scoped_ptr.h"
|
|
||||||
#include "webrtc/common_audio/resampler/include/resampler.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/vad_audio_proc.h"
|
||||||
#include "webrtc/modules/audio_processing/vad/common.h"
|
#include "webrtc/modules/audio_processing/vad/common.h"
|
||||||
@ -58,7 +58,7 @@ class VoiceActivityDetector {
|
|||||||
Resampler resampler_;
|
Resampler resampler_;
|
||||||
VadAudioProc audio_processing_;
|
VadAudioProc audio_processing_;
|
||||||
|
|
||||||
rtc::scoped_ptr<StandaloneVad> standalone_vad_;
|
std::unique_ptr<StandaloneVad> standalone_vad_;
|
||||||
PitchBasedVad pitch_based_vad_;
|
PitchBasedVad pitch_based_vad_;
|
||||||
|
|
||||||
int16_t resampled_[kLength10Ms];
|
int16_t resampled_[kLength10Ms];
|
||||||
|
|||||||
Reference in New Issue
Block a user