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

Side by Side Diff: media/base/video_frame_unittest.cc

Issue 1313413010: Add VideoFrame::CreateZeroInitializedFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « media/base/video_frame_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 VideoFrame::HashFrameForTesting(&context, frame); 151 VideoFrame::HashFrameForTesting(&context, frame);
152 base::MD5Final(&digest, &context); 152 base::MD5Final(&digest, &context);
153 EXPECT_EQ(MD5DigestToBase16(digest), "911991d51438ad2e1a40ed5f6fc7c796"); 153 EXPECT_EQ(MD5DigestToBase16(digest), "911991d51438ad2e1a40ed5f6fc7c796");
154 154
155 // Test an empty frame. 155 // Test an empty frame.
156 frame = VideoFrame::CreateEOSFrame(); 156 frame = VideoFrame::CreateEOSFrame();
157 EXPECT_TRUE( 157 EXPECT_TRUE(
158 frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM)); 158 frame->metadata()->IsTrue(VideoFrameMetadata::END_OF_STREAM));
159 } 159 }
160 160
161 TEST(VideoFrame, CreateZeroInitializedFrame) {
162 const int kWidth = 2;
163 const int kHeight = 2;
164 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337);
165
166 // Create a YV12 Video Frame.
167 gfx::Size size(kWidth, kHeight);
168 scoped_refptr<media::VideoFrame> frame =
169 VideoFrame::CreateZeroInitializedFrame(media::PIXEL_FORMAT_YV12, size,
170 gfx::Rect(size), size, kTimestamp);
171 ASSERT_TRUE(frame.get());
172 EXPECT_TRUE(frame->IsMappable());
173
174 // Verify that frame is initialized with zeros.
175 // TODO(emircan): Check all the contents when we know the exact size of the
176 // allocated buffer.
177 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i)
178 EXPECT_EQ(0, frame->data(i)[0]);
179 }
180
161 TEST(VideoFrame, CreateBlackFrame) { 181 TEST(VideoFrame, CreateBlackFrame) {
162 const int kWidth = 2; 182 const int kWidth = 2;
163 const int kHeight = 2; 183 const int kHeight = 2;
164 const uint8 kExpectedYRow[] = { 0, 0 }; 184 const uint8 kExpectedYRow[] = { 0, 0 };
165 const uint8 kExpectedUVRow[] = { 128 }; 185 const uint8 kExpectedUVRow[] = { 128 };
166 186
167 scoped_refptr<media::VideoFrame> frame = 187 scoped_refptr<media::VideoFrame> frame =
168 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight)); 188 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight));
169 ASSERT_TRUE(frame.get()); 189 ASSERT_TRUE(frame.get());
170 EXPECT_TRUE(frame->IsMappable()); 190 EXPECT_TRUE(frame->IsMappable());
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 474
455 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { 475 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
456 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); 476 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
457 int value = -1; 477 int value = -1;
458 EXPECT_TRUE(result.GetInteger(key, &value)); 478 EXPECT_TRUE(result.GetInteger(key, &value));
459 EXPECT_EQ(i, value); 479 EXPECT_EQ(i, value);
460 } 480 }
461 } 481 }
462 482
463 } // namespace media 483 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698