Index: webrtc/api/java/jni/androidmediaencoder_jni.cc |
diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc |
index ce1ebc17c07749a00be658de0f08910f0e606d6c..20dc1509e0412b9e18353deadec9033f9f8bdd2f 100644 |
--- a/webrtc/api/java/jni/androidmediaencoder_jni.cc |
+++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc |
@@ -670,7 +670,8 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread( |
} |
consecutive_full_queue_frame_drops_ = 0; |
- VideoFrame input_frame = frame; |
+ rtc::scoped_refptr<webrtc::VideoFrameBuffer> input_buffer( |
+ frame.video_frame_buffer()); |
if (scale_) { |
// Check framerate before spatial resolution change. |
quality_scaler_.OnEncodeFrame(frame.width(), frame.height()); |
@@ -678,21 +679,22 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread( |
quality_scaler_.GetScaledResolution(); |
if (scaled_resolution.width != frame.width() || |
scaled_resolution.height != frame.height()) { |
- if (frame.video_frame_buffer()->native_handle() != nullptr) { |
- rtc::scoped_refptr<webrtc::VideoFrameBuffer> scaled_buffer( |
- static_cast<AndroidTextureBuffer*>( |
- frame.video_frame_buffer().get())->CropScaleAndRotate( |
- frame.width(), frame.height(), 0, 0, |
- scaled_resolution.width, scaled_resolution.height, |
- webrtc::kVideoRotation_0)); |
- input_frame.set_video_frame_buffer(scaled_buffer); |
+ if (input_buffer->native_handle() != nullptr) { |
+ input_buffer = static_cast<AndroidTextureBuffer*>(input_buffer.get()) |
+ ->CropScaleAndRotate(frame.width(), frame.height(), |
+ 0, 0, |
+ scaled_resolution.width, |
+ scaled_resolution.height, |
+ webrtc::kVideoRotation_0); |
} else { |
- input_frame.set_video_frame_buffer( |
- quality_scaler_.GetScaledBuffer(frame.video_frame_buffer())); |
+ input_buffer = quality_scaler_.GetScaledBuffer(input_buffer); |
} |
} |
} |
+ VideoFrame input_frame(input_buffer, frame.timestamp(), |
+ frame.render_time_ms(), frame.rotation()); |
+ |
if (!MaybeReconfigureEncoderOnCodecThread(input_frame)) { |
ALOGE << "Failed to reconfigure encoder."; |
return WEBRTC_VIDEO_CODEC_ERROR; |