- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for check.
youre correct. the input was in YUV420 format (output of simple decode sample)
sorry for the hassle.
Nadav
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page