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

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

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use the texture target in the hardware video frame Created 7 years, 8 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 | Annotate | Revision Log
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 visible_rect.right() <= coded_size.width() && 56 visible_rect.right() <= coded_size.width() &&
57 visible_rect.bottom() <= coded_size.height() && 57 visible_rect.bottom() <= coded_size.height() &&
58 !natural_size.IsEmpty() && 58 !natural_size.IsEmpty() &&
59 natural_size.GetArea() <= limits::kMaxCanvas && 59 natural_size.GetArea() <= limits::kMaxCanvas &&
60 natural_size.width() <= limits::kMaxDimension && 60 natural_size.width() <= limits::kMaxDimension &&
61 natural_size.height() <= limits::kMaxDimension); 61 natural_size.height() <= limits::kMaxDimension);
62 } 62 }
63 63
64 // static 64 // static
65 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( 65 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture(
66 uint32 texture_id, 66 const gpu::Mailbox& texture_mailbox,
67 uint32 sync_point,
67 uint32 texture_target, 68 uint32 texture_target,
68 const gfx::Size& coded_size, 69 const gfx::Size& coded_size,
69 const gfx::Rect& visible_rect, 70 const gfx::Rect& visible_rect,
70 const gfx::Size& natural_size, 71 const gfx::Size& natural_size,
71 base::TimeDelta timestamp, 72 base::TimeDelta timestamp,
72 const ReadPixelsCB& read_pixels_cb, 73 const ReadPixelsCB& read_pixels_cb,
74 const TextureNoLongerNeededCallback& texture_no_longer_needed_cb,
73 const base::Closure& no_longer_needed_cb) { 75 const base::Closure& no_longer_needed_cb) {
74 scoped_refptr<VideoFrame> frame(new VideoFrame( 76 scoped_refptr<VideoFrame> frame(new VideoFrame(
75 NATIVE_TEXTURE, coded_size, visible_rect, natural_size, timestamp)); 77 NATIVE_TEXTURE, coded_size, visible_rect, natural_size, timestamp));
76 frame->texture_id_ = texture_id; 78 frame->texture_mailbox_ = texture_mailbox;
79 frame->texture_mailbox_sync_point_ = sync_point;
77 frame->texture_target_ = texture_target; 80 frame->texture_target_ = texture_target;
78 frame->read_pixels_cb_ = read_pixels_cb; 81 frame->read_pixels_cb_ = read_pixels_cb;
79 frame->no_longer_needed_cb_ = no_longer_needed_cb; 82 frame->no_longer_needed_cb_ = no_longer_needed_cb;
83 frame->texture_no_longer_needed_cb_ = texture_no_longer_needed_cb;
80 return frame; 84 return frame;
81 } 85 }
82 86
83 void VideoFrame::ReadPixelsFromNativeTexture(const SkBitmap& pixels) { 87 void VideoFrame::ReadPixelsFromNativeTexture(const SkBitmap& pixels) {
84 DCHECK_EQ(format_, NATIVE_TEXTURE); 88 DCHECK_EQ(format_, NATIVE_TEXTURE);
85 if (!read_pixels_cb_.is_null()) 89 if (!read_pixels_cb_.is_null())
86 read_pixels_cb_.Run(pixels); 90 read_pixels_cb_.Run(pixels);
87 } 91 }
88 92
89 // static 93 // static
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 250
247 VideoFrame::VideoFrame(VideoFrame::Format format, 251 VideoFrame::VideoFrame(VideoFrame::Format format,
248 const gfx::Size& coded_size, 252 const gfx::Size& coded_size,
249 const gfx::Rect& visible_rect, 253 const gfx::Rect& visible_rect,
250 const gfx::Size& natural_size, 254 const gfx::Size& natural_size,
251 base::TimeDelta timestamp) 255 base::TimeDelta timestamp)
252 : format_(format), 256 : format_(format),
253 coded_size_(coded_size), 257 coded_size_(coded_size),
254 visible_rect_(visible_rect), 258 visible_rect_(visible_rect),
255 natural_size_(natural_size), 259 natural_size_(natural_size),
256 texture_id_(0),
257 texture_target_(0), 260 texture_target_(0),
258 timestamp_(timestamp) { 261 timestamp_(timestamp) {
scherkus (not reviewing) 2013/04/19 23:32:07 init texture_mailbox_sync_point_ to some sort of k
danakj 2013/04/19 23:52:07 Done.
259 memset(&strides_, 0, sizeof(strides_)); 262 memset(&strides_, 0, sizeof(strides_));
260 memset(&data_, 0, sizeof(data_)); 263 memset(&data_, 0, sizeof(data_));
261 } 264 }
262 265
263 VideoFrame::~VideoFrame() { 266 VideoFrame::~VideoFrame() {
267 if (!texture_no_longer_needed_cb_.is_null()) {
268 base::ResetAndReturn(&texture_no_longer_needed_cb_).Run(
269 texture_mailbox_sync_point_);
270 }
264 if (!no_longer_needed_cb_.is_null()) 271 if (!no_longer_needed_cb_.is_null())
265 base::ResetAndReturn(&no_longer_needed_cb_).Run(); 272 base::ResetAndReturn(&no_longer_needed_cb_).Run();
266 } 273 }
267 274
268 bool VideoFrame::IsValidPlane(size_t plane) const { 275 bool VideoFrame::IsValidPlane(size_t plane) const {
269 return (plane < NumPlanes(format_)); 276 return (plane < NumPlanes(format_));
270 } 277 }
271 278
272 int VideoFrame::stride(size_t plane) const { 279 int VideoFrame::stride(size_t plane) const {
273 DCHECK(IsValidPlane(plane)); 280 DCHECK(IsValidPlane(plane));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // Intentionally leave out non-production formats. 325 // Intentionally leave out non-production formats.
319 NOTREACHED() << "Unsupported video frame format: " << format_; 326 NOTREACHED() << "Unsupported video frame format: " << format_;
320 return 0; 327 return 0;
321 } 328 }
322 329
323 uint8* VideoFrame::data(size_t plane) const { 330 uint8* VideoFrame::data(size_t plane) const {
324 DCHECK(IsValidPlane(plane)); 331 DCHECK(IsValidPlane(plane));
325 return data_[plane]; 332 return data_[plane];
326 } 333 }
327 334
328 uint32 VideoFrame::texture_id() const { 335 const gpu::Mailbox& VideoFrame::texture_mailbox() const {
329 DCHECK_EQ(format_, NATIVE_TEXTURE); 336 DCHECK_EQ(format_, NATIVE_TEXTURE);
330 return texture_id_; 337 return texture_mailbox_;
338 }
339
340 uint32 VideoFrame::texture_mailbox_sync_point() const {
341 DCHECK_EQ(format_, NATIVE_TEXTURE);
342 return texture_mailbox_sync_point_;
343 }
344
345 void VideoFrame::set_texture_mailbox_sync_point(uint32 sync_point) {
346 DCHECK_EQ(format_, NATIVE_TEXTURE);
347 texture_mailbox_sync_point_ = sync_point;
331 } 348 }
332 349
333 uint32 VideoFrame::texture_target() const { 350 uint32 VideoFrame::texture_target() const {
334 DCHECK_EQ(format_, NATIVE_TEXTURE); 351 DCHECK_EQ(format_, NATIVE_TEXTURE);
335 return texture_target_; 352 return texture_target_;
336 } 353 }
337 354
338 bool VideoFrame::IsEndOfStream() const { 355 bool VideoFrame::IsEndOfStream() const {
339 return format_ == VideoFrame::EMPTY; 356 return format_ == VideoFrame::EMPTY;
340 } 357 }
341 358
342 void VideoFrame::HashFrameForTesting(base::MD5Context* context) { 359 void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
343 for (int plane = 0; plane < kMaxPlanes; ++plane) { 360 for (int plane = 0; plane < kMaxPlanes; ++plane) {
344 if (!IsValidPlane(plane)) 361 if (!IsValidPlane(plane))
345 break; 362 break;
346 for (int row = 0; row < rows(plane); ++row) { 363 for (int row = 0; row < rows(plane); ++row) {
347 base::MD5Update(context, base::StringPiece( 364 base::MD5Update(context, base::StringPiece(
348 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 365 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
349 row_bytes(plane))); 366 row_bytes(plane)));
350 } 367 }
351 } 368 }
352 } 369 }
353 370
354 } // namespace media 371 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698