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

Side by Side Diff: webrtc/api/java/jni/androidmediaencoder_jni.cc

Issue 1867643003: Make QualityScaler not downscale below QVGA. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: update test Created 4 years, 8 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 | webrtc/modules/video_coding/utility/quality_scaler.h » ('j') | 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 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 jni, j_output_buffer_info_class, "presentationTimestampUs", "J"); 345 jni, j_output_buffer_info_class, "presentationTimestampUs", "J");
346 CHECK_EXCEPTION(jni) << "MediaCodecVideoEncoder ctor failed"; 346 CHECK_EXCEPTION(jni) << "MediaCodecVideoEncoder ctor failed";
347 srand(time(NULL)); 347 srand(time(NULL));
348 AllowBlockingCalls(); 348 AllowBlockingCalls();
349 } 349 }
350 350
351 int32_t MediaCodecVideoEncoder::InitEncode( 351 int32_t MediaCodecVideoEncoder::InitEncode(
352 const webrtc::VideoCodec* codec_settings, 352 const webrtc::VideoCodec* codec_settings,
353 int32_t /* number_of_cores */, 353 int32_t /* number_of_cores */,
354 size_t /* max_payload_size */) { 354 size_t /* max_payload_size */) {
355 const int kMinDimension = 180;
356 if (codec_settings == NULL) { 355 if (codec_settings == NULL) {
357 ALOGE << "NULL VideoCodec instance"; 356 ALOGE << "NULL VideoCodec instance";
358 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 357 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
359 } 358 }
360 // Factory should guard against other codecs being used with us. 359 // Factory should guard against other codecs being used with us.
361 RTC_CHECK(codec_settings->codecType == codecType_) 360 RTC_CHECK(codec_settings->codecType == codecType_)
362 << "Unsupported codec " << codec_settings->codecType << " for " 361 << "Unsupported codec " << codec_settings->codecType << " for "
363 << codecType_; 362 << codecType_;
364 363
365 codec_mode_ = codec_settings->mode; 364 codec_mode_ = codec_settings->mode;
(...skipping 23 matching lines...) Expand all
389 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false, 388 quality_scaler_.Init(kLowQpThreshold, kBadQpThreshold, false,
390 codec_settings->startBitrate, codec_settings->width, 389 codec_settings->startBitrate, codec_settings->width,
391 codec_settings->height, 390 codec_settings->height,
392 codec_settings->maxFramerate); 391 codec_settings->maxFramerate);
393 } else { 392 } else {
394 // When adding codec support to additional hardware codecs, also configure 393 // When adding codec support to additional hardware codecs, also configure
395 // their QP thresholds for scaling. 394 // their QP thresholds for scaling.
396 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds."; 395 RTC_NOTREACHED() << "Unsupported codec without configured QP thresholds.";
397 scale_ = false; 396 scale_ = false;
398 } 397 }
399 quality_scaler_.SetMinResolution(kMinDimension, kMinDimension);
400 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); 398 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution();
401 init_width = std::max(res.width, kMinDimension); 399 init_width = res.width;
402 init_height = std::max(res.height, kMinDimension); 400 init_height = res.height;
403 ALOGD << "Scaled resolution: " << init_width << " x " << init_height; 401 ALOGD << "Scaled resolution: " << init_width << " x " << init_height;
404 } 402 }
405 403
406 return codec_thread_->Invoke<int32_t>( 404 return codec_thread_->Invoke<int32_t>(
407 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread, 405 Bind(&MediaCodecVideoEncoder::InitEncodeOnCodecThread,
408 this, 406 this,
409 init_width, 407 init_width,
410 init_height, 408 init_height,
411 codec_settings->startBitrate, 409 codec_settings->startBitrate,
412 codec_settings->maxFramerate, 410 codec_settings->maxFramerate,
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 } 1250 }
1253 1251
1254 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( 1252 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder(
1255 webrtc::VideoEncoder* encoder) { 1253 webrtc::VideoEncoder* encoder) {
1256 ALOGD << "Destroy video encoder."; 1254 ALOGD << "Destroy video encoder.";
1257 delete encoder; 1255 delete encoder;
1258 } 1256 }
1259 1257
1260 } // namespace webrtc_jni 1258 } // namespace webrtc_jni
1261 1259
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/utility/quality_scaler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698