From 4a62c01b2c6e743e97fa6aaa430cf1c8b45a4346 Mon Sep 17 00:00:00 2001 From: fzharino Date: Mon, 1 Oct 2018 18:30:11 +0300 Subject: [PATCH] [samples] YUV reader: fix for ayuv and y410, backward compatibility is added Change-Id: I43225b55e8e1b0cfd69e8f156c401da2610f1463 --- samples/sample_common/src/sample_utils.cpp | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/samples/sample_common/src/sample_utils.cpp b/samples/sample_common/src/sample_utils.cpp index 0c954be006..87fb1bb04c 100644 --- a/samples/sample_common/src/sample_utils.cpp +++ b/samples/sample_common/src/sample_utils.cpp @@ -71,9 +71,8 @@ mfxStatus CopyBitstream2(mfxBitstream *dest, mfxBitstream *src) CSmplYUVReader::CSmplYUVReader() { m_bInited = false; - m_ColorFormat - = MFX_FOURCC_YV12; - shouldShift10BitsHigh = false; + m_ColorFormat = MFX_FOURCC_YV12; + shouldShift10BitsHigh = false; } mfxStatus CSmplYUVReader::Init(std::list inputs, mfxU32 ColorFormat, bool enableShifting) @@ -180,20 +179,27 @@ mfxStatus CSmplYUVReader::LoadNextFrame(mfxFrameSurface1* pSurface) mfxU32 nBytesPerPixel = (pInfo.FourCC == MFX_FOURCC_P010 || pInfo.FourCC == MFX_FOURCC_P210 ) ? 2 : 1; - if (MFX_FOURCC_YUY2 == pInfo.FourCC || MFX_FOURCC_RGB4 == pInfo.FourCC || MFX_FOURCC_BGR4 == pInfo.FourCC + if ( MFX_FOURCC_YUY2 == pInfo.FourCC + || MFX_FOURCC_RGB4 == pInfo.FourCC + || MFX_FOURCC_BGR4 == pInfo.FourCC + || MFX_FOURCC_AYUV == pInfo.FourCC + || MFX_FOURCC_A2RGB10 == pInfo.FourCC #if (MFX_VERSION >= 1027) - || pInfo.FourCC == MFX_FOURCC_Y210 || pInfo.FourCC == MFX_FOURCC_Y410 + || MFX_FOURCC_Y210 == pInfo.FourCC + || MFX_FOURCC_Y410 == pInfo.FourCC #endif ) { //Packed format: Luminance and chrominance are on the same plane switch (m_ColorFormat) { + case MFX_FOURCC_A2RGB10: + case MFX_FOURCC_AYUV: case MFX_FOURCC_RGB4: case MFX_FOURCC_BGR4: pitch = pData.Pitch; ptr = MSDK_MIN( MSDK_MIN(pData.R, pData.G), pData.B); - ptr = ptr + pInfo.CropX + pInfo.CropY * pData.Pitch; + ptr = ptr + pInfo.CropX*4 + pInfo.CropY * pData.Pitch; for(i = 0; i < h; i++) { @@ -219,21 +225,6 @@ mfxStatus CSmplYUVReader::LoadNextFrame(mfxFrameSurface1* pSurface) } } break; - case MFX_FOURCC_AYUV: - pitch = pData.Pitch; - ptr = pData.Y + pInfo.CropX*4 + pInfo.CropY * pData.Pitch; - - for (i = 0; i < h; i++) - { - nBytesRead = (mfxU32)fread(ptr + i * pitch, 4, w, m_files[vid]); - - if ((mfxU32)w != nBytesRead) - { - return MFX_ERR_MORE_DATA; - } - } - break; - #if (MFX_VERSION >= 1027) case MFX_FOURCC_Y210: case MFX_FOURCC_Y410: @@ -2451,8 +2442,16 @@ mfxU16 FourCCToChroma(mfxU32 fourCC) return MFX_CHROMAFORMAT_YUV420; case MFX_FOURCC_NV16: case MFX_FOURCC_P210: +#if (MFX_VERSION >= 1027) + case MFX_FOURCC_Y210: +#endif case MFX_FOURCC_YUY2: return MFX_CHROMAFORMAT_YUV422; +#if (MFX_VERSION >= 1027) + case MFX_FOURCC_Y410: + case MFX_FOURCC_A2RGB10: +#endif + case MFX_FOURCC_AYUV: case MFX_FOURCC_RGB4: return MFX_CHROMAFORMAT_YUV444; }