OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_NOISE_ESTIMATION_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_NOISE_ESTIMATION_H_ |
12 #define WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_NOISE_ESTIMATION_H_ | 12 #define WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_NOISE_ESTIMATION_H_ |
13 | 13 |
14 #include "webrtc/base/scoped_ptr.h" | 14 #include "webrtc/base/scoped_ptr.h" |
15 #include "webrtc/modules/include/module_common_types.h" | 15 #include "webrtc/modules/include/module_common_types.h" |
16 #include "webrtc/modules/video_processing/include/video_processing_defines.h" | 16 #include "webrtc/modules/video_processing/include/video_processing_defines.h" |
17 #include "webrtc/modules/video_processing/util/denoiser_filter.h" | 17 #include "webrtc/modules/video_processing/util/denoiser_filter.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 #define EXPERIMENTAL 0 | |
22 #define DISPLAY 0 | 21 #define DISPLAY 0 |
23 | 22 |
24 const int kNoiseThreshold = 200; | 23 const int kNoiseThreshold = 200; |
25 const int kNoiseThresholdNeon = 70; | 24 const int kNoiseThresholdNeon = 70; |
26 const int kConsecLowVarFrame = 6; | 25 const int kConsecLowVarFrame = 6; |
27 const int kAverageLumaMin = 20; | 26 const int kAverageLumaMin = 20; |
28 const int kAverageLumaMax = 220; | 27 const int kAverageLumaMax = 220; |
29 const int kBlockSelectionVarMax = kNoiseThreshold << 1; | 28 const int kBlockSelectionVarMax = kNoiseThreshold << 1; |
30 | 29 |
| 30 // TODO(jackychen): To test different sampling strategy. |
| 31 // Collect noise data every NOISE_SUBSAMPLE_INTERVAL blocks. |
| 32 #define NOISE_SUBSAMPLE_INTERVAL 41 |
| 33 |
31 class NoiseEstimation { | 34 class NoiseEstimation { |
32 public: | 35 public: |
33 void Init(int width, int height, CpuType cpu_type); | 36 void Init(int width, int height, CpuType cpu_type); |
| 37 // Collect noise data from one qualified block. |
34 void GetNoise(int mb_index, uint32_t var, uint32_t luma); | 38 void GetNoise(int mb_index, uint32_t var, uint32_t luma); |
| 39 // Reset the counter for consecutive low-var blocks. |
35 void ResetConsecLowVar(int mb_index); | 40 void ResetConsecLowVar(int mb_index); |
| 41 // Update noise level for current frame. |
36 void UpdateNoiseLevel(); | 42 void UpdateNoiseLevel(); |
37 // 0: low noise, 1: high noise | 43 // 0: low noise, 1: high noise |
38 uint8_t GetNoiseLevel(); | 44 uint8_t GetNoiseLevel(); |
39 | 45 |
40 private: | 46 private: |
41 int width_; | 47 int width_; |
42 int height_; | 48 int height_; |
43 int mb_rows_; | 49 int mb_rows_; |
44 int mb_cols_; | 50 int mb_cols_; |
| 51 int num_noisy_block_; |
| 52 int num_static_block_; |
45 CpuType cpu_type_; | 53 CpuType cpu_type_; |
46 uint32_t noise_var_; | 54 uint32_t noise_var_; |
47 double noise_var_accum_; | 55 double noise_var_accum_; |
48 int num_noisy_block_; | |
49 int num_static_block_; | |
50 double percent_static_block_; | 56 double percent_static_block_; |
51 rtc::scoped_ptr<uint32_t[]> consec_low_var_; | 57 std::unique_ptr<uint32_t[]> consec_low_var_; |
52 }; | 58 }; |
53 | 59 |
54 } // namespace webrtc | 60 } // namespace webrtc |
55 | 61 |
56 #endif // WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_NOISE_ESTIMATION_H_ | 62 #endif // WEBRTC_MODULES_VIDEO_PROCESSING_UTIL_NOISE_ESTIMATION_H_ |
OLD | NEW |