Replace scoped_ptr with unique_ptr in webrtc/common_audio/

(This is a re-land---without the real_fourier.h changes---of 11716, which was reverted in 11726.)

BUG=webrtc:5520

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

Cr-Commit-Position: refs/heads/master@{#11742}
This commit is contained in:
kwiberg 2016-02-24 05:22:32 -08:00 committed by Commit bot
parent 837b39e8f4
commit c2b785df5d
28 changed files with 108 additions and 89 deletions

View File

@ -136,11 +136,11 @@ class CompositionConverter : public AudioConverter {
ScopedVector<ChannelBuffer<float>> buffers_;
};
rtc::scoped_ptr<AudioConverter> AudioConverter::Create(size_t src_channels,
std::unique_ptr<AudioConverter> AudioConverter::Create(size_t src_channels,
size_t src_frames,
size_t dst_channels,
size_t dst_frames) {
rtc::scoped_ptr<AudioConverter> sp;
std::unique_ptr<AudioConverter> sp;
if (src_channels > dst_channels) {
if (src_frames != dst_frames) {
ScopedVector<AudioConverter> converters;

View File

@ -11,8 +11,9 @@
#ifndef WEBRTC_COMMON_AUDIO_AUDIO_CONVERTER_H_
#define WEBRTC_COMMON_AUDIO_AUDIO_CONVERTER_H_
#include <memory>
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/scoped_ptr.h"
namespace webrtc {
@ -26,7 +27,7 @@ class AudioConverter {
public:
// Returns a new AudioConverter, which will use the supplied format for its
// lifetime. Caller is responsible for the memory.
static rtc::scoped_ptr<AudioConverter> Create(size_t src_channels,
static std::unique_ptr<AudioConverter> Create(size_t src_channels,
size_t src_frames,
size_t dst_channels,
size_t dst_frames);

View File

@ -10,19 +10,19 @@
#include <cmath>
#include <algorithm>
#include <memory>
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/format_macros.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/audio_converter.h"
#include "webrtc/common_audio/channel_buffer.h"
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
namespace webrtc {
typedef rtc::scoped_ptr<ChannelBuffer<float>> ScopedBuffer;
typedef std::unique_ptr<ChannelBuffer<float>> ScopedBuffer;
// Sets the signal value to increase by |data| with every sample.
ScopedBuffer CreateBuffer(const std::vector<float>& data, size_t frames) {
@ -132,7 +132,7 @@ void RunAudioConverterTest(size_t src_channels,
printf("(%" PRIuS ", %d Hz) -> (%" PRIuS ", %d Hz) ",
src_channels, src_sample_rate_hz, dst_channels, dst_sample_rate_hz);
rtc::scoped_ptr<AudioConverter> converter = AudioConverter::Create(
std::unique_ptr<AudioConverter> converter = AudioConverter::Create(
src_channels, src_frames, dst_channels, dst_frames);
converter->Convert(src_buffer->channels(), src_buffer->size(),
dst_buffer->channels(), dst_buffer->size());

View File

@ -47,7 +47,7 @@ class AudioRingBuffer final {
private:
// We don't use a ScopedVector because it doesn't support a specialized
// deleter (like scoped_ptr for instance.)
// deleter (like unique_ptr for instance.)
std::vector<RingBuffer*> buffers_;
};

View File

@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <memory>
#include "webrtc/common_audio/audio_ring_buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -27,7 +29,7 @@ void ReadAndWriteTest(const ChannelBuffer<float>& input,
const size_t num_channels = input.num_channels();
const size_t total_frames = input.num_frames();
AudioRingBuffer buf(num_channels, buffer_frames);
rtc::scoped_ptr<float* []> slice(new float* [num_channels]);
std::unique_ptr<float* []> slice(new float*[num_channels]);
size_t input_pos = 0;
size_t output_pos = 0;

View File

@ -11,7 +11,8 @@
#ifndef WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_
#define WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_
#include "webrtc/base/scoped_ptr.h"
#include <memory>
#include "webrtc/common_audio/audio_ring_buffer.h"
#include "webrtc/common_audio/channel_buffer.h"
@ -109,7 +110,7 @@ class Blocker {
// Space for the output block (can't wrap because of overlap/add).
ChannelBuffer<float> output_block_;
rtc::scoped_ptr<float[]> window_;
std::unique_ptr<float[]> window_;
// The amount of frames between the start of contiguous blocks. For example,
// |shift_amount_| = |block_size_| / 2 for a Hann window.

View File

@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <memory>
#include "webrtc/common_audio/blocker.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -307,7 +309,7 @@ TEST_F(BlockerTest, InitialDelaysAreMinimum) {
CopyBlockerCallback callback;
for (size_t i = 0; i < arraysize(kChunkSize); ++i) {
rtc::scoped_ptr<float[]> window(new float[kBlockSize[i]]);
std::unique_ptr<float[]> window(new float[kBlockSize[i]]);
for (size_t j = 0; j < kBlockSize[i]; ++j) {
window[j] = 1.f;
}

View File

@ -10,6 +10,8 @@
#include "webrtc/common_audio/channel_buffer.h"
#include "webrtc/base/checks.h"
namespace webrtc {
IFChannelBuffer::IFChannelBuffer(size_t num_frames,
@ -44,7 +46,7 @@ const ChannelBuffer<float>* IFChannelBuffer::fbuf_const() const {
void IFChannelBuffer::RefreshF() const {
if (!fvalid_) {
assert(ivalid_);
RTC_DCHECK(ivalid_);
const int16_t* const* int_channels = ibuf_.channels();
float* const* float_channels = fbuf_.channels();
for (size_t i = 0; i < ibuf_.num_channels(); ++i) {
@ -58,7 +60,7 @@ void IFChannelBuffer::RefreshF() const {
void IFChannelBuffer::RefreshI() const {
if (!ivalid_) {
assert(fvalid_);
RTC_DCHECK(fvalid_);
int16_t* const* int_channels = ibuf_.channels();
const float* const* float_channels = fbuf_.channels();
for (size_t i = 0; i < ibuf_.num_channels(); ++i) {

View File

@ -13,9 +13,10 @@
#include <string.h>
#include <memory>
#include "webrtc/base/checks.h"
#include "webrtc/base/gtest_prod_util.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/include/audio_util.h"
namespace webrtc {
@ -125,9 +126,9 @@ class ChannelBuffer {
}
private:
rtc::scoped_ptr<T[]> data_;
rtc::scoped_ptr<T* []> channels_;
rtc::scoped_ptr<T* []> bands_;
std::unique_ptr<T[]> data_;
std::unique_ptr<T* []> channels_;
std::unique_ptr<T* []> bands_;
const size_t num_frames_;
const size_t num_frames_per_band_;
const size_t num_channels_;

View File

@ -13,7 +13,8 @@
#include <assert.h>
#include <string.h>
#include "webrtc/base/scoped_ptr.h"
#include <memory>
#include "webrtc/common_audio/fir_filter_neon.h"
#include "webrtc/common_audio/fir_filter_sse.h"
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
@ -30,8 +31,8 @@ class FIRFilterC : public FIRFilter {
private:
size_t coefficients_length_;
size_t state_length_;
rtc::scoped_ptr<float[]> coefficients_;
rtc::scoped_ptr<float[]> state_;
std::unique_ptr<float[]> coefficients_;
std::unique_ptr<float[]> state_;
};
FIRFilter* FIRFilter::Create(const float* coefficients,

View File

@ -11,7 +11,8 @@
#ifndef WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_
#define WEBRTC_COMMON_AUDIO_FIR_FILTER_NEON_H_
#include "webrtc/base/scoped_ptr.h"
#include <memory>
#include "webrtc/common_audio/fir_filter.h"
#include "webrtc/system_wrappers/include/aligned_malloc.h"
@ -28,8 +29,8 @@ class FIRFilterNEON : public FIRFilter {
private:
size_t coefficients_length_;
size_t state_length_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> coefficients_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> state_;
std::unique_ptr<float[], AlignedFreeDeleter> coefficients_;
std::unique_ptr<float[], AlignedFreeDeleter> state_;
};
} // namespace webrtc

View File

@ -11,6 +11,7 @@
#include "webrtc/common_audio/fir_filter_sse.h"
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <xmmintrin.h>

View File

@ -11,7 +11,8 @@
#ifndef WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_
#define WEBRTC_COMMON_AUDIO_FIR_FILTER_SSE_H_
#include "webrtc/base/scoped_ptr.h"
#include <memory>
#include "webrtc/common_audio/fir_filter.h"
#include "webrtc/system_wrappers/include/aligned_malloc.h"
@ -28,8 +29,8 @@ class FIRFilterSSE2 : public FIRFilter {
private:
size_t coefficients_length_;
size_t state_length_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> coefficients_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> state_;
std::unique_ptr<float[], AlignedFreeDeleter> coefficients_;
std::unique_ptr<float[], AlignedFreeDeleter> state_;
};
} // namespace webrtc

View File

@ -12,8 +12,9 @@
#include <string.h>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
namespace webrtc {
namespace {
@ -40,7 +41,7 @@ void VerifyOutput(const float* expected_output,
TEST(FIRFilterTest, FilterAsIdentity) {
const float kCoefficients[] = {1.f, 0.f, 0.f, 0.f, 0.f};
float output[kInputLength];
rtc::scoped_ptr<FIRFilter> filter(
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength));
filter->Filter(kInput, kInputLength, output);
@ -50,7 +51,7 @@ TEST(FIRFilterTest, FilterAsIdentity) {
TEST(FIRFilterTest, FilterUsedAsScalarMultiplication) {
const float kCoefficients[] = {5.f, 0.f, 0.f, 0.f, 0.f};
float output[kInputLength];
rtc::scoped_ptr<FIRFilter> filter(
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength));
filter->Filter(kInput, kInputLength, output);
@ -63,7 +64,7 @@ TEST(FIRFilterTest, FilterUsedAsScalarMultiplication) {
TEST(FIRFilterTest, FilterUsedAsInputShifting) {
const float kCoefficients[] = {0.f, 0.f, 0.f, 0.f, 1.f};
float output[kInputLength];
rtc::scoped_ptr<FIRFilter> filter(
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength));
filter->Filter(kInput, kInputLength, output);
@ -76,7 +77,7 @@ TEST(FIRFilterTest, FilterUsedAsInputShifting) {
TEST(FIRFilterTest, FilterUsedAsArbitraryWeighting) {
float output[kInputLength];
rtc::scoped_ptr<FIRFilter> filter(
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength));
filter->Filter(kInput, kInputLength, output);
@ -89,7 +90,7 @@ TEST(FIRFilterTest, FilterUsedAsArbitraryWeighting) {
TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) {
float output[kInputLength];
rtc::scoped_ptr<FIRFilter> filter(
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoefficients, kCoefficientsLength, 2));
filter->Filter(kInput, 2, output);
@ -106,7 +107,7 @@ TEST(FIRFilterTest, FilterInLengthLesserOrEqualToCoefficientsLength) {
TEST(FIRFilterTest, MultipleFilterCalls) {
float output[kInputLength];
rtc::scoped_ptr<FIRFilter> filter(
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoefficients, kCoefficientsLength, 3));
filter->Filter(kInput, 2, output);
EXPECT_FLOAT_EQ(0.2f, output[0]);
@ -137,7 +138,7 @@ TEST(FIRFilterTest, MultipleFilterCalls) {
TEST(FIRFilterTest, VerifySampleBasedVsBlockBasedFiltering) {
float output_block_based[kInputLength];
rtc::scoped_ptr<FIRFilter> filter(
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoefficients, kCoefficientsLength, kInputLength));
filter->Filter(kInput, kInputLength, output_block_based);
@ -162,7 +163,7 @@ TEST(FIRFilterTest, SimplestHighPassFilter) {
sizeof(kConstantInput[0]);
float output[kConstantInputLength];
rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create(
std::unique_ptr<FIRFilter> filter(FIRFilter::Create(
kCoefficients, kCoefficientsLength, kConstantInputLength));
filter->Filter(kConstantInput, kConstantInputLength, output);
EXPECT_FLOAT_EQ(1.f, output[0]);
@ -181,7 +182,7 @@ TEST(FIRFilterTest, SimplestLowPassFilter) {
sizeof(kHighFrequencyInput[0]);
float output[kHighFrequencyInputLength];
rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create(
std::unique_ptr<FIRFilter> filter(FIRFilter::Create(
kCoefficients, kCoefficientsLength, kHighFrequencyInputLength));
filter->Filter(kHighFrequencyInput, kHighFrequencyInputLength, output);
EXPECT_FLOAT_EQ(-1.f, output[0]);
@ -193,7 +194,7 @@ TEST(FIRFilterTest, SimplestLowPassFilter) {
TEST(FIRFilterTest, SameOutputWhenSwapedCoefficientsAndInput) {
float output[kCoefficientsLength];
float output_swaped[kCoefficientsLength];
rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create(
std::unique_ptr<FIRFilter> filter(FIRFilter::Create(
kCoefficients, kCoefficientsLength, kCoefficientsLength));
// Use kCoefficientsLength for in_length to get same-length outputs.
filter->Filter(kInput, kCoefficientsLength, output);

View File

@ -15,7 +15,6 @@
#include <cstring>
#include "webrtc/base/checks.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/typedefs.h"
namespace webrtc {

View File

@ -72,7 +72,8 @@ LappedTransform::LappedTransform(size_t num_in_channels,
window,
shift_amount,
&blocker_callback_),
fft_(RealFourier::Create(RealFourier::FftOrder(block_length_))),
fft_(rtc::ScopedToUnique(
RealFourier::Create(RealFourier::FftOrder(block_length_)))),
cplx_length_(RealFourier::ComplexLength(fft_->order())),
real_buf_(num_in_channels,
block_length_,

View File

@ -12,8 +12,8 @@
#define WEBRTC_COMMON_AUDIO_LAPPED_TRANSFORM_H_
#include <complex>
#include <memory>
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/blocker.h"
#include "webrtc/common_audio/real_fourier.h"
#include "webrtc/system_wrappers/include/aligned_array.h"
@ -112,7 +112,7 @@ class LappedTransform {
Callback* const block_processor_;
Blocker blocker_;
rtc::scoped_ptr<RealFourier> fft_;
std::unique_ptr<RealFourier> fft_;
const size_t cplx_length_;
AlignedArray<float> real_buf_;
AlignedArray<std::complex<float> > cplx_pre_;

View File

@ -12,8 +12,8 @@
#define WEBRTC_COMMON_AUDIO_REAL_FOURIER_OOURA_H_
#include <complex>
#include <memory>
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/real_fourier.h"
namespace webrtc {
@ -35,8 +35,8 @@ class RealFourierOoura : public RealFourier {
const size_t complex_length_;
// These are work arrays for Ooura. The names are based on the comments in
// fft4g.c.
const rtc::scoped_ptr<size_t[]> work_ip_;
const rtc::scoped_ptr<float[]> work_w_;
const std::unique_ptr<size_t[]> work_ip_;
const std::unique_ptr<float[]> work_w_;
};
} // namespace webrtc

View File

@ -13,7 +13,6 @@
#include <stdlib.h>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/real_fourier_openmax.h"
#include "webrtc/common_audio/real_fourier_ooura.h"

View File

@ -11,7 +11,8 @@
#ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_
#define WEBRTC_COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_
#include "webrtc/base/scoped_ptr.h"
#include <memory>
#include "webrtc/typedefs.h"
namespace webrtc {
@ -36,15 +37,15 @@ class PushResampler {
int Resample(const T* src, size_t src_length, T* dst, size_t dst_capacity);
private:
rtc::scoped_ptr<PushSincResampler> sinc_resampler_;
rtc::scoped_ptr<PushSincResampler> sinc_resampler_right_;
std::unique_ptr<PushSincResampler> sinc_resampler_;
std::unique_ptr<PushSincResampler> sinc_resampler_right_;
int src_sample_rate_hz_;
int dst_sample_rate_hz_;
size_t num_channels_;
rtc::scoped_ptr<T[]> src_left_;
rtc::scoped_ptr<T[]> src_right_;
rtc::scoped_ptr<T[]> dst_left_;
rtc::scoped_ptr<T[]> dst_right_;
std::unique_ptr<T[]> src_left_;
std::unique_ptr<T[]> src_right_;
std::unique_ptr<T[]> dst_left_;
std::unique_ptr<T[]> dst_right_;
};
} // namespace webrtc

View File

@ -11,8 +11,9 @@
#ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_
#define WEBRTC_COMMON_AUDIO_RESAMPLER_PUSH_SINC_RESAMPLER_H_
#include <memory>
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/resampler/sinc_resampler.h"
#include "webrtc/typedefs.h"
@ -56,8 +57,8 @@ class PushSincResampler : public SincResamplerCallback {
friend class PushSincResamplerTest;
SincResampler* get_resampler_for_testing() { return resampler_.get(); }
rtc::scoped_ptr<SincResampler> resampler_;
rtc::scoped_ptr<float[]> float_buffer_;
std::unique_ptr<SincResampler> resampler_;
std::unique_ptr<float[]> float_buffer_;
const float* source_ptr_;
const int16_t* source_ptr_int_;
const size_t destination_frames_;

View File

@ -10,10 +10,10 @@
#include <cmath>
#include <cstring>
#include <memory>
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/include/audio_util.h"
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
#include "webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h"
@ -71,10 +71,10 @@ void PushSincResamplerTest::ResampleBenchmarkTest(bool int_format) {
// Source for data to be resampled.
ZeroSource resampler_source;
rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]);
rtc::scoped_ptr<float[]> source(new float[input_samples]);
rtc::scoped_ptr<int16_t[]> source_int(new int16_t[input_samples]);
rtc::scoped_ptr<int16_t[]> destination_int(new int16_t[output_samples]);
std::unique_ptr<float[]> resampled_destination(new float[output_samples]);
std::unique_ptr<float[]> source(new float[input_samples]);
std::unique_ptr<int16_t[]> source_int(new int16_t[input_samples]);
std::unique_ptr<int16_t[]> destination_int(new int16_t[output_samples]);
resampler_source.Run(input_samples, source.get());
for (size_t i = 0; i < input_samples; ++i) {
@ -153,11 +153,11 @@ void PushSincResamplerTest::ResampleTest(bool int_format) {
// TODO(dalecurtis): If we switch to AVX/SSE optimization, we'll need to
// allocate these on 32-byte boundaries and ensure they're sized % 32 bytes.
rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]);
rtc::scoped_ptr<float[]> pure_destination(new float[output_samples]);
rtc::scoped_ptr<float[]> source(new float[input_samples]);
rtc::scoped_ptr<int16_t[]> source_int(new int16_t[input_block_size]);
rtc::scoped_ptr<int16_t[]> destination_int(new int16_t[output_block_size]);
std::unique_ptr<float[]> resampled_destination(new float[output_samples]);
std::unique_ptr<float[]> pure_destination(new float[output_samples]);
std::unique_ptr<float[]> source(new float[input_samples]);
std::unique_ptr<int16_t[]> source_int(new int16_t[input_block_size]);
std::unique_ptr<int16_t[]> destination_int(new int16_t[output_block_size]);
// The sinc resampler has an implicit delay of approximately half the kernel
// size at the input sample rate. By moving to a push model, this delay

View File

@ -14,9 +14,10 @@
#ifndef WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_
#define WEBRTC_COMMON_AUDIO_RESAMPLER_SINC_RESAMPLER_H_
#include <memory>
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/gtest_prod_util.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/aligned_malloc.h"
#include "webrtc/typedefs.h"
@ -137,12 +138,12 @@ class SincResampler {
// Contains kKernelOffsetCount kernels back-to-back, each of size kKernelSize.
// The kernel offsets are sub-sample shifts of a windowed sinc shifted from
// 0.0 to 1.0 sample.
rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_storage_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_window_storage_;
std::unique_ptr<float[], AlignedFreeDeleter> kernel_storage_;
std::unique_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_;
std::unique_ptr<float[], AlignedFreeDeleter> kernel_window_storage_;
// Data from the source is copied into this buffer for each processing pass.
rtc::scoped_ptr<float[], AlignedFreeDeleter> input_buffer_;
std::unique_ptr<float[], AlignedFreeDeleter> input_buffer_;
// Stores the runtime selection of which Convolve function to use.
// TODO(ajm): Move to using a global static which must only be initialized

View File

@ -16,9 +16,10 @@
#include <math.h>
#include <memory>
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/resampler/sinc_resampler.h"
#include "webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h"
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
@ -62,7 +63,7 @@ TEST(SincResamplerTest, ChunkedResample) {
static const int kChunks = 2;
size_t max_chunk_size = resampler.ChunkSize() * kChunks;
rtc::scoped_ptr<float[]> resampled_destination(new float[max_chunk_size]);
std::unique_ptr<float[]> resampled_destination(new float[max_chunk_size]);
// Verify requesting ChunkSize() frames causes a single callback.
EXPECT_CALL(mock_source, Run(_, _))
@ -81,7 +82,7 @@ TEST(SincResamplerTest, Flush) {
MockSource mock_source;
SincResampler resampler(kSampleRateRatio, SincResampler::kDefaultRequestSize,
&mock_source);
rtc::scoped_ptr<float[]> resampled_destination(
std::unique_ptr<float[]> resampled_destination(
new float[resampler.ChunkSize()]);
// Fill the resampler with junk data.
@ -269,7 +270,7 @@ TEST_P(SincResamplerTest, Resample) {
// Force an update to the sample rate ratio to ensure dyanmic sample rate
// changes are working correctly.
rtc::scoped_ptr<float[]> kernel(new float[SincResampler::kKernelStorageSize]);
std::unique_ptr<float[]> kernel(new float[SincResampler::kKernelStorageSize]);
memcpy(kernel.get(), resampler.get_kernel_for_testing(),
SincResampler::kKernelStorageSize);
resampler.SetRatio(M_PI);
@ -281,8 +282,8 @@ TEST_P(SincResamplerTest, Resample) {
// TODO(dalecurtis): If we switch to AVX/SSE optimization, we'll need to
// allocate these on 32-byte boundaries and ensure they're sized % 32 bytes.
rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]);
rtc::scoped_ptr<float[]> pure_destination(new float[output_samples]);
std::unique_ptr<float[]> resampled_destination(new float[output_samples]);
std::unique_ptr<float[]> pure_destination(new float[output_samples]);
// Generate resampled signal.
resampler.Resample(output_samples, resampled_destination.get());

View File

@ -12,10 +12,11 @@
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
namespace webrtc {
@ -24,7 +25,7 @@ struct FreeBufferDeleter {
WebRtc_FreeBuffer(ptr);
}
};
typedef rtc::scoped_ptr<RingBuffer, FreeBufferDeleter> scoped_ring_buffer;
typedef std::unique_ptr<RingBuffer, FreeBufferDeleter> scoped_ring_buffer;
static void AssertElementEq(int expected, int actual) {
ASSERT_EQ(expected, actual);
@ -58,8 +59,8 @@ static void RandomStressTest(int** data_ptr) {
srand(seed);
for (int i = 0; i < kNumTests; i++) {
const int buffer_size = std::max(rand() % kMaxBufferSize, 1);
rtc::scoped_ptr<int[]> write_data(new int[buffer_size]);
rtc::scoped_ptr<int[]> read_data(new int[buffer_size]);
std::unique_ptr<int[]> write_data(new int[buffer_size]);
std::unique_ptr<int[]> read_data(new int[buffer_size]);
scoped_ring_buffer buffer(WebRtc_CreateBuffer(buffer_size, sizeof(int)));
ASSERT_TRUE(buffer.get() != NULL);
WebRtc_InitBuffer(buffer.get());

View File

@ -8,11 +8,12 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <memory>
#include "webrtc/common_audio/sparse_fir_filter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/arraysize.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/fir_filter.h"
namespace webrtc {
@ -214,9 +215,8 @@ TEST(SparseFIRFilterTest, SameOutputAsFIRFilterWhenSparsityOneAndOffsetZero) {
const size_t kOffset = 0;
float output[arraysize(kInput)];
float sparse_output[arraysize(kInput)];
rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create(kCoeffs,
arraysize(kCoeffs),
arraysize(kInput)));
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoeffs, arraysize(kCoeffs), arraysize(kInput)));
SparseFIRFilter sparse_filter(kCoeffs,
arraysize(kCoeffs),
kSparsity,

View File

@ -295,11 +295,11 @@ int AudioProcessingImpl::InitializeLocked() {
formats_.rev_proc_format.num_channels(),
rev_audio_buffer_out_num_frames));
if (rev_conversion_needed()) {
render_.render_converter = rtc::ScopedToUnique(AudioConverter::Create(
render_.render_converter = AudioConverter::Create(
formats_.api_format.reverse_input_stream().num_channels(),
formats_.api_format.reverse_input_stream().num_frames(),
formats_.api_format.reverse_output_stream().num_channels(),
formats_.api_format.reverse_output_stream().num_frames()));
formats_.api_format.reverse_output_stream().num_frames());
} else {
render_.render_converter.reset(nullptr);
}

View File

@ -17,6 +17,7 @@
#include <deque>
#include <set>
#include "webrtc/base/checks.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"
@ -100,13 +101,13 @@ int TransientSuppressor::Initialize(int sample_rate_hz,
detector_.reset(new TransientDetector(detection_rate_hz));
data_length_ = sample_rate_hz * ts::kChunkSizeMs / 1000;
if (data_length_ > analysis_length_) {
assert(false);
RTC_NOTREACHED();
return -1;
}
buffer_delay_ = analysis_length_ - data_length_;
complex_analysis_length_ = analysis_length_ / 2 + 1;
assert(complex_analysis_length_ >= kMaxVoiceBin);
RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin);
num_channels_ = num_channels;
in_buffer_.reset(new float[analysis_length_ * num_channels_]);
memset(in_buffer_.get(),