Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Disable limitation for stream width for nv12
Browse files Browse the repository at this point in the history
Issue: MDP-68159
Test: manual
  • Loading branch information
aukhina committed Mar 17, 2022
1 parent a8f5d51 commit ace8e32
Showing 1 changed file with 25 additions and 33 deletions.
58 changes: 25 additions & 33 deletions samples/sample_common/src/sample_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,58 +390,50 @@ mfxStatus CSmplYUVReader::LoadNextFrame(mfxFrameSurface1* pSurface)
{
case MFX_FOURCC_I420:
case MFX_FOURCC_YV12:
switch (pInfo.FourCC)
{
switch (pInfo.FourCC) {
case MFX_FOURCC_NV12:

mfxU8 buf[2048]; // maximum supported chroma width for nv12
mfxU32 j, dstOffset[2];
w /= 2;
h /= 2;
ptr = pData.UV + pInfo.CropX + (pInfo.CropY / 2) * pitch;
if (w > 2048)
{
return MFX_ERR_UNSUPPORTED;
}

if (m_ColorFormat == MFX_FOURCC_I420) {
dstOffset[0] = 0;
dstOffset[1] = 1;
} else {
}
else {
dstOffset[0] = 1;
dstOffset[1] = 0;
}

// load first chroma plane: U (input == I420) or V (input == YV12)
for (i = 0; i < h; i++)
{
nBytesRead = (mfxU32)fread(buf, 1, w, m_files[vid]);
if (w != nBytesRead)
{
return MFX_ERR_MORE_DATA;
}
for (j = 0; j < w; j++)
{
ptr[i * pitch + j * 2 + dstOffset[0]] = buf[j];
try {
std::vector<mfxU8> buf(w);
for (i = 0; i < h; i++) {
nBytesRead = (mfxU32)fread(&buf[0], 1, w, m_files[vid]);
if (w != nBytesRead) {
return MFX_ERR_MORE_DATA;
}
for (j = 0; j < w; j++) {
ptr[i * pitch + j * 2 + dstOffset[0]] = buf[j];
}
}
}

// load second chroma plane: V (input == I420) or U (input == YV12)
for (i = 0; i < h; i++)
{

nBytesRead = (mfxU32)fread(buf, 1, w, m_files[vid]);
// load second chroma plane: V (input == I420) or U (input == YV12)
for (i = 0; i < h; i++) {
nBytesRead = (mfxU32)fread(&buf[0], 1, w, m_files[vid]);

if (w != nBytesRead)
{
return MFX_ERR_MORE_DATA;
}
for (j = 0; j < w; j++)
{
ptr[i * pitch + j * 2 + dstOffset[1]] = buf[j];
if (w != nBytesRead) {
return MFX_ERR_MORE_DATA;
}
for (j = 0; j < w; j++) {
ptr[i * pitch + j * 2 + dstOffset[1]] = buf[j];
}
}
}

catch (...) {
return MFX_ERR_MEMORY_ALLOC;
}
break;
case MFX_FOURCC_YV12:
w /= 2;
Expand Down

0 comments on commit ace8e32

Please sign in to comment.