Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 B1;2305;0c// Copyright (c) 2011 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/base/encoder_vp8.h" | 5 #include "remoting/base/encoder_vp8.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/base/callback.h" | 8 #include "media/base/callback.h" |
| 9 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
| 10 #include "remoting/base/capture_data.h" | 10 #include "remoting/base/capture_data.h" |
| 11 #include "remoting/base/util.h" | 11 #include "remoting/base/util.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 CHECK(algo); | 92 CHECK(algo); |
| 93 vpx_codec_err_t ret = vpx_codec_enc_config_default(algo, &config, 0); | 93 vpx_codec_err_t ret = vpx_codec_enc_config_default(algo, &config, 0); |
| 94 if (ret != VPX_CODEC_OK) | 94 if (ret != VPX_CODEC_OK) |
| 95 return false; | 95 return false; |
| 96 | 96 |
| 97 // Initialize active map. | 97 // Initialize active map. |
| 98 active_map_width_ = (size.width() + kMacroBlockSize - 1) / kMacroBlockSize; | 98 active_map_width_ = (size.width() + kMacroBlockSize - 1) / kMacroBlockSize; |
| 99 active_map_height_ = (size.height() + kMacroBlockSize - 1) / kMacroBlockSize; | 99 active_map_height_ = (size.height() + kMacroBlockSize - 1) / kMacroBlockSize; |
| 100 active_map_.reset(new uint8[active_map_width_ * active_map_height_]); | 100 active_map_.reset(new uint8[active_map_width_ * active_map_height_]); |
| 101 | 101 |
| 102 // TODO(hclam): Tune the parameters to better suit the application. | |
| 103 config.rc_target_bitrate = size.width() * size.height() * | 102 config.rc_target_bitrate = size.width() * size.height() * |
| 104 config.rc_target_bitrate / config.g_w / config.g_h; | 103 config.rc_target_bitrate / config.g_w / config.g_h; |
| 105 config.g_w = size.width(); | 104 config.g_w = size.width(); |
| 106 config.g_h = size.height(); | 105 config.g_h = size.height(); |
| 107 config.g_pass = VPX_RC_ONE_PASS; | 106 config.g_pass = VPX_RC_ONE_PASS; |
| 108 config.g_profile = 1; | 107 config.g_profile = 2; |
| 109 config.g_threads = 1; | 108 config.g_threads = 2; |
| 110 config.rc_min_quantizer = 20; | 109 config.rc_min_quantizer = 20; |
| 111 config.rc_max_quantizer = 30; | 110 config.rc_max_quantizer = 30; |
| 112 config.g_timebase.num = 1; | 111 config.g_timebase.num = 1; |
| 113 config.g_timebase.den = 20; | 112 config.g_timebase.den = 20; |
| 114 | 113 |
| 115 if (vpx_codec_enc_init(codec_.get(), algo, &config, 0)) | 114 if (vpx_codec_enc_init(codec_.get(), algo, &config, 0)) |
| 116 return false; | 115 return false; |
| 116 if (vpx_codec_control(codec_.get(), VP8E_SET_CPUUSED, 16)) | |
|
dmac
2011/05/28 00:16:33
Can we put some comments here as to why these valu
| |
| 117 return false; | |
| 118 if (vpx_codec_control(codec_.get(), VP8E_SET_NOISE_SENSITIVITY, 0)) | |
| 119 return false; | |
| 117 return true; | 120 return true; |
| 118 } | 121 } |
| 119 | 122 |
| 120 static int RoundToTwosMultiple(int x) { | 123 static int RoundToTwosMultiple(int x) { |
| 121 return x & (~1); | 124 return x & (~1); |
| 122 } | 125 } |
| 123 | 126 |
| 124 // Align the sides of the rectangle to multiples of 2 (expanding outwards). | 127 // Align the sides of the rectangle to multiples of 2 (expanding outwards). |
| 125 static gfx::Rect AlignRect(const gfx::Rect& rect) { | 128 static gfx::Rect AlignRect(const gfx::Rect& rect) { |
| 126 int x = RoundToTwosMultiple(rect.x()); | 129 int x = RoundToTwosMultiple(rect.x()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 rect->set_y(updated_rects[i].y()); | 284 rect->set_y(updated_rects[i].y()); |
| 282 rect->set_width(updated_rects[i].width()); | 285 rect->set_width(updated_rects[i].width()); |
| 283 rect->set_height(updated_rects[i].height()); | 286 rect->set_height(updated_rects[i].height()); |
| 284 } | 287 } |
| 285 | 288 |
| 286 data_available_callback->Run(message); | 289 data_available_callback->Run(message); |
| 287 delete data_available_callback; | 290 delete data_available_callback; |
| 288 } | 291 } |
| 289 | 292 |
| 290 } // namespace remoting | 293 } // namespace remoting |
| OLD | NEW |