| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |