P frames too large for VPU h.264

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

P frames too large for VPU h.264

1,170 Views
henryharrison
Contributor I

Hi,

I'm  using Boundary Devices Nitrogen6x with the Yocto Linux BSP (daisy).

I have written code to drive the VPU using the native API (vpu_lib.h) in order to encode h.264 at 1080p. I've based my code on this: imx-testing-apps-misc/libvpu_encode.c at master · ahmedammar/imx-testing-apps-misc · GitHub but also cross-checked it against how things are done in mfw_gst_vpu_encoder.c from the Gstreamer plugins.

I can correctly generate h.264 - the bitstream plays correctly using ffmpeg, and h264_analyze reports (as does EncOutputInfo::picType)  that the first frame is an I-frame and subsequent frames are P-frames. I can vary this appropriately by setting EncOpenParam::gopSize or by using EncParam::forceIPicture.

So far so good. However, the size of my P-frames is exactly the same as the size of I-frames - for fixed quantization the output bitrate is the same whether I use all I-frames (gopSize=1) or I and P frames (gopSize>1).

If I set CBR by putting EncOpenParam::bitrate>0 then I do get the bitrate that I asked for, but if I encode a static image, then the qp for each frame gets worse over time rather than better (as you'd expect) - again, consistent with each P frame actually being coded like an I frame.

I know this is not a hardware problem because when I use gstreamer I don't see the same effect - much smaller P frames than I frames for fixed qp, and qp getting better in each frame for CBR encoding of a static image. So clearly I am doing something wrong - but I have now tried just about every combination of parameter and nothing seems to change.

Has anyone ever seen this effect before? For various reasons, I don't just want to give up and use gstreamer, so I need to find a way of fixing this!

Thanks,

Henry

Labels (3)
0 Kudos
2 Replies

628 Views
chuck1
Contributor III

Henry,

Did you ever resolve this issue? 

I see the same phenomena that you describe above, i.e., the fact that encoded P frames are similar in size to encoded I frames instead of much smaller as one would expect plus the overall encoding efficiency is a factor of 4 to 6 lower than it should be (files are too large) AVC.  In addition (as I describe in my post), I see lots of encoding artifacts—changing encoding parameters, I can reduce the number of artifacts but I can never eliminate them.  Please see my post here: i.MX6 VPU H.264 Encoder Quality Issues

I have a hunch that the problem is related to how my code feeds YUV frames to the VPU and/or removes I/P frames from the VPU, i.e., the lack of proper buffer management.  If you have been able to solve this problem, could you please post your solution?  Any help would be much appreciated!

Thanks,

-Chuck

0 Kudos

628 Views
ronjacoby
Contributor II

hi,

im having the same problem with large P frames, and also some UV color artifacts.

did you find a solution for this ?

0 Kudos