After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796984 - vaapih265enc: Support hevc encode low latency B frame.
vaapih265enc: Support hevc encode low latency B frame.
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer-vaapi
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-08-17 07:30 UTC by Fei
Modified: 2018-08-29 13:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
enable hevc low latency B. (4.83 KB, patch)
2018-08-17 07:40 UTC, Fei
none Details | Review
enable hevc low latency B. (4.79 KB, patch)
2018-08-20 03:15 UTC, Fei
none Details | Review
enable hevc low latency B. (4.04 KB, patch)
2018-08-21 02:11 UTC, Fei
none Details | Review
enable hevc low latency B. (4.07 KB, patch)
2018-08-24 02:48 UTC, Fei
none Details | Review
enable hevc low latency B. (4.49 KB, patch)
2018-08-29 04:28 UTC, Fei
none Details | Review
enable hevc low delay B. (4.45 KB, patch)
2018-08-29 04:44 UTC, Fei
committed Details | Review

Description Fei 2018-08-17 07:30:16 UTC
Some Intel hardware doesn't hevc P frame encode, so need low latency B feature to transform P frame into predictive B frame.
Comment 1 Fei 2018-08-17 07:40:42 UTC
Created attachment 373367 [details] [review]
enable hevc low latency B.
Comment 2 Víctor Manuel Jáquez Leal 2018-08-17 09:17:51 UTC
Review of attachment 373367 [details] [review]:

Hi Fei,

Perhaps we need to complete the commit log information:  What Intel hardware? using which vaapi backend?

::: gst-libs/gst/vaapi/gstvaapiencoder_h265.c
@@ +824,3 @@
       WRITE_UINT32 (bs,
+          slice_param->slice_fields.
+          bits.slice_loop_filter_across_slices_enabled_flag, 1);

this change is related with code style, not with the purpose of this patch. I would remove it.

@@ +1748,3 @@
 
+    slice_param->slice_fields.
+        bits.slice_loop_filter_across_slices_enabled_flag = TRUE;

ditto.

@@ +2769,3 @@
+          "Low latency B will change P frame into predictive B frame",
+          FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+

I'm not very fond to add properties for every hardware specific requirement, because properties are like APIs, we have to keep them, and maintain them, as soon as they are public almost forever.

Are you sure there isn't a way to query vaapi backend or an API to query the chipset and set all this hacks???
Comment 3 Fei 2018-08-20 03:14:33 UTC
@Victor, update my commit log. Currently all our existed platforms support P and low latency B frame. And I cann't provide correct information if the next platform will also support P frame. So I will not mention the hardware info in commit log. And both vaapi-driver and media-driver support this.

There is a new interface in libva to provide query:
https://github.com/intel/libva/pull/220, if the patch merged(need driver to support it), we can write another patch to query if the hardware support it before do the low latency B. But I think the property is needed, now all our existed platforms support both P and low latency B, there should be a property to let user choose the right path.
Comment 4 Fei 2018-08-20 03:15:13 UTC
Created attachment 373411 [details] [review]
enable hevc low latency B.
Comment 5 Víctor Manuel Jáquez Leal 2018-08-20 10:35:35 UTC
Hi Fei,

(In reply to Fei from comment #3)
> @Victor, update my commit log. Currently all our existed platforms support P
> and low latency B frame. And I cann't provide correct information if the
> next platform will also support P frame. So I will not mention the hardware
> info in commit log. And both vaapi-driver and media-driver support this.

OK. What about the unrelated code-style changes?

> There is a new interface in libva to provide query:
> https://github.com/intel/libva/pull/220, if the patch merged(need driver to
> support it), we can write another patch to query if the hardware support it
> before do the low latency B. But I think the property is needed, now all our
> existed platforms support both P and low latency B, there should be a
> property to let user choose the right path.

I would wait for the patch to get merged. Otherwise I don't want to follow that path that would overpopulate the properties for particular architectures. But if we do, I would prefix them, as intel-*, in this case intel-low-latency-b

