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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 config.rc_max_quantizer = 0; | 126 config.rc_max_quantizer = 0; |
127 } else { | 127 } else { |
128 // Lossy encode using the same settings as for VP8. | 128 // Lossy encode using the same settings as for VP8. |
129 config.rc_min_quantizer = 20; | 129 config.rc_min_quantizer = 20; |
130 config.rc_max_quantizer = 30; | 130 config.rc_max_quantizer = 30; |
131 } | 131 } |
132 | 132 |
133 if (vpx_codec_enc_init(codec.get(), algo, &config, 0)) | 133 if (vpx_codec_enc_init(codec.get(), algo, &config, 0)) |
134 return ScopedVpxCodec(); | 134 return ScopedVpxCodec(); |
135 | 135 |
136 // Request the lowest-CPU encode feature-set that VP9 supports. | 136 // Request the lowest-CPU usage that VP9 supports, which depends on whether |
| 137 // we are encoding lossy or lossless. |
137 // Note that this is configured via the same parameter as for VP8. | 138 // Note that this is configured via the same parameter as for VP8. |
138 if (vpx_codec_control(codec.get(), VP8E_SET_CPUUSED, 5)) | 139 int cpu_used = lossless_encode ? 5 : 7; |
| 140 if (vpx_codec_control(codec.get(), VP8E_SET_CPUUSED, cpu_used)) |
139 return ScopedVpxCodec(); | 141 return ScopedVpxCodec(); |
140 | 142 |
141 // Use the lowest level of noise sensitivity so as to spend less time | 143 // Use the lowest level of noise sensitivity so as to spend less time |
142 // on motion estimation and inter-prediction mode. | 144 // on motion estimation and inter-prediction mode. |
143 // Note that this is configured via the same parameter as for VP8. | 145 // Note that this is configured via the same parameter as for VP8. |
144 if (vpx_codec_control(codec.get(), VP8E_SET_NOISE_SENSITIVITY, 0)) | 146 if (vpx_codec_control(codec.get(), VP8E_SET_NOISE_SENSITIVITY, 0)) |
145 return ScopedVpxCodec(); | 147 return ScopedVpxCodec(); |
146 | 148 |
147 return codec.Pass(); | 149 return codec.Pass(); |
148 } | 150 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 return packet.Pass(); | 329 return packet.Pass(); |
328 } | 330 } |
329 | 331 |
330 VideoEncoderVpx::VideoEncoderVpx(bool use_vp9) | 332 VideoEncoderVpx::VideoEncoderVpx(bool use_vp9) |
331 : use_vp9_(use_vp9), | 333 : use_vp9_(use_vp9), |
332 lossless_encode_(false), | 334 lossless_encode_(false), |
333 lossless_color_(false), | 335 lossless_color_(false), |
334 active_map_width_(0), | 336 active_map_width_(0), |
335 active_map_height_(0) { | 337 active_map_height_(0) { |
336 if (use_vp9_) { | 338 if (use_vp9_) { |
337 // Use lossless encoding mode by default. | |
338 SetLosslessEncode(true); | |
339 | |
340 // Use I444 colour space, by default, if specified on the command-line. | 339 // Use I444 colour space, by default, if specified on the command-line. |
341 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableI444SwitchName)) { | 340 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableI444SwitchName)) { |
342 SetLosslessColor(true); | 341 SetLosslessColor(true); |
343 } | 342 } |
344 } | 343 } |
345 } | 344 } |
346 | 345 |
347 bool VideoEncoderVpx::Initialize(const webrtc::DesktopSize& size) { | 346 bool VideoEncoderVpx::Initialize(const webrtc::DesktopSize& size) { |
348 DCHECK(use_vp9_ || !lossless_color_); | 347 DCHECK(use_vp9_ || !lossless_color_); |
349 DCHECK(use_vp9_ || !lossless_encode_); | 348 DCHECK(use_vp9_ || !lossless_encode_); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 uint8* map = active_map_.get() + top * active_map_width_; | 459 uint8* map = active_map_.get() + top * active_map_width_; |
461 for (int y = top; y <= bottom; ++y) { | 460 for (int y = top; y <= bottom; ++y) { |
462 for (int x = left; x <= right; ++x) | 461 for (int x = left; x <= right; ++x) |
463 map[x] = 1; | 462 map[x] = 1; |
464 map += active_map_width_; | 463 map += active_map_width_; |
465 } | 464 } |
466 } | 465 } |
467 } | 466 } |
468 | 467 |
469 } // namespace remoting | 468 } // namespace remoting |
OLD | NEW |