OLD | NEW |
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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 private: | 73 private: |
74 // Reconstruct a vp8 encoder with new config since the Vp8Encoder | 74 // Reconstruct a vp8 encoder with new config since the Vp8Encoder |
75 // class has no interface to update the config. | 75 // class has no interface to update the config. |
76 void RecreateVp8Encoder() { | 76 void RecreateVp8Encoder() { |
77 vp8_encoder_.reset(new Vp8Encoder(video_config_)); | 77 vp8_encoder_.reset(new Vp8Encoder(video_config_)); |
78 vp8_encoder_->Initialize(); | 78 vp8_encoder_->Initialize(); |
79 } | 79 } |
80 | 80 |
81 base::TimeDelta next_frame_timestamp_; | 81 base::TimeDelta next_frame_timestamp_; |
82 VideoSenderConfig video_config_; | 82 VideoSenderConfig video_config_; |
83 scoped_ptr<Vp8Encoder> vp8_encoder_; | 83 std::unique_ptr<Vp8Encoder> vp8_encoder_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(Vp8QuantizerParserTest); | 85 DISALLOW_COPY_AND_ASSIGN(Vp8QuantizerParserTest); |
86 }; | 86 }; |
87 | 87 |
88 // Encode 3 frames to test the cases with insufficient data input. | 88 // Encode 3 frames to test the cases with insufficient data input. |
89 TEST_F(Vp8QuantizerParserTest, InsufficientData) { | 89 TEST_F(Vp8QuantizerParserTest, InsufficientData) { |
90 for (int i = 0; i < 3; ++i) { | 90 for (int i = 0; i < 3; ++i) { |
91 scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); | 91 std::unique_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); |
92 const uint8_t* encoded_data = | 92 const uint8_t* encoded_data = |
93 reinterpret_cast<const uint8_t*>(encoded_frame->data.data()); | 93 reinterpret_cast<const uint8_t*>(encoded_frame->data.data()); |
94 // Null input. | 94 // Null input. |
95 int decoded_quantizer = | 95 int decoded_quantizer = |
96 ParseVp8HeaderQuantizer(encoded_data, encoded_frame->data.size()); | 96 ParseVp8HeaderQuantizer(encoded_data, encoded_frame->data.size()); |
97 EXPECT_EQ(-1, decoded_quantizer); | 97 EXPECT_EQ(-1, decoded_quantizer); |
98 EncodeOneFrame(encoded_frame.get()); | 98 EncodeOneFrame(encoded_frame.get()); |
99 encoded_data = reinterpret_cast<const uint8_t*>(encoded_frame->data.data()); | 99 encoded_data = reinterpret_cast<const uint8_t*>(encoded_frame->data.data()); |
100 // Zero bytes should not be enough to decode the quantizer value. | 100 // Zero bytes should not be enough to decode the quantizer value. |
101 decoded_quantizer = ParseVp8HeaderQuantizer(encoded_data, 0); | 101 decoded_quantizer = ParseVp8HeaderQuantizer(encoded_data, 0); |
(...skipping 29 matching lines...) Expand all Loading... |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 // Encode 3 fames for every quantizer value in the range of [4,63]. | 135 // Encode 3 fames for every quantizer value in the range of [4,63]. |
136 TEST_F(Vp8QuantizerParserTest, VariedQuantizer) { | 136 TEST_F(Vp8QuantizerParserTest, VariedQuantizer) { |
137 int decoded_quantizer = -1; | 137 int decoded_quantizer = -1; |
138 for (int qp = 4; qp <= 63; qp += 10) { | 138 for (int qp = 4; qp <= 63; qp += 10) { |
139 UpdateQuantizer(qp); | 139 UpdateQuantizer(qp); |
140 for (int i = 0; i < 3; ++i) { | 140 for (int i = 0; i < 3; ++i) { |
141 scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); | 141 std::unique_ptr<SenderEncodedFrame> encoded_frame( |
| 142 new SenderEncodedFrame()); |
142 EncodeOneFrame(encoded_frame.get()); | 143 EncodeOneFrame(encoded_frame.get()); |
143 decoded_quantizer = ParseVp8HeaderQuantizer( | 144 decoded_quantizer = ParseVp8HeaderQuantizer( |
144 reinterpret_cast<const uint8_t*>(encoded_frame->data.data()), | 145 reinterpret_cast<const uint8_t*>(encoded_frame->data.data()), |
145 encoded_frame->data.size()); | 146 encoded_frame->data.size()); |
146 EXPECT_EQ(qp, decoded_quantizer); | 147 EXPECT_EQ(qp, decoded_quantizer); |
147 } | 148 } |
148 } | 149 } |
149 } | 150 } |
150 | 151 |
151 } // namespace cast | 152 } // namespace cast |
152 } // namespace media | 153 } // namespace media |
OLD | NEW |