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

Disable limitation for stream width for nv12 #2912

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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