OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (scale_) { | 376 if (scale_) { |
377 if (codecType_ == kVideoCodecVP8) { | 377 if (codecType_ == kVideoCodecVP8) { |
378 // QP is obtained from VP8-bitstream for HW, so the QP corresponds to the | 378 // QP is obtained from VP8-bitstream for HW, so the QP corresponds to the |
379 // (internal) range: [0, 127]. And we cannot change QP_max in HW, so it is | 379 // (internal) range: [0, 127]. And we cannot change QP_max in HW, so it is |
380 // always = 127. Note that in SW, QP is that of the user-level range [0, | 380 // always = 127. Note that in SW, QP is that of the user-level range [0, |
381 // 63]. | 381 // 63]. |
382 const int kLowQpThreshold = 32; | 382 const int kLowQpThreshold = 32; |
383 const int kBadQpThreshold = 92; | 383 const int kBadQpThreshold = 92; |
384 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, | 384 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, |
385 codec_settings->startBitrate, | 385 codec_settings->startBitrate, |
386 codec_settings->width, codec_settings->height); | 386 codec_settings->width, codec_settings->height, |
| 387 codec_settings->height, codec_settings->maxFramerate); |
387 } else if (codecType_ == kVideoCodecH264) { | 388 } else if (codecType_ == kVideoCodecH264) { |
388 // H264 QP is in the range [0, 51]. | 389 // H264 QP is in the range [0, 51]. |
389 const int kLowQpThreshold = 21; | 390 const int kLowQpThreshold = 21; |
390 const int kBadQpThreshold = 36; | 391 const int kBadQpThreshold = 36; |
391 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, | 392 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, |
392 codec_settings->startBitrate, | 393 codec_settings->startBitrate, codec_settings->width, |
393 codec_settings->width, codec_settings->height); | 394 codec_settings->height, codec_settings->height, |
| 395 codec_settings->maxFramerate); |
394 } else { | 396 } else { |
395 // When adding codec support to additional hardware codecs, also configure | 397 // When adding codec support to additional hardware codecs, also configure |
396 // their QP thresholds for scaling. | 398 // their QP thresholds for scaling. |
397 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; | 399 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; |
398 scale_ = false; | 400 scale_ = false; |
399 } | 401 } |
400 quality_scaler_.SetMinResolution(kMinDimension, kMinDimension); | 402 quality_scaler_.SetMinResolution(kMinDimension, kMinDimension); |
401 quality_scaler_.ReportFramerate(codec_settings->maxFramerate); | |
402 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); | 403 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); |
403 init_width = std::max(res.width, kMinDimension); | 404 init_width = std::max(res.width, kMinDimension); |
404 init_height = std::max(res.height, kMinDimension); | 405 init_height = std::max(res.height, kMinDimension); |
405 ALOGD << "Scaled resolution: " << init_width << " x " << init_height; | 406 ALOGD << "Scaled resolution: " << init_width << " x " << init_height; |
406 } | 407 } |
407 | 408 |
408 return codec_thread_->Invoke<int32_t>( | 409 return codec_thread_->Invoke<int32_t>( |
409 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, | 410 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, |
410 this, | 411 this, |
411 init_width, | 412 init_width, |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 } | 1260 } |
1260 | 1261 |
1261 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1262 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1262 webrtc::VideoEncoder* encoder) { | 1263 webrtc::VideoEncoder* encoder) { |
1263 ALOGD << "Destroy video encoder."; | 1264 ALOGD << "Destroy video encoder."; |
1264 delete encoder; | 1265 delete encoder; |
1265 } | 1266 } |
1266 | 1267 |
1267 } // namespace webrtc_jni | 1268 } // namespace webrtc_jni |
1268 | 1269 |
OLD | NEW |