2013-04-29 17:27:29 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
|
#include "webrtc/common_audio/include/audio_util.h"
|
|
|
|
|
#include "webrtc/typedefs.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
void ExpectArraysEq(const int16_t* ref, const int16_t* test, int length) {
|
|
|
|
|
for (int i = 0; i < length; ++i) {
|
2014-03-04 20:58:13 +00:00
|
|
|
EXPECT_EQ(ref[i], test[i]);
|
2013-04-29 17:27:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-04 20:58:13 +00:00
|
|
|
void ExpectArraysEq(const float* ref, const float* test, int length) {
|
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
|
|
|
EXPECT_FLOAT_EQ(ref[i], test[i]);
|
|
|
|
|
}
|
2013-09-06 21:15:55 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-30 03:40:10 +00:00
|
|
|
TEST(AudioUtilTest, FloatToS16) {
|
|
|
|
|
const int kSize = 9;
|
Revert of Allow more than 2 input channels in AudioProcessing. (patchset #13 id:240001 of https://codereview.webrtc.org/1226093007/)
Reason for revert:
Breaks Chromium FYI content_browsertest on all platforms. The testcase that fails is WebRtcAecDumpBrowserTest.CallWithAecDump.
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux/builds/19388
Sample output:
[ RUN ] WebRtcAecDumpBrowserTest.CallWithAecDump
Xlib: extension "RANDR" missing on display ":9".
[4:14:0722/211548:1282124453:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: ISAC/48000/1 (105)
[4:14:0722/211548:1282124593:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMU/8000/2 (110)
[4:14:0722/211548:1282124700:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMA/8000/2 (118)
[4:14:0722/211548:1282124815:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: G722/8000/2 (119)
[19745:19745:0722/211548:1282133667:INFO:CONSOLE(64)] "Looking at video in element remote-view-1", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
[19745:19745:0722/211548:1282136892:INFO:CONSOLE(64)] "Looking at video in element remote-view-2", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
../../content/test/webrtc_content_browsertest_base.cc:62: Failure
Value of: ExecuteScriptAndExtractString( shell()->web_contents(), javascript, &result)
Actual: false
Expected: true
Failed to execute javascript call({video: true, audio: true});.
From javascript: (nothing)
When executing 'call({video: true, audio: true});'
../../content/test/webrtc_content_browsertest_base.cc:75: Failure
Failed
../../content/browser/media/webrtc_aecdump_browsertest.cc:26: Failure
Expected: (base::kNullProcessId) != (*id), actual: 0 vs 0
../../content/browser/media/webrtc_aecdump_browsertest.cc:95: Failure
Value of: GetRenderProcessHostId(&render_process_id)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:99: Failure
Value of: base::PathExists(dump_file)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:101: Failure
Value of: base::GetFileSize(dump_file, &file_size)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:102: Failure
Expected: (file_size) > (0), actual: 0 vs 0
[ FAILED ] WebRtcAecDumpBrowserTest.CallWithAecDump, where TypeParam = and GetParam() = (361 ms)
Original issue's description:
> Allow more than 2 input channels in AudioProcessing.
>
> The number of output channels is constrained to be equal to either 1 or the
> number of input channels.
>
> R=aluebs@webrtc.org, andrew@webrtc.org, pbos@webrtc.org
>
> Committed: https://chromium.googlesource.com/external/webrtc/+/c204754b7a0cc801c70e8ce6c689f57f6ce00b3b
TBR=andrew@webrtc.org,aluebs@webrtc.org,ajm@chromium.org,pbos@chromium.org,pbos@webrtc.org,mgraczyk@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.webrtc.org/1253573005
Cr-Commit-Position: refs/heads/master@{#9621}
2015-07-23 04:30:06 -07:00
|
|
|
const float kInput[kSize] = {
|
|
|
|
|
0.f, 0.4f / 32767.f, 0.6f / 32767.f, -0.4f / 32768.f, -0.6f / 32768.f,
|
|
|
|
|
1.f, -1.f, 1.1f, -1.1f};
|
|
|
|
|
const int16_t kReference[kSize] = {
|
|
|
|
|
0, 0, 1, 0, -1, 32767, -32768, 32767, -32768};
|
2014-10-30 03:40:10 +00:00
|
|
|
int16_t output[kSize];
|
|
|
|
|
FloatToS16(kInput, kSize, output);
|
|
|
|
|
ExpectArraysEq(kReference, output, kSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(AudioUtilTest, S16ToFloat) {
|
|
|
|
|
const int kSize = 7;
|
|
|
|
|
const int16_t kInput[kSize] = {0, 1, -1, 16384, -16384, 32767, -32768};
|
|
|
|
|
const float kReference[kSize] = {
|
|
|
|
|
0.f, 1.f / 32767.f, -1.f / 32768.f, 16384.f / 32767.f, -0.5f, 1.f, -1.f};
|
|
|
|
|
float output[kSize];
|
|
|
|
|
S16ToFloat(kInput, kSize, output);
|
|
|
|
|
ExpectArraysEq(kReference, output, kSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(AudioUtilTest, FloatS16ToS16) {
|
2014-02-20 20:55:21 +00:00
|
|
|
const int kSize = 7;
|
Revert of Allow more than 2 input channels in AudioProcessing. (patchset #13 id:240001 of https://codereview.webrtc.org/1226093007/)
Reason for revert:
Breaks Chromium FYI content_browsertest on all platforms. The testcase that fails is WebRtcAecDumpBrowserTest.CallWithAecDump.
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux/builds/19388
Sample output:
[ RUN ] WebRtcAecDumpBrowserTest.CallWithAecDump
Xlib: extension "RANDR" missing on display ":9".
[4:14:0722/211548:1282124453:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: ISAC/48000/1 (105)
[4:14:0722/211548:1282124593:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMU/8000/2 (110)
[4:14:0722/211548:1282124700:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMA/8000/2 (118)
[4:14:0722/211548:1282124815:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: G722/8000/2 (119)
[19745:19745:0722/211548:1282133667:INFO:CONSOLE(64)] "Looking at video in element remote-view-1", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
[19745:19745:0722/211548:1282136892:INFO:CONSOLE(64)] "Looking at video in element remote-view-2", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
../../content/test/webrtc_content_browsertest_base.cc:62: Failure
Value of: ExecuteScriptAndExtractString( shell()->web_contents(), javascript, &result)
Actual: false
Expected: true
Failed to execute javascript call({video: true, audio: true});.
From javascript: (nothing)
When executing 'call({video: true, audio: true});'
../../content/test/webrtc_content_browsertest_base.cc:75: Failure
Failed
../../content/browser/media/webrtc_aecdump_browsertest.cc:26: Failure
Expected: (base::kNullProcessId) != (*id), actual: 0 vs 0
../../content/browser/media/webrtc_aecdump_browsertest.cc:95: Failure
Value of: GetRenderProcessHostId(&render_process_id)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:99: Failure
Value of: base::PathExists(dump_file)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:101: Failure
Value of: base::GetFileSize(dump_file, &file_size)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:102: Failure
Expected: (file_size) > (0), actual: 0 vs 0
[ FAILED ] WebRtcAecDumpBrowserTest.CallWithAecDump, where TypeParam = and GetParam() = (361 ms)
Original issue's description:
> Allow more than 2 input channels in AudioProcessing.
>
> The number of output channels is constrained to be equal to either 1 or the
> number of input channels.
>
> R=aluebs@webrtc.org, andrew@webrtc.org, pbos@webrtc.org
>
> Committed: https://chromium.googlesource.com/external/webrtc/+/c204754b7a0cc801c70e8ce6c689f57f6ce00b3b
TBR=andrew@webrtc.org,aluebs@webrtc.org,ajm@chromium.org,pbos@chromium.org,pbos@webrtc.org,mgraczyk@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.webrtc.org/1253573005
Cr-Commit-Position: refs/heads/master@{#9621}
2015-07-23 04:30:06 -07:00
|
|
|
const float kInput[kSize] = {
|
|
|
|
|
0.f, 0.4f, 0.5f, -0.4f, -0.5f, 32768.f, -32769.f};
|
2014-02-20 20:55:21 +00:00
|
|
|
const int16_t kReference[kSize] = {0, 0, 1, 0, -1, 32767, -32768};
|
|
|
|
|
int16_t output[kSize];
|
2014-10-30 03:40:10 +00:00
|
|
|
FloatS16ToS16(kInput, kSize, output);
|
2014-03-04 20:58:13 +00:00
|
|
|
ExpectArraysEq(kReference, output, kSize);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-30 03:40:10 +00:00
|
|
|
TEST(AudioUtilTest, FloatToFloatS16) {
|
2014-03-04 20:58:13 +00:00
|
|
|
const int kSize = 9;
|
Revert of Allow more than 2 input channels in AudioProcessing. (patchset #13 id:240001 of https://codereview.webrtc.org/1226093007/)
Reason for revert:
Breaks Chromium FYI content_browsertest on all platforms. The testcase that fails is WebRtcAecDumpBrowserTest.CallWithAecDump.
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux/builds/19388
Sample output:
[ RUN ] WebRtcAecDumpBrowserTest.CallWithAecDump
Xlib: extension "RANDR" missing on display ":9".
[4:14:0722/211548:1282124453:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: ISAC/48000/1 (105)
[4:14:0722/211548:1282124593:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMU/8000/2 (110)
[4:14:0722/211548:1282124700:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMA/8000/2 (118)
[4:14:0722/211548:1282124815:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: G722/8000/2 (119)
[19745:19745:0722/211548:1282133667:INFO:CONSOLE(64)] "Looking at video in element remote-view-1", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
[19745:19745:0722/211548:1282136892:INFO:CONSOLE(64)] "Looking at video in element remote-view-2", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
../../content/test/webrtc_content_browsertest_base.cc:62: Failure
Value of: ExecuteScriptAndExtractString( shell()->web_contents(), javascript, &result)
Actual: false
Expected: true
Failed to execute javascript call({video: true, audio: true});.
From javascript: (nothing)
When executing 'call({video: true, audio: true});'
../../content/test/webrtc_content_browsertest_base.cc:75: Failure
Failed
../../content/browser/media/webrtc_aecdump_browsertest.cc:26: Failure
Expected: (base::kNullProcessId) != (*id), actual: 0 vs 0
../../content/browser/media/webrtc_aecdump_browsertest.cc:95: Failure
Value of: GetRenderProcessHostId(&render_process_id)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:99: Failure
Value of: base::PathExists(dump_file)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:101: Failure
Value of: base::GetFileSize(dump_file, &file_size)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:102: Failure
Expected: (file_size) > (0), actual: 0 vs 0
[ FAILED ] WebRtcAecDumpBrowserTest.CallWithAecDump, where TypeParam = and GetParam() = (361 ms)
Original issue's description:
> Allow more than 2 input channels in AudioProcessing.
>
> The number of output channels is constrained to be equal to either 1 or the
> number of input channels.
>
> R=aluebs@webrtc.org, andrew@webrtc.org, pbos@webrtc.org
>
> Committed: https://chromium.googlesource.com/external/webrtc/+/c204754b7a0cc801c70e8ce6c689f57f6ce00b3b
TBR=andrew@webrtc.org,aluebs@webrtc.org,ajm@chromium.org,pbos@chromium.org,pbos@webrtc.org,mgraczyk@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.webrtc.org/1253573005
Cr-Commit-Position: refs/heads/master@{#9621}
2015-07-23 04:30:06 -07:00
|
|
|
const float kInput[kSize] = {
|
|
|
|
|
0.f, 0.4f / 32767.f, 0.6f / 32767.f, -0.4f / 32768.f, -0.6f / 32768.f,
|
|
|
|
|
1.f, -1.f, 1.1f, -1.1f};
|
|
|
|
|
const float kReference[kSize] = {
|
|
|
|
|
0.f, 0.4f, 0.6f, -0.4f, -0.6f, 32767.f, -32768.f, 36043.7f, -36044.8f};
|
2014-10-30 03:40:10 +00:00
|
|
|
float output[kSize];
|
|
|
|
|
FloatToFloatS16(kInput, kSize, output);
|
2014-03-04 20:58:13 +00:00
|
|
|
ExpectArraysEq(kReference, output, kSize);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-30 03:40:10 +00:00
|
|
|
TEST(AudioUtilTest, FloatS16ToFloat) {
|
|
|
|
|
const int kSize = 9;
|
Revert of Allow more than 2 input channels in AudioProcessing. (patchset #13 id:240001 of https://codereview.webrtc.org/1226093007/)
Reason for revert:
Breaks Chromium FYI content_browsertest on all platforms. The testcase that fails is WebRtcAecDumpBrowserTest.CallWithAecDump.
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux/builds/19388
Sample output:
[ RUN ] WebRtcAecDumpBrowserTest.CallWithAecDump
Xlib: extension "RANDR" missing on display ":9".
[4:14:0722/211548:1282124453:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: ISAC/48000/1 (105)
[4:14:0722/211548:1282124593:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMU/8000/2 (110)
[4:14:0722/211548:1282124700:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: PCMA/8000/2 (118)
[4:14:0722/211548:1282124815:WARNING:webrtcvoiceengine.cc(472)] Unexpected codec: G722/8000/2 (119)
[19745:19745:0722/211548:1282133667:INFO:CONSOLE(64)] "Looking at video in element remote-view-1", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
[19745:19745:0722/211548:1282136892:INFO:CONSOLE(64)] "Looking at video in element remote-view-2", source: http://127.0.0.1:48819/media/webrtc_test_utilities.js (64)
../../content/test/webrtc_content_browsertest_base.cc:62: Failure
Value of: ExecuteScriptAndExtractString( shell()->web_contents(), javascript, &result)
Actual: false
Expected: true
Failed to execute javascript call({video: true, audio: true});.
From javascript: (nothing)
When executing 'call({video: true, audio: true});'
../../content/test/webrtc_content_browsertest_base.cc:75: Failure
Failed
../../content/browser/media/webrtc_aecdump_browsertest.cc:26: Failure
Expected: (base::kNullProcessId) != (*id), actual: 0 vs 0
../../content/browser/media/webrtc_aecdump_browsertest.cc:95: Failure
Value of: GetRenderProcessHostId(&render_process_id)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:99: Failure
Value of: base::PathExists(dump_file)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:101: Failure
Value of: base::GetFileSize(dump_file, &file_size)
Actual: false
Expected: true
../../content/browser/media/webrtc_aecdump_browsertest.cc:102: Failure
Expected: (file_size) > (0), actual: 0 vs 0
[ FAILED ] WebRtcAecDumpBrowserTest.CallWithAecDump, where TypeParam = and GetParam() = (361 ms)
Original issue's description:
> Allow more than 2 input channels in AudioProcessing.
>
> The number of output channels is constrained to be equal to either 1 or the
> number of input channels.
>
> R=aluebs@webrtc.org, andrew@webrtc.org, pbos@webrtc.org
>
> Committed: https://chromium.googlesource.com/external/webrtc/+/c204754b7a0cc801c70e8ce6c689f57f6ce00b3b
TBR=andrew@webrtc.org,aluebs@webrtc.org,ajm@chromium.org,pbos@chromium.org,pbos@webrtc.org,mgraczyk@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.webrtc.org/1253573005
Cr-Commit-Position: refs/heads/master@{#9621}
2015-07-23 04:30:06 -07:00
|
|
|
const float kInput[kSize] = {
|
|
|
|
|
0.f, 0.4f, 0.6f, -0.4f, -0.6f, 32767.f, -32768.f, 36043.7f, -36044.8f};
|
|
|
|
|
const float kReference[kSize] = {
|
|
|
|
|
0.f, 0.4f / 32767.f, 0.6f / 32767.f, -0.4f / 32768.f, -0.6f / 32768.f,
|
|
|
|
|
1.f, -1.f, 1.1f, -1.1f};
|
2014-03-04 20:58:13 +00:00
|
|
|
float output[kSize];
|
2014-10-30 03:40:10 +00:00
|
|
|
FloatS16ToFloat(kInput, kSize, output);
|
2014-03-04 20:58:13 +00:00
|
|
|
ExpectArraysEq(kReference, output, kSize);
|
2013-09-06 21:15:55 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-29 17:27:29 +00:00
|
|
|
TEST(AudioUtilTest, InterleavingStereo) {
|
|
|
|
|
const int16_t kInterleaved[] = {2, 3, 4, 9, 8, 27, 16, 81};
|
|
|
|
|
const int kSamplesPerChannel = 4;
|
|
|
|
|
const int kNumChannels = 2;
|
|
|
|
|
const int kLength = kSamplesPerChannel * kNumChannels;
|
|
|
|
|
int16_t left[kSamplesPerChannel], right[kSamplesPerChannel];
|
|
|
|
|
int16_t* deinterleaved[] = {left, right};
|
|
|
|
|
Deinterleave(kInterleaved, kSamplesPerChannel, kNumChannels, deinterleaved);
|
|
|
|
|
const int16_t kRefLeft[] = {2, 4, 8, 16};
|
|
|
|
|
const int16_t kRefRight[] = {3, 9, 27, 81};
|
2014-03-04 20:58:13 +00:00
|
|
|
ExpectArraysEq(kRefLeft, left, kSamplesPerChannel);
|
|
|
|
|
ExpectArraysEq(kRefRight, right, kSamplesPerChannel);
|
2013-04-29 17:27:29 +00:00
|
|
|
|
|
|
|
|
int16_t interleaved[kLength];
|
|
|
|
|
Interleave(deinterleaved, kSamplesPerChannel, kNumChannels, interleaved);
|
2014-03-04 20:58:13 +00:00
|
|
|
ExpectArraysEq(kInterleaved, interleaved, kLength);
|
2013-04-29 17:27:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(AudioUtilTest, InterleavingMonoIsIdentical) {
|
|
|
|
|
const int16_t kInterleaved[] = {1, 2, 3, 4, 5};
|
|
|
|
|
const int kSamplesPerChannel = 5;
|
|
|
|
|
const int kNumChannels = 1;
|
|
|
|
|
int16_t mono[kSamplesPerChannel];
|
|
|
|
|
int16_t* deinterleaved[] = {mono};
|
|
|
|
|
Deinterleave(kInterleaved, kSamplesPerChannel, kNumChannels, deinterleaved);
|
2014-03-04 20:58:13 +00:00
|
|
|
ExpectArraysEq(kInterleaved, mono, kSamplesPerChannel);
|
2013-04-29 17:27:29 +00:00
|
|
|
|
|
|
|
|
int16_t interleaved[kSamplesPerChannel];
|
|
|
|
|
Interleave(deinterleaved, kSamplesPerChannel, kNumChannels, interleaved);
|
2014-03-04 20:58:13 +00:00
|
|
|
ExpectArraysEq(mono, interleaved, kSamplesPerChannel);
|
2013-04-29 17:27:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|