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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); | 81 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 base::AlignedFree(rgb_data); | 85 base::AlignedFree(rgb_data); |
86 } | 86 } |
87 | 87 |
88 // Fill each plane to its reported extents and verify accessors report non | 88 // Fill each plane to its reported extents and verify accessors report non |
89 // zero values. Additionally, for the first plane verify the rows and | 89 // zero values. Additionally, for the first plane verify the rows and |
90 // row_bytes values are correct. | 90 // row_bytes values are correct. |
91 void ExpectFrameExtents(VideoFrame::Format format, int planes, | 91 void ExpectFrameExtents(VideoFrame::Format format, |
92 int bytes_per_pixel, const char* expected_hash) { | 92 int planes, |
93 const char* expected_hash) { | |
93 const unsigned char kFillByte = 0x80; | 94 const unsigned char kFillByte = 0x80; |
94 const int kWidth = 61; | 95 const int kWidth = 61; |
95 const int kHeight = 31; | 96 const int kHeight = 31; |
96 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); | 97 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); |
97 | 98 |
98 gfx::Size size(kWidth, kHeight); | 99 gfx::Size size(kWidth, kHeight); |
99 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( | 100 scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( |
100 format, size, gfx::Rect(size), size, kTimestamp); | 101 format, size, gfx::Rect(size), size, kTimestamp); |
101 ASSERT_TRUE(frame.get()); | 102 ASSERT_TRUE(frame.get()); |
102 | 103 |
103 for(int plane = 0; plane < planes; plane++) { | 104 for(int plane = 0; plane < planes; plane++) { |
104 SCOPED_TRACE(base::StringPrintf("Checking plane %d", plane)); | 105 SCOPED_TRACE(base::StringPrintf("Checking plane %d", plane)); |
105 EXPECT_TRUE(frame->data(plane)); | 106 EXPECT_TRUE(frame->data(plane)); |
106 EXPECT_TRUE(frame->stride(plane)); | 107 EXPECT_TRUE(frame->stride(plane)); |
107 EXPECT_TRUE(frame->rows(plane)); | 108 EXPECT_TRUE(frame->rows(plane)); |
108 EXPECT_TRUE(frame->row_bytes(plane)); | 109 EXPECT_TRUE(frame->row_bytes(plane)); |
109 | 110 |
110 if (plane == 0) { | |
Ami GONE FROM CHROMIUM
2014/02/28 23:17:32
Why this change?
sheu
2014/03/01 01:56:57
VideoFrame::CreateFrame() can pad the coded_size o
| |
111 EXPECT_EQ(frame->rows(plane), kHeight); | |
112 EXPECT_EQ(frame->row_bytes(plane), kWidth * bytes_per_pixel); | |
113 } | |
114 | |
115 memset(frame->data(plane), kFillByte, | 111 memset(frame->data(plane), kFillByte, |
116 frame->stride(plane) * frame->rows(plane)); | 112 frame->stride(plane) * frame->rows(plane)); |
117 } | 113 } |
118 | 114 |
119 base::MD5Context context; | 115 base::MD5Context context; |
120 base::MD5Init(&context); | 116 base::MD5Init(&context); |
121 frame->HashFrameForTesting(&context); | 117 frame->HashFrameForTesting(&context); |
122 base::MD5Digest digest; | 118 base::MD5Digest digest; |
123 base::MD5Final(&digest, &context); | 119 base::MD5Final(&digest, &context); |
124 EXPECT_EQ(MD5DigestToBase16(digest), expected_hash); | 120 EXPECT_EQ(MD5DigestToBase16(digest), expected_hash); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 v_plane += frame->stride(VideoFrame::kVPlane); | 195 v_plane += frame->stride(VideoFrame::kVPlane); |
200 } | 196 } |
201 } | 197 } |
202 | 198 |
203 // Ensure each frame is properly sized and allocated. Will trigger OOB reads | 199 // Ensure each frame is properly sized and allocated. Will trigger OOB reads |
204 // and writes as well as incorrect frame hashes otherwise. | 200 // and writes as well as incorrect frame hashes otherwise. |
205 TEST(VideoFrame, CheckFrameExtents) { | 201 TEST(VideoFrame, CheckFrameExtents) { |
206 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel, | 202 // Each call consists of a VideoFrame::Format, # of planes, bytes per pixel, |
207 // and the expected hash of all planes if filled with kFillByte (defined in | 203 // and the expected hash of all planes if filled with kFillByte (defined in |
208 // ExpectFrameExtents). | 204 // ExpectFrameExtents). |
209 ExpectFrameExtents( | 205 ExpectFrameExtents(VideoFrame::YV12, 3, "8e5d54cb23cd0edca111dd35ffb6ff05"); |
210 VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); | 206 ExpectFrameExtents(VideoFrame::YV16, 3, "cce408a044b212db42a10dfec304b3ef"); |
Ami GONE FROM CHROMIUM
2014/02/28 23:17:32
why these changes?
(does this mean a bug was hidin
sheu
2014/03/01 01:56:57
Nope; we're padding out coded_size now so there's
| |
211 ExpectFrameExtents( | |
212 VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); | |
213 } | 207 } |
214 | 208 |
215 static void TextureCallback(uint32* called_sync_point, | 209 static void TextureCallback(uint32* called_sync_point, |
216 scoped_ptr<gpu::MailboxHolder> mailbox_holder) { | 210 scoped_ptr<gpu::MailboxHolder> mailbox_holder) { |
217 *called_sync_point = mailbox_holder->sync_point; | 211 *called_sync_point = mailbox_holder->sync_point; |
218 } | 212 } |
219 | 213 |
220 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is | 214 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is |
221 // destroyed with the original sync point. | 215 // destroyed with the original sync point. |
222 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { | 216 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 EXPECT_EQ(sync_point, mailbox_holder->sync_point); | 259 EXPECT_EQ(sync_point, mailbox_holder->sync_point); |
266 | 260 |
267 // Finish using the mailbox_holder and drop our reference. | 261 // Finish using the mailbox_holder and drop our reference. |
268 sync_point = 10; | 262 sync_point = 10; |
269 mailbox_holder->sync_point = sync_point; | 263 mailbox_holder->sync_point = sync_point; |
270 } | 264 } |
271 EXPECT_EQ(sync_point, called_sync_point); | 265 EXPECT_EQ(sync_point, called_sync_point); |
272 } | 266 } |
273 | 267 |
274 } // namespace media | 268 } // namespace media |
OLD | NEW |