Replace scoped_ptr with unique_ptr in webrtc/common_video/

BUG=webrtc:5520

Review URL: https://codereview.webrtc.org/1749103003

Cr-Commit-Position: refs/heads/master@{#11838}
This commit is contained in:
kwiberg 2016-03-02 03:41:34 -08:00 committed by Commit bot
parent 60653ba3cc
commit c891eb479b
9 changed files with 34 additions and 24 deletions

View File

@ -13,7 +13,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/test/fake_texture_frame.h"
#include "webrtc/test/frame_utils.h"
#include "webrtc/video_frame.h"

View File

@ -11,9 +11,10 @@
#ifndef WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_
#define WEBRTC_COMMON_VIDEO_INCLUDE_INCOMING_VIDEO_STREAM_H_
#include <memory>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/thread_annotations.h"
#include "webrtc/common_video/video_render_frames.h"
@ -82,14 +83,14 @@ class IncomingVideoStream : public VideoRenderCallback {
rtc::CriticalSection buffer_critsect_;
// TODO(pbos): Make plain member and stop resetting this thread, just
// start/stoping it is enough.
rtc::scoped_ptr<rtc::PlatformThread> incoming_render_thread_
std::unique_ptr<rtc::PlatformThread> incoming_render_thread_
GUARDED_BY(thread_critsect_);
rtc::scoped_ptr<EventTimerWrapper> deliver_buffer_event_;
std::unique_ptr<EventTimerWrapper> deliver_buffer_event_;
bool running_ GUARDED_BY(stream_critsect_);
VideoRenderCallback* external_callback_ GUARDED_BY(thread_critsect_);
VideoRenderCallback* render_callback_ GUARDED_BY(thread_critsect_);
const rtc::scoped_ptr<VideoRenderFrames> render_buffers_
const std::unique_ptr<VideoRenderFrames> render_buffers_
GUARDED_BY(buffer_critsect_);
uint32_t incoming_rate_ GUARDED_BY(stream_critsect_);

View File

@ -11,9 +11,12 @@
#ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_
#define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_
#include <stdint.h>
#include <memory>
#include "webrtc/base/callback.h"
#include "webrtc/base/refcount.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/system_wrappers/include/aligned_malloc.h"
@ -87,7 +90,7 @@ class I420Buffer : public VideoFrameBuffer {
const int stride_y_;
const int stride_u_;
const int stride_v_;
const rtc::scoped_ptr<uint8_t, AlignedFreeDeleter> data_;
const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_;
};
// Base class for native-handle buffer is a wrapper around a |native_handle|.

View File

@ -11,8 +11,9 @@
#include <math.h>
#include <string.h>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/system_wrappers/include/tick_util.h"
#include "webrtc/test/testsupport/fileutils.h"
@ -83,7 +84,7 @@ class TestLibYuv : public ::testing::Test {
FILE* source_file_;
VideoFrame orig_frame_;
rtc::scoped_ptr<uint8_t[]> orig_buffer_;
std::unique_ptr<uint8_t[]> orig_buffer_;
const int width_;
const int height_;
const int size_y_;
@ -147,7 +148,7 @@ TEST_F(TestLibYuv, ConvertTest) {
(width_ + 1) / 2,
(width_ + 1) / 2);
printf("\nConvert #%d I420 <-> I420 \n", j);
rtc::scoped_ptr<uint8_t[]> out_i420_buffer(new uint8_t[frame_length_]);
std::unique_ptr<uint8_t[]> out_i420_buffer(new uint8_t[frame_length_]);
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kI420, 0,
out_i420_buffer.get()));
EXPECT_EQ(0, ConvertToI420(kI420, out_i420_buffer.get(), 0, 0, width_,
@ -161,7 +162,7 @@ TEST_F(TestLibYuv, ConvertTest) {
j++;
printf("\nConvert #%d I420 <-> RGB24\n", j);
rtc::scoped_ptr<uint8_t[]> res_rgb_buffer2(new uint8_t[width_ * height_ * 3]);
std::unique_ptr<uint8_t[]> res_rgb_buffer2(new uint8_t[width_ * height_ * 3]);
// Align the stride values for the output frame.
int stride_y = 0;
int stride_uv = 0;
@ -183,7 +184,7 @@ TEST_F(TestLibYuv, ConvertTest) {
j++;
printf("\nConvert #%d I420 <-> UYVY\n", j);
rtc::scoped_ptr<uint8_t[]> out_uyvy_buffer(new uint8_t[width_ * height_ * 2]);
std::unique_ptr<uint8_t[]> out_uyvy_buffer(new uint8_t[width_ * height_ * 2]);
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kUYVY, 0, out_uyvy_buffer.get()));
EXPECT_EQ(0, ConvertToI420(kUYVY, out_uyvy_buffer.get(), 0, 0, width_,
height_, 0, kVideoRotation_0, &res_i420_frame));
@ -195,8 +196,8 @@ TEST_F(TestLibYuv, ConvertTest) {
j++;
printf("\nConvert #%d I420 <-> YV12\n", j);
rtc::scoped_ptr<uint8_t[]> outYV120Buffer(new uint8_t[frame_length_]);
rtc::scoped_ptr<uint8_t[]> res_i420_buffer(new uint8_t[frame_length_]);
std::unique_ptr<uint8_t[]> outYV120Buffer(new uint8_t[frame_length_]);
std::unique_ptr<uint8_t[]> res_i420_buffer(new uint8_t[frame_length_]);
VideoFrame yv12_frame;
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kYV12, 0, outYV120Buffer.get()));
yv12_frame.CreateFrame(outYV120Buffer.get(),
@ -218,7 +219,7 @@ TEST_F(TestLibYuv, ConvertTest) {
j++;
printf("\nConvert #%d I420 <-> YUY2\n", j);
rtc::scoped_ptr<uint8_t[]> out_yuy2_buffer(new uint8_t[width_ * height_ * 2]);
std::unique_ptr<uint8_t[]> out_yuy2_buffer(new uint8_t[width_ * height_ * 2]);
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kYUY2, 0, out_yuy2_buffer.get()));
EXPECT_EQ(0, ConvertToI420(kYUY2, out_yuy2_buffer.get(), 0, 0, width_,
@ -231,7 +232,7 @@ TEST_F(TestLibYuv, ConvertTest) {
psnr = I420PSNR(&orig_frame_, &res_i420_frame);
EXPECT_EQ(48.0, psnr);
printf("\nConvert #%d I420 <-> RGB565\n", j);
rtc::scoped_ptr<uint8_t[]> out_rgb565_buffer(
std::unique_ptr<uint8_t[]> out_rgb565_buffer(
new uint8_t[width_ * height_ * 2]);
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kRGB565, 0,
out_rgb565_buffer.get()));
@ -251,7 +252,7 @@ TEST_F(TestLibYuv, ConvertTest) {
EXPECT_GT(ceil(psnr), 40);
printf("\nConvert #%d I420 <-> ARGB8888\n", j);
rtc::scoped_ptr<uint8_t[]> out_argb8888_buffer(
std::unique_ptr<uint8_t[]> out_argb8888_buffer(
new uint8_t[width_ * height_ * 4]);
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kARGB, 0,
out_argb8888_buffer.get()));
@ -285,7 +286,7 @@ TEST_F(TestLibYuv, ConvertAlignedFrame) {
Calc16ByteAlignedStride(width_, &stride_y, &stride_uv);
res_i420_frame.CreateEmptyFrame(width_, height_,
stride_y, stride_uv, stride_uv);
rtc::scoped_ptr<uint8_t[]> out_i420_buffer(new uint8_t[frame_length_]);
std::unique_ptr<uint8_t[]> out_i420_buffer(new uint8_t[frame_length_]);
EXPECT_EQ(0, ConvertFromI420(orig_frame_, kI420, 0,
out_i420_buffer.get()));
EXPECT_EQ(0, ConvertToI420(kI420, out_i420_buffer.get(), 0, 0, width_,

View File

@ -11,6 +11,8 @@
#include <math.h>
#include <string.h>
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/common_video/libyuv/include/scaler.h"
#include "webrtc/system_wrappers/include/tick_util.h"
@ -98,7 +100,7 @@ TEST_F(TestScaler, ScaleSendingBufferTooSmall) {
kI420, kI420,
kScalePoint));
VideoFrame test_frame2;
rtc::scoped_ptr<uint8_t[]> orig_buffer(new uint8_t[frame_length_]);
std::unique_ptr<uint8_t[]> orig_buffer(new uint8_t[frame_length_]);
EXPECT_GT(fread(orig_buffer.get(), 1, frame_length_, source_file_), 0U);
test_frame_.CreateFrame(orig_buffer.get(),
orig_buffer.get() + size_y_,
@ -358,7 +360,7 @@ void TestScaler::ScaleSequence(ScaleMethod method,
total_clock = 0;
int frame_count = 0;
size_t src_required_size = CalcBufferSize(kI420, src_width, src_height);
rtc::scoped_ptr<uint8_t[]> frame_buffer(new uint8_t[src_required_size]);
std::unique_ptr<uint8_t[]> frame_buffer(new uint8_t[src_required_size]);
int size_y = src_width * src_height;
int size_uv = ((src_width + 1) / 2) * ((src_height + 1) / 2);

View File

@ -11,6 +11,7 @@
#include "webrtc/test/linux/glx_renderer.h"
#include <assert.h>
#include <stdlib.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>

View File

@ -14,6 +14,7 @@
#include <stdio.h>
#include <algorithm> // min_element, max_element
#include <memory>
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/video_frame.h"
@ -111,8 +112,8 @@ int CalculateMetrics(VideoMetricsType video_metrics_type,
const size_t frame_length = 3 * width * height >> 1;
VideoFrame ref_frame;
VideoFrame test_frame;
rtc::scoped_ptr<uint8_t[]> ref_buffer(new uint8_t[frame_length]);
rtc::scoped_ptr<uint8_t[]> test_buffer(new uint8_t[frame_length]);
std::unique_ptr<uint8_t[]> ref_buffer(new uint8_t[frame_length]);
std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[frame_length]);
// Set decoded image parameters.
int half_width = (width + 1) / 2;

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_VIDEO_DECODER_H_
#define WEBRTC_VIDEO_DECODER_H_
#include <memory>
#include <string>
#include <vector>
@ -116,7 +117,7 @@ class VideoDecoderSoftwareFallbackWrapper : public webrtc::VideoDecoder {
VideoCodec codec_settings_;
int32_t number_of_cores_;
std::string fallback_implementation_name_;
rtc::scoped_ptr<VideoDecoder> fallback_decoder_;
std::unique_ptr<VideoDecoder> fallback_decoder_;
DecodedImageCallback* callback_;
};

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_VIDEO_ENCODER_H_
#define WEBRTC_VIDEO_ENCODER_H_
#include <memory>
#include <string>
#include <vector>
@ -177,7 +178,7 @@ class VideoEncoderSoftwareFallbackWrapper : public VideoEncoder {
const EncoderType encoder_type_;
webrtc::VideoEncoder* const encoder_;
rtc::scoped_ptr<webrtc::VideoEncoder> fallback_encoder_;
std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_;
std::string fallback_implementation_name_;
EncodedImageCallback* callback_;
};