OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 scale_ = webrtc::field_trial::FindFullName( | 299 scale_ = webrtc::field_trial::FindFullName( |
300 "WebRTC-MediaCodecVideoEncoder-AutomaticResize") == "Enabled"; | 300 "WebRTC-MediaCodecVideoEncoder-AutomaticResize") == "Enabled"; |
301 ALOGD("Automatic resize: %s", scale_ ? "enabled" : "disabled"); | 301 ALOGD("Automatic resize: %s", scale_ ? "enabled" : "disabled"); |
302 if (scale_) { | 302 if (scale_) { |
303 if (codecType_ == kVideoCodecVP8) { | 303 if (codecType_ == kVideoCodecVP8) { |
304 // QP is obtained from VP8-bitstream for HW, so the QP corresponds to the | 304 // QP is obtained from VP8-bitstream for HW, so the QP corresponds to the |
305 // (internal) range: [0, 127]. And we cannot change QP_max in HW, so it is | 305 // (internal) range: [0, 127]. And we cannot change QP_max in HW, so it is |
306 // always = 127. Note that in SW, QP is that of the user-level range [0, | 306 // always = 127. Note that in SW, QP is that of the user-level range [0, |
307 // 63]. | 307 // 63]. |
308 const int kMaxQp = 127; | 308 const int kMaxQp = 127; |
309 quality_scaler_.Init(kMaxQp / kLowQpThresholdDenominator, true); | 309 // TODO(pbos): Investigate whether high-QP thresholds make sense for VP8. |
| 310 // This effectively disables high QP as VP8 QP can't go above this |
| 311 // threshold. |
| 312 const int kDisabledBadQpThreshold = kMaxQp + 1; |
| 313 quality_scaler_.Init(kMaxQp / kLowQpThresholdDenominator, |
| 314 kDisabledBadQpThreshold, true); |
310 } else if (codecType_ == kVideoCodecH264) { | 315 } else if (codecType_ == kVideoCodecH264) { |
311 // H264 QP is in the range [0, 51]. | 316 // H264 QP is in the range [0, 51]. |
312 const int kMaxQp = 51; | 317 const int kMaxQp = 51; |
313 quality_scaler_.Init(kMaxQp / kLowQpThresholdDenominator, true); | 318 const int kBadQpThreshold = 40; |
| 319 quality_scaler_.Init(kMaxQp / kLowQpThresholdDenominator, kBadQpThreshold, |
| 320 false); |
314 } else { | 321 } else { |
315 // When adding codec support to additional hardware codecs, also configure | 322 // When adding codec support to additional hardware codecs, also configure |
316 // their QP thresholds for scaling. | 323 // their QP thresholds for scaling. |
317 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; | 324 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; |
318 } | 325 } |
319 quality_scaler_.SetMinResolution(kMinWidth, kMinHeight); | 326 quality_scaler_.SetMinResolution(kMinWidth, kMinHeight); |
320 quality_scaler_.ReportFramerate(codec_settings->maxFramerate); | 327 quality_scaler_.ReportFramerate(codec_settings->maxFramerate); |
321 } | 328 } |
322 return codec_thread_->Invoke<int32_t>( | 329 return codec_thread_->Invoke<int32_t>( |
323 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, | 330 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 } | 949 } |
943 | 950 |
944 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 951 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
945 webrtc::VideoEncoder* encoder) { | 952 webrtc::VideoEncoder* encoder) { |
946 ALOGD("Destroy video encoder."); | 953 ALOGD("Destroy video encoder."); |
947 delete encoder; | 954 delete encoder; |
948 } | 955 } |
949 | 956 |
950 } // namespace webrtc_jni | 957 } // namespace webrtc_jni |
951 | 958 |
OLD | NEW |