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

Commit

Permalink
[samples] YUV reader: fix for ayuv and y410, backward compatibility i…
Browse files Browse the repository at this point in the history
…s added

Change-Id: I43225b55e8e1b0cfd69e8f156c401da2610f1463
  • Loading branch information
fzhar committed Oct 4, 2018
1 parent 31722be commit 7beba65
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions samples/sample_common/src/sample_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<msdk_string> inputs, mfxU32 ColorFormat, bool enableShifting)
Expand Down Expand Up @@ -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++)
{
Expand All @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7beba65

Please sign in to comment.