From cfff652c82d65a14d1ec4be73f3b42ded4fe0624 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaevskiy Date: Fri, 3 May 2019 14:34:35 +0200 Subject: [PATCH] Don't invalidate whole update_rect if buffer conversion didn't change any pixels Bug: webrtc:10310,chromium:930186 Change-Id: Ib7c9937fc376cc6b0ce63538768623e9edbe221f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135123 Reviewed-by: Niels Moller Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/master@{#27859} --- video/video_stream_encoder.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 1fc4df70ae..f119acdc65 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -1335,14 +1335,15 @@ void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame, return; } - // UpdatedRect is reset to full update if it's not empty, because buffer was - // converted, therefore we can't guarantee that pixels outside of UpdateRect - // didn't change comparing to the previous frame. - VideoFrame::UpdateRect update_rect = - out_frame.update_rect().IsEmpty() - ? out_frame.update_rect() - : VideoFrame::UpdateRect{0, 0, out_frame.width(), - out_frame.height()}; + VideoFrame::UpdateRect update_rect = out_frame.update_rect(); + if (!update_rect.IsEmpty() && + out_frame.video_frame_buffer()->GetI420() == nullptr) { + // UpdatedRect is reset to full update if it's not empty, and buffer was + // converted, therefore we can't guarantee that pixels outside of + // UpdateRect didn't change comparing to the previous frame. + update_rect = + VideoFrame::UpdateRect{0, 0, out_frame.width(), out_frame.height()}; + } out_frame = VideoFrame::Builder() .set_video_frame_buffer(converted_buffer)