| 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) |  | 
| 48     : ap_(std::move(ap)), | 46     : ap_(std::move(ap)), | 
| 49       in_buf_(GetChannelBuffer(*in_file)), | 47       in_buf_(GetChannelBuffer(*in_file)), | 
| 50       out_buf_(GetChannelBuffer(*out_file)), | 48       out_buf_(GetChannelBuffer(*out_file)), | 
| 51       input_config_(GetStreamConfig(*in_file)), | 49       input_config_(GetStreamConfig(*in_file)), | 
| 52       output_config_(GetStreamConfig(*out_file)), | 50       output_config_(GetStreamConfig(*out_file)), | 
| 53       buffer_reader_(std::move(in_file)), | 51       buffer_reader_(std::move(in_file)), | 
| 54       buffer_writer_(std::move(out_file)) { | 52       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 } |  | 
| 78 | 53 | 
| 79 bool WavFileProcessor::ProcessChunk() { | 54 bool WavFileProcessor::ProcessChunk() { | 
| 80   if (!buffer_reader_.Read(&in_buf_)) { | 55   if (!buffer_reader_.Read(&in_buf_)) { | 
| 81     return false; | 56     return false; | 
| 82   } | 57   } | 
| 83   { | 58   { | 
| 84     const auto st = ScopedTimer(mutable_proc_time()); | 59     const auto st = ScopedTimer(mutable_proc_time()); | 
| 85     RTC_CHECK_EQ(kNoErr, | 60     RTC_CHECK_EQ(kNoErr, | 
| 86                  ap_->ProcessStream(in_buf_.channels(), input_config_, | 61                  ap_->ProcessStream(in_buf_.channels(), input_config_, | 
| 87                                     output_config_, out_buf_.channels())); | 62                                     output_config_, out_buf_.channels())); | 
| 88   } | 63   } | 
| 89   buffer_writer_.Write(out_buf_); | 64   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   } |  | 
| 106   return true; | 65   return true; | 
| 107 } | 66 } | 
| 108 | 67 | 
| 109 AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap, | 68 AecDumpFileProcessor::AecDumpFileProcessor(std::unique_ptr<AudioProcessing> ap, | 
| 110                                            FILE* dump_file, | 69                                            FILE* dump_file, | 
| 111                                            std::unique_ptr<WavWriter> out_file) | 70                                            std::unique_ptr<WavWriter> out_file) | 
| 112     : ap_(std::move(ap)), | 71     : ap_(std::move(ap)), | 
| 113       dump_file_(dump_file), | 72       dump_file_(dump_file), | 
| 114       out_buf_(GetChannelBuffer(*out_file)), | 73       out_buf_(GetChannelBuffer(*out_file)), | 
| 115       output_config_(GetStreamConfig(*out_file)), | 74       output_config_(GetStreamConfig(*out_file)), | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 211     const auto st = ScopedTimer(mutable_proc_time()); | 170     const auto st = ScopedTimer(mutable_proc_time()); | 
| 212     // TODO(ajm): This currently discards the processed output, which is needed | 171     // TODO(ajm): This currently discards the processed output, which is needed | 
| 213     // for e.g. intelligibility enhancement. | 172     // for e.g. intelligibility enhancement. | 
| 214     RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream( | 173     RTC_CHECK_EQ(kNoErr, ap_->ProcessReverseStream( | 
| 215                              reverse_buf_->channels(), reverse_config_, | 174                              reverse_buf_->channels(), reverse_config_, | 
| 216                              reverse_config_, reverse_buf_->channels())); | 175                              reverse_config_, reverse_buf_->channels())); | 
| 217   } | 176   } | 
| 218 } | 177 } | 
| 219 | 178 | 
| 220 }  // namespace webrtc | 179 }  // namespace webrtc | 
| OLD | NEW | 
|---|