Replace scoped_ptr with unique_ptr in webrtc/modules/audio_processing/test/
BUG=webrtc:5520 Review URL: https://codereview.webrtc.org/1694423002 Cr-Commit-Position: refs/heads/master@{#11653}
This commit is contained in:
parent
28c99bc44a
commit
62eaacf5ee
@ -16,7 +16,6 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
|
||||
|
||||
using rtc::scoped_ptr;
|
||||
using rtc::CheckedDivExact;
|
||||
using std::vector;
|
||||
using webrtc::audioproc::Event;
|
||||
@ -41,9 +40,9 @@ ChannelBuffer<float> GetChannelBuffer(const WavFile& file) {
|
||||
|
||||
} // namespace
|
||||
|
||||
WavFileProcessor::WavFileProcessor(scoped_ptr<AudioProcessing> ap,
|
||||
scoped_ptr<WavReader> in_file,
|
||||
scoped_ptr<WavWriter> out_file)
|
||||
WavFileProcessor::WavFileProcessor(std::unique_ptr<AudioProcessing> ap,
|
||||
std::unique_ptr<WavReader> in_file,
|
||||
std::unique_ptr<WavWriter> out_file)
|
||||
: ap_(std::move(ap)),
|
||||
in_buf_(GetChannelBuffer(*in_file)),
|
||||
out_buf_(GetChannelBuffer(*out_file)),
|
||||
@ -66,9 +65,9 @@ bool WavFileProcessor::ProcessChunk() {
|
||||
return true;
|
||||
}
|
||||
|
||||
AecDumpFileProcessor::AecDumpFileProcessor(scoped_ptr<AudioProcessing> ap,
|
||||
AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap,
|
||||
FILE* dump_file,
|
||||
scoped_ptr<WavWriter> out_file)
|
||||
std::unique_ptr<WavWriter> out_file)
|
||||
: ap_(std::move(ap)),
|
||||
dump_file_(dump_file),
|
||||
out_buf_(GetChannelBuffer(*out_file)),
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/channel_buffer.h"
|
||||
#include "webrtc/common_audio/wav_file.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
@ -84,16 +84,16 @@ class AudioFileProcessor {
|
||||
class WavFileProcessor final : public AudioFileProcessor {
|
||||
public:
|
||||
// Takes ownership of all parameters.
|
||||
WavFileProcessor(rtc::scoped_ptr<AudioProcessing> ap,
|
||||
rtc::scoped_ptr<WavReader> in_file,
|
||||
rtc::scoped_ptr<WavWriter> out_file);
|
||||
WavFileProcessor(std::unique_ptr<AudioProcessing> ap,
|
||||
std::unique_ptr<WavReader> in_file,
|
||||
std::unique_ptr<WavWriter> out_file);
|
||||
virtual ~WavFileProcessor() {}
|
||||
|
||||
// Processes one chunk from the WAV input and writes to the WAV output.
|
||||
bool ProcessChunk() override;
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<AudioProcessing> ap_;
|
||||
std::unique_ptr<AudioProcessing> ap_;
|
||||
|
||||
ChannelBuffer<float> in_buf_;
|
||||
ChannelBuffer<float> out_buf_;
|
||||
@ -107,9 +107,9 @@ class WavFileProcessor final : public AudioFileProcessor {
|
||||
class AecDumpFileProcessor final : public AudioFileProcessor {
|
||||
public:
|
||||
// Takes ownership of all parameters.
|
||||
AecDumpFileProcessor(rtc::scoped_ptr<AudioProcessing> ap,
|
||||
AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap,
|
||||
FILE* dump_file,
|
||||
rtc::scoped_ptr<WavWriter> out_file);
|
||||
std::unique_ptr<WavWriter> out_file);
|
||||
|
||||
virtual ~AecDumpFileProcessor();
|
||||
|
||||
@ -122,11 +122,11 @@ class AecDumpFileProcessor final : public AudioFileProcessor {
|
||||
void HandleMessage(const webrtc::audioproc::Stream& msg);
|
||||
void HandleMessage(const webrtc::audioproc::ReverseStream& msg);
|
||||
|
||||
rtc::scoped_ptr<AudioProcessing> ap_;
|
||||
std::unique_ptr<AudioProcessing> ap_;
|
||||
FILE* dump_file_;
|
||||
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> in_buf_;
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> reverse_buf_;
|
||||
std::unique_ptr<ChannelBuffer<float>> in_buf_;
|
||||
std::unique_ptr<ChannelBuffer<float>> reverse_buf_;
|
||||
ChannelBuffer<float> out_buf_;
|
||||
StreamConfig input_config_;
|
||||
StreamConfig reverse_config_;
|
||||
|
||||
@ -10,12 +10,13 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/common_audio/resampler/include/push_resampler.h"
|
||||
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
|
||||
@ -226,7 +227,7 @@ void OpenFileAndWriteMessage(const std::string filename,
|
||||
|
||||
int32_t size = msg.ByteSize();
|
||||
ASSERT_GT(size, 0);
|
||||
rtc::scoped_ptr<uint8_t[]> array(new uint8_t[size]);
|
||||
std::unique_ptr<uint8_t[]> array(new uint8_t[size]);
|
||||
ASSERT_TRUE(msg.SerializeToArray(array.get(), size));
|
||||
|
||||
ASSERT_EQ(1u, fwrite(&size, sizeof(size), 1, file));
|
||||
@ -390,11 +391,11 @@ class ApmTest : public ::testing::Test {
|
||||
const std::string output_path_;
|
||||
const std::string ref_path_;
|
||||
const std::string ref_filename_;
|
||||
rtc::scoped_ptr<AudioProcessing> apm_;
|
||||
std::unique_ptr<AudioProcessing> apm_;
|
||||
AudioFrame* frame_;
|
||||
AudioFrame* revframe_;
|
||||
rtc::scoped_ptr<ChannelBuffer<float> > float_cb_;
|
||||
rtc::scoped_ptr<ChannelBuffer<float> > revfloat_cb_;
|
||||
std::unique_ptr<ChannelBuffer<float> > float_cb_;
|
||||
std::unique_ptr<ChannelBuffer<float> > revfloat_cb_;
|
||||
int output_sample_rate_hz_;
|
||||
size_t num_output_channels_;
|
||||
FILE* far_file_;
|
||||
@ -1079,8 +1080,8 @@ TEST_F(ApmTest, EchoControlMobile) {
|
||||
// Set and get echo path
|
||||
const size_t echo_path_size =
|
||||
apm_->echo_control_mobile()->echo_path_size_bytes();
|
||||
rtc::scoped_ptr<char[]> echo_path_in(new char[echo_path_size]);
|
||||
rtc::scoped_ptr<char[]> echo_path_out(new char[echo_path_size]);
|
||||
std::unique_ptr<char[]> echo_path_in(new char[echo_path_size]);
|
||||
std::unique_ptr<char[]> echo_path_out(new char[echo_path_size]);
|
||||
EXPECT_EQ(apm_->kNullPointerError,
|
||||
apm_->echo_control_mobile()->SetEchoPath(NULL, echo_path_size));
|
||||
EXPECT_EQ(apm_->kNullPointerError,
|
||||
@ -1305,15 +1306,15 @@ TEST_F(ApmTest, AgcOnlyAdaptsWhenTargetSignalIsPresent) {
|
||||
config.Set<Beamforming>(new Beamforming(true, geometry));
|
||||
testing::NiceMock<MockNonlinearBeamformer>* beamformer =
|
||||
new testing::NiceMock<MockNonlinearBeamformer>(geometry);
|
||||
rtc::scoped_ptr<AudioProcessing> apm(
|
||||
std::unique_ptr<AudioProcessing> apm(
|
||||
AudioProcessing::Create(config, beamformer));
|
||||
EXPECT_EQ(kNoErr, apm->gain_control()->Enable(true));
|
||||
ChannelBuffer<float> src_buf(kSamplesPerChannel, kNumInputChannels);
|
||||
ChannelBuffer<float> dest_buf(kSamplesPerChannel, kNumOutputChannels);
|
||||
const size_t max_length = kSamplesPerChannel * std::max(kNumInputChannels,
|
||||
kNumOutputChannels);
|
||||
rtc::scoped_ptr<int16_t[]> int_data(new int16_t[max_length]);
|
||||
rtc::scoped_ptr<float[]> float_data(new float[max_length]);
|
||||
std::unique_ptr<int16_t[]> int_data(new int16_t[max_length]);
|
||||
std::unique_ptr<float[]> float_data(new float[max_length]);
|
||||
std::string filename = ResourceFilePath("far", kSampleRateHz);
|
||||
FILE* far_file = fopen(filename.c_str(), "rb");
|
||||
ASSERT_TRUE(far_file != NULL) << "Could not open file " << filename << "\n";
|
||||
@ -1828,9 +1829,9 @@ void ApmTest::VerifyDebugDumpTest(Format format) {
|
||||
ASSERT_TRUE(ref_file != NULL);
|
||||
ASSERT_TRUE(out_file != NULL);
|
||||
ASSERT_TRUE(limited_file != NULL);
|
||||
rtc::scoped_ptr<uint8_t[]> ref_bytes;
|
||||
rtc::scoped_ptr<uint8_t[]> out_bytes;
|
||||
rtc::scoped_ptr<uint8_t[]> limited_bytes;
|
||||
std::unique_ptr<uint8_t[]> ref_bytes;
|
||||
std::unique_ptr<uint8_t[]> out_bytes;
|
||||
std::unique_ptr<uint8_t[]> limited_bytes;
|
||||
|
||||
size_t ref_size = ReadMessageBytesFromFile(ref_file, &ref_bytes);
|
||||
size_t out_size = ReadMessageBytesFromFile(out_file, &out_bytes);
|
||||
@ -1944,7 +1945,7 @@ TEST_F(ApmTest, FloatAndIntInterfacesGiveSimilarResults) {
|
||||
|
||||
Config config;
|
||||
config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
|
||||
rtc::scoped_ptr<AudioProcessing> fapm(AudioProcessing::Create(config));
|
||||
std::unique_ptr<AudioProcessing> fapm(AudioProcessing::Create(config));
|
||||
EnableAllComponents();
|
||||
EnableAllAPComponents(fapm.get());
|
||||
for (int i = 0; i < ref_data.test_size(); i++) {
|
||||
@ -2285,7 +2286,7 @@ TEST_F(ApmTest, NoErrorsWithKeyboardChannel) {
|
||||
{AudioProcessing::kStereoAndKeyboard, AudioProcessing::kStereo},
|
||||
};
|
||||
|
||||
rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create());
|
||||
std::unique_ptr<AudioProcessing> ap(AudioProcessing::Create());
|
||||
// Enable one component just to ensure some processing takes place.
|
||||
ap->noise_suppression()->Enable(true);
|
||||
for (size_t i = 0; i < arraysize(cf); ++i) {
|
||||
@ -2410,7 +2411,7 @@ class AudioProcessingTest
|
||||
std::string output_file_prefix) {
|
||||
Config config;
|
||||
config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
|
||||
rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config));
|
||||
std::unique_ptr<AudioProcessing> ap(AudioProcessing::Create(config));
|
||||
EnableAllAPComponents(ap.get());
|
||||
|
||||
ProcessingConfig processing_config = {
|
||||
@ -2455,8 +2456,8 @@ class AudioProcessingTest
|
||||
const int max_length =
|
||||
2 * std::max(std::max(out_cb.num_frames(), rev_out_cb.num_frames()),
|
||||
std::max(fwd_cb.num_frames(), rev_cb.num_frames()));
|
||||
rtc::scoped_ptr<float[]> float_data(new float[max_length]);
|
||||
rtc::scoped_ptr<int16_t[]> int_data(new int16_t[max_length]);
|
||||
std::unique_ptr<float[]> float_data(new float[max_length]);
|
||||
std::unique_ptr<int16_t[]> int_data(new int16_t[max_length]);
|
||||
|
||||
int analog_level = 127;
|
||||
while (ReadChunk(far_file, int_data.get(), float_data.get(), &rev_cb) &&
|
||||
@ -2583,12 +2584,12 @@ TEST_P(AudioProcessingTest, Formats) {
|
||||
const size_t ref_length = SamplesFromRate(ref_rate) * out_num;
|
||||
const size_t out_length = SamplesFromRate(out_rate) * out_num;
|
||||
// Data from the reference file.
|
||||
rtc::scoped_ptr<float[]> ref_data(new float[ref_length]);
|
||||
std::unique_ptr<float[]> ref_data(new float[ref_length]);
|
||||
// Data from the output file.
|
||||
rtc::scoped_ptr<float[]> out_data(new float[out_length]);
|
||||
std::unique_ptr<float[]> out_data(new float[out_length]);
|
||||
// Data from the resampled output, in case the reference and output rates
|
||||
// don't match.
|
||||
rtc::scoped_ptr<float[]> cmp_data(new float[ref_length]);
|
||||
std::unique_ptr<float[]> cmp_data(new float[ref_length]);
|
||||
|
||||
PushResampler<float> resampler;
|
||||
resampler.InitializeIfNeeded(out_rate, ref_rate, out_num);
|
||||
|
||||
@ -9,7 +9,9 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -17,7 +19,6 @@
|
||||
#include "gflags/gflags.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/channel_buffer.h"
|
||||
#include "webrtc/common_audio/wav_file.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
@ -115,7 +116,7 @@ int main(int argc, char* argv[]) {
|
||||
config.Set<ExperimentalNs>(new ExperimentalNs(FLAGS_ts || FLAGS_all));
|
||||
config.Set<Intelligibility>(new Intelligibility(FLAGS_ie || FLAGS_all));
|
||||
|
||||
rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config));
|
||||
std::unique_ptr<AudioProcessing> ap(AudioProcessing::Create(config));
|
||||
RTC_CHECK_EQ(kNoErr, ap->echo_cancellation()->Enable(FLAGS_aec || FLAGS_all));
|
||||
RTC_CHECK_EQ(kNoErr, ap->gain_control()->Enable(FLAGS_agc || FLAGS_all));
|
||||
RTC_CHECK_EQ(kNoErr, ap->high_pass_filter()->Enable(FLAGS_hpf || FLAGS_all));
|
||||
@ -127,12 +128,12 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
ap->set_stream_key_pressed(FLAGS_ts);
|
||||
|
||||
rtc::scoped_ptr<AudioFileProcessor> processor;
|
||||
auto out_file = rtc_make_scoped_ptr(new WavWriter(
|
||||
std::unique_ptr<AudioFileProcessor> processor;
|
||||
auto out_file = std::unique_ptr<WavWriter>(new WavWriter(
|
||||
FLAGS_o, FLAGS_out_sample_rate, static_cast<size_t>(FLAGS_out_channels)));
|
||||
std::cout << FLAGS_o << ": " << out_file->FormatAsString() << std::endl;
|
||||
if (FLAGS_dump.empty()) {
|
||||
auto in_file = rtc_make_scoped_ptr(new WavReader(FLAGS_i));
|
||||
auto in_file = std::unique_ptr<WavReader>(new WavReader(FLAGS_i));
|
||||
std::cout << FLAGS_i << ": " << in_file->FormatAsString() << std::endl;
|
||||
processor.reset(new WavFileProcessor(std::move(ap), std::move(in_file),
|
||||
std::move(out_file)));
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/channel_buffer.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h"
|
||||
#include "webrtc/modules/audio_processing/debug.pb.h"
|
||||
@ -28,7 +29,7 @@ namespace test {
|
||||
|
||||
namespace {
|
||||
|
||||
void MaybeResetBuffer(rtc::scoped_ptr<ChannelBuffer<float>>* buffer,
|
||||
void MaybeResetBuffer(std::unique_ptr<ChannelBuffer<float>>* buffer,
|
||||
const StreamConfig& config) {
|
||||
auto& buffer_ref = *buffer;
|
||||
if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() ||
|
||||
@ -101,11 +102,11 @@ class DebugDumpGenerator {
|
||||
const int reverse_file_channels_;
|
||||
|
||||
// Buffer for APM input/output.
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> input_;
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> reverse_;
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> output_;
|
||||
std::unique_ptr<ChannelBuffer<float>> input_;
|
||||
std::unique_ptr<ChannelBuffer<float>> reverse_;
|
||||
std::unique_ptr<ChannelBuffer<float>> output_;
|
||||
|
||||
rtc::scoped_ptr<AudioProcessing> apm_;
|
||||
std::unique_ptr<AudioProcessing> apm_;
|
||||
|
||||
const std::string dump_file_name_;
|
||||
};
|
||||
@ -250,11 +251,11 @@ class DebugDumpTest : public ::testing::Test {
|
||||
void ConfigureApm(const audioproc::Config& msg);
|
||||
|
||||
// Buffer for APM input/output.
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> input_;
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> reverse_;
|
||||
rtc::scoped_ptr<ChannelBuffer<float>> output_;
|
||||
std::unique_ptr<ChannelBuffer<float>> input_;
|
||||
std::unique_ptr<ChannelBuffer<float>> reverse_;
|
||||
std::unique_ptr<ChannelBuffer<float>> output_;
|
||||
|
||||
rtc::scoped_ptr<AudioProcessing> apm_;
|
||||
std::unique_ptr<AudioProcessing> apm_;
|
||||
|
||||
StreamConfig input_config_;
|
||||
StreamConfig reverse_config_;
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
|
||||
@ -147,7 +147,7 @@ void void_main(int argc, char* argv[]) {
|
||||
printf("Try `process_test --help' for more information.\n\n");
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<AudioProcessing> apm(AudioProcessing::Create());
|
||||
std::unique_ptr<AudioProcessing> apm(AudioProcessing::Create());
|
||||
ASSERT_TRUE(apm.get() != NULL);
|
||||
|
||||
const char* pb_filename = NULL;
|
||||
@ -495,8 +495,8 @@ void void_main(int argc, char* argv[]) {
|
||||
FILE* aecm_echo_path_in_file = NULL;
|
||||
FILE* aecm_echo_path_out_file = NULL;
|
||||
|
||||
rtc::scoped_ptr<WavWriter> output_wav_file;
|
||||
rtc::scoped_ptr<RawFile> output_raw_file;
|
||||
std::unique_ptr<WavWriter> output_wav_file;
|
||||
std::unique_ptr<RawFile> output_raw_file;
|
||||
|
||||
if (pb_filename) {
|
||||
pb_file = OpenFile(pb_filename, "rb");
|
||||
@ -538,7 +538,7 @@ void void_main(int argc, char* argv[]) {
|
||||
|
||||
const size_t path_size =
|
||||
apm->echo_control_mobile()->echo_path_size_bytes();
|
||||
rtc::scoped_ptr<char[]> echo_path(new char[path_size]);
|
||||
std::unique_ptr<char[]> echo_path(new char[path_size]);
|
||||
ASSERT_EQ(path_size, fread(echo_path.get(),
|
||||
sizeof(char),
|
||||
path_size,
|
||||
@ -580,8 +580,8 @@ void void_main(int argc, char* argv[]) {
|
||||
// but for now we want to share the variables.
|
||||
if (pb_file) {
|
||||
Event event_msg;
|
||||
rtc::scoped_ptr<ChannelBuffer<float> > reverse_cb;
|
||||
rtc::scoped_ptr<ChannelBuffer<float> > primary_cb;
|
||||
std::unique_ptr<ChannelBuffer<float> > reverse_cb;
|
||||
std::unique_ptr<ChannelBuffer<float> > primary_cb;
|
||||
int output_sample_rate = 32000;
|
||||
AudioProcessing::ChannelLayout output_layout = AudioProcessing::kMono;
|
||||
while (ReadMessageFromFile(pb_file, &event_msg)) {
|
||||
@ -1061,7 +1061,7 @@ void void_main(int argc, char* argv[]) {
|
||||
if (aecm_echo_path_out_file != NULL) {
|
||||
const size_t path_size =
|
||||
apm->echo_control_mobile()->echo_path_size_bytes();
|
||||
rtc::scoped_ptr<char[]> echo_path(new char[path_size]);
|
||||
std::unique_ptr<char[]> echo_path(new char[path_size]);
|
||||
apm->echo_control_mobile()->GetEchoPath(echo_path.get(), path_size);
|
||||
ASSERT_EQ(path_size, fwrite(echo_path.get(),
|
||||
sizeof(char),
|
||||
|
||||
@ -9,10 +9,11 @@
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
size_t ReadMessageBytesFromFile(FILE* file, rtc::scoped_ptr<uint8_t[]>* bytes) {
|
||||
size_t ReadMessageBytesFromFile(FILE* file, std::unique_ptr<uint8_t[]>* bytes) {
|
||||
// The "wire format" for the size is little-endian. Assume we're running on
|
||||
// a little-endian machine.
|
||||
#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
|
||||
@ -30,7 +31,7 @@ size_t ReadMessageBytesFromFile(FILE* file, rtc::scoped_ptr<uint8_t[]>* bytes) {
|
||||
|
||||
// Returns true on success, false on error or end-of-file.
|
||||
bool ReadMessageFromFile(FILE* file, ::google::protobuf::MessageLite* msg) {
|
||||
rtc::scoped_ptr<uint8_t[]> bytes;
|
||||
std::unique_ptr<uint8_t[]> bytes;
|
||||
size_t size = ReadMessageBytesFromFile(file, &bytes);
|
||||
if (!size)
|
||||
return false;
|
||||
|
||||
@ -11,14 +11,15 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_PROTOBUF_UTILS_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_PROTOBUF_UTILS_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/audio_processing/debug.pb.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Allocates new memory in the scoped_ptr to fit the raw message and returns the
|
||||
// Allocates new memory in the unique_ptr to fit the raw message and returns the
|
||||
// number of bytes read.
|
||||
size_t ReadMessageBytesFromFile(FILE* file, rtc::scoped_ptr<uint8_t[]>* bytes);
|
||||
size_t ReadMessageBytesFromFile(FILE* file, std::unique_ptr<uint8_t[]>* bytes);
|
||||
|
||||
// Returns true on success, false on error or end-of-file.
|
||||
bool ReadMessageFromFile(FILE* file, ::google::protobuf::MessageLite* msg);
|
||||
|
||||
@ -33,7 +33,7 @@ void RawFile::WriteSamples(const float* samples, size_t num_samples) {
|
||||
fwrite(samples, sizeof(*samples), num_samples, file_handle_);
|
||||
}
|
||||
|
||||
ChannelBufferWavReader::ChannelBufferWavReader(rtc::scoped_ptr<WavReader> file)
|
||||
ChannelBufferWavReader::ChannelBufferWavReader(std::unique_ptr<WavReader> file)
|
||||
: file_(std::move(file)) {}
|
||||
|
||||
bool ChannelBufferWavReader::Read(ChannelBuffer<float>* buffer) {
|
||||
@ -50,7 +50,7 @@ bool ChannelBufferWavReader::Read(ChannelBuffer<float>* buffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ChannelBufferWavWriter::ChannelBufferWavWriter(rtc::scoped_ptr<WavWriter> file)
|
||||
ChannelBufferWavWriter::ChannelBufferWavWriter(std::unique_ptr<WavWriter> file)
|
||||
: file_(std::move(file)) {}
|
||||
|
||||
void ChannelBufferWavWriter::Write(const ChannelBuffer<float>& buffer) {
|
||||
@ -80,7 +80,7 @@ void WriteFloatData(const float* const* data,
|
||||
WavWriter* wav_file,
|
||||
RawFile* raw_file) {
|
||||
size_t length = num_channels * samples_per_channel;
|
||||
rtc::scoped_ptr<float[]> buffer(new float[length]);
|
||||
std::unique_ptr<float[]> buffer(new float[length]);
|
||||
Interleave(data, samples_per_channel, num_channels, buffer.get());
|
||||
if (raw_file) {
|
||||
raw_file->WriteSamples(buffer.get(), length);
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
#include <math.h>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_audio/channel_buffer.h"
|
||||
#include "webrtc/common_audio/wav_file.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
@ -46,14 +46,14 @@ class RawFile final {
|
||||
// Reads ChannelBuffers from a provided WavReader.
|
||||
class ChannelBufferWavReader final {
|
||||
public:
|
||||
explicit ChannelBufferWavReader(rtc::scoped_ptr<WavReader> file);
|
||||
explicit ChannelBufferWavReader(std::unique_ptr<WavReader> file);
|
||||
|
||||
// Reads data from the file according to the |buffer| format. Returns false if
|
||||
// a full buffer can't be read from the file.
|
||||
bool Read(ChannelBuffer<float>* buffer);
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<WavReader> file_;
|
||||
std::unique_ptr<WavReader> file_;
|
||||
std::vector<float> interleaved_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelBufferWavReader);
|
||||
@ -62,11 +62,11 @@ class ChannelBufferWavReader final {
|
||||
// Writes ChannelBuffers to a provided WavWriter.
|
||||
class ChannelBufferWavWriter final {
|
||||
public:
|
||||
explicit ChannelBufferWavWriter(rtc::scoped_ptr<WavWriter> file);
|
||||
explicit ChannelBufferWavWriter(std::unique_ptr<WavWriter> file);
|
||||
void Write(const ChannelBuffer<float>& buffer);
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<WavWriter> file_;
|
||||
std::unique_ptr<WavWriter> file_;
|
||||
std::vector<float> interleaved_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelBufferWavWriter);
|
||||
@ -95,7 +95,7 @@ template <typename T>
|
||||
void SetContainerFormat(int sample_rate_hz,
|
||||
size_t num_channels,
|
||||
AudioFrame* frame,
|
||||
rtc::scoped_ptr<ChannelBuffer<T> >* cb) {
|
||||
std::unique_ptr<ChannelBuffer<T> >* cb) {
|
||||
SetFrameSampleRate(frame, sample_rate_hz);
|
||||
frame->num_channels_ = num_channels;
|
||||
cb->reset(new ChannelBuffer<T>(frame->samples_per_channel_, num_channels));
|
||||
|
||||
@ -15,9 +15,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_processing/debug.pb.h"
|
||||
#include "webrtc/modules/audio_processing/test/protobuf_utils.h"
|
||||
#include "webrtc/modules/audio_processing/test/test_utils.h"
|
||||
@ -83,12 +84,12 @@ int do_main(int argc, char* argv[]) {
|
||||
size_t num_reverse_channels = 0;
|
||||
size_t num_input_channels = 0;
|
||||
size_t num_output_channels = 0;
|
||||
rtc::scoped_ptr<WavWriter> reverse_wav_file;
|
||||
rtc::scoped_ptr<WavWriter> input_wav_file;
|
||||
rtc::scoped_ptr<WavWriter> output_wav_file;
|
||||
rtc::scoped_ptr<RawFile> reverse_raw_file;
|
||||
rtc::scoped_ptr<RawFile> input_raw_file;
|
||||
rtc::scoped_ptr<RawFile> output_raw_file;
|
||||
std::unique_ptr<WavWriter> reverse_wav_file;
|
||||
std::unique_ptr<WavWriter> input_wav_file;
|
||||
std::unique_ptr<WavWriter> output_wav_file;
|
||||
std::unique_ptr<RawFile> reverse_raw_file;
|
||||
std::unique_ptr<RawFile> input_raw_file;
|
||||
std::unique_ptr<RawFile> output_raw_file;
|
||||
|
||||
FILE* settings_file = OpenFile(FLAGS_settings_file, "wb");
|
||||
|
||||
@ -116,7 +117,7 @@ int do_main(int argc, char* argv[]) {
|
||||
if (FLAGS_raw && !reverse_raw_file) {
|
||||
reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float"));
|
||||
}
|
||||
rtc::scoped_ptr<const float* []> data(
|
||||
std::unique_ptr<const float* []> data(
|
||||
new const float* [num_reverse_channels]);
|
||||
for (size_t i = 0; i < num_reverse_channels; ++i) {
|
||||
data[i] = reinterpret_cast<const float*>(msg.channel(i).data());
|
||||
@ -147,7 +148,7 @@ int do_main(int argc, char* argv[]) {
|
||||
if (FLAGS_raw && !input_raw_file) {
|
||||
input_raw_file.reset(new RawFile(FLAGS_input_file + ".float"));
|
||||
}
|
||||
rtc::scoped_ptr<const float* []> data(
|
||||
std::unique_ptr<const float* []> data(
|
||||
new const float* [num_input_channels]);
|
||||
for (size_t i = 0; i < num_input_channels; ++i) {
|
||||
data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data());
|
||||
@ -171,7 +172,7 @@ int do_main(int argc, char* argv[]) {
|
||||
if (FLAGS_raw && !output_raw_file) {
|
||||
output_raw_file.reset(new RawFile(FLAGS_output_file + ".float"));
|
||||
}
|
||||
rtc::scoped_ptr<const float* []> data(
|
||||
std::unique_ptr<const float* []> data(
|
||||
new const float* [num_output_channels]);
|
||||
for (size_t i = 0; i < num_output_channels; ++i) {
|
||||
data[i] =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user