aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
diff options
context:
space:
mode:
authorPeter Kasting <pkasting@google.com>2015-08-24 14:52:23 -0700
committerPeter Kasting <pkasting@google.com>2015-08-24 21:52:45 +0000
commitdce40cf804019a9898b6ab8d8262466b697c56e0 (patch)
tree83ae06d5acc897bbf2fe73ea0c944b5ea4a0414d /webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
parentb594041ec8a3ae9f501260e2456d9d5ce6482819 (diff)
downloadwebrtc-dce40cf804019a9898b6ab8d8262466b697c56e0.tar.gz
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}
Diffstat (limited to 'webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc')
-rw-r--r--webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc37
1 files changed, 19 insertions, 18 deletions
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
index d16dd3b791..a2ab6e8ecb 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
@@ -59,14 +59,14 @@ class AudioEncoderCngTest : public ::testing::Test {
void CreateCng() {
// The config_ parameters may be changed by the TEST_Fs up until CreateCng()
// is called, thus we cannot use the values until now.
- num_audio_samples_10ms_ = 10 * sample_rate_hz_ / 1000;
+ num_audio_samples_10ms_ = static_cast<size_t>(10 * sample_rate_hz_ / 1000);
ASSERT_LE(num_audio_samples_10ms_, kMaxNumSamples);
EXPECT_CALL(mock_encoder_, SampleRateHz())
.WillRepeatedly(Return(sample_rate_hz_));
// Max10MsFramesInAPacket() is just used to verify that the SID frame period
// is not too small. The return value does not matter that much, as long as
// it is smaller than 10.
- EXPECT_CALL(mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(1));
+ EXPECT_CALL(mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(1u));
EXPECT_CALL(mock_encoder_, MaxEncodedBytes())
.WillRepeatedly(Return(kMockMaxEncodedBytes));
cng_.reset(new AudioEncoderCng(config_));
@@ -83,10 +83,10 @@ class AudioEncoderCngTest : public ::testing::Test {
// Expect |num_calls| calls to the encoder, all successful. The last call
// claims to have encoded |kMockMaxEncodedBytes| bytes, and all the preceding
// ones 0 bytes.
- void ExpectEncodeCalls(int num_calls) {
+ void ExpectEncodeCalls(size_t num_calls) {
InSequence s;
AudioEncoder::EncodedInfo info;
- for (int j = 0; j < num_calls - 1; ++j) {
+ for (size_t j = 0; j < num_calls - 1; ++j) {
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _))
.WillOnce(Return(info));
}
@@ -98,7 +98,7 @@ class AudioEncoderCngTest : public ::testing::Test {
// Verifies that the cng_ object waits until it has collected
// |blocks_per_frame| blocks of audio, and then dispatches all of them to
// the underlying codec (speech or cng).
- void CheckBlockGrouping(int blocks_per_frame, bool active_speech) {
+ void CheckBlockGrouping(size_t blocks_per_frame, bool active_speech) {
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket())
.WillRepeatedly(Return(blocks_per_frame));
CreateCng();
@@ -107,7 +107,7 @@ class AudioEncoderCngTest : public ::testing::Test {
// Don't expect any calls to the encoder yet.
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0);
- for (int i = 0; i < blocks_per_frame - 1; ++i) {
+ for (size_t i = 0; i < blocks_per_frame - 1; ++i) {
Encode();
EXPECT_EQ(0u, encoded_info_.encoded_bytes);
}
@@ -127,14 +127,15 @@ class AudioEncoderCngTest : public ::testing::Test {
void CheckVadInputSize(int input_frame_size_ms,
int expected_first_block_size_ms,
int expected_second_block_size_ms) {
- const int blocks_per_frame = input_frame_size_ms / 10;
+ const size_t blocks_per_frame =
+ static_cast<size_t>(input_frame_size_ms / 10);
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket())
.WillRepeatedly(Return(blocks_per_frame));
// Expect nothing to happen before the last block is sent to cng_.
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _)).Times(0);
- for (int i = 0; i < blocks_per_frame - 1; ++i) {
+ for (size_t i = 0; i < blocks_per_frame - 1; ++i) {
Encode();
}
@@ -163,7 +164,7 @@ class AudioEncoderCngTest : public ::testing::Test {
Vad::Activity second_type) {
// Set the speech encoder frame size to 60 ms, to ensure that the VAD will
// be called twice.
- const int blocks_per_frame = 6;
+ const size_t blocks_per_frame = 6;
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket())
.WillRepeatedly(Return(blocks_per_frame));
InSequence s;
@@ -175,7 +176,7 @@ class AudioEncoderCngTest : public ::testing::Test {
.WillOnce(Return(second_type));
}
encoded_info_.payload_type = 0;
- for (int i = 0; i < blocks_per_frame; ++i) {
+ for (size_t i = 0; i < blocks_per_frame; ++i) {
Encode();
}
return encoded_info_.payload_type != kCngPayloadType;
@@ -199,8 +200,8 @@ TEST_F(AudioEncoderCngTest, CreateAndDestroy) {
TEST_F(AudioEncoderCngTest, CheckFrameSizePropagation) {
CreateCng();
- EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(17));
- EXPECT_EQ(17, cng_->Num10MsFramesInNextPacket());
+ EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(17U));
+ EXPECT_EQ(17U, cng_->Num10MsFramesInNextPacket());
}
TEST_F(AudioEncoderCngTest, CheckChangeBitratePropagation) {
@@ -217,7 +218,7 @@ TEST_F(AudioEncoderCngTest, CheckProjectedPacketLossRatePropagation) {
TEST_F(AudioEncoderCngTest, EncodeCallsVad) {
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket())
- .WillRepeatedly(Return(1));
+ .WillRepeatedly(Return(1U));
CreateCng();
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
.WillOnce(Return(Vad::kPassive));
@@ -249,7 +250,7 @@ TEST_F(AudioEncoderCngTest, EncodeCollects3BlocksActiveSpeech) {
}
TEST_F(AudioEncoderCngTest, EncodePassive) {
- const int kBlocksPerFrame = 3;
+ const size_t kBlocksPerFrame = 3;
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket())
.WillRepeatedly(Return(kBlocksPerFrame));
CreateCng();
@@ -258,7 +259,7 @@ TEST_F(AudioEncoderCngTest, EncodePassive) {
// Expect no calls at all to the speech encoder mock.
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0);
uint32_t expected_timestamp = timestamp_;
- for (int i = 0; i < 100; ++i) {
+ for (size_t i = 0; i < 100; ++i) {
Encode();
// Check if it was time to call the cng encoder. This is done once every
// |kBlocksPerFrame| calls.
@@ -339,7 +340,7 @@ TEST_F(AudioEncoderCngTest, VadInputSize60Ms) {
TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) {
CreateCng();
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0);
- EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1));
+ EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1U));
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
.WillOnce(Return(Vad::kPassive));
encoded_info_.payload_type = 0;
@@ -352,7 +353,7 @@ TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) {
TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) {
CreateCng();
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket())
- .WillRepeatedly(Return(1));
+ .WillRepeatedly(Return(1U));
// Start with encoding noise.
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
.Times(2)
@@ -443,7 +444,7 @@ TEST_F(AudioEncoderCngDeathTest, Stereo) {
TEST_F(AudioEncoderCngDeathTest, EncoderFrameSizeTooLarge) {
CreateCng();
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket())
- .WillRepeatedly(Return(7));
+ .WillRepeatedly(Return(7U));
for (int i = 0; i < 6; ++i)
Encode();
EXPECT_DEATH(Encode(),