OLD | NEW |
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 "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
15 #include "webrtc/base/scoped_ptr.h" | 15 #include "webrtc/base/scoped_ptr.h" |
16 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 16 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
17 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 17 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
18 #include "webrtc/system_wrappers/include/tick_util.h" | 18 #include "webrtc/system_wrappers/include/tick_util.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
20 #include "webrtc/test/testsupport/gtest_disable.h" | |
21 | 20 |
22 namespace webrtc { | 21 namespace webrtc { |
23 | 22 |
24 enum { kMaxWaitEncTimeMs = 100 }; | 23 enum { kMaxWaitEncTimeMs = 100 }; |
25 enum { kMaxWaitDecTimeMs = 25 }; | 24 enum { kMaxWaitDecTimeMs = 25 }; |
26 | 25 |
27 static const uint32_t kTestTimestamp = 123; | 26 static const uint32_t kTestTimestamp = 123; |
28 static const int64_t kTestNtpTimeMs = 456; | 27 static const int64_t kTestNtpTimeMs = 456; |
29 | 28 |
30 // TODO(mikhal): Replace these with mocks. | 29 // TODO(mikhal): Replace these with mocks. |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 encoder_->SetRates(bit_rate, codec_inst_.maxFramerate)); | 213 encoder_->SetRates(bit_rate, codec_inst_.maxFramerate)); |
215 | 214 |
216 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_inst_, 1, 1440)); | 215 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->InitEncode(&codec_inst_, 1, 1440)); |
217 | 216 |
218 // Decoder parameter tests. | 217 // Decoder parameter tests. |
219 // Calls before InitDecode(). | 218 // Calls before InitDecode(). |
220 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); | 219 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); |
221 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); | 220 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); |
222 } | 221 } |
223 | 222 |
224 TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(AlignedStrideEncodeDecode)) { | 223 #if defined(WEBRTC_ANDROID) |
| 224 #define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode |
| 225 #else |
| 226 #define MAYBE_AlignedStrideEncodeDecode AlignedStrideEncodeDecode |
| 227 #endif |
| 228 TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { |
225 SetUpEncodeDecode(); | 229 SetUpEncodeDecode(); |
226 encoder_->Encode(input_frame_, NULL, NULL); | 230 encoder_->Encode(input_frame_, NULL, NULL); |
227 EXPECT_GT(WaitForEncodedFrame(), 0u); | 231 EXPECT_GT(WaitForEncodedFrame(), 0u); |
228 // First frame should be a key frame. | 232 // First frame should be a key frame. |
229 encoded_frame_._frameType = kVideoFrameKey; | 233 encoded_frame_._frameType = kVideoFrameKey; |
230 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; | 234 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; |
231 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 235 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
232 decoder_->Decode(encoded_frame_, false, NULL)); | 236 decoder_->Decode(encoded_frame_, false, NULL)); |
233 EXPECT_GT(WaitForDecodedFrame(), 0u); | 237 EXPECT_GT(WaitForDecodedFrame(), 0u); |
234 // Compute PSNR on all planes (faster than SSIM). | 238 // Compute PSNR on all planes (faster than SSIM). |
235 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); | 239 EXPECT_GT(I420PSNR(&input_frame_, &decoded_frame_), 36); |
236 EXPECT_EQ(kTestTimestamp, decoded_frame_.timestamp()); | 240 EXPECT_EQ(kTestTimestamp, decoded_frame_.timestamp()); |
237 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_.ntp_time_ms()); | 241 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_.ntp_time_ms()); |
238 } | 242 } |
239 | 243 |
240 TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(DecodeWithACompleteKeyFrame)) { | 244 #if defined(WEBRTC_ANDROID) |
| 245 #define MAYBE_DecodeWithACompleteKeyFrame DISABLED_DecodeWithACompleteKeyFrame |
| 246 #else |
| 247 #define MAYBE_DecodeWithACompleteKeyFrame DecodeWithACompleteKeyFrame |
| 248 #endif |
| 249 TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) { |
241 SetUpEncodeDecode(); | 250 SetUpEncodeDecode(); |
242 encoder_->Encode(input_frame_, NULL, NULL); | 251 encoder_->Encode(input_frame_, NULL, NULL); |
243 EXPECT_GT(WaitForEncodedFrame(), 0u); | 252 EXPECT_GT(WaitForEncodedFrame(), 0u); |
244 // Setting complete to false -> should return an error. | 253 // Setting complete to false -> should return an error. |
245 encoded_frame_._completeFrame = false; | 254 encoded_frame_._completeFrame = false; |
246 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 255 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
247 decoder_->Decode(encoded_frame_, false, NULL)); | 256 decoder_->Decode(encoded_frame_, false, NULL)); |
248 // Setting complete back to true. Forcing a delta frame. | 257 // Setting complete back to true. Forcing a delta frame. |
249 encoded_frame_._frameType = kVideoFrameDelta; | 258 encoded_frame_._frameType = kVideoFrameDelta; |
250 encoded_frame_._completeFrame = true; | 259 encoded_frame_._completeFrame = true; |
(...skipping 18 matching lines...) Expand all Loading... |
269 | 278 |
270 EXPECT_EQ(0, decoder_->Decode(encoded_frame_, false, NULL)); | 279 EXPECT_EQ(0, decoder_->Decode(encoded_frame_, false, NULL)); |
271 rtc::scoped_ptr<uint8_t[]> second_frame_buffer(new uint8_t[length]); | 280 rtc::scoped_ptr<uint8_t[]> second_frame_buffer(new uint8_t[length]); |
272 ExtractBuffer(decoded_frame_, length, second_frame_buffer.get()); | 281 ExtractBuffer(decoded_frame_, length, second_frame_buffer.get()); |
273 | 282 |
274 EXPECT_EQ( | 283 EXPECT_EQ( |
275 0, memcmp(second_frame_buffer.get(), first_frame_buffer.get(), length)); | 284 0, memcmp(second_frame_buffer.get(), first_frame_buffer.get(), length)); |
276 } | 285 } |
277 | 286 |
278 } // namespace webrtc | 287 } // namespace webrtc |
OLD | NEW |