From e5a6ab45d351d23c17feca2b6d1961e5f7d4eec5 Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Sat, 6 Apr 2024 21:21:18 -0700 Subject: [PATCH] RTC_CHECK crop_width_,crop_height_ are nonnegative Similar to the two RTC_CHECK_GE's earlier in the VideoStreamEncoder::ReconfigureEncoder() method (originally added to webrtc/video/vie_encoder.cc in https://codereview.webrtc.org/2936393002), add two RTC_CHECK_GE's to ensure that crop_width_ and crop_height_ are nonnegative. Bug: b:330482827 Change-Id: Ia4989307b754abb101e50d33beeca4483a694a62 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/346026 Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Sergey Silkin Commit-Queue: Wan-Teh Chang Cr-Commit-Position: refs/heads/main@{#42017} --- video/video_stream_encoder.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 2f4c6e927d..4390fe30f4 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -1186,6 +1186,8 @@ void VideoStreamEncoder::ReconfigureEncoder() { encoder_config_.codec_type == kVideoCodecAV1) { // Spatial layers configuration might impose some parity restrictions, // thus some cropping might be needed. + RTC_CHECK_GE(last_frame_info_->width, codec.width); + RTC_CHECK_GE(last_frame_info_->height, codec.height); crop_width_ = last_frame_info_->width - codec.width; crop_height_ = last_frame_info_->height - codec.height; ApplySpatialLayerBitrateLimits(