Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: webrtc/modules/audio_processing/test/audio_file_processor.cc

Issue 1800413002: Add IntelligibilityEnhancer support to audioproc_float (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@reverse
Patch Set: Rebasing Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 24 matching lines...) Expand all
35 ChannelBuffer<float> GetChannelBuffer(const WavFile& file) { 35 ChannelBuffer<float> GetChannelBuffer(const WavFile& file) {
36 return ChannelBuffer<float>( 36 return ChannelBuffer<float>(
37 CheckedDivExact(file.sample_rate(), AudioFileProcessor::kChunksPerSecond), 37 CheckedDivExact(file.sample_rate(), AudioFileProcessor::kChunksPerSecond),
38 file.num_channels()); 38 file.num_channels());
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 WavFileProcessor::WavFileProcessor(std::unique_ptr<AudioProcessing> ap, 43 WavFileProcessor::WavFileProcessor(std::unique_ptr<AudioProcessing> ap,
44 std::unique_ptr<WavReader> in_file, 44 std::unique_ptr<WavReader> in_file,
45 std::unique_ptr<WavWriter> out_file) 45 std::unique_ptr<WavWriter> out_file,
46 std::unique_ptr<WavReader> reverse_in_file,
47 std::unique_ptr<WavWriter> reverse_out_file)
46 : ap_(std::move(ap)), 48 : ap_(std::move(ap)),
47 in_buf_(GetChannelBuffer(*in_file)), 49 in_buf_(GetChannelBuffer(*in_file)),
48 out_buf_(GetChannelBuffer(*out_file)), 50 out_buf_(GetChannelBuffer(*out_file)),
49 input_config_(GetStreamConfig(*in_file)), 51 input_config_(GetStreamConfig(*in_file)),
50 output_config_(GetStreamConfig(*out_file)), 52 output_config_(GetStreamConfig(*out_file)),
51 buffer_reader_(std::move(in_file)), 53 buffer_reader_(std::move(in_file)),
52 buffer_writer_(std::move(out_file)) {} 54 buffer_writer_(std::move(out_file)) {
55 if (reverse_in_file) {
56 const WavFile* reverse_out_config;
57 if (reverse_out_file) {
58 reverse_out_config = reverse_out_file.get();
59 } else {
60 reverse_out_config = reverse_in_file.get();
61 }
62 reverse_in_buf_.reset(
63 new ChannelBuffer<float>(GetChannelBuffer(*reverse_in_file)));
64 reverse_out_buf_.reset(
65 new ChannelBuffer<float>(GetChannelBuffer(*reverse_out_config)));
66 reverse_input_config_.reset(
67 new StreamConfig(GetStreamConfig(*reverse_in_file)));
68 reverse_output_config_.reset(
69 new StreamConfig(GetStreamConfig(*reverse_out_config)));
70 reverse_buffer_reader_.reset(
71 new ChannelBufferWavReader(std::move(reverse_in_file)));
72 if (reverse_out_file) {
73 reverse_buffer_writer_.reset(
74 new ChannelBufferWavWriter(std::move(reverse_out_file)));
75 }
76 }
77 }
53 78
54 bool WavFileProcessor::ProcessChunk() { 79 bool WavFileProcessor::ProcessChunk() {
55 if (!buffer_reader_.Read(&in_buf_)) { 80 if (!buffer_reader_.Read(&in_buf_)) {
56 return false; 81 return false;
57 } 82 }
58 { 83 {
59 const auto st = ScopedTimer(mutable_proc_time()); 84 const auto st = ScopedTimer(mutable_proc_time());
60 RTC_CHECK_EQ(kNoErr, 85 RTC_CHECK_EQ(kNoErr,
61 ap_->ProcessStream(in_buf_.channels(), input_config_, 86 ap_->ProcessStream(in_buf_.channels(), input_config_,
62 output_config_, out_buf_.channels())); 87 output_config_, out_buf_.channels()));
63 } 88 }
64 buffer_writer_.Write(out_buf_); 89 buffer_writer_.Write(out_buf_);
90 if (reverse_buffer_reader_) {
91 if (!reverse_buffer_reader_->Read(reverse_in_buf_.get())) {
92 return false;
93 }
94 {
95 const auto st = ScopedTimer(mutable_proc_time());
96 RTC_CHECK_EQ(kNoErr,
97 ap_->ProcessReverseStream(reverse_in_buf_->channels(),
98 *reverse_input_config_.get(),
99 *reverse_output_config_.get(),
100 reverse_out_buf_->channels()));
101 }
102 if (reverse_buffer_writer_) {
103 reverse_buffer_writer_->Write(*reverse_out_buf_.get());
104 }
105 }
65 return true; 106 return true;
66 } 107 }
67 108
68 AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap, 109 AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap,
69 FILE* dump_file, 110 FILE* dump_file,
70 std::unique_ptr<WavWriter> out_file) 111 std::unique_ptr<WavWriter> out_file)
71 : ap_(std::move(ap)), 112 : ap_(std::move(ap)),
72 dump_file_(dump_file), 113 dump_file_(dump_file),
73 out_buf_(GetChannelBuffer(*out_file)), 114 out_buf_(GetChannelBuffer(*out_file)),
74 output_config_(GetStreamConfig(*out_file)), 115 output_config_(GetStreamConfig(*out_file)),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 const auto st = ScopedTimer(mutable_proc_time()); 211 const auto st = ScopedTimer(mutable_proc_time());
171 // TODO(ajm): This currently discards the processed output, which is needed 212 // TODO(ajm): This currently discards the processed output, which is needed
172 // for e.g. intelligibility enhancement. 213 // for e.g. intelligibility enhancement.
173 RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream( 214 RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream(
174 reverse_buf_->channels(), reverse_config_, 215 reverse_buf_->channels(), reverse_config_,
175 reverse_config_, reverse_buf_->channels())); 216 reverse_config_, reverse_buf_->channels()));
176 } 217 }
177 } 218 }
178 219
179 } // namespace webrtc 220 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/test/audio_file_processor.h ('k') | webrtc/modules/audio_processing/test/audioproc_float.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698