| 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 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return 0; | 123 return 0; |
| 124 } | 124 } |
| 125 | 125 |
| 126 class TestVp8Impl : public ::testing::Test { | 126 class TestVp8Impl : public ::testing::Test { |
| 127 protected: | 127 protected: |
| 128 virtual void SetUp() { | 128 virtual void SetUp() { |
| 129 encoder_.reset(VP8Encoder::Create()); | 129 encoder_.reset(VP8Encoder::Create()); |
| 130 decoder_.reset(VP8Decoder::Create()); | 130 decoder_.reset(VP8Decoder::Create()); |
| 131 memset(&codec_inst_, 0, sizeof(codec_inst_)); | 131 memset(&codec_inst_, 0, sizeof(codec_inst_)); |
| 132 encode_complete_callback_.reset( | 132 encode_complete_callback_.reset( |
| 133 new Vp8UnitTestEncodeCompleteCallback(&encoded_frame_, 0, NULL)); | 133 new Vp8UnitTestEncodeCompleteCallback(&encoded_frame_, 0, nullptr)); |
| 134 decode_complete_callback_.reset( | 134 decode_complete_callback_.reset( |
| 135 new Vp8UnitTestDecodeCompleteCallback(&decoded_frame_)); | 135 new Vp8UnitTestDecodeCompleteCallback(&decoded_frame_)); |
| 136 encoder_->RegisterEncodeCompleteCallback(encode_complete_callback_.get()); | 136 encoder_->RegisterEncodeCompleteCallback(encode_complete_callback_.get()); |
| 137 decoder_->RegisterDecodeCompleteCallback(decode_complete_callback_.get()); | 137 decoder_->RegisterDecodeCompleteCallback(decode_complete_callback_.get()); |
| 138 // Using a QCIF image (aligned stride (u,v planes) > width). | 138 // Using a QCIF image (aligned stride (u,v planes) > width). |
| 139 // Processing only one frame. | 139 // Processing only one frame. |
| 140 source_file_ = fopen(test::ResourcePath("paris_qcif", "yuv").c_str(), "rb"); | 140 source_file_ = fopen(test::ResourcePath("paris_qcif", "yuv").c_str(), "rb"); |
| 141 ASSERT_TRUE(source_file_ != NULL); | 141 ASSERT_TRUE(source_file_ != nullptr); |
| 142 rtc::scoped_refptr<VideoFrameBuffer> compact_buffer( | 142 rtc::scoped_refptr<VideoFrameBuffer> compact_buffer( |
| 143 test::ReadI420Buffer(kWidth, kHeight, source_file_)); | 143 test::ReadI420Buffer(kWidth, kHeight, source_file_)); |
| 144 ASSERT_TRUE(compact_buffer); | 144 ASSERT_TRUE(compact_buffer); |
| 145 codec_inst_.width = kWidth; | 145 codec_inst_.width = kWidth; |
| 146 codec_inst_.height = kHeight; | 146 codec_inst_.height = kHeight; |
| 147 const int kFramerate = 30; | 147 const int kFramerate = 30; |
| 148 codec_inst_.maxFramerate = kFramerate; | 148 codec_inst_.maxFramerate = kFramerate; |
| 149 // Setting aligned stride values. | 149 // Setting aligned stride values. |
| 150 int stride_uv; | 150 int stride_uv; |
| 151 int stride_y; | 151 int stride_y; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); | 244 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1)); |
| 245 } | 245 } |
| 246 | 246 |
| 247 #if defined(WEBRTC_ANDROID) | 247 #if defined(WEBRTC_ANDROID) |
| 248 #define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode | 248 #define MAYBE_AlignedStrideEncodeDecode DISABLED_AlignedStrideEncodeDecode |
| 249 #else | 249 #else |
| 250 #define MAYBE_AlignedStrideEncodeDecode AlignedStrideEncodeDecode | 250 #define MAYBE_AlignedStrideEncodeDecode AlignedStrideEncodeDecode |
| 251 #endif | 251 #endif |
| 252 TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { | 252 TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) { |
| 253 SetUpEncodeDecode(); | 253 SetUpEncodeDecode(); |
| 254 encoder_->Encode(*input_frame_, NULL, NULL); | 254 encoder_->Encode(*input_frame_, nullptr, nullptr); |
| 255 EXPECT_GT(WaitForEncodedFrame(), 0u); | 255 EXPECT_GT(WaitForEncodedFrame(), 0u); |
| 256 // First frame should be a key frame. | 256 // First frame should be a key frame. |
| 257 encoded_frame_._frameType = kVideoFrameKey; | 257 encoded_frame_._frameType = kVideoFrameKey; |
| 258 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; | 258 encoded_frame_.ntp_time_ms_ = kTestNtpTimeMs; |
| 259 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 259 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 260 decoder_->Decode(encoded_frame_, false, NULL)); | 260 decoder_->Decode(encoded_frame_, false, nullptr)); |
| 261 EXPECT_GT(WaitForDecodedFrame(), 0u); | 261 EXPECT_GT(WaitForDecodedFrame(), 0u); |
| 262 ASSERT_TRUE(decoded_frame_); | 262 ASSERT_TRUE(decoded_frame_); |
| 263 // Compute PSNR on all planes (faster than SSIM). | 263 // Compute PSNR on all planes (faster than SSIM). |
| 264 EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36); | 264 EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36); |
| 265 EXPECT_EQ(kTestTimestamp, decoded_frame_->timestamp()); | 265 EXPECT_EQ(kTestTimestamp, decoded_frame_->timestamp()); |
| 266 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_->ntp_time_ms()); | 266 EXPECT_EQ(kTestNtpTimeMs, decoded_frame_->ntp_time_ms()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 #if defined(WEBRTC_ANDROID) | 269 #if defined(WEBRTC_ANDROID) |
| 270 #define MAYBE_DecodeWithACompleteKeyFrame DISABLED_DecodeWithACompleteKeyFrame | 270 #define MAYBE_DecodeWithACompleteKeyFrame DISABLED_DecodeWithACompleteKeyFrame |
| 271 #else | 271 #else |
| 272 #define MAYBE_DecodeWithACompleteKeyFrame DecodeWithACompleteKeyFrame | 272 #define MAYBE_DecodeWithACompleteKeyFrame DecodeWithACompleteKeyFrame |
| 273 #endif | 273 #endif |
| 274 TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) { | 274 TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) { |
| 275 SetUpEncodeDecode(); | 275 SetUpEncodeDecode(); |
| 276 encoder_->Encode(*input_frame_, NULL, NULL); | 276 encoder_->Encode(*input_frame_, nullptr, nullptr); |
| 277 EXPECT_GT(WaitForEncodedFrame(), 0u); | 277 EXPECT_GT(WaitForEncodedFrame(), 0u); |
| 278 // Setting complete to false -> should return an error. | 278 // Setting complete to false -> should return an error. |
| 279 encoded_frame_._completeFrame = false; | 279 encoded_frame_._completeFrame = false; |
| 280 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 280 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
| 281 decoder_->Decode(encoded_frame_, false, NULL)); | 281 decoder_->Decode(encoded_frame_, false, nullptr)); |
| 282 // Setting complete back to true. Forcing a delta frame. | 282 // Setting complete back to true. Forcing a delta frame. |
| 283 encoded_frame_._frameType = kVideoFrameDelta; | 283 encoded_frame_._frameType = kVideoFrameDelta; |
| 284 encoded_frame_._completeFrame = true; | 284 encoded_frame_._completeFrame = true; |
| 285 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, | 285 EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, |
| 286 decoder_->Decode(encoded_frame_, false, NULL)); | 286 decoder_->Decode(encoded_frame_, false, nullptr)); |
| 287 // Now setting a key frame. | 287 // Now setting a key frame. |
| 288 encoded_frame_._frameType = kVideoFrameKey; | 288 encoded_frame_._frameType = kVideoFrameKey; |
| 289 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | 289 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 290 decoder_->Decode(encoded_frame_, false, NULL)); | 290 decoder_->Decode(encoded_frame_, false, nullptr)); |
| 291 ASSERT_TRUE(decoded_frame_); | 291 ASSERT_TRUE(decoded_frame_); |
| 292 EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36); | 292 EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace webrtc | 295 } // namespace webrtc |
| OLD | NEW |