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

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

Issue 1783693005: Deprecate AudioProcessing::AnalyzeReverseStream(AudioFrame) API (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@voe
Patch Set: Rebasing Created 4 years, 9 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 frame_->samples_per_channel_, 582 frame_->samples_per_channel_,
583 frame_->sample_rate_hz_, 583 frame_->sample_rate_hz_,
584 LayoutFromChannels(frame_->num_channels_), 584 LayoutFromChannels(frame_->num_channels_),
585 output_sample_rate_hz_, 585 output_sample_rate_hz_,
586 LayoutFromChannels(num_output_channels_), 586 LayoutFromChannels(num_output_channels_),
587 float_cb_->channels()); 587 float_cb_->channels());
588 } 588 }
589 589
590 int ApmTest::AnalyzeReverseStreamChooser(Format format) { 590 int ApmTest::AnalyzeReverseStreamChooser(Format format) {
591 if (format == kIntFormat) { 591 if (format == kIntFormat) {
592 return apm_->AnalyzeReverseStream(revframe_); 592 return apm_->ProcessReverseStream(revframe_);
593 } 593 }
594 return apm_->AnalyzeReverseStream( 594 return apm_->AnalyzeReverseStream(
595 revfloat_cb_->channels(), 595 revfloat_cb_->channels(),
596 revframe_->samples_per_channel_, 596 revframe_->samples_per_channel_,
597 revframe_->sample_rate_hz_, 597 revframe_->sample_rate_hz_,
598 LayoutFromChannels(revframe_->num_channels_)); 598 LayoutFromChannels(revframe_->num_channels_));
599 } 599 }
600 600
601 void ApmTest::ProcessDelayVerificationTest(int delay_ms, int system_delay_ms, 601 void ApmTest::ProcessDelayVerificationTest(int delay_ms, int system_delay_ms,
602 int delay_min, int delay_max) { 602 int delay_min, int delay_max) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 AudioFrame* reverse_frame = frame; 638 AudioFrame* reverse_frame = frame;
639 AudioFrame* process_frame = frame_queue.front(); 639 AudioFrame* process_frame = frame_queue.front();
640 if (!causal) { 640 if (!causal) {
641 reverse_frame = frame_queue.front(); 641 reverse_frame = frame_queue.front();
642 // When we call ProcessStream() the frame is modified, so we can't use the 642 // When we call ProcessStream() the frame is modified, so we can't use the
643 // pointer directly when things are non-causal. Use an intermediate frame 643 // pointer directly when things are non-causal. Use an intermediate frame
644 // and copy the data. 644 // and copy the data.
645 process_frame = &tmp_frame; 645 process_frame = &tmp_frame;
646 process_frame->CopyFrom(*frame); 646 process_frame->CopyFrom(*frame);
647 } 647 }
648 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(reverse_frame)); 648 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(reverse_frame));
649 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(system_delay_ms)); 649 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(system_delay_ms));
650 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(process_frame)); 650 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(process_frame));
651 frame = frame_queue.front(); 651 frame = frame_queue.front();
652 frame_queue.pop(); 652 frame_queue.pop();
653 delete frame; 653 delete frame;
654 654
655 if (frame_count == 250) { 655 if (frame_count == 250) {
656 int median; 656 int median;
657 int std; 657 int std;
658 float poor_fraction; 658 float poor_fraction;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 EXPECT_EQ(0, apm_->stream_delay_ms()); 808 EXPECT_EQ(0, apm_->stream_delay_ms());
809 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100)); 809 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
810 EXPECT_EQ(50, apm_->stream_delay_ms()); 810 EXPECT_EQ(50, apm_->stream_delay_ms());
811 } 811 }
812 812
813 void ApmTest::TestChangingChannelsInt16Interface( 813 void ApmTest::TestChangingChannelsInt16Interface(
814 size_t num_channels, 814 size_t num_channels,
815 AudioProcessing::Error expected_return) { 815 AudioProcessing::Error expected_return) {
816 frame_->num_channels_ = num_channels; 816 frame_->num_channels_ = num_channels;
817 EXPECT_EQ(expected_return, apm_->ProcessStream(frame_)); 817 EXPECT_EQ(expected_return, apm_->ProcessStream(frame_));
818 EXPECT_EQ(expected_return, apm_->AnalyzeReverseStream(frame_)); 818 EXPECT_EQ(expected_return, apm_->ProcessReverseStream(frame_));
819 } 819 }
820 820
821 void ApmTest::TestChangingForwardChannels( 821 void ApmTest::TestChangingForwardChannels(
822 size_t num_in_channels, 822 size_t num_in_channels,
823 size_t num_out_channels, 823 size_t num_out_channels,
824 AudioProcessing::Error expected_return) { 824 AudioProcessing::Error expected_return) {
825 const StreamConfig input_stream = {frame_->sample_rate_hz_, num_in_channels}; 825 const StreamConfig input_stream = {frame_->sample_rate_hz_, num_in_channels};
826 const StreamConfig output_stream = {output_sample_rate_hz_, num_out_channels}; 826 const StreamConfig output_stream = {output_sample_rate_hz_, num_out_channels};
827 827
828 EXPECT_EQ(expected_return, 828 EXPECT_EQ(expected_return,
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 2, 1587 2,
1588 2, 1588 2,
1589 2, 1589 2,
1590 false); 1590 false);
1591 int analog_level = 127; 1591 int analog_level = 127;
1592 ASSERT_EQ(0, feof(far_file_)); 1592 ASSERT_EQ(0, feof(far_file_));
1593 ASSERT_EQ(0, feof(near_file_)); 1593 ASSERT_EQ(0, feof(near_file_));
1594 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) { 1594 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) {
1595 CopyLeftToRightChannel(revframe_->data_, revframe_->samples_per_channel_); 1595 CopyLeftToRightChannel(revframe_->data_, revframe_->samples_per_channel_);
1596 1596
1597 ASSERT_EQ(kNoErr, apm_->AnalyzeReverseStream(revframe_)); 1597 ASSERT_EQ(kNoErr, apm_->ProcessReverseStream(revframe_));
1598 1598
1599 CopyLeftToRightChannel(frame_->data_, frame_->samples_per_channel_); 1599 CopyLeftToRightChannel(frame_->data_, frame_->samples_per_channel_);
1600 frame_->vad_activity_ = AudioFrame::kVadUnknown; 1600 frame_->vad_activity_ = AudioFrame::kVadUnknown;
1601 1601
1602 ASSERT_EQ(kNoErr, apm_->set_stream_delay_ms(0)); 1602 ASSERT_EQ(kNoErr, apm_->set_stream_delay_ms(0));
1603 apm_->echo_cancellation()->set_stream_drift_samples(0); 1603 apm_->echo_cancellation()->set_stream_drift_samples(0);
1604 ASSERT_EQ(kNoErr, 1604 ASSERT_EQ(kNoErr,
1605 apm_->gain_control()->set_stream_analog_level(analog_level)); 1605 apm_->gain_control()->set_stream_analog_level(analog_level));
1606 ASSERT_EQ(kNoErr, apm_->ProcessStream(frame_)); 1606 ASSERT_EQ(kNoErr, apm_->ProcessStream(frame_));
1607 analog_level = apm_->gain_control()->stream_analog_level(); 1607 analog_level = apm_->gain_control()->stream_analog_level();
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 test::TempFilename(test::OutputPath(), "debug_aec"); 1862 test::TempFilename(test::OutputPath(), "debug_aec");
1863 EXPECT_EQ(apm_->kNullPointerError, 1863 EXPECT_EQ(apm_->kNullPointerError,
1864 apm_->StartDebugRecording(static_cast<const char*>(NULL), -1)); 1864 apm_->StartDebugRecording(static_cast<const char*>(NULL), -1));
1865 1865
1866 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1866 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1867 // Stopping without having started should be OK. 1867 // Stopping without having started should be OK.
1868 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1868 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1869 1869
1870 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(filename.c_str(), -1)); 1870 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(filename.c_str(), -1));
1871 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); 1871 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
1872 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); 1872 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
1873 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1873 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1874 1874
1875 // Verify the file has been written. 1875 // Verify the file has been written.
1876 FILE* fid = fopen(filename.c_str(), "r"); 1876 FILE* fid = fopen(filename.c_str(), "r");
1877 ASSERT_TRUE(fid != NULL); 1877 ASSERT_TRUE(fid != NULL);
1878 1878
1879 // Clean it up. 1879 // Clean it up.
1880 ASSERT_EQ(0, fclose(fid)); 1880 ASSERT_EQ(0, fclose(fid));
1881 ASSERT_EQ(0, remove(filename.c_str())); 1881 ASSERT_EQ(0, remove(filename.c_str()));
1882 #else 1882 #else
(...skipping 13 matching lines...) Expand all
1896 const std::string filename = 1896 const std::string filename =
1897 test::TempFilename(test::OutputPath(), "debug_aec"); 1897 test::TempFilename(test::OutputPath(), "debug_aec");
1898 fid = fopen(filename.c_str(), "w"); 1898 fid = fopen(filename.c_str(), "w");
1899 ASSERT_TRUE(fid); 1899 ASSERT_TRUE(fid);
1900 1900
1901 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1901 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1902 // Stopping without having started should be OK. 1902 // Stopping without having started should be OK.
1903 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1903 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1904 1904
1905 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(fid, -1)); 1905 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(fid, -1));
1906 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); 1906 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
1907 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); 1907 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
1908 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1908 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1909 1909
1910 // Verify the file has been written. 1910 // Verify the file has been written.
1911 fid = fopen(filename.c_str(), "r"); 1911 fid = fopen(filename.c_str(), "r");
1912 ASSERT_TRUE(fid != NULL); 1912 ASSERT_TRUE(fid != NULL);
1913 1913
1914 // Clean it up. 1914 // Clean it up.
1915 ASSERT_EQ(0, fclose(fid)); 1915 ASSERT_EQ(0, fclose(fid));
1916 ASSERT_EQ(0, remove(filename.c_str())); 1916 ASSERT_EQ(0, remove(filename.c_str()));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 ChannelBuffer<int16_t> output_cb(samples_per_channel, num_input_channels); 1956 ChannelBuffer<int16_t> output_cb(samples_per_channel, num_input_channels);
1957 ChannelBuffer<int16_t> output_int16(samples_per_channel, 1957 ChannelBuffer<int16_t> output_int16(samples_per_channel,
1958 num_input_channels); 1958 num_input_channels);
1959 1959
1960 int analog_level = 127; 1960 int analog_level = 127;
1961 size_t num_bad_chunks = 0; 1961 size_t num_bad_chunks = 0;
1962 while (ReadFrame(far_file_, revframe_, revfloat_cb_.get()) && 1962 while (ReadFrame(far_file_, revframe_, revfloat_cb_.get()) &&
1963 ReadFrame(near_file_, frame_, float_cb_.get())) { 1963 ReadFrame(near_file_, frame_, float_cb_.get())) {
1964 frame_->vad_activity_ = AudioFrame::kVadUnknown; 1964 frame_->vad_activity_ = AudioFrame::kVadUnknown;
1965 1965
1966 EXPECT_NOERR(apm_->AnalyzeReverseStream(revframe_)); 1966 EXPECT_NOERR(apm_->ProcessReverseStream(revframe_));
1967 EXPECT_NOERR(fapm->AnalyzeReverseStream( 1967 EXPECT_NOERR(fapm->AnalyzeReverseStream(
1968 revfloat_cb_->channels(), 1968 revfloat_cb_->channels(),
1969 samples_per_channel, 1969 samples_per_channel,
1970 test->sample_rate(), 1970 test->sample_rate(),
1971 LayoutFromChannels(num_render_channels))); 1971 LayoutFromChannels(num_render_channels)));
1972 1972
1973 EXPECT_NOERR(apm_->set_stream_delay_ms(0)); 1973 EXPECT_NOERR(apm_->set_stream_delay_ms(0));
1974 EXPECT_NOERR(fapm->set_stream_delay_ms(0)); 1974 EXPECT_NOERR(fapm->set_stream_delay_ms(0));
1975 apm_->echo_cancellation()->set_stream_drift_samples(0); 1975 apm_->echo_cancellation()->set_stream_drift_samples(0);
1976 fapm->echo_cancellation()->set_stream_drift_samples(0); 1976 fapm->echo_cancellation()->set_stream_drift_samples(0);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 int frame_count = 0; 2096 int frame_count = 0;
2097 int has_echo_count = 0; 2097 int has_echo_count = 0;
2098 int has_voice_count = 0; 2098 int has_voice_count = 0;
2099 int is_saturated_count = 0; 2099 int is_saturated_count = 0;
2100 int analog_level = 127; 2100 int analog_level = 127;
2101 int analog_level_average = 0; 2101 int analog_level_average = 0;
2102 int max_output_average = 0; 2102 int max_output_average = 0;
2103 float ns_speech_prob_average = 0.0f; 2103 float ns_speech_prob_average = 0.0f;
2104 2104
2105 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) { 2105 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) {
2106 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); 2106 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
2107 2107
2108 frame_->vad_activity_ = AudioFrame::kVadUnknown; 2108 frame_->vad_activity_ = AudioFrame::kVadUnknown;
2109 2109
2110 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0)); 2110 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0));
2111 apm_->echo_cancellation()->set_stream_drift_samples(0); 2111 apm_->echo_cancellation()->set_stream_drift_samples(0);
2112 EXPECT_EQ(apm_->kNoError, 2112 EXPECT_EQ(apm_->kNoError,
2113 apm_->gain_control()->set_stream_analog_level(analog_level)); 2113 apm_->gain_control()->set_stream_analog_level(analog_level));
2114 2114
2115 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); 2115 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
2116 2116
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), 2752 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35),
2753 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), 2753 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0),
2754 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), 2754 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20),
2755 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), 2755 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20),
2756 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20), 2756 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20),
2757 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); 2757 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0)));
2758 #endif 2758 #endif
2759 2759
2760 } // namespace 2760 } // namespace
2761 } // namespace webrtc 2761 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/include/audio_processing.h ('k') | webrtc/modules/audio_processing/test/process_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698