Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 process_reverse_stream_(reverse_in_file && reverse_out_file) { | |
|
peah-webrtc
2016/03/18 09:38:02
Why is this true only if both reverse_in_file reve
aluebs-webrtc
2016/03/18 18:36:54
In practice, the reverse_out_file is always specif
| |
| 56 if (process_reverse_stream_) { | |
| 57 reverse_in_buf_.reset( | |
| 58 new ChannelBuffer<float>(GetChannelBuffer(*reverse_in_file))); | |
| 59 reverse_out_buf_.reset( | |
| 60 new ChannelBuffer<float>(GetChannelBuffer(*reverse_out_file))); | |
| 61 reverse_input_config_.reset( | |
| 62 new StreamConfig(GetStreamConfig(*reverse_in_file))); | |
| 63 reverse_output_config_.reset( | |
| 64 new StreamConfig(GetStreamConfig(*reverse_out_file))); | |
| 65 reverse_buffer_reader_.reset( | |
| 66 new ChannelBufferWavReader(std::move(reverse_in_file))); | |
| 67 reverse_buffer_writer_.reset( | |
| 68 new ChannelBufferWavWriter(std::move(reverse_out_file))); | |
| 69 } | |
| 70 } | |
| 53 | 71 |
| 54 bool WavFileProcessor::ProcessChunk() { | 72 bool WavFileProcessor::ProcessChunk() { |
| 55 if (!buffer_reader_.Read(&in_buf_)) { | 73 if (!buffer_reader_.Read(&in_buf_)) { |
| 56 return false; | 74 return false; |
| 57 } | 75 } |
| 58 { | 76 { |
| 59 const auto st = ScopedTimer(mutable_proc_time()); | 77 const auto st = ScopedTimer(mutable_proc_time()); |
| 60 RTC_CHECK_EQ(kNoErr, | 78 RTC_CHECK_EQ(kNoErr, |
| 61 ap_->ProcessStream(in_buf_.channels(), input_config_, | 79 ap_->ProcessStream(in_buf_.channels(), input_config_, |
| 62 output_config_, out_buf_.channels())); | 80 output_config_, out_buf_.channels())); |
| 63 } | 81 } |
| 64 buffer_writer_.Write(out_buf_); | 82 buffer_writer_.Write(out_buf_); |
| 83 if (process_reverse_stream_) { | |
|
peah-webrtc
2016/03/18 09:38:02
This bool is a bit redundant: you should be able t
aluebs-webrtc
2016/03/18 18:36:53
I just though it was less bug prone to have one ce
| |
| 84 if (!reverse_buffer_reader_->Read(reverse_in_buf_.get())) { | |
| 85 return false; | |
| 86 } | |
| 87 { | |
| 88 const auto st = ScopedTimer(mutable_proc_time()); | |
| 89 RTC_CHECK_EQ(kNoErr, | |
| 90 ap_->ProcessReverseStream(reverse_in_buf_->channels(), | |
| 91 *reverse_input_config_.get(), | |
| 92 *reverse_output_config_.get(), | |
| 93 reverse_out_buf_->channels())); | |
| 94 } | |
| 95 reverse_buffer_writer_->Write(*reverse_out_buf_.get()); | |
| 96 } | |
| 65 return true; | 97 return true; |
| 66 } | 98 } |
| 67 | 99 |
| 68 AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap, | 100 AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap, |
| 69 FILE* dump_file, | 101 FILE* dump_file, |
| 70 std::unique_ptr<WavWriter> out_file) | 102 std::unique_ptr<WavWriter> out_file) |
| 71 : ap_(std::move(ap)), | 103 : ap_(std::move(ap)), |
| 72 dump_file_(dump_file), | 104 dump_file_(dump_file), |
| 73 out_buf_(GetChannelBuffer(*out_file)), | 105 out_buf_(GetChannelBuffer(*out_file)), |
| 74 output_config_(GetStreamConfig(*out_file)), | 106 output_config_(GetStreamConfig(*out_file)), |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 const auto st = ScopedTimer(mutable_proc_time()); | 202 const auto st = ScopedTimer(mutable_proc_time()); |
| 171 // TODO(ajm): This currently discards the processed output, which is needed | 203 // TODO(ajm): This currently discards the processed output, which is needed |
| 172 // for e.g. intelligibility enhancement. | 204 // for e.g. intelligibility enhancement. |
| 173 RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream( | 205 RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream( |
| 174 reverse_buf_->channels(), reverse_config_, | 206 reverse_buf_->channels(), reverse_config_, |
| 175 reverse_config_, reverse_buf_->channels())); | 207 reverse_config_, reverse_buf_->channels())); |
| 176 } | 208 } |
| 177 } | 209 } |
| 178 | 210 |
| 179 } // namespace webrtc | 211 } // namespace webrtc |
| OLD | NEW |