Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: media/cast/video_sender/codecs/vp8/vp8_encoder.cc

Issue 228313002: Cast: Use 2 threads for encoding on capable systems (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cast/test/sender.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO (pwestin): add a link to the design document describing the generic 5 // TODO (pwestin): add a link to the design document describing the generic
6 // protocol and the VP8 specific details. 6 // protocol and the VP8 specific details.
7 #include "media/cast/video_sender/codecs/vp8/vp8_encoder.h" 7 #include "media/cast/video_sender/codecs/vp8/vp8_encoder.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Creating a wrapper to the image - setting image data to NULL. Actual 72 // Creating a wrapper to the image - setting image data to NULL. Actual
73 // pointer will be set during encode. Setting align to 1, as it is 73 // pointer will be set during encode. Setting align to 1, as it is
74 // meaningless (actual memory is not allocated). 74 // meaningless (actual memory is not allocated).
75 raw_image_ = vpx_img_wrap( 75 raw_image_ = vpx_img_wrap(
76 NULL, IMG_FMT_I420, cast_config_.width, cast_config_.height, 1, NULL); 76 NULL, IMG_FMT_I420, cast_config_.width, cast_config_.height, 1, NULL);
77 77
78 for (int i = 0; i < kNumberOfVp8VideoBuffers; ++i) { 78 for (int i = 0; i < kNumberOfVp8VideoBuffers; ++i) {
79 acked_frame_buffers_[i] = true; 79 acked_frame_buffers_[i] = true;
80 used_buffers_frame_id_[i] = kStartFrameId; 80 used_buffers_frame_id_[i] = kStartFrameId;
81 } 81 }
82 InitEncode(cast_config_.number_of_cores); 82 InitEncode(cast_config_.number_of_encode_threads);
83 } 83 }
84 84
85 void Vp8Encoder::InitEncode(int number_of_cores) { 85 void Vp8Encoder::InitEncode(int number_of_encode_threads) {
86 DCHECK(thread_checker_.CalledOnValidThread()); 86 DCHECK(thread_checker_.CalledOnValidThread());
87 // Populate encoder configuration with default values. 87 // Populate encoder configuration with default values.
88 if (vpx_codec_enc_config_default(vpx_codec_vp8_cx(), config_.get(), 0)) { 88 if (vpx_codec_enc_config_default(vpx_codec_vp8_cx(), config_.get(), 0)) {
89 DCHECK(false) << "Invalid return value"; 89 DCHECK(false) << "Invalid return value";
90 } 90 }
91 config_->g_w = cast_config_.width; 91 config_->g_w = cast_config_.width;
92 config_->g_h = cast_config_.height; 92 config_->g_h = cast_config_.height;
93 config_->rc_target_bitrate = cast_config_.start_bitrate / 1000; // In kbit/s. 93 config_->rc_target_bitrate = cast_config_.start_bitrate / 1000; // In kbit/s.
94 94
95 // Setting the codec time base. 95 // Setting the codec time base.
96 config_->g_timebase.num = 1; 96 config_->g_timebase.num = 1;
97 config_->g_timebase.den = kVideoFrequency; 97 config_->g_timebase.den = kVideoFrequency;
98 config_->g_lag_in_frames = 0; 98 config_->g_lag_in_frames = 0;
99 config_->kf_mode = VPX_KF_DISABLED; 99 config_->kf_mode = VPX_KF_DISABLED;
100 if (use_multiple_video_buffers_) { 100 if (use_multiple_video_buffers_) {
101 // We must enable error resilience when we use multiple buffers, due to 101 // We must enable error resilience when we use multiple buffers, due to
102 // codec requirements. 102 // codec requirements.
103 config_->g_error_resilient = 1; 103 config_->g_error_resilient = 1;
104 } 104 }
105 105 config_->g_threads = number_of_encode_threads;
106 if (cast_config_.width * cast_config_.height > 640 * 480 &&
107 number_of_cores >= 2) {
108 config_->g_threads = 2; // 2 threads for qHD/HD.
109 } else {
110 config_->g_threads = 1; // 1 thread for VGA or less.
111 }
112 106
113 // Rate control settings. 107 // Rate control settings.
114 // TODO(pwestin): revisit these constants. Currently identical to webrtc. 108 // TODO(pwestin): revisit these constants. Currently identical to webrtc.
115 config_->rc_dropframe_thresh = 30; 109 config_->rc_dropframe_thresh = 30;
116 config_->rc_end_usage = VPX_CBR; 110 config_->rc_end_usage = VPX_CBR;
117 config_->g_pass = VPX_RC_ONE_PASS; 111 config_->g_pass = VPX_RC_ONE_PASS;
118 config_->rc_resize_allowed = 0; 112 config_->rc_resize_allowed = 0;
119 config_->rc_min_quantizer = cast_config_.min_qp; 113 config_->rc_min_quantizer = cast_config_.min_qp;
120 config_->rc_max_quantizer = cast_config_.max_qp; 114 config_->rc_max_quantizer = cast_config_.max_qp;
121 config_->rc_undershoot_pct = 100; 115 config_->rc_undershoot_pct = 100;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 float scale_parameter = 0.5; 393 float scale_parameter = 0.5;
400 uint32 target_pct = optimal_buffer_size_ms * scale_parameter * 394 uint32 target_pct = optimal_buffer_size_ms * scale_parameter *
401 cast_config_.max_frame_rate / 10; 395 cast_config_.max_frame_rate / 10;
402 396
403 // Don't go below 3 times the per frame bandwidth. 397 // Don't go below 3 times the per frame bandwidth.
404 return std::max(target_pct, kMinIntra); 398 return std::max(target_pct, kMinIntra);
405 } 399 }
406 400
407 } // namespace cast 401 } // namespace cast
408 } // namespace media 402 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/sender.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698