OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/codec/video_encoder_vpx.h" | 5 #include "remoting/codec/video_encoder_vpx.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
10 #include "remoting/base/util.h" | 12 #include "remoting/base/util.h" |
11 #include "remoting/proto/video.pb.h" | 13 #include "remoting/proto/video.pb.h" |
12 #include "third_party/libyuv/include/libyuv/convert_from_argb.h" | 14 #include "third_party/libyuv/include/libyuv/convert_from_argb.h" |
13 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
14 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 16 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
15 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 17 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
16 | 18 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Fill in the information for |image_|. | 217 // Fill in the information for |image_|. |
216 unsigned char* uchar_buffer = | 218 unsigned char* uchar_buffer = |
217 reinterpret_cast<unsigned char*>(image_buffer.get()); | 219 reinterpret_cast<unsigned char*>(image_buffer.get()); |
218 image->planes[0] = uchar_buffer; | 220 image->planes[0] = uchar_buffer; |
219 image->planes[1] = image->planes[0] + y_stride * y_rows; | 221 image->planes[1] = image->planes[0] + y_stride * y_rows; |
220 image->planes[2] = image->planes[1] + uv_stride * uv_rows; | 222 image->planes[2] = image->planes[1] + uv_stride * uv_rows; |
221 image->stride[0] = y_stride; | 223 image->stride[0] = y_stride; |
222 image->stride[1] = uv_stride; | 224 image->stride[1] = uv_stride; |
223 image->stride[2] = uv_stride; | 225 image->stride[2] = uv_stride; |
224 | 226 |
225 *out_image = image.Pass(); | 227 *out_image = std::move(image); |
226 *out_image_buffer = image_buffer.Pass(); | 228 *out_image_buffer = std::move(image_buffer); |
227 } | 229 } |
228 | 230 |
229 } // namespace | 231 } // namespace |
230 | 232 |
231 // static | 233 // static |
232 scoped_ptr<VideoEncoderVpx> VideoEncoderVpx::CreateForVP8() { | 234 scoped_ptr<VideoEncoderVpx> VideoEncoderVpx::CreateForVP8() { |
233 return make_scoped_ptr(new VideoEncoderVpx(false)); | 235 return make_scoped_ptr(new VideoEncoderVpx(false)); |
234 } | 236 } |
235 | 237 |
236 // static | 238 // static |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 switch (vpx_packet->kind) { | 334 switch (vpx_packet->kind) { |
333 case VPX_CODEC_CX_FRAME_PKT: | 335 case VPX_CODEC_CX_FRAME_PKT: |
334 got_data = true; | 336 got_data = true; |
335 packet->set_data(vpx_packet->data.frame.buf, vpx_packet->data.frame.sz); | 337 packet->set_data(vpx_packet->data.frame.buf, vpx_packet->data.frame.sz); |
336 break; | 338 break; |
337 default: | 339 default: |
338 break; | 340 break; |
339 } | 341 } |
340 } | 342 } |
341 | 343 |
342 return packet.Pass(); | 344 return packet; |
343 } | 345 } |
344 | 346 |
345 VideoEncoderVpx::VideoEncoderVpx(bool use_vp9) | 347 VideoEncoderVpx::VideoEncoderVpx(bool use_vp9) |
346 : use_vp9_(use_vp9), encode_unchanged_frame_(false) { | 348 : use_vp9_(use_vp9), encode_unchanged_frame_(false) { |
347 } | 349 } |
348 | 350 |
349 void VideoEncoderVpx::Configure(const webrtc::DesktopSize& size) { | 351 void VideoEncoderVpx::Configure(const webrtc::DesktopSize& size) { |
350 DCHECK(use_vp9_ || !lossless_color_); | 352 DCHECK(use_vp9_ || !lossless_color_); |
351 DCHECK(use_vp9_ || !lossless_encode_); | 353 DCHECK(use_vp9_ || !lossless_encode_); |
352 | 354 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 kMacroBlockSize * (y + 1))); | 536 kMacroBlockSize * (y + 1))); |
535 } | 537 } |
536 x0 = x1 + 1; | 538 x0 = x1 + 1; |
537 } | 539 } |
538 } | 540 } |
539 updated_region->IntersectWith( | 541 updated_region->IntersectWith( |
540 webrtc::DesktopRect::MakeWH(image_->w, image_->h)); | 542 webrtc::DesktopRect::MakeWH(image_->w, image_->h)); |
541 } | 543 } |
542 | 544 |
543 } // namespace remoting | 545 } // namespace remoting |
OLD | NEW |