From fe1ff938fc92164058c3ad68c0981ef460b5ce1f Mon Sep 17 00:00:00 2001 From: Alla Ukhina Date: Thu, 17 Mar 2022 14:38:38 +0300 Subject: [PATCH] Disable limitation for stream width for nv12 Issue: MDP-68159 Test: manual --- samples/sample_common/src/sample_utils.cpp | 58 ++++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/samples/sample_common/src/sample_utils.cpp b/samples/sample_common/src/sample_utils.cpp index 26aac01982..7e0c42ed70 100644 --- a/samples/sample_common/src/sample_utils.cpp +++ b/samples/sample_common/src/sample_utils.cpp @@ -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 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;