Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

H264 encoding and decoding problem?

bangjun_lei1
Beginner
951 Views
Dear All,

I managed to compile a successful build with 5.2beta (5.1 still has compiling problem) to encode and decode using H.264. To test this, I compress a frame and immediately decompress it. The code clip for doing this is as attached.

The encoding goes on quite well (ret1 is UMC_OK). However, the decoding is not succeeded (ret2 always returns as UMC_NOT_ENOUGH_DATA).

Could anyone help me on this?

Thank you very much!

Best Regards,
Bangjun.

0 Kudos
5 Replies
Vladimir_Dudnik
Employee
951 Views

Bangjun,

according standard, H.264 decoder can accumulate frames inside, so in case of UMC_NOT_ENOUGH_DATA you need to call decoder again with MediaData* in == NULL. This you will enforce decoder to output frame immediately

Regards,
Vladimir

0 Kudos
bangjun_lei1
Beginner
951 Views
Vladimir,

Thank you very much for your answer!

Yes. You are right. Now I get something in the decompressed video. However, it looks like the final decompressed video only contains the top-left quarter of the original video. And, after a while, the decompressing stops.

Could you help to check my code to see where the problem might be?

Best Regards,
Bangjun.
0 Kudos
Vladimir_Dudnik
Employee
951 Views

Please attach piece of code to that thread, so we can take a look on that.

Actually, more-less similar question was discussed at Using MPEG-4 Decoder thread, so you might be intersted in looking through the forum, by searching keywords like H.264, MPEG4

Regards,
Vladimir

0 Kudos
bangjun_lei1
Beginner
951 Views
Vladimir,

I already attached the source code with the first post of this thread.

I read the thread you recommended and all other posts related to H264. But I still cannot get a clue where it might be wrong. My problem sounds simple to be attacked by your current IPP suit.

Would you help to take a look at my code? (Note that my input pImageData is in RGB24 format).

Thank you again for your help!

Best Regards,
Bangjun.
0 Kudos
bangjun_lei1
Beginner
951 Views
Vladimir,

After some more experiments, I found one problem with my original approach was the color format. Now I first transform my video data into YV12 and it works.

However, I encounter a new problem when I test with
m_pVideoEncoder->GetFrame(&m_videoOutRaw, &m_videoOutCompressed);
m_videoDecoder.GetFrame(&m_videoOutCompressed, &m_videoInRaw);
where contains one YV12 format frame.

The problem lies in m_videoOutCompressed. Initialy in m_videoOutCompressed the data pointer is the same as the buffer pointer. However, when repeating the above process, the data pointer increases continuously and at certain time the 1st instruction in above would report UMC_NOT_ENOUGH_BUFFER error.

So I try to use the following process instead:
m_pVideoEncoder->GetFrame(&m_videoOutRaw, &m_videoOutCompressed);
int dataSize = m_videoOutCompressed.GetDataSize();
m_videoDecoder.GetFrame(&m_videoOutCompressed, &m_videoInRaw);
m_videoOutCompressed.MoveDataPointer(-dataSize);
which means I manually reset the data pointer after decompressing the data.

This works pretty well for MPEG4 codec. But it produces very strange results for H264 codec (it looks like I can only get frame differences after decoding). And also, I found out no matter how I change the H264 codec parameters, the decoded frame always comes with frame type NONE_PICTURE.

Could you please help me with those problems?

Thank you very much!

Best Regards,
Bangjun.
0 Kudos
Reply