2013-01-29 12:09:21 +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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Test to verify correct stereo and multi-channel operation.
|
|
|
|
|
|
2014-03-04 15:10:03 +00:00
|
|
|
#include <algorithm>
|
2013-01-29 12:09:21 +00:00
|
|
|
#include <list>
|
2016-02-14 09:28:33 -08:00
|
|
|
#include <memory>
|
2013-01-29 12:09:21 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2018-04-12 22:44:09 +02:00
|
|
|
#include "api/audio/audio_frame.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
2019-10-31 14:38:11 +01:00
|
|
|
#include "api/neteq/neteq.h"
|
2024-05-27 11:22:27 +02:00
|
|
|
#include "api/units/timestamp.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
|
2019-11-28 14:07:14 +01:00
|
|
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
|
|
|
|
|
#include "modules/audio_coding/neteq/tools/rtp_generator.h"
|
2018-09-06 13:41:30 +02:00
|
|
|
#include "rtc_base/strings/string_builder.h"
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
#include "system_wrappers/include/clock.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "test/gtest.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "test/testsupport/file_utils.h"
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
struct TestParameters {
|
|
|
|
|
int frame_size;
|
|
|
|
|
int sample_rate;
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_channels;
|
2013-01-29 12:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// This is a parameterized test. The test parameters are supplied through a
|
|
|
|
|
// TestParameters struct, which is obtained through the GetParam() method.
|
|
|
|
|
//
|
|
|
|
|
// The objective of the test is to create a mono input signal and a
|
|
|
|
|
// multi-channel input signal, where each channel is identical to the mono
|
|
|
|
|
// input channel. The two input signals are processed through their respective
|
|
|
|
|
// NetEq instances. After that, the output signals are compared. The expected
|
|
|
|
|
// result is that each channel in the multi-channel output is identical to the
|
|
|
|
|
// mono output.
|
|
|
|
|
class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> {
|
|
|
|
|
protected:
|
|
|
|
|
static const int kTimeStepMs = 10;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
static const size_t kMaxBlockSize = 480; // 10 ms @ 48 kHz.
|
2013-01-29 12:09:21 +00:00
|
|
|
static const uint8_t kPayloadTypeMono = 95;
|
|
|
|
|
static const uint8_t kPayloadTypeMulti = 96;
|
|
|
|
|
|
|
|
|
|
NetEqStereoTest()
|
|
|
|
|
: num_channels_(GetParam().num_channels),
|
|
|
|
|
sample_rate_hz_(GetParam().sample_rate),
|
|
|
|
|
samples_per_ms_(sample_rate_hz_ / 1000),
|
|
|
|
|
frame_size_ms_(GetParam().frame_size),
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
frame_size_samples_(
|
|
|
|
|
static_cast<size_t>(frame_size_ms_ * samples_per_ms_)),
|
2013-01-29 12:09:21 +00:00
|
|
|
output_size_samples_(10 * samples_per_ms_),
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
clock_(0),
|
2013-01-29 12:09:21 +00:00
|
|
|
rtp_generator_mono_(samples_per_ms_),
|
|
|
|
|
rtp_generator_(samples_per_ms_),
|
|
|
|
|
payload_size_bytes_(0),
|
|
|
|
|
multi_payload_size_bytes_(0),
|
|
|
|
|
last_send_time_(0),
|
|
|
|
|
last_arrival_time_(0) {
|
2014-04-14 18:49:17 +00:00
|
|
|
NetEq::Config config;
|
|
|
|
|
config.sample_rate_hz = sample_rate_hz_;
|
2019-11-28 14:07:14 +01:00
|
|
|
DefaultNetEqFactory neteq_factory;
|
|
|
|
|
auto decoder_factory = CreateBuiltinAudioDecoderFactory();
|
|
|
|
|
neteq_mono_ = neteq_factory.CreateNetEq(config, decoder_factory, &clock_);
|
|
|
|
|
neteq_ = neteq_factory.CreateNetEq(config, decoder_factory, &clock_);
|
2013-01-29 12:09:21 +00:00
|
|
|
input_ = new int16_t[frame_size_samples_];
|
|
|
|
|
encoded_ = new uint8_t[2 * frame_size_samples_];
|
|
|
|
|
input_multi_channel_ = new int16_t[frame_size_samples_ * num_channels_];
|
|
|
|
|
encoded_multi_channel_ =
|
|
|
|
|
new uint8_t[frame_size_samples_ * 2 * num_channels_];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~NetEqStereoTest() {
|
|
|
|
|
delete[] input_;
|
|
|
|
|
delete[] encoded_;
|
|
|
|
|
delete[] input_multi_channel_;
|
|
|
|
|
delete[] encoded_multi_channel_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
|
const std::string file_name =
|
|
|
|
|
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
|
|
|
|
input_file_.reset(new test::InputAudioFile(file_name));
|
2019-01-10 16:55:06 +01:00
|
|
|
RTC_CHECK_GE(num_channels_, 2);
|
|
|
|
|
ASSERT_TRUE(neteq_mono_->RegisterPayloadType(
|
|
|
|
|
kPayloadTypeMono, SdpAudioFormat("l16", sample_rate_hz_, 1)));
|
|
|
|
|
ASSERT_TRUE(neteq_->RegisterPayloadType(
|
|
|
|
|
kPayloadTypeMulti,
|
|
|
|
|
SdpAudioFormat("l16", sample_rate_hz_, num_channels_)));
|
2013-01-29 12:09:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void TearDown() {}
|
|
|
|
|
|
|
|
|
|
int GetNewPackets() {
|
|
|
|
|
if (!input_file_->Read(frame_size_samples_, input_)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
payload_size_bytes_ =
|
|
|
|
|
WebRtcPcm16b_Encode(input_, frame_size_samples_, encoded_);
|
|
|
|
|
if (frame_size_samples_ * 2 != payload_size_bytes_) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2024-05-27 11:22:27 +02:00
|
|
|
int next_send_time_ms = rtp_generator_mono_.GetRtpHeader(
|
2013-01-29 12:09:21 +00:00
|
|
|
kPayloadTypeMono, frame_size_samples_, &rtp_header_mono_);
|
2019-12-02 15:46:00 +01:00
|
|
|
MakeMultiChannelInput();
|
2013-01-29 12:09:21 +00:00
|
|
|
multi_payload_size_bytes_ = WebRtcPcm16b_Encode(
|
|
|
|
|
input_multi_channel_, frame_size_samples_ * num_channels_,
|
|
|
|
|
encoded_multi_channel_);
|
|
|
|
|
if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_,
|
|
|
|
|
&rtp_header_);
|
2024-05-27 11:22:27 +02:00
|
|
|
return next_send_time_ms;
|
2013-01-29 12:09:21 +00:00
|
|
|
}
|
|
|
|
|
|
2019-12-02 15:46:00 +01:00
|
|
|
virtual void MakeMultiChannelInput() {
|
|
|
|
|
test::InputAudioFile::DuplicateInterleaved(
|
|
|
|
|
input_, frame_size_samples_, num_channels_, input_multi_channel_);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-20 07:26:24 -08:00
|
|
|
virtual void VerifyOutput(size_t num_samples) {
|
2017-06-12 12:45:32 -07:00
|
|
|
const int16_t* output_data = output_.data();
|
|
|
|
|
const int16_t* output_multi_channel_data = output_multi_channel_.data();
|
2013-01-29 12:09:21 +00:00
|
|
|
for (size_t i = 0; i < num_samples; ++i) {
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t j = 0; j < num_channels_; ++j) {
|
2017-06-12 12:45:32 -07:00
|
|
|
ASSERT_EQ(output_data[i],
|
|
|
|
|
output_multi_channel_data[i * num_channels_ + j])
|
2016-03-04 10:34:21 -08:00
|
|
|
<< "Diff in sample " << i << ", channel " << j << ".";
|
2013-01-29 12:09:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual int GetArrivalTime(int send_time) {
|
|
|
|
|
int arrival_time = last_arrival_time_ + (send_time - last_send_time_);
|
|
|
|
|
last_send_time_ = send_time;
|
|
|
|
|
last_arrival_time_ = arrival_time;
|
|
|
|
|
return arrival_time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool Lost() { return false; }
|
|
|
|
|
|
|
|
|
|
void RunTest(int num_loops) {
|
|
|
|
|
// Get next input packets (mono and multi-channel).
|
2024-05-27 11:22:27 +02:00
|
|
|
int next_send_time_ms;
|
|
|
|
|
int next_arrival_time_ms;
|
2013-01-29 12:09:21 +00:00
|
|
|
do {
|
2024-05-27 11:22:27 +02:00
|
|
|
next_send_time_ms = GetNewPackets();
|
|
|
|
|
ASSERT_NE(-1, next_send_time_ms);
|
|
|
|
|
next_arrival_time_ms = GetArrivalTime(next_send_time_ms);
|
2013-01-29 12:09:21 +00:00
|
|
|
} while (Lost()); // If lost, immediately read the next packet.
|
|
|
|
|
|
2024-05-27 11:22:27 +02:00
|
|
|
int time_now_ms = 0;
|
2013-01-29 12:09:21 +00:00
|
|
|
for (int k = 0; k < num_loops; ++k) {
|
2024-05-27 11:22:27 +02:00
|
|
|
while (time_now_ms >= next_arrival_time_ms) {
|
2013-01-29 12:09:21 +00:00
|
|
|
// Insert packet in mono instance.
|
|
|
|
|
ASSERT_EQ(NetEq::kOK,
|
2024-05-27 11:22:27 +02:00
|
|
|
neteq_mono_->InsertPacket(rtp_header_mono_,
|
|
|
|
|
rtc::ArrayView<const uint8_t>(
|
|
|
|
|
encoded_, payload_size_bytes_),
|
|
|
|
|
Timestamp::Millis(time_now_ms)));
|
2013-01-29 12:09:21 +00:00
|
|
|
// Insert packet in multi-channel instance.
|
2024-05-27 11:22:27 +02:00
|
|
|
ASSERT_EQ(NetEq::kOK,
|
|
|
|
|
neteq_->InsertPacket(
|
|
|
|
|
rtp_header_,
|
|
|
|
|
rtc::ArrayView<const uint8_t>(encoded_multi_channel_,
|
|
|
|
|
multi_payload_size_bytes_),
|
|
|
|
|
Timestamp::Millis(time_now_ms)));
|
2013-01-29 12:09:21 +00:00
|
|
|
// Get next input packets (mono and multi-channel).
|
|
|
|
|
do {
|
2024-05-27 11:22:27 +02:00
|
|
|
next_send_time_ms = GetNewPackets();
|
|
|
|
|
ASSERT_NE(-1, next_send_time_ms);
|
|
|
|
|
next_arrival_time_ms = GetArrivalTime(next_send_time_ms);
|
2013-01-29 12:09:21 +00:00
|
|
|
} while (Lost()); // If lost, immediately read the next packet.
|
|
|
|
|
}
|
|
|
|
|
// Get audio from mono instance.
|
2016-05-12 13:51:28 -07:00
|
|
|
bool muted;
|
|
|
|
|
EXPECT_EQ(NetEq::kOK, neteq_mono_->GetAudio(&output_, &muted));
|
|
|
|
|
ASSERT_FALSE(muted);
|
2016-03-04 10:34:21 -08:00
|
|
|
EXPECT_EQ(1u, output_.num_channels_);
|
|
|
|
|
EXPECT_EQ(output_size_samples_, output_.samples_per_channel_);
|
2013-01-29 12:09:21 +00:00
|
|
|
// Get audio from multi-channel instance.
|
2016-05-12 13:51:28 -07:00
|
|
|
ASSERT_EQ(NetEq::kOK, neteq_->GetAudio(&output_multi_channel_, &muted));
|
|
|
|
|
ASSERT_FALSE(muted);
|
2016-03-04 10:34:21 -08:00
|
|
|
EXPECT_EQ(num_channels_, output_multi_channel_.num_channels_);
|
|
|
|
|
EXPECT_EQ(output_size_samples_,
|
|
|
|
|
output_multi_channel_.samples_per_channel_);
|
2018-09-06 13:41:30 +02:00
|
|
|
rtc::StringBuilder ss;
|
2013-01-29 12:09:21 +00:00
|
|
|
ss << "Lap number " << k << ".";
|
|
|
|
|
SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
|
|
|
|
|
// Compare mono and multi-channel.
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_));
|
|
|
|
|
|
2024-05-27 11:22:27 +02:00
|
|
|
time_now_ms += kTimeStepMs;
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
clock_.AdvanceTimeMilliseconds(kTimeStepMs);
|
2013-01-29 12:09:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
const size_t num_channels_;
|
2013-01-29 12:09:21 +00:00
|
|
|
const int sample_rate_hz_;
|
|
|
|
|
const int samples_per_ms_;
|
|
|
|
|
const int frame_size_ms_;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
const size_t frame_size_samples_;
|
|
|
|
|
const size_t output_size_samples_;
|
Reland "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
This reverts commit fab3460a821abe336ab610c6d6dfc0d392dac263.
Reason for revert: fix downstream instead
Original change's description:
> Revert "Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.""
>
> This reverts commit 9973933d2e606d64fcdc753acb9ba3afd6e30569.
>
> Reason for revert: breaking downstream projects and not reviewed by direct owners
>
> Original change's description:
> > Reland "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> >
> > This reverts commit 24192c267a40eb7d6b1850489ccdbf7a84f8ff0f.
> >
> > Reason for revert: Analyzed the performance regression in more detail.
> >
> > Most of the regression comes from the extra RtpPacketInfos-related memory allocations in every `NetEq::GetAudio()` call. Commit 1796a820f60cb9429bf4bcf13a40a41794ac8fb0 has removed roughly 2/3rds of the extra allocations from the impacted perf tests. Remaining perf impact is expected to be about "8 microseconds of CPU time per second" on the Linux benchmarking machines and "15 us per second" on Windows/Mac.
> >
> > There are options to optimize further but they are unlikely worth doing. Note for example that `NetEqPerformanceTest` uses the PCM codec while the real-world use cases would likely use the much heavier Opus codec. The numbers from `OpusSpeedTest` and `NetEqPerformanceTest` suggest that Opus decoding is about 10x as expensive as NetEq overall.
> >
> > Original change's description:
> > > Revert "Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker."
> > >
> > > This reverts commit 3e8ef940fe86cf6285afb80e68d2a0bedc631b9f.
> > >
> > > Reason for revert: This CL causes a performance regression in NetEq, see https://bugs.chromium.org/p/chromium/issues/detail?id=982260.
> > >
> > > Original change's description:
> > > > Add plumbing of RtpPacketInfos to each AudioFrame as input for SourceTracker.
> > > >
> > > > This change adds the plumbing of RtpPacketInfo from ChannelReceive::OnRtpPacket() to ChannelReceive::GetAudioFrameWithInfo() for audio. It is a step towards replacing the non-spec compliant ContributingSources that updates itself at packet-receive time, with the spec-compliant SourceTracker that will update itself at frame-delivery-to-track time.
> > > >
> > > > Bug: webrtc:10668
> > > > Change-Id: I03385d6865bbc7bfbef7634f88de820a934f787a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139890
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Reviewed-by: Minyue Li <minyue@webrtc.org>
> > > > Commit-Queue: Chen Xing <chxg@google.com>
> > > > Cr-Commit-Position: refs/heads/master@{#28434}
> > >
> > > TBR=kwiberg@webrtc.org,stefan@webrtc.org,minyue@webrtc.org,chxg@google.com
> > >
> > > Bug: webrtc:10668, chromium:982260
> > > Change-Id: I5e2cfde78c59d1123e21869564d76ed3f6193a5c
> > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145339
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#28561}
> >
> > TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: webrtc:10668, chromium:982260
> > Change-Id: Ie375a0b327ee368317bf3a04b2f1415c3a974470
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146707
> > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > Commit-Queue: Chen Xing <chxg@google.com>
> > Cr-Commit-Position: refs/heads/master@{#28664}
>
> TBR=kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
>
> Change-Id: I652cb0814d83b514d3bee34e65ca3bb693099b22
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:10668, chromium:982260
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146712
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#28671}
TBR=alessiob@webrtc.org,kwiberg@webrtc.org,stefan@webrtc.org,ivoc@webrtc.org,minyue@webrtc.org,chxg@google.com
Change-Id: Id43b7b3da79b4f48004b41767482bae1c1fa1e16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10668, chromium:982260
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146713
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28672}
2019-07-24 16:47:02 +00:00
|
|
|
SimulatedClock clock_;
|
2019-10-31 14:38:11 +01:00
|
|
|
std::unique_ptr<NetEq> neteq_mono_;
|
|
|
|
|
std::unique_ptr<NetEq> neteq_;
|
2013-01-29 12:09:21 +00:00
|
|
|
test::RtpGenerator rtp_generator_mono_;
|
|
|
|
|
test::RtpGenerator rtp_generator_;
|
|
|
|
|
int16_t* input_;
|
|
|
|
|
int16_t* input_multi_channel_;
|
|
|
|
|
uint8_t* encoded_;
|
|
|
|
|
uint8_t* encoded_multi_channel_;
|
2016-03-04 10:34:21 -08:00
|
|
|
AudioFrame output_;
|
|
|
|
|
AudioFrame output_multi_channel_;
|
2017-04-24 09:14:32 -07:00
|
|
|
RTPHeader rtp_header_mono_;
|
|
|
|
|
RTPHeader rtp_header_;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t payload_size_bytes_;
|
|
|
|
|
size_t multi_payload_size_bytes_;
|
2013-01-29 12:09:21 +00:00
|
|
|
int last_send_time_;
|
|
|
|
|
int last_arrival_time_;
|
2016-02-14 09:28:33 -08:00
|
|
|
std::unique_ptr<test::InputAudioFile> input_file_;
|
2013-01-29 12:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class NetEqStereoTestNoJitter : public NetEqStereoTest {
|
|
|
|
|
protected:
|
|
|
|
|
NetEqStereoTestNoJitter() : NetEqStereoTest() {
|
|
|
|
|
// Start the sender 100 ms before the receiver to pre-fill the buffer.
|
|
|
|
|
// This is to avoid doing preemptive expand early in the test.
|
|
|
|
|
// TODO(hlundin): Mock the decision making instead to control the modes.
|
|
|
|
|
last_arrival_time_ = -100;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-20 07:26:24 -08:00
|
|
|
TEST_P(NetEqStereoTestNoJitter, RunTest) {
|
2013-01-29 12:09:21 +00:00
|
|
|
RunTest(8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class NetEqStereoTestPositiveDrift : public NetEqStereoTest {
|
|
|
|
|
protected:
|
|
|
|
|
NetEqStereoTestPositiveDrift() : NetEqStereoTest(), drift_factor(0.9) {
|
|
|
|
|
// Start the sender 100 ms before the receiver to pre-fill the buffer.
|
|
|
|
|
// This is to avoid doing preemptive expand early in the test.
|
|
|
|
|
// TODO(hlundin): Mock the decision making instead to control the modes.
|
|
|
|
|
last_arrival_time_ = -100;
|
|
|
|
|
}
|
|
|
|
|
virtual int GetArrivalTime(int send_time) {
|
|
|
|
|
int arrival_time =
|
|
|
|
|
last_arrival_time_ + drift_factor * (send_time - last_send_time_);
|
|
|
|
|
last_send_time_ = send_time;
|
|
|
|
|
last_arrival_time_ = arrival_time;
|
|
|
|
|
return arrival_time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double drift_factor;
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-20 07:26:24 -08:00
|
|
|
TEST_P(NetEqStereoTestPositiveDrift, RunTest) {
|
2013-01-29 12:09:21 +00:00
|
|
|
RunTest(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift {
|
|
|
|
|
protected:
|
|
|
|
|
NetEqStereoTestNegativeDrift() : NetEqStereoTestPositiveDrift() {
|
|
|
|
|
drift_factor = 1.1;
|
|
|
|
|
last_arrival_time_ = 0;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-20 07:26:24 -08:00
|
|
|
TEST_P(NetEqStereoTestNegativeDrift, RunTest) {
|
2013-01-29 12:09:21 +00:00
|
|
|
RunTest(100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class NetEqStereoTestDelays : public NetEqStereoTest {
|
|
|
|
|
protected:
|
|
|
|
|
static const int kDelayInterval = 10;
|
|
|
|
|
static const int kDelay = 1000;
|
|
|
|
|
NetEqStereoTestDelays() : NetEqStereoTest(), frame_index_(0) {}
|
|
|
|
|
|
|
|
|
|
virtual int GetArrivalTime(int send_time) {
|
|
|
|
|
// Deliver immediately, unless we have a back-log.
|
|
|
|
|
int arrival_time = std::min(last_arrival_time_, send_time);
|
|
|
|
|
if (++frame_index_ % kDelayInterval == 0) {
|
|
|
|
|
// Delay this packet.
|
|
|
|
|
arrival_time += kDelay;
|
|
|
|
|
}
|
|
|
|
|
last_send_time_ = send_time;
|
|
|
|
|
last_arrival_time_ = arrival_time;
|
|
|
|
|
return arrival_time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int frame_index_;
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-20 07:26:24 -08:00
|
|
|
TEST_P(NetEqStereoTestDelays, RunTest) {
|
2013-01-29 12:09:21 +00:00
|
|
|
RunTest(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class NetEqStereoTestLosses : public NetEqStereoTest {
|
|
|
|
|
protected:
|
|
|
|
|
static const int kLossInterval = 10;
|
|
|
|
|
NetEqStereoTestLosses() : NetEqStereoTest(), frame_index_(0) {}
|
|
|
|
|
|
|
|
|
|
virtual bool Lost() { return (++frame_index_) % kLossInterval == 0; }
|
|
|
|
|
|
2016-01-20 07:26:24 -08:00
|
|
|
// TODO(hlundin): NetEq is not giving bitexact results for these cases.
|
|
|
|
|
virtual void VerifyOutput(size_t num_samples) {
|
|
|
|
|
for (size_t i = 0; i < num_samples; ++i) {
|
2017-06-12 12:45:32 -07:00
|
|
|
const int16_t* output_data = output_.data();
|
|
|
|
|
const int16_t* output_multi_channel_data = output_multi_channel_.data();
|
|
|
|
|
auto first_channel_sample = output_multi_channel_data[i * num_channels_];
|
2016-01-20 07:26:24 -08:00
|
|
|
for (size_t j = 0; j < num_channels_; ++j) {
|
|
|
|
|
const int kErrorMargin = 200;
|
2017-06-12 12:45:32 -07:00
|
|
|
EXPECT_NEAR(output_data[i],
|
|
|
|
|
output_multi_channel_data[i * num_channels_ + j],
|
2016-01-20 07:26:24 -08:00
|
|
|
kErrorMargin)
|
|
|
|
|
<< "Diff in sample " << i << ", channel " << j << ".";
|
|
|
|
|
EXPECT_EQ(first_channel_sample,
|
2017-06-12 12:45:32 -07:00
|
|
|
output_multi_channel_data[i * num_channels_ + j]);
|
2016-01-20 07:26:24 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
int frame_index_;
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-20 07:26:24 -08:00
|
|
|
TEST_P(NetEqStereoTestLosses, RunTest) {
|
2013-01-29 12:09:21 +00:00
|
|
|
RunTest(100);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-02 15:46:00 +01:00
|
|
|
class NetEqStereoTestSingleActiveChannelPlc : public NetEqStereoTestLosses {
|
|
|
|
|
protected:
|
|
|
|
|
NetEqStereoTestSingleActiveChannelPlc() : NetEqStereoTestLosses() {}
|
|
|
|
|
|
|
|
|
|
virtual void MakeMultiChannelInput() override {
|
|
|
|
|
// Create a multi-channel input by copying the mono channel from file to the
|
|
|
|
|
// first channel, and setting the others to zero.
|
|
|
|
|
memset(input_multi_channel_, 0,
|
|
|
|
|
frame_size_samples_ * num_channels_ * sizeof(int16_t));
|
|
|
|
|
for (size_t i = 0; i < frame_size_samples_; ++i) {
|
|
|
|
|
input_multi_channel_[i * num_channels_] = input_[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void VerifyOutput(size_t num_samples) override {
|
|
|
|
|
// Simply verify that all samples in channels other than the first are zero.
|
|
|
|
|
const int16_t* output_multi_channel_data = output_multi_channel_.data();
|
|
|
|
|
for (size_t i = 0; i < num_samples; ++i) {
|
|
|
|
|
for (size_t j = 1; j < num_channels_; ++j) {
|
|
|
|
|
EXPECT_EQ(0, output_multi_channel_data[i * num_channels_ + j])
|
|
|
|
|
<< "Sample " << i << ", channel " << j << " is non-zero.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_P(NetEqStereoTestSingleActiveChannelPlc, RunTest) {
|
|
|
|
|
RunTest(100);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Creates a list of parameter sets.
|
|
|
|
|
std::list<TestParameters> GetTestParameters() {
|
|
|
|
|
std::list<TestParameters> l;
|
|
|
|
|
const int sample_rates[] = {8000, 16000, 32000};
|
|
|
|
|
const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]);
|
|
|
|
|
// Loop through sample rates.
|
|
|
|
|
for (int rate_index = 0; rate_index < num_rates; ++rate_index) {
|
|
|
|
|
int sample_rate = sample_rates[rate_index];
|
|
|
|
|
// Loop through all frame sizes between 10 and 60 ms.
|
|
|
|
|
for (int frame_size = 10; frame_size <= 60; frame_size += 10) {
|
|
|
|
|
TestParameters p;
|
|
|
|
|
p.frame_size = frame_size;
|
|
|
|
|
p.sample_rate = sample_rate;
|
|
|
|
|
p.num_channels = 2;
|
|
|
|
|
l.push_back(p);
|
|
|
|
|
if (sample_rate == 8000) {
|
|
|
|
|
// Add a five-channel test for 8000 Hz.
|
|
|
|
|
p.num_channels = 5;
|
|
|
|
|
l.push_back(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Pretty-printing the test parameters in case of an error.
|
|
|
|
|
void PrintTo(const TestParameters& p, ::std::ostream* os) {
|
|
|
|
|
*os << "{frame_size = " << p.frame_size
|
|
|
|
|
<< ", num_channels = " << p.num_channels
|
|
|
|
|
<< ", sample_rate = " << p.sample_rate << "}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Instantiate the tests. Each test is instantiated using the function above,
|
|
|
|
|
// so that all different parameter combinations are tested.
|
2019-01-31 12:20:57 +01:00
|
|
|
INSTANTIATE_TEST_SUITE_P(MultiChannel,
|
|
|
|
|
NetEqStereoTestNoJitter,
|
|
|
|
|
::testing::ValuesIn(GetTestParameters()));
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2019-01-31 12:20:57 +01:00
|
|
|
INSTANTIATE_TEST_SUITE_P(MultiChannel,
|
|
|
|
|
NetEqStereoTestPositiveDrift,
|
|
|
|
|
::testing::ValuesIn(GetTestParameters()));
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2019-01-31 12:20:57 +01:00
|
|
|
INSTANTIATE_TEST_SUITE_P(MultiChannel,
|
|
|
|
|
NetEqStereoTestNegativeDrift,
|
|
|
|
|
::testing::ValuesIn(GetTestParameters()));
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2019-01-31 12:20:57 +01:00
|
|
|
INSTANTIATE_TEST_SUITE_P(MultiChannel,
|
|
|
|
|
NetEqStereoTestDelays,
|
|
|
|
|
::testing::ValuesIn(GetTestParameters()));
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2019-01-31 12:20:57 +01:00
|
|
|
INSTANTIATE_TEST_SUITE_P(MultiChannel,
|
|
|
|
|
NetEqStereoTestLosses,
|
|
|
|
|
::testing::ValuesIn(GetTestParameters()));
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2019-12-02 15:46:00 +01:00
|
|
|
INSTANTIATE_TEST_SUITE_P(MultiChannel,
|
|
|
|
|
NetEqStereoTestSingleActiveChannelPlc,
|
|
|
|
|
::testing::ValuesIn(GetTestParameters()));
|
2013-01-29 12:09:21 +00:00
|
|
|
} // namespace webrtc
|