Chromium Code Reviews| Index: remoting/codec/video_encoder_vpx.cc |
| diff --git a/remoting/codec/video_encoder_vpx.cc b/remoting/codec/video_encoder_vpx.cc |
| index c74f0d8ecf5e62c4c9d79d77127fb3408ff84932..708cf3ba24f6a4a0c44d19c8d220290af03a7c51 100644 |
| --- a/remoting/codec/video_encoder_vpx.cc |
| +++ b/remoting/codec/video_encoder_vpx.cc |
| @@ -5,7 +5,6 @@ |
| #include "remoting/codec/video_encoder_vpx.h" |
| #include "base/bind.h" |
| -#include "base/command_line.h" |
| #include "base/logging.h" |
| #include "base/sys_info.h" |
| #include "remoting/base/util.h" |
| @@ -25,9 +24,6 @@ namespace remoting { |
| namespace { |
| -// Name of command-line flag to enable VP9 to use I444 by default. |
| -const char kEnableI444SwitchName[] = "enable-i444"; |
| - |
| // Number of bytes in an RGBx pixel. |
| const int kBytesPerRgbPixel = 4; |
| @@ -103,7 +99,9 @@ void SetVp9CodecParameters(vpx_codec_enc_cfg_t* config, |
| config->rc_max_quantizer = 0; |
| config->rc_end_usage = VPX_VBR; |
| } else { |
| - config->rc_min_quantizer = 4; |
| + // TODO(wez): Set quantization range to 4-40, once the libvpx encoder is |
| + // updated not to output any bits if nothing needs topping-off. |
| + config->rc_min_quantizer = 20; |
| config->rc_max_quantizer = 30; |
| config->rc_end_usage = VPX_CBR; |
| // In the absence of a good bandwidth estimator set the target bitrate to a |
| @@ -268,6 +266,20 @@ scoped_ptr<VideoPacket> VideoEncoderVpx::Encode( |
| DCHECK_LE(32, frame.size().width()); |
| DCHECK_LE(32, frame.size().height()); |
| + // If nothing has changed, then only encode data to top-off from lossy to |
| + // lossless quantization. |
| + if (frame.updated_region().is_empty()) { |
| + // VP8 doesn't support top-off, and VP9's lossless mode doesn't need it. |
| + if (!use_vp9_ || lossless_encode_) |
| + return nullptr; |
| + if (!--topoff_frame_count_) { |
|
Sergey Ulanov
2015/05/26 21:57:22
nit: --topoff_frame_count > 0 (or != 0) would be m
Wez
2015/06/09 01:46:20
Plus, in cleaning it up, I fixed a bug in my imple
|
| + return nullptr; |
| + } |
| + } else { |
| + // Just allow a couple of fully empty frames' worth of top-off. |
| + topoff_frame_count_ = 2; |
|
Sergey Ulanov
2015/05/26 21:57:22
topoff_frame_count_ is set even when using VP8, bu
Wez
2015/06/09 01:46:20
Done.
|
| + } |
| + |
| base::TimeTicks encode_start_time = base::TimeTicks::Now(); |
| // Create or reconfigure the codec to match the size of |frame|. |
| @@ -348,14 +360,8 @@ VideoEncoderVpx::VideoEncoderVpx(bool use_vp9) |
| lossless_encode_(false), |
| lossless_color_(false), |
| active_map_width_(0), |
| - active_map_height_(0) { |
| - if (use_vp9_) { |
| - // Use I444 colour space, by default, if specified on the command-line. |
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - kEnableI444SwitchName)) { |
| - SetLosslessColor(true); |
| - } |
| - } |
| + active_map_height_(0), |
| + topoff_frame_count_(0) { |
| } |
| void VideoEncoderVpx::Configure(const webrtc::DesktopSize& size) { |