OLD | NEW |
---|---|
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 Loading... | |
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 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i) | |
mcasas
2015/09/05 01:29:25
nit: please add a TODO to extend this part here
to
emircan
2015/09/05 01:39:50
Done.
| |
176 EXPECT_EQ(0, frame->data(i)[0]); | |
177 } | |
178 | |
161 TEST(VideoFrame, CreateBlackFrame) { | 179 TEST(VideoFrame, CreateBlackFrame) { |
162 const int kWidth = 2; | 180 const int kWidth = 2; |
163 const int kHeight = 2; | 181 const int kHeight = 2; |
164 const uint8 kExpectedYRow[] = { 0, 0 }; | 182 const uint8 kExpectedYRow[] = { 0, 0 }; |
165 const uint8 kExpectedUVRow[] = { 128 }; | 183 const uint8 kExpectedUVRow[] = { 128 }; |
166 | 184 |
167 scoped_refptr<media::VideoFrame> frame = | 185 scoped_refptr<media::VideoFrame> frame = |
168 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight)); | 186 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight)); |
169 ASSERT_TRUE(frame.get()); | 187 ASSERT_TRUE(frame.get()); |
170 EXPECT_TRUE(frame->IsMappable()); | 188 EXPECT_TRUE(frame->IsMappable()); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 | 472 |
455 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { | 473 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { |
456 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); | 474 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); |
457 int value = -1; | 475 int value = -1; |
458 EXPECT_TRUE(result.GetInteger(key, &value)); | 476 EXPECT_TRUE(result.GetInteger(key, &value)); |
459 EXPECT_EQ(i, value); | 477 EXPECT_EQ(i, value); |
460 } | 478 } |
461 } | 479 } |
462 | 480 |
463 } // namespace media | 481 } // namespace media |
OLD | NEW |