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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
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, codec_settings->width, | 385 codec_settings->startBitrate, |
386 codec_settings->height, | 386 codec_settings->width, codec_settings->height); |
387 codec_settings->maxFramerate); | |
388 } else if (codecType_ == kVideoCodecH264) { | 387 } else if (codecType_ == kVideoCodecH264) { |
389 // H264 QP is in the range [0, 51]. | 388 // H264 QP is in the range [0, 51]. |
390 const int kLowQpThreshold = 21; | 389 const int kLowQpThreshold = 21; |
391 const int kBadQpThreshold = 36; | 390 const int kBadQpThreshold = 36; |
392 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, | 391 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, |
393 codec_settings->startBitrate, codec_settings->width, | 392 codec_settings->startBitrate, |
394 codec_settings->height, | 393 codec_settings->width, codec_settings->height); |
395 codec_settings->maxFramerate); | |
396 } else { | 394 } else { |
397 // When adding codec support to additional hardware codecs, also configure | 395 // When adding codec support to additional hardware codecs, also configure |
398 // their QP thresholds for scaling. | 396 // their QP thresholds for scaling. |
399 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; | 397 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; |
400 scale_ = false; | 398 scale_ = false; |
401 } | 399 } |
402 quality_scaler_.SetMinResolution(kMinDimension, kMinDimension); | 400 quality_scaler_.SetMinResolution(kMinDimension, kMinDimension); |
| 401 quality_scaler_.ReportFramerate(codec_settings->maxFramerate); |
403 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); | 402 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); |
404 init_width = std::max(res.width, kMinDimension); | 403 init_width = std::max(res.width, kMinDimension); |
405 init_height = std::max(res.height, kMinDimension); | 404 init_height = std::max(res.height, kMinDimension); |
406 ALOGD << "Scaled resolution: " << init_width << " x " << init_height; | 405 ALOGD << "Scaled resolution: " << init_width << " x " << init_height; |
407 } | 406 } |
408 | 407 |
409 return codec_thread_->Invoke<int32_t>( | 408 return codec_thread_->Invoke<int32_t>( |
410 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, | 409 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, |
411 this, | 410 this, |
412 init_width, | 411 init_width, |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 } | 1259 } |
1261 | 1260 |
1262 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1261 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1263 webrtc::VideoEncoder* encoder) { | 1262 webrtc::VideoEncoder* encoder) { |
1264 ALOGD << "Destroy video encoder."; | 1263 ALOGD << "Destroy video encoder."; |
1265 delete encoder; | 1264 delete encoder; |
1266 } | 1265 } |
1267 | 1266 |
1268 } // namespace webrtc_jni | 1267 } // namespace webrtc_jni |
1269 | 1268 |
OLD | NEW |