summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-22 21:38:13 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-22 21:38:13 +0000
commitf41082b7d8738ae92583cd5e5a1ccd68d6b195b7 (patch)
tree37faabaa734478af9814e0619de8c8e14bcd073d /media/base
parent83f48280ce81f40ad442a0618ac2579370f49a06 (diff)
downloadchromium_src-f41082b7d8738ae92583cd5e5a1ccd68d6b195b7.zip
chromium_src-f41082b7d8738ae92583cd5e5a1ccd68d6b195b7.tar.gz
chromium_src-f41082b7d8738ae92583cd5e5a1ccd68d6b195b7.tar.bz2
Fix frame hashing to include all valid planes.
Moves the frame hashing code from PipelineIntegrationTestBase to VideoFrame per suggestions in: https://chromiumcodereview.appspot.com/9716008/ Also disables frame hashing for BasicPlayback since it's failing on the TSAN bots. The code is still enabled for ffmpeg_regression_tests. BUG=118688 TEST=media_unittests, ffmpeg_regression_tests. Review URL: http://codereview.chromium.org/9732016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/video_frame.cc13
-rw-r--r--media/base/video_frame.h5
-rw-r--r--media/base/video_frame_unittest.cc14
3 files changed, 31 insertions, 1 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index fc97736..750c2770 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -5,6 +5,7 @@
#include "media/base/video_frame.h"
#include "base/logging.h"
+#include "base/string_piece.h"
#include "media/base/limits.h"
#include "media/base/video_util.h"
@@ -272,4 +273,16 @@ bool VideoFrame::IsEndOfStream() const {
return format_ == VideoFrame::EMPTY;
}
+void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
+ for(int plane = 0; plane < kMaxPlanes; plane++) {
+ if (!IsValidPlane(plane))
+ break;
+ for(int row = 0; row < rows(plane); row++) {
+ base::MD5Update(context, base::StringPiece(
+ reinterpret_cast<char*>(data(plane) + stride(plane) * row),
+ row_bytes(plane)));
+ }
+ }
+}
+
} // namespace media
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index f65bf23..073fa93 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -6,6 +6,7 @@
#define MEDIA_BASE_VIDEO_FRAME_H_
#include "base/callback.h"
+#include "base/md5.h"
#include "media/base/buffers.h"
namespace media {
@@ -106,6 +107,10 @@ class MEDIA_EXPORT VideoFrame : public StreamSample {
// StreamSample interface.
virtual bool IsEndOfStream() const OVERRIDE;
+ // Used to keep a running hash of seen frames. Expects an initialized MD5
+ // context. Calls MD5Update with the context and the contents of the frame.
+ void HashFrameForTesting(base::MD5Context* context);
+
private:
// Clients must use the static CreateFrame() method to create a new frame.
VideoFrame(Format format,
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc
index d90469b..5a6c0cd 100644
--- a/media/base/video_frame_unittest.cc
+++ b/media/base/video_frame_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,6 +14,8 @@
namespace media {
+using base::MD5DigestToBase16;
+
// Helper function that initializes a YV12 frame with white and black scan
// lines based on the |white_to_black| parameter. If 0, then the entire
// frame will be black, if 1 then the entire frame will be white.
@@ -112,11 +114,21 @@ TEST(VideoFrame, CreateFrame) {
InitializeYV12Frame(frame, 0.0f);
ExpectFrameColor(frame, 0xFF000000);
}
+ base::MD5Digest digest;
+ base::MD5Context context;
+ base::MD5Init(&context);
+ frame->HashFrameForTesting(&context);
+ base::MD5Final(&digest, &context);
+ EXPECT_EQ(MD5DigestToBase16(digest), "9065c841d9fca49186ef8b4ef547e79b");
{
SCOPED_TRACE("");
InitializeYV12Frame(frame, 1.0f);
ExpectFrameColor(frame, 0xFFFFFFFF);
}
+ base::MD5Init(&context);
+ frame->HashFrameForTesting(&context);
+ base::MD5Final(&digest, &context);
+ EXPECT_EQ(MD5DigestToBase16(digest), "911991d51438ad2e1a40ed5f6fc7c796");
// Test an empty frame.
frame = VideoFrame::CreateEmptyFrame();