Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc

Issue 1721353002: Replace scoped_ptr with unique_ptr in webrtc/modules/video_coding/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <stdio.h> 11 #include <stdio.h>
12 12
13 #include <memory>
14
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
15 #include "webrtc/base/scoped_ptr.h"
16 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
17 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 18 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
18 #include "webrtc/system_wrappers/include/tick_util.h" 19 #include "webrtc/system_wrappers/include/tick_util.h"
19 #include "webrtc/test/testsupport/fileutils.h" 20 #include "webrtc/test/testsupport/fileutils.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 enum { kMaxWaitEncTimeMs = 100 }; 24 enum { kMaxWaitEncTimeMs = 100 };
24 enum { kMaxWaitDecTimeMs = 25 }; 25 enum { kMaxWaitDecTimeMs = 25 };
25 26
26 static const uint32_t kTestTimestamp = 123; 27 static const uint32_t kTestTimestamp = 123;
27 static const int64_t kTestNtpTimeMs = 456; 28 static const int64_t kTestNtpTimeMs = 456;
28 29
29 // TODO(mikhal): Replace these with mocks. 30 // TODO(mikhal): Replace these with mocks.
30 class Vp8UnitTestEncodeCompleteCallback : public webrtc::EncodedImageCallback { 31 class Vp8UnitTestEncodeCompleteCallback : public webrtc::EncodedImageCallback {
31 public: 32 public:
32 Vp8UnitTestEncodeCompleteCallback(EncodedImage* frame, 33 Vp8UnitTestEncodeCompleteCallback(EncodedImage* frame,
33 unsigned int decoderSpecificSize, 34 unsigned int decoderSpecificSize,
34 void* decoderSpecificInfo) 35 void* decoderSpecificInfo)
35 : encoded_frame_(frame), encode_complete_(false) {} 36 : encoded_frame_(frame), encode_complete_(false) {}
36 37
37 virtual int Encoded(const EncodedImage& encoded_frame_, 38 virtual int Encoded(const EncodedImage& encoded_frame_,
38 const CodecSpecificInfo* codecSpecificInfo, 39 const CodecSpecificInfo* codecSpecificInfo,
39 const RTPFragmentationHeader*); 40 const RTPFragmentationHeader*);
40 bool EncodeComplete(); 41 bool EncodeComplete();
41 42
42 private: 43 private:
43 EncodedImage* const encoded_frame_; 44 EncodedImage* const encoded_frame_;
44 rtc::scoped_ptr<uint8_t[]> frame_buffer_; 45 std::unique_ptr<uint8_t[]> frame_buffer_;
45 bool encode_complete_; 46 bool encode_complete_;
46 }; 47 };
47 48
48 int Vp8UnitTestEncodeCompleteCallback::Encoded( 49 int Vp8UnitTestEncodeCompleteCallback::Encoded(
49 const EncodedImage& encoded_frame, 50 const EncodedImage& encoded_frame,
50 const CodecSpecificInfo* codecSpecificInfo, 51 const CodecSpecificInfo* codecSpecificInfo,
51 const RTPFragmentationHeader* fragmentation) { 52 const RTPFragmentationHeader* fragmentation) {
52 if (encoded_frame_->_size < encoded_frame._length) { 53 if (encoded_frame_->_size < encoded_frame._length) {
53 delete[] encoded_frame_->_buffer; 54 delete[] encoded_frame_->_buffer;
54 frame_buffer_.reset(new uint8_t[encoded_frame._length]); 55 frame_buffer_.reset(new uint8_t[encoded_frame._length]);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return CalcBufferSize(kI420, decoded_frame_.width(), 175 return CalcBufferSize(kI420, decoded_frame_.width(),
175 decoded_frame_.height()); 176 decoded_frame_.height());
176 } 177 }
177 } 178 }
178 return 0; 179 return 0;
179 } 180 }
180 181
181 const int kWidth = 172; 182 const int kWidth = 172;
182 const int kHeight = 144; 183 const int kHeight = 144;
183 184
184 rtc::scoped_ptr<Vp8UnitTestEncodeCompleteCallback> encode_complete_callback_; 185 std::unique_ptr<Vp8UnitTestEncodeCompleteCallback> encode_complete_callback_;
185 rtc::scoped_ptr<Vp8UnitTestDecodeCompleteCallback> decode_complete_callback_; 186 std::unique_ptr<Vp8UnitTestDecodeCompleteCallback> decode_complete_callback_;
186 rtc::scoped_ptr<uint8_t[]> source_buffer_; 187 std::unique_ptr<uint8_t[]> source_buffer_;
187 FILE* source_file_; 188 FILE* source_file_;
188 VideoFrame input_frame_; 189 VideoFrame input_frame_;
189 rtc::scoped_ptr<VideoEncoder> encoder_; 190 std::unique_ptr<VideoEncoder> encoder_;
190 rtc::scoped_ptr<VideoDecoder> decoder_; 191 std::unique_ptr<VideoDecoder> decoder_;
191 EncodedImage encoded_frame_; 192 EncodedImage encoded_frame_;
192 VideoFrame decoded_frame_; 193 VideoFrame decoded_frame_;
193 size_t length_source_frame_; 194 size_t length_source_frame_;
194 VideoCodec codec_inst_; 195 VideoCodec codec_inst_;
195 }; 196 };
196 197
197 TEST_F(TestVp8Impl, EncoderParameterTest) { 198 TEST_F(TestVp8Impl, EncoderParameterTest) {
198 strncpy(codec_inst_.plName, "VP8", 31); 199 strncpy(codec_inst_.plName, "VP8", 31);
199 codec_inst_.plType = 126; 200 codec_inst_.plType = 126;
200 codec_inst_.maxBitrate = 0; 201 codec_inst_.maxBitrate = 0;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, 261 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR,
261 decoder_->Decode(encoded_frame_, false, NULL)); 262 decoder_->Decode(encoded_frame_, false, NULL));
262 // Now setting a key frame. 263 // Now setting a key frame.
263 encoded_frame_._frameType = kVideoFrameKey; 264 encoded_frame_._frameType = kVideoFrameKey;
264 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, 265 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
265 decoder_->Decode(encoded_frame_, false, NULL)); 266 decoder_->Decode(encoded_frame_, false, NULL));
266 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); 267 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36);
267 } 268 }
268 269
269 } // namespace webrtc 270 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698