OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // 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" |
(...skipping 81 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. | 102 // TODO(hclam): Tune the parameters to better suit the application. |
Wez
2011/05/28 00:09:06
Can we elaborate more here on what tweaks we're ma
| |
103 config.rc_target_bitrate = size.width() * size.height() * | 103 config.rc_target_bitrate = size.width() * size.height() * |
104 config.rc_target_bitrate / config.g_w / config.g_h; | 104 config.rc_target_bitrate / config.g_w / config.g_h; |
105 config.g_w = size.width(); | 105 config.g_w = size.width(); |
106 config.g_h = size.height(); | 106 config.g_h = size.height(); |
107 config.g_pass = VPX_RC_ONE_PASS; | 107 config.g_pass = VPX_RC_ONE_PASS; |
108 config.g_profile = 1; | 108 config.g_profile = 2; |
109 config.g_threads = 1; | 109 config.g_threads = 2; |
110 config.rc_min_quantizer = 20; | 110 config.rc_min_quantizer = 20; |
111 config.rc_max_quantizer = 30; | 111 config.rc_max_quantizer = 30; |
112 config.g_timebase.num = 1; | 112 config.g_timebase.num = 1; |
113 config.g_timebase.den = 20; | 113 config.g_timebase.den = 20; |
114 | 114 |
115 if (vpx_codec_enc_init(codec_.get(), algo, &config, 0)) | 115 if (vpx_codec_enc_init(codec_.get(), algo, &config, 0)) |
116 return false; | 116 return false; |
117 | |
118 // More advanced options of vp8. | |
Wez
2011/05/28 00:09:06
Again, it will be helpful for others if the commen
| |
119 if (vpx_codec_control(codec_.get(), VP8E_SET_CPUUSED, 16)) | |
120 return false; | |
121 if (vpx_codec_control(codec_.get(), VP8E_SET_NOISE_SENSITIVITY, 0)) | |
122 return false; | |
117 return true; | 123 return true; |
118 } | 124 } |
119 | 125 |
120 static int RoundToTwosMultiple(int x) { | 126 static int RoundToTwosMultiple(int x) { |
121 return x & (~1); | 127 return x & (~1); |
122 } | 128 } |
123 | 129 |
124 // Align the sides of the rectangle to multiples of 2 (expanding outwards). | 130 // Align the sides of the rectangle to multiples of 2 (expanding outwards). |
125 static gfx::Rect AlignRect(const gfx::Rect& rect) { | 131 static gfx::Rect AlignRect(const gfx::Rect& rect) { |
126 int x = RoundToTwosMultiple(rect.x()); | 132 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()); | 287 rect->set_y(updated_rects[i].y()); |
282 rect->set_width(updated_rects[i].width()); | 288 rect->set_width(updated_rects[i].width()); |
283 rect->set_height(updated_rects[i].height()); | 289 rect->set_height(updated_rects[i].height()); |
284 } | 290 } |
285 | 291 |
286 data_available_callback->Run(message); | 292 data_available_callback->Run(message); |
287 delete data_available_callback; | 293 delete data_available_callback; |
288 } | 294 } |
289 | 295 |
290 } // namespace remoting | 296 } // namespace remoting |
OLD | NEW |