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

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: 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 frame_->samples_per_channel_, 577 frame_->samples_per_channel_,
578 frame_->sample_rate_hz_, 578 frame_->sample_rate_hz_,
579 LayoutFromChannels(frame_->num_channels_), 579 LayoutFromChannels(frame_->num_channels_),
580 output_sample_rate_hz_, 580 output_sample_rate_hz_,
581 LayoutFromChannels(num_output_channels_), 581 LayoutFromChannels(num_output_channels_),
582 float_cb_->channels()); 582 float_cb_->channels());
583 } 583 }
584 584
585 int ApmTest::AnalyzeReverseStreamChooser(Format format) { 585 int ApmTest::AnalyzeReverseStreamChooser(Format format) {
586 if (format == kIntFormat) { 586 if (format == kIntFormat) {
587 return apm_->AnalyzeReverseStream(revframe_); 587 return apm_->ProcessReverseStream(revframe_);
588 } 588 }
589 return apm_->AnalyzeReverseStream( 589 return apm_->AnalyzeReverseStream(
590 revfloat_cb_->channels(), 590 revfloat_cb_->channels(),
591 revframe_->samples_per_channel_, 591 revframe_->samples_per_channel_,
592 revframe_->sample_rate_hz_, 592 revframe_->sample_rate_hz_,
593 LayoutFromChannels(revframe_->num_channels_)); 593 LayoutFromChannels(revframe_->num_channels_));
594 } 594 }
595 595
596 void ApmTest::ProcessDelayVerificationTest(int delay_ms, int system_delay_ms, 596 void ApmTest::ProcessDelayVerificationTest(int delay_ms, int system_delay_ms,
597 int delay_min, int delay_max) { 597 int delay_min, int delay_max) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 AudioFrame* reverse_frame = frame; 633 AudioFrame* reverse_frame = frame;
634 AudioFrame* process_frame = frame_queue.front(); 634 AudioFrame* process_frame = frame_queue.front();
635 if (!causal) { 635 if (!causal) {
636 reverse_frame = frame_queue.front(); 636 reverse_frame = frame_queue.front();
637 // When we call ProcessStream() the frame is modified, so we can't use the 637 // When we call ProcessStream() the frame is modified, so we can't use the
638 // pointer directly when things are non-causal. Use an intermediate frame 638 // pointer directly when things are non-causal. Use an intermediate frame
639 // and copy the data. 639 // and copy the data.
640 process_frame = &tmp_frame; 640 process_frame = &tmp_frame;
641 process_frame->CopyFrom(*frame); 641 process_frame->CopyFrom(*frame);
642 } 642 }
643 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(reverse_frame)); 643 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(reverse_frame));
644 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(system_delay_ms)); 644 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(system_delay_ms));
645 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(process_frame)); 645 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(process_frame));
646 frame = frame_queue.front(); 646 frame = frame_queue.front();
647 frame_queue.pop(); 647 frame_queue.pop();
648 delete frame; 648 delete frame;
649 649
650 if (frame_count == 250) { 650 if (frame_count == 250) {
651 int median; 651 int median;
652 int std; 652 int std;
653 float poor_fraction; 653 float poor_fraction;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 EXPECT_EQ(0, apm_->stream_delay_ms()); 803 EXPECT_EQ(0, apm_->stream_delay_ms());
804 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100)); 804 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
805 EXPECT_EQ(50, apm_->stream_delay_ms()); 805 EXPECT_EQ(50, apm_->stream_delay_ms());
806 } 806 }
807 807
808 void ApmTest::TestChangingChannelsInt16Interface( 808 void ApmTest::TestChangingChannelsInt16Interface(
809 size_t num_channels, 809 size_t num_channels,
810 AudioProcessing::Error expected_return) { 810 AudioProcessing::Error expected_return) {
811 frame_->num_channels_ = num_channels; 811 frame_->num_channels_ = num_channels;
812 EXPECT_EQ(expected_return, apm_->ProcessStream(frame_)); 812 EXPECT_EQ(expected_return, apm_->ProcessStream(frame_));
813 EXPECT_EQ(expected_return, apm_->AnalyzeReverseStream(frame_)); 813 EXPECT_EQ(expected_return, apm_->ProcessReverseStream(frame_));
814 } 814 }
815 815
816 void ApmTest::TestChangingForwardChannels( 816 void ApmTest::TestChangingForwardChannels(
817 size_t num_in_channels, 817 size_t num_in_channels,
818 size_t num_out_channels, 818 size_t num_out_channels,
819 AudioProcessing::Error expected_return) { 819 AudioProcessing::Error expected_return) {
820 const StreamConfig input_stream = {frame_->sample_rate_hz_, num_in_channels}; 820 const StreamConfig input_stream = {frame_->sample_rate_hz_, num_in_channels};
821 const StreamConfig output_stream = {output_sample_rate_hz_, num_out_channels}; 821 const StreamConfig output_stream = {output_sample_rate_hz_, num_out_channels};
822 822
823 EXPECT_EQ(expected_return, 823 EXPECT_EQ(expected_return,
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 2, 1582 2,
1583 2, 1583 2,
1584 2, 1584 2,
1585 false); 1585 false);
1586 int analog_level = 127; 1586 int analog_level = 127;
1587 ASSERT_EQ(0, feof(far_file_)); 1587 ASSERT_EQ(0, feof(far_file_));
1588 ASSERT_EQ(0, feof(near_file_)); 1588 ASSERT_EQ(0, feof(near_file_));
1589 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) { 1589 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) {
1590 CopyLeftToRightChannel(revframe_->data_, revframe_->samples_per_channel_); 1590 CopyLeftToRightChannel(revframe_->data_, revframe_->samples_per_channel_);
1591 1591
1592 ASSERT_EQ(kNoErr, apm_->AnalyzeReverseStream(revframe_)); 1592 ASSERT_EQ(kNoErr, apm_->ProcessReverseStream(revframe_));
1593 1593
1594 CopyLeftToRightChannel(frame_->data_, frame_->samples_per_channel_); 1594 CopyLeftToRightChannel(frame_->data_, frame_->samples_per_channel_);
1595 frame_->vad_activity_ = AudioFrame::kVadUnknown; 1595 frame_->vad_activity_ = AudioFrame::kVadUnknown;
1596 1596
1597 ASSERT_EQ(kNoErr, apm_->set_stream_delay_ms(0)); 1597 ASSERT_EQ(kNoErr, apm_->set_stream_delay_ms(0));
1598 apm_->echo_cancellation()->set_stream_drift_samples(0); 1598 apm_->echo_cancellation()->set_stream_drift_samples(0);
1599 ASSERT_EQ(kNoErr, 1599 ASSERT_EQ(kNoErr,
1600 apm_->gain_control()->set_stream_analog_level(analog_level)); 1600 apm_->gain_control()->set_stream_analog_level(analog_level));
1601 ASSERT_EQ(kNoErr, apm_->ProcessStream(frame_)); 1601 ASSERT_EQ(kNoErr, apm_->ProcessStream(frame_));
1602 analog_level = apm_->gain_control()->stream_analog_level(); 1602 analog_level = apm_->gain_control()->stream_analog_level();
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 test::TempFilename(test::OutputPath(), "debug_aec"); 1857 test::TempFilename(test::OutputPath(), "debug_aec");
1858 EXPECT_EQ(apm_->kNullPointerError, 1858 EXPECT_EQ(apm_->kNullPointerError,
1859 apm_->StartDebugRecording(static_cast<const char*>(NULL), -1)); 1859 apm_->StartDebugRecording(static_cast<const char*>(NULL), -1));
1860 1860
1861 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1861 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1862 // Stopping without having started should be OK. 1862 // Stopping without having started should be OK.
1863 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1863 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1864 1864
1865 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(filename.c_str(), -1)); 1865 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(filename.c_str(), -1));
1866 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); 1866 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
1867 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); 1867 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
1868 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1868 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1869 1869
1870 // Verify the file has been written. 1870 // Verify the file has been written.
1871 FILE* fid = fopen(filename.c_str(), "r"); 1871 FILE* fid = fopen(filename.c_str(), "r");
1872 ASSERT_TRUE(fid != NULL); 1872 ASSERT_TRUE(fid != NULL);
1873 1873
1874 // Clean it up. 1874 // Clean it up.
1875 ASSERT_EQ(0, fclose(fid)); 1875 ASSERT_EQ(0, fclose(fid));
1876 ASSERT_EQ(0, remove(filename.c_str())); 1876 ASSERT_EQ(0, remove(filename.c_str()));
1877 #else 1877 #else
(...skipping 13 matching lines...) Expand all
1891 const std::string filename = 1891 const std::string filename =
1892 test::TempFilename(test::OutputPath(), "debug_aec"); 1892 test::TempFilename(test::OutputPath(), "debug_aec");
1893 fid = fopen(filename.c_str(), "w"); 1893 fid = fopen(filename.c_str(), "w");
1894 ASSERT_TRUE(fid); 1894 ASSERT_TRUE(fid);
1895 1895
1896 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 1896 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
1897 // Stopping without having started should be OK. 1897 // Stopping without having started should be OK.
1898 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1898 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1899 1899
1900 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(fid, -1)); 1900 EXPECT_EQ(apm_->kNoError, apm_->StartDebugRecording(fid, -1));
1901 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); 1901 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
1902 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); 1902 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
1903 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording()); 1903 EXPECT_EQ(apm_->kNoError, apm_->StopDebugRecording());
1904 1904
1905 // Verify the file has been written. 1905 // Verify the file has been written.
1906 fid = fopen(filename.c_str(), "r"); 1906 fid = fopen(filename.c_str(), "r");
1907 ASSERT_TRUE(fid != NULL); 1907 ASSERT_TRUE(fid != NULL);
1908 1908
1909 // Clean it up. 1909 // Clean it up.
1910 ASSERT_EQ(0, fclose(fid)); 1910 ASSERT_EQ(0, fclose(fid));
1911 ASSERT_EQ(0, remove(filename.c_str())); 1911 ASSERT_EQ(0, remove(filename.c_str()));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 ChannelBuffer<int16_t> output_cb(samples_per_channel, num_input_channels); 1951 ChannelBuffer<int16_t> output_cb(samples_per_channel, num_input_channels);
1952 ChannelBuffer<int16_t> output_int16(samples_per_channel, 1952 ChannelBuffer<int16_t> output_int16(samples_per_channel,
1953 num_input_channels); 1953 num_input_channels);
1954 1954
1955 int analog_level = 127; 1955 int analog_level = 127;
1956 size_t num_bad_chunks = 0; 1956 size_t num_bad_chunks = 0;
1957 while (ReadFrame(far_file_, revframe_, revfloat_cb_.get()) && 1957 while (ReadFrame(far_file_, revframe_, revfloat_cb_.get()) &&
1958 ReadFrame(near_file_, frame_, float_cb_.get())) { 1958 ReadFrame(near_file_, frame_, float_cb_.get())) {
1959 frame_->vad_activity_ = AudioFrame::kVadUnknown; 1959 frame_->vad_activity_ = AudioFrame::kVadUnknown;
1960 1960
1961 EXPECT_NOERR(apm_->AnalyzeReverseStream(revframe_)); 1961 EXPECT_NOERR(apm_->ProcessReverseStream(revframe_));
1962 EXPECT_NOERR(fapm->AnalyzeReverseStream( 1962 EXPECT_NOERR(fapm->AnalyzeReverseStream(
1963 revfloat_cb_->channels(), 1963 revfloat_cb_->channels(),
1964 samples_per_channel, 1964 samples_per_channel,
1965 test->sample_rate(), 1965 test->sample_rate(),
1966 LayoutFromChannels(num_render_channels))); 1966 LayoutFromChannels(num_render_channels)));
1967 1967
1968 EXPECT_NOERR(apm_->set_stream_delay_ms(0)); 1968 EXPECT_NOERR(apm_->set_stream_delay_ms(0));
1969 EXPECT_NOERR(fapm->set_stream_delay_ms(0)); 1969 EXPECT_NOERR(fapm->set_stream_delay_ms(0));
1970 apm_->echo_cancellation()->set_stream_drift_samples(0); 1970 apm_->echo_cancellation()->set_stream_drift_samples(0);
1971 fapm->echo_cancellation()->set_stream_drift_samples(0); 1971 fapm->echo_cancellation()->set_stream_drift_samples(0);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 int frame_count = 0; 2091 int frame_count = 0;
2092 int has_echo_count = 0; 2092 int has_echo_count = 0;
2093 int has_voice_count = 0; 2093 int has_voice_count = 0;
2094 int is_saturated_count = 0; 2094 int is_saturated_count = 0;
2095 int analog_level = 127; 2095 int analog_level = 127;
2096 int analog_level_average = 0; 2096 int analog_level_average = 0;
2097 int max_output_average = 0; 2097 int max_output_average = 0;
2098 float ns_speech_prob_average = 0.0f; 2098 float ns_speech_prob_average = 0.0f;
2099 2099
2100 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) { 2100 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) {
2101 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); 2101 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(revframe_));
2102 2102
2103 frame_->vad_activity_ = AudioFrame::kVadUnknown; 2103 frame_->vad_activity_ = AudioFrame::kVadUnknown;
2104 2104
2105 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0)); 2105 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0));
2106 apm_->echo_cancellation()->set_stream_drift_samples(0); 2106 apm_->echo_cancellation()->set_stream_drift_samples(0);
2107 EXPECT_EQ(apm_->kNoError, 2107 EXPECT_EQ(apm_->kNoError,
2108 apm_->gain_control()->set_stream_analog_level(analog_level)); 2108 apm_->gain_control()->set_stream_analog_level(analog_level));
2109 2109
2110 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); 2110 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
2111 2111
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), 2744 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35),
2745 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), 2745 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0),
2746 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), 2746 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20),
2747 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), 2747 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20),
2748 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 20), 2748 std::tr1::make_tuple(16000, 16000, 32000, 16000, 35, 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 } // namespace 2752 } // namespace
2753 } // namespace webrtc 2753 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698