Score flat blocks and always return some.

Adding score of flat blocks so that we can return some flat
blocks in the extremely noisy cases. This is a no-op for easier cases.

Change-Id: I99387a642bc84ceb468e5360d3e023735f693843
diff --git a/test/noise_model_test.cc b/test/noise_model_test.cc
index 72aa840..d9869ac 100644
--- a/test/noise_model_test.cc
+++ b/test/noise_model_test.cc
@@ -286,7 +286,7 @@
 template <typename T>
 class FlatBlockEstimatorTest : public ::testing::Test, public T {
  public:
-  virtual void SetUp() { random_.Reset(1071); }
+  virtual void SetUp() { random_.Reset(171); }
   typedef std::vector<typename T::data_type_t> VecType;
   VecType data_;
   libaom_test::ACMRandom random_;
@@ -409,12 +409,34 @@
   EXPECT_EQ(0, flat_blocks[1]);
 
   // Next 4 blocks are flat.
-  EXPECT_NE(0, flat_blocks[2]);
-  EXPECT_NE(0, flat_blocks[3]);
-  EXPECT_NE(0, flat_blocks[4]);
-  EXPECT_NE(0, flat_blocks[5]);
+  EXPECT_EQ(255, flat_blocks[2]);
+  EXPECT_EQ(255, flat_blocks[3]);
+  EXPECT_EQ(255, flat_blocks[4]);
+  EXPECT_EQ(255, flat_blocks[5]);
 
-  // Last 2 are not.
+  // Last 2 are not flat by threshold
+  EXPECT_EQ(0, flat_blocks[6]);
+  EXPECT_EQ(0, flat_blocks[7]);
+
+  // Add the noise from non-flat block 1 to every block.
+  for (int y = 0; y < kBlockSize; ++y) {
+    for (int x = 0; x < kBlockSize * num_blocks_w; ++x) {
+      this->data_[y * stride + x] +=
+          (this->data_[y * stride + x % kBlockSize + kBlockSize] -
+           (128 << shift));
+    }
+  }
+  // Now the scored selection will pick the one that is most likely flat (block
+  // 0)
+  EXPECT_EQ(1, aom_flat_block_finder_run(&flat_block_finder,
+                                         (uint8_t *)&this->data_[0], w, h,
+                                         stride, &flat_blocks[0]));
+  EXPECT_EQ(1, flat_blocks[0]);
+  EXPECT_EQ(0, flat_blocks[1]);
+  EXPECT_EQ(0, flat_blocks[2]);
+  EXPECT_EQ(0, flat_blocks[3]);
+  EXPECT_EQ(0, flat_blocks[4]);
+  EXPECT_EQ(0, flat_blocks[5]);
   EXPECT_EQ(0, flat_blocks[6]);
   EXPECT_EQ(0, flat_blocks[7]);