Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
2 Views

H.264Decoder returns corrupted images

As I know, when we call GetFrame like

GetFrame(NULL, out)

The decoder will try to return a displayable image if possible.

Since our application needs to limit the maximum number of compressed frames which can be passed to the decoder, we modified the sample application as follows.

The basic idea is that we have a counter, say iNumInputSurraces, which counts that the input compressed surface the decoder is holding. When we read a new compressed frame, we increase the counter. When we decode a frame, we descrease the counter.

When the counter reaches a limit, say, 32, we don't read any new data until the decoder returns a decoded frame and descrease the counter.

However, we got corrupted images when we run the following modified application.

It seems that the decoder returns partially decoded images when we stop giving new data during the midlle of decompression.

Could you please give me some help about this? Thanks.

int iNumInputSurfaces = 0;
bool bAllInputSurfacesUsed = false;

int x =0;

while(numDecodedFrames < numFramesToDecode)
{
if ((3 > in->GetDataSize()) &&
(false == bEndOfStream))
{
if (iNumInputSurfaces < 32)
{
Status statusHelper = splitter->GetNextVideoData(*(in.get()));
if(UMC_OK != statusHelper){
bEndOfStream = true;}

iNumInputSurfaces++;

bAllInputSurfacesUsed = false;

}
else
{
bAllInputSurfacesUsed = true;
}
}

if(!bInitialize)
{

}


Status ret = h264Decoder->GetFrame(
(bEndOfStream | bAllInputSurfacesUsed) ?
(NULL) : (in.get()), out.get());


if (UMC_ERR_N OT_ENOUGH_DATA == ret)
{
if (bEndOfStream)
break;
else
continue;
}

if (UMC_OK != ret)
continue;

savedata(f_dst, out.get(), out->GetWidth(), out->GetHeight());

numDecodedFrames++;

//release one input surface when a frame was outputed.
if (iNumInputSurfaces - 1 < 0)
{
_ASSERT(false);
}
else
{
iNumInputSurfaces--;
if (iNumInputSurfaces < iMaxNumInputSurfaces)
{
bAllInputSurfacesUsed = false;
}
}


}

0 Kudos
1 Reply
Highlighted
2 Views

You can't do like this with H.264 decoder. The number of buffered frames depends on stream characteristics. Trying directly limit number of buffred frames you break the decoder work logic.

Regards,
Vladimir

0 Kudos