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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 unsigned char high_th = 230; | 54 unsigned char high_th = 230; |
55 float prop_high = 0; | 55 float prop_high = 0; |
56 for (uint32_t i = high_th; i < 256; i++) { | 56 for (uint32_t i = high_th; i < 256; i++) { |
57 prop_high += stats.hist[i]; | 57 prop_high += stats.hist[i]; |
58 } | 58 } |
59 prop_high /= stats.num_pixels; | 59 prop_high /= stats.num_pixels; |
60 | 60 |
61 if (prop_high < 0.4) { | 61 if (prop_high < 0.4) { |
62 if (stats.mean < 90 || stats.mean > 170) { | 62 if (stats.mean < 90 || stats.mean > 170) { |
63 // Standard deviation of Y | 63 // Standard deviation of Y |
64 const uint8_t* buffer = frame.buffer(kYPlane); | 64 const uint8_t* buffer = frame.video_frame_buffer()->DataY(); |
65 float std_y = 0; | 65 float std_y = 0; |
66 for (int h = 0; h < height; h += (1 << stats.sub_sampling_factor)) { | 66 for (int h = 0; h < height; h += (1 << stats.sub_sampling_factor)) { |
67 int row = h * width; | 67 int row = h * width; |
68 for (int w = 0; w < width; w += (1 << stats.sub_sampling_factor)) { | 68 for (int w = 0; w < width; w += (1 << stats.sub_sampling_factor)) { |
69 std_y += | 69 std_y += |
70 (buffer[w + row] - stats.mean) * (buffer[w + row] - stats.mean); | 70 (buffer[w + row] - stats.mean) * (buffer[w + row] - stats.mean); |
71 } | 71 } |
72 } | 72 } |
73 std_y = sqrt(std_y / stats.num_pixels); | 73 std_y = sqrt(std_y / stats.num_pixels); |
74 | 74 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (frame_cnt_dark_ > frame_cnt_alarm) { | 127 if (frame_cnt_dark_ > frame_cnt_alarm) { |
128 return VideoProcessing::kDarkWarning; | 128 return VideoProcessing::kDarkWarning; |
129 } else if (frame_cnt_bright_ > frame_cnt_alarm) { | 129 } else if (frame_cnt_bright_ > frame_cnt_alarm) { |
130 return VideoProcessing::kBrightWarning; | 130 return VideoProcessing::kBrightWarning; |
131 } else { | 131 } else { |
132 return VideoProcessing::kNoWarning; | 132 return VideoProcessing::kNoWarning; |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 } // namespace webrtc | 136 } // namespace webrtc |
OLD | NEW |