Revert of Replace scoped_ptr with unique_ptr in webrtc/common_audio/ (patchset #4 id:60001 of https://codereview.webrtc.org/1712513002/ )

Reason for revert:
Breaks downstream compilation using webrtc/common_audio/real_fourier.h. Let's chat tomorrow on how to coordinate a re-land.

Original issue's description:
> Replace scoped_ptr with unique_ptr in webrtc/common_audio/
>
> BUG=webrtc:5520
>
> Committed: https://crrev.com/79d7a499c0c3e1de8f5ad1138236f0386701053f
> Cr-Commit-Position: refs/heads/master@{#11716}

TBR=henrik.lundin@webrtc.org,kwiberg@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5520

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

Cr-Commit-Position: refs/heads/master@{#11726}
This commit is contained in:
kjellander 2016-02-23 13:33:32 -08:00 committed by Commit bot
parent 9788534c77
commit e80f9d0218
29 changed files with 95 additions and 113 deletions

View File

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

View File

@ -11,9 +11,8 @@
#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 {
@ -27,7 +26,7 @@ class AudioConverter {
public:
// Returns a new AudioConverter, which will use the supplied format for its
// lifetime. Caller is responsible for the memory.
static std::unique_ptr<AudioConverter> Create(size_t src_channels,
static rtc::scoped_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 std::unique_ptr<ChannelBuffer<float>> ScopedBuffer;
typedef rtc::scoped_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);
std::unique_ptr<AudioConverter> converter = AudioConverter::Create(
rtc::scoped_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 unique_ptr for instance.)
// deleter (like scoped_ptr for instance.)
std::vector<RingBuffer*> buffers_;
};

View File

@ -8,8 +8,6 @@
* 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"
@ -29,7 +27,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);
std::unique_ptr<float* []> slice(new float*[num_channels]);
rtc::scoped_ptr<float* []> slice(new float* [num_channels]);
size_t input_pos = 0;
size_t output_pos = 0;

View File

@ -11,8 +11,7 @@
#ifndef WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_
#define WEBRTC_INTERNAL_BEAMFORMER_BLOCKER_H_
#include <memory>
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_audio/audio_ring_buffer.h"
#include "webrtc/common_audio/channel_buffer.h"
@ -110,7 +109,7 @@ class Blocker {
// Space for the output block (can't wrap because of overlap/add).
ChannelBuffer<float> output_block_;
std::unique_ptr<float[]> window_;
rtc::scoped_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,8 +8,6 @@
* 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"
@ -309,7 +307,7 @@ TEST_F(BlockerTest, InitialDelaysAreMinimum) {
CopyBlockerCallback callback;
for (size_t i = 0; i < arraysize(kChunkSize); ++i) {
std::unique_ptr<float[]> window(new float[kBlockSize[i]]);
rtc::scoped_ptr<float[]> window(new float[kBlockSize[i]]);
for (size_t j = 0; j < kBlockSize[i]; ++j) {
window[j] = 1.f;
}

View File

@ -10,8 +10,6 @@
#include "webrtc/common_audio/channel_buffer.h"
#include "webrtc/base/checks.h"
namespace webrtc {
IFChannelBuffer::IFChannelBuffer(size_t num_frames,
@ -46,7 +44,7 @@ const ChannelBuffer<float>* IFChannelBuffer::fbuf_const() const {
void IFChannelBuffer::RefreshF() const {
if (!fvalid_) {
RTC_DCHECK(ivalid_);
assert(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) {
@ -60,7 +58,7 @@ void IFChannelBuffer::RefreshF() const {
void IFChannelBuffer::RefreshI() const {
if (!ivalid_) {
RTC_DCHECK(fvalid_);
assert(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,10 +13,9 @@
#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 {
@ -126,9 +125,9 @@ class ChannelBuffer {
}
private:
std::unique_ptr<T[]> data_;
std::unique_ptr<T* []> channels_;
std::unique_ptr<T* []> bands_;
rtc::scoped_ptr<T[]> data_;
rtc::scoped_ptr<T* []> channels_;
rtc::scoped_ptr<T* []> bands_;
const size_t num_frames_;
const size_t num_frames_per_band_;
const size_t num_channels_;

View File

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

View File

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

View File

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

View File

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

View File

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

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_;
std::unique_ptr<RealFourier> fft_;
rtc::scoped_ptr<RealFourier> fft_;
const size_t cplx_length_;
AlignedArray<float> real_buf_;
AlignedArray<std::complex<float> > cplx_pre_;

View File

@ -21,11 +21,11 @@ using std::complex;
const size_t RealFourier::kFftBufferAlignment = 32;
std::unique_ptr<RealFourier> RealFourier::Create(int fft_order) {
rtc::scoped_ptr<RealFourier> RealFourier::Create(int fft_order) {
#if defined(RTC_USE_OPENMAX_DL)
return std::unique_ptr<RealFourier>(new RealFourierOpenmax(fft_order));
return rtc::scoped_ptr<RealFourier>(new RealFourierOpenmax(fft_order));
#else
return std::unique_ptr<RealFourier>(new RealFourierOoura(fft_order));
return rtc::scoped_ptr<RealFourier>(new RealFourierOoura(fft_order));
#endif
}

View File

@ -12,8 +12,8 @@
#define WEBRTC_COMMON_AUDIO_REAL_FOURIER_H_
#include <complex>
#include <memory>
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/system_wrappers/include/aligned_malloc.h"
// Uniform interface class for the real DFT and its inverse, for power-of-2
@ -25,8 +25,8 @@ namespace webrtc {
class RealFourier {
public:
// Shorthand typenames for the scopers used by the buffer allocation helpers.
typedef std::unique_ptr<float[], AlignedFreeDeleter> fft_real_scoper;
typedef std::unique_ptr<std::complex<float>[], AlignedFreeDeleter>
typedef rtc::scoped_ptr<float[], AlignedFreeDeleter> fft_real_scoper;
typedef rtc::scoped_ptr<std::complex<float>[], AlignedFreeDeleter>
fft_cplx_scoper;
// The alignment required for all input and output buffers, in bytes.
@ -34,7 +34,7 @@ class RealFourier {
// Construct a wrapper instance for the given input order, which must be
// between 1 and kMaxFftOrder, inclusively.
static std::unique_ptr<RealFourier> Create(int fft_order);
static rtc::scoped_ptr<RealFourier> Create(int fft_order);
virtual ~RealFourier() {};
// Helper to compute the smallest FFT order (a power of 2) which will contain

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 std::unique_ptr<size_t[]> work_ip_;
const std::unique_ptr<float[]> work_w_;
const rtc::scoped_ptr<size_t[]> work_ip_;
const rtc::scoped_ptr<float[]> work_w_;
};
} // namespace webrtc

View File

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

View File

@ -11,9 +11,8 @@
#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"
@ -57,8 +56,8 @@ class PushSincResampler : public SincResamplerCallback {
friend class PushSincResamplerTest;
SincResampler* get_resampler_for_testing() { return resampler_.get(); }
std::unique_ptr<SincResampler> resampler_;
std::unique_ptr<float[]> float_buffer_;
rtc::scoped_ptr<SincResampler> resampler_;
rtc::scoped_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;
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]);
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]);
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.
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]);
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]);
// 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,10 +14,9 @@
#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"
@ -138,12 +137,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.
std::unique_ptr<float[], AlignedFreeDeleter> kernel_storage_;
std::unique_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_;
std::unique_ptr<float[], AlignedFreeDeleter> kernel_window_storage_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_storage_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_pre_sinc_storage_;
rtc::scoped_ptr<float[], AlignedFreeDeleter> kernel_window_storage_;
// Data from the source is copied into this buffer for each processing pass.
std::unique_ptr<float[], AlignedFreeDeleter> input_buffer_;
rtc::scoped_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,10 +16,9 @@
#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"
@ -63,7 +62,7 @@ TEST(SincResamplerTest, ChunkedResample) {
static const int kChunks = 2;
size_t max_chunk_size = resampler.ChunkSize() * kChunks;
std::unique_ptr<float[]> resampled_destination(new float[max_chunk_size]);
rtc::scoped_ptr<float[]> resampled_destination(new float[max_chunk_size]);
// Verify requesting ChunkSize() frames causes a single callback.
EXPECT_CALL(mock_source, Run(_, _))
@ -82,7 +81,7 @@ TEST(SincResamplerTest, Flush) {
MockSource mock_source;
SincResampler resampler(kSampleRateRatio, SincResampler::kDefaultRequestSize,
&mock_source);
std::unique_ptr<float[]> resampled_destination(
rtc::scoped_ptr<float[]> resampled_destination(
new float[resampler.ChunkSize()]);
// Fill the resampler with junk data.
@ -270,7 +269,7 @@ TEST_P(SincResamplerTest, Resample) {
// Force an update to the sample rate ratio to ensure dyanmic sample rate
// changes are working correctly.
std::unique_ptr<float[]> kernel(new float[SincResampler::kKernelStorageSize]);
rtc::scoped_ptr<float[]> kernel(new float[SincResampler::kKernelStorageSize]);
memcpy(kernel.get(), resampler.get_kernel_for_testing(),
SincResampler::kKernelStorageSize);
resampler.SetRatio(M_PI);
@ -282,8 +281,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.
std::unique_ptr<float[]> resampled_destination(new float[output_samples]);
std::unique_ptr<float[]> pure_destination(new float[output_samples]);
rtc::scoped_ptr<float[]> resampled_destination(new float[output_samples]);
rtc::scoped_ptr<float[]> pure_destination(new float[output_samples]);
// Generate resampled signal.
resampler.Resample(output_samples, resampled_destination.get());

View File

@ -12,11 +12,10 @@
#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 {
@ -25,7 +24,7 @@ struct FreeBufferDeleter {
WebRtc_FreeBuffer(ptr);
}
};
typedef std::unique_ptr<RingBuffer, FreeBufferDeleter> scoped_ring_buffer;
typedef rtc::scoped_ptr<RingBuffer, FreeBufferDeleter> scoped_ring_buffer;
static void AssertElementEq(int expected, int actual) {
ASSERT_EQ(expected, actual);
@ -59,8 +58,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);
std::unique_ptr<int[]> write_data(new int[buffer_size]);
std::unique_ptr<int[]> read_data(new int[buffer_size]);
rtc::scoped_ptr<int[]> write_data(new int[buffer_size]);
rtc::scoped_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,12 +8,11 @@
* 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 {
@ -215,8 +214,9 @@ TEST(SparseFIRFilterTest, SameOutputAsFIRFilterWhenSparsityOneAndOffsetZero) {
const size_t kOffset = 0;
float output[arraysize(kInput)];
float sparse_output[arraysize(kInput)];
std::unique_ptr<FIRFilter> filter(
FIRFilter::Create(kCoeffs, arraysize(kCoeffs), arraysize(kInput)));
rtc::scoped_ptr<FIRFilter> filter(FIRFilter::Create(kCoeffs,
arraysize(kCoeffs),
arraysize(kInput)));
SparseFIRFilter sparse_filter(kCoeffs,
arraysize(kCoeffs),
kSparsity,

View File

@ -297,11 +297,11 @@ int AudioProcessingImpl::InitializeLocked() {
formats_.rev_proc_format.num_channels(),
rev_audio_buffer_out_num_frames));
if (rev_conversion_needed()) {
render_.render_converter = AudioConverter::Create(
render_.render_converter = rtc::ScopedToUnique(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,7 +17,6 @@
#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"
@ -101,13 +100,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_) {
RTC_NOTREACHED();
assert(false);
return -1;
}
buffer_delay_ = analysis_length_ - data_length_;
complex_analysis_length_ = analysis_length_ / 2 + 1;
RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin);
assert(complex_analysis_length_ >= kMaxVoiceBin);
num_channels_ = num_channels;
in_buffer_.reset(new float[analysis_length_ * num_channels_]);
memset(in_buffer_.get(),