Always call ConvertToI420 with positive crop_height

Source height may be negative, causing libyuv to invert the image.
However the height of the destination buffer specified by crop_height
should be positive. Remaining calls in common_video_unittests are valid.

Bug: webrtc:9447
Change-Id: I6d398909ae80a99d228ccbbd8c1d7ae804e5bf8d
Reviewed-on: https://webrtc-review.googlesource.com/c/86540
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25427}
This commit is contained in:
Robert Bares 2018-10-28 00:16:33 +00:00 committed by Commit Bot
parent 9862c2eb13
commit 0eb7d3ff35
2 changed files with 3 additions and 2 deletions

View File

@ -48,6 +48,7 @@ Peng Yu <yupeng323@gmail.com>
Rafael Lopez Diez <rafalopezdiez@gmail.com>
Ralph Giles <giles@ghostscript.com>
Riku Voipio <riku.voipio@linaro.org>
Robert Bares <robert@bares.me>
Robert Nagy <robert.nagy@gmail.com>
Ryan Yoakum <ryoakum@skobalt.com>
Satender Saroha <ssaroha@yahoo.com>

View File

@ -143,7 +143,7 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
int stride_y = width;
int stride_uv = (width + 1) / 2;
int target_width = width;
int target_height = height;
int target_height = abs(height);
// SetApplyRotation doesn't take any lock. Make a local copy here.
bool apply_rotation = apply_rotation_;
@ -163,7 +163,7 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
// TODO(nisse): Use a pool?
rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(
target_width, abs(target_height), stride_y, stride_uv, stride_uv);
target_width, target_height, stride_y, stride_uv, stride_uv);
libyuv::RotationMode rotation_mode = libyuv::kRotate0;
if (apply_rotation) {