Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

bug in sample encode

nadav
Beginner
321 Views

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;
}
return MFX_ERR_NONE;
}

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

 



 

0 Kudos
2 Replies
Petter_L_Intel
Employee
321 Views

Hi,

I do not see anything wrong with the sample code from Media SDK 2013 R2 with regards to reading RAW NV12 surfaces. 

To verify, I tested some NV12 input content with the sample_encode sample (using the -nv12 flag). The streams generated have no color tint or streaking which would indicate any file reading related issues.

I suspect your issue may be not feeding an actual NV12 formatted raw file to the sample?

Regards,
Petter 

0 Kudos
nadav
Beginner
321 Views

Thanks for check.
youre correct. the input was in YUV420 format (output of simple decode sample) 
sorry for the hassle. 
Nadav 

0 Kudos
Reply