From 85d8bb025aa1144f4266e093b0cf009d99ce8dcb Mon Sep 17 00:00:00 2001 From: kwiberg Date: Tue, 16 Feb 2016 20:39:36 -0800 Subject: [PATCH] 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} --- .../transient/click_annotate.cc | 9 ++-- .../audio_processing/transient/file_utils.cc | 19 +++---- .../transient/file_utils_unittest.cc | 50 +++++++++---------- .../transient/moving_moments.cc | 6 +-- .../transient/moving_moments.h | 4 +- .../transient/moving_moments_unittest.cc | 5 +- .../transient/transient_detector.cc | 2 + .../transient/transient_detector.h | 10 ++-- .../transient/transient_detector_unittest.cc | 8 +-- .../transient/transient_suppression_test.cc | 17 ++++--- .../transient/transient_suppressor.cc | 1 - .../transient/transient_suppressor.h | 22 ++++---- .../audio_processing/transient/wpd_node.cc | 1 - .../audio_processing/transient/wpd_node.h | 7 +-- .../transient/wpd_node_unittest.cc | 1 - .../audio_processing/transient/wpd_tree.cc | 3 +- .../audio_processing/transient/wpd_tree.h | 5 +- .../transient/wpd_tree_unittest.cc | 8 +-- 18 files changed, 90 insertions(+), 88 deletions(-) diff --git a/webrtc/modules/audio_processing/transient/click_annotate.cc b/webrtc/modules/audio_processing/transient/click_annotate.cc index 38f7a8eede..dd1c346ebd 100644 --- a/webrtc/modules/audio_processing/transient/click_annotate.cc +++ b/webrtc/modules/audio_processing/transient/click_annotate.cc @@ -11,14 +11,13 @@ #include #include #include +#include #include #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 pcm_file(FileWrapper::Create()); + std::unique_ptr 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 dat_file(FileWrapper::Create()); + std::unique_ptr 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 audio_buffer(new float[audio_buffer_length]); + std::unique_ptr audio_buffer(new float[audio_buffer_length]); std::vector send_times; // Read first buffer from the PCM test file. diff --git a/webrtc/modules/audio_processing/transient/file_utils.cc b/webrtc/modules/audio_processing/transient/file_utils.cc index e043286f80..ebe530663c 100644 --- a/webrtc/modules/audio_processing/transient/file_utils.cc +++ b/webrtc/modules/audio_processing/transient/file_utils.cc @@ -10,7 +10,8 @@ #include "webrtc/modules/audio_processing/transient/file_utils.h" -#include "webrtc/base/scoped_ptr.h" +#include + #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 byte_array(new uint8_t[2]); + std::unique_ptr 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 buffer16(new int16_t[length]); + std::unique_ptr 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 buffer16(new int16_t[length]); + std::unique_ptr 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 byte_array(new uint8_t[4]); + std::unique_ptr 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 byte_array(new uint8_t[8]); + std::unique_ptr 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 byte_array(new uint8_t[2]); + std::unique_ptr 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 byte_array(new uint8_t[4]); + std::unique_ptr 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 byte_array(new uint8_t[8]); + std::unique_ptr byte_array(new uint8_t[8]); size_t doubles_written = 0; diff --git a/webrtc/modules/audio_processing/transient/file_utils_unittest.cc b/webrtc/modules/audio_processing/transient/file_utils_unittest.cc index 065354228e..8520413154 100644 --- a/webrtc/modules/audio_processing/transient/file_utils_unittest.cc +++ b/webrtc/modules/audio_processing/transient/file_utils_unittest.cc @@ -12,10 +12,10 @@ #include #include +#include #include #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 bytes(new uint8_t[4]); + std::unique_ptr 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 bytes(new uint8_t[8]); + std::unique_ptr 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 file(FileWrapper::Create()); + std::unique_ptr 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 buffer(new int16_t[kBufferLength]); + std::unique_ptr 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 file(FileWrapper::Create()); + std::unique_ptr 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 buffer(new float[kBufferLength]); + std::unique_ptr 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 file(FileWrapper::Create()); + std::unique_ptr 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 buffer(new double[kBufferLength]); + std::unique_ptr 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 file(FileWrapper::Create()); + std::unique_ptr 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 buffer(new float[kBufferLength]); + std::unique_ptr 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 file(FileWrapper::Create()); + std::unique_ptr 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 buffer(new double[kBufferLength]); + std::unique_ptr 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 file(FileWrapper::Create()); + std::unique_ptr 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 written_buffer(new int16_t[kBufferLength]); - rtc::scoped_ptr read_buffer(new int16_t[kBufferLength]); + std::unique_ptr written_buffer(new int16_t[kBufferLength]); + std::unique_ptr 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 file(FileWrapper::Create()); + std::unique_ptr 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 written_buffer(new float[kBufferLength]); - rtc::scoped_ptr read_buffer(new float[kBufferLength]); + std::unique_ptr written_buffer(new float[kBufferLength]); + std::unique_ptr read_buffer(new float[kBufferLength]); written_buffer[0] = static_cast(kPi); written_buffer[1] = static_cast(kE); @@ -473,7 +473,7 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) { #define MAYBE_WriteDoubleBufferToFile WriteDoubleBufferToFile #endif TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) { - rtc::scoped_ptr file(FileWrapper::Create()); + std::unique_ptr 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 written_buffer(new double[kBufferLength]); - rtc::scoped_ptr read_buffer(new double[kBufferLength]); + std::unique_ptr written_buffer(new double[kBufferLength]); + std::unique_ptr 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_buffer(new int16_t[1]); - rtc::scoped_ptr double_buffer(new double[1]); - rtc::scoped_ptr file(FileWrapper::Create()); + std::unique_ptr int16_buffer(new int16_t[1]); + std::unique_ptr double_buffer(new double[1]); + std::unique_ptr file(FileWrapper::Create()); EXPECT_EQ(-1, ConvertByteArrayToDouble(NULL, &value)); EXPECT_EQ(-1, ConvertByteArrayToDouble(kPiBytes, NULL)); diff --git a/webrtc/modules/audio_processing/transient/moving_moments.cc b/webrtc/modules/audio_processing/transient/moving_moments.cc index aa47522018..bc0b6f0b91 100644 --- a/webrtc/modules/audio_processing/transient/moving_moments.cc +++ b/webrtc/modules/audio_processing/transient/moving_moments.cc @@ -13,7 +13,7 @@ #include #include -#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(); diff --git a/webrtc/modules/audio_processing/transient/moving_moments.h b/webrtc/modules/audio_processing/transient/moving_moments.h index 6e3ad5b6ee..9e22a92fe0 100644 --- a/webrtc/modules/audio_processing/transient/moving_moments.h +++ b/webrtc/modules/audio_processing/transient/moving_moments.h @@ -11,9 +11,9 @@ #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_ #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_ -#include +#include -#include "webrtc/base/scoped_ptr.h" +#include namespace webrtc { diff --git a/webrtc/modules/audio_processing/transient/moving_moments_unittest.cc b/webrtc/modules/audio_processing/transient/moving_moments_unittest.cc index 4d89ac6600..f1aa77329b 100644 --- a/webrtc/modules/audio_processing/transient/moving_moments_unittest.cc +++ b/webrtc/modules/audio_processing/transient/moving_moments_unittest.cc @@ -10,8 +10,9 @@ #include "webrtc/modules/audio_processing/transient/moving_moments.h" +#include + #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 moving_moments_; + std::unique_ptr moving_moments_; float output_mean_[kMaxOutputLength]; float output_mean_squares_[kMaxOutputLength]; }; diff --git a/webrtc/modules/audio_processing/transient/transient_detector.cc b/webrtc/modules/audio_processing/transient/transient_detector.cc index 7f021ac7b3..12a50bd46b 100644 --- a/webrtc/modules/audio_processing/transient/transient_detector.cc +++ b/webrtc/modules/audio_processing/transient/transient_detector.cc @@ -15,6 +15,8 @@ #include #include +#include + #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" diff --git a/webrtc/modules/audio_processing/transient/transient_detector.h b/webrtc/modules/audio_processing/transient/transient_detector.h index 3f96582aae..dbd2ba5d68 100644 --- a/webrtc/modules/audio_processing/transient/transient_detector.h +++ b/webrtc/modules/audio_processing/transient/transient_detector.h @@ -12,8 +12,8 @@ #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_DETECTOR_H_ #include +#include -#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 wpd_tree_; + std::unique_ptr wpd_tree_; size_t tree_leaves_data_length_; // A MovingMoments object is needed for each leaf in the WPD tree. - rtc::scoped_ptr moving_moments_[kLeaves]; + std::unique_ptr moving_moments_[kLeaves]; - rtc::scoped_ptr first_moments_; - rtc::scoped_ptr second_moments_; + std::unique_ptr first_moments_; + std::unique_ptr second_moments_; // Stores the last calculated moments from the previous detection. float last_first_moment_[kLeaves]; diff --git a/webrtc/modules/audio_processing/transient/transient_detector_unittest.cc b/webrtc/modules/audio_processing/transient/transient_detector_unittest.cc index b60077510b..18bb42e0eb 100644 --- a/webrtc/modules/audio_processing/transient/transient_detector_unittest.cc +++ b/webrtc/modules/audio_processing/transient/transient_detector_unittest.cc @@ -10,11 +10,11 @@ #include "webrtc/modules/audio_processing/transient/transient_detector.h" +#include #include #include #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 detect_file(FileWrapper::Create()); + std::unique_ptr 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 audio_file(FileWrapper::Create()); + std::unique_ptr 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 buffer(new float[buffer_length]); + std::unique_ptr buffer(new float[buffer_length]); const float kTolerance = 0.02f; diff --git a/webrtc/modules/audio_processing/transient/transient_suppression_test.cc b/webrtc/modules/audio_processing/transient/transient_suppression_test.cc index b7b7595abf..90ebb226d2 100644 --- a/webrtc/modules/audio_processing/transient/transient_suppression_test.cc +++ b/webrtc/modules/audio_processing/transient/transient_suppression_test.cc @@ -12,11 +12,12 @@ #include #include + +#include #include #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 tmpbuf; + std::unique_ptr 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 ibuf(new int16_t[detection_buffer_size]); + std::unique_ptr 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 ibuf(new int16_t[audio_buffer_size]); + std::unique_ptr 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 ibuf(new int16_t[num_channels * num_samples]); + std::unique_ptr 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 audio_buffer_i( + std::unique_ptr audio_buffer_i( new int16_t[FLAGS_num_channels * audio_buffer_size]); - rtc::scoped_ptr audio_buffer_f( + std::unique_ptr audio_buffer_f( new float[FLAGS_num_channels * audio_buffer_size]); - rtc::scoped_ptr detection_buffer, reference_buffer; + std::unique_ptr detection_buffer, reference_buffer; if (detection_file) detection_buffer.reset(new float[detection_buffer_size]); diff --git a/webrtc/modules/audio_processing/transient/transient_suppressor.cc b/webrtc/modules/audio_processing/transient/transient_suppressor.cc index c8d9e65858..25909b9008 100644 --- a/webrtc/modules/audio_processing/transient/transient_suppressor.cc +++ b/webrtc/modules/audio_processing/transient/transient_suppressor.cc @@ -17,7 +17,6 @@ #include #include -#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" diff --git a/webrtc/modules/audio_processing/transient/transient_suppressor.h b/webrtc/modules/audio_processing/transient/transient_suppressor.h index 489d71b93e..17c2a3964d 100644 --- a/webrtc/modules/audio_processing/transient/transient_suppressor.h +++ b/webrtc/modules/audio_processing/transient/transient_suppressor.h @@ -12,10 +12,10 @@ #define WEBRTC_MODULES_AUDIO_PROCESSING_TRANSIENT_TRANSIENT_SUPPRESSOR_H_ #include +#include #include #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 detector_; + std::unique_ptr 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 in_buffer_; - rtc::scoped_ptr detection_buffer_; + std::unique_ptr in_buffer_; + std::unique_ptr detection_buffer_; // Output buffer where the restored samples are stored. - rtc::scoped_ptr out_buffer_; + std::unique_ptr out_buffer_; // Arrays for fft. - rtc::scoped_ptr ip_; - rtc::scoped_ptr wfft_; + std::unique_ptr ip_; + std::unique_ptr wfft_; - rtc::scoped_ptr spectral_mean_; + std::unique_ptr spectral_mean_; // Stores the data for the fft. - rtc::scoped_ptr fft_buffer_; + std::unique_ptr fft_buffer_; - rtc::scoped_ptr magnitudes_; + std::unique_ptr magnitudes_; const float* window_; - rtc::scoped_ptr mean_factor_; + std::unique_ptr mean_factor_; float detector_smoothed_; diff --git a/webrtc/modules/audio_processing/transient/wpd_node.cc b/webrtc/modules/audio_processing/transient/wpd_node.cc index 8114a708b1..ab476a0ebd 100644 --- a/webrtc/modules/audio_processing/transient/wpd_node.cc +++ b/webrtc/modules/audio_processing/transient/wpd_node.cc @@ -14,7 +14,6 @@ #include #include -#include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/fir_filter.h" #include "webrtc/modules/audio_processing/transient/dyadic_decimator.h" diff --git a/webrtc/modules/audio_processing/transient/wpd_node.h b/webrtc/modules/audio_processing/transient/wpd_node.h index f66cad9543..99521fd32e 100644 --- a/webrtc/modules/audio_processing/transient/wpd_node.h +++ b/webrtc/modules/audio_processing/transient/wpd_node.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 + #include "webrtc/typedefs.h" namespace webrtc { @@ -36,9 +37,9 @@ class WPDNode { size_t length() const { return length_; } private: - rtc::scoped_ptr data_; + std::unique_ptr data_; size_t length_; - rtc::scoped_ptr filter_; + std::unique_ptr filter_; }; } // namespace webrtc diff --git a/webrtc/modules/audio_processing/transient/wpd_node_unittest.cc b/webrtc/modules/audio_processing/transient/wpd_node_unittest.cc index cde6cba0f1..7ab6da8949 100644 --- a/webrtc/modules/audio_processing/transient/wpd_node_unittest.cc +++ b/webrtc/modules/audio_processing/transient/wpd_node_unittest.cc @@ -13,7 +13,6 @@ #include #include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/base/scoped_ptr.h" namespace webrtc { diff --git a/webrtc/modules/audio_processing/transient/wpd_tree.cc b/webrtc/modules/audio_processing/transient/wpd_tree.cc index 227b48ade6..28cbb046ac 100644 --- a/webrtc/modules/audio_processing/transient/wpd_tree.cc +++ b/webrtc/modules/audio_processing/transient/wpd_tree.cc @@ -14,7 +14,6 @@ #include #include -#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[num_nodes_ + 1]); + nodes_.reset(new std::unique_ptr[num_nodes_ + 1]); // Create the first node const float kRootCoefficient = 1.f; // Identity Coefficient. diff --git a/webrtc/modules/audio_processing/transient/wpd_tree.h b/webrtc/modules/audio_processing/transient/wpd_tree.h index 7f0fc794e0..a64055e7de 100644 --- a/webrtc/modules/audio_processing/transient/wpd_tree.h +++ b/webrtc/modules/audio_processing/transient/wpd_tree.h @@ -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 + #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[]> nodes_; + std::unique_ptr[]> nodes_; }; } // namespace webrtc diff --git a/webrtc/modules/audio_processing/transient/wpd_tree_unittest.cc b/webrtc/modules/audio_processing/transient/wpd_tree_unittest.cc index e4e9048f88..3e202bf088 100644 --- a/webrtc/modules/audio_processing/transient/wpd_tree_unittest.cc +++ b/webrtc/modules/audio_processing/transient/wpd_tree_unittest.cc @@ -10,11 +10,11 @@ #include "webrtc/modules/audio_processing/transient/wpd_tree.h" +#include #include #include #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 matlab_files_data[kLeaves]; - rtc::scoped_ptr out_files_data[kLeaves]; + std::unique_ptr matlab_files_data[kLeaves]; + std::unique_ptr 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 test_file(FileWrapper::Create()); + std::unique_ptr test_file(FileWrapper::Create()); test_file->OpenFile(test_file_name.c_str(), true, // Read only.