| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "remoting/base/encoder_verbatim.h" | 5 #include "remoting/base/encoder_verbatim.h" |
| 6 | 6 |
| 7 #include "gfx/rect.h" | 7 #include "gfx/rect.h" |
| 8 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
| 9 #include "remoting/base/capture_data.h" | 9 #include "remoting/base/capture_data.h" |
| 10 #include "remoting/base/protocol_util.h" | 10 #include "remoting/base/protocol_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 int output_size = 0; | 60 int output_size = 0; |
| 61 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { | 61 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { |
| 62 // TODO(hclam): Handle YUV since the height would be different. | 62 // TODO(hclam): Handle YUV since the height would be different. |
| 63 const uint8* in = capture_data->data_planes().data[i]; | 63 const uint8* in = capture_data->data_planes().data[i]; |
| 64 if (!in) continue; | 64 if (!in) continue; |
| 65 output_size += row_size * height; | 65 output_size += row_size * height; |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Resize the output data buffer. | 68 // Resize the output data buffer. |
| 69 packet->mutable_rect_data()->mutable_data()->resize(output_size); | 69 packet->mutable_rect_data()->mutable_data()->resize(output_size); |
| 70 uint8* out = reinterpret_cast<uint8*>( | 70 uint8* out = (uint8*)packet->mutable_rect_data()->mutable_data()->data(); |
| 71 &((*packet->mutable_rect_data()->mutable_data())[0])); | |
| 72 | 71 |
| 73 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { | 72 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { |
| 74 // Skip over planes that don't have data. | 73 // Skip over planes that don't have data. |
| 75 if (!capture_data->data_planes().data[i]) | 74 if (!capture_data->data_planes().data[i]) |
| 76 continue; | 75 continue; |
| 77 | 76 |
| 78 const uint8* in = capture_data->data_planes().data[i] + | 77 const uint8* in = capture_data->data_planes().data[i] + |
| 79 y * capture_data->data_planes().strides[i] + | 78 y * capture_data->data_planes().strides[i] + |
| 80 x * bytes_per_pixel; | 79 x * bytes_per_pixel; |
| 81 | 80 |
| 82 // TODO(hclam): Handle YUV since the height would be different. | 81 // TODO(hclam): Handle YUV since the height would be different. |
| 83 for (int j = 0; j < height; ++j) { | 82 for (int j = 0; j < height; ++j) { |
| 84 DCHECK_LE(row_size, capture_data->data_planes().strides[i]); | 83 DCHECK_LE(row_size, capture_data->data_planes().strides[i]); |
| 85 memcpy(out, in, width * bytes_per_pixel); | 84 memcpy(out, in, width * bytes_per_pixel); |
| 86 in += capture_data->data_planes().strides[i]; | 85 in += capture_data->data_planes().strides[i]; |
| 87 out += row_size; | 86 out += row_size; |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 return true; | 89 return true; |
| 91 } | 90 } |
| 92 | 91 |
| 93 } // namespace remoting | 92 } // namespace remoting |
| OLD | NEW |