Revert "Fix memory corruption in BasicDesktopFrame::CopyTo"

This reverts commit 0ba10283fb3cbdf1cedea79d84e4bc3b720da6a1.

Reason for revert: This workaround is no longer needed, as the libyuv team has already fixed the underlying issue (in b/234824290)

Original change's description:
> Fix memory corruption in BasicDesktopFrame::CopyTo
>
> This memory corruption happens inside libyuv::CopyPlane()
> on platforms that support AVX. I opened b/234824290 so the libyuv team
> can investigate and fix this, but in the mean time we need to get this
> fixed asap as this is causing crashes on both M102 (which is released to
> stable) and M103 (which has this issue marked as beta blocking).
>
> Fixed: b/234824290
> Fixed: chromium:1330019
> Test: Manually reproduced on zork board
> Change-Id: I6bfd1e089020dfb23d974d3912d45c01a4e5ce26
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265041
> Auto-Submit: Jeroen Dhollander <jeroendh@google.com>
> Commit-Queue: Alexander Cooper <alcooper@chromium.org>
> Reviewed-by: Alexander Cooper <alcooper@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#37121}

Fixed: b/234824290
Fixed: chromium:1330019
Change-Id: Iafc0eac651fbc7a7fce5092306b12c4377248839
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265165
Auto-Submit: Jeroen Dhollander <jeroendh@google.com>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Frank Barchard <fbarchard@google.com>
Cr-Commit-Position: refs/heads/main@{#37142}
This commit is contained in:
Jeroen Dhollander
2022-06-07 10:33:38 +00:00
committed by WebRTC LUCI CQ
parent 0e230fd022
commit c949016e13

View File

@ -13,7 +13,6 @@
#include <string.h> #include <string.h>
#include <cmath> #include <cmath>
#include <cstring>
#include <memory> #include <memory>
#include <utility> #include <utility>
@ -24,15 +23,6 @@
namespace webrtc { namespace webrtc {
namespace {
// Calculate the size of the data buffer size used to store a BasicDesktopFrame.
int CalculateDataSizeFor(const DesktopSize& size) {
return DesktopFrame::kBytesPerPixel * size.width() * size.height();
}
} // namespace
DesktopFrame::DesktopFrame(DesktopSize size, DesktopFrame::DesktopFrame(DesktopSize size,
int stride, int stride,
uint8_t* data, uint8_t* data,
@ -157,7 +147,7 @@ void DesktopFrame::MoveFrameInfoFrom(DesktopFrame* other) {
BasicDesktopFrame::BasicDesktopFrame(DesktopSize size) BasicDesktopFrame::BasicDesktopFrame(DesktopSize size)
: DesktopFrame(size, : DesktopFrame(size,
kBytesPerPixel * size.width(), kBytesPerPixel * size.width(),
new uint8_t[CalculateDataSizeFor(size)](), new uint8_t[kBytesPerPixel * size.width() * size.height()](),
nullptr) {} nullptr) {}
BasicDesktopFrame::~BasicDesktopFrame() { BasicDesktopFrame::~BasicDesktopFrame() {
@ -167,9 +157,9 @@ 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());
// TODO(b/234824290): Using memcpy until libyuv::CopyPlane() is fixed to no libyuv::CopyPlane(frame.data(), frame.stride(), result->data(),
// longer introduce memory corruption on platforms that support AVX. result->stride(), frame.size().width() * kBytesPerPixel,
memcpy(result->data(), frame.data(), CalculateDataSizeFor(result->size())); frame.size().height());
result->CopyFrameInfoFrom(frame); result->CopyFrameInfoFrom(frame);
return result; return result;
} }