Replace scoped_ptr with unique_ptr in webrtc/modules/audio_processing/transient/
BUG=webrtc:5520 Review URL: https://codereview.webrtc.org/1698843003 Cr-Commit-Position: refs/heads/master@{#11645}
This commit is contained in:
parent
9d3584c47e
commit
85d8bb025a
@ -11,14 +11,13 @@
|
||||
#include <cfloat>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/transient_detector.h"
|
||||
#include "webrtc/modules/audio_processing/transient/file_utils.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
|
||||
using rtc::scoped_ptr;
|
||||
using webrtc::FileWrapper;
|
||||
using webrtc::TransientDetector;
|
||||
|
||||
@ -40,14 +39,14 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
scoped_ptr<FileWrapper> pcm_file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> pcm_file(FileWrapper::Create());
|
||||
pcm_file->OpenFile(argv[1], true, false, false);
|
||||
if (!pcm_file->Open()) {
|
||||
printf("\nThe %s could not be opened.\n\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scoped_ptr<FileWrapper> dat_file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> dat_file(FileWrapper::Create());
|
||||
dat_file->OpenFile(argv[2], false, false, false);
|
||||
if (!dat_file->Open()) {
|
||||
printf("\nThe %s could not be opened.\n\n", argv[2]);
|
||||
@ -69,7 +68,7 @@ int main(int argc, char* argv[]) {
|
||||
TransientDetector detector(sample_rate_hz);
|
||||
int lost_packets = 0;
|
||||
size_t audio_buffer_length = chunk_size_ms * sample_rate_hz / 1000;
|
||||
scoped_ptr<float[]> audio_buffer(new float[audio_buffer_length]);
|
||||
std::unique_ptr<float[]> audio_buffer(new float[audio_buffer_length]);
|
||||
std::vector<float> send_times;
|
||||
|
||||
// Read first buffer from the PCM test file.
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/file_utils.h"
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -83,7 +84,7 @@ size_t ReadInt16BufferFromFile(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
|
||||
size_t int16s_read = 0;
|
||||
|
||||
@ -109,7 +110,7 @@ size_t ReadInt16FromFileToFloatBuffer(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
std::unique_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
|
||||
size_t int16s_read = ReadInt16BufferFromFile(file, length, buffer16.get());
|
||||
|
||||
@ -127,7 +128,7 @@ size_t ReadInt16FromFileToDoubleBuffer(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
std::unique_ptr<int16_t[]> buffer16(new int16_t[length]);
|
||||
|
||||
size_t int16s_read = ReadInt16BufferFromFile(file, length, buffer16.get());
|
||||
|
||||
@ -145,7 +146,7 @@ size_t ReadFloatBufferFromFile(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
|
||||
size_t floats_read = 0;
|
||||
|
||||
@ -168,7 +169,7 @@ size_t ReadDoubleBufferFromFile(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
|
||||
size_t doubles_read = 0;
|
||||
|
||||
@ -191,7 +192,7 @@ size_t WriteInt16BufferToFile(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[2]);
|
||||
|
||||
size_t int16s_written = 0;
|
||||
|
||||
@ -215,7 +216,7 @@ size_t WriteFloatBufferToFile(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[4]);
|
||||
|
||||
size_t floats_written = 0;
|
||||
|
||||
@ -238,7 +239,7 @@ size_t WriteDoubleBufferToFile(FileWrapper* file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
std::unique_ptr<uint8_t[]> byte_array(new uint8_t[8]);
|
||||
|
||||
size_t doubles_written = 0;
|
||||
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
@ -123,7 +123,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ConvertByteArrayToDouble) {
|
||||
#define MAYBE_ConvertFloatToByteArray ConvertFloatToByteArray
|
||||
#endif
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_ConvertFloatToByteArray) {
|
||||
rtc::scoped_ptr<uint8_t[]> bytes(new uint8_t[4]);
|
||||
std::unique_ptr<uint8_t[]> bytes(new uint8_t[4]);
|
||||
|
||||
EXPECT_EQ(0, ConvertFloatToByteArray(kPi, bytes.get()));
|
||||
EXPECT_EQ(0, memcmp(bytes.get(), kPiBytesf, 4));
|
||||
@ -141,7 +141,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ConvertFloatToByteArray) {
|
||||
#define MAYBE_ConvertDoubleToByteArray ConvertDoubleToByteArray
|
||||
#endif
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_ConvertDoubleToByteArray) {
|
||||
rtc::scoped_ptr<uint8_t[]> bytes(new uint8_t[8]);
|
||||
std::unique_ptr<uint8_t[]> bytes(new uint8_t[8]);
|
||||
|
||||
EXPECT_EQ(0, ConvertDoubleToByteArray(kPi, bytes.get()));
|
||||
EXPECT_EQ(0, memcmp(bytes.get(), kPiBytes, 8));
|
||||
@ -161,7 +161,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ConvertDoubleToByteArray) {
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) {
|
||||
std::string test_filename = kTestFileName;
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
file->OpenFile(test_filename.c_str(),
|
||||
true, // Read only.
|
||||
@ -171,7 +171,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) {
|
||||
<< kTestFileName.c_str();
|
||||
|
||||
const size_t kBufferLength = 12;
|
||||
rtc::scoped_ptr<int16_t[]> buffer(new int16_t[kBufferLength]);
|
||||
std::unique_ptr<int16_t[]> buffer(new int16_t[kBufferLength]);
|
||||
|
||||
EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(),
|
||||
kBufferLength,
|
||||
@ -205,7 +205,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) {
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) {
|
||||
std::string test_filename = kTestFileName;
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
file->OpenFile(test_filename.c_str(),
|
||||
true, // Read only.
|
||||
@ -215,7 +215,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) {
|
||||
<< kTestFileName.c_str();
|
||||
|
||||
const size_t kBufferLength = 12;
|
||||
rtc::scoped_ptr<float[]> buffer(new float[kBufferLength]);
|
||||
std::unique_ptr<float[]> buffer(new float[kBufferLength]);
|
||||
|
||||
EXPECT_EQ(kBufferLength, ReadInt16FromFileToFloatBuffer(file.get(),
|
||||
kBufferLength,
|
||||
@ -252,7 +252,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) {
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) {
|
||||
std::string test_filename = kTestFileName;
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
file->OpenFile(test_filename.c_str(),
|
||||
true, // Read only.
|
||||
@ -262,7 +262,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) {
|
||||
<< kTestFileName.c_str();
|
||||
|
||||
const size_t kBufferLength = 12;
|
||||
rtc::scoped_ptr<double[]> buffer(new double[kBufferLength]);
|
||||
std::unique_ptr<double[]> buffer(new double[kBufferLength]);
|
||||
|
||||
EXPECT_EQ(kBufferLength, ReadInt16FromFileToDoubleBuffer(file.get(),
|
||||
kBufferLength,
|
||||
@ -297,7 +297,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) {
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) {
|
||||
std::string test_filename = kTestFileNamef;
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
file->OpenFile(test_filename.c_str(),
|
||||
true, // Read only.
|
||||
@ -307,7 +307,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) {
|
||||
<< kTestFileNamef.c_str();
|
||||
|
||||
const size_t kBufferLength = 3;
|
||||
rtc::scoped_ptr<float[]> buffer(new float[kBufferLength]);
|
||||
std::unique_ptr<float[]> buffer(new float[kBufferLength]);
|
||||
|
||||
EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(),
|
||||
kBufferLength,
|
||||
@ -339,7 +339,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) {
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) {
|
||||
std::string test_filename = kTestFileName;
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
file->OpenFile(test_filename.c_str(),
|
||||
true, // Read only.
|
||||
@ -349,7 +349,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) {
|
||||
<< kTestFileName.c_str();
|
||||
|
||||
const size_t kBufferLength = 3;
|
||||
rtc::scoped_ptr<double[]> buffer(new double[kBufferLength]);
|
||||
std::unique_ptr<double[]> buffer(new double[kBufferLength]);
|
||||
|
||||
EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(),
|
||||
kBufferLength,
|
||||
@ -379,7 +379,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) {
|
||||
#define MAYBE_WriteInt16BufferToFile WriteInt16BufferToFile
|
||||
#endif
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
std::string kOutFileName = CreateTempFilename(test::OutputPath(),
|
||||
"utils_test");
|
||||
@ -392,8 +392,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
|
||||
<< kOutFileName.c_str();
|
||||
|
||||
const size_t kBufferLength = 3;
|
||||
rtc::scoped_ptr<int16_t[]> written_buffer(new int16_t[kBufferLength]);
|
||||
rtc::scoped_ptr<int16_t[]> read_buffer(new int16_t[kBufferLength]);
|
||||
std::unique_ptr<int16_t[]> written_buffer(new int16_t[kBufferLength]);
|
||||
std::unique_ptr<int16_t[]> read_buffer(new int16_t[kBufferLength]);
|
||||
|
||||
written_buffer[0] = 1;
|
||||
written_buffer[1] = 2;
|
||||
@ -426,7 +426,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
|
||||
#define MAYBE_WriteFloatBufferToFile WriteFloatBufferToFile
|
||||
#endif
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
std::string kOutFileName = CreateTempFilename(test::OutputPath(),
|
||||
"utils_test");
|
||||
@ -439,8 +439,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
|
||||
<< kOutFileName.c_str();
|
||||
|
||||
const size_t kBufferLength = 3;
|
||||
rtc::scoped_ptr<float[]> written_buffer(new float[kBufferLength]);
|
||||
rtc::scoped_ptr<float[]> read_buffer(new float[kBufferLength]);
|
||||
std::unique_ptr<float[]> written_buffer(new float[kBufferLength]);
|
||||
std::unique_ptr<float[]> read_buffer(new float[kBufferLength]);
|
||||
|
||||
written_buffer[0] = static_cast<float>(kPi);
|
||||
written_buffer[1] = static_cast<float>(kE);
|
||||
@ -473,7 +473,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
|
||||
#define MAYBE_WriteDoubleBufferToFile WriteDoubleBufferToFile
|
||||
#endif
|
||||
TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) {
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
std::string kOutFileName = CreateTempFilename(test::OutputPath(),
|
||||
"utils_test");
|
||||
@ -486,8 +486,8 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) {
|
||||
<< kOutFileName.c_str();
|
||||
|
||||
const size_t kBufferLength = 3;
|
||||
rtc::scoped_ptr<double[]> written_buffer(new double[kBufferLength]);
|
||||
rtc::scoped_ptr<double[]> read_buffer(new double[kBufferLength]);
|
||||
std::unique_ptr<double[]> written_buffer(new double[kBufferLength]);
|
||||
std::unique_ptr<double[]> read_buffer(new double[kBufferLength]);
|
||||
|
||||
written_buffer[0] = kPi;
|
||||
written_buffer[1] = kE;
|
||||
@ -523,9 +523,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_ExpectedErrorReturnValues) {
|
||||
std::string test_filename = kTestFileName;
|
||||
|
||||
double value;
|
||||
rtc::scoped_ptr<int16_t[]> int16_buffer(new int16_t[1]);
|
||||
rtc::scoped_ptr<double[]> double_buffer(new double[1]);
|
||||
rtc::scoped_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
std::unique_ptr<int16_t[]> int16_buffer(new int16_t[1]);
|
||||
std::unique_ptr<double[]> double_buffer(new double[1]);
|
||||
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
|
||||
|
||||
EXPECT_EQ(-1, ConvertByteArrayToDouble(NULL, &value));
|
||||
EXPECT_EQ(-1, ConvertByteArrayToDouble(kPiBytes, NULL));
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -22,7 +22,7 @@ MovingMoments::MovingMoments(size_t length)
|
||||
queue_(),
|
||||
sum_(0.0),
|
||||
sum_of_squares_(0.0) {
|
||||
assert(length > 0);
|
||||
RTC_DCHECK_GT(length, 0u);
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
queue_.push(0.0);
|
||||
}
|
||||
@ -32,7 +32,7 @@ MovingMoments::~MovingMoments() {}
|
||||
|
||||
void MovingMoments::CalculateMoments(const float* in, size_t in_length,
|
||||
float* first, float* second) {
|
||||
assert(in && in_length > 0 && first && second);
|
||||
RTC_DCHECK(in && in_length > 0 && first && second);
|
||||
|
||||
for (size_t i = 0; i < in_length; ++i) {
|
||||
const float old_value = queue_.front();
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
|
||||
|
||||
#include <queue>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include <queue>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -10,8 +10,9 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/moving_moments.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -29,7 +30,7 @@ class MovingMomentsTest : public ::testing::Test {
|
||||
const float* expected_mean,
|
||||
const float* expected_mean_squares);
|
||||
|
||||
rtc::scoped_ptr<MovingMoments> moving_moments_;
|
||||
std::unique_ptr<MovingMoments> moving_moments_;
|
||||
float output_mean_[kMaxOutputLength];
|
||||
float output_mean_squares_[kMaxOutputLength];
|
||||
};
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/common.h"
|
||||
#include "webrtc/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h"
|
||||
#include "webrtc/modules/audio_processing/transient/moving_moments.h"
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/transient/moving_moments.h"
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_tree.h"
|
||||
|
||||
@ -55,14 +55,14 @@ class TransientDetector {
|
||||
|
||||
size_t samples_per_chunk_;
|
||||
|
||||
rtc::scoped_ptr<WPDTree> wpd_tree_;
|
||||
std::unique_ptr<WPDTree> wpd_tree_;
|
||||
size_t tree_leaves_data_length_;
|
||||
|
||||
// A MovingMoments object is needed for each leaf in the WPD tree.
|
||||
rtc::scoped_ptr<MovingMoments> moving_moments_[kLeaves];
|
||||
std::unique_ptr<MovingMoments> moving_moments_[kLeaves];
|
||||
|
||||
rtc::scoped_ptr<float[]> first_moments_;
|
||||
rtc::scoped_ptr<float[]> second_moments_;
|
||||
std::unique_ptr<float[]> first_moments_;
|
||||
std::unique_ptr<float[]> second_moments_;
|
||||
|
||||
// Stores the last calculated moments from the previous detection.
|
||||
float last_first_moment_[kLeaves];
|
||||
|
||||
@ -10,11 +10,11 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/transient_detector.h"
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/transient/common.h"
|
||||
#include "webrtc/modules/audio_processing/transient/file_utils.h"
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
@ -49,7 +49,7 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) {
|
||||
detect_file_name << "audio_processing/transient/detect"
|
||||
<< (sample_rate_hz / 1000) << "kHz";
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> detect_file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> detect_file(FileWrapper::Create());
|
||||
|
||||
detect_file->OpenFile(
|
||||
test::ResourcePath(detect_file_name.str(), "dat").c_str(),
|
||||
@ -66,7 +66,7 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) {
|
||||
audio_file_name << "audio_processing/transient/audio"
|
||||
<< (sample_rate_hz / 1000) << "kHz";
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> audio_file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> audio_file(FileWrapper::Create());
|
||||
|
||||
audio_file->OpenFile(
|
||||
test::ResourcePath(audio_file_name.str(), "pcm").c_str(),
|
||||
@ -78,7 +78,7 @@ TEST(TransientDetectorTest, CorrectnessBasedOnFiles) {
|
||||
TransientDetector detector(sample_rate_hz);
|
||||
|
||||
const size_t buffer_length = sample_rate_hz * ts::kChunkSizeMs / 1000;
|
||||
rtc::scoped_ptr<float[]> buffer(new float[buffer_length]);
|
||||
std::unique_ptr<float[]> buffer(new float[buffer_length]);
|
||||
|
||||
const float kTolerance = 0.02f;
|
||||
|
||||
|
||||
@ -12,11 +12,12 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/modules/audio_processing/agc/agc.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
@ -83,7 +84,7 @@ bool ReadBuffers(FILE* in_file,
|
||||
float* detection_buffer,
|
||||
FILE* reference_file,
|
||||
float* reference_buffer) {
|
||||
rtc::scoped_ptr<int16_t[]> tmpbuf;
|
||||
std::unique_ptr<int16_t[]> tmpbuf;
|
||||
int16_t* read_ptr = audio_buffer;
|
||||
if (num_channels > 1) {
|
||||
tmpbuf.reset(new int16_t[num_channels * audio_buffer_size]);
|
||||
@ -105,7 +106,7 @@ bool ReadBuffers(FILE* in_file,
|
||||
}
|
||||
}
|
||||
if (detection_file) {
|
||||
rtc::scoped_ptr<int16_t[]> ibuf(new int16_t[detection_buffer_size]);
|
||||
std::unique_ptr<int16_t[]> ibuf(new int16_t[detection_buffer_size]);
|
||||
if (fread(ibuf.get(), sizeof(ibuf[0]), detection_buffer_size,
|
||||
detection_file) != detection_buffer_size)
|
||||
return false;
|
||||
@ -113,7 +114,7 @@ bool ReadBuffers(FILE* in_file,
|
||||
detection_buffer[i] = ibuf[i];
|
||||
}
|
||||
if (reference_file) {
|
||||
rtc::scoped_ptr<int16_t[]> ibuf(new int16_t[audio_buffer_size]);
|
||||
std::unique_ptr<int16_t[]> ibuf(new int16_t[audio_buffer_size]);
|
||||
if (fread(ibuf.get(), sizeof(ibuf[0]), audio_buffer_size, reference_file)
|
||||
!= audio_buffer_size)
|
||||
return false;
|
||||
@ -127,7 +128,7 @@ static void WritePCM(FILE* f,
|
||||
size_t num_samples,
|
||||
int num_channels,
|
||||
const float* buffer) {
|
||||
rtc::scoped_ptr<int16_t[]> ibuf(new int16_t[num_channels * num_samples]);
|
||||
std::unique_ptr<int16_t[]> ibuf(new int16_t[num_channels * num_samples]);
|
||||
// Interleave.
|
||||
for (int i = 0; i < num_channels; ++i) {
|
||||
for (size_t j = 0; j < num_samples; ++j) {
|
||||
@ -182,12 +183,12 @@ void void_main() {
|
||||
FLAGS_chunk_size_ms * detection_rate_hz / 1000;
|
||||
|
||||
// int16 and float variants of the same data.
|
||||
rtc::scoped_ptr<int16_t[]> audio_buffer_i(
|
||||
std::unique_ptr<int16_t[]> audio_buffer_i(
|
||||
new int16_t[FLAGS_num_channels * audio_buffer_size]);
|
||||
rtc::scoped_ptr<float[]> audio_buffer_f(
|
||||
std::unique_ptr<float[]> audio_buffer_f(
|
||||
new float[FLAGS_num_channels * audio_buffer_size]);
|
||||
|
||||
rtc::scoped_ptr<float[]> detection_buffer, reference_buffer;
|
||||
std::unique_ptr<float[]> detection_buffer, reference_buffer;
|
||||
|
||||
if (detection_file)
|
||||
detection_buffer.reset(new float[detection_buffer_size]);
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/fft4g.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "webrtc/base/gtest_prod_util.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -71,7 +71,7 @@ class TransientSuppressor {
|
||||
void HardRestoration(float* spectral_mean);
|
||||
void SoftRestoration(float* spectral_mean);
|
||||
|
||||
rtc::scoped_ptr<TransientDetector> detector_;
|
||||
std::unique_ptr<TransientDetector> detector_;
|
||||
|
||||
size_t data_length_;
|
||||
size_t detection_length_;
|
||||
@ -80,25 +80,25 @@ class TransientSuppressor {
|
||||
size_t complex_analysis_length_;
|
||||
int num_channels_;
|
||||
// Input buffer where the original samples are stored.
|
||||
rtc::scoped_ptr<float[]> in_buffer_;
|
||||
rtc::scoped_ptr<float[]> detection_buffer_;
|
||||
std::unique_ptr<float[]> in_buffer_;
|
||||
std::unique_ptr<float[]> detection_buffer_;
|
||||
// Output buffer where the restored samples are stored.
|
||||
rtc::scoped_ptr<float[]> out_buffer_;
|
||||
std::unique_ptr<float[]> out_buffer_;
|
||||
|
||||
// Arrays for fft.
|
||||
rtc::scoped_ptr<size_t[]> ip_;
|
||||
rtc::scoped_ptr<float[]> wfft_;
|
||||
std::unique_ptr<size_t[]> ip_;
|
||||
std::unique_ptr<float[]> wfft_;
|
||||
|
||||
rtc::scoped_ptr<float[]> spectral_mean_;
|
||||
std::unique_ptr<float[]> spectral_mean_;
|
||||
|
||||
// Stores the data for the fft.
|
||||
rtc::scoped_ptr<float[]> fft_buffer_;
|
||||
std::unique_ptr<float[]> fft_buffer_;
|
||||
|
||||
rtc::scoped_ptr<float[]> magnitudes_;
|
||||
std::unique_ptr<float[]> magnitudes_;
|
||||
|
||||
const float* window_;
|
||||
|
||||
rtc::scoped_ptr<float[]> mean_factor_;
|
||||
std::unique_ptr<float[]> mean_factor_;
|
||||
|
||||
float detector_smoothed_;
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/fir_filter.h"
|
||||
#include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
|
||||
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_NODE_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -36,9 +37,9 @@ class WPDNode {
|
||||
size_t length() const { return length_; }
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<float[]> data_;
|
||||
std::unique_ptr<float[]> data_;
|
||||
size_t length_;
|
||||
rtc::scoped_ptr<FIRFilter> filter_;
|
||||
std::unique_ptr<FIRFilter> filter_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_node.h"
|
||||
|
||||
@ -32,7 +31,7 @@ WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients,
|
||||
levels > 0);
|
||||
// Size is 1 more, so we can use the array as 1-based. nodes_[0] is never
|
||||
// allocated.
|
||||
nodes_.reset(new rtc::scoped_ptr<WPDNode>[num_nodes_ + 1]);
|
||||
nodes_.reset(new std::unique_ptr<WPDNode>[num_nodes_ + 1]);
|
||||
|
||||
// Create the first node
|
||||
const float kRootCoefficient = 1.f; // Identity Coefficient.
|
||||
|
||||
@ -11,7 +11,8 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_WPD_TREE_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_node.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -83,7 +84,7 @@ class WPDTree {
|
||||
size_t data_length_;
|
||||
int levels_;
|
||||
int num_nodes_;
|
||||
rtc::scoped_ptr<rtc::scoped_ptr<WPDNode>[]> nodes_;
|
||||
std::unique_ptr<std::unique_ptr<WPDNode>[]> nodes_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -10,11 +10,11 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_tree.h"
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h"
|
||||
#include "webrtc/modules/audio_processing/transient/file_utils.h"
|
||||
#include "webrtc/system_wrappers/include/file_wrapper.h"
|
||||
@ -85,8 +85,8 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) {
|
||||
kDaubechies8CoefficientsLength,
|
||||
kLevels);
|
||||
// Allocate and open all matlab and out files.
|
||||
rtc::scoped_ptr<FileWrapper> matlab_files_data[kLeaves];
|
||||
rtc::scoped_ptr<FileWrapper> out_files_data[kLeaves];
|
||||
std::unique_ptr<FileWrapper> matlab_files_data[kLeaves];
|
||||
std::unique_ptr<FileWrapper> out_files_data[kLeaves];
|
||||
|
||||
for (int i = 0; i < kLeaves; ++i) {
|
||||
// Matlab files.
|
||||
@ -123,7 +123,7 @@ TEST(WPDTreeTest, CorrectnessBasedOnMatlabFiles) {
|
||||
std::string test_file_name = test::ResourcePath(
|
||||
"audio_processing/transient/ajm-macbook-1-spke16m", "pcm");
|
||||
|
||||
rtc::scoped_ptr<FileWrapper> test_file(FileWrapper::Create());
|
||||
std::unique_ptr<FileWrapper> test_file(FileWrapper::Create());
|
||||
|
||||
test_file->OpenFile(test_file_name.c_str(),
|
||||
true, // Read only.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user