Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Unified Diff: webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm

Issue 2205763002: Disable encoder scaling on iPhone4S. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
similarity index 97%
rename from webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc
rename to webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
index 4cbe2cd0bff1df04eef1ee04190311fd6fbc7541..f92bd8d4006f6cf93b0033146e3f587871422be9 100644
--- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc
+++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
@@ -18,6 +18,7 @@
#include <vector>
#if defined(WEBRTC_IOS)
+#import "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,8 +247,10 @@ 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.
- width_ = res.width;
- height_ = res.height;
+ 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;
@@ -264,7 +276,11 @@ H264VideoToolboxEncoder::GetScaledBufferOnEncode(
return frame;
// TODO(magjed): Implement efficient CVImageRef -> CVImageRef scaling instead
// of doing it via I420.
- return quality_scaler_.GetScaledBuffer(frame->NativeToI420Buffer());
+ if (enable_scaling_) {
+ return quality_scaler_.GetScaledBuffer(frame->NativeToI420Buffer());
+ } else {
+ return frame;
+ }
}
int H264VideoToolboxEncoder::Encode(

Powered by Google App Engine
This is Rietveld 408576698