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

Side by Side Diff: media/cast/sender/external_video_encoder_unittest.cc

Issue 1905763002: Convert //media/cast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/sender/external_video_encoder.h" 5 #include "media/cast/sender/external_video_encoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "media/base/video_frame.h" 9 #include "media/base/video_frame.h"
10 #include "media/base/video_types.h" 10 #include "media/base/video_types.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 return result; 31 return result;
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 TEST(QuantizerEstimator, EstimatesForTrivialFrames) { 36 TEST(QuantizerEstimator, EstimatesForTrivialFrames) {
37 QuantizerEstimator qe; 37 QuantizerEstimator qe;
38 38
39 const gfx::Size frame_size(320, 180); 39 const gfx::Size frame_size(320, 180);
40 const scoped_ptr<uint8_t[]> black_frame_data( 40 const std::unique_ptr<uint8_t[]> black_frame_data(
41 new uint8_t[frame_size.GetArea()]); 41 new uint8_t[frame_size.GetArea()]);
42 memset(black_frame_data.get(), 0, frame_size.GetArea()); 42 memset(black_frame_data.get(), 0, frame_size.GetArea());
43 const scoped_refptr<VideoFrame> black_frame = 43 const scoped_refptr<VideoFrame> black_frame =
44 CreateFrame(black_frame_data.get(), frame_size); 44 CreateFrame(black_frame_data.get(), frame_size);
45 45
46 // A solid color frame should always generate a minimum quantizer value (4.0) 46 // A solid color frame should always generate a minimum quantizer value (4.0)
47 // as a key frame. If it is provided repeatedly as delta frames, the minimum 47 // as a key frame. If it is provided repeatedly as delta frames, the minimum
48 // quantizer value should be repeatedly generated since there is no difference 48 // quantizer value should be repeatedly generated since there is no difference
49 // between frames. 49 // between frames.
50 EXPECT_EQ(4.0, qe.EstimateForKeyFrame(*black_frame)); 50 EXPECT_EQ(4.0, qe.EstimateForKeyFrame(*black_frame));
51 for (int i = 0; i < 3; ++i) 51 for (int i = 0; i < 3; ++i)
52 EXPECT_EQ(4.0, qe.EstimateForDeltaFrame(*black_frame)); 52 EXPECT_EQ(4.0, qe.EstimateForDeltaFrame(*black_frame));
53 53
54 const scoped_ptr<uint8_t[]> checkerboard_frame_data( 54 const std::unique_ptr<uint8_t[]> checkerboard_frame_data(
55 new uint8_t[frame_size.GetArea()]); 55 new uint8_t[frame_size.GetArea()]);
56 for (int i = 0, end = frame_size.GetArea(); i < end; ++i) 56 for (int i = 0, end = frame_size.GetArea(); i < end; ++i)
57 checkerboard_frame_data.get()[i] = (((i % 2) == 0) ? 0 : 255); 57 checkerboard_frame_data.get()[i] = (((i % 2) == 0) ? 0 : 255);
58 const scoped_refptr<VideoFrame> checkerboard_frame = 58 const scoped_refptr<VideoFrame> checkerboard_frame =
59 CreateFrame(checkerboard_frame_data.get(), frame_size); 59 CreateFrame(checkerboard_frame_data.get(), frame_size);
60 60
61 // Now, introduce a frame with a checkerboard pattern. Half of the pixels 61 // Now, introduce a frame with a checkerboard pattern. Half of the pixels
62 // will have a difference of 255, and half will have zero difference. 62 // will have a difference of 255, and half will have zero difference.
63 // Therefore, the Shannon Entropy should be 1.0 and the resulting quantizer 63 // Therefore, the Shannon Entropy should be 1.0 and the resulting quantizer
64 // estimate should be ~11.9. 64 // estimate should be ~11.9.
65 EXPECT_NEAR(11.9, qe.EstimateForDeltaFrame(*checkerboard_frame), 0.1); 65 EXPECT_NEAR(11.9, qe.EstimateForDeltaFrame(*checkerboard_frame), 0.1);
66 66
67 // Now, introduce a series of frames with "random snow" in them. Expect this 67 // Now, introduce a series of frames with "random snow" in them. Expect this
68 // results in high quantizer estimates. 68 // results in high quantizer estimates.
69 for (int i = 0; i < 3; ++i) { 69 for (int i = 0; i < 3; ++i) {
70 int rand_seed = 0xdeadbeef + i; 70 int rand_seed = 0xdeadbeef + i;
71 const scoped_ptr<uint8_t[]> random_frame_data( 71 const std::unique_ptr<uint8_t[]> random_frame_data(
72 new uint8_t[frame_size.GetArea()]); 72 new uint8_t[frame_size.GetArea()]);
73 for (int j = 0, end = frame_size.GetArea(); j < end; ++j) { 73 for (int j = 0, end = frame_size.GetArea(); j < end; ++j) {
74 rand_seed = (1103515245 * rand_seed + 12345) % (1 << 31); 74 rand_seed = (1103515245 * rand_seed + 12345) % (1 << 31);
75 random_frame_data.get()[j] = static_cast<uint8_t>(rand_seed & 0xff); 75 random_frame_data.get()[j] = static_cast<uint8_t>(rand_seed & 0xff);
76 } 76 }
77 const scoped_refptr<VideoFrame> random_frame = 77 const scoped_refptr<VideoFrame> random_frame =
78 CreateFrame(random_frame_data.get(), frame_size); 78 CreateFrame(random_frame_data.get(), frame_size);
79 EXPECT_LE(50.0, qe.EstimateForDeltaFrame(*random_frame)); 79 EXPECT_LE(50.0, qe.EstimateForDeltaFrame(*random_frame));
80 } 80 }
81 } 81 }
82 82
83 } // namespace cast 83 } // namespace cast
84 } // namespace media 84 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/external_video_encoder.cc ('k') | media/cast/sender/fake_video_encode_accelerator_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698