From 5a080f017c68b6230a6acea6cca89414d12db661 Mon Sep 17 00:00:00 2001 From: avi Date: Tue, 22 Dec 2015 15:15:43 -0800 Subject: Switch to standard integer types in remoting/. BUG=138542 TBR=wez@chromium.org Review URL: https://codereview.chromium.org/1542203002 Cr-Commit-Position: refs/heads/master@{#366684} --- remoting/codec/audio_decoder_opus.cc | 6 ++++-- remoting/codec/audio_decoder_opus.h | 2 +- remoting/codec/audio_decoder_verbatim.h | 1 + remoting/codec/audio_encoder_opus.cc | 11 +++++----- remoting/codec/audio_encoder_opus.h | 5 ++++- remoting/codec/audio_encoder_opus_unittest.cc | 31 ++++++++++++++------------- remoting/codec/audio_encoder_verbatim.h | 1 + remoting/codec/codec_test.cc | 5 ++++- remoting/codec/video_decoder.h | 1 - remoting/codec/video_decoder_verbatim.cc | 2 ++ remoting/codec/video_decoder_verbatim.h | 1 + remoting/codec/video_decoder_vpx.cc | 3 ++- remoting/codec/video_decoder_vpx.h | 1 + remoting/codec/video_encoder_helper.h | 1 + remoting/codec/video_encoder_verbatim.cc | 3 +++ remoting/codec/video_encoder_verbatim.h | 1 + remoting/codec/video_encoder_vpx.cc | 20 ++++++++--------- remoting/codec/video_encoder_vpx.h | 7 ++++-- remoting/codec/video_encoder_vpx_perftest.cc | 3 +++ remoting/codec/video_encoder_vpx_unittest.cc | 12 ++++++----- 20 files changed, 72 insertions(+), 45 deletions(-) (limited to 'remoting/codec') diff --git a/remoting/codec/audio_decoder_opus.cc b/remoting/codec/audio_decoder_opus.cc index e7bd5ac..0bcabcc 100644 --- a/remoting/codec/audio_decoder_opus.cc +++ b/remoting/codec/audio_decoder_opus.cc @@ -4,6 +4,8 @@ #include "remoting/codec/audio_decoder_opus.h" +#include + #include "base/logging.h" #include "base/stl_util.h" #include "base/time/time.h" @@ -106,8 +108,8 @@ scoped_ptr AudioDecoderOpus::Decode( int buffer_pos = 0; for (int i = 0; i < packet->data_size(); ++i) { - int16* pcm_buffer = - reinterpret_cast(string_as_array(decoded_data) + buffer_pos); + int16_t* pcm_buffer = + reinterpret_cast(string_as_array(decoded_data) + buffer_pos); CHECK_LE(buffer_pos + max_frame_bytes, static_cast(decoded_data->size())); std::string* frame = packet->mutable_data(i); diff --git a/remoting/codec/audio_decoder_opus.h b/remoting/codec/audio_decoder_opus.h index dcf8776..553f77f 100644 --- a/remoting/codec/audio_decoder_opus.h +++ b/remoting/codec/audio_decoder_opus.h @@ -5,7 +5,7 @@ #ifndef REMOTING_CODEC_AUDIO_DECODER_OPUS_H_ #define REMOTING_CODEC_AUDIO_DECODER_OPUS_H_ -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "remoting/codec/audio_decoder.h" diff --git a/remoting/codec/audio_decoder_verbatim.h b/remoting/codec/audio_decoder_verbatim.h index e6d1172..2aabe4a 100644 --- a/remoting/codec/audio_decoder_verbatim.h +++ b/remoting/codec/audio_decoder_verbatim.h @@ -7,6 +7,7 @@ #include "remoting/codec/audio_decoder.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" namespace remoting { diff --git a/remoting/codec/audio_encoder_opus.cc b/remoting/codec/audio_encoder_opus.cc index 315fb9f..547ef50 100644 --- a/remoting/codec/audio_encoder_opus.cc +++ b/remoting/codec/audio_encoder_opus.cc @@ -86,8 +86,7 @@ void AudioEncoderOpus::InitEncoder() { leftover_samples_ = 0; leftover_buffer_size_ = frame_size_ + media::SincResampler::kDefaultRequestSize; - leftover_buffer_.reset( - new int16[leftover_buffer_size_ * channels_]); + leftover_buffer_.reset(new int16_t[leftover_buffer_size_ * channels_]); } void AudioEncoderOpus::DestroyEncoder() { @@ -150,8 +149,8 @@ scoped_ptr AudioEncoderOpus::Encode( } int samples_in_packet = packet->data(0).size() / kBytesPerSample / channels_; - const int16* next_sample = - reinterpret_cast(packet->data(0).data()); + const int16_t* next_sample = + reinterpret_cast(packet->data(0).data()); // Create a new packet of encoded data. scoped_ptr encoded_packet(new AudioPacket()); @@ -164,7 +163,7 @@ scoped_ptr AudioEncoderOpus::Encode( int samples_wanted = frame_size_ + prefetch_samples; while (leftover_samples_ + samples_in_packet >= samples_wanted) { - const int16* pcm_buffer = nullptr; + const int16_t* pcm_buffer = nullptr; // Combine the packet with the leftover samples, if any. if (leftover_samples_ > 0) { @@ -188,7 +187,7 @@ scoped_ptr AudioEncoderOpus::Encode( resampler_bus_->ToInterleaved(kFrameSamples, kBytesPerSample, resample_buffer_.get()); - pcm_buffer = reinterpret_cast(resample_buffer_.get()); + pcm_buffer = reinterpret_cast(resample_buffer_.get()); } else { samples_consumed = frame_size_; } diff --git a/remoting/codec/audio_encoder_opus.h b/remoting/codec/audio_encoder_opus.h index e1c67d5..5e227a6 100644 --- a/remoting/codec/audio_encoder_opus.h +++ b/remoting/codec/audio_encoder_opus.h @@ -7,6 +7,9 @@ #include "remoting/codec/audio_encoder.h" +#include + +#include "base/macros.h" #include "remoting/proto/audio.pb.h" struct OpusEncoder; @@ -52,7 +55,7 @@ class AudioEncoderOpus : public AudioEncoder { int resampling_data_pos_; // Left-over unencoded samples from the previous AudioPacket. - scoped_ptr leftover_buffer_; + scoped_ptr leftover_buffer_; int leftover_buffer_size_; int leftover_samples_; diff --git a/remoting/codec/audio_encoder_opus_unittest.cc b/remoting/codec/audio_encoder_opus_unittest.cc index 52fac69..db731eb 100644 --- a/remoting/codec/audio_encoder_opus_unittest.cc +++ b/remoting/codec/audio_encoder_opus_unittest.cc @@ -5,6 +5,8 @@ // MSVC++ requires this to get M_PI. #define _USE_MATH_DEFINES #include +#include +#include #include "remoting/codec/audio_encoder_opus.h" @@ -51,11 +53,10 @@ class OpusAudioEncoderTest : public testing::Test { // defines frequency of the signal. |channel| is used to calculate phase shift // of the signal, so that different signals are generated for left and right // channels. - static int16 GetSampleValue( - AudioPacket::SamplingRate rate, - double frequency_hz, - double pos, - int channel) { + static int16_t GetSampleValue(AudioPacket::SamplingRate rate, + double frequency_hz, + double pos, + int channel) { double angle = pos * 2 * M_PI * frequency_hz / rate + kChannelPhaseShift * channel; return static_cast(sin(angle) * kMaxSampleValue + 0.5); @@ -68,7 +69,7 @@ class OpusAudioEncoderTest : public testing::Test { AudioPacket::SamplingRate rate, double frequency_hz, int pos) { - std::vector data(samples * kChannels); + std::vector data(samples * kChannels); for (int i = 0; i < samples; ++i) { data[i * kChannels] = GetSampleValue(rate, frequency_hz, i + pos, 0); data[i * kChannels + 1] = GetSampleValue(rate, frequency_hz, i + pos, 1); @@ -76,7 +77,7 @@ class OpusAudioEncoderTest : public testing::Test { scoped_ptr packet(new AudioPacket()); packet->add_data(reinterpret_cast(&(data[0])), - samples * kChannels * sizeof(int16)); + samples * kChannels * sizeof(int16_t)); packet->set_encoding(AudioPacket::ENCODING_RAW); packet->set_sampling_rate(rate); packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2); @@ -87,11 +88,11 @@ class OpusAudioEncoderTest : public testing::Test { // Decoded data is normally shifted in phase relative to the original signal. // This function returns the approximate shift in samples by finding the first // point when signal goes from negative to positive. - double EstimateSignalShift(const std::vector& received_data) { + double EstimateSignalShift(const std::vector& received_data) { for (size_t i = kSkippedFirstSamples; i < received_data.size() / kChannels - 1; i++) { - int16 this_sample = received_data[i * kChannels]; - int16 next_sample = received_data[(i + 1) * kChannels]; + int16_t this_sample = received_data[i * kChannels]; + int16_t next_sample = received_data[(i + 1) * kChannels]; if (this_sample < 0 && next_sample > 0) { return i + static_cast(-this_sample) / (next_sample - this_sample); @@ -106,7 +107,7 @@ class OpusAudioEncoderTest : public testing::Test { void ValidateReceivedData(int samples, AudioPacket::SamplingRate rate, double frequency_hz, - const std::vector& received_data) { + const std::vector& received_data) { double shift = EstimateSignalShift(received_data); double diff_sqare_sum = 0; for (size_t i = kSkippedFirstSamples; @@ -132,7 +133,7 @@ class OpusAudioEncoderTest : public testing::Test { encoder_.reset(new AudioEncoderOpus()); decoder_.reset(new AudioDecoderOpus()); - std::vector received_data; + std::vector received_data; int pos = 0; for (; pos < kTotalTestSamples; pos += packet_size) { scoped_ptr source_packet = @@ -143,11 +144,11 @@ class OpusAudioEncoderTest : public testing::Test { scoped_ptr decoded = decoder_->Decode(encoded.Pass()); EXPECT_EQ(kDefaultSamplingRate, decoded->sampling_rate()); for (int i = 0; i < decoded->data_size(); ++i) { - const int16* data = - reinterpret_cast(decoded->data(i).data()); + const int16_t* data = + reinterpret_cast(decoded->data(i).data()); received_data.insert( received_data.end(), data, - data + decoded->data(i).size() / sizeof(int16)); + data + decoded->data(i).size() / sizeof(int16_t)); } } } diff --git a/remoting/codec/audio_encoder_verbatim.h b/remoting/codec/audio_encoder_verbatim.h index ad14032..f546bef 100644 --- a/remoting/codec/audio_encoder_verbatim.h +++ b/remoting/codec/audio_encoder_verbatim.h @@ -5,6 +5,7 @@ #ifndef REMOTING_CODEC_AUDIO_ENCODER_VERBATIM_H_ #define REMOTING_CODEC_AUDIO_ENCODER_VERBATIM_H_ +#include "base/macros.h" #include "remoting/codec/audio_encoder.h" namespace remoting { diff --git a/remoting/codec/codec_test.cc b/remoting/codec/codec_test.cc index cec0043..bf71b6f 100644 --- a/remoting/codec/codec_test.cc +++ b/remoting/codec/codec_test.cc @@ -2,11 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include +#include +#include #include +#include #include "base/bind.h" #include "base/logging.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "media/base/video_frame.h" #include "remoting/base/util.h" diff --git a/remoting/codec/video_decoder.h b/remoting/codec/video_decoder.h index 65d488e..3ed5f5a 100644 --- a/remoting/codec/video_decoder.h +++ b/remoting/codec/video_decoder.h @@ -5,7 +5,6 @@ #ifndef REMOTING_CODEC_VIDEO_DECODER_H_ #define REMOTING_CODEC_VIDEO_DECODER_H_ -#include "base/basictypes.h" namespace webrtc { class DesktopFrame; diff --git a/remoting/codec/video_decoder_verbatim.cc b/remoting/codec/video_decoder_verbatim.cc index 0d7e8da..42505bd 100644 --- a/remoting/codec/video_decoder_verbatim.cc +++ b/remoting/codec/video_decoder_verbatim.cc @@ -4,6 +4,8 @@ #include "remoting/codec/video_decoder_verbatim.h" +#include + #include "base/logging.h" #include "remoting/base/util.h" #include "remoting/proto/video.pb.h" diff --git a/remoting/codec/video_decoder_verbatim.h b/remoting/codec/video_decoder_verbatim.h index cad36ca..f1d7784 100644 --- a/remoting/codec/video_decoder_verbatim.h +++ b/remoting/codec/video_decoder_verbatim.h @@ -6,6 +6,7 @@ #define REMOTING_CODEC_VIDEO_DECODER_VERBATIM_H_ #include "base/compiler_specific.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "remoting/codec/video_decoder.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" diff --git a/remoting/codec/video_decoder_vpx.cc b/remoting/codec/video_decoder_vpx.cc index 5c766a0..4d27955 100644 --- a/remoting/codec/video_decoder_vpx.cc +++ b/remoting/codec/video_decoder_vpx.cc @@ -5,6 +5,7 @@ #include "remoting/codec/video_decoder_vpx.h" #include +#include #include "base/logging.h" #include "remoting/base/util.h" @@ -82,7 +83,7 @@ bool VideoDecoderVpx::DecodePacket(const VideoPacket& packet, webrtc::DesktopFrame* frame) { // Pass the packet to the codec to process. vpx_codec_err_t ret = vpx_codec_decode( - codec_.get(), reinterpret_cast(packet.data().data()), + codec_.get(), reinterpret_cast(packet.data().data()), packet.data().size(), nullptr, 0); if (ret != VPX_CODEC_OK) { const char* error = vpx_codec_error(codec_.get()); diff --git a/remoting/codec/video_decoder_vpx.h b/remoting/codec/video_decoder_vpx.h index 81ba9e4..d002988 100644 --- a/remoting/codec/video_decoder_vpx.h +++ b/remoting/codec/video_decoder_vpx.h @@ -6,6 +6,7 @@ #define REMOTING_CODEC_VIDEO_DECODER_VPX_H_ #include "base/compiler_specific.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "remoting/codec/scoped_vpx_codec.h" #include "remoting/codec/video_decoder.h" diff --git a/remoting/codec/video_encoder_helper.h b/remoting/codec/video_encoder_helper.h index c33fdb9..65e4acc 100644 --- a/remoting/codec/video_encoder_helper.h +++ b/remoting/codec/video_encoder_helper.h @@ -5,6 +5,7 @@ #ifndef REMOTING_CODEC_VIDEO_ENCODER_HELPER_H_ #define REMOTING_CODEC_VIDEO_ENCODER_HELPER_H_ +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" diff --git a/remoting/codec/video_encoder_verbatim.cc b/remoting/codec/video_encoder_verbatim.cc index 8d1befb..ce65490 100644 --- a/remoting/codec/video_encoder_verbatim.cc +++ b/remoting/codec/video_encoder_verbatim.cc @@ -4,6 +4,9 @@ #include "remoting/codec/video_encoder_verbatim.h" +#include +#include + #include "base/logging.h" #include "base/stl_util.h" #include "remoting/base/util.h" diff --git a/remoting/codec/video_encoder_verbatim.h b/remoting/codec/video_encoder_verbatim.h index 1a348be..0e76b43 100644 --- a/remoting/codec/video_encoder_verbatim.h +++ b/remoting/codec/video_encoder_verbatim.h @@ -5,6 +5,7 @@ #ifndef REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_ #define REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_ +#include "base/macros.h" #include "remoting/codec/video_encoder.h" #include "remoting/codec/video_encoder_helper.h" diff --git a/remoting/codec/video_encoder_vpx.cc b/remoting/codec/video_encoder_vpx.cc index 0dcd456..bea9a8a 100644 --- a/remoting/codec/video_encoder_vpx.cc +++ b/remoting/codec/video_encoder_vpx.cc @@ -149,7 +149,7 @@ void SetVp9CodecOptions(vpx_codec_ctx_t* codec, bool lossless_encode) { void FreeImageIfMismatched(bool use_i444, const webrtc::DesktopSize& size, scoped_ptr* out_image, - scoped_ptr* out_image_buffer) { + scoped_ptr* out_image_buffer) { if (*out_image) { const vpx_img_fmt_t desired_fmt = use_i444 ? VPX_IMG_FMT_I444 : VPX_IMG_FMT_I420; @@ -164,7 +164,7 @@ void FreeImageIfMismatched(bool use_i444, void CreateImage(bool use_i444, const webrtc::DesktopSize& size, scoped_ptr* out_image, - scoped_ptr* out_image_buffer) { + scoped_ptr* out_image_buffer) { DCHECK(!size.is_empty()); DCHECK(!*out_image_buffer); DCHECK(!*out_image); @@ -207,7 +207,7 @@ void CreateImage(bool use_i444, // Allocate a YUV buffer large enough for the aligned data & padding. const int buffer_size = y_stride * y_rows + 2*uv_stride * uv_rows; - scoped_ptr image_buffer(new uint8[buffer_size]); + scoped_ptr image_buffer(new uint8_t[buffer_size]); // Reset image value to 128 so we just need to fill in the y plane. memset(image_buffer.get(), 128, buffer_size); @@ -360,7 +360,7 @@ void VideoEncoderVpx::Configure(const webrtc::DesktopSize& size) { (size.width() + kMacroBlockSize - 1) / kMacroBlockSize, (size.height() + kMacroBlockSize - 1) / kMacroBlockSize); active_map_.reset( - new uint8[active_map_size_.width() * active_map_size_.height()]); + new uint8_t[active_map_size_.width() * active_map_size_.height()]); // TODO(wez): Remove this hack once VPX can handle frame size reconfiguration. // See https://code.google.com/p/webm/issues/detail?id=912. @@ -447,14 +447,14 @@ void VideoEncoderVpx::PrepareImage(const webrtc::DesktopFrame& frame, } // Convert the updated region to YUV ready for encoding. - const uint8* rgb_data = frame.data(); + const uint8_t* rgb_data = frame.data(); const int rgb_stride = frame.stride(); const int y_stride = image_->stride[0]; DCHECK_EQ(image_->stride[1], image_->stride[2]); const int uv_stride = image_->stride[1]; - uint8* y_data = image_->planes[0]; - uint8* u_data = image_->planes[1]; - uint8* v_data = image_->planes[2]; + uint8_t* y_data = image_->planes[0]; + uint8_t* u_data = image_->planes[1]; + uint8_t* v_data = image_->planes[2]; switch (image_->fmt) { case VPX_IMG_FMT_I444: @@ -509,7 +509,7 @@ void VideoEncoderVpx::SetActiveMapFromRegion( DCHECK_LT(right, active_map_size_.width()); DCHECK_LT(bottom, active_map_size_.height()); - uint8* map = active_map_.get() + top * active_map_size_.width(); + uint8_t* map = active_map_.get() + top * active_map_size_.width(); for (int y = top; y <= bottom; ++y) { for (int x = left; x <= right; ++x) map[x] = 1; @@ -520,7 +520,7 @@ void VideoEncoderVpx::SetActiveMapFromRegion( void VideoEncoderVpx::UpdateRegionFromActiveMap( webrtc::DesktopRegion* updated_region) { - const uint8* map = active_map_.get(); + const uint8_t* map = active_map_.get(); for (int y = 0; y < active_map_size_.height(); ++y) { for (int x0 = 0; x0 < active_map_size_.width();) { int x1 = x0; diff --git a/remoting/codec/video_encoder_vpx.h b/remoting/codec/video_encoder_vpx.h index 7d80592..83c3549 100644 --- a/remoting/codec/video_encoder_vpx.h +++ b/remoting/codec/video_encoder_vpx.h @@ -5,7 +5,10 @@ #ifndef REMOTING_CODEC_VIDEO_ENCODER_VPX_H_ #define REMOTING_CODEC_VIDEO_ENCODER_VPX_H_ +#include + #include "base/callback.h" +#include "base/macros.h" #include "base/time/time.h" #include "remoting/codec/scoped_vpx_codec.h" #include "remoting/codec/video_encoder.h" @@ -69,10 +72,10 @@ class VideoEncoderVpx : public VideoEncoder { // VPX image and buffer to hold the actual YUV planes. scoped_ptr image_; - scoped_ptr image_buffer_; + scoped_ptr image_buffer_; // Active map used to optimize out processing of un-changed macroblocks. - scoped_ptr active_map_; + scoped_ptr active_map_; webrtc::DesktopSize active_map_size_; // True if the codec wants unchanged frames to finish topping-off with. diff --git a/remoting/codec/video_encoder_vpx_perftest.cc b/remoting/codec/video_encoder_vpx_perftest.cc index 3dc4ef1..0c2cf7f 100644 --- a/remoting/codec/video_encoder_vpx_perftest.cc +++ b/remoting/codec/video_encoder_vpx_perftest.cc @@ -4,10 +4,13 @@ #include "remoting/codec/video_encoder_vpx.h" +#include + #include #include #include "base/logging.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "remoting/codec/codec_test.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/remoting/codec/video_encoder_vpx_unittest.cc b/remoting/codec/video_encoder_vpx_unittest.cc index a847f03..edca813 100644 --- a/remoting/codec/video_encoder_vpx_unittest.cc +++ b/remoting/codec/video_encoder_vpx_unittest.cc @@ -4,6 +4,8 @@ #include "remoting/codec/video_encoder_vpx.h" +#include + #include #include @@ -16,8 +18,8 @@ namespace remoting { // xRGB pixel colors for use by tests. -const uint32 kBlueColor = 0x0000ff; -const uint32 kGreenColor = 0x00ff00; +const uint32_t kBlueColor = 0x0000ff; +const uint32_t kGreenColor = 0x00ff00; // Creates a frame stippled between blue and red pixels, which is useful for // lossy/lossless encode and color tests. By default all pixels in the frame @@ -28,9 +30,9 @@ static scoped_ptr CreateTestFrame( new webrtc::BasicDesktopFrame(frame_size)); for (int x = 0; x < frame_size.width(); ++x) { for (int y = 0; y < frame_size.height(); ++y) { - uint8* pixel_u8 = frame->data() + (y * frame->stride()) + - (x * webrtc::DesktopFrame::kBytesPerPixel); - *(reinterpret_cast(pixel_u8)) = + uint8_t* pixel_u8 = frame->data() + (y * frame->stride()) + + (x * webrtc::DesktopFrame::kBytesPerPixel); + *(reinterpret_cast(pixel_u8)) = ((x + y) & 1) ? kGreenColor : kBlueColor; } } -- cgit v1.1