Disable encoder scaling on iPhone4S.
Scaling causes us to work the CPU too much, which very quickly degrades quality. This causes us to at least behave better on good networks. NOTRY=True BUG= Review-Url: https://codereview.webrtc.org/2205763002 Cr-Commit-Position: refs/heads/master@{#13630}
This commit is contained in:
@ -179,8 +179,8 @@ if (is_ios) {
|
||||
sources = [
|
||||
"codecs/h264/h264_video_toolbox_decoder.cc",
|
||||
"codecs/h264/h264_video_toolbox_decoder.h",
|
||||
"codecs/h264/h264_video_toolbox_encoder.cc",
|
||||
"codecs/h264/h264_video_toolbox_encoder.h",
|
||||
"codecs/h264/h264_video_toolbox_encoder.mm",
|
||||
"codecs/h264/h264_video_toolbox_nalu.cc",
|
||||
"codecs/h264/h264_video_toolbox_nalu.h",
|
||||
]
|
||||
|
||||
@ -79,8 +79,8 @@
|
||||
'sources': [
|
||||
'h264_video_toolbox_decoder.cc',
|
||||
'h264_video_toolbox_decoder.h',
|
||||
'h264_video_toolbox_encoder.cc',
|
||||
'h264_video_toolbox_encoder.h',
|
||||
'h264_video_toolbox_encoder.mm',
|
||||
'h264_video_toolbox_nalu.cc',
|
||||
'h264_video_toolbox_nalu.h',
|
||||
],
|
||||
|
||||
@ -88,6 +88,7 @@ class H264VideoToolboxEncoder : public H264Encoder {
|
||||
rtc::CriticalSection quality_scaler_crit_;
|
||||
QualityScaler quality_scaler_ GUARDED_BY(quality_scaler_crit_);
|
||||
H264BitstreamParser h264_bitstream_parser_;
|
||||
bool enable_scaling_;
|
||||
}; // H264VideoToolboxEncoder
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
#if defined(WEBRTC_IOS)
|
||||
#import "WebRTC/UIDevice+RTCDevice.h"
|
||||
#include "RTCUIApplication.h"
|
||||
#endif
|
||||
#include "libyuv/convert_from.h"
|
||||
@ -217,7 +218,14 @@ namespace webrtc {
|
||||
H264VideoToolboxEncoder::H264VideoToolboxEncoder()
|
||||
: callback_(nullptr),
|
||||
compression_session_(nullptr),
|
||||
bitrate_adjuster_(Clock::GetRealTimeClock(), .5, .95) {}
|
||||
bitrate_adjuster_(Clock::GetRealTimeClock(), .5, .95),
|
||||
enable_scaling_(true) {
|
||||
#if defined(WEBRTC_IOS)
|
||||
if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) {
|
||||
enable_scaling_ = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
H264VideoToolboxEncoder::~H264VideoToolboxEncoder() {
|
||||
DestroyCompressionSession();
|
||||
@ -228,6 +236,8 @@ int H264VideoToolboxEncoder::InitEncode(const VideoCodec* codec_settings,
|
||||
size_t max_payload_size) {
|
||||
RTC_DCHECK(codec_settings);
|
||||
RTC_DCHECK_EQ(codec_settings->codecType, kVideoCodecH264);
|
||||
width_ = codec_settings->width;
|
||||
height_ = codec_settings->height;
|
||||
{
|
||||
rtc::CritScope lock(&quality_scaler_crit_);
|
||||
quality_scaler_.Init(QualityScaler::kLowH264QpThreshold,
|
||||
@ -237,9 +247,11 @@ int H264VideoToolboxEncoder::InitEncode(const VideoCodec* codec_settings,
|
||||
QualityScaler::Resolution res = quality_scaler_.GetScaledResolution();
|
||||
// TODO(tkchin): We may need to enforce width/height dimension restrictions
|
||||
// to match what the encoder supports.
|
||||
if (enable_scaling_) {
|
||||
width_ = res.width;
|
||||
height_ = res.height;
|
||||
}
|
||||
}
|
||||
// We can only set average bitrate on the HW encoder.
|
||||
target_bitrate_bps_ = codec_settings->startBitrate;
|
||||
bitrate_adjuster_.SetTargetBitrateBps(target_bitrate_bps_);
|
||||
@ -260,7 +272,8 @@ H264VideoToolboxEncoder::GetScaledBufferOnEncode(
|
||||
|
||||
// Handle native (CVImageRef) scaling.
|
||||
const QualityScaler::Resolution res = quality_scaler_.GetScaledResolution();
|
||||
if (res.width == frame->width() && res.height == frame->height())
|
||||
if (!enable_scaling_ ||
|
||||
(res.width == frame->width() && res.height == frame->height()))
|
||||
return frame;
|
||||
// TODO(magjed): Implement efficient CVImageRef -> CVImageRef scaling instead
|
||||
// of doing it via I420.
|
||||
@ -582,6 +582,7 @@ AVFoundationVideoCapturer::AVFoundationVideoCapturer()
|
||||
#if TARGET_OS_IPHONE
|
||||
if ([UIDevice deviceType] == RTCDeviceTypeIPhone4S) {
|
||||
supported_formats.push_back(cricket::VideoFormat(kIPhone4SFormat));
|
||||
set_enable_video_adapter(false);
|
||||
} else {
|
||||
supported_formats.push_back(cricket::VideoFormat(kDefaultFormat));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user