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

Side by Side Diff: talk/app/webrtc/java/jni/androidmediaencoder_jni.cc

Issue 1351573002: Add field trial for automic resize in MediaCodecVideoEncoder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
29 #include "talk/app/webrtc/java/jni/androidmediaencoder_jni.h" 29 #include "talk/app/webrtc/java/jni/androidmediaencoder_jni.h"
30 #include "talk/app/webrtc/java/jni/classreferenceholder.h" 30 #include "talk/app/webrtc/java/jni/classreferenceholder.h"
31 #include "talk/app/webrtc/java/jni/androidmediacodeccommon.h" 31 #include "talk/app/webrtc/java/jni/androidmediacodeccommon.h"
32 #include "webrtc/base/bind.h" 32 #include "webrtc/base/bind.h"
33 #include "webrtc/base/checks.h" 33 #include "webrtc/base/checks.h"
34 #include "webrtc/base/logging.h" 34 #include "webrtc/base/logging.h"
35 #include "webrtc/base/thread.h" 35 #include "webrtc/base/thread.h"
36 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" 36 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
37 #include "webrtc/modules/video_coding/utility/include/quality_scaler.h" 37 #include "webrtc/modules/video_coding/utility/include/quality_scaler.h"
38 #include "webrtc/modules/video_coding/utility/include/vp8_header_parser.h" 38 #include "webrtc/modules/video_coding/utility/include/vp8_header_parser.h"
39 #include "webrtc/system_wrappers/interface/field_trial.h"
39 #include "webrtc/system_wrappers/interface/logcat_trace_context.h" 40 #include "webrtc/system_wrappers/interface/logcat_trace_context.h"
40 #include "third_party/libyuv/include/libyuv/convert.h" 41 #include "third_party/libyuv/include/libyuv/convert.h"
41 #include "third_party/libyuv/include/libyuv/convert_from.h" 42 #include "third_party/libyuv/include/libyuv/convert_from.h"
42 #include "third_party/libyuv/include/libyuv/video_common.h" 43 #include "third_party/libyuv/include/libyuv/video_common.h"
43 44
44 using rtc::Bind; 45 using rtc::Bind;
45 using rtc::Thread; 46 using rtc::Thread;
46 using rtc::ThreadManager; 47 using rtc::ThreadManager;
47 using rtc::scoped_ptr; 48 using rtc::scoped_ptr;
48 49
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 const int kLowQpThresholdDenominator = 3; 290 const int kLowQpThresholdDenominator = 3;
290 if (codec_settings == NULL) { 291 if (codec_settings == NULL) {
291 ALOGE("NULL VideoCodec instance"); 292 ALOGE("NULL VideoCodec instance");
292 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 293 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
293 } 294 }
294 // Factory should guard against other codecs being used with us. 295 // Factory should guard against other codecs being used with us.
295 CHECK(codec_settings->codecType == codecType_) << "Unsupported codec " << 296 CHECK(codec_settings->codecType == codecType_) << "Unsupported codec " <<
296 codec_settings->codecType << " for " << codecType_; 297 codec_settings->codecType << " for " << codecType_;
297 298
298 ALOGD("InitEncode request"); 299 ALOGD("InitEncode request");
299 scale_ = false; 300
301 scale_ = webrtc::field_trial::FindFullName(
302 "WebRTC-MediaCodecVideoEncoder-AutomaticResize") == "Enabled";
303 ALOGD("Automatic resize: %s", scale_ ? "enabled" : "disabled");
304
300 if (scale_ && codecType_ == kVideoCodecVP8) { 305 if (scale_ && codecType_ == kVideoCodecVP8) {
301 quality_scaler_->Init(kMaxQP / kLowQpThresholdDenominator, true); 306 quality_scaler_->Init(kMaxQP / kLowQpThresholdDenominator, true);
302 quality_scaler_->SetMinResolution(kMinWidth, kMinHeight); 307 quality_scaler_->SetMinResolution(kMinWidth, kMinHeight);
303 quality_scaler_->ReportFramerate(codec_settings->maxFramerate); 308 quality_scaler_->ReportFramerate(codec_settings->maxFramerate);
304 updated_framerate_ = codec_settings->maxFramerate; 309 updated_framerate_ = codec_settings->maxFramerate;
305 } else { 310 } else {
306 updated_framerate_ = -1; 311 updated_framerate_ = -1;
307 } 312 }
308 return codec_thread_->Invoke<int32_t>( 313 return codec_thread_->Invoke<int32_t>(
309 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, 314 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread,
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 934 }
930 935
931 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( 936 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder(
932 webrtc::VideoEncoder* encoder) { 937 webrtc::VideoEncoder* encoder) {
933 ALOGD("Destroy video encoder."); 938 ALOGD("Destroy video encoder.");
934 delete encoder; 939 delete encoder;
935 } 940 }
936 941
937 } // namespace webrtc_jni 942 } // namespace webrtc_jni
938 943
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698