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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 static void CopyPlane(size_t plane, const uint8* source, int stride, int rows, | 12 static void CopyPlane(size_t plane, const uint8* source, size_t stride, |
13 VideoFrame* frame) { | 13 size_t rows, VideoFrame* frame) { |
Ami GONE FROM CHROMIUM
2012/03/21 04:33:44
Are you worried about an image w/ over 2 billion i
DaleCurtis
2012/03/22 01:24:43
I just flipped these to make them consistent with
| |
14 uint8* dest = frame->data(plane); | 14 uint8* dest = frame->data(plane); |
15 int dest_stride = frame->stride(plane); | 15 size_t dest_stride = frame->stride(plane); |
16 | 16 |
17 // Clamp in case source frame has smaller stride. | 17 // Clamp in case source frame has smaller stride. |
18 int bytes_to_copy_per_row = std::min(frame->row_bytes(plane), stride); | 18 size_t bytes_to_copy_per_row = std::min(frame->row_bytes(plane), stride); |
19 | 19 |
20 // Clamp in case source frame has smaller height. | 20 // Clamp in case source frame has smaller height. |
21 int rows_to_copy = std::min(frame->rows(plane), rows); | 21 size_t rows_to_copy = std::min(frame->rows(plane), rows); |
22 | 22 |
23 // Copy! | 23 // Copy! |
24 for (int row = 0; row < rows_to_copy; ++row) { | 24 for (size_t row = 0; row < rows_to_copy; ++row) { |
25 memcpy(dest, source, bytes_to_copy_per_row); | 25 memcpy(dest, source, bytes_to_copy_per_row); |
26 source += stride; | 26 source += stride; |
27 dest += dest_stride; | 27 dest += dest_stride; |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 void CopyYPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { | 31 void CopyYPlane(const uint8* source, size_t stride, size_t rows, |
32 VideoFrame* frame) { | |
32 CopyPlane(VideoFrame::kYPlane, source, stride, rows, frame); | 33 CopyPlane(VideoFrame::kYPlane, source, stride, rows, frame); |
33 } | 34 } |
34 | 35 |
35 void CopyUPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { | 36 void CopyUPlane(const uint8* source, size_t stride, size_t rows, |
37 VideoFrame* frame) { | |
36 CopyPlane(VideoFrame::kUPlane, source, stride, rows, frame); | 38 CopyPlane(VideoFrame::kUPlane, source, stride, rows, frame); |
37 } | 39 } |
38 | 40 |
39 void CopyVPlane(const uint8* source, int stride, int rows, VideoFrame* frame) { | 41 void CopyVPlane(const uint8* source, size_t stride, size_t rows, |
42 VideoFrame* frame) { | |
40 CopyPlane(VideoFrame::kVPlane, source, stride, rows, frame); | 43 CopyPlane(VideoFrame::kVPlane, source, stride, rows, frame); |
41 } | 44 } |
42 | 45 |
43 void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v) { | 46 void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v) { |
44 // Fill the Y plane. | 47 // Fill the Y plane. |
45 uint8* y_plane = frame->data(VideoFrame::kYPlane); | 48 uint8* y_plane = frame->data(VideoFrame::kYPlane); |
46 int y_rows = frame->rows(VideoFrame::kYPlane); | 49 int y_rows = frame->rows(VideoFrame::kYPlane); |
47 int y_row_bytes = frame->row_bytes(VideoFrame::kYPlane); | 50 int y_row_bytes = frame->row_bytes(VideoFrame::kYPlane); |
48 for (int i = 0; i < y_rows; ++i) { | 51 for (int i = 0; i < y_rows; ++i) { |
49 memset(y_plane, y, y_row_bytes); | 52 memset(y_plane, y, y_row_bytes); |
50 y_plane += frame->stride(VideoFrame::kYPlane); | 53 y_plane += frame->stride(VideoFrame::kYPlane); |
51 } | 54 } |
52 | 55 |
53 // Fill the U and V planes. | 56 // Fill the U and V planes. |
54 uint8* u_plane = frame->data(VideoFrame::kUPlane); | 57 uint8* u_plane = frame->data(VideoFrame::kUPlane); |
55 uint8* v_plane = frame->data(VideoFrame::kVPlane); | 58 uint8* v_plane = frame->data(VideoFrame::kVPlane); |
56 int uv_rows = frame->rows(VideoFrame::kUPlane); | 59 int uv_rows = frame->rows(VideoFrame::kUPlane); |
57 int u_row_bytes = frame->row_bytes(VideoFrame::kUPlane); | 60 int u_row_bytes = frame->row_bytes(VideoFrame::kUPlane); |
58 int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane); | 61 int v_row_bytes = frame->row_bytes(VideoFrame::kVPlane); |
59 for (int i = 0; i < uv_rows; ++i) { | 62 for (int i = 0; i < uv_rows; ++i) { |
60 memset(u_plane, u, u_row_bytes); | 63 memset(u_plane, u, u_row_bytes); |
61 memset(v_plane, v, v_row_bytes); | 64 memset(v_plane, v, v_row_bytes); |
62 u_plane += frame->stride(VideoFrame::kUPlane); | 65 u_plane += frame->stride(VideoFrame::kUPlane); |
63 v_plane += frame->stride(VideoFrame::kVPlane); | 66 v_plane += frame->stride(VideoFrame::kVPlane); |
64 } | 67 } |
65 } | 68 } |
66 | 69 |
67 } // namespace media | 70 } // namespace media |
OLD | NEW |