Simple, mergable fix to avoid a libyuv CopyPlane crash
Bug: chromium:1330019 Change-Id: I1a22967dff3231c1522fb94de38b309f441d468e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265442 Reviewed-by: Frank Barchard <fbarchard@google.com> Reviewed-by: Alexander Cooper <alcooper@chromium.org> Commit-Queue: Joe Downing <joedow@google.com> Cr-Commit-Position: refs/heads/main@{#37158}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
d70186367c
commit
f4a6928117
@ -45,9 +45,13 @@ void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer,
|
|||||||
RTC_CHECK(DesktopRect::MakeSize(size()).ContainsRect(dest_rect));
|
RTC_CHECK(DesktopRect::MakeSize(size()).ContainsRect(dest_rect));
|
||||||
|
|
||||||
uint8_t* dest = GetFrameDataAtPos(dest_rect.top_left());
|
uint8_t* dest = GetFrameDataAtPos(dest_rect.top_left());
|
||||||
libyuv::CopyPlane(src_buffer, src_stride, dest, stride(),
|
// TODO(crbug.com/1330019): Temporary workaround for a known libyuv crash when
|
||||||
DesktopFrame::kBytesPerPixel * dest_rect.width(),
|
// the height or width is 0. Remove this once this change has been merged.
|
||||||
dest_rect.height());
|
if (dest_rect.width() && dest_rect.height()) {
|
||||||
|
libyuv::CopyPlane(src_buffer, src_stride, dest, stride(),
|
||||||
|
DesktopFrame::kBytesPerPixel * dest_rect.width(),
|
||||||
|
dest_rect.height());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopFrame::CopyPixelsFrom(const DesktopFrame& src_frame,
|
void DesktopFrame::CopyPixelsFrom(const DesktopFrame& src_frame,
|
||||||
@ -157,9 +161,13 @@ BasicDesktopFrame::~BasicDesktopFrame() {
|
|||||||
// static
|
// static
|
||||||
DesktopFrame* BasicDesktopFrame::CopyOf(const DesktopFrame& frame) {
|
DesktopFrame* BasicDesktopFrame::CopyOf(const DesktopFrame& frame) {
|
||||||
DesktopFrame* result = new BasicDesktopFrame(frame.size());
|
DesktopFrame* result = new BasicDesktopFrame(frame.size());
|
||||||
libyuv::CopyPlane(frame.data(), frame.stride(), result->data(),
|
// TODO(crbug.com/1330019): Temporary workaround for a known libyuv crash when
|
||||||
result->stride(), frame.size().width() * kBytesPerPixel,
|
// the height or width is 0. Remove this once this change has been merged.
|
||||||
frame.size().height());
|
if (frame.size().width() && frame.size().height()) {
|
||||||
|
libyuv::CopyPlane(frame.data(), frame.stride(), result->data(),
|
||||||
|
result->stride(), frame.size().width() * kBytesPerPixel,
|
||||||
|
frame.size().height());
|
||||||
|
}
|
||||||
result->CopyFrameInfoFrom(frame);
|
result->CopyFrameInfoFrom(frame);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user