webrtc/sdk/objc/Framework/Classes
David Porter 25cc8ad198 Fixed issue with BGRA RTCCVPixelBuffer scale and crop
BGRA RTCCVPixelBuffers were cropped and scaled incorrectly. Libyuv’s
`ARGBScale` method is used in RTCCVPixelBuffer to scale and crop the
pixel buffer. To crop by `cropX` and `cropY` pixels, pointer
arithmetic is used to offset the src pointer of the original pixel
buffer bytes. There is a bug in how this offset is calculated.

The offset is done by `src += srcStride * _cropY + _cropX`. Libyuv
expects that the src pointer will point to the start of a new pixel.
However, if _cropX is a not a multiple of 4 (4 bytes for BGRA), the src
pointer will point to a byte in the middle of a pixel and thus libyuv
will incorrectly treat the data as the start of pixel (incorrectly
treating the first byte as red when it is actually green, etc...). To
fix this, the src pointer needs to be offset to always point to the
start of a new pixel.

Before this change:

Original Test Gradient image with a cropX of 2:
https://i.imgur.com/gSIgwGV.jpg

Scaled image (notice the colors are incorrect):
https://i.imgur.com/oPxbTEK.jpg

After this change:

Scaled image (notice the colors are correct):
https://i.imgur.com/dqBsmsH.jpg

A new unit test which tests scaling with cropX and cropY values has been
added. The test fails without this change and now passes with the
correct src pointer offsetting.

Bug: webrtc:9555
Change-Id: I87cbd7b91bc139d51fb4e11cc50ccb014cfa8051
Reviewed-on: https://webrtc-review.googlesource.com/89220
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24076}
2018-07-24 08:23:26 +00:00
..
Audio Clear interrupted flag on CallKit audio activation. 2018-07-11 19:01:46 +00:00
Common Make the default severity level of RTCCallbackLogger match the comment on its header. 2018-07-10 08:43:58 +00:00
Metal Reformat the WebRTC code base 2018-06-19 14:00:39 +00:00
PeerConnection Added API to Objective-C PeerConnectionFactoryOptions to enable GCM Ciphers. 2018-07-18 18:10:26 +00:00
UI iOS SDK 10.0 compatability. 2018-05-31 07:28:34 +00:00
Video Fixed issue with BGRA RTCCVPixelBuffer scale and crop 2018-07-24 08:23:26 +00:00
VideoToolbox Replace rtc::Optional with absl::optional 2018-06-21 09:32:56 +00:00