In my opinion, we need a third opinion on this case.
Comment 6 Fei 2018-08-21 02:11:16 UTC
Created attachment 373414 [details] [review]
enable hevc low latency B.
Comment 7 Fei 2018-08-21 02:13:36 UTC
Hi Victor, I have remove unrelated code change. And change the option into intel-low-latency-b. 

@Sree, could you give your opinion on this? Thanks.
Comment 8 haihao.xiang 2018-08-22 04:09:20 UTC
No, I don't think it is good idea to add a prefix of intel-. low-delay b frame is not intel specific.
Comment 9 Víctor Manuel Jáquez Leal 2018-08-22 10:43:36 UTC
Review of attachment 373414 [details] [review]:

lgtm

though we would need to reach a consensus on the property prefix and if the property is required at all
Comment 10 Fei 2018-08-23 02:15:29 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #9)
> Review of attachment 373414 [details] [review] [review]:
> 
> lgtm
> 
> though we would need to reach a consensus on the property prefix and if the
> property is required at all

Hi Victor,
Just as Haihao's comment, low delay B frame is not intel specific, so I think it's better to remove prefix Intel. Otherwise, it will confused. How do you think of this ?
Comment 11 Víctor Manuel Jáquez Leal 2018-08-23 10:12:37 UTC
(In reply to Fei from comment #10)
> (In reply to Víctor Manuel Jáquez Leal from comment #9)
> > Review of attachment 373414 [details] [review] [review] [review]:
> > 
> > lgtm
> > 
> > though we would need to reach a consensus on the property prefix and if the
> > property is required at all
> 
> Hi Victor,
> Just as Haihao's comment, low delay B frame is not intel specific, so I
> think it's better to remove prefix Intel. Otherwise, it will confused. How
> do you think of this ?

I agree it is not Intel exclusive, but still it is very driver backend specific. What would happen if users of other backends enables it breaking their uses cases?

We would document very carefully and exactly what does this property means and why the use should enable it or not.
Comment 12 Víctor Manuel Jáquez Leal 2018-08-23 10:19:38 UTC
Another question is, if  https://github.com/intel/libva/pull/220 is merged, this property should be moved to the base encoder class, since it will apply to all the codecs?

Is there any use case where a user would want to enable this option even it their backend supports P frames?
Comment 13 Fei 2018-08-24 02:48:35 UTC
Created attachment 373450 [details] [review]
enable hevc low latency B.
Comment 14 Fei 2018-08-24 02:57:12 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #12)
> Another question is, if  https://github.com/intel/libva/pull/220 is merged,
> this property should be moved to the base encoder class, since it will apply
> to all the codecs?
> 
> Is there any use case where a user would want to enable this option even it
> their backend supports P frames?

It won't break other backend after the libva patch merged. And we need to query if hardware support low latency B in gst-vaapi, if not, then break out and print to user the reason.

We can consider to move this property to base class in next step. AFAIK, this feature only benefit on none-p frame supported platforms.
Comment 15 Fei 2018-08-27 01:07:42 UTC
@Victor, If no other comment, could you help to review and merge this patch? Thanks.
Comment 16 sreerenj 2018-08-28 05:57:34 UTC
@Fei: Could you please explain a bit about the logic behind the low-delay-b implementation?

What I can see is that the patch just changes the slice type from P to B if low-delay-b enabled. Is it supposed to maintain 2 ref pic lists (list_0 and list_1) in this case?
Comment 17 Fei 2018-08-28 06:46:28 UTC
(In reply to sreerenj from comment #16)
> @Fei: Could you please explain a bit about the logic behind the low-delay-b
> implementation?
> 
> What I can see is that the patch just changes the slice type from P to B if
> low-delay-b enabled. Is it supposed to maintain 2 ref pic lists (list_0 and
> list_1) in this case?

Yes, In this case the 2 ref pic lists is needed. I guess driver will do low delay b when it detect frame type is B and there are 2 ref pic lists. And I encoded a yuv into h265 stream with low-latency-b enabled, and checked the stream with intel-video-analyzer, all P frame changed into predictive B which is expected. Here is reference code(option p2b) from libva-utils: https://github.com/intel/libva-utils/pull/116/
Comment 18 sreerenj 2018-08-28 08:37:41 UTC
Review of attachment 373450 [details] [review]:

::: gst-libs/gst/vaapi/gstvaapiencoder_h265.c
@@ +1721,1 @@
       for (; i_ref < reflist_1_count; ++i_ref) {

Will reflist_1_count be always zero here for any P picture ?
(https://bugzilla.gnome.org/show_bug.cgi?id=796984#c17)
Comment 19 Víctor Manuel Jáquez Leal 2018-08-28 14:29:40 UTC
(In reply to sreerenj from comment #18)
> Review of attachment 373450 [details] [review] [review]:
> 
> ::: gst-libs/gst/vaapi/gstvaapiencoder_h265.c
> @@ +1721,1 @@
>        for (; i_ref < reflist_1_count; ++i_ref) {
> 
> Will reflist_1_count be always zero here for any P picture ?
> (https://bugzilla.gnome.org/show_bug.cgi?id=796984#c17)

Sree hit something important, what would be the behavior of this property when the property max-bframes is zero (the default value, by the way)
Comment 20 Víctor Manuel Jáquez Leal 2018-08-28 14:35:21 UTC
Review of attachment 373450 [details] [review]:

I would recommend you to explain, in the commit log, the purpose of this patch a bit longer. At least answer these questions:

Why is this change necessary?
How does this commit address the issue?
What effects does this change have?
Comment 21 Víctor Manuel Jáquez Leal 2018-08-28 14:38:40 UTC
Review of attachment 373450 [details] [review]:

::: gst-libs/gst/vaapi/gstvaapiencoder_h265.c
@@ +2768,3 @@
+      g_param_spec_boolean ("low-latency-b",
+          "Enable low latency b",
+          "Low latency B provide function to transform P frame into predictive B frame.This function can be used when platform doen't support P frame.",

There are a couple typos.

I would rephrase this line as 

"Transforms P frames into predictive B frames. Enable it when P frames are not supported"
Comment 22 Fei 2018-08-29 04:26:19 UTC
(In reply to Víctor Manuel Jáquez Leal from comment #19)
> (In reply to sreerenj from comment #18)
> > Review of attachment 373450 [details] [review] [review] [review]:
> > 
> > ::: gst-libs/gst/vaapi/gstvaapiencoder_h265.c
> > @@ +1721,1 @@
> >        for (; i_ref < reflist_1_count; ++i_ref) {
> > 
> > Will reflist_1_count be always zero here for any P picture ?
> > (https://bugzilla.gnome.org/show_bug.cgi?id=796984#c17)
> 
> Sree hit something important, what would be the behavior of this property
> when the property max-bframes is zero (the default value, by the way)

Yes, low latency B's ref_pic_list1 should keep same with ref_pic_list0 of P frame but not B frame. I will fix this in my  next patch.
Comment 23 Fei 2018-08-29 04:28:44 UTC
Created attachment 373490 [details] [review]
enable hevc low latency B.

@Victor, fixed your two comments, please help review this again.
Comment 24 haihao.xiang 2018-08-29 04:35:06 UTC
Could you use 'low-delay b frame' instead of 'low latency b frame' in the patch? I can find something about 'low-delay b frame' by Google, but none for 'low latency b frame'.
Comment 25 Fei 2018-08-29 04:44:33 UTC
Created attachment 373491 [details] [review]
enable hevc low delay B.

use low delay B instead of low latency B.
Comment 26 Fei 2018-08-29 04:44:50 UTC
(In reply to haihao.xiang from comment #24)
> Could you use 'low-delay b frame' instead of 'low latency b frame' in the
> patch? I can find something about 'low-delay b frame' by Google, but none
> for 'low latency b frame'.

Fixed.
Comment 27 Víctor Manuel Jáquez Leal 2018-08-29 12:53:14 UTC
Review of attachment 373491 [details] [review]:

lgtm
Comment 28 Víctor Manuel Jáquez Leal 2018-08-29 12:53:15 UTC
Review of attachment 373491 [details] [review]:

lgtm
Comment 29 Víctor Manuel Jáquez Leal 2018-08-29 13:02:37 UTC
attachment 373491 [details] [review] was pushed as commit 2fce126c - libs: encoder: h265: add low delay B frame support.