External VNR speed improvement.

Improved visual quality with 3x times speed-up.
Change list:
 1. Remove second chance filter in temporal denoising filter to mitigate trailing artifact.
 2. Add swap buffer to save one whole-frame memcpy.
 3. Do noise estimation on every N blocks.
 4. Adopt a faster moving object detection algorithm (change the structure).
 5. Refactor the for loops and PositionCheck().
 6. Refactor the function ReduceFalseDetection (RFD).
 7. Fix a bug in TrailingBlock() which causes a mismatch.
 8. Change unit test to support swap buffer test.
 9. Remove CopyMem8x8, use memcpy to copy U/V plane which can be optimized future.
 10. Remove DenoiseMetrics.

Review URL: https://codereview.webrtc.org/1871853003

Cr-Commit-Position: refs/heads/master@{#12340}
diff --git a/webrtc/modules/video_processing/util/noise_estimation.h b/webrtc/modules/video_processing/util/noise_estimation.h
index ca5cc23..24d44ca 100644
--- a/webrtc/modules/video_processing/util/noise_estimation.h
+++ b/webrtc/modules/video_processing/util/noise_estimation.h
@@ -18,7 +18,6 @@
 
 namespace webrtc {
 
-#define EXPERIMENTAL 0
 #define DISPLAY 0
 
 const int kNoiseThreshold = 200;
@@ -28,11 +27,18 @@
 const int kAverageLumaMax = 220;
 const int kBlockSelectionVarMax = kNoiseThreshold << 1;
 
+// TODO(jackychen): To test different sampling strategy.
+// Collect noise data every NOISE_SUBSAMPLE_INTERVAL blocks.
+#define NOISE_SUBSAMPLE_INTERVAL 41
+
 class NoiseEstimation {
  public:
   void Init(int width, int height, CpuType cpu_type);
+  // Collect noise data from one qualified block.
   void GetNoise(int mb_index, uint32_t var, uint32_t luma);
+  // Reset the counter for consecutive low-var blocks.
   void ResetConsecLowVar(int mb_index);
+  // Update noise level for current frame.
   void UpdateNoiseLevel();
   // 0: low noise, 1: high noise
   uint8_t GetNoiseLevel();
@@ -42,13 +48,13 @@
   int height_;
   int mb_rows_;
   int mb_cols_;
+  int num_noisy_block_;
+  int num_static_block_;
   CpuType cpu_type_;
   uint32_t noise_var_;
   double noise_var_accum_;
-  int num_noisy_block_;
-  int num_static_block_;
   double percent_static_block_;
-  rtc::scoped_ptr<uint32_t[]> consec_low_var_;
+  std::unique_ptr<uint32_t[]> consec_low_var_;
 };
 
 }  // namespace webrtc