

va: Implement vah264enc (!1051) · Merge requests · GStreamer / gstreamer · GitLa...
source link: https://gitlab.freedesktop.org//gstreamer/gstreamer/-/merge_requests/1051
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Created 2 months ago by
va: Implement vah264enc
Deletes the source branch
- Resolved by He Junyan 2 months ago
He Junyan - @He_Junyan wrote here on 07, Sep 2021:
changed title from WIP: Implement the VA r h264 Encoder. to WIP: Implement the VA h264 Encoder.
Nicolas Dufresne - @ndufresne wrote here on 07, Sep 2021:
This is just one random comment, didn't took the time to review yet. This bit-writer seems to return a freshly allocated byte buffer, which defeats our attempt to avoid run-time allocation. Can we think of a way to write this into a pre-allocated and pooled block ? Of course that makes the API a tad more complex, in the case the block was too small, but I think it would be a nice feature.
He Junyan - @He_Junyan wrote here on 07, Sep 2021:
OK. I just want the base class to handle all misc thing, such as caps setting and multi-threading sync, and let the sub class implement
gboolean (*reconfigure) (GstVaBaseEnc * encoder);
gboolean (*push_frame) (GstVaBaseEnc * encoder,
GstVaEncFrame * frame,
gboolean last);
gboolean (*pop_frame) (GstVaBaseEnc * encoder,
GstVaEncFrame ** out_frame);
gboolean (*encode_frame) (GstVaBaseEnc * encoder,
GstVaEncFrame * frame);
to handle the real encoding.
It OK to mix them all as one for the first encoder, and split them when we write the second one.
Nicolas Dufresne - @ndufresne wrote here on 07, Sep 2021:
When I saw "baseclass", I thought of a proper libgstcodecs base class. I would rather consider that stateless encoder will use a base class from libgstcodecs and experiement with that.
Even though simpler, we still need to have something like a DPB, and we might need some tree structure for more advance coding patterns. Bit writers are helper seems fair though, but they could be in the per codec base classes to reduce the boiler plate code.
@sree also would like us to support software bitrate control, even for VA. His lib will likely never provide rate control for anything other then VP9 and AV1 though, so we'd probably also need some in-gstreamer "fallback" implementation, so it minimally works. Of course, most VA driver have their own, as VA API allow that.
He Junyan - @He_Junyan wrote here on 08, Sep 2021:
I think the problem in current stage is that we do not know what is the common logic for all encoders. Different encoders have different preference and limitation. And I agree with @vjaquez , firstly, write a lean and logic clean encoder, and move the common logic to some base iterative if we find.
About the rate control, I think we can provide a lib to analyse the relationship between the buffer fullness and the incoming frames, decide its init QP and other parameters. We can even write some lookahead element to do the better analysis, and link it before the encoder.
These are big pictures and it needs a lot of effort:). I firstly need to implement a VA encoder in good code logic and with median compression quality(Just depending on HW rate control).
Nicolas Dufresne - @ndufresne wrote here on 08, Sep 2021:
Well, remember that we found impossible to extract the logic from the VA code in GStreamer VA-API.
He Junyan - @He_Junyan wrote here on 09, Sep 2021:
added 1 commit
- 24b59434 - Add the encoder and va base encoder for h264
He Junyan - @He_Junyan wrote here on 14, Sep 2021:
added 30 commits
- 24b59434...364a2fe0 - 28 commits from branch
gstreamer:master
- 461cfe6c - Add a generic bit code writer for H264.
- 785b8226 - Add the encoder and va base encoder for h264
Víctor Manuel Jáquez Leal - @vjaquez wrote here on 16, Sep 2021:
btw, my original idea is to have low power entrypoint as different elements. So in the end will have vah264enc
and vah264lpenc
and the different devices, vaD129h264lpenc
In that way, iiuc, the logic will be simpler and the user will be in control of what they want.
Still the source will be the same for all of them, just a bool in the class structure.
U. Artie Eoff - @ullysses.a.eoff wrote here on 16, Sep 2021:
It would be nice if we could synergize the property names between the various hw plugin elements (e.g. va, vaapi, and msdk plugins).
Currently:
-
b-frames
is used here and msdkh264enc butmax-bframes
is used in vaapih264enc. -
keyframe-period
is used here and vaapih264enc butgop-size
is used in msdkh264enc. -
ref-frames
is used here and msdkh264enc butrefs
is used in vaapih264enc.
... there are other properties that have different names but the same function, too.
If we used the same property names across plugins, then it would make it a whole lot easier for users to remember. And way easier to write boilerplate scripts for testing the various plugins. At minimum, can we synergize property names between va and msdk?
He Junyan - @He_Junyan wrote here on 18, Sep 2021:
mentioned in merge request !886 (merged)
He Junyan - @He_Junyan wrote here on 04, Oct 2021:
added 57 commits
- 785b8226...ca8068c6 - 49 commits from branch
gstreamer:master
- 9144f3f1 - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- aaaa458c - codecparsers: bitwriter: Add the common bit writer functions for H264.
- d56a817a - test: Add test cases for the H264 bitwriter.
- c4f165fa - va: Make the gst_va_create_coded_caps as a common helper function.
- 2ac07697 - va: encoder: Add a common encoder object.
- 9e1cbf06 - va: encoder: Import the H264 encoder.
- 26807ae8 - va: enable the H264 encoder.
- a0bfff0f - va: Change the H264 profile string order in the profile_map.
He Junyan - @He_Junyan wrote here on 04, Oct 2021:
marked this merge request as ready
He Junyan - @He_Junyan wrote here on 04, Oct 2021:
@vjaquez I am a little sorry, I make that H264 encoder not so simple and added most of the properties in vaapi. Because I need to measure the performance of it and compare the BD-rate with other encoders:)
He Junyan - @He_Junyan wrote here on 04, Oct 2021:
I will try to do it, thanks for your notify.
He Junyan - @He_Junyan wrote here on 04, Oct 2021:
mentioned in merge request !1047 (closed)
[91/1018] Compiling C object subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/libgstcodecparsers-1.0.so.0.1902.0.p/gsth264bitwriter.c.o
../subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264bitwriter.c:570:3: warning: result of comparison of constant -12 with expression of type 'const guint8' (aka 'const unsigned char') is always false
[-Wtautological-constant-out-of-range-compare]
WRITE_SE_RANGE (bw, pps->second_chroma_qp_index_offset, -12, 12);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
../subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264bitwriter.c:84:24: note: expanded from macro 'WRITE_SE_RANGE'
if (val > max || val < min || \
~~~ ^ ~~~
1 warning generated.
../subprojects/gst-plugins-bad/sys/va/gstvah264enc.c:1557:30: warning: field 'type' with variable sized type 'VAEncMiscParameterBuffer' (aka 'struct _VAEncMiscParameterBuffer') not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
VAEncMiscParameterBuffer type;
^
../subprojects/gst-plugins-bad/sys/va/gstvah264enc.c:1595:30: warning: field 'type' with variable sized type 'VAEncMiscParameterBuffer' (aka 'struct _VAEncMiscParameterBuffer') not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
VAEncMiscParameterBuffer type;
^
../subprojects/gst-plugins-bad/sys/va/gstvah264enc.c:1627:30: warning: field 'type' with variable sized type 'VAEncMiscParameterBuffer' (aka 'struct _VAEncMiscParameterBuffer') not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
VAEncMiscParameterBuffer type;
^
../subprojects/gst-plugins-bad/sys/va/gstvah264enc.c:1653:30: warning: field 'type' with variable sized type 'VAEncMiscParameterBuffer' (aka 'struct _VAEncMiscParameterBuffer') not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
VAEncMiscParameterBuffer type;
^
../subprojects/gst-plugins-bad/sys/va/gstvah264enc.c:1683:30: warning: field 'type' with variable sized type 'VAEncMiscParameterBuffer' (aka 'struct _VAEncMiscParameterBuffer') not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
VAEncMiscParameterBuffer type;
-
163e1ed9...d189b0d0 - 31 commits from branch
gstreamer:main
- d91f8336 - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- b20626c1 - codecparsers: bitwriter: Add the common bit writer functions for H264.
- f9d839fd - test: Add test cases for the H264 bitwriter.
- e33589ab - va: Make the gst_va_create_coded_caps as a common helper function.
- b25ef5b9 - va: encoder: Add a common encoder object.
- a22b1d1e - va: encoder: Import the H264 encoder.
- dcfc2df0 - va: enable the H264 encoder.
- 64f10722 - va: Change the H264 profile string order in the profile_map.
Great job @He_Junyan !
I just pushed a branch in my repo with a couple style change proposals: https://gitlab.freedesktop.org/vjaquez/gstreamer/-/commits/mr-1051
The missing bit I see is downstream negotiation.
fwiw, I just started reading Direct3D12 video encoding APIs (part of Windows 11 SDK) and got an impression that overall flow is very similar to that of VA encoding
I would like to merge this in the next development cycle (for 1.21)
-
64f10722...7cb2dff8 - 210 commits from branch
gstreamer:main
- 790af46d - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- 63cbb27e - codecparsers: bitwriter: Add the common bit writer functions for H264.
- 84717a01 - test: Add test cases for the H264 bitwriter.
- e92a509b - va: Make the gst_va_create_coded_caps as a common helper function.
- 59790cd4 - va: encoder: Add a common encoder object.
- b095e895 - va: encoder: Import the H264 encoder.
- 17cd1c22 - va: enable the H264 encoder.
- d8170586 - va: Change the H264 profile string order in the profile_map.
-
d8170586...8c35850f - 35 commits from branch
gstreamer:main
- 92300a3e - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- c9227f89 - codecparsers: bitwriter: Add the common bit writer functions for H264.
- 3719487a - test: Add test cases for the H264 bitwriter.
- 426e9443 - va: Make the gst_va_create_coded_caps as a common helper function.
- 558d313e - va: Change the H264 profile string order in the profile_map.
- a8894ad9 - va: Add the profile string name into the profile_map.
- 5c7117da - va: encoder: Add a common encoder object.
- b696eb2c - va: encoder: Import the H264 encoder.
- b2903780 - va: enable the H264 encoder.
-
cc97041b...cfbd8201 - 12 commits from branch
gstreamer:main
- 37ed170e - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- 9246b54e - codecparsers: bitwriter: Add the common bit writer functions for H264.
- afa45042 - test: Add test cases for the H264 bitwriter.
- 23898e8b - va: caps: Make the gst_va_create_coded_caps as a common helper function.
- 22ebb097 - va: Change the H264 profile string order in the profile_map.
- 12c97b79 - va: Add the profile string name into the profile_map.
- f0c3940b - va: encoder: Add a common encoder object.
- 9f79a49b - va: encoder: Import the H264 encoder.
- 67e85251 - va: enable the H264 encoder.
-
67e85251...1e6d26ac - 27 commits from branch
gstreamer:main
- a19339e5 - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- 1bedc18d - codecparsers: bitwriter: Add the common bit writer functions for H264.
- b97f6e10 - test: Add test cases for the H264 bitwriter.
- 2c6a3269 - va: caps: Make the gst_va_create_coded_caps as a common helper function.
- 50099714 - va: Change the H264 profile string order in the profile_map.
- ee73a780 - va: Add the profile string name into the profile_map.
- a989101a - va: encoder: Add a common encoder object.
- 7104a257 - va: encoder: Import the H264 encoder.
- 94c2869e - va: enable the H264 encoder.
-
94c2869e...d6923936 - 52 commits from branch
gstreamer:main
- 72b2d7e9 - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- a01a6e07 - codecparsers: bitwriter: Add the common bit writer functions for H264.
- 2a22e6ba - test: Add test cases for the H264 bitwriter.
- b094285d - va: caps: Make the gst_va_create_coded_caps as a common helper function.
- f41302a1 - va: Change the H264 profile string order in the profile_map.
- 9a4911ac - va: Add the profile string name into the profile_map.
- 9b6a1f24 - va: encoder: Add a common encoder object.
- 73f0cc67 - va: encoder: Import the H264 encoder.
- 30e51bd3 - va: enable the H264 encoder.
-
30e51bd3...214691b9 - 30 commits from branch
gstreamer:main
- e496df70 - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- 3d3b36a2 - codecparsers: bitwriter: Add the common bit writer functions for H264.
- 2511da02 - test: Add test cases for the H264 bitwriter.
- 78e7db90 - va: caps: Make the gst_va_create_coded_caps as a common helper function.
- 06e4f468 - va: Change the H264 profile string order in the profile_map.
- ec262eab - va: Add the profile string name into the profile_map.
- 6585b38c - va: encoder: Add a common encoder object.
- 4b35f7fa - va: encoder: Import the H264 encoder.
- a406910f - va: enable the H264 encoder.
-
a406910f...972615cf - 28 commits from branch
gstreamer:main
- 735c0d25 - codecparsers: nalutils: Add nal_writer_reset_and_get_data help function.
- 15d01dc1 - codecparsers: bitwriter: Add the common bit writer functions for H264.
- 7446cc23 - test: Add test cases for the H264 bitwriter.
- fc1f6b0e - va: caps: Make the gst_va_create_coded_caps as a common helper function.
- 5d3fe98f - va: Change the H264 profile string order in the profile_map.
- e0ff8268 - va: Add the profile string name into the profile_map.
- 65d9c6b9 - va: encoder: Add a common encoder object.
- 1b730b32 - va: encoder: Import the H264 encoder.
- c1dd475a - va: enable the H264 encoder.
Source branch: gst-plugins-bad-encoder_h264
Recommend
-
137
March 1, 2021: Service on gitpitch.com has been shutdown permanently. GitPitch 4.0 About GitPitch 4.0 is the perfect slide deck solution for tech conferences, training, develop...
-
14
KDE switched over to a self-hostedGitLabinstance this year: invent.kde.org . Many thanks again to our system administrators and all other contribut...
-
12
Armin's BlogHDU 1051 Wooden Sticks(贪心)November 30, 2015题目链接 题意:第一行 T 组数据,每组数据的第一行 n 代表有 n 个棍...
-
13
Merged turnip: LRZ support Add support for low-resolution Z buffer feature on turnip. This is based on the free...
-
15
Auto Merge Dependabot Pull Requests April 28, 2021 • 5 min read A good year ago it
-
6
Fix an off-by-one in loadscpt here is the trace I'm trying to fix: jvoisin@grimhilde 18:52 ~/dev/openmw/openmw/build_fuzz_asan_master ./esmtool dump -C -p -q out/default/crashes/id\:000...
-
10
Fix a crash in aipackage.cpp Should fix #5966 (closed) R...
-
5
Merged Created 1 month ago by Various fixes for niftest Fixes
-
5
WIP: vulkan: Add vulkanh264dec Warning: Vulkan video is still work in progress, from specification to available drivers and applications. Do not use it for production software jus...
-
6
vapostproc: Process HDR caps fields This patch adds a new parameter: hdr-tone-mapping (same as vaapipostproc). If HDR filter available in driver the parameter is expose, but it's disabled by default.
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK