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_util.cc

Issue 12090109: Tab Capture: Backing store readbacks to YV12 VideoFrames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix per wjia Created 7 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 | Annotate | Revision Log
« no previous file with comments | « media/base/video_util.h ('k') | media/video/capture/mac/video_capture_device_qtkit_mac.mm » ('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_util.h" 5 #include "media/base/video_util.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 12 matching lines...) Expand all
23 static_cast<double>(aspect_ratio_denominator); 23 static_cast<double>(aspect_ratio_denominator);
24 24
25 int width = floor(visible_size.width() * aspect_ratio + 0.5); 25 int width = floor(visible_size.width() * aspect_ratio + 0.5);
26 int height = visible_size.height(); 26 int height = visible_size.height();
27 27
28 // An even width makes things easier for YV12 and appears to be the behavior 28 // An even width makes things easier for YV12 and appears to be the behavior
29 // expected by WebKit layout tests. 29 // expected by WebKit layout tests.
30 return gfx::Size(width & ~1, height); 30 return gfx::Size(width & ~1, height);
31 } 31 }
32 32
33 static void CopyPlane(size_t plane, const uint8* source, int stride, int rows, 33 void CopyPlane(size_t plane, const uint8* source, int stride, int rows,
34 VideoFrame* frame) { 34 VideoFrame* frame) {
35 uint8* dest = frame->data(plane); 35 uint8* dest = frame->data(plane);
36 int dest_stride = frame->stride(plane); 36 int dest_stride = frame->stride(plane);
37 37
38 // Clamp in case source frame has smaller stride. 38 // Clamp in case source frame has smaller stride.
39 int bytes_to_copy_per_row = std::min(frame->row_bytes(plane), stride); 39 int bytes_to_copy_per_row = std::min(frame->row_bytes(plane), stride);
40 40
41 // Clamp in case source frame has smaller height. 41 // Clamp in case source frame has smaller height.
42 int rows_to_copy = std::min(frame->rows(plane), rows); 42 int rows_to_copy = std::min(frame->rows(plane), rows);
43 43
44 // Copy! 44 // Copy!
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane); 79 int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane);
80 for (int i = 0; i < uv_rows; ++i) { 80 for (int i = 0; i < uv_rows; ++i) {
81 memset(u_plane, u, u_row_bytes); 81 memset(u_plane, u, u_row_bytes);
82 memset(v_plane, v, v_row_bytes); 82 memset(v_plane, v, v_row_bytes);
83 u_plane += frame->stride(VideoFrame::kUPlane); 83 u_plane += frame->stride(VideoFrame::kUPlane);
84 v_plane += frame->stride(VideoFrame::kVPlane); 84 v_plane += frame->stride(VideoFrame::kVPlane);
85 } 85 }
86 } 86 }
87 87
88 } // namespace media 88 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_util.h ('k') | media/video/capture/mac/video_capture_device_qtkit_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698