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

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

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 | « media/base/video_frame.h ('k') | media/base/video_frame_unittest.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 <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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/aligned_memory.h" 12 #include "base/memory/aligned_memory.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "gpu/command_buffer/common/mailbox_holder.h" 14 #include "gpu/command_buffer/common/mailbox_holder.h"
15 #include "media/base/limits.h" 15 #include "media/base/limits.h"
16 #include "media/base/video_util.h" 16 #include "media/base/video_util.h"
17 #include "ui/gfx/geometry/point.h" 17 #include "ui/gfx/geometry/point.h"
18 18
19 #if !defined(MEDIA_FOR_CAST_IOS)
20 #include "third_party/skia/include/core/SkBitmap.h"
21 #endif
22
23 namespace media { 19 namespace media {
24 20
25 static bool IsPowerOfTwo(size_t x) { 21 static bool IsPowerOfTwo(size_t x) {
26 return x != 0 && (x & (x - 1)) == 0; 22 return x != 0 && (x & (x - 1)) == 0;
27 } 23 }
28 24
29 static inline size_t RoundUp(size_t value, size_t alignment) { 25 static inline size_t RoundUp(size_t value, size_t alignment) {
30 DCHECK(IsPowerOfTwo(alignment)); 26 DCHECK(IsPowerOfTwo(alignment));
31 return ((value + (alignment - 1)) & ~(alignment - 1)); 27 return ((value + (alignment - 1)) & ~(alignment - 1));
32 } 28 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 242 }
247 243
248 // static 244 // static
249 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( 245 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture(
250 scoped_ptr<gpu::MailboxHolder> mailbox_holder, 246 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
251 const ReleaseMailboxCB& mailbox_holder_release_cb, 247 const ReleaseMailboxCB& mailbox_holder_release_cb,
252 const gfx::Size& coded_size, 248 const gfx::Size& coded_size,
253 const gfx::Rect& visible_rect, 249 const gfx::Rect& visible_rect,
254 const gfx::Size& natural_size, 250 const gfx::Size& natural_size,
255 base::TimeDelta timestamp, 251 base::TimeDelta timestamp,
256 const ReadPixelsCB& read_pixels_cb,
257 bool allow_overlay) { 252 bool allow_overlay) {
258 scoped_refptr<VideoFrame> frame(new VideoFrame(NATIVE_TEXTURE, 253 scoped_refptr<VideoFrame> frame(new VideoFrame(NATIVE_TEXTURE,
259 coded_size, 254 coded_size,
260 visible_rect, 255 visible_rect,
261 natural_size, 256 natural_size,
262 mailbox_holder.Pass(), 257 mailbox_holder.Pass(),
263 timestamp, 258 timestamp,
264 false)); 259 false));
265 frame->mailbox_holder_release_cb_ = mailbox_holder_release_cb; 260 frame->mailbox_holder_release_cb_ = mailbox_holder_release_cb;
266 frame->read_pixels_cb_ = read_pixels_cb;
267 frame->allow_overlay_ = allow_overlay; 261 frame->allow_overlay_ = allow_overlay;
268 262
269 return frame; 263 return frame;
270 } 264 }
271 265
272 #if !defined(MEDIA_FOR_CAST_IOS)
273 void VideoFrame::ReadPixelsFromNativeTexture(const SkBitmap& pixels) {
274 DCHECK_EQ(format_, NATIVE_TEXTURE);
275 if (!read_pixels_cb_.is_null())
276 read_pixels_cb_.Run(pixels);
277 }
278 #endif
279
280 // static 266 // static
281 scoped_refptr<VideoFrame> VideoFrame::WrapExternalPackedMemory( 267 scoped_refptr<VideoFrame> VideoFrame::WrapExternalPackedMemory(
282 Format format, 268 Format format,
283 const gfx::Size& coded_size, 269 const gfx::Size& coded_size,
284 const gfx::Rect& visible_rect, 270 const gfx::Rect& visible_rect,
285 const gfx::Size& natural_size, 271 const gfx::Size& natural_size,
286 uint8* data, 272 uint8* data,
287 size_t data_size, 273 size_t data_size,
288 base::SharedMemoryHandle handle, 274 base::SharedMemoryHandle handle,
289 size_t data_offset, 275 size_t data_offset,
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { 811 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) {
826 for (int row = 0; row < rows(plane); ++row) { 812 for (int row = 0; row < rows(plane); ++row) {
827 base::MD5Update(context, base::StringPiece( 813 base::MD5Update(context, base::StringPiece(
828 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 814 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
829 row_bytes(plane))); 815 row_bytes(plane)));
830 } 816 }
831 } 817 }
832 } 818 }
833 819
834 } // namespace media 820 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/video_frame_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698