MediaCodecVideoEncoder: Add QP stats to Encoded callback for VP9 and turn on quality scaling.
Add default QP scaling thresholds for VP9. BUG=webrtc:7662 Review-Url: https://codereview.webrtc.org/2914363002 Cr-Commit-Position: refs/heads/master@{#18469}
This commit is contained in:
@ -421,6 +421,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings(
|
|||||||
// VP9 denoising is disabled by default.
|
// VP9 denoising is disabled by default.
|
||||||
vp9_settings.denoisingOn = codec_default_denoising ? true : denoising;
|
vp9_settings.denoisingOn = codec_default_denoising ? true : denoising;
|
||||||
vp9_settings.frameDroppingOn = frame_dropping;
|
vp9_settings.frameDroppingOn = frame_dropping;
|
||||||
|
vp9_settings.automaticResizeOn = automatic_resize;
|
||||||
return new rtc::RefCountedObject<
|
return new rtc::RefCountedObject<
|
||||||
webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
|
webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,11 @@ static const int kHighH264QpThreshold = 37;
|
|||||||
// bitstream range of [0, 127] and not the user-level range of [0,63].
|
// bitstream range of [0, 127] and not the user-level range of [0,63].
|
||||||
static const int kLowVp8QpThreshold = 29;
|
static const int kLowVp8QpThreshold = 29;
|
||||||
static const int kHighVp8QpThreshold = 95;
|
static const int kHighVp8QpThreshold = 95;
|
||||||
|
// QP is obtained from VP9-bitstream for HW, so the QP corresponds to the
|
||||||
|
// bitstream range of [0, 255] and not the user-level range of [0,63].
|
||||||
|
// Current VP9 settings are mapped from VP8 thresholds above.
|
||||||
|
static const int kLowVp9QpThreshold = 96;
|
||||||
|
static const int kHighVp9QpThreshold = 208;
|
||||||
static const int kMinFramesNeededToScale = 2 * 30;
|
static const int kMinFramesNeededToScale = 2 * 30;
|
||||||
|
|
||||||
static VideoEncoder::QpThresholds CodecTypeToDefaultThresholds(
|
static VideoEncoder::QpThresholds CodecTypeToDefaultThresholds(
|
||||||
@ -54,6 +59,10 @@ static VideoEncoder::QpThresholds CodecTypeToDefaultThresholds(
|
|||||||
low = kLowVp8QpThreshold;
|
low = kLowVp8QpThreshold;
|
||||||
high = kHighVp8QpThreshold;
|
high = kHighVp8QpThreshold;
|
||||||
break;
|
break;
|
||||||
|
case kVideoCodecVP9:
|
||||||
|
low = kLowVp9QpThreshold;
|
||||||
|
high = kHighVp9QpThreshold;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
RTC_NOTREACHED() << "Invalid codec type for QualityScaler.";
|
RTC_NOTREACHED() << "Invalid codec type for QualityScaler.";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ include_rules = [
|
|||||||
"+webrtc/common_video/libyuv/include/webrtc_libyuv.h",
|
"+webrtc/common_video/libyuv/include/webrtc_libyuv.h",
|
||||||
"+webrtc/modules/utility/include/jvm_android.h",
|
"+webrtc/modules/utility/include/jvm_android.h",
|
||||||
"+webrtc/modules/video_coding/utility/vp8_header_parser.h",
|
"+webrtc/modules/video_coding/utility/vp8_header_parser.h",
|
||||||
|
"+webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h",
|
||||||
"+webrtc/pc",
|
"+webrtc/pc",
|
||||||
"+webrtc/system_wrappers/include/field_trial_default.h",
|
"+webrtc/system_wrappers/include/field_trial_default.h",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||||
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
||||||
#include "webrtc/modules/video_coding/utility/vp8_header_parser.h"
|
#include "webrtc/modules/video_coding/utility/vp8_header_parser.h"
|
||||||
|
#include "webrtc/modules/video_coding/utility/vp9_uncompressed_header_parser.h"
|
||||||
#include "webrtc/sdk/android/src/jni/androidmediacodeccommon.h"
|
#include "webrtc/sdk/android/src/jni/androidmediacodeccommon.h"
|
||||||
#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
|
#include "webrtc/sdk/android/src/jni/classreferenceholder.h"
|
||||||
#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
|
#include "webrtc/sdk/android/src/jni/native_handle_impl.h"
|
||||||
@ -404,12 +405,14 @@ int32_t MediaCodecVideoEncoder::InitEncode(
|
|||||||
codec_mode_ = codec_settings->mode;
|
codec_mode_ = codec_settings->mode;
|
||||||
int init_width = codec_settings->width;
|
int init_width = codec_settings->width;
|
||||||
int init_height = codec_settings->height;
|
int init_height = codec_settings->height;
|
||||||
// Scaling is disabled for VP9, but optionally enabled for VP8.
|
// Scaling is optionally enabled for VP8 and VP9.
|
||||||
// TODO(pbos): Extract automaticResizeOn out of VP8 settings.
|
// TODO(pbos): Extract automaticResizeOn out of VP8 settings.
|
||||||
scale_ = false;
|
scale_ = false;
|
||||||
if (codec_type == kVideoCodecVP8) {
|
if (codec_type == kVideoCodecVP8) {
|
||||||
scale_ = codec_settings->VP8().automaticResizeOn;
|
scale_ = codec_settings->VP8().automaticResizeOn;
|
||||||
} else if (codec_type != kVideoCodecVP9) {
|
} else if (codec_type == kVideoCodecVP9) {
|
||||||
|
scale_ = codec_settings->VP9().automaticResizeOn;
|
||||||
|
} else {
|
||||||
scale_ = true;
|
scale_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1104,6 +1107,12 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
|
|||||||
current_acc_qp_ += qp;
|
current_acc_qp_ += qp;
|
||||||
image->qp_ = qp;
|
image->qp_ = qp;
|
||||||
}
|
}
|
||||||
|
} else if (codec_type == kVideoCodecVP9) {
|
||||||
|
int qp;
|
||||||
|
if (webrtc::vp9::GetQp(payload, payload_size, &qp)) {
|
||||||
|
current_acc_qp_ += qp;
|
||||||
|
image->qp_ = qp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (codec_type == kVideoCodecH264) {
|
} else if (codec_type == kVideoCodecH264) {
|
||||||
h264_bitstream_parser_.ParseBitstream(payload, payload_size);
|
h264_bitstream_parser_.ParseBitstream(payload, payload_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user