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

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

Issue 2020593002: Refactor scaling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Trivial rebase. Created 4 years, 6 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/api/java/jni/androidvideocapturer_jni.cc » ('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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 663 }
664 frames_dropped_media_encoder_++; 664 frames_dropped_media_encoder_++;
665 OnDroppedFrameOnCodecThread(); 665 OnDroppedFrameOnCodecThread();
666 return WEBRTC_VIDEO_CODEC_OK; 666 return WEBRTC_VIDEO_CODEC_OK;
667 } 667 }
668 consecutive_full_queue_frame_drops_ = 0; 668 consecutive_full_queue_frame_drops_ = 0;
669 669
670 VideoFrame input_frame = frame; 670 VideoFrame input_frame = frame;
671 if (scale_) { 671 if (scale_) {
672 // Check framerate before spatial resolution change. 672 // Check framerate before spatial resolution change.
673 quality_scaler_.OnEncodeFrame(frame); 673 quality_scaler_.OnEncodeFrame(frame.width(), frame.height());
674 const webrtc::QualityScaler::Resolution scaled_resolution = 674 const webrtc::QualityScaler::Resolution scaled_resolution =
675 quality_scaler_.GetScaledResolution(); 675 quality_scaler_.GetScaledResolution();
676 if (scaled_resolution.width != frame.width() || 676 if (scaled_resolution.width != frame.width() ||
677 scaled_resolution.height != frame.height()) { 677 scaled_resolution.height != frame.height()) {
678 if (frame.video_frame_buffer()->native_handle() != nullptr) { 678 if (frame.video_frame_buffer()->native_handle() != nullptr) {
679 rtc::scoped_refptr<webrtc::VideoFrameBuffer> scaled_buffer( 679 rtc::scoped_refptr<webrtc::VideoFrameBuffer> scaled_buffer(
680 static_cast<AndroidTextureBuffer*>( 680 static_cast<AndroidTextureBuffer*>(
681 frame.video_frame_buffer().get())->CropScaleAndRotate( 681 frame.video_frame_buffer().get())->CropScaleAndRotate(
682 frame.width(), frame.height(), 0, 0, 682 frame.width(), frame.height(), 0, 0,
683 scaled_resolution.width, scaled_resolution.height, 683 scaled_resolution.width, scaled_resolution.height,
684 webrtc::kVideoRotation_0)); 684 webrtc::kVideoRotation_0));
685 input_frame.set_video_frame_buffer(scaled_buffer); 685 input_frame.set_video_frame_buffer(scaled_buffer);
686 } else { 686 } else {
687 input_frame = quality_scaler_.GetScaledFrame(frame); 687 input_frame.set_video_frame_buffer(
688 quality_scaler_.GetScaledBuffer(frame.video_frame_buffer()));
688 } 689 }
689 } 690 }
690 } 691 }
691 692
692 if (!MaybeReconfigureEncoderOnCodecThread(input_frame)) { 693 if (!MaybeReconfigureEncoderOnCodecThread(input_frame)) {
693 ALOGE << "Failed to reconfigure encoder."; 694 ALOGE << "Failed to reconfigure encoder.";
694 return WEBRTC_VIDEO_CODEC_ERROR; 695 return WEBRTC_VIDEO_CODEC_ERROR;
695 } 696 }
696 697
697 const int64_t time_before_calling_encode = rtc::TimeMillis(); 698 const int64_t time_before_calling_encode = rtc::TimeMillis();
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 return supported_codecs_; 1273 return supported_codecs_;
1273 } 1274 }
1274 1275
1275 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( 1276 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder(
1276 webrtc::VideoEncoder* encoder) { 1277 webrtc::VideoEncoder* encoder) {
1277 ALOGD << "Destroy video encoder."; 1278 ALOGD << "Destroy video encoder.";
1278 delete encoder; 1279 delete encoder;
1279 } 1280 }
1280 1281
1281 } // namespace webrtc_jni 1282 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/java/jni/androidvideocapturer_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698