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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
682件の閲覧回数
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 解決策
617件の閲覧回数
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 返答(返信)
654件の閲覧回数
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 件の賞賛
返信
629件の閲覧回数
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 件の賞賛
返信
618件の閲覧回数
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 件の賞賛
返信
660件の閲覧回数
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 件の賞賛
返信