OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_TEST_UTILITY_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_TEST_UTILITY_H_ |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <map> | 15 #include <map> |
16 #include <memory> | 16 #include <memory> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/api/video/i420_buffer.h" | 19 #include "webrtc/api/video/i420_buffer.h" |
20 #include "webrtc/api/video/video_frame.h" | 20 #include "webrtc/api/video/video_frame.h" |
21 #include "webrtc/common_video/include/video_frame.h" | 21 #include "webrtc/common_video/include/video_frame.h" |
22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 Decoded(decoded_image); | 154 Decoded(decoded_image); |
155 } | 155 } |
156 int DecodedFrames() { return decoded_frames_; } | 156 int DecodedFrames() { return decoded_frames_; } |
157 | 157 |
158 private: | 158 private: |
159 int decoded_frames_; | 159 int decoded_frames_; |
160 }; | 160 }; |
161 | 161 |
162 class TestVp8Simulcast : public ::testing::Test { | 162 class TestVp8Simulcast : public ::testing::Test { |
163 public: | 163 public: |
164 TestVp8Simulcast(VP8Encoder* encoder, VP8Decoder* decoder) | |
165 : encoder_(encoder), decoder_(decoder) {} | |
166 | |
167 static void SetPlane(uint8_t* data, | 164 static void SetPlane(uint8_t* data, |
168 uint8_t value, | 165 uint8_t value, |
169 int width, | 166 int width, |
170 int height, | 167 int height, |
171 int stride) { | 168 int stride) { |
172 for (int i = 0; i < height; i++, data += stride) { | 169 for (int i = 0; i < height; i++, data += stride) { |
173 // Setting allocated area to zero - setting only image size to | 170 // Setting allocated area to zero - setting only image size to |
174 // requested values - will make it easier to distinguish between image | 171 // requested values - will make it easier to distinguish between image |
175 // size and frame size (accounting for stride). | 172 // size and frame size (accounting for stride). |
176 memset(data, value, width); | 173 memset(data, value, width); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 stream->width = width; | 234 stream->width = width; |
238 stream->height = height; | 235 stream->height = height; |
239 stream->maxBitrate = max_bitrate; | 236 stream->maxBitrate = max_bitrate; |
240 stream->minBitrate = min_bitrate; | 237 stream->minBitrate = min_bitrate; |
241 stream->targetBitrate = target_bitrate; | 238 stream->targetBitrate = target_bitrate; |
242 stream->numberOfTemporalLayers = num_temporal_layers; | 239 stream->numberOfTemporalLayers = num_temporal_layers; |
243 stream->qpMax = 45; | 240 stream->qpMax = 45; |
244 } | 241 } |
245 | 242 |
246 protected: | 243 protected: |
247 void SetUp() override { SetUpCodec(kDefaultTemporalLayerProfile); } | 244 virtual VP8Encoder* CreateEncoder() = 0; |
| 245 virtual VP8Decoder* CreateDecoder() = 0; |
| 246 |
| 247 void SetUp() override { |
| 248 encoder_.reset(CreateEncoder()); |
| 249 decoder_.reset(CreateDecoder()); |
| 250 SetUpCodec(kDefaultTemporalLayerProfile); |
| 251 } |
248 | 252 |
249 void TearDown() override { | 253 void TearDown() override { |
250 encoder_->Release(); | 254 encoder_->Release(); |
251 decoder_->Release(); | 255 decoder_->Release(); |
| 256 encoder_.reset(); |
| 257 decoder_.reset(); |
252 } | 258 } |
253 | 259 |
254 void SetUpCodec(const int* temporal_layer_profile) { | 260 void SetUpCodec(const int* temporal_layer_profile) { |
255 encoder_->RegisterEncodeCompleteCallback(&encoder_callback_); | 261 encoder_->RegisterEncodeCompleteCallback(&encoder_callback_); |
256 decoder_->RegisterDecodeCompleteCallback(&decoder_callback_); | 262 decoder_->RegisterDecodeCompleteCallback(&decoder_callback_); |
257 DefaultSettings(&settings_, temporal_layer_profile); | 263 DefaultSettings(&settings_, temporal_layer_profile); |
258 SetUpRateAllocator(); | 264 SetUpRateAllocator(); |
259 EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200)); | 265 EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200)); |
260 EXPECT_EQ(0, decoder_->InitDecode(&settings_, 1)); | 266 EXPECT_EQ(0, decoder_->InitDecode(&settings_, 1)); |
261 input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight); | 267 input_buffer_ = I420Buffer::Create(kDefaultWidth, kDefaultHeight); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 MockDecodedImageCallback decoder_callback_; | 745 MockDecodedImageCallback decoder_callback_; |
740 VideoCodec settings_; | 746 VideoCodec settings_; |
741 rtc::scoped_refptr<I420Buffer> input_buffer_; | 747 rtc::scoped_refptr<I420Buffer> input_buffer_; |
742 std::unique_ptr<VideoFrame> input_frame_; | 748 std::unique_ptr<VideoFrame> input_frame_; |
743 std::unique_ptr<SimulcastRateAllocator> rate_allocator_; | 749 std::unique_ptr<SimulcastRateAllocator> rate_allocator_; |
744 }; | 750 }; |
745 | 751 |
746 } // namespace testing | 752 } // namespace testing |
747 } // namespace webrtc | 753 } // namespace webrtc |
748 | 754 |
749 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 755 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_TEST_UTILITY_H_ |
OLD | NEW |