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 9259ea706f38ccf6943d4a19cb70e861c209e9fc..beff31c371df67b59ffc165e94a8a67b448d9732 100644 |
| --- a/remoting/codec/video_encoder_vpx.cc |
| +++ b/remoting/codec/video_encoder_vpx.cc |
| @@ -77,6 +77,57 @@ ScopedVpxCodec CreateVP8Codec(const webrtc::DesktopSize& size) { |
| return codec.Pass(); |
| } |
| +ScopedVpxCodec CreateVP9Codec(const webrtc::DesktopSize& size) { |
| + ScopedVpxCodec codec(new vpx_codec_ctx_t); |
| + |
| + // Configure the encoder. |
| + vpx_codec_enc_cfg_t config; |
| + const vpx_codec_iface_t* algo = vpx_codec_vp9_cx(); |
| + CHECK(algo); |
| + vpx_codec_err_t ret = vpx_codec_enc_config_default(algo, &config, 0); |
| + if (ret != VPX_CODEC_OK) |
| + return ScopedVpxCodec(); |
| + |
| + //config.rc_target_bitrate = size.width() * size.height() * |
| + // config.rc_target_bitrate / config.g_w / config.g_h; |
| + config.g_w = size.width(); |
| + config.g_h = size.height(); |
| + config.g_pass = VPX_RC_ONE_PASS; |
| + |
| + // Value of 2 means using the real time profile. This is basically a |
| + // redundant option since we explicitly select real time mode when doing |
| + // encoding. |
|
Jamie
2013/10/21 18:15:28
You're not using 2 for VP9. Please update either t
Wez
2013/10/22 01:12:33
Done.
|
| + config.g_profile = 0; |
| + |
| + // Start emitting packets immediately. |
| + config.g_lag_in_frames = 0; |
| + |
| + // Using 2 threads gives a great boost in performance for most systems with |
| + // adequate processing power. NB: Going to multiple threads on low end |
| + // windows systems can really hurt performance. |
| + // http://crbug.com/99179 |
| + //config.g_threads = (base::SysInfo::NumberOfProcessors() > 2) ? 2 : 1; |
| + //config.rc_min_quantizer = 20; |
| + //config.rc_max_quantizer = 30; |
| + //config.g_timebase.num = 1; |
| + //config.g_timebase.den = 20; |
| + |
| + if (vpx_codec_enc_init(codec.get(), algo, &config, 0)) |
| + return ScopedVpxCodec(); |
| + |
| + // Value of 16 will have the smallest CPU load. This turns off subpixel |
| + // motion search. |
|
Jamie
2013/10/21 18:15:28
You're not using 16 for VP9. Please update either
Wez
2013/10/22 01:12:33
Done.
|
| + if (vpx_codec_control(codec.get(), VP8E_SET_CPUUSED, 4)) |
|
Jamie
2013/10/21 18:15:28
Is this use of a VP8_ constant correct for the VP9
Wez
2013/10/22 01:12:33
Yup. Updated comment to make that explicit.
|
| + return ScopedVpxCodec(); |
| + |
| + // Use the lowest level of noise sensitivity so as to spend less time |
| + // on motion estimation and inter-prediction mode. |
| + if (vpx_codec_control(codec.get(), VP8E_SET_NOISE_SENSITIVITY, 0)) |
| + return ScopedVpxCodec(); |
| + |
| + return codec.Pass(); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -85,6 +136,12 @@ scoped_ptr<VideoEncoderVpx> VideoEncoderVpx::CreateForVP8() { |
| new VideoEncoderVpx(base::Bind(&CreateVP8Codec))); |
| } |
| +// static |
| +scoped_ptr<VideoEncoderVpx> VideoEncoderVpx::CreateForVP9() { |
| + return scoped_ptr<VideoEncoderVpx>( |
| + new VideoEncoderVpx(base::Bind(&CreateVP9Codec))); |
| +} |
| + |
| VideoEncoderVpx::~VideoEncoderVpx() {} |
| scoped_ptr<VideoPacket> VideoEncoderVpx::Encode( |