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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 const int kWidth = 4; | 210 const int kWidth = 4; |
211 const int kHeight = 4; | 211 const int kHeight = 4; |
212 scoped_refptr<media::VideoFrame> frame; | 212 scoped_refptr<media::VideoFrame> frame; |
213 bool no_longer_needed_triggered = false; | 213 bool no_longer_needed_triggered = false; |
214 { | 214 { |
215 scoped_refptr<media::VideoFrame> wrapped_frame = | 215 scoped_refptr<media::VideoFrame> wrapped_frame = |
216 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight)); | 216 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight)); |
217 ASSERT_TRUE(wrapped_frame.get()); | 217 ASSERT_TRUE(wrapped_frame.get()); |
218 | 218 |
219 gfx::Rect visible_rect(1, 1, 1, 1); | 219 gfx::Rect visible_rect(1, 1, 1, 1); |
| 220 gfx::Size natural_size = visible_rect.size(); |
220 frame = media::VideoFrame::WrapVideoFrame( | 221 frame = media::VideoFrame::WrapVideoFrame( |
221 wrapped_frame, visible_rect, | 222 wrapped_frame, visible_rect, natural_size, |
222 base::Bind(&FrameNoLongerNeededCallback, wrapped_frame, | 223 base::Bind(&FrameNoLongerNeededCallback, wrapped_frame, |
223 &no_longer_needed_triggered)); | 224 &no_longer_needed_triggered)); |
224 EXPECT_EQ(wrapped_frame->coded_size(), frame->coded_size()); | 225 EXPECT_EQ(wrapped_frame->coded_size(), frame->coded_size()); |
225 EXPECT_EQ(wrapped_frame->data(media::VideoFrame::kYPlane), | 226 EXPECT_EQ(wrapped_frame->data(media::VideoFrame::kYPlane), |
226 frame->data(media::VideoFrame::kYPlane)); | 227 frame->data(media::VideoFrame::kYPlane)); |
227 EXPECT_NE(wrapped_frame->visible_rect(), frame->visible_rect()); | 228 EXPECT_NE(wrapped_frame->visible_rect(), frame->visible_rect()); |
228 EXPECT_EQ(visible_rect, frame->visible_rect()); | 229 EXPECT_EQ(visible_rect, frame->visible_rect()); |
| 230 EXPECT_NE(wrapped_frame->natural_size(), frame->natural_size()); |
| 231 EXPECT_EQ(natural_size, frame->natural_size()); |
229 } | 232 } |
230 | 233 |
231 EXPECT_FALSE(no_longer_needed_triggered); | 234 EXPECT_FALSE(no_longer_needed_triggered); |
232 frame = NULL; | 235 frame = NULL; |
233 EXPECT_TRUE(no_longer_needed_triggered); | 236 EXPECT_TRUE(no_longer_needed_triggered); |
234 } | 237 } |
235 | 238 |
236 // Ensure each frame is properly sized and allocated. Will trigger OOB reads | 239 // Ensure each frame is properly sized and allocated. Will trigger OOB reads |
237 // and writes as well as incorrect frame hashes otherwise. | 240 // and writes as well as incorrect frame hashes otherwise. |
238 TEST(VideoFrame, CheckFrameExtents) { | 241 TEST(VideoFrame, CheckFrameExtents) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 EXPECT_EQ(sync_point, mailbox_holder->sync_point); | 301 EXPECT_EQ(sync_point, mailbox_holder->sync_point); |
299 | 302 |
300 // Finish using the mailbox_holder and drop our reference. | 303 // Finish using the mailbox_holder and drop our reference. |
301 sync_point = 10; | 304 sync_point = 10; |
302 mailbox_holder->sync_point = sync_point; | 305 mailbox_holder->sync_point = sync_point; |
303 } | 306 } |
304 EXPECT_EQ(sync_point, called_sync_point); | 307 EXPECT_EQ(sync_point, called_sync_point); |
305 } | 308 } |
306 | 309 |
307 } // namespace media | 310 } // namespace media |
OLD | NEW |