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

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

Issue 10830110: Remove VideoDecoderConfig::aspect_ratio_xxx methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments & rebased Created 8 years, 4 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/ffmpeg/ffmpeg_common.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_util.h" 5 #include "media/base/video_util.h"
6 6
7 #include <cmath>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
9 11
10 namespace media { 12 namespace media {
11 13
14 gfx::Size GetNaturalSize(const gfx::Size& visible_size,
15 int aspect_ratio_numerator,
16 int aspect_ratio_denominator) {
17 if (aspect_ratio_denominator == 0 ||
18 aspect_ratio_numerator < 0 ||
19 aspect_ratio_denominator < 0)
20 return gfx::Size();
21
22 double aspect_ratio = aspect_ratio_numerator /
23 static_cast<double>(aspect_ratio_denominator);
24
25 int width = floor(visible_size.width() * aspect_ratio + 0.5);
26 int height = visible_size.height();
27
28 // An even width makes things easier for YV12 and appears to be the behavior
29 // expected by WebKit layout tests.
30 return gfx::Size(width & ~1, height);
31 }
32
12 static void CopyPlane(size_t plane, const uint8* source, int stride, int rows, 33 static void CopyPlane(size_t plane, const uint8* source, int stride, int rows,
13 VideoFrame* frame) { 34 VideoFrame* frame) {
14 uint8* dest = frame->data(plane); 35 uint8* dest = frame->data(plane);
15 int dest_stride = frame->stride(plane); 36 int dest_stride = frame->stride(plane);
16 37
17 // Clamp in case source frame has smaller stride. 38 // Clamp in case source frame has smaller stride.
18 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);
19 40
20 // Clamp in case source frame has smaller height. 41 // Clamp in case source frame has smaller height.
21 int rows_to_copy = std::min(frame->rows(plane), rows); 42 int rows_to_copy = std::min(frame->rows(plane), rows);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane); 79 int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane);
59 for (int i = 0; i < uv_rows; ++i) { 80 for (int i = 0; i < uv_rows; ++i) {
60 memset(u_plane, u, u_row_bytes); 81 memset(u_plane, u, u_row_bytes);
61 memset(v_plane, v, v_row_bytes); 82 memset(v_plane, v, v_row_bytes);
62 u_plane += frame->stride(VideoFrame::kUPlane); 83 u_plane += frame->stride(VideoFrame::kUPlane);
63 v_plane += frame->stride(VideoFrame::kVPlane); 84 v_plane += frame->stride(VideoFrame::kVPlane);
64 } 85 }
65 } 86 }
66 87
67 } // namespace media 88 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_util.h ('k') | media/ffmpeg/ffmpeg_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698