[iMX8MP] How to decode a single frame within an H264 data

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

[iMX8MP] How to decode a single frame within an H264 data

跳至解决方案
696 次查看
b_m
Contributor III

Hi Community

I am making a decoder app using VPU wrapper. (Input: H264, Output: YUV)
Input H264 data is updated real time.
If VPU_DecDecodeBuf() has been called once to decode the I-frame,
then P-frame is encoded and appended to the input H264 data,
which parameter should I change so that the next time VPU_DecDecodeBuf() is called 
it will decode the P-frame?

0 项奖励
回复
1 解答
631 次查看
b_m
Contributor III

>what kind of streaming do you need to decode? 
I said in my OP that my input is H264 data

>I don't think raw P frame append to the I frame is correct procedure, you also can refer to the nxp source code for reference
Input H264 data is set to VpuBufferNode then passed to VPU_DecDecodeBuf().
If originally the H264 data has both I and P Frames before setting to VpuBufferNode, decoding works.
(1st call of VPU_DecDecodeBuf() decodes I, then 2nd call decodes P)

However, if original input H264 data only has I frame, then P frame was created separately so it has to be reflected to VpuBufferNode, I wanted to know what to change before calling VPU_DecDecodeBuf() for the 2nd time.

After some trial and error, I found the following code to solve the above problem.
 /** Change address of input set in VpuBufferNode to the address of P-Frame */
m_vpuBufferNode.pVirAddr = <P-Frame address>;
/** Change input data size */
m_vpuBufferNode.nSize = <P-Frame size>;

在原帖中查看解决方案

0 项奖励
回复
4 回复数
668 次查看
b_m
Contributor III

Please consider this sequence
1. VpuBufferNode only contains I-Frame
2. VPU_DecDecodeBuf() is called
    Result: I-Frame is decoded properly

(Here comes my problem)
3. A P-Frame has been created separately, so I understand it has to be appended to VpuBufferNode, like this
    /** Append P-Frame data at the end of I-Frame data in VpuBufferNode */
    memcpy(m_vpuBufferNode.pVirAddr + <I-Frame size>, <P-Frame address>, <P-Frame size>);
    /** Update input data size */
    m_vpuBufferNode.nSize = <I-Frame size> +  <P-Frame size>;
4. VPU_DecDecodeBuf() is called again and is expected to decode the P-frame added in #3
     Result: No image is decoded (output decoded data from VPU_DecGetOutputFrame is all-zero)

My question is, is the implementation of #3 enough to update VpuBufferNode, before calling VPU_DecDecodeBuf() again?

0 项奖励
回复
643 次查看
joanxie
NXP TechSupport
NXP TechSupport

what kind of streaming do you need to decode? I don't think raw P frame append to the I frame is correct procedure, you also can refer to the nxp source code for reference

0 项奖励
回复
632 次查看
b_m
Contributor III

>what kind of streaming do you need to decode? 
I said in my OP that my input is H264 data

>I don't think raw P frame append to the I frame is correct procedure, you also can refer to the nxp source code for reference
Input H264 data is set to VpuBufferNode then passed to VPU_DecDecodeBuf().
If originally the H264 data has both I and P Frames before setting to VpuBufferNode, decoding works.
(1st call of VPU_DecDecodeBuf() decodes I, then 2nd call decodes P)

However, if original input H264 data only has I frame, then P frame was created separately so it has to be reflected to VpuBufferNode, I wanted to know what to change before calling VPU_DecDecodeBuf() for the 2nd time.

After some trial and error, I found the following code to solve the above problem.
 /** Change address of input set in VpuBufferNode to the address of P-Frame */
m_vpuBufferNode.pVirAddr = <P-Frame address>;
/** Change input data size */
m_vpuBufferNode.nSize = <P-Frame size>;

0 项奖励
回复
674 次查看
joanxie
NXP TechSupport
NXP TechSupport

this is part of decoding flow, after decoding one frame, if still have more frames, the VPU will decode next frame before close the VPU

joanxie_0-1747710718527.png

 

0 项奖励
回复