Fixing warning C4267 on Win (more_configs).

This is a follow-up of https://webrtc-review.googlesource.com/c/src/+/12921.

Bug: chromium:759980
Change-Id: Ifd39adb6541c0c7e0337f587a8b34b84a07331ed
Reviewed-on: https://webrtc-review.googlesource.com/13122
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20341}
This commit is contained in:
Mirko Bonadei
2017-10-19 09:00:17 +02:00
committed by Commit Bot
parent 117c48291c
commit 737e073f8d
16 changed files with 70 additions and 43 deletions

View File

@ -9,6 +9,7 @@
*/
#include "modules/audio_coding/neteq/audio_multi_vector.h"
#include "rtc_base/safe_conversions.h"
#include <assert.h>
#include <stdlib.h>
@ -51,7 +52,7 @@ class AudioMultiVectorTest : public ::testing::TestWithParam<size_t> {
// And so on.
for (size_t i = 0; i < array_length(); ++i) {
for (size_t j = 1; j <= num_channels_; ++j) {
*ptr = j * 100 + i;
*ptr = rtc::checked_cast<int16_t>(j * 100 + i);
++ptr;
}
}

View File

@ -9,6 +9,7 @@
*/
#include "modules/audio_coding/neteq/audio_vector.h"
#include "rtc_base/safe_conversions.h"
#include <assert.h>
#include <stdlib.h>
@ -25,7 +26,7 @@ class AudioVectorTest : public ::testing::Test {
virtual void SetUp() {
// Populate test array.
for (size_t i = 0; i < array_length(); ++i) {
array_[i] = i;
array_[i] = rtc::checked_cast<int16_t>(i);
}
}
@ -253,7 +254,7 @@ TEST_F(AudioVectorTest, InsertAtEnd) {
for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i;
}
int insert_position = array_length();
int insert_position = rtc::checked_cast<int>(array_length());
vec.InsertAt(new_array, kNewLength, insert_position);
// Verify that the vector looks as follows:
// {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }.
@ -282,7 +283,8 @@ TEST_F(AudioVectorTest, InsertBeyondEnd) {
for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i;
}
int insert_position = array_length() + 10; // Too large.
int insert_position = rtc::checked_cast<int>(
array_length() + 10); // Too large.
vec.InsertAt(new_array, kNewLength, insert_position);
// Verify that the vector looks as follows:
// {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }.
@ -338,7 +340,7 @@ TEST_F(AudioVectorTest, OverwriteBeyondEnd) {
for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i;
}
int insert_position = array_length() - 2;
int insert_position = rtc::checked_cast<int>(array_length() - 2);
vec.OverwriteAt(new_array, kNewLength, insert_position);
ASSERT_EQ(array_length() - 2u + kNewLength, vec.Size());
// Verify that the vector looks as follows:

View File

@ -88,8 +88,8 @@ class ExpandTest : public ::testing::Test {
void SetUp() override {
// Fast-forward the input file until there is speech (about 1.1 second into
// the file).
const size_t speech_start_samples =
static_cast<size_t>(test_sample_rate_hz_ * 1.1f);
const int speech_start_samples =
static_cast<int>(test_sample_rate_hz_ * 1.1f);
ASSERT_TRUE(input_file_.Seek(speech_start_samples));
// Pre-load the sync buffer with speech data.

View File

@ -483,7 +483,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
decoded[i] = next_value_++;
}
*speech_type = kSpeech;
return encoded_len;
return rtc::checked_cast<int>(encoded_len);
}
void Reset() override { next_value_ = 1; }
@ -1312,7 +1312,7 @@ class Decoder120ms : public AudioDecoder {
decoded[i] = next_value_++;
}
*speech_type = speech_type_;
return decoded_len;
return rtc::checked_cast<int>(decoded_len);
}
void Reset() override { next_value_ = 1; }

View File

@ -20,6 +20,7 @@
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "modules/audio_coding/neteq/mock/mock_decoder_database.h"
#include "modules/audio_coding/neteq/packet.h"
#include "rtc_base/safe_conversions.h"
#include "test/gtest.h"
#include "test/mock_audio_decoder_factory.h"
@ -99,7 +100,8 @@ Packet CreateRedPayload(size_t num_payloads,
// Not the last block; set F = 1.
*payload_ptr |= 0x80;
++payload_ptr;
int this_offset = (num_payloads - i - 1) * timestamp_offset;
int this_offset = rtc::checked_cast<int>(
(num_payloads - i - 1) * timestamp_offset);
*payload_ptr = this_offset >> 6;
++payload_ptr;
assert(kPayloadLength <= 1023); // Max length described by 10 bits.

View File

@ -9,6 +9,7 @@
*/
#include "modules/audio_coding/neteq/sync_buffer.h"
#include "rtc_base/safe_conversions.h"
#include "test/gtest.h"
@ -57,7 +58,7 @@ TEST(SyncBuffer, PushBackAndFlush) {
// Populate |new_data|.
for (size_t channel = 0; channel < kChannels; ++channel) {
for (size_t i = 0; i < kNewLen; ++i) {
new_data[channel][i] = i;
new_data[channel][i] = rtc::checked_cast<int16_t>(i);
}
}
// Push back |new_data| into |sync_buffer|. This operation should pop out
@ -97,7 +98,7 @@ TEST(SyncBuffer, PushFrontZeros) {
// Populate |new_data|.
for (size_t channel = 0; channel < kChannels; ++channel) {
for (size_t i = 0; i < kNewLen; ++i) {
new_data[channel][i] = 1000 + i;
new_data[channel][i] = rtc::checked_cast<int16_t>(1000 + i);
}
}
sync_buffer.PushBack(new_data);
@ -130,7 +131,7 @@ TEST(SyncBuffer, GetNextAudioInterleaved) {
// Populate |new_data|.
for (size_t channel = 0; channel < kChannels; ++channel) {
for (size_t i = 0; i < kNewLen; ++i) {
new_data[channel][i] = i;
new_data[channel][i] = rtc::checked_cast<int16_t>(i);
}
}
// Push back |new_data| into |sync_buffer|. This operation should pop out

View File

@ -11,6 +11,7 @@
// Unit tests for test InputAudioFile class.
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
#include "rtc_base/safe_conversions.h"
#include "test/gtest.h"
@ -22,7 +23,7 @@ TEST(TestInputAudioFile, DuplicateInterleaveSeparateSrcDst) {
static const size_t kChannels = 2;
int16_t input[kSamples];
for (size_t i = 0; i < kSamples; ++i) {
input[i] = i;
input[i] = rtc::checked_cast<int16_t>(i);
}
int16_t output[kSamples * kChannels];
InputAudioFile::DuplicateInterleaved(input, kSamples, kChannels, output);
@ -41,7 +42,7 @@ TEST(TestInputAudioFile, DuplicateInterleaveSameSrcDst) {
static const size_t kChannels = 5;
int16_t input[kSamples * kChannels];
for (size_t i = 0; i < kSamples; ++i) {
input[i] = i;
input[i] = rtc::checked_cast<int16_t>(i);
}
InputAudioFile::DuplicateInterleaved(input, kSamples, kChannels, input);