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

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

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 years, 3 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 300
301 void OpenFileAndReadMessage(const std::string filename, 301 void OpenFileAndReadMessage(const std::string filename,
302 ::google::protobuf::MessageLite* msg) { 302 ::google::protobuf::MessageLite* msg) {
303 FILE* file = fopen(filename.c_str(), "rb"); 303 FILE* file = fopen(filename.c_str(), "rb");
304 ASSERT_TRUE(file != NULL); 304 ASSERT_TRUE(file != NULL);
305 ReadMessageFromFile(file, msg); 305 ReadMessageFromFile(file, msg);
306 fclose(file); 306 fclose(file);
307 } 307 }
308 308
309 // Reads a 10 ms chunk of int16 interleaved audio from the given (assumed 309 // Reads a 10 ms chunk of int16_t interleaved audio from the given (assumed
310 // stereo) file, converts to deinterleaved float (optionally downmixing) and 310 // stereo) file, converts to deinterleaved float (optionally downmixing) and
311 // returns the result in |cb|. Returns false if the file ended (or on error) and 311 // returns the result in |cb|. Returns false if the file ended (or on error) and
312 // true otherwise. 312 // true otherwise.
313 // 313 //
314 // |int_data| and |float_data| are just temporary space that must be 314 // |int_data| and |float_data| are just temporary space that must be
315 // sufficiently large to hold the 10 ms chunk. 315 // sufficiently large to hold the 10 ms chunk.
316 bool ReadChunk(FILE* file, int16_t* int_data, float* float_data, 316 bool ReadChunk(FILE* file, int16_t* int_data, float* float_data,
317 ChannelBuffer<float>* cb) { 317 ChannelBuffer<float>* cb) {
318 // The files always contain stereo audio. 318 // The files always contain stereo audio.
319 size_t frame_size = cb->num_frames() * 2; 319 size_t frame_size = cb->num_frames() * 2;
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 if (msg.channel_size() > 0) { 1750 if (msg.channel_size() > 0) {
1751 ASSERT_EQ(revframe_->num_channels_, msg.channel_size()); 1751 ASSERT_EQ(revframe_->num_channels_, msg.channel_size());
1752 for (int i = 0; i < msg.channel_size(); ++i) { 1752 for (int i = 0; i < msg.channel_size(); ++i) {
1753 memcpy(revfloat_cb_->channels()[i], 1753 memcpy(revfloat_cb_->channels()[i],
1754 msg.channel(i).data(), 1754 msg.channel(i).data(),
1755 msg.channel(i).size()); 1755 msg.channel(i).size());
1756 } 1756 }
1757 } else { 1757 } else {
1758 memcpy(revframe_->data_, msg.data().data(), msg.data().size()); 1758 memcpy(revframe_->data_, msg.data().data(), msg.data().size());
1759 if (format == kFloatFormat) { 1759 if (format == kFloatFormat) {
1760 // We're using an int16 input file; convert to float. 1760 // We're using an int16_t input file; convert to float.
1761 ConvertToFloat(*revframe_, revfloat_cb_.get()); 1761 ConvertToFloat(*revframe_, revfloat_cb_.get());
1762 } 1762 }
1763 } 1763 }
1764 AnalyzeReverseStreamChooser(format); 1764 AnalyzeReverseStreamChooser(format);
1765 1765
1766 } else if (event_msg.type() == audioproc::Event::STREAM) { 1766 } else if (event_msg.type() == audioproc::Event::STREAM) {
1767 const audioproc::Stream msg = event_msg.stream(); 1767 const audioproc::Stream msg = event_msg.stream();
1768 // ProcessStream could have changed this for the output frame. 1768 // ProcessStream could have changed this for the output frame.
1769 frame_->num_channels_ = apm_->num_input_channels(); 1769 frame_->num_channels_ = apm_->num_input_channels();
1770 1770
1771 EXPECT_NOERR(apm_->gain_control()->set_stream_analog_level(msg.level())); 1771 EXPECT_NOERR(apm_->gain_control()->set_stream_analog_level(msg.level()));
1772 EXPECT_NOERR(apm_->set_stream_delay_ms(msg.delay())); 1772 EXPECT_NOERR(apm_->set_stream_delay_ms(msg.delay()));
1773 apm_->echo_cancellation()->set_stream_drift_samples(msg.drift()); 1773 apm_->echo_cancellation()->set_stream_drift_samples(msg.drift());
1774 if (msg.has_keypress()) { 1774 if (msg.has_keypress()) {
1775 apm_->set_stream_key_pressed(msg.keypress()); 1775 apm_->set_stream_key_pressed(msg.keypress());
1776 } else { 1776 } else {
1777 apm_->set_stream_key_pressed(true); 1777 apm_->set_stream_key_pressed(true);
1778 } 1778 }
1779 1779
1780 if (msg.input_channel_size() > 0) { 1780 if (msg.input_channel_size() > 0) {
1781 ASSERT_EQ(frame_->num_channels_, msg.input_channel_size()); 1781 ASSERT_EQ(frame_->num_channels_, msg.input_channel_size());
1782 for (int i = 0; i < msg.input_channel_size(); ++i) { 1782 for (int i = 0; i < msg.input_channel_size(); ++i) {
1783 memcpy(float_cb_->channels()[i], 1783 memcpy(float_cb_->channels()[i],
1784 msg.input_channel(i).data(), 1784 msg.input_channel(i).data(),
1785 msg.input_channel(i).size()); 1785 msg.input_channel(i).size());
1786 } 1786 }
1787 } else { 1787 } else {
1788 memcpy(frame_->data_, msg.input_data().data(), msg.input_data().size()); 1788 memcpy(frame_->data_, msg.input_data().data(), msg.input_data().size());
1789 if (format == kFloatFormat) { 1789 if (format == kFloatFormat) {
1790 // We're using an int16 input file; convert to float. 1790 // We're using an int16_t input file; convert to float.
1791 ConvertToFloat(*frame_, float_cb_.get()); 1791 ConvertToFloat(*frame_, float_cb_.get());
1792 } 1792 }
1793 } 1793 }
1794 ProcessStreamChooser(format); 1794 ProcessStreamChooser(format);
1795 } 1795 }
1796 } 1796 }
1797 EXPECT_NOERR(apm_->StopDebugRecording()); 1797 EXPECT_NOERR(apm_->StopDebugRecording());
1798 fclose(in_file); 1798 fclose(in_file);
1799 } 1799 }
1800 1800
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20), 2748 std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20),
2749 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); 2749 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0)));
2750 #endif 2750 #endif
2751 2751
2752 // TODO(henrike): re-implement functionality lost when removing the old main 2752 // TODO(henrike): re-implement functionality lost when removing the old main
2753 // function. See 2753 // function. See
2754 // https://code.google.com/p/webrtc/issues/detail?id=1981 2754 // https://code.google.com/p/webrtc/issues/detail?id=1981
2755 2755
2756 } // namespace 2756 } // namespace
2757 } // namespace webrtc 2757 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698