Quantcast
Channel: Intel® Software - Media
Viewing all articles
Browse latest Browse all 2185

bug in sample encode

$
0
0

Hi, 
I think there's a bug in SDK 2013 R2 samples.

in sample_encode if i use -nv12 in command line - i get wrong output.
it seems that the bug is in CSmplYUVReader::LoadNextFrame for ColorFormat MFX_FOURCC_NV12 when loading  U, V planes.
i've changed the following code:

case MFX_FOURCC_NV12:

h /= 2;
ptr = pData->UV + pInfo->CropX + (pInfo->CropY / 2) * pitch;
for(i = 0; i < h; i++)
{
if (!m_bIsMultiView)
{
nBytesRead = (mfxU32)fread(ptr + i * pitch, 1, w, m_fSource);
}
else
{
nBytesRead = (mfxU32)fread(ptr + i * pitch, 1, w, m_fSourceMVC[vid]);
}
if (w != nBytesRead)
{
return MFX_ERR_MORE_DATA;
}
}
break;

 to the code from older simple_encode sample:

case MFX_FOURCC_NV12:
mfxU8 buf[2048]; // maximum supported chroma width for nv12
w /= 2;
h /= 2;
ptr = pData->UV + pInfo->CropX + (pInfo->CropY / 2) * pitch;
if (w > 2048)
return MFX_ERR_UNSUPPORTED;

// load U
mfxStatus sts;
sts = ReadPlaneData(w, h, buf, ptr, pitch, 0, m_fSource);
if(MFX_ERR_NONE != sts) return sts;
// load V
ReadPlaneData(w, h, buf, ptr, pitch, 1, m_fSource);
if(MFX_ERR_NONE != sts) return sts;
break;

mfxStatus ReadPlaneData(mfxU16 w, mfxU16 h, mfxU8 *buf, mfxU8 *ptr, mfxU16 pitch, mfxU16 offset, FILE* fSource)
{
mfxU32 nBytesRead;
for (mfxU16 i = 0; i < h; i++)
{
nBytesRead = (mfxU32)fread(buf, 1, w, fSource);
if (w != nBytesRead)
return MFX_ERR_MORE_DATA;
for (mfxU16 j = 0; j < w; j++)
ptr[i * pitch + j * 2 + offset] = buf[j];
}
return MFX_ERR_NONE;
}

and it wroked.
it also applies to the ffmpeg integration sample (which i started from...)
please check.
thanks 

 

 


Viewing all articles
Browse latest Browse all 2185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>