Bug 1451297. r=nical

This commit is contained in:
Andrew Osmond
2018-05-22 11:25:49 -04:00
parent a2f467fb58
commit 5ff30e30ff
3 changed files with 46 additions and 2 deletions

View File

@@ -78,6 +78,41 @@ ComputeYCbCrBufferSize(const gfx::IntSize& aYSize, int32_t aYStride,
2 * GetAlignedStride<4>(aCbCrSize.height, aCbCrStride);
}
uint32_t
ComputeYCbCrBufferSize(const gfx::IntSize& aYSize, int32_t aYStride,
const gfx::IntSize& aCbCrSize, int32_t aCbCrStride,
uint32_t aYOffset, uint32_t aCbOffset,
uint32_t aCrOffset)
{
MOZ_ASSERT(aYSize.height >= 0 && aYSize.width >= 0);
if (aYSize.height < 0 || aYSize.width < 0 || aCbCrSize.height < 0 || aCbCrSize.width < 0 ||
!gfx::Factory::AllowedSurfaceSize(IntSize(aYStride, aYSize.height)) ||
!gfx::Factory::AllowedSurfaceSize(IntSize(aCbCrStride, aCbCrSize.height))) {
return 0;
}
uint32_t yLength = GetAlignedStride<4>(aYStride, aYSize.height);
uint32_t cbCrLength = GetAlignedStride<4>(aCbCrStride, aCbCrSize.height);
if (yLength == 0 || cbCrLength == 0) {
return 0;
}
CheckedInt<uint32_t> yEnd = aYOffset;
yEnd += yLength;
CheckedInt<uint32_t> cbEnd = aCbOffset;
cbEnd += cbCrLength;
CheckedInt<uint32_t> crEnd = aCrOffset;
crEnd += cbCrLength;
if (!yEnd.isValid() || !cbEnd.isValid() || !crEnd.isValid() ||
yEnd.value() > aCbOffset || cbEnd.value() > aCrOffset) {
return 0;
}
return crEnd.value();
}
uint32_t
ComputeYCbCrBufferSize(uint32_t aBufferSize)
{