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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 void CopyUPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { | 57 void CopyUPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { |
58 CopyPlane(VideoFrame::kUPlane, source, stride, rows, frame); | 58 CopyPlane(VideoFrame::kUPlane, source, stride, rows, frame); |
59 } | 59 } |
60 | 60 |
61 void CopyVPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { | 61 void CopyVPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { |
62 CopyPlane(VideoFrame::kVPlane, source, stride, rows, frame); | 62 CopyPlane(VideoFrame::kVPlane, source, stride, rows, frame); |
63 } | 63 } |
64 | 64 |
65 void CopyAPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { | |
66 CopyPlane(VideoFrame::kAPlane, source, stride, rows, frame); | |
67 } | |
68 | |
69 void MakeOpaqueAPlane(int stride, int rows, VideoFrame* frame) { | |
70 int rows_to_clear = std::min(frame->rows(VideoFrame::kAPlane), rows); | |
71 memset(frame->data(VideoFrame::kAPlane), 255, | |
72 frame->stride(VideoFrame::kAPlane) * rows_to_clear); | |
73 } | |
74 | |
75 void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v) { | 65 void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v) { |
76 // Fill the Y plane. | 66 // Fill the Y plane. |
77 uint8* y_plane = frame->data(VideoFrame::kYPlane); | 67 uint8* y_plane = frame->data(VideoFrame::kYPlane); |
78 int y_rows = frame->rows(VideoFrame::kYPlane); | 68 int y_rows = frame->rows(VideoFrame::kYPlane); |
79 int y_row_bytes = frame->row_bytes(VideoFrame::kYPlane); | 69 int y_row_bytes = frame->row_bytes(VideoFrame::kYPlane); |
80 for (int i = 0; i < y_rows; ++i) { | 70 for (int i = 0; i < y_rows; ++i) { |
81 memset(y_plane, y, y_row_bytes); | 71 memset(y_plane, y, y_row_bytes); |
82 y_plane += frame->stride(VideoFrame::kYPlane); | 72 y_plane += frame->stride(VideoFrame::kYPlane); |
83 } | 73 } |
84 | 74 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 frame->data(kU) + uv_offset, | 283 frame->data(kU) + uv_offset, |
294 frame->data(kV) + uv_offset, | 284 frame->data(kV) + uv_offset, |
295 region_in_frame.width(), | 285 region_in_frame.width(), |
296 region_in_frame.height(), | 286 region_in_frame.height(), |
297 stride, | 287 stride, |
298 frame->stride(kY), | 288 frame->stride(kY), |
299 uv_stride); | 289 uv_stride); |
300 } | 290 } |
301 | 291 |
302 } // namespace media | 292 } // namespace media |
OLD | NEW |