Chromium Code Reviews| Index: webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc |
| diff --git a/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc b/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc |
| index 92406ec107c0b4fc8365f0b7e26e2eec69efa223..3d35bcc9bf6eb539900355408d7a0dc7e1ad4035 100644 |
| --- a/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc |
| +++ b/webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc |
| @@ -86,6 +86,7 @@ namespace { |
| const size_t kFrameDiffThresholdMs = 350; |
| const int kMinKeyFrameInterval = 6; |
| const char kH264HighProfileFieldTrial[] = "WebRTC-H264HighProfile"; |
| +const char kCustomQPThresholdsFieldTrial[] = "WebRTC-CustomQPThresholds"; |
| } // namespace |
| // MediaCodecVideoEncoder is a webrtc::VideoEncoder implementation that uses |
| @@ -180,6 +181,8 @@ class MediaCodecVideoEncoder : public webrtc::VideoEncoder { |
| // Displays encoder statistics. |
| void LogStatistics(bool force_log); |
| + VideoCodecType GetCodecType() const; |
|
kthelgason
2017/03/22 07:38:58
Thanks for cleaning this up!
|
| + |
| #if RTC_DCHECK_IS_ON |
| // Mutex for protecting inited_. It is only used for correctness checking on |
| // debug build. It is used for checking that encoder has been released in the |
| @@ -384,8 +387,7 @@ int32_t MediaCodecVideoEncoder::InitEncode( |
| return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
| } |
| // Factory should guard against other codecs being used with us. |
| - const VideoCodecType codec_type = webrtc::PayloadNameToCodecType(codec_.name) |
| - .value_or(webrtc::kVideoCodecUnknown); |
| + const VideoCodecType codec_type = GetCodecType(); |
| RTC_CHECK(codec_settings->codecType == codec_type) |
| << "Unsupported codec " << codec_settings->codecType << " for " |
| << codec_type; |
| @@ -498,6 +500,11 @@ int32_t MediaCodecVideoEncoder::ProcessHWErrorOnEncode() { |
| : WEBRTC_VIDEO_CODEC_ERROR; |
| } |
| +VideoCodecType MediaCodecVideoEncoder::GetCodecType() const { |
| + return webrtc::PayloadNameToCodecType(codec_.name) |
| + .value_or(webrtc::kVideoCodecUnknown); |
| +} |
| + |
| int32_t MediaCodecVideoEncoder::InitEncodeInternal(int width, |
| int height, |
| int kbps, |
| @@ -511,8 +518,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeInternal(int width, |
| JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
| ScopedLocalRefFrame local_ref_frame(jni); |
| - const VideoCodecType codec_type = webrtc::PayloadNameToCodecType(codec_.name) |
| - .value_or(webrtc::kVideoCodecUnknown); |
| + const VideoCodecType codec_type = GetCodecType(); |
| ALOGD << "InitEncodeInternal Type: " << (int)codec_type << ", " << width |
| << " x " << height << ". Bitrate: " << kbps << " kbps. Fps: " << fps; |
| if (kbps == 0) { |
| @@ -1022,9 +1028,7 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) { |
| } |
| // Callback - return encoded frame. |
| - const VideoCodecType codec_type = |
| - webrtc::PayloadNameToCodecType(codec_.name) |
| - .value_or(webrtc::kVideoCodecUnknown); |
| + const VideoCodecType codec_type = GetCodecType(); |
| webrtc::EncodedImageCallback::Result callback_result( |
| webrtc::EncodedImageCallback::Result::OK); |
| if (callback_) { |
| @@ -1186,6 +1190,33 @@ void MediaCodecVideoEncoder::LogStatistics(bool force_log) { |
| webrtc::VideoEncoder::ScalingSettings |
| MediaCodecVideoEncoder::GetScalingSettings() const { |
| + if (webrtc::field_trial::IsEnabled(kCustomQPThresholdsFieldTrial)) { |
| + const VideoCodecType codec_type = GetCodecType(); |
| + std::string experiment_string = |
| + webrtc::field_trial::FindFullName(kCustomQPThresholdsFieldTrial); |
| + ALOGD << "QP custom thresholds: " << experiment_string << " for codec " |
|
stefan-webrtc
2017/03/23 17:58:04
LOG(LS_INFO) or similar?
AlexG
2017/03/23 19:25:08
ALOGD is used now for all logging in this file - t
|
| + << codec_type; |
| + int lowVp8QpThreshold; |
| + int highVp8QpThreshold; |
| + int lowH264QpThreshold; |
| + int highH264QpThreshold; |
|
stefan-webrtc
2017/03/23 17:58:04
No camelCase
AlexG
2017/03/23 19:25:08
Done.
|
| + int parsed_values = sscanf(experiment_string.c_str(), "Enabled-%u,%u,%u,%u", |
| + &lowVp8QpThreshold, &highVp8QpThreshold, |
| + &lowH264QpThreshold, &highH264QpThreshold); |
| + if (parsed_values == 4) { |
| + RTC_CHECK_GT(highVp8QpThreshold, lowVp8QpThreshold); |
| + RTC_CHECK_GT(lowVp8QpThreshold, 0); |
| + RTC_CHECK_GT(highH264QpThreshold, lowH264QpThreshold); |
| + RTC_CHECK_GT(lowH264QpThreshold, 0); |
| + if (codec_type == kVideoCodecVP8) { |
| + return VideoEncoder::ScalingSettings(scale_, lowVp8QpThreshold, |
| + highVp8QpThreshold); |
| + } else if (codec_type == kVideoCodecH264) { |
| + return VideoEncoder::ScalingSettings(scale_, lowH264QpThreshold, |
| + highH264QpThreshold); |
| + } |
| + } |
| + } |
| return VideoEncoder::ScalingSettings(scale_); |
| } |