| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 half_width_((width_ + 1) / 2), | 62 half_width_((width_ + 1) / 2), |
| 63 height_(288), | 63 height_(288), |
| 64 size_y_(width_ * height_), | 64 size_y_(width_ * height_), |
| 65 size_uv_(half_width_ * ((height_ + 1) / 2)), | 65 size_uv_(half_width_ * ((height_ + 1) / 2)), |
| 66 frame_length_(CalcBufferSize(kI420, width_, height_)) {} | 66 frame_length_(CalcBufferSize(kI420, width_, height_)) {} |
| 67 | 67 |
| 68 void VideoProcessingTest::SetUp() { | 68 void VideoProcessingTest::SetUp() { |
| 69 vp_ = VideoProcessing::Create(); | 69 vp_ = VideoProcessing::Create(); |
| 70 ASSERT_TRUE(vp_ != NULL); | 70 ASSERT_TRUE(vp_ != NULL); |
| 71 | 71 |
| 72 video_frame_.CreateEmptyFrame(width_, height_, width_, | 72 ASSERT_EQ(0, video_frame_.CreateEmptyFrame(width_, height_, width_, |
| 73 half_width_, half_width_); | 73 half_width_, half_width_)); |
| 74 // Clear video frame so DrMemory/Valgrind will allow reads of the buffer. | 74 // Clear video frame so DrMemory/Valgrind will allow reads of the buffer. |
| 75 memset(video_frame_.buffer(kYPlane), 0, video_frame_.allocated_size(kYPlane)); | 75 memset(video_frame_.buffer(kYPlane), 0, video_frame_.allocated_size(kYPlane)); |
| 76 memset(video_frame_.buffer(kUPlane), 0, video_frame_.allocated_size(kUPlane)); | 76 memset(video_frame_.buffer(kUPlane), 0, video_frame_.allocated_size(kUPlane)); |
| 77 memset(video_frame_.buffer(kVPlane), 0, video_frame_.allocated_size(kVPlane)); | 77 memset(video_frame_.buffer(kVPlane), 0, video_frame_.allocated_size(kVPlane)); |
| 78 const std::string video_file = | 78 const std::string video_file = |
| 79 webrtc::test::ResourcePath("foreman_cif", "yuv"); | 79 webrtc::test::ResourcePath("foreman_cif", "yuv"); |
| 80 source_file_ = fopen(video_file.c_str(), "rb"); | 80 source_file_ = fopen(video_file.c_str(), "rb"); |
| 81 ASSERT_TRUE(source_file_ != NULL) | 81 ASSERT_TRUE(source_file_ != NULL) |
| 82 << "Cannot read source file: " + video_file + "\n"; | 82 << "Cannot read source file: " + video_file + "\n"; |
| 83 } | 83 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 VideoFrame video_frame2; | 135 VideoFrame video_frame2; |
| 136 VideoProcessing::FrameStats stats; | 136 VideoProcessing::FrameStats stats; |
| 137 // Only testing non-static functions here. | 137 // Only testing non-static functions here. |
| 138 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); | 138 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); |
| 139 ASSERT_EQ(frame_length_, | 139 ASSERT_EQ(frame_length_, |
| 140 fread(video_buffer.get(), 1, frame_length_, source_file_)); | 140 fread(video_buffer.get(), 1, frame_length_, source_file_)); |
| 141 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 141 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
| 142 0, kVideoRotation_0, &video_frame_)); | 142 0, kVideoRotation_0, &video_frame_)); |
| 143 vp_->GetFrameStats(video_frame_, &stats); | 143 vp_->GetFrameStats(video_frame_, &stats); |
| 144 EXPECT_GT(stats.num_pixels, 0u); | 144 EXPECT_GT(stats.num_pixels, 0u); |
| 145 video_frame2.CopyFrame(video_frame_); | 145 ASSERT_EQ(0, video_frame2.CopyFrame(video_frame_)); |
| 146 ASSERT_EQ(0, vp_->Deflickering(&video_frame_, &stats)); | 146 ASSERT_EQ(0, vp_->Deflickering(&video_frame_, &stats)); |
| 147 | 147 |
| 148 // Retrieve frame stats again in case Deflickering() has zeroed them. | 148 // Retrieve frame stats again in case Deflickering() has zeroed them. |
| 149 vp_->GetFrameStats(video_frame2, &stats); | 149 vp_->GetFrameStats(video_frame2, &stats); |
| 150 EXPECT_GT(stats.num_pixels, 0u); | 150 EXPECT_GT(stats.num_pixels, 0u); |
| 151 ASSERT_EQ(0, vp_->Deflickering(&video_frame2, &stats)); | 151 ASSERT_EQ(0, vp_->Deflickering(&video_frame2, &stats)); |
| 152 EXPECT_TRUE(CompareFrames(video_frame_, video_frame2)); | 152 EXPECT_TRUE(CompareFrames(video_frame_, video_frame2)); |
| 153 | 153 |
| 154 ASSERT_EQ(frame_length_, | 154 ASSERT_EQ(frame_length_, |
| 155 fread(video_buffer.get(), 1, frame_length_, source_file_)); | 155 fread(video_buffer.get(), 1, frame_length_, source_file_)); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 std::cout << "Watch " << filename.str() << " and verify that it is okay." | 406 std::cout << "Watch " << filename.str() << " and verify that it is okay." |
| 407 << std::endl; | 407 << std::endl; |
| 408 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); | 408 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); |
| 409 if (PrintVideoFrame(processed, stand_alone_file) < 0) | 409 if (PrintVideoFrame(processed, stand_alone_file) < 0) |
| 410 std::cerr << "Failed to write: " << filename.str() << std::endl; | 410 std::cerr << "Failed to write: " << filename.str() << std::endl; |
| 411 if (stand_alone_file) | 411 if (stand_alone_file) |
| 412 fclose(stand_alone_file); | 412 fclose(stand_alone_file); |
| 413 } | 413 } |
| 414 | 414 |
| 415 } // namespace webrtc | 415 } // namespace webrtc |
| OLD | NEW |