Revert 7121 "ValidateFrame, When dumping the first 4 samples of a frame, first copy it to a temporary buffer that is zero padded, them use that."

Breaks other repos.

TBR=fbarchard@google.com
BUG=N/A

Review URL: https://webrtc-codereview.appspot.com/23639004

git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@7170 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/media/base/videoframe.cc b/media/base/videoframe.cc
index 018d065..1c5cfd8 100644
--- a/media/base/videoframe.cc
+++ b/media/base/videoframe.cc
@@ -235,7 +235,7 @@
 }
 
 static const size_t kMaxSampleSize = 1000000000u;
-// Returns whether a sample is valid.
+// Returns whether a sample is valid
 bool VideoFrame::Validate(uint32 fourcc, int w, int h,
                           const uint8 *sample, size_t sample_size) {
   if (h < 0) {
@@ -311,11 +311,6 @@
                   << " " << sample_size;
     return false;
   }
-  // TODO(fbarchard): Make function to dump information about frames.
-  uint8 four_samples[4] = { 0, 0, 0, 0 };
-  for (size_t i = 0; i < ARRAY_SIZE(four_samples) && i < sample_size; ++i) {
-    four_samples[i] = sample[i];
-  }
   if (sample_size < expected_size) {
     LOG(LS_ERROR) << "Size field is too small."
                   << " format: " << GetFourccName(format)
@@ -323,10 +318,10 @@
                   << " size: " << w << "x" << h
                   << " " << sample_size
                   << " expected: " << expected_size
-                  << " sample[0..3]: " << static_cast<int>(four_samples[0])
-                  << ", " << static_cast<int>(four_samples[1])
-                  << ", " << static_cast<int>(four_samples[2])
-                  << ", " << static_cast<int>(four_samples[3]);
+                  << " sample[0..3]: " << static_cast<int>(sample[0])
+                  << ", " << static_cast<int>(sample[1])
+                  << ", " << static_cast<int>(sample[2])
+                  << ", " << static_cast<int>(sample[3]);
     return false;
   }
   if (sample_size > kMaxSampleSize) {
@@ -336,14 +331,13 @@
                     << " size: " << w << "x" << h
                     << " " << sample_size
                     << " expected: " << 2 * expected_size
-                    << " sample[0..3]: " << static_cast<int>(four_samples[0])
-                    << ", " << static_cast<int>(four_samples[1])
-                    << ", " << static_cast<int>(four_samples[2])
-                    << ", " << static_cast<int>(four_samples[3]);
+                    << " sample[0..3]: " << static_cast<int>(sample[0])
+                    << ", " << static_cast<int>(sample[1])
+                    << ", " << static_cast<int>(sample[2])
+                    << ", " << static_cast<int>(sample[3]);
     return false;
   }
   // Show large size warning once every 100 frames.
-  // TODO(fbarchard): Make frame counter atomic for thread safety.
   static int large_warn100 = 0;
   size_t large_expected_size = expected_size * 2;
   if (expected_bpp >= 8 &&
@@ -356,14 +350,27 @@
                     << " size: " << w << "x" << h
                     << " bytes: " << sample_size
                     << " expected: " << large_expected_size
-                    << " sample[0..3]: " << static_cast<int>(four_samples[0])
-                    << ", " << static_cast<int>(four_samples[1])
-                    << ", " << static_cast<int>(four_samples[2])
-                    << ", " << static_cast<int>(four_samples[3]);
+                    << " sample[0..3]: " << static_cast<int>(sample[0])
+                    << ", " << static_cast<int>(sample[1])
+                    << ", " << static_cast<int>(sample[2])
+                    << ", " << static_cast<int>(sample[3]);
+  }
+  // Scan pages to ensure they are there and don't contain a single value and
+  // to generate an error.
+  if (!memcmp(sample + sample_size - 8, sample + sample_size - 4, 4) &&
+      !memcmp(sample, sample + 4, sample_size - 4)) {
+    LOG(LS_WARNING) << "Duplicate value for all pixels."
+                    << " format: " << GetFourccName(format)
+                    << " bpp: " << expected_bpp
+                    << " size: " << w << "x" << h
+                    << " bytes: " << sample_size
+                    << " expected: " << expected_size
+                    << " sample[0..3]: " << static_cast<int>(sample[0])
+                    << ", " << static_cast<int>(sample[1])
+                    << ", " << static_cast<int>(sample[2])
+                    << ", " << static_cast<int>(sample[3]);
   }
 
-  // TODO(fbarchard): Add duplicate pixel check.
-  // TODO(fbarchard): Use frame counter atomic for thread safety.
   static bool valid_once = true;
   if (valid_once) {
     valid_once = false;
@@ -373,10 +380,10 @@
                  << " size: " << w << "x" << h
                  << " bytes: " << sample_size
                  << " expected: " << expected_size
-                 << " sample[0..3]: " << static_cast<int>(four_samples[0])
-                 << ", " << static_cast<int>(four_samples[1])
-                 << ", " << static_cast<int>(four_samples[2])
-                 << ", " << static_cast<int>(four_samples[3]);
+                 << " sample[0..3]: " << static_cast<int>(sample[0])
+                 << ", " << static_cast<int>(sample[1])
+                 << ", " << static_cast<int>(sample[2])
+                 << ", " << static_cast<int>(sample[3]);
   }
   return true;
 }