Bug 83143

Summary: [SNB|IVB|HSW][Media][Encode] CBR mode H264 encoding is broken while providing PackedSliceHeaders from upper layer
Product: libva Reporter: sreerenj <bsreerenj>
Component: intelAssignee: haihao <haihao.xiang>
Status: RESOLVED FIXED QA Contact: Sean V Kelley <seanvk>
Severity: major    
Priority: medium CC: zhixinx.liu
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
See Also: https://bugzilla.gnome.org/show_bug.cgi?id=734992
Whiteboard:
i915 platform: i915 features:
Attachments: Fix the incorrect QP setting under CBR when slice_header info is passed

Description sreerenj 2014-08-27 12:36:31 UTC
In Constant Bitrate  Mode encoding, the driver is calculating the qp value dynamically and filling the slice_qp_delta. This won't work if upper layer 
provides the PackedSliceHeaders since it doesn't know about the qp values which
are finding out inside the driver.

How to reproduce the bug?: Explained here: https://bugzilla.gnome.org/show_bug.cgi?id=734992

There were discussion about this sometimes before but not yet implemented in driver.Copy&past from,
http://lists.freedesktop.org/archives/libva/2014-May/002193.html

""
> Another thing is for CBR, the QP might be changed per frame in the
> driver and app/middleware doesn't not know the final QP. How does app
> get the right slice_qp_delta to build the right packed slice header ?
> does app always use a fixed slice_qp_delta ?

AFAIK, slice_qp_delta does not really matter. You can start off QP =
26 (defaults with pic_init_qp_minus26 = 0 + slice_qp_delta = 0), and
the driver can still generate per-MB QP that fits. i.e. you have an
additional delta at the macroblock layer IIRC. That should fit most
purposes.
""

Note: The "avcenc"  is working fine with CBR because it is not providing the packed slice headers, and the driver itself is inserting those.
Comment 1 ykzhao 2014-08-29 05:29:23 UTC
Created attachment 105407 [details] [review]
Fix the incorrect QP setting under CBR when slice_header info is passed

Hi, Screenj

    Will you please try the attached patch and see whether the issue is resolved?

Thanks.
   Yakui
Comment 2 sreerenj 2014-08-29 09:56:39 UTC
(In reply to comment #1)
> Created attachment 105407 [details] [review] [review]
> Fix the incorrect QP setting under CBR when slice_header info is passed
> 
> Hi, Screenj
> 
>     Will you please try the attached patch and see whether the issue is
> resolved?
> 
> Thanks.
>    Yakui

Did some quick tests and seems to be fine.
Thanks Yakui.
Comment 3 ykzhao 2014-09-01 07:50:34 UTC
Thanks for your testing and verification.

I will send it to libva@lists.freedesktop.org

Thanks.
   Yakui
Comment 4 ykzhao 2014-09-02 01:23:06 UTC
Now the patch is already pushed to the master/staging branch.

Thanks.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.