Use VideoFrameBuffer::Scale in encoder wrappers

This sincludes the SimulcastEncoderAdapter and the
VideoEncoderSoftwareFallbackWrapper. This avoids converting
the frame when that is not needed.

Bug: webrtc:11976
Change-Id: I686725ecfb79c3b8d87d587a907da1602483bfe8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/187343
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#32389}
This commit is contained in:
Evan Shrubsole
2020-10-12 14:43:39 +02:00
committed by Commit Bot
parent 84524e6b19
commit 5089a8ea14
2 changed files with 14 additions and 9 deletions

View File

@ -367,9 +367,12 @@ int32_t VideoEncoderSoftwareFallbackWrapper::EncodeWithMainEncoder(
RTC_LOG(LS_ERROR) << "Failed to convert from to I420";
return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE;
}
rtc::scoped_refptr<I420Buffer> dst_buffer =
I420Buffer::Create(codec_settings_.width, codec_settings_.height);
dst_buffer->ScaleFrom(*src_buffer);
rtc::scoped_refptr<VideoFrameBuffer> dst_buffer =
src_buffer->Scale(codec_settings_.width, codec_settings_.height);
if (!dst_buffer) {
RTC_LOG(LS_ERROR) << "Failed to scale video frame.";
return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE;
}
VideoFrame scaled_frame = frame;
scaled_frame.set_video_frame_buffer(dst_buffer);
scaled_frame.set_update_rect(VideoFrame::UpdateRect{