Bug 1038879: ensure odd widths/heights in getUserMedia are handled correctly r=rillian

This commit is contained in:
Randell Jesup 2014-07-15 15:49:01 -04:00
Родитель 34feea774d
Коммит d344eea963
1 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -79,8 +79,8 @@ MediaEngineWebRTCVideoSource::DeliverFrame(
return 0;
}
MOZ_ASSERT(mWidth*mHeight*3/2 == size);
if (mWidth*mHeight*3/2 != size) {
if (mWidth*mHeight + 2*(((mWidth+1)/2)*((mHeight+1)/2)) != size) {
MOZ_ASSERT(false, "Wrong size frame in DeliverFrame!");
return 0;
}
@ -93,14 +93,15 @@ MediaEngineWebRTCVideoSource::DeliverFrame(
const uint8_t lumaBpp = 8;
const uint8_t chromaBpp = 4;
// Take lots of care to round up!
layers::PlanarYCbCrData data;
data.mYChannel = frame;
data.mYSize = IntSize(mWidth, mHeight);
data.mYStride = mWidth * lumaBpp/ 8;
data.mCbCrStride = mWidth * chromaBpp / 8;
data.mYStride = (mWidth * lumaBpp + 7)/ 8;
data.mCbCrStride = (mWidth * chromaBpp + 7) / 8;
data.mCbChannel = frame + mHeight * data.mYStride;
data.mCrChannel = data.mCbChannel + mHeight * data.mCbCrStride / 2;
data.mCbCrSize = IntSize(mWidth/ 2, mHeight/ 2);
data.mCrChannel = data.mCbChannel + ((mHeight+1)/2) * data.mCbCrStride;
data.mCbCrSize = IntSize((mWidth+1)/ 2, (mHeight+1)/ 2);
data.mPicX = 0;
data.mPicY = 0;
data.mPicSize = IntSize(mWidth, mHeight);