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

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

Issue 1154153003: Relanding 1143663007: VideoFrame: Separate Pixel Format from Storage Type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NV12 support in CrOS Created 5 years, 6 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.cc ('k') | media/blink/skcanvas_video_renderer.cc » ('j') | 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 yv12_frame->coded_size().height(), 69 yv12_frame->coded_size().height(),
70 yv12_frame->stride(VideoFrame::kYPlane), 70 yv12_frame->stride(VideoFrame::kYPlane),
71 yv12_frame->stride(VideoFrame::kUPlane), 71 yv12_frame->stride(VideoFrame::kUPlane),
72 bytes_per_row, 72 bytes_per_row,
73 media::YV12); 73 media::YV12);
74 74
75 for (int row = 0; row < yv12_frame->coded_size().height(); ++row) { 75 for (int row = 0; row < yv12_frame->coded_size().height(); ++row) {
76 uint32* rgb_row_data = reinterpret_cast<uint32*>( 76 uint32* rgb_row_data = reinterpret_cast<uint32*>(
77 rgb_data + (bytes_per_row * row)); 77 rgb_data + (bytes_per_row * row));
78 for (int col = 0; col < yv12_frame->coded_size().width(); ++col) { 78 for (int col = 0; col < yv12_frame->coded_size().width(); ++col) {
79 SCOPED_TRACE( 79 SCOPED_TRACE(base::StringPrintf("Checking (%d, %d)", row, col));
80 base::StringPrintf("Checking (%d, %d)", row, col));
81 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); 80 EXPECT_EQ(expect_rgb_color, rgb_row_data[col]);
82 } 81 }
83 } 82 }
84 83
85 base::AlignedFree(rgb_data); 84 base::AlignedFree(rgb_data);
86 } 85 }
87 86
88 // Fill each plane to its reported extents and verify accessors report non 87 // Fill each plane to its reported extents and verify accessors report non
89 // zero values. Additionally, for the first plane verify the rows and 88 // zero values. Additionally, for the first plane verify the rows and
90 // row_bytes values are correct. 89 // row_bytes values are correct.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 { 253 {
255 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( 254 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture(
256 gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */), 255 gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */),
257 base::Bind(&TextureCallback, &called_sync_point), 256 base::Bind(&TextureCallback, &called_sync_point),
258 gfx::Size(10, 10), // coded_size 257 gfx::Size(10, 10), // coded_size
259 gfx::Rect(10, 10), // visible_rect 258 gfx::Rect(10, 10), // visible_rect
260 gfx::Size(10, 10), // natural_size 259 gfx::Size(10, 10), // natural_size
261 base::TimeDelta(), // timestamp 260 base::TimeDelta(), // timestamp
262 false, // allow_overlay 261 false, // allow_overlay
263 true); // has_alpha 262 true); // has_alpha
264 EXPECT_EQ(VideoFrame::TEXTURE_RGBA, frame->texture_format()); 263 EXPECT_EQ(VideoFrame::STORAGE_TEXTURE, frame->storage_type());
264 EXPECT_EQ(VideoFrame::ARGB, frame->format());
265 } 265 }
266 // Nobody set a sync point to |frame|, so |frame| set |called_sync_point| to 0 266 // Nobody set a sync point to |frame|, so |frame| set |called_sync_point| to 0
267 // as default value. 267 // as default value.
268 EXPECT_EQ(0u, called_sync_point); 268 EXPECT_EQ(0u, called_sync_point);
269 } 269 }
270 270
271 namespace { 271 namespace {
272 272
273 class SyncPointClientImpl : public VideoFrame::SyncPointClient { 273 class SyncPointClientImpl : public VideoFrame::SyncPointClient {
274 public: 274 public:
(...skipping 28 matching lines...) Expand all
303 gpu::MailboxHolder(mailbox[VideoFrame::kYPlane], target, sync_point), 303 gpu::MailboxHolder(mailbox[VideoFrame::kYPlane], target, sync_point),
304 gpu::MailboxHolder(mailbox[VideoFrame::kUPlane], target, sync_point), 304 gpu::MailboxHolder(mailbox[VideoFrame::kUPlane], target, sync_point),
305 gpu::MailboxHolder(mailbox[VideoFrame::kVPlane], target, sync_point), 305 gpu::MailboxHolder(mailbox[VideoFrame::kVPlane], target, sync_point),
306 base::Bind(&TextureCallback, &called_sync_point), 306 base::Bind(&TextureCallback, &called_sync_point),
307 gfx::Size(10, 10), // coded_size 307 gfx::Size(10, 10), // coded_size
308 gfx::Rect(10, 10), // visible_rect 308 gfx::Rect(10, 10), // visible_rect
309 gfx::Size(10, 10), // natural_size 309 gfx::Size(10, 10), // natural_size
310 base::TimeDelta(), // timestamp 310 base::TimeDelta(), // timestamp
311 false); // allow_overlay 311 false); // allow_overlay
312 312
313 EXPECT_EQ(VideoFrame::TEXTURE_YUV_420, frame->texture_format()); 313 EXPECT_EQ(VideoFrame::STORAGE_TEXTURE, frame->storage_type());
314 EXPECT_EQ(3u, VideoFrame::NumTextures(frame->texture_format())); 314 EXPECT_EQ(VideoFrame::I420, frame->format());
315 for (size_t i = 0; i < VideoFrame::NumTextures(frame->texture_format()); 315 EXPECT_EQ(3u, VideoFrame::NumPlanes(frame->format()));
316 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format());
316 ++i) { 317 ++i) {
317 const gpu::MailboxHolder& mailbox_holder = frame->mailbox_holder(i); 318 const gpu::MailboxHolder& mailbox_holder = frame->mailbox_holder(i);
318 EXPECT_EQ(mailbox[i].name[0], mailbox_holder.mailbox.name[0]); 319 EXPECT_EQ(mailbox[i].name[0], mailbox_holder.mailbox.name[0]);
319 EXPECT_EQ(target, mailbox_holder.texture_target); 320 EXPECT_EQ(target, mailbox_holder.texture_target);
320 EXPECT_EQ(sync_point, mailbox_holder.sync_point); 321 EXPECT_EQ(sync_point, mailbox_holder.sync_point);
321 } 322 }
322 323
323 SyncPointClientImpl client(release_sync_point); 324 SyncPointClientImpl client(release_sync_point);
324 frame->UpdateReleaseSyncPoint(&client); 325 frame->UpdateReleaseSyncPoint(&client);
325 EXPECT_EQ(sync_point, 326 EXPECT_EQ(sync_point,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 422
422 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { 423 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
423 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); 424 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
424 int value = -1; 425 int value = -1;
425 EXPECT_TRUE(result.GetInteger(key, &value)); 426 EXPECT_TRUE(result.GetInteger(key, &value));
426 EXPECT_EQ(i, value); 427 EXPECT_EQ(i, value);
427 } 428 }
428 } 429 }
429 430
430 } // namespace media 431 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | media/blink/skcanvas_video_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698