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

Commit fe1ff93

Browse files
committed
Disable limitation for stream width for nv12
Issue: MDP-68159 Test: manual
1 parent cf54452 commit fe1ff93

File tree

1 file changed

+25
-33
lines changed

1 file changed

+25
-33
lines changed

samples/sample_common/src/sample_utils.cpp

+25-33
Original file line numberDiff line numberDiff line change
@@ -390,58 +390,50 @@ mfxStatus CSmplYUVReader::LoadNextFrame(mfxFrameSurface1* pSurface)
390390
{
391391
case MFX_FOURCC_I420:
392392
case MFX_FOURCC_YV12:
393-
switch (pInfo.FourCC)
394-
{
393+
switch (pInfo.FourCC) {
395394
case MFX_FOURCC_NV12:
396-
397-
mfxU8 buf[2048]; // maximum supported chroma width for nv12
398395
mfxU32 j, dstOffset[2];
399396
w /= 2;
400397
h /= 2;
401398
ptr = pData.UV + pInfo.CropX + (pInfo.CropY / 2) * pitch;
402-
if (w > 2048)
403-
{
404-
return MFX_ERR_UNSUPPORTED;
405-
}
406399

407400
if (m_ColorFormat == MFX_FOURCC_I420) {
408401
dstOffset[0] = 0;
409402
dstOffset[1] = 1;
410-
} else {
403+
}
404+
else {
411405
dstOffset[0] = 1;
412406
dstOffset[1] = 0;
413407
}
414408

415409
// load first chroma plane: U (input == I420) or V (input == YV12)
416-
for (i = 0; i < h; i++)
417-
{
418-
nBytesRead = (mfxU32)fread(buf, 1, w, m_files[vid]);
419-
if (w != nBytesRead)
420-
{
421-
return MFX_ERR_MORE_DATA;
422-
}
423-
for (j = 0; j < w; j++)
424-
{
425-
ptr[i * pitch + j * 2 + dstOffset[0]] = buf[j];
410+
try {
411+
std::vector<mfxU8> buf(w);
412+
for (i = 0; i < h; i++) {
413+
nBytesRead = (mfxU32)fread(&buf[0], 1, w, m_files[vid]);
414+
if (w != nBytesRead) {
415+
return MFX_ERR_MORE_DATA;
416+
}
417+
for (j = 0; j < w; j++) {
418+
ptr[i * pitch + j * 2 + dstOffset[0]] = buf[j];
419+
}
426420
}
427-
}
428-
429-
// load second chroma plane: V (input == I420) or U (input == YV12)
430-
for (i = 0; i < h; i++)
431-
{
432421

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

435-
if (w != nBytesRead)
436-
{
437-
return MFX_ERR_MORE_DATA;
438-
}
439-
for (j = 0; j < w; j++)
440-
{
441-
ptr[i * pitch + j * 2 + dstOffset[1]] = buf[j];
426+
if (w != nBytesRead) {
427+
return MFX_ERR_MORE_DATA;
428+
}
429+
for (j = 0; j < w; j++) {
430+
ptr[i * pitch + j * 2 + dstOffset[1]] = buf[j];
431+
}
442432
}
443433
}
444-
434+
catch (...) {
435+
return MFX_ERR_MEMORY_ALLOC;
436+
}
445437
break;
446438
case MFX_FOURCC_YV12:
447439
w /= 2;

0 commit comments

Comments
 (0)