| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "media/base/callback.h" | 6 #include "media/base/callback.h" |
| 7 #include "media/base/media.h" | 7 #include "media/base/media.h" |
| 8 #include "remoting/base/capture_data.h" | 8 #include "remoting/base/capture_data.h" |
| 9 #include "remoting/base/encoder_vp8.h" | 9 #include "remoting/base/encoder_vp8.h" |
| 10 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 uint8* in = capture_data->data_planes().data[0]; | 119 uint8* in = capture_data->data_planes().data[0]; |
| 120 const int in_stride = capture_data->data_planes().strides[0]; | 120 const int in_stride = capture_data->data_planes().strides[0]; |
| 121 uint8* y_out = yuv_image_.get(); | 121 uint8* y_out = yuv_image_.get(); |
| 122 uint8* u_out = yuv_image_.get() + plane_size; | 122 uint8* u_out = yuv_image_.get() + plane_size; |
| 123 uint8* v_out = yuv_image_.get() + plane_size + plane_size / 4; | 123 uint8* v_out = yuv_image_.get() + plane_size + plane_size / 4; |
| 124 const int out_stride = image_->stride[0]; | 124 const int out_stride = image_->stride[0]; |
| 125 for (int i = 0; i < capture_data->height(); ++i) { | 125 for (int i = 0; i < capture_data->height(); ++i) { |
| 126 for (int j = 0; j < capture_data->width(); ++j) { | 126 for (int j = 0; j < capture_data->width(); ++j) { |
| 127 // Since the input pixel format is RGB32, there are 4 bytes per pixel. | 127 // Since the input pixel format is RGB32, there are 4 bytes per pixel. |
| 128 uint8* pixel = in + 4 * j; | 128 uint8* pixel = in + 4 * j; |
| 129 y_out[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + | 129 y_out[j] = clip_byte(((pixel[0] * 66 + pixel[1] * 129 + |
| 130 pixel[0] * 25 + 128) >> 8) + 16); | 130 pixel[2] * 25 + 128) >> 8) + 16); |
| 131 if (i % 2 == 0 && j % 2 == 0) { | 131 if (i % 2 == 0 && j % 2 == 0) { |
| 132 u_out[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 + | 132 u_out[j / 2] = clip_byte(((pixel[0] * -38 + pixel[1] * -74 + |
| 133 pixel[0] * 112 + 128) >> 8) + 128); | 133 pixel[2] * 112 + 128) >> 8) + 128); |
| 134 v_out[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + | 134 v_out[j / 2] = clip_byte(((pixel[0] * 112 + pixel[1] * -94 + |
| 135 pixel[1] * -18 + 128) >> 8) + 128); | 135 pixel[2] * -18 + 128) >> 8) + 128); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 in += in_stride; | 138 in += in_stride; |
| 139 y_out += out_stride; | 139 y_out += out_stride; |
| 140 if (i % 2 == 0) { | 140 if (i % 2 == 0) { |
| 141 u_out += out_stride / 2; | 141 u_out += out_stride / 2; |
| 142 v_out += out_stride / 2; | 142 v_out += out_stride / 2; |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 return true; | 145 return true; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); | 198 message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); |
| 199 message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET); | 199 message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET); |
| 200 | 200 |
| 201 data_available_callback->Run(message); | 201 data_available_callback->Run(message); |
| 202 delete data_available_callback; | 202 delete data_available_callback; |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace remoting | 205 } // namespace remoting |
| OLD | NEW |