OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 rewind(source_file_); | 51 rewind(source_file_); |
52 frameNum = 0; | 52 frameNum = 0; |
53 warningCount = 0; | 53 warningCount = 0; |
54 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == | 54 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == |
55 frame_length_ && | 55 frame_length_ && |
56 frameNum < 300) { | 56 frameNum < 300) { |
57 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 57 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
58 0, kVideoRotation_0, &video_frame_)); | 58 0, kVideoRotation_0, &video_frame_)); |
59 frameNum++; | 59 frameNum++; |
60 | 60 |
61 uint8_t* frame = video_frame_.buffer(kYPlane); | 61 uint8_t* frame = video_frame_.video_frame_buffer()->MutableDataY(); |
62 uint32_t yTmp = 0; | 62 uint32_t yTmp = 0; |
63 for (int yIdx = 0; yIdx < width_ * height_; yIdx++) { | 63 for (int yIdx = 0; yIdx < width_ * height_; yIdx++) { |
64 yTmp = frame[yIdx] << 1; | 64 yTmp = frame[yIdx] << 1; |
65 if (yTmp > 255) { | 65 if (yTmp > 255) { |
66 yTmp = 255; | 66 yTmp = 255; |
67 } | 67 } |
68 frame[yIdx] = static_cast<uint8_t>(yTmp); | 68 frame[yIdx] = static_cast<uint8_t>(yTmp); |
69 } | 69 } |
70 | 70 |
71 VideoProcessing::FrameStats stats; | 71 VideoProcessing::FrameStats stats; |
(...skipping 16 matching lines...) Expand all Loading... |
88 rewind(source_file_); | 88 rewind(source_file_); |
89 frameNum = 0; | 89 frameNum = 0; |
90 warningCount = 0; | 90 warningCount = 0; |
91 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == | 91 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == |
92 frame_length_ && | 92 frame_length_ && |
93 frameNum < 300) { | 93 frameNum < 300) { |
94 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 94 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
95 0, kVideoRotation_0, &video_frame_)); | 95 0, kVideoRotation_0, &video_frame_)); |
96 frameNum++; | 96 frameNum++; |
97 | 97 |
98 uint8_t* y_plane = video_frame_.buffer(kYPlane); | 98 uint8_t* y_plane = video_frame_.video_frame_buffer()->MutableDataY(); |
99 int32_t yTmp = 0; | 99 int32_t yTmp = 0; |
100 for (int yIdx = 0; yIdx < width_ * height_; yIdx++) { | 100 for (int yIdx = 0; yIdx < width_ * height_; yIdx++) { |
101 yTmp = y_plane[yIdx] >> 1; | 101 yTmp = y_plane[yIdx] >> 1; |
102 y_plane[yIdx] = static_cast<uint8_t>(yTmp); | 102 y_plane[yIdx] = static_cast<uint8_t>(yTmp); |
103 } | 103 } |
104 | 104 |
105 VideoProcessing::FrameStats stats; | 105 VideoProcessing::FrameStats stats; |
106 vp_->GetFrameStats(video_frame_, &stats); | 106 vp_->GetFrameStats(video_frame_, &stats); |
107 EXPECT_GT(stats.num_pixels, 0u); | 107 EXPECT_GT(stats.num_pixels, 0u); |
108 ASSERT_GE(brightnessWarning = vp_->BrightnessDetection(video_frame_, stats), | 108 ASSERT_GE(brightnessWarning = vp_->BrightnessDetection(video_frame_, stats), |
109 0); | 109 0); |
110 EXPECT_NE(VideoProcessing::kBrightWarning, brightnessWarning); | 110 EXPECT_NE(VideoProcessing::kBrightWarning, brightnessWarning); |
111 if (brightnessWarning == VideoProcessing::kDarkWarning) { | 111 if (brightnessWarning == VideoProcessing::kDarkWarning) { |
112 warningCount++; | 112 warningCount++; |
113 } | 113 } |
114 } | 114 } |
115 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; | 115 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; |
116 | 116 |
117 // Expect many darkness warnings | 117 // Expect many darkness warnings |
118 warningProportion = static_cast<float>(warningCount) / frameNum * 100; | 118 warningProportion = static_cast<float>(warningCount) / frameNum * 100; |
119 printf("Dark foreman: %.1f %%\n\n", warningProportion); | 119 printf("Dark foreman: %.1f %%\n\n", warningProportion); |
120 EXPECT_GT(warningProportion, 90); | 120 EXPECT_GT(warningProportion, 90); |
121 } | 121 } |
122 } // namespace webrtc | 122 } // namespace webrtc |
OLD | NEW |