mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 00:38:39 +09:00
[GMP] Factor out more detailed CheckDimensions function for CreateFrame.
This commit is contained in:
parent
9a6e3bc30d
commit
b848a924bc
2 changed files with 33 additions and 5 deletions
|
|
@ -89,6 +89,34 @@ GMPVideoi420FrameImpl::CheckFrameData(const GMPVideoi420FrameData& aFrameData)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
GMPVideoi420FrameImpl::CheckDimensions(int32_t aWidth, int32_t aHeight,
|
||||
int32_t aStride_y,
|
||||
int32_t aStride_u,
|
||||
int32_t aStride_v, int32_t aSize_y,
|
||||
int32_t aSize_u, int32_t aSize_v) {
|
||||
if (aWidth < 1 || aHeight < 1 || aStride_y < aWidth || aSize_y < 1 ||
|
||||
aSize_u < 1 || aSize_v < 1) {
|
||||
return false;
|
||||
}
|
||||
auto halfWidth = (CheckedInt<int32_t>(aWidth) + 1) / 2;
|
||||
if (!halfWidth.isValid() || aStride_u < halfWidth.value() ||
|
||||
aStride_v < halfWidth.value()) {
|
||||
return false;
|
||||
}
|
||||
auto height = CheckedInt<int32_t>(aHeight);
|
||||
auto halfHeight = (height + 1) / 2;
|
||||
auto minSizeY = height * aStride_y;
|
||||
auto minSizeU = halfHeight * aStride_u;
|
||||
auto minSizeV = halfHeight * aStride_v;
|
||||
if (!minSizeY.isValid() || !minSizeU.isValid() || !minSizeV.isValid() ||
|
||||
minSizeY.value() > aSize_y || minSizeU.value() > aSize_u ||
|
||||
minSizeV.value() > aSize_v) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
GMPVideoi420FrameImpl::CheckDimensions(int32_t aWidth, int32_t aHeight,
|
||||
int32_t aStride_y, int32_t aStride_u, int32_t aStride_v)
|
||||
|
|
@ -179,11 +207,8 @@ GMPVideoi420FrameImpl::CreateFrame(int32_t aSize_y, const uint8_t* aBuffer_y,
|
|||
MOZ_ASSERT(aBuffer_u);
|
||||
MOZ_ASSERT(aBuffer_v);
|
||||
|
||||
if (aSize_y < 1 || aSize_u < 1 || aSize_v < 1) {
|
||||
return GMPGenericErr;
|
||||
}
|
||||
|
||||
if (!CheckDimensions(aWidth, aHeight, aStride_y, aStride_u, aStride_v)) {
|
||||
if (!CheckDimensions(aWidth, aHeight, aStride_y, aStride_u, aStride_v,
|
||||
aSize_y, aSize_u, aSize_v)) {
|
||||
return GMPGenericErr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ public:
|
|||
void ResetSize() override;
|
||||
|
||||
private:
|
||||
bool CheckDimensions(int32_t aWidth, int32_t aHeight, int32_t aStride_y,
|
||||
int32_t aStride_u, int32_t aStride_v, int32_t aSize_y,
|
||||
int32_t aSize_u, int32_t aSize_v);
|
||||
bool CheckDimensions(int32_t aWidth, int32_t aHeight,
|
||||
int32_t aStride_y, int32_t aStride_u, int32_t aStride_v);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue