OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/media/video_track_recorder.h" | 5 #include "content/renderer/media/video_track_recorder.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 const vpx_codec_iface_t* interface = | 273 const vpx_codec_iface_t* interface = |
274 use_vp9_ ? vpx_codec_vp9_cx() : vpx_codec_vp8_cx(); | 274 use_vp9_ ? vpx_codec_vp9_cx() : vpx_codec_vp8_cx(); |
275 vpx_codec_err_t result = | 275 vpx_codec_err_t result = |
276 vpx_codec_enc_config_default(interface, &codec_config_, 0 /* reserved */); | 276 vpx_codec_enc_config_default(interface, &codec_config_, 0 /* reserved */); |
277 DCHECK_EQ(VPX_CODEC_OK, result); | 277 DCHECK_EQ(VPX_CODEC_OK, result); |
278 | 278 |
279 DCHECK_EQ(320u, codec_config_.g_w); | 279 DCHECK_EQ(320u, codec_config_.g_w); |
280 DCHECK_EQ(240u, codec_config_.g_h); | 280 DCHECK_EQ(240u, codec_config_.g_h); |
281 DCHECK_EQ(256u, codec_config_.rc_target_bitrate); | 281 DCHECK_EQ(256u, codec_config_.rc_target_bitrate); |
282 // Use the selected bitrate or adjust default bit rate to account for the | 282 // Use the selected bitrate or adjust default bit rate to account for the |
283 // actual size. | 283 // actual size. Note: |rc_target_bitrate| units are kbit per second. |
284 if (bits_per_second_ > 0) { | 284 if (bits_per_second_ > 0) { |
285 codec_config_.rc_target_bitrate = bits_per_second_; | 285 codec_config_.rc_target_bitrate = bits_per_second_ / 1000; |
286 } else { | 286 } else { |
287 codec_config_.rc_target_bitrate = size.GetArea() * | 287 codec_config_.rc_target_bitrate = size.GetArea() * |
288 codec_config_.rc_target_bitrate / | 288 codec_config_.rc_target_bitrate / |
289 codec_config_.g_w / codec_config_.g_h; | 289 codec_config_.g_w / codec_config_.g_h; |
290 } | 290 } |
291 // Both VP8/VP9 configuration should be Variable BitRate by default. | 291 // Both VP8/VP9 configuration should be Variable BitRate by default. |
292 DCHECK_EQ(VPX_VBR, codec_config_.rc_end_usage); | 292 DCHECK_EQ(VPX_VBR, codec_config_.rc_end_usage); |
293 if (use_vp9_) { | 293 if (use_vp9_) { |
294 // Number of frames to consume before producing output. | 294 // Number of frames to consume before producing output. |
295 codec_config_.g_lag_in_frames = 0; | 295 codec_config_.g_lag_in_frames = 0; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 encoder_->set_paused(false); | 417 encoder_->set_paused(false); |
418 } | 418 } |
419 | 419 |
420 void VideoTrackRecorder::OnVideoFrameForTesting( | 420 void VideoTrackRecorder::OnVideoFrameForTesting( |
421 const scoped_refptr<media::VideoFrame>& frame, | 421 const scoped_refptr<media::VideoFrame>& frame, |
422 base::TimeTicks timestamp) { | 422 base::TimeTicks timestamp) { |
423 encoder_->StartFrameEncode(frame, timestamp); | 423 encoder_->StartFrameEncode(frame, timestamp); |
424 } | 424 } |
425 | 425 |
426 } // namespace content | 426 } // namespace content |
OLD | NEW |