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

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

Issue 850993002: gpu video: optimize HW video to SW canvas and implement it for WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android build fail Created 5 years, 10 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 | « content/renderer/media/webmediaplayer_ms.cc ('k') | media/base/video_frame.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 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_
6 #define MEDIA_BASE_VIDEO_FRAME_H_ 6 #define MEDIA_BASE_VIDEO_FRAME_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/md5.h" 11 #include "base/md5.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "media/base/buffers.h" 14 #include "media/base/buffers.h"
15 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
17 17
18 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
19 #include <CoreVideo/CVPixelBuffer.h> 19 #include <CoreVideo/CVPixelBuffer.h>
20 #include "base/mac/scoped_cftyperef.h" 20 #include "base/mac/scoped_cftyperef.h"
21 #endif 21 #endif
22 22
23 class SkBitmap;
24
25 namespace gpu { 23 namespace gpu {
26 struct MailboxHolder; 24 struct MailboxHolder;
27 } // namespace gpu 25 } // namespace gpu
28 26
29 namespace media { 27 namespace media {
30 28
31 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { 29 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
32 public: 30 public:
33 enum { 31 enum {
34 kFrameSizeAlignment = 16, 32 kFrameSizeAlignment = 16,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // can be used to DCHECK() plane parameters. 84 // can be used to DCHECK() plane parameters.
87 static bool IsValidPlane(size_t plane, VideoFrame::Format format); 85 static bool IsValidPlane(size_t plane, VideoFrame::Format format);
88 86
89 // Call prior to CreateFrame to ensure validity of frame configuration. Called 87 // Call prior to CreateFrame to ensure validity of frame configuration. Called
90 // automatically by VideoDecoderConfig::IsValidConfig(). 88 // automatically by VideoDecoderConfig::IsValidConfig().
91 // TODO(scherkus): VideoDecoderConfig shouldn't call this method 89 // TODO(scherkus): VideoDecoderConfig shouldn't call this method
92 static bool IsValidConfig(Format format, const gfx::Size& coded_size, 90 static bool IsValidConfig(Format format, const gfx::Size& coded_size,
93 const gfx::Rect& visible_rect, 91 const gfx::Rect& visible_rect,
94 const gfx::Size& natural_size); 92 const gfx::Size& natural_size);
95 93
96 // CB to write pixels from the texture backing this frame into the
97 // |const SkBitmap&| parameter.
98 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB;
99
100 // CB to be called on the mailbox backing this frame when the frame is 94 // CB to be called on the mailbox backing this frame when the frame is
101 // destroyed. 95 // destroyed.
102 typedef base::Callback<void(uint32)> ReleaseMailboxCB; 96 typedef base::Callback<void(uint32)> ReleaseMailboxCB;
103 97
104 // Wraps a native texture of the given parameters with a VideoFrame. The 98 // Wraps a native texture of the given parameters with a VideoFrame. The
105 // backing of the VideoFrame is held in the mailbox held by |mailbox_holder|, 99 // backing of the VideoFrame is held in the mailbox held by |mailbox_holder|,
106 // and |mailbox_holder_release_cb| will be called with |mailbox_holder| as the 100 // and |mailbox_holder_release_cb| will be called with |mailbox_holder| as the
107 // argument when the VideoFrame is to be destroyed. 101 // argument when the VideoFrame is to be destroyed.
108 // |read_pixels_cb| may be used to do (slow!) readbacks from the 102 // |read_pixels_cb| may be used to do (slow!) readbacks from the
109 // texture to main memory. 103 // texture to main memory.
110 static scoped_refptr<VideoFrame> WrapNativeTexture( 104 static scoped_refptr<VideoFrame> WrapNativeTexture(
111 scoped_ptr<gpu::MailboxHolder> mailbox_holder, 105 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
112 const ReleaseMailboxCB& mailbox_holder_release_cb, 106 const ReleaseMailboxCB& mailbox_holder_release_cb,
113 const gfx::Size& coded_size, 107 const gfx::Size& coded_size,
114 const gfx::Rect& visible_rect, 108 const gfx::Rect& visible_rect,
115 const gfx::Size& natural_size, 109 const gfx::Size& natural_size,
116 base::TimeDelta timestamp, 110 base::TimeDelta timestamp,
117 const ReadPixelsCB& read_pixels_cb,
118 bool allow_overlay); 111 bool allow_overlay);
119 112
120 #if !defined(MEDIA_FOR_CAST_IOS)
121 // Read pixels from the native texture backing |*this| and write
122 // them to |pixels| as BGRA. |pixels| must point to a buffer at
123 // least as large as 4 * visible_rect().size().GetArea().
124 void ReadPixelsFromNativeTexture(const SkBitmap& pixels);
125 #endif
126
127 // Wraps packed image data residing in a memory buffer with a VideoFrame. 113 // Wraps packed image data residing in a memory buffer with a VideoFrame.
128 // The image data resides in |data| and is assumed to be packed tightly in a 114 // The image data resides in |data| and is assumed to be packed tightly in a
129 // buffer of logical dimensions |coded_size| with the appropriate bit depth 115 // buffer of logical dimensions |coded_size| with the appropriate bit depth
130 // and plane count as given by |format|. The shared memory handle of the 116 // and plane count as given by |format|. The shared memory handle of the
131 // backing allocation, if present, can be passed in with |handle|. When the 117 // backing allocation, if present, can be passed in with |handle|. When the
132 // frame is destroyed, |no_longer_needed_cb.Run()| will be called. 118 // frame is destroyed, |no_longer_needed_cb.Run()| will be called.
133 // Returns NULL on failure. 119 // Returns NULL on failure.
134 static scoped_refptr<VideoFrame> WrapExternalPackedMemory( 120 static scoped_refptr<VideoFrame> WrapExternalPackedMemory(
135 Format format, 121 Format format,
136 const gfx::Size& coded_size, 122 const gfx::Size& coded_size,
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // of the surface divided by the horizontal sampling period. Note that 371 // of the surface divided by the horizontal sampling period. Note that
386 // strides can be negative. 372 // strides can be negative.
387 int32 strides_[kMaxPlanes]; 373 int32 strides_[kMaxPlanes];
388 374
389 // Array of data pointers to each plane. 375 // Array of data pointers to each plane.
390 uint8* data_[kMaxPlanes]; 376 uint8* data_[kMaxPlanes];
391 377
392 // Native texture mailbox, if this is a NATIVE_TEXTURE frame. 378 // Native texture mailbox, if this is a NATIVE_TEXTURE frame.
393 const scoped_ptr<gpu::MailboxHolder> mailbox_holder_; 379 const scoped_ptr<gpu::MailboxHolder> mailbox_holder_;
394 ReleaseMailboxCB mailbox_holder_release_cb_; 380 ReleaseMailboxCB mailbox_holder_release_cb_;
395 ReadPixelsCB read_pixels_cb_;
396 381
397 // Shared memory handle, if this frame was allocated from shared memory. 382 // Shared memory handle, if this frame was allocated from shared memory.
398 base::SharedMemoryHandle shared_memory_handle_; 383 base::SharedMemoryHandle shared_memory_handle_;
399 384
400 // Offset in shared memory buffer. 385 // Offset in shared memory buffer.
401 size_t shared_memory_offset_; 386 size_t shared_memory_offset_;
402 387
403 #if defined(OS_POSIX) 388 #if defined(OS_POSIX)
404 // Dmabufs for each plane, if this frame is wrapping memory 389 // Dmabufs for each plane, if this frame is wrapping memory
405 // acquired via dmabuf. 390 // acquired via dmabuf.
(...skipping 15 matching lines...) Expand all
421 const bool end_of_stream_; 406 const bool end_of_stream_;
422 407
423 bool allow_overlay_; 408 bool allow_overlay_;
424 409
425 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 410 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
426 }; 411 };
427 412
428 } // namespace media 413 } // namespace media
429 414
430 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 415 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_ms.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698