Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: webrtc/modules/video_processing/util/noise_estimation.cc

Issue 1871853003: External VNR speed improvement and more. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More clean-up. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_processing/util/noise_estimation.cc
diff --git a/webrtc/modules/video_processing/util/noise_estimation.cc b/webrtc/modules/video_processing/util/noise_estimation.cc
index 87beac38ae582e265fe35c0541aaf2c15b729179..a0ae2c474a3819c7ad9bb589c2eb40559c4a36a8 100644
--- a/webrtc/modules/video_processing/util/noise_estimation.cc
+++ b/webrtc/modules/video_processing/util/noise_estimation.cc
@@ -27,10 +27,10 @@ void NoiseEstimation::GetNoise(int mb_index, uint32_t var, uint32_t luma) {
consec_low_var_[mb_index]++;
num_static_block_++;
if (consec_low_var_[mb_index] >= kConsecLowVarFrame &&
- (luma >> 8) < kAverageLumaMax && (luma >> 8) > kAverageLumaMin) {
+ (luma >> 6) < kAverageLumaMax && (luma >> 6) > kAverageLumaMin) {
// Normalized var by the average luma value, this gives more weight to
// darker blocks.
- int nor_var = var / (luma >> 12);
+ int nor_var = var / (luma >> 10);
noise_var_ +=
nor_var > kBlockSelectionVarMax ? kBlockSelectionVarMax : nor_var;
num_noisy_block_++;
@@ -46,25 +46,28 @@ void NoiseEstimation::UpdateNoiseLevel() {
// condition more reasonable.
// No enough samples implies the motion of the camera or too many moving
// objects in the frame.
- if (num_static_block_ < (0.65 * mb_cols_ * mb_rows_) || !num_noisy_block_) {
+ if (num_static_block_ <
+ (0.65 * mb_cols_ * mb_rows_ / NOISE_SUBSAMPLE_INTERVAL) ||
+ !num_noisy_block_) {
+#if DISPLAY
+ printf("Not enough samples. %d \n", num_static_block_);
+#endif
noise_var_ = 0;
noise_var_accum_ = 0;
- num_static_block_ = 0;
num_noisy_block_ = 0;
-#if DISPLAY
- printf("Not enough samples.\n");
-#endif
+ num_static_block_ = 0;
return;
} else {
- // Normalized by the number of noisy blocks.
- noise_var_ /= num_noisy_block_;
- // Get the percentage of static blocks.
- percent_static_block_ =
- static_cast<double>(num_static_block_) / (mb_cols_ * mb_rows_);
#if DISPLAY
- printf("%d %d fraction = %.3f\n", num_static_block_, mb_cols_ * mb_rows_,
+ printf("%d %d fraction = %.3f\n", num_static_block_,
+ mb_cols_ * mb_rows_ / NOISE_SUBSAMPLE_INTERVAL,
percent_static_block_);
#endif
+ // Normalized by the number of noisy blocks.
+ noise_var_ /= num_noisy_block_;
+ // Get the percentage of static blocks.
+ percent_static_block_ = static_cast<double>(num_static_block_) /
+ (mb_cols_ * mb_rows_ / NOISE_SUBSAMPLE_INTERVAL);
num_noisy_block_ = 0;
num_static_block_ = 0;
}
@@ -75,12 +78,12 @@ void NoiseEstimation::UpdateNoiseLevel() {
} else {
noise_var_accum_ = (noise_var_accum_ * 15 + noise_var_) / 16;
}
- // Reset noise_var_ for the next frame.
- noise_var_ = 0;
#if DISPLAY
printf("noise_var_accum_ = %.1f, noise_var_ = %d.\n", noise_var_accum_,
noise_var_);
#endif
+ // Reset noise_var_ for the next frame.
+ noise_var_ = 0;
}
uint8_t NoiseEstimation::GetNoiseLevel() {
« no previous file with comments | « webrtc/modules/video_processing/util/noise_estimation.h ('k') | webrtc/modules/video_processing/video_denoiser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698